[FFmpeg-devel] [PATCH 6/7] avcodec: allow multiple hwaccels for the same codec/pixfmt

wm4 nfxjfg at googlemail.com
Tue Oct 3 17:04:41 EEST 2017


On Tue, 3 Oct 2017 15:58:32 +0200
Timo Rothenpieler <timo at rothenpieler.org> wrote:

> Am 03.10.2017 um 15:15 schrieb wm4:
> > Currently, AVHWAccels are looked up using a (codec_id, pixfmt) tuple.
> > This means it's impossible to have 2 decoders for the same codec and
> > using the same opaque hardware pixel format.
> > 
> > This breaks merging Libav's CUVID hwaccel. FFmpeg has its own CUVID
> > support, but it's a full stream decoder, using NVIDIA's codec parser.
> > The Libav one is a true hwaccel, which is based on the builtin software
> > decoders.
> > 
> > Fix this by introducing another field to disambiguate AVHWAccels, and
> > use it for our CUVID decoders. FF_CODEC_CAP_HWACCEL_REQUIRE_CLASS makes
> > this mechanism backwards compatible and optional.
> > ---
> >   libavcodec/Makefile   |  1 +
> >   libavcodec/avcodec.h  |  5 +++++
> >   libavcodec/cuviddec.c |  2 ++
> >   libavcodec/decode.c   | 12 ++++++++----
> >   libavcodec/internal.h |  5 +++++
> >   5 files changed, 21 insertions(+), 4 deletions(-)
> > 
> > diff --git a/libavcodec/Makefile b/libavcodec/Makefile
> > index fa3ab8f08a..3e0d654541 100644
> > --- a/libavcodec/Makefile
> > +++ b/libavcodec/Makefile
> > @@ -820,6 +820,7 @@ OBJS-$(CONFIG_ADPCM_YAMAHA_DECODER)       += adpcm.o adpcm_data.o
> >   OBJS-$(CONFIG_ADPCM_YAMAHA_ENCODER)       += adpcmenc.o adpcm_data.o
> >   
> >   # hardware accelerators
> > +OBJS-$(CONFIG_CUVID)                      += cuvid.o
> >   OBJS-$(CONFIG_D3D11VA)                    += dxva2.o
> >   OBJS-$(CONFIG_DXVA2)                      += dxva2.o
> >   OBJS-$(CONFIG_VAAPI)                      += vaapi_decode.o
> > diff --git a/libavcodec/avcodec.h b/libavcodec/avcodec.h
> > index 52cc5b0ca0..ecc49e5643 100644
> > --- a/libavcodec/avcodec.h
> > +++ b/libavcodec/avcodec.h
> > @@ -4000,6 +4000,11 @@ typedef struct AVHWAccel {
> >        * Internal hwaccel capabilities.
> >        */
> >       int caps_internal;
> > +
> > +    /**
> > +     * Some hwaccels are ambiguous if only  
> 
> This seems to be truncated?

Fixed locally with:

    /**
     * Some hwaccels are ambiguous if only the id and pix_fmt fields are used.
     * If non-NULL, the associated AVCodec must have
     * FF_CODEC_CAP_HWACCEL_REQUIRE_CLASS set.
     */
    const AVClass *decoder_class;



More information about the ffmpeg-devel mailing list