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 AFB9E48607 for ; Thu, 11 Jan 2024 06:32:37 +0000 (UTC) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 1592568CF16; Thu, 11 Jan 2024 08:32:35 +0200 (EET) Received: from mgamail.intel.com (mgamail.intel.com [134.134.136.20]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 6564F68CCBD for ; Thu, 11 Jan 2024 08:32:27 +0200 (EET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1704954752; x=1736490752; h=from:to:cc:subject:date:message-id:mime-version: content-transfer-encoding; bh=gg1kjhtO9QWKqScqFRHwbMGXg1E2yXQr0tRzjjEUQo8=; b=MfwkfxZ8/oYIODeJX0vR92pq5L2OBkuJFw/VlVeMLbPQwTarKSMkHHNa S7SfCgX0jJIjsbg7cxUjMC3J9Mjzk806mZN+MPVdpr/vsIKLuIyO6grr0 DLlA4c4aOmbKirnMzgnkTJusKGlsSlbRX6k4SM/9doXJhH+lGGZZ0Zsdw 9UKf8CERvZLxZHprNZt2g/FsHYUDawHPRI4j05gbtgHulPyf4c9mc+Sak KE5aHZRHet80/Y0Q90L3hWwBhSGUTF9LlBwWRFNmmj9ny48eMQ179JNkR 1side8LPxQ2CqoiYpvRCsTIwUjTNTqeulmpYe1uKL7NDNiiu2AZ2xCDKJ Q==; X-IronPort-AV: E=McAfee;i="6600,9927,10949"; a="389192328" X-IronPort-AV: E=Sophos;i="6.04,185,1695711600"; d="scan'208";a="389192328" Received: from orviesa001.jf.intel.com ([10.64.159.141]) by orsmga101.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 10 Jan 2024 22:32:23 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.04,185,1695711600"; d="scan'208";a="30891909" Received: from desktop-qn7n0nf.sh.intel.com (HELO localhost.localdomain) ([10.239.160.66]) by orviesa001.jf.intel.com with ESMTP; 10 Jan 2024 22:32:23 -0800 From: tong1.wu-at-intel.com@ffmpeg.org To: ffmpeg-devel@ffmpeg.org Date: Thu, 11 Jan 2024 14:31:20 +0800 Message-ID: <20240111063121.1467-1-tong1.wu@intel.com> X-Mailer: git-send-email 2.41.0.windows.1 MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 1/2] avcodec/d3d12va_decode: check existance before assigning a new index 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: , Reply-To: FFmpeg development discussions and patches Cc: Tong Wu 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: From: Tong Wu Fixes #10759. It can happen in H.264, MPEG2, VC1 that the current frame resource memory is already in ref_resource. For example, for a interlaced frame, the same curr memory is passed twice. For the second time it could possibly reference itself. When this happens the curr is already given an index and in ref_resources. When the reference frame index is required, we should check the existance in the ref_resources first before assigning a new index for it. Signed-off-by: Tong Wu --- libavcodec/d3d12va_decode.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/libavcodec/d3d12va_decode.c b/libavcodec/d3d12va_decode.c index c5c599675e..a6f40236d1 100644 --- a/libavcodec/d3d12va_decode.c +++ b/libavcodec/d3d12va_decode.c @@ -62,14 +62,14 @@ unsigned ff_d3d12va_get_surface_index(const AVCodecContext *avctx, if (!res) goto fail; - if (!curr) { - for (i = 0; i < ctx->max_num_ref; i++) { - if (ctx->ref_resources[i] && res == ctx->ref_resources[i]) { - ctx->used_mask |= 1 << i; - return i; - } + for (i = 0; i < ctx->max_num_ref; i++) { + if (ctx->ref_resources[i] && res == ctx->ref_resources[i]) { + ctx->used_mask |= 1 << i; + return i; } - } else { + } + + if (curr) { for (i = 0; i < ctx->max_num_ref; i++) { if (!((ctx->used_mask >> i) & 0x1)) { ctx->ref_resources[i] = res; -- 2.41.0.windows.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".