[matroska] r1047 - trunk/DvdMenuXtractor

[email protected]
Newsgroups gmane.comp.multimedia.matroska.cvs
Message-ID <[email protected]>
Author: robux4
Date: 2005-01-19 18:54:11 +0300 (Wed, 19 Jan 2005)
New Revision: 1047

Modified:
   trunk/DvdMenuXtractor/DvdMenuXtractor.cpp
   trunk/DvdMenuXtractor/README.txt
Log:
DMX: handle the PTTs (DVD chapters) correctly

Modified: trunk/DvdMenuXtractor/DvdMenuXtractor.cpp
===================================================================
--- trunk/DvdMenuXtractor/DvdMenuXtractor.cpp	2005-01-19 14:04:29 UTC (rev 1046)
+++ trunk/DvdMenuXtractor/DvdMenuXtractor.cpp	2005-01-19 15:54:11 UTC (rev 1047)
@@ -73,7 +73,7 @@
 wxString outputDirectory;
 wxString mtxDirectory;
 const wxString APPLICATION_NAME = "DVDMenuXtractor: DMX - a fair-use tool";
-const wxString APPLICATION_VERSION = "0.8.4";
+const wxString APPLICATION_VERSION = "0.9.0";
 
 // ----------------------------------------------------------------------------
 
@@ -903,25 +903,14 @@
 		return result;
 	}
 
-	uint64_t OutputProgram(int lvl, wxTextFile & XmlFile, const pgc_t * pgc, int program_number, const CellsListType & cell_list) const
+	uint64_t OutputProgram(int lvl, wxTextFile & XmlFile, const pgc_t * pgc, int program_number, const CellsListType & cell_list, int16_t pgc_num, const ttu_t * ptts) const
 	{
-		static unsigned char _PrivatePG[] = {0x10, 0x00, 0x00};
+		static unsigned char _PrivatePTT[] = {0x10, 0x00};
+		static unsigned char _PrivatePG[] = {0x18, 0x00, 0x00};
 		static unsigned char _PrivateCN[] = {0x08, 0x00, 0x00, 0x00, 0x00};
 		
 		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)+"<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, _PrivatePG, 3);
 		// for this program
 		int entry_cell_num = pgc->program_map[program_number];
 		int program_last_cell_num = pgc->nr_of_cells;
@@ -930,6 +919,49 @@
 			next_program_entry_cell_num = program_last_cell_num+1;
 		else
 			next_program_entry_cell_num = pgc->program_map[program_number+1];
+
+		XmlFile.AddLine(IndentString(lvl)+"<!-- Program PGN#"+wxString::Format("%d",program_number+1)+" in this PGC -->");
+		XmlFile.AddLine(IndentString(lvl)+"<ChapterAtom>");
+		lvl++;
+		wxString _myUID = CreateUID();
+		XmlFile.AddLine(IndentString(lvl)+"<ChapterUID>"+_myUID+"</ChapterUID>");
+		_PrivatePG[1] = (program_number+1) >> 8;
+		_PrivatePG[2] = (program_number+1) & 0xFF;
+		OutputCodecPrivate(lvl, XmlFile, _PrivatePG, 3);
+
+		if (ptts != NULL)
+		{
+			// find all PTT corresponding to this PGC/PG number
+			for (uint16_t pppt_nr=0; pppt_nr<ptts->nr_of_ptts; pppt_nr++)
+			{
+				// use the start timecode of the first cell
+				const cell_position_t & position = pgc->cell_position[entry_cell_num-1];
+				const CellListElem * cell_elt = cell_list.Get(position);
+				// TODO: make this test optional (create chapters even without the content)
+				if (cell_elt == NULL || !cell_elt->found)
+					continue;
+				start_time = cell_elt->start_time;
+				if (ptts->ptt[pppt_nr].pgcn == pgc_num+1 && ptts->ptt[pppt_nr].pgn == program_number+1)
+				{
+					XmlFile.AddLine(IndentString(lvl)+wxString::Format("<!-- Chapter PTT#%d [%02d.%02d]-->",pppt_nr+1,pgc_num+1,program_number+1));
+					XmlFile.AddLine(IndentString(lvl)+"<ChapterAtom>");
+					lvl++;
+						XmlFile.AddLine(IndentString(lvl)+"<ChapterDisplay>");
+							lvl++;
+							XmlFile.AddLine(IndentString(lvl)+wxString::Format("<ChapterString>Your Name Here For Chapter #%d</ChapterString>", pppt_nr+1));
+							lvl--;
+						XmlFile.AddLine(IndentString(lvl)+"</ChapterDisplay>");
+						wxString _myUID = CreateUID();
+						XmlFile.AddLine(IndentString(lvl)+"<ChapterUID>"+_myUID+"</ChapterUID>");
+						_PrivatePTT[1] = pppt_nr+1;
+						OutputCodecPrivate(lvl, XmlFile, _PrivatePTT, 2);
+						XmlFile.AddLine(IndentString(lvl)+"<ChapterTimeStart>"+TimeFormat(start_time)+"</ChapterTimeStart>");
+					lvl--;
+					XmlFile.AddLine(IndentString(lvl)+"</ChapterAtom>");
+				}
+			}
+		}
+
 		for (int cell_num = entry_cell_num; cell_num<next_program_entry_cell_num; cell_num++)
 		{
 			// Output cells
@@ -940,6 +972,7 @@
 				continue;
 
 			const CellListElem * cell_elt = cell_list.Get(position);
+			// TODO: make this test optional (create chapters even without the content)
 			if (cell_elt == NULL || !cell_elt->found)
 				continue;
 
@@ -948,26 +981,6 @@
 			else
 				XmlFile.AddLine(IndentString(lvl)+wxString::Format("<!-- Program %sCell CN#%d [%02d.%d] -->",(cell_num==entry_cell_num)?"Entry ":"", cell_num, cell_elt->vobid, cell_elt->cellid));
 
-			if (cell.still_time == 0xFF) {
-				XmlFile.AddLine(IndentString(lvl)+"<!-- Infinite loop Still Cell -->");
-				
-				// output an additional tag to specify this is cell should loop infinitely
-				// post-process command, jump to timecode "st_time"
-				XmlFile.AddLine(IndentString(lvl)+"<ChapterProcess>");
-				lvl++;
-					XmlFile.AddLine(IndentString(lvl)+"<ChapterProcessCodecID>0</ChapterProcessCodecID>");
-					XmlFile.AddLine(IndentString(lvl)+"<!-- Post command: replay this cell -->");
-					XmlFile.AddLine(IndentString(lvl)+"<ChapterProcessCommand>");
-					lvl++;
-						XmlFile.AddLine(IndentString(lvl)+"<ChapterProcessTime>2</ChapterProcessTime>");
-						XmlFile.AddLine(IndentString(lvl)+"<ChapterProcessData format=\"ascii\">GotoAndPlay("+_myUID+");</ChapterProcessData>");
-					lvl--;
-					XmlFile.AddLine(IndentString(lvl)+"</ChapterProcessCommand>");
-				lvl--;
-				XmlFile.AddLine(IndentString(lvl)+"</ChapterProcess>");
-			} else if (cell.still_time != 0)
-				XmlFile.AddLine(IndentString(lvl)+wxString::Format("<!-- Still cell (%ds) -->", cell.still_time));
-
 			XmlFile.AddLine(IndentString(lvl)+"<ChapterAtom>");
 				lvl++;
 				wxString _myUID = CreateUID();
@@ -979,6 +992,26 @@
 				_PrivateCN[4] = cell_num - entry_cell_num + 1; // Number of angles
 				OutputCodecPrivate(lvl, XmlFile, _PrivateCN, 5);
 
+				if (cell.still_time == 0xFF) {
+					XmlFile.AddLine(IndentString(lvl)+"<!-- Infinite loop Still Cell -->");
+					
+					// output an additional tag to specify this is cell should loop infinitely
+					// post-process command, jump to timecode "st_time"
+					XmlFile.AddLine(IndentString(lvl)+"<ChapterProcess>");
+					lvl++;
+						XmlFile.AddLine(IndentString(lvl)+"<ChapterProcessCodecID>0</ChapterProcessCodecID>");
+						XmlFile.AddLine(IndentString(lvl)+"<!-- Post command: replay this cell -->");
+						XmlFile.AddLine(IndentString(lvl)+"<ChapterProcessCommand>");
+						lvl++;
+							XmlFile.AddLine(IndentString(lvl)+"<ChapterProcessTime>2</ChapterProcessTime>");
+							XmlFile.AddLine(IndentString(lvl)+"<ChapterProcessData format=\"ascii\">GotoAndPlay("+_myUID+");</ChapterProcessData>");
+						lvl--;
+						XmlFile.AddLine(IndentString(lvl)+"</ChapterProcessCommand>");
+					lvl--;
+					XmlFile.AddLine(IndentString(lvl)+"</ChapterProcess>");
+				} else if (cell.still_time != 0)
+					XmlFile.AddLine(IndentString(lvl)+wxString::Format("<!-- Still cell (%ds) -->", cell.still_time));
+	
 				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;
@@ -1000,7 +1033,6 @@
 	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) const
 	{
 		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()));
@@ -1033,41 +1065,7 @@
 		// Handle the Programs/Cells in the PGC
 		for (int i=0; i< pgc->nr_of_programs; i++)
 		{
-			// handle the PTT/Chapter
-			if (ptts != NULL)
-			{
-				// find if the PGCN/PGN is in the list
-				for (int ptt_num=0; ptt_num<ptts->nr_of_ptts; ptt_num++)
-				{
-					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++;
-							wxString _myUIDa = CreateUID();
-							XmlFile.AddLine(IndentString(lvl)+"<ChapterUID>"+_myUIDa+"</ChapterUID>");
-							// display the UID for the lazy rippers
-							XmlFile.AddLine(IndentString(lvl)+"<ChapterDisplay>");
-								lvl++;
-								XmlFile.AddLine(IndentString(lvl)+wxString::Format("<ChapterString>Your Name Here For Chapter #%d</ChapterString>", ptt_num+1));
-								lvl--;
-							XmlFile.AddLine(IndentString(lvl)+"</ChapterDisplay>");
-							_PrivatePTT[1] = (ptt_num+1) >> 8;
-							_PrivatePTT[2] = (ptt_num+1) & 0xFF;
-							OutputCodecPrivate(lvl, XmlFile, _PrivatePTT, 3);
-				
-						XmlFile.AddLine(IndentString(lvl)+"<ChapterTimeStart>"+TimeFormat(start_time)+"</ChapterTimeStart>");
-						lvl--;
-						XmlFile.AddLine(IndentString(lvl)+"</ChapterAtom>");
-*/
-						break;
-					}
-				}
-			}
-
-			XmlFile.AddLine(IndentString(lvl)+"<!-- Program PGN#"+wxString::Format("%d",i+1)+" in this PGC -->");
-			found_time = OutputProgram(lvl, XmlFile, pgc, i, cell_list);
+			found_time = OutputProgram(lvl, XmlFile, pgc, i, cell_list, pgc_num, ptts);
 			if (start_time > found_time)
 				start_time = found_time;
 

Modified: trunk/DvdMenuXtractor/README.txt
===================================================================
--- trunk/DvdMenuXtractor/README.txt	2005-01-19 14:04:29 UTC (rev 1046)
+++ trunk/DvdMenuXtractor/README.txt	2005-01-19 15:54:11 UTC (rev 1047)
@@ -1,5 +1,4 @@
 TODO :
-* get the PTT handling back and correct...
 * generate the d2v file ?
 * allow skipping DVD parts when extracting (VMG, VTSM, VTS)
 * allow selection of stream output (audio & subs languages)
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.