: _video_content (c)
#endif
, _same (false)
+ , _last_seek_accurate (true)
{
_black_image.reset (new Image (PIX_FMT_RGB24, _video_content->video_size(), true));
_black_image->make_black ();
method returned (and possibly a few more). If the requested frame is not in _decoded_video and it is not the next
one after the end of _decoded_video we need to seek.
*/
-
+
if (_decoded_video.empty() || frame < _decoded_video.front().frame || frame > (_decoded_video.back().frame + 1)) {
seek (ContentTime::from_frames (frame, _video_content->video_frame_rate()), accurate);
}
return dec;
}
-/** Fill _decoded_video up to, but not including, the specified frame */
+/** Fill _decoded_video from `from' up to, but not including, `to' */
void
-VideoDecoder::fill_up_to_2d (VideoFrame frame)
+VideoDecoder::fill_2d (VideoFrame from, VideoFrame to)
{
- if (frame == 0) {
+ if (to == 0) {
/* Already OK */
return;
}
filler_part = _decoded_video.back().part;
}
- VideoFrame filler_frame = _decoded_video.empty() ? 0 : (_decoded_video.back().frame + 1);
- while (filler_frame < frame) {
+ VideoFrame filler_frame = from;
+
+ while (filler_frame < (to - 1)) {
#ifdef DCPOMATIC_DEBUG
test_gaps++;
#endif
-
_decoded_video.push_back (
ContentVideo (filler_image, EYES_BOTH, filler_part, filler_frame)
);
}
}
-/** Fill _decoded_video up to, but not including, the specified frame and eye */
+/** Fill _decoded_video from `from' up to, but not including, `to' */
void
-VideoDecoder::fill_up_to_3d (VideoFrame frame, Eyes eye)
+VideoDecoder::fill_3d (VideoFrame from, VideoFrame to, Eyes eye)
{
- if (frame == 0 && eye == EYES_LEFT) {
+ if (to == 0 && eye == EYES_LEFT) {
/* Already OK */
return;
}
}
}
- VideoFrame filler_frame = _decoded_video.empty() ? 0 : _decoded_video.back().frame;
+ VideoFrame filler_frame = from;
Eyes filler_eye = _decoded_video.empty() ? EYES_LEFT : _decoded_video.back().eyes;
if (_decoded_video.empty ()) {
filler_eye = EYES_LEFT;
}
- while (filler_frame != frame || filler_eye != eye) {
+ while (filler_frame != to || filler_eye != eye) {
#ifdef DCPOMATIC_DEBUG
test_gaps++;
and the things we are about to push.
*/
- if (_video_content->video_frame_type() == VIDEO_FRAME_TYPE_2D) {
- fill_up_to_2d (to_push.front().frame);
- } else {
- fill_up_to_3d (to_push.front().frame, to_push.front().eyes);
+ boost::optional<VideoFrame> from;
+ boost::optional<VideoFrame> to;
+
+ if (_decoded_video.empty() && _last_seek_time && _last_seek_accurate) {
+ from = _last_seek_time->frames (_video_content->video_frame_rate ());
+ to = to_push.front().frame;
+ } else if (!_decoded_video.empty ()) {
+ from = _decoded_video.back().frame + 1;
+ to = to_push.front().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);
+ }
}
copy (to_push.begin(), to_push.end(), back_inserter (_decoded_video));
}
void
-VideoDecoder::seek (ContentTime, bool)
+VideoDecoder::seek (ContentTime s, bool accurate)
{
_decoded_video.clear ();
+ _last_seek_time = s;
+ _last_seek_accurate = accurate;
}
-
void seek (ContentTime time, bool accurate);
void video (boost::shared_ptr<const ImageProxy>, VideoFrame frame);
std::list<ContentVideo> decoded_video (VideoFrame frame);
- void fill_up_to_2d (VideoFrame);
- void fill_up_to_3d (VideoFrame, Eyes);
+ void fill_2d (VideoFrame from, VideoFrame to);
+ void fill_3d (VideoFrame from, VideoFrame to, Eyes);
boost::shared_ptr<const VideoContent> _video_content;
std::list<ContentVideo> _decoded_video;
bool _same;
boost::shared_ptr<Image> _black_image;
+ boost::optional<ContentTime> _last_seek_time;
+ bool _last_seek_accurate;
};
#endif
shared_ptr<ImageContent> c (new ImageContent (film, "test/data/simple_testcard_640x480.png"));
ImageDecoder decoder (c);
- decoder.fill_up_to_2d (4);
+ decoder.fill_2d (0, 4);
BOOST_CHECK_EQUAL (decoder._decoded_video.size(), 4);
list<ContentVideo>::iterator i = decoder._decoded_video.begin();
for (int j = 0; j < 4; ++j) {
++i;
}
- decoder.fill_up_to_2d (7);
+ decoder.fill_2d (0, 7);
BOOST_CHECK_EQUAL (decoder._decoded_video.size(), 7);
i = decoder._decoded_video.begin();
for (int j = 0; j < 7; ++j) {
shared_ptr<ImageContent> c (new ImageContent (film, "test/data/simple_testcard_640x480.png"));
ImageDecoder decoder (c);
- decoder.fill_up_to_3d (4, EYES_LEFT);
+ decoder.fill_3d (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) {
++i;
}
- decoder.fill_up_to_3d (7, EYES_RIGHT);
+ decoder.fill_3d (0, 7, EYES_RIGHT);
BOOST_CHECK_EQUAL (decoder._decoded_video.size(), 15);
i = decoder._decoded_video.begin();
for (int j = 0; j < 15; ++j) {