From dd8af67083dbd1b05d063e62662a4487ec64d59e Mon Sep 17 00:00:00 2001 From: Moritz Bunkus Date: Sun, 9 Oct 2011 00:43:35 +0200 Subject: [PATCH] MPEG TS: Support PES private data tracks without specific desc tag --- ChangeLog | 2 +- src/input/r_mpeg_ts.cpp | 20 +++++++++++++++++++- 2 files changed, 20 insertions(+), 2 deletions(-) diff --git a/ChangeLog b/ChangeLog index ff80080ed..8d6787536 100644 --- a/ChangeLog +++ b/ChangeLog @@ -4,7 +4,7 @@ v7/quilt 3.0 format. * mkvmerge: enhancement: Implemented support for yet another way - of storing EAC3 in MPEG transport streams. + of storing EAC3 and DTS in MPEG transport streams. 2011-10-05 Moritz Bunkus diff --git a/src/input/r_mpeg_ts.cpp b/src/input/r_mpeg_ts.cpp index c1f0bb5ab..34baacf25 100644 --- a/src/input/r_mpeg_ts.cpp +++ b/src/input/r_mpeg_ts.cpp @@ -717,7 +717,8 @@ mpeg_ts_reader_c::parse_pmt(unsigned char *pmt) { 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; 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(pmt_descriptor->tag) % static_cast(pmt_descriptor->length)); @@ -726,6 +727,7 @@ mpeg_ts_reader_c::parse_pmt(unsigned char *pmt) { case 0x56: // Teletext descriptor if (pmt_pid_info->stream_type == ISO_13818_PES_PRIVATE) { // PES containig private data track->type = ES_UNKNOWN; + type_known = true; mxdebug_if(m_debug_pat_pmt, "mpeg_ts:parse_pmt: Teletext found but not handled !!\n"); } break; @@ -733,6 +735,7 @@ mpeg_ts_reader_c::parse_pmt(unsigned char *pmt) { if (pmt_pid_info->stream_type == ISO_13818_PES_PRIVATE) { // PES containig private data track->type = ES_SUBT_TYPE; track->fourcc = FOURCC('V', 'S', 'U', 'B'); + type_known = true; } break; case 0x6A: // AC3 descriptor @@ -740,6 +743,14 @@ mpeg_ts_reader_c::parse_pmt(unsigned char *pmt) { if (pmt_pid_info->stream_type == ISO_13818_PES_PRIVATE) { // PES containig private data track->type = ES_AUDIO_TYPE; track->fourcc = FOURCC('A', 'C', '3', ' '); + type_known = true; + } + break; + case 0x7b: // DTS descriptor + if (pmt_pid_info->stream_type == ISO_13818_PES_PRIVATE) { // PES containig private data + track->type = ES_AUDIO_TYPE; + track->fourcc = FOURCC('D', 'T', 'S', ' '); + type_known = true; } break; case 0x0a: // ISO 639 language descriptor @@ -754,6 +765,13 @@ mpeg_ts_reader_c::parse_pmt(unsigned char *pmt) { pmt_descriptor = (mpeg_ts_pmt_descriptor_t *)((unsigned char *)pmt_descriptor + sizeof(mpeg_ts_pmt_descriptor_t) + pmt_descriptor->length); } + // Default to AC3 if it's a PES private stream type that's missing + // a known/more concrete descriptor tag. + if ((pmt_pid_info->stream_type == ISO_13818_PES_PRIVATE) && !type_known) { + track->type = ES_AUDIO_TYPE; + track->fourcc = FOURCC('A', 'C', '3', ' '); + } + pmt_pid_info = (mpeg_ts_pmt_pid_info_t *)((unsigned char *)pmt_pid_info + sizeof(mpeg_ts_pmt_pid_info_t) + es_info_length); if (track->type != ES_UNKNOWN) { PMT_found = true;