Keep information about the video range (full/JPEG or video/MPEG) in
[dcpomatic.git] / test / image_test.cc
index 5adc3560330623f8e4f6e44245043a7c7d5a9d24..58c4cf74a44374218a2baeb8a67330a43c15c216 100644 (file)
@@ -38,7 +38,7 @@ using boost::shared_ptr;
 
 BOOST_AUTO_TEST_CASE (aligned_image_test)
 {
-       Image* s = new Image (AV_PIX_FMT_RGB24, dcp::Size (50, 50), true);
+       Image* s = new Image (AV_PIX_FMT_RGB24, true, dcp::Size (50, 50), true);
        BOOST_CHECK_EQUAL (s->planes(), 1);
        /* 160 is 150 aligned to the nearest 32 bytes */
        BOOST_CHECK_EQUAL (s->stride()[0], 160);
@@ -65,7 +65,7 @@ BOOST_AUTO_TEST_CASE (aligned_image_test)
        BOOST_CHECK_EQUAL (t->stride()[0], s->stride()[0]);
 
        /* assignment operator */
-       Image* u = new Image (AV_PIX_FMT_YUV422P, dcp::Size (150, 150), false);
+       Image* u = new Image (AV_PIX_FMT_YUV422P, true, dcp::Size (150, 150), false);
        *u = *s;
        BOOST_CHECK_EQUAL (u->planes(), 1);
        BOOST_CHECK_EQUAL (u->stride()[0], 160);
@@ -88,7 +88,7 @@ BOOST_AUTO_TEST_CASE (aligned_image_test)
 
 BOOST_AUTO_TEST_CASE (compact_image_test)
 {
-       Image* s = new Image (AV_PIX_FMT_RGB24, dcp::Size (50, 50), false);
+       Image* s = new Image (AV_PIX_FMT_RGB24, true, dcp::Size (50, 50), false);
        BOOST_CHECK_EQUAL (s->planes(), 1);
        BOOST_CHECK_EQUAL (s->stride()[0], 50 * 3);
        BOOST_CHECK_EQUAL (s->line_size()[0], 50 * 3);
@@ -114,7 +114,7 @@ BOOST_AUTO_TEST_CASE (compact_image_test)
        BOOST_CHECK_EQUAL (t->stride()[0], s->stride()[0]);
 
        /* assignment operator */
-       Image* u = new Image (AV_PIX_FMT_YUV422P, dcp::Size (150, 150), true);
+       Image* u = new Image (AV_PIX_FMT_YUV422P, true, dcp::Size (150, 150), true);
        *u = *s;
        BOOST_CHECK_EQUAL (u->planes(), 1);
        BOOST_CHECK_EQUAL (u->stride()[0], 50 * 3);
@@ -140,9 +140,9 @@ alpha_blend_test_one (AVPixelFormat format, string suffix)
 {
        shared_ptr<MagickImageProxy> proxy (new MagickImageProxy (private_data / "prophet_frame.tiff"));
        shared_ptr<Image> raw = proxy->image().first;
-       shared_ptr<Image> background = raw->convert_pixel_format (dcp::YUV_TO_RGB_REC709, format, true, false);
+       shared_ptr<Image> background = raw->convert_pixel_format (dcp::YUV_TO_RGB_REC709, format, true, true, false);
 
-       shared_ptr<Image> overlay (new Image (AV_PIX_FMT_BGRA, dcp::Size(431, 891), true));
+       shared_ptr<Image> overlay (new Image (AV_PIX_FMT_BGRA, true, dcp::Size(431, 891), true));
        overlay->make_transparent ();
 
        for (int y = 0; y < 128; ++y) {
@@ -171,7 +171,7 @@ alpha_blend_test_one (AVPixelFormat format, string suffix)
 
        background->alpha_blend (overlay, Position<int> (13, 17));
 
-       shared_ptr<Image> save = background->convert_pixel_format (dcp::YUV_TO_RGB_REC709, AV_PIX_FMT_RGB24, false, false);
+       shared_ptr<Image> save = background->convert_pixel_format (dcp::YUV_TO_RGB_REC709, AV_PIX_FMT_RGB24, true, false, false);
 
        write_image (save, "build/test/image_test_" + suffix + ".png", "RGB");
        check_image ("build/test/image_test_" + suffix + ".png", private_data / ("image_test_" + suffix + ".png"));
@@ -194,7 +194,7 @@ BOOST_AUTO_TEST_CASE (merge_test1)
 {
        int const stride = 48 * 4;
 
-       shared_ptr<Image> A (new Image (AV_PIX_FMT_BGRA, dcp::Size (48, 48), false));
+       shared_ptr<Image> A (new Image (AV_PIX_FMT_BGRA, true, dcp::Size (48, 48), false));
        A->make_transparent ();
        uint8_t* a = A->data()[0];
 
@@ -219,7 +219,7 @@ BOOST_AUTO_TEST_CASE (merge_test1)
 /** Test merge (list<PositionImage>) with two images */
 BOOST_AUTO_TEST_CASE (merge_test2)
 {
-       shared_ptr<Image> A (new Image (AV_PIX_FMT_BGRA, dcp::Size (48, 1), false));
+       shared_ptr<Image> A (new Image (AV_PIX_FMT_BGRA, true, dcp::Size (48, 1), false));
        A->make_transparent ();
        uint8_t* a = A->data()[0];
        for (int x = 0; x < 16; ++x) {
@@ -229,7 +229,7 @@ BOOST_AUTO_TEST_CASE (merge_test2)
                a[x * 4 + 3] = 255;
        }
 
-       shared_ptr<Image> B (new Image (AV_PIX_FMT_BGRA, dcp::Size (48, 1), false));
+       shared_ptr<Image> B (new Image (AV_PIX_FMT_BGRA, true, dcp::Size (48, 1), false));
        B->make_transparent ();
        uint8_t* b = B->data()[0];
        for (int x = 0; x < 16; ++x) {
@@ -262,8 +262,8 @@ BOOST_AUTO_TEST_CASE (crop_scale_window_test)
 {
        shared_ptr<MagickImageProxy> proxy(new MagickImageProxy("test/data/flat_red.png"));
        shared_ptr<Image> raw = proxy->image().first;
-       shared_ptr<Image> out = raw->crop_scale_window(Crop(), dcp::Size(1998, 836), dcp::Size(1998, 1080), dcp::YUV_TO_RGB_REC709, AV_PIX_FMT_YUV420P, true, false);
-       shared_ptr<Image> save = out->scale(dcp::Size(1998, 1080), dcp::YUV_TO_RGB_REC709, AV_PIX_FMT_RGB24, false, false);
+       shared_ptr<Image> out = raw->crop_scale_window(Crop(), dcp::Size(1998, 836), dcp::Size(1998, 1080), dcp::YUV_TO_RGB_REC709, AV_PIX_FMT_YUV420P, true, true, false);
+       shared_ptr<Image> save = out->scale(dcp::Size(1998, 1080), dcp::YUV_TO_RGB_REC709, AV_PIX_FMT_RGB24, true, false, false);
        write_image(save, "build/test/crop_scale_window_test.png", "RGB");
        check_image("test/data/crop_scale_window_test.png", "build/test/crop_scale_window_test.png");
 }