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

Debargha Mukherjee debargha at google.com
Sat Apr 4 03:37:44 CEST 2015


On Thu, Apr 2, 2015 at 3:10 PM, James Zern <jzern at google.com> wrote:

> 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'.
>

done


>
> > +#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.
>

done.


>
> > +#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.
>

done.


>
> > -    .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
>

done using ff_vp9_init_static().


>
> Now a non-high-bitdepth build will fail the encode if given a high-bitdepth
> file. Previously this would silently downsample.
> _______________________________________________
> ffmpeg-devel mailing list
> ffmpeg-devel at ffmpeg.org
> http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
>



-- 
Debargha Mukherjee, Ph.D.
Staff Software Engineer,
Google, Inc.
Email: debargha at google.com
Phone: 408-234-5956 (cell)
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0001-Support-for-VP9-high-color-high-bit-depth-encoding.patch
Type: text/x-patch
Size: 8509 bytes
Desc: not available
URL: <https://ffmpeg.org/pipermail/ffmpeg-devel/attachments/20150403/7510858a/attachment.bin>


More information about the ffmpeg-devel mailing list