From patchwork Tue Jan 25 07:12:35 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Chen, Wenbin" X-Patchwork-Id: 33834 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6602:2c4e:0:0:0:0 with SMTP id x14csp378941iov; Mon, 24 Jan 2022 23:13:27 -0800 (PST) X-Google-Smtp-Source: ABdhPJzrqPbgToed9nkMhHqQ2B3ZoVA3f3HQ7RswjjhKxvnSNjrsBaDV1Z66XqsZh3hLLiXdzdEU X-Received: by 2002:a17:907:3e98:: with SMTP id hs24mr4078084ejc.615.1643094807254; Mon, 24 Jan 2022 23:13:27 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1643094807; cv=none; d=google.com; s=arc-20160816; b=UHCuoLmtaH3DzDGq3FOHiRoLvWhkkNH6sXvJ8Ar76w5sz9CkHiY/O8W8jWK2IgKuR+ lWZz5HrGgKc48i9QNC70fEEfeM4FdmoEMOf8vS1jmAqUysw22XWueLgXQr6diaPbEFt2 QIM6auA7BvS/ixhyXyKS12uuFeglOrYP0QUiboxELxl0bNilrs1Omq3R00ByW6qq1B5v Pxyi1+bSnbQ3oDx/Odim2C3o/YpY+6fBA1mnkRSyaUyY/HbhtD5OYj3vzzO8kHAWuaOA SCKJkjS+3DoPdMlPhO0EqK2FLunnXkaLOu8RktHQTCKFN6+rIzZNDcLnl0gMjABavWr0 p/iA== 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=SCY8cOBxu/t7WBmtHNj0Se8b5S5FGFuanP7tHXX9i28=; b=Q4xPJ7PZWmwLUbrKf5ceAl02R082Gdnd1QOk9AjJeOVpUnAkRSNvqLw0/KiG5KCMui ZVG0NbmL5271FAX8Xo9xG4T+XMCKvzFfPv31C1QTV5o2+KoIaNN3CiA9F9xQ7X3DQ9uL /Erw4Y/TSaNX8eQcLDdYD4FJ0CU56sMD1rI0Fx3+TpuvJeW4Sgo4xggXnK8tIOXrig/+ iAICAVN/XgKG2K/pACGOVDI1NEQDqD0yY1epalVMDuFCjCDSLXCUlKHKlIs6xKqqfH6P uKyc7Oo8OUFRPczWjI1N72j2fM1XoFjMR0DbuOvDR4Q2mpFowgOyBMu5HRbCSPU+ReLn 5yOg== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@intel.com header.s=Intel header.b=mDjf5b7Q; 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 6si4716096ejk.189.2022.01.24.23.13.19; Mon, 24 Jan 2022 23:13:27 -0800 (PST) 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=mDjf5b7Q; 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 161AF68B098; Tue, 25 Jan 2022 09:13:06 +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 E56FB68AF12 for ; Tue, 25 Jan 2022 09:12:57 +0200 (EET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1643094783; x=1674630783; h=from:to:subject:date:message-id:mime-version: content-transfer-encoding; bh=Yn3cDr09hwWU6yIIfR4ftO9CYdRQ0Vd8LSXbhxKvQ8s=; b=mDjf5b7QWR0+JE5zTxtfudo9XY0ork35qqd9QtiG1GnSK+OuvuCzg+Nz OOtjfINw4iP74FgssFF1Hkm5YiEqsMZJXhiw248BzT56wyHQD2wkyNlTH m/QYKDXRuLqGSFbVae4q8Mv2p/C7O1bBrxWu82zb5Zi6okT4NLic4g0do yLuAbGLU3R0YRfBDhbMo1Rluvj65kdKPLgDsB3+3LdazYiQL1r1WrFmlU XFuHMGuLxXof84CLmuzX7R3PSU3TeD8d/mrd0SRPAl8O/FP4ZAR/eqd9o D5iCAMJAD1QWG8W+SdPqd4GX9EbIJauW7FcNvCyGHaOkVMzCy8QmMWQPy Q==; X-IronPort-AV: E=McAfee;i="6200,9189,10237"; a="309557547" X-IronPort-AV: E=Sophos;i="5.88,314,1635231600"; d="scan'208";a="309557547" Received: from orsmga005.jf.intel.com ([10.7.209.41]) by orsmga105.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 24 Jan 2022 23:12:38 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.88,314,1635231600"; d="scan'208";a="695729643" Received: from wenbin-z390-aorus-ultra.sh.intel.com ([10.239.35.110]) by orsmga005.jf.intel.com with ESMTP; 24 Jan 2022 23:12:37 -0800 From: Wenbin Chen To: ffmpeg-devel@ffmpeg.org Date: Tue, 25 Jan 2022 15:12:35 +0800 Message-Id: <20220125071237.58735-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/qsvenc: Add max slice size support to hevc_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: H3jiBKHdPIez Add max_slice_size option to hevc_qsv as well. Signed-off-by: Wenbin Chen --- doc/encoders.texi | 3 +++ libavcodec/qsvenc.c | 9 ++++----- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/doc/encoders.texi b/doc/encoders.texi index e3adbf4325..8966610263 100644 --- a/doc/encoders.texi +++ b/doc/encoders.texi @@ -3397,6 +3397,9 @@ Enable rate distortion optimization. @item @var{max_frame_size} Maximum encoded frame size in bytes. +@item @var{max_slice_size} +Maximum encoded slice size in bytes. + @item @var{p_strategy} Enable P-pyramid: 0-default 1-simple 2-pyramid(bf need to be set to 0). diff --git a/libavcodec/qsvenc.c b/libavcodec/qsvenc.c index 413e5ae8f6..f311cd9ce4 100644 --- a/libavcodec/qsvenc.c +++ b/libavcodec/qsvenc.c @@ -877,11 +877,6 @@ static int init_video_param(AVCodecContext *avctx, QSVEncContext *q) if (q->mbbrc >= 0) q->extco2.MBBRC = q->mbbrc ? MFX_CODINGOPTION_ON : MFX_CODINGOPTION_OFF; -#if QSV_HAVE_MAX_SLICE_SIZE - if (q->max_slice_size >= 0) - q->extco2.MaxSliceSize = q->max_slice_size; -#endif - #if QSV_HAVE_TRELLIS if (avctx->trellis >= 0) q->extco2.Trellis = (avctx->trellis == 0) ? MFX_TRELLIS_OFF : (MFX_TRELLIS_I | MFX_TRELLIS_P | MFX_TRELLIS_B); @@ -907,6 +902,10 @@ 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; +#if QSV_HAVE_MAX_SLICE_SIZE + if (q->max_slice_size >= 0) + q->extco2.MaxSliceSize = q->max_slice_size; +#endif #if QSV_HAVE_DISABLEDEBLOCKIDC q->extco2.DisableDeblockingIdc = q->dblk_idc; #endif From patchwork Tue Jan 25 07:12:36 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Chen, Wenbin" X-Patchwork-Id: 33833 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6602:2c4e:0:0:0:0 with SMTP id x14csp378871iov; Mon, 24 Jan 2022 23:13:17 -0800 (PST) X-Google-Smtp-Source: ABdhPJx7yBtY/6lSw8gdwNoujBr31s39tH1eCKzaqiTGEUfZqXedxVBVRAXleUagoerHaV2pc1wy X-Received: by 2002:a17:907:1607:: with SMTP id hb7mr8135271ejc.726.1643094796945; Mon, 24 Jan 2022 23:13:16 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1643094796; cv=none; d=google.com; s=arc-20160816; b=DsxSudbrmAwsMejhKxqcxonXTeD25NL0+0BfoFhpVaiXxl0Zm5Af2MOt5PmbHs1SDF tbJUU/yVYs9BN5Q+pQ42hbqIp/fMZjW9EcenRV3xlZSHTYzuHanZhVEA4zmxI1fQPPa8 OAIvYoyz73TF+ujqFMYBuAW8RZpwy4bk8ThjYvob8QaktrWPVw2vnutRtk9XcMkMAGcY 72BmEHuEJ54rpy/MM4wzJSdYt6DQxOcsIWGbZrFQtXERZDD29SFpBbuTD2eEp1I86Wsy POdSCRjI46WR6mEkrU1+renXbxO2ZBJQK7borB7riVxZNZUsJvLqIGoPs5ysNshlInuf dKng== 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=8UBKWvxnW9nlJSHMq69N4TPEexVjquLEpVwgvBotm1Q=; b=vNZ/7a00DaiRmMyekgMCUdvCulqQ8a3SAY94BRRPuMFQNvOGVXkq6HolHt6mw7hXP3 4yBVbFeNvnDdKE4rrmZZ+VWdi7k8jdl5rCp758mmHfhcaS8UtV4pX9BQbqXu/kX+ksXk kg9xu/zw8sLckgXZaC7dXwXtk+f7q/BWrURy3dNocEanrE0peafmt6YrH20lae8+uekr y348UI+xzDTgOSclHA9gWLTNLw+kW/1ucIpoZztXm8+E3u29owNae1UChaX+DUDVu96E WeZyaEGOM0KeLbfhqplLR98eIjsIfYUHW1dO6S99Q2m41MCf7QCR9G+v581e4cQ0MdKs M6sg== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@intel.com header.s=Intel header.b=AUCMFdKr; 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 y25si8838162ejk.148.2022.01.24.23.13.08; Mon, 24 Jan 2022 23:13:16 -0800 (PST) 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=AUCMFdKr; 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 ED16768AF12; Tue, 25 Jan 2022 09:13:04 +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 E873368B036 for ; Tue, 25 Jan 2022 09:12:57 +0200 (EET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1643094783; x=1674630783; h=from:to:subject:date:message-id:in-reply-to:references: mime-version:content-transfer-encoding; bh=RSTqmcKBmXNOOeLIi9ZxheO7+x4wj4kM8ZWhSWw3t+A=; b=AUCMFdKrRxAyaluKXLvnH50hCEHBNGtlgEfhTE20CVmurmtljqFxMiBe VT6uaRNlJxbXdWPVJe818rLhbeu5JZh5o+ZgZ5uHGiCn9Sbh4TjOf9JUK dCRNKeFp9ZTQ/ZXtoGJC5yfmhGXHvFR5GUSQJRVL+1CsoZwSF8stg+mXY 9rTmvtk74D0Zt2kKJ/VsXxR+ueG9BJzUpns7i6MY98VJpsVlhCzRKR9Xy npQL9JMT8Me3Amn+RABc7IqwTO+OQPdsnr4CbnI5ghDjyi3Z+dOZn3j48 bpS4aVnZDffE8CULWXCttpfNbUTGMm/GsMfHsUamGuHPazIhHKIZRCgDV w==; X-IronPort-AV: E=McAfee;i="6200,9189,10237"; a="309557549" X-IronPort-AV: E=Sophos;i="5.88,314,1635231600"; d="scan'208";a="309557549" Received: from orsmga005.jf.intel.com ([10.7.209.41]) by orsmga105.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 24 Jan 2022 23:12:38 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.88,314,1635231600"; d="scan'208";a="695729645" Received: from wenbin-z390-aorus-ultra.sh.intel.com ([10.239.35.110]) by orsmga005.jf.intel.com with ESMTP; 24 Jan 2022 23:12:38 -0800 From: Wenbin Chen To: ffmpeg-devel@ffmpeg.org Date: Tue, 25 Jan 2022 15:12:36 +0800 Message-Id: <20220125071237.58735-2-wenbin.chen@intel.com> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20220125071237.58735-1-wenbin.chen@intel.com> References: <20220125071237.58735-1-wenbin.chen@intel.com> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH V2 2/3] libavcodec/qsvenc: Add b_strategy option to hevc_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: HLty/XkG0zv5 Add b_strategy option to hevc_qsv. By enabling this option, encoder can use b frames as reference. Signed-off-by: Wenbin Chen --- doc/encoders.texi | 3 +++ libavcodec/qsvenc.c | 6 ++++-- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/doc/encoders.texi b/doc/encoders.texi index 8966610263..6c1c4df57a 100644 --- a/doc/encoders.texi +++ b/doc/encoders.texi @@ -3403,6 +3403,9 @@ Maximum encoded slice size in bytes. @item @var{p_strategy} Enable P-pyramid: 0-default 1-simple 2-pyramid(bf need to be set to 0). +@item @var{b_strategy} +This option controls usage of B frames as reference. + @item @var{dblk_idc} This option disable deblocking. It has value in range 0~2. diff --git a/libavcodec/qsvenc.c b/libavcodec/qsvenc.c index f311cd9ce4..a8d876d6d9 100644 --- a/libavcodec/qsvenc.c +++ b/libavcodec/qsvenc.c @@ -888,8 +888,6 @@ static int init_video_param(AVCodecContext *avctx, QSVEncContext *q) q->extco2.LookAheadDS = q->look_ahead_downsampling; q->extco2.RepeatPPS = q->repeat_pps ? MFX_CODINGOPTION_ON : MFX_CODINGOPTION_OFF; - if (q->b_strategy >= 0) - q->extco2.BRefType = q->b_strategy ? MFX_B_REF_PYRAMID : MFX_B_REF_OFF; if (q->adaptive_i >= 0) q->extco2.AdaptiveI = q->adaptive_i ? MFX_CODINGOPTION_ON : MFX_CODINGOPTION_OFF; if (q->adaptive_b >= 0) @@ -910,6 +908,10 @@ static int init_video_param(AVCodecContext *avctx, QSVEncContext *q) q->extco2.DisableDeblockingIdc = q->dblk_idc; #endif +#if QSV_VERSION_ATLEAST(1, 8) + if (q->b_strategy >= 0) + q->extco2.BRefType = q->b_strategy ? MFX_B_REF_PYRAMID : MFX_B_REF_OFF; +#endif #if QSV_VERSION_ATLEAST(1, 9) if (avctx->qmin >= 0 && avctx->qmax >= 0 && avctx->qmin > avctx->qmax) { av_log(avctx, AV_LOG_ERROR, "qmin and or qmax are set but invalid, please make sure min <= max\n"); From patchwork Tue Jan 25 07:12:37 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Chen, Wenbin" X-Patchwork-Id: 33835 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6602:2c4e:0:0:0:0 with SMTP id x14csp379024iov; Mon, 24 Jan 2022 23:13:36 -0800 (PST) X-Google-Smtp-Source: ABdhPJxBH53G5dCjCrVxSeB+NYJ2LroidsJNJPF2Slqg1rVUuai5opVf0E+rqBryKvvixnPfNDbl X-Received: by 2002:a17:907:2d90:: with SMTP id gt16mr14994605ejc.495.1643094816582; Mon, 24 Jan 2022 23:13:36 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1643094816; cv=none; d=google.com; s=arc-20160816; b=NxEHEI7DiVbi3wKTrCoFzMwG4AUpaX1/z4qkhDSewymRUTqfLogbnBNpJS4gviMDT/ 1XGHcxN++ySV7O9gm1614iwovYBKW+e0Ja1WFDRpEmBMXQZum0bnTQZ2CR4VWGq783rj gwv2AeVYh7akZUfmsD22F1bdH/syl/bBjah9CGQqpojX9MH5x6xJzzJBQlSIkMJtZc5D aFPs3A+BEP1bMARMuuiQU4e9BpBbXdkOwTwrgpbIJnQ2jH7o2Gxyw/JztWZmXPZslgHY zQKBfh4pRChLXD56cmw58lV9vlfWFYL85qomXV3TktEadDaAcTqi4C59UaV2usA2Or+r keGg== 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=vG/jTrkTcKjLo2sNJjaJJ8IEox451+afFkcVSChEuLs=; b=RncG3lkQoDi3LazjL+Aoq8R9jz380QV/qdUVTLdE9dDO5ZDSdZi9TGIIDFcPtSFLMf U+srnBI4wMYSNVOG9U7OqVZAkntPQektKyoE+T5AFVhHot7C/22Qs1CssJjaU17fVsx5 NE3GfPay4S/Z8TEAU//rhHJ6jlI3MBuz33sYrA6V0Lrow463+KjyqlSmA0wpTmPSCYiL ZnoBUxbLiBmm4EkvY9+XXIxCBWmcp9nCHvmTIgbgdhq477jvzeOVeo9ZbepUOkl5ldBr QgC6TacQbXifozPm8q+dF8fg8c1RLPq3kooT4vYCSuAzUYg7nmb5vqufLrk3xmPJ0vYX qrGQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@intel.com header.s=Intel header.b=NngrLYuJ; 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 hq25si10776021ejc.691.2022.01.24.23.13.28; Mon, 24 Jan 2022 23:13:36 -0800 (PST) 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=NngrLYuJ; 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 1528068B0B7; Tue, 25 Jan 2022 09:13:11 +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 DA40768AFFD for ; Tue, 25 Jan 2022 09:13:03 +0200 (EET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1643094789; x=1674630789; h=from:to:subject:date:message-id:in-reply-to:references: mime-version:content-transfer-encoding; bh=TxqG5VmJg3aU29fKJtVc+HD+SjS1pnV1SPGNnyUrlZU=; b=NngrLYuJs0gLXDpi63OGYo6XLMUS5/WqAi+Ok5jExiSyk2AblaM43Dal epqlmPregSyWQbwW0qnSxMmMTze0SI6ekKrik6hksmBl1Qd40/Fmzy6dX t/ME56zmfMDsmQIkhp8pQWbkEErCao1p3zc+1AUaUMvwVZddkx0r6Wfd7 2x9MWUPrUyvC/yH28mAFIRsV7P6X5TeSwXZ5j0p3lzZK/xI6R7d27h6jI PzcbPdHk6s2cNIyWI+oWynmjfNbMS8qxXDrUDo+E2wQBmL3pA6vNJu9t0 kMOSL5PcAcQ9Ej/6i49cHfHvvlncz9hGqo5ovTAIEHUH7X684oZg+Ux61 Q==; X-IronPort-AV: E=McAfee;i="6200,9189,10237"; a="309557552" X-IronPort-AV: E=Sophos;i="5.88,314,1635231600"; d="scan'208";a="309557552" Received: from orsmga005.jf.intel.com ([10.7.209.41]) by orsmga105.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 24 Jan 2022 23:12:39 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.88,314,1635231600"; d="scan'208";a="695729647" Received: from wenbin-z390-aorus-ultra.sh.intel.com ([10.239.35.110]) by orsmga005.jf.intel.com with ESMTP; 24 Jan 2022 23:12:38 -0800 From: Wenbin Chen To: ffmpeg-devel@ffmpeg.org Date: Tue, 25 Jan 2022 15:12:37 +0800 Message-Id: <20220125071237.58735-3-wenbin.chen@intel.com> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20220125071237.58735-1-wenbin.chen@intel.com> References: <20220125071237.58735-1-wenbin.chen@intel.com> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH V2 3/3] libavcodec/qsvenc: Add intra refresh to hevc_qsv and add new intra refresh parameter 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: ZznTcA1Mfhj8 Add intra refresh support to hevc_qsv as well. Add an new intra refresh type: "horizontal", and an new param ref_cycle_dist. This param specify the distance between the beginnings of the intra-refresh cycles in frames. Signed-off-by: Wenbin Chen --- doc/encoders.texi | 26 +++++++++++++++++++++++++- libavcodec/qsvenc.c | 21 ++++++++++++++------- libavcodec/qsvenc.h | 1 + libavcodec/qsvenc_h264.c | 7 +++++-- libavcodec/qsvenc_hevc.c | 9 +++++++++ 5 files changed, 54 insertions(+), 10 deletions(-) diff --git a/doc/encoders.texi b/doc/encoders.texi index 6c1c4df57a..4e35e50e4d 100644 --- a/doc/encoders.texi +++ b/doc/encoders.texi @@ -3344,7 +3344,8 @@ 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. +vertical refresh, by column of MBs. 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 @@ -3355,6 +3356,9 @@ Specifies QP difference for inserted intra MBs. This is signed value in [-51, 51] range if target encoding bit-depth for luma samples is 8 and this range is [-63, 63] for 10 bit-depth or [-75, 75] for 12 bit-depth respectively. +@item @var{int_ref_cycle_dist} +Distance between the beginnings of the intra-refresh cycles in frames. + @item @var{profile} @table @samp @item unknown @@ -3463,6 +3467,26 @@ Insert picture timing SEI with pic_struct_syntax element. @item @var{transform_skip} Turn this option ON to enable transformskip. It is supported on platform equal or newer than ICL. + +@item @var{int_ref_type} +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. + +@item @var{int_ref_cycle_size} +Specifies number of pictures within refresh cycle starting from 2. 0 and 1 are +invalid values. + +@item @var{int_ref_qp_delta} +Specifies QP difference for inserted intra MBs. This is signed value in +[-51, 51] range if target encoding bit-depth for luma samples is 8 and this +range is [-63, 63] for 10 bit-depth or [-75, 75] for 12 bit-depth respectively. + +@item @var{int_ref_cycle_dist} +Distance between the beginnings of the intra-refresh cycles in frames. @end table @subsection MPEG2 Options diff --git a/libavcodec/qsvenc.c b/libavcodec/qsvenc.c index a8d876d6d9..c31776d536 100644 --- a/libavcodec/qsvenc.c +++ b/libavcodec/qsvenc.c @@ -364,6 +364,10 @@ static void dump_video_param(AVCodecContext *avctx, QSVEncContext *q, #if QSV_VERSION_ATLEAST(1, 26) av_log(avctx, AV_LOG_VERBOSE, "TransformSkip: %s \n", print_threestate(co3->TransformSkip)); #endif + +#if QSV_VERSION_ATLEAST(1, 16) + av_log(avctx, AV_LOG_VERBOSE, "IntRefCycleDist: %"PRId16"\n", co3->IntRefCycleDist); +#endif } static void dump_video_vp9_param(AVCodecContext *avctx, QSVEncContext *q, @@ -865,13 +869,6 @@ static int init_video_param(AVCodecContext *avctx, QSVEncContext *q) #if QSV_HAVE_CO2 if (avctx->codec_id == AV_CODEC_ID_H264) { - if (q->int_ref_type >= 0) - q->extco2.IntRefType = q->int_ref_type; - if (q->int_ref_cycle_size >= 0) - q->extco2.IntRefCycleSize = q->int_ref_cycle_size; - if (q->int_ref_qp_delta != INT16_MIN) - q->extco2.IntRefQPDelta = q->int_ref_qp_delta; - if (q->bitrate_limit >= 0) q->extco2.BitrateLimit = q->bitrate_limit ? MFX_CODINGOPTION_ON : MFX_CODINGOPTION_OFF; if (q->mbbrc >= 0) @@ -900,6 +897,12 @@ 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; + if (q->int_ref_type >= 0) + q->extco2.IntRefType = q->int_ref_type; + if (q->int_ref_cycle_size >= 0) + q->extco2.IntRefCycleSize = q->int_ref_cycle_size; + if (q->int_ref_qp_delta != INT16_MIN) + q->extco2.IntRefQPDelta = q->int_ref_qp_delta; #if QSV_HAVE_MAX_SLICE_SIZE if (q->max_slice_size >= 0) q->extco2.MaxSliceSize = q->max_slice_size; @@ -973,6 +976,10 @@ static int init_video_param(AVCodecContext *avctx, QSVEncContext *q) av_log(avctx, AV_LOG_WARNING, "Please set max_b_frames(-bf) to 0 to enable P-pyramid\n"); } +#endif +#if QSV_VERSION_ATLEAST(1, 16) + if (q->int_ref_cycle_dist >= 0) + q->extco3.IntRefCycleDist = q->int_ref_cycle_dist; #endif } diff --git a/libavcodec/qsvenc.h b/libavcodec/qsvenc.h index 65f035045c..5fa0b6f5ba 100644 --- a/libavcodec/qsvenc.h +++ b/libavcodec/qsvenc.h @@ -195,6 +195,7 @@ typedef struct QSVEncContext { int int_ref_type; int int_ref_cycle_size; int int_ref_qp_delta; + int int_ref_cycle_dist; int recovery_point_sei; int repeat_pps; diff --git a/libavcodec/qsvenc_h264.c b/libavcodec/qsvenc_h264.c index 9f127607b7..bec3633268 100644 --- a/libavcodec/qsvenc_h264.c +++ b/libavcodec/qsvenc_h264.c @@ -126,13 +126,16 @@ static const AVOption options[] = { { "4x" , NULL, 0, AV_OPT_TYPE_CONST, { .i64 = MFX_LOOKAHEAD_DS_4x }, INT_MIN, INT_MAX, VE, "look_ahead_downsampling" }, #endif - { "int_ref_type", "Intra refresh type", OFFSET(qsv.int_ref_type), AV_OPT_TYPE_INT, { .i64 = -1 }, -1, UINT16_MAX, VE, "int_ref_type" }, + { "int_ref_type", "Intra refresh type. B frames should be set to 0.", OFFSET(qsv.int_ref_type), AV_OPT_TYPE_INT, { .i64 = -1 }, -1, UINT16_MAX, VE, "int_ref_type" }, { "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" }, { "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 }, - +#if QSV_VERSION_ATLEAST(1, 16) + { "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 }, +#endif { "profile", NULL, OFFSET(qsv.profile), AV_OPT_TYPE_INT, { .i64 = MFX_PROFILE_UNKNOWN }, 0, INT_MAX, VE, "profile" }, { "unknown" , NULL, 0, AV_OPT_TYPE_CONST, { .i64 = MFX_PROFILE_UNKNOWN }, INT_MIN, INT_MAX, VE, "profile" }, { "baseline", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = MFX_PROFILE_AVC_BASELINE }, INT_MIN, INT_MAX, VE, "profile" }, diff --git a/libavcodec/qsvenc_hevc.c b/libavcodec/qsvenc_hevc.c index 91a316f9c8..5cac141c4d 100644 --- a/libavcodec/qsvenc_hevc.c +++ b/libavcodec/qsvenc_hevc.c @@ -258,6 +258,15 @@ static const AVOption options[] = { #if QSV_VERSION_ATLEAST(1, 26) { "transform_skip", "Turn this option ON to enable transformskip", OFFSET(qsv.transform_skip), AV_OPT_TYPE_INT, { .i64 = -1}, -1, 1, VE}, #endif + { "int_ref_type", "Intra refresh type. B frames should be set to 0", OFFSET(qsv.int_ref_type), AV_OPT_TYPE_INT, { .i64 = -1 }, -1, UINT16_MAX, VE, "int_ref_type" }, + { "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" }, + { "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 }, +#if QSV_VERSION_ATLEAST(1, 16) + { "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 }, +#endif { NULL }, };