diff options
author | Rodeo <[email protected]> | 2012-09-20 14:59:14 +0000 |
---|---|---|
committer | Rodeo <[email protected]> | 2012-09-20 14:59:14 +0000 |
commit | eb883aebc401881e0a861df2e7d2a591a2ad4705 (patch) | |
tree | dde1267b685e8f6f733597ce53d906f700ad93c3 /libhb | |
parent | d20e2f8c79443b3733908c6bd629c29fb2374310 (diff) |
decpgssub: avoid dropping subtitles when we get broken timestamps.
Instead, use a default PTS difference of 3 seconds.
git-svn-id: svn://svn.handbrake.fr/HandBrake/trunk@4970 b64f7644-9d1e-0410-96f1-a4d463321fa5
Diffstat (limited to 'libhb')
-rw-r--r-- | libhb/decpgssub.c | 33 |
1 files changed, 24 insertions, 9 deletions
diff --git a/libhb/decpgssub.c b/libhb/decpgssub.c index ec7ce54b2..9d32c85e3 100644 --- a/libhb/decpgssub.c +++ b/libhb/decpgssub.c @@ -27,6 +27,10 @@ struct hb_work_private_s // while parsing an input packet. hb_buffer_t * list_buffer; hb_buffer_t * last_buffer; + // XXX: we may occasionally see subtitles with broken timestamps + // while this should really get fixed elsewhere, + // dropping subtitles should be avoided as much as possible + int64_t last_pts; // for PGS subs, we need to pass 'empty' subtitles through (they clear the // display) - when doing forced-only extraction, only pass empty subtitles // through if we've seen a forced sub and haven't seen any empty sub since @@ -47,9 +51,10 @@ static int decsubInit( hb_work_object_t * w, hb_job_t * job ) w->private_data = pv; pv->discard_subtitle = 1; - pv->seen_forced_sub = 0; - pv->context = context; - pv->job = job; + pv->seen_forced_sub = 0; + pv->last_pts = 0; + pv->context = context; + pv->job = job; return 0; } @@ -272,6 +277,21 @@ static int decsubWork( hb_work_object_t * w, hb_buffer_t ** buf_in, int64_t pts = av_rescale(subtitle.pts, 90000, AV_TIME_BASE); hb_buffer_t * out = NULL; + // work around broken timestamps + if (pts < 0 && in->s.start >= 0) + { + pts = in->s.start; + } + else if (pts < 0) + { + // XXX: a broken pts will cause us to drop this subtitle, + // which is bad; use a default duration of 3 seconds + pts = pv->last_pts + 3 * 90000LL; + hb_log("[warning] decpgssub: track %d, invalid PTS", + w->subtitle->out_track); + } + pv->last_pts = pts; + if ( w->subtitle->config.dest == PASSTHRUSUB && hb_subtitle_can_pass( PGSSUB, pv->job->mux ) ) { @@ -312,12 +332,7 @@ static int decsubWork( hb_work_object_t * w, hb_buffer_t ** buf_in, out->s = in->s; out->sequence = in->sequence; } - if (pts >= 0) - { - // this should (eventually) always be the case - out->s.start = pts; - } - out->s.stop = out->s.start; + out->s.start = out->s.stop = pts; } else { |