diff options
| author | Carl Hetherington <cth@carlh.net> | 2015-09-29 10:20:50 +0100 |
|---|---|---|
| committer | Carl Hetherington <cth@carlh.net> | 2015-09-29 10:20:50 +0100 |
| commit | 5dacabb5bf3372107e032f3a90555c3c7f9cb6a7 (patch) | |
| tree | 7c9325c3a4e6d3fcbc15a9396e8be0ae5dc9d3d7 | |
| parent | b08f08eadf8692202af93e385de93b210b7cd5f4 (diff) | |
Make sure we round properly when deciding how many audio frames to discard.
| -rw-r--r-- | ChangeLog | 4 | ||||
| -rw-r--r-- | src/lib/dcpomatic_time.h | 5 | ||||
| -rw-r--r-- | src/lib/ffmpeg_decoder.cc | 2 |
3 files changed, 10 insertions, 1 deletions
@@ -1,3 +1,7 @@ +2015-09-29 Carl Hetherington <cth@carlh.net> + + * Improve fix for failure to analyse some audio. + 2015-09-28 Carl Hetherington <cth@carlh.net> * Version 2.3.9 released. diff --git a/src/lib/dcpomatic_time.h b/src/lib/dcpomatic_time.h index 7d755a46c..a5a0684e5 100644 --- a/src/lib/dcpomatic_time.h +++ b/src/lib/dcpomatic_time.h @@ -140,6 +140,11 @@ public: return floor (_t * r / HZ); } + template <typename T> + int64_t frames_ceil (T r) const { + return ceil (_t * r / HZ); + } + /** @param r Frames per second */ template <typename T> void split (T r, int& h, int& m, int& s, int& f) const diff --git a/src/lib/ffmpeg_decoder.cc b/src/lib/ffmpeg_decoder.cc index 7923be59b..c23d56b42 100644 --- a/src/lib/ffmpeg_decoder.cc +++ b/src/lib/ffmpeg_decoder.cc @@ -337,7 +337,7 @@ FFmpegDecoder::decode_audio_packet () if (ct < ContentTime ()) { /* Discard audio data that comes before time 0 */ - Frame const remove = min (int64_t (data->frames()), -ct.frames_round ((*stream)->frame_rate ())); + Frame const remove = min (int64_t (data->frames()), (-ct).frames_ceil(double((*stream)->frame_rate ()))); data->move (remove, 0, data->frames() - remove); data->set_frames (data->frames() - remove); ct += ContentTime::from_frames (remove, (*stream)->frame_rate ()); |
