+ return dec;
+}
+
+/** Fill _decoded_video 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)
+ */
+void
+VideoDecoder::fill_one_eye (Frame from, Frame to, Eyes eye)
+{
+ if (to == 0) {
+ /* Already OK */
+ return;
+ }
+
+ /* Fill with black... */
+ shared_ptr<const ImageProxy> filler_image (new RawImageProxy (_black_image));
+ Part filler_part = PART_WHOLE;
+
+ /* ...unless there's some video we can fill with */
+ if (!_decoded_video.empty ()) {
+ filler_image = _decoded_video.back().image;
+ filler_part = _decoded_video.back().part;
+ }
+
+ for (Frame i = from; i < to; ++i) {
+#ifdef DCPOMATIC_DEBUG
+ test_gaps++;
+#endif
+ _decoded_video.push_back (
+ ContentVideo (filler_image, eye, filler_part, i)
+ );
+ }
+}
+
+/** Fill _decoded_video from `from' up to, but not including, `to'
+ * adding both left and right eye frames.
+ */
+void
+VideoDecoder::fill_both_eyes (Frame from, Frame to, Eyes eye)
+{
+ if (to == 0 && eye == EYES_LEFT) {
+ /* Already OK */
+ return;
+ }
+
+ /* Fill with black... */
+ shared_ptr<const ImageProxy> filler_left_image (new RawImageProxy (_black_image));
+ shared_ptr<const ImageProxy> filler_right_image (new RawImageProxy (_black_image));
+ Part filler_left_part = PART_WHOLE;
+ Part filler_right_part = PART_WHOLE;
+
+ /* ...unless there's some video we can fill with */
+ for (list<ContentVideo>::const_reverse_iterator i = _decoded_video.rbegin(); i != _decoded_video.rend(); ++i) {
+ if (i->eyes == EYES_LEFT && !filler_left_image) {
+ filler_left_image = i->image;
+ filler_left_part = i->part;
+ } else if (i->eyes == EYES_RIGHT && !filler_right_image) {
+ filler_right_image = i->image;
+ filler_right_part = i->part;
+ }
+
+ if (filler_left_image && filler_right_image) {
+ break;
+ }
+ }
+
+ Frame filler_frame = from;
+ Eyes filler_eye = _decoded_video.empty() ? EYES_LEFT : _decoded_video.back().eyes;
+
+ if (_decoded_video.empty ()) {
+ filler_frame = 0;
+ filler_eye = EYES_LEFT;
+ } else if (_decoded_video.back().eyes == EYES_LEFT) {
+ filler_frame = _decoded_video.back().frame;
+ filler_eye = EYES_RIGHT;
+ } else if (_decoded_video.back().eyes == EYES_RIGHT) {
+ filler_frame = _decoded_video.back().frame + 1;
+ filler_eye = EYES_LEFT;
+ }
+
+ while (filler_frame != to || filler_eye != eye) {
+
+#ifdef DCPOMATIC_DEBUG
+ test_gaps++;
+#endif
+
+ _decoded_video.push_back (
+ ContentVideo (
+ filler_eye == EYES_LEFT ? filler_left_image : filler_right_image,
+ filler_eye,
+ filler_eye == EYES_LEFT ? filler_left_part : filler_right_part,
+ filler_frame
+ )
+ );
+
+ if (filler_eye == EYES_LEFT) {
+ filler_eye = EYES_RIGHT;
+ } else {
+ filler_eye = EYES_LEFT;
+ ++filler_frame;
+ }
+ }