diff options
| author | Carl Hetherington <cth@carlh.net> | 2013-06-07 17:07:02 +0100 |
|---|---|---|
| committer | Carl Hetherington <cth@carlh.net> | 2013-06-07 17:07:02 +0100 |
| commit | 0b97307b78b1d5e017e97ff90d5d05102cb70c1c (patch) | |
| tree | 16306c8f066b10a3fb356a3065c2db84220348ce /src/lib | |
| parent | 0799f9481791f8a70589bf9e6991883f48e27b3d (diff) | |
Fix seeks past the end of video files.
Diffstat (limited to 'src/lib')
| -rw-r--r-- | src/lib/ffmpeg_decoder.cc | 9 | ||||
| -rw-r--r-- | src/lib/video_decoder.cc | 24 | ||||
| -rw-r--r-- | src/lib/video_decoder.h | 4 |
3 files changed, 36 insertions, 1 deletions
diff --git a/src/lib/ffmpeg_decoder.cc b/src/lib/ffmpeg_decoder.cc index 1d000b62b..2f890c0cd 100644 --- a/src/lib/ffmpeg_decoder.cc +++ b/src/lib/ffmpeg_decoder.cc @@ -247,7 +247,9 @@ FFmpegDecoder::pass () if (_ffmpeg_content->audio_stream() && _decode_audio) { decode_audio_packet (); } - + + /* Stop us being asked for any more data */ + _next_video = _next_audio = _ffmpeg_content->length (); return; } @@ -277,6 +279,8 @@ FFmpegDecoder::pass () } avsubtitle_free (&sub); } + } else { + cout << "[ffmpeg] other packet.\n"; } av_free_packet (&_packet); @@ -443,6 +447,7 @@ void FFmpegDecoder::seek (Time t) { do_seek (t, false, false); + VideoDecoder::seek (t); } void @@ -453,6 +458,7 @@ FFmpegDecoder::seek_back () } do_seek (next() - 2.5 * TIME_HZ / video_frame_rate(), true, true); + VideoDecoder::seek_back (); } void @@ -463,6 +469,7 @@ FFmpegDecoder::seek_forward () } do_seek (next() - 0.5 * TIME_HZ / video_frame_rate(), true, true); + VideoDecoder::seek_forward (); } void diff --git a/src/lib/video_decoder.cc b/src/lib/video_decoder.cc index a5147f42e..c5e1850c0 100644 --- a/src/lib/video_decoder.cc +++ b/src/lib/video_decoder.cc @@ -121,3 +121,27 @@ VideoDecoder::video_done () const return (_video_content->length() - _next_video) < film->video_frames_to_time (1); } + +void +VideoDecoder::seek (Time t) +{ + _next_video = t; +} + +void +VideoDecoder::seek_back () +{ + shared_ptr<const Film> film = _film.lock (); + assert (film); + _next_video -= film->video_frames_to_time (1); +} + +void +VideoDecoder::seek_forward () +{ + shared_ptr<const Film> film = _film.lock (); + assert (film); + _next_video += film->video_frames_to_time (1); +} + + diff --git a/src/lib/video_decoder.h b/src/lib/video_decoder.h index 5073efead..b47d7fc3a 100644 --- a/src/lib/video_decoder.h +++ b/src/lib/video_decoder.h @@ -31,6 +31,10 @@ class VideoDecoder : public VideoSource, public virtual Decoder public: VideoDecoder (boost::shared_ptr<const Film>, boost::shared_ptr<const VideoContent>); + virtual void seek (Time); + virtual void seek_back (); + virtual void seek_forward (); + /* Calls for VideoContent to find out about itself */ /** @return video frame rate second, or 0 if unknown */ |
