diff options
author | jstebbins <[email protected]> | 2010-06-20 21:20:40 +0000 |
---|---|---|
committer | jstebbins <[email protected]> | 2010-06-20 21:20:40 +0000 |
commit | 57bcc243f164e5aceea7f763f9e1a8cfc721891f (patch) | |
tree | a8f335e3461c657413573414b44dff64e38076c0 | |
parent | f089f0bda2381bcc97ea26e3f1212ae8066746b3 (diff) |
fix problem with spurious timestamp change
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://svn.handbrake.fr/HandBrake/trunk@3399 b64f7644-9d1e-0410-96f1-a4d463321fa5
-rw-r--r-- | libhb/reader.c | 11 |
1 files changed, 7 insertions, 4 deletions
diff --git a/libhb/reader.c b/libhb/reader.c index 6e7f0e63b..fd08b6ae3 100644 --- a/libhb/reader.c +++ b/libhb/reader.c @@ -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; } /*********************************************************************** |