2 Copyright (C) 2024 Carl Hetherington <cth@carlh.net>
4 This file is part of DCP-o-matic.
6 DCP-o-matic is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2 of the License, or
9 (at your option) any later version.
11 DCP-o-matic is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
16 You should have received a copy of the GNU General Public License
17 along with DCP-o-matic. If not, see <http://www.gnu.org/licenses/>.
22 #include "lib/content_factory.h"
24 #include "lib/video_content.h"
26 #include <dcp/colour_conversion.h>
29 #include <dcp/mono_picture_asset_reader.h>
31 #include <dcp/reel_mono_picture_asset.h>
32 #include <boost/test/unit_test.hpp>
35 using std::dynamic_pointer_cast;
36 using std::shared_ptr;
41 BOOST_AUTO_TEST_CASE(remake_video_after_yub_rgb_matrix_changed)
43 auto content = content_factory("test/data/rgb_grey_testcard.mp4")[0];
44 auto film = new_test_film2("remake_video_after_yub_rgb_matrix_changed", { content });
46 auto conversion = content->video->colour_conversion();
47 BOOST_REQUIRE(static_cast<bool>(conversion));
48 conversion->set_yuv_to_rgb(dcp::YUVToRGB::REC709);
49 content->video->set_colour_conversion(*conversion);
51 auto calculate_picture_hashes = [](shared_ptr<Film> film) {
52 /* >1 CPLs in the DCP raises an error in ClairMeta */
53 make_and_verify_dcp(film, {}, true, false);
54 dcp::DCP dcp(film->dir(film->dcp_name()));
56 BOOST_REQUIRE(!dcp.cpls().empty());
57 auto cpl = dcp.cpls()[0];
58 BOOST_REQUIRE(!cpl->reels().empty());
59 auto reel = cpl->reels()[0];
60 BOOST_REQUIRE(reel->main_picture());
61 auto mono = dynamic_pointer_cast<dcp::MonoPictureAsset>(reel->main_picture()->asset());
63 auto reader = mono->start_read();
65 vector<string> hashes;
66 for (auto i = 0; i < reel->main_picture()->intrinsic_duration(); ++i) {
67 auto frame = reader->get_frame(i);
68 hashes.push_back(dcp::make_digest(dcp::ArrayData(frame->data(), frame->size())));
73 auto before = calculate_picture_hashes(film);
74 conversion->set_yuv_to_rgb(dcp::YUVToRGB::REC601);
75 content->video->set_colour_conversion(*conversion);
76 auto after = calculate_picture_hashes(film);
78 BOOST_CHECK(before != after);