if (sub.num_rects > 0) {
shared_ptr<TimedSubtitle> ts;
try {
- emit_subtitle (shared_ptr<TimedSubtitle> (new TimedSubtitle (sub, _first_video.get())));
+ emit_subtitle (shared_ptr<TimedSubtitle> (new TimedSubtitle (sub)));
} catch (...) {
/* some problem with the subtitle; we probably didn't understand it */
}
/** Construct a TimedSubtitle. This is a subtitle image, position,
* and a range of time over which it should be shown.
* @param sub AVSubtitle to read.
- * @param c Fractional seconds that should be subtracted from the AVSubtitle's PTS.
*/
-TimedSubtitle::TimedSubtitle (AVSubtitle const & sub, double c)
+TimedSubtitle::TimedSubtitle (AVSubtitle const & sub)
{
assert (sub.rects > 0);
- /* subtitle PTS in seconds */
- double const packet_time = ((sub.pts / AV_TIME_BASE) + float (sub.pts % AV_TIME_BASE) / 1e6) - c;
+ /* Subtitle PTS in seconds (within the source, not taking into account any of the
+ source that we may have chopped off for the DCP)
+ */
+ double const packet_time = ((sub.pts / AV_TIME_BASE) + float (sub.pts % AV_TIME_BASE) / 1e6);
/* hence start time for this sub */
_from = packet_time + (double (sub.start_display_time) / 1e3);
class TimedSubtitle
{
public:
- TimedSubtitle (AVSubtitle const &, double c);
+ TimedSubtitle (AVSubtitle const &);
bool displayed_at (double t) const;
/** Called by subclasses to tell the world that some video data is ready.
* We find a subtitle then emit it for listeners.
- * @param frame to emit.
+ * @param image frame to emit.
+ * @param f Frame within the source.
*/
void
VideoDecoder::emit_video (shared_ptr<Image> image, SourceFrame f)
{
shared_ptr<Subtitle> sub;
if (_timed_subtitle && _timed_subtitle->displayed_at (f / _film->frames_per_second())) {
+ _film->log()->log (String::compose ("putting subtitle using %1 instead of %2", f, video_frame()));
sub = _timed_subtitle->subtitle ();
}