summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorCarl Hetherington <cth@carlh.net>2025-09-19 11:41:03 +0200
committerCarl Hetherington <cth@carlh.net>2025-09-23 09:14:10 +0200
commitaac6fad8adad9020e6a82140085091fdef2873cf (patch)
treea8512e8f4aa8be0b234b7c1d0f993e730e3a847b /test
parenta757fe63424074e9d3dfe7847a17bfe2b5fd93de (diff)
Return quite close to original approach for "no colour conversion".
There's a few things going on here: 1. Improve the regression test for 3042. Previously we made a DCP from the reporter's _original_ prores file (before they converted it to XYZ) and compared the result to a reference J2K file of uncertain origin. This seems wrong because: a) We never got confirmation from the reporter that the fix worked for them, so any arbitrary reference is dubious. b) It doesn't seem to reflect their actual complaint, which was that they got a different result when making a DCP from XYZ TIFFs compared to their "XYZ" Prores. The new test makes a DCP from their TIFFs and "XYZ" Prores and compares the result. 2. Revert to the old approach to "no conversion" handling. In the good old days we did everything -> RGB48LE except XYZ12LE -> XYZ12LE, and that's what we do again here. 3. Change the YUV->RGB conversion from Rec.601 to Rec.709 for the "no conversion" case. This fixes the 3042 regression test. The supposed "XYZ" Prores is yuv444p12le according to ffprobe. So I think what we have here is actually a file that was converted to XYZ and then back to YUV by Resolve. I experimented with using the raw YUV values and considering them as XYZ but this was clearly wrong. I think 3 is probably what I should have done in the first place.
Diffstat (limited to 'test')
-rw-r--r--test/3042_regression_test.cc43
-rw-r--r--test/mpeg2_dcp_test.cc4
-rw-r--r--test/test.cc42
-rw-r--r--test/test.h1
4 files changed, 75 insertions, 15 deletions
diff --git a/test/3042_regression_test.cc b/test/3042_regression_test.cc
index 3660a3590..b8b485803 100644
--- a/test/3042_regression_test.cc
+++ b/test/3042_regression_test.cc
@@ -20,21 +20,48 @@
#include "lib/content_factory.h"
+#include "lib/dcp_content_type.h"
#include "lib/film.h"
#include "lib/video_content.h"
#include "test.h"
#include <boost/test/unit_test.hpp>
-BOOST_AUTO_TEST_CASE(encode_xyz_from_prores_test)
-{
- auto content = content_factory(TestPaths::private_data() / "dcp-o-matic_test_20250521_p3d65.mov")[0];
- auto film = new_test_film("encode_xyz_from_prores_test", { content });
- content->video->unset_colour_conversion();
+using std::string;
- make_and_verify_dcp(film);
- check_one_frame(film->dir(film->dcp_name()), 0, TestPaths::private_data() / "dcp-o-matic_test_20250521_p3d65_frame0.j2c", 18);
+BOOST_AUTO_TEST_CASE(encode_xyz_from_prores_test)
+{
+ auto const name = string{"encode_xyz_from_prores_test"};
+
+ auto prores_content = content_factory(TestPaths::private_data() / "3042" / "dcp-o-matic_test_20250521.mov")[0];
+ auto prores_source = new_test_film(name + "_prores");
+ auto prores_film = new_test_film("encode_xyz_from_prores_test", { prores_content });
+ prores_film->set_dcp_content_type(DCPContentType::from_isdcf_name("FTR"));
+ prores_film->set_container(Ratio::from_id("239"));
+ prores_content->video->unset_colour_conversion();
+ make_and_verify_dcp(
+ prores_film,
+ {
+ dcp::VerificationNote::Code::MISSING_FFMC_IN_FEATURE,
+ dcp::VerificationNote::Code::MISSING_FFEC_IN_FEATURE
+ });
+
+ auto tiff_content = content_factory(TestPaths::private_data() / "3042" / "tiff")[0];
+ auto tiff_source = new_test_film(name + "_tiff");
+ auto tiff_film = new_test_film("encode_xyz_from_tiff_test", { tiff_content });
+ tiff_film->set_dcp_content_type(DCPContentType::from_isdcf_name("FTR"));
+ tiff_film->set_container(Ratio::from_id("239"));
+ tiff_content->video->unset_colour_conversion();
+ make_and_verify_dcp(
+ tiff_film,
+ {
+ dcp::VerificationNote::Code::MISSING_FFMC_IN_FEATURE,
+ dcp::VerificationNote::Code::MISSING_FFEC_IN_FEATURE
+ });
+
+ check_one_frame_against_dcp(tiff_film->dir(tiff_film->dcp_name()), 0, TestPaths::private_data() / "3042" / "dcp-o-matic_testing_from_tiff_20250521", 312, 101);
+ check_one_frame_against_dcp(prores_film->dir(prores_film->dcp_name()), 312, TestPaths::private_data() / "3042" / "dcp-o-matic_testing_from_tiff_20250521", 312, 110);
}
@@ -46,6 +73,6 @@ BOOST_AUTO_TEST_CASE(encode_xyz_from_dpx_test)
make_and_verify_dcp(film);
- check_one_frame(film->dir(film->dcp_name()), 0, TestPaths::private_data() / "count.j2c", 18);
+ check_one_frame_against_j2c(film->dir(film->dcp_name()), 0, TestPaths::private_data() / "count.j2c", 18);
}
diff --git a/test/mpeg2_dcp_test.cc b/test/mpeg2_dcp_test.cc
index 0a4d4512e..77f266784 100644
--- a/test/mpeg2_dcp_test.cc
+++ b/test/mpeg2_dcp_test.cc
@@ -134,7 +134,7 @@ BOOST_AUTO_TEST_CASE(mpeg2_video_bitrate1)
false, false
);
- BOOST_CHECK_CLOSE(mbits_per_second(film), 25.0047, 1e-3);
+ BOOST_CHECK_CLOSE(mbits_per_second(film), 25.0047, 0.001);
#ifdef DCPOMATIC_LINUX
BOOST_CHECK_EQUAL(bitrate_in_header(film), "25.0 Mb/s");
#endif
@@ -155,7 +155,7 @@ BOOST_AUTO_TEST_CASE(mpeg2_video_bitrate2)
false, false
);
- BOOST_CHECK_CLOSE(mbits_per_second(film), 5.02106571, 1e-3);
+ BOOST_CHECK_CLOSE(mbits_per_second(film), 5.01890659, 0.05);
#ifdef DCPOMATIC_LINUX
BOOST_CHECK_EQUAL(bitrate_in_header(film), "5 000 kb/s");
#endif
diff --git a/test/test.cc b/test/test.cc
index fb5f11902..633e2df6a 100644
--- a/test/test.cc
+++ b/test/test.cc
@@ -823,15 +823,20 @@ check_ffmpeg (boost::filesystem::path ref, boost::filesystem::path check, int au
BOOST_REQUIRE_EQUAL (WEXITSTATUS(r), 0);
}
+
+static
+shared_ptr<dcp::OpenJPEGImage>
+get_dcp_frame(boost::filesystem::path dcp_dir, int64_t index)
{
- dcp::DCP dcp (dcp_dir);
- dcp.read ();
+ dcp::DCP dcp(dcp_dir);
+ dcp.read();
auto asset = dynamic_pointer_cast<dcp::MonoJ2KPictureAsset>(dcp.cpls().front()->reels().front()->main_picture()->asset());
- BOOST_REQUIRE (asset);
+ BOOST_REQUIRE(asset);
auto frame = asset->start_read()->get_frame(index);
- dcp::MonoJ2KPictureFrame ref_frame(ref);
+ return frame->xyz_image();
+}
+
- auto image = frame->xyz_image ();
void
check_one_frame_against_j2c(boost::filesystem::path test, int64_t test_index, boost::filesystem::path ref, int tolerance)
{
@@ -858,6 +863,33 @@ check_one_frame_against_j2c(boost::filesystem::path test, int64_t test_index, bo
}
}
+
+void
+check_one_frame_against_dcp(boost::filesystem::path test, int64_t test_index, boost::filesystem::path ref, int64_t ref_index, int tolerance)
+{
+ auto test_image = get_dcp_frame(test, test_index);
+ auto ref_image = get_dcp_frame(ref, ref_index);
+
+ BOOST_REQUIRE_MESSAGE(
+ test_image->size() == ref_image->size(),
+ "Reference is " << ref_image->size().width << "x" << ref_image->size().height
+ << ", test image is " << test_image->size().width << "x" << test_image->size().height);
+
+ int off = 0;
+ for (int y = 0; y < ref_image->size().height; ++y) {
+ for (int x = 0; x < ref_image->size().width; ++x) {
+ auto x_error = std::abs(ref_image->data(0)[off] - test_image->data(0)[off]);
+ BOOST_REQUIRE_MESSAGE(x_error <= tolerance, "x component at " << x << "," << y << " differs by " << x_error);
+ auto y_error = std::abs(ref_image->data(1)[off] - test_image->data(1)[off]);
+ BOOST_REQUIRE_MESSAGE(y_error <= tolerance, "y component at " << x << "," << y << " differs by " << y_error);
+ auto z_error = std::abs(ref_image->data(2)[off] - test_image->data(2)[off]);
+ BOOST_REQUIRE_MESSAGE(z_error <= tolerance, "z component at " << x << "," << y << " differs by " << z_error);
+ ++off;
+ }
+ }
+}
+
+
boost::filesystem::path
dcp_file (shared_ptr<const Film> film, string prefix)
{
diff --git a/test/test.h b/test/test.h
index 2856cc01d..b176c6c2f 100644
--- a/test/test.h
+++ b/test/test.h
@@ -73,6 +73,7 @@ extern boost::filesystem::path test_film_dir (std::string);
extern void write_image (std::shared_ptr<const Image> image, boost::filesystem::path file);
boost::filesystem::path dcp_file (std::shared_ptr<const Film> film, std::string prefix);
void check_one_frame_against_j2c(boost::filesystem::path test, int64_t test_index, boost::filesystem::path ref, int tolerance = 0);
+void check_one_frame_against_dcp(boost::filesystem::path test, int64_t test_index, boost::filesystem::path ref, int64_t ref_index, int tolerance = 0);
extern boost::filesystem::path subtitle_file (std::shared_ptr<Film> film);
extern void make_random_file (boost::filesystem::path path, size_t size);
extern void verify_dcp(boost::filesystem::path dir, std::vector<dcp::VerificationNote::Code> ignore);