summaryrefslogtreecommitdiff
path: root/src/lib
diff options
context:
space:
mode:
authorCarl Hetherington <cth@carlh.net>2014-03-18 14:24:08 +0000
committerCarl Hetherington <cth@carlh.net>2014-03-18 14:24:08 +0000
commit04ef57589ebb7c0de3377172a03b24698fd2364a (patch)
treee6afb1b0d1d20e15804033929ddd6ab1b19d2d41 /src/lib
parent02e2271a16804a35698f513f536a9ab1893b8612 (diff)
Tentative support for 3D from alternate frames.
Also remove references to libpostproc. Requested-by: Jean-Jacques Mantello
Diffstat (limited to 'src/lib')
-rw-r--r--src/lib/ffmpeg.cc1
-rw-r--r--src/lib/ffmpeg_content.cc6
-rw-r--r--src/lib/ffmpeg_decoder.cc2
-rw-r--r--src/lib/ffmpeg_decoder.h1
-rw-r--r--src/lib/image.cc1
-rw-r--r--src/lib/image_content.cc2
-rw-r--r--src/lib/scaler.h2
-rw-r--r--src/lib/types.h3
-rw-r--r--src/lib/util.cc2
-rw-r--r--src/lib/video_content.cc6
-rw-r--r--src/lib/video_content.h9
-rw-r--r--src/lib/video_decoder.cc3
-rw-r--r--src/lib/video_decoder.h3
13 files changed, 28 insertions, 13 deletions
diff --git a/src/lib/ffmpeg.cc b/src/lib/ffmpeg.cc
index fae9baa2b..60eea6ec7 100644
--- a/src/lib/ffmpeg.cc
+++ b/src/lib/ffmpeg.cc
@@ -21,7 +21,6 @@ extern "C" {
#include <libavcodec/avcodec.h>
#include <libavformat/avformat.h>
#include <libswscale/swscale.h>
-#include <libpostproc/postprocess.h>
}
#include "ffmpeg.h"
#include "ffmpeg_content.h"
diff --git a/src/lib/ffmpeg_content.cc b/src/lib/ffmpeg_content.cc
index fadeec9cd..b7551c96a 100644
--- a/src/lib/ffmpeg_content.cc
+++ b/src/lib/ffmpeg_content.cc
@@ -239,7 +239,7 @@ FFmpegContent::information () const
stringstream s;
- s << String::compose (_("%1 frames; %2 frames per second"), video_length(), video_frame_rate()) << "\n";
+ s << String::compose (_("%1 frames; %2 frames per second"), video_length_after_3d_combine(), video_frame_rate()) << "\n";
s << VideoContent::information ();
return s.str ();
@@ -272,7 +272,7 @@ FFmpegContent::audio_length () const
{
int const cafr = content_audio_frame_rate ();
int const vfr = video_frame_rate ();
- VideoContent::Frame const vl = video_length ();
+ VideoContent::Frame const vl = video_length_after_3d_combine ();
boost::mutex::scoped_lock lm (_mutex);
if (!_audio_stream) {
@@ -429,7 +429,7 @@ FFmpegContent::full_length () const
assert (film);
FrameRateConversion frc (video_frame_rate (), film->video_frame_rate ());
- return video_length() * frc.factor() * TIME_HZ / film->video_frame_rate ();
+ return video_length_after_3d_combine() * frc.factor() * TIME_HZ / film->video_frame_rate ();
}
AudioMapping
diff --git a/src/lib/ffmpeg_decoder.cc b/src/lib/ffmpeg_decoder.cc
index 851c64606..1920f9275 100644
--- a/src/lib/ffmpeg_decoder.cc
+++ b/src/lib/ffmpeg_decoder.cc
@@ -142,7 +142,7 @@ FFmpegDecoder::flush ()
}
/* Stop us being asked for any more data */
- _video_position = _ffmpeg_content->video_length ();
+ _video_position = _ffmpeg_content->video_length_after_3d_combine ();
_audio_position = _ffmpeg_content->audio_length ();
}
diff --git a/src/lib/ffmpeg_decoder.h b/src/lib/ffmpeg_decoder.h
index 63a8f0c71..d4b4fa1c0 100644
--- a/src/lib/ffmpeg_decoder.h
+++ b/src/lib/ffmpeg_decoder.h
@@ -29,7 +29,6 @@
#include <boost/thread/mutex.hpp>
extern "C" {
#include <libavcodec/avcodec.h>
-#include <libpostproc/postprocess.h>
}
#include "util.h"
#include "decoder.h"
diff --git a/src/lib/image.cc b/src/lib/image.cc
index 25d1ef276..d083cf3f6 100644
--- a/src/lib/image.cc
+++ b/src/lib/image.cc
@@ -26,7 +26,6 @@ extern "C" {
#include <libswscale/swscale.h>
#include <libavutil/pixfmt.h>
#include <libavutil/pixdesc.h>
-#include <libpostproc/postprocess.h>
}
#include "image.h"
#include "exceptions.h"
diff --git a/src/lib/image_content.cc b/src/lib/image_content.cc
index fd0b57894..13f7c52e3 100644
--- a/src/lib/image_content.cc
+++ b/src/lib/image_content.cc
@@ -127,7 +127,7 @@ ImageContent::full_length () const
assert (film);
FrameRateConversion frc (video_frame_rate(), film->video_frame_rate ());
- return video_length() * frc.factor() * TIME_HZ / video_frame_rate();
+ return video_length_after_3d_combine() * frc.factor() * TIME_HZ / video_frame_rate();
}
string
diff --git a/src/lib/scaler.h b/src/lib/scaler.h
index 6a039edd8..14077ff1d 100644
--- a/src/lib/scaler.h
+++ b/src/lib/scaler.h
@@ -36,7 +36,7 @@ class Scaler : public boost::noncopyable
public:
Scaler (int f, std::string i, std::string n);
- /** @return id used for calls to FFmpeg's pp_postprocess */
+ /** @return id used for calls to FFmpeg's sws_getContext */
int ffmpeg_id () const {
return _ffmpeg_id;
}
diff --git a/src/lib/types.h b/src/lib/types.h
index 96b993a8e..8a16818bd 100644
--- a/src/lib/types.h
+++ b/src/lib/types.h
@@ -69,7 +69,8 @@ enum VideoFrameType
{
VIDEO_FRAME_TYPE_2D,
VIDEO_FRAME_TYPE_3D_LEFT_RIGHT,
- VIDEO_FRAME_TYPE_3D_TOP_BOTTOM
+ VIDEO_FRAME_TYPE_3D_TOP_BOTTOM,
+ VIDEO_FRAME_TYPE_3D_ALTERNATE
};
enum Eyes
diff --git a/src/lib/util.cc b/src/lib/util.cc
index 35385ab40..85c52b039 100644
--- a/src/lib/util.cc
+++ b/src/lib/util.cc
@@ -57,7 +57,6 @@ extern "C" {
#include <libavformat/avformat.h>
#include <libswscale/swscale.h>
#include <libavfilter/avfiltergraph.h>
-#include <libpostproc/postprocess.h>
#include <libavutil/pixfmt.h>
}
#include "util.h"
@@ -248,7 +247,6 @@ dependency_version_summary ()
<< N_("libavfilter ") << ffmpeg_version_to_string (avfilter_version()) << N_(", ")
<< N_("libavformat ") << ffmpeg_version_to_string (avformat_version()) << N_(", ")
<< N_("libavutil ") << ffmpeg_version_to_string (avutil_version()) << N_(", ")
- << N_("libpostproc ") << ffmpeg_version_to_string (postproc_version()) << N_(", ")
<< N_("libswscale ") << ffmpeg_version_to_string (swscale_version()) << N_(", ")
<< MagickVersion << N_(", ")
<< N_("libssh ") << ssh_version (0) << N_(", ")
diff --git a/src/lib/video_content.cc b/src/lib/video_content.cc
index 966b8e8b3..4a1ef95ac 100644
--- a/src/lib/video_content.cc
+++ b/src/lib/video_content.cc
@@ -317,7 +317,10 @@ VideoContent::set_video_frame_type (VideoFrameType t)
string
VideoContent::technical_summary () const
{
- return String::compose ("video: length %1, size %2x%3, rate %4", video_length(), video_size().width, video_size().height, video_frame_rate());
+ return String::compose (
+ "video: length %1, size %2x%3, rate %4",
+ video_length_after_3d_combine(), video_size().width, video_size().height, video_frame_rate()
+ );
}
libdcp::Size
@@ -326,6 +329,7 @@ VideoContent::video_size_after_3d_split () const
libdcp::Size const s = video_size ();
switch (video_frame_type ()) {
case VIDEO_FRAME_TYPE_2D:
+ case VIDEO_FRAME_TYPE_3D_ALTERNATE:
return s;
case VIDEO_FRAME_TYPE_3D_LEFT_RIGHT:
return libdcp::Size (s.width / 2, s.height);
diff --git a/src/lib/video_content.h b/src/lib/video_content.h
index ea4676cec..f846b7ac9 100644
--- a/src/lib/video_content.h
+++ b/src/lib/video_content.h
@@ -96,6 +96,15 @@ public:
return _video_length;
}
+ VideoContent::Frame video_length_after_3d_combine () const {
+ boost::mutex::scoped_lock lm (_mutex);
+ if (_video_frame_type == VIDEO_FRAME_TYPE_3D_ALTERNATE) {
+ return _video_length / 2;
+ }
+
+ return _video_length;
+ }
+
libdcp::Size video_size () const {
boost::mutex::scoped_lock lm (_mutex);
return _video_size;
diff --git a/src/lib/video_decoder.cc b/src/lib/video_decoder.cc
index e7ddec5e6..3ae963a20 100644
--- a/src/lib/video_decoder.cc
+++ b/src/lib/video_decoder.cc
@@ -40,6 +40,9 @@ VideoDecoder::video (shared_ptr<const Image> image, bool same, VideoContent::Fra
case VIDEO_FRAME_TYPE_2D:
Video (image, EYES_BOTH, same, frame);
break;
+ case VIDEO_FRAME_TYPE_3D_ALTERNATE:
+ Video (image, (frame % 2) ? EYES_RIGHT : EYES_LEFT, same, frame / 2);
+ break;
case VIDEO_FRAME_TYPE_3D_LEFT_RIGHT:
{
int const half = image->size().width / 2;
diff --git a/src/lib/video_decoder.h b/src/lib/video_decoder.h
index 142320a04..255a038a9 100644
--- a/src/lib/video_decoder.h
+++ b/src/lib/video_decoder.h
@@ -51,6 +51,9 @@ protected:
void video (boost::shared_ptr<const Image>, bool, VideoContent::Frame);
boost::shared_ptr<const VideoContent> _video_content;
+ /** This is in frames without taking 3D into account (e.g. if we are doing 3D alternate,
+ * this would equal 2 on the left-eye second frame (not 1)).
+ */
VideoContent::Frame _video_position;
};