I have been working on a project where I use YUV as an input and have to pass this information to the Kernel in order to process the function. I had looked into similar questions but never found an accurate answer to my concern. I have tried a simple method to convert the YUV into an Image format for Opencl Processing. However, when I try to print the data which has been converted into the image I get first value correct then another three as zeroes and then I get the 5th pixel value correct. I dont understand whether writing is the problem or the reading part. I am confused as to how to proceed on this. If anyone could help me I would be really grateful or if you can give me example on how to convert YUV into an 2D image. Is it necessary for me to convert YUV into RGB in order to process it on the device. I can also post the sample code if anyone needs it. Thank you for any help in advance.
/*Kernel Code*/
int2 position;
uint4 Input;
for(int i = 0; i < Frame_Height; i++){
for(int j = 0; j < Frame_Width; j+=4){
position = (int2)(j,i);
Input.s0 = (uint)YUV_Data[j];
Input.s1 = (uint)YUV_Data[j+1];
Input.s2 = (uint)YUV_Data[j+2];
Input.s3 = (uint)YUV_Data[j+3];
write_imageui( 2D_Image, position, Input );
}
YUV_Data += Frame_Width;
}
YUV_Data is an unsigned char. Here YUV_Data is the buffer which contains input YUV Image, but I am just processing only Y element in the code.