[FFmpeg-devel] [PATCH] lavu/pixfmt: summarize yuv naming conventions
Nicolas George
george at nsup.org
Wed Jul 27 18:24:47 EEST 2022
Signed-off-by: Nicolas George <george at nsup.org>
---
libavutil/pixfmt.h | 17 +++++++++++++++++
1 file changed, 17 insertions(+)
Note: we have log2_chroma_h = 2 for yuv410p, meaning each chroma pixel
is 4×4 luma pixels, but everywhere I look on the web, ilcuding:
https://en.wikipedia.org/wiki/Chroma_subsampling
I find that it is supposed to be 4×2, and we should set log2_chroma_h = 1.
Who is right?
Regards,
--
Nicolas George
diff --git a/libavutil/pixfmt.h b/libavutil/pixfmt.h
index 2d3927cc3f..3d0f92ed4d 100644
--- a/libavutil/pixfmt.h
+++ b/libavutil/pixfmt.h
@@ -60,6 +60,23 @@
* For all the 8 bits per pixel formats, an RGB32 palette is in data[1] like
* for pal8. This palette is filled in automatically by the function
* allocating the picture.
+ *
+ * @par
+ * Summary of the naming conventions for YUV formats:
+ * 444 422 440 420 411 410
+ * ╋━╋━╋━╋━╋ ╋━┿━╋━┿━╋ ╋━╋━╋━╋━╋ ╋━┿━╋━┿━╋ ╋━┿━┿━┿━╋ ╋━┿━┿━┿━╋
+ * ╋━╋━╋━╋━╋ ╋━┿━╋━┿━╋ ╂─╂─╂─╂─╂ ╂─┼─╂─┼─╂ ╋━┿━┿━┿━╋ ╂─┼─┼─┼─╂
+ * ╋━╋━╋━╋━╋ ╋━┿━╋━┿━╋ ╋━╋━╋━╋━╋ ╋━┿━╋━┿━╋ ╋━┿━┿━┿━╋ ╂─┼─┼─┼─╂
+ * ╋━╋━╋━╋━╋ ╋━┿━╋━┿━╋ ╂─╂─╂─╂─╂ ╂─┼─╂─┼─╂ ╋━┿━┿━┿━╋ ╂─┼─┼─┼─╂
+ * ╋━╋━╋━╋━╋ ╋━┿━╋━┿━╋ ╋━╋━╋━╋━╋ ╋━┿━╋━┿━╋ ╋━┿━┿━┿━╋ ╋━┿━┿━┿━╋
+ * where
+ * ┼─┼ = luma pixel ╋━╋ = chroma pixel
+ * ┼─┼ ╋━╋
+ *
+ * yuv4ab →
+ * log2_chroma_w = log₂(4/a)
+ * log2_chroma_h = b == a ? 0 : b == 0 ? log2_chroma_w : unused
+ * i.e. a = horizontally, number of luma pixels for four chroma pixels
*/
enum AVPixelFormat {
AV_PIX_FMT_NONE = -1,
--
2.35.1
More information about the ffmpeg-devel
mailing list