summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xrun/tests2
-rw-r--r--src/lib/dcp_video.cc25
-rw-r--r--src/lib/player_video.cc2
-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
7 files changed, 83 insertions, 36 deletions
diff --git a/run/tests b/run/tests
index 18be05718..3324b02ab 100755
--- a/run/tests
+++ b/run/tests
@@ -3,7 +3,7 @@
# e.g. --run_tests=foo
set -e
-PRIVATE_GIT="ddd3a3c138912b4588536c3b0ced7ef816facd12"
+PRIVATE_GIT="5aa4660a36d2aa9c95de8e353b75c9cf29f6b02e"
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"
source $DIR/environment
diff --git a/src/lib/dcp_video.cc b/src/lib/dcp_video.cc
index fdbd5774f..775298091 100644
--- a/src/lib/dcp_video.cc
+++ b/src/lib/dcp_video.cc
@@ -104,12 +104,13 @@ DCPVideo::convert_to_xyz(shared_ptr<const PlayerVideo> frame)
{
shared_ptr<dcp::OpenJPEGImage> xyz;
- if (frame->colour_conversion()) {
- auto conversion = [](AVPixelFormat fmt) {
- return fmt == AV_PIX_FMT_XYZ12LE ? AV_PIX_FMT_XYZ12LE : AV_PIX_FMT_RGB48LE;
- };
+ auto conversion = [](AVPixelFormat fmt) {
+ return fmt == AV_PIX_FMT_XYZ12LE ? AV_PIX_FMT_XYZ12LE : AV_PIX_FMT_RGB48LE;
+ };
+
+ auto image = frame->image(conversion, VideoRange::FULL, false);
- auto image = frame->image(conversion, VideoRange::FULL, false);
+ if (frame->colour_conversion()) {
xyz = dcp::rgb_to_xyz(
image->data()[0],
image->size(),
@@ -117,20 +118,6 @@ DCPVideo::convert_to_xyz(shared_ptr<const PlayerVideo> frame)
frame->colour_conversion().get()
);
} else {
- auto conversion = [](AVPixelFormat fmt) {
- auto const descriptor = av_pix_fmt_desc_get(fmt);
- if (!descriptor) {
- return fmt;
- }
-
- if (descriptor->flags & AV_PIX_FMT_FLAG_RGB) {
- return AV_PIX_FMT_RGB48LE;
- }
-
- return AV_PIX_FMT_XYZ12LE;
- };
-
- auto image = frame->image(conversion, VideoRange::FULL, false);
xyz = make_shared<dcp::OpenJPEGImage>(image->data()[0], image->size(), image->stride()[0]);
}
diff --git a/src/lib/player_video.cc b/src/lib/player_video.cc
index 63811fb69..a3868856b 100644
--- a/src/lib/player_video.cc
+++ b/src/lib/player_video.cc
@@ -177,7 +177,7 @@ PlayerVideo::make_image(function<AVPixelFormat (AVPixelFormat)> pixel_format, Vi
total_crop.bottom /= r;
}
- dcp::YUVToRGB yuv_to_rgb = dcp::YUVToRGB::REC601;
+ dcp::YUVToRGB yuv_to_rgb = dcp::YUVToRGB::REC709;
if (_colour_conversion) {
yuv_to_rgb = _colour_conversion.get().yuv_to_rgb();
}
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);