From patchwork Mon Apr 26 03:03: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: 27410 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a6b:5014:0:0:0:0:0 with SMTP id e20csp3598089iob; Sun, 25 Apr 2021 20:07:20 -0700 (PDT) X-Google-Smtp-Source: ABdhPJy0/E4iQ38+IKhMkAL2bEITZYXvyjRrI5qmxjTbPYWMG/ki6urTPx1knvj8o9+l/8dlgvGe X-Received: by 2002:aa7:db14:: with SMTP id t20mr18114933eds.311.1619406439840; Sun, 25 Apr 2021 20:07:19 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1619406439; cv=none; d=google.com; s=arc-20160816; b=aTUfaUVFfHo3B55jdd6TKn2o5982FNwb5z188svFOxi7dgiVN1brIc8OF/Z5Xq49Vc AYxt6UZpTzvVp8EZ+yoaK3RI6atALre5z6DZzIb8esediGNU98ytejPpEAKZYVgfSAJD jd+PI4mLgubzZ9mkmq37vVVdf5P2DVLGcT7SXNljZSdhMiGH2PbEPFTIGw/VaDExJF5V rMOZBWXoF2LPrAjnRE0UxTiatqtV4+Lk3YXkqv+15AvIrZu9MGagoYtErniQ3ZWDCc3i U1kHaXA2hZdKLnuTNt20T0vNG+8N8Ii2GFHiF/UA6q3Rcs6wpKeApNeHM7CJ3xWNmaxr r3zg== 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 :list-subscribe:list-help:list-post:list-archive:list-unsubscribe :list-id:precedence:subject:mime-version:message-id:date:to:from :ironport-sdr:ironport-sdr:delivered-to; bh=ZkBfnrTxt37lVcnJWPkbNv3Mm0TS/HJTrJ3UvonN+to=; b=HKhCMT7LMpTFyrbrNnUUK0KSAiZirWiBgXWIXXQn8JVWRk+k/d6fyLszZk+Djc5f3d H13E9KhJRxeKKRiH0RRrUJO3J8SwPUmIJnP51Xvu34H9lDg1NMd6J/QI2znZxtWLoqrU V6/Bbh1KVtbxDVBEXEA/2Rzz6wRhXC0ex0xKDGx9B48Zv5sSPJmG0f7FgxoEnd6CxWLv iK3t3uB/jlI07yjjZu3MyKB9/WLhauhnIe/Sisli3tUKBvknIL6RAaVVRRmDXyqVe0XV AzLSU2/sSQ+Ms81x9VSwJtikB6QdFcg09E9umviRK+/G4P/6ICBNil6ooG2T718Xh7+h 96nw== 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id r17si11902248ejc.193.2021.04.25.20.07.19; Sun, 25 Apr 2021 20:07:19 -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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id C69FC68994E; Mon, 26 Apr 2021 06:07:15 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mga02.intel.com (mga02.intel.com [134.134.136.20]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 9667C6891E7 for ; Mon, 26 Apr 2021 06:07:08 +0300 (EEST) IronPort-SDR: S91JIWuZ91EsR8dp9zLN73Q/hcVz6qSD4SzeMFdY7zbpG84Nc3cXrUNmYOHtjQoKLmlr4zmBa4 qgYcxiE+c8kg== X-IronPort-AV: E=McAfee;i="6200,9189,9965"; a="183406439" X-IronPort-AV: E=Sophos;i="5.82,251,1613462400"; d="scan'208";a="183406439" Received: from fmsmga008.fm.intel.com ([10.253.24.58]) by orsmga101.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 25 Apr 2021 20:07:04 -0700 IronPort-SDR: HoOo7KMXq7cPcQiiChGcjAUX49CkJsrQiLHMFh36izMLWbzINqAw0vy6q5EUr05TPJ9pUXqekD SEVgzwKYlDeg== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.82,251,1613462400"; d="scan'208";a="422435033" Received: from chenwenbin-z390-aorus-ultra.sh.intel.com ([10.239.35.3]) by fmsmga008.fm.intel.com with ESMTP; 25 Apr 2021 20:07:03 -0700 From: wenbin.chen@intel.com To: ffmpeg-devel@ffmpeg.org Date: Mon, 26 Apr 2021 11:03:39 +0800 Message-Id: <20210426030341.3274799-1-wenbin.chen@intel.com> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 1/3] libavcodec/qsvdec: reinit decoder according to decode() return value 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: "Chen,Wenbin" Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" X-TUID: fzQS8Ni2DAXP From: "Chen,Wenbin" FFmpeg-qsv decoder reinit codec when width and height change, but there are not only resolution change need to reinit codec. I change it to use return value from DecodeFrameAsync() to decide whether decoder need to be reinitialized. Signed-off-by Wenbin Chen Signed-off-by Guangxin Xu --- libavcodec/qsvdec.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/libavcodec/qsvdec.c b/libavcodec/qsvdec.c index 5f2e641373..88232f5d8d 100644 --- a/libavcodec/qsvdec.c +++ b/libavcodec/qsvdec.c @@ -481,6 +481,13 @@ static int qsv_decode(AVCodecContext *avctx, QSVContext *q, } while (ret == MFX_WRN_DEVICE_BUSY || ret == MFX_ERR_MORE_SURFACE); + if (ret == MFX_ERR_INCOMPATIBLE_VIDEO_PARAM) { + q->reinit_flag = 1; + av_log(avctx, AV_LOG_DEBUG, "Video parameter change\n"); + av_freep(&sync); + return 0; + } + if (ret != MFX_ERR_NONE && ret != MFX_ERR_MORE_DATA && ret != MFX_WRN_VIDEO_PARAM_CHANGED && @@ -632,9 +639,9 @@ static int qsv_process_data(AVCodecContext *avctx, QSVContext *q, ret = qsv_decode_header(avctx, q, pkt, pix_fmt, ¶m); - if (ret >= 0 && (q->orig_pix_fmt != ff_qsv_map_fourcc(param.mfx.FrameInfo.FourCC) || + if (q->reinit_flag || (ret >= 0 && (q->orig_pix_fmt != ff_qsv_map_fourcc(param.mfx.FrameInfo.FourCC) || avctx->coded_width != param.mfx.FrameInfo.Width || - avctx->coded_height != param.mfx.FrameInfo.Height)) { + avctx->coded_height != param.mfx.FrameInfo.Height))) { AVPacket zero_pkt = {0}; if (q->buffered_count) {