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 "lib/image_decoder.h"
22 #include "lib/image_content.h"
23 #include "lib/content_video.h"
24 #include "lib/video_decoder.h"
27 #include <boost/test/unit_test.hpp>
28 #include <boost/make_shared.hpp>
33 using boost::shared_ptr;
34 using boost::make_shared;
36 BOOST_AUTO_TEST_CASE (video_decoder_fill_test1)
38 shared_ptr<Film> film = new_test_film ("video_decoder_fill_test");
39 shared_ptr<ImageContent> c = make_shared<ImageContent> (film, "test/data/simple_testcard_640x480.png");
40 ImageDecoder decoder (c, film->log());
42 decoder.video->fill_one_eye (0, 4, EYES_BOTH);
43 BOOST_CHECK_EQUAL (decoder.video->_decoded.size(), 4U);
44 list<ContentVideo>::iterator i = decoder.video->_decoded.begin();
45 for (int j = 0; j < 4; ++j) {
46 BOOST_CHECK_EQUAL (i->frame.index(), j);
50 decoder.video->_decoded.clear ();
52 decoder.video->fill_one_eye (0, 7, EYES_BOTH);
53 BOOST_CHECK_EQUAL (decoder.video->_decoded.size(), 7);
54 i = decoder.video->_decoded.begin();
55 for (int j = 0; j < 7; ++j) {
56 BOOST_CHECK_EQUAL (i->frame.index(), j);
61 BOOST_AUTO_TEST_CASE (video_decoder_fill_test2)
63 shared_ptr<Film> film = new_test_film ("video_decoder_fill_test");
64 shared_ptr<ImageContent> c = make_shared<ImageContent> (film, "test/data/simple_testcard_640x480.png");
65 ImageDecoder decoder (c, film->log());
67 decoder.video->fill_both_eyes (VideoFrame (0, EYES_LEFT), VideoFrame (4, EYES_LEFT));
68 BOOST_CHECK_EQUAL (decoder.video->_decoded.size(), 8);
69 list<ContentVideo>::iterator i = decoder.video->_decoded.begin();
70 for (int j = 0; j < 8; ++j) {
71 BOOST_CHECK_EQUAL (i->frame.index(), j / 2);
72 BOOST_CHECK_EQUAL (i->frame.eyes(), (j % 2) == 0 ? EYES_LEFT : EYES_RIGHT);
76 decoder.video->_decoded.clear ();
77 decoder.video->fill_both_eyes (VideoFrame (0, EYES_LEFT), VideoFrame (7, EYES_RIGHT));
78 BOOST_CHECK_EQUAL (decoder.video->_decoded.size(), 15);
79 i = decoder.video->_decoded.begin();
80 for (int j = 0; j < 15; ++j) {
81 BOOST_CHECK_EQUAL (i->frame.index(), j / 2);
82 BOOST_CHECK_EQUAL (i->frame.eyes(), (j % 2) == 0 ? EYES_LEFT : EYES_RIGHT);
86 decoder.video->_decoded.clear ();
87 decoder.video->fill_both_eyes (VideoFrame (0, EYES_RIGHT), VideoFrame (7, EYES_RIGHT));
88 BOOST_CHECK_EQUAL (decoder.video->_decoded.size(), 14);
89 i = decoder.video->_decoded.begin();
90 for (int j = 0; j < 14; ++j) {
91 BOOST_CHECK_EQUAL (i->frame.index(), (j + 1) / 2);
92 BOOST_CHECK_EQUAL (i->frame.eyes(), (j % 2) == 0 ? EYES_RIGHT : EYES_LEFT);