Fixes for separate L/R eye content.
authorCarl Hetherington <cth@carlh.net>
Fri, 29 Jul 2016 11:19:50 +0000 (12:19 +0100)
committerCarl Hetherington <cth@carlh.net>
Fri, 29 Jul 2016 11:19:50 +0000 (12:19 +0100)
ChangeLog
src/lib/video_decoder.cc

index bb6059eb55018b90b0dce5334280802fdbbbba65..9c6bd45e9e2d18607f34e4b42578bd3a87b24536 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,8 @@
 2016-07-29  c.hetherington  <cth@carlh.net>
 
+       * Fix various problems with separate L/R eye
+       content.
+
        * Rearrange Make KDM window and replace the
        confusing OK/Cancel buttons with "Make KDM" (part of #848).
        Rearrange the KDM Creator window similarly.
index aedc1a13f0b80f09dfde79af245b7a41ff813911..f87e4108616ccdc260d70d10f0dacc2a1e5a67d9 100644 (file)
@@ -90,7 +90,22 @@ VideoDecoder::get (Frame frame, bool accurate)
                _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;
+       unsigned int frames_wanted = 0;
+       switch (_content->video->frame_type()) {
+       case VIDEO_FRAME_TYPE_2D:
+       case VIDEO_FRAME_TYPE_3D:
+       case VIDEO_FRAME_TYPE_3D_ALTERNATE:
+       case VIDEO_FRAME_TYPE_3D_LEFT:
+       case VIDEO_FRAME_TYPE_3D_RIGHT:
+               frames_wanted = 1;
+               break;
+       case VIDEO_FRAME_TYPE_3D_LEFT_RIGHT:
+       case VIDEO_FRAME_TYPE_3D_TOP_BOTTOM:
+               frames_wanted = 2;
+               break;
+       default:
+               DCPOMATIC_ASSERT (false);
+       }
 
        list<ContentVideo> dec;
 
@@ -288,8 +303,16 @@ VideoDecoder::give (shared_ptr<const ImageProxy> image, Frame frame)
                        _content->video->frame_type() == VIDEO_FRAME_TYPE_2D ? EYES_BOTH : EYES_LEFT
                        );
        } else if (!_decoded.empty ()) {
+               /* Get the last frame we have */
                from = _decoded.back().frame;
+               /* And move onto the first frame we need */
                ++(*from);
+               if (_content->video->frame_type() == VIDEO_FRAME_TYPE_3D_LEFT || _content->video->frame_type() == VIDEO_FRAME_TYPE_3D_RIGHT) {
+                       /* The previous ++ will increment a 3D-left-eye to the same index right-eye.  If we are dealing with
+                          a single-eye source we need an extra ++ to move back to the same eye.
+                       */
+                       ++(*from);
+               }
        }
 
        /* If we've pre-rolled on a seek we may now receive out-of-order frames