[matroska] r962 - trunk/DvdMenuXtractor
[email protected] Sun, 12 Dec 2004 00:26:11 +0300 (MSK)
Newsgroups
gmane.comp.multimedia.matroska.cvs
Message-ID
<[email protected] >
Author: robux4
Date: 2004-12-12 00:26:11 +0300 (Sun, 12 Dec 2004)
New Revision: 962
Modified:
trunk/DvdMenuXtractor/DvdMenuXtractor.cpp
trunk/DvdMenuXtractor/VobParser.cpp
trunk/DvdMenuXtractor/VobParser.h
Log:
timecode files are now handled in a logical order
Modified: trunk/DvdMenuXtractor/DvdMenuXtractor.cpp
===================================================================
--- trunk/DvdMenuXtractor/DvdMenuXtractor.cpp 2004-12-11 19:30:43 UTC (rev 961)
+++ trunk/DvdMenuXtractor/DvdMenuXtractor.cpp 2004-12-11 21:26:11 UTC (rev 962)
@@ -539,20 +539,15 @@
{
wxString newFilename;
wxString cellName;
- uint32_t cell = 0;
const CellsListType *CellsList = IfoFile->GetCellsList(title, language);
if (!CellsList)
return;
aVobParser.Reset();
-
+
try
{
- m_gaDemuxProgress->SetRange(CellsList->GetCount());
-
- CompositeDemuxWriter & demuxer = aVobParser.GetDemuxer();
-
const AudioTrackList & _audioTracks = IfoFile->AudioTracks(title, language);
const SubtitleTrackList & _subTracks = IfoFile->SubsTracks(title, language);
uint16_t _width, _height;
@@ -560,6 +555,11 @@
IfoFile->VideoSize(title, language, _width, _height, _fps);
const uint32_t * _palette = IfoFile->GetPalette(title, language);
+ uint32_t cell = 0;
+ CompositeDemuxWriter & demuxer = aVobParser.GetDemuxer();
+
+ m_gaDemuxProgress->SetRange(CellsList->GetCount());
+
if (title == 0)
newFilename = "VMG";
else
@@ -569,98 +569,90 @@
m_txtDemuxLog->AppendText("Processing " + newFilename + "\n");
- while(aVobParser.ParseNextPacket())
- {
- if(aVobParser.IsNewCell())
+ Demuxer * _muxer = new VideoDemuxWriter(outputDirectory + newFilename, _fps);
+ if (!demuxer.AddDemuxer(VIDEO_STREAM, _muxer))
+ delete _muxer;
+
+ int _stream;
+
+ // decide which audio streams to process
+ if (_audioTracks.GetCount())
+ {
+ for (_stream=0; _stream<_audioTracks.GetCount();_stream++)
{
- demuxer.SetBoundary();
- m_gaDemuxProgress->SetValue(cell);
- if(IfoFile->IsACandidateCell(aVobParser.GetVobID(),aVobParser.GetCellID()))
- {
- cellName = CellName(title, aVobParser.GetVobID(), aVobParser.GetCellID(), language);
+ wxString _langName;
+ audio_attr_t * _attr = _audioTracks.Item(_stream)->GetData();
- Demuxer * _muxer = new VideoDemuxWriter(outputDirectory + newFilename, _fps);
- if (!demuxer.AddDemuxer(VIDEO_STREAM, _muxer))
+ // get the possible ID for this track for this Cell/PGC
+ uint8_t _ID = IfoFile->GetAudioId(_stream, title, language);
+ if (_attr->lang_code == 0)
+ _langName = wxString::Format("_%d_un", _ID);
+ else
+ _langName = wxString::Format("_%d_%c%c", _ID, _attr->lang_code >> 8, _attr->lang_code & 0xFF);
+ switch (_audioTracks.Item(_stream)->GetData()->audio_format)
+ {
+ case 0:
+ _muxer = new AC3DemuxWriter(outputDirectory + newFilename+_langName, 0x80 + _ID);
+ if (!demuxer.AddDemuxer(SUBSTREAM_AC3_LOW + _ID, _muxer))
delete _muxer;
+ break;
- int _stream;
+ case 2:
+ case 3:
+ _muxer = new MPADemuxWriter(outputDirectory + newFilename+_langName, 0xC0 + _ID);
+ if (!demuxer.AddDemuxer(AUDIO_STREAM + _ID, _muxer))
+ delete _muxer;
+ break;
- // decide which audio streams to process
- if (_audioTracks.GetCount())
- {
- for (_stream=0; _stream<_audioTracks.GetCount();_stream++)
- {
- wxString _langName;
- audio_attr_t * _attr = _audioTracks.Item(_stream)->GetData();
+ case 4:
+ _muxer = new LPCMDemuxWriter(outputDirectory + newFilename+_langName, 0xA0 + _ID);
+ if (!demuxer.AddDemuxer(SUBSTREAM_PCM_LOW + _ID, _muxer))
+ delete _muxer;
+ break;
- // get the possible ID for this track for this Cell/PGC
- uint8_t _ID = IfoFile->GetAudioId(_stream, title, language);
- if (_attr->lang_code == 0)
- _langName = wxString::Format("_%d_un", _ID);
- else
- _langName = wxString::Format("_%d_%c%c", _ID, _attr->lang_code >> 8, _attr->lang_code & 0xFF);
- switch (_audioTracks.Item(_stream)->GetData()->audio_format)
- {
- case 0:
- _muxer = new AC3DemuxWriter(outputDirectory + newFilename+_langName, 0x80 + _ID);
- if (!demuxer.AddDemuxer(SUBSTREAM_AC3_LOW + _ID, _muxer))
- delete _muxer;
- break;
+ case 6:
+ _muxer = new DTSDemuxWriter(outputDirectory + newFilename+_langName, 0x88 + _ID);
+ if (!demuxer.AddDemuxer(SUBSTREAM_DTS_LOW + _ID, _muxer))
+ delete _muxer;
+ break;
- case 2:
- case 3:
- _muxer = new MPADemuxWriter(outputDirectory + newFilename+_langName, 0xC0 + _ID);
- if (!demuxer.AddDemuxer(AUDIO_STREAM + _ID, _muxer))
- delete _muxer;
- break;
+ default:
+ myfprintf(stderr, "Unknown audio format %d", _attr->audio_format);
+ break;
+ }
+ }
+ }
- case 4:
- _muxer = new LPCMDemuxWriter(outputDirectory + newFilename+_langName, 0xA0 + _ID);
- if (!demuxer.AddDemuxer(SUBSTREAM_PCM_LOW + _ID, _muxer))
- delete _muxer;
- break;
+ if (_subTracks.GetCount())
+ {
+ for (_stream=0; _stream<_subTracks.GetCount();_stream++)
+ {
+ // get the possible IDs for this track for this Cell/PGC
+ IdArray _IDs = IfoFile->GetSubsId(_stream, title, language);
+ for (int _IDidx=0; _IDidx < _IDs.GetCount(); _IDidx++)
+ {
+ wxString _langName;
- case 6:
- _muxer = new DTSDemuxWriter(outputDirectory + newFilename+_langName, 0x88 + _ID);
- if (!demuxer.AddDemuxer(SUBSTREAM_DTS_LOW + _ID, _muxer))
- delete _muxer;
- break;
+ subp_attr_t * _attr = _subTracks.Item(_stream)->GetData();
+ if (_attr->lang_code == 0)
+ _langName = wxString::Format("_%d_un", _IDs.Item(_IDidx));
+ else
+ _langName = wxString::Format("_%d_%c%c", _IDs.Item(_IDidx), _attr->lang_code >> 8, _attr->lang_code & 0xFF);
+ _muxer = new SubDemuxWriter(outputDirectory + newFilename+_langName, 0x20 + _IDs.Item(_IDidx), _width, _height, _palette, _attr->lang_code, _attr->lang_extension == 9);
+ if (!demuxer.AddDemuxer(SUBSTREAM_SUB_LOW + _IDs.Item(_IDidx), _muxer))
+ delete _muxer;
+ }
+ }
+ // create a possible button demuxer too
+ _muxer = new BtnDemuxWriter(outputDirectory + newFilename);
+ if (!demuxer.AddDemuxer(SUBSTREAM_PCI, _muxer))
+ delete _muxer;
+ }
- default:
- myfprintf(stderr, "Unknown audio format %d", _attr->audio_format);
- break;
- }
- }
- }
-
- if (_subTracks.GetCount())
- {
- for (_stream=0; _stream<_subTracks.GetCount();_stream++)
- {
- // get the possible IDs for this track for this Cell/PGC
- IdArray _IDs = IfoFile->GetSubsId(_stream, title, language);
- for (int _IDidx=0; _IDidx < _IDs.GetCount(); _IDidx++)
- {
- wxString _langName;
-
- subp_attr_t * _attr = _subTracks.Item(_stream)->GetData();
- if (_attr->lang_code == 0)
- _langName = wxString::Format("_%d_un", _IDs.Item(_IDidx));
- else
- _langName = wxString::Format("_%d_%c%c", _IDs.Item(_IDidx), _attr->lang_code >> 8, _attr->lang_code & 0xFF);
- _muxer = new SubDemuxWriter(outputDirectory + newFilename+_langName, 0x20 + _IDs.Item(_IDidx), _width, _height, _palette, _attr->lang_code, _attr->lang_extension == 9);
- if (!demuxer.AddDemuxer(SUBSTREAM_SUB_LOW + _IDs.Item(_IDidx), _muxer))
- delete _muxer;
- }
- }
- // create a possible button demuxer too
- _muxer = new BtnDemuxWriter(outputDirectory + newFilename);
- if (!demuxer.AddDemuxer(SUBSTREAM_PCI, _muxer))
- delete _muxer;
- }
- }
- }
- m_gaDemuxProgress->SetValue(aVobParser.GetPacketIndex());
+ while(aVobParser.ParseNextPacket(*IfoFile))
+ {
+// m_gaDemuxProgress->SetValue(cell);
+ m_gaDemuxProgress->SetValue(aVobParser.GetPacketIndex());
wxYield();
}
}
Modified: trunk/DvdMenuXtractor/VobParser.cpp
===================================================================
--- trunk/DvdMenuXtractor/VobParser.cpp 2004-12-11 19:30:43 UTC (rev 961)
+++ trunk/DvdMenuXtractor/VobParser.cpp 2004-12-11 21:26:11 UTC (rev 962)
@@ -103,13 +103,13 @@
}
}
-void CompositeDemuxWriter::SetBoundary()
+void CompositeDemuxWriter::SetBoundary(uint32_t end_timecode, uint16_t vob_id, uint16_t cell_id)
{
for (int i=0; i<256; i++)
{
if (m_muxers[i] != NULL)
{
- m_muxers[i]->SetBoundary();
+ m_muxers[i]->SetBoundary(end_timecode, vob_id, cell_id);
}
}
}
@@ -184,7 +184,7 @@
// ----------------------------------------------------------------------------
-bool VobParser::ParseNextPacket()
+bool VobParser::ParseNextPacket(IFOFile & IfoFile)
{
if(GetNextPacket())
{
@@ -238,6 +238,8 @@
SkipNBytes(_size);
}
}
+ if (IsNewCell())
+ m_demuxer.SetBoundary(0,GetVobID(), GetCellID());
}
else if ((_StreamID & VIDEO_STREAM) == VIDEO_STREAM)
{
@@ -403,17 +405,6 @@
void VobParser::ParseNavPacket()
{
- DebugLog("Private Stream 2 {\n");
- inc_lvl();
- ParsePrivateStream2();
- dec_lvl();
- DebugLog("}\n");
-}
-
-// ----------------------------------------------------------------------------
-
-void VobParser::ParsePrivateStream2()
-{
uint32_t endStreamIndex = 0;
uint16_t length = GetNext16Bits();
endStreamIndex = m_index + length;
@@ -438,7 +429,7 @@
DebugLog("}\n");
break;
default:
- DebugLog("ParsePrivateStream2: unknown substream id @LBA=%d\n", m_pktindex);
+ DebugLog("ParseNavPacket: unknown substream id @LBA=%d\n", m_pktindex);
}
m_index = endStreamIndex;
@@ -739,7 +730,7 @@
// ----------------------------------------------------------------------------
-void VobParser::BuildMap()
+void VobParser::BuildMap(IFOFile & IfoFile)
{
cell_info_node* cell;
ButtonListElem* ble;
@@ -747,7 +738,7 @@
m_map.Clear();
m_pci.btn_ns = 0;
- while(ParseNextPacket())
+ while(ParseNextPacket(IfoFile))
{
if(IsNewCell())
{
@@ -797,6 +788,13 @@
}
// ----------------------------------------------------------------------------
+
+uint32_t VobParser::GetCellSCR() const
+{
+ return m_dsi.nv_pck_scr;
+}
+
+// ----------------------------------------------------------------------------
const CellMap& VobParser::GetVobMap() const
{
@@ -867,7 +865,14 @@
void BtnDemuxWriter::WriteTimecodeInfo(int32_t delay, uint64_t filepos, wxString & debug)
{
m_TimecodeFile = GetTimecodeFile();
- bool sign = delay < 0;
+ if (m_prev_timecode < m_timecode)
+ {
+ // there was a gap
+ fprintf(m_TimecodeFile, "gap,%lf", 1000.0 * (m_timecode - m_prev_timecode));
+ m_prev_timecode = m_timecode;
+ }
+ m_timecode = delay;
+/* bool sign = delay < 0;
delay = sign?-delay:delay;
int millisecond = delay % 1000;
delay /= 1000;
@@ -876,7 +881,7 @@
int minute = delay % 60;
delay /= 60;
fprintf(m_TimecodeFile, "timestamp: %s%02d:%02d:%02d:%03d, filepos: %09x\n", sign?"-":"", delay,minute,second,millisecond,filepos);
-}
+*/}
void DTSDemuxWriter::WriteTimecodeInfo(int32_t delay, uint64_t filepos, wxString & debug)
{
@@ -950,30 +955,39 @@
// ============================================================================
-void VideoDemuxWriter::SetBoundary()
+void VideoDemuxWriter::SetBoundary(uint32_t end_timecode, uint16_t vob_id, uint16_t cell_id)
{
}
-void AC3DemuxWriter::SetBoundary()
+void AC3DemuxWriter::SetBoundary(uint32_t end_timecode, uint16_t vob_id, uint16_t cell_id)
{
}
-void DTSDemuxWriter::SetBoundary()
+void DTSDemuxWriter::SetBoundary(uint32_t end_timecode, uint16_t vob_id, uint16_t cell_id)
{
}
-void LPCMDemuxWriter::SetBoundary()
+void LPCMDemuxWriter::SetBoundary(uint32_t end_timecode, uint16_t vob_id, uint16_t cell_id)
{
}
-void MPADemuxWriter::SetBoundary()
+void MPADemuxWriter::SetBoundary(uint32_t end_timecode, uint16_t vob_id, uint16_t cell_id)
{
}
-void SubDemuxWriter::SetBoundary()
+void SubDemuxWriter::SetBoundary(uint32_t end_timecode, uint16_t vob_id, uint16_t cell_id)
{
}
-void BtnDemuxWriter::SetBoundary()
+void BtnDemuxWriter::SetBoundary(uint32_t end_timecode, uint16_t vob_id, uint16_t cell_id)
{
+ m_TimecodeFile = GetTimecodeFile();
+ if (m_prev_timecode < m_timecode)
+ {
+ // there was a gap
+ fprintf(m_TimecodeFile, "gap,%lf\n", 1000.0 * (m_timecode - m_prev_timecode));
+ m_prev_timecode = m_timecode;
+ }
+ fprintf(m_TimecodeFile, "# VOB %d Cell %d\n", vob_id, cell_id);
+ fprintf(m_TimecodeFile, "timecode %d\n", end_timecode);
}
Modified: trunk/DvdMenuXtractor/VobParser.h
===================================================================
--- trunk/DvdMenuXtractor/VobParser.h 2004-12-11 19:30:43 UTC (rev 961)
+++ trunk/DvdMenuXtractor/VobParser.h 2004-12-11 21:26:11 UTC (rev 962)
@@ -177,7 +177,7 @@
public:
virtual ~Demuxer() {}
virtual void ProcessStream(uint8_t* buff, uint32_t size, int32_t delay, wxString & debug) = 0;
- virtual void SetBoundary() = 0;
+ virtual void SetBoundary(uint32_t end_timecode, uint16_t vob_id, uint16_t cell_id) = 0;
};
// ----------------------------------------------------------------------------
@@ -251,7 +251,7 @@
public:
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();
+ void SetBoundary(uint32_t end_timecode, uint16_t vob_id, uint16_t cell_id);
protected:
void WriteTimecodeInfo(int32_t delay, uint64_t filepos, wxString & debug);
};
@@ -267,7 +267,7 @@
{
Write(buff,size, delay, debug);
}
- void SetBoundary();
+ void SetBoundary(uint32_t end_timecode, uint16_t vob_id, uint16_t cell_id);
private:
uint8_t m_streamID;
protected:
@@ -285,7 +285,7 @@
{
Write(buff,size, delay, debug);
}
- void SetBoundary();
+ void SetBoundary(uint32_t end_timecode, uint16_t vob_id, uint16_t cell_id);
private:
uint8_t m_streamID;
protected:
@@ -303,7 +303,7 @@
{
Write(buff,size, delay, debug);
}
- void SetBoundary();
+ void SetBoundary(uint32_t end_timecode, uint16_t vob_id, uint16_t cell_id);
private:
uint8_t m_streamID;
protected:
@@ -321,7 +321,7 @@
{
Write(buff,size, delay, debug);
}
- void SetBoundary();
+ void SetBoundary(uint32_t end_timecode, uint16_t vob_id, uint16_t cell_id);
private:
uint8_t m_streamID;
protected:
@@ -345,7 +345,7 @@
{
Write(buff,size, delay, debug);
}
- void SetBoundary();
+ void SetBoundary(uint32_t end_timecode, uint16_t vob_id, uint16_t cell_id);
protected:
void WriteTimecodeInfo(int32_t delay, uint64_t filepos, wxString & debug);
private:
@@ -363,14 +363,18 @@
public:
BtnDemuxWriter(const char* filenamePrefix)
:Writer(filenamePrefix, "btn",0.0)
+ ,m_timecode(0)
+ ,m_prev_timecode(0)
{}
void ProcessStream(uint8_t* buff, uint32_t size, int32_t delay, wxString & debug)
{
Write(buff,size, delay, debug);
}
- void SetBoundary();
+ void SetBoundary(uint32_t end_timecode, uint16_t vob_id, uint16_t cell_id);
protected:
void WriteTimecodeInfo(int32_t delay, uint64_t filepos, wxString & debug);
+ uint32_t m_timecode;
+ uint32_t m_prev_timecode;
};
// ----------------------------------------------------------------------------
@@ -383,7 +387,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();
+ void SetBoundary(uint32_t end_timecode, uint16_t vob_id, uint16_t cell_id);
protected:
Demuxer * m_muxers[256];
@@ -481,25 +485,28 @@
// Main class
// ============================================================================
-class VobParser
+class IFOFile;
+
+class VobParser
{
public:
VobParser(const char* dirname, int16_t title, bool language);
void Reset();
- bool ParseNextPacket();
+ bool ParseNextPacket(IFOFile & IfoFile);
uint32_t GetPacketCount() const;
uint32_t GetPacketIndex() const;
char* GetCurrentPacketData() const;
uint8_t GetVobID() const;
uint8_t GetCellID() const;
bool IsNewCell();
- void BuildMap();
+ void BuildMap(IFOFile & IfoFile);
const CellMap& GetVobMap() const;
virtual ~VobParser();
inline CompositeDemuxWriter & GetDemuxer()
{
return m_demuxer;
}
+ uint32_t GetCellSCR() const;
nav_dsi_gi m_dsi;
nav_pci_gi m_pci;
@@ -510,7 +517,6 @@
void ParseAudioPacket(uint8_t StreamID);
void ParseVideoPacket();
void ParsePrivateStream1();
- void ParsePrivateStream2();
void ParseSCR();
void ParsePCI();