diff options
| author | Carl Hetherington <cth@carlh.net> | 2013-04-14 23:41:57 +0100 |
|---|---|---|
| committer | Carl Hetherington <cth@carlh.net> | 2013-04-14 23:41:57 +0100 |
| commit | 9fcaaf1cc7582598b06f5a43878cbd9aa2b4ff17 (patch) | |
| tree | 2f596a2e2f977d303a10025f48e4da1a9c3c0fd3 /test | |
| parent | ea7b50b1b1f42e3a722f2efdca6fa2c3184d2105 (diff) | |
Add Trimmer class; not linked in.
Diffstat (limited to 'test')
| -rw-r--r-- | test/metadata.ref | 1 | ||||
| -rw-r--r-- | test/test.cc | 51 |
2 files changed, 52 insertions, 0 deletions
diff --git a/test/metadata.ref b/test/metadata.ref index 16e3837c8..b7a031883 100644 --- a/test/metadata.ref +++ b/test/metadata.ref @@ -14,6 +14,7 @@ filter unsharp scaler bicubic trim_start 42 trim_end 99 +trim_type cpl dcp_ab 1 use_content_audio 1 audio_gain 0 diff --git a/test/test.cc b/test/test.cc index 6fad0986b..ac7ab85fe 100644 --- a/test/test.cc +++ b/test/test.cc @@ -40,6 +40,7 @@ #include "scaler.h" #include "ffmpeg_decoder.h" #include "sndfile_decoder.h" +#include "trimmer.h" #define BOOST_TEST_DYN_LINK #define BOOST_TEST_MODULE dvdomatic_test #include <boost/test/unit_test.hpp> @@ -123,6 +124,55 @@ BOOST_AUTO_TEST_CASE (make_black_test) } } +shared_ptr<AudioBuffers> trimmer_test_last; + +void +trimmer_test_helper (shared_ptr<AudioBuffers> audio) +{ + trimmer_test_last = audio; +} + +/** Test the audio handling of the Trimmer */ +BOOST_AUTO_TEST_CASE (trimmer_test) +{ + Trimmer trimmer (shared_ptr<Log> (), 25, 75, 200, 48000, 25, 25); + + trimmer.Audio.connect (bind (&trimmer_test_helper, _1)); + + /* 21 video frames-worth of audio frames; should be completely stripped */ + trimmer_test_last.reset (); + shared_ptr<AudioBuffers> audio (new AudioBuffers (6, 21 * 1920)); + trimmer.process_audio (audio); + BOOST_CHECK (trimmer_test_last == 0); + + /* 42 more video frames-worth, 4 should be stripped from the start */ + audio.reset (new AudioBuffers (6, 42 * 1920)); + trimmer.process_audio (audio); + BOOST_CHECK (trimmer_test_last); + BOOST_CHECK_EQUAL (trimmer_test_last->frames(), 38 * 1920); + + /* 42 more video frames-worth, should be kept as-is */ + trimmer_test_last.reset (); + audio.reset (new AudioBuffers (6, 42 * 1920)); + trimmer.process_audio (audio); + BOOST_CHECK (trimmer_test_last); + BOOST_CHECK_EQUAL (trimmer_test_last->frames(), 42 * 1920); + + /* 25 more video frames-worth, 5 should be trimmed from the end */ + trimmer_test_last.reset (); + audio.reset (new AudioBuffers (6, 25 * 1920)); + trimmer.process_audio (audio); + BOOST_CHECK (trimmer_test_last); + BOOST_CHECK_EQUAL (trimmer_test_last->frames(), 20 * 1920); + + /* Now some more; all should be trimmed */ + trimmer_test_last.reset (); + audio.reset (new AudioBuffers (6, 100 * 1920)); + trimmer.process_audio (audio); + BOOST_CHECK (trimmer_test_last == 0); +} + + BOOST_AUTO_TEST_CASE (film_metadata_test) { setup_test_config (); @@ -863,3 +913,4 @@ BOOST_AUTO_TEST_CASE (aligned_image_test) delete t; delete u; } + |
