diff options
author | jstebbins <[email protected]> | 2009-11-09 18:02:37 +0000 |
---|---|---|
committer | jstebbins <[email protected]> | 2009-11-09 18:02:37 +0000 |
commit | 867a53a08540f6ae2101599a30e30a59ce40521c (patch) | |
tree | fe6a8d655eafd8c14df088016a1df20840d256e9 /libhb/stream.c | |
parent | 94fc7c3115a9275bfa3029717837666a8dbb9e89 (diff) |
fix an off-by-one error in assignment of audio stream registration descriptor
format. This sometimes caused the misdetection of TrueHD audio since it
would be tagged as the format of the stream following it in the PMT.
Also fix a problem in PMT parsing that I stumbled upon while investigating
the above problem. If a PMT has a PID listed more than once for some reason,
we would add that PID multiple times to our stream list. And if it happened
to be a video PID that is duplicated, the duplications would be interpreted
as audio PIDs.
git-svn-id: svn://svn.handbrake.fr/HandBrake/trunk@2920 b64f7644-9d1e-0410-96f1-a4d463321fa5
Diffstat (limited to 'libhb/stream.c')
-rw-r--r-- | libhb/stream.c | 54 |
1 files changed, 28 insertions, 26 deletions
diff --git a/libhb/stream.c b/libhb/stream.c index 26b6a7c84..538353e52 100644 --- a/libhb/stream.c +++ b/libhb/stream.c @@ -1695,7 +1695,7 @@ static void decode_element_descriptors(hb_stream_t* stream, int esindx, switch (dp[0]) { case 5: // Registration descriptor - stream->ts_format_id[esindx] = (dp[2] << 24) | (dp[3] << 16) | + stream->ts_format_id[esindx+1] = (dp[2] << 24) | (dp[3] << 16) | (dp[4] << 8) | dp[5]; break; @@ -1770,33 +1770,35 @@ int decode_program_map(hb_stream_t* stream) if ( index_of_pid( elementary_PID, stream ) < 0 ) { - // already have this pid - do nothing - } - if (stream->ts_number_video_pids == 0 && st2codec[stream_type].kind == V ) - { - stream->ts_video_pids[0] = elementary_PID; - stream->ts_stream_type[0] = stream_type; - stream->ts_number_video_pids = 1; - } - else - { - // Defined audio stream types are 0x81 for AC-3/A52 audio and 0x03 - // for mpeg audio. But content producers seem to use other - // values (0x04 and 0x06 have both been observed) so at this point - // we say everything that isn't a video pid is audio then at the end - // of hb_stream_title_scan we'll figure out which are really audio - // by looking at the PES headers. - i = stream->ts_number_audio_pids; - if (i < kMaxNumberAudioPIDS) + // don't have this pid yet + if (stream->ts_number_video_pids == 0 && + st2codec[stream_type].kind == V ) { - stream->ts_audio_pids[i] = elementary_PID; - stream->ts_stream_type[1 + i] = stream_type; - if (ES_info_length > 0) + stream->ts_video_pids[0] = elementary_PID; + stream->ts_stream_type[0] = stream_type; + stream->ts_number_video_pids = 1; + } + else + { + // Defined audio stream types are 0x81 for AC-3/A52 audio + // and 0x03 for mpeg audio. But content producers seem to + // use other values (0x04 and 0x06 have both been observed) + // so at this point we say everything that isn't a video + // pid is audio then at the end of hb_stream_title_scan + // we'll figure out which are really audio by looking at + // the PES headers. + i = stream->ts_number_audio_pids; + if (i < kMaxNumberAudioPIDS) { - decode_element_descriptors(stream, i, ES_info_buf, - ES_info_length); + stream->ts_audio_pids[i] = elementary_PID; + stream->ts_stream_type[1 + i] = stream_type; + if (ES_info_length > 0) + { + decode_element_descriptors(stream, i, ES_info_buf, + ES_info_length); + } + ++stream->ts_number_audio_pids; } - ++stream->ts_number_audio_pids; } } @@ -1805,7 +1807,7 @@ int decode_program_map(hb_stream_t* stream) free(ES_info_buf); if (cur_pos >= section_length - 4 /* stop before the CRC */) - done_reading_stream_types = 1; + done_reading_stream_types = 1; } free(descriptor_buf); |