Rename guess_crop -> guess_crop_by_brightness.
authorCarl Hetherington <cth@carlh.net>
Fri, 6 Dec 2024 16:45:47 +0000 (17:45 +0100)
committerCarl Hetherington <cth@carlh.net>
Thu, 26 Dec 2024 16:20:24 +0000 (17:20 +0100)
src/lib/guess_crop.cc
src/lib/guess_crop.h
src/wx/content_menu.cc
test/guess_crop_test.cc

index 5eb7e66e8adc4c5caa2ea6c966125e9b2402864e..14ef9a9edd2da51b1005dc486a4b1d2eec9bc4d2 100644 (file)
@@ -32,7 +32,7 @@ using namespace dcpomatic;
 
 
 Crop
-guess_crop (shared_ptr<const Image> image, double threshold)
+guess_crop_by_brightness(shared_ptr<const Image> image, double threshold)
 {
        auto const width = image->size().width;
        auto const height = image->size().height;
@@ -73,7 +73,7 @@ guess_crop (shared_ptr<const Image> image, double threshold)
                        break;
                }
                default:
-                       throw PixelFormatError("guess_crop()", image->pixel_format());
+                       throw PixelFormatError("guess_crop_by_brightness()", image->pixel_format());
                }
 
                return brightest > threshold;
@@ -115,7 +115,7 @@ guess_crop (shared_ptr<const Image> image, double threshold)
 
 /** @param position Time within the content to get a video frame from when guessing the crop */
 Crop
-guess_crop (shared_ptr<const Film> film, shared_ptr<const Content> content, double threshold, ContentTime position)
+guess_crop_by_brightness(shared_ptr<const Film> film, shared_ptr<const Content> content, double threshold, ContentTime position)
 {
        DCPOMATIC_ASSERT (content->video);
 
@@ -126,7 +126,7 @@ guess_crop (shared_ptr<const Film> film, shared_ptr<const Content> content, doub
        auto crop = Crop{};
 
        auto handle_video = [&done, &crop, threshold](ContentVideo video) {
-               crop = guess_crop(video.image->image(Image::Alignment::COMPACT).image, threshold);
+               crop = guess_crop_by_brightness(video.image->image(Image::Alignment::COMPACT).image, threshold);
                done = true;
        };
 
index f18c2db5e6c90fe65bd5826c41d9c95c894822c1..9585ed92a14ef00e751f82d81b97b011d670eaaa 100644 (file)
@@ -29,6 +29,6 @@ class Film;
 class Image;
 
 
-Crop guess_crop (std::shared_ptr<const Image> image, double threshold);
-Crop guess_crop (std::shared_ptr<const Film> fillm, std::shared_ptr<const Content> content, double threshold, dcpomatic::ContentTime position);
+Crop guess_crop_by_brightness(std::shared_ptr<const Image> image, double threshold);
+Crop guess_crop_by_brightness(std::shared_ptr<const Film> fillm, std::shared_ptr<const Content> content, double threshold, dcpomatic::ContentTime position);
 
index ef4e87a80c6cea6d56e55e26066f3f96aa41415a..30abe7416cd859f91a71e2ee61e2676219c5f6ee 100644 (file)
@@ -562,7 +562,7 @@ ContentMenu::auto_crop ()
                auto position = _viewer.position_in_content(_content.front()).get_value_or(
                        ContentTime::from_frames(_content.front()->video->length(), _content.front()->video_frame_rate().get_value_or(24))
                        );
-               return guess_crop(film, _content.front(), Config::instance()->auto_crop_threshold(), position);
+               return guess_crop_by_brightness(film, _content.front(), Config::instance()->auto_crop_threshold(), position);
        };
 
        /* Make an initial guess in the view and open the dialog */
index c58432382372dac5dc724e489bb7f2c50611f7e7..b62042d1a42fb42a8f91711da72f3f861f1de81a 100644 (file)
@@ -37,7 +37,7 @@ BOOST_AUTO_TEST_CASE (guess_crop_image_test1)
        auto content = content_factory(TestPaths::private_data() / "arrietty_724.tiff");
        auto film = new_test_film("guess_crop_image_test1", content);
 
-       BOOST_CHECK (guess_crop(film, content[0], 0.1, {}) == Crop(0, 0, 11, 11));
+       BOOST_CHECK(guess_crop_by_brightness(film, content[0], 0.1, {}) == Crop(0, 0, 11, 11));
 }
 
 
@@ -46,7 +46,7 @@ BOOST_AUTO_TEST_CASE (guess_crop_image_test2)
        auto content = content_factory(TestPaths::private_data() / "prophet_frame.tiff");
        auto film = new_test_film("guess_crop_image_test2", content);
 
-       BOOST_CHECK(guess_crop(film, content[0], 0.1, {}) == Crop(0, 0, 22, 22));
+       BOOST_CHECK(guess_crop_by_brightness(film, content[0], 0.1, {}) == Crop(0, 0, 22, 22));
 }
 
 
@@ -55,5 +55,5 @@ BOOST_AUTO_TEST_CASE (guess_crop_image_test3)
        auto content = content_factory(TestPaths::private_data() / "pillarbox.png");
        auto film = new_test_film("guess_crop_image_test3", content);
 
-       BOOST_CHECK(guess_crop(film, content[0], 0.1, {}) == Crop(113, 262, 0, 0));
+       BOOST_CHECK(guess_crop_by_brightness(film, content[0], 0.1, {}) == Crop(113, 262, 0, 0));
 }