[matroska] r1125 - trunk/DvdMenuXtractor

[email protected]
Newsgroups gmane.comp.multimedia.matroska.cvs
Message-ID <[email protected]>
Author: robux4
Date: 2005-04-10 21:36:45 +0400 (Sun, 10 Apr 2005)
New Revision: 1125

Modified:
   trunk/DvdMenuXtractor/VobParser.cpp
   trunk/DvdMenuXtractor/VobParser.h
Log:
DMX: using the MPEG parser solves the trailing cell gap bug

Modified: trunk/DvdMenuXtractor/VobParser.cpp
===================================================================
--- trunk/DvdMenuXtractor/VobParser.cpp	2005-04-10 14:31:26 UTC (rev 1124)
+++ trunk/DvdMenuXtractor/VobParser.cpp	2005-04-10 17:36:45 UTC (rev 1125)
@@ -928,21 +928,14 @@
 
 void VideoDemuxWriter::ProcessStream(uint8_t* buff, uint32_t size, uint32_t start_time, uint32_t end_time, const wxString & debug)
 {
-	m_parser.WriteData(buff, size);
+	m_parser->WriteData(buff, size);
 
-	MPEG2ParserState state = m_parser.GetState();
+	MPEG2ParserState state = m_parser->GetState();
 
 	while (state == MPV_PARSER_STATE_FRAME) 
 	{
-		MPEGFrame* current_frame = m_parser.ReadFrame();
-		if ((current_frame->timecode + current_frame->duration) / 1000000 > m_last_end_timecode)
-		{
-			m_last_start_timecode = current_frame->timecode / 1000000;
-			m_last_end_timecode = (current_frame->timecode + current_frame->duration) / 1000000;
-		}
-		delete current_frame;
-
-		state = m_parser.GetState();
+		delete m_parser->ReadFrame();
+		state = m_parser->GetState();
 	}
 
 	Write(buff, size, start_time, end_time, debug); 
@@ -950,10 +943,30 @@
 
 void VideoDemuxWriter::SetBoundary(uint32_t start_timecode, uint32_t duration, const CellListElem *cell)
 {
+	if (m_parser != NULL)
+	{
+		m_parser->SetEOS();
+
+		MPEG2ParserState state = m_parser->GetState();
+
+		while (state == MPV_PARSER_STATE_FRAME) 
+		{
+			MPEGFrame* current_frame = m_parser->ReadFrame();
+			if ((current_frame->timecode + current_frame->duration) / 1000000 > m_last_end_timecode)
+			{
+				m_last_start_timecode = current_frame->timecode / 1000000;
+				m_last_end_timecode = (current_frame->timecode + current_frame->duration) / 1000000;
+			}
+			delete current_frame;
+
+			state = m_parser->GetState();
+		}
+		delete m_parser;
+	}
+	m_parser = new M2VParser();
+
 	m_TimecodeFile = GetTimecodeFile();
 
-	m_last_end_timecode += 1000.0 / m_fps;
-
 	if (m_end_timecode != 0)
 	{
 		if (m_is_still) {
@@ -1091,9 +1104,28 @@
 VideoDemuxWriter::~VideoDemuxWriter()
 {
 	m_TimecodeFile = GetTimecodeFile();
+	if (m_parser != NULL)
+	{
+		m_parser->SetEOS();
 
-	m_last_end_timecode += 1000.0 / m_fps;
+		MPEG2ParserState state = m_parser->GetState();
 
+		while (state == MPV_PARSER_STATE_FRAME) 
+		{
+			MPEGFrame* current_frame = m_parser->ReadFrame();
+			if ((current_frame->timecode + current_frame->duration) / 1000000 > m_last_end_timecode)
+			{
+				m_last_start_timecode = current_frame->timecode / 1000000;
+				m_last_end_timecode = (current_frame->timecode + current_frame->duration) / 1000000;
+			}
+			delete current_frame;
+
+			state = m_parser->GetState();
+		}
+		delete m_parser;
+	}
+
+
 	if (m_end_timecode != 0)
 	{
 		if (m_is_still) {

Modified: trunk/DvdMenuXtractor/VobParser.h
===================================================================
--- trunk/DvdMenuXtractor/VobParser.h	2005-04-10 14:31:26 UTC (rev 1124)
+++ trunk/DvdMenuXtractor/VobParser.h	2005-04-10 17:36:45 UTC (rev 1125)
@@ -281,6 +281,7 @@
 		,m_last_start_timecode(0)
 		,m_last_end_timecode(0)
 		,m_is_still(false)
+		,m_parser(NULL)
 	{}
 	void ProcessStream(uint8_t* buff, uint32_t size, uint32_t start_time, uint32_t end_time, const wxString & debug);
 	void SetBoundary(uint32_t start_timecode, uint32_t duration, const CellListElem *cell);
@@ -293,7 +294,7 @@
 	uint32_t m_last_end_timecode;
 	bool m_is_still;
 
-	M2VParser m_parser;
+	M2VParser * m_parser;
 };
 
 // ----------------------------------------------------------------------------
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.