From patchwork Thu Oct 13 13:49:03 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anton Khirnov X-Patchwork-Id: 38724 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:4a86:b0:9d:28a3:170e with SMTP id fn6csp349285pzb; Thu, 13 Oct 2022 06:50:50 -0700 (PDT) X-Google-Smtp-Source: AMsMyM40n7MjfmhBigmDqbYFSKctg4DcK+dtIMHdBpmvj8B3h+dilPuxKL0uxPRCJLztgKg1DQFb X-Received: by 2002:a17:907:31ca:b0:780:2170:e08c with SMTP id xf10-20020a17090731ca00b007802170e08cmr26525365ejb.145.1665669049759; Thu, 13 Oct 2022 06:50:49 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1665669049; cv=none; d=google.com; s=arc-20160816; b=d2ApkmiEIHDl2vhe55qsNwM9iHRC/y0QaXJTaNB3g+zOmMsgM8jZFdN4y43l9EiH2p y/gIbPRJLPE2tfetVWq/yPSpX6QwmniOi4/Isn6ocCOBouC0ANHTqxINSGDW81xVyMI0 d5PIzv1k07A3aMdkt6Z33vv//zcsA7b44ntO4IiWSWcxuIzhbHAEj+s1+uACZwZ0XTpE cU0JlXXbepP3MTvdlqbLvtK4FHjd0giepMoZBnuizjSEINeVSFPwVZg0yGbs2kUGs/JA Dbw4LQR9Uify1bpPGCIMifO9I0BlM97A/ul2s+R0bvrmRmU2jtfCf3GcMYnyBaxSQiMZ kXwg== 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=QfeZaS24cmlykSrs0tRWFYQ3bMniGzkWPPbhRNh2r2I=; b=KZaRtDU5SiH3owze3T2NKsjmCyzyYOSQezN172ds26UfhBl/1uvhYiiPdi3uyngtMK 36mKTiQkAsBPUQPNrhvHKCgd9P3UivSghdziSCczcWMQKbxsMDmPx2/he/+DHY7abxn/ mt/fJfnMiZOGly/z75jhezbH3dv4mFivwNK+dmgb/JDcT+shoPVpBg5ibTmZmgtGESLt Agl2UZboao/utRS9za6K2F0WCWpB9obqrnyKnt3RrlxuKy+FcnmMQ+96MDBYT8T7hWvK qoMlZ6LRUi143idjVJhkW8o1WfidCsVFV9pw1o5oLI0PFN8U2qiaAv63KVI0AwZa/U6u f8sA== 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 k14-20020a1709063fce00b0078db6f5f4c3si9530378ejj.664.2022.10.13.06.50.49; Thu, 13 Oct 2022 06:50:49 -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 E886E68BD8E; 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 97B1468BD40 for ; Thu, 13 Oct 2022 16:49:19 +0300 (EEST) Received: from localhost (localhost [IPv6:::1]) by mail0.khirnov.net (Postfix) with ESMTP id B872C2406C7 for ; Thu, 13 Oct 2022 15:49:17 +0200 (CEST) Received: from mail0.khirnov.net ([IPv6:::1]) by localhost (mail0.khirnov.net [IPv6:::1]) (amavisd-new, port 10024) with ESMTP id B26GHhq_mzES for ; Thu, 13 Oct 2022 15:49:17 +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 551942405EC 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 3BB6A3A1909 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:03 +0200 Message-Id: <20221013134904.10104-12-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 12/13] fftools/ffmpeg_mux: move sq_mux from OutputFile to Muxer 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: hdieYOD4cDWo It is internal to ffmpeg_mux* and does not need to be visible to other code. --- fftools/ffmpeg.h | 1 - fftools/ffmpeg_mux.c | 8 ++++---- fftools/ffmpeg_mux.h | 1 + fftools/ffmpeg_mux_init.c | 8 ++++---- 4 files changed, 9 insertions(+), 9 deletions(-) diff --git a/fftools/ffmpeg.h b/fftools/ffmpeg.h index 9ccd158e4b..20eb6e2aa9 100644 --- a/fftools/ffmpeg.h +++ b/fftools/ffmpeg.h @@ -620,7 +620,6 @@ typedef struct OutputFile { const char *url; SyncQueue *sq_encode; - SyncQueue *sq_mux; int nb_streams; int ost_index; /* index of the first stream in output_streams */ diff --git a/fftools/ffmpeg_mux.c b/fftools/ffmpeg_mux.c index f830e5854b..652628185e 100644 --- a/fftools/ffmpeg_mux.c +++ b/fftools/ffmpeg_mux.c @@ -159,12 +159,12 @@ static int sync_queue_process(Muxer *mux, OutputStream *ost, AVPacket *pkt) OutputFile *of = &mux->of; if (ost->sq_idx_mux >= 0) { - int ret = sq_send(of->sq_mux, ost->sq_idx_mux, SQPKT(pkt)); + int ret = sq_send(mux->sq_mux, ost->sq_idx_mux, SQPKT(pkt)); if (ret < 0) return ret; while (1) { - ret = sq_receive(of->sq_mux, -1, SQPKT(mux->sq_pkt)); + ret = sq_receive(mux->sq_mux, -1, SQPKT(mux->sq_pkt)); if (ret < 0) return (ret == AVERROR_EOF || ret == AVERROR(EAGAIN)) ? 0 : ret; @@ -540,7 +540,7 @@ int of_stream_init(OutputFile *of, OutputStream *ost) { Muxer *mux = mux_from_of(of); if (ost->sq_idx_mux >= 0) - sq_set_tb(of->sq_mux, ost->sq_idx_mux, ost->mux_timebase); + sq_set_tb(mux->sq_mux, ost->sq_idx_mux, ost->mux_timebase); ost->initialized = 1; @@ -611,7 +611,7 @@ void of_close(OutputFile **pof) thread_stop(mux); sq_free(&of->sq_encode); - sq_free(&of->sq_mux); + sq_free(&mux->sq_mux); for (int i = 0; i < mux->of.nb_streams; i++) { MuxStream *ms = &mux->streams[i]; diff --git a/fftools/ffmpeg_mux.h b/fftools/ffmpeg_mux.h index d9c4dce750..7cb1337b49 100644 --- a/fftools/ffmpeg_mux.h +++ b/fftools/ffmpeg_mux.h @@ -68,6 +68,7 @@ typedef struct Muxer { atomic_int_least64_t last_filesize; int header_written; + SyncQueue *sq_mux; AVPacket *sq_pkt; } Muxer; diff --git a/fftools/ffmpeg_mux_init.c b/fftools/ffmpeg_mux_init.c index be7286c26d..3945bbed3a 100644 --- a/fftools/ffmpeg_mux_init.c +++ b/fftools/ffmpeg_mux_init.c @@ -1100,8 +1100,8 @@ static int setup_sync_queues(Muxer *mux, AVFormatContext *oc, int64_t buf_size_u /* if there are any additional interleaved streams, then ALL the streams * are also synchronized before sending them to the muxer */ if (nb_interleaved > nb_av_enc) { - of->sq_mux = sq_alloc(SYNC_QUEUE_PACKETS, buf_size_us); - if (!of->sq_mux) + mux->sq_mux = sq_alloc(SYNC_QUEUE_PACKETS, buf_size_us); + if (!mux->sq_mux) return AVERROR(ENOMEM); mux->sq_pkt = av_packet_alloc(); @@ -1115,13 +1115,13 @@ static int setup_sync_queues(Muxer *mux, AVFormatContext *oc, int64_t buf_size_u if (!IS_INTERLEAVED(type)) continue; - ost->sq_idx_mux = sq_add_stream(of->sq_mux, + ost->sq_idx_mux = sq_add_stream(mux->sq_mux, of->shortest || ost->max_frames < INT64_MAX); if (ost->sq_idx_mux < 0) return ost->sq_idx_mux; if (ost->max_frames != INT64_MAX) - sq_limit_frames(of->sq_mux, ost->sq_idx_mux, ost->max_frames); + sq_limit_frames(mux->sq_mux, ost->sq_idx_mux, ost->max_frames); } }