From patchwork Mon Nov 14 15:13:46 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anton Khirnov X-Patchwork-Id: 39278 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a21:999a:b0:a4:2148:650a with SMTP id ve26csp2488665pzb; Mon, 14 Nov 2022 07:15:25 -0800 (PST) X-Google-Smtp-Source: AA0mqf7oSnYyvc5L09NhWKh0NDS9sVwGNjTg2MSg9GA+Ye4doTjyrV+JpQrXLtiuSwfMHfZKX3sX X-Received: by 2002:aa7:cd67:0:b0:464:b8b:f594 with SMTP id ca7-20020aa7cd67000000b004640b8bf594mr11364149edb.407.1668438925749; Mon, 14 Nov 2022 07:15:25 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1668438925; cv=none; d=google.com; s=arc-20160816; b=W0qb972SBvWB8gGSgJLULGRIjOcwnnL35mYi+zkhz/FoJGt+QvRO2Ou1Nt+shWKO14 gZ5Gmzf+CLqC6zNdkFcBJ6v0GLXZzilDnTDUSENLgcPvtlFdCF0IMHa2KLtH5iK3fyTs 8n/E6+4Jiv/zaa1XZJBFJ4xP9El47v8n6V8VpElK359p4b+R/Gv9dD9MP7TvrwrPjHNq G2P1f68LY/hSrl9zdrYe6pMmWWyTLR43afGsxtbZAkpxeTvpbIKadL8t4yDbnzv7EoLe eTdqjykCrn1/UC1oybsYbh7p+lu9fWWiVZ7LEXhb/rkMRQetPV7NoBxjya3I/v4STBYq 3krQ== 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=u7hqS6cHJqiVpNUvIoOmWPf8XwMRQ04PceACoZbScuk=; b=nv0T9EAKSI5jlUXkXUUgMiDZGkMo7k5f486cl+VYvDVvIzxixxGVL5nOIVL7mYg3zT BDd7qPhI3s/lhzfsWlYJ9iWUL1+u+LlC7J645V+fGK0iC67gvy03pNxHmcDgWvUoRXlM 2oJvUWdMMD40MIUwdny02dtXY9p8aaJq5s4ZgJzgpIp89A3yGHpqY83nM6gLHfT/r7BY UCKJUElLAv4nf6KyYHsRwzo4UlGFFUtjlbIMfiI6LyfIUAnmg4bFwfX0jGKo8B4Q15ku jk97xeF/HSIP9XSorq7YaXfoMLmIXHEtdqPygotHXEFqbFSZSWcOAKFjQ2VS5oUgnX6t F1IQ== 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 q10-20020a056402518a00b004610f91a242si10480319edd.300.2022.11.14.07.15.25; Mon, 14 Nov 2022 07:15:25 -0800 (PST) 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 AFE6A68BE3E; Mon, 14 Nov 2022 17:14:33 +0200 (EET) 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 0989468BE1F for ; Mon, 14 Nov 2022 17:14:25 +0200 (EET) Received: from localhost (localhost [IPv6:::1]) by mail0.khirnov.net (Postfix) with ESMTP id E011A2404F8 for ; Mon, 14 Nov 2022 16:14:22 +0100 (CET) Received: from mail0.khirnov.net ([IPv6:::1]) by localhost (mail0.khirnov.net [IPv6:::1]) (amavisd-new, port 10024) with ESMTP id 7YHryiR_tBqY for ; Mon, 14 Nov 2022 16:14:22 +0100 (CET) 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 2E5712405F9 for ; Mon, 14 Nov 2022 16:14:19 +0100 (CET) Received: from libav.khirnov.net (libav.khirnov.net [IPv6:::1]) by libav.khirnov.net (Postfix) with ESMTP id B3CAC3A054D for ; Mon, 14 Nov 2022 16:14:18 +0100 (CET) From: Anton Khirnov To: ffmpeg-devel@ffmpeg.org Date: Mon, 14 Nov 2022 16:13:46 +0100 Message-Id: <20221114151350.5134-4-anton@khirnov.net> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20221114151350.5134-1-anton@khirnov.net> References: <20221114151350.5134-1-anton@khirnov.net> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 4/8] fftools/ffmpeg: move OutputStream.max_frames to MuxStream 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: O7Jo4pwuDZD7 It no longer needs to be visible outside of the muxing code. --- fftools/ffmpeg.h | 1 - fftools/ffmpeg_mux.c | 5 ----- fftools/ffmpeg_mux.h | 7 +++++++ fftools/ffmpeg_mux_init.c | 23 +++++++++++++---------- 4 files changed, 20 insertions(+), 16 deletions(-) diff --git a/fftools/ffmpeg.h b/fftools/ffmpeg.h index 23850c7573..ad53ad4ce8 100644 --- a/fftools/ffmpeg.h +++ b/fftools/ffmpeg.h @@ -508,7 +508,6 @@ typedef struct OutputStream { AVRational enc_timebase; AVCodecContext *enc_ctx; - int64_t max_frames; AVFrame *filtered_frame; AVFrame *last_frame; AVFrame *sq_frame; diff --git a/fftools/ffmpeg_mux.c b/fftools/ffmpeg_mux.c index 778626e20f..ad04f5049d 100644 --- a/fftools/ffmpeg_mux.c +++ b/fftools/ffmpeg_mux.c @@ -45,11 +45,6 @@ static Muxer *mux_from_of(OutputFile *of) return (Muxer*)of; } -static MuxStream *ms_from_ost(OutputStream *ost) -{ - return (MuxStream*)ost; -} - static int64_t filesize(AVIOContext *pb) { int64_t ret = -1; diff --git a/fftools/ffmpeg_mux.h b/fftools/ffmpeg_mux.h index 6ea7c692ef..6a72b9dc91 100644 --- a/fftools/ffmpeg_mux.h +++ b/fftools/ffmpeg_mux.h @@ -42,6 +42,8 @@ typedef struct MuxStream { AVBSFContext *bsf_ctx; + int64_t max_frames; + /* * The size of the AVPackets' buffers in queue. * Updated when a packet is either pushed or pulled from the queue. @@ -84,4 +86,9 @@ extern int want_sdp; int mux_check_init(Muxer *mux); +static MuxStream *ms_from_ost(OutputStream *ost) +{ + return (MuxStream*)ost; +} + #endif /* FFTOOLS_FFMPEG_MUX_H */ diff --git a/fftools/ffmpeg_mux_init.c b/fftools/ffmpeg_mux_init.c index 303bf25096..150eb77ee2 100644 --- a/fftools/ffmpeg_mux_init.c +++ b/fftools/ffmpeg_mux_init.c @@ -295,8 +295,8 @@ static OutputStream *new_output_stream(Muxer *mux, const OptionsContext *o, ost->enc_timebase = q; } - ost->max_frames = INT64_MAX; - MATCH_PER_STREAM_OPT(max_frames, i64, ost->max_frames, oc, st); + ms->max_frames = INT64_MAX; + MATCH_PER_STREAM_OPT(max_frames, i64, ms->max_frames, oc, st); for (i = 0; inb_max_frames; i++) { char *p = o->max_frames[i].specifier; if (!*p && type != AVMEDIA_TYPE_VIDEO) { @@ -1165,6 +1165,7 @@ static int setup_sync_queues(Muxer *mux, AVFormatContext *oc, int64_t buf_size_u for (int i = 0; i < oc->nb_streams; i++) { OutputStream *ost = of->streams[i]; + MuxStream *ms = ms_from_ost(ost); enum AVMediaType type = ost->st->codecpar->codec_type; ost->sq_idx_encode = -1; @@ -1173,8 +1174,8 @@ static int setup_sync_queues(Muxer *mux, AVFormatContext *oc, int64_t buf_size_u nb_interleaved += IS_INTERLEAVED(type); nb_av_enc += IS_AV_ENC(ost, type); - limit_frames |= ost->max_frames < INT64_MAX; - limit_frames_av_enc |= (ost->max_frames < INT64_MAX) && IS_AV_ENC(ost, type); + limit_frames |= ms->max_frames < INT64_MAX; + limit_frames_av_enc |= (ms->max_frames < INT64_MAX) && IS_AV_ENC(ost, type); } if (!((nb_interleaved > 1 && of->shortest) || @@ -1191,13 +1192,14 @@ static int setup_sync_queues(Muxer *mux, AVFormatContext *oc, int64_t buf_size_u for (int i = 0; i < oc->nb_streams; i++) { OutputStream *ost = of->streams[i]; + MuxStream *ms = ms_from_ost(ost); enum AVMediaType type = ost->st->codecpar->codec_type; if (!IS_AV_ENC(ost, type)) continue; ost->sq_idx_encode = sq_add_stream(of->sq_encode, - of->shortest || ost->max_frames < INT64_MAX); + of->shortest || ms->max_frames < INT64_MAX); if (ost->sq_idx_encode < 0) return ost->sq_idx_encode; @@ -1205,8 +1207,8 @@ static int setup_sync_queues(Muxer *mux, AVFormatContext *oc, int64_t buf_size_u if (!ost->sq_frame) return AVERROR(ENOMEM); - if (ost->max_frames != INT64_MAX) - sq_limit_frames(of->sq_encode, ost->sq_idx_encode, ost->max_frames); + if (ms->max_frames != INT64_MAX) + sq_limit_frames(of->sq_encode, ost->sq_idx_encode, ms->max_frames); } } @@ -1223,18 +1225,19 @@ static int setup_sync_queues(Muxer *mux, AVFormatContext *oc, int64_t buf_size_u for (int i = 0; i < oc->nb_streams; i++) { OutputStream *ost = of->streams[i]; + MuxStream *ms = ms_from_ost(ost); enum AVMediaType type = ost->st->codecpar->codec_type; if (!IS_INTERLEAVED(type)) continue; ost->sq_idx_mux = sq_add_stream(mux->sq_mux, - of->shortest || ost->max_frames < INT64_MAX); + of->shortest || ms->max_frames < INT64_MAX); if (ost->sq_idx_mux < 0) return ost->sq_idx_mux; - if (ost->max_frames != INT64_MAX) - sq_limit_frames(mux->sq_mux, ost->sq_idx_mux, ost->max_frames); + if (ms->max_frames != INT64_MAX) + sq_limit_frames(mux->sq_mux, ost->sq_idx_mux, ms->max_frames); } }