--- fftools/ffmpeg_mux_init.c | 40 ++++++++++++++++++++++++++------------- 1 file changed, 27 insertions(+), 13 deletions(-)
diff --git a/fftools/ffmpeg_mux_init.c b/fftools/ffmpeg_mux_init.c index 63a25a350f..6c473a8f09 100644 --- a/fftools/ffmpeg_mux_init.c +++ b/fftools/ffmpeg_mux_init.c @@ -365,6 +365,26 @@ static int enc_stats_init(OutputStream *ost, EncStats *es, int pre, c = &es->components[es->nb_components - 1]; + for (size_t i = 0; i < FF_ARRAY_ELEMS(fmt_specs); i++) { + if (!strcmp(val, fmt_specs[i].str)) { + c->type = fmt_specs[i].type; + c->str = val; + c->str_len = val_len; + break; + } + } + + if (!c->type) { + av_log(NULL, AV_LOG_ERROR, "Invalid format directive: %s\n", val); + ret = AVERROR(EINVAL); + goto fail; + } + } + + for (int j = 0; j < es->nb_components; j++) { + EncStatsComponent *c = &es->components[j]; + char *val = c->str; + for (size_t i = 0; i < FF_ARRAY_ELEMS(fmt_specs); i++) { if (!strcmp(val, fmt_specs[i].str)) { if ((pre && fmt_specs[i].post_only) || (!pre && fmt_specs[i].pre_only)) { @@ -375,8 +395,6 @@ static int enc_stats_init(OutputStream *ost, EncStats *es, int pre, goto fail; } - c->type = fmt_specs[i].type; - if (fmt_specs[i].need_input_data && !ost->ist) { av_log(ost, AV_LOG_WARNING, "Format directive '%s' is unavailable, because " @@ -387,20 +405,16 @@ static int enc_stats_init(OutputStream *ost, EncStats *es, int pre, break; } } - - if (!c->type) { - av_log(NULL, AV_LOG_ERROR, "Invalid format directive: %s\n", val); - ret = AVERROR(EINVAL); - goto fail; - } - -fail: - av_freep(&val); - if (ret < 0) - return ret; } ret = enc_stats_get_file(&es->io, path); +fail: + for (int j = 0; j < es->nb_components; j++) { + EncStatsComponent *c = &es->components[j]; + if (c->type != ENC_STATS_LITERAL) { + av_freep(&c->str); + } + } if (ret < 0) return ret; -- 2.37.1 (Apple Git-137.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-requ...@ffmpeg.org with subject "unsubscribe".