diff options
| author | Carl Hetherington <cth@carlh.net> | 2014-06-12 22:27:50 +0100 |
|---|---|---|
| committer | Carl Hetherington <cth@carlh.net> | 2014-06-12 22:27:50 +0100 |
| commit | 04533b9cf34ce8089113015715083ee9c5b2b001 (patch) | |
| tree | 582334f3740be291a78cc97de403b4295d8847c1 /src/lib | |
| parent | 4e411ea97b4dab8a5fa282d1d4cf7971ef1e24ad (diff) | |
| parent | 51f1885e63193b8ab62a51089298c3711269d2a3 (diff) | |
Merge master.
Diffstat (limited to 'src/lib')
| -rw-r--r-- | src/lib/video_content.cc | 28 | ||||
| -rw-r--r-- | src/lib/video_content.h | 3 |
2 files changed, 31 insertions, 0 deletions
diff --git a/src/lib/video_content.cc b/src/lib/video_content.cc index f871f2df6..05f5c538e 100644 --- a/src/lib/video_content.cc +++ b/src/lib/video_content.cc @@ -46,6 +46,8 @@ using std::stringstream; using std::setprecision; using std::cout; using std::vector; +using std::min; +using std::max; using boost::shared_ptr; using boost::optional; using boost::dynamic_pointer_cast; @@ -380,6 +382,32 @@ VideoContent::dcp_time_to_content_time (DCPTime t) const return ContentTime (t, FrameRateChange (video_frame_rate(), film->video_frame_rate())); } +void +VideoContent::scale_and_crop_to_fit_width () +{ + shared_ptr<const Film> film = _film.lock (); + assert (film); + + set_scale (VideoContentScale (film->container ())); + + int const crop = max (0, int (video_size().height - double (film->frame_size().height) * video_size().width / film->frame_size().width)); + set_top_crop (crop / 2); + set_bottom_crop (crop / 2); +} + +void +VideoContent::scale_and_crop_to_fit_height () +{ + shared_ptr<const Film> film = _film.lock (); + assert (film); + + set_scale (VideoContentScale (film->container ())); + + int const crop = max (0, int (video_size().width - double (film->frame_size().width) * video_size().height / film->frame_size().height)); + set_left_crop (crop / 2); + set_right_crop (crop / 2); +} + VideoContentScale::VideoContentScale (Ratio const * r) : _ratio (r) , _scale (true) diff --git a/src/lib/video_content.h b/src/lib/video_content.h index 8313c73ee..4206efc2c 100644 --- a/src/lib/video_content.h +++ b/src/lib/video_content.h @@ -171,6 +171,9 @@ public: ContentTime dcp_time_to_content_time (DCPTime) const; + void scale_and_crop_to_fit_width (); + void scale_and_crop_to_fit_height (); + protected: void take_from_video_examiner (boost::shared_ptr<VideoExaminer>); |
