diff options
Diffstat (limited to 'src/lib/ffmpeg_decoder.cc')
| -rw-r--r-- | src/lib/ffmpeg_decoder.cc | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/src/lib/ffmpeg_decoder.cc b/src/lib/ffmpeg_decoder.cc index f0500a629..e2c200d77 100644 --- a/src/lib/ffmpeg_decoder.cc +++ b/src/lib/ffmpeg_decoder.cc @@ -425,6 +425,8 @@ FFmpegDecoder::decode_audio_packet () LOG_WARNING ("Crazy timestamp %s", to_string (ct)); } + update_position (ct); + /* Give this data provided there is some, and its time is sane */ if (ct >= ContentTime() && data->frames() > 0) { audio->give (*stream, data, ct); @@ -476,6 +478,7 @@ FFmpegDecoder::decode_video_packet () shared_ptr<ImageProxy> (new RawImageProxy (image)), llrint (pts * _ffmpeg_content->active_video_frame_rate ()) ); + update_position (ContentTime::from_seconds (pts)); } else { LOG_WARNING_NC ("Dropping frame without PTS"); } @@ -506,6 +509,7 @@ FFmpegDecoder::decode_subtitle_packet () FFmpegSubtitlePeriod sub_period = subtitle_period (sub); ContentTimePeriod period; period.from = sub_period.from + _pts_offset; + update_position (period.from); if (sub_period.to) { /* We already know the subtitle period `to' time */ period.to = sub_period.to.get() + _pts_offset; @@ -639,3 +643,16 @@ FFmpegDecoder::decode_ass_subtitle (string ass, ContentTimePeriod period) subtitle->give_text (period, i); } } + +void +FFmpegDecoder::update_position (ContentTime p) +{ + /* _position should err on the side of being too big, as then there is less + chance that we will erroneously decide not to seek when _position > request. + */ + if (!_position) { + _position = p; + } else { + _position = max (*_position, p); + } +} |
