[matroska] r966 - trunk/DvdMenuXtractor
[email protected] Sun, 12 Dec 2004 17:06:21 +0300 (MSK)
Newsgroups
gmane.comp.multimedia.matroska.cvs
Message-ID
<[email protected] >
Author: robux4
Date: 2004-12-12 17:06:21 +0300 (Sun, 12 Dec 2004)
New Revision: 966
Modified:
trunk/DvdMenuXtractor/VobParser.cpp
trunk/DvdMenuXtractor/VobParser.h
Log:
support timecode files for AC3, DTS and LPCM
Modified: trunk/DvdMenuXtractor/VobParser.cpp
===================================================================
--- trunk/DvdMenuXtractor/VobParser.cpp 2004-12-12 13:04:46 UTC (rev 965)
+++ trunk/DvdMenuXtractor/VobParser.cpp 2004-12-12 14:06:21 UTC (rev 966)
@@ -661,7 +661,7 @@
ParsePESHeaderData();
m_demuxer.ProcessStream(VIDEO_STREAM, &m_buff[m_index],
- length - 3 - pes_header_data_content.PES_header_data_len, pktinfo.pts/90, pktinfo.dts/90, wxString::Format("DTS %d PTS %d - %d %d\n", (int32_t)m_startdts/90, (int32_t)m_startpts/90, pktinfo.dts/90, pktinfo.pts/90));
+ length - 3 - pes_header_data_content.PES_header_data_len, pktinfo.pts/90, pktinfo.dts/90, wxString::Format("DTS %d PTS %d - %d %d\n", m_startdts/90, m_startpts/90, pktinfo.dts/90, pktinfo.pts/90));
}
void VobParser::ParseAudioPacket(uint8_t StreamID)
@@ -671,7 +671,7 @@
ParsePESHeaderData();
m_demuxer.ProcessStream(StreamID, &m_buff[m_index],
- length - 3 - pes_header_data_content.PES_header_data_len, pktinfo.pts/90, pktinfo.dts/90, wxString::Format("DTS %d PTS %d - %d %d\n", (int32_t)m_startdts/90, (int32_t)m_startpts/90, pktinfo.dts/90, pktinfo.pts/90));
+ length - 3 - pes_header_data_content.PES_header_data_len, pktinfo.pts/90, pktinfo.dts/90, wxString::Format("DTS %d PTS %d - %d %d\n", m_startdts/90, m_startpts/90, pktinfo.dts/90, pktinfo.pts/90));
}
// ----------------------------------------------------------------------------
@@ -685,16 +685,17 @@
ParsePESHeaderData();
uint8_t substreamID = GetNext8Bits();
+ 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;
if(substreamID >= SUBSTREAM_SUB_LOW && substreamID < SUBSTREAM_SUB_HIGH)
{
DebugLog("Subtitles streamID = 0x%X\n", substreamID);
// .sub files the VobSub way (includes the whole packet)
- m_demuxer.ProcessStream(substreamID, m_buff, DVD_VIDEO_LB_LEN, pktinfo.pts/90, pktinfo.dts/90, wxString::Format("DTS %d PTS %d - %d %d\n", (int32_t)m_startdts/90, (int32_t)m_startpts/90, pktinfo.dts/90, pktinfo.pts/90));
+ m_demuxer.ProcessStream(substreamID, m_buff, DVD_VIDEO_LB_LEN, pktinfo.pts/90, pktinfo.dts/90, wxString::Format("DTS %d PTS %d - %d %d\n", m_startdts/90, m_startpts/90, pktinfo.dts/90, pktinfo.pts/90));
}
else if(substreamID >= SUBSTREAM_AC3_LOW && substreamID < SUBSTREAM_AC3_HIGH)
{
-
DebugLog("AC3 streamID = 0x%X\n", substreamID);
// Skip frame header number
SkipNBytes(1);
@@ -702,7 +703,7 @@
SkipNBytes(2);
uint16_t ac3DataLen = length - (m_index - dataStartIndex);
- m_demuxer.ProcessStream(substreamID, &m_buff[m_index], ac3DataLen, pktinfo.pts/90, pktinfo.dts/90, wxString::Format("DTS %d PTS %d - %d %d\n", (int32_t)m_startdts/90, (int32_t)m_startpts/90, pktinfo.dts/90, pktinfo.pts/90));
+ m_demuxer.ProcessStream(substreamID, &m_buff[m_index], ac3DataLen, t3, t4, wxString::Format("DTS %d PTS %d - %d %d\n", m_startdts/90, m_startpts/90, pktinfo.dts/90, pktinfo.pts/90));
}
else if(substreamID >= SUBSTREAM_DTS_LOW && substreamID < SUBSTREAM_DTS_HIGH)
{
@@ -713,7 +714,7 @@
SkipNBytes(2);
uint16_t ac3DataLen = length - (m_index - dataStartIndex);
- m_demuxer.ProcessStream(substreamID, &m_buff[m_index], ac3DataLen, pktinfo.pts/90, pktinfo.dts/90, wxString::Format("DTS %d PTS %d - %d %d\n", (int32_t)m_startdts/90, (int32_t)m_startpts/90, pktinfo.dts/90, pktinfo.pts/90));
+ m_demuxer.ProcessStream(substreamID, &m_buff[m_index], ac3DataLen, t3, t4, wxString::Format("DTS %d PTS %d - %d %d\n", m_startdts/90, m_startpts/90, pktinfo.dts/90, pktinfo.pts/90));
}
else if(substreamID >= SUBSTREAM_PCM_LOW && substreamID < SUBSTREAM_PCM_HIGH)
{
@@ -722,7 +723,7 @@
SkipNBytes(6);
uint16_t ac3DataLen = length - (m_index - dataStartIndex);
- m_demuxer.ProcessStream(substreamID, &m_buff[m_index], ac3DataLen, pktinfo.pts/90, pktinfo.dts/90, wxString::Format("DTS %d PTS %d - %d %d\n", (int32_t)m_startdts/90, (int32_t)m_startpts/90, pktinfo.dts/90, pktinfo.pts/90));
+ m_demuxer.ProcessStream(substreamID, &m_buff[m_index], ac3DataLen, t3, t4, wxString::Format("DTS %d PTS %d - %d %d\n", m_startdts/90, m_startpts/90, pktinfo.dts/90, pktinfo.pts/90));
}
else
{
@@ -857,61 +858,42 @@
void DTSDemuxWriter::WriteTimecodeInfo(uint32_t start_time, uint32_t end_time, uint64_t filepos, wxString & debug)
{
m_TimecodeFile = GetTimecodeFile();
- int32_t delay = start_time - end_time;
- bool sign = delay < 0;
- delay = sign?-delay:delay;
- int millisecond = delay % 1000;
- delay /= 1000;
- int second = delay % 60;
- delay /= 60;
- int minute = delay % 60;
- delay /= 60;
- fprintf(m_TimecodeFile, "timestamp: %s%02d:%02d:%02d:%03d, filepos: %09x\n", sign?"-":"", delay,minute,second,millisecond,filepos);
+ 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 LPCMDemuxWriter::WriteTimecodeInfo(uint32_t start_time, uint32_t end_time, uint64_t filepos, wxString & debug)
{
m_TimecodeFile = GetTimecodeFile();
- int32_t delay = start_time - end_time;
- bool sign = delay < 0;
- delay = sign?-delay:delay;
- int millisecond = delay % 1000;
- delay /= 1000;
- int second = delay % 60;
- delay /= 60;
- int minute = delay % 60;
- delay /= 60;
- fprintf(m_TimecodeFile, "timestamp: %s%02d:%02d:%02d:%03d, filepos: %09x\n", sign?"-":"", delay,minute,second,millisecond,filepos);
+ 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 MPADemuxWriter::WriteTimecodeInfo(uint32_t start_time, uint32_t end_time, uint64_t filepos, wxString & debug)
{
m_TimecodeFile = GetTimecodeFile();
- int32_t delay = start_time - end_time;
- bool sign = delay < 0;
- delay = sign?-delay:delay;
- int millisecond = delay % 1000;
- delay /= 1000;
- int second = delay % 60;
- delay /= 60;
- 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 AC3DemuxWriter::WriteTimecodeInfo(uint32_t start_time, uint32_t end_time, uint64_t filepos, wxString & debug)
{
m_TimecodeFile = GetTimecodeFile();
- int32_t delay = start_time - end_time;
- bool sign = delay < 0;
- delay = sign?-delay:delay;
- int millisecond = delay % 1000;
- delay /= 1000;
- int second = delay % 60;
- delay /= 60;
- int minute = delay % 60;
- delay /= 60;
- fprintf(m_TimecodeFile, "timestamp: %s%02d:%02d:%02d:%03d, filepos: %09x\n", sign?"-":"", delay,minute,second,millisecond,filepos);
+ 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 VideoDemuxWriter::WriteTimecodeInfo(uint32_t start_time, uint32_t end_time, uint64_t filepos, wxString & debug)
@@ -936,14 +918,71 @@
void AC3DemuxWriter::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;
+
+ fprintf(m_TimecodeFile, "\n# VOB %d Cell %d\n", vob_id, cell_id);
}
void DTSDemuxWriter::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;
+
+ fprintf(m_TimecodeFile, "\n# VOB %d Cell %d\n", vob_id, cell_id);
}
void LPCMDemuxWriter::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;
+
+ fprintf(m_TimecodeFile, "\n# VOB %d Cell %d\n", vob_id, cell_id);
}
void MPADemuxWriter::SetBoundary(uint32_t start_timecode, uint32_t duration, uint16_t vob_id, uint16_t cell_id)
@@ -985,6 +1024,54 @@
fprintf(m_TimecodeFile, "%lf\n", (m_end_timecode - m_start_timecode) / 1000.0);
}
+AC3DemuxWriter::~AC3DemuxWriter()
+{
+ 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);
+ }
+}
+
+DTSDemuxWriter::~DTSDemuxWriter()
+{
+ 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);
+ }
+}
+
+LPCMDemuxWriter::~LPCMDemuxWriter()
+{
+ 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);
+ }
+}
+
BtnDemuxWriter::~BtnDemuxWriter()
{
m_TimecodeFile = GetTimecodeFile();
Modified: trunk/DvdMenuXtractor/VobParser.h
===================================================================
--- trunk/DvdMenuXtractor/VobParser.h 2004-12-12 13:04:46 UTC (rev 965)
+++ trunk/DvdMenuXtractor/VobParser.h 2004-12-12 14:06:21 UTC (rev 966)
@@ -269,8 +269,14 @@
class AC3DemuxWriter : public Demuxer, public Writer
{
public:
- AC3DemuxWriter(const char* filenamePrefix, const uint8_t streamID) :
- Writer(filenamePrefix,"ac3", 0.0), m_streamID(streamID) {}
+ AC3DemuxWriter(const char* filenamePrefix, const uint8_t streamID)
+ :Writer(filenamePrefix,"ac3", 0.0)
+ ,m_streamID(streamID)
+ ,m_end_timecode(0)
+ ,m_last_start_timecode(0)
+ ,m_last_end_timecode(0)
+ {}
+ ~AC3DemuxWriter();
void ProcessStream(uint8_t* buff, uint32_t size, uint32_t start_time, uint32_t end_time, wxString & debug)
{
Write(buff,size, start_time, end_time, debug);
@@ -280,6 +286,10 @@
uint8_t m_streamID;
protected:
void WriteTimecodeInfo(uint32_t start_time, uint32_t end_time, uint64_t filepos, wxString & debug);
+ uint32_t m_start_timecode;
+ uint32_t m_end_timecode;
+ uint32_t m_last_start_timecode;
+ uint32_t m_last_end_timecode;
};
// ----------------------------------------------------------------------------
@@ -287,8 +297,14 @@
class DTSDemuxWriter : public Demuxer, public Writer
{
public:
- DTSDemuxWriter(const char* filenamePrefix, const uint8_t streamID) :
- Writer(filenamePrefix,"dts",0.0), m_streamID(streamID) {}
+ DTSDemuxWriter(const char* filenamePrefix, const uint8_t streamID)
+ :Writer(filenamePrefix,"dts",0.0)
+ ,m_streamID(streamID)
+ ,m_end_timecode(0)
+ ,m_last_start_timecode(0)
+ ,m_last_end_timecode(0)
+ {}
+ ~DTSDemuxWriter();
void ProcessStream(uint8_t* buff, uint32_t size, uint32_t start_time, uint32_t end_time, wxString & debug)
{
Write(buff,size, start_time, end_time, debug);
@@ -298,6 +314,10 @@
uint8_t m_streamID;
protected:
void WriteTimecodeInfo(uint32_t start_time, uint32_t end_time, uint64_t filepos, wxString & debug);
+ uint32_t m_start_timecode;
+ uint32_t m_end_timecode;
+ uint32_t m_last_start_timecode;
+ uint32_t m_last_end_timecode;
};
// ----------------------------------------------------------------------------
@@ -305,8 +325,14 @@
class LPCMDemuxWriter : public Demuxer, public Writer
{
public:
- LPCMDemuxWriter(const char* filenamePrefix, const uint8_t streamID) :
- Writer(filenamePrefix,"pcm",0.0), m_streamID(streamID) {}
+ LPCMDemuxWriter(const char* filenamePrefix, const uint8_t streamID)
+ :Writer(filenamePrefix,"pcm",0.0)
+ ,m_streamID(streamID)
+ ,m_end_timecode(0)
+ ,m_last_start_timecode(0)
+ ,m_last_end_timecode(0)
+ {}
+ ~LPCMDemuxWriter();
void ProcessStream(uint8_t* buff, uint32_t size, uint32_t start_time, uint32_t end_time, wxString & debug)
{
Write(buff,size, start_time, end_time, debug);
@@ -316,6 +342,10 @@
uint8_t m_streamID;
protected:
void WriteTimecodeInfo(uint32_t start_time, uint32_t end_time, uint64_t filepos, wxString & debug);
+ uint32_t m_start_timecode;
+ uint32_t m_end_timecode;
+ uint32_t m_last_start_timecode;
+ uint32_t m_last_end_timecode;
};
// ----------------------------------------------------------------------------