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 56E57434C0 for ; Thu, 13 Oct 2022 13:50:12 +0000 (UTC) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id C830B68BD7D; Thu, 13 Oct 2022 16:49:26 +0300 (EEST) Received: from mail0.khirnov.net (red.khirnov.net [176.97.15.12]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 1A9AB68BD3B for ; Thu, 13 Oct 2022 16:49:21 +0300 (EEST) Received: from localhost (localhost [IPv6:::1]) by mail0.khirnov.net (Postfix) with ESMTP id 9C47E2406CB for ; Thu, 13 Oct 2022 15:49:18 +0200 (CEST) Received: from mail0.khirnov.net ([IPv6:::1]) by localhost (mail0.khirnov.net [IPv6:::1]) (amavisd-new, port 10024) with ESMTP id uSPhk4njvaqe for ; Thu, 13 Oct 2022 15:49:18 +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 7EC402406CD for ; Thu, 13 Oct 2022 15:49:14 +0200 (CEST) Received: from libav.khirnov.net (libav.khirnov.net [IPv6:::1]) by libav.khirnov.net (Postfix) with ESMTP id 099373A168C for ; Thu, 13 Oct 2022 15:49:08 +0200 (CEST) From: Anton Khirnov To: ffmpeg-devel@ffmpeg.org Date: Thu, 13 Oct 2022 15:48:56 +0200 Message-Id: <20221013134904.10104-5-anton@khirnov.net> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20221013134904.10104-1-anton@khirnov.net> References: <20221013134904.10104-1-anton@khirnov.net> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 05/13] fftools/ffmpeg: move some stream initialization code to ffmpeg_mux 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: The code in question is muxing-specific and so belongs there. This will allow make some objects private to the muxer in future commits. --- fftools/ffmpeg.c | 8 +------- fftools/ffmpeg.h | 10 ++++++++-- fftools/ffmpeg_mux.c | 15 ++++++++++++--- 3 files changed, 21 insertions(+), 12 deletions(-) diff --git a/fftools/ffmpeg.c b/fftools/ffmpeg.c index 015ff762c9..9bb877fb34 100644 --- a/fftools/ffmpeg.c +++ b/fftools/ffmpeg.c @@ -3115,7 +3115,6 @@ static int init_output_stream_encode(OutputStream *ost, AVFrame *frame) static int init_output_stream(OutputStream *ost, AVFrame *frame, char *error, int error_len) { - OutputFile *of = output_files[ost->file_index]; int ret = 0; if (ost->enc_ctx) { @@ -3220,12 +3219,7 @@ static int init_output_stream(OutputStream *ost, AVFrame *frame, if (ret < 0) return ret; - if (ost->sq_idx_mux >= 0) - sq_set_tb(of->sq_mux, ost->sq_idx_mux, ost->mux_timebase); - - ost->initialized = 1; - - ret = of_check_init(output_files[ost->file_index]); + ret = of_stream_init(output_files[ost->file_index], ost); if (ret < 0) return ret; diff --git a/fftools/ffmpeg.h b/fftools/ffmpeg.h index 632b7c0e86..5030f72fe5 100644 --- a/fftools/ffmpeg.h +++ b/fftools/ffmpeg.h @@ -720,8 +720,14 @@ int hwaccel_decode_init(AVCodecContext *avctx); int of_muxer_init(OutputFile *of, AVFormatContext *fc, AVDictionary *opts, int64_t limit_filesize, int thread_queue_size); -/* open the muxer when all the streams are initialized */ -int of_check_init(OutputFile *of); + +/* + * Initialize muxing state for the given stream, should be called + * after the codec/streamcopy setup has been done. + * + * Open the muxer once all the streams have been initialized. + */ +int of_stream_init(OutputFile *of, OutputStream *ost); int of_write_trailer(OutputFile *of); void of_close(OutputFile **pof); diff --git a/fftools/ffmpeg_mux.c b/fftools/ffmpeg_mux.c index 63f63c0852..7bc25c6175 100644 --- a/fftools/ffmpeg_mux.c +++ b/fftools/ffmpeg_mux.c @@ -516,8 +516,7 @@ fail: return ret; } -/* open the muxer when all the streams are initialized */ -int of_check_init(OutputFile *of) +static int mux_check_init(OutputFile *of) { AVFormatContext *fc = of->mux->fc; int ret, i; @@ -565,6 +564,16 @@ int of_check_init(OutputFile *of) return 0; } +int of_stream_init(OutputFile *of, OutputStream *ost) +{ + if (ost->sq_idx_mux >= 0) + sq_set_tb(of->sq_mux, ost->sq_idx_mux, ost->mux_timebase); + + ost->initialized = 1; + + return mux_check_init(of); +} + int of_write_trailer(OutputFile *of) { AVFormatContext *fc = of->mux->fc; @@ -710,7 +719,7 @@ int of_muxer_init(OutputFile *of, AVFormatContext *fc, /* write the header for files with no streams */ if (of->format->flags & AVFMT_NOSTREAMS && fc->nb_streams == 0) { - ret = of_check_init(of); + ret = mux_check_init(of); if (ret < 0) goto fail; } -- 2.35.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".