+
+BOOST_AUTO_TEST_CASE (ffmpeg_audio_only_test2)
+{
+ /* S32 1 channel */
+ auto film = test ("test/data/sine_440.wav");
+
+ /* Compare the audio data in the DCP with what libsndfile reads */
+
+ SF_INFO info;
+ info.format = 0;
+ ref = sf_open ("test/data/sine_440.wav", SFM_READ, &info);
+ /* We don't want to test anything that requires resampling */
+ BOOST_REQUIRE_EQUAL (info.samplerate, 48000);
+
+ auto buffer = new int32_t[info.channels * 2000];
+
+ dcp::SoundAsset asset (dcp_file(film, "pcm"));
+ auto reader = asset.start_read ();
+ for (int i = 0; i < asset.intrinsic_duration(); ++i) {
+ auto frame = reader->get_frame(i);
+ sf_count_t this_time = min (info.frames, sf_count_t(2000));
+ sf_readf_int (ref, buffer, this_time);
+ for (int j = 0; j < this_time; ++j) {
+ int32_t s = frame->get(2, j);
+ if (s > (1 << 23)) {
+ s -= (1 << 24);
+ }
+ BOOST_REQUIRE_MESSAGE (abs(s - (buffer[j] / 256)) <= 1, "failed on asset frame " << i << " sample " << j);
+ }
+ info.frames -= this_time;
+ }
+
+ delete[] buffer;
+}
+
+
+BOOST_AUTO_TEST_CASE (ffmpeg_audio_only_test3)
+{
+ /* S24 1 channel */
+ auto film = test ("test/data/sine_24_48_440.wav");
+
+ /* Compare the audio data in the DCP with what libsndfile reads */
+
+ SF_INFO info;
+ info.format = 0;
+ ref = sf_open ("test/data/sine_24_48_440.wav", SFM_READ, &info);
+ /* We don't want to test anything that requires resampling */
+ BOOST_REQUIRE_EQUAL (info.samplerate, 48000);
+
+ auto buffer = new int32_t[info.channels * 2000];
+
+ dcp::SoundAsset asset (dcp_file(film, "pcm"));
+ auto reader = asset.start_read ();
+ for (int i = 0; i < asset.intrinsic_duration(); ++i) {
+ auto frame = reader->get_frame(i);
+ sf_count_t this_time = min (info.frames, sf_count_t(2000));
+ sf_readf_int (ref, buffer, this_time);
+ for (int j = 0; j < this_time; ++j) {
+ int32_t s = frame->get(2, j);
+ if (s > (1 << 23)) {
+ s -= (1 << 24);
+ }
+ BOOST_REQUIRE_MESSAGE (abs(s - buffer[j] /256) <= 1, "failed on asset frame " << i << " sample " << j);
+ }
+ info.frames -= this_time;
+ }
+
+ delete[] buffer;
+}