summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorjstebbins <[email protected]>2013-10-19 23:06:36 +0000
committerjstebbins <[email protected]>2013-10-19 23:06:36 +0000
commit4759bd40cda7b1e71a015e0deb668b56b2fad5fb (patch)
treec9afe258123cf7d893700ff878fca787e80f4629
parent83d7c415ce5d3b3af108e1b9e13f65abd021189d (diff)
libhb: fix pgs timestamp problems
Fixes "pts < dts" and "non-monotically increasing dts" errors in avformat muxing. git-svn-id: svn://svn.handbrake.fr/HandBrake/trunk@5843 b64f7644-9d1e-0410-96f1-a4d463321fa5
-rw-r--r--libhb/decpgssub.c58
1 files changed, 35 insertions, 23 deletions
diff --git a/libhb/decpgssub.c b/libhb/decpgssub.c
index f6004cb6d..937d2e567 100644
--- a/libhb/decpgssub.c
+++ b/libhb/decpgssub.c
@@ -198,7 +198,14 @@ static int decsubWork( hb_work_object_t * w, hb_buffer_t ** buf_in,
avp.data = in->data;
avp.size = in->size;
// libav wants pkt pts in AV_TIME_BASE units
- avp.pts = av_rescale(in->s.start, AV_TIME_BASE, 90000);
+ if (in->s.start != -1)
+ {
+ avp.pts = av_rescale(in->s.start, AV_TIME_BASE, 90000);
+ }
+ else
+ {
+ avp.pts = AV_NOPTS_VALUE;
+ }
int has_subtitle = 0;
@@ -276,39 +283,43 @@ static int decsubWork( hb_work_object_t * w, hb_buffer_t ** buf_in,
if (useable_sub)
{
- int64_t pts = av_rescale(subtitle.pts, 90000, AV_TIME_BASE);
+ int64_t pts = AV_NOPTS_VALUE;
hb_buffer_t * out = NULL;
- // work around broken timestamps
- if (pts < 0 && in->s.start >= 0)
+ if (subtitle.pts != AV_NOPTS_VALUE)
+ {
+ pts = av_rescale(subtitle.pts, 90000, AV_TIME_BASE);
+ }
+ else
{
- if (pts < pv->last_pts)
+ if (in->s.start >= 0)
{
- // 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);
+ pts = in->s.start;
}
else
{
- pts = in->s.start;
+ // 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);
}
}
- else if (pts < 0)
+ // work around broken timestamps
+ if (pts < pv->last_pts)
{
- // XXX: a broken pts will cause us to drop this subtitle,
- // which is bad; use a default duration of 3 seconds
+ // XXX: this should only happen if the prevous pts
+ // was unknown and our 3 second default duration
+ // overshot the next pgs pts.
//
- // 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",
+ // 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);
}
pv->last_pts = pts;
@@ -354,6 +365,7 @@ static int decsubWork( hb_work_object_t * w, hb_buffer_t ** buf_in,
out->s.frametype = HB_FRAME_SUBTITLE;
out->sequence = in->sequence;
}
+ out->s.renderOffset = -1;
out->s.start = out->s.stop = pts;
}
else