summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorCarl Hetherington <cth@carlh.net>2013-04-17 10:37:12 +0100
committerCarl Hetherington <cth@carlh.net>2013-04-17 10:37:12 +0100
commitf074b7016ec58e831d9270f98ddc3ea31874a786 (patch)
treee98a28e7df33ccc7425925023e309a504c694f16 /test
parent650f2c95f9bcb58b747d97f17e656c0898aec68b (diff)
parent8c1a2972ac7e18758759515c3c1889c5b6fd86b5 (diff)
Merge branch 'master' into staging
Diffstat (limited to 'test')
-rw-r--r--test/metadata.ref1
-rw-r--r--test/test.cc51
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 724b7ac00..b0b2cef7d 100644
--- a/test/test.cc
+++ b/test/test.cc
@@ -39,6 +39,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>
@@ -122,6 +123,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 ();
@@ -769,3 +819,4 @@ BOOST_AUTO_TEST_CASE (aligned_image_test)
delete t;
delete u;
}
+