Rationalise video/audio frame types.
authorCarl Hetherington <cth@carlh.net>
Thu, 2 Jan 2014 13:02:30 +0000 (13:02 +0000)
committerCarl Hetherington <cth@carlh.net>
Thu, 2 Jan 2014 13:02:30 +0000 (13:02 +0000)
25 files changed:
src/lib/analyse_audio_job.cc
src/lib/analyse_audio_job.h
src/lib/audio_content.cc
src/lib/audio_content.h
src/lib/ffmpeg_content.cc
src/lib/ffmpeg_content.h
src/lib/ffmpeg_examiner.cc
src/lib/ffmpeg_examiner.h
src/lib/film.cc
src/lib/film.h
src/lib/image_content.cc
src/lib/image_content.h
src/lib/image_examiner.h
src/lib/player.h
src/lib/sndfile_content.cc
src/lib/sndfile_content.h
src/lib/sndfile_decoder.cc
src/lib/sndfile_decoder.h
src/lib/transcode_job.cc
src/lib/types.h
src/lib/util.cc
src/lib/util.h
src/lib/video_content.cc
src/lib/video_content.h
src/lib/video_examiner.h

index 3f84bf16d7cc819240b8695a3628f962cd013ab0..872947b55d3d56cac4a957ca561bc5944a81d34c 100644 (file)
@@ -69,7 +69,7 @@ AnalyseAudioJob::run ()
        _analysis.reset (new AudioAnalysis (_film->audio_channels ()));
 
        _done = 0;
-       OutputAudioFrame const len = _film->time_to_audio_frames (_film->length ());
+       AudioFrame const len = _film->time_to_audio_frames (_film->length ());
        while (!player->pass ()) {
                set_progress (double (_done) / len);
        }
index 2e93ef500ffcd05542f558d74ae4587a53f0fc9d..6ed236d85ca57854a7a4f4691f4082bf4c1c059e 100644 (file)
@@ -36,7 +36,7 @@ private:
        void audio (boost::shared_ptr<const AudioBuffers>, DCPTime);
 
        boost::weak_ptr<AudioContent> _content;
-       OutputAudioFrame _done;
+       AudioFrame _done;
        int64_t _samples_per_point;
        std::vector<AudioPoint> _current;
 
index 83a43f3bd2eae6ee48a54594adf313403dca8df2..3c0d13ba93c1b98b5bbd1760f33ecc16c38786db 100644 (file)
@@ -157,7 +157,7 @@ AudioContent::technical_summary () const
  *  @param at The time within the DCP to get the active frame rate change from; i.e. a point at which
  *  the `controlling' video content is active.
  */
-AudioContent::Frame
+AudioFrame
 AudioContent::time_to_content_audio_frames (DCPTime t, DCPTime at) const
 {
        shared_ptr<const Film> film = _film.lock ();
index e1b38bd97003c8c19b456b082e763750dc17ae25..0b2ee2e461fe6b001d98509b6481efb61a214657 100644 (file)
@@ -52,7 +52,7 @@ public:
        std::string technical_summary () const;
 
        virtual int audio_channels () const = 0;
-       virtual AudioContent::Frame audio_length () const = 0;
+       virtual AudioFrame audio_length () const = 0;
        virtual int content_audio_frame_rate () const = 0;
        virtual int output_audio_frame_rate () const = 0;
        virtual AudioMapping audio_mapping () const = 0;
index 65a8d24f1ce3f073f697b4e364495246511d78e6..eb873fe653eefabfa9f869e62a79804bf4f6357e 100644 (file)
@@ -163,7 +163,7 @@ FFmpegContent::examine (shared_ptr<Job> job)
 
        shared_ptr<FFmpegExaminer> examiner (new FFmpegExaminer (shared_from_this ()));
 
-       VideoContent::Frame video_length = 0;
+       VideoFrame video_length = 0;
        video_length = examiner->video_length ();
        film->log()->log (String::compose ("Video length obtained from header as %1 frames", video_length));
 
@@ -262,12 +262,12 @@ FFmpegContent::set_audio_stream (shared_ptr<FFmpegAudioStream> s)
        signal_changed (FFmpegContentProperty::AUDIO_STREAM);
 }
 
-AudioContent::Frame
+AudioFrame
 FFmpegContent::audio_length () const
 {
        int const cafr = content_audio_frame_rate ();
        int const vfr  = video_frame_rate ();
-       VideoContent::Frame const vl = video_length ();
+       VideoFrame const vl = video_length ();
 
        boost::mutex::scoped_lock lm (_mutex);
        if (!_audio_stream) {
index ba73c0f9b23cdf00d0812417fd1e70a0f11ef2d8..d9037b0d8ca2f70ee38ee3edc56e9c703c4dd874 100644 (file)
@@ -140,7 +140,7 @@ public:
        
        /* AudioContent */
        int audio_channels () const;
-       AudioContent::Frame audio_length () const;
+       AudioFrame audio_length () const;
        int content_audio_frame_rate () const;
        int output_audio_frame_rate () const;
        AudioMapping audio_mapping () const;
index 78b6e3121c363faf1b0c95a4701970273b970636..e86a82fad72d5b98bac507a2111d3a2bf4e90a3a 100644 (file)
@@ -135,10 +135,10 @@ FFmpegExaminer::video_size () const
 }
 
 /** @return Length (in video frames) according to our content's header */
-VideoContent::Frame
+VideoFrame
 FFmpegExaminer::video_length () const
 {
-       VideoContent::Frame const length = (double (_format_context->duration) / AV_TIME_BASE) * video_frame_rate();
+       VideoFrame const length = (double (_format_context->duration) / AV_TIME_BASE) * video_frame_rate();
        return max (1, length);
 }
 
index 4de475d2a3f78d753985f6b165e56bf3b74c7290..2dd8b2e34baabc95594f4b21c79b92fae7eb679f 100644 (file)
@@ -31,7 +31,7 @@ public:
        
        float video_frame_rate () const;
        libdcp::Size video_size () const;
-       VideoContent::Frame video_length () const;
+       VideoFrame video_length () const;
 
        std::vector<boost::shared_ptr<FFmpegSubtitleStream> > subtitle_streams () const {
                return _subtitle_streams;
index 98b7bf6b90595589e48326b0157e40739ff92e17..932048d8b2997418bcb3b8902777c4631d8fdb60 100644 (file)
@@ -854,7 +854,7 @@ Film::has_subtitles () const
        return _playlist->has_subtitles ();
 }
 
-OutputVideoFrame
+VideoFrame
 Film::best_video_frame_rate () const
 {
        return _playlist->best_dcp_frame_rate ();
@@ -884,31 +884,31 @@ Film::playlist_changed ()
        signal_changed (CONTENT);
 }      
 
-OutputAudioFrame
+AudioFrame
 Film::time_to_audio_frames (DCPTime t) const
 {
        return t * audio_frame_rate () / TIME_HZ;
 }
 
-OutputVideoFrame
+VideoFrame
 Film::time_to_video_frames (DCPTime t) const
 {
        return t * video_frame_rate () / TIME_HZ;
 }
 
 DCPTime
-Film::audio_frames_to_time (OutputAudioFrame f) const
+Film::audio_frames_to_time (AudioFrame f) const
 {
        return f * TIME_HZ / audio_frame_rate ();
 }
 
 DCPTime
-Film::video_frames_to_time (OutputVideoFrame f) const
+Film::video_frames_to_time (VideoFrame f) const
 {
        return f * TIME_HZ / video_frame_rate ();
 }
 
-OutputAudioFrame
+AudioFrame
 Film::audio_frame_rate () const
 {
        /* XXX */
index f1564e83bece00051f16140df7f6c8bb435e6aa2..24ddad0bdc545ee8d55cae15ec9d390bbb8f03b7 100644 (file)
@@ -101,19 +101,19 @@ public:
        boost::shared_ptr<Player> make_player () const;
        boost::shared_ptr<Playlist> playlist () const;
 
-       OutputAudioFrame audio_frame_rate () const;
+       AudioFrame audio_frame_rate () const;
 
-       OutputAudioFrame time_to_audio_frames (DCPTime) const;
-       OutputVideoFrame time_to_video_frames (DCPTime) const;
-       DCPTime video_frames_to_time (OutputVideoFrame) const;
-       DCPTime audio_frames_to_time (OutputAudioFrame) const;
+       AudioFrame time_to_audio_frames (DCPTime) const;
+       VideoFrame time_to_video_frames (DCPTime) const;
+       DCPTime video_frames_to_time (VideoFrame) const;
+       DCPTime audio_frames_to_time (AudioFrame) const;
 
        /* Proxies for some Playlist methods */
 
        ContentList content () const;
        DCPTime length () const;
        bool has_subtitles () const;
-       OutputVideoFrame best_video_frame_rate () const;
+       VideoFrame best_video_frame_rate () const;
        FrameRateChange active_frame_rate_change (DCPTime) const;
 
        libdcp::KDM
index 0f952607159f99e4da16b6990f7efac0a32a541b..87276ce4dc92d6c5538139d8fb88988f1c22f8ea 100644 (file)
@@ -110,7 +110,7 @@ ImageContent::examine (shared_ptr<Job> job)
 }
 
 void
-ImageContent::set_video_length (VideoContent::Frame len)
+ImageContent::set_video_length (VideoFrame len)
 {
        {
                boost::mutex::scoped_lock lm (_mutex);
index 88c178faad35578cc5e7143f334c9feb1d22dbef..ef2bc0447c9262e13357154f5f3c313996bccfb3 100644 (file)
@@ -45,7 +45,7 @@ public:
 
        std::string identifier () const;
        
-       void set_video_length (VideoContent::Frame);
+       void set_video_length (VideoFrame);
        bool still () const;
 };
 
index 8887f0d3d15a2587f56faff713a62835b3af8a7b..f5d5150749971c6f874880802e1da1ff09b96555 100644 (file)
@@ -32,7 +32,7 @@ public:
 
        float video_frame_rate () const;
        libdcp::Size video_size () const;
-       VideoContent::Frame video_length () const {
+       VideoFrame video_length () const {
                return _video_length;
        }
 
@@ -40,5 +40,5 @@ private:
        boost::weak_ptr<const Film> _film;
        boost::shared_ptr<const ImageContent> _image_content;
        boost::optional<libdcp::Size> _video_size;
-       VideoContent::Frame _video_length;
+       VideoFrame _video_length;
 };
index 897c6116b5acbf7c3351e4b774b214b01ad8c7f5..5f7c553a0f9f0bd44b2c6b49c628c59520d9381c 100644 (file)
@@ -149,7 +149,7 @@ private:
        void do_seek (DCPTime, bool);
        void flush ();
        void emit_black ();
-       void emit_silence (OutputAudioFrame);
+       void emit_silence (AudioFrame);
        void film_changed (Film::Property);
        void update_subtitle ();
        void emit_video (boost::weak_ptr<Piece>, boost::shared_ptr<DecodedVideo>);
@@ -171,7 +171,7 @@ private:
        /** The time after the last audio that we emitted */
        DCPTime _audio_position;
 
-       AudioMerger<DCPTime, AudioContent::Frame> _audio_merger;
+       AudioMerger<DCPTime, AudioFrame> _audio_merger;
 
        libdcp::Size _video_container_size;
        boost::shared_ptr<PlayerImage> _black_frame;
index 1c872cf96ef165d6685c8fe01caadbce36ba2509..48bdb56ec9a149dbaaccbaf1fbcdec37e8193bf7 100644 (file)
@@ -49,7 +49,7 @@ SndfileContent::SndfileContent (shared_ptr<const Film> f, shared_ptr<const cxml:
        , _audio_mapping (node->node_child ("AudioMapping"))
 {
        _audio_channels = node->number_child<int> ("AudioChannels");
-       _audio_length = node->number_child<AudioContent::Frame> ("AudioLength");
+       _audio_length = node->number_child<AudioFrame> ("AudioLength");
        _audio_frame_rate = node->number_child<int> ("AudioFrameRate");
 }
 
@@ -147,7 +147,7 @@ SndfileContent::full_length () const
        shared_ptr<const Film> film = _film.lock ();
        assert (film);
 
-       OutputAudioFrame const len = audio_length() * output_audio_frame_rate() / content_audio_frame_rate ();
+       AudioFrame const len = audio_length() * output_audio_frame_rate() / content_audio_frame_rate ();
        
        /* XXX: this depends on whether, alongside this audio, we are running video slower or faster than
           it should be.  The calculation above works out the output audio frames assuming that we are just
index c88764c1b22808e953d696d55f3cc50d2ce017de..94f46fea34f5650f4fd9f8832ac76027505ae5d7 100644 (file)
@@ -52,7 +52,7 @@ public:
                return _audio_channels;
        }
        
-       AudioContent::Frame audio_length () const {
+       AudioFrame audio_length () const {
                boost::mutex::scoped_lock lm (_mutex);
                return _audio_length;
        }
@@ -75,7 +75,7 @@ public:
 
 private:
        int _audio_channels;
-       AudioContent::Frame _audio_length;
+       AudioFrame _audio_length;
        int _audio_frame_rate;
        AudioMapping _audio_mapping;
 };
index 5bbd90633c38bd7ff9b8f5694b0d7cb0c302c775..5e3f3313b50451939dac51171844c77aa1af6cd0 100644 (file)
@@ -107,7 +107,7 @@ SndfileDecoder::audio_channels () const
        return _info.channels;
 }
 
-AudioContent::Frame
+AudioFrame
 SndfileDecoder::audio_length () const
 {
        return _info.frames;
index 63f2f7dc49f7553b9c265732dc683f79c58c718d..9cbddc9f683f63e7d7d9ea9f75cba664c3ad3831 100644 (file)
@@ -32,7 +32,7 @@ public:
        void seek (ContentTime, bool);
 
        int audio_channels () const;
-       AudioContent::Frame audio_length () const;
+       AudioFrame audio_length () const;
        int audio_frame_rate () const;
 
 private:
@@ -44,7 +44,7 @@ private:
        boost::shared_ptr<const SndfileContent> _sndfile_content;
        SNDFILE* _sndfile;
        SF_INFO _info;
-       AudioContent::Frame _done;
-       AudioContent::Frame _remaining;
+       AudioFrame _done;
+       AudioFrame _remaining;
        float* _deinterleave_buffer;
 };
index fd69b08e7c58b5a353570433d5f53c937585ed48..fe07ba2f656af010c1ff989a53a4f1e088822ed6 100644 (file)
@@ -111,6 +111,6 @@ TranscodeJob::remaining_time () const
        }
 
        /* Compute approximate proposed length here, as it's only here that we need it */
-       OutputVideoFrame const left = _film->time_to_video_frames (_film->length ()) - _transcoder->video_frames_out();
+       VideoFrame const left = _film->time_to_video_frames (_film->length ()) - _transcoder->video_frames_out();
        return left / fps;
 }
index 33c0c171feecb6758d5976203ddea1020feeac99..924279c25eafb1885ad1e9fe504287565f1ebb67 100644 (file)
@@ -42,8 +42,8 @@ typedef int64_t DCPTime;
 #define TIME_MAX INT64_MAX
 #define TIME_HZ         ((DCPTime) 96000)
 typedef int64_t ContentTime;
-typedef int64_t OutputAudioFrame;
-typedef int    OutputVideoFrame;
+typedef int64_t AudioFrame;
+typedef int    VideoFrame;
 typedef std::vector<boost::shared_ptr<Content> > ContentList;
 typedef std::vector<boost::shared_ptr<VideoContent> > VideoContentList;
 typedef std::vector<boost::shared_ptr<AudioContent> > AudioContentList;
index 381c47a9ae606253a7207a492351965987638c58..e4fc24564edc9f9ad1a9ac717c12f81979a90d11 100644 (file)
@@ -747,7 +747,7 @@ ensure_ui_thread ()
  *  @return Equivalent number of audio frames for `v'.
  */
 int64_t
-video_frames_to_audio_frames (VideoContent::Frame v, float audio_sample_rate, float frames_per_second)
+video_frames_to_audio_frames (VideoFrame v, float audio_sample_rate, float frames_per_second)
 {
        return ((int64_t) v * audio_sample_rate / frames_per_second);
 }
index 892b473f739a21de88827d8aecd94682b3f2fe24..a84e7e4cf815522ae65ffa6cf52bebbf46849210 100644 (file)
@@ -166,7 +166,7 @@ private:
        int _timeout;
 };
 
-extern int64_t video_frames_to_audio_frames (VideoContent::Frame v, float audio_sample_rate, float frames_per_second);
+extern int64_t video_frames_to_audio_frames (VideoFrame v, float audio_sample_rate, float frames_per_second);
 
 class LocaleGuard
 {
index 404549532806fc947ecc7440d6acb85aef521bc0..bf13e1c764f61df1c8c578474c47e5bce5788276 100644 (file)
@@ -59,7 +59,7 @@ VideoContent::VideoContent (shared_ptr<const Film> f)
        setup_default_colour_conversion ();
 }
 
-VideoContent::VideoContent (shared_ptr<const Film> f, DCPTime s, VideoContent::Frame len)
+VideoContent::VideoContent (shared_ptr<const Film> f, DCPTime s, VideoFrame len)
        : Content (f, s)
        , _video_length (len)
        , _video_frame_rate (0)
@@ -83,7 +83,7 @@ VideoContent::VideoContent (shared_ptr<const Film> f, shared_ptr<const cxml::Nod
        : Content (f, node)
        , _ratio (0)
 {
-       _video_length = node->number_child<VideoContent::Frame> ("VideoLength");
+       _video_length = node->number_child<VideoFrame> ("VideoLength");
        _video_size.width = node->number_child<int> ("VideoWidth");
        _video_size.height = node->number_child<int> ("VideoHeight");
        _video_frame_rate = node->number_child<float> ("VideoFrameRate");
@@ -356,7 +356,7 @@ VideoContent::video_size_after_crop () const
  *  @return Corresponding frame index, rounded up so that the frame index
  *  is that of the next complete frame which starts after `t'.
  */
-VideoContent::Frame
+VideoFrame
 VideoContent::time_to_content_video_frames (DCPTime t) const
 {
        shared_ptr<const Film> film = _film.lock ();
index f008143fa2a7460aa6b37abc09e1b7fd9269b1e6..d03aa9ce4ae326248e24f4abb57fa6acebcec5c1 100644 (file)
@@ -43,7 +43,7 @@ public:
        typedef int Frame;
 
        VideoContent (boost::shared_ptr<const Film>);
-       VideoContent (boost::shared_ptr<const Film>, DCPTime, VideoContent::Frame);
+       VideoContent (boost::shared_ptr<const Film>, DCPTime, VideoFrame);
        VideoContent (boost::shared_ptr<const Film>, boost::filesystem::path);
        VideoContent (boost::shared_ptr<const Film>, boost::shared_ptr<const cxml::Node>);
        VideoContent (boost::shared_ptr<const Film>, std::vector<boost::shared_ptr<Content> >);
@@ -53,7 +53,7 @@ public:
        virtual std::string information () const;
        virtual std::string identifier () const;
 
-       VideoContent::Frame video_length () const {
+       VideoFrame video_length () const {
                boost::mutex::scoped_lock lm (_mutex);
                return _video_length;
        }
@@ -123,12 +123,12 @@ public:
        libdcp::Size video_size_after_3d_split () const;
        libdcp::Size video_size_after_crop () const;
 
-       VideoContent::Frame time_to_content_video_frames (DCPTime) const;
+       VideoFrame time_to_content_video_frames (DCPTime) const;
 
 protected:
        void take_from_video_examiner (boost::shared_ptr<VideoExaminer>);
 
-       VideoContent::Frame _video_length;
+       VideoFrame _video_length;
 
 private:
        friend class ffmpeg_pts_offset_test;
index 039c494b52fe98f630798729207b65b26b4d46f3..98c0cdff1433d21e0ad0106c994bf06762f6ffd8 100644 (file)
@@ -27,5 +27,5 @@ public:
        virtual ~VideoExaminer () {}
        virtual float video_frame_rate () const = 0;
        virtual libdcp::Size video_size () const = 0;
-       virtual VideoContent::Frame video_length () const = 0;
+       virtual VideoFrame video_length () const = 0;
 };