From patchwork Fri Mar 12 02:44:06 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Wenbin Chen X-Patchwork-Id: 26347 Return-Path: X-Original-To: patchwork@ffaux-bg.ffmpeg.org Delivered-To: patchwork@ffaux-bg.ffmpeg.org Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org [79.124.17.100]) by ffaux.localdomain (Postfix) with ESMTP id 866B244AD3E for ; Fri, 12 Mar 2021 04:46:05 +0200 (EET) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 5E29268AF45; Fri, 12 Mar 2021 04:46:05 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mga18.intel.com (mga18.intel.com [134.134.136.126]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 5DFE668AF40 for ; Fri, 12 Mar 2021 04:45:58 +0200 (EET) IronPort-SDR: 1/8IHD23lBOtFied/J6eyrusTcQNOidjm9X7lnlK2ZR2ukJcd+iwnw252HuMuH22twTXxAwMcw Nb0J1GuSVG3A== X-IronPort-AV: E=McAfee;i="6000,8403,9920"; a="176365514" X-IronPort-AV: E=Sophos;i="5.81,241,1610438400"; d="scan'208";a="176365514" Received: from fmsmga008.fm.intel.com ([10.253.24.58]) by orsmga106.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 11 Mar 2021 18:45:54 -0800 IronPort-SDR: uzK5E46m5E5HSMOq1ImZtJkkRQwVwXKowTccy8pS62sNhseprIPzZsFoDDoezNEUSCrHEHrK7c wUw3SfvnwRsg== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.81,241,1610438400"; d="scan'208";a="404284263" Received: from unknown (HELO chenwenbin-Z390-AORUS-ULTRA.sh.intel.com) ([10.239.35.3]) by fmsmga008.fm.intel.com with ESMTP; 11 Mar 2021 18:45:52 -0800 From: wenbin.chen@intel.com To: ffmpeg-devel@ffmpeg.org Date: Fri, 12 Mar 2021 10:44:06 +0800 Message-Id: <20210312024406.642094-1-wenbin.chen@intel.com> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH V2] libavcodec/qsvdec.c: using queue count to unref frame X-BeenThere: ffmpeg-devel@ffmpeg.org X-Mailman-Version: 2.1.20 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: "Chen,Wenbin" Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" From: "Chen,Wenbin" MSDK vc1 and av1 sometimes output frame into the same suface, but ffmpeg-qsv assume the surface will be used only once, so it will unref the frame when it receives the output surface. Now change it to unref frame according to queue count. Signed-off-by Wenbin Chen --- libavcodec/qsvdec.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/libavcodec/qsvdec.c b/libavcodec/qsvdec.c index 5f2e641373..3abd7bd4a2 100644 --- a/libavcodec/qsvdec.c +++ b/libavcodec/qsvdec.c @@ -513,7 +513,7 @@ static int qsv_decode(AVCodecContext *avctx, QSVContext *q, return AVERROR_BUG; } - out_frame->queued = 1; + out_frame->queued += 1; av_fifo_generic_write(q->async_fifo, &out_frame, sizeof(out_frame), NULL); av_fifo_generic_write(q->async_fifo, &sync, sizeof(sync), NULL); } else { @@ -526,7 +526,7 @@ static int qsv_decode(AVCodecContext *avctx, QSVContext *q, av_fifo_generic_read(q->async_fifo, &out_frame, sizeof(out_frame), NULL); av_fifo_generic_read(q->async_fifo, &sync, sizeof(sync), NULL); - out_frame->queued = 0; + out_frame->queued -= 1; if (avctx->pix_fmt != AV_PIX_FMT_QSV) { do {