summaryrefslogtreecommitdiff
path: root/src/lib
diff options
context:
space:
mode:
authorCarl Hetherington <cth@carlh.net>2014-04-01 21:44:06 +0100
committerCarl Hetherington <cth@carlh.net>2014-04-01 21:44:06 +0100
commit1eeba876ce09cedfa4c779bf3554372c01dc34c5 (patch)
tree3b1590b8b1e25a985a7805e28187d454df52a1a6 /src/lib
parent70b1f90c6986e36afc2af36ee127f6a3eb8653cd (diff)
Various small fixes.
Diffstat (limited to 'src/lib')
-rw-r--r--src/lib/audio_decoder.cc1
-rw-r--r--src/lib/content_video.h7
-rw-r--r--src/lib/player.cc3
-rw-r--r--src/lib/player.h2
-rw-r--r--src/lib/video_decoder.cc40
-rw-r--r--src/lib/video_decoder.h8
6 files changed, 41 insertions, 20 deletions
diff --git a/src/lib/audio_decoder.cc b/src/lib/audio_decoder.cc
index 616abf846..9606c378c 100644
--- a/src/lib/audio_decoder.cc
+++ b/src/lib/audio_decoder.cc
@@ -36,6 +36,7 @@ using boost::shared_ptr;
AudioDecoder::AudioDecoder (shared_ptr<const AudioContent> content)
: _audio_content (content)
+ , _decoded_audio (shared_ptr<AudioBuffers> (new AudioBuffers (content->audio_channels(), 0)), 0)
{
if (content->output_audio_frame_rate() != content->content_audio_frame_rate() && content->audio_channels ()) {
_resampler.reset (new Resampler (content->content_audio_frame_rate(), content->output_audio_frame_rate(), content->audio_channels ()));
diff --git a/src/lib/content_video.h b/src/lib/content_video.h
index 96ce5450c..20b5b8dec 100644
--- a/src/lib/content_video.h
+++ b/src/lib/content_video.h
@@ -17,6 +17,11 @@
*/
+#ifndef DCPOMATIC_CONTENT_VIDEO_H
+#define DCPOMATIC_CONTENT_VIDEO_H
+
+class Image;
+
/** @class ContentVideo
* @brief A frame of video straight out of some content.
*/
@@ -37,3 +42,5 @@ public:
Eyes eyes;
VideoFrame frame;
};
+
+#endif
diff --git a/src/lib/player.cc b/src/lib/player.cc
index 8902929cc..02ae4e5c9 100644
--- a/src/lib/player.cc
+++ b/src/lib/player.cc
@@ -319,7 +319,8 @@ Player::get_video (DCPTime time, bool accurate)
shared_ptr<VideoContent> content = dynamic_pointer_cast<VideoContent> (piece->content);
assert (content);
- shared_ptr<ContentVideo> dec = decoder->get_video (dcp_to_content_video (piece, time), accurate);
+ optional<ContentVideo> dec = decoder->get_video (dcp_to_content_video (piece, time), accurate);
+ assert (dec);
dcp::Size image_size = content->scale().size (content, _video_container_size, _film->frame_size ());
if (_approximate_size) {
diff --git a/src/lib/player.h b/src/lib/player.h
index be5cbddb4..852e7243f 100644
--- a/src/lib/player.h
+++ b/src/lib/player.h
@@ -138,7 +138,7 @@ private:
{
std::list<boost::shared_ptr<Piece> > overlaps;
for (typename std::list<boost::shared_ptr<Piece> >::const_iterator i = _pieces.begin(); i != _pieces.end(); ++i) {
- if (boost::dynamic_pointer_cast<C> ((*i)->content) && (*i)->content->position() >= t && (*i)->content->end() < t) {
+ if (boost::dynamic_pointer_cast<C> ((*i)->content) && (*i)->content->position() <= t && t < (*i)->content->end()) {
overlaps.push_back (*i);
}
}
diff --git a/src/lib/video_decoder.cc b/src/lib/video_decoder.cc
index f3d3a3104..34299bd3c 100644
--- a/src/lib/video_decoder.cc
+++ b/src/lib/video_decoder.cc
@@ -34,27 +34,27 @@ VideoDecoder::VideoDecoder (shared_ptr<const VideoContent> c)
}
-shared_ptr<ContentVideo>
+optional<ContentVideo>
VideoDecoder::decoded_video (VideoFrame frame)
{
- for (list<shared_ptr<ContentVideo> >::const_iterator i = _decoded_video.begin(); i != _decoded_video.end(); ++i) {
- if ((*i)->frame == frame) {
+ for (list<ContentVideo>::const_iterator i = _decoded_video.begin(); i != _decoded_video.end(); ++i) {
+ if (i->frame == frame) {
return *i;
}
}
- return shared_ptr<ContentVideo> ();
+ return optional<ContentVideo> ();
}
-shared_ptr<ContentVideo>
+optional<ContentVideo>
VideoDecoder::get_video (VideoFrame frame, bool accurate)
{
- if (_decoded_video.empty() || (frame < _decoded_video.front()->frame || frame > (_decoded_video.back()->frame + 1))) {
+ if (_decoded_video.empty() || (frame < _decoded_video.front().frame || frame > (_decoded_video.back().frame + 1))) {
/* Either we have no decoded data, or what we do have is a long way from what we want: seek */
seek (ContentTime::from_frames (frame, _video_content->video_frame_rate()), accurate);
}
- shared_ptr<ContentVideo> dec;
+ optional<ContentVideo> dec;
/* Now enough pass() calls will either:
* (a) give us what we want, or
@@ -73,7 +73,7 @@ VideoDecoder::get_video (VideoFrame frame, bool accurate)
}
/* Clean up decoded_video */
- while (!_decoded_video.empty() && _decoded_video.front()->frame < (frame - 1)) {
+ while (!_decoded_video.empty() && _decoded_video.front().frame < (frame - 1)) {
_decoded_video.pop_front ();
}
@@ -85,25 +85,37 @@ VideoDecoder::get_video (VideoFrame frame, bool accurate)
void
VideoDecoder::video (shared_ptr<const Image> image, VideoFrame frame)
{
+ /* Fill in gaps */
+ /* XXX: 3D */
+ while (!_decoded_video.empty () && (_decoded_video.back().frame + 1) < frame) {
+ _decoded_video.push_back (
+ ContentVideo (
+ _decoded_video.back().image,
+ _decoded_video.back().eyes,
+ _decoded_video.back().frame + 1
+ )
+ );
+ }
+
switch (_video_content->video_frame_type ()) {
case VIDEO_FRAME_TYPE_2D:
- _decoded_video.push_back (shared_ptr<ContentVideo> (new ContentVideo (image, EYES_BOTH, frame)));
+ _decoded_video.push_back (ContentVideo (image, EYES_BOTH, frame));
break;
case VIDEO_FRAME_TYPE_3D_ALTERNATE:
- _decoded_video.push_back (shared_ptr<ContentVideo> (new ContentVideo (image, (frame % 2) ? EYES_RIGHT : EYES_LEFT, frame)));
+ _decoded_video.push_back (ContentVideo (image, (frame % 2) ? EYES_RIGHT : EYES_LEFT, frame));
break;
case VIDEO_FRAME_TYPE_3D_LEFT_RIGHT:
{
int const half = image->size().width / 2;
- _decoded_video.push_back (shared_ptr<ContentVideo> (new ContentVideo (image->crop (Crop (0, half, 0, 0), true), EYES_LEFT, frame)));
- _decoded_video.push_back (shared_ptr<ContentVideo> (new ContentVideo (image->crop (Crop (half, 0, 0, 0), true), EYES_RIGHT, frame)));
+ _decoded_video.push_back (ContentVideo (image->crop (Crop (0, half, 0, 0), true), EYES_LEFT, frame));
+ _decoded_video.push_back (ContentVideo (image->crop (Crop (half, 0, 0, 0), true), EYES_RIGHT, frame));
break;
}
case VIDEO_FRAME_TYPE_3D_TOP_BOTTOM:
{
int const half = image->size().height / 2;
- _decoded_video.push_back (shared_ptr<ContentVideo> (new ContentVideo (image->crop (Crop (0, 0, 0, half), true), EYES_LEFT, frame)));
- _decoded_video.push_back (shared_ptr<ContentVideo> (new ContentVideo (image->crop (Crop (0, 0, half, 0), true), EYES_RIGHT, frame)));
+ _decoded_video.push_back (ContentVideo (image->crop (Crop (0, 0, 0, half), true), EYES_LEFT, frame));
+ _decoded_video.push_back (ContentVideo (image->crop (Crop (0, 0, half, 0), true), EYES_RIGHT, frame));
break;
}
default:
diff --git a/src/lib/video_decoder.h b/src/lib/video_decoder.h
index 7c7ec35b9..86a9489b1 100644
--- a/src/lib/video_decoder.h
+++ b/src/lib/video_decoder.h
@@ -25,17 +25,17 @@
#include "decoder.h"
#include "video_content.h"
#include "util.h"
+#include "content_video.h"
class VideoContent;
class Image;
-class ContentVideo;
class VideoDecoder : public virtual Decoder
{
public:
VideoDecoder (boost::shared_ptr<const VideoContent> c);
- boost::shared_ptr<ContentVideo> get_video (VideoFrame frame, bool accurate);
+ boost::optional<ContentVideo> get_video (VideoFrame frame, bool accurate);
boost::shared_ptr<const VideoContent> video_content () const {
return _video_content;
@@ -45,10 +45,10 @@ protected:
void seek (ContentTime time, bool accurate);
void video (boost::shared_ptr<const Image>, VideoFrame frame);
- boost::shared_ptr<ContentVideo> decoded_video (VideoFrame frame);
+ boost::optional<ContentVideo> decoded_video (VideoFrame frame);
boost::shared_ptr<const VideoContent> _video_content;
- std::list<boost::shared_ptr<ContentVideo> > _decoded_video;
+ std::list<ContentVideo> _decoded_video;
};
#endif