diff options
author | jstebbins <[email protected]> | 2011-04-25 15:32:43 +0000 |
---|---|---|
committer | jstebbins <[email protected]> | 2011-04-25 15:32:43 +0000 |
commit | c9fd57320b601bafaec8178680d689d3e5b75f77 (patch) | |
tree | e07362d65422ddcfe026b65326513773e81173bf | |
parent | c510a6e18cfee78560a0006dde859872bec4db8e (diff) |
Fix a problem when encoding the same source audio track twice from BD sources
The pid and substream were being added to the TS stream list twice which
caused 2 copies of each packet to be returned to reader. This caused sync
to drop every second packet with "time went backwards" log message.
git-svn-id: svn://svn.handbrake.fr/HandBrake/trunk@3957 b64f7644-9d1e-0410-96f1-a4d463321fa5
-rw-r--r-- | libhb/stream.c | 28 |
1 files changed, 23 insertions, 5 deletions
diff --git a/libhb/stream.c b/libhb/stream.c index 899c49513..fd213ecc3 100644 --- a/libhb/stream.c +++ b/libhb/stream.c @@ -316,6 +316,19 @@ static int index_of_pid(hb_stream_t *stream, int pid) return -1; } +static int index_of_substream(hb_stream_t *stream, int pid, int substream_type) +{ + int ii; + int idx = index_of_pid( stream, pid ); + + for ( ii = 0; ii < stream->ts[idx].number_substreams; ii++ ) + { + if ( stream->ts[idx].substream_type[ii] == substream_type ) + return ii; + } + return -1; +} + static int index_of_video(hb_stream_t *stream) { int i; @@ -730,23 +743,28 @@ hb_stream_t * hb_bd_stream_open( hb_title_t *title ) { int pid = audio->id & 0xFFFF; int idx = index_of_pid( d, pid ); + int substream_type = audio->config.in.substream_type; if ( idx < 0 ) { // New pid d->ts[d->ts_number_pids].pid = audio->id & 0xFFFF; d->ts[d->ts_number_pids].stream_type = audio->config.in.stream_type; - d->ts[d->ts_number_pids].substream_type[0] = audio->config.in.substream_type; + d->ts[d->ts_number_pids].substream_type[0] = substream_type; d->ts[d->ts_number_pids].number_substreams = 1; d->ts[d->ts_number_pids].stream_kind = A; d->ts_number_pids++; } else if ( d->ts[idx].number_substreams < kMaxNumberDecodeSubStreams ) { - d->ts[idx].substream_type[d->ts[idx].number_substreams] = - audio->config.in.substream_type; - d->ts[idx].number_substreams++; - d->ts[idx].stream_kind = A; + // Only add substream if it has not already been added. + if ( index_of_substream( d, pid, substream_type ) < 0 ) + { + d->ts[idx].substream_type[d->ts[idx].number_substreams] = + substream_type; + d->ts[idx].number_substreams++; + d->ts[idx].stream_kind = A; + } } else { |