rgb order

97 views
Skip to first unread message

Pawel Veselov

unread,
Mar 31, 2014, 2:54:15 AM3/31/14
to discuss...@googlegroups.com
Hi.

Sorry if this sounds stupid, I don't do image/video a lot.

What should I expect the order of a/r/g/b components after *ToARGB() conversion?

I'm converting YUYV(YUY2) to ARGB. YUY2 comes from a webcam (v4l2 drivers), 
and is advertised as YUYV.

When I draw the ARGB using GDK, which expects red, green, blue, padding bytes
(using gdk_draw_rgb_32_image() and I don't care about alpha), red and blue components
are clearly switched around. Same if I do ARGBToRGB24, and use gdk_draw_rgb_image,
which expects red, green and blue bytes. 

Is there a good resource on understanding the order of components for these various 
*RGB formats, and whether they are supposed to be treated as byte arrays, or wider
types, which would make host byte order matter.

Thank you.

Frank Barchard

unread,
Mar 31, 2014, 5:33:41 PM3/31/14
to discuss-libyuv
Hi Pawel,
Its not a stupid question at all... channel ordering is a common area of confusion.

For 32 bit ARGB formats, the ordering refers to the order in a register.  On a little endian machine the order in memory will be the opposite.
This documentation is supposed to cover that, but if its unclear or incomplete, let me know.

The fourcc convention comes mainly from fourcc.org which is Windows centric.  The video_common.h has a few links/info as well.

For your particular questions
RGBx in memory would be FOURCC_ABGR

For 24 bit R,G,B in memory it would be FOURCC_RAW
And the function names follow the same naming conventions.

There is no direct conversion from YUY2ToABGR or RAW - it would take 2 steps.
YUY2ToI420 and I420ToABGR.  Or YUY2ToARGB and ARGBToABGR.
The later would be easier to code - you could do the 2nd step in place and RGB formats only need one buffer/pointer.  But 32 bit is more memory so likely a bit slower.

If you think a direct conversion would be important, open an 'issue'




--
You received this message because you are subscribed to the Google Groups "discuss-libyuv" group.
To unsubscribe from this group and stop receiving emails from it, send an email to discuss-libyu...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Pawel Veselov

unread,
Apr 1, 2014, 1:28:15 AM4/1/14
to discuss...@googlegroups.com
Hi Frank,

the Wiki page really helps with ARGB fourccs, thank you.

I am doing the conversion in two steps: YUY2ToARGB then ARGBToRGB24 (RGB24 is same as raw, right?).

raw should be, byte-to-byte, R,G,B (if I understood you correctly about FOURCC_RAW), so I shouldn't see R/B channels swapped...

Frank Barchard

unread,
Apr 1, 2014, 3:28:55 AM4/1/14
to discuss-libyuv
FOURCC_RAW is R,G,B in memory.
FOURCC_RGB24 is B,G,R in memory.



Reply all
Reply to author
Forward
0 new messages