From patchwork Sat Jul 15 10:45:42 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anton Khirnov X-Patchwork-Id: 42707 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:6da1:b0:131:a7d0:bc6d with SMTP id gl33csp4239764pzb; Sat, 15 Jul 2023 03:48:59 -0700 (PDT) X-Google-Smtp-Source: APBJJlGXMGtcJFHozJBaY9FFOsqQq1E/xzcKFzbE+jU4HD/vmcAOmmf0bwZNy3jNBEwY7ykikMAF X-Received: by 2002:a17:906:39d2:b0:989:3e0d:89fb with SMTP id i18-20020a17090639d200b009893e0d89fbmr5496119eje.45.1689418139488; Sat, 15 Jul 2023 03:48:59 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1689418139; cv=none; d=google.com; s=arc-20160816; b=x+V0rImTkOrMjN3wa5qNZT5UkFhIC1X7AmF4yThO6747fopTOOAYV0FQ7mKOim9Av3 Wv0Z2hOatdLEdSgsCid4YHa1qpvM61GfNuuiZTkOns7DkkhZLB5mUfv8MsCfUtF3PNkY NC+Pda60wugraLmFn5CjygmLDqEjmvtBIb9aDXtffhLHuF+KlH4MoOvFNCsUZrjRof2V WNN0DCz53mu5ByxhRaJq6E/p3ZS6G2J0idkhXR1PCkVhhdnkAd5dvzDntWmPNwN3ryob 11mUEdwFQdcnVwfMoOTme92o35lvCt8rkdb5unaFf3Au/Z/Ryf47h2dLMHN8KOvqVE/T APdw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:reply-to:list-subscribe :list-help:list-post:list-archive:list-unsubscribe:list-id :precedence:subject:mime-version:references:in-reply-to:message-id :date:to:from:delivered-to; bh=p24SysbxRegoJA2giiQiulqvDL6nKOgGjBVLYF3+uxI=; fh=8ZF2QtiKOjBtyn9wuO2cMeZaLsE4aq02Bq77gGK61E8=; b=Vnqp6vzoGfK0ZvxRYvQ6JtbiC9LHa+/RLEh4LLd7cIUgoBTujSOSKbrtwYMHLA66Oy I1x67aAEBMCqTm/B9XoCMS64RJsdjhjaIxb64o1I3c8byPoQPSQmu9RNoI62GOt1oeQu CWpxL+fzXpiqv8gAlzBAvndCh2nWbmMHZKVTtlz8a96BG5xx8spM2EG/tPv5iWvBYmrN 2Xlf00LE6wEiPYvbY5fOemo2v9eO6nREWxryPy0o9QSLebD+D/HXMZLCrLdj5DW74Osf 2yj7d0pMQBIe4+aaD7+3tPveiQEHWXUNx5fTPeLom2TDj5AILTbbmtA/tuJklodoGrk3 vcPg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) smtp.mailfrom=ffmpeg-devel-bounces@ffmpeg.org Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id va25-20020a17090711d900b009662960f217si2158366ejb.303.2023.07.15.03.48.58; Sat, 15 Jul 2023 03:48:59 -0700 (PDT) Received-SPF: pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) client-ip=79.124.17.100; Authentication-Results: mx.google.com; spf=pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) smtp.mailfrom=ffmpeg-devel-bounces@ffmpeg.org Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 6593768C708; Sat, 15 Jul 2023 13:46:51 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail0.khirnov.net (red.khirnov.net [176.97.15.12]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id B0B1768C675 for ; Sat, 15 Jul 2023 13:46:34 +0300 (EEST) Received: from localhost (localhost [IPv6:::1]) by mail0.khirnov.net (Postfix) with ESMTP id 9F1322404EA for ; Sat, 15 Jul 2023 12:46:33 +0200 (CEST) Received: from mail0.khirnov.net ([IPv6:::1]) by localhost (mail0.khirnov.net [IPv6:::1]) (amavisd-new, port 10024) with ESMTP id 1YLKgGWzqdGX for ; Sat, 15 Jul 2023 12:46: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 C70062406CC for ; Sat, 15 Jul 2023 12:46:26 +0200 (CEST) Received: from libav.khirnov.net (libav.khirnov.net [IPv6:::1]) by libav.khirnov.net (Postfix) with ESMTP id C37C23A188A for ; Sat, 15 Jul 2023 12:46:20 +0200 (CEST) From: Anton Khirnov To: ffmpeg-devel@ffmpeg.org Date: Sat, 15 Jul 2023 12:45:42 +0200 Message-Id: <20230715104611.17902-18-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 18/47] fftools/ffmpeg_filter: replace remaining exit_program() with error codes 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 Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" X-TUID: /gkPZep8M4xm --- fftools/ffmpeg.h | 2 +- fftools/ffmpeg_filter.c | 15 ++++++++++----- fftools/ffmpeg_opt.c | 4 +++- 3 files changed, 14 insertions(+), 7 deletions(-) diff --git a/fftools/ffmpeg.h b/fftools/ffmpeg.h index d7e16d034f..043eb5e6ec 100644 --- a/fftools/ffmpeg.h +++ b/fftools/ffmpeg.h @@ -717,7 +717,7 @@ const AVCodec *find_codec_or_die(void *logctx, const char *name, enum AVMediaType type, int encoder); int parse_and_set_vsync(const char *arg, int *vsync_var, int file_idx, int st_idx, int is_global); -void check_filter_outputs(void); +int check_filter_outputs(void); int filtergraph_is_simple(const FilterGraph *fg); int init_simple_filtergraph(InputStream *ist, OutputStream *ost, char *graph_desc); diff --git a/fftools/ffmpeg_filter.c b/fftools/ffmpeg_filter.c index 79e034d248..ed0df9f320 100644 --- a/fftools/ffmpeg_filter.c +++ b/fftools/ffmpeg_filter.c @@ -1246,7 +1246,7 @@ static int configure_output_filter(FilterGraph *fg, OutputFilter *ofilter, { if (!ofilter->ost) { av_log(fg, AV_LOG_FATAL, "Filter %s has an unconnected output\n", ofilter->name); - exit_program(1); + return AVERROR(EINVAL); } switch (avfilter_pad_get_type(out->filter_ctx->output_pads, out->pad_idx)) { @@ -1256,7 +1256,7 @@ static int configure_output_filter(FilterGraph *fg, OutputFilter *ofilter, } } -void check_filter_outputs(void) +int check_filter_outputs(void) { int i; for (i = 0; i < nb_filtergraphs; i++) { @@ -1266,10 +1266,12 @@ void check_filter_outputs(void) if (!output->ost) { av_log(filtergraphs[i], AV_LOG_FATAL, "Filter %s has an unconnected output\n", output->name); - exit_program(1); + return AVERROR(EINVAL); } } } + + return 0; } static void sub2video_prepare(InputFilterPriv *ifp) @@ -1570,8 +1572,11 @@ static int configure_filtergraph(FilterGraph *fg) } avfilter_inout_free(&inputs); - for (cur = outputs, i = 0; cur; cur = cur->next, i++) - configure_output_filter(fg, fg->outputs[i], cur); + for (cur = outputs, i = 0; cur; cur = cur->next, i++) { + ret = configure_output_filter(fg, fg->outputs[i], cur); + if (ret < 0) + return ret; + } avfilter_inout_free(&outputs); if (fgp->disable_conversions) diff --git a/fftools/ffmpeg_opt.c b/fftools/ffmpeg_opt.c index 300f042660..44bf263621 100644 --- a/fftools/ffmpeg_opt.c +++ b/fftools/ffmpeg_opt.c @@ -1301,7 +1301,9 @@ int ffmpeg_parse_options(int argc, char **argv) apply_sync_offsets(); - check_filter_outputs(); + ret = check_filter_outputs(); + if (ret < 0) + goto fail; fail: uninit_parse_context(&octx);