0

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.

Pawel Veselov
  • 3,996
  • 7
  • 44
  • 62

1 Answers1

1

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
dmitriykovalev
  • 534
  • 3
  • 6
  • 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. – Pawel Veselov Dec 02 '13 at 09:02
  • 1
    This 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". – dmitriykovalev Dec 03 '13 at 20:04