diff options
| author | Carl Hetherington <cth@carlh.net> | 2024-03-04 00:41:01 +0100 |
|---|---|---|
| committer | Carl Hetherington <cth@carlh.net> | 2024-03-04 00:43:28 +0100 |
| commit | 17f8f22b07bd32d57edada0acde6fd9fffe3baf3 (patch) | |
| tree | e72a5dfd79b3040c38e33180226aba05f46a36f0 /src/lib/player.cc | |
| parent | 34bfe29024dd7926db8289781fa70c5e408263e5 (diff) | |
More correctly calculate bitmap subtitle scaling (#2670).2670-again
This was partially fixed before in
6ac468554c7fea0dfaefde85fb6cdd0fceaf5cad
The last try accounted for cropping, but not for cases where the
source video (after crop) does not precisely fit the DCP container.
In those cases the x scale for the subtitles could be different
to the y scale, squashing or stretching them.
Diffstat (limited to 'src/lib/player.cc')
| -rw-r--r-- | src/lib/player.cc | 12 |
1 files changed, 7 insertions, 5 deletions
diff --git a/src/lib/player.cc b/src/lib/player.cc index c03cb97a5..1b5eca65c 100644 --- a/src/lib/player.cc +++ b/src/lib/player.cc @@ -1233,7 +1233,8 @@ Player::bitmap_text_start (weak_ptr<Piece> weak_piece, weak_ptr<const TextConten auto piece = weak_piece.lock (); auto content = weak_content.lock (); - if (!piece || !content) { + auto film = _film.lock(); + if (!piece || !content || !film) { return; } @@ -1254,15 +1255,16 @@ Player::bitmap_text_start (weak_ptr<Piece> weak_piece, weak_ptr<const TextConten auto image = sub.image; - /* We will scale the subtitle up to fit _video_container_size */ - int const width = sub.rectangle.width * _video_container_size.load().width; - int const height = sub.rectangle.height * _video_container_size.load().height; + auto const inter_size = scale_for_display(sub.parent_size, _video_container_size.load(), film->frame_size(), {}); + + int const width = sub.rectangle.width * inter_size.width; + int const height = sub.rectangle.height * inter_size.height; if (width == 0 || height == 0) { return; } dcp::Size scaled_size (width, height); - ps.bitmap.push_back (BitmapText(image->scale(scaled_size, dcp::YUVToRGB::REC601, image->pixel_format(), Image::Alignment::PADDED, _fast), sub.rectangle)); + ps.bitmap.push_back(BitmapText(sub.parent_size, image->scale(scaled_size, dcp::YUVToRGB::REC601, image->pixel_format(), Image::Alignment::PADDED, _fast), sub.rectangle)); } DCPTime from(content_time_to_dcp(piece, subtitle.from())); |
