From patchwork Fri Sep 22 20:40:09 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Benjamin Cheng X-Patchwork-Id: 43875 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:38a7:b0:15d:8365:d4b8 with SMTP id n39csp1072365pzf; Fri, 22 Sep 2023 13:40:33 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGLCnKnG9uZE/pXj+DOpEicSzsNoK736vHRokcmIj8EzC8RpregKlFod+ZrtZdHj06aa4Vk X-Received: by 2002:a17:907:7759:b0:9a5:d16b:6631 with SMTP id kx25-20020a170907775900b009a5d16b6631mr332568ejc.70.1695415232917; Fri, 22 Sep 2023 13:40:32 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1695415232; cv=none; d=google.com; s=arc-20160816; b=wAF6FDExfh3AuR4ks1trTBDjdrBrqxi/+k4Bie1/olIXOLlusTLzv9BcAPPtx0Uh2R XyCH9nB/6oFOzMproBmsBoTd0gYOxmz7HOeNV+CTl4hacGunns/jyiaBWKs95Wt6kwpT 1VL63mwhIS7rGRPwuw2gs6fP7DpiQRmxLFgjYTrxBi6/LOgGAjsmUa1gt96IIHccGk5e +rWGe44aorOsOCd8NS7fRjfHEfFRcdBKgoHjwqw9isX7kcFeUNT4PXeUen8btfyKmJYJ OsJZm2pEm6gZFbB/eso1MF3R0WcpaLDT3ydUrdPGM+hkiwBFqci73OoBMiNu1ZCRZbS+ CwzA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:cc:reply-to:from :list-subscribe:list-help:list-post:list-archive:list-unsubscribe :list-id:precedence:subject:mime-version:message-id:date:to :delivered-to; bh=wO1Ly4yuQULgemGc2Yl78t/7KJE0kjkb6y1kXxh9n8w=; fh=gclhhGXccg6u5Ag9tYQBjkHCTtwdm1Rs9cVW3gQSMVo=; b=LwP2hPUnCnBGWg/tYLm7Ac3ERry10OhPBpqDeYEnuAeQ1mzhdsBWornMQNoUNl+VMy G+RV9OIr+PLJ8kQGvsi51HxrbvkphdNrcC2xdlxoe1bSE9WyXThtStZZeeBFZN6rfJ3p PS4iJM+dkOw+fSsMN6Zlo7cR8yrdehsfKApJjZRagq88/JeDnmr6LHxr95K82ovZiijO pzSKLZAOn6qm/wCv0PfGu4WPnMvJVjTJTmZIJXYit6iyA1eOJXocdIyGiswuP17pviMH 1PJedR8Bik9kVawIFGj9yZW3jl4QP9y09OPDZUR88HbnRUs6+qrXoNA4rS9ovRoZ4JfV NliQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) smtp.mailfrom=ffmpeg-devel-bounces@ffmpeg.org Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id t4-20020a1709064f0400b0099233867740si4185800eju.144.2023.09.22.13.40.32; Fri, 22 Sep 2023 13:40:32 -0700 (PDT) Received-SPF: pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) client-ip=79.124.17.100; Authentication-Results: mx.google.com; spf=pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) smtp.mailfrom=ffmpeg-devel-bounces@ffmpeg.org Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id CF4F868C939; Fri, 22 Sep 2023 23:40:28 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org 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: , X-Patchwork-Original-From: Benjamin Cheng via ffmpeg-devel From: Benjamin Cheng Reply-To: FFmpeg development discussions and patches Cc: Benjamin Cheng Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" X-TUID: L4qnTrsbPv9w 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) {