- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi all,
I have a decoded frame, which is in YUV420 format. I need to convert this file to BGRA or RGBA format. I have found ippiYCbCr420ToBGR_8u_P3C4R API and gave it a try but failed. Could you please help me to find the mistake?
int YUV420_TO_RGB32_IPP( unsigned char *apImage, unsigned char *pY, unsigned char *pU, unsigned char *pV, unsigned int nWidth, unsigned int nHeight) {
const Ipp8u *pYUV[3];
int srcStep[3];
IppiSize roiSize;
pYUV[0] = pY;
pYUV[1] = pU;
pYUV[2] = pV;
srcStep[0] = nWidth;
srcStep[1] = nWidth/2;
srcStep[2] = nWidth/2;
roiSize.width = nWidth;
roiSize.height = nHeight;
Ipp8u aval=255;
ippiYCbCr420ToBGR_8u_P3C4R(pYUV, srcStep, apImage, nWidth*4, roiSize, aval);
return 0;
}
Here is the image that I am supposed to get: https://www.dropbox.com/s/5bgrm4j1cy3v6wq/1.png
Here is the image what I am getting: https://www.dropbox.com/s/86crcvyijz7vd2y/2.png
Thanks.
Link Copied
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi,
Please make sure, that you correctly use "step" variables. They are not image "width", but in most cases "width * channels", i.e. distance between the beginnings of image lines measured in bytes.
Regards,
Sergey
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi Sergey,
I have tried many different values for step but couldn't get it working. Since the source image is in YUV format, it contains 3 planars, Y, U and V. The resolution of the Y image is let say 1000x500, which is the same resolution of the destionation. In this case the resolution of the U and V should be 500x250. I couldn't get the idea behind "width * channels". Why should I multiply the width by channels while they are in planar format?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Yes. you're right. I have just looked at result image. This picture usually is seen when step (source or destination) is chosen wrong. How do you allocate space for "apImage"? With plain malloc? That is, step for destination image is really nWidth * 4 ?
Regards,
Sergey
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Actually, the apImage is like the following,
QImage myimage(1000,500, RGB32);
apImage = myimage.bits();
I was using another format converter and that I got a perfect image from that converter. So it means that the allocation part is already eliminated.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
In Qt::QImage there's QImage::bytesPerLine() method. So, in
ippiYCbCr420ToBGR_8u_P3C4R(pYUV, srcStep, apImage, nWidth*4, roiSize, aval);
in the place of "NWidth*4" argument "bytesPerLine()" should be used. It is not always eq to width*4.
Regards,
Sergey
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page