X-Git-Url: https://main.carlh.net/gitweb/?a=blobdiff_plain;f=test%2Ftest.cc;h=2dac199fe316f62aa9115e5cfb683e0a27eb5ee3;hb=2cb2078282c8b799d7a0d0016e1518f1a4b55af1;hp=a64725401ed030a16a6eae9920ef29ba7ca07f9e;hpb=8bc480da2db924349465dbe557f87bd6f05b7fdd;p=libdcp.git diff --git a/test/test.cc b/test/test.cc index a6472540..2dac199f 100644 --- a/test/test.cc +++ b/test/test.cc @@ -37,6 +37,7 @@ #include "cpl.h" #include "dcp.h" #include "interop_subtitle_asset.h" +#include "file.h" #include "j2k_transcode.h" #include "mono_picture_asset.h" #include "mono_picture_asset.h" @@ -210,25 +211,25 @@ check_file (boost::filesystem::path ref, boost::filesystem::path check) { uintmax_t size = boost::filesystem::file_size (ref); BOOST_CHECK_EQUAL (size, boost::filesystem::file_size(check)); - auto ref_file = dcp::fopen_boost (ref, "rb"); + dcp::File ref_file(ref, "rb"); BOOST_REQUIRE (ref_file); - auto check_file = dcp::fopen_boost (check, "rb"); + dcp::File check_file(check, "rb"); BOOST_REQUIRE (check_file); int const buffer_size = 65536; - auto ref_buffer = new uint8_t[buffer_size]; - auto check_buffer = new uint8_t[buffer_size]; + std::vector ref_buffer(buffer_size); + std::vector check_buffer(buffer_size); uintmax_t pos = 0; while (pos < size) { uintmax_t this_time = min (uintmax_t(buffer_size), size - pos); - size_t r = fread (ref_buffer, 1, this_time, ref_file); + size_t r = ref_file.read(ref_buffer.data(), 1, this_time); BOOST_CHECK_EQUAL (r, this_time); - r = fread (check_buffer, 1, this_time, check_file); + r = check_file.read(check_buffer.data(), 1, this_time); BOOST_CHECK_EQUAL (r, this_time); - if (memcmp(ref_buffer, check_buffer, this_time) != 0) { + if (memcmp(ref_buffer.data(), check_buffer.data(), this_time) != 0) { for (int i = 0; i < buffer_size; ++i) { if (ref_buffer[i] != check_buffer[i]) { BOOST_CHECK_MESSAGE ( @@ -243,12 +244,6 @@ check_file (boost::filesystem::path ref, boost::filesystem::path check) pos += this_time; } - - delete[] ref_buffer; - delete[] check_buffer; - - fclose (ref_file); - fclose (check_file); } @@ -278,7 +273,7 @@ simple_picture (boost::filesystem::path path, string suffix, int frames, optiona if (key) { mp->set_key (*key); } - auto picture_writer = mp->start_write (path / dcp::String::compose("video%1.mxf", suffix), false); + auto picture_writer = mp->start_write(path / dcp::String::compose("video%1.mxf", suffix), dcp::PictureAsset::Behaviour::MAKE_NEW); dcp::Size const size (1998, 1080); auto image = make_shared(size); @@ -297,10 +292,8 @@ simple_picture (boost::filesystem::path path, string suffix, int frames, optiona shared_ptr -simple_sound (boost::filesystem::path path, string suffix, dcp::MXFMetadata mxf_meta, string language, int frames, int sample_rate, optional key) +simple_sound(boost::filesystem::path path, string suffix, dcp::MXFMetadata mxf_meta, string language, int frames, int sample_rate, optional key, int channels) { - int const channels = 6; - /* Set a valid language, then overwrite it, so that the language parameter can be badly formed */ auto ms = make_shared(dcp::Fraction(24, 1), sample_rate, channels, dcp::LanguageTag("en-US"), dcp::Standard::SMPTE); if (key) { @@ -308,7 +301,7 @@ simple_sound (boost::filesystem::path path, string suffix, dcp::MXFMetadata mxf_ } ms->_language = language; ms->set_metadata (mxf_meta); - shared_ptr sound_writer = ms->start_write (path / dcp::String::compose("audio%1.mxf", suffix)); + auto sound_writer = ms->start_write(path / dcp::String::compose("audio%1.mxf", suffix), {}, dcp::SoundAsset::AtmosSync::DISABLED, dcp::SoundAsset::MCASubDescriptors::ENABLED); int const samples_per_frame = sample_rate / 24; @@ -319,7 +312,7 @@ simple_sound (boost::filesystem::path path, string suffix, dcp::MXFMetadata mxf_ } for (auto i = 0; i < frames; ++i) { - sound_writer->write (silence, samples_per_frame); + sound_writer->write(silence, channels, samples_per_frame); } sound_writer->finalize (); @@ -354,7 +347,7 @@ make_simple (boost::filesystem::path path, int reels, int frames, dcp::Standard cpl->set_content_version ( dcp::ContentVersion("urn:uuid:75ac29aa-42ac-1234-ecae-49251abefd11", "content-version-label-text") ); - cpl->set_main_sound_configuration("51/L,R,C,LFE,Ls,Rs"); + cpl->set_main_sound_configuration(dcp::MainSoundConfiguration("51/L,R,C,LFE,Ls,Rs")); cpl->set_main_sound_sample_rate(sample_rate); cpl->set_main_picture_stored_area(dcp::Size(1998, 1080)); cpl->set_main_picture_active_area(dcp::Size(1998, 1080)); @@ -371,7 +364,7 @@ make_simple (boost::filesystem::path path, int reels, int frames, dcp::Standard shared_ptr(new dcp::ReelSoundAsset(ms, 0)) ); - auto markers = make_shared(dcp::Fraction(24, 1), frames, 0); + auto markers = make_shared(dcp::Fraction(24, 1), frames); if (i == 0) { markers->set (dcp::Marker::FFOC, dcp::Time(0, 0, 0, 1, 24)); } @@ -391,7 +384,7 @@ make_simple (boost::filesystem::path path, int reels, int frames, dcp::Standard shared_ptr simple_subtitle () { - return make_shared( + return std::make_shared( optional(), false, false, @@ -405,6 +398,7 @@ simple_subtitle () dcp::HAlign::CENTER, 0.8, dcp::VAlign::TOP, + 0, dcp::Direction::LTR, "Hello world", dcp::Effect::NONE, @@ -419,7 +413,7 @@ simple_subtitle () shared_ptr simple_markers (int frames) { - auto markers = make_shared(dcp::Fraction(24, 1), frames, 0); + auto markers = make_shared(dcp::Fraction(24, 1), frames); markers->set (dcp::Marker::FFOC, dcp::Time(1, 24, 24)); markers->set (dcp::Marker::LFOC, dcp::Time(frames - 1, 24, 24)); return markers; @@ -436,6 +430,7 @@ make_simple_with_interop_subs (boost::filesystem::path path) boost::filesystem::create_directory (path / "subs"); dcp::ArrayData data(4096); + memset(data.data(), 0, data.size()); subs->add_font ("afont", data); subs->write (path / "subs" / "subs.xml"); @@ -521,7 +516,7 @@ black_picture_asset (boost::filesystem::path dir, int frames) auto asset = make_shared(dcp::Fraction(24, 1), dcp::Standard::SMPTE); asset->set_metadata (dcp::MXFMetadata("libdcp", "libdcp", "1.6.4devel")); boost::filesystem::create_directories (dir); - auto writer = asset->start_write (dir / "pic.mxf", true); + auto writer = asset->start_write(dir / "pic.mxf", dcp::PictureAsset::Behaviour::MAKE_NEW); for (int i = 0; i < frames; ++i) { writer->write (frame.data(), frame.size()); }