summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAnton Khirnov <anton@khirnov.net>2022-08-03 14:30:48 +0200
committerAnton Khirnov <anton@khirnov.net>2022-08-08 16:20:58 +0200
commit57d75ca031943c0b4858bcd2a0f1812df0d502b0 (patch)
treefe6baa0a0a71f2c778c5fc608395e8e9cfed4811
parent07da07ddb0fb7ee6a4ddd26fc5676e4939dd7441 (diff)
fftools/ffmpeg: move get_input_packet() to ffmpeg_demux.c
Also rename it to use the ifile_* namespace.
-rw-r--r--fftools/ffmpeg.c30
-rw-r--r--fftools/ffmpeg.h1
-rw-r--r--fftools/ffmpeg_demux.c26
3 files changed, 29 insertions, 28 deletions
diff --git a/fftools/ffmpeg.c b/fftools/ffmpeg.c
index b9cafb3c36..4ce31d8440 100644
--- a/fftools/ffmpeg.c
+++ b/fftools/ffmpeg.c
@@ -3610,32 +3610,6 @@ static int check_keyboard_interaction(int64_t cur_time)
return 0;
}
-static int get_input_packet(InputFile *f, AVPacket **pkt)
-{
- if (f->readrate || f->rate_emu) {
- int i;
- int64_t file_start = copy_ts * (
- (f->ctx->start_time != AV_NOPTS_VALUE ? f->ctx->start_time * !start_at_zero : 0) +
- (f->start_time != AV_NOPTS_VALUE ? f->start_time : 0)
- );
- float scale = f->rate_emu ? 1.0 : f->readrate;
- for (i = 0; i < f->nb_streams; i++) {
- InputStream *ist = input_streams[f->ist_index + i];
- int64_t stream_ts_offset, pts, now;
- if (!ist->nb_packets || (ist->decoding_needed && !ist->got_output)) continue;
- stream_ts_offset = FFMAX(ist->first_dts != AV_NOPTS_VALUE ? ist->first_dts : 0, file_start);
- pts = av_rescale(ist->dts, 1000000, AV_TIME_BASE);
- now = (av_gettime_relative() - ist->start) * scale + stream_ts_offset;
- if (pts > now)
- return AVERROR(EAGAIN);
- }
- }
-
- return av_thread_message_queue_recv(f->in_thread_queue, pkt,
- f->non_blocking ?
- AV_THREAD_MESSAGE_NONBLOCK : 0);
-}
-
static int got_eagain(void)
{
int i;
@@ -3752,7 +3726,7 @@ static int process_input(int file_index)
int disable_discontinuity_correction = copy_ts;
is = ifile->ctx;
- ret = get_input_packet(ifile, &pkt);
+ ret = ifile_get_packet(ifile, &pkt);
if (ret == AVERROR(EAGAIN)) {
ifile->eagain = 1;
@@ -3777,7 +3751,7 @@ static int process_input(int file_index)
if (ret < 0)
av_log(NULL, AV_LOG_WARNING, "Seek to start failed.\n");
else
- ret = get_input_packet(ifile, &pkt);
+ ret = ifile_get_packet(ifile, &pkt);
if (ret == AVERROR(EAGAIN)) {
ifile->eagain = 1;
return ret;
diff --git a/fftools/ffmpeg.h b/fftools/ffmpeg.h
index 81356fd566..f983d077d9 100644
--- a/fftools/ffmpeg.h
+++ b/fftools/ffmpeg.h
@@ -710,6 +710,7 @@ int64_t of_filesize(OutputFile *of);
AVChapter * const *
of_get_chapters(OutputFile *of, unsigned int *nb_chapters);
+int ifile_get_packet(InputFile *f, AVPacket **pkt);
int init_input_threads(void);
int init_input_thread(int i);
void free_input_threads(void);
diff --git a/fftools/ffmpeg_demux.c b/fftools/ffmpeg_demux.c
index 2d49a3c48c..182364dae5 100644
--- a/fftools/ffmpeg_demux.c
+++ b/fftools/ffmpeg_demux.c
@@ -163,3 +163,29 @@ int init_input_threads(void)
}
return 0;
}
+
+int ifile_get_packet(InputFile *f, AVPacket **pkt)
+{
+ if (f->readrate || f->rate_emu) {
+ int i;
+ int64_t file_start = copy_ts * (
+ (f->ctx->start_time != AV_NOPTS_VALUE ? f->ctx->start_time * !start_at_zero : 0) +
+ (f->start_time != AV_NOPTS_VALUE ? f->start_time : 0)
+ );
+ float scale = f->rate_emu ? 1.0 : f->readrate;
+ for (i = 0; i < f->nb_streams; i++) {
+ InputStream *ist = input_streams[f->ist_index + i];
+ int64_t stream_ts_offset, pts, now;
+ if (!ist->nb_packets || (ist->decoding_needed && !ist->got_output)) continue;
+ stream_ts_offset = FFMAX(ist->first_dts != AV_NOPTS_VALUE ? ist->first_dts : 0, file_start);
+ pts = av_rescale(ist->dts, 1000000, AV_TIME_BASE);
+ now = (av_gettime_relative() - ist->start) * scale + stream_ts_offset;
+ if (pts > now)
+ return AVERROR(EAGAIN);
+ }
+ }
+
+ return av_thread_message_queue_recv(f->in_thread_queue, pkt,
+ f->non_blocking ?
+ AV_THREAD_MESSAGE_NONBLOCK : 0);
+}