YUV Conversion Issue

YUV Conversion Issue

Hi,

I have a bitmap(no header)buffer of size 176x144 and want to conver to YUV format before calling H.264 encoding routine.

I did it in the following way

int FrameSize = VideoWidth*VideoHeight*3/2;

IppStatus retValue;

Ipp8u * yuvData[3];

IppiSize srcSize={VideoWidth, VideoHeight};

int srcStep = VideoWidth*3;

//yuvData[0]=cYUVData + VideoWidth*VideoHeight*3/2;

yuvData[0]=cYUVData;

yuvData[1]=yuvData[0] +VideoWidth*VideoHeight;

yuvData[2]=yuvData[1] +VideoWidth*VideoHeight/4;

int pDstStepYVU[3] = {VideoWidth, VideoWidth/2, VideoWidth/2};

retValue = ippiRGBToYCbCr420_8u_C3P3R(cRGB24Data, srcStep, yuvData, pDstStepYVU, srcSize);

and retValue is success.
How can I get the size of the cYUVData aftertheabove function call so that I can validate the YUV data by writing to a file.

Pls help.

7 posts / 0 new
Last post
For more complete information about compiler optimizations, see our Optimization Notice.

I think you need to know size of resulting YUC data before the call to IPP function in order to allocate memory buffer of sufficient size to put converted image.

And size is defined by width and height of your RGB image, meaning for 420 sampling you will have Y plane with the same width and height, and U and V planes with width/2 and height/2.

Vladimir

Hi Vladimir,

Thanks for you response.

Are my above RGB to YUV conversion code is correct if the bitmap(RGB24) buffer size is 176x144?

Hi,

It looks fine for me. The BMP data in the memory is possilly in BGR order. If this is your case, it need to call ippiBGRToYCrCb420_8u_C3P3R(..) function.

Thanks,
Chao

Hi

I have a raw RGB24 bitmap buffer of size 640x480(921600 bytes) from a web cam callback function that i want to convert to YUV format of size 176x144. I tried it as follows.

int VideoWidth=176,VideoHeight=144,FrameNumber=1;

int nMaxYUVSize = (VideoWidth*VideoHeight + (VideoWidth*VideoHeight)/2);

Ipp8u *cYUVData = ippsMalloc_8u(nMaxYUVSize);

Ipp8u *cRGB24Data = ippsMalloc_8u(921600); and cRGB24Data is filled with raw bitmap from webcam callback function

IppStatus retValue;

Ipp8u * yuvData[3];

IppiSize srcSize={VideoWidth, VideoHeight};

int srcStep = VideoWidth*3;

yuvData[0]=cYUVData;

yuvData[1]=yuvData[0] +VideoWidth*VideoHeight;

yuvData[2]=yuvData[1] +VideoWidth*VideoHeight/4;

int pDstStepYVU[3] = {VideoWidth, VideoWidth/2, VideoWidth/2};

retValue = ippiRGBToYCbCr420_8u_C3P3R(cRGB24Data, srcStep,yuvData, pDstStepYVU, srcSize);

eventhough retValue == ippStsNoErr, the yuvData appears to be wrong.

What is wrong with the above method?

Somebody please help

Best Reply

Hello,

It looks the input and output image size is different.

In color conversion functions, the input and out function have the same size. It has no functionality to resize the image.

You need to call IPP resize function (ippiResizeSqrPixel_) first to change the image size to 176x144, then call color conversion function.

Thanks,
Chao

Hi

Thanks for the help. WhenI resize the image the issue solved.

Leave a Comment

Please sign in to add a comment. Not a member? Join today