2 Copyright (C) 2014-2016 Carl Hetherington <cth@carlh.net>
4 This file is part of DCP-o-matic.
6 DCP-o-matic is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2 of the License, or
9 (at your option) any later version.
11 DCP-o-matic is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
16 You should have received a copy of the GNU General Public License
17 along with DCP-o-matic. If not, see <http://www.gnu.org/licenses/>.
21 #include <boost/test/unit_test.hpp>
22 #include "lib/image_decoder.h"
23 #include "lib/image_content.h"
24 #include "lib/content_video.h"
25 #include "lib/video_decoder.h"
32 using boost::shared_ptr;
34 BOOST_AUTO_TEST_CASE (video_decoder_fill_test1)
36 shared_ptr<Film> film = new_test_film ("video_decoder_fill_test");
37 shared_ptr<ImageContent> c (new ImageContent (film, "test/data/simple_testcard_640x480.png"));
38 ImageDecoder decoder (c, film->log());
40 decoder.video->fill_one_eye (0, 4, EYES_BOTH);
41 BOOST_CHECK_EQUAL (decoder.video->_decoded.size(), 4U);
42 list<ContentVideo>::iterator i = decoder.video->_decoded.begin();
43 for (int j = 0; j < 4; ++j) {
44 BOOST_CHECK_EQUAL (i->frame.index(), j);
48 decoder.video->_decoded.clear ();
50 decoder.video->fill_one_eye (0, 7, EYES_BOTH);
51 BOOST_CHECK_EQUAL (decoder.video->_decoded.size(), 7);
52 i = decoder.video->_decoded.begin();
53 for (int j = 0; j < 7; ++j) {
54 BOOST_CHECK_EQUAL (i->frame.index(), j);
59 BOOST_AUTO_TEST_CASE (video_decoder_fill_test2)
61 shared_ptr<Film> film = new_test_film ("video_decoder_fill_test");
62 shared_ptr<ImageContent> c (new ImageContent (film, "test/data/simple_testcard_640x480.png"));
63 ImageDecoder decoder (c, film->log());
65 decoder.video->fill_both_eyes (VideoFrame (0, EYES_LEFT), VideoFrame (4, EYES_LEFT));
66 BOOST_CHECK_EQUAL (decoder.video->_decoded.size(), 8);
67 list<ContentVideo>::iterator i = decoder.video->_decoded.begin();
68 for (int j = 0; j < 8; ++j) {
69 BOOST_CHECK_EQUAL (i->frame.index(), j / 2);
70 BOOST_CHECK_EQUAL (i->frame.eyes(), (j % 2) == 0 ? EYES_LEFT : EYES_RIGHT);
74 decoder.video->_decoded.clear ();
75 decoder.video->fill_both_eyes (VideoFrame (0, EYES_LEFT), VideoFrame (7, EYES_RIGHT));
76 BOOST_CHECK_EQUAL (decoder.video->_decoded.size(), 15);
77 i = decoder.video->_decoded.begin();
78 for (int j = 0; j < 15; ++j) {
79 BOOST_CHECK_EQUAL (i->frame.index(), j / 2);
80 BOOST_CHECK_EQUAL (i->frame.eyes(), (j % 2) == 0 ? EYES_LEFT : EYES_RIGHT);
84 decoder.video->_decoded.clear ();
85 decoder.video->fill_both_eyes (VideoFrame (0, EYES_RIGHT), VideoFrame (7, EYES_RIGHT));
86 BOOST_CHECK_EQUAL (decoder.video->_decoded.size(), 14);
87 i = decoder.video->_decoded.begin();
88 for (int j = 0; j < 14; ++j) {
89 BOOST_CHECK_EQUAL (i->frame.index(), (j + 1) / 2);
90 BOOST_CHECK_EQUAL (i->frame.eyes(), (j % 2) == 0 ? EYES_RIGHT : EYES_LEFT);