summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorCarl Hetherington <cth@carlh.net>2014-03-25 09:41:36 +0000
committerCarl Hetherington <cth@carlh.net>2014-03-25 09:41:36 +0000
commitee77b3cf5f59f775e75e628aa28e8f2f9f941530 (patch)
treebbf9ab4ef1f0f633591889cbbd6b7b65de8f5a57 /test
parente6f28e7cda23c1ba3c49cc1bf2dc1491c2f87160 (diff)
It builds.
Diffstat (limited to 'test')
-rw-r--r--test/audio_merger_test.cc103
-rw-r--r--test/ffmpeg_pts_offset.cc10
-rw-r--r--test/ffmpeg_seek_test.cc117
-rw-r--r--test/long_ffmpeg_seek_test.cc105
-rw-r--r--test/play_test.cc126
-rw-r--r--test/seek_zero_test.cc15
-rw-r--r--test/subrip_test.cc9
-rw-r--r--test/wscript4
8 files changed, 15 insertions, 474 deletions
diff --git a/test/audio_merger_test.cc b/test/audio_merger_test.cc
deleted file mode 100644
index 2fa0ccea5..000000000
--- a/test/audio_merger_test.cc
+++ /dev/null
@@ -1,103 +0,0 @@
-/*
- 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 <boost/bind.hpp>
-#include <boost/function.hpp>
-#include <boost/signals2.hpp>
-#include "lib/audio_merger.h"
-#include "lib/audio_buffers.h"
-
-using boost::shared_ptr;
-using boost::bind;
-
-static shared_ptr<const AudioBuffers> last_audio;
-
-BOOST_AUTO_TEST_CASE (audio_merger_test1)
-{
- int const frame_rate = 48000;
- AudioMerger merger (1, frame_rate);
-
- /* Push 64 samples, 0 -> 63 at time 0 */
- shared_ptr<AudioBuffers> buffers (new AudioBuffers (1, 64));
- for (int i = 0; i < 64; ++i) {
- buffers->data()[0][i] = i;
- }
- merger.push (buffers, DCPTime ());
-
- /* Push 64 samples, 0 -> 63 at time 22 */
- merger.push (buffers, DCPTime::from_frames (22, frame_rate));
-
- TimedAudioBuffers tb = merger.pull (DCPTime::from_frames (22, frame_rate));
- BOOST_CHECK (tb.audio != shared_ptr<const AudioBuffers> ());
- BOOST_CHECK_EQUAL (tb.audio->frames(), 22);
- BOOST_CHECK_EQUAL (tb.time, DCPTime ());
-
- /* And they should be a staircase */
- for (int i = 0; i < 22; ++i) {
- BOOST_CHECK_EQUAL (tb.audio->data()[0][i], i);
- }
-
- tb = merger.flush ();
-
- /* That flush should give us 64 samples at 22 */
- BOOST_CHECK_EQUAL (tb.audio->frames(), 64);
- BOOST_CHECK_EQUAL (tb.time, DCPTime::from_frames (22, frame_rate));
-
- /* Check the sample values */
- for (int i = 0; i < 64; ++i) {
- int correct = i;
- if (i < (64 - 22)) {
- correct += i + 22;
- }
- BOOST_CHECK_EQUAL (tb.audio->data()[0][i], correct);
- }
-}
-
-BOOST_AUTO_TEST_CASE (audio_merger_test2)
-{
- int const frame_rate = 48000;
- AudioMerger merger (1, frame_rate);
-
- /* Push 64 samples, 0 -> 63 at time 9 */
- shared_ptr<AudioBuffers> buffers (new AudioBuffers (1, 64));
- for (int i = 0; i < 64; ++i) {
- buffers->data()[0][i] = i;
- }
- merger.push (buffers, DCPTime::from_frames (9, frame_rate));
-
- TimedAudioBuffers tb = merger.pull (DCPTime::from_frames (9, frame_rate));
- BOOST_CHECK_EQUAL (tb.audio->frames(), 9);
- BOOST_CHECK_EQUAL (tb.time, DCPTime ());
-
- for (int i = 0; i < 9; ++i) {
- BOOST_CHECK_EQUAL (tb.audio->data()[0][i], 0);
- }
-
- tb = merger.flush ();
-
- /* That flush should give us 64 samples at 9 */
- BOOST_CHECK_EQUAL (tb.audio->frames(), 64);
- BOOST_CHECK_EQUAL (tb.time, DCPTime::from_frames (9, frame_rate));
-
- /* Check the sample values */
- for (int i = 0; i < 64; ++i) {
- BOOST_CHECK_EQUAL (tb.audio->data()[0][i], i);
- }
-}
diff --git a/test/ffmpeg_pts_offset.cc b/test/ffmpeg_pts_offset.cc
index bada6a40b..dc391ed46 100644
--- a/test/ffmpeg_pts_offset.cc
+++ b/test/ffmpeg_pts_offset.cc
@@ -36,7 +36,7 @@ BOOST_AUTO_TEST_CASE (ffmpeg_pts_offset_test)
/* Sound == video so no offset required */
content->_first_video = ContentTime ();
content->_audio_stream->first_audio = ContentTime ();
- FFmpegDecoder decoder (content, film->log(), true, true, true);
+ FFmpegDecoder decoder (content, film->log());
BOOST_CHECK_EQUAL (decoder._pts_offset, ContentTime ());
}
@@ -44,7 +44,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);
- FFmpegDecoder decoder (content, film->log(), true, true, true);
+ FFmpegDecoder decoder (content, film->log());
BOOST_CHECK_EQUAL (decoder._pts_offset, ContentTime::from_seconds (-600));
}
@@ -52,7 +52,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 ();
- FFmpegDecoder decoder (content, film->log(),true, true, true);
+ FFmpegDecoder decoder (content, film->log());
BOOST_CHECK_EQUAL (decoder._pts_offset, ContentTime ());
}
@@ -61,7 +61,7 @@ BOOST_AUTO_TEST_CASE (ffmpeg_pts_offset_test)
double const frame = 1.0 / 24.0;
content->_first_video = ContentTime::from_seconds (frame + 0.0215);
content->_audio_stream->first_audio = ContentTime ();
- FFmpegDecoder decoder (content, film->log(), true, true, true);
+ FFmpegDecoder decoder (content, film->log());
BOOST_CHECK_CLOSE (decoder._pts_offset.seconds(), (frame - 0.0215), 0.00001);
}
@@ -70,7 +70,7 @@ BOOST_AUTO_TEST_CASE (ffmpeg_pts_offset_test)
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);
- FFmpegDecoder decoder (content, film->log(), true, true, true);
+ FFmpegDecoder decoder (content, film->log());
BOOST_CHECK_EQUAL (decoder._pts_offset.seconds(), (frame - 0.0215) - 4.1);
}
}
diff --git a/test/ffmpeg_seek_test.cc b/test/ffmpeg_seek_test.cc
deleted file mode 100644
index c25a071de..000000000
--- a/test/ffmpeg_seek_test.cc
+++ /dev/null
@@ -1,117 +0,0 @@
-/*
- 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.
-
-*/
-
-/** @file test/ffmpeg_seek_test.cc
- * @brief Test seek using Player with an FFmpegDecoder; note that the player
- * can hide problems with FFmpegDecoder seeking as it will skip frames / insert
- * black as it sees fit.
- */
-
-#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;
-using boost::optional;
-
-#define FFMPEG_SEEK_TEST_DEBUG 1
-
-optional<DCPTime> first_video;
-optional<DCPTime> first_audio;
-shared_ptr<Film> film;
-
-static void
-process_video (shared_ptr<PlayerImage>, Eyes, ColourConversion, bool, DCPTime t)
-{
- if (!first_video) {
- first_video = t;
- }
-}
-
-static void
-process_audio (shared_ptr<const AudioBuffers>, DCPTime t)
-{
- if (!first_audio) {
- first_audio = t;
- }
-}
-
-static string
-print_time (DCPTime t, float fps)
-{
- stringstream s;
- s << t.seconds() << "s " << t.frames (fps) << "f";
- return s.str ();
-}
-
-static void
-check (shared_ptr<Player> p, DCPTime 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
-
- /* Outputs should be on or after seek time */
- BOOST_CHECK (first_video.get() >= t);
- BOOST_CHECK (first_audio.get() >= t);
- /* And should be rounded to frame boundaries */
- BOOST_CHECK_EQUAL (first_video.get(), first_video.get().round_up (film->video_frame_rate()));
- BOOST_CHECK_EQUAL (first_audio.get(), first_audio.get().round_up (film->audio_frame_rate()));
-}
-
-/* Test basic seeking */
-BOOST_AUTO_TEST_CASE (ffmpeg_seek_test)
-{
- film = new_test_film ("ffmpeg_seek_test");
- film->set_name ("ffmpeg_seek_test");
- film->set_container (Ratio::from_id ("185"));
- shared_ptr<FFmpegContent> c (new FFmpegContent (film, "test/data/staircase.mov"));
- c->set_scale (VideoContentScale (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, DCPTime::from_seconds (0));
- check (player, DCPTime::from_seconds (0.1));
- check (player, DCPTime::from_seconds (0.2));
- check (player, DCPTime::from_seconds (0.3));
-}
diff --git a/test/long_ffmpeg_seek_test.cc b/test/long_ffmpeg_seek_test.cc
deleted file mode 100644
index 58b039eee..000000000
--- a/test/long_ffmpeg_seek_test.cc
+++ /dev/null
@@ -1,105 +0,0 @@
-/*
- 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<DCPTime> first_video;
-boost::optional<DCPTime> first_audio;
-
-static void
-process_video (shared_ptr<PlayerImage>, Eyes, ColourConversion, bool, DCPTime t)
-{
- if (!first_video) {
- first_video = t;
- }
-}
-
-static void
-process_audio (shared_ptr<const AudioBuffers>, DCPTime t)
-{
- if (!first_audio) {
- first_audio = t;
- }
-}
-
-static string
-print_time (DCPTime t, float fps)
-{
- stringstream s;
- s << t << " " << t.seconds() << "s " << t.frames(fps) << "f";
- return s.str ();
-}
-
-static void
-check (shared_ptr<Player> p, DCPTime 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_scale (VideoContentScale (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, DCPTime::from_seconds (i));
- }
-}
-
-
diff --git a/test/play_test.cc b/test/play_test.cc
deleted file mode 100644
index ed3e497ed..000000000
--- a/test/play_test.cc
+++ /dev/null
@@ -1,126 +0,0 @@
-/*
- 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/ratio.h"
-#include "lib/dcp_content_type.h"
-#include "test.h"
-
-/* This test needs stuff in Player that is only included in debug mode */
-#ifdef DCPOMATIC_DEBUG
-
-using std::cout;
-using boost::optional;
-using boost::shared_ptr;
-
-struct Video
-{
- boost::shared_ptr<Content> content;
- boost::shared_ptr<const Image> image;
- DCPTime time;
-};
-
-class PlayerWrapper
-{
-public:
- PlayerWrapper (shared_ptr<Player> p)
- : _player (p)
- {
- _player->Video.connect (bind (&PlayerWrapper::process_video, this, _1, _2, _5));
- }
-
- void process_video (shared_ptr<PlayerImage> i, bool, DCPTime t)
- {
- Video v;
- v.content = _player->_last_video;
- v.image = i->image (PIX_FMT_RGB24, false);
- v.time = t;
- _queue.push_front (v);
- }
-
- optional<Video> get_video ()
- {
- while (_queue.empty() && !_player->pass ()) {}
- if (_queue.empty ()) {
- return optional<Video> ();
- }
-
- Video v = _queue.back ();
- _queue.pop_back ();
- return v;
- }
-
- void seek (DCPTime t, bool ac)
- {
- _player->seek (t, ac);
- _queue.clear ();
- }
-
-private:
- shared_ptr<Player> _player;
- std::list<Video> _queue;
-};
-
-BOOST_AUTO_TEST_CASE (play_test)
-{
- shared_ptr<Film> film = new_test_film ("play_test");
- film->set_dcp_content_type (DCPContentType::from_dci_name ("FTR"));
- film->set_container (Ratio::from_id ("185"));
- film->set_name ("play_test");
-
- shared_ptr<FFmpegContent> A (new FFmpegContent (film, "test/data/red_24.mp4"));
- film->examine_and_add_content (A);
- wait_for_jobs ();
-
- BOOST_CHECK_EQUAL (A->video_length_after_3d_combine().frames (24), 16);
-
- shared_ptr<FFmpegContent> B (new FFmpegContent (film, "test/data/red_30.mp4"));
- film->examine_and_add_content (B);
- wait_for_jobs ();
-
- BOOST_CHECK_EQUAL (B->video_length_after_3d_combine().frames (30), 16);
-
- /* Film should have been set to 25fps */
- BOOST_CHECK_EQUAL (film->video_frame_rate(), 25);
-
- BOOST_CHECK_EQUAL (A->position(), DCPTime ());
- /* A is 16 frames long at 25 fps */
- BOOST_CHECK_EQUAL (B->position(), DCPTime::from_frames (16, 25));
-
- shared_ptr<Player> player = film->make_player ();
- PlayerWrapper wrap (player);
-
- for (int i = 0; i < 32; ++i) {
- optional<Video> v = wrap.get_video ();
- BOOST_CHECK (v);
- if (i < 16) {
- BOOST_CHECK (v.get().content == A);
- } else {
- BOOST_CHECK (v.get().content == B);
- }
- }
-
- player->seek (DCPTime::from_frames (6, 25), true);
- optional<Video> v = wrap.get_video ();
- BOOST_CHECK (v);
- BOOST_CHECK_EQUAL (v.get().time, DCPTime::from_frames (6, 25));
-}
-
-#endif
diff --git a/test/seek_zero_test.cc b/test/seek_zero_test.cc
index 07f9e3694..cda4f0729 100644
--- a/test/seek_zero_test.cc
+++ b/test/seek_zero_test.cc
@@ -28,6 +28,7 @@
#include "lib/ratio.h"
#include "lib/dcp_content_type.h"
#include "lib/ffmpeg_decoder.h"
+#include "lib/content_video.h"
#include "test.h"
using std::cout;
@@ -45,13 +46,9 @@ BOOST_AUTO_TEST_CASE (seek_zero_test)
film->examine_and_add_content (content);
wait_for_jobs ();
- FFmpegDecoder decoder (content, film->log(), true, false, false);
- shared_ptr<DecodedVideo> a = dynamic_pointer_cast<DecodedVideo> (decoder.peek ());
- decoder.seek (ContentTime(), true);
- shared_ptr<DecodedVideo> b = dynamic_pointer_cast<DecodedVideo> (decoder.peek ());
-
- /* a will be after no seek, and b after a seek to zero, which should
- have the same effect.
- */
- BOOST_CHECK_EQUAL (a->content_time, b->content_time);
+ FFmpegDecoder decoder (content, film->log());
+ shared_ptr<ContentVideo> a = decoder.get_video (0, true);
+ shared_ptr<ContentVideo> b = decoder.get_video (0, true);
+ BOOST_CHECK_EQUAL (a->frame, 0);
+ BOOST_CHECK_EQUAL (b->frame, 0);
}
diff --git a/test/subrip_test.cc b/test/subrip_test.cc
index 85bb7c4e8..f38ffb59b 100644
--- a/test/subrip_test.cc
+++ b/test/subrip_test.cc
@@ -186,11 +186,10 @@ BOOST_AUTO_TEST_CASE (subrip_render_test)
shared_ptr<Film> film = new_test_film ("subrip_render_test");
shared_ptr<SubRipDecoder> decoder (new SubRipDecoder (content));
- shared_ptr<DecodedTextSubtitle> dts = dynamic_pointer_cast<DecodedTextSubtitle> (decoder->peek ());
+ list<shared_ptr<ContentTextSubtitle> > cts = decoder->get_text_subtitles (ContentTime::from_seconds (109), ContentTime::from_seconds (110));
+ BOOST_CHECK_EQUAL (cts.size(), 1);
- shared_ptr<Image> image;
- Position<int> position;
- render_subtitles (dts->subs, dcp::Size (1998, 1080), image, position);
- write_image (image, "build/test/subrip_render_test.png");
+ PositionImage image = render_subtitles (cts.front()->subs, dcp::Size (1998, 1080));
+ write_image (image.image, "build/test/subrip_render_test.png");
check_file ("build/test/subrip_render_test.png", "test/data/subrip_render_test.png");
}
diff --git a/test/wscript b/test/wscript
index ec8dfd42c..ba5aabb7c 100644
--- a/test/wscript
+++ b/test/wscript
@@ -19,7 +19,6 @@ def build(bld):
audio_analysis_test.cc
audio_delay_test.cc
audio_mapping_test.cc
- audio_merger_test.cc
black_fill_test.cc
client_server_test.cc
colour_conversion_test.cc
@@ -27,7 +26,6 @@ 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
@@ -35,7 +33,6 @@ def build(bld):
job_test.cc
make_black_test.cc
pixel_formats_test.cc
- play_test.cc
ratio_test.cc
repeat_frame_test.cc
recover_test.cc
@@ -60,7 +57,6 @@ def build(bld):
obj.use = 'libdcpomatic'
obj.source = """
test.cc
- long_ffmpeg_seek_test.cc
"""
obj.target = 'long-unit-tests'