diff options
| author | Carl Hetherington <cth@carlh.net> | 2022-11-15 00:44:37 +0100 |
|---|---|---|
| committer | Carl Hetherington <cth@carlh.net> | 2022-11-15 22:42:43 +0100 |
| commit | d42bc731c125170efb1bb7b8c9f990a3e9fa5b57 (patch) | |
| tree | c612e631ba68c07672b337e9769607a5f24eed38 /src/lib/ffmpeg_decoder.h | |
| parent | 5e09964bf1801b76970ed960122249e1d273abea (diff) | |
Improve flushing behaviour when there is a lot of space to fill (#2364).
Previously a call to flush() could result in a lot of audio being
emitted from the decoder (if there is a big gap between the end
of the audio and the video). This would end up being emitted in
one chunk from the player, crashing the audio analyser with an OOM
in some cases.
Diffstat (limited to 'src/lib/ffmpeg_decoder.h')
| -rw-r--r-- | src/lib/ffmpeg_decoder.h | 18 |
1 files changed, 17 insertions, 1 deletions
diff --git a/src/lib/ffmpeg_decoder.h b/src/lib/ffmpeg_decoder.h index 9de44333c..1e47e2fca 100644 --- a/src/lib/ffmpeg_decoder.h +++ b/src/lib/ffmpeg_decoder.h @@ -58,7 +58,12 @@ public: private: friend struct ::ffmpeg_pts_offset_test; - bool flush (); + enum class FlushResult { + DONE, + AGAIN + }; + + FlushResult flush(); AVSampleFormat audio_sample_format (std::shared_ptr<FFmpegAudioStream> stream) const; int bytes_per_audio_sample (std::shared_ptr<FFmpegAudioStream> stream) const; @@ -77,6 +82,9 @@ private: void maybe_add_subtitle (); + FlushResult flush_codecs(); + FlushResult flush_fill(); + VideoFilterGraphSet _filter_graphs; dcpomatic::ContentTime _pts_offset; @@ -87,4 +95,12 @@ private: std::shared_ptr<Image> _black_image; std::map<std::shared_ptr<FFmpegAudioStream>, boost::optional<dcpomatic::ContentTime>> _next_time; + + enum class FlushState { + CODECS, + AUDIO_DECODER, + FILL, + }; + + FlushState _flush_state = FlushState::CODECS; }; |
