summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCarl Hetherington <cth@carlh.net>2015-08-17 23:00:12 +0100
committerCarl Hetherington <cth@carlh.net>2015-08-17 23:00:12 +0100
commitd184945d41ea7d6e489621dc6492a93b5d91f7de (patch)
treed464fc4d700a2bee193ea0d0bf584700af07e692
parent59dd3e3f06efb6249c1e4105ca746f877bc8ca93 (diff)
Do filling correctly for separate-content L/R 3D; before it was
trying to fill each individual piece of content as if it was providing both L and R frames.
-rw-r--r--ChangeLog3
-rw-r--r--src/lib/video_decoder.cc34
-rw-r--r--src/lib/video_decoder.h4
-rw-r--r--test/video_decoder_fill_test.cc8
4 files changed, 34 insertions, 15 deletions
diff --git a/ChangeLog b/ChangeLog
index 00273b56c..c3ea3f022 100644
--- 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>
diff --git a/src/lib/video_decoder.cc b/src/lib/video_decoder.cc
index 2b9b13689..1b4a625d6 100644
--- a/src/lib/video_decoder.cc
+++ b/src/lib/video_decoder.cc
@@ -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);
}
}
diff --git a/src/lib/video_decoder.h b/src/lib/video_decoder.h
index 5266604c5..42cfc4906 100644
--- a/src/lib/video_decoder.h
+++ b/src/lib/video_decoder.h
@@ -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;
diff --git a/test/video_decoder_fill_test.cc b/test/video_decoder_fill_test.cc
index 25f754853..6d75e30da 100644
--- a/test/video_decoder_fill_test.cc
+++ b/test/video_decoder_fill_test.cc
@@ -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) {