[matroska] r961 - trunk/DvdMenuXtractor
[email protected] Sat, 11 Dec 2004 22:30:44 +0300 (MSK)
Newsgroups
gmane.comp.multimedia.matroska.cvs
Message-ID
<[email protected] >
Author: robux4
Date: 2004-12-11 22:30:43 +0300 (Sat, 11 Dec 2004)
New Revision: 961
Modified:
trunk/DvdMenuXtractor/DvdMenuXtractor.cpp
trunk/DvdMenuXtractor/IFOFile.cpp
trunk/DvdMenuXtractor/IFOFile.h
trunk/DvdMenuXtractor/VobParser.cpp
trunk/DvdMenuXtractor/VobParser.h
Log:
more work on the timecode file
Modified: trunk/DvdMenuXtractor/DvdMenuXtractor.cpp
===================================================================
--- trunk/DvdMenuXtractor/DvdMenuXtractor.cpp 2004-12-11 16:04:55 UTC (rev 960)
+++ trunk/DvdMenuXtractor/DvdMenuXtractor.cpp 2004-12-11 19:30:43 UTC (rev 961)
@@ -65,7 +65,7 @@
IFOFile* IfoFile = NULL;
wxLogWindow* wxLogWin;
wxString outputDirectory;
-const wxString APPLICATION_NAME = "DVDMenu-X-tractor";
+const wxString APPLICATION_NAME = "DVDMenuXtractor: DMX - a fair-use tool";
// ----------------------------------------------------------------------------
@@ -556,7 +556,8 @@
const AudioTrackList & _audioTracks = IfoFile->AudioTracks(title, language);
const SubtitleTrackList & _subTracks = IfoFile->SubsTracks(title, language);
uint16_t _width, _height;
- IfoFile->VideoSize(title, language, _width, _height);
+ double _fps;
+ IfoFile->VideoSize(title, language, _width, _height, _fps);
const uint32_t * _palette = IfoFile->GetPalette(title, language);
if (title == 0)
@@ -572,12 +573,13 @@
{
if(aVobParser.IsNewCell())
{
+ demuxer.SetBoundary();
m_gaDemuxProgress->SetValue(cell);
if(IfoFile->IsACandidateCell(aVobParser.GetVobID(),aVobParser.GetCellID()))
{
cellName = CellName(title, aVobParser.GetVobID(), aVobParser.GetCellID(), language);
- Demuxer * _muxer = new VideoDemuxWriter(outputDirectory + newFilename);
+ Demuxer * _muxer = new VideoDemuxWriter(outputDirectory + newFilename, _fps);
if (!demuxer.AddDemuxer(VIDEO_STREAM, _muxer))
delete _muxer;
Modified: trunk/DvdMenuXtractor/IFOFile.cpp
===================================================================
--- trunk/DvdMenuXtractor/IFOFile.cpp 2004-12-11 16:04:55 UTC (rev 960)
+++ trunk/DvdMenuXtractor/IFOFile.cpp 2004-12-11 19:30:43 UTC (rev 961)
@@ -341,7 +341,7 @@
return _ifo->m_Subs;
}
-bool IFOFile::VideoSize(unsigned int title, bool language, uint16_t & width, uint16_t & height) const
+bool IFOFile::VideoSize(unsigned int title, bool language, uint16_t & width, uint16_t & height, double & fps) const
{
IfoContent *_ifo = m_ifos.GetIfoTitle(title);
assert(_ifo != NULL);
@@ -374,8 +374,12 @@
if (_attr != NULL)
{
height = 480;
- if(_attr->video_format != 0)
+ if(_attr->video_format != 0) {
+ fps = 25.0;
height = 576;
+ } else {
+ fps = 30000.0/1001.0;
+ }
switch(_attr->picture_size) {
case 0:
width = 720;
Modified: trunk/DvdMenuXtractor/IFOFile.h
===================================================================
--- trunk/DvdMenuXtractor/IFOFile.h 2004-12-11 16:04:55 UTC (rev 960)
+++ trunk/DvdMenuXtractor/IFOFile.h 2004-12-11 19:30:43 UTC (rev 961)
@@ -91,7 +91,7 @@
const int16_t NumberOfTitles() const;
const AudioTrackList & AudioTracks(unsigned int title, bool language) const;
const SubtitleTrackList & SubsTracks(unsigned int title, bool language) const;
- bool VideoSize(unsigned int title, bool language, uint16_t & width, uint16_t & height) const;
+ bool VideoSize(unsigned int title, bool language, uint16_t & width, uint16_t & height, double & fps) const;
const uint32_t * GetPalette(unsigned int title, bool language) const;
uint8_t GetAudioId(uint8_t streamID, uint8_t title, bool language) const;
Modified: trunk/DvdMenuXtractor/VobParser.cpp
===================================================================
--- trunk/DvdMenuXtractor/VobParser.cpp 2004-12-11 16:04:55 UTC (rev 960)
+++ trunk/DvdMenuXtractor/VobParser.cpp 2004-12-11 19:30:43 UTC (rev 961)
@@ -102,8 +102,18 @@
}
}
}
-
+void CompositeDemuxWriter::SetBoundary()
+{
+ for (int i=0; i<256; i++)
+ {
+ if (m_muxers[i] != NULL)
+ {
+ m_muxers[i]->SetBoundary();
+ }
+ }
+}
+
// ----------------------------------------------------------------------------
VobParser::VobParser(const char* dirname, int16_t title, bool language)
@@ -856,14 +866,7 @@
void BtnDemuxWriter::WriteTimecodeInfo(int32_t delay, uint64_t filepos, wxString & debug)
{
- if (!m_TimecodeFile)
- {
- wxString m_filename = m_Filename;
- m_filename += "_btn.tmc";
- m_TimecodeFile = fopen(m_filename.c_str(),"w");
- fwrite("# timecode format v3\n", 1, 21, m_TimecodeFile);
- fprintf(m_TimecodeFile, "assume %lf\n", 0.0);
- }
+ m_TimecodeFile = GetTimecodeFile();
bool sign = delay < 0;
delay = sign?-delay:delay;
int millisecond = delay % 1000;
@@ -877,14 +880,7 @@
void DTSDemuxWriter::WriteTimecodeInfo(int32_t delay, uint64_t filepos, wxString & debug)
{
- if (!m_TimecodeFile)
- {
- wxString m_filename = m_Filename;
- m_filename += "_dts.tmc";
- m_TimecodeFile = fopen(m_filename.c_str(),"w");
- fwrite("# timecode format v3\n", 1, 21, m_TimecodeFile);
- fprintf(m_TimecodeFile, "assume %lf\n", 0.0);
- }
+ m_TimecodeFile = GetTimecodeFile();
bool sign = delay < 0;
delay = sign?-delay:delay;
int millisecond = delay % 1000;
@@ -898,14 +894,7 @@
void LPCMDemuxWriter::WriteTimecodeInfo(int32_t delay, uint64_t filepos, wxString & debug)
{
- if (!m_TimecodeFile)
- {
- wxString m_filename = m_Filename;
- m_filename += "_lpmc.tmc";
- m_TimecodeFile = fopen(m_filename.c_str(),"w");
- fwrite("# timecode format v3\n", 1, 21, m_TimecodeFile);
- fprintf(m_TimecodeFile, "assume %lf\n", 0.0);
- }
+ m_TimecodeFile = GetTimecodeFile();
bool sign = delay < 0;
delay = sign?-delay:delay;
int millisecond = delay % 1000;
@@ -919,14 +908,7 @@
void MPADemuxWriter::WriteTimecodeInfo(int32_t delay, uint64_t filepos, wxString & debug)
{
- if (!m_TimecodeFile)
- {
- wxString m_filename = m_Filename;
- m_filename += "_mpa.tmc";
- m_TimecodeFile = fopen(m_filename.c_str(),"w");
- fwrite("# timecode format v3\n", 1, 21, m_TimecodeFile);
- fprintf(m_TimecodeFile, "assume %lf\n", 0.0);
- }
+ m_TimecodeFile = GetTimecodeFile();
bool sign = delay < 0;
delay = sign?-delay:delay;
int millisecond = delay % 1000;
@@ -940,14 +922,7 @@
void AC3DemuxWriter::WriteTimecodeInfo(int32_t delay, uint64_t filepos, wxString & debug)
{
- if (!m_TimecodeFile)
- {
- wxString m_filename = m_Filename;
- m_filename += "_ac3.tmc";
- m_TimecodeFile = fopen(m_filename.c_str(),"w");
- fwrite("# timecode format v3\n", 1, 21, m_TimecodeFile);
- fprintf(m_TimecodeFile, "assume %lf\n", 0.0);
- }
+ m_TimecodeFile = GetTimecodeFile();
bool sign = delay < 0;
delay = sign?-delay:delay;
int millisecond = delay % 1000;
@@ -961,14 +936,7 @@
void VideoDemuxWriter::WriteTimecodeInfo(int32_t delay, uint64_t filepos, wxString & debug)
{
- if (!m_TimecodeFile)
- {
- wxString m_filename = m_Filename;
- m_filename += "_vid.tmc";
- m_TimecodeFile = fopen(m_filename.c_str(),"w");
- fwrite("# timecode format v3\n", 1, 21, m_TimecodeFile);
- fprintf(m_TimecodeFile, "assume %lf\n", 0.0);
- }
+ m_TimecodeFile = GetTimecodeFile();
bool sign = delay < 0;
delay = sign?-delay:delay;
int millisecond = delay % 1000;
@@ -982,3 +950,30 @@
// ============================================================================
+void VideoDemuxWriter::SetBoundary()
+{
+}
+
+void AC3DemuxWriter::SetBoundary()
+{
+}
+
+void DTSDemuxWriter::SetBoundary()
+{
+}
+
+void LPCMDemuxWriter::SetBoundary()
+{
+}
+
+void MPADemuxWriter::SetBoundary()
+{
+}
+
+void SubDemuxWriter::SetBoundary()
+{
+}
+
+void BtnDemuxWriter::SetBoundary()
+{
+}
Modified: trunk/DvdMenuXtractor/VobParser.h
===================================================================
--- trunk/DvdMenuXtractor/VobParser.h 2004-12-11 16:04:55 UTC (rev 960)
+++ trunk/DvdMenuXtractor/VobParser.h 2004-12-11 19:30:43 UTC (rev 961)
@@ -177,6 +177,7 @@
public:
virtual ~Demuxer() {}
virtual void ProcessStream(uint8_t* buff, uint32_t size, int32_t delay, wxString & debug) = 0;
+ virtual void SetBoundary() = 0;
};
// ----------------------------------------------------------------------------
@@ -184,9 +185,10 @@
class Writer
{
public:
- Writer(const char* filenamePrefix, const char* extension)
+ Writer(const char* filenamePrefix, const char* extension, double fps)
:m_file(NULL)
,m_TimecodeFile(NULL)
+ ,m_fps(fps)
{
m_Filename = filenamePrefix;
m_fileExtension = extension;
@@ -207,8 +209,8 @@
if(!m_file)
{
wxString m_filename = m_Filename;
- if (delay != 0)
- m_filename += wxString::Format("_%dms",delay);
+// if (delay != 0)
+// m_filename += wxString::Format("_%dms",delay);
m_filename += ".";
m_filename += m_fileExtension;
m_file = fopen(m_filename.c_str(),"wb");
@@ -217,22 +219,29 @@
fwrite(buff, 1, size, m_file);
}
protected:
- wxString m_Filename;
- wxString m_fileExtension;
- FILE* m_file;
- FILE* m_TimecodeFile;
-
- virtual void WriteTimecodeInfo(int32_t delay, uint64_t filepos, wxString & debug)
+ inline FILE* GetTimecodeFile()
{
if (!m_TimecodeFile)
{
wxString m_filename = m_Filename;
- m_filename += "_time.txt";
+ m_filename += "_";
+ m_filename += m_fileExtension;
+ m_filename += ".tmc";
m_TimecodeFile = fopen(m_filename.c_str(),"w");
- fwrite("# Debug file\n", 1, 13, m_TimecodeFile);
+ fwrite("# timecode format v3\n", 1, 21, m_TimecodeFile);
+ fprintf(m_TimecodeFile, "assume %lf\n", m_fps);
}
- fwrite(debug.c_str(), 1, debug.length(), m_TimecodeFile);
+ return m_TimecodeFile;
}
+
+
+ wxString m_Filename;
+ wxString m_fileExtension;
+ FILE* m_file;
+ FILE* m_TimecodeFile;
+ double m_fps;
+
+ virtual void WriteTimecodeInfo(int32_t delay, uint64_t filepos, wxString & debug) = 0;
};
// ----------------------------------------------------------------------------
@@ -240,8 +249,9 @@
class VideoDemuxWriter : public Demuxer, public Writer
{
public:
- VideoDemuxWriter(const char* filenamePrefix) : Writer(filenamePrefix,"m2v") {}
+ VideoDemuxWriter(const char* filenamePrefix, double fps) : Writer(filenamePrefix,"m2v", fps) {}
void ProcessStream(uint8_t* buff, uint32_t size, int32_t delay, wxString & debug) { Write(buff, size, delay, debug); }
+ void SetBoundary();
protected:
void WriteTimecodeInfo(int32_t delay, uint64_t filepos, wxString & debug);
};
@@ -252,11 +262,12 @@
{
public:
AC3DemuxWriter(const char* filenamePrefix, const uint8_t streamID) :
- Writer(filenamePrefix,"ac3"), m_streamID(streamID) {}
+ Writer(filenamePrefix,"ac3", 0.0), m_streamID(streamID) {}
void ProcessStream(uint8_t* buff, uint32_t size, int32_t delay, wxString & debug)
{
Write(buff,size, delay, debug);
}
+ void SetBoundary();
private:
uint8_t m_streamID;
protected:
@@ -269,11 +280,12 @@
{
public:
DTSDemuxWriter(const char* filenamePrefix, const uint8_t streamID) :
- Writer(filenamePrefix,"dts"), m_streamID(streamID) {}
+ Writer(filenamePrefix,"dts",0.0), m_streamID(streamID) {}
void ProcessStream(uint8_t* buff, uint32_t size, int32_t delay, wxString & debug)
{
Write(buff,size, delay, debug);
}
+ void SetBoundary();
private:
uint8_t m_streamID;
protected:
@@ -286,11 +298,12 @@
{
public:
LPCMDemuxWriter(const char* filenamePrefix, const uint8_t streamID) :
- Writer(filenamePrefix,"pcm"), m_streamID(streamID) {}
+ Writer(filenamePrefix,"pcm",0.0), m_streamID(streamID) {}
void ProcessStream(uint8_t* buff, uint32_t size, int32_t delay, wxString & debug)
{
Write(buff,size, delay, debug);
}
+ void SetBoundary();
private:
uint8_t m_streamID;
protected:
@@ -303,11 +316,12 @@
{
public:
MPADemuxWriter(const char* filenamePrefix, const uint8_t streamID) :
- Writer(filenamePrefix,"mpa"), m_streamID(streamID) {}
+ Writer(filenamePrefix,"mpa",0.0), m_streamID(streamID) {}
void ProcessStream(uint8_t* buff, uint32_t size, int32_t delay, wxString & debug)
{
Write(buff,size, delay, debug);
}
+ void SetBoundary();
private:
uint8_t m_streamID;
protected:
@@ -320,7 +334,7 @@
{
public:
SubDemuxWriter(const char* filenamePrefix, const uint8_t streamID, uint16_t width, uint16_t height, const uint32_t * palette, uint16_t language, bool forced)
- :Writer(filenamePrefix, "sub")
+ :Writer(filenamePrefix, "sub",0.0)
,m_width(width)
,m_height(height)
,m_forced(forced)
@@ -331,6 +345,7 @@
{
Write(buff,size, delay, debug);
}
+ void SetBoundary();
protected:
void WriteTimecodeInfo(int32_t delay, uint64_t filepos, wxString & debug);
private:
@@ -347,12 +362,13 @@
{
public:
BtnDemuxWriter(const char* filenamePrefix)
- :Writer(filenamePrefix, "btn")
+ :Writer(filenamePrefix, "btn",0.0)
{}
void ProcessStream(uint8_t* buff, uint32_t size, int32_t delay, wxString & debug)
{
Write(buff,size, delay, debug);
}
+ void SetBoundary();
protected:
void WriteTimecodeInfo(int32_t delay, uint64_t filepos, wxString & debug);
};
@@ -367,6 +383,7 @@
bool AddDemuxer(uint8_t streamID, Demuxer * demuxer);
void ProcessStream(uint8_t streamID, uint8_t* buff, uint32_t size, int32_t delay, wxString & debug);
void Reset();
+ void SetBoundary();
protected:
Demuxer * m_muxers[256];