[FFmpeg-devel] [PATCH] libvpx: Support setting color range for vp9.

Sasi Inguva isasi at google.com
Wed Dec 30 21:44:05 CET 2015


Pass through color range to vp9 encoder.

Signed-off-by: Sasi Inguva <isasi at google.com>
---
 libavcodec/libvpxenc.c | 26 ++++++++++++++++++++++++++
 1 file changed, 26 insertions(+)

diff --git a/libavcodec/libvpxenc.c b/libavcodec/libvpxenc.c
index 8588241..58da30d 100644
--- a/libavcodec/libvpxenc.c
+++ b/libavcodec/libvpxenc.c
@@ -124,6 +124,9 @@ static const char *const ctlidstr[] = {
 #if VPX_ENCODER_ABI_VERSION > 8
     [VP9E_SET_COLOR_SPACE]             = "VP9E_SET_COLOR_SPACE",
 #endif
+#if VPX_ENCODER_ABI_VERSION >= 11
+    [VP9E_SET_COLOR_RANGE]             = "VP9E_SET_COLOR_RANGE",
+#endif
 #endif
 };
 
@@ -367,6 +370,26 @@ static void set_colorspace(AVCodecContext *avctx)
     codecctl_int(avctx, VP9E_SET_COLOR_SPACE, vpx_cs);
 }
 #endif
+
+#if VPX_ENCODER_ABI_VERSION >= 11
+static void set_color_range(AVCodecContext *avctx)
+{
+    enum vpx_color_range vpx_cr;
+    switch (avctx->color_range) {
+    case AVCOL_RANGE_UNSPECIFIED:
+    case AVCOL_RANGE_MPEG:
+        vpx_cr = VPX_CR_STUDIO_RANGE; break;
+    case AVCOL_RANGE_JPEG:
+        vpx_cr = VPX_CR_FULL_RANGE; break;
+    default:
+        av_log(avctx, AV_LOG_WARNING, "Unsupported color range (%d)\n",
+               avctx->color_range);
+        return;
+    }
+
+    codecctl_int(avctx, VP9E_SET_COLOR_RANGE, vpx_cr);
+}
+#endif
 #endif
 
 static av_cold int vpx_init(AVCodecContext *avctx,
@@ -616,6 +639,9 @@ static av_cold int vpx_init(AVCodecContext *avctx,
 #if VPX_ENCODER_ABI_VERSION > 8
         set_colorspace(avctx);
 #endif
+#if VPX_ENCODER_ABI_VERSION >= 11
+        set_color_range(avctx);
+#endif
     }
 #endif
 
-- 
2.6.0.rc2.230.g3dd15c0



More information about the ffmpeg-devel mailing list