[matroska] r1021 - trunk/DvdMenuXtractor

[email protected]
Newsgroups gmane.comp.multimedia.matroska.cvs
Message-ID <[email protected]>
Author: robux4
Date: 2005-01-08 18:41:48 +0300 (Sat, 08 Jan 2005)
New Revision: 1021

Modified:
   trunk/DvdMenuXtractor/DvdMenuXtractor.cpp
   trunk/DvdMenuXtractor/IFOFile.cpp
   trunk/DvdMenuXtractor/IFOFile.h
   trunk/DvdMenuXtractor/VobParser.h
Log:
DMX: use the used cells only to fill the chapters, don't use the PTT level anymore

Modified: trunk/DvdMenuXtractor/DvdMenuXtractor.cpp
===================================================================
--- trunk/DvdMenuXtractor/DvdMenuXtractor.cpp	2005-01-08 11:05:08 UTC (rev 1020)
+++ trunk/DvdMenuXtractor/DvdMenuXtractor.cpp	2005-01-08 15:41:48 UTC (rev 1021)
@@ -581,40 +581,23 @@
 		return wxString::Format("cell_%sT%02d_V%03d_C%02d", language?"L_":"", title, vobid, cellid);
 	}
 
-    void SplitAndDemux(VobParser & aVobParser, int16_t title, bool language)
+    void SplitAndDemux(VobParser * aVobParser, int16_t title, bool language)
     {
 		wxString newFilename;
 		wxString cellName;
+		wxString MtxCommandString;
 		const CellsListType *CellsList = IfoFile->GetCellsList(title, language);
 
 		if (!CellsList)
 			return;
 
-		aVobParser.Reset();
-
         try
         {
-			const AudioTrackList & _audioTracks = IfoFile->AudioTracks(title, language);
-			const SubtitleTrackList & _subTracks = IfoFile->SubsTracks(title, language);
-			uint16_t _width, _height;
-			double _fps;
-			IfoFile->VideoSize(title, language, _width, _height, _fps);
-			const uint32_t * _palette = IfoFile->GetPalette(title, language);
-
-			uint32_t cell = 0;
-			CompositeDemuxWriter & demuxer = aVobParser.GetDemuxer();
-
-            m_gaDemuxProgress->SetRange(CellsList->GetCount());
-
 			if (title == 0)
 				newFilename = "VMG";
 			else
 				newFilename = wxString::Format("VTS%s%02d", language?"M":"", title);
 
-			demuxer.Reset();
-
-            m_txtDemuxLog->AppendText("Processing " + newFilename + "\n");
-
 			wxString MtxFilename = outputDirectory + newFilename + ".bat";
 			wxFile MtxCommandFile;
 			MtxCommandFile.Create(MtxFilename, true, wxS_DEFAULT | wxS_IXUSR | wxS_IXGRP | wxS_IXOTH);
@@ -623,133 +606,170 @@
 			MtxCommandFile.Write(ShellString.c_str(), ShellString.Length());
 #endif
 #if defined(WIN32)
-			wxString MtxCommandString = "\"" + mtxDirectory + "mkvmerge\" -o " + outputDirectory+newFilename + ".mkv";
+			MtxCommandString = "\"" + mtxDirectory + "mkvmerge\" -o " + outputDirectory+newFilename + ".mkv";
 #else
-			wxString MtxCommandString = mtxDirectory + "mkvmerge -o " + outputDirectory+newFilename + ".mkv";
+			MtxCommandString = mtxDirectory + "mkvmerge -o " + outputDirectory+newFilename + ".mkv";
 #endif
-			wxString MtxCommandStringTemp = " --track-name 0:\"video\" --timecodes 0:" + outputDirectory+newFilename + "_m2v.tmc " + outputDirectory+newFilename + ".m2v";
 
-			Writer * _muxer = new VideoDemuxWriter(outputDirectory + newFilename, _fps);
-            if (!demuxer.AddDemuxer(VIDEO_STREAM, _muxer, MtxCommandStringTemp))
-				delete _muxer;
+			if (aVobParser != NULL)
+			{
+				aVobParser->Reset();
 
-			size_t _stream;
+				const AudioTrackList & _audioTracks = IfoFile->AudioTracks(title, language);
+				const SubtitleTrackList & _subTracks = IfoFile->SubsTracks(title, language);
+				uint16_t _width, _height;
+				double _fps;
+				IfoFile->VideoSize(title, language, _width, _height, _fps);
+				const uint32_t * _palette = IfoFile->GetPalette(title, language);
 
-			// decide which audio streams to process
-			if (_audioTracks.size())
-			{
-				for (_stream=0; _stream<_audioTracks.size();_stream++)
-				{
-					wxString _langName;
-					wxString MtxTempString;
-					const audio_attr_t * _attr = _audioTracks[_stream];
+				uint32_t cell = 0;
+				CompositeDemuxWriter & demuxer = aVobParser->GetDemuxer();
 
-					// get the possible ID for this track for this Cell/PGC
-					uint8_t _ID = IfoFile->GetAudioId(_stream, title, language);
-					MtxTempString = " --track-name 0:\"aud-" ;
-					if (_attr->lang_code == 0)
-					{
-						_langName = wxString::Format("_%d_un", _ID);
-						MtxTempString += newFilename+_langName + "\" --language 0:und";
-					}
-					else
-					{
-						_langName = wxString::Format("_%d_%c%c", _ID, _attr->lang_code >> 8, _attr->lang_code & 0xFF);
-						MtxTempString += newFilename+_langName + "\" --language 0:";
-						MtxTempString += wxString::Format("%c%c", _attr->lang_code >> 8, _attr->lang_code & 0xFF);
-					}
-					MtxTempString += " --timecodes 0:" + outputDirectory+newFilename+_langName;
-					switch (_audioTracks[_stream]->audio_format)
-					{
-					case 0:
-						MtxTempString += "_ac3.tmc " + outputDirectory+newFilename+_langName + ".ac3";
-						_muxer = new AC3DemuxWriter(outputDirectory + newFilename+_langName, 0x80 + _ID);
-						if (!demuxer.AddDemuxer(SUBSTREAM_AC3_LOW + _ID, _muxer, MtxTempString))
-							delete _muxer;
-						break;
+				m_gaDemuxProgress->SetRange(CellsList->GetCount());
 
-					case 2:
-					case 3:
-						MtxTempString += "_mpa.tmc " + outputDirectory+newFilename+_langName + ".mpa";
-						_muxer = new MPADemuxWriter(outputDirectory + newFilename+_langName, 0xC0 + _ID);
-						if (!demuxer.AddDemuxer(AUDIO_STREAM + _ID, _muxer, MtxTempString))
-							delete _muxer;
-						break;
+				demuxer.Reset();
 
-					case 4:
-						// TODO possibly other LPCM formats ?
-						MtxTempString += "_wav.tmc " + outputDirectory+newFilename+_langName + ".wav";
-						_muxer = new LPCMDemuxWriter(outputDirectory + newFilename+_langName, 0xA0 + _ID, 48000, 16, 2);
-						if (!demuxer.AddDemuxer(SUBSTREAM_PCM_LOW + _ID, _muxer, MtxTempString))
-							delete _muxer;
-						break;
+				m_txtDemuxLog->AppendText("Processing " + newFilename + "\n");
 
-					case 6:
-						MtxTempString += "_dts.tmc " + outputDirectory+newFilename+_langName + ".dts";
-						_muxer = new DTSDemuxWriter(outputDirectory + newFilename+_langName, 0x88 + _ID);
-						if (!demuxer.AddDemuxer(SUBSTREAM_DTS_LOW + _ID, _muxer, MtxTempString))
-							delete _muxer;
-						break;
+				wxString MtxCommandStringTemp = " --track-name 0:\"video\" --timecodes 0:" + outputDirectory+newFilename + "_m2v.tmc " + outputDirectory+newFilename + ".m2v";
 
-					default:
-						wxLogError("Unknown audio format %d", _attr->audio_format);
-						break;
-					}
-				}
-			}
+				Writer * _muxer = new VideoDemuxWriter(outputDirectory + newFilename, _fps);
+				if (!demuxer.AddDemuxer(VIDEO_STREAM, _muxer, MtxCommandStringTemp))
+					delete _muxer;
 
-			if (_subTracks.size())
-			{
-				for (_stream=0; _stream<_subTracks.size();_stream++)
+				size_t _stream;
+
+				// decide which audio streams to process
+				if (_audioTracks.size())
 				{
-					// get the possible IDs for this track for this Cell/PGC
-					IdArray _IDs = IfoFile->GetSubsId(_stream, title, language);
-					for (size_t _IDidx=0; _IDidx < _IDs.GetCount(); _IDidx++)
+					for (_stream=0; _stream<_audioTracks.size();_stream++)
 					{
 						wxString _langName;
 						wxString MtxTempString;
+						const audio_attr_t * _attr = _audioTracks[_stream];
 
-						const subp_attr_t * _attr = _subTracks[_stream];
-						MtxTempString = " --track-name 0:\"sub-";
+						// get the possible ID for this track for this Cell/PGC
+						uint8_t _ID = IfoFile->GetAudioId(_stream, title, language);
+						MtxTempString = " --track-name 0:\"aud-" ;
 						if (_attr->lang_code == 0)
 						{
-							_langName = wxString::Format("_%d_un", _IDs.Item(_IDidx));
-							MtxTempString += newFilename+_langName + "\" --language 0:und ";
+							_langName = wxString::Format("_%d_un", _ID);
+							MtxTempString += newFilename+_langName + "\" --language 0:und";
 						}
 						else
 						{
-							_langName = wxString::Format("_%d_%c%c", _IDs.Item(_IDidx), _attr->lang_code >> 8, _attr->lang_code & 0xFF);
+							_langName = wxString::Format("_%d_%c%c", _ID, _attr->lang_code >> 8, _attr->lang_code & 0xFF);
 							MtxTempString += newFilename+_langName + "\" --language 0:";
-							MtxTempString += wxString::Format("%c%c ", _attr->lang_code >> 8, _attr->lang_code & 0xFF);
+							MtxTempString += wxString::Format("%c%c", _attr->lang_code >> 8, _attr->lang_code & 0xFF);
 						}
-						MtxTempString += outputDirectory+newFilename+_langName + ".idx";
-						_muxer = new SubDemuxWriter(outputDirectory + newFilename+_langName, 0x20 + _IDs.Item(_IDidx), _width, _height, _palette, _attr->lang_code, _attr->lang_extension == 9);
-						if (!demuxer.AddDemuxer(SUBSTREAM_SUB_LOW + _IDs.Item(_IDidx), _muxer, MtxTempString))
-							delete _muxer;
+						MtxTempString += " --timecodes 0:" + outputDirectory+newFilename+_langName;
+						switch (_audioTracks[_stream]->audio_format)
+						{
+						case 0:
+							MtxTempString += "_ac3.tmc " + outputDirectory+newFilename+_langName + ".ac3";
+							_muxer = new AC3DemuxWriter(outputDirectory + newFilename+_langName, 0x80 + _ID);
+							if (!demuxer.AddDemuxer(SUBSTREAM_AC3_LOW + _ID, _muxer, MtxTempString))
+								delete _muxer;
+							break;
+
+						case 2:
+						case 3:
+							MtxTempString += "_mpa.tmc " + outputDirectory+newFilename+_langName + ".mpa";
+							_muxer = new MPADemuxWriter(outputDirectory + newFilename+_langName, 0xC0 + _ID);
+							if (!demuxer.AddDemuxer(AUDIO_STREAM + _ID, _muxer, MtxTempString))
+								delete _muxer;
+							break;
+
+						case 4:
+							// TODO possibly other LPCM formats ?
+							MtxTempString += "_wav.tmc " + outputDirectory+newFilename+_langName + ".wav";
+							_muxer = new LPCMDemuxWriter(outputDirectory + newFilename+_langName, 0xA0 + _ID, 48000, 16, 2);
+							if (!demuxer.AddDemuxer(SUBSTREAM_PCM_LOW + _ID, _muxer, MtxTempString))
+								delete _muxer;
+							break;
+
+						case 6:
+							MtxTempString += "_dts.tmc " + outputDirectory+newFilename+_langName + ".dts";
+							_muxer = new DTSDemuxWriter(outputDirectory + newFilename+_langName, 0x88 + _ID);
+							if (!demuxer.AddDemuxer(SUBSTREAM_DTS_LOW + _ID, _muxer, MtxTempString))
+								delete _muxer;
+							break;
+
+						default:
+							wxLogError("Unknown audio format %d", _attr->audio_format);
+							break;
+						}
 					}
 				}
-				// create a possible button demuxer too
-				MtxCommandStringTemp = " --track-name 0:\"btn-" + newFilename + "\" --timecodes 0:" + outputDirectory+newFilename + "_btn.tmc " + outputDirectory+newFilename + ".btn";
-				_muxer = new BtnDemuxWriter(outputDirectory + newFilename, _width, _height);
-				if (!demuxer.AddDemuxer(SUBSTREAM_PCI, _muxer, MtxCommandStringTemp))
-					delete _muxer;
+
+				if (_subTracks.size())
+				{
+					for (_stream=0; _stream<_subTracks.size();_stream++)
+					{
+						// get the possible IDs for this track for this Cell/PGC
+						IdArray _IDs = IfoFile->GetSubsId(_stream, title, language);
+						for (size_t _IDidx=0; _IDidx < _IDs.GetCount(); _IDidx++)
+						{
+							wxString _langName;
+							wxString MtxTempString;
+
+							const subp_attr_t * _attr = _subTracks[_stream];
+							MtxTempString = " --track-name 0:\"sub-";
+							if (_attr->lang_code == 0)
+							{
+								_langName = wxString::Format("_%d_un", _IDs.Item(_IDidx));
+								MtxTempString += newFilename+_langName + "\" --language 0:und ";
+							}
+							else
+							{
+								_langName = wxString::Format("_%d_%c%c", _IDs.Item(_IDidx), _attr->lang_code >> 8, _attr->lang_code & 0xFF);
+								MtxTempString += newFilename+_langName + "\" --language 0:";
+								MtxTempString += wxString::Format("%c%c ", _attr->lang_code >> 8, _attr->lang_code & 0xFF);
+							}
+							MtxTempString += outputDirectory+newFilename+_langName + ".idx";
+							_muxer = new SubDemuxWriter(outputDirectory + newFilename+_langName, 0x20 + _IDs.Item(_IDidx), _width, _height, _palette, _attr->lang_code, _attr->lang_extension == 9);
+							if (!demuxer.AddDemuxer(SUBSTREAM_SUB_LOW + _IDs.Item(_IDidx), _muxer, MtxTempString))
+								delete _muxer;
+						}
+					}
+					// create a possible button demuxer too
+					MtxCommandStringTemp = " --track-name 0:\"btn-" + newFilename + "\" --timecodes 0:" + outputDirectory+newFilename + "_btn.tmc " + outputDirectory+newFilename + ".btn";
+					_muxer = new BtnDemuxWriter(outputDirectory + newFilename, _width, _height);
+					if (!demuxer.AddDemuxer(SUBSTREAM_PCI, _muxer, MtxCommandStringTemp))
+						delete _muxer;
+				}
+
+				m_gaDemuxProgress->SetValue(0);
+				m_gaDemuxProgress->SetRange(aVobParser->GetPacketCount() >> 8);
+				while(aVobParser->ParseNextPacket(*CellsList))
+				{
+					m_gaDemuxProgress->SetValue(aVobParser->GetPacketIndex() >> 8);
+					wxYield();
+				}
+				
+				// create the command line using the list of used files
+				for (_stream = 0; _stream < 256; _stream++)
+				{
+					if (demuxer.FileExists(_stream))
+						MtxCommandString += demuxer.GetString(_stream);
+				}
 			}
 
-			m_gaDemuxProgress->SetValue(0);
-			m_gaDemuxProgress->SetRange(aVobParser.GetPacketCount() >> 8);
-            while(aVobParser.ParseNextPacket(*CellsList))
-            {
-				m_gaDemuxProgress->SetValue(aVobParser.GetPacketIndex() >> 8);
-                wxYield();
-            }
-			
-			// create the command line using the list of used files
-			for (_stream = 0; _stream < 256; _stream++)
+			CellsListType *CellsListDone = (CellsListType *)CellsList;
+			CellsListDone->Arrange();
+
+			bool addChapters;
+
+			if (language)
+				addChapters = GenerateXMLScriptMenu(outputDirectory+newFilename + "_menu.xml", title);
+			else
+				addChapters = GenerateXMLScript(outputDirectory+newFilename + "_menu.xml", title);
+
+			if (addChapters)
 			{
-				if (demuxer.FileExists(_stream))
-					MtxCommandString += demuxer.GetString(_stream);
+				MtxCommandString += " --chapters " + outputDirectory+newFilename + "_menu.xml";
 			}
-			MtxCommandString += " --chapters " + outputDirectory+newFilename + "_menu.xml";
+
 			MtxCommandFile.Write(MtxCommandString);
 			MtxCommandFile.Close();
 
@@ -867,13 +887,17 @@
 		static unsigned char _PrivatePG[] = {0x10, 0x00, 0x00};
 		static unsigned char _PrivateCN[] = {0x08, 0x00, 0x00, 0x00, 0x00};
 		
-		uint64_t end_time = 0;
+		uint64_t start_time = uint64_t(-1), end_time = 0;
 
 		XmlFile.AddLine(IndentString(lvl)+"<ChapterAtom>");
 		lvl++;
 		wxString _myUID = CreateUID();
 		XmlFile.AddLine(IndentString(lvl)+"<ChapterUID>"+_myUID+"</ChapterUID>");
-		XmlFile.AddLine(IndentString(lvl)+"<ChapterFlagHidden>1</ChapterFlagHidden>");
+		XmlFile.AddLine(IndentString(lvl)+"<ChapterDisplay>");
+			lvl++;
+			XmlFile.AddLine(IndentString(lvl)+wxString::Format("<ChapterString>Your Name Here For Chapter #%d</ChapterString>", program_number+1));
+			lvl--;
+		XmlFile.AddLine(IndentString(lvl)+"</ChapterDisplay>");
 		_PrivatePG[1] = (program_number+1) >> 8;
 		_PrivatePG[2] = (program_number+1) & 0xFF;
 		OutputCodecPrivate(lvl, XmlFile, encodebase64(_PrivatePG,3));
@@ -938,20 +962,23 @@
 				DisplayTime(lvl, XmlFile, cell_elt->start_time, cell_elt->start_time + cell_elt->duration);
 				if (end_time < cell_elt->start_time + cell_elt->duration)
 					end_time = cell_elt->start_time + cell_elt->duration;
+				if (start_time > cell_elt->start_time)
+					start_time = cell_elt->start_time;
 				lvl--;
 			XmlFile.AddLine(IndentString(lvl)+"</ChapterAtom>");
 		}
 		
+		XmlFile.AddLine(IndentString(lvl)+"<ChapterTimeStart>"+TimeFormat(start_time)+"</ChapterTimeStart>");
 		lvl--;
-XmlFile.AddLine("<!-- dummy --><ChapterTimeStart>00:00:00.0</ChapterTimeStart>");
 		XmlFile.AddLine(IndentString(lvl)+"</ChapterAtom>");
-		return end_time;
+		return start_time;
 	}
 	
-	void OutputPGC(int lvl, wxTextFile & XmlFile, const pgc_t * pgc, uint16_t pgc_num, unsigned char pgc_type, const CellsListType & cell_list, const ttu_t * ptts)
+	uint64_t OutputPGC(int lvl, wxTextFile & XmlFile, const pgc_t * pgc, uint16_t pgc_num, unsigned char pgc_type, const CellsListType & cell_list, const ttu_t * ptts)
 	{
 		static unsigned char _PrivatePGC[] = {0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
 		static unsigned char _PrivatePTT[] = {0x18, 0x00, 0x00};
+		uint64_t start_time = uint64_t(-1), found_time;
 
 		XmlFile.AddLine(IndentString(lvl)+wxString::Format("<!-- PGC PGC_%d type %s -->",pgc_num+1,GetPGCType(pgc_type).c_str()));
 		XmlFile.AddLine(IndentString(lvl)+"<ChapterAtom>");
@@ -991,6 +1018,7 @@
 				{
 					if (ptts->ptt[ptt_num].pgcn == pgc_num+1 && ptts->ptt[ptt_num].pgn == i+1)
 					{
+/* Don't save the PTT anymore
 						XmlFile.AddLine(IndentString(lvl)+wxString::Format("<!-- Chapter PTT_%d -->", ptt_num+1));
 						XmlFile.AddLine(IndentString(lvl)+"<ChapterAtom>");
 						lvl++;
@@ -1006,21 +1034,29 @@
 							_PrivatePTT[2] = (ptt_num+1) & 0xFF;
 							OutputCodecPrivate(lvl, XmlFile, encodebase64(_PrivatePTT,3));
 				
+						XmlFile.AddLine(IndentString(lvl)+"<ChapterTimeStart>"+TimeFormat(start_time)+"</ChapterTimeStart>");
 						lvl--;
-XmlFile.AddLine("<!-- dummy --><ChapterTimeStart>00:00:00.0</ChapterTimeStart>");
 						XmlFile.AddLine(IndentString(lvl)+"</ChapterAtom>");
+*/
 						break;
 					}
 				}
 			}
 
-			XmlFile.AddLine(IndentString(lvl)+"<!-- Program PGN#"+wxString::Format("%d",i+1)+" in this PGC -->");
-			OutputProgram(lvl, XmlFile, pgc, i, cell_list);
+			XmlFile.AddLine(IndentString(lvl)+"<!-- Program PTT#"+wxString::Format("%d",i+1)+" in this PGC -->");
+			found_time = OutputProgram(lvl, XmlFile, pgc, i, cell_list);
+			if (start_time > found_time)
+				start_time = found_time;
+
 		}
 	
+		if (start_time == uint64_t(-1))
+			start_time = 0;
+
+		XmlFile.AddLine(IndentString(lvl)+"<ChapterTimeStart>"+TimeFormat(start_time)+"</ChapterTimeStart>");
 		lvl--;
-XmlFile.AddLine("<!-- dummy --><ChapterTimeStart>00:00:00.0</ChapterTimeStart>");
 		XmlFile.AddLine(IndentString(lvl)+"</ChapterAtom>");
+		return start_time;
 	}
 	
 // Macro to convert Binary Coded Decimal to Decimal
@@ -1083,9 +1119,10 @@
 		XmlFile.AddLine(IndentString(lvl)+"<ChapterTimeEnd>"+TimeFormat(end_time)+"</ChapterTimeEnd>");
 	}
 	
-	void HandleLanguageUnit(int lvl, wxTextFile & XmlFile, const IFOFile & _ifo, int title)
+	uint64_t HandleLanguageUnit(int lvl, wxTextFile & XmlFile, const IFOFile & _ifo, int title)
 	{
 		static unsigned char _PrivateLU[]  = {0x2A, 0x00, 0x00, 0x00};
+		uint64_t start_time = uint64_t(-1), found_time;
 
 		for (int i=0 ;i<_ifo.LanguageUnits(title)->nr_of_lus; i++)
 		{
@@ -1114,13 +1151,16 @@
 					for (int j=0; j<_LU.pgcit->nr_of_pgci_srp; j++)
 					{
 						const pgci_srp_t &_PGC_SRP = _LU.pgcit->pgci_srp[j];
-						OutputPGC(lvl, XmlFile, _PGC_SRP.pgc, j, _PGC_SRP.entry_id, _ifo.CellsList(title, true), NULL);
+						found_time = OutputPGC(lvl, XmlFile, _PGC_SRP.pgc, j, _PGC_SRP.entry_id, _ifo.CellsList(title, true), NULL);
+						if (start_time > found_time)
+							start_time = found_time;
 					}
 				}
+				XmlFile.AddLine(IndentString(lvl)+"<ChapterTimeStart>"+TimeFormat(start_time)+"</ChapterTimeStart>");
 				lvl--;
-XmlFile.AddLine("<!-- dummy --><ChapterTimeStart>00:00:00.0</ChapterTimeStart>");
 			XmlFile.AddLine(IndentString(lvl)+"</ChapterAtom>");
 		}
+		return start_time;
 	}
 
 	void OutputCodecPrivate(int lvl, wxTextFile & XmlFile, const wxString & CodecPrivate, bool bOpenClose = true)
@@ -1137,23 +1177,15 @@
 		}
 	}
 	
-	void GenerateXMLScript()
+	bool GenerateXMLScriptMenu(const wxString & Filename, uint16_t title)
 	{
-		if (!IfoFile)
-		{
-			wxLogError("No IFO file loaded !");
-			return;
-		}
-
 		static unsigned char _PrivateFP[]  = {0x30, 0x00, 0x00, 0x00};
 		static unsigned char _PrivateVM[]  = {0x30, 0xC0, 0x00, 0x00};
 		static unsigned char _PrivateVTS[] = {0x30, 0x80, 0x00, 0x00};
 		static unsigned char _PrivateTT[]  = {0x28, 0x00, 0x00};
 
 		wxString line, editionUID = CreateUID();
-		wxFileConfig *pConfig = (wxFileConfig *)wxConfigBase::Get();
         // Get sub directory
-        wxString Filename = pConfig->Read(OutputDirSaved,"") + "VMG_menu.xml";
 		wxTextFile XmlFile(Filename);
 		XmlFile.Create();
 		XmlFile.AddLine("<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"no\"?>");
@@ -1170,7 +1202,7 @@
 			XmlFile.AddLine(IndentString(lvl)+"<EditionFlagOrdered>1</EditionFlagOrdered>");
 
 			// Write the first play PGC
-			if (IfoFile->FirstPlayPGC())
+			if (title == 0 && IfoFile->FirstPlayPGC())
 			{
 				XmlFile.AddLine(IndentString(lvl)+"<!-- First Play PGC -->");
 				XmlFile.AddLine(IndentString(lvl)+"<ChapterAtom>");
@@ -1194,138 +1226,122 @@
 						lvl--;
 					XmlFile.AddLine(IndentString(lvl)+"</ChapterProcess>");
 					lvl--;
-XmlFile.AddLine("<!-- dummy --><ChapterTimeStart>00:00:00.0</ChapterTimeStart>");
 				XmlFile.AddLine(IndentString(lvl)+"</ChapterAtom>");
 			}
-			
-			// Language Units
-			if (IfoFile->FirstPlayPGC() && IfoFile->LanguageUnits(0) && IfoFile->LanguageUnits(0)->nr_of_lus)
+
+			// Write the Video Title Set
+			if (IfoFile->LanguageUnits(title) && IfoFile->LanguageUnits(title)->nr_of_lus)
 			{
-				XmlFile.AddLine("\n"+IndentString(lvl)+"<!-- Video Manager -->");
+				// VTS Menu
+				XmlFile.AddLine(IndentString(lvl)+"<!-- Video Title Set -->");
 				XmlFile.AddLine(IndentString(lvl)+"<ChapterAtom>");
 					lvl++;
 					wxString _myUIDa = CreateUID();
 					XmlFile.AddLine(IndentString(lvl)+"<ChapterUID>"+_myUIDa+"</ChapterUID>");
-					OutputCodecPrivate(lvl, XmlFile, encodebase64(_PrivateVM,4));
-					
-					HandleLanguageUnit(lvl, XmlFile, *IfoFile, 0);
-				
+					_PrivateVTS[2] = title >> 8;
+					_PrivateVTS[3] = title & 0xFF;
+					OutputCodecPrivate(lvl, XmlFile, encodebase64(_PrivateVTS,4));
+
+					uint64_t start_time = HandleLanguageUnit(lvl, XmlFile, *IfoFile, title);
+
+					XmlFile.AddLine(IndentString(lvl)+"<ChapterTimeStart>"+TimeFormat(start_time)+"</ChapterTimeStart>");
 					lvl--;
-XmlFile.AddLine("<!-- dummy --><ChapterTimeStart>00:00:00.0</ChapterTimeStart>");
 				XmlFile.AddLine(IndentString(lvl)+"</ChapterAtom>");
 			}
+
 			lvl--;
 		XmlFile.AddLine(IndentString(lvl)+"</EditionEntry>");
 		lvl--;
 		XmlFile.AddLine("</Chapters>");
 		XmlFile.Write();
 
-        // Write the Video Title Set
-        for (int title=1; title <= IfoFile->NumberOfTitles(); title++)
-        {
-			// VTS Menu
-			if (IfoFile->LanguageUnits(title) && IfoFile->LanguageUnits(title)->nr_of_lus)
-			{
-				wxString Filename = pConfig->Read(OutputDirSaved,"") + wxString::Format("VTSM%02d_menu.xml", title);
-				wxTextFile XmlFile(Filename);
-				XmlFile.Create();
-				XmlFile.AddLine("<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"no\"?>");
-				XmlFile.AddLine("<!DOCTYPE Chapters SYSTEM \"matroskachapters.dtd\">");
-				XmlFile.AddLine("");
+		return true;
+	}
 
-				XmlFile.AddLine("<Chapters>");
-				lvl++;
-				XmlFile.AddLine(IndentString(lvl)+"<EditionEntry>");
-					lvl++;
-					XmlFile.AddLine(IndentString(lvl)+"<EditionUID>"+editionUID+"</EditionUID>");
-					XmlFile.AddLine(IndentString(lvl)+"<EditionFlagOrdered>1</EditionFlagOrdered>");
+	bool GenerateXMLScript(const wxString & Filename, uint16_t title)
+	{
+		static unsigned char _PrivateFP[]  = {0x30, 0x00, 0x00, 0x00};
+		static unsigned char _PrivateVM[]  = {0x30, 0xC0, 0x00, 0x00};
+		static unsigned char _PrivateVTS[] = {0x30, 0x80, 0x00, 0x00};
+		static unsigned char _PrivateTT[]  = {0x28, 0x00, 0x00};
+		uint64_t start_timeH = uint64_t(-1);
 
-					XmlFile.AddLine(IndentString(lvl)+"<!-- Video Title Set -->");
-					XmlFile.AddLine(IndentString(lvl)+"<ChapterAtom>");
-						lvl++;
-						wxString _myUIDa = CreateUID();
-						XmlFile.AddLine(IndentString(lvl)+"<ChapterUID>"+_myUIDa+"</ChapterUID>");
-						_PrivateVTS[2] = title >> 8;
-						_PrivateVTS[3] = title & 0xFF;
-						OutputCodecPrivate(lvl, XmlFile, encodebase64(_PrivateVTS,4));
+		wxString line, editionUID = CreateUID();
+        // Get sub directory
+		wxTextFile XmlFile(Filename);
+		XmlFile.Create();
+		XmlFile.AddLine("<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"no\"?>");
+		XmlFile.AddLine("<!DOCTYPE Chapters SYSTEM \"matroskachapters.dtd\">");
+		XmlFile.AddLine("");
 
-						HandleLanguageUnit(lvl, XmlFile, *IfoFile, title);
+		int lvl = 0;
 
-						lvl--;
-XmlFile.AddLine("<!-- dummy --><ChapterTimeStart>00:00:00.0</ChapterTimeStart>");
-					XmlFile.AddLine(IndentString(lvl)+"</ChapterAtom>");
+		// VTS content
+        XmlFile.AddLine("<Chapters>");
+        lvl++;
+        XmlFile.AddLine(IndentString(lvl)+"<EditionEntry>");
+            lvl++;
+            XmlFile.AddLine(IndentString(lvl)+"<EditionUID>"+editionUID+"</EditionUID>");
+			XmlFile.AddLine(IndentString(lvl)+"<EditionFlagOrdered>1</EditionFlagOrdered>");
 
-					lvl--;
-				XmlFile.AddLine(IndentString(lvl)+"</EditionEntry>");
-				lvl--;
-				XmlFile.AddLine("</Chapters>");
-				XmlFile.Write();
-			}
+			XmlFile.AddLine(IndentString(lvl)+"<!-- Video Title Set -->");
+			XmlFile.AddLine(IndentString(lvl)+"<ChapterAtom>");
+				lvl++;
+				wxString _myUIDa = CreateUID();
+				XmlFile.AddLine(IndentString(lvl)+"<ChapterUID>"+_myUIDa+"</ChapterUID>");
+				_PrivateVTS[2] = title >> 8;
+				_PrivateVTS[3] = title & 0xFF;
+				OutputCodecPrivate(lvl, XmlFile, encodebase64(_PrivateVTS,4));
 
-			// VTS content
-            wxString Filename = pConfig->Read(OutputDirSaved,"") + wxString::Format("VTS%02d_menu.xml", title);
-            wxTextFile XmlFile(Filename);
-            XmlFile.Create();
-            XmlFile.AddLine("<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"no\"?>");
-            XmlFile.AddLine("<!DOCTYPE Chapters SYSTEM \"matroskachapters.dtd\">");
-            XmlFile.AddLine("");
-    
-            XmlFile.AddLine("<Chapters>");
-            lvl++;
-            XmlFile.AddLine(IndentString(lvl)+"<EditionEntry>");
-                lvl++;
-                XmlFile.AddLine(IndentString(lvl)+"<EditionUID>"+editionUID+"</EditionUID>");
-				XmlFile.AddLine(IndentString(lvl)+"<EditionFlagOrdered>1</EditionFlagOrdered>");
-    
-				XmlFile.AddLine(IndentString(lvl)+"<!-- Video Title Set -->");
-				XmlFile.AddLine(IndentString(lvl)+"<ChapterAtom>");
-					lvl++;
-					wxString _myUIDa = CreateUID();
-					XmlFile.AddLine(IndentString(lvl)+"<ChapterUID>"+_myUIDa+"</ChapterUID>");
-					_PrivateVTS[2] = title >> 8;
-					_PrivateVTS[3] = title & 0xFF;
-					OutputCodecPrivate(lvl, XmlFile, encodebase64(_PrivateVTS,4));
-
-					if (IfoFile->VtsTitles(title) && IfoFile->VtsPGCs(title))
+				if (IfoFile->VtsTitles(title) && IfoFile->VtsPGCs(title))
+				{
+					for (int i=0; i<IfoFile->VtsTitles(title)->nr_of_srpts; i++)
 					{
-						for (int i=0; i<IfoFile->VtsTitles(title)->nr_of_srpts; i++)
-						{
-							XmlFile.AddLine(IndentString(lvl)+wxString::Format("<!-- Title TTU_%d -->",i+1));
-							XmlFile.AddLine(IndentString(lvl)+"<ChapterAtom>");
-								lvl++;
-								wxString _myUIDa = CreateUID();
-								XmlFile.AddLine(IndentString(lvl)+"<ChapterUID>"+_myUIDa+"</ChapterUID>");
+						uint64_t start_time = uint64_t(-1), found_time;
+						XmlFile.AddLine(IndentString(lvl)+wxString::Format("<!-- Title TTU_%d -->",i+1));
+						XmlFile.AddLine(IndentString(lvl)+"<ChapterAtom>");
+							lvl++;
+							wxString _myUIDa = CreateUID();
+							XmlFile.AddLine(IndentString(lvl)+"<ChapterUID>"+_myUIDa+"</ChapterUID>");
 
-								_PrivateTT[1] = (i+1) >> 8;
-								_PrivateTT[2] = (i+1) & 0xFF;
-								OutputCodecPrivate(lvl, XmlFile, encodebase64(_PrivateTT,3));
-							
-								// add the PGC that match this PTT
-								for (int k=0; k<IfoFile->VtsPGCs(title)->nr_of_pgci_srp; k++)
+							_PrivateTT[1] = (i+1) >> 8;
+							_PrivateTT[2] = (i+1) & 0xFF;
+							OutputCodecPrivate(lvl, XmlFile, encodebase64(_PrivateTT,3));
+						
+							// add the PGC that match this PTT
+							for (int k=0; k<IfoFile->VtsPGCs(title)->nr_of_pgci_srp; k++)
+							{
+								if ((IfoFile->VtsPGCs(title)->pgci_srp[k].entry_id & 0x7F) == i+1)
 								{
-									if ((IfoFile->VtsPGCs(title)->pgci_srp[k].entry_id & 0x7F) == i+1)
-									{
-											OutputPGC(lvl, XmlFile, 
-												IfoFile->VtsPGCs(title)->pgci_srp[k].pgc, k, 0, IfoFile->CellsList(title, false), &IfoFile->VtsTitles(title)->title[i]);
-									}
+									found_time = OutputPGC(lvl, XmlFile, 
+											IfoFile->VtsPGCs(title)->pgci_srp[k].pgc, k, 0, IfoFile->CellsList(title, false), &IfoFile->VtsTitles(title)->title[i]);
+									if (start_time > found_time)
+										start_time = found_time;
 								}
-								
-								lvl--;
-XmlFile.AddLine("<!-- dummy --><ChapterTimeStart>00:00:00.0</ChapterTimeStart>");
-							XmlFile.AddLine(IndentString(lvl)+"</ChapterAtom>");
-						}
+							}
+							
+							XmlFile.AddLine(IndentString(lvl)+"<ChapterTimeStart>"+TimeFormat(start_time)+"</ChapterTimeStart>");
+							lvl--;
+						XmlFile.AddLine(IndentString(lvl)+"</ChapterAtom>");
+						if (start_timeH > start_time)
+							start_timeH = start_time;
 					}
-					
-					lvl--;
-XmlFile.AddLine("<!-- dummy --><ChapterTimeStart>00:00:00.0</ChapterTimeStart>");
-				XmlFile.AddLine(IndentString(lvl)+"</ChapterAtom>");
+				}
 
-                lvl--;
-            XmlFile.AddLine(IndentString(lvl)+"</EditionEntry>");
+				if (start_timeH == uint64_t(-1))
+					start_timeH = 0;
+
+				XmlFile.AddLine(IndentString(lvl)+"<ChapterTimeStart>"+TimeFormat(start_timeH)+"</ChapterTimeStart>");
+				lvl--;
+			XmlFile.AddLine(IndentString(lvl)+"</ChapterAtom>");
+
             lvl--;
-            XmlFile.AddLine("</Chapters>");
-            XmlFile.Write();
-        }
+        XmlFile.AddLine(IndentString(lvl)+"</EditionEntry>");
+        lvl--;
+        XmlFile.AddLine("</Chapters>");
+        XmlFile.Write();
+
+		return true;
 	}
 
    virtual void AfterShow(void)
@@ -1361,24 +1377,18 @@
 
 				VobParser *aVobParser = BuildVobMap(title, language);
 
+				StepString = StepString.Format(StepStringFormat, Step++, NbsStep, "Splitting and demuxing");
+				m_lbStep->SetLabel(StepString);
+				m_txtDemuxLog->AppendText(StepString+"\n");		
+				m_lbStep->Update();
+				SplitAndDemux(aVobParser, title, language);
+
 				if (aVobParser != NULL)
-				{
-					StepString = StepString.Format(StepStringFormat, Step++, NbsStep, "Splitting and demuxing");
-					m_lbStep->SetLabel(StepString);
-					m_txtDemuxLog->AppendText(StepString+"\n");		
-					m_lbStep->Update();
-					SplitAndDemux(*aVobParser, title, language);
-
 					delete aVobParser;
-				}
 				language = !language;
 			} while (!language);
 		}
 
-		IfoFile->ArrangeAll();
-
-		GenerateXMLScript();
-
 		m_txtDemuxLog->AppendText("I'm done\n");
 		wxBell();
 
@@ -1418,8 +1428,6 @@
     {
         wxMyWizard::ShowCustomButton1();
         wxMyWizard::SetCustomButton1Text("Show &logs");
-        wxMyWizard::ShowCustomButton2();
-        wxMyWizard::SetCustomButton2Text("&Settings");
     }
 
 protected:

Modified: trunk/DvdMenuXtractor/IFOFile.cpp
===================================================================
--- trunk/DvdMenuXtractor/IFOFile.cpp	2005-01-08 11:05:08 UTC (rev 1020)
+++ trunk/DvdMenuXtractor/IFOFile.cpp	2005-01-08 15:41:48 UTC (rev 1021)
@@ -241,6 +241,7 @@
 						cle->last_sector = adt.cell_adr_table[l].last_sector;
 						cle->selected = true; // all cells selected for the moment
 						cle->found = false;
+/* debug	* /			cle->found = true;*/
 
 						cle->nb_frames = dvdtime2frame(&srp.pgc->cell_playback[k].playback_time, cle->frame_dur);
 						cle->isStill = (srp.pgc->cell_playback[k].still_time > 0);
@@ -282,15 +283,6 @@
 	}
 }
 
-void IFOFile::ArrangeAll()
-{
-	for (size_t i=0; i<m_ifos.GetCount(); i++)
-	{
-		m_ifos[i]->m_CellsList.Arrange();
-		m_ifos[i]->m_langCellsList.Arrange();
-	}
-}
-
 // ----------------------------------------------------------------------------
 
 const AudioTrackList & IFOFile::AudioTracks(unsigned int title, bool language) const

Modified: trunk/DvdMenuXtractor/IFOFile.h
===================================================================
--- trunk/DvdMenuXtractor/IFOFile.h	2005-01-08 11:05:08 UTC (rev 1020)
+++ trunk/DvdMenuXtractor/IFOFile.h	2005-01-08 15:41:48 UTC (rev 1021)
@@ -98,7 +98,6 @@
 	const CellsListType & CellsList(unsigned int title, bool language) const;
 	bool VideoSize(unsigned int title, bool language, uint16_t & width, uint16_t & height, double & fps) const;
 	const uint32_t * GetPalette(unsigned int title, bool language) const;
-	void ArrangeAll();
 
 	uint8_t GetAudioId(uint8_t streamID, uint8_t title, bool language) const;
 	IdArray GetSubsId(uint8_t streamID, uint8_t title, bool language) const;

Modified: trunk/DvdMenuXtractor/VobParser.h
===================================================================
--- trunk/DvdMenuXtractor/VobParser.h	2005-01-08 11:05:08 UTC (rev 1020)
+++ trunk/DvdMenuXtractor/VobParser.h	2005-01-08 15:41:48 UTC (rev 1021)
@@ -57,8 +57,8 @@
 	uint32_t start_sector;
 	uint32_t last_sector;
 	double frame_dur;
-	int64_t start_time;
-	int64_t duration;
+	uint64_t start_time;
+	uint64_t duration;
 	bool isStill;
 	bool selected;
 	bool found;
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.