summaryrefslogtreecommitdiff
path: root/src/lib/ffmpeg_decoder.cc
diff options
context:
space:
mode:
authorCarl Hetherington <cth@carlh.net>2018-12-03 20:53:34 +0000
committerCarl Hetherington <cth@carlh.net>2018-12-03 20:53:34 +0000
commit1a719b15445a6244ce47c69157b64f1fd3377635 (patch)
tree0bb92b237db72c70f38710f2dfadc132d251362d /src/lib/ffmpeg_decoder.cc
parentb5dffd18c0f38ea54481c66b869d107d84fa13df (diff)
Work around width/height being 0 in subtitle_codec_context(), seen
in the wild in a MP4, apparently from a DVD rip.
Diffstat (limited to 'src/lib/ffmpeg_decoder.cc')
-rw-r--r--src/lib/ffmpeg_decoder.cc15
1 files changed, 13 insertions, 2 deletions
diff --git a/src/lib/ffmpeg_decoder.cc b/src/lib/ffmpeg_decoder.cc
index 3d9e965a9..ce20997c8 100644
--- a/src/lib/ffmpeg_decoder.cc
+++ b/src/lib/ffmpeg_decoder.cc
@@ -659,8 +659,19 @@ FFmpegDecoder::decode_bitmap_subtitle (AVSubtitleRect const * rect, ContentTime
out_p += image->stride()[0] / sizeof (uint32_t);
}
- int const target_width = subtitle_codec_context()->width;
- int const target_height = subtitle_codec_context()->height;
+ int target_width = subtitle_codec_context()->width;
+ if (target_width == 0 && video_codec_context()) {
+ /* subtitle_codec_context()->width == 0 has been seen in the wild but I don't
+ know if it's supposed to mean something from FFmpeg's point of view.
+ */
+ target_width = video_codec_context()->width;
+ }
+ int target_height = subtitle_codec_context()->height;
+ if (target_height == 0 && video_codec_context()) {
+ target_height = video_codec_context()->height;
+ }
+ DCPOMATIC_ASSERT (target_width);
+ DCPOMATIC_ASSERT (target_height);
dcpomatic::Rect<double> const scaled_rect (
static_cast<double> (rect->x) / target_width,
static_cast<double> (rect->y) / target_height,