From patchwork Thu Aug 18 06:59:07 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Chen, Wenbin" X-Patchwork-Id: 37338 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:139a:b0:8f:1db5:eae2 with SMTP id w26csp148053pzh; Thu, 18 Aug 2022 00:01:34 -0700 (PDT) X-Google-Smtp-Source: AA6agR4qeeYIzPFY/hMUX9liAfidKK+uk+ysoeaPZv2c5PpySuqFOsbFlJmpJryuEDHIUSV90wHy X-Received: by 2002:a17:907:c0e:b0:731:614:e507 with SMTP id ga14-20020a1709070c0e00b007310614e507mr1066557ejc.529.1660806094224; Thu, 18 Aug 2022 00:01:34 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1660806094; cv=none; d=google.com; s=arc-20160816; b=zeX1PX6RR6bEFP+fl+m1FFmqgTB0OvzgmaaXbVZHKTM/Yl3DlXrFhR94qaVhW9vJya 0MEp553K2gVMQVqupOA8FDWXUZNpt80AhE57d4hPhW45GH/14VC82/556KFlGZt8KdgF Z1Q3XHTH8x1Xc+WN/hw5WZXmGW6IENSaNt0ZyyQ2vK52BCc+eZuL5cK+T3CFRsDCEzXj v+eFVcT9xA/6R7GwDHRBOZECd1jfnAHlBecVUuFp0fauFTnl4AMwtfCRiUCLolEgYAb3 5Fh+ZSg6I3ZVV/lhEK7/n7FMzR7ulvsnurrTEl6lJ7xzAhzIJhYU8e46s3avYE6mRqmS LMbA== 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=J0OF0ITnXbRj1C3yOfTAPzUQZr8DSKS0Na+dX2V9/s0=; b=oPkXOCRI2kRa5PVo2g4UsyNOdm80aoOXh/670r/M3pLcxKf1CDaJZUsgCEZPNsgBSh GsOTXlwEcshk2Jgd54UA9Qgq9Nj3V0v4GU03q1lL2lXRr5kAudWlVrj1EfpqA41sX+rK zpAwhpp4fiev+fb6RjxfZBwxkI9O2DZzkX3lia9y2ELJ1+mPRGB6mV7yJVtqZ/lMuSdB vtd2WI5PUKOdTxOVONme9RBMJ/59kLXwKsAjCLLjG2Rm9ZY6eOXEMSiNgPGnP6X97lra uPvhL5ap1x8PakO0ZeBvcRJEzoYHaXM+ysK5tNy3ehchDVqIOh0tk92EzA8NfX0vUlVU 3h+g== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@intel.com header.s=Intel header.b=Kd9ugXlj; 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 hr2-20020a1709073f8200b0073096c2b51csi639233ejc.543.2022.08.18.00.01.33; Thu, 18 Aug 2022 00:01:34 -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=Kd9ugXlj; 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 4098468B985; Thu, 18 Aug 2022 10:01:29 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mga05.intel.com (mga05.intel.com [192.55.52.43]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id DFD5B68B8ED for ; Thu, 18 Aug 2022 10:01:22 +0300 (EEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1660806088; x=1692342088; h=from:to:subject:date:message-id:mime-version: content-transfer-encoding; bh=Pg4udbW+ZUvsC2fVCo+BQVq1B/5FBrft8C/FoAKFpzA=; b=Kd9ugXljOHMSXxC7yxIIKROYNFtDzilrFMW7cX1e2ZzJF7boAs5gg2qy sy9mAeLgp+qGmBVIH0WLmf++8snL3hw/p/Hkp5FghK44ZNtrc35D8kAsP ZWR2VrYAZFWXzLfk1FXTVETYuie9oOKgF2Kac+QKhdxjgfOjMhBWHvfUf N5GscuGOU/aAkYtXrIUiwtxkBH8p48hI0SaMfNF98X6Yg0UgQ2YP76Y68 AKu1rBXFCiqNOJDQih8y4jT3ximchBLEbYig709VmyFIxUG/7tkdkMB+y 5dlD9hmrbgsKobgyidtRhhEepsN595Jq1LlVF2CwEBkBO9AGHAKlX/6vf w==; X-IronPort-AV: E=McAfee;i="6500,9779,10442"; a="378975921" X-IronPort-AV: E=Sophos;i="5.93,245,1654585200"; d="scan'208";a="378975921" Received: from orsmga007.jf.intel.com ([10.7.209.58]) by fmsmga105.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 18 Aug 2022 00:01:11 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.93,245,1654585200"; d="scan'208";a="604155632" Received: from wenbin-z390-aorus-ultra.sh.intel.com ([10.239.35.4]) by orsmga007.jf.intel.com with ESMTP; 18 Aug 2022 00:01:10 -0700 From: Wenbin Chen To: ffmpeg-devel@ffmpeg.org Date: Thu, 18 Aug 2022 14:59:07 +0800 Message-Id: <20220818065912.158693-1-wenbin.chen@intel.com> X-Mailer: git-send-email 2.32.0 MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 1/6] libavcodec/qsvenc: Add max_frame_size reset support to qsv 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: waX6tGvkZwmT Signed-off-by: Wenbin Chen --- doc/encoders.texi | 4 ++++ libavcodec/qsvenc.c | 20 ++++++++++++++++++++ libavcodec/qsvenc.h | 2 ++ 3 files changed, 26 insertions(+) diff --git a/doc/encoders.texi b/doc/encoders.texi index 6d73f74196..69fa46f3ea 100644 --- a/doc/encoders.texi +++ b/doc/encoders.texi @@ -3344,6 +3344,10 @@ Following options can be used durning qsv encoding. @item @var{b_quant_offset} Supported in h264_qsv and hevc_qsv. Change these value to reset qsv codec's qp configuration. + +@item @var{max_frame_size} +Supported in h264_qsv and hevc_qsv. +Change this value to reset qsv codec's MaxFrameSize configuration. @end table @subsection H264 options diff --git a/libavcodec/qsvenc.c b/libavcodec/qsvenc.c index 4831640868..c911b81e7d 100644 --- a/libavcodec/qsvenc.c +++ b/libavcodec/qsvenc.c @@ -828,6 +828,7 @@ static int init_video_param(AVCodecContext *avctx, QSVEncContext *q) q->extco2.ExtBRC = q->extbrc ? MFX_CODINGOPTION_ON : MFX_CODINGOPTION_OFF; if (q->max_frame_size >= 0) q->extco2.MaxFrameSize = q->max_frame_size; + q->old_max_frame_size = q->max_frame_size; if (q->int_ref_type >= 0) q->extco2.IntRefType = q->int_ref_type; if (q->int_ref_cycle_size >= 0) @@ -1673,6 +1674,24 @@ static int update_qp(AVCodecContext *avctx, QSVEncContext *q) return updated; } +static int update_max_frame_size(AVCodecContext *avctx, QSVEncContext *q) +{ + int updated = 0; + + if (avctx->codec_id != AV_CODEC_ID_H264 && avctx->codec_id != AV_CODEC_ID_HEVC) + return 0; + + UPDATE_PARAM(q->old_max_frame_size, q->max_frame_size); + if (!updated) + return 0; + + q->extco2.MaxFrameSize = FFMAX(0, q->max_frame_size); + av_log(avctx, AV_LOG_DEBUG, + "Reset MaxFrameSize: %d;\n", q->extco2.MaxFrameSize); + + return updated; +} + static int update_parameters(AVCodecContext *avctx, QSVEncContext *q, const AVFrame *frame) { @@ -1682,6 +1701,7 @@ static int update_parameters(AVCodecContext *avctx, QSVEncContext *q, return 0; needReset = update_qp(avctx, q); + needReset |= update_max_frame_size(avctx, q); if (!needReset) return 0; diff --git a/libavcodec/qsvenc.h b/libavcodec/qsvenc.h index d35a1318f2..c452c5b806 100644 --- a/libavcodec/qsvenc.h +++ b/libavcodec/qsvenc.h @@ -235,6 +235,8 @@ typedef struct QSVEncContext { float old_i_quant_offset; float old_b_quant_factor; float old_b_quant_offset; + // This is used for max_frame_size reset + int old_max_frame_size; } QSVEncContext; int ff_qsv_enc_init(AVCodecContext *avctx, QSVEncContext *q); From patchwork Thu Aug 18 06:59:08 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Chen, Wenbin" X-Patchwork-Id: 37339 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:139a:b0:8f:1db5:eae2 with SMTP id w26csp148140pzh; Thu, 18 Aug 2022 00:01:45 -0700 (PDT) X-Google-Smtp-Source: AA6agR4ZErs6bMgUv4gJc7DCClwvc3RjZxABvFYKsNnSMNbtZaYcBure4VAvTyLU1tzLLcRzHQ14 X-Received: by 2002:a50:ed06:0:b0:445:e986:599e with SMTP id j6-20020a50ed06000000b00445e986599emr1217522eds.10.1660806105242; Thu, 18 Aug 2022 00:01:45 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1660806105; cv=none; d=google.com; s=arc-20160816; b=Zre1E4k8YPgPFAkzRyimB/x4KL6z/k5skRi7ZOQabzuwQ6/jLGOJSflrBjUeKR/CdK K8yLu74XKcaleICovzlbwsSZHcbguEEF3m1PVWAin1U3d9PHbKYmVnIfpLJtUk08IHfI ZdDOpcOk1XhRLiMCFgg4D1+MOoi0AVS8lp3kGOPDC95veT2YQupxKIx3sB4GpnJyPmNW sn2fFHOdf9xRA3Xbts/lzPBJYYo1+WFQUZmQuurwz18fYgLuB3vHtmXyEiNXBzelaaKR tG7O2Pq8uxZPgA059qMShu5dN1JmQCauILEhf+YM8cbQD5vndokOH9YZKgjaKKok7pmk 1dgQ== 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:references:in-reply-to:message-id :date:to:from:dkim-signature:delivered-to; bh=wQib1eAf4LSz9yMp2rsWRflu0bsEigCh9/ZrKeRCCOs=; b=C5RoxO5jBMLyG4GAgyopbYkz0QT6CQaAon+YanOq/nVmitAQd5bz75DbrIXyy41wqU PHHRzfaZcTtroPhIP1telidVrX81xrDBVmSTFTfY+l8tngQWQVgCnwFsnk7yuAJeiKEo XyXZfYPBbo3fhqodDvxH8JNe3S+BPvqh3h+Sf2ZBdKEY/84KCd+FqPqSsL3HR7pCX7Mv qLth2liIzM6GcdCZBwKN3PyTy6dKma7JPMhFhjCMBYcMOIikbgNAtlSW7pO/GBAWKjFn 70c3b28Y8e588pR8cFBY55C6vLoTPQzmCXgfi+8/KSKi+8g+xAU4w2EV/EMPxAiKUYC9 stfw== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@intel.com header.s=Intel header.b=H4z7mYBT; 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 mc3-20020a170906eb4300b0073836824062si438137ejb.202.2022.08.18.00.01.44; Thu, 18 Aug 2022 00:01:45 -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=H4z7mYBT; 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 4D0E268B991; Thu, 18 Aug 2022 10:01:35 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mga05.intel.com (mga05.intel.com [192.55.52.43]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id C92D568B8ED for ; Thu, 18 Aug 2022 10:01:28 +0300 (EEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1660806094; x=1692342094; h=from:to:subject:date:message-id:in-reply-to:references: mime-version:content-transfer-encoding; bh=H9QUtxRjhcYCGCxzXFlGcNZzE1iJKnF47X4Tfj54/yc=; b=H4z7mYBTdDttc4u4s0VyiB4fTleqWRL1whkL7lUT/KzvQvSbhfX7yZ2D Dw3cIC2q45j2xHlc4Ho/yQc2Ym7N3OTr5hwbuqTEk1Vv9jcZnEmwPcn1X pJ/uLd7nHd0yrzgz3bE8fY7zV/JQCa4m1mx7oUbkOnb8WqRn4mJ5WxAJA pTGWOjxTAqXOArzacxitNCGuk23sKunYT8WQMktqWa+b58uyAGvBmBklo x3v9QMTMDe6L3eBnffUjfEtHtB/EmuhMl6wtURVSc1e2nj0oJpmj6xixa EaZfezimGTus9XFe+QtdJotUKcwGQVzBhoAtWO7yisaSXPNkVkIt6Ys/V A==; X-IronPort-AV: E=McAfee;i="6500,9779,10442"; a="378975923" X-IronPort-AV: E=Sophos;i="5.93,245,1654585200"; d="scan'208";a="378975923" Received: from orsmga007.jf.intel.com ([10.7.209.58]) by fmsmga105.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 18 Aug 2022 00:01:12 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.93,245,1654585200"; d="scan'208";a="604155641" Received: from wenbin-z390-aorus-ultra.sh.intel.com ([10.239.35.4]) by orsmga007.jf.intel.com with ESMTP; 18 Aug 2022 00:01:11 -0700 From: Wenbin Chen To: ffmpeg-devel@ffmpeg.org Date: Thu, 18 Aug 2022 14:59:08 +0800 Message-Id: <20220818065912.158693-2-wenbin.chen@intel.com> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20220818065912.158693-1-wenbin.chen@intel.com> References: <20220818065912.158693-1-wenbin.chen@intel.com> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 2/6] libavcodec/qsvenc: Add gop_size reset support to qsvenc 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: Cn72vZwXcOA+ Signed-off-by: Wenbin Chen --- doc/encoders.texi | 3 +++ libavcodec/qsvenc.c | 18 +++++++++++++++++- libavcodec/qsvenc.h | 2 ++ 3 files changed, 22 insertions(+), 1 deletion(-) diff --git a/doc/encoders.texi b/doc/encoders.texi index 69fa46f3ea..9fb63856b1 100644 --- a/doc/encoders.texi +++ b/doc/encoders.texi @@ -3348,6 +3348,9 @@ Change these value to reset qsv codec's qp configuration. @item @var{max_frame_size} Supported in h264_qsv and hevc_qsv. Change this value to reset qsv codec's MaxFrameSize configuration. + +@item @var{gop_size} +Change this value to reset qsv codec's gop configuration. @end table @subsection H264 options diff --git a/libavcodec/qsvenc.c b/libavcodec/qsvenc.c index c911b81e7d..b3820e4fe0 100644 --- a/libavcodec/qsvenc.c +++ b/libavcodec/qsvenc.c @@ -635,6 +635,7 @@ static int init_video_param(AVCodecContext *avctx, QSVEncContext *q) q->param.mfx.CodecProfile = q->profile; q->param.mfx.TargetUsage = avctx->compression_level; q->param.mfx.GopPicSize = FFMAX(0, avctx->gop_size); + q->old_gop_size = avctx->gop_size; q->param.mfx.GopRefDist = FFMAX(-1, avctx->max_b_frames) + 1; q->param.mfx.GopOptFlag = avctx->flags & AV_CODEC_FLAG_CLOSED_GOP ? MFX_GOP_CLOSED : MFX_GOP_STRICT; @@ -1692,16 +1693,31 @@ static int update_max_frame_size(AVCodecContext *avctx, QSVEncContext *q) return updated; } +static int update_gop_size(AVCodecContext *avctx, QSVEncContext *q) +{ + int updated = 0; + UPDATE_PARAM(q->old_gop_size, avctx->gop_size); + if (!updated) + return 0; + + q->param.mfx.GopPicSize = FFMAX(0, avctx->gop_size); + av_log(avctx, AV_LOG_DEBUG, "reset GopPicSize to %d\n", + q->param.mfx.GopPicSize); + + return updated; +} + static int update_parameters(AVCodecContext *avctx, QSVEncContext *q, const AVFrame *frame) { int needReset = 0, ret = 0; - if (!frame) + if (!frame || avctx->codec_id == AV_CODEC_ID_MJPEG) return 0; needReset = update_qp(avctx, q); needReset |= update_max_frame_size(avctx, q); + needReset |= update_gop_size(avctx, q); if (!needReset) return 0; diff --git a/libavcodec/qsvenc.h b/libavcodec/qsvenc.h index c452c5b806..fdedae28dd 100644 --- a/libavcodec/qsvenc.h +++ b/libavcodec/qsvenc.h @@ -237,6 +237,8 @@ typedef struct QSVEncContext { float old_b_quant_offset; // This is used for max_frame_size reset int old_max_frame_size; + // This is used for gop reset + int old_gop_size; } QSVEncContext; int ff_qsv_enc_init(AVCodecContext *avctx, QSVEncContext *q); From patchwork Thu Aug 18 06:59: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: 37340 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:139a:b0:8f:1db5:eae2 with SMTP id w26csp148218pzh; Thu, 18 Aug 2022 00:01:54 -0700 (PDT) X-Google-Smtp-Source: AA6agR5uL6Skq1HwCfXAVEBTRENnvsAQi1NWPa14ihW76F6+U3OuFj/59W++fLWuxlkUbeEalzO4 X-Received: by 2002:a17:907:2be3:b0:730:6866:a9b1 with SMTP id gv35-20020a1709072be300b007306866a9b1mr1005098ejc.693.1660806114707; Thu, 18 Aug 2022 00:01:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1660806114; cv=none; d=google.com; s=arc-20160816; b=N01AQE0waSAkCdNZoQiI6xtKa/+se5WpP181lJMnF0Ob1ujls783X2EFgSikqL0vYq +nNvElGEW9TsnRkGX0vsmtMPOzfxcynGG9KJnylaoPFd6DA3mua4YnMyMTly1mUbpe31 3IQQlnoaJdte3qZNNJxr5KKDVLtXBqrxd8f8S+4jXT/zkL7afrMpitxVt8IIw0MyEd5Z qQwtKj7hfmCEw7x7kbVhPU4nMK1mJr3APuL3gyqdd3cD3coQzkSKEfBiDHjcB/z7pAeg e90XUYqAzKp+EG7niqXzd37nMbWzgBKd+k3dgex6Qi6Ihuf6W/rOS9j/YduLKjcGSbv+ toOw== 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:references:in-reply-to:message-id :date:to:from:dkim-signature:delivered-to; bh=nDiP458wCFGd15Oe1lGmmJ8hsCbyGu/7+M9CJz56rEY=; b=OTbyqkYM3RXJ+s1xtXWY56nJFEkR5AdSalHkY3K1y1x/Xv5TFQqc5IEUfMCA/7Yzzl PhDkaeBmQYED6nARjzIyTB1bOggIs4rECupZi8ImpK8OlJDPm4F4ZkyYQjFIsfmpuYr4 O0272xht505+lOyBB6OYwXC9iZH7vFu7hpB9ozS3OjnMmVEMZCOMYB0OkRmLvBcjblUK 2p09TGTGn4s1SlPQmyc3x2czmtkBsjJzpdVR3ZLoUqKVhc1xF5FOSXRYTz+hEMFrT7sm LcGy7oudxDpISMpUkDY8SwEjlDtVr87AZjMyXp8QS0uFUNkfBjN4qVQmBiqDzV+r20BW 9bdg== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@intel.com header.s=Intel header.b="A/4CswGN"; 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 au18-20020a170907093200b0072f7debe7d3si528897ejc.352.2022.08.18.00.01.54; Thu, 18 Aug 2022 00:01:54 -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="A/4CswGN"; 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 59F7968B99A; Thu, 18 Aug 2022 10:01:36 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mga05.intel.com (mga05.intel.com [192.55.52.43]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 1E5EB68B98F for ; Thu, 18 Aug 2022 10:01:29 +0300 (EEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1660806095; x=1692342095; h=from:to:subject:date:message-id:in-reply-to:references: mime-version:content-transfer-encoding; bh=psW2tSznrnRdKvnlMj4BtCDTM1NEBYzTx4LcaCdUvi8=; b=A/4CswGNEmqocFY8mB0BBQvQVv0/8jXRFj2EMSUYFZVWpvKnxQPmub+P gyXt6lS1Dwys5Q/X3qb3huHCb+ruOA28dK7LrItEA+F5iW7RXvluHB13b poloOBY3O00aJsNufgsMsBcmNqRc5jEV38Nsbhyh9JUnHHPEZ2nzZBENP k/BMmLTPvgmPMjptDUo+nuORQWbY4dmZJ0kjo/kZaDMsvzsQbpR0nTbWu BZf27AjVnIphVS5z86HJhlOm6a+kzBTHc9CVFohp9x9LKx+RI8KEIZUHQ 9xti/kTJqtDGKNKxSIwq4ujZaGweZUEkgfEK9H4k6nqtWWwiScnvbITZh g==; X-IronPort-AV: E=McAfee;i="6500,9779,10442"; a="378975924" X-IronPort-AV: E=Sophos;i="5.93,245,1654585200"; d="scan'208";a="378975924" Received: from orsmga007.jf.intel.com ([10.7.209.58]) by fmsmga105.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 18 Aug 2022 00:01:13 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.93,245,1654585200"; d="scan'208";a="604155651" Received: from wenbin-z390-aorus-ultra.sh.intel.com ([10.239.35.4]) by orsmga007.jf.intel.com with ESMTP; 18 Aug 2022 00:01:12 -0700 From: Wenbin Chen To: ffmpeg-devel@ffmpeg.org Date: Thu, 18 Aug 2022 14:59:09 +0800 Message-Id: <20220818065912.158693-3-wenbin.chen@intel.com> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20220818065912.158693-1-wenbin.chen@intel.com> References: <20220818065912.158693-1-wenbin.chen@intel.com> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 3/6] libavcodec/qsvenc: Add "slice" intra refresh type to qsvenc 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: S4oEpA6ZxWqw Add "slice" intra refresh type to h264_qsv and hevc_qsv. This type means horizontal refresh by slices without overlapping. Also update the doc. Signed-off-by: Wenbin Chen --- doc/encoders.texi | 12 ++++++++---- libavcodec/qsvenc_h264.c | 1 + libavcodec/qsvenc_hevc.c | 1 + 3 files changed, 10 insertions(+), 4 deletions(-) diff --git a/doc/encoders.texi b/doc/encoders.texi index 9fb63856b1..48fe73fd33 100644 --- a/doc/encoders.texi +++ b/doc/encoders.texi @@ -3454,8 +3454,10 @@ Specifies intra refresh type. The major goal of intra refresh is improvement of error resilience without significant impact on encoded bitstream size caused by I frames. The SDK encoder achieves this by encoding part of each frame in refresh cycle using intra MBs. @var{none} means no refresh. @var{vertical} means -vertical refresh, by column of MBs. To enable intra refresh, B frame should be -set to 0. +vertical refresh, by column of MBs. @var{horizontal} means horizontal refresh, +by rows of MBs. @var{slice} means horizontal refresh by slices without +overlapping. In case of @var{slice}, in_ref_cycle_size is ignored. To enable +intra refresh, B frame should be set to 0. @item @var{int_ref_cycle_size} Specifies number of pictures within refresh cycle starting from 2. 0 and 1 are @@ -3619,8 +3621,10 @@ Specifies intra refresh type. The major goal of intra refresh is improvement of error resilience without significant impact on encoded bitstream size caused by I frames. The SDK encoder achieves this by encoding part of each frame in refresh cycle using intra MBs. @var{none} means no refresh. @var{vertical} means -vertical refresh, by column of MBs. To enable intra refresh, B frame should be -set to 0. +vertical refresh, by column of MBs. @var{horizontal} means horizontal refresh, +by rows of MBs. @var{slice} means horizontal refresh by slices without +overlapping. In case of @var{slice}, in_ref_cycle_size is ignored. To enable +intra refresh, B frame should be set to 0. @item @var{int_ref_cycle_size} Specifies number of pictures within refresh cycle starting from 2. 0 and 1 are diff --git a/libavcodec/qsvenc_h264.c b/libavcodec/qsvenc_h264.c index ad9cf629df..b589fccc89 100644 --- a/libavcodec/qsvenc_h264.c +++ b/libavcodec/qsvenc_h264.c @@ -138,6 +138,7 @@ static const AVOption options[] = { { "none", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = 0 }, .flags = VE, "int_ref_type" }, { "vertical", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = 1 }, .flags = VE, "int_ref_type" }, { "horizontal", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = 2 }, .flags = VE, "int_ref_type" }, + { "slice" , NULL, 0, AV_OPT_TYPE_CONST, { .i64 = 3 }, .flags = VE, "int_ref_type" }, { "int_ref_cycle_size", "Number of frames in the intra refresh cycle", OFFSET(qsv.int_ref_cycle_size), AV_OPT_TYPE_INT, { .i64 = -1 }, -1, UINT16_MAX, VE }, { "int_ref_qp_delta", "QP difference for the refresh MBs", OFFSET(qsv.int_ref_qp_delta), AV_OPT_TYPE_INT, { .i64 = INT16_MIN }, INT16_MIN, INT16_MAX, VE }, { "recovery_point_sei", "Insert recovery point SEI messages", OFFSET(qsv.recovery_point_sei), AV_OPT_TYPE_INT, { .i64 = -1 }, -1, 1, VE }, diff --git a/libavcodec/qsvenc_hevc.c b/libavcodec/qsvenc_hevc.c index e11f5dec4a..8fcf8b2cef 100644 --- a/libavcodec/qsvenc_hevc.c +++ b/libavcodec/qsvenc_hevc.c @@ -267,6 +267,7 @@ static const AVOption options[] = { { "none", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = 0 }, .flags = VE, "int_ref_type" }, { "vertical", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = 1 }, .flags = VE, "int_ref_type" }, { "horizontal", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = 2 }, .flags = VE, "int_ref_type" }, + { "slice" , NULL, 0, AV_OPT_TYPE_CONST, { .i64 = 3 }, .flags = VE, "int_ref_type" }, { "int_ref_cycle_size", "Number of frames in the intra refresh cycle", OFFSET(qsv.int_ref_cycle_size), AV_OPT_TYPE_INT, { .i64 = -1 }, -1, UINT16_MAX, VE }, { "int_ref_qp_delta", "QP difference for the refresh MBs", OFFSET(qsv.int_ref_qp_delta), AV_OPT_TYPE_INT, { .i64 = INT16_MIN }, INT16_MIN, INT16_MAX, VE }, { "int_ref_cycle_dist", "Distance between the beginnings of the intra-refresh cycles in frames", OFFSET(qsv.int_ref_cycle_dist), AV_OPT_TYPE_INT, { .i64 = -1 }, -1, INT16_MAX, VE }, From patchwork Thu Aug 18 06:59:10 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Chen, Wenbin" X-Patchwork-Id: 37343 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:139a:b0:8f:1db5:eae2 with SMTP id w26csp148504pzh; Thu, 18 Aug 2022 00:02:25 -0700 (PDT) X-Google-Smtp-Source: AA6agR52EDXwQRminBTQFRVAp06HEb0jJa3Gvs1l1iHkqKnha56MeTBK11MvZfSymde4JiQhzKoC X-Received: by 2002:a05:6402:2684:b0:43d:9964:d2a0 with SMTP id w4-20020a056402268400b0043d9964d2a0mr1184982edd.250.1660806145709; Thu, 18 Aug 2022 00:02:25 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1660806145; cv=none; d=google.com; s=arc-20160816; b=0yV5Fbp3upggoHinqLsKj77yjHTX59YN4MIftd00F8tWu7daA9XuQMa8VH2FQ64mbS vIk4AlQB/xsoOhhZjHaOaFHAz/GT2gJ+p9dK2b/kCu7Zk2UI/TyYhxml8CMzRbFLergu hJGr3hPha3UBaiR4dND8emOtpdnMYwelZydwiNytgH/XYnr5v+aFQit1mLe2YB54KXv9 fXTtcccG2S+PYu38mPQhjZhph7niJzJwMLePAWJ4qRlzGdEfuPGE4tkfNdnKinwapG92 rPgMNJVkMGjwef+8/RxEgHfZNTIgpeRimPoX5JNsQEjZSr8HfSzS48HeJiYIWLn+HQxH 5Big== 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:references:in-reply-to:message-id :date:to:from:dkim-signature:delivered-to; bh=KYrsCL2XUNGcIxB2xnb/Z+jGT9BzTJF6ttQ2cpHwfsU=; b=0j/dqfBMbOeuj+6I6/RigEALecrYNDYCqvs9knVUIeKDIiGuNc+cAW1VwSWgW/NjtF UQKJtImE8y2d/h3uEzLphv3FeG7a+XYhh6HkH2MmxfSDN3je0FuWiyF2zmiSTxkY8L04 0KlaKWS2LOEjBTIph46mfaa2rfM+V3Vk/B2Pwa73WST+2lqWwEy8OFHS2Orss9ND6DwQ BCwl9rj98meI4ErahLkk1P0XNUQCsevLCLxo50ksKVYuIuuvs5k93fysrQ06cSRvChsM NeygepHyZ76PRb2y1kGnvz8NPbXvtll2DJ8UfS8RoFORHqGwE/qtyIdENB8REXR0O9uf cHXQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@intel.com header.s=Intel header.b=N8HEhEnc; 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 c1-20020a50d641000000b0043dfb97250esi679408edj.456.2022.08.18.00.02.25; Thu, 18 Aug 2022 00:02:25 -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=N8HEhEnc; 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 4B96968B9AC; Thu, 18 Aug 2022 10:01:44 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mga05.intel.com (mga05.intel.com [192.55.52.43]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id D1A3568B9A3 for ; Thu, 18 Aug 2022 10:01:34 +0300 (EEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1660806101; x=1692342101; h=from:to:subject:date:message-id:in-reply-to:references: mime-version:content-transfer-encoding; bh=U4F2Clh3EpycbFn1AWgzRhnxKoHtUzYVsQeE8GViALg=; b=N8HEhEncPBBtSn+F5wDib4A7cUhXUQZZkW+LK1ezEMAepxLorSAvdoRs 0bdXnT4Y5GIvCBXBeFTo6541IBy8JISRtgKyBamcGcS9rqrVtdlMI+k2n VJ7xDNVUROJyRpLlb9JZ9AR6I0w3OY+4FSW0on1xelYwHwm7iy4fZx+LG BH9MUwLYDjn/vQ7mVhHNUS1jel+5X3ik/vlWHjWIBBnachAryD0Bb9kGJ UFwrNVwi6gqXnbmytDdEsw6lzWY+fZG3u79EikZqoT2uOY2l3D5NMDQg5 TTgjGTORGHIywQJhLgbAWvDmobgdwdqO8hiMNK+fz82kA7E7zG2DjyjzY g==; X-IronPort-AV: E=McAfee;i="6500,9779,10442"; a="378975925" X-IronPort-AV: E=Sophos;i="5.93,245,1654585200"; d="scan'208";a="378975925" Received: from orsmga007.jf.intel.com ([10.7.209.58]) by fmsmga105.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 18 Aug 2022 00:01:14 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.93,245,1654585200"; d="scan'208";a="604155655" Received: from wenbin-z390-aorus-ultra.sh.intel.com ([10.239.35.4]) by orsmga007.jf.intel.com with ESMTP; 18 Aug 2022 00:01:13 -0700 From: Wenbin Chen To: ffmpeg-devel@ffmpeg.org Date: Thu, 18 Aug 2022 14:59:10 +0800 Message-Id: <20220818065912.158693-4-wenbin.chen@intel.com> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20220818065912.158693-1-wenbin.chen@intel.com> References: <20220818065912.158693-1-wenbin.chen@intel.com> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 4/6] libavcodec/qsvenc: Add intra refresh reset support to qsvenc 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: 9G0BsS+AGrEc Signed-off-by: Wenbin Chen --- doc/encoders.texi | 7 +++++++ libavcodec/qsvenc.c | 33 +++++++++++++++++++++++++++++++++ libavcodec/qsvenc.h | 5 +++++ 3 files changed, 45 insertions(+) diff --git a/doc/encoders.texi b/doc/encoders.texi index 48fe73fd33..b28b1f7f0b 100644 --- a/doc/encoders.texi +++ b/doc/encoders.texi @@ -3351,6 +3351,13 @@ Change this value to reset qsv codec's MaxFrameSize configuration. @item @var{gop_size} Change this value to reset qsv codec's gop configuration. + +@item @var{int_ref_type} +@item @var{int_ref_cycle_size} +@item @var{int_ref_qp_delta} +@item @var{int_ref_cycle_dist} +Supported in h264_qsv and hevc_qsv. +Change these value to reset qsv codec's Intra Refresh configuration. @end table @subsection H264 options diff --git a/libavcodec/qsvenc.c b/libavcodec/qsvenc.c index b3820e4fe0..dbb1f49101 100644 --- a/libavcodec/qsvenc.c +++ b/libavcodec/qsvenc.c @@ -832,10 +832,13 @@ static int init_video_param(AVCodecContext *avctx, QSVEncContext *q) q->old_max_frame_size = q->max_frame_size; if (q->int_ref_type >= 0) q->extco2.IntRefType = q->int_ref_type; + q->old_int_ref_type = q->int_ref_type; if (q->int_ref_cycle_size >= 0) q->extco2.IntRefCycleSize = q->int_ref_cycle_size; + q->old_int_ref_cycle_size = q->int_ref_cycle_size; if (q->int_ref_qp_delta != INT16_MIN) q->extco2.IntRefQPDelta = q->int_ref_qp_delta; + q->old_int_ref_qp_delta = q->int_ref_qp_delta; if (q->max_slice_size >= 0) q->extco2.MaxSliceSize = q->max_slice_size; q->extco2.DisableDeblockingIdc = q->dblk_idc; @@ -920,6 +923,7 @@ static int init_video_param(AVCodecContext *avctx, QSVEncContext *q) } if (q->int_ref_cycle_dist >= 0) q->extco3.IntRefCycleDist = q->int_ref_cycle_dist; + q->old_int_ref_cycle_dist = q->int_ref_cycle_dist; if (q->low_delay_brc >= 0) q->extco3.LowDelayBRC = q->low_delay_brc ? MFX_CODINGOPTION_ON : MFX_CODINGOPTION_OFF; if (q->max_frame_size_i >= 0) @@ -1707,6 +1711,34 @@ static int update_gop_size(AVCodecContext *avctx, QSVEncContext *q) return updated; } +static int update_rir(AVCodecContext *avctx, QSVEncContext *q) +{ + int updated = 0; + + if (avctx->codec_id != AV_CODEC_ID_H264 && avctx->codec_id != AV_CODEC_ID_HEVC) + return 0; + + UPDATE_PARAM(q->old_int_ref_type, q->int_ref_type); + UPDATE_PARAM(q->old_int_ref_cycle_size, q->int_ref_cycle_size); + UPDATE_PARAM(q->old_int_ref_qp_delta, q->int_ref_qp_delta); + UPDATE_PARAM(q->old_int_ref_cycle_dist, q->int_ref_cycle_dist); + if (!updated) + return 0; + + q->extco2.IntRefType = FFMAX(0, q->int_ref_type); + q->extco2.IntRefCycleSize = FFMAX(0, q->int_ref_cycle_size); + q->extco2.IntRefQPDelta = + q->int_ref_qp_delta != INT16_MIN ? q->int_ref_qp_delta : 0; + q->extco3.IntRefCycleDist = FFMAX(0, q->int_ref_cycle_dist); + av_log(avctx, AV_LOG_DEBUG, + "Reset IntRefType: %d; IntRefCycleSize: %d; " + "IntRefQPDelta: %d; IntRefCycleDist: %d\n", + q->extco2.IntRefType, q->extco2.IntRefCycleSize, + q->extco2.IntRefQPDelta, q->extco3.IntRefCycleDist); + + return updated; +} + static int update_parameters(AVCodecContext *avctx, QSVEncContext *q, const AVFrame *frame) { @@ -1718,6 +1750,7 @@ static int update_parameters(AVCodecContext *avctx, QSVEncContext *q, needReset = update_qp(avctx, q); needReset |= update_max_frame_size(avctx, q); needReset |= update_gop_size(avctx, q); + needReset |= update_rir(avctx, q); if (!needReset) return 0; diff --git a/libavcodec/qsvenc.h b/libavcodec/qsvenc.h index fdedae28dd..5a395d422e 100644 --- a/libavcodec/qsvenc.h +++ b/libavcodec/qsvenc.h @@ -239,6 +239,11 @@ typedef struct QSVEncContext { int old_max_frame_size; // This is used for gop reset int old_gop_size; + // These are used for intra refresh reset + int old_int_ref_type; + int old_int_ref_cycle_size; + int old_int_ref_qp_delta; + int old_int_ref_cycle_dist; } QSVEncContext; int ff_qsv_enc_init(AVCodecContext *avctx, QSVEncContext *q); From patchwork Thu Aug 18 06:59:11 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Chen, Wenbin" X-Patchwork-Id: 37341 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:139a:b0:8f:1db5:eae2 with SMTP id w26csp148322pzh; Thu, 18 Aug 2022 00:02:05 -0700 (PDT) X-Google-Smtp-Source: AA6agR6D/Axe1xDx5cdz7nvSG9yJP0sUXciH+V3uqkb+hrFcECWp9b/lsavqQACnYBf3rZkpXaNH X-Received: by 2002:a17:906:cc4a:b0:730:850f:5cb5 with SMTP id mm10-20020a170906cc4a00b00730850f5cb5mr1059974ejb.658.1660806125370; Thu, 18 Aug 2022 00:02:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1660806125; cv=none; d=google.com; s=arc-20160816; b=f9WgeYLOfJIyrFVg9gMt1s/FIfg/3xiqoxz6pPzswnMgMnFCaAke3XW5phigJ8xXb8 1+/v0sSOIgB4IqK7VfuIqqmF/ztKZHfmZcQN6X96HsPARtwM72bT+IZWiBaI9nZbU1Yn n106QXdH4rD/Fkl/3cA3LhRMhuB6jOTi4wcHONytj4B37+DevhyCIfbXuzkqvF5VSKYf O1VxaMRqlntD/x3ASEDm6kuzwRZNrHwwYvqijvraXkS2I6q4Zl0L4CoO+59L+uFJgDjM vIYkZjyWhYcn5IKMGhz55p8XB+2FTDcL+oKGA6po3IiQ5kMxw55Gy5dU72SBGM1iaATG ADVQ== 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:references:in-reply-to:message-id :date:to:from:dkim-signature:delivered-to; bh=DzWMxkA8JwDbW/OrnzV+unnS5r3Tt8pGVtywrEkhrOk=; b=DmjBkxmqWBwo9uFiqPMBGPNkIkJBRuk1+nZxB4IKJNADAwIg9DmNP56nD2qtPKHbGZ EFdub9ZkH+pevSxILY9lYFSGE6aRexPOr5lcTf8uB4vEOlq++MwgdztFxV+wQMxdnWau jOPLRGsRj3Rd1wtHo0bI6cjsBDnk234QM0OIghDTX3BMfLtz8+XgdVOWlRF3lOLEyDxP wIMISUaJL+pluP1Ad+rGuRahBV4SVhY/HN17LJhlm2bLENGrEL4A5YefnfhgPygi4QqA Ejwtxy8DgANlQHste/5mOFlN3an33OUBuGThfUj74IGrrUdrv1SmHTgg4aTrgzS9oDeh agLw== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@intel.com header.s=Intel header.b=XjeMZ0yn; 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 y1-20020aa7c241000000b0043bbafc0129si678255edo.235.2022.08.18.00.02.05; Thu, 18 Aug 2022 00:02:05 -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=XjeMZ0yn; 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 58B8E68B9A8; Thu, 18 Aug 2022 10:01:38 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mga05.intel.com (mga05.intel.com [192.55.52.43]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 1C71868B995 for ; Thu, 18 Aug 2022 10:01:35 +0300 (EEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1660806096; x=1692342096; h=from:to:subject:date:message-id:in-reply-to:references: mime-version:content-transfer-encoding; bh=BxavRX+mEXE4a2dnZp6DOj+PvvaZbCyUpxF3utNdrZc=; b=XjeMZ0yn5BWiBJoEv4IdYRqP0xacTCAKS+lrp0/MHetTlubtLvas+PyF yoJfrQYP75vUnnpbeDO/LqUMsloJlTWc7tpMdFxHrOWp/P+7jlLApyY0c xs7Wry5rLQXhGWiBzdpdELzcOo9BPMIZ/SwMzaLo3eccsORZQ2zNs3S3E 54gaHT2zYNUn4npAubrPyqq+eNqtVeZZwFyaIFWulal/mIqS45xjgOYI8 QJbKr61r6wPqx/KpAw2y17cZAzLz9Bpu8xrX0ZvQJaQ/KnespNMTkSD7w xN3zQrpgsR+Azpw/otA4ZeF8E6MN9nrvzBnq1SeHDlxDEm1GnxsyML1us Q==; X-IronPort-AV: E=McAfee;i="6500,9779,10442"; a="378975928" X-IronPort-AV: E=Sophos;i="5.93,245,1654585200"; d="scan'208";a="378975928" Received: from orsmga007.jf.intel.com ([10.7.209.58]) by fmsmga105.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 18 Aug 2022 00:01:15 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.93,245,1654585200"; d="scan'208";a="604155663" Received: from wenbin-z390-aorus-ultra.sh.intel.com ([10.239.35.4]) by orsmga007.jf.intel.com with ESMTP; 18 Aug 2022 00:01:14 -0700 From: Wenbin Chen To: ffmpeg-devel@ffmpeg.org Date: Thu, 18 Aug 2022 14:59:11 +0800 Message-Id: <20220818065912.158693-5-wenbin.chen@intel.com> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20220818065912.158693-1-wenbin.chen@intel.com> References: <20220818065912.158693-1-wenbin.chen@intel.com> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 5/6] libavcodec/qsvenc: Add max/min qp reset support in qsvenc 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: X0FiGJ9YsBRT Signed-off-by: Wenbin Chen --- doc/encoders.texi | 11 +++++++ libavcodec/qsvenc.c | 78 +++++++++++++++++++++++++++++++++++++++++++++ libavcodec/qsvenc.h | 9 ++++++ 3 files changed, 98 insertions(+) diff --git a/doc/encoders.texi b/doc/encoders.texi index b28b1f7f0b..fad3cad30b 100644 --- a/doc/encoders.texi +++ b/doc/encoders.texi @@ -3358,6 +3358,17 @@ Change this value to reset qsv codec's gop configuration. @item @var{int_ref_cycle_dist} Supported in h264_qsv and hevc_qsv. Change these value to reset qsv codec's Intra Refresh configuration. + +@item @var{qmax} +@item @var{qmin} +@item @var{max_qp_i} +@item @var{min_qp_i} +@item @var{max_qp_p} +@item @var{min_qp_p} +@item @var{max_qp_b} +@item @var{min_qp_b} +Supported in h264_qsv. +Change these value to reset qsv codec's max/min qp configuration. @end table @subsection H264 options diff --git a/libavcodec/qsvenc.c b/libavcodec/qsvenc.c index dbb1f49101..3a3e6ccc9a 100644 --- a/libavcodec/qsvenc.c +++ b/libavcodec/qsvenc.c @@ -858,22 +858,30 @@ static int init_video_param(AVCodecContext *avctx, QSVEncContext *q) q->extco2.MinQPI = avctx->qmin > 51 ? 51 : avctx->qmin; q->extco2.MinQPP = q->extco2.MinQPB = q->extco2.MinQPI; } + q->old_qmin = avctx->qmin; if (avctx->qmax >= 0) { q->extco2.MaxQPI = avctx->qmax > 51 ? 51 : avctx->qmax; q->extco2.MaxQPP = q->extco2.MaxQPB = q->extco2.MaxQPI; } + q->old_qmax = avctx->qmax; if (q->min_qp_i >= 0) q->extco2.MinQPI = q->min_qp_i > 51 ? 51 : q->min_qp_i; + q->old_min_qp_i = q->min_qp_i; if (q->max_qp_i >= 0) q->extco2.MaxQPI = q->max_qp_i > 51 ? 51 : q->max_qp_i; + q->old_max_qp_i = q->max_qp_i; if (q->min_qp_p >= 0) q->extco2.MinQPP = q->min_qp_p > 51 ? 51 : q->min_qp_p; + q->old_min_qp_p = q->min_qp_p; if (q->max_qp_p >= 0) q->extco2.MaxQPP = q->max_qp_p > 51 ? 51 : q->max_qp_p; + q->old_max_qp_p = q->max_qp_p; if (q->min_qp_b >= 0) q->extco2.MinQPB = q->min_qp_b > 51 ? 51 : q->min_qp_b; + q->old_min_qp_b = q->min_qp_b; if (q->max_qp_b >= 0) q->extco2.MaxQPB = q->max_qp_b > 51 ? 51 : q->max_qp_b; + q->old_max_qp_b = q->max_qp_b; if (q->mbbrc >= 0) q->extco2.MBBRC = q->mbbrc ? MFX_CODINGOPTION_ON : MFX_CODINGOPTION_OFF; @@ -1739,6 +1747,71 @@ static int update_rir(AVCodecContext *avctx, QSVEncContext *q) return updated; } +static int update_min_max_qp(AVCodecContext *avctx, QSVEncContext *q) +{ + int updated = 0; + + if (avctx->codec_id != AV_CODEC_ID_H264) + return 0; + + UPDATE_PARAM(q->old_qmax, avctx->qmin); + UPDATE_PARAM(q->old_qmax, avctx->qmin); + UPDATE_PARAM(q->old_min_qp_i, q->min_qp_i); + UPDATE_PARAM(q->old_max_qp_i, q->max_qp_i); + UPDATE_PARAM(q->old_min_qp_p, q->min_qp_p); + UPDATE_PARAM(q->old_max_qp_p, q->max_qp_p); + UPDATE_PARAM(q->old_min_qp_b, q->min_qp_b); + UPDATE_PARAM(q->old_max_qp_b, q->max_qp_b); + if (!updated) + return 0; + + if ((avctx->qmin >= 0 && avctx->qmax >= 0 && avctx->qmin > avctx->qmax) || + (q->max_qp_i >= 0 && q->min_qp_i >= 0 && q->min_qp_i > q->max_qp_i) || + (q->max_qp_p >= 0 && q->min_qp_p >= 0 && q->min_qp_p > q->max_qp_p) || + (q->max_qp_b >= 0 && q->min_qp_b >= 0 && q->min_qp_b > q->max_qp_b)) { + av_log(avctx, AV_LOG_ERROR, + "qmin and or qmax are set but invalid," + " please make sure min <= max\n"); + return AVERROR(EINVAL); + } + + q->extco2.MinQPI = 0; + q->extco2.MaxQPI = 0; + q->extco2.MinQPP = 0; + q->extco2.MaxQPP = 0; + q->extco2.MinQPB = 0; + q->extco2.MaxQPB = 0; + if (avctx->qmin >= 0) { + q->extco2.MinQPI = avctx->qmin > 51 ? 51 : avctx->qmin; + q->extco2.MinQPB = q->extco2.MinQPP = q->extco2.MinQPI; + } + if (avctx->qmax >= 0) { + q->extco2.MaxQPI = avctx->qmax > 51 ? 51 : avctx->qmax; + q->extco2.MaxQPB = q->extco2.MaxQPP = q->extco2.MaxQPI; + } + if (q->min_qp_i >= 0) + q->extco2.MinQPI = q->min_qp_i > 51 ? 51 : q->min_qp_i; + if (q->max_qp_i >= 0) + q->extco2.MaxQPI = q->max_qp_i > 51 ? 51 : q->max_qp_i; + if (q->min_qp_p >= 0) + q->extco2.MinQPP = q->min_qp_p > 51 ? 51 : q->min_qp_p; + if (q->max_qp_p >= 0) + q->extco2.MaxQPP = q->max_qp_p > 51 ? 51 : q->max_qp_p; + if (q->min_qp_b >= 0) + q->extco2.MinQPB = q->min_qp_b > 51 ? 51 : q->min_qp_b; + if (q->max_qp_b >= 0) + q->extco2.MaxQPB = q->max_qp_b > 51 ? 51 : q->max_qp_b; + + av_log(avctx, AV_LOG_VERBOSE, "Reset MinQPI: %d; MaxQPI: %d; " + "MinQPP: %d; MaxQPP: %d; " + "MinQPB: %d; MaxQPB: %d\n", + q->extco2.MinQPI, q->extco2.MaxQPI, + q->extco2.MinQPP, q->extco2.MaxQPP, + q->extco2.MinQPB, q->extco2.MaxQPB); + + return updated; +} + static int update_parameters(AVCodecContext *avctx, QSVEncContext *q, const AVFrame *frame) { @@ -1751,6 +1824,11 @@ static int update_parameters(AVCodecContext *avctx, QSVEncContext *q, needReset |= update_max_frame_size(avctx, q); needReset |= update_gop_size(avctx, q); needReset |= update_rir(avctx, q); + + ret = update_min_max_qp(avctx, q); + if (ret < 0) + return ret; + needReset |= ret; if (!needReset) return 0; diff --git a/libavcodec/qsvenc.h b/libavcodec/qsvenc.h index 5a395d422e..f48c87fbad 100644 --- a/libavcodec/qsvenc.h +++ b/libavcodec/qsvenc.h @@ -244,6 +244,15 @@ typedef struct QSVEncContext { int old_int_ref_cycle_size; int old_int_ref_qp_delta; int old_int_ref_cycle_dist; + // These are used for max/min qp reset; + int old_qmax; + int old_qmin; + int old_max_qp_i; + int old_min_qp_i; + int old_max_qp_p; + int old_min_qp_p; + int old_max_qp_b; + int old_min_qp_b; } QSVEncContext; int ff_qsv_enc_init(AVCodecContext *avctx, QSVEncContext *q); From patchwork Thu Aug 18 06:59:12 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Chen, Wenbin" X-Patchwork-Id: 37342 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:139a:b0:8f:1db5:eae2 with SMTP id w26csp148407pzh; Thu, 18 Aug 2022 00:02:15 -0700 (PDT) X-Google-Smtp-Source: AA6agR7LWLxHSeWi8qEBKNEpY603SAjILYNvss4aIJFIhn1N4sGDkhP8SfuMCKmoZyToXVXJQCWq X-Received: by 2002:a05:6402:40d0:b0:43f:8f56:6b0e with SMTP id z16-20020a05640240d000b0043f8f566b0emr1186490edb.380.1660806135448; Thu, 18 Aug 2022 00:02:15 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1660806135; cv=none; d=google.com; s=arc-20160816; b=WDqaLFS6rYshJe2rvG9//sCdyqmFA5CfU37HiUKBgNSaj1ZjgR7h/A1gQqBrwOwrHv A3zEGy6ZqIDJBErVWaZJbxILmdTBrh1CXQNPlIWzhSIj4jfYSCiASMwZplGCXtOIbJjl VJr+uPZwPPQcvA994yRAhjzraiPenPuPJw7/nme+cjk3AOTS9wQGNdtW5T5aSX2Uev6q reJmzM44UObS13mzgT1RNCSlnAn5gCf/hfUd28om2/FYkSGubcA8tFm4lbOXAYPSiqI7 UqOHnKGiXXyClehihPJhC0EReC6I7VJU/3/BPmV9a4J7WE/bTNJSG8as6mjoSz85B8+P V+MA== 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:references:in-reply-to:message-id :date:to:from:dkim-signature:delivered-to; bh=buVREGlNbu/FUlDn/s5Ds+uyvPx3bUvE2P/DBFVayCU=; b=wsR8aKdWgE0jC+/PochxGhmDKjXUc8xvOtap4keR1qdFiUK6WMki7RoaEPQXdZq+KV 2RQpHx89HSzKoBD8POZYrJa/SGvKKejcuX+o+KknYbdeeTSIStA3nJ7A7TTHyVETmasU fZ5eFSQYv3YOdXw0cqI15fQWtLWLuDMW4mEG4ZTG9QhCqNcP98K97PmzkX3VNRSkWs6f qzZyOM5NVD2zojwdk9PtNcnISc1KQ0DI5jhQpnOmqmeIZ6bP5sRfiiDlPh9bvMcq3GEr IRFxnvZ+tin6NDzVvcv6pUc9kQrbku8zcGAobjAQmA3KSTXp5oOZb0aCXyJghokdb58r CvZA== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@intel.com header.s=Intel header.b=hyDISlnx; 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 nb10-20020a1709071c8a00b0073093a35cf0si604572ejc.696.2022.08.18.00.02.15; Thu, 18 Aug 2022 00:02:15 -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=hyDISlnx; 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 3E3EA68B993; Thu, 18 Aug 2022 10:01:39 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mga05.intel.com (mga05.intel.com [192.55.52.43]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 2297A68B998 for ; Thu, 18 Aug 2022 10:01:35 +0300 (EEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1660806096; x=1692342096; h=from:to:subject:date:message-id:in-reply-to:references: mime-version:content-transfer-encoding; bh=q+7/OT6SrnFNB9SteH9me4DqQqi52wXjOF/cyLS5xRo=; b=hyDISlnxHLeSY+iHwX9njDrH2X7111+ZIgWBsGpFvFBG+iKibRXqA0Jt //OUT1AQDHThOnt8QLLuXiBtnYlEHbVJI+K2OIS64SUJztMDcNAU2lKbk aeh5Bg9mjefuT0lLb7JOCVg/RlzP0T+BG7d1HxeWRm9d962PNVDQnBtlK k6fv2MWkdZOPRYygv+pYTuC12259ragk6d/cbJf3k/eYZS2RHMdp7Gc7s Dr4pbcDqmccYt6EdY3QtwJUULe8z9JKTXWPSFd5tmYlOoggtSjVzxhTHp YBQrTE7iQao8B+LhrfbhQbuwSkZDjnLGAZay9P7YGvwvZh8rHhOsFL4TB Q==; X-IronPort-AV: E=McAfee;i="6500,9779,10442"; a="378975930" X-IronPort-AV: E=Sophos;i="5.93,245,1654585200"; d="scan'208";a="378975930" Received: from orsmga007.jf.intel.com ([10.7.209.58]) by fmsmga105.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 18 Aug 2022 00:01:16 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.93,245,1654585200"; d="scan'208";a="604155678" Received: from wenbin-z390-aorus-ultra.sh.intel.com ([10.239.35.4]) by orsmga007.jf.intel.com with ESMTP; 18 Aug 2022 00:01:15 -0700 From: Wenbin Chen To: ffmpeg-devel@ffmpeg.org Date: Thu, 18 Aug 2022 14:59:12 +0800 Message-Id: <20220818065912.158693-6-wenbin.chen@intel.com> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20220818065912.158693-1-wenbin.chen@intel.com> References: <20220818065912.158693-1-wenbin.chen@intel.com> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 6/6] libavcodec/qsvenc: Add low_delay_brc reset support to qsvenc 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: xYB4RnXkjSLw Signed-off-by: Wenbin Chen --- doc/encoders.texi | 4 ++++ libavcodec/qsvenc.c | 23 ++++++++++++++++++++++- libavcodec/qsvenc.h | 2 ++ 3 files changed, 28 insertions(+), 1 deletion(-) diff --git a/doc/encoders.texi b/doc/encoders.texi index fad3cad30b..d8e52006ce 100644 --- a/doc/encoders.texi +++ b/doc/encoders.texi @@ -3369,6 +3369,10 @@ Change these value to reset qsv codec's Intra Refresh configuration. @item @var{min_qp_b} Supported in h264_qsv. Change these value to reset qsv codec's max/min qp configuration. + +@item @var{low_delay_brc} +Supported in h264_qsv and hevc_qsv. +Change this value to reset qsv codec's low_delay_brc configuration. @end table @subsection H264 options diff --git a/libavcodec/qsvenc.c b/libavcodec/qsvenc.c index 3a3e6ccc9a..b53c25223a 100644 --- a/libavcodec/qsvenc.c +++ b/libavcodec/qsvenc.c @@ -934,6 +934,7 @@ static int init_video_param(AVCodecContext *avctx, QSVEncContext *q) q->old_int_ref_cycle_dist = q->int_ref_cycle_dist; if (q->low_delay_brc >= 0) q->extco3.LowDelayBRC = q->low_delay_brc ? MFX_CODINGOPTION_ON : MFX_CODINGOPTION_OFF; + q->old_low_delay_brc = q->low_delay_brc; if (q->max_frame_size_i >= 0) q->extco3.MaxFrameSizeI = q->max_frame_size_i; if (q->max_frame_size_p >= 0) @@ -1812,6 +1813,26 @@ static int update_min_max_qp(AVCodecContext *avctx, QSVEncContext *q) return updated; } +static int update_low_delay_brc(AVCodecContext *avctx, QSVEncContext *q) +{ + int updated = 0; + + if (avctx->codec_id != AV_CODEC_ID_H264 && avctx->codec_id != AV_CODEC_ID_HEVC) + return 0; + + UPDATE_PARAM(q->old_low_delay_brc, q->low_delay_brc); + if (!updated) + return 0; + + q->extco3.LowDelayBRC = MFX_CODINGOPTION_UNKNOWN; + if (q->low_delay_brc >= 0) + q->extco3.LowDelayBRC = q->low_delay_brc ? MFX_CODINGOPTION_ON : MFX_CODINGOPTION_OFF; + av_log(avctx, AV_LOG_DEBUG, "Reset LowDelayBRC: %s\n", + print_threestate(q->extco3.LowDelayBRC)); + + return updated; +} + static int update_parameters(AVCodecContext *avctx, QSVEncContext *q, const AVFrame *frame) { @@ -1824,7 +1845,7 @@ static int update_parameters(AVCodecContext *avctx, QSVEncContext *q, needReset |= update_max_frame_size(avctx, q); needReset |= update_gop_size(avctx, q); needReset |= update_rir(avctx, q); - + needReset |= update_low_delay_brc(avctx, q); ret = update_min_max_qp(avctx, q); if (ret < 0) return ret; diff --git a/libavcodec/qsvenc.h b/libavcodec/qsvenc.h index f48c87fbad..30db9dc94d 100644 --- a/libavcodec/qsvenc.h +++ b/libavcodec/qsvenc.h @@ -253,6 +253,8 @@ typedef struct QSVEncContext { int old_min_qp_p; int old_max_qp_b; int old_min_qp_b; + // This is used for low_delay_brc reset + int old_low_delay_brc; } QSVEncContext; int ff_qsv_enc_init(AVCodecContext *avctx, QSVEncContext *q);