diff options
author | XhmikosR <xhmikosr@users.sourceforge.net> | 2010-04-09 18:12:59 +0400 |
---|---|---|
committer | XhmikosR <xhmikosr@users.sourceforge.net> | 2010-04-09 18:12:59 +0400 |
commit | efbc9d9043ff8ff92716ddd00a5f61412d535593 (patch) | |
tree | 8f3e621f756cf1f5b4d64d97964c7e7abd8aaf08 /src/filters/parser/OggSplitter/OggFile.cpp | |
parent | df6b139a6d9027156f614b68687e039e3a5854db (diff) |
revert r1783
git-svn-id: https://mpc-hc.svn.sourceforge.net/svnroot/mpc-hc/trunk@1785 10f7b99b-c216-0410-bff0-8a66a9350fd8
Diffstat (limited to 'src/filters/parser/OggSplitter/OggFile.cpp')
-rw-r--r-- | src/filters/parser/OggSplitter/OggFile.cpp | 97 |
1 files changed, 46 insertions, 51 deletions
diff --git a/src/filters/parser/OggSplitter/OggFile.cpp b/src/filters/parser/OggSplitter/OggFile.cpp index 2bf8ffd25..e8a3a6d1f 100644 --- a/src/filters/parser/OggSplitter/OggFile.cpp +++ b/src/filters/parser/OggSplitter/OggFile.cpp @@ -2,81 +2,76 @@ #include "./oggfile.h"
COggFile::COggFile(IAsyncReader* pAsyncReader, HRESULT& hr)
- : CBaseSplitterFile(pAsyncReader, hr, DEFAULT_CACHE_LENGTH, false)
+ : CBaseSplitterFile(pAsyncReader, hr, DEFAULT_CACHE_LENGTH, false)
{
- if(FAILED(hr)) return;
- hr = Init();
+ if(FAILED(hr)) return;
+ hr = Init();
}
HRESULT COggFile::Init()
{
- Seek(0);
- if(!Sync()) return E_FAIL;
+ Seek(0);
+ if(!Sync()) return E_FAIL;
- return S_OK;
+ return S_OK;
}
bool COggFile::Sync(HANDLE hBreak)
{
- __int64 start = GetPos();
+ __int64 start = GetPos();
- DWORD dw;
- for(__int64 i = 0, j = hBreak ? GetLength() - start : 65536;
- i < j && S_OK == ByteRead((BYTE*)&dw, sizeof(dw))
- && ((i & 0xffff) || !hBreak || WaitForSingleObject(hBreak, 0) != WAIT_OBJECT_0);
- i++, Seek(start + i))
- {
- if(dw == 'SggO')
- {
- Seek(start + i);
- return(true);
- }
- }
+ DWORD dw;
+ for(__int64 i = 0, j = hBreak ? GetLength() - start : 65536;
+ i < j && S_OK == ByteRead((BYTE*)&dw, sizeof(dw))
+ && ((i&0xffff) || !hBreak || WaitForSingleObject(hBreak, 0) != WAIT_OBJECT_0);
+ i++, Seek(start + i))
+ {
+ if(dw == 'SggO')
+ {
+ Seek(start + i);
+ return(true);
+ }
+ }
- Seek(start);
+ Seek(start);
- return(false);
+ return(false);
}
bool COggFile::Read(OggPageHeader& hdr, HANDLE hBreak)
{
- return Sync(hBreak) && S_OK == ByteRead((BYTE*)&hdr, sizeof(hdr)) && hdr.capture_pattern == 'SggO';
+ return Sync(hBreak) && S_OK == ByteRead((BYTE*)&hdr, sizeof(hdr)) && hdr.capture_pattern == 'SggO';
}
bool COggFile::Read(OggPage& page, bool fFull, HANDLE hBreak)
{
- memset(&page.m_hdr, 0, sizeof(page.m_hdr));
- page.m_lens.RemoveAll();
- page.SetCount(0);
+ memset(&page.m_hdr, 0, sizeof(page.m_hdr));
+ page.m_lens.RemoveAll();
+ page.SetCount(0);
- if(!Read(page.m_hdr, hBreak))
- return(false);
+ if(!Read(page.m_hdr, hBreak))
+ return(false);
- int pagelen = 0, packetlen = 0;
- for(BYTE i = 0; i < page.m_hdr.number_page_segments; i++)
- {
- BYTE b;
+ int pagelen = 0, packetlen = 0;
+ for(BYTE i = 0; i < page.m_hdr.number_page_segments; i++)
+ {
+ BYTE b;
if(S_OK != ByteRead(&b, 1)) return(false);
- packetlen += b;
- if(1/*b < 0xff*/)
- {
- page.m_lens.AddTail(packetlen);
- pagelen += packetlen;
- packetlen = 0;
- }
- }
+ packetlen += b;
+ if(1/*b < 0xff*/) {page.m_lens.AddTail(packetlen); pagelen += packetlen; packetlen = 0;}
+ }
- if(fFull)
- {
- page.SetCount(pagelen);
- if(S_OK != ByteRead(page.GetData(), page.GetCount()))
- return(false);
- }
- else
- {
- Seek(GetPos() + pagelen);
- page.m_lens.RemoveAll();
- }
+ if(fFull)
+ {
+ page.SetCount(pagelen);
+ if(S_OK != ByteRead(page.GetData(), page.GetCount()))
+ return(false);
+ }
+ else
+ {
+ Seek(GetPos() + pagelen);
+ page.m_lens.RemoveAll();
+ }
- return(true);
+ return(true);
}
|