From patchwork Wed Mar 10 22:48:59 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christopher Degawa X-Patchwork-Id: 26334 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 9393644B92A for ; Thu, 11 Mar 2021 00:49:10 +0200 (EET) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 6988568AB83; Thu, 11 Mar 2021 00:49:10 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from degawa.com (unknown [174.127.109.95]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 2C7AC689B13 for ; Thu, 11 Mar 2021 00:49:03 +0200 (EET) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=randomderp.com; s=default; h=Content-Transfer-Encoding:MIME-Version: Message-Id:Date:Subject:Cc:To:From:Sender:Reply-To:Content-Type:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:In-Reply-To:References:List-Id:List-Help:List-Unsubscribe: List-Subscribe:List-Post:List-Owner:List-Archive; bh=rUfYj4gXZHuCtPWoI7Ykir022oSy5gTaOSxFO7iC/Ik=; b=kQ8OzqO6/QX9Xq4fSNpgD1o6jq ToLIE4Z1yQ476vwgxwmY9Nk/pRogVxTmNTNm0TbU+Fs6DvZrJDQZLk+1qbio7zHjVxxhbvap8YX3Z aSlZ+Z0hwCjCNCUTeUMQvVG+rIqxAvmGSuMlWCyZAnQzdFCxpzl2vRhx+WYAaKLOJwIvTGz2tuXyL 8RMNv1KagPwQDnd9iFETKR0Qu5jvwJjn9Fqq4MpT+Zhf/sTYDFBwIsQIgjWZD50RWU72v1S8ZFiCS hoOG2TE1n/uCfhbmZtmjZ7DhweYdVlAfBFRRr6jRS9WiqfJ5LAgqZPycuk5q8UFvEkF+MAfmTP+cF 5MqdL0lQ==; Received: from 108-216-168-194.lightspeed.mmphtn.sbcglobal.net ([108.216.168.194]:46704 helo=localhost.localdomain) by slmp-550-1.slc.westdc.net with esmtpsa (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.93) (envelope-from ) id 1lK7dV-00024X-7h; Wed, 10 Mar 2021 15:49:01 -0700 From: Christopher Degawa To: ffmpeg-devel@ffmpeg.org Date: Wed, 10 Mar 2021 16:48:59 -0600 Message-Id: <20210310224859.1726693-1-ccom@randomderp.com> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 X-AntiAbuse: This header was added to track abuse, please include it with any abuse report X-AntiAbuse: Primary Hostname - slmp-550-1.slc.westdc.net X-AntiAbuse: Original Domain - ffmpeg.org X-AntiAbuse: Originator/Caller UID/GID - [47 12] / [47 12] X-AntiAbuse: Sender Address Domain - randomderp.com X-Get-Message-Sender-Via: slmp-550-1.slc.westdc.net: authenticated_id: ccom/from_h X-Authenticated-Sender: slmp-550-1.slc.westdc.net: ccom@randomderp.com X-Source: X-Source-Args: X-Source-Dir: Subject: [FFmpeg-devel] [PATCH] libsvtav1: Add crf and enable_tpl_la options 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: Christopher Degawa Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" libsvtav1 internally changed cqp to be crf while enable-tp-la is on, which is on by default, and uses the same variables as cqp Signed-off-by: Christopher Degawa --- doc/encoders.texi | 14 +++++++++++++- libavcodec/libsvtav1.c | 15 +++++++++++++-- 2 files changed, 26 insertions(+), 3 deletions(-) diff --git a/doc/encoders.texi b/doc/encoders.texi index c9c8785afb..86b7d27aeb 100644 --- a/doc/encoders.texi +++ b/doc/encoders.texi @@ -1759,9 +1759,13 @@ Set the rate control mode to use. Possible modes: @table @option +@item crf +Constant quality mode: used a fixed value for quality throughout the stream. +This mode is the default. + @item cqp Constant quantizer: use fixed values of qindex (dependent on the frame type) -throughout the stream. This mode is the default. +throughout the stream. This mode is enabled if enable_tpl_la is disabled. @item vbr Variable bitrate: use a target bitrate for the whole stream. @@ -1776,6 +1780,9 @@ Set the maximum quantizer to use when using a bitrate mode. @item qmin Set the minimum quantizer to use when using a bitrate mode. +@item crf +Set the factor to use for the constant quality rate control mode (0-63). + @item qp Set the quantizer used in cqp rate control mode (0-63). @@ -1789,6 +1796,11 @@ Set number of frames to look ahead (0-120). Set the quality-speed tradeoff, in the range 0 to 8. Higher values are faster but lower quality. Defaults to 8 (highest speed). +@item enable_tpl_la +Enables changing the quantizer on a block to block basis within a frame +and only works if la_depth is set to greater than zero or is set to -1. +Is enabled by default and changes the cqp mode to crf (0-1). + @item tile_rows Set log2 of the number of rows of tiles to use (0-6). diff --git a/libavcodec/libsvtav1.c b/libavcodec/libsvtav1.c index eb6043bcac..17f69b005d 100644 --- a/libavcodec/libsvtav1.c +++ b/libavcodec/libsvtav1.c @@ -69,6 +69,8 @@ typedef struct SvtContext { int tier; + uint8_t enable_tpl_la; + int tile_columns; int tile_rows; } SvtContext; @@ -215,6 +217,8 @@ static int config_enc_params(EbSvtAv1EncConfiguration *param, if (svt_enc->la_depth >= 0) param->look_ahead_distance = svt_enc->la_depth; + param->enable_tpl_la = svt_enc->enable_tpl_la; + param->tile_columns = svt_enc->tile_columns; param->tile_rows = svt_enc->tile_rows; @@ -520,16 +524,23 @@ static const AVOption options[] = { { "rc", "Bit rate control mode", OFFSET(rc_mode), AV_OPT_TYPE_INT, { .i64 = 0 }, 0, 3, VE , "rc"}, - { "cqp", "Constant quantizer", 0, AV_OPT_TYPE_CONST, { .i64 = 0 }, INT_MIN, INT_MAX, VE, "rc" }, + { "crf", "Constant quality mode, alias to cqp if enable_tpl_la is set to 0", 0, AV_OPT_TYPE_CONST, { .i64 = 0 }, INT_MIN, INT_MAX, VE, "rc" }, + { "cqp", "Constant quantizer, alias to crf if enable_tpl_la is set to 1", 0, AV_OPT_TYPE_CONST, { .i64 = 0 }, INT_MIN, INT_MAX, VE, "rc" }, { "vbr", "Variable Bit Rate, use a target bitrate for the entire stream", 0, AV_OPT_TYPE_CONST, { .i64 = 1 }, INT_MIN, INT_MAX, VE, "rc" }, { "cvbr", "Constrained Variable Bit Rate, use a target bitrate for each GOP", 0, AV_OPT_TYPE_CONST,{ .i64 = 2 }, INT_MIN, INT_MAX, VE, "rc" }, - { "qp", "Quantizer to use with cqp rate control mode", OFFSET(qp), + { "crf", "Factor to use with for constant quality mode, alias to qp if enable_tpl_la is set to 0", OFFSET(qp), + AV_OPT_TYPE_INT, { .i64 = 50 }, 0, 63, VE }, + + { "qp", "Quantizer to use with cqp rate control mode, alias to crf if enable_tpl_la is set to 1", OFFSET(qp), AV_OPT_TYPE_INT, { .i64 = 50 }, 0, 63, VE }, { "sc_detection", "Scene change detection", OFFSET(scd), AV_OPT_TYPE_BOOL, { .i64 = 0 }, 0, 1, VE }, + { "enable_tpl_la", "Enable changing qp on a block to block basis within a frame, only works if la_depth is greater than 0", OFFSET(enable_tpl_la), + AV_OPT_TYPE_BOOL, {.i64 = 1}, 0, 1, VE}, + { "tile_columns", "Log2 of number of tile columns to use", OFFSET(tile_columns), AV_OPT_TYPE_INT, {.i64 = 0}, 0, 4, VE}, { "tile_rows", "Log2 of number of tile rows to use", OFFSET(tile_rows), AV_OPT_TYPE_INT, {.i64 = 0}, 0, 6, VE},