summaryrefslogtreecommitdiff
path: root/fftools
diff options
context:
space:
mode:
authorAnton Khirnov <anton@khirnov.net>2022-10-17 11:23:55 +0200
committerAnton Khirnov <anton@khirnov.net>2022-10-25 11:04:42 +0200
commit09cd147dccc149ae17081d6016ccb79f1afcb592 (patch)
tree788a03b37b479655078b71b0ba5b788bf157caf1 /fftools
parent69753205065e6152caa4e971a9c8f7d018097e6c (diff)
fftools/ffmpeg: drop init_input_threads()
Start threads implicitly when ifile_get_packet() is called. Simplifies the demuxer API.
Diffstat (limited to 'fftools')
-rw-r--r--fftools/ffmpeg.c3
-rw-r--r--fftools/ffmpeg.h1
-rw-r--r--fftools/ffmpeg_demux.c24
3 files changed, 9 insertions, 19 deletions
diff --git a/fftools/ffmpeg.c b/fftools/ffmpeg.c
index e57486fd4a..f8b02a8871 100644
--- a/fftools/ffmpeg.c
+++ b/fftools/ffmpeg.c
@@ -3912,9 +3912,6 @@ static int transcode(void)
timer_start = av_gettime_relative();
- if ((ret = init_input_threads()) < 0)
- goto fail;
-
while (!received_sigterm) {
int64_t cur_time= av_gettime_relative();
diff --git a/fftools/ffmpeg.h b/fftools/ffmpeg.h
index 12df5920a6..ab8b9018ca 100644
--- a/fftools/ffmpeg.h
+++ b/fftools/ffmpeg.h
@@ -770,7 +770,6 @@ int ifile_open(OptionsContext *o, const char *filename);
* - a negative error code on failure
*/
int ifile_get_packet(InputFile *f, AVPacket **pkt);
-int init_input_threads(void);
void free_input_threads(void);
#define SPECIFIER_OPT_FMT_str "%s"
diff --git a/fftools/ffmpeg_demux.c b/fftools/ffmpeg_demux.c
index 847d6901d3..53a497da66 100644
--- a/fftools/ffmpeg_demux.c
+++ b/fftools/ffmpeg_demux.c
@@ -346,11 +346,10 @@ void free_input_threads(void)
free_input_thread(i);
}
-static int init_input_thread(int i)
+static int thread_start(Demuxer *d)
{
int ret;
- InputFile *f = input_files[i];
- Demuxer *d = demuxer_from_ifile(f);
+ InputFile *f = &d->f;
if (f->thread_queue_size <= 0)
f->thread_queue_size = (nb_input_files > 1 ? 8 : 1);
@@ -393,24 +392,19 @@ fail:
return ret;
}
-int init_input_threads(void)
-{
- int i, ret;
-
- for (i = 0; i < nb_input_files; i++) {
- ret = init_input_thread(i);
- if (ret < 0)
- return ret;
- }
- return 0;
-}
-
int ifile_get_packet(InputFile *f, AVPacket **pkt)
{
+ Demuxer *d = demuxer_from_ifile(f);
InputStream *ist;
DemuxMsg msg;
int ret;
+ if (!f->in_thread_queue) {
+ ret = thread_start(d);
+ if (ret < 0)
+ return ret;
+ }
+
if (f->readrate || f->rate_emu) {
int i;
int64_t file_start = copy_ts * (