From patchwork Fri Mar 18 06:25:09 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Chen, Wenbin" X-Patchwork-Id: 34832 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6838:3486:0:0:0:0 with SMTP id ek6csp1536883nkb; Thu, 17 Mar 2022 23:25:54 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzZfE8DqLcBEnEmE4cZafvtMMlzjaavae938pGV3+P7sqstrfzHdNLstUO9oAan36/rKden X-Received: by 2002:a05:6402:520a:b0:417:f20c:6b5a with SMTP id s10-20020a056402520a00b00417f20c6b5amr8040148edd.11.1647584753883; Thu, 17 Mar 2022 23:25:53 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1647584753; cv=none; d=google.com; s=arc-20160816; b=mgRWTkGkQftq2xISfECuGYraFO2JiK/caYN9MSgNePigob1LUfO7xTct9Dz6J5vmG8 F9vLuXUg/BWeXoVKKWiqZ5fBg8VsdJlTmESAUf3/FcjiT5KNr4v9NNMlaeMfJfET4sVY EzD66UvpbN+rWdAPatTCLfBO7QnDhKXPnL4XlLuLxQrq+OnxUz25DQA0pXKVC8uKskU2 exN77GeW/5iWx3noxmWHckJLtNxchVmu5omxEqvKoMNibcSBH7WTvYSY59+WenBz4Vx+ UPkTNRCjSWa5zEKT9fnAJiA31DoDfR6WOswDomIesfKn9x0saj5jq89gHxWmVmSPH4Hs 3m5Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:reply-to:list-subscribe :list-help:list-post:list-archive:list-unsubscribe:list-id :precedence:subject:mime-version:message-id:date:to:from :dkim-signature:delivered-to; bh=7F6gHWZDfNXfU3KyV3Pkg9/9cVGN03zVudSvUcdkWIA=; b=BhhN7b6JOS4uxZAVJZfN5uqefSYgdJfqfNM3frLzWp0A56wDQIwbggKM4vADSTwn7I yfasp4KLaqrz7yByt809SzgvGCPIQcfbXxMrVghCDyb4TZgaLs2aoJdYB4Y7+Ca8ytuR zdkSGbPKiXeFu9smmdgJq+JPdiPxFGCQO+bi0iu89cFef+sgeNhO1akKqg2/zltsIMx+ fnLKXMzecBBGbcDWlV3EFS0NQgSAzlq5pelDtwiZQkJ0AxeHU3WFiICAousGuDJBg7rh TyRrE15MXUTDvbfRj2QIv/LYdGSA2SnuLpVK/+XYU82ybMyOIiB+Hh8rdQRD8RB+IYhb qmFA== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@intel.com header.s=Intel header.b=CagY8kET; 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 s9-20020a17090699c900b006df76385c27si548976ejn.199.2022.03.17.23.25.53; Thu, 17 Mar 2022 23:25:53 -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; dkim=neutral (body hash did not verify) header.i=@intel.com header.s=Intel header.b=CagY8kET; 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 10D9968A3B7; Fri, 18 Mar 2022 08:25:49 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mga14.intel.com (mga14.intel.com [192.55.52.115]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 1EABF68A3B7 for ; Fri, 18 Mar 2022 08:25:41 +0200 (EET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1647584747; x=1679120747; h=from:to:subject:date:message-id:mime-version: content-transfer-encoding; bh=BerfIXDIeuTtBe1q0UpnDr1OhxJPGK/3YsaH2i+eROE=; b=CagY8kETBhNDaXIDBRatK2VroNLhNNACwNjFXL116IV9oiMgnv4+ZjcW RHy4qA7LWgtwtwVHfXSYGHO8Zv1kIK5/Ot6fR4T4aYT4BriboRdxhhGTU tBRXmGDZsO0aK/0Ey/Oxp61O26vyMWtBvenURR8LixPcdiW5tuhnkmFQs T6WxbzrmsS6R0ZksZg553pWJoppYR2s41EMxtbLt1EmVt2ZG18n6mppfD ESnZ/7EgKjrNW/kBkSbYkowAfVXzobAQtL1koojFmkqke9H8MHA6eaSZE 9kZt4evrs9ktU1kjiNwUCGXpuH1bTHir+zJTSlDaBJUcmOR3WBACPVJLK w==; X-IronPort-AV: E=McAfee;i="6200,9189,10289"; a="257252882" X-IronPort-AV: E=Sophos;i="5.90,191,1643702400"; d="scan'208";a="257252882" Received: from fmsmga005.fm.intel.com ([10.253.24.32]) by fmsmga103.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 17 Mar 2022 23:25:38 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.90,191,1643702400"; d="scan'208";a="822049459" Received: from wenbin-z390-aorus-ultra.sh.intel.com ([10.239.35.4]) by fmsmga005.fm.intel.com with ESMTP; 17 Mar 2022 23:25:38 -0700 From: Wenbin Chen To: ffmpeg-devel@ffmpeg.org Date: Fri, 18 Mar 2022 14:25:09 +0800 Message-Id: <20220318062511.382951-1-wenbin.chen@intel.com> X-Mailer: git-send-email 2.32.0 MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH v2 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 Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" X-TUID: MjaieBjEfAe8 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 1b5bf85cb6..0b5e416867 100644 --- a/libavcodec/qsvdec.c +++ b/libavcodec/qsvdec.c @@ -630,6 +630,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 && @@ -782,9 +789,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) {