From ec915d89da5cebf5f30b9c8e909a1233d105a14d Mon Sep 17 00:00:00 2001 From: jstebbins Date: Mon, 26 Aug 2013 21:27:39 +0000 Subject: [PATCH] libhb: fix potential pgs timestamp problem Under rare circumstances, the computed start time would jump backward. git-svn-id: svn://svn.handbrake.fr/HandBrake/trunk@5753 b64f7644-9d1e-0410-96f1-a4d463321fa5 --- libhb/decpgssub.c | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/libhb/decpgssub.c b/libhb/decpgssub.c index 3c6c8fe90..f6004cb6d 100644 --- a/libhb/decpgssub.c +++ b/libhb/decpgssub.c @@ -282,12 +282,31 @@ static int decsubWork( hb_work_object_t * w, hb_buffer_t ** buf_in, // work around broken timestamps if (pts < 0 && in->s.start >= 0) { - pts = in->s.start; + if (pts < pv->last_pts) + { + // XXX: this should only happen if the prevous pts + // was unknown and our 3 second default duration + // overshot the next pgs pts. + // + // assign a 1 second duration + pts = pv->last_pts + 1 * 90000LL; + hb_log("[warning] decpgssub: track %d, non-monotically increasing PTS", + w->subtitle->out_track); + } + else + { + 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 + // + // A broken pts is only generated when a pgs packet + // occurs after a discontinuity and before the + // next audio or video packet which re-establishes + // timing (afaik). pts = pv->last_pts + 3 * 90000LL; hb_log("[warning] decpgssub: track %d, invalid PTS", w->subtitle->out_track); -- 2.40.0