diff options
| author | Carl Hetherington <cth@carlh.net> | 2022-01-01 21:20:51 +0000 |
|---|---|---|
| committer | Carl Hetherington <cth@carlh.net> | 2022-01-16 00:38:53 +0100 |
| commit | 7b66e9c9de6df12f49b358d9496a9e64b68db550 (patch) | |
| tree | a7174cc9c15afb6ee7c8a462b4899d4e86ab4e82 /src/lib | |
| parent | 348c4507bc8d37de6da9f4b2ecd1ae1b180c47d2 (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 | 10 | ||||
| -rw-r--r-- | src/lib/player.cc | 18 | ||||
| -rw-r--r-- | src/lib/player.h | 3 | ||||
| -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, 46 insertions, 2 deletions
diff --git a/src/lib/config.cc b/src/lib/config.cc index bf294aec9..da7082a8e 100644 --- a/src/lib/config.cc +++ b/src/lib/config.cc @@ -183,6 +183,7 @@ Config::set_defaults () _audio_mapping = boost::none; _custom_languages.clear (); _add_files_path = boost::none; + _auto_crop_threshold = 0.1; _allowed_dcp_frame_rates.clear (); _allowed_dcp_frame_rates.push_back (24); @@ -583,6 +584,7 @@ try } _add_files_path = f.optional_string_child("AddFilesPath"); + _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 /* [XML] AddFilesPath The default path that will be offered in the picker when adding files to a film. */ root->add_child("AddFilesPath")->add_child_text(_add_files_path->string()); } + 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 5289656e3..bdf6c8395 100644 --- a/src/lib/config.h +++ b/src/lib/config.h @@ -84,6 +84,7 @@ public: HISTORY, SHOW_EXPERIMENTAL_AUDIO_PROCESSORS, AUDIO_MAPPING, + AUTO_CROP_THRESHOLD, OTHER }; @@ -547,6 +548,10 @@ public: return _add_files_path; } + double auto_crop_threshold () const { + return _auto_crop_threshold; + } + /* SET (mostly) */ void set_master_encoding_threads (int n) { @@ -1055,6 +1060,10 @@ public: changed (); } + 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 @@ -1268,6 +1277,7 @@ private: boost::optional<AudioMapping> _audio_mapping; std::vector<dcp::LanguageTag> _custom_languages; boost::optional<boost::filesystem::path> _add_files_path; + double _auto_crop_threshold; static int const _current_version; diff --git a/src/lib/player.cc b/src/lib/player.cc index 01413115b..f1fd060f4 100644 --- a/src/lib/player.cc +++ b/src/lib/player.cc @@ -1384,7 +1384,7 @@ Player::set_dcp_decode_reduction (optional<int> reduction) optional<DCPTime> -Player::content_time_to_dcp (shared_ptr<Content> content, ContentTime t) +Player::content_time_to_dcp (shared_ptr<const Content> content, ContentTime t) { boost::mutex::scoped_lock lm (_mutex); @@ -1399,6 +1399,22 @@ Player::content_time_to_dcp (shared_ptr<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 0d0116e92..3bd293889 100644 --- a/src/lib/player.h +++ b/src/lib/player.h @@ -101,7 +101,8 @@ public: void set_play_referenced (); void set_dcp_decode_reduction (boost::optional<int> reduction); - boost::optional<dcpomatic::DCPTime> content_time_to_dcp (std::shared_ptr<Content> content, dcpomatic::ContentTime t); + 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 27eb04fe0..1b24101f3 100644 --- a/src/lib/video_content.cc +++ b/src/lib/video_content.cc @@ -532,6 +532,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 2adf941d9..d16af14d8 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); |
