[matroska] r771 - trunk/DvdMenuXtractor

[email protected]
Newsgroups gmane.comp.multimedia.matroska.cvs
Message-ID <[email protected]>
Author: robux4
Date: 2004-09-09 16:49:09 +0400 (Thu, 09 Sep 2004)
New Revision: 771

Modified:
   trunk/DvdMenuXtractor/DvdMenuXtractor.cpp
Log:
the Language Unit is now fully mapped to Matroska chapters

Modified: trunk/DvdMenuXtractor/DvdMenuXtractor.cpp
===================================================================
--- trunk/DvdMenuXtractor/DvdMenuXtractor.cpp	2004-09-09 11:29:53 UTC (rev 770)
+++ trunk/DvdMenuXtractor/DvdMenuXtractor.cpp	2004-09-09 12:49:09 UTC (rev 771)
@@ -869,13 +869,58 @@
 		return result;
 	}
 
-	uint64_t OutputProgram(int lvl, wxTextFile & XmlFile, const pgc_program_map_t * program, uint64_t start_time)
+	uint64_t OutputProgram(int lvl, wxTextFile & XmlFile, const pgc_t * pgc, int program_number, uint64_t start_time)
 	{
+		static unsigned char _PrivatePG[] = {0x10, 0x00, 0x00};
+		static unsigned char _PrivateCN[] = {0x08, 0x00, 0x00, 0x00};
+		
+		uint64_t st_time = start_time, end_time;
+
+		lvl++;
+		wxString _myUID = CreateUID();
+		XmlFile.AddLine(IndentString(lvl)+"<ChapterUID>"+_myUID+"</ChapterUID>");
+		// display the UID for the lazy rippers
+		XmlFile.AddLine(IndentString(lvl)+"<ChapterDisplay>");
+			lvl++;
+			XmlFile.AddLine(IndentString(lvl)+"<ChapterString>Program "+_myUID+"</ChapterString>");
+			lvl--;
+		XmlFile.AddLine(IndentString(lvl)+"</ChapterDisplay>");
+		_PrivatePG[1] = (program_number+1) >> 8;
+		_PrivatePG[2] = (program_number+1) & 0xFF;
+		XmlFile.AddLine(IndentString(lvl)+"<ChapterProcessPrivate>"+encodebase64(_PrivatePG,3)+"</ChapterProcessPrivate>");
+		// Output cells
+		XmlFile.AddLine(IndentString(lvl)+"<!-- Program Entry Cell #"+wxString::Format("%d",pgc->program_map[program_number])+" -->");
+		do {
+			XmlFile.AddLine(IndentString(lvl)+"<ChapterAtom>");
+				lvl++;
+				const cell_position_t & position = pgc->cell_position[program_number];
+				const cell_playback_t & cell = pgc->cell_playback[program_number];
+				wxString _myUID = CreateUID();
+				XmlFile.AddLine(IndentString(lvl)+"<ChapterUID>"+_myUID+"</ChapterUID>");
+			
+				_PrivateCN[1] = (position.vob_id_nr) >> 8;
+				_PrivateCN[2] = (position.vob_id_nr) & 0xFF;
+				_PrivateCN[3] = position.cell_nr;
+				XmlFile.AddLine(IndentString(lvl)+"<ChapterProcessPrivate>"+encodebase64(_PrivateCN,4)+"</ChapterProcessPrivate>");
+			
+				end_time = st_time + DvdTimecodeToNano(cell.playback_time);
+//XmlFile.AddLine(IndentString(lvl)+"<incorrect/>");
+				DisplayTime(lvl, XmlFile, st_time, end_time);
+				st_time = end_time;
+				lvl--;
+			XmlFile.AddLine(IndentString(lvl)+"</ChapterAtom>");
+		} while(0); // TODO: for the moment we assume there is only one cell per program
+		
+		// PGC start/end times
+		DisplayTime(lvl, XmlFile, start_time, end_time);
+		lvl--;
+		return end_time;
 	}
 	
 	uint64_t OutputPGC(int lvl, wxTextFile & XmlFile, const pgc_t * pgc, uint64_t start_time, uint16_t pgc_num, unsigned char pgc_type)
 	{
 		static unsigned char _PrivatePGC[] = {0x20, 0x00, 0x00, 0x00};
+		uint64_t st_time = start_time, end_time;
 
 		lvl++;
 		wxString _myUID = CreateUID();
@@ -894,20 +939,17 @@
 		// PGC commands
 		AddCommands(lvl, XmlFile, pgc->command_tbl);
 
-		// TODO: handle the PROGRAMS/Cells in the PGC
+		// Handle the Programs/Cells in the PGC
 		for (int i=0; i< pgc->nr_of_programs; i++)
 		{
-			XmlFile.AddLine(IndentString(lvl)+"<!-- Program #"+wxString::Format("%d",i)+" in this PGC -->");
+			XmlFile.AddLine(IndentString(lvl)+"<!-- Program #"+wxString::Format("%d",i+1)+" in this PGC -->");
 			XmlFile.AddLine(IndentString(lvl)+"<ChapterAtom>");
-				lvl++;
-				// TODO
-				OutputProgram(lvl, XmlFile, &pgc->program_map[i], start_time);
-				lvl--;
+			st_time = OutputProgram(lvl, XmlFile, pgc, i, st_time);
 			XmlFile.AddLine(IndentString(lvl)+"</ChapterAtom>");
 		}
 
 		// PGC start/end times
-		DisplayTime(lvl, XmlFile, start_time, start_time+ DvdTimecodeToNano(pgc->playback_time));
+		DisplayTime(lvl, XmlFile, start_time, st_time);
 		lvl--;
 		return start_time + DvdTimecodeToNano(pgc->playback_time);
 	}
@@ -915,7 +957,7 @@
 // Macro to convert Binary Coded Decimal to Decimal
 #define BCD2D(__x__) (((__x__ & 0xf0) >> 4) * 10 + (__x__ & 0x0f))
 
-	uint64_t DvdTimecodeToNano(dvd_time_t dtime)
+	uint64_t DvdTimecodeToNano(const dvd_time_t & dtime)
 	{
 		uint64_t nano_duration = 0;
 		nano_duration += uint64_t(BCD2D(dtime.hour)) * 60 * 60 * 1000000000;
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.