summaryrefslogtreecommitdiff
path: root/src/lib/ffmpeg_decoder.cc
diff options
context:
space:
mode:
authorCarl Hetherington <cth@carlh.net>2022-04-28 14:00:07 +0200
committerCarl Hetherington <cth@carlh.net>2022-04-28 23:55:16 +0200
commite2d4793bfd92b4f210147889b8a69fbda7e3ed7f (patch)
tree724370a5223767ea833db49e7949b9fdedc1cc95 /src/lib/ffmpeg_decoder.cc
parenta0a6f0dc8107f78b8efba6b1c76aaa8ac8f05ed2 (diff)
Handle multiple bitmap subtitles at the same time correctly (#2239).
Previously if there were two images at the same time we would start them both, then the stop time would be set in the second one but not the first. This meant that the first one would hang around forever.
Diffstat (limited to 'src/lib/ffmpeg_decoder.cc')
-rw-r--r--src/lib/ffmpeg_decoder.cc13
1 files changed, 9 insertions, 4 deletions
diff --git a/src/lib/ffmpeg_decoder.cc b/src/lib/ffmpeg_decoder.cc
index f76c7699e..bc7d28d7d 100644
--- a/src/lib/ffmpeg_decoder.cc
+++ b/src/lib/ffmpeg_decoder.cc
@@ -644,6 +644,7 @@ FFmpegDecoder::decode_and_process_subtitle_packet (AVPacket* packet)
_have_current_subtitle = true;
}
+ ContentBitmapText bitmap_text(from);
for (unsigned int i = 0; i < sub.num_rects; ++i) {
auto const rect = sub.rects[i];
@@ -651,7 +652,7 @@ FFmpegDecoder::decode_and_process_subtitle_packet (AVPacket* packet)
case SUBTITLE_NONE:
break;
case SUBTITLE_BITMAP:
- process_bitmap_subtitle (rect, from);
+ bitmap_text.subs.push_back(process_bitmap_subtitle(rect));
break;
case SUBTITLE_TEXT:
cout << "XXX: SUBTITLE_TEXT " << rect->text << "\n";
@@ -662,6 +663,10 @@ FFmpegDecoder::decode_and_process_subtitle_packet (AVPacket* packet)
}
}
+ if (!bitmap_text.subs.empty()) {
+ only_text()->emit_bitmap_start(bitmap_text);
+ }
+
if (_current_subtitle_to) {
only_text()->emit_stop (*_current_subtitle_to);
}
@@ -670,8 +675,8 @@ FFmpegDecoder::decode_and_process_subtitle_packet (AVPacket* packet)
}
-void
-FFmpegDecoder::process_bitmap_subtitle (AVSubtitleRect const * rect, ContentTime from)
+BitmapText
+FFmpegDecoder::process_bitmap_subtitle (AVSubtitleRect const * rect)
{
/* Note BGRA is expressed little-endian, so the first byte in the word is B, second
G, third R, fourth A.
@@ -754,7 +759,7 @@ FFmpegDecoder::process_bitmap_subtitle (AVSubtitleRect const * rect, ContentTime
static_cast<double>(rect->h) / target_height
);
- only_text()->emit_bitmap_start ({ from, image, scaled_rect });
+ return { image, scaled_rect };
}