[vlc-commits] [Git][videolan/vlc][master] 6 commits: avcodec/chroma: mark the full range chromas

Steve Lhomme (@robUx4) gitlab at videolan.org
Sun Oct 8 14:58:41 UTC 2023



Steve Lhomme pushed to branch master at VideoLAN / VLC


Commits:
3317a0e9 by Steve Lhomme at 2023-10-08T14:31:33+00:00
avcodec/chroma: mark the full range chromas

- - - - -
febc89b8 by Steve Lhomme at 2023-10-08T14:31:33+00:00
avcodec/video: get the VLC chroma with the color range

This will be used later.

- - - - -
a0a06750 by Steve Lhomme at 2023-10-08T14:31:33+00:00
avcodec/chroma: remove unused FindVlcChroma()

- - - - -
a30cd2a0 by Steve Lhomme at 2023-10-08T14:31:33+00:00
avcodec/chroma: remap full range YUV to chroma+range

The AV_PIX_FMT_YUVJxxx chromas are deprecated and might be removed someday.
We can map these values to VLC chromas+range, but not the other way
around.

- - - - -
5debcc34 by Steve Lhomme at 2023-10-08T14:31:33+00:00
avcodec/chroma: map AV_PIX_FMT_YUVJ411P

It's a full range VLC_CODEC_I411.

- - - - -
e380c2a8 by Steve Lhomme at 2023-10-08T14:31:33+00:00
avcodec/chroma: replace GetFfmpegChroma() calls with FindFfmpegChroma()

We may map libavutil chromas with range to VLC+range, but we should not map to
libavutil chromas+range as these chromas are deprecated.

- - - - -


6 changed files:

- modules/codec/avcodec/chroma.c
- modules/codec/avcodec/chroma.h
- modules/codec/avcodec/encoder.c
- modules/codec/avcodec/video.c
- modules/demux/avformat/mux.c
- modules/video_chroma/swscale.c


Changes:

=====================================
modules/codec/avcodec/chroma.c
=====================================
@@ -57,190 +57,171 @@ static const struct
 {
     vlc_fourcc_t  i_chroma;
     enum AVPixelFormat i_chroma_id;
+    video_color_range_t range;
 
 } chroma_table[] =
 {
     /* Planar YUV formats */
-    {VLC_CODEC_I444, AV_PIX_FMT_YUV444P },
-    {VLC_CODEC_J444, AV_PIX_FMT_YUVJ444P },
-
-    {VLC_CODEC_I440, AV_PIX_FMT_YUV440P },
-    {VLC_CODEC_J440, AV_PIX_FMT_YUVJ440P },
-
-    {VLC_CODEC_I422, AV_PIX_FMT_YUV422P },
-    {VLC_CODEC_J422, AV_PIX_FMT_YUVJ422P },
-
-    {VLC_CODEC_I420, AV_PIX_FMT_YUV420P },
-    {VLC_CODEC_YV12, AV_PIX_FMT_YUV420P },
-    {VLC_CODEC_J420, AV_PIX_FMT_YUVJ420P },
-    {VLC_CODEC_I411, AV_PIX_FMT_YUV411P },
-    {VLC_CODEC_I410, AV_PIX_FMT_YUV410P },
-    {VLC_CODEC_YV9, AV_PIX_FMT_YUV410P },
-
-    {VLC_CODEC_NV12, AV_PIX_FMT_NV12 },
-    {VLC_CODEC_NV21, AV_PIX_FMT_NV21 },
-
-    {VLC_CODEC_I420_9L, AV_PIX_FMT_YUV420P9LE },
-    {VLC_CODEC_I420_9B, AV_PIX_FMT_YUV420P9BE },
-    {VLC_CODEC_I420_10L, AV_PIX_FMT_YUV420P10LE },
-    {VLC_CODEC_I420_10B, AV_PIX_FMT_YUV420P10BE },
+    {VLC_CODEC_I444, AV_PIX_FMT_YUV444P,  COLOR_RANGE_UNDEF },
+    {VLC_CODEC_I444, AV_PIX_FMT_YUVJ444P,  COLOR_RANGE_FULL },
+
+    {VLC_CODEC_I440, AV_PIX_FMT_YUV440P,  COLOR_RANGE_UNDEF },
+    {VLC_CODEC_I440, AV_PIX_FMT_YUVJ440P,  COLOR_RANGE_FULL },
+
+    {VLC_CODEC_I422, AV_PIX_FMT_YUV422P,  COLOR_RANGE_UNDEF },
+    {VLC_CODEC_I422, AV_PIX_FMT_YUVJ422P,  COLOR_RANGE_FULL },
+
+    {VLC_CODEC_I420, AV_PIX_FMT_YUV420P,  COLOR_RANGE_UNDEF },
+    {VLC_CODEC_YV12, AV_PIX_FMT_YUV420P,  COLOR_RANGE_UNDEF },
+    {VLC_CODEC_I420, AV_PIX_FMT_YUVJ420P,  COLOR_RANGE_FULL },
+    {VLC_CODEC_I411, AV_PIX_FMT_YUV411P,  COLOR_RANGE_UNDEF },
+    {VLC_CODEC_I411, AV_PIX_FMT_YUVJ411P,  COLOR_RANGE_FULL },
+    {VLC_CODEC_I410, AV_PIX_FMT_YUV410P,  COLOR_RANGE_UNDEF },
+    {VLC_CODEC_YV9, AV_PIX_FMT_YUV410P,  COLOR_RANGE_UNDEF },
+
+    {VLC_CODEC_NV12, AV_PIX_FMT_NV12,  COLOR_RANGE_UNDEF },
+    {VLC_CODEC_NV21, AV_PIX_FMT_NV21,  COLOR_RANGE_UNDEF },
+
+    {VLC_CODEC_I420_9L, AV_PIX_FMT_YUV420P9LE,  COLOR_RANGE_UNDEF },
+    {VLC_CODEC_I420_9B, AV_PIX_FMT_YUV420P9BE,  COLOR_RANGE_UNDEF },
+    {VLC_CODEC_I420_10L, AV_PIX_FMT_YUV420P10LE,  COLOR_RANGE_UNDEF },
+    {VLC_CODEC_I420_10B, AV_PIX_FMT_YUV420P10BE,  COLOR_RANGE_UNDEF },
 #ifdef AV_PIX_FMT_YUV420P12 /* 54, 17, 100 */
-    {VLC_CODEC_I420_12L, AV_PIX_FMT_YUV420P12LE },
-    {VLC_CODEC_I420_12B, AV_PIX_FMT_YUV420P12BE },
+    {VLC_CODEC_I420_12L, AV_PIX_FMT_YUV420P12LE,  COLOR_RANGE_UNDEF },
+    {VLC_CODEC_I420_12B, AV_PIX_FMT_YUV420P12BE,  COLOR_RANGE_UNDEF },
 #endif
-    {VLC_CODEC_I420_16L, AV_PIX_FMT_YUV420P16LE },
-    {VLC_CODEC_I420_16B, AV_PIX_FMT_YUV420P16BE },
+    {VLC_CODEC_I420_16L, AV_PIX_FMT_YUV420P16LE,  COLOR_RANGE_UNDEF },
+    {VLC_CODEC_I420_16B, AV_PIX_FMT_YUV420P16BE,  COLOR_RANGE_UNDEF },
 #ifdef AV_PIX_FMT_P010LE
-    {VLC_CODEC_P010, AV_PIX_FMT_P010LE },
+    {VLC_CODEC_P010, AV_PIX_FMT_P010LE,  COLOR_RANGE_UNDEF },
 #endif
 #ifdef AV_PIX_FMT_P016LE
-    {VLC_CODEC_P016, AV_PIX_FMT_P016LE },
+    {VLC_CODEC_P016, AV_PIX_FMT_P016LE,  COLOR_RANGE_UNDEF },
 #endif
 
-    {VLC_CODEC_I422_9L, AV_PIX_FMT_YUV422P9LE },
-    {VLC_CODEC_I422_9B, AV_PIX_FMT_YUV422P9BE },
-    {VLC_CODEC_I422_10L, AV_PIX_FMT_YUV422P10LE },
-    {VLC_CODEC_I422_10B, AV_PIX_FMT_YUV422P10BE },
-    {VLC_CODEC_I422_16L, AV_PIX_FMT_YUV422P16LE },
-    {VLC_CODEC_I422_16B, AV_PIX_FMT_YUV422P16BE },
+    {VLC_CODEC_I422_9L, AV_PIX_FMT_YUV422P9LE,  COLOR_RANGE_UNDEF },
+    {VLC_CODEC_I422_9B, AV_PIX_FMT_YUV422P9BE,  COLOR_RANGE_UNDEF },
+    {VLC_CODEC_I422_10L, AV_PIX_FMT_YUV422P10LE,  COLOR_RANGE_UNDEF },
+    {VLC_CODEC_I422_10B, AV_PIX_FMT_YUV422P10BE,  COLOR_RANGE_UNDEF },
+    {VLC_CODEC_I422_16L, AV_PIX_FMT_YUV422P16LE,  COLOR_RANGE_UNDEF },
+    {VLC_CODEC_I422_16B, AV_PIX_FMT_YUV422P16BE,  COLOR_RANGE_UNDEF },
 #ifdef AV_PIX_FMT_YUV422P12 /* 54, 17, 100 */
-    {VLC_CODEC_I422_12L, AV_PIX_FMT_YUV422P12LE },
-    {VLC_CODEC_I422_12B, AV_PIX_FMT_YUV422P12BE },
+    {VLC_CODEC_I422_12L, AV_PIX_FMT_YUV422P12LE,  COLOR_RANGE_UNDEF },
+    {VLC_CODEC_I422_12B, AV_PIX_FMT_YUV422P12BE,  COLOR_RANGE_UNDEF },
 #endif
 
-    {VLC_CODEC_YUV420A, AV_PIX_FMT_YUVA420P },
-    {VLC_CODEC_YUV422A, AV_PIX_FMT_YUVA422P },
-    {VLC_CODEC_YUVA,    AV_PIX_FMT_YUVA444P },
+    {VLC_CODEC_YUV420A, AV_PIX_FMT_YUVA420P,  COLOR_RANGE_UNDEF },
+    {VLC_CODEC_YUV422A, AV_PIX_FMT_YUVA422P,  COLOR_RANGE_UNDEF },
+    {VLC_CODEC_YUVA,    AV_PIX_FMT_YUVA444P,  COLOR_RANGE_UNDEF },
 
-    {VLC_CODEC_YUVA_444_10L, AV_PIX_FMT_YUVA444P10LE },
-    {VLC_CODEC_YUVA_444_10B, AV_PIX_FMT_YUVA444P10BE },
+    {VLC_CODEC_YUVA_444_10L, AV_PIX_FMT_YUVA444P10LE,  COLOR_RANGE_UNDEF },
+    {VLC_CODEC_YUVA_444_10B, AV_PIX_FMT_YUVA444P10BE,  COLOR_RANGE_UNDEF },
 
 #if LIBAVUTIL_VERSION_INT >= AV_VERSION_INT(56, 24, 101)
-    {VLC_CODEC_YUVA_444_12L, AV_PIX_FMT_YUVA444P12LE },
-    {VLC_CODEC_YUVA_444_12B, AV_PIX_FMT_YUVA444P12BE },
+    {VLC_CODEC_YUVA_444_12L, AV_PIX_FMT_YUVA444P12LE,  COLOR_RANGE_UNDEF },
+    {VLC_CODEC_YUVA_444_12B, AV_PIX_FMT_YUVA444P12BE,  COLOR_RANGE_UNDEF },
 #endif
 
-    {VLC_CODEC_I444_9L, AV_PIX_FMT_YUV444P9LE },
-    {VLC_CODEC_I444_9B, AV_PIX_FMT_YUV444P9BE },
-    {VLC_CODEC_I444_10L, AV_PIX_FMT_YUV444P10LE },
-    {VLC_CODEC_I444_10B, AV_PIX_FMT_YUV444P10BE },
+    {VLC_CODEC_I444_9L, AV_PIX_FMT_YUV444P9LE,  COLOR_RANGE_UNDEF },
+    {VLC_CODEC_I444_9B, AV_PIX_FMT_YUV444P9BE,  COLOR_RANGE_UNDEF },
+    {VLC_CODEC_I444_10L, AV_PIX_FMT_YUV444P10LE,  COLOR_RANGE_UNDEF },
+    {VLC_CODEC_I444_10B, AV_PIX_FMT_YUV444P10BE,  COLOR_RANGE_UNDEF },
 #ifdef AV_PIX_FMT_YUV444P12 /* 54, 17, 100 */
-    {VLC_CODEC_I444_12L, AV_PIX_FMT_YUV444P12LE },
-    {VLC_CODEC_I444_12B, AV_PIX_FMT_YUV444P12BE },
+    {VLC_CODEC_I444_12L, AV_PIX_FMT_YUV444P12LE,  COLOR_RANGE_UNDEF },
+    {VLC_CODEC_I444_12B, AV_PIX_FMT_YUV444P12BE,  COLOR_RANGE_UNDEF },
 #endif
-    {VLC_CODEC_I444_16L, AV_PIX_FMT_YUV444P16LE },
-    {VLC_CODEC_I444_16B, AV_PIX_FMT_YUV444P16BE },
+    {VLC_CODEC_I444_16L, AV_PIX_FMT_YUV444P16LE,  COLOR_RANGE_UNDEF },
+    {VLC_CODEC_I444_16B, AV_PIX_FMT_YUV444P16BE,  COLOR_RANGE_UNDEF },
 
     /* Packed YUV formats */
-    {VLC_CODEC_YUYV, AV_PIX_FMT_YUYV422 },
-    {VLC_CODEC_UYVY, AV_PIX_FMT_UYVY422 },
-    {VLC_CODEC_YVYU, AV_PIX_FMT_YVYU422 },
+    {VLC_CODEC_YUYV, AV_PIX_FMT_YUYV422,  COLOR_RANGE_UNDEF },
+    {VLC_CODEC_UYVY, AV_PIX_FMT_UYVY422,  COLOR_RANGE_UNDEF },
+    {VLC_CODEC_YVYU, AV_PIX_FMT_YVYU422,  COLOR_RANGE_UNDEF },
 
     /* Packed RGB formats */
-    {VLC_CODEC_RGB233, AV_PIX_FMT_RGB8 },
-    {VLC_CODEC_BGR233, AV_PIX_FMT_BGR8 },
+    {VLC_CODEC_RGB233, AV_PIX_FMT_RGB8,  COLOR_RANGE_UNDEF },
+    {VLC_CODEC_BGR233, AV_PIX_FMT_BGR8,  COLOR_RANGE_UNDEF },
 
-    {VLC_CODEC_RGB565BE, AV_PIX_FMT_RGB565BE },
-    {VLC_CODEC_RGB565LE, AV_PIX_FMT_RGB565LE },
-    {VLC_CODEC_BGR565BE, AV_PIX_FMT_BGR565BE },
-    {VLC_CODEC_BGR565LE, AV_PIX_FMT_BGR565LE },
+    {VLC_CODEC_RGB565BE, AV_PIX_FMT_RGB565BE,  COLOR_RANGE_UNDEF },
+    {VLC_CODEC_RGB565LE, AV_PIX_FMT_RGB565LE,  COLOR_RANGE_UNDEF },
+    {VLC_CODEC_BGR565BE, AV_PIX_FMT_BGR565BE,  COLOR_RANGE_UNDEF },
+    {VLC_CODEC_BGR565LE, AV_PIX_FMT_BGR565LE,  COLOR_RANGE_UNDEF },
 
-    {VLC_CODEC_RGB555BE, AV_PIX_FMT_RGB555BE },
-    {VLC_CODEC_RGB555LE, AV_PIX_FMT_RGB555LE },
-    {VLC_CODEC_BGR555BE, AV_PIX_FMT_BGR555BE },
-    {VLC_CODEC_BGR555LE, AV_PIX_FMT_BGR555LE },
+    {VLC_CODEC_RGB555BE, AV_PIX_FMT_RGB555BE,  COLOR_RANGE_UNDEF },
+    {VLC_CODEC_RGB555LE, AV_PIX_FMT_RGB555LE,  COLOR_RANGE_UNDEF },
+    {VLC_CODEC_BGR555BE, AV_PIX_FMT_BGR555BE,  COLOR_RANGE_UNDEF },
+    {VLC_CODEC_BGR555LE, AV_PIX_FMT_BGR555LE,  COLOR_RANGE_UNDEF },
 
-    {VLC_CODEC_RGB24, AV_PIX_FMT_RGB24 },
-    {VLC_CODEC_BGR24, AV_PIX_FMT_BGR24 },
+    {VLC_CODEC_RGB24, AV_PIX_FMT_RGB24,  COLOR_RANGE_UNDEF },
+    {VLC_CODEC_BGR24, AV_PIX_FMT_BGR24,  COLOR_RANGE_UNDEF },
 
-    {VLC_CODEC_RGBX, AV_PIX_FMT_RGB0 },
-    {VLC_CODEC_XRGB, AV_PIX_FMT_0RGB },
-    {VLC_CODEC_BGRX, AV_PIX_FMT_BGR0 },
-    {VLC_CODEC_XBGR, AV_PIX_FMT_0BGR },
+    {VLC_CODEC_RGBX, AV_PIX_FMT_RGB0,  COLOR_RANGE_UNDEF },
+    {VLC_CODEC_XRGB, AV_PIX_FMT_0RGB,  COLOR_RANGE_UNDEF },
+    {VLC_CODEC_BGRX, AV_PIX_FMT_BGR0,  COLOR_RANGE_UNDEF },
+    {VLC_CODEC_XBGR, AV_PIX_FMT_0BGR,  COLOR_RANGE_UNDEF },
 
-    {VLC_CODEC_RGBA, AV_PIX_FMT_RGBA },
-    {VLC_CODEC_ARGB, AV_PIX_FMT_ARGB },
-    {VLC_CODEC_BGRA, AV_PIX_FMT_BGRA },
-    {VLC_CODEC_ABGR, AV_PIX_FMT_ABGR },
+    {VLC_CODEC_RGBA, AV_PIX_FMT_RGBA,  COLOR_RANGE_UNDEF },
+    {VLC_CODEC_ARGB, AV_PIX_FMT_ARGB,  COLOR_RANGE_UNDEF },
+    {VLC_CODEC_BGRA, AV_PIX_FMT_BGRA,  COLOR_RANGE_UNDEF },
+    {VLC_CODEC_ABGR, AV_PIX_FMT_ABGR,  COLOR_RANGE_UNDEF },
 
 #ifdef WORDS_BIGENDIAN
-    {VLC_CODEC_RGBA64, AV_PIX_FMT_RGBA64BE },
+    {VLC_CODEC_RGBA64, AV_PIX_FMT_RGBA64BE,  COLOR_RANGE_UNDEF },
 #else /* !WORDS_BIGENDIAN */
-    {VLC_CODEC_RGBA64, AV_PIX_FMT_RGBA64LE },
+    {VLC_CODEC_RGBA64, AV_PIX_FMT_RGBA64LE,  COLOR_RANGE_UNDEF },
 #endif /* !WORDS_BIGENDIAN */
 
 #ifdef AV_PIX_FMT_X2BGR10
-    {VLC_CODEC_RGBA10, AV_PIX_FMT_X2BGR10 },
+    {VLC_CODEC_RGBA10, AV_PIX_FMT_X2BGR10,  COLOR_RANGE_UNDEF },
 #endif
 
-    {VLC_CODEC_GREY, AV_PIX_FMT_GRAY8 },
+    {VLC_CODEC_GREY, AV_PIX_FMT_GRAY8,  COLOR_RANGE_UNDEF},
 #ifdef AV_PIX_FMT_GRAY10
-    {VLC_CODEC_GREY_10L, AV_PIX_FMT_GRAY10LE },
-    {VLC_CODEC_GREY_10B, AV_PIX_FMT_GRAY10BE },
+    {VLC_CODEC_GREY_10L, AV_PIX_FMT_GRAY10LE,  COLOR_RANGE_UNDEF},
+    {VLC_CODEC_GREY_10B, AV_PIX_FMT_GRAY10BE,  COLOR_RANGE_UNDEF},
 #endif
 #ifdef AV_PIX_FMT_GRAY12
-    {VLC_CODEC_GREY_12L, AV_PIX_FMT_GRAY12LE },
-    {VLC_CODEC_GREY_12B, AV_PIX_FMT_GRAY12BE },
+    {VLC_CODEC_GREY_12L, AV_PIX_FMT_GRAY12LE,  COLOR_RANGE_UNDEF},
+    {VLC_CODEC_GREY_12B, AV_PIX_FMT_GRAY12BE,  COLOR_RANGE_UNDEF},
 #endif
-    {VLC_CODEC_GREY_16L, AV_PIX_FMT_GRAY16LE },
-    {VLC_CODEC_GREY_16B, AV_PIX_FMT_GRAY16BE },
+    {VLC_CODEC_GREY_16L, AV_PIX_FMT_GRAY16LE,  COLOR_RANGE_UNDEF},
+    {VLC_CODEC_GREY_16B, AV_PIX_FMT_GRAY16BE,  COLOR_RANGE_UNDEF},
 
      /* Paletized RGB */
-    {VLC_CODEC_RGBP, AV_PIX_FMT_PAL8 },
+    {VLC_CODEC_RGBP, AV_PIX_FMT_PAL8,  COLOR_RANGE_UNDEF},
 
-    {VLC_CODEC_GBR_PLANAR, AV_PIX_FMT_GBRP },
-    {VLC_CODEC_GBR_PLANAR_9L, AV_PIX_FMT_GBRP9LE },
-    {VLC_CODEC_GBR_PLANAR_9B, AV_PIX_FMT_GBRP9BE },
-    {VLC_CODEC_GBR_PLANAR_10L, AV_PIX_FMT_GBRP10LE },
-    {VLC_CODEC_GBR_PLANAR_10B, AV_PIX_FMT_GBRP10BE },
+    {VLC_CODEC_GBR_PLANAR, AV_PIX_FMT_GBRP,  COLOR_RANGE_UNDEF },
+    {VLC_CODEC_GBR_PLANAR_9L, AV_PIX_FMT_GBRP9LE,  COLOR_RANGE_UNDEF },
+    {VLC_CODEC_GBR_PLANAR_9B, AV_PIX_FMT_GBRP9BE,  COLOR_RANGE_UNDEF },
+    {VLC_CODEC_GBR_PLANAR_10L, AV_PIX_FMT_GBRP10LE,  COLOR_RANGE_UNDEF },
+    {VLC_CODEC_GBR_PLANAR_10B, AV_PIX_FMT_GBRP10BE,  COLOR_RANGE_UNDEF },
 #ifdef AV_PIX_FMT_GBRP12 /* 55, 24, 0 / 51, 74, 100 */
-    {VLC_CODEC_GBR_PLANAR_12L, AV_PIX_FMT_GBRP12LE },
-    {VLC_CODEC_GBR_PLANAR_12B, AV_PIX_FMT_GBRP12BE },
+    {VLC_CODEC_GBR_PLANAR_12L, AV_PIX_FMT_GBRP12LE,  COLOR_RANGE_UNDEF },
+    {VLC_CODEC_GBR_PLANAR_12B, AV_PIX_FMT_GBRP12BE,  COLOR_RANGE_UNDEF },
 #endif
 #ifdef AV_PIX_FMT_GBRP14 /* ffmpeg only */
-    {VLC_CODEC_GBR_PLANAR_14L, AV_PIX_FMT_GBRP14LE },
-    {VLC_CODEC_GBR_PLANAR_14B, AV_PIX_FMT_GBRP14BE },
+    {VLC_CODEC_GBR_PLANAR_14L, AV_PIX_FMT_GBRP14LE,  COLOR_RANGE_UNDEF },
+    {VLC_CODEC_GBR_PLANAR_14B, AV_PIX_FMT_GBRP14BE,  COLOR_RANGE_UNDEF },
 #endif
-    {VLC_CODEC_GBR_PLANAR_16L, AV_PIX_FMT_GBRP16LE },
-    {VLC_CODEC_GBR_PLANAR_16B, AV_PIX_FMT_GBRP16BE },
-    {VLC_CODEC_GBRA_PLANAR, AV_PIX_FMT_GBRAP },
+    {VLC_CODEC_GBR_PLANAR_16L, AV_PIX_FMT_GBRP16LE,  COLOR_RANGE_UNDEF },
+    {VLC_CODEC_GBR_PLANAR_16B, AV_PIX_FMT_GBRP16BE,  COLOR_RANGE_UNDEF },
+    {VLC_CODEC_GBRA_PLANAR, AV_PIX_FMT_GBRAP,  COLOR_RANGE_UNDEF },
 #ifdef AV_PIX_FMT_GBRAP10 /* 56, 1, 0 / 55, 25, 100 */
-    {VLC_CODEC_GBRA_PLANAR_10L, AV_PIX_FMT_GBRAP10LE },
-    {VLC_CODEC_GBRA_PLANAR_10B, AV_PIX_FMT_GBRAP10BE },
+    {VLC_CODEC_GBRA_PLANAR_10L, AV_PIX_FMT_GBRAP10LE,  COLOR_RANGE_UNDEF },
+    {VLC_CODEC_GBRA_PLANAR_10B, AV_PIX_FMT_GBRAP10BE,  COLOR_RANGE_UNDEF },
 #endif
 #ifdef AV_PIX_FMT_GBRAP12 /* 55, 25, 0, 19, 100 */
-    {VLC_CODEC_GBRA_PLANAR_12L, AV_PIX_FMT_GBRAP12LE },
-    {VLC_CODEC_GBRA_PLANAR_12B, AV_PIX_FMT_GBRAP12BE },
+    {VLC_CODEC_GBRA_PLANAR_12L, AV_PIX_FMT_GBRAP12LE,  COLOR_RANGE_UNDEF },
+    {VLC_CODEC_GBRA_PLANAR_12B, AV_PIX_FMT_GBRAP12BE,  COLOR_RANGE_UNDEF },
 #endif
-    {VLC_CODEC_GBRA_PLANAR_16L, AV_PIX_FMT_GBRAP16LE },
-    {VLC_CODEC_GBRA_PLANAR_16B, AV_PIX_FMT_GBRAP16BE },
+    {VLC_CODEC_GBRA_PLANAR_16L, AV_PIX_FMT_GBRAP16LE,  COLOR_RANGE_UNDEF },
+    {VLC_CODEC_GBRA_PLANAR_16B, AV_PIX_FMT_GBRAP16BE,  COLOR_RANGE_UNDEF },
 
     /* XYZ */
-    {VLC_CODEC_XYZ12, AV_PIX_FMT_XYZ12BE },
-    { 0, 0 }
+    {VLC_CODEC_XYZ12, AV_PIX_FMT_XYZ12BE,  COLOR_RANGE_UNDEF },
+    { 0, 0, COLOR_RANGE_UNDEF }
 };
 
-/* FIXME special case the RGB formats */
-enum AVPixelFormat GetFfmpegChroma( const video_format_t *fmt )
-{
-    for( int i = 0; chroma_table[i].i_chroma != 0; i++ )
-    {
-        if( chroma_table[i].i_chroma == fmt->i_chroma )
-        {
-            return chroma_table[i].i_chroma_id;
-        }
-    }
-    return AV_PIX_FMT_NONE;
-}
-
-vlc_fourcc_t FindVlcChroma( enum AVPixelFormat i_ffmpeg_id )
-{
-    for( int i = 0; chroma_table[i].i_chroma != 0; i++ )
-        if( chroma_table[i].i_chroma_id == i_ffmpeg_id )
-            return chroma_table[i].i_chroma;
-    return 0;
-}
-
 int GetVlcChroma( video_format_t *fmt, enum AVPixelFormat i_ffmpeg_chroma )
 {
     for( int i = 0; chroma_table[i].i_chroma != 0; i++ )
@@ -248,6 +229,8 @@ int GetVlcChroma( video_format_t *fmt, enum AVPixelFormat i_ffmpeg_chroma )
         if( chroma_table[i].i_chroma_id == i_ffmpeg_chroma )
         {
             fmt->i_chroma = chroma_table[i].i_chroma;
+            if (chroma_table[i].range != COLOR_RANGE_UNDEF)
+                fmt->color_range = chroma_table[i].range;
             return VLC_SUCCESS;
         }
     }


=====================================
modules/codec/avcodec/chroma.h
=====================================
@@ -28,9 +28,7 @@
 #include <libavutil/pixfmt.h>
 
 enum AVPixelFormat FindFfmpegChroma( vlc_fourcc_t );
-enum AVPixelFormat GetFfmpegChroma( const video_format_t *fmt );
 
-vlc_fourcc_t FindVlcChroma( enum AVPixelFormat );
 int GetVlcChroma( video_format_t *fmt, enum AVPixelFormat i_ffmpeg_chroma );
 
 #endif


=====================================
modules/codec/avcodec/encoder.c
=====================================
@@ -569,7 +569,7 @@ int InitVideoEnc( vlc_object_t *p_this )
             p_enc->fmt_in.video.i_chroma = VLC_CODEC_RGB24;
         }
 
-        p_context->pix_fmt = GetFfmpegChroma( &p_enc->fmt_in.video );
+        p_context->pix_fmt = FindFfmpegChroma( p_enc->fmt_in.video.i_chroma );
 
         if( p_codec->pix_fmts )
         {
@@ -868,7 +868,7 @@ int InitVideoEnc( vlc_object_t *p_this )
     {
         /* XXX: hack: Force same codec (will be handled by transcode) */
         p_enc->fmt_in.video.i_chroma = p_enc->fmt_in.i_codec = p_enc->fmt_out.i_codec;
-        p_context->pix_fmt = GetFfmpegChroma( &p_enc->fmt_in.video );
+        p_context->pix_fmt = FindFfmpegChroma( p_enc->fmt_in.video.i_chroma );
     }
 
     /* Make sure we get extradata filled by the encoder */


=====================================
modules/codec/avcodec/video.c
=====================================
@@ -325,24 +325,15 @@ static int lavc_UpdateVideoFormat(decoder_t *dec, AVCodecContext *ctx,
     return 0;
 }
 
-static bool chroma_compatible(vlc_fourcc_t a, vlc_fourcc_t b)
+static bool chroma_compatible(const video_format_t *a, const video_format_t *b)
 {
-    static const vlc_fourcc_t compat_lists[][2] = {
-        {VLC_CODEC_J420, VLC_CODEC_I420},
-        {VLC_CODEC_J422, VLC_CODEC_I422},
-        {VLC_CODEC_J440, VLC_CODEC_I440},
-        {VLC_CODEC_J444, VLC_CODEC_I444},
-    };
-
-    if (a == b)
-        return true;
-
-    for (size_t i = 0; i < ARRAY_SIZE(compat_lists); i++) {
-        if ((a == compat_lists[i][0] || a == compat_lists[i][1]) &&
-            (b == compat_lists[i][0] || b == compat_lists[i][1]))
-            return true;
-    }
-    return false;
+    if (a->i_chroma != b->i_chroma)
+        return false;
+
+    if (a->color_range != b->color_range && a->color_range != COLOR_RANGE_UNDEF)
+        return false;
+
+    return true;
 }
 
 /**
@@ -353,15 +344,16 @@ static int lavc_CopyPicture(decoder_t *dec, picture_t *pic, AVFrame *frame)
 {
     decoder_sys_t *sys = dec->p_sys;
 
-    vlc_fourcc_t fourcc = FindVlcChroma(frame->format);
-    if (!fourcc)
+    video_format_t test_chroma;
+    video_format_Init(&test_chroma, 0);
+    if (GetVlcChroma(&test_chroma, frame->format) != VLC_SUCCESS)
     {
         const char *name = av_get_pix_fmt_name(frame->format);
 
         msg_Err(dec, "Unsupported decoded output format %d (%s)",
                 sys->p_context->pix_fmt, (name != NULL) ? name : "unknown");
         return VLC_EGENERIC;
-    } else if (!chroma_compatible(fourcc, pic->format.i_chroma)
+    } else if (!chroma_compatible(&test_chroma, &pic->format)
      /* ensure we never read more than dst lines/pixels from src */
      || frame->width != (int) pic->format.i_visible_width
      || frame->height < (int) pic->format.i_visible_height)


=====================================
modules/demux/avformat/mux.c
=====================================
@@ -320,7 +320,7 @@ static int AddStream( sout_mux_t *p_mux, sout_input_t *p_input )
         {
             video_format_t vfmt;
             video_format_Copy(&vfmt, &fmt->video);
-            enum AVPixelFormat avformat = GetFfmpegChroma(&vfmt);
+            enum AVPixelFormat avformat = FindFfmpegChroma(vfmt.i_chroma);
             if(avformat == AV_PIX_FMT_NONE)
                 msg_Warn(p_mux, "can't match format RAW video %4.4s",
                          (const char *)&vfmt.i_chroma);


=====================================
modules/video_chroma/swscale.c
=====================================
@@ -324,8 +324,8 @@ static int GetParameters( ScalerConfiguration *p_cfg,
     bool b_swap_uvi = false;
     bool b_swap_uvo = false;
 
-    i_fmti = GetFfmpegChroma( p_fmti );
-    i_fmto = GetFfmpegChroma( p_fmto );
+    i_fmti = FindFfmpegChroma( p_fmti->i_chroma );
+    i_fmto = FindFfmpegChroma( p_fmto->i_chroma );
 
     if( p_fmti->i_chroma == p_fmto->i_chroma )
     {



View it on GitLab: https://code.videolan.org/videolan/vlc/-/compare/6468fb25955ebe9c76b553abfb755dc0392369e5...e380c2a8261d1c368c963a6cc41827dcde25f6ac

-- 
View it on GitLab: https://code.videolan.org/videolan/vlc/-/compare/6468fb25955ebe9c76b553abfb755dc0392369e5...e380c2a8261d1c368c963a6cc41827dcde25f6ac
You're receiving this email because of your account on code.videolan.org.


VideoLAN code repository instance


More information about the vlc-commits mailing list