MPEG TS: only treat »missing PMT tag altogether« as AC3, not on »unknown PMT tag«

Case in point: HEVC uses a PMT tag that's unknown to mkvmerge. Before
this commit mkvmerge would treat it as AC3 and try to probe it as that
which takes a lot of time.
This commit is contained in:
Moritz Bunkus 2014-12-16 13:51:14 +01:00
parent 7eaae9eae2
commit d1457ea677

View File

@ -901,28 +901,31 @@ mpeg_ts_reader_c::parse_pmt(unsigned char *pmt) {
break; break;
} }
pmt_descriptor = (mpeg_ts_pmt_descriptor_t *)((unsigned char *)pmt_pid_info + sizeof(mpeg_ts_pmt_pid_info_t)); pmt_descriptor = (mpeg_ts_pmt_descriptor_t *)((unsigned char *)pmt_pid_info + sizeof(mpeg_ts_pmt_pid_info_t));
bool type_known = false; bool missing_tag = true;
while (pmt_descriptor < (mpeg_ts_pmt_descriptor_t *)((unsigned char *)pmt_pid_info + sizeof(mpeg_ts_pmt_pid_info_t) + es_info_length)) { while (pmt_descriptor < (mpeg_ts_pmt_descriptor_t *)((unsigned char *)pmt_pid_info + sizeof(mpeg_ts_pmt_pid_info_t) + es_info_length)) {
mxdebug_if(m_debug_pat_pmt, boost::format("mpeg_ts:parse_pmt: PMT descriptor tag 0x%|1$02x| length %2%\n") % static_cast<unsigned int>(pmt_descriptor->tag) % static_cast<unsigned int>(pmt_descriptor->length)); mxdebug_if(m_debug_pat_pmt, boost::format("mpeg_ts:parse_pmt: PMT descriptor tag 0x%|1$02x| length %2%\n") % static_cast<unsigned int>(pmt_descriptor->tag) % static_cast<unsigned int>(pmt_descriptor->length));
if (0x0a != pmt_descriptor->tag)
missing_tag = false;
switch (pmt_descriptor->tag) { switch (pmt_descriptor->tag) {
case 0x0a: // ISO 639 language descriptor case 0x0a: // ISO 639 language descriptor
track->parse_iso639_language_from(pmt_descriptor + 1); track->parse_iso639_language_from(pmt_descriptor + 1);
break; break;
case 0x56: // Teletext descriptor case 0x56: // Teletext descriptor
type_known = track->parse_srt_pmt_descriptor(*pmt_descriptor, *pmt_pid_info); track->parse_srt_pmt_descriptor(*pmt_descriptor, *pmt_pid_info);
break; break;
case 0x59: // Subtitles descriptor case 0x59: // Subtitles descriptor
type_known = track->parse_vobsub_pmt_descriptor(*pmt_descriptor, *pmt_pid_info); track->parse_vobsub_pmt_descriptor(*pmt_descriptor, *pmt_pid_info);
break; break;
case 0x6A: // AC3 descriptor case 0x6A: // AC3 descriptor
case 0x7A: // EAC3 descriptor case 0x7A: // EAC3 descriptor
type_known = track->parse_ac3_pmt_descriptor(*pmt_descriptor, *pmt_pid_info); track->parse_ac3_pmt_descriptor(*pmt_descriptor, *pmt_pid_info);
break; break;
case 0x7b: // DTS descriptor case 0x7b: // DTS descriptor
type_known = track->parse_dts_pmt_descriptor(*pmt_descriptor, *pmt_pid_info); track->parse_dts_pmt_descriptor(*pmt_descriptor, *pmt_pid_info);
break; break;
} }
@ -931,7 +934,7 @@ mpeg_ts_reader_c::parse_pmt(unsigned char *pmt) {
// Default to AC3 if it's a PES private stream type that's missing // Default to AC3 if it's a PES private stream type that's missing
// a known/more concrete descriptor tag. // a known/more concrete descriptor tag.
if ((pmt_pid_info->stream_type == ISO_13818_PES_PRIVATE) && !type_known) { if ((pmt_pid_info->stream_type == ISO_13818_PES_PRIVATE) && missing_tag) {
track->type = ES_AUDIO_TYPE; track->type = ES_AUDIO_TYPE;
track->codec = codec_c::look_up(CT_A_AC3); track->codec = codec_c::look_up(CT_A_AC3);
} }
@ -944,8 +947,10 @@ mpeg_ts_reader_c::parse_pmt(unsigned char *pmt) {
tracks.push_back(track); tracks.push_back(track);
es_to_process++; es_to_process++;
mxdebug_if(m_debug_pat_pmt, boost::format("mpeg_ts:parse_pmt: PID %1% has type: %2%\n") % track->pid % track->codec.get_name()); mxdebug_if(m_debug_pat_pmt, boost::format("mpeg_ts:parse_pmt: PID %1% has type: %2%\n") % track->pid % track->codec.get_name());
}
} } else
mxdebug_if(m_debug_pat_pmt, boost::format("mpeg_ts:parse_pmt: PID %1% has an unknown type\n") % track->pid);
}
return 0; return 0;
} }