Fix misunderstandings in decoder frame handling for 3D/3D-alternate.
authorCarl Hetherington <cth@carlh.net>
Wed, 19 Oct 2016 22:40:31 +0000 (23:40 +0100)
committerCarl Hetherington <cth@carlh.net>
Wed, 19 Oct 2016 22:40:31 +0000 (23:40 +0100)
ChangeLog
src/lib/video_decoder.cc
test/threed_test.cc

index c84c3801c83df1a65b586dc599cd6d8de7ab9ac8..4eecb76d96c5c80cff63e9fc35fb17da7eeaf6e5 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2016-10-19  Carl Hetherington  <cth@carlh.net>
+
+       * Fix various problems with 3D DCP creation
+       from 3D DCP and 3D-alernate-frame sources.
+
 2016-10-18  Carl Hetherington  <cth@carlh.net>
 
        * Updated de_DE translation from Carsten Kurz.
index f87e4108616ccdc260d70d10f0dacc2a1e5a67d9..8c1b27653199716288b69e506c8ce84a08204c67 100644 (file)
@@ -90,15 +90,19 @@ VideoDecoder::get (Frame frame, bool accurate)
                _parent->seek (ContentTime::from_frames (frame, _content->active_video_frame_rate()), accurate);
        }
 
+       /* Work out the number of frames that we should return; we
+          must return all frames in our content at the requested `time'
+          (i.e. frame)
+       */
        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:
+       case VIDEO_FRAME_TYPE_3D_ALTERNATE:
        case VIDEO_FRAME_TYPE_3D_LEFT_RIGHT:
        case VIDEO_FRAME_TYPE_3D_TOP_BOTTOM:
                frames_wanted = 2;
@@ -263,15 +267,17 @@ VideoDecoder::give (shared_ptr<const ImageProxy> image, Frame frame)
                to_push.push_back (ContentVideo (image, VideoFrame (frame, EYES_BOTH), PART_WHOLE));
                break;
        case VIDEO_FRAME_TYPE_3D:
-       case VIDEO_FRAME_TYPE_3D_ALTERNATE:
        {
-               /* We receive the same frame index twice for 3D-alternate; hence we know which
+               /* We receive the same frame index twice for 3D; hence we know which
                   frame this one is.
                */
                bool const same = (!_decoded.empty() && frame == _decoded.back().frame.index());
                to_push.push_back (ContentVideo (image, VideoFrame (frame, same ? EYES_RIGHT : EYES_LEFT), PART_WHOLE));
                break;
        }
+       case VIDEO_FRAME_TYPE_3D_ALTERNATE:
+               to_push.push_back (ContentVideo (image, VideoFrame (frame / 2, (frame % 2) ? EYES_RIGHT : EYES_LEFT), PART_WHOLE));
+               break;
        case VIDEO_FRAME_TYPE_3D_LEFT_RIGHT:
                to_push.push_back (ContentVideo (image, VideoFrame (frame, EYES_LEFT), PART_LEFT_HALF));
                to_push.push_back (ContentVideo (image, VideoFrame (frame, EYES_RIGHT), PART_RIGHT_HALF));
index 5a28122c0aa63a3b3e561d00acb10488b64dd6a2..4ffbdf0e61e267375997a5bfcb8a86b81ec0bd8f 100644 (file)
@@ -34,9 +34,9 @@
 using std::cout;
 using boost::shared_ptr;
 
-BOOST_AUTO_TEST_CASE (threed_test)
+BOOST_AUTO_TEST_CASE (threed_test1)
 {
-       shared_ptr<Film> film = new_test_film ("threed_test");
+       shared_ptr<Film> film = new_test_film ("threed_test2");
        film->set_name ("test_film2");
        shared_ptr<FFmpegContent> c (new FFmpegContent (film, "test/data/test.mp4"));
        film->examine_and_add_content (c);
@@ -53,3 +53,26 @@ BOOST_AUTO_TEST_CASE (threed_test)
 
        wait_for_jobs ();
 }
+
+/** Basic sanity check of 3D-alternate; at the moment this is just to make sure
+ *  that such a transcode completes without error.
+ */
+BOOST_AUTO_TEST_CASE (threed_test2)
+{
+       shared_ptr<Film> film = new_test_film ("threed_test2");
+       film->set_name ("test_film2");
+       shared_ptr<FFmpegContent> c (new FFmpegContent (film, "test/data/test.mp4"));
+       film->examine_and_add_content (c);
+       wait_for_jobs ();
+
+       c->video->set_frame_type (VIDEO_FRAME_TYPE_3D_ALTERNATE);
+       c->video->set_scale (VideoContentScale (Ratio::from_id ("185")));
+
+       film->set_container (Ratio::from_id ("185"));
+       film->set_dcp_content_type (DCPContentType::from_isdcf_name ("TST"));
+       film->set_three_d (true);
+       film->make_dcp ();
+       film->write_metadata ();
+
+       wait_for_jobs ();
+}