From: bcheng <code@ffmpeg.org> To: ffmpeg-devel@ffmpeg.org Subject: [FFmpeg-devel] [PATCH] vulkan_vp9: Fix frame threading (PR #20176) Date: Fri, 8 Aug 2025 15:48:15 +0300 (EEST) Message-ID: <20250808124815.0CB6668CCEE@ffbox0-bg.ffmpeg.org> (raw) PR #20176 opened by bcheng URL: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/20176 Patch URL: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/20176.patch The original cleanup of frame_id_alloc_mask was done in free_frame_priv which may be called after the start_frame for the next few frames, causing the frame_id slots to be exhausted. Instead, decide the in-use frame_id slots by checking the frame_id present in the DPB as we need it. From 04147adb519fd4ac9edba14628647a62fed56a00 Mon Sep 17 00:00:00 2001 From: Benjamin Cheng <ben@bcheng.me> Date: Fri, 8 Aug 2025 08:42:57 -0400 Subject: [PATCH] vulkan_vp9: Fix frame threading The original cleanup of frame_id_alloc_mask was done in free_frame_priv which may be called after the start_frame for the next few frames, causing the frame_id slots to be exhausted. Instead, decide the in-use frame_id slots by checking the frame_id present in the DPB as we need it. --- libavcodec/vulkan_vp9.c | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/libavcodec/vulkan_vp9.c b/libavcodec/vulkan_vp9.c index 82e26cede9..f8ce73dc90 100644 --- a/libavcodec/vulkan_vp9.c +++ b/libavcodec/vulkan_vp9.c @@ -110,6 +110,7 @@ static int vk_vp9_start_frame(AVCodecContext *avctx, int err; int ref_count = 0; const VP9SharedContext *s = avctx->priv_data; + uint32_t frame_id_alloc_mask = 0; const VP9Frame *pic = &s->frames[CUR_FRAME]; FFVulkanDecodeContext *dec = avctx->internal->hwaccel_priv_data; @@ -118,17 +119,24 @@ static int vk_vp9_start_frame(AVCodecContext *avctx, VP9VulkanDecodePicture *ap = pic->hwaccel_picture_private; FFVulkanDecodePicture *vp = &ap->vp; + /* Use the current frame_ids in ref_frames[] to decide occupied frame_ids */ + for (int i = 0; i < STD_VIDEO_VP9_NUM_REF_FRAMES; i++) { + const VP9VulkanDecodePicture* rp = s->ref_frames[i].hwaccel_picture_private; + if (rp) + frame_id_alloc_mask |= 1 << rp->frame_id; + } + if (!ap->frame_id_set) { unsigned slot_idx = 0; for (unsigned i = 0; i < 32; i++) { - if (!(dec->frame_id_alloc_mask & (1 << i))) { + if (!(frame_id_alloc_mask & (1 << i))) { slot_idx = i; break; } } ap->frame_id = slot_idx; ap->frame_id_set = 1; - dec->frame_id_alloc_mask |= (1 << slot_idx); + frame_id_alloc_mask |= (1 << slot_idx); } for (int i = 0; i < STD_VIDEO_VP9_REFS_PER_FRAME; i++) { @@ -338,10 +346,6 @@ static void vk_vp9_free_frame_priv(AVRefStructOpaque _hwctx, void *data) AVHWDeviceContext *hwctx = _hwctx.nc; VP9VulkanDecodePicture *ap = data; - /* Workaround for a spec issue. */ - if (ap->frame_id_set) - ap->dec->frame_id_alloc_mask &= ~(1 << ap->frame_id); - /* Free frame resources, this also destroys the session parameters. */ ff_vk_decode_free_frame(hwctx, &ap->vp); } -- 2.49.1 _______________________________________________ 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".
reply other threads:[~2025-08-08 12:48 UTC|newest] Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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=20250808124815.0CB6668CCEE@ffbox0-bg.ffmpeg.org \ --to=code@ffmpeg.org \ --cc=ffmpeg-devel@ffmpeg.org \ /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