diff options
| author | Carl Hetherington <cth@carlh.net> | 2025-03-19 21:53:20 +0100 |
|---|---|---|
| committer | Carl Hetherington <cth@carlh.net> | 2025-03-19 21:53:20 +0100 |
| commit | 8fb9468aff13b6840fb02a8a899e314b79395f5d (patch) | |
| tree | ffb1fce61851c80c1345580645e33feec1e3ae05 | |
| parent | 4ddd6052b00a07583fda682730dde3c3d1206d1b (diff) | |
Fix auto-crop with DCPs (#2999).
| -rw-r--r-- | src/lib/guess_crop.cc | 10 | ||||
| -rw-r--r-- | test/guess_crop_test.cc | 13 |
2 files changed, 22 insertions, 1 deletions
diff --git a/src/lib/guess_crop.cc b/src/lib/guess_crop.cc index 7089d245d..7213eb668 100644 --- a/src/lib/guess_crop.cc +++ b/src/lib/guess_crop.cc @@ -109,6 +109,16 @@ guess_crop_by_brightness(shared_ptr<const Image> image, double threshold) } break; } + case AV_PIX_FMT_XYZ12LE: + { + uint16_t const* data = reinterpret_cast<uint16_t*>(image->data()[0] + (start_x * 6) + (start_y * image->stride()[0])); + for (int p = 0; p < pixels; ++p) { + /* Just using Y */ + brightest = std::max(brightest, static_cast<double>(data[1]) / 4096); + data += rows ? 3 : (image->stride()[0] / 2); + } + break; + } default: throw PixelFormatError("guess_crop_by_brightness()", image->pixel_format()); } diff --git a/test/guess_crop_test.cc b/test/guess_crop_test.cc index b62042d1a..9ce089a80 100644 --- a/test/guess_crop_test.cc +++ b/test/guess_crop_test.cc @@ -21,14 +21,15 @@ #include "lib/content.h" #include "lib/content_factory.h" +#include "lib/dcp_content.h" #include "lib/guess_crop.h" #include "lib/video_content.h" #include "test.h" #include <boost/test/unit_test.hpp> -#include <iostream> #include <vector> +using std::make_shared; using namespace dcpomatic; @@ -57,3 +58,13 @@ BOOST_AUTO_TEST_CASE (guess_crop_image_test3) BOOST_CHECK(guess_crop_by_brightness(film, content[0], 0.1, {}) == Crop(113, 262, 0, 0)); } + + +BOOST_AUTO_TEST_CASE(guess_crop_image_dcp_test) +{ + auto content = make_shared<DCPContent>("test/data/scaling_test_133_185"); + auto film = new_test_film("guess_crop_image_dcp_test", { content }); + + BOOST_CHECK(guess_crop_by_brightness(film, content, 0.1, {}) == Crop(279, 279, 0, 0)); +} + |
