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 C10DB40846 for ; Sun, 28 May 2023 09:15:41 +0000 (UTC) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 631A768C214; Sun, 28 May 2023 12:15:00 +0300 (EEST) Received: from mail0.khirnov.net (red.khirnov.net [176.97.15.12]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 7970E68C1E6 for ; Sun, 28 May 2023 12:14:50 +0300 (EEST) Received: from localhost (localhost [IPv6:::1]) by mail0.khirnov.net (Postfix) with ESMTP id 3F53F2404EC for ; Sun, 28 May 2023 11:14:50 +0200 (CEST) Received: from mail0.khirnov.net ([IPv6:::1]) by localhost (mail0.khirnov.net [IPv6:::1]) (amavisd-new, port 10024) with ESMTP id zhNb0JchKMRf for ; Sun, 28 May 2023 11:14:47 +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 71E03240177 for ; Sun, 28 May 2023 11:14:47 +0200 (CEST) Received: from libav.khirnov.net (libav.khirnov.net [IPv6:::1]) by libav.khirnov.net (Postfix) with ESMTP id 112BE3A01C0 for ; Sun, 28 May 2023 11:14:41 +0200 (CEST) From: Anton Khirnov To: ffmpeg-devel@ffmpeg.org Date: Sun, 28 May 2023 11:13:53 +0200 Message-Id: <20230528091416.17927-1-anton@khirnov.net> X-Mailer: git-send-email 2.40.1 MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 01/24] fftools/ffmpeg_mux_init: merge ost_add_from_filter() to ost_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: This way ost_add() knows about the complex filtergraph it is fed from, which will become useful in future commits. --- fftools/ffmpeg_mux_init.c | 71 ++++++++++++++++++--------------------- 1 file changed, 32 insertions(+), 39 deletions(-) diff --git a/fftools/ffmpeg_mux_init.c b/fftools/ffmpeg_mux_init.c index 7878789bb4..de39b360af 100644 --- a/fftools/ffmpeg_mux_init.c +++ b/fftools/ffmpeg_mux_init.c @@ -985,7 +985,8 @@ fail: } static OutputStream *ost_add(Muxer *mux, const OptionsContext *o, - enum AVMediaType type, InputStream *ist) + enum AVMediaType type, InputStream *ist, + OutputFilter *ofilter) { AVFormatContext *oc = mux->fc; MuxStream *ms; @@ -1040,6 +1041,14 @@ static OutputStream *ost_add(Muxer *mux, const OptionsContext *o, av_strlcat(ms->log_name, "/", sizeof(ms->log_name)); av_strlcat(ms->log_name, enc->name, sizeof(ms->log_name)); } else { + if (ofilter) { + av_log(ost, AV_LOG_ERROR, + "Streamcopy requested for output stream fed " + "from a complex filtergraph. Filtering and streamcopy " + "cannot be used together.\n"); + exit_program(1); + } + av_strlcat(ms->log_name, "/copy", sizeof(ms->log_name)); } @@ -1233,22 +1242,26 @@ static OutputStream *ost_add(Muxer *mux, const OptionsContext *o, exit_program(1); } - if (ost->ist) { - if (ost->enc && - (type == AVMEDIA_TYPE_VIDEO || type == AVMEDIA_TYPE_AUDIO)) { + if (ost->enc && + (type == AVMEDIA_TYPE_VIDEO || type == AVMEDIA_TYPE_AUDIO)) { + if (ofilter) { + ost->filter = ofilter; + ofilter->ost = ost; + avfilter_inout_free(&ofilter->out_tmp); + } else { ret = init_simple_filtergraph(ost->ist, ost); if (ret < 0) { av_log(ost, AV_LOG_ERROR, "Error initializing a simple filtergraph\n"); exit_program(1); } - } 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); - } + } + } else if (ost->ist) { + 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); } } @@ -1261,26 +1274,6 @@ static OutputStream *ost_add(Muxer *mux, const OptionsContext *o, return ost; } -// add a new output stream fed by the provided filtergraph output -static void ost_add_from_filter(OutputFilter *ofilter, const OptionsContext *o, - Muxer *mux) -{ - OutputStream *ost = ost_add(mux, o, ofilter->type, NULL); - - ost->filter = ofilter; - - ofilter->ost = ost; - - if (!ost->enc_ctx) { - av_log(ost, AV_LOG_ERROR, "Streamcopy requested for output stream fed " - "from a complex filtergraph. Filtering and streamcopy " - "cannot be used together.\n"); - exit_program(1); - } - - avfilter_inout_free(&ofilter->out_tmp); -} - static void map_auto_video(Muxer *mux, const OptionsContext *o) { AVFormatContext *oc = mux->fc; @@ -1329,7 +1322,7 @@ static void map_auto_video(Muxer *mux, const OptionsContext *o) } } if (best_ist) - ost_add(mux, o, AVMEDIA_TYPE_VIDEO, best_ist); + ost_add(mux, o, AVMEDIA_TYPE_VIDEO, best_ist, NULL); } static void map_auto_audio(Muxer *mux, const OptionsContext *o) @@ -1371,7 +1364,7 @@ static void map_auto_audio(Muxer *mux, const OptionsContext *o) } } if (best_ist) - ost_add(mux, o, AVMEDIA_TYPE_AUDIO, best_ist); + ost_add(mux, o, AVMEDIA_TYPE_AUDIO, best_ist, NULL); } static void map_auto_subtitle(Muxer *mux, const OptionsContext *o) @@ -1406,7 +1399,7 @@ static void map_auto_subtitle(Muxer *mux, const OptionsContext *o) input_descriptor && output_descriptor && (!input_descriptor->props || !output_descriptor->props)) { - ost_add(mux, o, AVMEDIA_TYPE_SUBTITLE, ist); + ost_add(mux, o, AVMEDIA_TYPE_SUBTITLE, ist, NULL); break; } } @@ -1426,7 +1419,7 @@ static void map_auto_data(Muxer *mux, const OptionsContext *o) continue; if (ist->st->codecpar->codec_type == AVMEDIA_TYPE_DATA && ist->st->codecpar->codec_id == codec_id ) - ost_add(mux, o, AVMEDIA_TYPE_DATA, ist); + ost_add(mux, o, AVMEDIA_TYPE_DATA, ist, NULL); } } @@ -1458,7 +1451,7 @@ loop_end: "in any defined filter graph, or was already used elsewhere.\n", map->linklabel); exit_program(1); } - ost_add_from_filter(ofilter, o, mux); + ost_add(mux, o, ofilter->type, NULL, ofilter); } else { ist = input_files[map->file_index]->streams[map->stream_index]; if (ist->user_set_discard == AVDISCARD_ALL) { @@ -1490,7 +1483,7 @@ loop_end: return; } - ost_add(mux, o, ist->st->codecpar->codec_type, ist); + ost_add(mux, o, ist->st->codecpar->codec_type, ist, NULL); } } @@ -1524,7 +1517,7 @@ static void of_add_attachments(Muxer *mux, const OptionsContext *o) avio_read(pb, attachment, len); memset(attachment + len, 0, AV_INPUT_BUFFER_PADDING_SIZE); - ost = ost_add(mux, o, AVMEDIA_TYPE_ATTACHMENT, NULL); + ost = ost_add(mux, o, AVMEDIA_TYPE_ATTACHMENT, NULL, NULL); ost->attachment_filename = o->attachments[i]; ost->par_in->extradata = attachment; ost->par_in->extradata_size = len; @@ -1557,7 +1550,7 @@ static void create_streams(Muxer *mux, const OptionsContext *o) case AVMEDIA_TYPE_AUDIO: auto_disable_a = 1; break; case AVMEDIA_TYPE_SUBTITLE: auto_disable_s = 1; break; } - ost_add_from_filter(ofilter, o, mux); + ost_add(mux, o, ofilter->type, NULL, ofilter); } } -- 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".