diff options
author | Aleksoid <aleksoid@users.sourceforge.net> | 2011-06-08 00:59:56 +0400 |
---|---|---|
committer | Aleksoid <aleksoid@users.sourceforge.net> | 2011-06-08 00:59:56 +0400 |
commit | 86bb3bd522a787154aa94e9825c45ff870ba3fcb (patch) | |
tree | f0c8db72911fbc806f2dbf55a8ff1fd1fda335df /src/filters/parser/MpegSplitter | |
parent | aa0534f704e490fd099b73b0569103edddffde9b (diff) |
Code rewrite.
git-svn-id: https://mpc-hc.svn.sourceforge.net/svnroot/mpc-hc/trunk@3196 10f7b99b-c216-0410-bff0-8a66a9350fd8
Diffstat (limited to 'src/filters/parser/MpegSplitter')
-rw-r--r-- | src/filters/parser/MpegSplitter/MpegSplitter.cpp | 19 | ||||
-rw-r--r-- | src/filters/parser/MpegSplitter/MpegSplitterFile.cpp | 69 |
2 files changed, 34 insertions, 54 deletions
diff --git a/src/filters/parser/MpegSplitter/MpegSplitter.cpp b/src/filters/parser/MpegSplitter/MpegSplitter.cpp index 8d74777f1..328eb02e0 100644 --- a/src/filters/parser/MpegSplitter/MpegSplitter.cpp +++ b/src/filters/parser/MpegSplitter/MpegSplitter.cpp @@ -670,24 +670,7 @@ HRESULT CMpegSplitterFilter::DemuxNextPacket(REFERENCE_TIME rtStartOffset) __int64 pos = m_pFile->GetPos();
- 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);
- }
- }
- }
- }
+ m_pFile->UpdatePrograms(h);
if(h.payload && ISVALIDPID(h.pid)/* && !h.scrambling*/) {
DWORD TrackNumber = h.pid;
diff --git a/src/filters/parser/MpegSplitter/MpegSplitterFile.cpp b/src/filters/parser/MpegSplitter/MpegSplitterFile.cpp index 680ab6494..38d2dae1a 100644 --- a/src/filters/parser/MpegSplitter/MpegSplitterFile.cpp +++ b/src/filters/parser/MpegSplitter/MpegSplitterFile.cpp @@ -354,24 +354,7 @@ HRESULT CMpegSplitterFile::SearchStreams(__int64 start, __int64 stop, IAsyncRead __int64 pos = GetPos();
- if(h.payload && h.payloadstart) {
- UpdatePrograms(h);
- } else {
- if(CAtlMap<WORD, program>::CPair* pPair = 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) {
- 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);
- }
- }
- }
- }
+ UpdatePrograms(h);
if(h.payload && ISVALIDPID(h.pid)) {
peshdr h2;
@@ -735,7 +718,7 @@ void CMpegSplitterFile::UpdatePrograms(const trhdr& h) {
CAutoLock cAutoLock(&m_csProps);
- if(h.pid == 0) {
+ if(h.payload && h.payloadstart && h.pid == 0) {
trsechdr h2;
if(Read(h2) && h2.table_id == 0) {
CAtlMap<WORD, bool> newprograms;
@@ -764,25 +747,39 @@ void CMpegSplitterFile::UpdatePrograms(const trhdr& h) }
}
} else if(CAtlMap<WORD, program>::CPair* pPair = m_programs.Lookup(h.pid)) {
- trsechdr h2;
- if(Read(h2) && h2.table_id == 2) {
- int len = h2.section_length;
- len -= 5+4;
-
- BYTE buffer[1024];
- ByteRead(buffer, len);
- CGolombBuffer gb(buffer, len);
+ if(h.payload && h.payloadstart) {
+ trsechdr h2;
+ if(Read(h2) && h2.table_id == 2) {
+ int len = h2.section_length;
+ len -= 5+4;
+
+ BYTE buffer[1024];
+ ByteRead(buffer, len);
+ CGolombBuffer gb(buffer, len);
- int max_len = h.bytes - 9;
+ int max_len = h.bytes - 9;
- if(len > max_len) {
- memset(pPair->m_value.ts_buffer, 0, sizeof(pPair->m_value.ts_buffer));
- pPair->m_value.ts_len_cur = max_len;
- pPair->m_value.ts_len_packet = len;
- memcpy(pPair->m_value.ts_buffer, buffer, max_len);
- } else {
- CGolombBuffer gb(buffer, len);
- UpdatePrograms(gb, h.pid);
+ if(len > max_len) {
+ memset(pPair->m_value.ts_buffer, 0, sizeof(pPair->m_value.ts_buffer));
+ pPair->m_value.ts_len_cur = max_len;
+ pPair->m_value.ts_len_packet = len;
+ memcpy(pPair->m_value.ts_buffer, buffer, max_len);
+ } else {
+ CGolombBuffer gb(buffer, len);
+ UpdatePrograms(gb, h.pid);
+ }
+ }
+ } else {
+ 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) {
+ 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);
+ }
}
}
}
|