diff options
| author | Carl Hetherington <cth@carlh.net> | 2016-06-14 15:07:58 +0100 |
|---|---|---|
| committer | Carl Hetherington <cth@carlh.net> | 2016-06-14 15:07:58 +0100 |
| commit | 0b6f2d7b04819711228ed5fbc5d299b58cef997e (patch) | |
| tree | 6acc37024cadbcc50755e8cc7c5075749893e231 /src/lib/encoder.cc | |
| parent | 2a72bebc04cc5d0b34c81840f10bd1387955a7a4 (diff) | |
Clean up of 3D->2D conversion.
It makes slightly more sense to discard 2D in the Transcoder
rather than the Encoder. Unfortunately this requires quite
invasive changes, mainly to remove Encoder::_position and instead
derive this information from the PlayerVideo that is being handled.
This is also nicer than before, I think.
A notable change is that in player.cc; using time rather than
content_video_to_dcp(). This means we are assuming that the decoder
returns video at the time we ask it to, rather than checking
what it has returned. I can't think of a problem with this (yet).
Diffstat (limited to 'src/lib/encoder.cc')
| -rw-r--r-- | src/lib/encoder.cc | 44 |
1 files changed, 12 insertions, 32 deletions
diff --git a/src/lib/encoder.cc b/src/lib/encoder.cc index 38bf4e290..8f2aa58f7 100644 --- a/src/lib/encoder.cc +++ b/src/lib/encoder.cc @@ -58,7 +58,6 @@ int const Encoder::_history_size = 25; /** @param f Film that we are encoding */ Encoder::Encoder (shared_ptr<const Film> film, shared_ptr<Writer> writer) : _film (film) - , _position (0) , _writer (writer) { servers_list_changed (); @@ -140,12 +139,11 @@ Encoder::current_encoding_rate () const return _history_size / (seconds (now) - seconds (_time_history.back ())); } -/** @return Number of video frames that have been sent out */ +/** @return Number of video frames that have been queued for encoding */ int -Encoder::video_frames_out () const +Encoder::video_frames_enqueued () const { - boost::mutex::scoped_lock (_state_mutex); - return _position; + return _last_player_video->time().frames_floor (_film->video_frame_rate ()); } /** Should be called when a frame has been encoded successfully. @@ -170,27 +168,7 @@ Encoder::frame_done () * for this DCP frame. */ void -Encoder::encode (list<shared_ptr<PlayerVideo> > pv) -{ - BOOST_FOREACH (shared_ptr<PlayerVideo> i, pv) { - if (!_film->three_d()) { - /* 2D DCP */ - if (i->eyes() == EYES_RIGHT) { - /* Discard right-eye images */ - continue; - } else if (i->eyes() == EYES_LEFT) { - /* Use left-eye images for both eyes */ - i->set_eyes (EYES_BOTH); - } - } - - enqueue (i); - } - ++_position; -} - -void -Encoder::enqueue (shared_ptr<PlayerVideo> pv) +Encoder::encode (shared_ptr<PlayerVideo> pv) { _waker.nudge (); @@ -216,22 +194,24 @@ Encoder::enqueue (shared_ptr<PlayerVideo> pv) */ rethrow (); - if (_writer->can_fake_write (_position)) { + Frame const position = pv->time().frames_floor(_film->video_frame_rate()); + + if (_writer->can_fake_write (position)) { /* We can fake-write this frame */ - _writer->fake_write (_position, pv->eyes ()); + _writer->fake_write (position, pv->eyes ()); frame_done (); } else if (pv->has_j2k ()) { /* 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)) { - _writer->repeat (_position, pv->eyes ()); + _writer->write (pv->j2k(), position, pv->eyes ()); + } else if (_last_player_video && _writer->can_repeat(position) && pv->same (_last_player_video)) { + _writer->repeat (position, pv->eyes ()); } else { /* Queue this new frame for encoding */ LOG_TIMING ("add-frame-to-queue queue=%1", _queue.size ()); _queue.push_back (shared_ptr<DCPVideo> ( new DCPVideo ( pv, - _position, + position, _film->video_frame_rate(), _film->j2k_bandwidth(), _film->resolution(), |
