[matroska] r964 - trunk/DvdMenuXtractor

[email protected]
Newsgroups gmane.comp.multimedia.matroska.cvs
Message-ID <[email protected]>
Author: robux4
Date: 2004-12-12 14:10:46 +0300 (Sun, 12 Dec 2004)
New Revision: 964

Added:
   trunk/DvdMenuXtractor/README.txt
Modified:
   trunk/DvdMenuXtractor/IFOFile.cpp
   trunk/DvdMenuXtractor/VobParser.cpp
   trunk/DvdMenuXtractor/VobParser.h
Log:
the timecode file for buttons is valid
don't handle still frame durations for the moment

Modified: trunk/DvdMenuXtractor/IFOFile.cpp
===================================================================
--- trunk/DvdMenuXtractor/IFOFile.cpp	2004-12-12 09:53:18 UTC (rev 963)
+++ trunk/DvdMenuXtractor/IFOFile.cpp	2004-12-12 11:10:46 UTC (rev 964)
@@ -233,7 +233,7 @@
 				cle->isStill = (srp.pgc->cell_playback[k].still_time > 0);
 				if (cle->isStill)
 				{
-					cle->frame_dur = srp.pgc->cell_playback[k].still_time * 1000.0 / cle->nb_frames;
+// _todo_ Still should be optional					cle->frame_dur = srp.pgc->cell_playback[k].still_time * 1000.0 / cle->nb_frames;
 				}
 				cle->first_sector = srp.pgc->cell_playback[k].first_sector;
 			}

Added: trunk/DvdMenuXtractor/README.txt
===================================================================
--- trunk/DvdMenuXtractor/README.txt	2004-12-12 09:53:18 UTC (rev 963)
+++ trunk/DvdMenuXtractor/README.txt	2004-12-12 11:10:46 UTC (rev 964)
@@ -0,0 +1,2 @@
+Known issues :
+* The duration of still frames is not handled yet (only lasts as normal frames)
\ No newline at end of file

Modified: trunk/DvdMenuXtractor/VobParser.cpp
===================================================================
--- trunk/DvdMenuXtractor/VobParser.cpp	2004-12-12 09:53:18 UTC (rev 963)
+++ trunk/DvdMenuXtractor/VobParser.cpp	2004-12-12 11:10:46 UTC (rev 964)
@@ -246,10 +246,10 @@
 					{
 						if (m_dsi.nv_pck_scr == 0)
 							m_pci_vob_timecode_offset = m_pci.vobu_s_ptm / 90;
-						m_demuxer.SetBoundary(m_pci.vobu_s_ptm/90 - m_pci_vob_timecode_offset, cell->nb_frames * cell->frame_dur, cell->vobid, cell->vobid);
+						m_demuxer.SetBoundary(m_pci.vobu_s_ptm/90 - m_pci_vob_timecode_offset, cell->nb_frames * cell->frame_dur, cell->vobid, cell->cellid);
 					}
-			}
-				if (m_pci.btn_ns != 0) 
+				}
+				if (m_pci.btn_ns != 0)
 				{ // there are some buttons
 					uint32_t t3 = m_pci.vobu_s_ptm/90 - m_pci_vob_timecode_offset;
 					uint32_t t4 = m_pci.vobu_e_ptm/90 - m_pci_vob_timecode_offset;
@@ -845,8 +845,13 @@
 void BtnDemuxWriter::WriteTimecodeInfo(int32_t start_time, int32_t end_time, uint64_t filepos, wxString & debug)
 {
 	m_TimecodeFile = GetTimecodeFile();
-	fwrite(debug.c_str(), 1, debug.length(), m_TimecodeFile);
-	fprintf(m_TimecodeFile, "# timecode %d\n", m_timecode);
+	if (start_time > m_last_end_timecode)
+	{
+		fprintf(m_TimecodeFile, "%lf\n", (m_last_end_timecode - m_last_start_timecode) / 1000.0);
+		fprintf(m_TimecodeFile, "gap,%lf\n", (start_time - m_last_end_timecode) / 1000.0);
+	}
+	m_last_start_timecode = start_time;
+	m_last_end_timecode = end_time;
 }
 
 void DTSDemuxWriter::WriteTimecodeInfo(int32_t start_time, int32_t end_time, uint64_t filepos, wxString & debug)
@@ -953,15 +958,42 @@
 void BtnDemuxWriter::SetBoundary(uint32_t start_timecode, uint32_t duration, uint16_t vob_id, uint16_t cell_id)
 {
 	m_TimecodeFile = GetTimecodeFile();
+
+	// handle ending of the previous cell
+	if (m_last_end_timecode < m_end_timecode)
+	{
+		fprintf(m_TimecodeFile, "gap,%lf\n", (m_end_timecode - m_last_end_timecode) / 1000.0);
+		m_last_start_timecode = start_timecode;
+	}
+	else
+	{
+		if (m_end_timecode != 0)
+			fprintf(m_TimecodeFile, "%lf\n", (m_end_timecode - m_start_timecode) / 1000.0);
+	}
+
+	m_start_timecode = start_timecode;
+	m_end_timecode = start_timecode + duration;
+	m_last_end_timecode = start_timecode;
+
 	if (start_timecode == 0) // new VOB
 	{
-		if (m_prev_timecode < start_timecode)
-		{
-			// there was a gap
-			fprintf(m_TimecodeFile, "gap,%lf\n", ((double)(start_timecode - m_prev_timecode)) / 1000.0);
-			m_prev_timecode = start_timecode;
-		}
+		m_offset_timecode = m_start_timecode;
 	}
-	fprintf(m_TimecodeFile, "# VOB %d Cell %d\n", vob_id, cell_id);
-	fprintf(m_TimecodeFile, "# CELL TIMECODE %d -> %d [%d]\n", start_timecode, start_timecode+duration, duration);
+	fprintf(m_TimecodeFile, "\n# VOB %d Cell %d\n", vob_id, cell_id);
 }
+
+BtnDemuxWriter::~BtnDemuxWriter()
+{
+	m_TimecodeFile = GetTimecodeFile();
+
+	// handle ending of the previous cell
+	if (m_last_end_timecode < m_end_timecode)
+	{
+		fprintf(m_TimecodeFile, "gap,%lf\n", (m_end_timecode - m_last_end_timecode) / 1000.0);
+	}
+	else
+	{
+		if (m_end_timecode != 0)
+			fprintf(m_TimecodeFile, "%lf\n", (m_end_timecode - m_start_timecode) / 1000.0);
+	}
+}

Modified: trunk/DvdMenuXtractor/VobParser.h
===================================================================
--- trunk/DvdMenuXtractor/VobParser.h	2004-12-12 09:53:18 UTC (rev 963)
+++ trunk/DvdMenuXtractor/VobParser.h	2004-12-12 11:10:46 UTC (rev 964)
@@ -361,18 +361,24 @@
 public:
 	BtnDemuxWriter(const char* filenamePrefix)
 		:Writer(filenamePrefix, "btn",0.0)
-		,m_timecode(0)
-		,m_prev_timecode(0)
+		,m_offset_timecode(0)
+		,m_end_timecode(0)
+		,m_last_start_timecode(0)
+		,m_last_end_timecode(0)
 	{}
 	void ProcessStream(uint8_t* buff, uint32_t size, int32_t start_time, int32_t end_time, wxString & debug)
 	{
 		Write(buff,size, start_time, end_time, debug);
 	}
 	void SetBoundary(uint32_t start_timecode, uint32_t duration, uint16_t vob_id, uint16_t cell_id);
+	~BtnDemuxWriter();
 protected:
 	void WriteTimecodeInfo(int32_t start_time, int32_t end_time, uint64_t filepos, wxString & debug);
-	uint32_t m_timecode;
-	uint32_t m_prev_timecode;
+	uint32_t m_start_timecode;
+	uint32_t m_end_timecode;
+	uint32_t m_offset_timecode;
+	uint32_t m_last_start_timecode;
+	uint32_t m_last_end_timecode;
 };
 
 // ----------------------------------------------------------------------------
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.