summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCarl Hetherington <cth@carlh.net>2015-07-24 22:14:31 +0100
committerCarl Hetherington <cth@carlh.net>2015-07-24 22:14:31 +0100
commit7ba331621429d3516ba48a4585e58f1f6fa76cdf (patch)
tree15a386afd66bf02307f18c9da232387f08aaf835
parent5807c8a5f7baec5355a2bae2771f197989001c92 (diff)
Fix mistaken clamp to length_after_trim after adding trim_start.
-rw-r--r--ChangeLog5
-rw-r--r--src/lib/player.cc6
-rw-r--r--src/lib/video_decoder.cc7
-rw-r--r--test/time_calculation_test.cc16
4 files changed, 23 insertions, 11 deletions
diff --git a/ChangeLog b/ChangeLog
index 60f49027b..7687e265d 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2015-07-24 Carl Hetherington <cth@carlh.net>
+
+ * Fix problems when using large start trims relative
+ to content length.
+
2015-07-22 Carl Hetherington <cth@carlh.net>
* Use NR for rating an in ISDCF name if none is specified.
diff --git a/src/lib/player.cc b/src/lib/player.cc
index a44d916d8..e73481107 100644
--- a/src/lib/player.cc
+++ b/src/lib/player.cc
@@ -538,9 +538,9 @@ Player::content_video_to_dcp (shared_ptr<const Piece> piece, Frame f) const
Frame
Player::dcp_to_resampled_audio (shared_ptr<const Piece> piece, DCPTime t) const
{
- DCPTime s = t - piece->content->position () + DCPTime (piece->content->trim_start (), piece->frc);
- s = max (DCPTime (), min (piece->content->length_after_trim(), s));
- return s.frames (_film->audio_frame_rate ());
+ DCPTime s = t - piece->content->position ();
+ s = min (piece->content->length_after_trim(), s);
+ return max (DCPTime (), DCPTime (piece->content->trim_start (), piece->frc) + s).frames (_film->audio_frame_rate ());
}
ContentTime
diff --git a/src/lib/video_decoder.cc b/src/lib/video_decoder.cc
index cdf8bc12a..944b1b695 100644
--- a/src/lib/video_decoder.cc
+++ b/src/lib/video_decoder.cc
@@ -285,14 +285,11 @@ VideoDecoder::video (shared_ptr<const ImageProxy> image, Frame frame)
to = to_push.front().frame;
}
- /* It has been known that this method receives frames out of order; at this
- point I'm not sure why, but we'll just ignore them.
+ /* If we've pre-rolled on a seek we may now receive out-of-order frames
+ (frames before the last seek time) which we can just ignore.
*/
if (from && to && from.get() > to.get()) {
- _video_content->film()->log()->log (
- String::compose ("Ignoring out-of-order decoded frame %1 after %2", to.get(), from.get()), Log::TYPE_WARNING
- );
return;
}
diff --git a/test/time_calculation_test.cc b/test/time_calculation_test.cc
index 2be49f629..9f91be584 100644
--- a/test/time_calculation_test.cc
+++ b/test/time_calculation_test.cc
@@ -562,7 +562,7 @@ BOOST_AUTO_TEST_CASE (player_time_calculation_test3)
BOOST_REQUIRE_EQUAL (player->_pieces.size(), 1);
piece = player->_pieces.front ();
BOOST_CHECK_EQUAL (player->dcp_to_resampled_audio (piece, DCPTime ()), 0);
- BOOST_CHECK_EQUAL (player->dcp_to_resampled_audio (piece, DCPTime::from_seconds (0.50)), 0);
+ BOOST_CHECK_EQUAL (player->dcp_to_resampled_audio (piece, DCPTime::from_seconds (0.50)), 0);
BOOST_CHECK_EQUAL (player->dcp_to_resampled_audio (piece, DCPTime::from_seconds (3.00)), 72000);
BOOST_CHECK_EQUAL (player->dcp_to_resampled_audio (piece, DCPTime::from_seconds (4.50)), 144000);
BOOST_CHECK_EQUAL (player->dcp_to_resampled_audio (piece, DCPTime::from_seconds (9.75)), 396000);
@@ -596,8 +596,7 @@ BOOST_AUTO_TEST_CASE (player_time_calculation_test3)
BOOST_CHECK_EQUAL (player->dcp_to_resampled_audio (piece, DCPTime::from_seconds (9.75)), 324000);
/* Position 3s, 1.6s trim, content rate 24, DCP rate 25, both audio rates still 48k.
- Since the DCP is faster, and resampled audio is at the DCP rate, our 1.6s trim in
- content time corresponds to 1.6 * 24 * 48000 / 25 audio samples.
+ 1s of content is 46080 samples after resampling.
*/
content->set_position (DCPTime::from_seconds (3));
content->set_trim_start (ContentTime::from_seconds (1.6));
@@ -748,4 +747,15 @@ BOOST_AUTO_TEST_CASE (player_time_calculation_test3)
BOOST_CHECK_EQUAL (player->dcp_to_resampled_audio (piece, DCPTime::from_seconds (3.00)), 72000);
BOOST_CHECK_EQUAL (player->dcp_to_resampled_audio (piece, DCPTime::from_seconds (4.50)), 144000);
BOOST_CHECK_EQUAL (player->dcp_to_resampled_audio (piece, DCPTime::from_seconds (9.75)), 396000);
+
+ /* Check with a large start trim */
+ content->set_position (DCPTime::from_seconds (0));
+ content->set_trim_start (ContentTime::from_seconds (54143));
+ content->set_video_frame_rate (24);
+ film->set_video_frame_rate (24);
+ stream->_frame_rate = 48000;
+ player->setup_pieces ();
+ BOOST_REQUIRE_EQUAL (player->_pieces.size(), 1);
+ piece = player->_pieces.front ();
+ BOOST_CHECK_EQUAL (player->dcp_to_resampled_audio (piece, DCPTime ()), 54143L * 48000);
}