Merge remote-tracking branch 'origin/main' into v2.17.x
[dcpomatic.git] / src / lib / ffmpeg_decoder.cc
index 6130d8e5fb5c59be98c6aec9c6ed7b78e23eeac1..17973d0004126cf1d9564c4c1318ced61c6a6263 100644 (file)
@@ -178,9 +178,8 @@ FFmpegDecoder::flush_fill()
        full_length = full_length.ceil (frc.source);
        if (video && !video->ignore()) {
                double const vfr = _ffmpeg_content->video_frame_rate().get();
-               auto const f = full_length.frames_round (vfr);
-               auto const v = video->position(film()).get_value_or(ContentTime()).frames_round(vfr) + 1;
-               if (v < f) {
+               auto const v = video->position(film()).get_value_or(ContentTime()) + ContentTime::from_frames(1, vfr);
+               if (v < full_length) {
                        video->emit(film(), make_shared<const RawImageProxy>(_black_image), v);
                        did_something = true;
                }
@@ -260,7 +259,7 @@ deinterleave_audio(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);
@@ -622,7 +621,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");