Community
cancel
Showing results for 
Search instead for 
Did you mean: 
Highlighted
Beginner
16 Views

YUV420 array to BGR24

I'm getting a pointer to a raw video feed from a capture card in YUV420 format. Is there a way to convert this to BGR24 without trying to figure out how convert the data to a planar format?

Matt
0 Kudos
7 Replies
Highlighted
Employee
16 Views

Quoting - vikingsooner
I'm getting a pointer to a raw video feed from a capture card in YUV420 format. Is there a way to convert this to BGR24 without trying to figure out how convert the data to a planar format?

Matt

Hi Matt,

Seems there is no way out of this. The existing YUV420 -> BGR24 IPP funtionsalways ask input as 3 planar.
const Ipp8u* const pSrc[3], int srcStep[3], thus you have tofeed the parameter.

But in general, it is easy to provide the parameter, for example,
const Ipp8u *(pSrc[3]) = {(Ipp8u*)in->GetPlanePointer(0),
(Ipp8u*)in->GetPlanePointer(1),
(Ipp8u*)in->GetPlanePointer(2)};
Ipp32s pSrcStep[3] = {in->GetPlanePitch(0),
in->GetPlanePitch(1),
in->GetPlanePitch(2)};

is thereany problem for you to get the planer pointer from the output of capature card? The pSrc[3] could be {Pcap, Pcap+Ystep*height, Pcap+5*Ystep*height/4} in your case?

Best Regards,
Ying
0 Kudos
Highlighted
Beginner
16 Views


Hi Ying,

May i ask if i wanted to use ippiYUV420ToBGR_8u_P3C3R, and i only have a ipp8u pointer to access to my YUV420 data, that means i have to separate the planar first right? and is itby using ippiCopy_8u_C3P3R ?

if so, may i know how can i get the srcStep and the dstStep or both the function? My program need me to convert YUV420 back to RGB24. Sorry for troubling you with this sort of question as i'm pretty confuse with the stride and step of an image. Thanks in advance.


Best Regards,
YanQin


0 Kudos
Highlighted
Employee
16 Views

Quoting - yanqin

Hi Ying,

May i ask if i wanted to use ippiYUV420ToBGR_8u_P3C3R, and i only have a ipp8u pointer to access to my YUV420 data, that means i have to separate the planar first right? and is itby using ippiCopy_8u_C3P3R ?

if so, may i know how can i get the srcStep and the dstStep or both the function? My program need me to convert YUV420 back to RGB24. Sorry for troubling you with this sort of question as i'm pretty confuse with the stride and step of an image. Thanks in advance.


Best Regards,
YanQin



Hi YanQin,

In princple, you don't need to use ippiCopy_8u_C3P3R again. Just define a pointer array
pSrc[3]
and let them be {Pcap, Pcap+Ystep*height, Pcap+5*Ystep*height/4}

About the step, itis the image row in byte. If no special case,it isarray width.
But you are using UMC codeand YUV stored in 3seperate array. Umc provides several functions like GetPlanePointer, GetPlanePitch, you can usethem directly.SeetheUMC functionsusage in UMC_manual.pdf

Best Regards,
Ying
0 Kudos
Highlighted
Employee
16 Views

HelloMatt,


YanQin and me happenedto have similiar discussion at
http://software.intel.com/en-us/forums/showthread.php?t=68163.

One question for you, after you get raw video from the capture card, do you have further operation, like encode the YUV to H.264 file?


The article http://software.intel.com/en-us/articles/getting-started-with-intel-ipp-unified-media-classes-sample...give some sample to show how to use UMC to implement H.264encoder. It is asking asingle consecutive YUVData as input. If you are using this, you don't need do the conversion option.

Additionally, the UMC Color_space_converter project support most of color conversion (include YUV420 to BGR24) You may refer to them.

Best Regards,
Ying
0 Kudos
Highlighted
Beginner
16 Views

Quoting - Ying H (Intel)

Hi YanQin,

In princple, you don't need to use ippiCopy_8u_C3P3R again. Just define a pointer array
pSrc[3]
and let them be {Pcap, Pcap+Ystep*height, Pcap+5*Ystep*height/4}

About the step, itis the image row in byte. If no special case,it isarray width.
But you are using UMC codeand YUV stored in 3seperate array. Umc provides several functions like GetPlanePointer, GetPlanePitch, you can usethem directly.SeetheUMC functionsusage in UMC_manual.pdf

Best Regards,
Ying

Hi,

I understand that Pcap should be my pointer for my source. But i still don't know how to get Ystep. Any function that i can use to get Ystep? I'm sure i read it somewhere before but i cant seem to find them now.

Best Regards,
YanQin
0 Kudos
Highlighted
Employee
16 Views

Quoting - yanqin

Hi,

I understand that Pcap should be my pointer for my source. But i still don't know how to get Ystep. Any function that i can use to get Ystep? I'm sure i read it somewhere before but i cant seem to find them now.

Best Regards,
YanQin

Hi YanQin,

1) If the pCapis from Capture Card and it is in I420 format (no alignment, no pitch),
then Y, U, V plane is
LPBYTE pSrcY = pCap;
LPBYTE pSrcU = pCap + (imgWidth * imgHeight);
LPBYTE pSrcV = pSrcU + ((imgWidth * imgHeight) / 4);

and The Step is

int pSrcStepYVU[3] = {imgWidth, imgWidth/2, imgWidth/2};

The YStep=imWidth.

2) if your pCap is from some UMC video process(may add alignment for high performance),then you can get them from the function,

GetPlanePitchconst Ipp8u *(pDst[3]) = {(Ipp8u*)out->GetPlanePointer(0),
(Ipp8u*)out->GetPlanePointer(1),
(Ipp8u*)out->GetPlanePointer(2)};
Ipp32s pDstStep[3] = {out->GetPlanePitch(0),
out->GetPlanePitch(1),
out->GetPlanePitch(2)};

Here Ystep is GetPlanePitch(0).

Regards,
Ying
0 Kudos
Highlighted
Beginner
16 Views

I get it now and it works like magic! Thanks for all your help =]


Best Regards,
YanQin
0 Kudos