PR #25908 opened by nyanmisaka URL: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/25908 Patch URL: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/25908.patch
# Summary of changes When the decoder parameters change and the filter graph is reinitialized, `fps.last_frame` retains a reference to a frame from the previous graph. This keeps its associated `AVHWFramesContext` alive and prevents the underlying hardware frame pool from being destroyed. This can lead to leaks or crashes, for example, in the vaapi->hwmap->vulkan pipeline. Fixes 9196be2 Signed-off-by: nyanmisaka <[email protected]> >From bafb7370f22789647a66d8fff3e98d2148664d7b Mon Sep 17 00:00:00 2001 From: nyanmisaka <[email protected]> Date: Tue, 10 Nov 2026 17:03:35 +0800 Subject: [PATCH] fftools/ffmpeg_filter: unref the last_frame on filter graph cleanup When the decoder parameters change and the filter graph is reinitialized, `fps.last_frame` retains a reference to a frame from the previous graph. This keeps its associated `AVHWFramesContext` alive and prevents the underlying hardware frame pool from being destroyed. This can lead to leaks or crashes, for example, in the vaapi->hwmap->vulkan pipeline. Fixes 9196be2 Signed-off-by: nyanmisaka <[email protected]> --- 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 32ff6648555..e30e0814785 100644 --- a/fftools/ffmpeg_filter.c +++ b/fftools/ffmpeg_filter.c @@ -2151,8 +2151,11 @@ static int configure_input_filter(FilterGraph *fg, AVFilterGraph *graph, static void cleanup_filtergraph(FilterGraph *fg, FilterGraphThread *fgt) { - for (int i = 0; i < fg->nb_outputs; i++) + for (int i = 0; i < fg->nb_outputs; i++) { fg->outputs[i]->filter = NULL; + // drop the last frame retained by FPS conversion before graph reinitialization + av_frame_unref(ofp_from_ofilter(fg->outputs[i])->fps.last_frame); + } for (int i = 0; i < fg->nb_inputs; i++) fg->inputs[i]->filter = NULL; avfilter_graph_free(&fgt->graph); -- 2.54.0 _______________________________________________ ffmpeg-devel mailing list -- [email protected] To unsubscribe send an email to [email protected]
