This is an automated email from the git hooks/post-receive script. Git pushed a commit to branch master in repository ffmpeg.
commit 4f3b01a32d544bee608dfffd3693c735f3a2d062 Author: James Almer <[email protected]> AuthorDate: Tue Feb 11 19:14:15 2025 -0300 Commit: James Almer <[email protected]> CommitDate: Thu Aug 13 11:04:44 2026 -0300 avcodec/libaomenc: add support for encoder reconfiguration Signed-off-by: James Almer <[email protected]> --- libavcodec/libaomenc.c | 47 ++++++++++++++++++++++++++++++++++++++++++----- 1 file changed, 42 insertions(+), 5 deletions(-) diff --git a/libavcodec/libaomenc.c b/libavcodec/libaomenc.c index daa7f762c2..992b1bd47c 100644 --- a/libavcodec/libaomenc.c +++ b/libavcodec/libaomenc.c @@ -1550,9 +1550,40 @@ static av_cold int av1_init(AVCodecContext *avctx) return aom_init(avctx, aom_codec_av1_cx()); } +static av_cold int av1_reconf(AVCodecContext *avctx, AVDictionary **dict) +{ + AOMContext *ctx = avctx->priv_data; + int loglevel; + int res; + + res = ff_encode_reconf_parse_dict(avctx, dict); + if (res < 0) + return res; + + res = aom_config(avctx, ctx->encoder.iface); + if (res < 0) + return res; + + res = aom_codec_enc_config_set(&ctx->encoder, &ctx->enccfg); + loglevel = res != AOM_CODEC_OK ? AV_LOG_WARNING : AV_LOG_DEBUG; + av_log(avctx, loglevel, "Reconfigure options:\n"); + dump_enc_cfg(avctx, &ctx->enccfg, loglevel); + if (res != AOM_CODEC_OK) { + log_encoder_error(avctx, "Failed to reconfigure encoder"); + return AVERROR(EINVAL); + } + + res = aom_codecctl(avctx); + if (res < 0) + return res; + + return 0; +} + #define VE AV_OPT_FLAG_VIDEO_PARAM | AV_OPT_FLAG_ENCODING_PARAM +#define VER VE | AV_OPT_FLAG_RUNTIME_PARAM static const AVOption options[] = { - { "cpu-used", "Quality/Speed ratio modifier", OFFSET(cpu_used), AV_OPT_TYPE_INT, {.i64 = 1}, 0, 8, VE}, + { "cpu-used", "Quality/Speed ratio modifier", OFFSET(cpu_used), AV_OPT_TYPE_INT, {.i64 = 1}, 0, 8, VER}, { "auto-alt-ref", "Enable use of alternate reference " "frames (2-pass only)", OFFSET(auto_alt_ref), AV_OPT_TYPE_INT, {.i64 = -1}, -1, 2, VE}, { "lag-in-frames", "Number of frames to look ahead at for " @@ -1566,7 +1597,7 @@ static const AVOption options[] = { { "cyclic", "Cyclic Refresh Aq", 0, AV_OPT_TYPE_CONST, {.i64 = 3}, 0, 0, VE, .unit = "aq_mode"}, { "error-resilience", "Error resilience configuration", OFFSET(error_resilient), AV_OPT_TYPE_FLAGS, {.i64 = 0}, INT_MIN, INT_MAX, VE, .unit = "er"}, { "default", "Improve resiliency against losses of whole frames", 0, AV_OPT_TYPE_CONST, {.i64 = AOM_ERROR_RESILIENT_DEFAULT}, 0, 0, VE, .unit = "er"}, - { "crf", "Select the quality for constant quality mode", offsetof(AOMContext, crf), AV_OPT_TYPE_INT, {.i64 = -1}, -1, 63, VE }, + { "crf", "Select the quality for constant quality mode", offsetof(AOMContext, crf), AV_OPT_TYPE_INT, {.i64 = -1}, -1, 63, VER }, { "static-thresh", "A change threshold on blocks below which they will be skipped by the encoder", OFFSET(static_thresh), AV_OPT_TYPE_INT, { .i64 = 0 }, 0, INT_MAX, VE }, { "drop-threshold", "Frame drop threshold", offsetof(AOMContext, drop_threshold), AV_OPT_TYPE_INT, {.i64 = 0 }, INT_MIN, INT_MAX, VE }, { "denoise-noise-level", "Amount of noise to be removed", OFFSET(denoise_noise_level), AV_OPT_TYPE_INT, {.i64 = -1}, -1, INT_MAX, VE}, @@ -1630,9 +1661,13 @@ static const AVOption options[] = { }; static const FFCodecDefault defaults[] = { - { "b", "0" }, - { "qmin", "-1" }, - { "qmax", "-1" }, + { "b", "0", AV_OPT_FLAG_RUNTIME_PARAM }, + { "bufsize", "0", AV_OPT_FLAG_RUNTIME_PARAM }, + { "maxrate", "0", AV_OPT_FLAG_RUNTIME_PARAM }, + { "minrate", "0", AV_OPT_FLAG_RUNTIME_PARAM }, + { "qmin", "-1", AV_OPT_FLAG_RUNTIME_PARAM }, + { "qmax", "-1", AV_OPT_FLAG_RUNTIME_PARAM }, + { "sar", "0", AV_OPT_FLAG_RUNTIME_PARAM }, { "g", "-1" }, { "keyint_min", "-1" }, { NULL }, @@ -1652,6 +1687,7 @@ const FFCodec ff_libaom_av1_encoder = { .p.id = AV_CODEC_ID_AV1, .p.capabilities = AV_CODEC_CAP_DR1 | AV_CODEC_CAP_DELAY | AV_CODEC_CAP_ENCODER_RECON_FRAME | + AV_CODEC_CAP_RECONF | AV_CODEC_CAP_OTHER_THREADS, .color_ranges = AVCOL_RANGE_MPEG | AVCOL_RANGE_JPEG, .p.profiles = NULL_IF_CONFIG_SMALL(ff_av1_profiles), @@ -1659,6 +1695,7 @@ const FFCodec ff_libaom_av1_encoder = { .p.wrapper_name = "libaom", .priv_data_size = sizeof(AOMContext), .init = av1_init, + .reconf = av1_reconf, FF_CODEC_ENCODE_CB(aom_encode), .close = aom_free, .caps_internal = FF_CODEC_CAP_NOT_INIT_THREADSAFE | _______________________________________________ ffmpeg-cvslog mailing list -- [email protected] To unsubscribe send an email to [email protected]
