diff options
author | Benjamin Cheng <ben@bcheng.me> | 2023-10-13 15:10:55 -0400 |
---|---|---|
committer | Lynne <dev@lynne.ee> | 2023-10-31 21:35:23 +0100 |
commit | 4536de3769796a74ea26fcdfdae73af5e0fa8b5a (patch) | |
tree | c17042b98be10b94b8350283c6e41aedb6a2c208 | |
parent | 1e63e24c760dac0b1dc20c0d286a909206c8379c (diff) | |
download | ffmpeg-4536de3769796a74ea26fcdfdae73af5e0fa8b5a.tar.gz |
vulkan_h264: fix long-term ref handling
h->long_ref isn't guaranteed to be contiguously filled. Use the approach
from both vaapi_h264 and vdpau_h264 which goes through the 16 frames in
h->long_ref to find the LTR entries.
Fixes MR2_MW_A.264 from JVT-AVC_V1.
-rw-r--r-- | libavcodec/vulkan_h264.c | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/libavcodec/vulkan_h264.c b/libavcodec/vulkan_h264.c index 172c6c4e8e..e727aafb16 100644 --- a/libavcodec/vulkan_h264.c +++ b/libavcodec/vulkan_h264.c @@ -406,10 +406,14 @@ static int vk_h264_start_frame(AVCodecContext *avctx, } /* Fill in long-term refs */ - for (int r = 0, i = h->short_ref_count; i < h->short_ref_count + h->long_ref_count; i++, r++) { + for (int r = 0, i = h->short_ref_count; r < H264_MAX_DPB_FRAMES && + i < h->short_ref_count + h->long_ref_count; r++) { + if (!h->long_ref[r]) + continue; + dpb_slot_index = 0; - for (unsigned slot = 0; slot < H264_MAX_PICTURE_COUNT; slot++) { - if (h->long_ref[i] == &h->DPB[slot]) { + for (unsigned slot = 0; slot < 16; slot++) { + if (h->long_ref[r] == &h->DPB[slot]) { dpb_slot_index = slot; break; } @@ -422,6 +426,7 @@ static int vk_h264_start_frame(AVCodecContext *avctx, dpb_slot_index); if (err < 0) return err; + i++; } hp->h264pic = (StdVideoDecodeH264PictureInfo) { |