[matroska] r751 - trunk/DvdMenuXtractor
[email protected] Wed, 8 Sep 2004 00:24:41 +0400 (MSD)
Newsgroups
gmane.comp.multimedia.matroska.cvs
Message-ID
<[email protected] >
Author: robux4
Date: 2004-09-08 00:24:40 +0400 (Wed, 08 Sep 2004)
New Revision: 751
Added:
trunk/DvdMenuXtractor/base64.cpp
trunk/DvdMenuXtractor/base64.h
Modified:
trunk/DvdMenuXtractor/DvdMenuXtractor.cpp
trunk/DvdMenuXtractor/IFOFile.cpp
trunk/DvdMenuXtractor/IFOFile.h
Log:
roughly added first play PGC support and Base64 encoding
Modified: trunk/DvdMenuXtractor/DvdMenuXtractor.cpp
===================================================================
--- trunk/DvdMenuXtractor/DvdMenuXtractor.cpp 2004-09-07 20:22:24 UTC (rev 750)
+++ trunk/DvdMenuXtractor/DvdMenuXtractor.cpp 2004-09-07 20:24:40 UTC (rev 751)
@@ -1,5 +1,6 @@
// ----------------------------------------------------------------------------
// For compilers that support precompilation, includes "wx/wx.h".
+#include <time.h>
#include "wx/wxprec.h"
#ifdef __BORLANDC__
@@ -30,6 +31,7 @@
#include "MPEG2Decoder.h"
#include "A52Decoder.h"
#include "SUBDecoder.h"
+#include "base64.h"
// TODO : settings
// - preferred language
@@ -97,6 +99,8 @@
this->m_pageTitle = "Data menu extraction";
this->m_pageDesc = "Source files selection";
+ srand( (unsigned)time( NULL ) );
+
wxFileConfig *pConfig = (wxFileConfig *)wxConfigBase::Get();
wxFlexGridSizer *fgs = new wxFlexGridSizer(4,3,0,0);
fgs->AddGrowableCol(1);
@@ -765,12 +769,16 @@
wxString result = "";
for(int i=0; i < lvl; i++)
- for(int j=0; j < 2; j++)
- result += " ";
+ result += "\t";
return result;
}
+ inline wxString CreateUID()
+ {
+ return wxString::Format("%d", rand() | (rand() << 16) );
+ }
+
void GenerateXMLScript()
{
CellListElem* cle;
@@ -779,16 +787,71 @@
CellMap& cell_map = m_VobParser->GetVobMap();
cell_info_node* cin;
+ static unsigned char _PrivateFP[] = {0x30, 0x00};
+
wxString line;
wxFileConfig *pConfig = (wxFileConfig *)wxConfigBase::Get();
// Get sub directory
wxString Filename = pConfig->Read("OutputDirectory","") + "menu.xml";
wxTextFile XmlFile(Filename);
XmlFile.Create();
- XmlFile.AddLine("<?xml version=\"1.0\"?>");
+ XmlFile.AddLine("<?xml version=\"1.0\" encoding=\"UTF-8\"?>");
XmlFile.AddLine("");
+ XmlFile.AddLine("<!-- Matroska chapter file -->");
+ XmlFile.AddLine("");
int lvl = 0;
+
+ XmlFile.AddLine("<Chapters>");
+ lvl++;
+ XmlFile.AddLine(IndentString(lvl)+"<EditionEntry>");
+ lvl++;
+ XmlFile.AddLine(IndentString(lvl)+"<EditionUID>"+CreateUID()+"</EditionUID>");
+ XmlFile.AddLine(IndentString(lvl)+"<EditionProcessed>1</EditionProcessed>"); // DVD style menu
+
+ // Write the first play PGC
+ if (IfoFile->FirstPlayPGC())
+ {
+ XmlFile.AddLine(IndentString(lvl)+"<!-- First Play PGC -->");
+ lvl++;
+ XmlFile.AddLine(IndentString(lvl)+"<ChapterAtom>");
+ lvl++;
+ wxString _myUID = CreateUID();
+ XmlFile.AddLine(IndentString(lvl)+"<ChapterUID>"+_myUID+"</ChapterUID>");
+// XmlFile.AddLine(IndentString(lvl)+"<ChapterTimeStart>00:00:00.000000000</ChapterTimeStart>");
+ // display the UID for the lazy rippers
+ XmlFile.AddLine(IndentString(lvl)+"<ChapterDisplay>");
+ lvl++;
+ XmlFile.AddLine(IndentString(lvl)+"<ChapterString>"+_myUID+"</ChapterString>");
+ lvl--;
+ XmlFile.AddLine(IndentString(lvl)+"</ChapterDisplay>");
+
+ XmlFile.AddLine(IndentString(lvl)+"<ChapterProcessPrivate>"+encodebase64(_PrivateFP,2)+"</ChapterProcessPrivate>");
+ // PGC pre-commands
+ if (IfoFile->FirstPlayPGC()->command_tbl && IfoFile->FirstPlayPGC()->command_tbl->nr_of_pre)
+ {
+ XmlFile.AddLine(IndentString(lvl)+"<ChapterProcess>");
+ lvl++;
+ XmlFile.AddLine(IndentString(lvl)+"<ChapProcessTime>1</ChapProcessTime>");
+ unsigned char *_buf= (unsigned char*) malloc(1+IfoFile->FirstPlayPGC()->command_tbl->nr_of_pre * 8);
+ _buf[0] = IfoFile->FirstPlayPGC()->command_tbl->nr_of_pre;
+ memcpy(&_buf[1], IfoFile->FirstPlayPGC()->command_tbl->pre_cmds, IfoFile->FirstPlayPGC()->command_tbl->nr_of_pre * 8);
+ XmlFile.AddLine(IndentString(lvl)+"<ChapProcessCommand>"+encodebase64(_buf,1+IfoFile->FirstPlayPGC()->command_tbl->nr_of_pre * 8)+"</ChapProcessCommand>");
+ free(_buf);
+ lvl--;
+ XmlFile.AddLine(IndentString(lvl)+"</ChapterProcess>");
+ }
+
+ lvl--;
+ XmlFile.AddLine(IndentString(lvl)+"</ChapterAtom>");
+ lvl--;
+ }
+
+ lvl--;
+ XmlFile.AddLine(IndentString(lvl)+"</EditionEntry>");
+ lvl--;
+ XmlFile.AddLine("</Chapters>");
+#if 0
XmlFile.AddLine(IndentString(lvl)+"<pages>");
for (node = CellsList->GetFirst(); node != NULL; node = node->GetNext() )
@@ -817,6 +880,7 @@
}
XmlFile.AddLine(IndentString(lvl)+"</pages>");
+#endif
XmlFile.Write();
}
Modified: trunk/DvdMenuXtractor/IFOFile.cpp
===================================================================
--- trunk/DvdMenuXtractor/IFOFile.cpp 2004-09-07 20:22:24 UTC (rev 750)
+++ trunk/DvdMenuXtractor/IFOFile.cpp 2004-09-07 20:24:40 UTC (rev 751)
@@ -94,6 +94,16 @@
// ----------------------------------------------------------------------------
+const pgc_t *IFOFile::FirstPlayPGC()
+{
+ if (m_ifo)
+ return m_ifo->first_play_pgc;
+ else
+ return NULL;
+}
+
+// ----------------------------------------------------------------------------
+
// declare a hash map with int keys and CellListElem* values
WX_DECLARE_HASH_MAP( int, CellListElem*, wxIntegerHash, wxIntegerEqual, CellsHashType );
#define MAKE_CELLS_KEY(__cell_elem__) ((__cell_elem__->vobid << 8) | __cell_elem__->cellid)
Modified: trunk/DvdMenuXtractor/IFOFile.h
===================================================================
--- trunk/DvdMenuXtractor/IFOFile.h 2004-09-07 20:22:24 UTC (rev 750)
+++ trunk/DvdMenuXtractor/IFOFile.h 2004-09-07 20:24:40 UTC (rev 751)
@@ -43,6 +43,7 @@
const CellsListType* GetCellsList();
bool IsACandidateCell(const unsigned int vobid, const unsigned int cellid);
virtual ~IFOFile();
+ const pgc_t *FirstPlayPGC();
private:
ifo_handle_t* m_ifo;
Added: trunk/DvdMenuXtractor/base64.cpp
===================================================================
--- trunk/DvdMenuXtractor/base64.cpp 2004-09-07 20:22:24 UTC (rev 750)
+++ trunk/DvdMenuXtractor/base64.cpp 2004-09-07 20:24:40 UTC (rev 751)
@@ -0,0 +1,44 @@
+#include "wx/wxprec.h"
+
+#include "base64.h"
+
+/*
+** Translation Table as described in RFC1113
+*/
+static const char cb64[]="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
+
+/*
+** Translation Table to decode (created by author)
+*/
+static const char cd64[]="|$$$}rstuvwxyz{$$$$$$$>?@ABCDEFGHIJKLMNOPQRSTUVW$$$$$$XYZ[\\]^_`abcdefghijklmnopq";
+
+/*
+** encodeblock
+**
+** encode 3 8-bit binary bytes as 4 '6-bit' characters
+*/
+static void encodeblock( const unsigned char in[3], unsigned char out[4], int len )
+{
+ out[0] = cb64[ in[0] >> 2 ];
+ out[1] = cb64[ ((in[0] & 0x03) << 4) | ((in[1] & 0xf0) >> 4) ];
+ out[2] = (unsigned char) (len > 1 ? cb64[ ((in[1] & 0x0f) << 2) | ((in[2] & 0xc0) >> 6) ] : '=');
+ out[3] = (unsigned char) (len > 2 ? cb64[ in[2] & 0x3f ] : '=');
+}
+
+wxString encodebase64(const unsigned char * buffer, unsigned int size)
+{
+ wxString result = "";
+ unsigned char _out[5];
+ unsigned int _len;
+ _out[4] = 0;
+
+ while (size)
+ {
+ _len = (size < 3)?size:3;
+ encodeblock(buffer, _out, _len);
+ size -= _len;
+ result += _out;
+ }
+
+ return result;
+}
Added: trunk/DvdMenuXtractor/base64.h
===================================================================
--- trunk/DvdMenuXtractor/base64.h 2004-09-07 20:22:24 UTC (rev 750)
+++ trunk/DvdMenuXtractor/base64.h 2004-09-07 20:24:40 UTC (rev 751)
@@ -0,0 +1,3 @@
+#include "wx/wx.h"
+
+wxString encodebase64(const unsigned char * buffer, unsigned int size);