[FFmpeg-devel] Patch for High color and High bit-depth support

James Zern jzern at google.com
Fri Apr 3 00:10:48 CEST 2015


On Thu, Apr 2, 2015 at 12:19 PM, Debargha Mukherjee <debargha at google.com> wrote:
> [...]
>
> Updated patch to handle the checks better.
>

> +#if CONFIG_LIBVPX_VP9_ENCODER
> +static int set_pix_fmt(AVCodecContext *avctx, vpx_codec_caps_t codec_caps,
> +                       struct vpx_codec_enc_cfg *enccfg, vpx_codec_flags_t *flags,
> +                       vpx_img_fmt_t *img_fmt) {
> +    switch (avctx->pix_fmt) {
> +        case AV_PIX_FMT_YUV420P:
>

Indent is inconsistent with the other switch in this file: align 'case' with
'switch'.

> +#ifdef VPX_IMG_FMT_HIGHBITDEPTH
> +            enccfg->g_bit_depth = enccfg->g_input_bit_depth = 8;
> +#endif
> +            enccfg->g_profile = 0;
> +            *img_fmt = VPX_IMG_FMT_I420;
> +            return 0;
> +        case AV_PIX_FMT_YUV422P:
> +#ifdef VPX_IMG_FMT_HIGHBITDEPTH
> +            enccfg->g_bit_depth = enccfg->g_input_bit_depth = 8;
> +#endif
> +            enccfg->g_profile = 1;
> +            *img_fmt = VPX_IMG_FMT_I422;
> +            return 0;
> +        case AV_PIX_FMT_YUV444P:
> +#ifdef VPX_IMG_FMT_HIGHBITDEPTH
> +            enccfg->g_bit_depth = enccfg->g_input_bit_depth = 8;
> +#endif
> +            enccfg->g_profile = 1;
> +            *img_fmt = VPX_IMG_FMT_I444;
> +            return 0;
>

You can probably merge profile 1 like 2/3 to cut down on the duplication. You
might want to set bitdepth to 8 by default reducing the ifdefs here too.

> +#if CONFIG_LIBVPX_VP9_ENCODER
> +    if (avctx->codec_id == AV_CODEC_ID_VP9) {
> +        if (set_pix_fmt(avctx, codec_caps, &enccfg, &flags, &img_fmt))
> +            return AVERROR(EINVAL);
> +        av_log(avctx, AV_LOG_INFO, "Bit-depth: %d\n", enccfg.g_bit_depth);
>

Won't build with a non-high-bitdepth build.

> -    .pix_fmts       = (const enum AVPixelFormat[]){ AV_PIX_FMT_YUV420P, AV_PIX_FMT_NONE },
> +    .pix_fmts       = (const enum AVPixelFormat[]){ AV_PIX_FMT_YUV420P,
> +                                                    AV_PIX_FMT_YUV422P,
> +                                                    AV_PIX_FMT_YUV444P,
> +#ifdef VPX_IMG_FMT_HIGHBITDEPTH
> +                                                    AV_PIX_FMT_YUV420P10LE,
> +                                                    AV_PIX_FMT_YUV422P10LE,
> +                                                    AV_PIX_FMT_YUV444P10LE,
> +                                                    AV_PIX_FMT_YUV420P12LE,
> +                                                    AV_PIX_FMT_YUV422P12LE,
> +                                                    AV_PIX_FMT_YUV444P12LE,
> +#endif

Now a non-high-bitdepth build will fail the encode if given a high-bitdepth
file. Previously this would silently downsample.


More information about the ffmpeg-devel mailing list