[FFmpeg-devel] [PATCH 03/13] lavc: Use hardware config information in ff_get_format()

Mark Thompson sw at jkqxz.net
Sat Nov 18 21:15:32 EET 2017


On 18/11/17 18:47, Mark Thompson wrote:
> This removes the dependency that hardware pixel formats previously had on
> AVHWAccel instances, meaning only those which actually do something need
> exist after this patch.
> 
> Also updates avcodec_default_get_format() to be able to choose hardware
> formats if either a matching device has been supplied or no additional
> external configuration is required, and avcodec_get_hw_frames_parameters()
> to use the hardware config rather than searching the old hwaccel list.
> 
> The FF_CODEC_CAP_HWACCEL_REQUIRE_CLASS mechanism is deleted because it
> no longer does anything (the codec already contains the pointers to the
> matching hwaccels).
> ---
>  libavcodec/avcodec.h  |   7 --
>  libavcodec/cuviddec.c |   2 -
>  libavcodec/decode.c   | 285 +++++++++++++++++++++++++++++++++++---------------
>  libavcodec/internal.h |  11 +-
>  4 files changed, 208 insertions(+), 97 deletions(-)
> 
> diff --git a/libavcodec/decode.c b/libavcodec/decode.c
> index a7f1e23fc2..8b2bec1ce9 100644
> --- a/libavcodec/decode.c
> +++ b/libavcodec/decode.c
> ...
> +        for (i = 0;; i++) {
> +            hw_config = avctx->codec->hw_configs[i];
> +            if (!hw_config)
> +                break;
> +            if (hw_config->public.pix_fmt == user_choice)
>                  break;
> -            }
>          }

This needs to check for avctx->codec->hw_configs being non-NULL, and immediately fall into the below case if it isn't.  (Stupidly I was only testing with codecs where it's set...)

>  
> -        if (!setup_hwaccel(avctx, ret, desc->name))
> +        if (!hw_config) {
> +            // No config available, so no extra setup required.
> +            ret = user_choice;
>              break;
> +        }

Fixed locally.

- Mark


More information about the ffmpeg-devel mailing list