From: James Almer <jamrial@gmail.com> To: ffmpeg-devel@ffmpeg.org Subject: [FFmpeg-devel] [PATCH] avcodec/libsvtav1: add a svtav1-params option to pass a list of key=value parameters Date: Wed, 16 Feb 2022 10:37:02 -0300 Message-ID: <20220216133702.959-1-jamrial@gmail.com> (raw) 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".
reply other threads:[~2022-02-16 13:38 UTC|newest] Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=20220216133702.959-1-jamrial@gmail.com \ --to=jamrial@gmail.com \ --cc=ffmpeg-devel@ffmpeg.org \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: link
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