From: Niklas Haas <ffmpeg@haasn.xyz> To: ffmpeg-devel@ffmpeg.org Cc: Niklas Haas <git@haasn.dev> Subject: [FFmpeg-devel] [PATCH 2/3] avfilter/hwupload: wait for all pending transfers on uninit() Date: Sat, 1 Mar 2025 17:46:20 +0100 Message-ID: <20250301164621.130530-2-ffmpeg@haasn.xyz> (raw) In-Reply-To: <20250301164621.130530-1-ffmpeg@haasn.xyz> From: Niklas Haas <git@haasn.dev> Uploads can be asynchronous, so we need to wait for them on unit to prevent a cyclic reference from keeping the hwfc alive indefinitely, since there is no other way for the hwfc to know when prior commands should be cleaned up. In theory, it might be possible for this to be signalled backwards by downstream consumers of the corresponding AVFrames, but this is very nontrivial as there may be multiple, or even no downstream consumers, such as in the degenerate case of: ffmpeg ... -vf hwupload -f null - Waiting for outstanding transfers to have completed explicitly in uninit is the only solution that is both robust, simple, and comes without a performance penalty. --- libavfilter/vf_hwupload.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/libavfilter/vf_hwupload.c b/libavfilter/vf_hwupload.c index 6aafac4d4d..3142aabb17 100644 --- a/libavfilter/vf_hwupload.c +++ b/libavfilter/vf_hwupload.c @@ -222,6 +222,15 @@ static av_cold void hwupload_uninit(AVFilterContext *avctx) { HWUploadContext *ctx = avctx->priv; + /** + * Ensure that all outstanding asynchronous uploads are properly completed. + * This is to avoid leaking the context, because nobody else will clean up + * after the hwfc while there are still pending asynchronous transfers + * referencing it. + */ + if (ctx->hwframes_ref) + av_hwframe_transfer_wait_all(ctx->hwframes_ref, 0); + av_buffer_unref(&ctx->hwframes_ref); av_buffer_unref(&ctx->hwdevice_ref); } -- 2.47.0 _______________________________________________ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".
next prev parent reply other threads:[~2025-03-01 16:46 UTC|newest] Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top 2025-03-01 16:46 [FFmpeg-devel] [PATCH 1/3] avutil/hwcontext: add av_hwframe_transfer_wait_all() Niklas Haas 2025-03-01 16:46 ` Niklas Haas [this message] 2025-03-01 16:46 ` [FFmpeg-devel] [PATCH 3/3] avutil/hwcontext_vulkan: add frames_sync() implementation Niklas Haas
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=20250301164621.130530-2-ffmpeg@haasn.xyz \ --to=ffmpeg@haasn.xyz \ --cc=ffmpeg-devel@ffmpeg.org \ --cc=git@haasn.dev \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: link
Git Inbox Mirror of the ffmpeg-devel mailing list - see https://ffmpeg.org/mailman/listinfo/ffmpeg-devel This inbox may be cloned and mirrored by anyone: git clone --mirror https://master.gitmailbox.com/ffmpegdev/0 ffmpegdev/git/0.git # If you have public-inbox 1.1+ installed, you may # initialize and index your mirror using the following commands: public-inbox-init -V2 ffmpegdev ffmpegdev/ https://master.gitmailbox.com/ffmpegdev \ ffmpegdev@gitmailbox.com public-inbox-index ffmpegdev Example config snippet for mirrors. AGPL code for this site: git clone https://public-inbox.org/public-inbox.git