summaryrefslogtreecommitdiff
path: root/src/lib
diff options
context:
space:
mode:
authorCarl Hetherington <cth@carlh.net>2012-10-24 13:52:24 +0100
committerCarl Hetherington <cth@carlh.net>2012-10-24 13:52:24 +0100
commit7a25c08988111224f264ecfffa7df392d4c9af1a (patch)
tree6a50872f1b03d4ef9d91121eb6e8334bc1c67970 /src/lib
parent6d1748f37097e6f61ee1c6fb66c4352b0834ec8c (diff)
Try to fix overrunning subtitles.
Diffstat (limited to 'src/lib')
-rw-r--r--src/lib/decoder.cc2
-rw-r--r--src/lib/ffmpeg_decoder.cc6
2 files changed, 5 insertions, 3 deletions
diff --git a/src/lib/decoder.cc b/src/lib/decoder.cc
index da75decc8..045c1b818 100644
--- a/src/lib/decoder.cc
+++ b/src/lib/decoder.cc
@@ -463,7 +463,7 @@ Decoder::process_subtitle (shared_ptr<TimedSubtitle> s)
{
_timed_subtitle = s;
- if (_opt->apply_crop) {
+ if (_timed_subtitle && _opt->apply_crop) {
Position const p = _timed_subtitle->subtitle()->position ();
_timed_subtitle->subtitle()->set_position (Position (p.x - _fs->crop().left, p.y - _fs->crop().top));
}
diff --git a/src/lib/ffmpeg_decoder.cc b/src/lib/ffmpeg_decoder.cc
index e954294ec..9891bb55b 100644
--- a/src/lib/ffmpeg_decoder.cc
+++ b/src/lib/ffmpeg_decoder.cc
@@ -309,11 +309,13 @@ FFmpegDecoder::do_pass ()
int got_subtitle;
AVSubtitle sub;
if (avcodec_decode_subtitle2 (_subtitle_codec_context, &sub, &got_subtitle, &_packet) && got_subtitle) {
- /* I'm not entirely sure why, but sometimes we get an AVSubtitle with
- no AVSubtitleRects.
+ /* Sometimes we get an empty AVSubtitle, which is used by some codecs to
+ indicate that the previous subtitle should stop.
*/
if (sub.num_rects > 0) {
process_subtitle (shared_ptr<TimedSubtitle> (new TimedSubtitle (sub, _first_video.get())));
+ } else {
+ process_subtitle (shared_ptr<TimedSubtitle> ());
}
avsubtitle_free (&sub);
}