summaryrefslogtreecommitdiff
path: root/src/lib
diff options
context:
space:
mode:
Diffstat (limited to 'src/lib')
-rw-r--r--src/lib/dcpomatic_time.h5
-rw-r--r--src/lib/ffmpeg_decoder.cc2
2 files changed, 6 insertions, 1 deletions
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 ());