summaryrefslogtreecommitdiff
path: root/src/lib
diff options
context:
space:
mode:
authorCarl Hetherington <cth@carlh.net>2012-12-16 14:04:05 +0000
committerCarl Hetherington <cth@carlh.net>2012-12-16 14:04:05 +0000
commit1073b0ea3f80e1c941fd36546994ec053c5407c9 (patch)
treeb98323da7dba31f075f3b4098c86cf7e02fe9f6f /src/lib
parentbd75347a20c3952954121ce00ec2ac6fa62a01ac (diff)
Various fixes.
Diffstat (limited to 'src/lib')
-rw-r--r--src/lib/ffmpeg_decoder.cc10
-rw-r--r--src/lib/imagemagick_decoder.cc2
-rw-r--r--src/lib/video_decoder.cc6
-rw-r--r--src/lib/video_decoder.h9
4 files changed, 16 insertions, 11 deletions
diff --git a/src/lib/ffmpeg_decoder.cc b/src/lib/ffmpeg_decoder.cc
index 9fd6a0c05..314ab7c06 100644
--- a/src/lib/ffmpeg_decoder.cc
+++ b/src/lib/ffmpeg_decoder.cc
@@ -547,8 +547,11 @@ FFmpegDecoder::filter_and_emit_video (AVFrame* frame)
list<shared_ptr<Image> > images = graph->process (frame);
+ SourceFrame const sf = av_q2d (_format_context->streams[_video_stream]->time_base)
+ * av_frame_get_best_effort_timestamp(_frame) * frames_per_second();
+
for (list<shared_ptr<Image> >::iterator i = images.begin(); i != images.end(); ++i) {
- emit_video (*i);
+ emit_video (*i, sf);
}
}
@@ -558,11 +561,6 @@ FFmpegDecoder::seek (SourceFrame f)
int64_t const t = static_cast<int64_t>(f) / (av_q2d (_format_context->streams[_video_stream]->time_base) * frames_per_second());
int const r = av_seek_frame (_format_context, _video_stream, t, 0);
avcodec_flush_buffers (_video_codec_context);
-
- if (r >= 0) {
- OutputChanged ();
- }
-
return r < 0;
}
diff --git a/src/lib/imagemagick_decoder.cc b/src/lib/imagemagick_decoder.cc
index 3957da5dd..9d11e043f 100644
--- a/src/lib/imagemagick_decoder.cc
+++ b/src/lib/imagemagick_decoder.cc
@@ -92,7 +92,7 @@ ImageMagickDecoder::pass ()
delete magick_image;
- emit_video (image);
+ emit_video (image, 0);
++_iter;
return false;
diff --git a/src/lib/video_decoder.cc b/src/lib/video_decoder.cc
index a8da40b7c..d3b441fbf 100644
--- a/src/lib/video_decoder.cc
+++ b/src/lib/video_decoder.cc
@@ -31,16 +31,17 @@ using boost::optional;
VideoDecoder::VideoDecoder (shared_ptr<Film> f, shared_ptr<const DecodeOptions> o, Job* j)
: Decoder (f, o, j)
, _video_frame (0)
+ , _last_source_frame (0)
{
}
/** Called by subclasses to tell the world that some video data is ready.
* We find a subtitle then emit it for listeners.
- * @param frame to decode; caller manages memory.
+ * @param frame to emit.
*/
void
-VideoDecoder::emit_video (shared_ptr<Image> image)
+VideoDecoder::emit_video (shared_ptr<Image> image, SourceFrame f)
{
shared_ptr<Subtitle> sub;
if (_timed_subtitle && _timed_subtitle->displayed_at (double (video_frame()) / _film->frames_per_second())) {
@@ -48,6 +49,7 @@ VideoDecoder::emit_video (shared_ptr<Image> image)
}
signal_video (image, sub);
+ _last_source_frame = f;
}
void
diff --git a/src/lib/video_decoder.h b/src/lib/video_decoder.h
index a8296d918..41e876e0a 100644
--- a/src/lib/video_decoder.h
+++ b/src/lib/video_decoder.h
@@ -55,11 +55,15 @@ public:
return _subtitle_streams;
}
+ SourceFrame last_source_frame () const {
+ return _last_source_frame;
+ }
+
protected:
virtual PixelFormat pixel_format () const = 0;
- void emit_video (boost::shared_ptr<Image>);
+ void emit_video (boost::shared_ptr<Image>, SourceFrame);
void emit_subtitle (boost::shared_ptr<TimedSubtitle>);
void repeat_last_video ();
@@ -72,7 +76,8 @@ private:
void signal_video (boost::shared_ptr<Image>, boost::shared_ptr<Subtitle>);
SourceFrame _video_frame;
-
+ SourceFrame _last_source_frame;
+
boost::shared_ptr<TimedSubtitle> _timed_subtitle;
boost::shared_ptr<Image> _last_image;