libvpx codec operations use vpx_image_t structure for exchanging uncompressed frame data.
I got through understanding what majority of the members mean, but I'm stuck with x_chroma_shift
and y_chroma_shift
. The only explanation provided in the documentation is that it's "sub-sampling order". I am a newbie in YUV image formats, but I believe I understand what chroma sub-sampling is, but I can't quite figure out what does order of it mean.
1 Answer
Consider (w, h) YUV image (w and h are even numbers). Y plane size is also (w, h) but U/V plane size is (w << x_chroma_shift, h << y_chroma_shift) which is equivalent to (w / (1 << x_chroma_shift), h / (1 << y_chroma_shift)). Different chroma shift combinations define different YUV sub-samplings:
YUV | x_chroma_shift | y_chroma_shift
======+================+===============
4:2:0 | 1 | 1
4:2:2 | 1 | 0
4:4:4 | 0 | 0
-
Interesting way to represent sub-sampling, thank you. But that would also make these members redundant, at least for input, along with
bps
, since them all determined by image type. Dec 2, 2013 at 9:02 -
1This is just a quick way to determine U/V plane width and height. In general, of course, you can use image type (vpx_img_fmt_t) for that. Note that bps is only for "packed" formats, not for "planar". Dec 3, 2013 at 20:04