OSDN Git Service

fix problem with spurious timestamp change
authorjstebbins <jstebbins@b64f7644-9d1e-0410-96f1-a4d463321fa5>
Sun, 20 Jun 2010 21:20:40 +0000 (21:20 +0000)
committerjstebbins <jstebbins@b64f7644-9d1e-0410-96f1-a4d463321fa5>
Sun, 20 Jun 2010 21:20:40 +0000 (21:20 +0000)
some rearrangement of code that was previously done to reader caused
scr_offset to be subtracted from renderOffset twice whenever a
new scr_offset was calculated.  this could cause subsequent timestamp
calculations to be way off and in at least one known case lead to
a crash due to consuming too much memory in hb_buffer_t's

git-svn-id: svn://localhost/HandBrake/trunk@3399 b64f7644-9d1e-0410-96f1-a4d463321fa5

libhb/reader.c

index 6e7f0e6..fd08b6a 100644 (file)
@@ -167,8 +167,12 @@ static void update_ipt( hb_reader_t *r, const hb_buffer_t *buf )
 {
     stream_timing_t *st = id_to_st( r, buf );
     double dt = buf->renderOffset - st->last;
-    st->average += ( dt - st->average ) * (1./32.);
-    st->last = buf->renderOffset;
+    // Protect against spurious bad timestamps
+    if ( dt > -5 * 90000LL && dt < 5 * 90000LL )
+    {
+        st->average += ( dt - st->average ) * (1./32.);
+        st->last = buf->renderOffset;
+    }
 }
 
 // use the per-stream state associated with 'buf' to compute a new scr_offset
@@ -180,9 +184,8 @@ static void new_scr_offset( hb_reader_t *r, hb_buffer_t *buf )
     stream_timing_t *st = id_to_st( r, buf );
     int64_t nxt = st->last + st->average;
     r->scr_offset = buf->renderOffset - nxt;
-    buf->renderOffset = nxt;
     r->scr_changes = r->demux.scr_changes;
-    st->last = buf->renderOffset;
+    st->last = nxt;
 }
 
 /***********************************************************************