diff options
| author | Carl Hetherington <cth@carlh.net> | 2022-01-01 21:20:51 +0000 |
|---|---|---|
| committer | Carl Hetherington <cth@carlh.net> | 2022-04-29 01:44:15 +0200 |
| commit | d5c059a2ff9bab5c2973db6bc4860591679dd42b (patch) | |
| tree | c8ec57cdeae4c3746f6ff7abd28816310540604b /src/lib | |
| parent | 5b2b8279d8eb33d31166027d876b4c9f86087bfd (diff) | |
Primitive auto-crop (#1477).
Diffstat (limited to 'src/lib')
| -rw-r--r-- | src/lib/config.cc | 3 | ||||
| -rw-r--r-- | src/lib/config.h | 9 | ||||
| -rw-r--r-- | src/lib/player.cc | 16 | ||||
| -rw-r--r-- | src/lib/player.h | 1 | ||||
| -rw-r--r-- | src/lib/rect.h | 7 | ||||
| -rw-r--r-- | src/lib/video_content.cc | 6 | ||||
| -rw-r--r-- | src/lib/video_content.h | 1 |
7 files changed, 43 insertions, 0 deletions
diff --git a/src/lib/config.cc b/src/lib/config.cc index 36aae76de..d11a60c94 100644 --- a/src/lib/config.cc +++ b/src/lib/config.cc @@ -188,6 +188,7 @@ Config::set_defaults () _write_kdms_to_disk = true; _email_kdms = false; _default_kdm_type = dcp::Formulation::MODIFIED_TRANSITIONAL_1; + _auto_crop_threshold = 0.1; _allowed_dcp_frame_rates.clear (); _allowed_dcp_frame_rates.push_back (24); @@ -579,6 +580,7 @@ try _write_kdms_to_disk = f.optional_bool_child("WriteKDMsToDisk").get_value_or(true); _email_kdms = f.optional_bool_child("EmailKDMs").get_value_or(false); _default_kdm_type = dcp::string_to_formulation(f.optional_string_child("DefaultKDMType").get_value_or("modified-transitional-1")); + _auto_crop_threshold = f.optional_number_child<double>("AutoCropThreshold").get_value_or(0.1); if (boost::filesystem::exists (_cinemas_file)) { cxml::Document f ("Cinemas"); @@ -1014,6 +1016,7 @@ Config::write_config () const root->add_child("WriteKDMsToDisk")->add_child_text(_write_kdms_to_disk ? "1" : "0"); root->add_child("EmailKDMs")->add_child_text(_email_kdms ? "1" : "0"); root->add_child("DefaultKDMType")->add_child_text(dcp::formulation_to_string(_default_kdm_type)); + root->add_child("AutoCropThreshold")->add_child_text(raw_convert<string>(_auto_crop_threshold)); auto target = config_write_file(); diff --git a/src/lib/config.h b/src/lib/config.h index 1d40a3b15..40497e219 100644 --- a/src/lib/config.h +++ b/src/lib/config.h @@ -91,6 +91,7 @@ public: HISTORY, SHOW_EXPERIMENTAL_AUDIO_PROCESSORS, AUDIO_MAPPING, + AUTO_CROP_THRESHOLD, OTHER }; @@ -571,6 +572,9 @@ public: return _default_kdm_type; } + double auto_crop_threshold () const { + return _auto_crop_threshold; + } /* SET (mostly) */ @@ -1096,6 +1100,10 @@ public: maybe_set (_default_kdm_type, type); } + void set_auto_crop_threshold (double threshold) { + maybe_set (_auto_crop_threshold, threshold, AUTO_CROP_THRESHOLD); + } + void changed (Property p = OTHER); boost::signals2::signal<void (Property)> Changed; /** Emitted if read() failed on an existing Config file. There is nothing @@ -1316,6 +1324,7 @@ private: bool _write_kdms_to_disk; bool _email_kdms; dcp::Formulation _default_kdm_type; + double _auto_crop_threshold; static int const _current_version; diff --git a/src/lib/player.cc b/src/lib/player.cc index 619a3583c..b2db2b3ef 100644 --- a/src/lib/player.cc +++ b/src/lib/player.cc @@ -1432,6 +1432,22 @@ Player::content_time_to_dcp (shared_ptr<const Content> content, ContentTime t) } +optional<ContentTime> +Player::dcp_to_content_time (shared_ptr<const Content> content, DCPTime t) +{ + boost::mutex::scoped_lock lm (_mutex); + + for (auto i: _pieces) { + if (i->content == content) { + return dcp_to_content_time (i, t); + } + } + + /* We couldn't find this content; perhaps things are being changed over */ + return {}; +} + + shared_ptr<const Playlist> Player::playlist () const { diff --git a/src/lib/player.h b/src/lib/player.h index b70ea05dd..7d99c22c6 100644 --- a/src/lib/player.h +++ b/src/lib/player.h @@ -101,6 +101,7 @@ public: void set_dcp_decode_reduction (boost::optional<int> reduction); boost::optional<dcpomatic::DCPTime> content_time_to_dcp (std::shared_ptr<const Content> content, dcpomatic::ContentTime t); + boost::optional<dcpomatic::ContentTime> dcp_to_content_time (std::shared_ptr<const Content> content, dcpomatic::DCPTime t); boost::signals2::signal<void (ChangeType, int, bool)> Change; diff --git a/src/lib/rect.h b/src/lib/rect.h index 5f807f499..a01e0f885 100644 --- a/src/lib/rect.h +++ b/src/lib/rect.h @@ -119,6 +119,13 @@ public: }; +template <class T> +bool operator== (Rect<T> const& a, Rect<T> const& b) +{ + return a.x == b.x && a.y == b.y && a.width == b.width && a.height == b.height; +} + + } diff --git a/src/lib/video_content.cc b/src/lib/video_content.cc index 86efeee7b..de3d3f3a2 100644 --- a/src/lib/video_content.cc +++ b/src/lib/video_content.cc @@ -530,6 +530,12 @@ VideoContent::set_length (Frame len) } void +VideoContent::set_crop (Crop c) +{ + maybe_set (_crop, c, VideoContentProperty::CROP); +} + +void VideoContent::set_left_crop (int c) { maybe_set (_crop.left, c, VideoContentProperty::CROP); diff --git a/src/lib/video_content.h b/src/lib/video_content.h index 3ec884578..7214d35e4 100644 --- a/src/lib/video_content.h +++ b/src/lib/video_content.h @@ -89,6 +89,7 @@ public: void set_frame_type (VideoFrameType); + void set_crop (Crop crop); void set_left_crop (int); void set_right_crop (int); void set_top_crop (int); |
