new SubtitleDecoder (
this,
c->subtitle,
+ log,
bind (&FFmpegDecoder::image_subtitles_during, this, _1, _2),
bind (&FFmpegDecoder::text_subtitles_during, this, _1, _2)
)
}
if (ct < ContentTime()) {
- LOG_WARNING ("Crazy timestamp %s", to_string (ct));
+ LOG_WARNING ("Crazy timestamp %1", to_string (ct));
}
/* Give this data provided there is some, and its time is sane */
FFmpegSubtitlePeriod sub_period = subtitle_period (sub);
ContentTimePeriod period;
period.from = sub_period.from + _pts_offset;
- if (sub_period.to) {
- /* We already know the subtitle period `to' time */
- period.to = sub_period.to.get() + _pts_offset;
- } else {
- /* We have to look up the `to' time in the stream's records */
- period.to = ffmpeg_content()->subtitle_stream()->find_subtitle_to (subtitle_id (sub));
- }
+ /* We can't trust the `to' time from sub_period as there are some decoders which
+ give a sub_period time for `to' which is subsequently overridden by a `stop' subtitle;
+ see also FFmpegExaminer.
+ */
+ period.to = ffmpeg_content()->subtitle_stream()->find_subtitle_to (subtitle_id (sub));
for (unsigned int i = 0; i < sub.num_rects; ++i) {
AVSubtitleRect const * rect = sub.rects[i];
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);