diff options
| author | Carl Hetherington <cth@carlh.net> | 2025-05-31 02:40:50 +0200 |
|---|---|---|
| committer | Carl Hetherington <cth@carlh.net> | 2025-06-17 00:04:03 +0200 |
| commit | dce8911cbc577f9f8f272d78c455e708c0b47aa9 (patch) | |
| tree | 7884dc6b40bd88c3bef6e4b354799c7044e32756 /src/tools | |
| parent | ec06811bae7ed4fc6bd80c3154fd473028ee8e13 (diff) | |
Support cropping of content on playback (#3041).
This is to allow, for example, pillarboxed 1.78:1 DCPs to be played nicely
on 1.78:1 projectors. DCP-o-matic can now crop the pillarboxing before
display, rather than putting the pillarboxed 1.85:1 onto a 1.78:1 monitor,
thereby adding letterboxing.
Diffstat (limited to 'src/tools')
| -rw-r--r-- | src/tools/dcpomatic_player.cc | 24 |
1 files changed, 22 insertions, 2 deletions
diff --git a/src/tools/dcpomatic_player.cc b/src/tools/dcpomatic_player.cc index ffb4f5dbd..60d6911ef 100644 --- a/src/tools/dcpomatic_player.cc +++ b/src/tools/dcpomatic_player.cc @@ -494,7 +494,7 @@ public: } /* Start off as Flat */ - _film->set_container (Ratio::from_id("185")); + auto auto_ratio = Ratio::from_id("185"); _film->set_audio_channels (MAX_DCP_AUDIO_CHANNELS); @@ -509,7 +509,7 @@ public: auto const r = Ratio::nearest_from_ratio(i->video->size()->ratio()); if (r.id() == "239") { /* Any scope content means we use scope */ - _film->set_container(r); + auto_ratio = r; } } @@ -539,6 +539,8 @@ public: _cpl_menu->Remove (i); } + auto const crop = Config::instance()->player_crop_output_ratio(); + if (_film->content().size() == 1) { /* Offer a CPL menu */ auto first = dynamic_pointer_cast<DCPContent>(_film->content().front()); @@ -553,6 +555,24 @@ public: ++id; } } + + if (crop) { + auto size = _film->content()[0]->video->size().get_value_or({1998, 1080}); + int pixels = 0; + if (*crop > (2048.0 / 1080.0)) { + pixels = (size.height - (size.width / *crop)) / 2; + _film->content()[0]->video->set_crop(Crop{0, 0, pixels, pixels}); + } else { + pixels = (size.width - (size.height * *crop)) / 2; + _film->content()[0]->video->set_crop(Crop{pixels, pixels, 0, 0}); + } + } + } + + if (crop) { + _film->set_container(Ratio(*crop, "custom", "custom", {}, "custom")); + } else { + _film->set_container(auto_ratio); } } |
