From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org [79.124.17.100]) by master.gitmailbox.com (Postfix) with ESMTP id BB945477FA for ; Fri, 22 Sep 2023 20:40:31 +0000 (UTC) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 9235068C926; Fri, 22 Sep 2023 23:40:28 +0300 (EEST) Received: from out-200.mta1.migadu.com (out-200.mta1.migadu.com [95.215.58.200]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 369F268C828 for ; Fri, 22 Sep 2023 23:40:22 +0300 (EEST) X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. To: ffmpeg-devel@ffmpeg.org Date: Fri, 22 Sep 2023 16:40:09 -0400 Message-ID: <20230922204009.188847-1-ben@bcheng.me> MIME-Version: 1.0 X-Migadu-Flow: FLOW_OUT Subject: [FFmpeg-devel] [PATCH] vulkan_h264: fix long-term ref handling X-BeenThere: ffmpeg-devel@ffmpeg.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: FFmpeg development discussions and patches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , From: Benjamin Cheng via ffmpeg-devel Reply-To: FFmpeg development discussions and patches Cc: Benjamin Cheng Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" Archived-At: List-Archive: List-Post: 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. --- libavcodec/vulkan_h264.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/libavcodec/vulkan_h264.c b/libavcodec/vulkan_h264.c index 32ef32d640..4135188e7a 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) { -- 2.42.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".