diff options
author | van <[email protected]> | 2008-09-16 21:31:46 +0000 |
---|---|---|
committer | van <[email protected]> | 2008-09-16 21:31:46 +0000 |
commit | c235b2520cfbafb3acdf2c0836b4df8e54882b50 (patch) | |
tree | 224f322b18ec3a4650068f26d21d2b6757e3fd09 /libhb | |
parent | ab154ca5555a0b04a5ee4f00bf65b27a57f64471 (diff) |
Another bug fix in the per-stream timing code: If the clock reference changes on the first buffer of a stream we haven't seen before we don't have the history we need to compute a clock offset & need to wait for a stream we've been tracking.
git-svn-id: svn://svn.handbrake.fr/HandBrake/trunk@1704 b64f7644-9d1e-0410-96f1-a4d463321fa5
Diffstat (limited to 'libhb')
-rw-r--r-- | libhb/reader.c | 36 |
1 files changed, 29 insertions, 7 deletions
diff --git a/libhb/reader.c b/libhb/reader.c index d1c0a598a..75fd1b4fa 100644 --- a/libhb/reader.c +++ b/libhb/reader.c @@ -83,10 +83,23 @@ static void push_buf( const hb_reader_t *r, hb_fifo_t *fifo, hb_buffer_t *buf ) // seemlessly join packets on either side of the discontinuity. This join // requires that we know the timestamp of the previous packet and the // average inter-packet time (since we position the new packet at the end -// of the previous packet). The next three routines keep track of this +// of the previous packet). The next four routines keep track of this // per-stream timing. -// find the per-stream timing state associated with 'buf' +// find the per-stream timing state for 'buf' + +static stream_timing_t *find_st( hb_reader_t *r, const hb_buffer_t *buf ) +{ + stream_timing_t *st = r->stream_timing; + for ( ; st->id != -1; ++st ) + { + if ( st->id == buf->id ) + return st; + } + return NULL; +} + +// find or create the per-stream timing state for 'buf' static stream_timing_t *id_to_st( hb_reader_t *r, const hb_buffer_t *buf ) { @@ -275,10 +288,7 @@ static void ReaderFunc( void * _r ) buf->renderOffset != -1 ) { r->saw_video = 1; - r->scr_changes = r->demux.scr_changes; - new_scr_offset( r, buf ); - hb_log( "reader: first SCR %lld scr_offset %lld", - r->demux.last_scr, r->scr_offset ); + hb_log( "reader: first SCR %lld", r->demux.last_scr ); } else { @@ -304,7 +314,19 @@ static void ReaderFunc( void * _r ) // change. Compute a new scr offset that would make this // packet follow the last of this stream with the correct // average spacing. - new_scr_offset( r, buf ); + if ( find_st( r, buf ) ) + { + new_scr_offset( r, buf ); + } + else + { + // we got a new scr at the same time as the first + // packet of a stream we've never seen before. We + // have no idea what the timing should be so toss + // this buffer & wait for a stream we've already seen. + hb_buffer_close( &buf ); + continue; + } } } if ( buf->start != -1 ) |