Change how video timing is done.
[dcpomatic.git] / src / lib / ffmpeg_decoder.cc
index 27b7aa7b7514e4cdcc20d9c2c79c0dd87cf873a5..6a1e0b64298a184d74363bac461abc0c059448c7 100644 (file)
@@ -144,11 +144,10 @@ FFmpegDecoder::flush ()
        full_length = full_length.ceil (frc.source);
        if (video) {
                double const vfr = _ffmpeg_content->video_frame_rate().get();
-               auto const f = full_length.frames_round (vfr);
-               auto v = video->position(film()).get_value_or(ContentTime()).frames_round(vfr) + 1;
-               while (v < f) {
-                       video->emit (film(), make_shared<const RawImageProxy>(_black_image), v);
-                       ++v;
+               auto v = video->position(film()).get_value_or(ContentTime()) + ContentTime::from_frames(1, vfr);
+               while (v < full_length) {
+                       video->emit(film(), make_shared<const RawImageProxy>(_black_image), v);
+                       v += ContentTime::from_frames(1, vfr);
                }
        }
 
@@ -228,7 +227,7 @@ deinterleave_audio(shared_ptr<FFmpegAudioStream> stream, AVFrame* frame)
 
        /* XXX: can't we use swr_convert() to do the format conversion? */
 
-       int const channels = frame->channels;
+       int const channels = frame->ch_layout.nb_channels;
        int const frames = frame->nb_samples;
        int const total_samples = frames * channels;
        auto audio = make_shared<AudioBuffers>(channels, frames);
@@ -591,7 +590,7 @@ FFmpegDecoder::process_video_frame ()
                        video->emit (
                                film(),
                                make_shared<RawImageProxy>(image),
-                               llrint(pts * _ffmpeg_content->active_video_frame_rate(film()))
+                               ContentTime::from_seconds(pts)
                                );
                } else {
                        LOG_WARNING_NC ("Dropping frame without PTS");