2 Copyright (C) 2015 Carl Hetherington <cth@carlh.net>
4 This program is free software; you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by
6 the Free Software Foundation; either version 2 of the License, or
7 (at your option) any later version.
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU General Public License for more details.
14 You should have received a copy of the GNU General Public License
15 along with this program; if not, write to the Free Software
16 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
21 #include "lib/ffmpeg_content.h"
23 #include <boost/test/unit_test.hpp>
27 using boost::shared_ptr;
29 BOOST_AUTO_TEST_CASE (ffmpeg_time_calculation_test)
31 shared_ptr<Film> film = new_test_film ("ffmpeg_time_calculation_test");
33 string const xml = "<Content>"
35 "<BurnSubtitles>0</BurnSubtitles>"
36 "<BitsPerPixel>8</BitsPerPixel>"
37 "<Path>/home/c.hetherington/DCP/clapperboard.mp4</Path>"
38 "<Digest>2760e03c7251480f7f02c01a907792673784335</Digest>"
39 "<Position>0</Position>"
40 "<TrimStart>0</TrimStart>"
41 "<TrimEnd>0</TrimEnd>"
42 "<VideoLength>1353600</VideoLength>"
43 "<VideoWidth>1280</VideoWidth>"
44 "<VideoHeight>720</VideoHeight>"
45 "<VideoFrameRate>25</VideoFrameRate>"
46 "<VideoFrameType>0</VideoFrameType>"
47 "<LeftCrop>0</LeftCrop>"
48 "<RightCrop>0</RightCrop>"
49 "<TopCrop>0</TopCrop>"
50 "<BottomCrop>0</BottomCrop>"
55 "<InputTransferFunction>"
56 "<Type>ModifiedGamma</Type>"
57 "<Power>2.222222222222222</Power>"
58 "<Threshold>0.081</Threshold>"
61 "</InputTransferFunction>"
64 "<GreenX>0.3</GreenX>"
65 "<GreenY>0.6</GreenY>"
68 "<WhiteX>0.3127</WhiteX>"
69 "<WhiteY>0.329</WhiteY>"
70 "<OutputGamma>2.6</OutputGamma>"
73 "<FadeOut>0</FadeOut>"
74 "<AudioGain>0</AudioGain>"
75 "<AudioDelay>0</AudioDelay>"
76 "<UseSubtitles>0</UseSubtitles>"
77 "<SubtitleXOffset>0</SubtitleXOffset>"
78 "<SubtitleYOffset>0</SubtitleYOffset>"
79 "<SubtitleXScale>1</SubtitleXScale>"
80 "<SubtitleYScale>1</SubtitleYScale>"
81 "<SubtitleLanguage></SubtitleLanguage>"
83 "<Selected>1</Selected>"
84 "<Name>und; 2 channels</Name>"
86 "<FrameRate>44100</FrameRate>"
87 "<Channels>2</Channels>"
88 "<FirstAudio>0</FirstAudio>"
90 "<InputChannels>2</InputChannels>"
91 "<OutputChannels>12</OutputChannels>"
92 "<Gain Input=\"0\" Output=\"0\">1</Gain>"
93 "<Gain Input=\"0\" Output=\"1\">0</Gain>"
94 "<Gain Input=\"0\" Output=\"2\">0</Gain>"
95 "<Gain Input=\"0\" Output=\"3\">0</Gain>"
96 "<Gain Input=\"0\" Output=\"4\">0</Gain>"
97 "<Gain Input=\"0\" Output=\"5\">0</Gain>"
98 "<Gain Input=\"0\" Output=\"6\">0</Gain>"
99 "<Gain Input=\"0\" Output=\"7\">0</Gain>"
100 "<Gain Input=\"0\" Output=\"8\">0</Gain>"
101 "<Gain Input=\"0\" Output=\"9\">0</Gain>"
102 "<Gain Input=\"0\" Output=\"10\">0</Gain>"
103 "<Gain Input=\"0\" Output=\"11\">0</Gain>"
104 "<Gain Input=\"1\" Output=\"0\">0</Gain>"
105 "<Gain Input=\"1\" Output=\"1\">1</Gain>"
106 "<Gain Input=\"1\" Output=\"2\">0</Gain>"
107 "<Gain Input=\"1\" Output=\"3\">0</Gain>"
108 "<Gain Input=\"1\" Output=\"4\">0</Gain>"
109 "<Gain Input=\"1\" Output=\"5\">0</Gain>"
110 "<Gain Input=\"1\" Output=\"6\">0</Gain>"
111 "<Gain Input=\"1\" Output=\"7\">0</Gain>"
112 "<Gain Input=\"1\" Output=\"8\">0</Gain>"
113 "<Gain Input=\"1\" Output=\"9\">0</Gain>"
114 "<Gain Input=\"1\" Output=\"10\">0</Gain>"
115 "<Gain Input=\"1\" Output=\"11\">0</Gain>"
118 "<FirstVideo>0</FirstVideo>"
121 shared_ptr<cxml::Document> doc (new cxml::Document);
122 doc->read_string (xml);
125 shared_ptr<FFmpegContent> content (new FFmpegContent (film, doc, film->state_version(), notes));
127 /* 25fps content, 25fps DCP */
128 film->set_video_frame_rate (25);
129 BOOST_CHECK_EQUAL (content->full_length(), DCPTime::from_seconds (content->video_length() / 25.0));
130 /* 25fps content, 24fps DCP; length should be increased */
131 film->set_video_frame_rate (24);
132 BOOST_CHECK_EQUAL (content->full_length(), DCPTime::from_seconds (content->video_length() / 24.0));
133 /* 25fps content, 30fps DCP; length should be decreased */
134 film->set_video_frame_rate (30);
135 BOOST_CHECK_EQUAL (content->full_length(), DCPTime::from_seconds (content->video_length() / 30.0));
136 /* 25fps content, 50fps DCP; length should be the same */
137 film->set_video_frame_rate (50);
138 BOOST_CHECK_EQUAL (content->full_length(), DCPTime::from_seconds (content->video_length() / 25.0));
139 /* 25fps content, 60fps DCP; length should be decreased */
140 film->set_video_frame_rate (60);
141 BOOST_CHECK_EQUAL (content->full_length(), DCPTime::from_seconds (content->video_length() * (50.0 / 60) / 25.0));
144 /* XXX much more stuff to test */