From: Anton Khirnov <anton@khirnov.net> To: ffmpeg-devel@ffmpeg.org Subject: [FFmpeg-devel] [PATCH 4/8] fftools/ffmpeg: move OutputStream.max_frames to MuxStream Date: Mon, 14 Nov 2022 16:13:46 +0100 Message-ID: <20221114151350.5134-4-anton@khirnov.net> (raw) In-Reply-To: <20221114151350.5134-1-anton@khirnov.net> 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; i<o->nb_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); } } -- 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".
next prev parent reply other threads:[~2022-11-14 15:15 UTC|newest] Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top 2022-11-14 15:13 [FFmpeg-devel] [PATCH 1/8] fftools/ffmpeg: simplify ost_iter() Anton Khirnov 2022-11-14 15:13 ` [FFmpeg-devel] [PATCH 2/8] fftools/ffmpeg_mux_init: move more code from of_open() to create_streams() Anton Khirnov 2022-11-14 15:13 ` [FFmpeg-devel] [PATCH 3/8] fftools/ffmpeg: stop handling max_frames in do_video_out() Anton Khirnov 2022-11-14 15:13 ` Anton Khirnov [this message] 2022-11-14 15:13 ` [FFmpeg-devel] [PATCH 5/8] fftools/ffmpeg_mux_init: move validating codec avoptions to a separate function Anton Khirnov 2022-11-14 15:13 ` [FFmpeg-devel] [PATCH 6/8] fftools/ffmpeg_mux_init: do not call av{codec, format}_get_class() repeatedly Anton Khirnov 2022-11-14 15:13 ` [FFmpeg-devel] [PATCH 7/8] fftools/ffmpeg_mux_init: use av_dict_iterate() where appropriate Anton Khirnov 2022-11-14 15:13 ` [FFmpeg-devel] [PATCH 8/8] fftools/ffmpeg_mux_init: drop an always-false check Anton Khirnov 2022-11-14 17:29 ` [FFmpeg-devel] [PATCH 1/8] fftools/ffmpeg: simplify ost_iter() Soft Works
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=20221114151350.5134-4-anton@khirnov.net \ --to=anton@khirnov.net \ --cc=ffmpeg-devel@ffmpeg.org \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: link
Git Inbox Mirror of the ffmpeg-devel mailing list - see https://ffmpeg.org/mailman/listinfo/ffmpeg-devel This inbox may be cloned and mirrored by anyone: git clone --mirror https://master.gitmailbox.com/ffmpegdev/0 ffmpegdev/git/0.git # If you have public-inbox 1.1+ installed, you may # initialize and index your mirror using the following commands: public-inbox-init -V2 ffmpegdev ffmpegdev/ https://master.gitmailbox.com/ffmpegdev \ ffmpegdev@gitmailbox.com public-inbox-index ffmpegdev Example config snippet for mirrors. AGPL code for this site: git clone https://public-inbox.org/public-inbox.git