mirror of
https://git.ffmpeg.org/ffmpeg.git
synced 2025-02-26 00:31:12 +00:00
libvpx: Support setting color range for vp9.
Pass through color range to vp9 encoder. Parse color range in libvpxdec.c. Reviewed-by: Ronald S. Bultje <rsbultje@gmail.com> Signed-off-by: Sasi Inguva <isasi@google.com> Signed-off-by: James Almer <jamrial@gmail.com>
This commit is contained in:
parent
2039b3e751
commit
cbcc88c039
@ -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,
|
AVCOL_SPC_SMPTE240M, AVCOL_SPC_BT2020_NCL, AVCOL_SPC_RESERVED, AVCOL_SPC_RGB,
|
||||||
};
|
};
|
||||||
avctx->colorspace = colorspaces[img->cs];
|
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
|
#endif
|
||||||
if (avctx->codec_id == AV_CODEC_ID_VP8 && img->fmt != VPX_IMG_FMT_I420)
|
if (avctx->codec_id == AV_CODEC_ID_VP8 && img->fmt != VPX_IMG_FMT_I420)
|
||||||
return AVERROR_INVALIDDATA;
|
return AVERROR_INVALIDDATA;
|
||||||
|
@ -125,6 +125,9 @@ static const char *const ctlidstr[] = {
|
|||||||
#if VPX_ENCODER_ABI_VERSION > 8
|
#if VPX_ENCODER_ABI_VERSION > 8
|
||||||
[VP9E_SET_COLOR_SPACE] = "VP9E_SET_COLOR_SPACE",
|
[VP9E_SET_COLOR_SPACE] = "VP9E_SET_COLOR_SPACE",
|
||||||
#endif
|
#endif
|
||||||
|
#if VPX_ENCODER_ABI_VERSION >= 11
|
||||||
|
[VP9E_SET_COLOR_RANGE] = "VP9E_SET_COLOR_RANGE",
|
||||||
|
#endif
|
||||||
#endif
|
#endif
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -368,6 +371,24 @@ static void set_colorspace(AVCodecContext *avctx)
|
|||||||
codecctl_int(avctx, VP9E_SET_COLOR_SPACE, vpx_cs);
|
codecctl_int(avctx, VP9E_SET_COLOR_SPACE, vpx_cs);
|
||||||
}
|
}
|
||||||
#endif
|
#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
|
#endif
|
||||||
|
|
||||||
static av_cold int vpx_init(AVCodecContext *avctx,
|
static av_cold int vpx_init(AVCodecContext *avctx,
|
||||||
@ -616,6 +637,9 @@ static av_cold int vpx_init(AVCodecContext *avctx,
|
|||||||
codecctl_int(avctx, VP9E_SET_AQ_MODE, ctx->aq_mode);
|
codecctl_int(avctx, VP9E_SET_AQ_MODE, ctx->aq_mode);
|
||||||
#if VPX_ENCODER_ABI_VERSION > 8
|
#if VPX_ENCODER_ABI_VERSION > 8
|
||||||
set_colorspace(avctx);
|
set_colorspace(avctx);
|
||||||
|
#endif
|
||||||
|
#if VPX_ENCODER_ABI_VERSION >= 11
|
||||||
|
set_color_range(avctx);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
Loading…
Reference in New Issue
Block a user