From patchwork Thu Mar 11 05:26:39 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Wenbin Chen X-Patchwork-Id: 26338 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 8DB8544AD63 for ; Thu, 11 Mar 2021 07:28:43 +0200 (EET) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 5CA6168AB96; Thu, 11 Mar 2021 07:28:43 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mga07.intel.com (mga07.intel.com [134.134.136.100]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 5FD02689E47 for ; Thu, 11 Mar 2021 07:28:36 +0200 (EET) IronPort-SDR: C2M37viFsIOc1U08kVv9ZS3bTd5SSDiBpPXBxKpOe/vSedvZBipun6WNK5yHF0iAPYqoh/RXZr ynBl2NPqkMgw== X-IronPort-AV: E=McAfee;i="6000,8403,9919"; a="252632598" X-IronPort-AV: E=Sophos;i="5.81,239,1610438400"; d="scan'208";a="252632598" Received: from fmsmga006.fm.intel.com ([10.253.24.20]) by orsmga105.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 10 Mar 2021 21:28:34 -0800 IronPort-SDR: 8BruSq19HXDktvmjulzaj7FzuW40yo97QfOrwsyMb+uSkKmbzvO0ZPZhqdygbKbqnc7RNVeD9z h6Fp+GagctVg== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.81,239,1610438400"; d="scan'208";a="600083434" Received: from unknown (HELO chenwenbin-Z390-AORUS-ULTRA.sh.intel.com) ([10.239.35.3]) by fmsmga006.fm.intel.com with ESMTP; 10 Mar 2021 21:28:32 -0800 From: wenbin.chen@intel.com To: ffmpeg-devel@ffmpeg.org Date: Thu, 11 Mar 2021 13:26:39 +0800 Message-Id: <20210311052639.488078-1-wenbin.chen@intel.com> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH] 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 outpur 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 d10f90a0db..e073e10699 100644 --- a/libavcodec/qsvdec.c +++ b/libavcodec/qsvdec.c @@ -470,7 +470,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 { @@ -483,7 +483,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 {