PDA

View Full Version : Order of RGB or YUV Frame values in memory


Inc
16th August 2005, 13:31
Question a):

Lets assume I do load rgb data into memory using dgdecode.dll's getRGBFrame() at a memorypointer *rgb24.

Now how is the order of the RGB data in memory:

(RGB24 Like ...

RGBRGBRGBRGBRGBRGBRGBRGBRGBRGBRGBRGBRGBRGB ...... etc.

I do know getRGBFrame results in rgb24 data, but just to know how generally rgb32 data is stored )


RGB32 like ...

RGBARGBARGBARGBARGBARGBARGBARGBARGBA ..... etc.


And for YUV via dgdecode.dll's getFrame()

YUVYUVYUVYUVYUVYUVYUVYUVYUVYUVYUVYUV .... etc.

is that right? I think not due 4:2:0 12 Bit allocation?


Question b)

If I do use the VFW API AviFileGetFrame() is there generally a RGB result, no matter if even the Frame in the avi is YUV ?

Would the allocation of Pixeldata using AviFileGetFrame() also be stored as YUV Values in Memory like ...

B = BITMAPINFOHEADER data and its size

BYUVBYUVBYUVBYUVBYUVBYUV .... etc.

?

Thanks for your help


Purpose of all this is that I want to build an autocrop part in a video applikation using the way of directly peeking the memory instead of GetPixe() via API out of a generated Bitmap using SetDIBits() ... I think the peek() approach would be much faster.

Also if I can handle it, I would like to build a histogram window using the peek function on the image data at a given Memorypointer.

Wilbert
16th August 2005, 18:25
Regarding question a:


(RGB24 Like ...

RGBRGBRGBRGBRGBRGBRGBRGBRGBRGBRGBRGBRGBRGB ...... etc.

It is

BGR BGR ...


RGB32 like ...

RGBARGBARGBARGBARGBARGBARGBARGBARGBA ..... etc.

Likewise

BGRA BGRA ...


And for YUV via dgdecode.dll's getFrame()

YUVYUVYUVYUVYUVYUVYUVYUVYUVYUVYUVYUV .... etc.

is that right? I think not due 4:2:0 12 Bit allocation?

For YV12 planar: first Y plane, then V plane, then U plane. I guess you know YUY2 (YUYV YUYV ...).

Inc
17th August 2005, 13:47
Ah, yep RGB is ordered as BGR, now I remember, thanks. :)

But about YV12 and YUY2 ...

Did I understood right that YV12 is ordered as YVUYVUYVUYVUYVUYVU .... ?
But how about peeking these Y V U values in the memory?

I do peek the B,G,R each as Byte including 8bits, but I dont think Y,V,U will be byte,byte,byte ?


Also how are the rows of the image allocated?
Means in case of a 10px width and 4px height image ...

is it a zigzag order? :

00 01 02 03 04 05 06 07 08 09
10 11 12 13 14 15 16 17 18 19
20 21 22 23 24 25 26 27 28 29
30 31 32 33 34 35 36 37 38 39

(above assuming one Number would contain RGB just for demonstration)

Nic
17th August 2005, 20:17
No, YV12 is planar....i.e. YYYYYYYYUUVV So all the Ys then the Us then the Vs.

-Nic