[FFmpeg-cvslog] libvpxenc: support setting colorspace for vp9
James Zern
git at videolan.org
Sun Jun 21 01:32:49 CEST 2015
ffmpeg | branch: master | James Zern <jzern at google.com> | Sat Jun 13 12:27:48 2015 -0700| [9b747500f361305d4175b137394f233845cb7d54] | committer: James Zern
libvpxenc: support setting colorspace for vp9
the vp9 bitstream supports 8 values:
unknown (default), bt601, bt709, smpte170, smpte240, bt2020, reserved
and sRGB.
Reviewed-by: Ronald S. Bultje <rsbultje at gmail.com>
Signed-off-by: James Zern <jzern at google.com>
> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=9b747500f361305d4175b137394f233845cb7d54
---
doc/encoders.texi | 12 ++++++++++++
libavcodec/libvpxenc.c | 29 +++++++++++++++++++++++++++++
2 files changed, 41 insertions(+)
diff --git a/doc/encoders.texi b/doc/encoders.texi
index 8b0ecb7..8fed2fc 100644
--- a/doc/encoders.texi
+++ b/doc/encoders.texi
@@ -1550,6 +1550,18 @@ Enable frame parallel decodability features.
@item aq-mode
Set adaptive quantization mode (0: off (default), 1: variance 2: complexity, 3:
cyclic refresh).
+ at item colorspace @emph{color-space}
+Set input color space. The VP9 bitstream supports signaling the following
+colorspaces:
+ at table @option
+ at item @samp{rgb} @emph{sRGB}
+ at item @samp{bt709} @emph{bt709}
+ at item @samp{unspecified} @emph{unknown}
+ at item @samp{bt470bg} @emph{bt601}
+ at item @samp{smpte170m} @emph{smpte170}
+ at item @samp{smpte240m} @emph{smpte240}
+ at item @samp{bt2020_ncl} @emph{bt2020}
+ at end table
@end table
@end table
diff --git a/libavcodec/libvpxenc.c b/libavcodec/libvpxenc.c
index 28a0e14..b2deb5d 100644
--- a/libavcodec/libvpxenc.c
+++ b/libavcodec/libvpxenc.c
@@ -128,6 +128,9 @@ static const char *const ctlidstr[] = {
[VP9E_SET_TILE_ROWS] = "VP9E_SET_TILE_ROWS",
[VP9E_SET_FRAME_PARALLEL_DECODING] = "VP9E_SET_FRAME_PARALLEL_DECODING",
[VP9E_SET_AQ_MODE] = "VP9E_SET_AQ_MODE",
+#if VPX_ENCODER_ABI_VERSION > 8
+ [VP9E_SET_COLOR_SPACE] = "VP9E_SET_COLOR_SPACE",
+#endif
#endif
};
@@ -349,6 +352,29 @@ static int set_pix_fmt(AVCodecContext *avctx, vpx_codec_caps_t codec_caps,
av_log(avctx, AV_LOG_ERROR, "Unsupported pixel format.\n");
return AVERROR_INVALIDDATA;
}
+
+#if VPX_ENCODER_ABI_VERSION > 8
+static void set_colorspace(AVCodecContext *avctx)
+{
+ enum vpx_color_space vpx_cs;
+
+ switch (avctx->colorspace) {
+ case AVCOL_SPC_RGB: vpx_cs = VPX_CS_SRGB; break;
+ case AVCOL_SPC_BT709: vpx_cs = VPX_CS_BT_709; break;
+ case AVCOL_SPC_UNSPECIFIED: vpx_cs = VPX_CS_UNKNOWN; break;
+ case AVCOL_SPC_RESERVED: vpx_cs = VPX_CS_RESERVED; break;
+ case AVCOL_SPC_BT470BG: vpx_cs = VPX_CS_BT_601; break;
+ case AVCOL_SPC_SMPTE170M: vpx_cs = VPX_CS_SMPTE_170; break;
+ case AVCOL_SPC_SMPTE240M: vpx_cs = VPX_CS_SMPTE_240; break;
+ case AVCOL_SPC_BT2020_NCL: vpx_cs = VPX_CS_BT_2020; break;
+ default:
+ av_log(avctx, AV_LOG_WARNING, "Unsupported colorspace (%d)\n",
+ avctx->colorspace);
+ return;
+ }
+ codecctl_int(avctx, VP9E_SET_COLOR_SPACE, vpx_cs);
+}
+#endif
#endif
static av_cold int vpx_init(AVCodecContext *avctx,
@@ -593,6 +619,9 @@ static av_cold int vpx_init(AVCodecContext *avctx,
codecctl_int(avctx, VP9E_SET_FRAME_PARALLEL_DECODING, ctx->frame_parallel);
if (ctx->aq_mode >= 0)
codecctl_int(avctx, VP9E_SET_AQ_MODE, ctx->aq_mode);
+#if VPX_ENCODER_ABI_VERSION > 8
+ set_colorspace(avctx);
+#endif
}
#endif
More information about the ffmpeg-cvslog
mailing list