diff options
author | Aleksoid <aleksoid@users.sourceforge.net> | 2011-06-06 09:02:35 +0400 |
---|---|---|
committer | Aleksoid <aleksoid@users.sourceforge.net> | 2011-06-06 09:02:35 +0400 |
commit | cdc7ca503cb52953aeca768b1ad5a0913601cfb8 (patch) | |
tree | 082313766292475704e6887e530b0b6be95851cc /src/filters/parser/MpegSplitter | |
parent | 8aea8e6baf92dbb997f5745a3b3c442fcf4c44e6 (diff) |
Fix : rev. 3180, crash on some TS file.
git-svn-id: https://mpc-hc.svn.sourceforge.net/svnroot/mpc-hc/trunk@3183 10f7b99b-c216-0410-bff0-8a66a9350fd8
Diffstat (limited to 'src/filters/parser/MpegSplitter')
-rw-r--r-- | src/filters/parser/MpegSplitter/MpegSplitter.cpp | 20 | ||||
-rw-r--r-- | src/filters/parser/MpegSplitter/MpegSplitterFile.cpp | 45 | ||||
-rw-r--r-- | src/filters/parser/MpegSplitter/MpegSplitterFile.h | 5 |
3 files changed, 30 insertions, 40 deletions
diff --git a/src/filters/parser/MpegSplitter/MpegSplitter.cpp b/src/filters/parser/MpegSplitter/MpegSplitter.cpp index 8576041cc..8d74777f1 100644 --- a/src/filters/parser/MpegSplitter/MpegSplitter.cpp +++ b/src/filters/parser/MpegSplitter/MpegSplitter.cpp @@ -672,9 +672,24 @@ HRESULT CMpegSplitterFilter::DemuxNextPacket(REFERENCE_TIME rtStartOffset) if(h.payload && h.payloadstart) {
m_pFile->UpdatePrograms(h);
+ } else {
+ if(CAtlMap<WORD, CMpegSplitterFile::program>::CPair* pPair = m_pFile->m_programs.Lookup(h.pid))
+ {
+ if(pPair->m_value.ts_len_cur > 0) {
+ int len = pPair->m_value.ts_len_packet - pPair->m_value.ts_len_cur;
+ if(len > h.bytes) {
+ m_pFile->ByteRead(pPair->m_value.ts_buffer + pPair->m_value.ts_len_cur, h.bytes);
+ pPair->m_value.ts_len_cur += h.bytes;
+ } else {
+ m_pFile->ByteRead(pPair->m_value.ts_buffer + pPair->m_value.ts_len_cur, pPair->m_value.ts_len_packet - pPair->m_value.ts_len_cur);
+ CGolombBuffer gb(pPair->m_value.ts_buffer, pPair->m_value.ts_len_packet);
+ m_pFile->UpdatePrograms(gb, h.pid);
+ }
+ }
+ }
}
- if(h.payload && h.pid >= 16 && h.pid < 0x1fff && !h.scrambling) {
+ if(h.payload && ISVALIDPID(h.pid)/* && !h.scrambling*/) {
DWORD TrackNumber = h.pid;
CMpegSplitterFile::peshdr h2;
@@ -699,9 +714,6 @@ HRESULT CMpegSplitterFilter::DemuxNextPacket(REFERENCE_TIME rtStartOffset) StreamTime(rtNow);
TRACE ("Now=%S PCR=%S\n", ReftimeToString(rtNow.m_time), ReftimeToString(h.PCR));
}
- if (h2.fpts && h.pid == 241) {
- TRACE ("Sub=%S\n", ReftimeToString(h2.pts - rtStartOffset));
- }
p->rtStart = h2.fpts ? (h2.pts - rtStartOffset) : Packet::INVALID_TIME;
p->rtStop = p->rtStart+1;
diff --git a/src/filters/parser/MpegSplitter/MpegSplitterFile.cpp b/src/filters/parser/MpegSplitter/MpegSplitterFile.cpp index 0414c1e02..50b609664 100644 --- a/src/filters/parser/MpegSplitter/MpegSplitterFile.cpp +++ b/src/filters/parser/MpegSplitter/MpegSplitterFile.cpp @@ -27,7 +27,6 @@ #include <moreuuids.h>
#define MEGABYTE 1024*1024
-#define ISVALIDPID(pid) (pid >= 0x10 && pid < 0x1fff)
CMpegSplitterFile::CMpegSplitterFile(IAsyncReader* pAsyncReader, HRESULT& hr, bool bIsHdmv, CHdmvClipInfo &ClipInfo, int guid_flag)
: CBaseSplitterFileEx(pAsyncReader, hr, DEFAULT_CACHE_LENGTH, false, true)
@@ -361,14 +360,15 @@ HRESULT CMpegSplitterFile::SearchStreams(__int64 start, __int64 stop, IAsyncRead if(CAtlMap<WORD, program>::CPair* pPair = m_programs.Lookup(h.pid))
{
if(pPair->m_value.ts_len_cur > 0) {
- ByteRead(pPair->m_value.ts_buffer + pPair->m_value.ts_len_cur, pPair->m_value.ts_len_packet - pPair->m_value.ts_len_cur);
- CGolombBuffer gb(pPair->m_value.ts_buffer, pPair->m_value.ts_len_packet);
- UpdatePrograms(gb, h.pid);
-#ifdef DEBUG
- HexDump(NULL, pPair->m_value.ts_buffer, pPair->m_value.ts_len_packet);
-#endif
- pPair->m_value.ts_len_cur = 0;
- pPair->m_value.ts_len_packet = 0;
+ int len = pPair->m_value.ts_len_packet - pPair->m_value.ts_len_cur;
+ if(len > h.bytes) {
+ ByteRead(pPair->m_value.ts_buffer + pPair->m_value.ts_len_cur, h.bytes);
+ pPair->m_value.ts_len_cur += h.bytes;
+ } else {
+ ByteRead(pPair->m_value.ts_buffer + pPair->m_value.ts_len_cur, pPair->m_value.ts_len_packet - pPair->m_value.ts_len_cur);
+ CGolombBuffer gb(pPair->m_value.ts_buffer, pPair->m_value.ts_len_packet);
+ UpdatePrograms(gb, h.pid);
+ }
}
}
}
@@ -464,28 +464,10 @@ DWORD CMpegSplitterFile::AddStream(WORD pid, BYTE pesid, DWORD len) }
}
- BYTE skip_pesid = m_skippid[pid];
-
stream s;
s.pid = pid;
s.pesid = pesid;
- if(m_type == ts) {
- if(!PMT_find)
- return 0;
-
- int iProgram;
- const CHdmvClipInfo::Stream *pClipInfo;
- const program* pProgram = FindProgram (s.pid, iProgram, pClipInfo);
- if(pProgram != NULL) {
- PES_STREAM_TYPE StreamType = INVALID;
- StreamType = pProgram->streams[iProgram].type;
- // Disable AAC latm stream support until make correct header parsing ...
- if(StreamType == AUDIO_STREAM_AAC_LATM)
- return 0;
- }
- }
-
int type = unknown;
if(pesid >= 0xe0 && pesid < 0xf0) { // mpeg video
@@ -779,7 +761,7 @@ void CMpegSplitterFile::UpdatePrograms(const trhdr& h) int len = h2.section_length;
len -= 5+4;
- BYTE buffer[256];
+ BYTE buffer[1024];
ByteRead(buffer, len);
CGolombBuffer gb(buffer, len);
@@ -793,11 +775,6 @@ void CMpegSplitterFile::UpdatePrograms(const trhdr& h) } else {
CGolombBuffer gb(buffer, len);
UpdatePrograms(gb, h.pid);
- pPair->m_value.ts_len_cur = 0;
-#ifdef DEBUG
- HexDump(NULL, buffer, len);
-#endif
-
}
}
}
@@ -884,6 +861,8 @@ void CMpegSplitterFile::UpdatePrograms(CGolombBuffer gb, WORD pid) }
}
PMT_find = true;
+ pPair->m_value.ts_len_cur = 0;
+ pPair->m_value.ts_len_packet = 0;
}
}
diff --git a/src/filters/parser/MpegSplitter/MpegSplitterFile.h b/src/filters/parser/MpegSplitter/MpegSplitterFile.h index 77643a871..f2ecee5af 100644 --- a/src/filters/parser/MpegSplitter/MpegSplitterFile.h +++ b/src/filters/parser/MpegSplitter/MpegSplitterFile.h @@ -29,6 +29,7 @@ #define NO_SUBTITLE_PID 1 // Fake PID use for the "No subtitle" entry
#define NO_SUBTITLE_NAME _T("No subtitle")
+#define ISVALIDPID(pid) (pid >= 0x10 && pid < 0x1fff)
class CMpegSplitterFile : public CBaseSplitterFileEx
{
@@ -36,8 +37,6 @@ class CMpegSplitterFile : public CBaseSplitterFileEx CAtlMap<WORD, CMpegSplitterFile::avchdr> avch;
bool m_bIsHdmv;
- CAtlMap<WORD, BYTE> m_skippid;
-
HRESULT Init(IAsyncReader* pAsyncReader);
void OnComplete(IAsyncReader* pAsyncReader);
@@ -135,7 +134,7 @@ public: memset(this, 0, sizeof(*this));
}
- BYTE ts_buffer[512];
+ BYTE ts_buffer[1024];
WORD ts_len_cur, ts_len_packet;
};
|