From patchwork Tue Oct 18 12:36:58 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anton Khirnov X-Patchwork-Id: 38789 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:4a86:b0:9d:28a3:170e with SMTP id fn6csp2083302pzb; Tue, 18 Oct 2022 05:40:02 -0700 (PDT) X-Google-Smtp-Source: AMsMyM5BhiiHFNVqHKoAdZMH7bcwZT87xhsQidiVo/s2DzjuqPzUxTjt3u2E7Ru0SUsALNSRyE6+ X-Received: by 2002:a17:906:fe0b:b0:787:f1d3:2105 with SMTP id wy11-20020a170906fe0b00b00787f1d32105mr2248309ejb.83.1666096801931; Tue, 18 Oct 2022 05:40:01 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666096801; cv=none; d=google.com; s=arc-20160816; b=i11Q0kyTf+xDLV21RKoAblFzPhRH9eV2QxnVLqcBd1XraX7j4DShZlQC5+gL3R+PwT Fx6PHSiq4vqORX5QFczTaZ9MFLcJWHDjjL6+dlRnAAze/oYCDTgupgIZBfR9LLPGryjd uXDQur3ok1a4D/2dNFNOF2w53DsIyWO84/XxxIDjXYqcUhd/kvwNpwgF8KL1CdPgJ4LZ p7jURKWLcdQaw1sJROAcgv24et5+eXHHST2AYIIo/eJklaacBvNC2Q3smSer74EMz5A2 GNHPyLMltma1UuOHYvbRBiKZVOwLEntGcY40fnbZX3ak8f482TWXeDrXyN5BUNVQz1qH VYrA== 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=PTFQVdV+IT6XLVPrudO/9wRdqBlp4J3VDJu+K8I5VjA=; b=YBXmDjYwDmsIy1FvernOd0KcUYX0uqsQ6oKB+pPF1x0Jo/0S9pSmRnzddWzhHT1KbB Nbwo95HZ7813MwJ59wTpCfgS8jhhmKUGw7zCevtoZk9jQ7BJBz8pabNVdJzCxjSkYDpI Lrjvvgx6XRsEdTXIw2gVJ1fx+x4VlJQDfBl+pB/ELyIrMvJCJH6nJJcYak25R9BkXM9E bOVL0eQdTARmQhP0BK1noXaJZ+dGuSe9tkhdNJlL6ksCHrORBPbJ+UQ3K5MprZOpXMDv iWKEOuKTdHLSUrpoDwuHeeTTWvbsUsL/STcGegs5cw3fgzNfYrJ4mpqd0fOOpKaAzty6 8cRQ== 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 y18-20020aa7ce92000000b00442296a8407si10097878edv.629.2022.10.18.05.40.01; Tue, 18 Oct 2022 05:40:01 -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 BAFE268BD9C; Tue, 18 Oct 2022 15:38:33 +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 2121368BD15 for ; Tue, 18 Oct 2022 15:38:21 +0300 (EEST) Received: from localhost (localhost [IPv6:::1]) by mail0.khirnov.net (Postfix) with ESMTP id 368C02404F5 for ; Tue, 18 Oct 2022 14:38:20 +0200 (CEST) Received: from mail0.khirnov.net ([IPv6:::1]) by localhost (mail0.khirnov.net [IPv6:::1]) (amavisd-new, port 10024) with ESMTP id EbGcRI6sd7hS for ; Tue, 18 Oct 2022 14:38:19 +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 DD12F2406E1 for ; Tue, 18 Oct 2022 14:38:13 +0200 (CEST) Received: from libav.khirnov.net (libav.khirnov.net [IPv6:::1]) by libav.khirnov.net (Postfix) with ESMTP id D6D903A1E5A for ; Tue, 18 Oct 2022 14:38:13 +0200 (CEST) From: Anton Khirnov To: ffmpeg-devel@ffmpeg.org Date: Tue, 18 Oct 2022 14:36:58 +0200 Message-Id: <20221018123701.25002-17-anton@khirnov.net> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20221018123701.25002-1-anton@khirnov.net> References: <20221018123701.25002-1-anton@khirnov.net> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 17/20] fftools/ffmpeg_mux_init: move code creating streams into a new function 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: q1+3vGd4NbTk Makes it easy to see where all the streams are created. Will also be useful in the following commit. --- fftools/ffmpeg_mux_init.c | 72 +++++++++++++++++++++------------------ 1 file changed, 39 insertions(+), 33 deletions(-) diff --git a/fftools/ffmpeg_mux_init.c b/fftools/ffmpeg_mux_init.c index d25dace105..6687ba872a 100644 --- a/fftools/ffmpeg_mux_init.c +++ b/fftools/ffmpeg_mux_init.c @@ -1062,6 +1062,42 @@ loop_end: } } +static void create_streams(Muxer *mux, OptionsContext *o) +{ + /* create streams for all unlabeled output pads */ + for (int i = 0; i < nb_filtergraphs; i++) { + FilterGraph *fg = filtergraphs[i]; + for (int j = 0; j < fg->nb_outputs; j++) { + OutputFilter *ofilter = fg->outputs[j]; + + if (!ofilter->out_tmp || ofilter->out_tmp->name) + continue; + + switch (ofilter->type) { + case AVMEDIA_TYPE_VIDEO: o->video_disable = 1; break; + case AVMEDIA_TYPE_AUDIO: o->audio_disable = 1; break; + case AVMEDIA_TYPE_SUBTITLE: o->subtitle_disable = 1; break; + } + init_output_filter(ofilter, o, mux); + } + } + + if (!o->nb_stream_maps) { + /* pick the "best" stream of each type */ + if (!o->video_disable) + map_auto_video(mux, o); + if (!o->audio_disable) + map_auto_audio(mux, o); + if (!o->subtitle_disable) + map_auto_subtitle(mux, o); + if (!o->data_disable) + map_auto_data(mux, o); + } else { + for (int i = 0; i < o->nb_stream_maps; i++) + map_manual(mux, o, &o->stream_maps[i]); + } +} + static int setup_sync_queues(Muxer *mux, AVFormatContext *oc, int64_t buf_size_us) { OutputFile *of = &mux->of; @@ -1666,7 +1702,7 @@ int of_open(OptionsContext *o, const char *filename) { Muxer *mux; AVFormatContext *oc; - int i, j, err; + int err; OutputFile *of; AVDictionary *unused_opts = NULL; const AVDictionaryEntry *e = NULL; @@ -1728,38 +1764,8 @@ int of_open(OptionsContext *o, const char *filename) AVFMT_FLAG_BITEXACT); } - /* create streams for all unlabeled output pads */ - for (i = 0; i < nb_filtergraphs; i++) { - FilterGraph *fg = filtergraphs[i]; - for (j = 0; j < fg->nb_outputs; j++) { - OutputFilter *ofilter = fg->outputs[j]; - - if (!ofilter->out_tmp || ofilter->out_tmp->name) - continue; - - switch (ofilter->type) { - case AVMEDIA_TYPE_VIDEO: o->video_disable = 1; break; - case AVMEDIA_TYPE_AUDIO: o->audio_disable = 1; break; - case AVMEDIA_TYPE_SUBTITLE: o->subtitle_disable = 1; break; - } - init_output_filter(ofilter, o, mux); - } - } - - if (!o->nb_stream_maps) { - /* pick the "best" stream of each type */ - if (!o->video_disable) - map_auto_video(mux, o); - if (!o->audio_disable) - map_auto_audio(mux, o); - if (!o->subtitle_disable) - map_auto_subtitle(mux, o); - if (!o->data_disable) - map_auto_data(mux, o); - } else { - for (int i = 0; i < o->nb_stream_maps; i++) - map_manual(mux, o, &o->stream_maps[i]); - } + /* create all output streams for this file */ + create_streams(mux, o); of_add_attachments(mux, o);