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 6B9C843509 for ; Thu, 13 Oct 2022 13:50:39 +0000 (UTC) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id D3C4A68BD89; Thu, 13 Oct 2022 16:49:29 +0300 (EEST) Received: from mail0.khirnov.net (red.khirnov.net [176.97.15.12]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 7F3EE68BD67 for ; Thu, 13 Oct 2022 16:49:19 +0300 (EEST) Received: from localhost (localhost [IPv6:::1]) by mail0.khirnov.net (Postfix) with ESMTP id A74142405F9 for ; Thu, 13 Oct 2022 15:49:16 +0200 (CEST) Received: from mail0.khirnov.net ([IPv6:::1]) by localhost (mail0.khirnov.net [IPv6:::1]) (amavisd-new, port 10024) with ESMTP id L7oReiJWkkip for ; Thu, 13 Oct 2022 15:49:16 +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 6D94A2406CA for ; Thu, 13 Oct 2022 15:49:13 +0200 (CEST) Received: from libav.khirnov.net (libav.khirnov.net [IPv6:::1]) by libav.khirnov.net (Postfix) with ESMTP id 2E0E43A184A for ; Thu, 13 Oct 2022 15:49:08 +0200 (CEST) From: Anton Khirnov To: ffmpeg-devel@ffmpeg.org Date: Thu, 13 Oct 2022 15:49:00 +0200 Message-Id: <20221013134904.10104-9-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 09/13] fftools/ffmpeg_mux: allocate sq_pkt in setup_sync_queues() 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 is now possible since setup_sync_queues() can interact with Muxer. --- fftools/ffmpeg_mux.c | 8 -------- fftools/ffmpeg_mux_init.c | 13 ++++++++++--- 2 files changed, 10 insertions(+), 11 deletions(-) diff --git a/fftools/ffmpeg_mux.c b/fftools/ffmpeg_mux.c index 4cb5a71659..4c56f4ba96 100644 --- a/fftools/ffmpeg_mux.c +++ b/fftools/ffmpeg_mux.c @@ -671,14 +671,6 @@ int of_muxer_init(OutputFile *of, AVFormatContext *fc, if (strcmp(of->format->name, "rtp")) want_sdp = 0; - if (of->sq_mux) { - mux->sq_pkt = av_packet_alloc(); - if (!mux->sq_pkt) { - ret = AVERROR(ENOMEM); - goto fail; - } - } - /* write the header for files with no streams */ if (of->format->flags & AVFMT_NOSTREAMS && fc->nb_streams == 0) { ret = mux_check_init(of); diff --git a/fftools/ffmpeg_mux_init.c b/fftools/ffmpeg_mux_init.c index 5b515ed034..6c4d9bad1e 100644 --- a/fftools/ffmpeg_mux_init.c +++ b/fftools/ffmpeg_mux_init.c @@ -1040,8 +1040,9 @@ loop_end: } } -static int setup_sync_queues(OutputFile *of, AVFormatContext *oc, int64_t buf_size_us) +static int setup_sync_queues(Muxer *mux, AVFormatContext *oc, int64_t buf_size_us) { + OutputFile *of = &mux->of; int nb_av_enc = 0, nb_interleaved = 0; int limit_frames = 0, limit_frames_av_enc = 0; @@ -1103,6 +1104,10 @@ static int setup_sync_queues(OutputFile *of, AVFormatContext *oc, int64_t buf_si if (!of->sq_mux) return AVERROR(ENOMEM); + mux->sq_pkt = av_packet_alloc(); + if (!mux->sq_pkt) + return AVERROR(ENOMEM); + for (int i = 0; i < oc->nb_streams; i++) { OutputStream *ost = output_streams[of->ost_index + i]; enum AVMediaType type = ost->st->codecpar->codec_type; @@ -1573,6 +1578,7 @@ static int set_dispositions(OutputFile *of, AVFormatContext *ctx) int of_open(OptionsContext *o, const char *filename) { + Muxer *mux; AVFormatContext *oc; int i, j, err; OutputFile *of; @@ -1594,7 +1600,8 @@ int of_open(OptionsContext *o, const char *filename) } } - of = allocate_array_elem(&output_files, sizeof(Muxer), &nb_output_files); + mux = allocate_array_elem(&output_files, sizeof(Muxer), &nb_output_files); + of = &mux->of; of->index = nb_output_files - 1; of->ost_index = nb_output_streams; @@ -1869,7 +1876,7 @@ int of_open(OptionsContext *o, const char *filename) exit_program(1); } - err = setup_sync_queues(of, oc, o->shortest_buf_duration * AV_TIME_BASE); + err = setup_sync_queues(mux, oc, o->shortest_buf_duration * AV_TIME_BASE); if (err < 0) { av_log(NULL, AV_LOG_FATAL, "Error setting up output sync queues\n"); exit_program(1); -- 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".