X-Git-Url: https://git.carlh.net/gitweb/?a=blobdiff_plain;f=src%2Flib%2Fencoder.cc;h=e43325f58fde5ad4a7cc4fd97e620c8136ce0991;hb=67a68bd971ebe1b35daa3f75873b4ccb53c00ba0;hp=8a6e1ce8c954c35a8f923e5d372e62e8254f3fa2;hpb=12a621982da4a7e0976829654ecc16026665c4e9;p=dcpomatic.git diff --git a/src/lib/encoder.cc b/src/lib/encoder.cc index 8a6e1ce8c..e43325f58 100644 --- a/src/lib/encoder.cc +++ b/src/lib/encoder.cc @@ -45,6 +45,7 @@ #define LOG_GENERAL_NC(...) _film->log()->log (__VA_ARGS__, LogEntry::TYPE_GENERAL); #define LOG_ERROR(...) _film->log()->log (String::compose (__VA_ARGS__), LogEntry::TYPE_ERROR); #define LOG_TIMING(...) _film->log()->log (String::compose (__VA_ARGS__), LogEntry::TYPE_TIMING); +#define LOG_DEBUG_ENCODE(...) _film->log()->log (String::compose (__VA_ARGS__), LogEntry::TYPE_DEBUG_ENCODE); using std::list; using std::cout; @@ -55,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) @@ -164,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 () { @@ -187,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 (); @@ -221,18 +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(time)); _writer->fake_write (position, pv->eyes ()); frame_done (); } else if (pv->has_j2k ()) { + 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(time)); _writer->repeat (position, pv->eyes ()); } else { + 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 ( @@ -253,6 +261,7 @@ Encoder::encode (shared_ptr pv) } _last_player_video = pv; + _last_player_video_time = time; } void