diff options
| author | Carl Hetherington <cth@carlh.net> | 2013-12-11 10:31:18 +0000 |
|---|---|---|
| committer | Carl Hetherington <cth@carlh.net> | 2013-12-11 10:31:18 +0000 |
| commit | ea910e250a0fb3b0ad3ce0cf32dd27b24c17cd1d (patch) | |
| tree | 32119d2a04532d3162c656df7c7e715b289c6e61 /test | |
| parent | 3e5df964ada49e10a880a200c985cc309ccecb64 (diff) | |
Various work on better seeking (and seeking of audio).
Diffstat (limited to 'test')
| -rw-r--r-- | test/ffmpeg_seek_test.cc | 106 | ||||
| -rw-r--r-- | test/frame_rate_test.cc | 52 | ||||
| -rw-r--r-- | test/long_ffmpeg_seek_test.cc | 105 | ||||
| -rw-r--r-- | test/test.cc | 4 | ||||
| -rw-r--r-- | test/wscript | 15 |
5 files changed, 261 insertions, 21 deletions
diff --git a/test/ffmpeg_seek_test.cc b/test/ffmpeg_seek_test.cc new file mode 100644 index 000000000..7014bf1b0 --- /dev/null +++ b/test/ffmpeg_seek_test.cc @@ -0,0 +1,106 @@ +/* + 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/player.h" +#include "lib/ffmpeg_decoder.h" +#include "lib/film.h" +#include "lib/ratio.h" +#include "test.h" + +using std::cout; +using std::string; +using std::stringstream; +using boost::shared_ptr; + +#define FFMPEG_SEEK_TEST_DEBUG 1 + +boost::optional<Time> first_video; +boost::optional<Time> first_audio; + +static void +process_video (shared_ptr<PlayerImage>, Eyes, ColourConversion, bool, Time t) +{ + if (!first_video) { + first_video = t; + } +} + +static void +process_audio (shared_ptr<const AudioBuffers>, Time t) +{ + if (!first_audio) { + first_audio = t; + } +} + +static string +print_time (Time t, float fps) +{ + stringstream s; + s << t << " " << (float(t) / TIME_HZ) << "s " << (float(t) * fps / TIME_HZ) << "f"; + return s.str (); +} + +static void +check (shared_ptr<Player> p, Time t) +{ + first_video.reset (); + first_audio.reset (); + +#if FFMPEG_SEEK_TEST_DEBUG == 1 + cout << "\n-- Seek to " << print_time (t, 24) << "\n"; +#endif + + p->seek (t, true); + while (!first_video || !first_audio) { + p->pass (); + } + +#if FFMPEG_SEEK_TEST_DEBUG == 1 + cout << "First video " << print_time (first_video.get(), 24) << "\n"; + cout << "First audio " << print_time (first_audio.get(), 24) << "\n"; +#endif + + BOOST_CHECK (first_video.get() >= t); + BOOST_CHECK (first_audio.get() >= t); +} + +BOOST_AUTO_TEST_CASE (ffmpeg_seek_test) +{ + shared_ptr<Film> film = new_test_film ("ffmpeg_audio_test"); + film->set_name ("ffmpeg_audio_test"); + film->set_container (Ratio::from_id ("185")); + shared_ptr<FFmpegContent> c (new FFmpegContent (film, "test/data/staircase.mov")); + c->set_ratio (Ratio::from_id ("185")); + film->examine_and_add_content (c); + + wait_for_jobs (); + + shared_ptr<Player> player = film->make_player (); + player->Video.connect (boost::bind (&process_video, _1, _2, _3, _4, _5)); + player->Audio.connect (boost::bind (&process_audio, _1, _2)); + + check (player, 0); + check (player, 0.1 * TIME_HZ); + check (player, 0.2 * TIME_HZ); + check (player, 0.3 * TIME_HZ); +} + + diff --git a/test/frame_rate_test.cc b/test/frame_rate_test.cc index fdfdcf452..7d3904e74 100644 --- a/test/frame_rate_test.cc +++ b/test/frame_rate_test.cc @@ -47,91 +47,102 @@ BOOST_AUTO_TEST_CASE (best_dcp_frame_rate_test_single) content->_video_frame_rate = 60; int best = film->playlist()->best_dcp_frame_rate (); - FrameRateConversion frc = FrameRateConversion (60, best); + FrameRateChange frc = FrameRateChange (60, best); BOOST_CHECK_EQUAL (best, 30); BOOST_CHECK_EQUAL (frc.skip, true); BOOST_CHECK_EQUAL (frc.repeat, 1); BOOST_CHECK_EQUAL (frc.change_speed, false); + BOOST_CHECK_CLOSE (frc.speed_up, 1, 0.1); content->_video_frame_rate = 50; best = film->playlist()->best_dcp_frame_rate (); - frc = FrameRateConversion (50, best); + frc = FrameRateChange (50, best); BOOST_CHECK_EQUAL (best, 25); BOOST_CHECK_EQUAL (frc.skip, true); BOOST_CHECK_EQUAL (frc.repeat, 1); BOOST_CHECK_EQUAL (frc.change_speed, false); + BOOST_CHECK_CLOSE (frc.speed_up, 1, 0.1); content->_video_frame_rate = 48; best = film->playlist()->best_dcp_frame_rate (); - frc = FrameRateConversion (48, best); + frc = FrameRateChange (48, best); BOOST_CHECK_EQUAL (best, 24); BOOST_CHECK_EQUAL (frc.skip, true); BOOST_CHECK_EQUAL (frc.repeat, 1); BOOST_CHECK_EQUAL (frc.change_speed, false); + BOOST_CHECK_CLOSE (frc.speed_up, 1, 0.1); content->_video_frame_rate = 30; best = film->playlist()->best_dcp_frame_rate (); - frc = FrameRateConversion (30, best); + frc = FrameRateChange (30, best); BOOST_CHECK_EQUAL (best, 30); BOOST_CHECK_EQUAL (frc.skip, false); BOOST_CHECK_EQUAL (frc.repeat, 1); BOOST_CHECK_EQUAL (frc.change_speed, false); + BOOST_CHECK_CLOSE (frc.speed_up, 1, 0.1); content->_video_frame_rate = 29.97; best = film->playlist()->best_dcp_frame_rate (); - frc = FrameRateConversion (29.97, best); + frc = FrameRateChange (29.97, best); BOOST_CHECK_EQUAL (best, 30); BOOST_CHECK_EQUAL (frc.skip, false); BOOST_CHECK_EQUAL (frc.repeat, 1); BOOST_CHECK_EQUAL (frc.change_speed, true); + BOOST_CHECK_CLOSE (frc.speed_up, 30 / 29.97, 0.1); content->_video_frame_rate = 25; best = film->playlist()->best_dcp_frame_rate (); - frc = FrameRateConversion (25, best); + frc = FrameRateChange (25, best); BOOST_CHECK_EQUAL (best, 25); BOOST_CHECK_EQUAL (frc.skip, false); BOOST_CHECK_EQUAL (frc.repeat, 1); BOOST_CHECK_EQUAL (frc.change_speed, false); + BOOST_CHECK_CLOSE (frc.speed_up, 1, 0.1); content->_video_frame_rate = 24; best = film->playlist()->best_dcp_frame_rate (); - frc = FrameRateConversion (24, best); + frc = FrameRateChange (24, best); BOOST_CHECK_EQUAL (best, 24); BOOST_CHECK_EQUAL (frc.skip, false); BOOST_CHECK_EQUAL (frc.repeat, 1); BOOST_CHECK_EQUAL (frc.change_speed, false); + BOOST_CHECK_CLOSE (frc.speed_up, 1, 0.1); content->_video_frame_rate = 14.5; best = film->playlist()->best_dcp_frame_rate (); - frc = FrameRateConversion (14.5, best); + frc = FrameRateChange (14.5, best); BOOST_CHECK_EQUAL (best, 30); BOOST_CHECK_EQUAL (frc.skip, false); BOOST_CHECK_EQUAL (frc.repeat, 2); BOOST_CHECK_EQUAL (frc.change_speed, true); + BOOST_CHECK_CLOSE (frc.speed_up, 15 / 14.5, 0.1); content->_video_frame_rate = 12.6; best = film->playlist()->best_dcp_frame_rate (); - frc = FrameRateConversion (12.6, best); + frc = FrameRateChange (12.6, best); BOOST_CHECK_EQUAL (best, 25); BOOST_CHECK_EQUAL (frc.skip, false); BOOST_CHECK_EQUAL (frc.repeat, 2); BOOST_CHECK_EQUAL (frc.change_speed, true); + BOOST_CHECK_CLOSE (frc.speed_up, 25 / 25.2, 0.1); content->_video_frame_rate = 12.4; best = film->playlist()->best_dcp_frame_rate (); - frc = FrameRateConversion (12.4, best); + frc = FrameRateChange (12.4, best); BOOST_CHECK_EQUAL (best, 25); BOOST_CHECK_EQUAL (frc.skip, false); BOOST_CHECK_EQUAL (frc.repeat, 2); BOOST_CHECK_EQUAL (frc.change_speed, true); + BOOST_CHECK_CLOSE (frc.speed_up, 25 / 24.8, 0.1); content->_video_frame_rate = 12; best = film->playlist()->best_dcp_frame_rate (); - frc = FrameRateConversion (12, best); + frc = FrameRateChange (12, best); BOOST_CHECK_EQUAL (best, 24); BOOST_CHECK_EQUAL (frc.skip, false); BOOST_CHECK_EQUAL (frc.repeat, 2); BOOST_CHECK_EQUAL (frc.change_speed, false); + BOOST_CHECK_CLOSE (frc.speed_up, 1, 0.1); /* Now add some more rates and see if it will use them in preference to skip/repeat. @@ -144,34 +155,38 @@ BOOST_AUTO_TEST_CASE (best_dcp_frame_rate_test_single) content->_video_frame_rate = 60; best = film->playlist()->best_dcp_frame_rate (); - frc = FrameRateConversion (60, best); + frc = FrameRateChange (60, best); BOOST_CHECK_EQUAL (best, 60); BOOST_CHECK_EQUAL (frc.skip, false); BOOST_CHECK_EQUAL (frc.repeat, 1); BOOST_CHECK_EQUAL (frc.change_speed, false); + BOOST_CHECK_CLOSE (frc.speed_up, 1, 0.1); content->_video_frame_rate = 50; best = film->playlist()->best_dcp_frame_rate (); - frc = FrameRateConversion (50, best); + frc = FrameRateChange (50, best); BOOST_CHECK_EQUAL (best, 50); BOOST_CHECK_EQUAL (frc.skip, false); BOOST_CHECK_EQUAL (frc.repeat, 1); BOOST_CHECK_EQUAL (frc.change_speed, false); + BOOST_CHECK_CLOSE (frc.speed_up, 1, 0.1); content->_video_frame_rate = 48; best = film->playlist()->best_dcp_frame_rate (); - frc = FrameRateConversion (48, best); + frc = FrameRateChange (48, best); BOOST_CHECK_EQUAL (best, 48); BOOST_CHECK_EQUAL (frc.skip, false); BOOST_CHECK_EQUAL (frc.repeat, 1); BOOST_CHECK_EQUAL (frc.change_speed, false); + BOOST_CHECK_CLOSE (frc.speed_up, 1, 0.1); /* Check some out-there conversions (not the best) */ - frc = FrameRateConversion (14.99, 24); + frc = FrameRateChange (14.99, 24); BOOST_CHECK_EQUAL (frc.skip, false); BOOST_CHECK_EQUAL (frc.repeat, 2); BOOST_CHECK_EQUAL (frc.change_speed, true); + BOOST_CHECK_CLOSE (frc.speed_up, 2 * 14.99 / 24, 0.1); /* Check some conversions with limited DCP targets */ @@ -181,14 +196,15 @@ BOOST_AUTO_TEST_CASE (best_dcp_frame_rate_test_single) content->_video_frame_rate = 25; best = film->playlist()->best_dcp_frame_rate (); - frc = FrameRateConversion (25, best); + frc = FrameRateChange (25, best); BOOST_CHECK_EQUAL (best, 24); BOOST_CHECK_EQUAL (frc.skip, false); BOOST_CHECK_EQUAL (frc.repeat, 1); BOOST_CHECK_EQUAL (frc.change_speed, true); + BOOST_CHECK_CLOSE (frc.speed_up, 24.0 / 25, 0.1); } -/* Test Playlist::best_dcp_frame_rate and FrameRateConversion +/* Test Playlist::best_dcp_frame_rate and FrameRateChange with two pieces of content. */ BOOST_AUTO_TEST_CASE (best_dcp_frame_rate_test_double) @@ -266,7 +282,7 @@ BOOST_AUTO_TEST_CASE (audio_sampling_rate_test) 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))); - /* The FrameRateConversion within output_audio_frame_rate should choose to double-up + /* The FrameRateChange within output_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->output_audio_frame_rate(), rint (48000 * 2 * 14.99 / 25)); diff --git a/test/long_ffmpeg_seek_test.cc b/test/long_ffmpeg_seek_test.cc new file mode 100644 index 000000000..5f7f6c2f2 --- /dev/null +++ b/test/long_ffmpeg_seek_test.cc @@ -0,0 +1,105 @@ +/* + 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/player.h" +#include "lib/ffmpeg_decoder.h" +#include "lib/film.h" +#include "lib/ratio.h" +#include "test.h" + +using std::cout; +using std::string; +using std::stringstream; +using boost::shared_ptr; + +#define LONG_FFMPEG_SEEK_TEST_DEBUG 1 + +boost::optional<Time> first_video; +boost::optional<Time> first_audio; + +static void +process_video (shared_ptr<PlayerImage>, Eyes, ColourConversion, bool, Time t) +{ + if (!first_video) { + first_video = t; + } +} + +static void +process_audio (shared_ptr<const AudioBuffers>, Time t) +{ + if (!first_audio) { + first_audio = t; + } +} + +static string +print_time (Time t, float fps) +{ + stringstream s; + s << t << " " << (float(t) / TIME_HZ) << "s " << (float(t) * fps / TIME_HZ) << "f"; + return s.str (); +} + +static void +check (shared_ptr<Player> p, Time t) +{ + first_video.reset (); + first_audio.reset (); + +#if LONG_FFMPEG_SEEK_TEST_DEBUG == 1 + cout << "\n-- Seek to " << print_time (t, 24) << "\n"; +#endif + + p->seek (t, true); + while (!first_video || !first_audio) { + p->pass (); + } + +#if LONG_FFMPEG_SEEK_TEST_DEBUG == 1 + cout << "First video " << print_time (first_video.get(), 24) << "\n"; + cout << "First audio " << print_time (first_audio.get(), 24) << "\n"; +#endif + + BOOST_CHECK (first_video.get() >= t); + BOOST_CHECK (first_audio.get() >= t); +} + +BOOST_AUTO_TEST_CASE (long_ffmpeg_seek_test) +{ + shared_ptr<Film> film = new_test_film ("long_ffmpeg_audio_test"); + film->set_name ("long_ffmpeg_audio_test"); + film->set_container (Ratio::from_id ("185")); + shared_ptr<FFmpegContent> c (new FFmpegContent (film, "test/long_data/dolby_aurora.vob")); + c->set_ratio (Ratio::from_id ("185")); + film->examine_and_add_content (c); + + wait_for_jobs (); + + shared_ptr<Player> player = film->make_player (); + player->Video.connect (boost::bind (&process_video, _1, _2, _3, _4, _5)); + player->Audio.connect (boost::bind (&process_audio, _1, _2)); + + for (float i = 0; i < 10; i += 0.1) { + check (player, i * TIME_HZ); + } +} + + diff --git a/test/test.cc b/test/test.cc index 22dea1fc4..92ce95656 100644 --- a/test/test.cc +++ b/test/test.cc @@ -53,9 +53,9 @@ public: struct TestConfig { - TestConfig() + TestConfig () { - dcpomatic_setup(); + dcpomatic_setup (); Config::instance()->set_num_local_encoding_threads (1); Config::instance()->set_server_port_base (61920); diff --git a/test/wscript b/test/wscript index 4ae49b087..df9aa88d3 100644 --- a/test/wscript +++ b/test/wscript @@ -10,7 +10,7 @@ def configure(conf): """, msg = 'Checking for boost unit testing library', lib = 'boost_unit_test_framework%s' % boost_test_suffix, uselib_store = 'BOOST_TEST') def build(bld): - obj = bld(features = 'cxx cxxprogram') + obj = bld(features='cxx cxxprogram') obj.name = 'unit-tests' obj.uselib = 'BOOST_TEST DCP OPENJPEG AVFORMAT AVFILTER AVCODEC AVUTIL SWSCALE POSTPROC CXML' obj.use = 'libdcpomatic' @@ -26,6 +26,7 @@ def build(bld): ffmpeg_dcp_test.cc ffmpeg_examiner_test.cc ffmpeg_pts_offset.cc + ffmpeg_seek_test.cc file_group_test.cc film_metadata_test.cc frame_rate_test.cc @@ -46,3 +47,15 @@ def build(bld): obj.target = 'unit-tests' obj.install_path = '' + + obj = bld(features='cxx cxxprogram') + obj.name = 'long-unit-tests' + obj.uselib = 'BOOST_TEST DCP OPENJPEG AVFORMAT AVFILTER AVCODEC AVUTIL SWSCALE POSTPROC CXML' + obj.use = 'libdcpomatic' + obj.source = """ + test.cc + long_ffmpeg_seek_test.cc + """ + + obj.target = 'long-unit-tests' + obj.install_path = '' |
