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
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;
}
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);
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));
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);
}