diff mbox series

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

Message ID 20240209145349.104511-1-ffmpeg@haasn.xyz
State New
Headers show
Series [FFmpeg-devel,1/5] avfilter: tighten semantics on hw_device_ctx | expand

Checks

Context Check Description
yinshiyou/make_loongarch64 success Make finished
yinshiyou/make_fate_loongarch64 success Make fate finished
andriy/make_x86 success Make finished
andriy/make_fate_x86 success Make fate finished

Commit Message

Niklas Haas Feb. 9, 2024, 2:53 p.m. UTC
From: Niklas Haas <git@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(-)

Comments

Anton Khirnov Feb. 9, 2024, 4:53 p.m. UTC | #1
Quoting Niklas Haas (2024-02-09 15:53:45)
> From: Niklas Haas <git@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.
diff mbox series

Patch

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).
      */
     AVBufferRef *hw_device_ctx;