From 3dfdd5795cf6514e15fdbece54c28f3bddc2aadc Mon Sep 17 00:00:00 2001 From: Carl Hetherington Date: Thu, 2 Jan 2014 13:02:30 +0000 Subject: [PATCH] Rationalise video/audio frame types. --- src/lib/analyse_audio_job.cc | 2 +- src/lib/analyse_audio_job.h | 2 +- src/lib/audio_content.cc | 2 +- src/lib/audio_content.h | 2 +- src/lib/ffmpeg_content.cc | 6 +++--- src/lib/ffmpeg_content.h | 2 +- src/lib/ffmpeg_examiner.cc | 4 ++-- src/lib/ffmpeg_examiner.h | 2 +- src/lib/film.cc | 12 ++++++------ src/lib/film.h | 12 ++++++------ src/lib/image_content.cc | 2 +- src/lib/image_content.h | 2 +- src/lib/image_examiner.h | 4 ++-- src/lib/player.h | 4 ++-- src/lib/sndfile_content.cc | 4 ++-- src/lib/sndfile_content.h | 4 ++-- src/lib/sndfile_decoder.cc | 2 +- src/lib/sndfile_decoder.h | 6 +++--- src/lib/transcode_job.cc | 2 +- src/lib/types.h | 4 ++-- src/lib/util.cc | 2 +- src/lib/util.h | 2 +- src/lib/video_content.cc | 6 +++--- src/lib/video_content.h | 8 ++++---- src/lib/video_examiner.h | 2 +- 25 files changed, 50 insertions(+), 50 deletions(-) diff --git a/src/lib/analyse_audio_job.cc b/src/lib/analyse_audio_job.cc index 3f84bf16d..872947b55 100644 --- a/src/lib/analyse_audio_job.cc +++ b/src/lib/analyse_audio_job.cc @@ -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); } diff --git a/src/lib/analyse_audio_job.h b/src/lib/analyse_audio_job.h index 2e93ef500..6ed236d85 100644 --- a/src/lib/analyse_audio_job.h +++ b/src/lib/analyse_audio_job.h @@ -36,7 +36,7 @@ private: void audio (boost::shared_ptr, DCPTime); boost::weak_ptr _content; - OutputAudioFrame _done; + AudioFrame _done; int64_t _samples_per_point; std::vector _current; diff --git a/src/lib/audio_content.cc b/src/lib/audio_content.cc index 83a43f3bd..3c0d13ba9 100644 --- a/src/lib/audio_content.cc +++ b/src/lib/audio_content.cc @@ -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 film = _film.lock (); diff --git a/src/lib/audio_content.h b/src/lib/audio_content.h index e1b38bd97..0b2ee2e46 100644 --- a/src/lib/audio_content.h +++ b/src/lib/audio_content.h @@ -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; diff --git a/src/lib/ffmpeg_content.cc b/src/lib/ffmpeg_content.cc index 65a8d24f1..eb873fe65 100644 --- a/src/lib/ffmpeg_content.cc +++ b/src/lib/ffmpeg_content.cc @@ -163,7 +163,7 @@ FFmpegContent::examine (shared_ptr job) shared_ptr 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 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) { diff --git a/src/lib/ffmpeg_content.h b/src/lib/ffmpeg_content.h index ba73c0f9b..d9037b0d8 100644 --- a/src/lib/ffmpeg_content.h +++ b/src/lib/ffmpeg_content.h @@ -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; diff --git a/src/lib/ffmpeg_examiner.cc b/src/lib/ffmpeg_examiner.cc index 78b6e3121..e86a82fad 100644 --- a/src/lib/ffmpeg_examiner.cc +++ b/src/lib/ffmpeg_examiner.cc @@ -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); } diff --git a/src/lib/ffmpeg_examiner.h b/src/lib/ffmpeg_examiner.h index 4de475d2a..2dd8b2e34 100644 --- a/src/lib/ffmpeg_examiner.h +++ b/src/lib/ffmpeg_examiner.h @@ -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 > subtitle_streams () const { return _subtitle_streams; diff --git a/src/lib/film.cc b/src/lib/film.cc index 98b7bf6b9..932048d8b 100644 --- a/src/lib/film.cc +++ b/src/lib/film.cc @@ -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 */ diff --git a/src/lib/film.h b/src/lib/film.h index f1564e83b..24ddad0bd 100644 --- a/src/lib/film.h +++ b/src/lib/film.h @@ -101,19 +101,19 @@ public: boost::shared_ptr make_player () const; boost::shared_ptr 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 diff --git a/src/lib/image_content.cc b/src/lib/image_content.cc index 0f9526071..87276ce4d 100644 --- a/src/lib/image_content.cc +++ b/src/lib/image_content.cc @@ -110,7 +110,7 @@ ImageContent::examine (shared_ptr job) } void -ImageContent::set_video_length (VideoContent::Frame len) +ImageContent::set_video_length (VideoFrame len) { { boost::mutex::scoped_lock lm (_mutex); diff --git a/src/lib/image_content.h b/src/lib/image_content.h index 88c178faa..ef2bc0447 100644 --- a/src/lib/image_content.h +++ b/src/lib/image_content.h @@ -45,7 +45,7 @@ public: std::string identifier () const; - void set_video_length (VideoContent::Frame); + void set_video_length (VideoFrame); bool still () const; }; diff --git a/src/lib/image_examiner.h b/src/lib/image_examiner.h index 8887f0d3d..f5d515074 100644 --- a/src/lib/image_examiner.h +++ b/src/lib/image_examiner.h @@ -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 _film; boost::shared_ptr _image_content; boost::optional _video_size; - VideoContent::Frame _video_length; + VideoFrame _video_length; }; diff --git a/src/lib/player.h b/src/lib/player.h index 897c6116b..5f7c553a0 100644 --- a/src/lib/player.h +++ b/src/lib/player.h @@ -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, boost::shared_ptr); @@ -171,7 +171,7 @@ private: /** The time after the last audio that we emitted */ DCPTime _audio_position; - AudioMerger _audio_merger; + AudioMerger _audio_merger; libdcp::Size _video_container_size; boost::shared_ptr _black_frame; diff --git a/src/lib/sndfile_content.cc b/src/lib/sndfile_content.cc index 1c872cf96..48bdb56ec 100644 --- a/src/lib/sndfile_content.cc +++ b/src/lib/sndfile_content.cc @@ -49,7 +49,7 @@ SndfileContent::SndfileContent (shared_ptr f, shared_ptrnode_child ("AudioMapping")) { _audio_channels = node->number_child ("AudioChannels"); - _audio_length = node->number_child ("AudioLength"); + _audio_length = node->number_child ("AudioLength"); _audio_frame_rate = node->number_child ("AudioFrameRate"); } @@ -147,7 +147,7 @@ SndfileContent::full_length () const shared_ptr 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 diff --git a/src/lib/sndfile_content.h b/src/lib/sndfile_content.h index c88764c1b..94f46fea3 100644 --- a/src/lib/sndfile_content.h +++ b/src/lib/sndfile_content.h @@ -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; }; diff --git a/src/lib/sndfile_decoder.cc b/src/lib/sndfile_decoder.cc index 5bbd90633..5e3f3313b 100644 --- a/src/lib/sndfile_decoder.cc +++ b/src/lib/sndfile_decoder.cc @@ -107,7 +107,7 @@ SndfileDecoder::audio_channels () const return _info.channels; } -AudioContent::Frame +AudioFrame SndfileDecoder::audio_length () const { return _info.frames; diff --git a/src/lib/sndfile_decoder.h b/src/lib/sndfile_decoder.h index 63f2f7dc4..9cbddc9f6 100644 --- a/src/lib/sndfile_decoder.h +++ b/src/lib/sndfile_decoder.h @@ -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 _sndfile_content; SNDFILE* _sndfile; SF_INFO _info; - AudioContent::Frame _done; - AudioContent::Frame _remaining; + AudioFrame _done; + AudioFrame _remaining; float* _deinterleave_buffer; }; diff --git a/src/lib/transcode_job.cc b/src/lib/transcode_job.cc index fd69b08e7..fe07ba2f6 100644 --- a/src/lib/transcode_job.cc +++ b/src/lib/transcode_job.cc @@ -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; } diff --git a/src/lib/types.h b/src/lib/types.h index 33c0c171f..924279c25 100644 --- a/src/lib/types.h +++ b/src/lib/types.h @@ -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 > ContentList; typedef std::vector > VideoContentList; typedef std::vector > AudioContentList; diff --git a/src/lib/util.cc b/src/lib/util.cc index 381c47a9a..e4fc24564 100644 --- a/src/lib/util.cc +++ b/src/lib/util.cc @@ -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); } diff --git a/src/lib/util.h b/src/lib/util.h index 892b473f7..a84e7e4cf 100644 --- a/src/lib/util.h +++ b/src/lib/util.h @@ -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 { diff --git a/src/lib/video_content.cc b/src/lib/video_content.cc index 404549532..bf13e1c76 100644 --- a/src/lib/video_content.cc +++ b/src/lib/video_content.cc @@ -59,7 +59,7 @@ VideoContent::VideoContent (shared_ptr f) setup_default_colour_conversion (); } -VideoContent::VideoContent (shared_ptr f, DCPTime s, VideoContent::Frame len) +VideoContent::VideoContent (shared_ptr f, DCPTime s, VideoFrame len) : Content (f, s) , _video_length (len) , _video_frame_rate (0) @@ -83,7 +83,7 @@ VideoContent::VideoContent (shared_ptr f, shared_ptrnumber_child ("VideoLength"); + _video_length = node->number_child ("VideoLength"); _video_size.width = node->number_child ("VideoWidth"); _video_size.height = node->number_child ("VideoHeight"); _video_frame_rate = node->number_child ("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 film = _film.lock (); diff --git a/src/lib/video_content.h b/src/lib/video_content.h index f008143fa..d03aa9ce4 100644 --- a/src/lib/video_content.h +++ b/src/lib/video_content.h @@ -43,7 +43,7 @@ public: typedef int Frame; VideoContent (boost::shared_ptr); - VideoContent (boost::shared_ptr, DCPTime, VideoContent::Frame); + VideoContent (boost::shared_ptr, DCPTime, VideoFrame); VideoContent (boost::shared_ptr, boost::filesystem::path); VideoContent (boost::shared_ptr, boost::shared_ptr); VideoContent (boost::shared_ptr, std::vector >); @@ -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); - VideoContent::Frame _video_length; + VideoFrame _video_length; private: friend class ffmpeg_pts_offset_test; diff --git a/src/lib/video_examiner.h b/src/lib/video_examiner.h index 039c494b5..98c0cdff1 100644 --- a/src/lib/video_examiner.h +++ b/src/lib/video_examiner.h @@ -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; }; -- 2.30.2