diff options
| author | Carl Hetherington <cth@carlh.net> | 2020-05-10 01:57:20 +0200 |
|---|---|---|
| committer | Carl Hetherington <cth@carlh.net> | 2020-05-11 22:02:49 +0200 |
| commit | 15a83d720780d58f905d40f8493cdcb86596eaee (patch) | |
| tree | 96edb81d905bed4231819efc5bd6292aefaf2c4c /test | |
| parent | dd7c63112eda87f2e491261873075acff114396b (diff) | |
Change video content scaling so that it either:
1. scales the content up to fit the DCP container,
preserving aspect ratio, or
2. stretches the content to a custom aspect ratio, or
3. scales the content to some custom size.
Diffstat (limited to 'test')
| -rw-r--r-- | test/4k_test.cc | 2 | ||||
| -rw-r--r-- | test/create_cli_test.cc | 37 | ||||
| m--------- | test/data | 0 | ||||
| -rw-r--r-- | test/empty_test.cc | 6 | ||||
| -rw-r--r-- | test/ffmpeg_audio_test.cc | 2 | ||||
| -rw-r--r-- | test/ffmpeg_dcp_test.cc | 2 | ||||
| -rw-r--r-- | test/isdcf_name_test.cc | 8 | ||||
| -rw-r--r-- | test/player_test.cc | 4 | ||||
| -rw-r--r-- | test/recover_test.cc | 6 | ||||
| -rw-r--r-- | test/repeat_frame_test.cc | 4 | ||||
| -rw-r--r-- | test/scaling_test.cc | 16 | ||||
| -rw-r--r-- | test/skip_frame_test.cc | 1 | ||||
| -rw-r--r-- | test/threed_test.cc | 2 | ||||
| -rw-r--r-- | test/video_content_scale_test.cc | 282 |
14 files changed, 144 insertions, 228 deletions
diff --git a/test/4k_test.cc b/test/4k_test.cc index 71d60f573..d8d3d66ec 100644 --- a/test/4k_test.cc +++ b/test/4k_test.cc @@ -50,8 +50,6 @@ BOOST_AUTO_TEST_CASE (fourk_test) film->examine_and_add_content (c); BOOST_REQUIRE (!wait_for_jobs()); - c->video->set_scale (VideoContentScale (Ratio::from_id ("185"))); - film->make_dcp (); BOOST_REQUIRE (!wait_for_jobs()); diff --git a/test/create_cli_test.cc b/test/create_cli_test.cc index b92cb284b..5425969b6 100644 --- a/test/create_cli_test.cc +++ b/test/create_cli_test.cc @@ -70,60 +70,53 @@ BOOST_AUTO_TEST_CASE (create_cli_test) cc = run ("dcpomatic2_create -h"); BOOST_REQUIRE (cc.error); - cc = run ("dcpomatic2_create x --content-ratio 185 --name frobozz --template bar"); + cc = run ("dcpomatic2_create x --name frobozz --template bar"); BOOST_CHECK (!cc.error); BOOST_CHECK_EQUAL (cc.name, "frobozz"); BOOST_REQUIRE (cc.template_name); BOOST_CHECK_EQUAL (*cc.template_name, "bar"); - cc = run ("dcpomatic2_create x --content-ratio 185 --dcp-content-type FTR"); + cc = run ("dcpomatic2_create x --dcp-content-type FTR"); BOOST_CHECK (!cc.error); BOOST_CHECK_EQUAL (cc.dcp_content_type, DCPContentType::from_isdcf_name("FTR")); - cc = run ("dcpomatic2_create x --content-ratio 185 --dcp-frame-rate 30"); + cc = run ("dcpomatic2_create x --dcp-frame-rate 30"); BOOST_CHECK (!cc.error); BOOST_REQUIRE (cc.dcp_frame_rate); BOOST_CHECK_EQUAL (*cc.dcp_frame_rate, 30); - cc = run ("dcpomatic2_create x --content-ratio 185 --container-ratio 185"); + cc = run ("dcpomatic2_create x --container-ratio 185"); BOOST_CHECK (!cc.error); BOOST_CHECK_EQUAL (cc.container_ratio, Ratio::from_id("185")); - cc = run ("dcpomatic2_create x --content-ratio 185 --container-ratio XXX"); + cc = run ("dcpomatic2_create x --container-ratio XXX"); BOOST_CHECK (cc.error); - cc = run ("dcpomatic2_create x --content-ratio 185 --content-ratio 239"); - BOOST_CHECK (!cc.error); - BOOST_CHECK_EQUAL (cc.content_ratio, Ratio::from_id("239")); - - cc = run ("dcpomatic2_create x --content-ratio 240"); - BOOST_CHECK (cc.error); - - cc = run ("dcpomatic2_create x --content-ratio 185 --still-length 42"); + cc = run ("dcpomatic2_create x --still-length 42"); BOOST_CHECK (!cc.error); BOOST_CHECK_EQUAL (cc.still_length, 42); - cc = run ("dcpomatic2_create x --content-ratio 185 --standard SMPTE"); + cc = run ("dcpomatic2_create x --standard SMPTE"); BOOST_CHECK (!cc.error); BOOST_CHECK_EQUAL (cc.standard, dcp::SMPTE); - cc = run ("dcpomatic2_create x --content-ratio 185 --standard SMPTEX"); + cc = run ("dcpomatic2_create x --standard SMPTEX"); BOOST_CHECK (cc.error); - cc = run ("dcpomatic2_create x --content-ratio 185 --config foo/bar"); + cc = run ("dcpomatic2_create x --config foo/bar"); BOOST_CHECK (!cc.error); BOOST_REQUIRE (cc.config_dir); BOOST_CHECK_EQUAL (*cc.config_dir, "foo/bar"); - cc = run ("dcpomatic2_create x --content-ratio 185 --output fred/jim"); + cc = run ("dcpomatic2_create x --output fred/jim"); BOOST_CHECK (!cc.error); BOOST_REQUIRE (cc.output_dir); BOOST_CHECK_EQUAL (*cc.output_dir, "fred/jim"); - cc = run ("dcpomatic2_create x --content-ratio 185 --outputX fred/jim"); + cc = run ("dcpomatic2_create x --outputX fred/jim"); BOOST_CHECK (cc.error); - cc = run ("dcpomatic2_create --content-ratio 185 --config foo/bar --still-length 42 --output flaps fred jim sheila"); + cc = run ("dcpomatic2_create --config foo/bar --still-length 42 --output flaps fred jim sheila"); BOOST_CHECK (!cc.error); BOOST_REQUIRE (cc.config_dir); BOOST_CHECK_EQUAL (*cc.config_dir, "foo/bar"); @@ -138,7 +131,7 @@ BOOST_AUTO_TEST_CASE (create_cli_test) BOOST_CHECK_EQUAL (cc.content[2].path, "sheila"); BOOST_CHECK_EQUAL (cc.content[2].frame_type, VIDEO_FRAME_TYPE_2D); - cc = run ("dcpomatic2_create --content-ratio 185 --left-eye left.mp4 --right-eye right.mp4"); + cc = run ("dcpomatic2_create --left-eye left.mp4 --right-eye right.mp4"); BOOST_REQUIRE_EQUAL (cc.content.size(), 2); BOOST_CHECK_EQUAL (cc.content[0].path, "left.mp4"); BOOST_CHECK_EQUAL (cc.content[0].frame_type, VIDEO_FRAME_TYPE_3D_LEFT); @@ -146,13 +139,13 @@ BOOST_AUTO_TEST_CASE (create_cli_test) BOOST_CHECK_EQUAL (cc.content[1].frame_type, VIDEO_FRAME_TYPE_3D_RIGHT); BOOST_CHECK_EQUAL (cc.fourk, false); - cc = run ("dcpomatic2_create --fourk --content-ratio 185 foo.mp4"); + cc = run ("dcpomatic2_create --fourk foo.mp4"); BOOST_REQUIRE_EQUAL (cc.content.size(), 1); BOOST_CHECK_EQUAL (cc.content[0].path, "foo.mp4"); BOOST_CHECK_EQUAL (cc.fourk, true); BOOST_CHECK (!cc.error); - cc = run ("dcpomatic2_create --j2k-bandwidth 120 --content-ratio 185 foo.mp4"); + cc = run ("dcpomatic2_create --j2k-bandwidth 120 foo.mp4"); BOOST_REQUIRE_EQUAL (cc.content.size(), 1); BOOST_CHECK_EQUAL (cc.content[0].path, "foo.mp4"); BOOST_REQUIRE (cc.j2k_bandwidth); diff --git a/test/data b/test/data -Subproject 6b694889479064979b52c1839a1919dc5fde673 +Subproject 9ec245b7f59b65ad6dd6d0f717686931ff66d74 diff --git a/test/empty_test.cc b/test/empty_test.cc index 029e83966..a2557d4d8 100644 --- a/test/empty_test.cc +++ b/test/empty_test.cc @@ -55,10 +55,8 @@ BOOST_AUTO_TEST_CASE (empty_test1) /* 0 1 2 3 4 5 6 7 * A A A B */ - contentA->video->set_scale (VideoContentScale (Ratio::from_id ("185"))); contentA->video->set_length (3); contentA->set_position (film, DCPTime::from_frames (2, vfr)); - contentB->video->set_scale (VideoContentScale (Ratio::from_id ("185"))); contentB->video->set_length (1); contentB->set_position (film, DCPTime::from_frames (7, vfr)); @@ -89,10 +87,8 @@ BOOST_AUTO_TEST_CASE (empty_test2) /* 0 1 2 3 4 5 6 7 * A A A B */ - contentA->video->set_scale (VideoContentScale (Ratio::from_id ("185"))); contentA->video->set_length (3); contentA->set_position (film, DCPTime(0)); - contentB->video->set_scale (VideoContentScale (Ratio::from_id ("185"))); contentB->video->set_length (1); contentB->set_position (film, DCPTime::from_frames(7, vfr)); @@ -129,10 +125,8 @@ BOOST_AUTO_TEST_CASE (empty_test3) /* 0 1 2 3 4 5 6 7 * A A A B */ - contentA->video->set_scale (VideoContentScale (Ratio::from_id ("185"))); contentA->video->set_length (3); contentA->set_position (film, DCPTime(0)); - contentB->video->set_scale (VideoContentScale (Ratio::from_id ("185"))); contentB->video->set_length (1); contentB->set_position (film, DCPTime::from_frames(7, vfr)); diff --git a/test/ffmpeg_audio_test.cc b/test/ffmpeg_audio_test.cc index 6ad6c1fdb..e9b0c7039 100644 --- a/test/ffmpeg_audio_test.cc +++ b/test/ffmpeg_audio_test.cc @@ -53,8 +53,6 @@ BOOST_AUTO_TEST_CASE (ffmpeg_audio_test) BOOST_REQUIRE (!wait_for_jobs()); - c->video->set_scale (VideoContentScale (Ratio::from_id ("185"))); - film->set_container (Ratio::from_id ("185")); film->set_audio_channels (6); film->set_dcp_content_type (DCPContentType::from_isdcf_name ("TST")); diff --git a/test/ffmpeg_dcp_test.cc b/test/ffmpeg_dcp_test.cc index 78847e40b..ad09e5e1a 100644 --- a/test/ffmpeg_dcp_test.cc +++ b/test/ffmpeg_dcp_test.cc @@ -46,8 +46,6 @@ BOOST_AUTO_TEST_CASE (ffmpeg_dcp_test) BOOST_REQUIRE (!wait_for_jobs()); - c->video->set_scale (VideoContentScale (Ratio::from_id ("185"))); - film->set_container (Ratio::from_id ("185")); film->set_dcp_content_type (DCPContentType::from_isdcf_name ("TST")); film->make_dcp (); diff --git a/test/isdcf_name_test.cc b/test/isdcf_name_test.cc index 3315833b0..487f80ea2 100644 --- a/test/isdcf_name_test.cc +++ b/test/isdcf_name_test.cc @@ -97,7 +97,7 @@ BOOST_AUTO_TEST_CASE (isdcf_name_test) shared_ptr<ImageContent> content (new ImageContent ("test/data/simple_testcard_640x480.png")); film->examine_and_add_content (content); BOOST_REQUIRE (!wait_for_jobs()); - content->video->set_scale (VideoContentScale (Ratio::from_id ("133"))); + content->video->set_custom_ratio (1.33); film->set_container (Ratio::from_id ("185")); BOOST_CHECK_EQUAL (film->isdcf_name(false), "MyNiceFilmWith_TLR-2_F_DE-fr_US-R_MOS_4K_DI_20140704_PP_SMPTE_OV"); @@ -108,12 +108,12 @@ BOOST_AUTO_TEST_CASE (isdcf_name_test) /* And it should always be numeric */ - content->video->set_scale (VideoContentScale (Ratio::from_id ("239"))); + content->video->set_custom_ratio (2.39); BOOST_CHECK_EQUAL (film->isdcf_name(false), "MyNiceFilmWith_XSN-2_F-239_DE-fr_US-R_MOS_4K_DI_20140704_PP_SMPTE_OV"); - content->video->set_scale (VideoContentScale (Ratio::from_id ("190"))); + content->video->set_custom_ratio (1.9); BOOST_CHECK_EQUAL (film->isdcf_name(false), "MyNiceFilmWith_XSN-2_F-190_DE-fr_US-R_MOS_4K_DI_20140704_PP_SMPTE_OV"); - content->video->set_scale (VideoContentScale (Ratio::from_id ("133"))); + content->video->set_custom_ratio (1.33); /* Test 3D */ diff --git a/test/player_test.cc b/test/player_test.cc index 6877d7e21..2e979eb44 100644 --- a/test/player_test.cc +++ b/test/player_test.cc @@ -103,12 +103,12 @@ BOOST_AUTO_TEST_CASE (player_black_fill_test) film->examine_and_add_content (contentB); BOOST_REQUIRE (!wait_for_jobs()); - contentA->video->set_scale (VideoContentScale (Ratio::from_id ("185"))); contentA->video->set_length (3); contentA->set_position (film, DCPTime::from_frames(2, film->video_frame_rate())); - contentB->video->set_scale (VideoContentScale (Ratio::from_id ("185"))); + contentA->video->set_custom_ratio (1.85); contentB->video->set_length (1); contentB->set_position (film, DCPTime::from_frames(7, film->video_frame_rate())); + contentB->video->set_custom_ratio (1.85); film->make_dcp (); diff --git a/test/recover_test.cc b/test/recover_test.cc index e8194fd81..9c1ed7e66 100644 --- a/test/recover_test.cc +++ b/test/recover_test.cc @@ -62,7 +62,7 @@ BOOST_AUTO_TEST_CASE (recover_test_2d) film->make_dcp (); BOOST_REQUIRE (!wait_for_jobs()); - boost::filesystem::path const video = "build/test/recover_test_2d/video/185_2K_d4343facdd66ca71f62a964fbade89f3_24_100000000_P_S_0_1200000.mxf"; + boost::filesystem::path const video = "build/test/recover_test_2d/video/185_2K_02543352c540f4b083bff3f1e309d4a9_24_100000000_P_S_0_1200000.mxf"; boost::filesystem::copy_file ( video, "build/test/recover_test_2d/original.mxf" @@ -97,7 +97,7 @@ BOOST_AUTO_TEST_CASE (recover_test_3d, * boost::unit_test::depends_on("recover_t film->make_dcp (); BOOST_REQUIRE (!wait_for_jobs()); - boost::filesystem::path const video = "build/test/recover_test_3d/video/185_2K_342fe9115d2b446914b31f7602e48cc6_24_100000000_P_S_3D_0_96000.mxf"; + boost::filesystem::path const video = "build/test/recover_test_3d/video/185_2K_70e6661af92ae94458784c16a21a9748_24_100000000_P_S_3D_0_96000.mxf"; boost::filesystem::copy_file ( video, @@ -135,7 +135,7 @@ BOOST_AUTO_TEST_CASE (recover_test_2d_encrypted, * boost::unit_test::depends_on( BOOST_REQUIRE (!wait_for_jobs()); boost::filesystem::path const video = - "build/test/recover_test_2d_encrypted/video/185_2K_d4343facdd66ca71f62a964fbade89f3_24_100000000_Eeafcb91c9f5472edf01f3a2404c57258_S_0_1200000.mxf"; + "build/test/recover_test_2d_encrypted/video/185_2K_02543352c540f4b083bff3f1e309d4a9_24_100000000_Eeafcb91c9f5472edf01f3a2404c57258_S_0_1200000.mxf"; boost::filesystem::copy_file ( video, diff --git a/test/repeat_frame_test.cc b/test/repeat_frame_test.cc index 1075f96fc..358e6fe8f 100644 --- a/test/repeat_frame_test.cc +++ b/test/repeat_frame_test.cc @@ -45,10 +45,8 @@ BOOST_AUTO_TEST_CASE (repeat_frame_test) film->set_interop (false); shared_ptr<FFmpegContent> c (new FFmpegContent("test/data/red_24.mp4")); film->examine_and_add_content (c); - BOOST_REQUIRE (!wait_for_jobs()); - - c->video->set_scale (VideoContentScale (Ratio::from_id ("185"))); + c->video->set_custom_ratio (1.85); film->set_video_frame_rate (48); film->make_dcp (); diff --git a/test/scaling_test.cc b/test/scaling_test.cc index 93c994741..dd3b6118e 100644 --- a/test/scaling_test.cc +++ b/test/scaling_test.cc @@ -34,9 +34,9 @@ using std::string; using boost::shared_ptr; -static void scaling_test_for (shared_ptr<Film> film, shared_ptr<Content> content, string image, string container) +static void scaling_test_for (shared_ptr<Film> film, shared_ptr<Content> content, float ratio, std::string image, string container) { - content->video->set_scale (VideoContentScale (Ratio::from_id (image))); + content->video->set_custom_ratio (ratio); film->set_container (Ratio::from_id (container)); film->set_interop (false); film->make_dcp (); @@ -71,16 +71,16 @@ BOOST_AUTO_TEST_CASE (scaling_test) imc->video->set_length (1); /* F-133: 133 image in a flat container */ - scaling_test_for (film, imc, "133", "185"); + scaling_test_for (film, imc, 4.0 / 3, "133", "185"); /* F: flat image in a flat container */ - scaling_test_for (film, imc, "185", "185"); + scaling_test_for (film, imc, 1.85, "185", "185"); /* F-S: scope image in a flat container */ - scaling_test_for (film, imc, "239", "185"); + scaling_test_for (film, imc, 2.38695, "239", "185"); /* S-133: 133 image in a scope container */ - scaling_test_for (film, imc, "133", "239"); + scaling_test_for (film, imc, 4.0 / 3, "133", "239"); /* S-F: flat image in a scope container */ - scaling_test_for (film, imc, "185", "239"); + scaling_test_for (film, imc, 1.85, "185", "239"); /* S: scope image in a scope container */ - scaling_test_for (film, imc, "239", "239"); + scaling_test_for (film, imc, 2.38695, "239", "239"); } diff --git a/test/skip_frame_test.cc b/test/skip_frame_test.cc index e30143b18..aea389ce3 100644 --- a/test/skip_frame_test.cc +++ b/test/skip_frame_test.cc @@ -48,7 +48,6 @@ BOOST_AUTO_TEST_CASE (skip_frame_test) BOOST_REQUIRE (!wait_for_jobs()); - c->video->set_scale (VideoContentScale (Ratio::from_id ("185"))); film->write_metadata (); film->set_video_frame_rate (24); diff --git a/test/threed_test.cc b/test/threed_test.cc index 473cc00d3..266b7bf58 100644 --- a/test/threed_test.cc +++ b/test/threed_test.cc @@ -49,7 +49,6 @@ BOOST_AUTO_TEST_CASE (threed_test1) BOOST_REQUIRE (!wait_for_jobs()); c->video->set_frame_type (VIDEO_FRAME_TYPE_3D_LEFT_RIGHT); - c->video->set_scale (VideoContentScale (Ratio::from_id ("185"))); film->set_container (Ratio::from_id ("185")); film->set_dcp_content_type (DCPContentType::from_isdcf_name ("TST")); @@ -72,7 +71,6 @@ BOOST_AUTO_TEST_CASE (threed_test2) BOOST_REQUIRE (!wait_for_jobs()); c->video->set_frame_type (VIDEO_FRAME_TYPE_3D_ALTERNATE); - c->video->set_scale (VideoContentScale (Ratio::from_id ("185"))); film->set_container (Ratio::from_id ("185")); film->set_dcp_content_type (DCPContentType::from_isdcf_name ("TST")); diff --git a/test/video_content_scale_test.cc b/test/video_content_scale_test.cc index 67bfda3e5..b3e3ff76c 100644 --- a/test/video_content_scale_test.cc +++ b/test/video_content_scale_test.cc @@ -1,5 +1,5 @@ /* - Copyright (C) 2015 Carl Hetherington <cth@carlh.net> + Copyright (C) 2020 Carl Hetherington <cth@carlh.net> This file is part of DCP-o-matic. @@ -18,188 +18,128 @@ */ -/** @file test/video_content_scale_test.cc - * @brief Test VideoContentScale - * @ingroup selfcontained - */ -#include "lib/ffmpeg_content.h" #include "lib/ratio.h" #include "lib/video_content.h" -#include <dcp/raw_convert.h> #include <boost/test/unit_test.hpp> -using std::list; -using std::string; -using std::cerr; -using boost::shared_ptr; -using boost::optional; -using dcp::raw_convert; -static -void -test (dcp::Size content_size, dcp::Size display_size, dcp::Size film_size, Crop crop, Ratio const * ratio, bool scale, dcp::Size correct) -{ - shared_ptr<Film> film; - string s = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>" - "<Content>" - "<Type>FFmpeg</Type>" - "<Path>/home/c.hetherington/DCP/prophet_long_clip.mkv</Path>" - "<Digest>f3f23663da5bef6d2cbaa0db066f3351314142710</Digest>" - "<Position>0</Position>" - "<TrimStart>0</TrimStart>" - "<TrimEnd>0</TrimEnd>" - "<VideoLength>2879</VideoLength>" - "<VideoWidth>" + raw_convert<string>(content_size.width) + "</VideoWidth>" - "<VideoHeight>" + raw_convert<string>(content_size.height) + "</VideoHeight>" - "<VideoFrameRate>23.97602462768555</VideoFrameRate>" - "<OriginalVideoFrameRate>23.97602462768555</OriginalVideoFrameRate>" - "<VideoFrameType>0</VideoFrameType>" - "<SampleAspectRatio>1</SampleAspectRatio>" - "<BitsPerPixel>12</BitsPerPixel>" - "<LeftCrop>" + raw_convert<string>(crop.left) + "</LeftCrop>" - "<RightCrop>" + raw_convert<string>(crop.right) + "</RightCrop>" - "<TopCrop>" + raw_convert<string>(crop.top) + "</TopCrop>" - "<BottomCrop>" + raw_convert<string>(crop.bottom) + "</BottomCrop>" - "<Scale>"; - - if (ratio) { - s += "<Ratio>" + ratio->id() + "</Ratio>"; - } else { - s += "<Scale>" + string(scale ? "1" : "0") + "</Scale>"; - } +static dcp::Size const FOUR_TO_THREE(1436, 1080); +static dcp::Size const FLAT(1998, 1080); +static dcp::Size const SCOPE(2048, 858); - s += "</Scale>" - "<ColourConversion>" - "<InputGamma>2.4</InputGamma>" - "<InputGammaLinearised>1</InputGammaLinearised>" - "<Matrix i=\"0\" j=\"0\">0.4124564</Matrix>" - "<Matrix i=\"0\" j=\"1\">0.3575761</Matrix>" - "<Matrix i=\"0\" j=\"2\">0.1804375</Matrix>" - "<Matrix i=\"1\" j=\"0\">0.2126729</Matrix>" - "<Matrix i=\"1\" j=\"1\">0.7151522</Matrix>" - "<Matrix i=\"1\" j=\"2\">0.072175</Matrix>" - "<Matrix i=\"2\" j=\"0\">0.0193339</Matrix>" - "<Matrix i=\"2\" j=\"1\">0.119192</Matrix>" - "<Matrix i=\"2\" j=\"2\">0.9503041</Matrix>" - "<OutputGamma>2.6</OutputGamma>" - "</ColourConversion>" - "<AudioGain>0</AudioGain>" - "<AudioDelay>0</AudioDelay>" - "<SubtitleXOffset>0</SubtitleXOffset>" - "<SubtitleYOffset>0</SubtitleYOffset>" - "<SubtitleXScale>0</SubtitleXScale>" - "<SubtitleYScale>0</SubtitleYScale>" - "</Content>"; - - shared_ptr<cxml::Document> doc (new cxml::Document ()); - doc->read_string (s); - - list<string> notes; - shared_ptr<FFmpegContent> vc (new FFmpegContent (doc, 10, notes)); - - optional<VideoContentScale> sc; - if (ratio) { - sc = VideoContentScale (ratio); - } else { - sc = VideoContentScale (scale); - } - dcp::Size answer = sc.get().size (vc->video, display_size, film_size); - if (answer != correct) { - cerr << "Testing " << vc->video->size().width << "x" << vc->video->size().height << "\n"; - cerr << "Testing " << display_size.width << "x" << display_size.height << "\n"; - cerr << answer.width << "x" << answer.height << " instead of " << correct.width << "x" << correct.height << "\n"; - } - BOOST_CHECK (answer == correct); +/* Test VideoContent::scaled_size() without any legacy stuff */ +BOOST_AUTO_TEST_CASE (scaled_size_test1) +{ + VideoContent vc (0); + + /* Images at full size and in DCP-approved sizes that will not be scaled */ + // Flat/scope content into flat/scope container + vc._size = FLAT; + BOOST_CHECK_EQUAL (vc.scaled_size(FLAT), FLAT); + vc._size = SCOPE; + BOOST_CHECK_EQUAL (vc.scaled_size(SCOPE), SCOPE); + // 1.33:1 into flat container + vc._size = FOUR_TO_THREE; + BOOST_CHECK_EQUAL (vc.scaled_size(FLAT), dcp::Size(FOUR_TO_THREE)); + // Scope into flat container + vc._size = SCOPE; + BOOST_CHECK_EQUAL (vc.scaled_size(FLAT), dcp::Size(1998, 837)); + + /* Smaller images but in the same ratios */ + vc._size = dcp::Size(185, 100); + BOOST_CHECK_EQUAL (vc.scaled_size(FLAT), FLAT); + vc._size = dcp::Size(955, 400); + BOOST_CHECK_EQUAL (vc.scaled_size(SCOPE), SCOPE); + // 1.33:1 into flat container + vc._size = dcp::Size(133, 100); + BOOST_CHECK_EQUAL (vc.scaled_size(FLAT), dcp::Size(FOUR_TO_THREE)); + // Scope into flat container + vc._size = dcp::Size(239, 100); + BOOST_CHECK_EQUAL (vc.scaled_size(FLAT), dcp::Size(1998, 836)); + + /* Images at full size that are not DCP-approved but will still remain unscaled */ + vc._size = dcp::Size(600, 1080); + BOOST_CHECK_EQUAL (vc.scaled_size(FLAT), dcp::Size(600, 1080)); + vc._size = dcp::Size(1700, 1080); + BOOST_CHECK_EQUAL (vc.scaled_size(FLAT), dcp::Size(1700, 1080)); + + /* Image at full size that is too big for the container and will be shrunk */ + vc._size = dcp::Size(3000, 1080); + BOOST_CHECK_EQUAL (vc.scaled_size(FLAT), dcp::Size(1998, 719)); } -/* Test scale and stretch to specified ratio */ -BOOST_AUTO_TEST_CASE (video_content_scale_test_to_ratio) + +/* Same as scaled_size_test1 but with a non-unity sample aspect ratio */ +BOOST_AUTO_TEST_CASE (scaled_size_test2) { - /* To DCP */ - - // Flat in flat container - test ( - dcp::Size (400, 200), - dcp::Size (1998, 1080), - dcp::Size (1998, 1080), - Crop (0, 0, 0, 0), - Ratio::from_id ("185"), - true, - dcp::Size (1998, 1080) - ); - - // Scope in flat container - test ( - dcp::Size (400, 200), - dcp::Size (1998, 1080), - dcp::Size (1998, 1080), - Crop (0, 0, 0, 0), - Ratio::from_id ("239"), - true, - dcp::Size (1998, 837) - ); - - // Flat in scope container - test ( - dcp::Size (400, 200), - dcp::Size (2048, 858), - dcp::Size (2048, 858), - Crop (0, 0, 0, 0), - Ratio::from_id ("185"), - true, - dcp::Size (1587, 858) - ); - - - /* To player */ - - // Flat in flat container - test ( - dcp::Size (400, 200), - dcp::Size (185, 100), - dcp::Size (1998, 1080), - Crop (0, 0, 0, 0), - Ratio::from_id ("185"), - true, - dcp::Size (185, 100) - ); - - // Scope in flat container - test ( - dcp::Size (400, 200), - dcp::Size (185, 100), - dcp::Size (1998, 1080), - Crop (0, 0, 0, 0), - Ratio::from_id ("239"), - true, - dcp::Size (185, 78) - ); - - // Flat in scope container - test ( - dcp::Size (400, 200), - dcp::Size (239, 100), - dcp::Size (2048, 858), - Crop (0, 0, 0, 0), - Ratio::from_id ("185"), - true, - dcp::Size (185, 100) - ); + VideoContent vc (0); + + vc._sample_aspect_ratio = 2; + + /* Images at full size and in DCP-approved sizes that will not be scaled */ + // Flat/scope content into flat/scope container + vc._size = dcp::Size (1998 / 2, 1080); + BOOST_CHECK_EQUAL (vc.scaled_size(FLAT), FLAT); + vc._size = dcp::Size (2048 / 2, 858); + BOOST_CHECK_EQUAL (vc.scaled_size(SCOPE), SCOPE); + // 1.33:1 into flat container + vc._size = dcp::Size (1436 / 2, 1080); + BOOST_CHECK_EQUAL (vc.scaled_size(FLAT), dcp::Size(FOUR_TO_THREE)); + // Scope into flat container + vc._size = dcp::Size (2048 / 2, 858); + BOOST_CHECK_EQUAL (vc.scaled_size(FLAT), dcp::Size(1998, 837)); + + /* Smaller images but in the same ratios */ + vc._size = dcp::Size(185, 200); + BOOST_CHECK_EQUAL (vc.scaled_size(FLAT), FLAT); + vc._size = dcp::Size(955, 800); + BOOST_CHECK_EQUAL (vc.scaled_size(SCOPE), SCOPE); + // 4:3 into flat container + vc._size = dcp::Size(133, 200); + BOOST_CHECK_EQUAL (vc.scaled_size(FLAT), dcp::Size(FOUR_TO_THREE)); + // Scope into flat container + vc._size = dcp::Size(239, 200); + BOOST_CHECK_EQUAL (vc.scaled_size(FLAT), dcp::Size(1998, 836)); + + /* Images at full size that are not DCP-approved but will still remain unscaled */ + vc._size = dcp::Size(600 / 2, 1080); + BOOST_CHECK_EQUAL (vc.scaled_size(FLAT), dcp::Size(600, 1080)); + vc._size = dcp::Size(1700 / 2, 1080); + BOOST_CHECK_EQUAL (vc.scaled_size(FLAT), dcp::Size(1700, 1080)); + + /* Image at full size that is too big for the container and will be shrunk */ + vc._size = dcp::Size(3000 / 2, 1080); + BOOST_CHECK_EQUAL (vc.scaled_size(FLAT), dcp::Size(1998, 719)); } -/* Test no scale */ -BOOST_AUTO_TEST_CASE (video_content_scale_no_scale) + +/* Test VideoContent::scaled_size() with some legacy stuff */ +BOOST_AUTO_TEST_CASE (scaled_size_legacy_test) { - /* No scale where the content is bigger than even the film container */ - test ( - dcp::Size (1920, 1080), - dcp::Size (887, 371), - dcp::Size (2048, 858), - Crop (), - 0, - false, - dcp::Size (659, 371) - ); + { + /* 640x480 content that the user had asked to be stretched to 1.85:1 */ + VideoContent vc (0); + vc._size = dcp::Size(640, 480); + vc._legacy_ratio = Ratio::from_id("185")->ratio(); + BOOST_CHECK_EQUAL (vc.scaled_size(FLAT), FLAT); + } + + { + /* 640x480 content that the user had asked to be scaled to fit the container, without stretch */ + VideoContent vc (0); + vc._size = dcp::Size(640, 480); + vc._legacy_ratio = 1.33; + BOOST_CHECK_EQUAL (vc.scaled_size(FLAT), FOUR_TO_THREE); + } + + { + /* 640x480 content that the user had asked to be kept the same size */ + VideoContent vc (0); + vc._size = dcp::Size(640, 480); + vc._custom_size = dcp::Size(640, 480); + BOOST_CHECK_EQUAL (vc.scaled_size(FLAT), dcp::Size(640, 480)); + } } + |
