From: Carl Hetherington Date: Thu, 6 Feb 2020 09:34:30 +0000 (+0100) Subject: Fix crash with bitmapped subs that have zero width or height. X-Git-Tag: v2.14.27~15 X-Git-Url: https://main.carlh.net/gitweb/?p=dcpomatic.git;a=commitdiff_plain;h=9482a41238c370e093c896145b844dac0b221345 Fix crash with bitmapped subs that have zero width or height. Back-ported from dec5ae11238495c64fffdab37f189d96aed7d636 in v2.15.x. --- diff --git a/src/lib/player.cc b/src/lib/player.cc index fe08241ab..30b49d186 100644 --- a/src/lib/player.cc +++ b/src/lib/player.cc @@ -1,5 +1,5 @@ /* - Copyright (C) 2013-2018 Carl Hetherington + Copyright (C) 2013-2020 Carl Hetherington This file is part of DCP-o-matic. @@ -937,8 +937,15 @@ Player::bitmap_text_start (weak_ptr wp, weak_ptr wc, C PlayerText ps; shared_ptr image = subtitle.sub.image; + /* We will scale the subtitle up to fit _video_container_size */ - dcp::Size scaled_size (subtitle.sub.rectangle.width * _video_container_size.width, subtitle.sub.rectangle.height * _video_container_size.height); + int const width = subtitle.sub.rectangle.width * _video_container_size.width; + int const height = subtitle.sub.rectangle.height * _video_container_size.height; + if (width == 0 || height == 0) { + return; + } + + dcp::Size scaled_size (width, height); ps.bitmap.push_back (BitmapText(image->scale(scaled_size, dcp::YUV_TO_RGB_REC601, image->pixel_format(), true, _fast), subtitle.sub.rectangle)); DCPTime from (content_time_to_dcp (piece, subtitle.from()));