diff options
| author | Carl Hetherington <cth@carlh.net> | 2018-11-21 12:15:26 +0000 |
|---|---|---|
| committer | Carl Hetherington <cth@carlh.net> | 2018-11-21 12:15:26 +0000 |
| commit | f67bc45820b4e56f90eecb97ba3b7762c119f9b5 (patch) | |
| tree | 58b009c238bc4dad8606e70ba617bcb7a49fb89c /src/lib | |
| parent | 84012cdd64f451891febd36154b7226ea21a899b (diff) | |
Add and use new FrameRateChange constructors.
Diffstat (limited to 'src/lib')
| -rw-r--r-- | src/lib/atmos_mxf_content.cc | 2 | ||||
| -rw-r--r-- | src/lib/atmos_mxf_content.h | 4 | ||||
| -rw-r--r-- | src/lib/audio_content.cc | 2 | ||||
| -rw-r--r-- | src/lib/dcp_content.cc | 2 | ||||
| -rw-r--r-- | src/lib/dcp_subtitle_content.cc | 2 | ||||
| -rw-r--r-- | src/lib/ffmpeg_content.cc | 2 | ||||
| -rw-r--r-- | src/lib/ffmpeg_content.h | 4 | ||||
| -rw-r--r-- | src/lib/frame_rate_change.cc | 27 | ||||
| -rw-r--r-- | src/lib/frame_rate_change.h | 12 | ||||
| -rw-r--r-- | src/lib/image_content.cc | 2 | ||||
| -rw-r--r-- | src/lib/image_content.h | 4 | ||||
| -rw-r--r-- | src/lib/player.cc | 4 | ||||
| -rw-r--r-- | src/lib/string_text_file_content.cc | 2 | ||||
| -rw-r--r-- | src/lib/string_text_file_content.h | 4 | ||||
| -rw-r--r-- | src/lib/video_mxf_content.cc | 2 | ||||
| -rw-r--r-- | src/lib/video_mxf_content.h | 4 |
16 files changed, 64 insertions, 15 deletions
diff --git a/src/lib/atmos_mxf_content.cc b/src/lib/atmos_mxf_content.cc index 8300c2cd6..4835442d5 100644 --- a/src/lib/atmos_mxf_content.cc +++ b/src/lib/atmos_mxf_content.cc @@ -93,6 +93,6 @@ AtmosMXFContent::as_xml (xmlpp::Node* node, bool with_paths) const DCPTime AtmosMXFContent::full_length (shared_ptr<const Film> film) const { - FrameRateChange const frc (active_video_frame_rate(film), film->video_frame_rate()); + FrameRateChange const frc (film, shared_from_this()); return DCPTime::from_frames (llrint (_length * frc.factor()), film->video_frame_rate()); } diff --git a/src/lib/atmos_mxf_content.h b/src/lib/atmos_mxf_content.h index 156ebc788..854824c67 100644 --- a/src/lib/atmos_mxf_content.h +++ b/src/lib/atmos_mxf_content.h @@ -30,6 +30,10 @@ public: return boost::dynamic_pointer_cast<AtmosMXFContent> (Content::shared_from_this ()); } + boost::shared_ptr<const AtmosMXFContent> shared_from_this () const { + return boost::dynamic_pointer_cast<const AtmosMXFContent> (Content::shared_from_this ()); + } + void examine (boost::shared_ptr<const Film> film, boost::shared_ptr<Job> job); std::string summary () const; void as_xml (xmlpp::Node* node, bool with_path) const; diff --git a/src/lib/audio_content.cc b/src/lib/audio_content.cc index f33720119..b513fb443 100644 --- a/src/lib/audio_content.cc +++ b/src/lib/audio_content.cc @@ -199,7 +199,7 @@ AudioContent::resampled_frame_rate (shared_ptr<const Film> film) const /* Resample to a DCI-approved sample rate */ double t = has_rate_above_48k() ? 96000 : 48000; - FrameRateChange frc (_parent->active_video_frame_rate(film), film->video_frame_rate()); + FrameRateChange frc (film, _parent); /* Compensate if the DCP is being run at a different frame rate to the source; that is, if the video is run such that it will diff --git a/src/lib/dcp_content.cc b/src/lib/dcp_content.cc index 62284e433..3110f93ad 100644 --- a/src/lib/dcp_content.cc +++ b/src/lib/dcp_content.cc @@ -342,7 +342,7 @@ DCPContent::full_length (shared_ptr<const Film> film) const if (!video) { return DCPTime(); } - FrameRateChange const frc (active_video_frame_rate(film), film->video_frame_rate()); + FrameRateChange const frc (film, shared_from_this()); return DCPTime::from_frames (llrint(video->length() * frc.factor()), film->video_frame_rate()); } diff --git a/src/lib/dcp_subtitle_content.cc b/src/lib/dcp_subtitle_content.cc index 21a50c199..d25e06188 100644 --- a/src/lib/dcp_subtitle_content.cc +++ b/src/lib/dcp_subtitle_content.cc @@ -84,7 +84,7 @@ DCPSubtitleContent::examine (shared_ptr<const Film> film, shared_ptr<Job> job) DCPTime DCPSubtitleContent::full_length (shared_ptr<const Film> film) const { - FrameRateChange const frc (active_video_frame_rate(film), film->video_frame_rate()); + FrameRateChange const frc (film, shared_from_this()); return DCPTime (_length, frc); } diff --git a/src/lib/ffmpeg_content.cc b/src/lib/ffmpeg_content.cc index 2b494dc92..fcadc9116 100644 --- a/src/lib/ffmpeg_content.cc +++ b/src/lib/ffmpeg_content.cc @@ -402,7 +402,7 @@ operator!= (FFmpegStream const & a, FFmpegStream const & b) DCPTime FFmpegContent::full_length (shared_ptr<const Film> film) const { - FrameRateChange const frc (active_video_frame_rate(film), film->video_frame_rate()); + FrameRateChange const frc (film, shared_from_this()); if (video) { return DCPTime::from_frames (llrint (video->length_after_3d_combine() * frc.factor()), film->video_frame_rate()); } diff --git a/src/lib/ffmpeg_content.h b/src/lib/ffmpeg_content.h index 8bd5ef4fa..b7685bf09 100644 --- a/src/lib/ffmpeg_content.h +++ b/src/lib/ffmpeg_content.h @@ -54,6 +54,10 @@ public: return boost::dynamic_pointer_cast<FFmpegContent> (Content::shared_from_this ()); } + boost::shared_ptr<const FFmpegContent> shared_from_this () const { + return boost::dynamic_pointer_cast<const FFmpegContent> (Content::shared_from_this ()); + } + void examine (boost::shared_ptr<const Film> film, boost::shared_ptr<Job>); void take_settings_from (boost::shared_ptr<const Content> c); std::string summary () const; diff --git a/src/lib/frame_rate_change.cc b/src/lib/frame_rate_change.cc index 80a167029..456b4151e 100644 --- a/src/lib/frame_rate_change.cc +++ b/src/lib/frame_rate_change.cc @@ -20,12 +20,15 @@ #include "frame_rate_change.h" #include "types.h" +#include "content.h" +#include "film.h" #include "compose.hpp" #include <cmath> #include "i18n.h" using std::string; +using boost::shared_ptr; static bool about_equal (double a, double b) @@ -33,14 +36,20 @@ about_equal (double a, double b) return (fabs (a - b) < VIDEO_FRAME_RATE_EPSILON); } - FrameRateChange::FrameRateChange (double source_, int dcp_) - : source (source_) - , dcp (dcp_) - , skip (false) + : skip (false) , repeat (1) , change_speed (false) { + construct (source_, dcp_); +} + +void +FrameRateChange::construct (double source_, int dcp_) +{ + source = source_; + dcp = dcp_; + if (fabs (source / 2.0 - dcp) < fabs (source - dcp)) { /* The difference between source and DCP frame rate will be lower (i.e. better) if we skip. @@ -58,6 +67,16 @@ FrameRateChange::FrameRateChange (double source_, int dcp_) change_speed = !about_equal (speed_up, 1.0); } +FrameRateChange::FrameRateChange (shared_ptr<const Film> film, shared_ptr<const Content> content) +{ + construct (content->active_video_frame_rate(film), film->video_frame_rate()); +} + +FrameRateChange::FrameRateChange (shared_ptr<const Film> film, Content const * content) +{ + construct (content->active_video_frame_rate(film), film->video_frame_rate()); +} + string FrameRateChange::description () const { diff --git a/src/lib/frame_rate_change.h b/src/lib/frame_rate_change.h index ae3615328..05660ce82 100644 --- a/src/lib/frame_rate_change.h +++ b/src/lib/frame_rate_change.h @@ -21,11 +21,18 @@ #ifndef DCPOMATIC_FRAME_RATE_CHANGE_H #define DCPOMATIC_FRAME_RATE_CHANGE_H +#include <boost/shared_ptr.hpp> #include <string> -struct FrameRateChange +class Film; +class Content; + +class FrameRateChange { +public: FrameRateChange (double, int); + FrameRateChange (boost::shared_ptr<const Film> film, boost::shared_ptr<const Content> content); + FrameRateChange (boost::shared_ptr<const Film> film, Content const * content); /** @return factor by which to multiply a source frame rate to get the effective rate after any skip or repeat has happened. @@ -62,6 +69,9 @@ struct FrameRateChange double speed_up; std::string description () const; + +private: + void construct (double source_, int dcp_); }; #endif diff --git a/src/lib/image_content.cc b/src/lib/image_content.cc index 55ffac4f2..c84ba7d29 100644 --- a/src/lib/image_content.cc +++ b/src/lib/image_content.cc @@ -135,7 +135,7 @@ ImageContent::examine (shared_ptr<const Film> film, shared_ptr<Job> job) DCPTime ImageContent::full_length (shared_ptr<const Film> film) const { - FrameRateChange const frc (active_video_frame_rate(film), film->video_frame_rate()); + FrameRateChange const frc (film, shared_from_this()); return DCPTime::from_frames (llrint(video->length_after_3d_combine() * frc.factor()), film->video_frame_rate()); } diff --git a/src/lib/image_content.h b/src/lib/image_content.h index bc0f33151..6a450ef8f 100644 --- a/src/lib/image_content.h +++ b/src/lib/image_content.h @@ -33,6 +33,10 @@ public: return boost::dynamic_pointer_cast<ImageContent> (Content::shared_from_this ()); }; + boost::shared_ptr<const ImageContent> shared_from_this () const { + return boost::dynamic_pointer_cast<const ImageContent> (Content::shared_from_this ()); + }; + void examine (boost::shared_ptr<const Film> film, boost::shared_ptr<Job>); std::string summary () const; std::string technical_summary () const; diff --git a/src/lib/player.cc b/src/lib/player.cc index 80b9744d8..5a71c1330 100644 --- a/src/lib/player.cc +++ b/src/lib/player.cc @@ -156,7 +156,7 @@ Player::setup_pieces_unlocked () } shared_ptr<Decoder> decoder = decoder_factory (_film, i, _fast); - FrameRateChange frc (i->active_video_frame_rate(_film), _film->video_frame_rate()); + FrameRateChange frc (_film, i); if (!decoder) { /* Not something that we can decode; e.g. Atmos content */ @@ -735,7 +735,7 @@ Player::video (weak_ptr<Piece> wp, ContentVideo video) return; } - FrameRateChange frc(piece->content->active_video_frame_rate(_film), _film->video_frame_rate()); + FrameRateChange frc (_film, piece->content); if (frc.skip && (video.frame % 2) == 1) { return; } diff --git a/src/lib/string_text_file_content.cc b/src/lib/string_text_file_content.cc index 35f76be7c..8b740546e 100644 --- a/src/lib/string_text_file_content.cc +++ b/src/lib/string_text_file_content.cc @@ -91,6 +91,6 @@ StringTextFileContent::as_xml (xmlpp::Node* node, bool with_paths) const DCPTime StringTextFileContent::full_length (shared_ptr<const Film> film) const { - FrameRateChange const frc (active_video_frame_rate(film), film->video_frame_rate()); + FrameRateChange const frc (film, shared_from_this()); return DCPTime (_length, frc); } diff --git a/src/lib/string_text_file_content.h b/src/lib/string_text_file_content.h index 9a71d5828..4932f2a72 100644 --- a/src/lib/string_text_file_content.h +++ b/src/lib/string_text_file_content.h @@ -35,6 +35,10 @@ public: return boost::dynamic_pointer_cast<StringTextFileContent> (Content::shared_from_this ()); } + boost::shared_ptr<const StringTextFileContent> shared_from_this () const { + return boost::dynamic_pointer_cast<const StringTextFileContent> (Content::shared_from_this ()); + } + void examine (boost::shared_ptr<const Film> film, boost::shared_ptr<Job>); std::string summary () const; std::string technical_summary () const; diff --git a/src/lib/video_mxf_content.cc b/src/lib/video_mxf_content.cc index 4f69cb2e2..def58c5eb 100644 --- a/src/lib/video_mxf_content.cc +++ b/src/lib/video_mxf_content.cc @@ -119,7 +119,7 @@ VideoMXFContent::as_xml (xmlpp::Node* node, bool with_paths) const DCPTime VideoMXFContent::full_length (shared_ptr<const Film> film) const { - FrameRateChange const frc (active_video_frame_rate(film), film->video_frame_rate()); + FrameRateChange const frc (film, shared_from_this()); return DCPTime::from_frames (llrint (video->length_after_3d_combine() * frc.factor()), film->video_frame_rate()); } diff --git a/src/lib/video_mxf_content.h b/src/lib/video_mxf_content.h index c536cb2aa..6236568b1 100644 --- a/src/lib/video_mxf_content.h +++ b/src/lib/video_mxf_content.h @@ -30,6 +30,10 @@ public: return boost::dynamic_pointer_cast<VideoMXFContent> (Content::shared_from_this ()); } + boost::shared_ptr<const VideoMXFContent> shared_from_this () const { + return boost::dynamic_pointer_cast<const VideoMXFContent> (Content::shared_from_this ()); + } + void examine (boost::shared_ptr<const Film> film, boost::shared_ptr<Job> job); std::string summary () const; std::string technical_summary () const; |
