summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorCarl Hetherington <cth@carlh.net>2025-01-10 01:35:42 +0100
committerCarl Hetherington <cth@carlh.net>2025-01-10 02:05:41 +0100
commit3fa25e91b9ed746b9a65fc6ff0b5fc4388097459 (patch)
tree6aa7328119e26c59ddb2ba3a306a7ac581cf9888 /test
parentb7cd23cc92140a0f5246c804ce0f1eaa7b3f9d6c (diff)
Fix invalid return values from fade() causing various odd effects (#2932).
Diffstat (limited to 'test')
-rw-r--r--test/video_content_test.cc53
-rw-r--r--test/wscript1
2 files changed, 54 insertions, 0 deletions
diff --git a/test/video_content_test.cc b/test/video_content_test.cc
new file mode 100644
index 000000000..ab5f38b77
--- /dev/null
+++ b/test/video_content_test.cc
@@ -0,0 +1,53 @@
+/*
+ Copyright (C) 2025 Carl Hetherington <cth@carlh.net>
+
+ This file is part of DCP-o-matic.
+
+ DCP-o-matic 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.
+
+ DCP-o-matic 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 DCP-o-matic. If not, see <http://www.gnu.org/licenses/>.
+
+*/
+
+
+#include "lib/content_factory.h"
+#include "lib/dcpomatic_time.h"
+#include "lib/video_content.h"
+#include "test.h"
+#include <boost/test/unit_test.hpp>
+
+
+BOOST_AUTO_TEST_CASE(video_content_fade_test)
+{
+ auto content = content_factory("test/data/flat_red.png")[0];
+ auto film = new_test_film("video_content_fade_test", { content });
+
+ content->video->set_length(240);
+ content->set_trim_start(film, dcpomatic::ContentTime::from_frames(24, 24));
+ content->video->set_fade_in(15);
+ content->video->set_fade_out(4);
+
+ /* Before fade-in */
+ BOOST_CHECK(content->video->fade(film, dcpomatic::ContentTime::from_frames(24 - 12, 24)).get_value_or(-99) == 0);
+ /* Start of fade-in */
+ BOOST_CHECK(content->video->fade(film, dcpomatic::ContentTime::from_frames(24, 24)).get_value_or(-99) == 0);
+ /* During fade-in */
+ BOOST_CHECK(content->video->fade(film, dcpomatic::ContentTime::from_frames(24 + 13, 24)).get_value_or(-99) > 0);
+ BOOST_CHECK(content->video->fade(film, dcpomatic::ContentTime::from_frames(24 + 13, 24)).get_value_or(-99) < 1);
+ /* After fade-in */
+ BOOST_CHECK(!static_cast<bool>(content->video->fade(film, dcpomatic::ContentTime::from_frames(24 + 55, 24))));
+ /* During fade-out */
+ BOOST_CHECK(content->video->fade(film, dcpomatic::ContentTime::from_frames(240 - 16, 24)).get_value_or(-90) <= 1);
+ /* After fade-out */
+ BOOST_CHECK(content->video->fade(film, dcpomatic::ContentTime::from_frames(240 + 20, 24)).get_value_or(-90) >= 0);
+}
+
diff --git a/test/wscript b/test/wscript
index 229330265..1cbcab29f 100644
--- a/test/wscript
+++ b/test/wscript
@@ -177,6 +177,7 @@ def build(bld):
upmixer_a_test.cc
util_test.cc
vf_test.cc
+ video_content_test.cc
video_content_scale_test.cc
video_level_test.cc
video_mxf_content_test.cc