diff options
| author | Carl Hetherington <cth@carlh.net> | 2012-10-20 00:52:08 +0100 |
|---|---|---|
| committer | Carl Hetherington <cth@carlh.net> | 2012-10-20 00:52:08 +0100 |
| commit | d7d1a6b8d97390e57ce8d2442d90d25f97d8b562 (patch) | |
| tree | 22fc8fdb65b6d7e7f09ee196f34b8faa2807431a /src/lib | |
| parent | e06f9e4dc4290b387eb08fea0c90460ef46654b4 (diff) | |
Cope with AVSubtitles having no AVSubtitleRects.
Diffstat (limited to 'src/lib')
| -rw-r--r-- | src/lib/ffmpeg_decoder.cc | 7 | ||||
| -rw-r--r-- | src/lib/subtitle.cc | 2 |
2 files changed, 8 insertions, 1 deletions
diff --git a/src/lib/ffmpeg_decoder.cc b/src/lib/ffmpeg_decoder.cc index 828934604..554188343 100644 --- a/src/lib/ffmpeg_decoder.cc +++ b/src/lib/ffmpeg_decoder.cc @@ -254,7 +254,12 @@ FFmpegDecoder::do_pass () int got_subtitle; AVSubtitle sub; if (avcodec_decode_subtitle2 (_subtitle_codec_context, &sub, &got_subtitle, &_packet) && got_subtitle) { - process_subtitle (shared_ptr<TimedSubtitle> (new TimedSubtitle (sub))); + /* I'm not entirely sure why, but sometimes we get an AVSubtitle with + no AVSubtitleRects. + */ + if (sub.num_rects > 0) { + process_subtitle (shared_ptr<TimedSubtitle> (new TimedSubtitle (sub))); + } avsubtitle_free (&sub); } } diff --git a/src/lib/subtitle.cc b/src/lib/subtitle.cc index 451d83691..f851d5643 100644 --- a/src/lib/subtitle.cc +++ b/src/lib/subtitle.cc @@ -35,6 +35,8 @@ using namespace boost; */ TimedSubtitle::TimedSubtitle (AVSubtitle const & sub) { + assert (sub.rects > 0); + /* subtitle PTS in seconds */ float const packet_time = (sub.pts / AV_TIME_BASE) + float (sub.pts % AV_TIME_BASE) / 1e6; |
