diff options
| author | Carl Hetherington <cth@carlh.net> | 2013-07-25 22:04:20 +0100 |
|---|---|---|
| committer | Carl Hetherington <cth@carlh.net> | 2013-07-25 22:04:20 +0100 |
| commit | 78e5a331074a456097a162d47501daf1df1ab1a3 (patch) | |
| tree | 17dbc6cd0e3e6a4878277959d7cd86129fb516b4 /test | |
| parent | 991244a0d4be149e8733a8dd70bfd745cab72583 (diff) | |
Hopefully much cleaner handling of PTS changes under resample.
Diffstat (limited to 'test')
| -rw-r--r-- | test/resampler_test.cc | 55 | ||||
| -rw-r--r-- | test/wscript | 1 |
2 files changed, 56 insertions, 0 deletions
diff --git a/test/resampler_test.cc b/test/resampler_test.cc new file mode 100644 index 000000000..1ef69b0c2 --- /dev/null +++ b/test/resampler_test.cc @@ -0,0 +1,55 @@ +/* + Copyright (C) 2013 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 + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + +*/ + +#include <boost/test/unit_test.hpp> +#include "lib/audio_buffers.h" +#include "lib/resampler.h" + +using std::pair; +using std::cout; +using boost::shared_ptr; + +static void +resampler_test_one (int from, int to) +{ + Resampler resamp (from, to, 1); + + int total_out = 0; + + /* 3 hours */ + int64_t const N = from * 60 * 60 * 3; + + for (int64_t i = 0; i < N; i += 1000) { + shared_ptr<AudioBuffers> a (new AudioBuffers (1, 1000)); + a->make_silent (); + pair<shared_ptr<const AudioBuffers>, AudioContent::Frame> r = resamp.run (a, i); + BOOST_CHECK_EQUAL (r.second, total_out); + total_out += r.first->frames (); + } +} + +/** Check that the timings that come back from the resampler correspond + to the number of samples it generates. +*/ +BOOST_AUTO_TEST_CASE (resampler_test) +{ + resampler_test_one (44100, 48000); + resampler_test_one (44100, 46080); + resampler_test_one (44100, 50000); +} diff --git a/test/wscript b/test/wscript index f7e7180c8..fef1584f3 100644 --- a/test/wscript +++ b/test/wscript @@ -16,6 +16,7 @@ def build(bld): obj.use = 'libdcpomatic' obj.source = """ test.cc + resampler_test.cc ffmpeg_audio_test.cc threed_test.cc play_test.cc |
