From patchwork Fri Oct 13 19:10:55 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Benjamin Cheng X-Patchwork-Id: 44249 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:4b15:b0:15d:8365:d4b8 with SMTP id fp21csp1208647pzb; Fri, 13 Oct 2023 12:12:25 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGj9sqiXSCSaeTaw0O6YCM8Fnys8L1Oym42y7T9N0vKqvDNt2pej/o3oilztlK3fKfpU/cE X-Received: by 2002:a5d:4443:0:b0:323:36f1:c26b with SMTP id x3-20020a5d4443000000b0032336f1c26bmr23251872wrr.6.1697224345732; Fri, 13 Oct 2023 12:12:25 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1697224345; cv=none; d=google.com; s=arc-20160816; b=iuHrSHfoc6lizSQTnn68gcO8+beRuGRaY+PS1vrbnHU8HVPV/OV8sUSEOQ8jlnGK/b LpTO4uhmHEm4N7HAFgZ9b+zLAmIEMWXv2Kz48UAHUtApC+5hdBmsXf8xq/OLA5IPdQe2 6PkmnNIBncMHyxSurjBsCWunThLj0byW9j29bi1XwYSKbbt4fgRIDblcaB6tWjmQO+sJ lvmN7bY8/n4VJrGBTICW1adwGUiyvmtTD49+N5KpOs993aDROyk8GMi4sjmDYe+tUVrT x8zjAk6KGI1eX8u5xZ3xrCx0gh3o7w34q9O83isbCseAuh/xOIDr1db/leH8xisXTO+k nTZw== 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=87DZdM9h8SSrajwcT/QLJwvW6PbnY5dKssJAu9gnWZc=; fh=gclhhGXccg6u5Ag9tYQBjkHCTtwdm1Rs9cVW3gQSMVo=; b=NOBSL492stm72j97dWPEkSzdataLhgJ2F669XhsrqkRqgB8WupB+/GVQWsWPgVJpiZ HpIF1lEMcHnLahX/K2ZUgUyUmEVNOg1GrE2tlxZzyS41iUxMHM7uFtSaHy+5pRgAJ8Cy rbf5QI1Jk2fQZSTSLW2RzBFlqugySLqxCN2Ar0nfXiGsx/JYejearVmQYC+Opdw4viGv clidekMBzyl1OXJJZtHdpRzrAP+Dv3I88SgnfbGHcUAKiDPBzDYTgFD0cDcdrCkbt4O5 A+rev9GhGhJM49XwO88C1AwhlzZu2N8COjDJE5eNdpkaydjZCB3yw+GncrL5J6mSF+Cz Tjmw== 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 z5-20020a05640240c500b0053e2b01bf0csi1482136edb.119.2023.10.13.12.12.25; Fri, 13 Oct 2023 12:12:25 -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 C518F68C945; Fri, 13 Oct 2023 22:12:21 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from out-207.mta0.migadu.com (out-207.mta0.migadu.com [91.218.175.207]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 9D4BA68C323 for ; Fri, 13 Oct 2023 22:12:14 +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, 13 Oct 2023 15:10:55 -0400 Message-ID: <20231013191054.32093-2-ben@bcheng.me> MIME-Version: 1.0 X-Migadu-Flow: FLOW_OUT Subject: [FFmpeg-devel] [PATCH v2] 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: SoOZldNNKDy6 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..1bbef7b0e8 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) {