[matroska] r907 - trunk/DvdMenuXtractor

[email protected]
Newsgroups gmane.comp.multimedia.matroska.cvs
Message-ID <[email protected]>
Author: robux4
Date: 2004-10-23 22:41:08 +0400 (Sat, 23 Oct 2004)
New Revision: 907

Modified:
   trunk/DvdMenuXtractor/DvdMenuXtractor.cpp
   trunk/DvdMenuXtractor/VobParser.cpp
   trunk/DvdMenuXtractor/VobParser.h
Log:
fix major memory leaks, start support of LPCM

Modified: trunk/DvdMenuXtractor/DvdMenuXtractor.cpp
===================================================================
--- trunk/DvdMenuXtractor/DvdMenuXtractor.cpp	2004-10-23 14:37:53 UTC (rev 906)
+++ trunk/DvdMenuXtractor/DvdMenuXtractor.cpp	2004-10-23 18:41:08 UTC (rev 907)
@@ -583,7 +583,7 @@
 								switch (_audioTracks.Item(_stream)->GetData()->audio_format)
 								{
 								case 0:
-									demuxer->AddDemuxer(new AC3DemuxWriter(ac3Directory+newFilename+_langName));
+									demuxer->AddDemuxer(new AC3DemuxWriter(ac3Directory+newFilename+_langName, 0x80 + _stream));
 									break;
 
 								case 2:
@@ -595,7 +595,7 @@
 									break;
 
 								case 4:
-									myfprintf(stderr, "LPCM audio not supported yet");
+									demuxer->AddDemuxer(new LPCMDemuxWriter(ac3Directory+newFilename+_langName, 0xA0 + _stream));
 									break;
 
 								case 6:
@@ -623,7 +623,7 @@
 									_langName = wxString::Format("_%c%c", _attr->lang_code >> 8, _attr->lang_code & 0xFF);
 //								if(aVobParser.m_pci.btn_ns > 0)
 								{
-									demuxer->AddDemuxer(new SubDemuxWriter(subDirectory+newFilename+_langName));
+									demuxer->AddDemuxer(new SubDemuxWriter(subDirectory+newFilename+_langName, 0x20 + _stream));
 								}
 							}
 						}
@@ -1322,6 +1322,8 @@
 					m_txtDemuxLog->AppendText(StepString+"\n");		
 					m_lbStep->Update();
 					ConvertButtonMaskToBMP(title, language);
+
+					delete aVobParser;
 				}
 				language = !language;
 			} while (!language);

Modified: trunk/DvdMenuXtractor/VobParser.cpp
===================================================================
--- trunk/DvdMenuXtractor/VobParser.cpp	2004-10-23 14:37:53 UTC (rev 906)
+++ trunk/DvdMenuXtractor/VobParser.cpp	2004-10-23 18:41:08 UTC (rev 907)
@@ -71,7 +71,7 @@
 #else
 #define inc_lvl()
 #define dec_lvl()
-#define DebugLog myfprintf
+#define DebugLog wxLogMessage
 #endif
 
 // ----------------------------------------------------------------------------
@@ -657,7 +657,16 @@
 	}
 	else if(substreamID >= SUBSTREAM_PCM_LOW && substreamID <= SUBSTREAM_PCM_HIGH)
 	{
-		DebugLog("PCM stream not supported yet\n");
+		DebugLog("LPCM streamID = 0x%X\n", substreamID);
+		// Skip frame header number
+		SkipNBytes(1);
+		// Skip first access unit pointer
+		SkipNBytes(2);
+		if(m_demuxer)
+		{
+			uint16_t ac3DataLen = length - (m_index - dataStartIndex);
+			m_demuxer->ProcessLPCMStream(&m_buff[m_index], ac3DataLen, substreamID);
+		}
 	}
 	else
 	{

Modified: trunk/DvdMenuXtractor/VobParser.h
===================================================================
--- trunk/DvdMenuXtractor/VobParser.h	2004-10-23 14:37:53 UTC (rev 906)
+++ trunk/DvdMenuXtractor/VobParser.h	2004-10-23 18:41:08 UTC (rev 907)
@@ -163,6 +163,7 @@
 	virtual void ProcessAudioStream(uint8_t* buff, uint32_t size) {}
 	virtual void ProcessVOBStream(uint8_t* buff, uint32_t size) {}
 	virtual void ProcessAC3Stream(uint8_t* buff, uint32_t size, uint8_t streamID) {}
+	virtual void ProcessLPCMStream(uint8_t* buff, uint32_t size, uint8_t streamID) {}
 	virtual void ProcessSubStream(uint8_t* buff, uint32_t size, uint8_t streamID) {}
 	Demuxer* m_next; // used by the CompositeDemuxWriter (linked list of demuxer)
 };
@@ -222,7 +223,7 @@
 class AC3DemuxWriter : public Demuxer, public Writer
 {
 public:
-	AC3DemuxWriter(const char* filenamePrefix, const uint8_t streamID = 0x80) :
+	AC3DemuxWriter(const char* filenamePrefix, const uint8_t streamID) :
 	  Writer(filenamePrefix,"ac3"), m_streamID(streamID) {}
 	void ProcessAC3Stream(uint8_t* buff, uint32_t size, uint8_t streamID)
 	{
@@ -234,10 +235,25 @@
 
 // ----------------------------------------------------------------------------
 
+class LPCMDemuxWriter : public Demuxer, public Writer
+{
+public:
+	LPCMDemuxWriter(const char* filenamePrefix, const uint8_t streamID) :
+	  Writer(filenamePrefix,"pcm"), m_streamID(streamID) {}
+	void ProcessLPCMStream(uint8_t* buff, uint32_t size, uint8_t streamID)
+	{
+		if(m_streamID == streamID) { Write(buff,size); }
+	}
+private:
+	uint8_t m_streamID;
+};
+
+// ----------------------------------------------------------------------------
+
 class SubDemuxWriter : public Demuxer, public Writer
 {
 public:
-	SubDemuxWriter(const char* filenamePrefix, const uint8_t streamID = 0x20) :
+	SubDemuxWriter(const char* filenamePrefix, const uint8_t streamID) :
 	  Writer(filenamePrefix, "sub"), m_streamID(streamID) {}
 	void ProcessSubStream(uint8_t* buff, uint32_t size, uint8_t streamID)
 	{
@@ -311,6 +327,16 @@
 		}		
 	}
 
+	void ProcessLPCMStream(uint8_t* buff, uint32_t size, uint8_t streamID)
+	{
+		Demuxer* demuxCursor = m_demuxerRoot;
+		while(demuxCursor)
+		{
+			demuxCursor->ProcessLPCMStream(buff,size,streamID);
+			demuxCursor = demuxCursor->m_next;
+		}		
+	}
+
 	void ProcessSubStream(uint8_t* buff, uint32_t size, uint8_t streamID)
 	{
 		Demuxer* demuxCursor = m_demuxerRoot;
@@ -335,65 +361,7 @@
 	stream_info_node* next;
 };
 
-// ----------------------------------------------------------------------------
 
-class StreamList
-{
-public:
-	StreamList()
-	{
-		root = NULL;
-		last = NULL;
-		count = 0;
-	}
-
-	stream_info_node* AddStream(uint8_t id, uint8_t type)
-	{
-		stream_info_node* newnode = new stream_info_node;
-
-		count++;
-		newnode->next = NULL;
-
-		if(root == NULL) {
-			last = root = newnode;
-		} else {
-			last->next = newnode;
-			last = newnode;
-		}
-		return last;
-	}
-
-	int GetCount() { return count; }
-
-	void Clear()
-	{
-		stream_info_node* tmp_nextnode;
-		while(root)
-		{
-			tmp_nextnode = root->next;
-			delete root;
-			root = tmp_nextnode;
-		}
-	}
-
-	bool Exist(uint8_t id)
-	{
-		stream_info_node* cursor = root;
-		while(cursor)
-		{
-			if(cursor->id == id)
-				return true;
-			cursor = cursor->next;
-		}
-		return false;
-	}
-
-private:
-	stream_info_node* root;
-	stream_info_node* last;
-	int count;
-};
-
 // ----------------------------------------------------------------------------
 
 typedef struct 
@@ -413,20 +381,13 @@
 		vobid(vobid),
 		cellid(cellid)
 	{
-	
 	}
 
-	virtual ~cell_info_node()
-	{
-		stream_list.Clear();
-	}
-
 	uint8_t vobid;
 	uint8_t cellid;
 	bool hasVideo;
 	bool hasAudio;
 	bool hasSubs;
-	StreamList stream_list;
 	ButtonsListType btt_list;
 };
 
@@ -443,7 +404,6 @@
 public:
 	CellMap()
 	{
-
 	}
 
 	~CellMap()
@@ -492,25 +452,21 @@
 
 	void ProcessVideoStream(uint8_t* buff, uint32_t size)
 	{
-		m_cid->stream_list.AddStream(0x0, VIDEO_STREAM_TYPE);		
 		m_cid->hasVideo = true;
 	}
 
 	void ProcessAudioStream(uint8_t* buff, uint32_t size)
 	{
-		m_cid->stream_list.AddStream(0x0, AUDIO_STREAM_TYPE);		
 		m_cid->hasAudio = true;
 	}
 
 	void ProcessAC3Stream(uint8_t* buff, uint32_t size, uint8_t streamID)
 	{
-		m_cid->stream_list.AddStream(streamID, AC3_STREAM_TYPE);	
 		m_cid->hasAudio = true;
 	}
 
 	void ProcessSubStream(uint8_t* buff, uint32_t size, uint8_t streamID)
 	{
-		m_cid->stream_list.AddStream(streamID, SUB_STREAM_TYPE);
 		m_cid->hasSubs = true;
 	}
 private:
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.