Fix incorrect scaling of DVB subtitles when the picture is not 720x576.
authorCarl Hetherington <cth@carlh.net>
Fri, 18 Nov 2016 21:33:25 +0000 (21:33 +0000)
committerCarl Hetherington <cth@carlh.net>
Sat, 19 Nov 2016 00:51:05 +0000 (00:51 +0000)
src/lib/ffmpeg_decoder.cc

index e2c200d7713224ae0c978ca5e8477f8ed4c318df..253272e9638a3387f529b7d5548eff86321ddaf6 100644 (file)
@@ -612,12 +612,13 @@ FFmpegDecoder::decode_bitmap_subtitle (AVSubtitleRect const * rect, ContentTimeP
                out_p += image->stride()[0] / sizeof (uint32_t);
        }
 
-       dcp::Size const vs = _ffmpeg_content->video->size ();
+       int const target_width = subtitle_codec_context()->width;
+       int const target_height = subtitle_codec_context()->height;
        dcpomatic::Rect<double> const scaled_rect (
-               static_cast<double> (rect->x) / vs.width,
-               static_cast<double> (rect->y) / vs.height,
-               static_cast<double> (rect->w) / vs.width,
-               static_cast<double> (rect->h) / vs.height
+               static_cast<double> (rect->x) / target_width,
+               static_cast<double> (rect->y) / target_height,
+               static_cast<double> (rect->w) / target_width,
+               static_cast<double> (rect->h) / target_height
                );
 
        subtitle->give_image (period, image, scaled_rect);