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 9F39046E7D for ; Sat, 15 Jul 2023 10:53:55 +0000 (UTC) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 4F11D68C74C; Sat, 15 Jul 2023 13:53:42 +0300 (EEST) Received: from mail0.khirnov.net (red.khirnov.net [176.97.15.12]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 752F968C716 for ; Sat, 15 Jul 2023 13:53:35 +0300 (EEST) Received: from localhost (localhost [IPv6:::1]) by mail0.khirnov.net (Postfix) with ESMTP id 041BC2404F5 for ; Sat, 15 Jul 2023 12:53:35 +0200 (CEST) Received: from mail0.khirnov.net ([IPv6:::1]) by localhost (mail0.khirnov.net [IPv6:::1]) (amavisd-new, port 10024) with ESMTP id RqiZD9xCiA7f for ; Sat, 15 Jul 2023 12:53:32 +0200 (CEST) Received: from libav.khirnov.net (libav.khirnov.net [IPv6:2a00:c500:561:201::7]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256 client-signature RSA-PSS (2048 bits) client-digest SHA256) (Client CN "libav.khirnov.net", Issuer "smtp.khirnov.net SMTP CA" (verified OK)) by mail0.khirnov.net (Postfix) with ESMTPS id B67FB2404EE for ; Sat, 15 Jul 2023 12:53:32 +0200 (CEST) Received: from libav.khirnov.net (libav.khirnov.net [IPv6:::1]) by libav.khirnov.net (Postfix) with ESMTP id CE6503A2812 for ; Sat, 15 Jul 2023 12:46:21 +0200 (CEST) From: Anton Khirnov To: ffmpeg-devel@ffmpeg.org Date: Sat, 15 Jul 2023 12:46:04 +0200 Message-Id: <20230715104611.17902-40-anton@khirnov.net> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20230715104611.17902-1-anton@khirnov.net> References: <20230715104611.17902-1-anton@khirnov.net> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 40/47] fftools/ffmpeg: return an error from assert_avoptions() instead of aborting 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: , Reply-To: FFmpeg development discussions and patches 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: Rename it to check_avoptions(). --- fftools/ffmpeg.c | 6 ++++-- fftools/ffmpeg.h | 2 +- fftools/ffmpeg_dec.c | 5 ++++- fftools/ffmpeg_demux.c | 5 ++++- fftools/ffmpeg_enc.c | 5 ++++- 5 files changed, 17 insertions(+), 6 deletions(-) diff --git a/fftools/ffmpeg.c b/fftools/ffmpeg.c index 50d6658472..ecb3f89f85 100644 --- a/fftools/ffmpeg.c +++ b/fftools/ffmpeg.c @@ -457,13 +457,15 @@ void remove_avoptions(AVDictionary **a, AVDictionary *b) } } -void assert_avoptions(AVDictionary *m) +int check_avoptions(AVDictionary *m) { const AVDictionaryEntry *t; if ((t = av_dict_get(m, "", NULL, AV_DICT_IGNORE_SUFFIX))) { av_log(NULL, AV_LOG_FATAL, "Option %s not found.\n", t->key); - exit_program(1); + return AVERROR_OPTION_NOT_FOUND; } + + return 0; } void update_benchmark(const char *fmt, ...) diff --git a/fftools/ffmpeg.h b/fftools/ffmpeg.h index 60dff87436..73baad238c 100644 --- a/fftools/ffmpeg.h +++ b/fftools/ffmpeg.h @@ -705,7 +705,7 @@ void term_exit(void); void show_usage(void); void remove_avoptions(AVDictionary **a, AVDictionary *b); -void assert_avoptions(AVDictionary *m); +int check_avoptions(AVDictionary *m); int assert_file_overwrite(const char *filename); char *file_read(const char *filename); diff --git a/fftools/ffmpeg_dec.c b/fftools/ffmpeg_dec.c index 62c1baf287..8a3b52fd7e 100644 --- a/fftools/ffmpeg_dec.c +++ b/fftools/ffmpeg_dec.c @@ -1119,7 +1119,10 @@ int dec_open(InputStream *ist) av_err2str(ret)); return ret; } - assert_avoptions(ist->decoder_opts); + + ret = check_avoptions(ist->decoder_opts); + if (ret < 0) + return ret; ret = dec_thread_start(ist); if (ret < 0) { diff --git a/fftools/ffmpeg_demux.c b/fftools/ffmpeg_demux.c index d612c5f434..48edbd7f6b 100644 --- a/fftools/ffmpeg_demux.c +++ b/fftools/ffmpeg_demux.c @@ -1511,7 +1511,10 @@ int ifile_open(const OptionsContext *o, const char *filename) if (scan_all_pmts_set) av_dict_set(&o->g->format_opts, "scan_all_pmts", NULL, AV_DICT_MATCH_CASE); remove_avoptions(&o->g->format_opts, o->g->codec_opts); - assert_avoptions(o->g->format_opts); + + ret = check_avoptions(o->g->format_opts); + if (ret < 0) + return ret; /* apply forced codec ids */ for (i = 0; i < ic->nb_streams; i++) { diff --git a/fftools/ffmpeg_enc.c b/fftools/ffmpeg_enc.c index 01e1b0656c..dde239657f 100644 --- a/fftools/ffmpeg_enc.c +++ b/fftools/ffmpeg_enc.c @@ -411,7 +411,10 @@ int enc_open(OutputStream *ost, AVFrame *frame) ost->sq_idx_encode, ost->enc_ctx->frame_size); } - assert_avoptions(ost->encoder_opts); + ret = check_avoptions(ost->encoder_opts); + if (ret < 0) + return ret; + if (ost->enc_ctx->bit_rate && ost->enc_ctx->bit_rate < 1000 && ost->enc_ctx->codec_id != AV_CODEC_ID_CODEC2 /* don't complain about 700 bit/s modes */) av_log(ost, AV_LOG_WARNING, "The bitrate parameter is set too low." -- 2.40.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".