From: Anton Khirnov <anton@khirnov.net>
To: ffmpeg-devel@ffmpeg.org
Subject: [FFmpeg-devel] [PATCH 07/20] fftools/ffmpeg: move duration/time_base from InputFile to Demuxer
Date: Tue, 18 Oct 2022 14:36:48 +0200
Message-ID: <20221018123701.25002-7-anton@khirnov.net> (raw)
In-Reply-To: <20221018123701.25002-1-anton@khirnov.net>
They are private to the demuxer and do not need to be visible outside of
it.
---
fftools/ffmpeg.h | 3 ---
fftools/ffmpeg_demux.c | 30 ++++++++++++++++++------------
2 files changed, 18 insertions(+), 15 deletions(-)
diff --git a/fftools/ffmpeg.h b/fftools/ffmpeg.h
index 8c3effdb05..2f635c779d 100644
--- a/fftools/ffmpeg.h
+++ b/fftools/ffmpeg.h
@@ -434,9 +434,6 @@ typedef struct InputFile {
int eof_reached; /* true if eof reached */
int eagain; /* true if last read attempt returned EAGAIN */
int ist_index; /* index of first stream in input_streams */
- int64_t duration; /* actual duration of the longest stream in a file
- at the moment when looping happens */
- AVRational time_base; /* time base of the duration */
int64_t input_ts_offset;
int input_sync_ref;
diff --git a/fftools/ffmpeg_demux.c b/fftools/ffmpeg_demux.c
index 90868de7aa..fe1b3bd8b7 100644
--- a/fftools/ffmpeg_demux.c
+++ b/fftools/ffmpeg_demux.c
@@ -50,6 +50,11 @@ typedef struct Demuxer {
/* number of times input stream should be looped */
int loop;
+ /* actual duration of the longest stream in a file at the moment when
+ * looping happens */
+ int64_t duration;
+ /* time base of the duration */
+ AVRational time_base;
AVThreadMessageQueue *in_thread_queue;
int thread_queue_size;
@@ -84,7 +89,7 @@ static void report_new_stream(InputFile *file, const AVPacket *pkt)
file->nb_streams_warn = pkt->stream_index + 1;
}
-static void ifile_duration_update(InputFile *f, InputStream *ist,
+static void ifile_duration_update(Demuxer *d, InputStream *ist,
int64_t last_duration)
{
/* the total duration of the stream, max_pts - min_pts is
@@ -93,11 +98,11 @@ static void ifile_duration_update(InputFile *f, InputStream *ist,
ist->max_pts - (uint64_t)ist->min_pts < INT64_MAX - last_duration)
last_duration += ist->max_pts - ist->min_pts;
- if (!f->duration ||
- av_compare_ts(f->duration, f->time_base,
+ if (!d->duration ||
+ av_compare_ts(d->duration, d->time_base,
last_duration, ist->st->time_base) < 0) {
- f->duration = last_duration;
- f->time_base = ist->st->time_base;
+ d->duration = last_duration;
+ d->time_base = ist->st->time_base;
}
}
@@ -126,7 +131,7 @@ static int seek_to_start(Demuxer *d)
got_durations++;
ist = input_streams[ifile->ist_index + dur.stream_idx];
- ifile_duration_update(ifile, ist, dur.duration);
+ ifile_duration_update(d, ist, dur.duration);
}
} else {
for (int i = 0; i < ifile->nb_streams; i++) {
@@ -141,7 +146,7 @@ static int seek_to_start(Demuxer *d)
duration = 1;
}
- ifile_duration_update(ifile, ist, duration);
+ ifile_duration_update(d, ist, duration);
}
}
@@ -151,8 +156,9 @@ static int seek_to_start(Demuxer *d)
return ret;
}
-static void ts_fixup(InputFile *ifile, AVPacket *pkt, int *repeat_pict)
+static void ts_fixup(Demuxer *d, AVPacket *pkt, int *repeat_pict)
{
+ InputFile *ifile = &d->f;
InputStream *ist = input_streams[ifile->ist_index + pkt->stream_index];
const int64_t start_time = ifile->ctx->start_time;
int64_t duration;
@@ -195,7 +201,7 @@ static void ts_fixup(InputFile *ifile, AVPacket *pkt, int *repeat_pict)
if (pkt->dts != AV_NOPTS_VALUE)
pkt->dts *= ist->ts_scale;
- duration = av_rescale_q(ifile->duration, ifile->time_base, ist->st->time_base);
+ duration = av_rescale_q(d->duration, d->time_base, ist->st->time_base);
if (pkt->pts != AV_NOPTS_VALUE) {
pkt->pts += duration;
ist->max_pts = FFMAX(pkt->pts, ist->max_pts);
@@ -274,7 +280,7 @@ static void *input_thread(void *arg)
}
}
- ts_fixup(f, pkt, &msg.repeat_pict);
+ ts_fixup(d, pkt, &msg.repeat_pict);
msg.pkt = av_packet_alloc();
if (!msg.pkt) {
@@ -960,8 +966,8 @@ int ifile_open(OptionsContext *o, const char *filename)
f->rate_emu = o->rate_emu;
f->accurate_seek = o->accurate_seek;
d->loop = o->loop;
- f->duration = 0;
- f->time_base = (AVRational){ 1, 1 };
+ d->duration = 0;
+ d->time_base = (AVRational){ 1, 1 };
f->readrate = o->readrate ? o->readrate : 0.0;
if (f->readrate < 0.0f) {
--
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-10-18 12:40 UTC|newest]
Thread overview: 24+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-10-18 12:36 [FFmpeg-devel] [PATCH 01/20] fftools/ffmpeg_opt: move opening input files to ffmpeg_demux.c Anton Khirnov
2022-10-18 12:36 ` [FFmpeg-devel] [PATCH 02/20] fftools/ffmpeg_demux: add demuxer private data Anton Khirnov
2022-10-18 12:36 ` [FFmpeg-devel] [PATCH 03/20] fftools/ffmpeg: drop init_input_threads() Anton Khirnov
2022-10-18 12:36 ` [FFmpeg-devel] [PATCH 04/20] fftools/ffmpeg: move closing the input file into a separate function Anton Khirnov
2022-10-18 12:36 ` [FFmpeg-devel] [PATCH 05/20] fftools/ffmpeg: drop free_input_threads() Anton Khirnov
2022-10-18 12:36 ` [FFmpeg-devel] [PATCH 06/20] fftools/ffmpeg: move threading fields from InputFile to Demuxer Anton Khirnov
2022-10-18 12:36 ` Anton Khirnov [this message]
2022-10-18 12:36 ` [FFmpeg-devel] [PATCH 08/20] fftools/ffmpeg_demux: do not log to the demuxer context Anton Khirnov
2022-10-18 12:36 ` [FFmpeg-devel] [PATCH 09/20] fftools/ffmpeg: move nb_streams_warn from InputFile to Demuxer Anton Khirnov
2022-10-18 12:36 ` [FFmpeg-devel] [PATCH 10/20] fftools/ffmpeg_demux: log when the demuxer thread terminates Anton Khirnov
2022-10-18 12:36 ` [FFmpeg-devel] [PATCH 11/20] fftools/ffmpeg: factor out copying metadata/chapters from of_open() Anton Khirnov
2022-10-18 12:36 ` [FFmpeg-devel] [PATCH 12/20] fftools/ffmpeg_mux_init: avoid modifying OptionsContext.chapters_input_file Anton Khirnov
2022-10-18 12:36 ` [FFmpeg-devel] [PATCH 13/20] fftools/ffmpeg_mux_init: constify metadata specifier arguments Anton Khirnov
2022-10-18 12:36 ` [FFmpeg-devel] [PATCH 14/20] fftools/ffmpeg_mux_init: drop a duplicated block in copy_metadata() Anton Khirnov
2022-10-18 21:51 ` Michael Niedermayer
2022-11-08 12:46 ` Anton Khirnov
2022-11-14 9:24 ` Anton Khirnov
2022-11-14 22:21 ` Michael Niedermayer
2022-10-18 12:36 ` [FFmpeg-devel] [PATCH 15/20] fftools/ffmpeg_mux_init: stop using OptionsContext as storage " Anton Khirnov
2022-10-18 12:36 ` [FFmpeg-devel] [PATCH 16/20] fftools/ffmpeg_mux_init: stop modifying some OptionsContext fields Anton Khirnov
2022-10-18 12:36 ` [FFmpeg-devel] [PATCH 17/20] fftools/ffmpeg_mux_init: move code creating streams into a new function Anton Khirnov
2022-10-18 12:36 ` [FFmpeg-devel] [PATCH 18/20] fftools/ffmpeg_mux_init: stop modifying OptionsContext.*_disable Anton Khirnov
2022-10-18 12:37 ` [FFmpeg-devel] [PATCH 19/20] fftools/ffmpeg_demux: stop modifying OptionsContext Anton Khirnov
2022-10-18 12:37 ` [FFmpeg-devel] [PATCH 20/20] fftools/ffmpeg_[de]mux: constify all uses of OptionsContext Anton Khirnov
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=20221018123701.25002-7-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