summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorCarl Hetherington <cth@carlh.net>2015-08-27 15:54:13 +0100
committerCarl Hetherington <cth@carlh.net>2015-08-27 15:54:13 +0100
commit52dc5e2f2d0e5be8e9ba75b5978a1de58b11cb25 (patch)
tree131d4cda682f1ca95ebf7f24004e272f4c4a62d3 /src
parentee1ff372a27202a0244f48a04c955dbb48644573 (diff)
Fix Player::dcp_to_content_video with similar but not equal content/DCP frame rates.
Diffstat (limited to 'src')
-rw-r--r--src/lib/audio_decoder_stream.cc2
-rw-r--r--src/lib/player.cc12
-rw-r--r--src/lib/transcoder.cc1
3 files changed, 11 insertions, 4 deletions
diff --git a/src/lib/audio_decoder_stream.cc b/src/lib/audio_decoder_stream.cc
index 2f12af198..365be336f 100644
--- a/src/lib/audio_decoder_stream.cc
+++ b/src/lib/audio_decoder_stream.cc
@@ -62,7 +62,7 @@ AudioDecoderStream::get (Frame frame, Frame length, bool accurate)
{
shared_ptr<ContentAudio> dec;
- _content->film()->log()->log (String::compose ("ADS has request for %1 %2", frame, length), Log::TYPE_DEBUG_DECODE);
+ _content->film()->log()->log (String::compose ("-> ADS has request for %1 %2", frame, length), Log::TYPE_DEBUG_DECODE);
Frame const end = frame + length - 1;
diff --git a/src/lib/player.cc b/src/lib/player.cc
index d2ef1a5ff..d6e142c5e 100644
--- a/src/lib/player.cc
+++ b/src/lib/player.cc
@@ -524,10 +524,16 @@ Player::dcp_to_content_video (shared_ptr<const Piece> piece, DCPTime t) const
shared_ptr<const VideoContent> vc = dynamic_pointer_cast<const VideoContent> (piece->content);
DCPTime s = t - piece->content->position ();
s = min (piece->content->length_after_trim(), s);
- /* We're returning a frame index here so we need to floor() the conversion since we want to know the frame
- that contains t, I think
+ s = max (DCPTime(), s + DCPTime (piece->content->trim_start(), piece->frc));
+
+ /* It might seem more logical here to convert s to a ContentTime (using the FrameRateChange)
+ then convert that ContentTime to frames at the content's rate. However this fails for
+ situations like content at 29.9978733fps, DCP at 30fps. The accuracy of the Time type is not
+ enough to distinguish between the two with low values of time (e.g. 3200 in Time units).
+
+ Instead we convert the DCPTime using the DCP video rate then account for any skip/repeat.
*/
- return max (ContentTime (), ContentTime (s, piece->frc) + piece->content->trim_start ()).frames_floor (vc->video_frame_rate ());
+ return s.frames_floor (piece->frc.dcp) / piece->frc.factor ();
}
DCPTime
diff --git a/src/lib/transcoder.cc b/src/lib/transcoder.cc
index ad8e4ab9b..27e35ac52 100644
--- a/src/lib/transcoder.cc
+++ b/src/lib/transcoder.cc
@@ -32,6 +32,7 @@
#include "player.h"
#include "job.h"
#include "writer.h"
+#include "compose.hpp"
#include "subtitle_content.h"
#include <boost/signals2.hpp>
#include <boost/foreach.hpp>