Intel® Integrated Performance Primitives
Community support and discussions relating to developing high-performance vision, signal, security, and storage applications.

YUV Conversion Issue

ipp_test
Beginner
161 Views
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.

0 Kudos
1 Solution
Chao_Y_Intel
Employee
161 Views

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

View solution in original post

6 Replies
Vladimir_Dudnik
Employee
161 Views
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
ipp_test
Beginner
161 Views
Hi Vladimir,

Thanks for you response.

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

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

ipp_test
Beginner
161 Views
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

Chao_Y_Intel
Employee
162 Views

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

ipp_test
Beginner
161 Views
Hi

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