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 870F645B33 for ; Wed, 17 May 2023 10:22:39 +0000 (UTC) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 8979168C195; Wed, 17 May 2023 13:21:04 +0300 (EEST) Received: from mail0.khirnov.net (red.khirnov.net [176.97.15.12]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 7646268C13B for ; Wed, 17 May 2023 13:20:52 +0300 (EEST) Received: from localhost (localhost [IPv6:::1]) by mail0.khirnov.net (Postfix) with ESMTP id 4D5B32406CA for ; Wed, 17 May 2023 12:20:50 +0200 (CEST) Received: from mail0.khirnov.net ([IPv6:::1]) by localhost (mail0.khirnov.net [IPv6:::1]) (amavisd-new, port 10024) with ESMTP id qjdurX8aYitl for ; Wed, 17 May 2023 12:20:49 +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 F28DA2405EC for ; Wed, 17 May 2023 12:20:45 +0200 (CEST) Received: from libav.khirnov.net (libav.khirnov.net [IPv6:::1]) by libav.khirnov.net (Postfix) with ESMTP id C8AD83A1594 for ; Wed, 17 May 2023 12:20:39 +0200 (CEST) From: Anton Khirnov To: ffmpeg-devel@ffmpeg.org Date: Wed, 17 May 2023 12:20:03 +0200 Message-Id: <20230517102029.541-10-anton@khirnov.net> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230517102029.541-1-anton@khirnov.net> References: <20230517102029.541-1-anton@khirnov.net> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 10/36] fftools/ffmpeg: return error codes from ist_*_add() 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: Will be useful in future commits. --- fftools/ffmpeg.h | 4 ++-- fftools/ffmpeg_demux.c | 26 +++++++++++++++++++------- fftools/ffmpeg_filter.c | 15 ++++++++++++--- fftools/ffmpeg_mux_init.c | 10 ++++++++-- 4 files changed, 41 insertions(+), 14 deletions(-) diff --git a/fftools/ffmpeg.h b/fftools/ffmpeg.h index 9cb7198dfd..189454d629 100644 --- a/fftools/ffmpeg.h +++ b/fftools/ffmpeg.h @@ -879,8 +879,8 @@ void ifile_close(InputFile **f); */ int ifile_get_packet(InputFile *f, AVPacket **pkt); -void ist_output_add(InputStream *ist, OutputStream *ost); -void ist_filter_add(InputStream *ist, InputFilter *ifilter, int is_simple); +int ist_output_add(InputStream *ist, OutputStream *ost); +int ist_filter_add(InputStream *ist, InputFilter *ifilter, int is_simple); /** * Find an unused input stream of given type. diff --git a/fftools/ffmpeg_demux.c b/fftools/ffmpeg_demux.c index b93e171037..ae2133bdbf 100644 --- a/fftools/ffmpeg_demux.c +++ b/fftools/ffmpeg_demux.c @@ -844,7 +844,7 @@ void ifile_close(InputFile **pf) av_freep(pf); } -static void ist_use(InputStream *ist, int decoding_needed) +static int ist_use(InputStream *ist, int decoding_needed) { DemuxStream *ds = ds_from_ist(ist); @@ -856,23 +856,33 @@ static void ist_use(InputStream *ist, int decoding_needed) if (decoding_needed && !avcodec_is_open(ist->dec_ctx)) { int ret = dec_open(ist); if (ret < 0) - report_and_exit(ret); + return ret; } + + return 0; } -void ist_output_add(InputStream *ist, OutputStream *ost) +int ist_output_add(InputStream *ist, OutputStream *ost) { - ist_use(ist, ost->enc ? DECODING_FOR_OST : 0); + int ret; + + ret = ist_use(ist, ost->enc ? DECODING_FOR_OST : 0); + if (ret < 0) + return ret; GROW_ARRAY(ist->outputs, ist->nb_outputs); ist->outputs[ist->nb_outputs - 1] = ost; + + return 0; } -void ist_filter_add(InputStream *ist, InputFilter *ifilter, int is_simple) +int ist_filter_add(InputStream *ist, InputFilter *ifilter, int is_simple) { int ret; - ist_use(ist, is_simple ? DECODING_FOR_OST : DECODING_FOR_FILTER); + ret = ist_use(ist, is_simple ? DECODING_FOR_OST : DECODING_FOR_FILTER); + if (ret < 0) + return ret; GROW_ARRAY(ist->filters, ist->nb_filters); ist->filters[ist->nb_filters - 1] = ifilter; @@ -880,7 +890,9 @@ void ist_filter_add(InputStream *ist, InputFilter *ifilter, int is_simple) // initialize fallback parameters for filtering ret = ifilter_parameters_from_dec(ifilter, ist->dec_ctx); if (ret < 0) - report_and_exit(ret); + return ret; + + return 0; } static const AVCodec *choose_decoder(const OptionsContext *o, AVFormatContext *s, AVStream *st, diff --git a/fftools/ffmpeg_filter.c b/fftools/ffmpeg_filter.c index 8cc76209d0..ca43b4803a 100644 --- a/fftools/ffmpeg_filter.c +++ b/fftools/ffmpeg_filter.c @@ -334,6 +334,7 @@ int init_simple_filtergraph(InputStream *ist, OutputStream *ost) FilterGraph *fg; OutputFilter *ofilter; InputFilter *ifilter; + int ret; fg = fg_create(NULL); if (!fg) @@ -347,7 +348,9 @@ int init_simple_filtergraph(InputStream *ist, OutputStream *ost) ifilter = ifilter_alloc(fg); ifilter->ist = ist; - ist_filter_add(ist, ifilter, 1); + ret = ist_filter_add(ist, ifilter, 1); + if (ret < 0) + return ret; return 0; } @@ -375,7 +378,7 @@ static void init_input_filter(FilterGraph *fg, AVFilterInOut *in) InputStream *ist = NULL; enum AVMediaType type = avfilter_pad_get_type(in->filter_ctx->input_pads, in->pad_idx); InputFilter *ifilter; - int i; + int i, ret; // TODO: support other filter types if (type != AVMEDIA_TYPE_VIDEO && type != AVMEDIA_TYPE_AUDIO) { @@ -435,7 +438,13 @@ static void init_input_filter(FilterGraph *fg, AVFilterInOut *in) ifilter->type = ist->st->codecpar->codec_type; ifilter->name = describe_filter_link(fg, in, 1); - ist_filter_add(ist, ifilter, 0); + ret = ist_filter_add(ist, ifilter, 0); + if (ret < 0) { + av_log(NULL, AV_LOG_ERROR, + "Error binding an input stream to complex filtergraph input %s.\n", + in->name ? in->name : ""); + exit_program(1); + } } static int read_binary(const char *path, uint8_t **data, int *len) diff --git a/fftools/ffmpeg_mux_init.c b/fftools/ffmpeg_mux_init.c index 2c0e2faf4a..b73791acee 100644 --- a/fftools/ffmpeg_mux_init.c +++ b/fftools/ffmpeg_mux_init.c @@ -1225,8 +1225,14 @@ static OutputStream *ost_add(Muxer *mux, const OptionsContext *o, "Error initializing a simple filtergraph\n"); exit_program(1); } - } else - ist_output_add(ost->ist, ost); + } else { + ret = ist_output_add(ost->ist, ost); + if (ret < 0) { + av_log(ost, AV_LOG_ERROR, + "Error binding an input stream\n"); + exit_program(1); + } + } } if (ost->ist && !ost->enc) { -- 2.39.2 _______________________________________________ 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".