Various fixes to make audio analysis sort-of work.
[dcpomatic.git] / src / lib / ffmpeg_decoder.cc
index 2f890c0cd669067204bede8da26160f43e150ac4..2e586b8f7fcdfc486abec542c052297ac1bb8bea 100644 (file)
@@ -1,5 +1,3 @@
-/* -*- c-basic-offset: 8; default-tab-width: 8; -*- */
-
 /*
     Copyright (C) 2012 Carl Hetherington <cth@carlh.net>
 
@@ -63,7 +61,7 @@ using libdcp::Size;
 
 boost::mutex FFmpegDecoder::_mutex;
 
-FFmpegDecoder::FFmpegDecoder (shared_ptr<const Film> f, shared_ptr<const FFmpegContent> c, bool video, bool audio, bool subtitles)
+FFmpegDecoder::FFmpegDecoder (shared_ptr<const Film> f, shared_ptr<const FFmpegContent> c, bool video, bool audio)
        : Decoder (f)
        , VideoDecoder (f, c)
        , AudioDecoder (f, c)
@@ -79,7 +77,6 @@ FFmpegDecoder::FFmpegDecoder (shared_ptr<const Film> f, shared_ptr<const FFmpegC
        , _subtitle_codec (0)
        , _decode_video (video)
        , _decode_audio (audio)
-       , _decode_subtitles (subtitles)
 {
        setup_general ();
        setup_video ();
@@ -259,7 +256,7 @@ FFmpegDecoder::pass ()
                decode_video_packet ();
        } else if (_ffmpeg_content->audio_stream() && _packet.stream_index == _ffmpeg_content->audio_stream()->id && _decode_audio) {
                decode_audio_packet ();
-       } else if (_ffmpeg_content->subtitle_stream() && _packet.stream_index == _ffmpeg_content->subtitle_stream()->id && _decode_subtitles) {
+       } else if (_ffmpeg_content->subtitle_stream() && _packet.stream_index == _ffmpeg_content->subtitle_stream()->id) {
 
                int got_subtitle;
                AVSubtitle sub;
@@ -279,8 +276,6 @@ FFmpegDecoder::pass ()
                        }
                        avsubtitle_free (&sub);
                }
-       } else {
-               cout << "[ffmpeg] other packet.\n";
        }
 
        av_free_packet (&_packet);
@@ -453,22 +448,22 @@ FFmpegDecoder::seek (Time t)
 void
 FFmpegDecoder::seek_back ()
 {
-       if (next() < (2.5 * TIME_HZ / video_frame_rate())) {
+       if (position() < (2.5 * TIME_HZ / video_frame_rate())) {
                return;
        }
        
-       do_seek (next() - 2.5 * TIME_HZ / video_frame_rate(), true, true);
+       do_seek (position() - 2.5 * TIME_HZ / video_frame_rate(), true, true);
        VideoDecoder::seek_back ();
 }
 
 void
 FFmpegDecoder::seek_forward ()
 {
-       if (next() >= (_ffmpeg_content->length() - 0.5 * TIME_HZ / video_frame_rate())) {
+       if (position() >= (_ffmpeg_content->length() - 0.5 * TIME_HZ / video_frame_rate())) {
                return;
        }
        
-       do_seek (next() - 0.5 * TIME_HZ / video_frame_rate(), true, true);
+       do_seek (position() - 0.5 * TIME_HZ / video_frame_rate(), true, true);
        VideoDecoder::seek_forward ();
 }
 
@@ -542,7 +537,7 @@ FFmpegDecoder::decode_audio_packet ()
                                        );
                                
                                assert (_audio_codec_context->channels == _ffmpeg_content->audio_channels());
-                               audio (deinterleave_audio (_frame->data, data_size), source_pts_seconds);
+                               audio (deinterleave_audio (_frame->data, data_size), source_pts_seconds * TIME_HZ);
                        }
                        
                        copy_packet.data += decode_result;
@@ -609,7 +604,7 @@ FFmpegDecoder::decode_video_packet ()
 }
 
 Time
-FFmpegDecoder::next () const
+FFmpegDecoder::position () const
 {
        if (_decode_video && _decode_audio && _audio_codec_context) {
                return min (_next_video, _next_audio);