diff mbox series

[FFmpeg-devel] libsvtav1: Add crf and enable_tpl_la options

Message ID 20210310224859.1726693-1-ccom@randomderp.com
State New
Headers show
Series [FFmpeg-devel] libsvtav1: Add crf and enable_tpl_la options
Related show

Checks

Context Check Description
andriy/x86_make success Make finished
andriy/x86_make_fate success Make fate finished
andriy/PPC64_make success Make finished
andriy/PPC64_make_fate success Make fate finished

Commit Message

Christopher Degawa March 10, 2021, 10:48 p.m. UTC
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 <ccom@randomderp.com>
---
 doc/encoders.texi      | 14 +++++++++++++-
 libavcodec/libsvtav1.c | 15 +++++++++++++--
 2 files changed, 26 insertions(+), 3 deletions(-)

Comments

Christopher Degawa March 17, 2021, 4:45 a.m. UTC | #1
ping on this patch
Christopher Degawa March 23, 2021, 5:35 p.m. UTC | #2
ping again, would rather not have to maintain this and the
logical_processor patch out of tree
Christopher Degawa April 21, 2021, 11:52 p.m. UTC | #3
ping.
diff mbox series

Patch

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},