From patchwork Sat Jul 15 10:45:40 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anton Khirnov X-Patchwork-Id: 42696 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:6da1:b0:131:a7d0:bc6d with SMTP id gl33csp4239305pzb; Sat, 15 Jul 2023 03:47:31 -0700 (PDT) X-Google-Smtp-Source: APBJJlEEylGHF99I+iUVmFeOkI9fiZu3CWwGRadu0hbzZlku3q4K+cWOGITxGd0GttSRjpikyPU7 X-Received: by 2002:a17:906:7a0b:b0:994:522f:3f4a with SMTP id d11-20020a1709067a0b00b00994522f3f4amr3692314ejo.29.1689418050918; Sat, 15 Jul 2023 03:47:30 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1689418050; cv=none; d=google.com; s=arc-20160816; b=UqmfwJY/KhbSOLRVKL/9U5Hqd0Wdgs5nVcF53AWSEDLthQ86Vb+2m+akjYyUjtpUCk 1RRwP2SZm+Tc/SRYLuIHiglL+6LsS+8X4MPMt247uz1ZV1CPBfYTEe4Fkb/pbgT5HGaT iYmGkXmjN7WiYu/sKv7QQI6tzihtNuX9CZfQa2SQW2AZ61ymw/ZR9MUbafFEDlp9W/oF jD4HJoskDAPNmUsK54HKCNtz80K7b6diL0lVP5dNOvYN6RPLzFswfYVONZ0HFeJMko2Y I9ObWsao+0eDfuISfILvxgZFR9qAwf5KUF6QUo7vb8IO/G64B4PBAGmeDDxzu0ICA5X0 zOiA== 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=Tk47l0j/g5e6EGokj4EM0wk56rUCK/SUoJNNg3Ij1Ns=; fh=8ZF2QtiKOjBtyn9wuO2cMeZaLsE4aq02Bq77gGK61E8=; b=U0Qj0Efkvse6z5FivpdajsIrDK1xbBDyq7tMlP8vJizDmsuepjwrl6GfBQVMKOAfbg pJTAxK9j95YQSkqqiEJ16v8SNZM16Jl3x0LnICRVVNCda1BS+fdgV7FTeiny2BBQKdpW IGaVSYcOgoHKezLMCk47Kfduj3GCDRvdO0fAIlLdZzq/S1mjcUP7y+J7nUTf/MNOH55u NSvttOGRSr84TkbxMKIj++poJZ+niv27mWY3fj+CIaN2lQrXma5ve4dqisH+AEsPVvbt enPmSStu3KgiHf738hb0LOx+0F/JUqBHM88T1VwS0kQAhSbOeryKuwEczyPNAscrA2WB Xj6A== 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 h2-20020a1709067cc200b00987b0a5f325si9888717ejp.1043.2023.07.15.03.47.30; Sat, 15 Jul 2023 03:47:30 -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 78F5D68C665; Sat, 15 Jul 2023 13:46:40 +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 1DB2B68C5DC for ; Sat, 15 Jul 2023 13:46:35 +0300 (EEST) Received: from localhost (localhost [IPv6:::1]) by mail0.khirnov.net (Postfix) with ESMTP id A93072406CC for ; Sat, 15 Jul 2023 12:46:34 +0200 (CEST) Received: from mail0.khirnov.net ([IPv6:::1]) by localhost (mail0.khirnov.net [IPv6:::1]) (amavisd-new, port 10024) with ESMTP id QHRSghmGZRL0 for ; Sat, 15 Jul 2023 12:46:33 +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 CD4552406CE 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 AC0763A1829 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:40 +0200 Message-Id: <20230715104611.17902-16-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 16/47] fftools/ffmpeg_filter: return error codes from ofilter_bind_ost() 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 Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" X-TUID: NO/QLTkahYsG --- fftools/ffmpeg.h | 2 +- fftools/ffmpeg_filter.c | 12 ++++++++---- fftools/ffmpeg_mux_init.c | 4 +++- 3 files changed, 12 insertions(+), 6 deletions(-) diff --git a/fftools/ffmpeg.h b/fftools/ffmpeg.h index 62b56a8cd8..d7e16d034f 100644 --- a/fftools/ffmpeg.h +++ b/fftools/ffmpeg.h @@ -744,7 +744,7 @@ void ifilter_sub2video_heartbeat(InputFilter *ifilter, int64_t pts, AVRational t */ int ifilter_parameters_from_dec(InputFilter *ifilter, const AVCodecContext *dec); -void ofilter_bind_ost(OutputFilter *ofilter, OutputStream *ost); +int ofilter_bind_ost(OutputFilter *ofilter, OutputStream *ost); /** * Create a new filtergraph in the global filtergraph list. diff --git a/fftools/ffmpeg_filter.c b/fftools/ffmpeg_filter.c index d373d8c002..cdf5610620 100644 --- a/fftools/ffmpeg_filter.c +++ b/fftools/ffmpeg_filter.c @@ -624,7 +624,7 @@ static void set_channel_layout(OutputFilterPriv *f, OutputStream *ost) av_channel_layout_default(&f->ch_layout, ost->enc_ctx->ch_layout.nb_channels); } -void ofilter_bind_ost(OutputFilter *ofilter, OutputStream *ost) +int ofilter_bind_ost(OutputFilter *ofilter, OutputStream *ost) { OutputFilterPriv *ofp = ofp_from_ofilter(ofilter); FilterGraph *fg = ofilter->graph; @@ -699,15 +699,17 @@ void ofilter_bind_ost(OutputFilter *ofilter, OutputStream *ost) for (int i = 0; i < fg->nb_outputs; i++) if (!fg->outputs[i]->ost) - return; + return 0; ret = configure_filtergraph(fg); if (ret < 0) { av_log(fg, AV_LOG_ERROR, "Error configuring filter graph: %s\n", av_err2str(ret)); - exit_program(1); + return ret; } } + + return 0; } static InputFilter *ifilter_alloc(FilterGraph *fg) @@ -899,7 +901,9 @@ int init_simple_filtergraph(InputStream *ist, OutputStream *ost, if (ret < 0) return ret; - ofilter_bind_ost(fg->outputs[0], ost); + ret = ofilter_bind_ost(fg->outputs[0], ost); + if (ret < 0) + return ret; return 0; } diff --git a/fftools/ffmpeg_mux_init.c b/fftools/ffmpeg_mux_init.c index cc5ec68040..359a5149d4 100644 --- a/fftools/ffmpeg_mux_init.c +++ b/fftools/ffmpeg_mux_init.c @@ -1393,7 +1393,9 @@ static int ost_add(Muxer *mux, const OptionsContext *o, enum AVMediaType type, (type == AVMEDIA_TYPE_VIDEO || type == AVMEDIA_TYPE_AUDIO)) { if (ofilter) { ost->filter = ofilter; - ofilter_bind_ost(ofilter, ost); + ret = ofilter_bind_ost(ofilter, ost); + if (ret < 0) + return ret; } else { ret = init_simple_filtergraph(ost->ist, ost, filters); if (ret < 0) {