[FFmpeg-devel] [PATCH v1] avcodec/av1dec: check if hwaccel is specificed

Hendrik Leppkes h.leppkes at gmail.com
Fri Aug 27 20:09:47 EEST 2021


On Fri, Aug 27, 2021 at 1:54 PM Fei Wang <fei.w.wang at intel.com> wrote:
>
> Since av1 decoder is only available for hw acceleration. This will
> gives out more accurate information if this decoder used but doesn't
> specificed a hwaccel.
>
> For example:
> ffmpeg -c:v av1 -i INPUT OUTPUT
>
> Signed-off-by: Fei Wang <fei.w.wang at intel.com>
> ---
> 1. This is improvement of patch for:
> https://patchwork.ffmpeg.org/project/ffmpeg/list/?series=4660
>
>  libavcodec/av1dec.c | 17 ++++++++++++-----
>  1 file changed, 12 insertions(+), 5 deletions(-)
>
> diff --git a/libavcodec/av1dec.c b/libavcodec/av1dec.c
> index a69808f7b6..58a9deeb4e 100644
> --- a/libavcodec/av1dec.c
> +++ b/libavcodec/av1dec.c
> @@ -452,15 +452,22 @@ static int get_pixel_format(AVCodecContext *avctx)
>      *fmtp++ = s->pix_fmt;
>      *fmtp = AV_PIX_FMT_NONE;
>
> -    ret = ff_thread_get_format(avctx, pix_fmts);
> -    if (ret < 0)
> -        return ret;
> -
>      /**
> -     * check if the HW accel is inited correctly. If not, return un-implemented.
> +     * check if the HW accel is specificed. If not, return un-implemented.
>       * Since now the av1 decoder doesn't support native decode, if it will be
>       * implemented in the future, need remove this check.
>       */
> +    if (!avctx->hw_device_ctx) {
> +        av_log(avctx, AV_LOG_ERROR, "The AV1 decoder requires a hw acceleration"
> +              " to be specified.\n");
> +        return AVERROR(ENOSYS);
> +    }
> +

Not every hwaccel uses a hw_device_ctx. Its still perfectly valid and
supported to use the old setup which overrides get_format/get_buffer2
and sets avctx->hwaccel_context directly.
You will not know if this is the case before get_format was called, so
you cannot pre-detect it.

Or in other words, this patch breaks my application, so its not a
valid solution.

- Hendrik


More information about the ffmpeg-devel mailing list