Add test that partially fails (failures commented out).
[dcpomatic.git] / test / image_test.cc
index c638523a881c76038442dc03144ef927c2d6a559..e6ffbdedc109d72f7e1b0a2272eb2c1c69d89e99 100644 (file)
@@ -355,7 +355,7 @@ BOOST_AUTO_TEST_CASE (crop_scale_window_test4)
                Crop(512, 0, 0, 0), dcp::Size(1486, 1080), dcp::Size(1998, 1080), dcp::YUVToRGB::REC709, VideoRange::FULL, AV_PIX_FMT_XYZ12LE, VideoRange::FULL, Image::Alignment::COMPACT, false
                );
        write_image(cropped, "build/test/crop_scale_window_test4.png");
-       check_image("test/data/crop_scale_window_test4.png", "build/test/crop_scale_window_test4.png", 35000);
+       check_image("test/data/crop_scale_window_test4.png", "build/test/crop_scale_window_test4.png");
 }
 
 
@@ -379,7 +379,7 @@ BOOST_AUTO_TEST_CASE (crop_scale_window_test6)
                Crop(512, 0, 0, 0), dcp::Size(1486, 1080), dcp::Size(1998, 1080), dcp::YUVToRGB::REC709, VideoRange::FULL, AV_PIX_FMT_XYZ12LE, VideoRange::FULL, Image::Alignment::COMPACT, false
                );
        write_image(cropped, "build/test/crop_scale_window_test6.png");
-       check_image("test/data/crop_scale_window_test6.png", "build/test/crop_scale_window_test6.png", 35000);
+       check_image("test/data/crop_scale_window_test6.png", "build/test/crop_scale_window_test6.png");
 }
 
 
@@ -426,6 +426,59 @@ BOOST_AUTO_TEST_CASE (crop_scale_window_test8)
 }
 
 
+
+BOOST_AUTO_TEST_CASE(crop_scale_window_noise_on_edge)
+{
+       auto test = [](dcp::Size in_size, dcp::Size out_size) {
+
+               using namespace boost::filesystem;
+
+               auto image = make_shared<Image>(AV_PIX_FMT_RGB24, in_size, Image::Alignment::PADDED);
+               for (int y = 0; y < in_size.height; ++y) {
+                       auto data = image->data()[0] + image->stride()[0] * y;
+                       for (int x = 0; x < in_size.width; ++x) {
+                               *data++ = 0;
+                               *data++ = 255;
+                               *data++ = 0;
+                       }
+               }
+
+               auto scaled = image->crop_scale_window(
+                       Crop(), out_size, out_size, dcp::YUVToRGB::REC709, VideoRange::FULL, AV_PIX_FMT_RGB24, VideoRange::FULL, Image::Alignment::PADDED, false
+                       );
+
+               auto const scaled_size = scaled->size();
+
+               for (auto y = 0; y < scaled_size.height; ++y) {
+                       auto data = scaled->data()[0] + scaled->stride()[0] * y;
+                       for (int x = 0; x < scaled_size.width; ++x) {
+                               if (*data++ != 0) {
+                                       return false;
+                               }
+                               if (*data++ != 255) {
+                                       return false;
+                               }
+                               if (*data++ != 0) {
+                                       return false;
+                               }
+                       }
+               }
+
+               return true;
+       };
+
+       BOOST_CHECK(test({998, 540}, {441, 239}));
+       BOOST_CHECK(test({998, 541}, {441, 239}));
+       BOOST_CHECK(test({492, 101}, {494, 103}));
+       /* These all fail; there's little bars of "noise" on the right hand side of the image */
+       // BOOST_CHECK(test({999, 540}, {440, 540}));
+       // BOOST_CHECK(test({999, 540}, {432, 540}));
+       // BOOST_CHECK(test({999, 540}, {440, 540}));
+       // BOOST_CHECK(test({999, 540}, {440, 239}));
+}
+
+
+
 BOOST_AUTO_TEST_CASE (as_png_test)
 {
        auto proxy = make_shared<FFmpegImageProxy>("test/data/3d_test/000001.png");
@@ -584,6 +637,7 @@ BOOST_AUTO_TEST_CASE (make_part_black_test)
                AV_PIX_FMT_BGRA,
                AV_PIX_FMT_YUV420P,
                AV_PIX_FMT_YUV422P10LE,
+               AV_PIX_FMT_YUV444P10LE
        };
 
        list<std::pair<int, int>> positions = {