[FFmpeg-devel] [PATCH 2/5] fftools/ffmpeg_filter: provide hwctx when probing graph

Anton Khirnov anton at khirnov.net
Fri Feb 9 19:12:18 EET 2024


Quoting Niklas Haas (2024-02-09 15:53:46)
> From: Niklas Haas <git at haasn.dev>
> 
> Otherwise, filters that depend on a hw_device_ctx being present at
> init() time would fail configuring under the semantics outlined in the
> previous commit.
> ---
>  fftools/ffmpeg_filter.c | 5 ++++-
>  1 file changed, 4 insertions(+), 1 deletion(-)
> 
> diff --git a/fftools/ffmpeg_filter.c b/fftools/ffmpeg_filter.c
> index 38ddd1963a..46e1d790e7 100644
> --- a/fftools/ffmpeg_filter.c
> +++ b/fftools/ffmpeg_filter.c
> @@ -931,6 +931,7 @@ int fg_create(FilterGraph **pfg, char *graph_desc, Scheduler *sch)
>  
>      AVFilterInOut *inputs, *outputs;
>      AVFilterGraph *graph;
> +    AVBufferRef *hw_device;
>      int ret = 0;
>  
>      fgp = allocate_array_elem(&filtergraphs, sizeof(*fgp), &nb_filtergraphs);
> @@ -961,7 +962,9 @@ int fg_create(FilterGraph **pfg, char *graph_desc, Scheduler *sch)
>          return AVERROR(ENOMEM);;
>      graph->nb_threads = 1;
>  
> -    ret = graph_parse(graph, fgp->graph_desc, &inputs, &outputs, NULL);
> +    hw_device = hw_device_for_filter();

This function may be called before any decoders are opened, and if I'm
reading the code right, opening decoders may creat new globally
available devices which are then returned from hw_device_for_filter().

It should probably be ok to cache the device you get here in
FilterGraphPriv to ensure you always use the same device.

-- 
Anton Khirnov


More information about the ffmpeg-devel mailing list