X-Git-Url: https://git.carlh.net/gitweb/?a=blobdiff_plain;f=src%2Flib%2Fencoder.cc;h=e43325f58fde5ad4a7cc4fd97e620c8136ce0991;hb=67a68bd971ebe1b35daa3f75873b4ccb53c00ba0;hp=32af746a583a0cdae5f2e3b65123e7b8c619ee55;hpb=9a8a53ba467c275af7759adbca797a97b86cc4c6;p=dcpomatic.git diff --git a/src/lib/encoder.cc b/src/lib/encoder.cc index 32af746a5..e43325f58 100644 --- a/src/lib/encoder.cc +++ b/src/lib/encoder.cc @@ -56,7 +56,9 @@ using dcp::Data; int const Encoder::_history_size = 200; -/** @param f Film that we are encoding */ +/** @param film Film that we are encoding. + * @param writer Writer that we are using. + */ Encoder::Encoder (shared_ptr film, shared_ptr writer) : _film (film) , _writer (writer) @@ -165,16 +167,14 @@ Encoder::current_encoding_rate () const int Encoder::video_frames_enqueued () const { - if (!_last_player_video) { + if (!_last_player_video_time) { return 0; } - return _last_player_video->time().frames_floor (_film->video_frame_rate ()); + return _last_player_video_time->frames_floor (_film->video_frame_rate ()); } -/** Should be called when a frame has been encoded successfully. - * @param n Source frame index. - */ +/** Should be called when a frame has been encoded successfully */ void Encoder::frame_done () { @@ -188,13 +188,16 @@ Encoder::frame_done () } } -/** Called to start encoding of the next video frame in the DCP. This is called in order, +/** Called to request encoding of the next video frame in the DCP. This is called in order, * so each time the supplied frame is the one after the previous one. * pv represents one video frame, and could be empty if there is nothing to encode * for this DCP frame. + * + * @param pv PlayerVideo to encode. + * @param time Time of \p pv within the DCP. */ void -Encoder::encode (shared_ptr pv) +Encoder::encode (shared_ptr pv, DCPTime time) { _waker.nudge (); @@ -222,22 +225,22 @@ Encoder::encode (shared_ptr pv) */ rethrow (); - Frame const position = pv->time().frames_floor(_film->video_frame_rate()); + Frame const position = time.frames_floor(_film->video_frame_rate()); if (_writer->can_fake_write (position)) { /* We can fake-write this frame */ - LOG_DEBUG_ENCODE("Frame @ %1 FAKE", to_string(pv->time())); + LOG_DEBUG_ENCODE("Frame @ %1 FAKE", to_string(time)); _writer->fake_write (position, pv->eyes ()); frame_done (); } else if (pv->has_j2k ()) { - LOG_DEBUG_ENCODE("Frame @ %1 J2K", to_string(pv->time())); + LOG_DEBUG_ENCODE("Frame @ %1 J2K", to_string(time)); /* This frame already has JPEG2000 data, so just write it */ _writer->write (pv->j2k(), position, pv->eyes ()); } else if (_last_player_video && _writer->can_repeat(position) && pv->same (_last_player_video)) { - LOG_DEBUG_ENCODE("Frame @ %1 REPEAT", to_string(pv->time())); + LOG_DEBUG_ENCODE("Frame @ %1 REPEAT", to_string(time)); _writer->repeat (position, pv->eyes ()); } else { - LOG_DEBUG_ENCODE("Frame @ %1 ENCODE", to_string(pv->time())); + LOG_DEBUG_ENCODE("Frame @ %1 ENCODE", to_string(time)); /* Queue this new frame for encoding */ LOG_TIMING ("add-frame-to-queue queue=%1", _queue.size ()); _queue.push_back (shared_ptr ( @@ -258,6 +261,7 @@ Encoder::encode (shared_ptr pv) } _last_player_video = pv; + _last_player_video_time = time; } void