[matroska] r908 - trunk/DvdMenuXtractor
[email protected] Sun, 24 Oct 2004 01:03:59 +0400 (MSD)
Newsgroups
gmane.comp.multimedia.matroska.cvs
Message-ID
<[email protected] >
Author: robux4
Date: 2004-10-24 01:03:58 +0400 (Sun, 24 Oct 2004)
New Revision: 908
Modified:
trunk/DvdMenuXtractor/VobParser.cpp
Log:
cleaner VOB files parsing
Modified: trunk/DvdMenuXtractor/VobParser.cpp
===================================================================
--- trunk/DvdMenuXtractor/VobParser.cpp 2004-10-23 18:41:08 UTC (rev 907)
+++ trunk/DvdMenuXtractor/VobParser.cpp 2004-10-23 21:03:58 UTC (rev 908)
@@ -12,13 +12,15 @@
// ----------------------------------------------------------------------------
-#define PACK_HEADER 0x000001BA
-#define SYSTEM_HEADER 0x000001BB
-#define PRIVATE_STREAM1 0x000001BD
-#define PADDING_STREAM 0x000001BE
-#define PRIVATE_STREAM2 0x000001BF
-#define AUDIO_STREAM 0x000001C0
-#define VIDEO_STREAM 0x000001E0
+#define VOB_SLICE 0x00000100
+#define PACK_HEADER 0xBA
+#define SYSTEM_HEADER 0xBB
+#define PROGRAM_STREAM_MAP 0xBC
+#define PRIVATE_STREAM1 0xBD
+#define PADDING_STREAM 0xBE
+#define PRIVATE_STREAM2 0xBF
+#define AUDIO_STREAM 0xC0
+#define VIDEO_STREAM 0xE0
#define SUBSTREAM_PCI 0x00
#define SUBSTREAM_DSI 0x01
@@ -149,7 +151,7 @@
if(GetNextPacket())
{
pktinfo.identifier = GetNext32Bits();
- if(pktinfo.identifier != PACK_HEADER)
+ if((pktinfo.identifier & VOB_SLICE) != VOB_SLICE || (pktinfo.identifier & PACK_HEADER) != PACK_HEADER)
{
// Invalid block start code
throw VobParserInvalidPacketException(CURRENT_OFFSET-4);
@@ -163,46 +165,74 @@
assert(pktinfo.program_mux_rate != 0);
// Skip Pack stuffing length
- SkipNBytes(1);
+ int stuffing_nb = GetNext8Bits() & 0x07;
+ SkipNBytes(stuffing_nb);
DebugLog("%06d) ", m_pktindex);
- uint32_t _StreamID = GetNext32Bits();
- switch(_StreamID)
+ uint32_t _Header = GetNext32Bits();
+ uint8_t _StreamID;
+ if ((_Header & VOB_SLICE) == VOB_SLICE)
{
- case SYSTEM_HEADER:
- DebugLog("Navigation pack {\n");
- inc_lvl();
- DebugLog("SCR: %d.%d\n", pktinfo.scr, pktinfo.scr_ext);
- DebugLog("Program mux rate: %d (%d bps)\n", pktinfo.program_mux_rate,
- pktinfo.program_mux_rate * 50 * 8);
- ParseNavPacket();
- dec_lvl();
- DebugLog("}\n");
- break;
-
- case VIDEO_STREAM:
- DebugLog("Video pack {}\n");
- ParseVideoPacket();
- break;
-
- // TODO : MPEG audio
- case AUDIO_STREAM:
- DebugLog("Video pack {}\n");
- ParseAudioPacket();
- break;
-
- case PRIVATE_STREAM1:
- DebugLog("Private stream 1 pack {\n");
- inc_lvl();
- ParsePrivateStream1();
- dec_lvl();
- DebugLog("}\n");
- break;
+ _StreamID = _Header & 0xFF;
+ if (_StreamID == SYSTEM_HEADER)
+ {
+ // skip the system header data
+ uint16_t _size = GetNext16Bits();
+ SkipNBytes(_size);
- default:
- DebugLog("Unknown pack\n");
+ while (AvailablePacketData())
+ {
+ _Header = GetNext32Bits();
+ _StreamID = _Header & 0xFF;
+ if (_StreamID == PRIVATE_STREAM2)
+ {
+ DebugLog("Navigation pack {\n");
+ inc_lvl();
+ DebugLog("SCR: %d.%d\n", pktinfo.scr, pktinfo.scr_ext);
+ DebugLog("Program mux rate: %d (%d bps)\n", pktinfo.program_mux_rate,
+ pktinfo.program_mux_rate * 50 * 8);
+ ParseNavPacket();
+ dec_lvl();
+ DebugLog("}\n");
+ }
+ else
+ {
+ // skip these data
+ uint16_t _size = GetNext16Bits();
+ SkipNBytes(_size);
+ }
+ }
+ }
+ else if ((_StreamID & VIDEO_STREAM) == VIDEO_STREAM)
+ {
+ DebugLog("Video pack {}\n");
+ ParseVideoPacket();
+ }
+ else if ((_StreamID & AUDIO_STREAM) == AUDIO_STREAM)
+ {
+ DebugLog("Video pack {}\n");
+ ParseAudioPacket();
+ }
+ else if (_StreamID == PRIVATE_STREAM1)
+ {
+ DebugLog("Private stream 1 pack {\n");
+ inc_lvl();
+ ParsePrivateStream1();
+ dec_lvl();
+ DebugLog("}\n");
+ }
+ else
+ {
+ uint16_t _size = GetNext16Bits();
+ SkipNBytes(_size);
+ DebugLog("Unknown slice type\n");
+ }
}
+ else
+ {
+ DebugLog("Unknown start code\n");
+ }
if(m_demuxer)
{
@@ -345,26 +375,11 @@
void VobParser::ParseNavPacket()
{
- uint16_t systemHeaderLength = GetNext16Bits();
- // Skip system header
- SkipNBytes(systemHeaderLength);
-
- while(AvailablePacketData())
- {
- switch(GetNext32Bits())
- {
- case PRIVATE_STREAM2:
- DebugLog("Private Stream 2 {\n");
- inc_lvl();
- ParsePrivateStream2();
- dec_lvl();
- DebugLog("}\n");
- break;
- default:
- DebugLog("ParseNavPacket: unknown stream id @LBA=%d\n", m_pktindex);
- break;
- }
- }
+ DebugLog("Private Stream 2 {\n");
+ inc_lvl();
+ ParsePrivateStream2();
+ dec_lvl();
+ DebugLog("}\n");
}
// ----------------------------------------------------------------------------
@@ -699,6 +714,7 @@
ButtonListElem* ble;
m_map.Clear();
+ m_pci.btn_ns = 0;
while(ParseNextPacket())
{
@@ -716,6 +732,7 @@
ble->y2 = m_pci.btnit[i].end_y;
cell->btt_list.Append(ble);
}
+ m_pci.btn_ns = 0;
SetDemuxer(new DemuxStreamMapper(cell));
}