Merge branch 'master' of ssh://git.carlh.net/home/carl/git/dcpomatic
authorCarl Hetherington <cth@carlh.net>
Tue, 14 Jun 2016 08:34:09 +0000 (09:34 +0100)
committerCarl Hetherington <cth@carlh.net>
Tue, 14 Jun 2016 08:34:09 +0000 (09:34 +0100)
ChangeLog
src/lib/types.cc
src/lib/types.h
src/lib/video_content.cc
src/lib/video_decoder.cc
src/lib/video_decoder.h
src/wx/video_panel.cc
test/video_decoder_fill_test.cc

index c57730218e331a2b4e2a5826094b0d894d97cfcc..1f230c1341213003a3a1e3b1ed191fad8f910597 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -4,6 +4,8 @@
 
 2016-06-13  c.hetherington  <cth@carlh.net>
 
+       * Add 3D video frame type for 3D DCP inputs (#806).
+
        * Add button to move things to the start of reels (#798).
 
 2016-06-08  Carl Hetherington  <cth@carlh.net>
index ce50814644de70bd866d6a3d6bd11803f80d8cf7..f31e7a3ec3854f9c1fee5d27592897e20a52628a 100644 (file)
@@ -95,6 +95,8 @@ video_frame_type_to_string (VideoFrameType t)
        switch (t) {
        case VIDEO_FRAME_TYPE_2D:
                return "2d";
+       case VIDEO_FRAME_TYPE_3D:
+               return "3d";
        case VIDEO_FRAME_TYPE_3D_LEFT_RIGHT:
                return "3d-left-right";
        case VIDEO_FRAME_TYPE_3D_TOP_BOTTOM:
@@ -117,6 +119,8 @@ string_to_video_frame_type (string s)
 {
        if (s == "2d") {
                return VIDEO_FRAME_TYPE_2D;
+       } else if (s == "3d") {
+               return VIDEO_FRAME_TYPE_3D;
        } else if (s == "3d-left-right") {
                return VIDEO_FRAME_TYPE_3D_LEFT_RIGHT;
        } else if (s == "3d-top-bottom") {
index 8513fde519efac8b9a1d2dbd4b372e957949c29f..041db1786ea6c2653eba64c97161898b530a76c7 100644 (file)
@@ -78,6 +78,8 @@ typedef int64_t Frame;
 enum VideoFrameType
 {
        VIDEO_FRAME_TYPE_2D,
+       /** `True' 3D content, e.g. 3D DCPs */
+       VIDEO_FRAME_TYPE_3D,
        VIDEO_FRAME_TYPE_3D_LEFT_RIGHT,
        VIDEO_FRAME_TYPE_3D_TOP_BOTTOM,
        VIDEO_FRAME_TYPE_3D_ALTERNATE,
index 66c63961e8142bb90c3778fe3fdefdf17d8ae281..a59e9669d62de990b6f4b9359476ee17bededcb4 100644 (file)
@@ -303,6 +303,7 @@ VideoContent::size_after_3d_split () const
        dcp::Size const s = size ();
        switch (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:
index 81991b88298f7c89c2571a656960abede3b1f9b7..cc6cbfc308d53ad065032f24ffc627668911d374 100644 (file)
@@ -90,6 +90,8 @@ 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;
+
        list<ContentVideo> dec;
 
        /* Now enough pass() calls should either:
@@ -104,7 +106,7 @@ VideoDecoder::get (Frame frame, bool accurate)
                bool no_data = false;
 
                while (true) {
-                       if (!decoded(frame).empty ()) {
+                       if (decoded(frame).size() == frames_wanted) {
                                /* We got what we want */
                                break;
                        }
@@ -131,10 +133,14 @@ VideoDecoder::get (Frame frame, bool accurate)
                }
 
        } else {
-               /* Any frame will do: use the first one that comes out of pass() */
-               while (_decoded.empty() && !_parent->pass (Decoder::PASS_REASON_VIDEO, accurate)) {}
-               if (!_decoded.empty ()) {
-                       dec.push_back (_decoded.front ());
+               /* 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;
                }
        }
 
@@ -183,13 +189,8 @@ VideoDecoder::fill_one_eye (Frame from, Frame to, Eyes eye)
  *  adding both left and right eye frames.
  */
 void
-VideoDecoder::fill_both_eyes (Frame from, Frame to, Eyes eye)
+VideoDecoder::fill_both_eyes (Frame from_frame, Eyes from_eye, Frame to_frame, Eyes to_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));
@@ -211,21 +212,7 @@ VideoDecoder::fill_both_eyes (Frame from, Frame to, Eyes eye)
                }
        }
 
-       Frame filler_frame = from;
-       Eyes filler_eye = _decoded.empty() ? EYES_LEFT : _decoded.back().eyes;
-
-       if (_decoded.empty ()) {
-               filler_frame = 0;
-               filler_eye = EYES_LEFT;
-       } else if (_decoded.back().eyes == EYES_LEFT) {
-               filler_frame = _decoded.back().frame;
-               filler_eye = EYES_RIGHT;
-       } else if (_decoded.back().eyes == EYES_RIGHT) {
-               filler_frame = _decoded.back().frame + 1;
-               filler_eye = EYES_LEFT;
-       }
-
-       while (filler_frame != to || filler_eye != eye) {
+       while (from_frame != to_frame || from_eye != to_eye) {
 
 #ifdef DCPOMATIC_DEBUG
                test_gaps++;
@@ -233,18 +220,18 @@ VideoDecoder::fill_both_eyes (Frame from, Frame to, Eyes eye)
 
                _decoded.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
+                               from_eye == EYES_LEFT ? filler_left_image : filler_right_image,
+                               from_eye,
+                               from_eye == EYES_LEFT ? filler_left_part : filler_right_part,
+                               from_frame
                                )
                        );
 
-               if (filler_eye == EYES_LEFT) {
-                       filler_eye = EYES_RIGHT;
+               if (from_eye == EYES_LEFT) {
+                       from_eye = EYES_RIGHT;
                } else {
-                       filler_eye = EYES_LEFT;
-                       ++filler_frame;
+                       from_eye = EYES_LEFT;
+                       ++from_frame;
                }
        }
 }
@@ -265,6 +252,7 @@ VideoDecoder::give (shared_ptr<const ImageProxy> image, Frame frame)
        case VIDEO_FRAME_TYPE_2D:
                to_push.push_back (ContentVideo (image, EYES_BOTH, PART_WHOLE, frame));
                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
@@ -297,40 +285,60 @@ VideoDecoder::give (shared_ptr<const ImageProxy> image, Frame frame)
           and the things we are about to push.
        */
 
-       optional<Frame> from;
-       optional<Frame> to;
+       optional<Frame> from_frame;
+       optional<Eyes> from_eye;
 
        if (_decoded.empty() && _last_seek_time && _last_seek_accurate) {
-               from = _last_seek_time->frames_round (_content->active_video_frame_rate ());
-               to = to_push.front().frame;
+               from_frame = _last_seek_time->frames_round (_content->active_video_frame_rate ());
+               from_eye = EYES_LEFT;
        } else if (!_decoded.empty ()) {
-               from = _decoded.back().frame + 1;
-               to = to_push.front().frame;
+               switch (_content->video->frame_type()) {
+               case VIDEO_FRAME_TYPE_2D:
+               case VIDEO_FRAME_TYPE_3D_LEFT:
+               case VIDEO_FRAME_TYPE_3D_RIGHT:
+                       from_frame = _decoded.back().frame + 1;
+                       break;
+               case VIDEO_FRAME_TYPE_3D:
+               case VIDEO_FRAME_TYPE_3D_LEFT_RIGHT:
+               case VIDEO_FRAME_TYPE_3D_TOP_BOTTOM:
+               case VIDEO_FRAME_TYPE_3D_ALTERNATE:
+                       /* Get the last frame that we have */
+                       from_frame = _decoded.back().frame;
+                       from_eye = _decoded.back().eyes;
+                       /* And increment */
+                       if (from_eye.get() == EYES_LEFT) {
+                               from_eye = EYES_RIGHT;
+                       } else {
+                               from_eye = EYES_LEFT;
+                               from_frame = from_frame.get() + 1;
+                       }
+               }
        }
 
        /* If we've pre-rolled on a seek we may now receive out-of-order frames
           (frames before the last seek time) which we can just ignore.
        */
 
-       if (from && to && from.get() > to.get()) {
+       if (from_frame && from_frame.get() > to_push.front().frame) {
                return;
        }
 
-       if (from) {
+       if (from_frame) {
                switch (_content->video->frame_type ()) {
                case VIDEO_FRAME_TYPE_2D:
-                       fill_one_eye (from.get(), to.get (), EYES_BOTH);
+                       fill_one_eye (from_frame.get(), to_push.front().frame, EYES_BOTH);
                        break;
+               case VIDEO_FRAME_TYPE_3D:
                case VIDEO_FRAME_TYPE_3D_LEFT_RIGHT:
                case VIDEO_FRAME_TYPE_3D_TOP_BOTTOM:
                case VIDEO_FRAME_TYPE_3D_ALTERNATE:
-                       fill_both_eyes (from.get(), to.get(), to_push.front().eyes);
+                       fill_both_eyes (from_frame.get(), from_eye.get(), to_push.front().frame, to_push.front().eyes);
                        break;
                case VIDEO_FRAME_TYPE_3D_LEFT:
-                       fill_one_eye (from.get(), to.get (), EYES_LEFT);
+                       fill_one_eye (from_frame.get(), to_push.front().frame, EYES_LEFT);
                        break;
                case VIDEO_FRAME_TYPE_3D_RIGHT:
-                       fill_one_eye (from.get(), to.get (), EYES_RIGHT);
+                       fill_one_eye (from_frame.get(), to_push.front().frame, EYES_RIGHT);
                        break;
                }
        }
index 5053d32ebfe3a23aa60126e2ddee303dcd43a50c..7c2374dd8f154eaf370022c031824f04decd5b89 100644 (file)
@@ -68,7 +68,7 @@ private:
 
        std::list<ContentVideo> decoded (Frame frame);
        void fill_one_eye (Frame from, Frame to, Eyes);
-       void fill_both_eyes (Frame from, Frame to, Eyes);
+       void fill_both_eyes (Frame from_frame, Eyes from_eyes, Frame to_frame, Eyes to_eyes);
 
        Decoder* _parent;
        boost::shared_ptr<const Content> _content;
index 8a8dbd181609e5c15734cc2fc4770bcdb5fd5c20..18d5894830f0a57fa5cf70eb26c4535cb8d82eff 100644 (file)
@@ -232,6 +232,7 @@ VideoPanel::VideoPanel (ContentPanel* p)
        }
 
        _frame_type->wrapped()->Append (_("2D"));
+       _frame_type->wrapped()->Append (_("3D"));
        _frame_type->wrapped()->Append (_("3D left/right"));
        _frame_type->wrapped()->Append (_("3D top/bottom"));
        _frame_type->wrapped()->Append (_("3D alternate"));
index da23b277558ba284d0a086f78d39a4105286610b..737bc883c62486b36f40516f27d77b66850e2d68 100644 (file)
@@ -62,7 +62,7 @@ BOOST_AUTO_TEST_CASE (video_decoder_fill_test2)
        shared_ptr<ImageContent> c (new ImageContent (film, "test/data/simple_testcard_640x480.png"));
        ImageDecoder decoder (c, film->log());
 
-       decoder.video->fill_both_eyes (0, 4, EYES_LEFT);
+       decoder.video->fill_both_eyes (0, EYES_LEFT, 4, EYES_LEFT);
        BOOST_CHECK_EQUAL (decoder.video->_decoded.size(), 8);
        list<ContentVideo>::iterator i = decoder.video->_decoded.begin();
        for (int j = 0; j < 8; ++j) {
@@ -71,7 +71,8 @@ BOOST_AUTO_TEST_CASE (video_decoder_fill_test2)
                ++i;
        }
 
-       decoder.video->fill_both_eyes (0, 7, EYES_RIGHT);
+       decoder.video->_decoded.clear ();
+       decoder.video->fill_both_eyes (0, EYES_LEFT, 7, EYES_RIGHT);
        BOOST_CHECK_EQUAL (decoder.video->_decoded.size(), 15);
        i = decoder.video->_decoded.begin();
        for (int j = 0; j < 15; ++j) {
@@ -79,4 +80,14 @@ BOOST_AUTO_TEST_CASE (video_decoder_fill_test2)
                BOOST_CHECK_EQUAL (i->eyes, (j % 2) == 0 ? EYES_LEFT : EYES_RIGHT);
                ++i;
        }
+
+       decoder.video->_decoded.clear ();
+       decoder.video->fill_both_eyes (0, EYES_RIGHT, 7, EYES_RIGHT);
+       BOOST_CHECK_EQUAL (decoder.video->_decoded.size(), 14);
+       i = decoder.video->_decoded.begin();
+       for (int j = 0; j < 14; ++j) {
+               BOOST_CHECK_EQUAL (i->frame, (j + 1) / 2);
+               BOOST_CHECK_EQUAL (i->eyes, (j % 2) == 0 ? EYES_RIGHT : EYES_LEFT);
+               ++i;
+       }
 }