diff options
| author | Carl Hetherington <cth@carlh.net> | 2016-06-01 23:53:06 +0100 |
|---|---|---|
| committer | Carl Hetherington <cth@carlh.net> | 2016-06-01 23:53:06 +0100 |
| commit | a68b877d96a9e9f366f27752e071bc0e895e9dc7 (patch) | |
| tree | 11a32d1efd6abf182b03ce22f1f1fe84258bb7de /test | |
| parent | f9cba324c8160a70b108d9e5b60a4ccad6ee9be2 (diff) | |
Add Reader classes to permit much more efficient DCP reading.
Diffstat (limited to 'test')
| -rw-r--r-- | test/decryption_test.cc | 4 | ||||
| -rw-r--r-- | test/round_trip_test.cc | 5 | ||||
| -rw-r--r-- | test/sound_frame_test.cc | 29 |
3 files changed, 23 insertions, 15 deletions
diff --git a/test/decryption_test.cc b/test/decryption_test.cc index 2f0bb420..1496a0d5 100644 --- a/test/decryption_test.cc +++ b/test/decryption_test.cc @@ -23,6 +23,7 @@ #include "decrypted_kdm.h" #include "encrypted_kdm.h" #include "mono_picture_asset.h" +#include "mono_picture_asset_reader.h" #include "reel_picture_asset.h" #include "reel.h" #include "test.h" @@ -46,7 +47,8 @@ get_frame (dcp::DCP const & dcp) BOOST_CHECK (picture); shared_ptr<const dcp::MonoPictureAsset> mono_picture = dynamic_pointer_cast<const dcp::MonoPictureAsset> (picture); - shared_ptr<const dcp::MonoPictureFrame> j2k_frame = mono_picture->get_frame (0); + shared_ptr<const dcp::MonoPictureAssetReader> reader = mono_picture->start_read (); + shared_ptr<const dcp::MonoPictureFrame> j2k_frame = reader->get_frame (0); shared_ptr<dcp::OpenJPEGImage> xyz = j2k_frame->xyz_image(); uint8_t* argb = new uint8_t[xyz->size().width * xyz->size().height * 4]; diff --git a/test/round_trip_test.cc b/test/round_trip_test.cc index 45b2cbad..e735a276 100644 --- a/test/round_trip_test.cc +++ b/test/round_trip_test.cc @@ -29,6 +29,7 @@ #include "mono_picture_frame.h" #include "certificate_chain.h" #include "mono_picture_asset_writer.h" +#include "mono_picture_asset_reader.h" #include "reel_picture_asset.h" #include "reel_mono_picture_asset.h" #include "file.h" @@ -107,8 +108,8 @@ BOOST_AUTO_TEST_CASE (round_trip_test) BOOST_CHECK (!kdm_B.keys().empty ()); asset_B->set_key (kdm_B.keys().front().key()); - shared_ptr<dcp::OpenJPEGImage> xyz_A = asset_A->get_frame(0)->xyz_image (); - shared_ptr<dcp::OpenJPEGImage> xyz_B = asset_B->get_frame(0)->xyz_image (); + shared_ptr<dcp::OpenJPEGImage> xyz_A = asset_A->start_read()->get_frame(0)->xyz_image (); + shared_ptr<dcp::OpenJPEGImage> xyz_B = asset_B->start_read()->get_frame(0)->xyz_image (); scoped_array<uint8_t> frame_A (new uint8_t[xyz_A->size().width * xyz_A->size().height * 4]); dcp::xyz_to_rgba (xyz_A, dcp::ColourConversion::srgb_to_xyz(), frame_A.get()); diff --git a/test/sound_frame_test.cc b/test/sound_frame_test.cc index fa7e2103..837cfe32 100644 --- a/test/sound_frame_test.cc +++ b/test/sound_frame_test.cc @@ -20,21 +20,25 @@ #include <boost/test/unit_test.hpp> #include "test.h" #include "sound_frame.h" +#include "sound_asset.h" +#include "sound_asset_reader.h" #include "exceptions.h" #include <sndfile.h> +using boost::shared_ptr; + BOOST_AUTO_TEST_CASE (sound_frame_test) { int const frame_length = 2000; int const channels = 6; - dcp::SoundFrame frame ( - private_test / "TONEPLATES-SMPTE-PLAINTEXT_TST_F_XX-XX_ITL-TD_51-XX_2K_WOE_20111001_WOE_OV/pcm_95734608-5d47-4d3f-bf5f-9e9186b66afa_.mxf", - 42, - 0 + dcp::SoundAsset asset ( + private_test / "TONEPLATES-SMPTE-PLAINTEXT_TST_F_XX-XX_ITL-TD_51-XX_2K_WOE_20111001_WOE_OV/pcm_95734608-5d47-4d3f-bf5f-9e9186b66afa_.mxf" ); - BOOST_REQUIRE_EQUAL (frame.size(), channels * frame_length * 3); + shared_ptr<const dcp::SoundFrame> frame = asset.start_read()->get_frame(42); + + BOOST_REQUIRE_EQUAL (frame->size(), channels * frame_length * 3); boost::filesystem::path ref_file = private_test / "data" / "frame.wav"; SF_INFO info; @@ -46,7 +50,7 @@ BOOST_AUTO_TEST_CASE (sound_frame_test) int const read = sf_readf_int (sndfile, ref_data, frame_length); BOOST_REQUIRE_EQUAL (read, frame_length); - uint8_t const * p = frame.data (); + uint8_t const * p = frame->data (); for (int i = 0; i < (frame_length * channels); ++i) { int x = ref_data[i] >> 8; if (x < 0) { @@ -60,11 +64,12 @@ BOOST_AUTO_TEST_CASE (sound_frame_test) BOOST_AUTO_TEST_CASE (sound_frame_test2) { - BOOST_CHECK_THROW (dcp::SoundFrame ("frobozz", 42, 0), dcp::FileError); - BOOST_CHECK_THROW (dcp::SoundFrame ( - private_test / - "TONEPLATES-SMPTE-PLAINTEXT_TST_F_XX-XX_ITL-TD_51-XX_2K_WOE_20111001_WOE_OV/pcm_95734608-5d47-4d3f-bf5f-9e9186b66afa_.mxf", - 999999999, 0 - ), dcp::DCPReadError + BOOST_CHECK_THROW (dcp::SoundAsset("frobozz"), dcp::FileError); + + dcp::SoundAsset asset ( + private_test / + "TONEPLATES-SMPTE-PLAINTEXT_TST_F_XX-XX_ITL-TD_51-XX_2K_WOE_20111001_WOE_OV/pcm_95734608-5d47-4d3f-bf5f-9e9186b66afa_.mxf" ); + + BOOST_CHECK_THROW (asset.start_read()->get_frame (99999999), dcp::DCPReadError); } |
