[FFmpeg-devel] [PATCH] libvpx: Support setting color range for vp9.
Ronald S. Bultje
rsbultje at gmail.com
Sat Jan 9 15:43:25 CET 2016
Hi,
On Fri, Jan 8, 2016 at 10:12 PM, Sasi Inguva <isasi at google.com> wrote:
> Pass through color range to vp9 encoder. Parse color range in libvpxdec.c.
>
> Signed-off-by: Sasi Inguva <isasi at google.com>
> ---
> libavcodec/libvpxdec.c | 6 ++++++
> libavcodec/libvpxenc.c | 26 ++++++++++++++++++++++++++
> 2 files changed, 32 insertions(+)
>
> diff --git a/libavcodec/libvpxdec.c b/libavcodec/libvpxdec.c
> index 698c546..de72be9 100644
> --- a/libavcodec/libvpxdec.c
> +++ b/libavcodec/libvpxdec.c
> @@ -69,6 +69,12 @@ static int set_pix_fmt(AVCodecContext *avctx, struct
> vpx_image *img)
> AVCOL_SPC_SMPTE240M, AVCOL_SPC_BT2020_NCL, AVCOL_SPC_RESERVED,
> AVCOL_SPC_RGB,
> };
> avctx->colorspace = colorspaces[img->cs];
> +#if VPX_IMAGE_ABI_VERSION >= 4
> + static const enum AVColorRange color_ranges[] = {
> + AVCOL_RANGE_MPEG, AVCOL_RANGE_JPEG
> + };
> + avctx->color_range = color_ranges[img->range];
> +#endif
> #endif
> if (avctx->codec_id == AV_CODEC_ID_VP8 && img->fmt !=
> VPX_IMG_FMT_I420)
> return AVERROR_INVALIDDATA;
> diff --git a/libavcodec/libvpxenc.c b/libavcodec/libvpxenc.c
> index 9cf32bf..ef531d5 100644
> --- a/libavcodec/libvpxenc.c
> +++ b/libavcodec/libvpxenc.c
> @@ -125,6 +125,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
> };
>
> @@ -368,6 +371,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;
>
Patch itself is good, but can you please put the break on a newline? I
don't think we ever put break on the same line as the statement unless it's
on the same line as the "case" also.
(Whoever commits this patch can also do it for you.)
Thanks,
Ronald
More information about the ffmpeg-devel
mailing list