Commit Graph

11 Commits

Author SHA1 Message Date
Anton Khirnov 8d26a21bf6 fftools/ffmpeg: stop accessing av_stream_get_parser() from the main thread
It races with the demuxing thread. Instead, send the information along
with the demuxed packets.

Ideally, the code should stop using the stream-internal parsing
completely, but that requires considerably more effort.

Fixes races, e.g. in:
- fate-h264-brokensps-2580
- fate-h264-extradata-reload
- fate-iv8-demux
- fate-m4v-cfr
- fate-m4v
2022-08-29 15:42:11 +02:00
Anton Khirnov 6ded80af92 fftools/ffmpeg: move packet timestamp processing to demuxer thread
Discontinuity detection/correction is left in the main thread, as it is
entangled with InputStream.next_dts and related variables, which may be
set by decoding code.

Fixes races e.g. in fate-ffmpeg-streamloop after
aae9de0cb2.
2022-08-13 12:41:05 +02:00
Anton Khirnov a5e025e826 fftools/ffmpeg: move handling corrupt packets to the input thread 2022-08-08 16:20:58 +02:00
Anton Khirnov 61d9f34c70 fftools/ffmpeg_demux: do not store demux packet in the context
Its use is local to input_thread().
2022-08-08 16:20:58 +02:00
Anton Khirnov de9fb9fba7 fftools/ffmpeg_demux: factorize signalling end of demuxing 2022-08-08 16:20:58 +02:00
Anton Khirnov aae9de0cb2 fftools/ffmpeg: move -stream_loop handling to the demuxer thread
-stream_loop is currently handled by destroying the demuxer thread,
seeking, then recreating it anew. This is very messy and conflicts with
the future goal of moving each major ffmpeg component into its own
thread.

Handle -stream_loop directly in the demuxer thread. Looping requires the
demuxer to know the duration of the file, which takes into account the
duration of the last decoded audio frame (if any). Use a thread message
queue to communicate this information from the main thread to the
demuxer thread.
2022-08-08 16:20:58 +02:00
Anton Khirnov b99462cd27 fftools/ffmpeg: move seek_to_start() to ffmpeg_demux.c
Reduces the diff in the following commit.
2022-08-08 16:20:58 +02:00
Anton Khirnov 57d75ca031 fftools/ffmpeg: move get_input_packet() to ffmpeg_demux.c
Also rename it to use the ifile_* namespace.
2022-08-08 16:20:58 +02:00
Anton Khirnov 07da07ddb0 fftools/ffmpeg: report new streams from the input thread
This avoids a potential race with the demuxer adding new streams. It is
also more efficient, since we no longer do inter-thread transfers of
packets that will be just discarded.
2022-08-08 16:20:58 +02:00
Anton Khirnov 9c16310fe5 fftools/ffmpeg: handle dumping input packets in input_thread()
This is a more appropriate place for this.
2022-08-08 16:20:58 +02:00
Anton Khirnov 7b6622705e fftools/ffmpeg: move the input thread into its own file
It will contain more demuxing-specific code in the future.
2022-08-08 16:20:58 +02:00