Do filling correctly for separate-content L/R 3D; before it was
authorCarl Hetherington <cth@carlh.net>
Mon, 17 Aug 2015 22:00:12 +0000 (23:00 +0100)
committerCarl Hetherington <cth@carlh.net>
Mon, 17 Aug 2015 22:00:12 +0000 (23:00 +0100)
trying to fill each individual piece of content as if it was providing
both L and R frames.

ChangeLog
src/lib/video_decoder.cc
src/lib/video_decoder.h
test/video_decoder_fill_test.cc

index 00273b56c03fe3f73a94285432a2bfd475f0722a..c3ea3f022fedd39443887599dcc639720e88d723 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,8 @@
 2015-08-17  Carl Hetherington  <cth@carlh.net>
 
+       * Fix problems when encoding 3D from separate
+       L/R sources.
+
        * Version 2.1.38 released.
 
 2015-08-17  Carl Hetherington  <cth@carlh.net>
index 2b9b13689434854de1fd9e9c385a4a27bb65ac22..1b4a625d6ef829b9fd58346d7e7b72da0ded4824 100644 (file)
@@ -130,9 +130,12 @@ VideoDecoder::get_video (Frame frame, bool accurate)
        return dec;
 }
 
-/** Fill _decoded_video from `from' up to, but not including, `to' */
+/** 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_2d (Frame from, Frame to)
+VideoDecoder::fill_one_eye (Frame from, Frame to, Eyes eye)
 {
        if (to == 0) {
                /* Already OK */
@@ -154,14 +157,16 @@ VideoDecoder::fill_2d (Frame from, Frame to)
                test_gaps++;
 #endif
                _decoded_video.push_back (
-                       ContentVideo (filler_image, EYES_BOTH, filler_part, i)
+                       ContentVideo (filler_image, eye, filler_part, i)
                        );
        }
 }
 
-/** Fill _decoded_video from `from' up to, but not including, `to' */
+/** Fill _decoded_video from `from' up to, but not including, `to'
+ *  adding both left and right eye frames.
+ */
 void
-VideoDecoder::fill_3d (Frame from, Frame to, Eyes eye)
+VideoDecoder::fill_both_eyes (Frame from, Frame to, Eyes eye)
 {
        if (to == 0 && eye == EYES_LEFT) {
                /* Already OK */
@@ -236,6 +241,7 @@ VideoDecoder::video (shared_ptr<const ImageProxy> image, Frame frame)
        }
 
        _video_content->film()->log()->log (String::compose ("VD receives %1", frame), Log::TYPE_DEBUG_DECODE);
+       cout << "receive " << frame << " for " << _video_content->path(0) << "\n";
 
        /* We may receive the same frame index twice for 3D, and we need to know
           when that happens.
@@ -294,10 +300,20 @@ VideoDecoder::video (shared_ptr<const ImageProxy> image, Frame frame)
        }
 
        if (from) {
-               if (_video_content->video_frame_type() == VIDEO_FRAME_TYPE_2D) {
-                       fill_2d (from.get(), to.get ());
-               } else {
-                       fill_3d (from.get(), to.get(), to_push.front().eyes);
+               switch (_video_content->video_frame_type ()) {
+               case VIDEO_FRAME_TYPE_2D:
+                       fill_one_eye (from.get(), to.get (), EYES_BOTH);
+                       break;
+               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);
+                       break;
+               case VIDEO_FRAME_TYPE_3D_LEFT:
+                       fill_one_eye (from.get(), to.get (), EYES_LEFT);
+                       break;
+               case VIDEO_FRAME_TYPE_3D_RIGHT:
+                       fill_one_eye (from.get(), to.get (), EYES_RIGHT);
                }
        }
 
index 5266604c58c54fa94e5132af1146c7440d6c255f..42cfc49063de396fa5043f193430ccffc6279eb0 100644 (file)
@@ -62,8 +62,8 @@ protected:
        void seek (ContentTime time, bool accurate);
        void video (boost::shared_ptr<const ImageProxy>, Frame frame);
        std::list<ContentVideo> decoded_video (Frame frame);
-       void fill_2d (Frame from, Frame to);
-       void fill_3d (Frame from, Frame to, Eyes);
+       void fill_one_eye (Frame from, Frame to, Eyes);
+       void fill_both_eyes (Frame from, Frame to, Eyes);
 
        boost::shared_ptr<const VideoContent> _video_content;
        std::list<ContentVideo> _decoded_video;
index 25f7548535e8b793869e3b4a1687310d02c3bd58..6d75e30da26c9c6b772af450f72148a71d57d59b 100644 (file)
@@ -32,7 +32,7 @@ BOOST_AUTO_TEST_CASE (video_decoder_fill_test1)
        shared_ptr<ImageContent> c (new ImageContent (film, "test/data/simple_testcard_640x480.png"));
        ImageDecoder decoder (c);
 
-       decoder.fill_2d (0, 4);
+       decoder.fill_one_eye (0, 4, EYES_BOTH);
        BOOST_CHECK_EQUAL (decoder._decoded_video.size(), 4U);
        list<ContentVideo>::iterator i = decoder._decoded_video.begin();
        for (int j = 0; j < 4; ++j) {
@@ -42,7 +42,7 @@ BOOST_AUTO_TEST_CASE (video_decoder_fill_test1)
 
        decoder._decoded_video.clear ();
 
-       decoder.fill_2d (0, 7);
+       decoder.fill_one_eye (0, 7, EYES_BOTH);
        BOOST_CHECK_EQUAL (decoder._decoded_video.size(), 7);
        i = decoder._decoded_video.begin();
        for (int j = 0; j < 7; ++j) {
@@ -57,7 +57,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);
 
-       decoder.fill_3d (0, 4, EYES_LEFT);
+       decoder.fill_both_eyes (0, 4, EYES_LEFT);
        BOOST_CHECK_EQUAL (decoder._decoded_video.size(), 8);
        list<ContentVideo>::iterator i = decoder._decoded_video.begin();
        for (int j = 0; j < 8; ++j) {
@@ -66,7 +66,7 @@ BOOST_AUTO_TEST_CASE (video_decoder_fill_test2)
                ++i;
        }
 
-       decoder.fill_3d (0, 7, EYES_RIGHT);
+       decoder.fill_both_eyes (0, 7, EYES_RIGHT);
        BOOST_CHECK_EQUAL (decoder._decoded_video.size(), 15);
        i = decoder._decoded_video.begin();
        for (int j = 0; j < 15; ++j) {