YUV420 to BGR32 converter?

YUV420 to BGR32 converter?

I'm investigating the IPP library as a means of decoding and displaying MPEG2, and eventually MPEG4/H.264/etc on Linux. To start with, I'm just looking at the color conversion from YCbCr420 to RGB so that the image can be displayed.

To test it out, I've got an NTSC signal coming into a capture card controlled by Video4Linux2. I've got the card set to spit out YUV420 frames from an NTSC signal, which I am converting as they come out. I figure this will give me a pretty decent approximation of the operating conditions that I'll see with the decoder.

The problem is that at 24-bit color depth, X appears to take images in a BGR32, or BGRA, format (although the alpha is ignored). I was hoping that the IPP library would enable me to do the conversion directly, but as far as I can tell the only function that can convert YCbCr420 into BGR32 is ippiYCrCb420ToBGR_Filter_8u_P3C4R. I really don't know what kind of filtering is happening here (the function doesn't seem to be documented) but whatever it is, it's slow. Other similar color conversion functions (ippiYUV420ToRGB_8u_P3AC4R, ippiYUV420ToBGR_8u_P3C3R, ippiYCbCr420ToBGR_8u_P3C3R) only seem to take around 8-9% CPU. ippiYCrCb420ToBGR_Filter_8u_P3C4R takes around 30%.

It seems like I either have to "filter" the data needlessly, or inefficently convert the image using more than one conversion function. There are so many ways to do something close to what I need using IPP, it makes me think that there really should be a way to do exactly what I'm looking for. The conversion function I wrote myself takes around 20% CPU, so right now I'm not seeing a lot of benefit to the IPP library in this respect.

Is there any way to convert YCrCb420 directly into BGRA? If not, is there any way around this problem?



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

Hello Andre,

if ippiYUV420ToRGB_8u_P3AC4R does'n work for you (what is a bit strange, usually, on Linux color data considered as RGB order, not BGR like on Windows) you need to apply ippiSwapChannels functions to place the data into desired channel's order. See IPP manual for more details on color image representation in IPP and related functions.


Leave a Comment

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