summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCarl Hetherington <cth@carlh.net>2025-01-17 11:14:32 +0100
committerCarl Hetherington <cth@carlh.net>2025-01-18 21:06:40 +0100
commitef2eb8521358684042807dfcec62ce0e5639ec8d (patch)
tree15d0e21d870399f30ca0f658a428e4f22a7fcce5
parent10c45dc1418bc8c4766ec2c189dc78162d4664dd (diff)
Fix first frame being shown even when trimmed (#2952).
We calculated the DCP time of the first frame (when its content was trimmed) and it was clamped from -8 frames to 0, which meant it was used when it should not have been.
-rw-r--r--src/lib/player.cc2
m---------test/data0
-rw-r--r--test/video_trim_test.cc57
-rw-r--r--test/wscript1
4 files changed, 59 insertions, 1 deletions
diff --git a/src/lib/player.cc b/src/lib/player.cc
index f348f6b28..1f44c961c 100644
--- a/src/lib/player.cc
+++ b/src/lib/player.cc
@@ -608,7 +608,7 @@ Player::dcp_to_content_time (shared_ptr<const Piece> piece, DCPTime t) const
DCPTime
Player::content_time_to_dcp (shared_ptr<const Piece> piece, ContentTime t) const
{
- return max (DCPTime(), DCPTime(t - piece->content->trim_start(), piece->frc) + piece->content->position());
+ return DCPTime(t - piece->content->trim_start(), piece->frc) + piece->content->position();
}
diff --git a/test/data b/test/data
-Subproject dc18332316687dc2e4171e3b5905ea266c35763
+Subproject c2ad073f0bf7105fb628dbbe2eb82d92bc800dc
diff --git a/test/video_trim_test.cc b/test/video_trim_test.cc
new file mode 100644
index 000000000..c4b24b449
--- /dev/null
+++ b/test/video_trim_test.cc
@@ -0,0 +1,57 @@
+/*
+ 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/image_png.h"
+#include "lib/player.h"
+#include "lib/player_video.h"
+#include "test.h"
+#include <boost/test/unit_test.hpp>
+
+
+using std::make_shared;
+using std::shared_ptr;
+
+
+
+BOOST_AUTO_TEST_CASE(video_trim_test)
+{
+ auto content = content_factory("test/data/count300bd24.m2ts")[0];
+ auto film = new_test_film("trim_video_test", { content });
+
+ content->set_trim_start(film, dcpomatic::ContentTime::from_frames(8, 24));
+
+ shared_ptr<PlayerVideo> first_video;
+
+ auto player = make_shared<Player>(film, Image::Alignment::COMPACT);
+ player->Video.connect([&first_video](shared_ptr<PlayerVideo> video, dcpomatic::DCPTime) {
+ first_video = video;
+ });
+
+ while (!first_video) {
+ BOOST_REQUIRE(!player->pass());
+ }
+
+ image_as_png(first_video->image([](AVPixelFormat) { return AV_PIX_FMT_RGB24; }, VideoRange::FULL, true)).write("build/test/video_trim_test.png");
+ check_image("test/data/video_trim_test.png", "build/test/video_trim_test.png");
+}
+
diff --git a/test/wscript b/test/wscript
index 8c02f8ebc..44f4d9c63 100644
--- a/test/wscript
+++ b/test/wscript
@@ -184,6 +184,7 @@ def build(bld):
video_mxf_content_test.cc
vf_kdm_test.cc
writer_test.cc
+ video_trim_test.cc
zipper_test.cc
"""