diff options
| author | Carl Hetherington <cth@carlh.net> | 2012-12-16 14:04:05 +0000 |
|---|---|---|
| committer | Carl Hetherington <cth@carlh.net> | 2012-12-16 14:04:05 +0000 |
| commit | 1073b0ea3f80e1c941fd36546994ec053c5407c9 (patch) | |
| tree | b98323da7dba31f075f3b4098c86cf7e02fe9f6f /src | |
| parent | bd75347a20c3952954121ce00ec2ac6fa62a01ac (diff) | |
Various fixes.
Diffstat (limited to 'src')
| -rw-r--r-- | src/lib/ffmpeg_decoder.cc | 10 | ||||
| -rw-r--r-- | src/lib/imagemagick_decoder.cc | 2 | ||||
| -rw-r--r-- | src/lib/video_decoder.cc | 6 | ||||
| -rw-r--r-- | src/lib/video_decoder.h | 9 | ||||
| -rw-r--r-- | src/wx/film_viewer.cc | 33 | ||||
| -rw-r--r-- | src/wx/film_viewer.h | 1 |
6 files changed, 35 insertions, 26 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; diff --git a/src/wx/film_viewer.cc b/src/wx/film_viewer.cc index 80516328c..241b60e8a 100644 --- a/src/wx/film_viewer.cc +++ b/src/wx/film_viewer.cc @@ -118,12 +118,7 @@ FilmViewer::set_film (shared_ptr<Film> f) void FilmViewer::decoder_changed () { - shared_ptr<Image> last = _display; - while (last == _display) { - _decoders.video->pass (); - } - _panel->Refresh (); - _panel->Update (); + seek_and_update (_decoders.video->last_source_frame ()); } void @@ -137,15 +132,10 @@ FilmViewer::timer (wxTimerEvent& ev) _decoders.video->pass (); } -#if 0 - if (_last_frame_in_seconds) { - double const video_length_in_seconds = static_cast<double>(_format_context->duration) / AV_TIME_BASE; - int const new_slider_position = 4096 * _last_frame_in_seconds / video_length_in_seconds; - if (new_slider_position != _slider->GetValue()) { - _slider->SetValue (new_slider_position); - } + int const new_slider_position = 4096 * _decoders.video->last_source_frame() / _film->length().get(); + if (new_slider_position != _slider->GetValue()) { + _slider->SetValue (new_slider_position); } -#endif } @@ -166,7 +156,20 @@ FilmViewer::paint_panel (wxPaintEvent& ev) void FilmViewer::slider_moved (wxCommandEvent& ev) { - _decoders.video->seek (_slider->GetValue() * _film->length().get() / 4096); + seek_and_update (_slider->GetValue() * _film->length().get() / 4096); +} + +void +FilmViewer::seek_and_update (SourceFrame f) +{ + _decoders.video->seek (f); + + shared_ptr<Image> last = _display; + while (last == _display) { + _decoders.video->pass (); + } + _panel->Refresh (); + _panel->Update (); } void diff --git a/src/wx/film_viewer.h b/src/wx/film_viewer.h index b1d0b99d3..8194d0206 100644 --- a/src/wx/film_viewer.h +++ b/src/wx/film_viewer.h @@ -52,6 +52,7 @@ private: void check_play_state (); void update_from_raw (); void decoder_changed (); + void seek_and_update (SourceFrame); boost::shared_ptr<Film> _film; |
