Tidy up test film naming.
[dcpomatic.git] / src / lib / decoder.cc
index 65e5ff7225ccb1e913ed54c6d2366183121d600a..045c1b818270052d58a93249377a7e2a6f5c6e27 100644 (file)
@@ -112,7 +112,7 @@ Decoder::process_end ()
           in to get it to the right length.
        */
 
-       int64_t const video_length_in_audio_frames = ((int64_t) _fs->dcp_length() * _fs->target_sample_rate() / _fs->frames_per_second());
+       int64_t const video_length_in_audio_frames = ((int64_t) _fs->dcp_length() * _fs->audio_sample_rate() / _fs->frames_per_second());
        int64_t const audio_short_by_frames = video_length_in_audio_frames - _audio_frames_processed;
 
        _log->log (
@@ -266,7 +266,7 @@ Decoder::emit_audio (uint8_t* data, int size)
        }
 
        /* Update the number of audio frames we've pushed to the encoder */
-       _audio_frames_processed += frames;
+       _audio_frames_processed += audio->frames ();
 
        Audio (audio);
 }
@@ -352,7 +352,7 @@ Decoder::process_video (AVFrame* frame)
                        }
 
                        shared_ptr<Subtitle> sub;
-                       if (_timed_subtitle && _timed_subtitle->displayed_at (double (last_video_frame()) / rint (_fs->frames_per_second()))) {
+                       if (_timed_subtitle && _timed_subtitle->displayed_at (double (last_video_frame()) / _fs->frames_per_second())) {
                                sub = _timed_subtitle->subtitle ();
                        }
 
@@ -463,7 +463,7 @@ Decoder::process_subtitle (shared_ptr<TimedSubtitle> s)
 {
        _timed_subtitle = s;
        
-       if (_opt->apply_crop) {
+       if (_timed_subtitle && _opt->apply_crop) {
                Position const p = _timed_subtitle->subtitle()->position ();
                _timed_subtitle->subtitle()->set_position (Position (p.x - _fs->crop().left, p.y - _fs->crop().top));
        }