/*
- Copyright (C) 2020 Carl Hetherington <cth@carlh.net>
+ Copyright (C) 2020-2021 Carl Hetherington <cth@carlh.net>
This file is part of DCP-o-matic.
/** @file test/video_level_test.cc
* @brief Test that video level ranges are handled correctly.
- * @ingroup specific
+ * @ingroup feature
*/
using std::max;
using std::pair;
using std::string;
-using boost::dynamic_pointer_cast;
+using std::dynamic_pointer_cast;
+using std::make_shared;
using boost::optional;
-using boost::shared_ptr;
+#if BOOST_VERSION >= 106100
+using namespace boost::placeholders;
+#endif
+using std::shared_ptr;
static
shared_ptr<Image>
grey_image (dcp::Size size, uint8_t pixel)
{
- shared_ptr<Image> grey(new Image(AV_PIX_FMT_RGB24, size, true));
+ auto grey = make_shared<Image>(AV_PIX_FMT_RGB24, size, true);
for (int y = 0; y < size.height; ++y) {
uint8_t* p = grey->data()[0] + y * grey->stride()[0];
for (int x = 0; x < size.width; ++x) {
write_image (grey_image(size, grey_pixel), file);
- FFmpegImageProxy proxy (file, VIDEO_RANGE_FULL);
+ FFmpegImageProxy proxy (file, VideoRange::FULL);
ImageProxy::Result result = proxy.image ();
BOOST_REQUIRE (!result.error);
write_image (grey_image(size, grey_pixel), file);
- FFmpegImageProxy proxy (file, VIDEO_RANGE_VIDEO);
+ FFmpegImageProxy proxy (file, VideoRange::VIDEO);
ImageProxy::Result result = proxy.image ();
BOOST_REQUIRE (!result.error);
pair<int, int>
pixel_range (shared_ptr<Film> film, shared_ptr<const FFmpegContent> content)
{
- shared_ptr<FFmpegDecoder> decoder(new FFmpegDecoder(film, content, false));
+ auto decoder = make_shared<FFmpegDecoder>(film, content, false);
decoder->video->Data.connect (bind(&video_handler, _1));
content_video = boost::none;
while (!content_video) {
pair<int, int>
pixel_range (shared_ptr<Film> film, shared_ptr<const ImageContent> content)
{
- shared_ptr<ImageDecoder> decoder(new ImageDecoder(film, content));
+ auto decoder = make_shared<ImageDecoder>(film, content);
decoder->video->Data.connect (bind(&video_handler, _1));
content_video = boost::none;
while (!content_video) {
dcp::DCP dcp (dcp_path);
dcp.read ();
- shared_ptr<dcp::MonoPictureAsset> picture = dynamic_pointer_cast<dcp::MonoPictureAsset>(dcp.cpls().front()->reels().front()->main_picture()->asset());
+ auto picture = dynamic_pointer_cast<dcp::MonoPictureAsset>(dcp.cpls().front()->reels().front()->main_picture()->asset());
BOOST_REQUIRE (picture);
- shared_ptr<dcp::OpenJPEGImage> frame = picture->start_read()->get_frame(0)->xyz_image();
+ auto frame = picture->start_read()->get_frame(0)->xyz_image();
int const width = frame->size().width;
int const height = frame->size().height;
shared_ptr<Film>
movie_V (string name)
{
- shared_ptr<Film> film = new_test_film2 (name);
- shared_ptr<FFmpegContent> content = dynamic_pointer_cast<FFmpegContent>(content_factory("test/data/rgb_grey_testcard.mp4").front());
+ auto film = new_test_film2 (name);
+ auto content = dynamic_pointer_cast<FFmpegContent>(content_factory("test/data/rgb_grey_testcard.mp4").front());
BOOST_REQUIRE (content);
film->examine_and_add_content (content);
BOOST_REQUIRE (!wait_for_jobs());
- pair<int, int> range = pixel_range (film, content);
+ auto range = pixel_range (film, content);
BOOST_CHECK_EQUAL (range.first, 15);
BOOST_CHECK_EQUAL (range.second, 243);
shared_ptr<Film>
movie_VoF (string name)
{
- shared_ptr<Film> film = new_test_film2 (name);
- shared_ptr<FFmpegContent> content = dynamic_pointer_cast<FFmpegContent>(content_factory("test/data/rgb_grey_testcard.mp4").front());
+ auto film = new_test_film2 (name);
+ auto content = dynamic_pointer_cast<FFmpegContent>(content_factory("test/data/rgb_grey_testcard.mp4").front());
BOOST_REQUIRE (content);
film->examine_and_add_content (content);
BOOST_REQUIRE (!wait_for_jobs());
- content->video->set_range (VIDEO_RANGE_FULL);
+ content->video->set_range (VideoRange::FULL);
- pair<int, int> range = pixel_range (film, content);
+ auto range = pixel_range (film, content);
BOOST_CHECK_EQUAL (range.first, 15);
BOOST_CHECK_EQUAL (range.second, 243);
shared_ptr<Film>
movie_F (string name)
{
- shared_ptr<Film> film = new_test_film2 (name);
- shared_ptr<FFmpegContent> content = dynamic_pointer_cast<FFmpegContent>(content_factory("test/data/rgb_grey_testcard.mov").front());
+ auto film = new_test_film2 (name);
+ auto content = dynamic_pointer_cast<FFmpegContent>(content_factory("test/data/rgb_grey_testcard.mov").front());
BOOST_REQUIRE (content);
film->examine_and_add_content (content);
BOOST_REQUIRE (!wait_for_jobs());
- pair<int, int> range = pixel_range (film, content);
+ auto range = pixel_range (film, content);
BOOST_CHECK_EQUAL (range.first, 0);
BOOST_CHECK_EQUAL (range.second, 1023);
shared_ptr<Film>
movie_FoV (string name)
{
- shared_ptr<Film> film = new_test_film2 (name);
- shared_ptr<FFmpegContent> content = dynamic_pointer_cast<FFmpegContent>(content_factory("test/data/rgb_grey_testcard.mov").front());
+ auto film = new_test_film2 (name);
+ auto content = dynamic_pointer_cast<FFmpegContent>(content_factory("test/data/rgb_grey_testcard.mov").front());
BOOST_REQUIRE (content);
film->examine_and_add_content (content);
BOOST_REQUIRE (!wait_for_jobs());
- content->video->set_range (VIDEO_RANGE_VIDEO);
+ content->video->set_range (VideoRange::VIDEO);
- pair<int, int> range = pixel_range (film, content);
+ auto range = pixel_range (film, content);
BOOST_CHECK_EQUAL (range.first, 0);
BOOST_CHECK_EQUAL (range.second, 1023);
shared_ptr<Film>
image_F (string name)
{
- shared_ptr<Film> film = new_test_film2 (name);
- shared_ptr<ImageContent> content = dynamic_pointer_cast<ImageContent>(content_factory("test/data/rgb_grey_testcard.png").front());
+ auto film = new_test_film2 (name);
+ auto content = dynamic_pointer_cast<ImageContent>(content_factory("test/data/rgb_grey_testcard.png").front());
BOOST_REQUIRE (content);
film->examine_and_add_content (content);
BOOST_REQUIRE (!wait_for_jobs());
- pair<int, int> range = pixel_range (film, content);
+ auto range = pixel_range (film, content);
BOOST_CHECK_EQUAL (range.first, 0);
BOOST_CHECK_EQUAL (range.second, 255);
shared_ptr<Film>
image_FoV (string name)
{
- shared_ptr<Film> film = new_test_film2 (name);
- shared_ptr<ImageContent> content = dynamic_pointer_cast<ImageContent>(content_factory("test/data/rgb_grey_testcard.png").front());
+ auto film = new_test_film2 (name);
+ auto content = dynamic_pointer_cast<ImageContent>(content_factory("test/data/rgb_grey_testcard.png").front());
BOOST_REQUIRE (content);
film->examine_and_add_content (content);
BOOST_REQUIRE (!wait_for_jobs());
- content->video->set_range (VIDEO_RANGE_VIDEO);
+ content->video->set_range (VideoRange::VIDEO);
- pair<int, int> range = pixel_range (film, content);
+ auto range = pixel_range (film, content);
BOOST_CHECK_EQUAL (range.first, 11);
BOOST_CHECK_EQUAL (range.second, 250);
dcp_F (string name)
{
boost::filesystem::path const dcp = "test/data/RgbGreyTestcar_TST-1_F_MOS_2K_20201115_SMPTE_OV";
- shared_ptr<Film> film = new_test_film2 (name);
- shared_ptr<DCPContent> content(new DCPContent(dcp));
- film->examine_and_add_content (shared_ptr<DCPContent>(new DCPContent(dcp)));
+ auto film = new_test_film2 (name);
+ auto content = make_shared<DCPContent>(dcp);
+ film->examine_and_add_content (content);
BOOST_REQUIRE (!wait_for_jobs());
- pair<int, int> range = pixel_range (dcp);
+ auto range = pixel_range (dcp);
BOOST_CHECK_EQUAL (range.first, 0);
BOOST_CHECK_EQUAL (range.second, 4081);
pair<int, int>
dcp_range (shared_ptr<Film> film)
{
- film->make_dcp ();
- BOOST_REQUIRE (!wait_for_jobs());
+ make_and_verify_dcp (film);
return pixel_range (film->dir(film->dcp_name()));
}
pair<int, int>
V_movie_range (shared_ptr<Film> film)
{
- shared_ptr<TranscodeJob> job (new TranscodeJob(film));
+ auto job = make_shared<TranscodeJob>(film);
job->set_encoder (
- shared_ptr<FFmpegEncoder>(
- new FFmpegEncoder (film, job, film->file("export.mov"), EXPORT_FORMAT_PRORES, true, false, false, 23)
- )
+ make_shared<FFmpegEncoder>(film, job, film->file("export.mov"), ExportFormat::PRORES, true, false, false, 23)
);
JobManager::instance()->add (job);
BOOST_REQUIRE (!wait_for_jobs());
/* This is a bit of a hack; add the exported file into the project so we can decode it */
- shared_ptr<FFmpegContent> content(new FFmpegContent(film->file("export.mov")));
+ auto content = make_shared<FFmpegContent>(film->file("export.mov"));
film->examine_and_add_content (content);
BOOST_REQUIRE (!wait_for_jobs());
BOOST_AUTO_TEST_CASE (movie_V_to_dcp)
{
- pair<int, int> range = dcp_range (movie_V("movie_V_to_dcp"));
+ auto range = dcp_range (movie_V("movie_V_to_dcp"));
/* Video range has been correctly expanded to full for the DCP */
- BOOST_CHECK_EQUAL (range.first, 0);
- BOOST_CHECK_EQUAL (range.second, 4082);
+ check_int_close (range, {0, 4083}, 2);
}
BOOST_AUTO_TEST_CASE (movie_VoF_to_dcp)
{
- pair<int, int> range = dcp_range (movie_VoF("movie_VoF_to_dcp"));
+ auto range = dcp_range (movie_VoF("movie_VoF_to_dcp"));
/* We said that video range data was really full range, so here we are in the DCP
* with video-range data.
*/
- BOOST_CHECK_EQUAL (range.first, 350);
- BOOST_CHECK_EQUAL (range.second, 3832);
+ check_int_close (range, {350, 3832}, 2);
}
BOOST_AUTO_TEST_CASE (movie_F_to_dcp)
{
- pair<int, int> range = dcp_range (movie_F("movie_F_to_dcp"));
+ auto range = dcp_range (movie_F("movie_F_to_dcp"));
/* The nearly-full-range of the input has been preserved */
- BOOST_CHECK_EQUAL (range.first, 0);
- BOOST_CHECK_EQUAL (range.second, 4082);
+ check_int_close (range, {0, 4083}, 2);
}
BOOST_AUTO_TEST_CASE (video_FoV_to_dcp)
{
- pair<int, int> range = dcp_range (movie_FoV("video_FoV_to_dcp"));
+ auto range = dcp_range (movie_FoV("video_FoV_to_dcp"));
/* The nearly-full-range of the input has become even more full, and clipped */
- BOOST_CHECK_EQUAL (range.first, 0);
- BOOST_CHECK_EQUAL (range.second, 4095);
+ check_int_close (range, {0, 4095}, 2);
}
BOOST_AUTO_TEST_CASE (image_F_to_dcp)
{
- pair<int, int> range = dcp_range (image_F("image_F_to_dcp"));
- BOOST_CHECK_EQUAL (range.first, 0);
- BOOST_CHECK_EQUAL (range.second, 4081);
+ auto range = dcp_range (image_F("image_F_to_dcp"));
+ check_int_close (range, {0, 4083}, 3);
}
BOOST_AUTO_TEST_CASE (image_FoV_to_dcp)
{
- pair<int, int> range = dcp_range (image_FoV("image_FoV_to_dcp"));
- BOOST_CHECK_EQUAL (range.first, 431);
- BOOST_CHECK_EQUAL (range.second, 4012);
+ auto range = dcp_range (image_FoV("image_FoV_to_dcp"));
+ check_int_close (range, {430, 4012}, 2);
}
BOOST_AUTO_TEST_CASE (movie_V_to_V_movie)
{
- pair<int, int> range = V_movie_range (movie_V("movie_V_to_V_movie"));
+ auto range = V_movie_range (movie_V("movie_V_to_V_movie"));
BOOST_CHECK_EQUAL (range.first, 60);
BOOST_CHECK_EQUAL (range.second, 998);
}
BOOST_AUTO_TEST_CASE (movie_VoF_to_V_movie)
{
- pair<int, int> range = V_movie_range (movie_VoF("movie_VoF_to_V_movie"));
+ auto range = V_movie_range (movie_VoF("movie_VoF_to_V_movie"));
BOOST_CHECK_EQUAL (range.first, 116);
BOOST_CHECK_EQUAL (range.second, 939);
}
BOOST_AUTO_TEST_CASE (movie_F_to_V_movie)
{
- pair<int, int> range = V_movie_range (movie_F("movie_F_to_V_movie"));
+ auto range = V_movie_range (movie_F("movie_F_to_V_movie"));
BOOST_CHECK_EQUAL (range.first, 4);
BOOST_CHECK_EQUAL (range.second, 1019);
}
BOOST_AUTO_TEST_CASE (movie_FoV_to_V_movie)
{
- pair<int, int> range = V_movie_range (movie_FoV("movie_FoV_to_V_movie"));
+ auto range = V_movie_range (movie_FoV("movie_FoV_to_V_movie"));
BOOST_CHECK_EQUAL (range.first, 4);
BOOST_CHECK_EQUAL (range.second, 1019);
}
BOOST_AUTO_TEST_CASE (image_F_to_V_movie)
{
- pair<int, int> range = V_movie_range (image_F("image_F_to_V_movie"));
+ auto range = V_movie_range (image_F("image_F_to_V_movie"));
BOOST_CHECK_EQUAL (range.first, 64);
BOOST_CHECK_EQUAL (range.second, 960);
}
BOOST_AUTO_TEST_CASE (image_FoV_to_V_movie)
{
- pair<int, int> range = V_movie_range (image_FoV("image_FoV_to_V_movie"));
+ auto range = V_movie_range (image_FoV("image_FoV_to_V_movie"));
BOOST_CHECK_EQUAL (range.first, 102);
BOOST_CHECK_EQUAL (range.second, 923);
}
BOOST_AUTO_TEST_CASE (dcp_F_to_V_movie)
{
- pair<int, int> range = V_movie_range (dcp_F("dcp_F_to_V_movie"));
+ auto range = V_movie_range (dcp_F("dcp_F_to_V_movie"));
BOOST_CHECK_EQUAL (range.first, 64);
BOOST_CHECK_EQUAL (range.second, 944);
}