[matroska] r892 - in trunk: DvdMenuXtractor libebml/src

[email protected]
Newsgroups gmane.comp.multimedia.matroska.cvs
Message-ID <[email protected]>
Author: robux4
Date: 2004-10-18 23:28:58 +0400 (Mon, 18 Oct 2004)
New Revision: 892

Modified:
   trunk/DvdMenuXtractor/DvdMenuXtractor.cpp
   trunk/DvdMenuXtractor/IFOFile.cpp
   trunk/DvdMenuXtractor/IFOFile.h
   trunk/libebml/src/EbmlElement.cpp
   trunk/libebml/src/EbmlMaster.cpp
Log:
better code to handle all VTS VOBs (not yet there)

Modified: trunk/DvdMenuXtractor/DvdMenuXtractor.cpp
===================================================================
--- trunk/DvdMenuXtractor/DvdMenuXtractor.cpp	2004-10-18 13:15:16 UTC (rev 891)
+++ trunk/DvdMenuXtractor/DvdMenuXtractor.cpp	2004-10-18 19:28:58 UTC (rev 892)
@@ -323,7 +323,7 @@
     {
         if(PreviousPageHasChanged())
         {
-            wxArrayString languageList = IfoFile->GetLanguageList();
+            wxArrayString languageList = IfoFile->GetLanguageList(0);
             m_lstbLanguage->Clear();
             if(languageList.Count() > 0)
             {
@@ -522,7 +522,13 @@
 	{
 		wxFileConfig *pConfig = (wxFileConfig *)wxConfigBase::Get();
 		
-      VobParser * _VobParser = new VobParser(pConfig->Read("InDirectory","").c_str(), title);
+		VobParser * _VobParser = NULL;
+		try {
+			_VobParser = new VobParser(pConfig->Read("InDirectory","").c_str(), title);
+		} catch (...)
+		{
+			m_txtDemuxLog->AppendText(wxString::Format("no VOB files found in %s for Title %02d\n",pConfig->Read("InDirectory","").c_str(),title));
+		}
 		if (_VobParser != NULL)
 			_VobParser->BuildMap();
 		return _VobParser;

Modified: trunk/DvdMenuXtractor/IFOFile.cpp
===================================================================
--- trunk/DvdMenuXtractor/IFOFile.cpp	2004-10-18 13:15:16 UTC (rev 891)
+++ trunk/DvdMenuXtractor/IFOFile.cpp	2004-10-18 19:28:58 UTC (rev 892)
@@ -77,14 +77,14 @@
 
 // ----------------------------------------------------------------------------
 
-const wxArrayString& IFOFile::GetLanguageList()
+const wxArrayString& IFOFile::GetLanguageList(unsigned int title)
 {
 	m_languageList.Clear();
 
-	for(int i=0; i < m_ifos.Item(0)->GetData()->pgci_ut->nr_of_lus; i++)
+	for(int i=0; i < m_ifos.Item(title)->GetData()->pgci_ut->nr_of_lus; i++)
 	{
-		pgci_lu_t* lu = &m_ifos.Item(0)->GetData()->pgci_ut->lu[i];
-		m_languageList.Add(DecodeLanguage(lu->lang_code));
+		pgci_lu_t& lu = m_ifos.Item(title)->GetData()->pgci_ut->lu[i];
+		m_languageList.Add(DecodeLanguage(lu.lang_code));
 		m_SelectionTab[i] = 1;
 	}
 
@@ -182,53 +182,65 @@
 }
 
 // ----------------------------------------------------------------------------
+void IFOFile::GetPGCCells(const pgcit_t & pgcit, CellsHashType * CellsHash)
+{
+	CellListElem* cle;
 
+	for(int j=0; j < pgcit.nr_of_pgci_srp; j++)
+	{
+		pgci_srp_t& srp = pgcit.pgci_srp[j];
+		for(int k=0; k < srp.pgc->nr_of_cells; k++)
+		{
+			cle = new CellListElem();
+			cle->vobid = srp.pgc->cell_position[k].vob_id_nr;
+			cle->cellid = srp.pgc->cell_position[k].cell_nr;
+
+			if(srp.pgc->cell_playback[k].still_time > 0)
+			{
+				// stills
+				double frame_rate = ((srp.pgc->cell_playback[k].playback_time.frame_u & 0xc0) >> 6) == 1 ? 25.0 : 30;
+				cle->duration = srp.pgc->cell_playback[k].still_time * frame_rate;
+				cle->isStill = TRUE;
+			}
+			else
+			{
+				// video
+				cle->duration = dvdtime2frame(&srp.pgc->cell_playback[k].playback_time);
+				cle->isStill = FALSE;
+			}
+			cle->first_sector = srp.pgc->cell_playback[k].first_sector;
+
+			(*CellsHash)[MAKE_CELLS_KEY(cle)] = cle;
+		}
+	}
+}
+
+// ----------------------------------------------------------------------------
+
 const CellsListType* IFOFile::GetCellsList(unsigned int title)
 {
 	CellsHashType CellsHash;
-	CellListElem* cle;
 
 	if (title >= m_ifos.GetCount())
 		return NULL;
 	
 	ifo_handle_t *_ifo = m_ifos.Item(title)->GetData(); 
 	
-	for(int i = 0; i < _ifo->pgci_ut->nr_of_lus; i++)
+	if (_ifo->pgci_ut)
 	{
-//		if(m_SelectionTab[i] == 1)
+		for(int i = 0; i < _ifo->pgci_ut->nr_of_lus; i++)
 		{
-			pgci_lu_t* lu = &_ifo->pgci_ut->lu[i];
-
-			for(int j=0; j < lu->pgcit->nr_of_pgci_srp; j++)
-			{
-				pgci_srp_t* srp = &lu->pgcit->pgci_srp[j];
-				for(int k=0; k < srp->pgc->nr_of_cells; k++)
-				{
-					cle = new CellListElem();
-					cle->vobid = srp->pgc->cell_position[k].vob_id_nr;
-					cle->cellid = srp->pgc->cell_position[k].cell_nr;
-
-					if(srp->pgc->cell_playback[k].still_time > 0)
-					{
-						// stills
-						double frame_rate = ((srp->pgc->cell_playback[k].playback_time.frame_u & 0xc0) >> 6) == 1 ? 25.0 : 30;
-						cle->duration = srp->pgc->cell_playback[k].still_time * frame_rate;
-						cle->isStill = TRUE;
-					}
-					else
-					{
-						// video
-						cle->duration = dvdtime2frame(&srp->pgc->cell_playback[k].playback_time);
-						cle->isStill = FALSE;
-					}
-					cle->first_sector = srp->pgc->cell_playback[k].first_sector;
-
-					CellsHash[MAKE_CELLS_KEY(cle)] = cle;
-				}
-			}
+			pgci_lu_t& lu = _ifo->pgci_ut->lu[i];
+			GetPGCCells(*lu.pgcit, &CellsHash);
 		}
 	}
 	
+	// handle non-language unit cells
+	if (_ifo->vts_pgcit)
+	{
+		GetPGCCells(*_ifo->vts_pgcit, &CellsHash);
+	}
+
 	// Transfer hash map to the list to be sorted
 	m_cellsList.DeleteContents(TRUE);
 	m_cellsList.Clear();

Modified: trunk/DvdMenuXtractor/IFOFile.h
===================================================================
--- trunk/DvdMenuXtractor/IFOFile.h	2004-10-18 13:15:16 UTC (rev 891)
+++ trunk/DvdMenuXtractor/IFOFile.h	2004-10-18 19:28:58 UTC (rev 892)
@@ -33,13 +33,15 @@
 
 WX_DECLARE_LIST(ifo_handle_t, IfoHandleList);
 
+class CellsHashType;
+
 // ----------------------------------------------------------------------------
 
 class IFOFile  
 {
 public:
 	IFOFile(const wxString& filename);
-	const wxArrayString& GetLanguageList();
+	const wxArrayString& GetLanguageList(unsigned int title);
 	void AddLanguageToSelection(const int languageNumber);
 	void ClearLanguageSelection();
 	const CellsListType* GetCellsList(unsigned int title);
@@ -51,6 +53,9 @@
 	const pgcit_t *VtsPGCs(unsigned int title) const;
 	const int16_t NumberOfTitles() const;
 
+protected:
+	void GetPGCCells(const pgcit_t & pgc, CellsHashType * CellsHash);
+
 private:
 	IfoHandleList m_ifos;
 	dvd_reader_t* m_dvd;

Modified: trunk/libebml/src/EbmlElement.cpp
===================================================================
--- trunk/libebml/src/EbmlElement.cpp	2004-10-18 13:15:16 UTC (rev 891)
+++ trunk/libebml/src/EbmlElement.cpp	2004-10-18 19:28:58 UTC (rev 892)
@@ -531,7 +531,7 @@
 */
 uint32 EbmlElement::Render(IOCallback & output, bool bSaveDefault, bool bKeepPosition, bool bForceRender)
 {
-	assert(bValueIsSet); // an element is been rendered without a value set !!!
+	assert(bValueIsSet || (bSaveDefault && DefaultISset())); // an element is been rendered without a value set !!!
 		                 // it may be a mandatory element without a default value
 	try {
 		if (!bSaveDefault && IsDefaultValue()) {

Modified: trunk/libebml/src/EbmlMaster.cpp
===================================================================
--- trunk/libebml/src/EbmlMaster.cpp	2004-10-18 13:15:16 UTC (rev 891)
+++ trunk/libebml/src/EbmlMaster.cpp	2004-10-18 19:28:58 UTC (rev 892)
@@ -92,8 +92,9 @@
 	uint32 Result = 0;
 	size_t Index;
 
-	if (!bForceRender)
+	if (!bForceRender) {
 		assert(CheckMandatory());
+	}
 
 	if (!bChecksumUsed) { // old school
 		for (Index = 0; Index < ElementList.size(); Index++) {
@@ -133,8 +134,9 @@
 	if (!bSizeIsFinite)
 		return (0-1);
 
-	if (!bForceRender)
+	if (!bForceRender) {
 		assert(CheckMandatory());
+    }
 	
 	size_t Index;
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.