Look at more then one piece of video content when required for separate-eye 3D (...
authorCarl Hetherington <cth@carlh.net>
Mon, 13 Jul 2015 23:23:49 +0000 (00:23 +0100)
committerCarl Hetherington <cth@carlh.net>
Mon, 13 Jul 2015 23:23:49 +0000 (00:23 +0100)
ChangeLog
src/lib/player.cc

index 0d962e7b2effa3b8d6011655d26c4377bbcd0f07..6f3ed961cca450a03663c862041d5c1cce20ad10 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2015-07-14  Carl Hetherington  <cth@carlh.net>
+
+       * Fix non-working 3D DCP creation when using separate
+       pieces of content for each eye (#635).
+
 2015-07-12  Carl Hetherington  <cth@carlh.net>
 
        * Enforce restrictions on SSL certificate properties.
index 32892054918ee412961a792e69688d87bb66665a..b0ba415979a7ba61e8ab55499ee06d49a5871f1a 100644 (file)
@@ -361,38 +361,57 @@ Player::get_video (DCPTime time, bool accurate)
                /* No video content at this time */
                pvf.push_back (black_player_video_frame (time));
        } else {
-               /* Create a PlayerVideo from the content's video at this time */
-
-               shared_ptr<Piece> piece = ov.back ();
-               shared_ptr<VideoDecoder> decoder = dynamic_pointer_cast<VideoDecoder> (piece->decoder);
-               DCPOMATIC_ASSERT (decoder);
-               shared_ptr<VideoContent> video_content = dynamic_pointer_cast<VideoContent> (piece->content);
-               DCPOMATIC_ASSERT (video_content);
-
-               list<ContentVideo> content_video = decoder->get_video (dcp_to_content_video (piece, time), accurate);
-               if (content_video.empty ()) {
-                       pvf.push_back (black_player_video_frame (time));
-                       return pvf;
+               /* Decide which pieces of content to use */
+               list<shared_ptr<Piece> > ov_to_use;
+
+               /* Always use the last one */
+               list<shared_ptr<Piece> >::reverse_iterator i = ov.rbegin ();
+               ov_to_use.push_back (*i);
+               VideoFrameType const first_type = dynamic_pointer_cast<VideoContent> ((*i)->content)->video_frame_type ();
+
+               ++i;
+               if (i != ov.rend ()) {
+                       shared_ptr<VideoContent> vc = dynamic_pointer_cast<VideoContent> ((*i)->content);
+                       /* Use the second to last if it's the other part of a 3D content pair */
+                       if (
+                               (first_type == EYES_LEFT && vc->video_frame_type() == EYES_RIGHT) ||
+                               (first_type == EYES_RIGHT && vc->video_frame_type() == EYES_LEFT)
+                               ) {
+                               /* Other part of a pair of 3D content */
+                               ov_to_use.push_back (*i);
+                       }
                }
 
-               dcp::Size image_size = video_content->scale().size (video_content, _video_container_size, _film->frame_size ());
-
-               for (list<ContentVideo>::const_iterator i = content_video.begin(); i != content_video.end(); ++i) {
-                       pvf.push_back (
-                               shared_ptr<PlayerVideo> (
-                                       new PlayerVideo (
-                                               i->image,
-                                               content_video_to_dcp (piece, i->frame),
-                                               video_content->crop (),
-                                               video_content->fade (i->frame),
-                                               image_size,
-                                               _video_container_size,
-                                               i->eyes,
-                                               i->part,
-                                               video_content->colour_conversion ()
-                                               )
-                                       )
-                               );
+               BOOST_FOREACH (shared_ptr<Piece> piece, ov_to_use) {
+                       shared_ptr<VideoDecoder> decoder = dynamic_pointer_cast<VideoDecoder> (piece->decoder);
+                       DCPOMATIC_ASSERT (decoder);
+                       shared_ptr<VideoContent> video_content = dynamic_pointer_cast<VideoContent> (piece->content);
+                       DCPOMATIC_ASSERT (video_content);
+
+                       list<ContentVideo> content_video = decoder->get_video (dcp_to_content_video (piece, time), accurate);
+                       if (content_video.empty ()) {
+                               pvf.push_back (black_player_video_frame (time));
+                       } else {
+                               dcp::Size image_size = video_content->scale().size (video_content, _video_container_size, _film->frame_size ());
+
+                               for (list<ContentVideo>::const_iterator i = content_video.begin(); i != content_video.end(); ++i) {
+                                       pvf.push_back (
+                                               shared_ptr<PlayerVideo> (
+                                                       new PlayerVideo (
+                                                               i->image,
+                                                               content_video_to_dcp (piece, i->frame),
+                                                               video_content->crop (),
+                                                               video_content->fade (i->frame),
+                                                               image_size,
+                                                               _video_container_size,
+                                                               i->eyes,
+                                                               i->part,
+                                                               video_content->colour_conversion ()
+                                                               )
+                                                       )
+                                               );
+                               }
+                       }
                }
        }