[FFmpeg-devel] [PATCH 1/5] avfilter: tighten semantics on hw_device_ctx

Anton Khirnov anton at khirnov.net
Fri Feb 9 18:53:33 EET 2024


Quoting Niklas Haas (2024-02-09 15:53:45)
> From: Niklas Haas <git at haasn.dev>
> 
> Currently, such filters defer hardware device initialization to
> query_formats(), which is not really the correct place to have it. It
> would be far more logical for these filters to create the hardware
> context at init time, and error out otherwise.
> 
> By contrast, filters which merely receive or process hardware frames
> typically do this at link config time, because they do not need access
> to the hwframe specifics in order to query supported formats.
> 
> The intention here is to specifically stop creating hardware devices in
> query_formats.
> ---
>  libavfilter/avfilter.h | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
> 
> diff --git a/libavfilter/avfilter.h b/libavfilter/avfilter.h
> index 246d000251..b6adcf2473 100644
> --- a/libavfilter/avfilter.h
> +++ b/libavfilter/avfilter.h
> @@ -464,7 +464,8 @@ struct AVFilterContext {
>       *
>       * May be set by the caller on filters flagged with AVFILTER_FLAG_HWDEVICE
>       * before initializing the filter with avfilter_init_str() or
> -     * avfilter_init_dict().
> +     * avfilter_init_dict(). *Must* be set for filters which do not have another
> +     * way of obtaining a hardware device context (e.g. from an input link).

This now reads as if the user is required to set this field for any
AVFILTER_FLAG_HWDEVICE filter, which is not true.

IMO the text already requires callers to set it before init, so there's
no need to change anything.

-- 
Anton Khirnov


More information about the ffmpeg-devel mailing list