From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org [79.124.17.100]) by master.gitmailbox.com (Postfix) with ESMTP id 6D7A448163 for ; Mon, 11 Dec 2023 15:07:47 +0000 (UTC) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 198A268CC70; Mon, 11 Dec 2023 17:07:36 +0200 (EET) Received: from shout02.mail.de (shout02.mail.de [62.201.172.25]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 193AE68D129 for ; Mon, 11 Dec 2023 17:07:28 +0200 (EET) Received: from postfix01.mail.de (postfix01.bt.mail.de [10.0.121.125]) by shout02.mail.de (Postfix) with ESMTP id B1617240DB2 for ; Mon, 11 Dec 2023 16:07:27 +0100 (CET) Received: from smtp01.mail.de (smtp02.bt.mail.de [10.0.121.212]) by postfix01.mail.de (Postfix) with ESMTP id 998748029D for ; Mon, 11 Dec 2023 16:07:27 +0100 (CET) Received: from [127.0.0.1] (localhost [127.0.0.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by smtp01.mail.de (Postfix) with ESMTPSA id 68F46240CD0 for ; Mon, 11 Dec 2023 16:07:27 +0100 (CET) To: ffmpeg-devel@ffmpeg.org Date: Mon, 11 Dec 2023 16:07:21 +0100 Message-Id: <20231211150725.46473-2-thilo.borgmann@mail.de> In-Reply-To: <20231211150725.46473-1-thilo.borgmann@mail.de> References: <20231211150725.46473-1-thilo.borgmann@mail.de> MIME-Version: 1.0 X-purgate: clean X-purgate: This mail is considered clean (visit http://www.eleven.de for further information) X-purgate-type: clean X-purgate-Ad: Categorized by eleven eXpurgate (R) http://www.eleven.de X-purgate: This mail is considered clean (visit http://www.eleven.de for further information) X-purgate: clean X-purgate-size: 2440 X-purgate-ID: 154282::1702307247-9252C878-C2937605/0/0 Subject: [FFmpeg-devel] [PATCH 1/5] fftools/ffmpeg: split loop for parsing and validation of -stats_* specifiers X-BeenThere: ffmpeg-devel@ffmpeg.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: FFmpeg development discussions and patches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , From: Thilo Borgmann via ffmpeg-devel Reply-To: FFmpeg development discussions and patches Cc: Thilo Borgmann Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" Archived-At: List-Archive: List-Post: --- 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-request@ffmpeg.org with subject "unsubscribe".