- _log->log (String::compose ("VD has request for %1", frame), LogEntry::TYPE_DEBUG_DECODE);
-
- if (_decoded.empty() || frame < _decoded.front().frame.index() || frame > (_decoded.back().frame.index() + 1)) {
- _parent->seek (ContentTime::from_frames (frame, _content->active_video_frame_rate()), accurate);
- }
-
- unsigned int const frames_wanted = _content->video->frame_type() == VIDEO_FRAME_TYPE_2D ? 1 : 2;
-
- list<ContentVideo> dec;
-
- /* Now enough pass() calls should either:
- * (a) give us what we want, or
- * (b) give us something after what we want, indicating that we will never get what we want, or
- * (c) hit the end of the decoder.
- */
- if (accurate) {
- /* We are being accurate, so we want the right frame.
- * This could all be one statement but it's split up for clarity.
- */
- bool no_data = false;
-
- while (true) {
- if (decoded(frame).size() == frames_wanted) {
- /* We got what we want */
- break;
- }
-
- if (_parent->pass (Decoder::PASS_REASON_VIDEO, accurate)) {
- /* The decoder has nothing more for us */
- no_data = true;
- break;
- }
-
- if (!_decoded.empty() && _decoded.front().frame.index() > frame) {
- /* We're never going to get the frame we want. Perhaps the caller is asking
- * for a video frame before the content's video starts (if its audio
- * begins before its video, for example).
- */
- break;
- }
- }
-
- dec = decoded (frame);
-
- if (no_data && dec.empty()) {
- _no_data_frame = frame;
- }
-
- } else {
- /* Any frame(s) will do: use the first one(s) that comes out of pass() */
- while (_decoded.size() < frames_wanted && !_parent->pass (Decoder::PASS_REASON_VIDEO, accurate)) {}
- list<ContentVideo>::const_iterator i = _decoded.begin();
- unsigned int j = 0;
- while (i != _decoded.end() && j < frames_wanted) {
- dec.push_back (*i);
- ++i;
- ++j;
- }
- }
-
- /* Clean up _decoded; keep the frame we are returning, if any (which may have two images
- for 3D), but nothing before that */
- while (!_decoded.empty() && !dec.empty() && _decoded.front().frame.index() < dec.front().frame.index()) {
- _decoded.pop_front ();
- }
-
- return dec;
-}
-
-/** Fill _decoded from `from' up to, but not including, `to' with
- * a frame for one particular Eyes value (which could be EYES_BOTH,
- * EYES_LEFT or EYES_RIGHT)