[FFmpeg-cvslog] avcodec/libsvtav1: update some options and defaults
James Almer
git at videolan.org
Fri Feb 25 01:43:31 EET 2022
ffmpeg | branch: master | James Almer <jamrial at gmail.com> | Thu Feb 24 20:36:46 2022 -0300| [1dddb930aaf0cadaa19f86e81225c9c352745262] | committer: James Almer
avcodec/libsvtav1: update some options and defaults
And bump the minimum required version to 0.9.0
Signed-off-by: James Almer <jamrial at gmail.com>
> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=1dddb930aaf0cadaa19f86e81225c9c352745262
---
configure | 2 +-
doc/encoders.texi | 23 +++++----------------
libavcodec/libsvtav1.c | 55 ++++++++++++++++++++++++++++++++------------------
3 files changed, 41 insertions(+), 39 deletions(-)
diff --git a/configure b/configure
index 1535dc3c5b..4dab8d4715 100755
--- a/configure
+++ b/configure
@@ -6595,7 +6595,7 @@ enabled libsoxr && require libsoxr soxr.h soxr_create -lsoxr
enabled libssh && require_pkg_config libssh libssh libssh/sftp.h sftp_init
enabled libspeex && require_pkg_config libspeex speex speex/speex.h speex_decoder_init
enabled libsrt && require_pkg_config libsrt "srt >= 1.3.0" srt/srt.h srt_socket
-enabled libsvtav1 && require_pkg_config libsvtav1 "SvtAv1Enc >= 0.8.4" EbSvtAv1Enc.h svt_av1_enc_init_handle
+enabled libsvtav1 && require_pkg_config libsvtav1 "SvtAv1Enc >= 0.9.0" EbSvtAv1Enc.h svt_av1_enc_init_handle
enabled libtensorflow && require libtensorflow tensorflow/c/c_api.h TF_Version -ltensorflow
enabled libtesseract && require_pkg_config libtesseract tesseract tesseract/capi.h TessBaseAPICreate
enabled libtheora && require libtheora theora/theoraenc.h th_info_init -ltheoraenc -ltheoradec -logg
diff --git a/doc/encoders.texi b/doc/encoders.texi
index 6af9f19b04..9afb920f69 100644
--- a/doc/encoders.texi
+++ b/doc/encoders.texi
@@ -1775,28 +1775,15 @@ This is the default.
@item high
@end table
- at item rc
-Set the rate control mode to use.
-
-Possible modes:
- at table @option
- at item cqp
-Constant quantizer: use fixed values of qindex (dependent on the frame type)
-throughout the stream. This mode is the default.
-
- at item vbr
-Variable bitrate: use a target bitrate for the whole stream.
-
- at item cvbr
-Constrained variable bitrate: use a target bitrate for each GOP.
- at end table
-
@item qmax
Set the maximum quantizer to use when using a bitrate mode.
@item qmin
Set the minimum quantizer to use when using a bitrate mode.
+ at item crf
+Constant rate factor value used in crf rate control mode (0-63).
+
@item qp
Set the quantizer used in cqp rate control mode (0-63).
@@ -1807,8 +1794,8 @@ Enable scene change detection.
Set number of frames to look ahead (0-120).
@item preset
-Set the quality-speed tradeoff, in the range 0 to 8. Higher values are
-faster but lower quality. Defaults to 8 (highest speed).
+Set the quality-speed tradeoff, in the range 0 to 13. Higher values are
+faster but lower quality.
@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 e0287d867a..3b803a0a3c 100644
--- a/libavcodec/libsvtav1.c
+++ b/libavcodec/libsvtav1.c
@@ -68,7 +68,7 @@ typedef struct SvtContext {
int hierarchical_level;
int la_depth;
int enc_mode;
- int rc_mode;
+ int crf;
int scd;
int qp;
@@ -160,11 +160,32 @@ static int config_enc_params(EbSvtAv1EncConfiguration *param,
// Update param from options
param->hierarchical_levels = svt_enc->hierarchical_level;
- param->enc_mode = svt_enc->enc_mode;
+
+ if (svt_enc->enc_mode >= 0)
+ param->enc_mode = svt_enc->enc_mode;
+
param->tier = svt_enc->tier;
- param->rate_control_mode = svt_enc->rc_mode;
+
+ if (avctx->bit_rate) {
+ param->target_bit_rate = avctx->bit_rate;
+ if (avctx->rc_max_rate != avctx->bit_rate)
+ param->rate_control_mode = 1;
+ else
+ param->rate_control_mode = 2;
+ }
+ param->max_bit_rate = avctx->rc_max_rate;
+ param->vbv_bufsize = avctx->rc_buffer_size;
+
+ if (svt_enc->crf > 0) {
+ param->qp = svt_enc->crf;
+ param->rate_control_mode = 0;
+ param->enable_tpl_la = 1;
+ } else if (svt_enc->qp > 0) {
+ param->qp = svt_enc->qp;
+ param->rate_control_mode = 0;
+ param->enable_tpl_la = 0;
+ }
param->scene_change_detection = svt_enc->scd;
- param->qp = svt_enc->qp;
if (svt_enc->la_depth >= 0)
param->look_ahead_distance = svt_enc->la_depth;
@@ -224,8 +245,6 @@ static int config_enc_params(EbSvtAv1EncConfiguration *param,
param->profile = FF_PROFILE_AV1_HIGH;
}
- param->target_bit_rate = avctx->bit_rate;
-
if (avctx->gop_size > 0)
param->intra_period_length = avctx->gop_size - 1;
@@ -237,8 +256,8 @@ static int config_enc_params(EbSvtAv1EncConfiguration *param,
param->frame_rate_denominator = avctx->time_base.num * avctx->ticks_per_frame;
}
- param->enable_tpl_la = !!param->rate_control_mode;
- if (param->rate_control_mode) {
+ avctx->bit_rate = param->target_bit_rate;
+ if (avctx->bit_rate) {
param->max_qp_allowed = avctx->qmax;
param->min_qp_allowed = avctx->qmin;
}
@@ -508,8 +527,8 @@ static const AVOption options[] = {
{ "la_depth", "Look ahead distance [0, 120]", OFFSET(la_depth),
AV_OPT_TYPE_INT, { .i64 = -1 }, -1, 120, VE },
- { "preset", "Encoding preset [0, 8]",
- OFFSET(enc_mode), AV_OPT_TYPE_INT, { .i64 = MAX_ENC_PRESET }, 0, MAX_ENC_PRESET, VE },
+ { "preset", "Encoding preset",
+ OFFSET(enc_mode), AV_OPT_TYPE_INT, { .i64 = -1 }, -1, MAX_ENC_PRESET, VE },
{ "tier", "Set operating point tier", OFFSET(tier),
AV_OPT_TYPE_INT, { .i64 = 0 }, 0, 1, VE, "tier" },
@@ -546,14 +565,10 @@ static const AVOption options[] = {
{ LEVEL("7.3", 73) },
#undef LEVEL
- { "rc", "Bit rate control mode", OFFSET(rc_mode),
- AV_OPT_TYPE_INT, { .i64 = 0 }, 0, 2, VE , "rc"},
- { "cqp", "Constant quantizer", 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),
- AV_OPT_TYPE_INT, { .i64 = 50 }, 0, 63, VE },
+ { "crf", "Constant Rate Factor value", OFFSET(crf),
+ AV_OPT_TYPE_INT, { .i64 = 0 }, 0, 63, VE },
+ { "qp", "Initial Quantizer level value", OFFSET(qp),
+ AV_OPT_TYPE_INT, { .i64 = 0 }, 0, 63, VE },
{ "sc_detection", "Scene change detection", OFFSET(scd),
AV_OPT_TYPE_BOOL, { .i64 = 0 }, 0, 1, VE },
@@ -574,10 +589,10 @@ static const AVClass class = {
};
static const AVCodecDefault eb_enc_defaults[] = {
- { "b", "7M" },
+ { "b", "0" },
{ "flags", "+cgop" },
{ "g", "-1" },
- { "qmin", "0" },
+ { "qmin", "1" },
{ "qmax", "63" },
{ NULL },
};
More information about the ffmpeg-cvslog
mailing list