diff options
| author | Carl Hetherington <cth@carlh.net> | 2017-03-02 11:21:47 +0000 |
|---|---|---|
| committer | Carl Hetherington <cth@carlh.net> | 2017-04-19 23:04:32 +0100 |
| commit | 3449bc0a6d6e77e851240a0953363f5a07ec6517 (patch) | |
| tree | 22896494bfb065afc1bc1e40dd9c8e57738363c0 /test | |
| parent | 05e2f7d954b20c6103bf31ee64cd4b81b28cc2ea (diff) | |
Add some more bits to the torture test.
Diffstat (limited to 'test')
| -rw-r--r-- | test/torture_test.cc | 99 |
1 files changed, 99 insertions, 0 deletions
diff --git a/test/torture_test.cc b/test/torture_test.cc index 7c2d42aa1..b941a5ade 100644 --- a/test/torture_test.cc +++ b/test/torture_test.cc @@ -27,15 +27,21 @@ #include "lib/dcp_content_type.h" #include "lib/ratio.h" #include "lib/content_factory.h" +#include "lib/video_content.h" #include "test.h" #include <dcp/cpl.h> #include <dcp/reel.h> #include <dcp/reel_sound_asset.h> +#include <dcp/reel_picture_asset.h> #include <dcp/sound_asset.h> +#include <dcp/mono_picture_asset.h> +#include <dcp/mono_picture_frame.h> +#include <dcp/openjpeg_image.h> #include <boost/test/unit_test.hpp> using std::list; using boost::shared_ptr; +using boost::dynamic_pointer_cast; /** Test start/end trim and positioning of some audio content */ BOOST_AUTO_TEST_CASE (torture_test1) @@ -64,6 +70,13 @@ BOOST_AUTO_TEST_CASE (torture_test1) staircase->set_trim_end (ContentTime::from_frames (35, 48000)); staircase->audio->set_gain (20 * log10(2)); + /* 1s of red at 5s in */ + shared_ptr<Content> red = content_factory(film, "test/data/flat_red.png").front (); + film->examine_and_add_content (red); + wait_for_jobs (); + red->set_position (DCPTime::from_seconds (5)); + red->video->set_length (24); + film->set_video_frame_rate (24); film->write_metadata (); film->make_dcp (); @@ -77,10 +90,13 @@ BOOST_AUTO_TEST_CASE (torture_test1) list<shared_ptr<dcp::Reel> > reels = cpls.front()->reels (); BOOST_REQUIRE_EQUAL (reels.size(), 1); + /* Check sound */ + shared_ptr<dcp::ReelSoundAsset> reel_sound = reels.front()->main_sound(); BOOST_REQUIRE (reel_sound); shared_ptr<dcp::SoundAsset> sound = reel_sound->asset(); BOOST_REQUIRE (sound); + BOOST_CHECK_EQUAL (sound->intrinsic_duration(), 144); shared_ptr<dcp::SoundAssetReader> sound_reader = sound->start_read (); @@ -146,6 +162,7 @@ BOOST_AUTO_TEST_CASE (torture_test1) } /* Then the same thing again */ + stair = 12; fr = sound_reader->get_frame (25); @@ -183,4 +200,86 @@ BOOST_AUTO_TEST_CASE (torture_test1) } } } + + /* Then some silence */ + + for (int i = 28; i < 144; ++i) { + fr = sound_reader->get_frame (i); + for (int j = 0; j < fr->samples(); ++j) { + for (int k = 0; k < 6; ++k) { + BOOST_CHECK_EQUAL (fr->get(k, j), 0); + } + } + } + + /* Check picture */ + + shared_ptr<dcp::ReelPictureAsset> reel_picture = reels.front()->main_picture(); + BOOST_REQUIRE (reel_picture); + shared_ptr<dcp::MonoPictureAsset> picture = dynamic_pointer_cast<dcp::MonoPictureAsset> (reel_picture->asset()); + BOOST_REQUIRE (picture); + BOOST_CHECK_EQUAL (picture->intrinsic_duration(), 144); + + shared_ptr<dcp::MonoPictureAssetReader> picture_reader = picture->start_read (); + + /* First 5 * 24 = 120 frames should be black */ + + shared_ptr<dcp::OpenJPEGImage> ref; + for (int i = 0; i < 120; ++i) { + shared_ptr<const dcp::MonoPictureFrame> fr = picture_reader->get_frame (i); + shared_ptr<dcp::OpenJPEGImage> image = fr->xyz_image (); + dcp::Size const size = image->size (); + if (i == 0) { + for (int c = 0; c < 3; ++c) { + for (int y = 0; y < size.height; ++y) { + for (int x = 0; x < size.width; ++x) { + BOOST_REQUIRE_EQUAL (image->data(c)[y * size.height + x], 0); + } + } + } + ref = image; + } else { + for (int c = 0; c < 3; ++c) { + BOOST_REQUIRE_MESSAGE ( + memcmp (image->data(c), ref->data(c), size.width * size.height * sizeof(int)) == 0, + "failed on frame " << i << " component " << c + ); + } + } + } + + /* Then 24 red */ + + for (int i = 120; i < 144; ++i) { + shared_ptr<const dcp::MonoPictureFrame> fr = picture_reader->get_frame (i); + shared_ptr<dcp::OpenJPEGImage> image = fr->xyz_image (); + dcp::Size const size = image->size (); + if (i == 120) { + for (int y = 0; y < size.height; ++y) { + for (int x = 0; x < size.width; ++x) { + BOOST_REQUIRE_MESSAGE ( + abs(image->data(0)[y * size.height + x] - 2808) <= 2, + "failed on frame " << i << " with image data " << image->data(0)[y * size.height + x] + ); + BOOST_REQUIRE_MESSAGE ( + abs(image->data(1)[y * size.height + x] - 2176) <= 2, + "failed on frame " << i << " with image data " << image->data(1)[y * size.height + x] + ); + BOOST_REQUIRE_MESSAGE ( + abs(image->data(2)[y * size.height + x] - 865) <= 2, + "failed on frame " << i << " with image data " << image->data(2)[y * size.height + x] + ); + } + } + ref = image; + } else { + for (int c = 0; c < 3; ++c) { + BOOST_REQUIRE_MESSAGE ( + memcmp (image->data(c), ref->data(c), size.width * size.height * sizeof(int)) == 0, + "failed on frame " << i << " component " << c + ); + } + } + } + } |
