* [FFmpeg-devel] [PATCH] vulkan_vp9: Fix frame threading (PR #20176)
@ 2025-08-08 12:48 bcheng
0 siblings, 0 replies; only message in thread
From: bcheng @ 2025-08-08 12:48 UTC (permalink / raw)
To: ffmpeg-devel
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".
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2025-08-08 12:48 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2025-08-08 12:48 [FFmpeg-devel] [PATCH] vulkan_vp9: Fix frame threading (PR #20176) bcheng
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