* [FFmpeg-devel] [PATCH] avcodec/libsvtav1: add a svtav1-params option to pass a list of key=value parameters
@ 2022-02-16 13:37 James Almer
0 siblings, 0 replies; only message in thread
From: James Almer @ 2022-02-16 13:37 UTC (permalink / raw)
To: ffmpeg-devel
Signed-off-by: James Almer <jamrial@gmail.com>
---
doc/encoders.texi | 3 +++
libavcodec/libsvtav1.c | 52 ++++++++++++++++++++++++++++++------------
2 files changed, 41 insertions(+), 14 deletions(-)
diff --git a/doc/encoders.texi b/doc/encoders.texi
index bfb6c7eef6..1a040bccdd 100644
--- a/doc/encoders.texi
+++ b/doc/encoders.texi
@@ -1816,6 +1816,9 @@ Set log2 of the number of rows of tiles to use (0-6).
@item tile_columns
Set log2 of the number of columns of tiles to use (0-4).
+@item svtav1-params
+Set the SVT-AV1 configuration using a :-separated list of key=value parameters
+
@end table
@section libkvazaar
diff --git a/libavcodec/libsvtav1.c b/libavcodec/libsvtav1.c
index 6196da25e6..ce3b0ba7ac 100644
--- a/libavcodec/libsvtav1.c
+++ b/libavcodec/libsvtav1.c
@@ -60,6 +60,7 @@ typedef struct SvtContext {
EOS_STATUS eos_flag;
// User options.
+ AVDictionary *svtav1_opts;
int hierarchical_level;
int la_depth;
int enc_mode;
@@ -151,6 +152,41 @@ static int config_enc_params(EbSvtAv1EncConfiguration *param,
{
SvtContext *svt_enc = avctx->priv_data;
const AVPixFmtDescriptor *desc;
+ AVDictionaryEntry *en = NULL;
+
+ // Update param from options
+ param->hierarchical_levels = svt_enc->hierarchical_level;
+ param->enc_mode = svt_enc->enc_mode;
+ param->tier = svt_enc->tier;
+ param->rate_control_mode = svt_enc->rc_mode;
+ 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;
+
+ param->tile_columns = svt_enc->tile_columns;
+ param->tile_rows = svt_enc->tile_rows;
+
+#if SVT_AV1_CHECK_VERSION(0, 9, 1)
+ while ((en = av_dict_get(svt_enc->svtav1_opts, "", en, AV_DICT_IGNORE_SUFFIX))) {
+ EbErrorType ret = svt_av1_enc_parse_parameter(param, en->key, en->value);
+ if (ret != EB_ErrorNone) {
+ int level = (avctx->err_recognition & AV_EF_EXPLODE) ? AV_LOG_ERROR : AV_LOG_WARNING;
+ av_log(avctx, level, "Error parsing option %s: %s.\n", en->key, en->value);
+ if (avctx->err_recognition & AV_EF_EXPLODE)
+ return AVERROR(EINVAL);
+ }
+ }
+#else
+ if ((en = av_dict_get(svt_enc->svtav1_opts, "", NULL, AV_DICT_IGNORE_SUFFIX))) {
+ int level = (avctx->err_recognition & AV_EF_EXPLODE) ? AV_LOG_ERROR : AV_LOG_WARNING;
+ av_log(avctx, level, "svt-params needs libavcodec to be compiled with SVT-AV1 "
+ "headers >= 0.9.1.\n");
+ if (avctx->err_recognition & AV_EF_EXPLODE)
+ return AVERROR(ENOSYS);
+ }
+#endif
param->source_width = avctx->width;
param->source_height = avctx->height;
@@ -184,14 +220,6 @@ static int config_enc_params(EbSvtAv1EncConfiguration *param,
param->profile = FF_PROFILE_AV1_HIGH;
}
- // Update param from options
- param->hierarchical_levels = svt_enc->hierarchical_level;
- param->enc_mode = svt_enc->enc_mode;
- param->tier = svt_enc->tier;
- param->rate_control_mode = svt_enc->rc_mode;
- param->scene_change_detection = svt_enc->scd;
- param->qp = svt_enc->qp;
-
param->target_bit_rate = avctx->bit_rate;
if (avctx->gop_size > 0)
@@ -214,12 +242,6 @@ static int config_enc_params(EbSvtAv1EncConfiguration *param,
/* 2 = IDR, closed GOP, 1 = CRA, open GOP */
param->intra_refresh_type = avctx->flags & AV_CODEC_FLAG_CLOSED_GOP ? 2 : 1;
- if (svt_enc->la_depth >= 0)
- param->look_ahead_distance = svt_enc->la_depth;
-
- param->tile_columns = svt_enc->tile_columns;
- param->tile_rows = svt_enc->tile_rows;
-
return 0;
}
@@ -535,6 +557,8 @@ static const AVOption options[] = {
{ "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},
+ { "svtav1-params", "Set the SVT-AV1 configuration using a :-separated list of key=value parameters", OFFSET(svtav1_opts), AV_OPT_TYPE_DICT, { 0 }, 0, 0, VE },
+
{NULL},
};
--
2.35.1
_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
To unsubscribe, visit link above, or email
ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2022-02-16 13:38 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-02-16 13:37 [FFmpeg-devel] [PATCH] avcodec/libsvtav1: add a svtav1-params option to pass a list of key=value parameters James Almer
Git Inbox Mirror of the ffmpeg-devel mailing list - see https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
This inbox may be cloned and mirrored by anyone:
git clone --mirror https://master.gitmailbox.com/ffmpegdev/0 ffmpegdev/git/0.git
# If you have public-inbox 1.1+ installed, you may
# initialize and index your mirror using the following commands:
public-inbox-init -V2 ffmpegdev ffmpegdev/ https://master.gitmailbox.com/ffmpegdev \
ffmpegdev@gitmailbox.com
public-inbox-index ffmpegdev
Example config snippet for mirrors.
AGPL code for this site: git clone https://public-inbox.org/public-inbox.git