diff options
| author | Carl Hetherington <cth@carlh.net> | 2015-05-27 20:55:51 +0100 |
|---|---|---|
| committer | Carl Hetherington <cth@carlh.net> | 2015-06-02 13:38:21 +0100 |
| commit | 0a93237cb5e4642d3b698ff9b7d0cfae5401478c (patch) | |
| tree | b0d5255ae2b90d1c9ef489e78239c2f081ea0a9e /test | |
| parent | 608c146eb09fac2a8fc60e1a72591f6bb8364e1f (diff) | |
Handle multiple audio streams in a single piece of content
in a similar way to the V1 patch.
Diffstat (limited to 'test')
| -rw-r--r-- | test/audio_decoder_test.cc | 65 | ||||
| -rw-r--r-- | test/audio_delay_test.cc | 4 | ||||
| -rw-r--r-- | test/ffmpeg_audio_test.cc | 2 | ||||
| -rw-r--r-- | test/ffmpeg_decoder_seek_test.cc | 6 | ||||
| -rw-r--r-- | test/ffmpeg_decoder_sequential_test.cc | 12 | ||||
| -rw-r--r-- | test/ffmpeg_pts_offset_test.cc | 12 | ||||
| -rw-r--r-- | test/frame_rate_test.cc | 22 | ||||
| -rw-r--r-- | test/seek_zero_test.cc | 2 | ||||
| -rw-r--r-- | test/upmixer_a_test.cc | 3 |
9 files changed, 58 insertions, 70 deletions
diff --git a/test/audio_decoder_test.cc b/test/audio_decoder_test.cc index 3753ca379..880e3d6b6 100644 --- a/test/audio_decoder_test.cc +++ b/test/audio_decoder_test.cc @@ -25,50 +25,34 @@ #include <boost/test/unit_test.hpp> #include "test.h" #include "lib/audio_decoder.h" -#include "lib/audio_content.h" +#include "lib/single_stream_audio_content.h" using std::string; using std::cout; using std::min; using boost::shared_ptr; -class TestAudioContent : public AudioContent +class TestAudioContent : public SingleStreamAudioContent { public: - TestAudioContent (shared_ptr<Film> film) + TestAudioContent (shared_ptr<const Film> film) : Content (film) - , AudioContent (film, DCPTime ()) - {} - - string summary () const { - return ""; + , SingleStreamAudioContent (film) + { + _audio_stream.reset (new AudioStream (48000, 2)); } - string information () const { + std::string summary () const { return ""; } DCPTime full_length () const { - return DCPTime::from_seconds (float (audio_length()) / audio_frame_rate ()); + return DCPTime::from_seconds (float (audio_length()) / audio_stream()->frame_rate ()); } - - int audio_channels () const { - return 2; - } - + Frame audio_length () const { - return rint (61.2942 * audio_frame_rate ()); - } - - int audio_frame_rate () const { - return 48000; + return rint (61.2942 * audio_stream()->frame_rate ()); } - - AudioMapping audio_mapping () const { - return AudioMapping (audio_channels ()); - } - - void set_audio_mapping (AudioMapping) {} }; class TestAudioDecoder : public AudioDecoder @@ -87,14 +71,14 @@ public: _test_audio_content->audio_length() - _position ); - shared_ptr<AudioBuffers> buffers (new AudioBuffers (_audio_content->audio_channels(), N)); - for (int i = 0; i < _audio_content->audio_channels(); ++i) { + shared_ptr<AudioBuffers> buffers (new AudioBuffers (_test_audio_content->audio_stream()->channels(), N)); + for (int i = 0; i < _test_audio_content->audio_stream()->channels(); ++i) { for (int j = 0; j < N; ++j) { buffers->data(i)[j] = j + _position; } } - audio (buffers, ContentTime::from_frames (_position, _audio_content->resampled_audio_frame_rate ())); + audio (_test_audio_content->audio_stream(), buffers, ContentTime::from_frames (_position, 48000)); _position += N; return N < 2000; @@ -103,7 +87,7 @@ public: void seek (ContentTime t, bool accurate) { AudioDecoder::seek (t, accurate); - _position = t.frames (_audio_content->resampled_audio_frame_rate ()); + _position = t.frames (_test_audio_content->resampled_audio_frame_rate ()); } private: @@ -114,23 +98,22 @@ private: shared_ptr<TestAudioContent> content; shared_ptr<TestAudioDecoder> decoder; -static shared_ptr<ContentAudio> +static ContentAudio get (Frame from, Frame length) { decoder->seek (ContentTime::from_frames (from, content->resampled_audio_frame_rate ()), true); - shared_ptr<ContentAudio> ca = decoder->get_audio (from, length, true); - BOOST_CHECK_EQUAL (ca->frame, from); + ContentAudio ca = decoder->get_audio (content->audio_stream(), from, length, true); + BOOST_CHECK_EQUAL (ca.frame, from); return ca; } static void check (Frame from, Frame length) { - shared_ptr<ContentAudio> ca = get (from, length); - for (int i = 0; i < content->audio_channels(); ++i) { + ContentAudio ca = get (from, length); + for (int i = 0; i < content->audio_stream()->channels(); ++i) { for (int j = 0; j < length; ++j) { - BOOST_CHECK_EQUAL (ca->audio->data(i)[j], j + from); - assert (ca->audio->data(i)[j] == j + from); + BOOST_REQUIRE_EQUAL (ca.audio->data(i)[j], j + from); } } } @@ -152,11 +135,11 @@ BOOST_AUTO_TEST_CASE (audio_decoder_get_audio_test) Frame const from = content->resampled_audio_frame_rate() * 61; Frame const length = content->resampled_audio_frame_rate() * 4; - shared_ptr<ContentAudio> ca = get (from, length); + ContentAudio ca = get (from, length); - for (int i = 0; i < content->audio_channels(); ++i) { - for (int j = 0; j < ca->audio->frames(); ++j) { - BOOST_REQUIRE_EQUAL (ca->audio->data(i)[j], j + from); + for (int i = 0; i < content->audio_stream()->channels(); ++i) { + for (int j = 0; j < ca.audio->frames(); ++j) { + BOOST_REQUIRE_EQUAL (ca.audio->data(i)[j], j + from); } } } diff --git a/test/audio_delay_test.cc b/test/audio_delay_test.cc index 68e14ff3c..63f363114 100644 --- a/test/audio_delay_test.cc +++ b/test/audio_delay_test.cc @@ -43,6 +43,8 @@ using boost::shared_ptr; static void test_audio_delay (int delay_in_ms) { + BOOST_TEST_MESSAGE ("Testing delay of " << delay_in_ms); + string const film_name = "audio_delay_test_" + lexical_cast<string> (delay_in_ms); shared_ptr<Film> film = new_test_film (film_name); film->set_dcp_content_type (DCPContentType::from_isdcf_name ("FTR")); @@ -87,7 +89,7 @@ void test_audio_delay (int delay_in_ms) delayed = 0; } - BOOST_CHECK_EQUAL (sample, delayed); + BOOST_REQUIRE_EQUAL (sample, delayed); ++n; } } diff --git a/test/ffmpeg_audio_test.cc b/test/ffmpeg_audio_test.cc index 444b0869b..1e2bbb377 100644 --- a/test/ffmpeg_audio_test.cc +++ b/test/ffmpeg_audio_test.cc @@ -1,5 +1,5 @@ /* - Copyright (C) 2013-2014 Carl Hetherington <cth@carlh.net> + Copyright (C) 2013-2015 Carl Hetherington <cth@carlh.net> This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/test/ffmpeg_decoder_seek_test.cc b/test/ffmpeg_decoder_seek_test.cc index f3504ffc5..c15bf8c98 100644 --- a/test/ffmpeg_decoder_seek_test.cc +++ b/test/ffmpeg_decoder_seek_test.cc @@ -41,10 +41,10 @@ using boost::shared_ptr; using boost::optional; static void -check (FFmpegDecoder& decoder, int frame) +check (shared_ptr<FFmpegDecoder> decoder, int frame) { list<ContentVideo> v; - v = decoder.get_video (frame, true); + v = decoder->get_video (frame, true); BOOST_CHECK (v.size() == 1); BOOST_CHECK_EQUAL (v.front().frame, frame); } @@ -63,7 +63,7 @@ test (boost::filesystem::path file, vector<int> frames) film->examine_and_add_content (content); wait_for_jobs (); shared_ptr<Log> log (new NullLog); - FFmpegDecoder decoder (content, log); + shared_ptr<FFmpegDecoder> decoder (new FFmpegDecoder (content, log)); for (vector<int>::const_iterator i = frames.begin(); i != frames.end(); ++i) { check (decoder, *i); diff --git a/test/ffmpeg_decoder_sequential_test.cc b/test/ffmpeg_decoder_sequential_test.cc index 6b02efcb5..b4f37dd0b 100644 --- a/test/ffmpeg_decoder_sequential_test.cc +++ b/test/ffmpeg_decoder_sequential_test.cc @@ -50,22 +50,22 @@ test (boost::filesystem::path file, float fps, int gaps) film->examine_and_add_content (content); wait_for_jobs (); shared_ptr<Log> log (new NullLog); - FFmpegDecoder decoder (content, log); + shared_ptr<FFmpegDecoder> decoder (new FFmpegDecoder (content, log)); - BOOST_CHECK_CLOSE (decoder.video_content()->video_frame_rate(), fps, 0.01); + BOOST_CHECK_CLOSE (decoder->video_content()->video_frame_rate(), fps, 0.01); - Frame const N = decoder.video_content()->video_length(); + Frame const N = decoder->video_content()->video_length(); #ifdef DCPOMATIC_DEBUG - decoder.test_gaps = 0; + decoder->test_gaps = 0; #endif for (Frame i = 0; i < N; ++i) { list<ContentVideo> v; - v = decoder.get_video (i, true); + v = decoder->get_video (i, true); BOOST_CHECK_EQUAL (v.size(), 1); BOOST_CHECK_EQUAL (v.front().frame, i); } #ifdef DCPOMATIC_DEBUG - BOOST_CHECK_EQUAL (decoder.test_gaps, gaps); + BOOST_CHECK_EQUAL (decoder->test_gaps, gaps); #endif } diff --git a/test/ffmpeg_pts_offset_test.cc b/test/ffmpeg_pts_offset_test.cc index 94e7223ab..0ded56431 100644 --- a/test/ffmpeg_pts_offset_test.cc +++ b/test/ffmpeg_pts_offset_test.cc @@ -34,13 +34,13 @@ BOOST_AUTO_TEST_CASE (ffmpeg_pts_offset_test) { shared_ptr<Film> film = new_test_film ("ffmpeg_pts_offset_test"); shared_ptr<FFmpegContent> content (new FFmpegContent (film, "test/data/test.mp4")); - content->_audio_stream.reset (new FFmpegAudioStream); + content->_audio_streams.push_back (shared_ptr<FFmpegAudioStream> (new FFmpegAudioStream)); content->_video_frame_rate = 24; { /* Sound == video so no offset required */ content->_first_video = ContentTime (); - content->_audio_stream->first_audio = ContentTime (); + content->_audio_streams.front()->first_audio = ContentTime (); FFmpegDecoder decoder (content, film->log()); BOOST_CHECK_EQUAL (decoder._pts_offset, ContentTime ()); } @@ -48,7 +48,7 @@ BOOST_AUTO_TEST_CASE (ffmpeg_pts_offset_test) { /* Common offset should be removed */ content->_first_video = ContentTime::from_seconds (600); - content->_audio_stream->first_audio = ContentTime::from_seconds (600); + content->_audio_streams.front()->first_audio = ContentTime::from_seconds (600); FFmpegDecoder decoder (content, film->log()); BOOST_CHECK_EQUAL (decoder._pts_offset, ContentTime::from_seconds (-600)); } @@ -56,7 +56,7 @@ BOOST_AUTO_TEST_CASE (ffmpeg_pts_offset_test) { /* Video is on a frame boundary */ content->_first_video = ContentTime::from_frames (1, 24); - content->_audio_stream->first_audio = ContentTime (); + content->_audio_streams.front()->first_audio = ContentTime (); FFmpegDecoder decoder (content, film->log()); BOOST_CHECK_EQUAL (decoder._pts_offset, ContentTime ()); } @@ -65,7 +65,7 @@ BOOST_AUTO_TEST_CASE (ffmpeg_pts_offset_test) /* Video is off a frame boundary */ double const frame = 1.0 / 24.0; content->_first_video = ContentTime::from_seconds (frame + 0.0215); - content->_audio_stream->first_audio = ContentTime (); + content->_audio_streams.front()->first_audio = ContentTime (); FFmpegDecoder decoder (content, film->log()); BOOST_CHECK_CLOSE (decoder._pts_offset.seconds(), (frame - 0.0215), 0.00001); } @@ -74,7 +74,7 @@ BOOST_AUTO_TEST_CASE (ffmpeg_pts_offset_test) /* Video is off a frame boundary and both have a common offset */ double const frame = 1.0 / 24.0; content->_first_video = ContentTime::from_seconds (frame + 0.0215 + 4.1); - content->_audio_stream->first_audio = ContentTime::from_seconds (4.1); + content->_audio_streams.front()->first_audio = ContentTime::from_seconds (4.1); FFmpegDecoder decoder (content, film->log()); BOOST_CHECK_CLOSE (decoder._pts_offset.seconds(), (frame - 0.0215) - 4.1, 0.1); } diff --git a/test/frame_rate_test.cc b/test/frame_rate_test.cc index e8ebcea3b..39a64504d 100644 --- a/test/frame_rate_test.cc +++ b/test/frame_rate_test.cc @@ -1,5 +1,5 @@ /* - Copyright (C) 2012-2014 Carl Hetherington <cth@carlh.net> + Copyright (C) 2012-2015 Carl Hetherington <cth@carlh.net> This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -237,7 +237,6 @@ BOOST_AUTO_TEST_CASE (best_dcp_frame_rate_test_double) BOOST_CHECK_EQUAL (film->playlist()->best_dcp_frame_rate(), 25); } - BOOST_AUTO_TEST_CASE (audio_sampling_rate_test) { shared_ptr<Film> film = new_test_film ("audio_sampling_rate_test"); @@ -252,46 +251,47 @@ BOOST_AUTO_TEST_CASE (audio_sampling_rate_test) afr.push_back (30); Config::instance()->set_allowed_dcp_frame_rates (afr); + shared_ptr<FFmpegAudioStream> stream (new FFmpegAudioStream ("foo", 0, 0, 0)); + content->_audio_streams.push_back (stream); content->_video_frame_rate = 24; film->set_video_frame_rate (24); - content->set_audio_stream (shared_ptr<FFmpegAudioStream> (new FFmpegAudioStream ("a", 42, 48000, 0))); + stream->_frame_rate = 48000; BOOST_CHECK_EQUAL (content->resampled_audio_frame_rate(), 48000); - content->set_audio_stream (shared_ptr<FFmpegAudioStream> (new FFmpegAudioStream ("a", 42, 44100, 0))); + stream->_frame_rate = 44100; BOOST_CHECK_EQUAL (content->resampled_audio_frame_rate(), 48000); - content->set_audio_stream (shared_ptr<FFmpegAudioStream> (new FFmpegAudioStream ("a", 42, 80000, 0))); + stream->_frame_rate = 80000; BOOST_CHECK_EQUAL (content->resampled_audio_frame_rate(), 96000); content->_video_frame_rate = 23.976; film->set_video_frame_rate (24); - content->set_audio_stream (shared_ptr<FFmpegAudioStream> (new FFmpegAudioStream ("a", 42, 48000, 0))); + stream->_frame_rate = 48000; BOOST_CHECK_EQUAL (content->resampled_audio_frame_rate(), 47952); content->_video_frame_rate = 29.97; film->set_video_frame_rate (30); BOOST_CHECK_EQUAL (film->video_frame_rate (), 30); - content->set_audio_stream (shared_ptr<FFmpegAudioStream> (new FFmpegAudioStream ("a", 42, 48000, 0))); + stream->_frame_rate = 48000; BOOST_CHECK_EQUAL (content->resampled_audio_frame_rate(), 47952); content->_video_frame_rate = 25; film->set_video_frame_rate (24); - content->set_audio_stream (shared_ptr<FFmpegAudioStream> (new FFmpegAudioStream ("a", 42, 48000, 0))); + stream->_frame_rate = 48000; BOOST_CHECK_EQUAL (content->resampled_audio_frame_rate(), 50000); content->_video_frame_rate = 25; film->set_video_frame_rate (24); - content->set_audio_stream (shared_ptr<FFmpegAudioStream> (new FFmpegAudioStream ("a", 42, 44100, 0))); + stream->_frame_rate = 44100; BOOST_CHECK_EQUAL (content->resampled_audio_frame_rate(), 50000); /* Check some out-there conversions (not the best) */ content->_video_frame_rate = 14.99; film->set_video_frame_rate (25); - content->set_audio_stream (shared_ptr<FFmpegAudioStream> (new FFmpegAudioStream ("a", 42, 16000, 0))); + stream->_frame_rate = 16000; /* The FrameRateChange within resampled_audio_frame_rate should choose to double-up the 14.99 fps video to 30 and then run it slow at 25. */ BOOST_CHECK_EQUAL (content->resampled_audio_frame_rate(), rint (48000 * 2 * 14.99 / 25)); } - diff --git a/test/seek_zero_test.cc b/test/seek_zero_test.cc index f00180c89..3aef11373 100644 --- a/test/seek_zero_test.cc +++ b/test/seek_zero_test.cc @@ -52,7 +52,7 @@ BOOST_AUTO_TEST_CASE (seek_zero_test) /* Work out the first video frame index that we will be given, taking into account * the difference between first video and first audio. */ - ContentTime video_delay = content->first_video().get() - content->audio_stream()->first_audio.get(); + ContentTime video_delay = content->first_video().get() - content->ffmpeg_audio_streams().front()->first_audio.get(); if (video_delay < ContentTime ()) { video_delay = ContentTime (); } diff --git a/test/upmixer_a_test.cc b/test/upmixer_a_test.cc index 9bcbf3a69..5192809ab 100644 --- a/test/upmixer_a_test.cc +++ b/test/upmixer_a_test.cc @@ -30,6 +30,8 @@ using boost::shared_ptr; +#if 0 +/* XXX: no audio processors in content any more */ BOOST_AUTO_TEST_CASE (upmixer_a_test) { shared_ptr<Film> film = new_test_film ("upmixer_a_test"); @@ -78,3 +80,4 @@ BOOST_AUTO_TEST_CASE (upmixer_a_test) check_audio_file ("test/data/upmixer_a_test/Ls.wav", "build/test/upmixer_a_test/Ls.wav"); check_audio_file ("test/data/upmixer_a_test/Rs.wav", "build/test/upmixer_a_test/Rs.wav"); } +#endif |
