From patchwork Thu Oct 13 13:49:00 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anton Khirnov X-Patchwork-Id: 38715 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:4a86:b0:9d:28a3:170e with SMTP id fn6csp349218pzb; Thu, 13 Oct 2022 06:50:42 -0700 (PDT) X-Google-Smtp-Source: AMsMyM42/U7enopbEzH2UAwn2Usq/yVuf4Ax4V9S2n9fO2k+I45fZeSVQHfN5NgyjVkJzpHU4GaT X-Received: by 2002:a17:907:9495:b0:78e:1bee:5919 with SMTP id dm21-20020a170907949500b0078e1bee5919mr449861ejc.701.1665669042201; Thu, 13 Oct 2022 06:50:42 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1665669042; cv=none; d=google.com; s=arc-20160816; b=Eitw7ovLqW28OvTDgg5/tCvB4pJzNQtBhd6mIgvP0jd6wClKVr1hBn9VKRfiUx7HUM 8pTQ0303p0IXKC/1Eno/vYoVqNKsf9XXNShd1BQH9+kmXl4zYTOJndSwlgoXfROe058b TG63iSh0PBTMGx94wWmUSOrv4akRqO5Tzkh5AIqETb0PsAxL3xoIpnEflBK38tE7UnGc aieTPASgJ6dWvtBF8AeRgwYcA6UEwX3G+mXjLPuLFgO+eL0rRHbh4xHD28xh/XOI9EU+ V/iqX/ECGMNwHcwvRNARho7dyC4oI78gl00Yg8GhP6Aj55SQ1nzknHY0Zo/bLtcZsvtM kPgg== 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=8BqEtL59UnuDXGdBD98rRzs9m1s6rQn5EtzrSRqg15E=; b=G3eZ6NzAPtB2L16ezuufKut/vQ8P7/JQBh4A1O4VOhG0YDZFJhcs9kHG4CXti6jcSc cOUMLetnrGpPizinHu1wHBlBMBIYToEIsMC5RqAels2snzWT4Z1SJU4pJt90q4wUKrXY APE5vw6Teg6Ana0lDahxPM0fHRtv4nVLnG2pC5EjWQvRnrtq10qHZwPhkHsGwnTFKfWS cRiOBi5/Gx26bSmGCGjvJDAm9QShaKAzdvIpZ2zBUOCgzCfg24hY0CFDQX0XXYIjCpQk A4cZ+WEA4oLEi14EHQZCwxErvdG0bcF/6wbpiyp4C+cEZbsLWbz21B1fggGWNjWmoA9z PIEQ== 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 bx23-20020a0564020b5700b0045bc5ea5334si4887728edb.115.2022.10.13.06.50.41; Thu, 13 Oct 2022 06:50:42 -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 12AE368BD8A; Thu, 13 Oct 2022 16:49:30 +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 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 Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" X-TUID: o1oMZNMq7zl1 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);