Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mpc-hc/mpc-hc.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorXhmikosR <xhmikosr@users.sourceforge.net>2010-12-17 19:42:55 +0300
committerXhmikosR <xhmikosr@users.sourceforge.net>2010-12-17 19:42:55 +0300
commit7359bd509afa235acc2ac2f7f95fc9cb5cafd1a4 (patch)
treeb5bb90eeca58fdeb9fde6825f21a25a319823cb4 /src/filters/parser/OggSplitter/OggSplitter.cpp
parentd30b15ed4b98c28951d6d45b8928f4c2b6a11129 (diff)
apply astyle formatting
git-svn-id: https://mpc-hc.svn.sourceforge.net/svnroot/mpc-hc/trunk@2786 10f7b99b-c216-0410-bff0-8a66a9350fd8
Diffstat (limited to 'src/filters/parser/OggSplitter/OggSplitter.cpp')
-rw-r--r--src/filters/parser/OggSplitter/OggSplitter.cpp634
1 files changed, 317 insertions, 317 deletions
diff --git a/src/filters/parser/OggSplitter/OggSplitter.cpp b/src/filters/parser/OggSplitter/OggSplitter.cpp
index fa348c31f..7a341b12b 100644
--- a/src/filters/parser/OggSplitter/OggSplitter.cpp
+++ b/src/filters/parser/OggSplitter/OggSplitter.cpp
@@ -1,4 +1,4 @@
-/*
+/*
* Copyright (C) 2003-2006 Gabest
* http://www.gabest.org
*
@@ -6,12 +6,12 @@
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2, or (at your option)
* any later version.
- *
+ *
* This Program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
- *
+ *
* You should have received a copy of the GNU General Public License
* along with GNU Make; see the file COPYING. If not, write to
* the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
@@ -38,25 +38,21 @@
#ifdef REGISTER_FILTER
-const AMOVIESETUP_MEDIATYPE sudPinTypesIn[] =
-{
+const AMOVIESETUP_MEDIATYPE sudPinTypesIn[] = {
{&MEDIATYPE_Stream, &MEDIASUBTYPE_NULL},
};
-const AMOVIESETUP_PIN sudpPins[] =
-{
- {L"Input", FALSE, FALSE, FALSE, FALSE, &CLSID_NULL, NULL, countof(sudPinTypesIn), sudPinTypesIn},
- {L"Output", FALSE, TRUE, FALSE, FALSE, &CLSID_NULL, NULL, 0, NULL}
+const AMOVIESETUP_PIN sudpPins[] = {
+ {L"Input", FALSE, FALSE, FALSE, FALSE, &CLSID_NULL, NULL, countof(sudPinTypesIn), sudPinTypesIn},
+ {L"Output", FALSE, TRUE, FALSE, FALSE, &CLSID_NULL, NULL, 0, NULL}
};
-const AMOVIESETUP_FILTER sudFilter[] =
-{
+const AMOVIESETUP_FILTER sudFilter[] = {
{&__uuidof(COggSplitterFilter), L"MPC - Ogg Splitter", MERIT_NORMAL+1, countof(sudpPins), sudpPins, CLSID_LegacyAmFilterCategory},
{&__uuidof(COggSourceFilter), L"MPC - Ogg Source", MERIT_NORMAL+1, 0, NULL, CLSID_LegacyAmFilterCategory},
};
-CFactoryTemplate g_Templates[] =
-{
+CFactoryTemplate g_Templates[] = {
{sudFilter[0].strName, sudFilter[0].clsID, CreateInstance<COggSplitterFilter>, NULL, &sudFilter[0]},
{sudFilter[1].strName, sudFilter[1].clsID, CreateInstance<COggSourceFilter>, NULL, &sudFilter[1]},
};
@@ -66,8 +62,8 @@ int g_cTemplates = countof(g_Templates);
STDAPI DllRegisterServer()
{
RegisterSourceFilter(
- CLSID_AsyncReader,
- MEDIASUBTYPE_Ogg,
+ CLSID_AsyncReader,
+ MEDIASUBTYPE_Ogg,
_T("0,4,,4F676753"), // OggS
_T(".ogg"), _T(".ogm"), NULL);
@@ -96,35 +92,42 @@ class bitstream
BYTE* m_p;
int m_len, m_pos;
public:
- bitstream(BYTE* p, int len, bool rev = false) : m_p(p), m_len(len*8) {m_pos = !rev ? 0 : len*8;}
- bool hasbits(int cnt)
- {
+ bitstream(BYTE* p, int len, bool rev = false) : m_p(p), m_len(len*8) {
+ m_pos = !rev ? 0 : len*8;
+ }
+ bool hasbits(int cnt) {
int pos = m_pos+cnt;
return(pos >= 0 && pos < m_len);
}
- unsigned int showbits(int cnt) // a bit unclean, but works and can read backwards too! :P
- {
- if(!hasbits(cnt)) {ASSERT(0); return 0;}
+ unsigned int showbits(int cnt) { // a bit unclean, but works and can read backwards too! :P
+ if(!hasbits(cnt)) {
+ ASSERT(0);
+ return 0;
+ }
unsigned int ret = 0, off = 0;
BYTE* p = m_p;
- if(cnt < 0)
- {
+ if(cnt < 0) {
p += (m_pos+cnt)>>3;
off = (m_pos+cnt)&7;
cnt = abs(cnt);
- ret = (*p++&(~0<<off))>>off; off = 8 - off; cnt -= off;
- }
- else
- {
+ ret = (*p++&(~0<<off))>>off;
+ off = 8 - off;
+ cnt -= off;
+ } else {
p += m_pos>>3;
off = m_pos&7;
- ret = (*p++>>off)&((1<<min(cnt,8))-1); off = 0; cnt -= 8 - off;
+ ret = (*p++>>off)&((1<<min(cnt,8))-1);
+ off = 0;
+ cnt -= 8 - off;
+ }
+ while(cnt > 0) {
+ ret |= (*p++&((1<<min(cnt,8))-1)) << off;
+ off += 8;
+ cnt -= 8;
}
- while(cnt > 0) {ret |= (*p++&((1<<min(cnt,8))-1)) << off; off += 8; cnt -= 8;}
return ret;
}
- unsigned int getbits(int cnt)
- {
+ unsigned int getbits(int cnt) {
unsigned int ret = showbits(cnt);
m_pos += cnt;
return ret;
@@ -153,8 +156,13 @@ HRESULT COggSplitterFilter::CreateOutputs(IAsyncReader* pAsyncReader)
m_pFile.Free();
m_pFile.Attach(DNew COggFile(pAsyncReader, hr));
- if(!m_pFile) return E_OUTOFMEMORY;
- if(FAILED(hr)) {m_pFile.Free(); return hr;}
+ if(!m_pFile) {
+ return E_OUTOFMEMORY;
+ }
+ if(FAILED(hr)) {
+ m_pFile.Free();
+ return hr;
+ }
m_rtNewStart = m_rtCurrent = 0;
m_rtNewStop = m_rtStop = 0;
@@ -163,12 +171,10 @@ HRESULT COggSplitterFilter::CreateOutputs(IAsyncReader* pAsyncReader)
m_pFile->Seek(0);
OggPage page;
- for(int i = 0, nWaitForMore = 0; m_pFile->Read(page); i++)
- {
+ for(int i = 0, nWaitForMore = 0; m_pFile->Read(page); i++) {
BYTE* p = page.GetData();
- if(!(page.m_hdr.header_type_flag & OggPageHeader::continued))
- {
+ if(!(page.m_hdr.header_type_flag & OggPageHeader::continued)) {
BYTE type = *p++;
CStringW name;
@@ -176,110 +182,90 @@ HRESULT COggSplitterFilter::CreateOutputs(IAsyncReader* pAsyncReader)
HRESULT hr;
- if(type >= 0x80 && type <= 0x82 && !memcmp(p, "theora", 6))
- {
- if(type == 0x80)
- {
+ if(type >= 0x80 && type <= 0x82 && !memcmp(p, "theora", 6)) {
+ if(type == 0x80) {
name.Format(L"Theora %d", i);
CAutoPtr<CBaseSplitterOutputPin> pPinOut;
pPinOut.Attach(DNew COggTheoraOutputPin(page.GetData(), name, this, this, &hr));
AddOutputPin(page.m_hdr.bitstream_serial_number, pPinOut);
nWaitForMore++;
}
- }
- else if(type == 1 && (page.m_hdr.header_type_flag & OggPageHeader::first))
- {
+ } else if(type == 1 && (page.m_hdr.header_type_flag & OggPageHeader::first)) {
CAutoPtr<CBaseSplitterOutputPin> pPinOut;
- if(!memcmp(p, "vorbis", 6))
- {
+ if(!memcmp(p, "vorbis", 6)) {
name.Format(L"Vorbis %d", i);
pPinOut.Attach(DNew COggVorbisOutputPin((OggVorbisIdHeader*)(p+6), name, this, this, &hr));
nWaitForMore++;
- }
- else if(!memcmp(p, "video", 5))
- {
+ } else if(!memcmp(p, "video", 5)) {
name.Format(L"Video %d", i);
pPinOut.Attach(DNew COggVideoOutputPin((OggStreamHeader*)p, name, this, this, &hr));
- }
- else if(!memcmp(p, "audio", 5))
- {
+ } else if(!memcmp(p, "audio", 5)) {
name.Format(L"Audio %d", i);
pPinOut.Attach(DNew COggAudioOutputPin((OggStreamHeader*)p, name, this, this, &hr));
- }
- else if(!memcmp(p, "text", 4))
- {
+ } else if(!memcmp(p, "text", 4)) {
name.Format(L"Text %d", i);
pPinOut.Attach(DNew COggTextOutputPin((OggStreamHeader*)p, name, this, this, &hr));
- }
- else if(!memcmp(p, "Direct Show Samples embedded in Ogg", 35))
- {
+ } else if(!memcmp(p, "Direct Show Samples embedded in Ogg", 35)) {
name.Format(L"DirectShow %d", i);
pPinOut.Attach(DNew COggDirectShowOutputPin((AM_MEDIA_TYPE*)(p+35+sizeof(GUID)), name, this, this, &hr));
}
AddOutputPin(page.m_hdr.bitstream_serial_number, pPinOut);
- }
- else if(type == 3 && !memcmp(p, "vorbis", 6))
- {
- if(COggSplitterOutputPin* pOggPin =
- dynamic_cast<COggSplitterOutputPin*>(GetOutputPin(page.m_hdr.bitstream_serial_number)))
- {
+ } else if(type == 3 && !memcmp(p, "vorbis", 6)) {
+ if(COggSplitterOutputPin* pOggPin =
+ dynamic_cast<COggSplitterOutputPin*>(GetOutputPin(page.m_hdr.bitstream_serial_number))) {
pOggPin->AddComment(p+6, page.GetCount()-6-1);
}
- }
- else if(type == 0x7F && page.GetCount()>12 && *(long*)(p+8) == 0x43614C66) // Flac
- {
+ } else if(type == 0x7F && page.GetCount()>12 && *(long*)(p+8) == 0x43614C66) { // Flac
// Ogg Flac : method 1
CAutoPtr<CBaseSplitterOutputPin> pPinOut;
name.Format(L"Flac %d", i);
pPinOut.Attach(DNew COggFlacOutputPin(p+12, page.GetCount()-14, name, this, this, &hr));
AddOutputPin(page.m_hdr.bitstream_serial_number, pPinOut);
- }
- else if (*(long*)(p-1) == 0x43614C66)
- {
+ } else if (*(long*)(p-1) == 0x43614C66) {
//bFlac = true;
//nWaitForMore++;
- if (m_pFile->Read(page))
- {
+ if (m_pFile->Read(page)) {
CAutoPtr<CBaseSplitterOutputPin> pPinOut;
name.Format(L"Flac %d", i);
p = page.GetData();
pPinOut.Attach(DNew COggFlacOutputPin(p, page.GetCount(), name, this, this, &hr));
AddOutputPin(page.m_hdr.bitstream_serial_number, pPinOut);
}
- }
- else if(!(type&1) && nWaitForMore == 0)
- {
+ } else if(!(type&1) && nWaitForMore == 0) {
break;
}
}
- if(COggTheoraOutputPin* p = dynamic_cast<COggTheoraOutputPin*>(GetOutputPin(page.m_hdr.bitstream_serial_number)))
- {
+ if(COggTheoraOutputPin* p = dynamic_cast<COggTheoraOutputPin*>(GetOutputPin(page.m_hdr.bitstream_serial_number))) {
p->UnpackInitPage(page);
- if(p->IsInitialized()) nWaitForMore--;
+ if(p->IsInitialized()) {
+ nWaitForMore--;
+ }
}
- if(COggVorbisOutputPin* p = dynamic_cast<COggVorbisOutputPin*>(GetOutputPin(page.m_hdr.bitstream_serial_number)))
- {
+ if(COggVorbisOutputPin* p = dynamic_cast<COggVorbisOutputPin*>(GetOutputPin(page.m_hdr.bitstream_serial_number))) {
p->UnpackInitPage(page);
- if(p->IsInitialized()) nWaitForMore--;
+ if(p->IsInitialized()) {
+ nWaitForMore--;
+ }
}
}
- if(m_pOutputs.IsEmpty())
+ if(m_pOutputs.IsEmpty()) {
return E_FAIL;
+ }
- if(m_pFile->IsRandomAccess())
- {
+ if(m_pFile->IsRandomAccess()) {
m_pFile->Seek(max(m_pFile->GetLength()-65536, 0));
OggPage page;
- while(m_pFile->Read(page))
- {
+ while(m_pFile->Read(page)) {
COggSplitterOutputPin* pOggPin = dynamic_cast<COggSplitterOutputPin*>(GetOutputPin(page.m_hdr.bitstream_serial_number));
- if(!pOggPin || page.m_hdr.granule_position == -1) continue;
+ if(!pOggPin || page.m_hdr.granule_position == -1) {
+ continue;
+ }
REFERENCE_TIME rt = pOggPin->GetRefTime(page.m_hdr.granule_position);
m_rtDuration = max(rt, m_rtDuration);
}
@@ -298,20 +284,19 @@ HRESULT COggSplitterFilter::CreateOutputs(IAsyncReader* pAsyncReader)
tagmap[L"DESCRIPTION"] = L"DESC";
POSITION pos2 = tagmap.GetStartPosition();
- while(pos2)
- {
+ while(pos2) {
CStringW oggtag, dsmtag;
tagmap.GetNextAssoc(pos2, oggtag, dsmtag);
POSITION pos = m_pOutputs.GetHeadPosition();
- while(pos)
- {
+ while(pos) {
COggSplitterOutputPin* pOggPin = dynamic_cast<COggSplitterOutputPin*>((CBaseOutputPin*)m_pOutputs.GetNext(pos));
- if(!pOggPin) continue;
+ if(!pOggPin) {
+ continue;
+ }
CStringW value = pOggPin->GetComment(oggtag);
- if(!value.IsEmpty())
- {
+ if(!value.IsEmpty()) {
SetProperty(dsmtag, value);
break;
}
@@ -319,23 +304,29 @@ HRESULT COggSplitterFilter::CreateOutputs(IAsyncReader* pAsyncReader)
}
POSITION pos = m_pOutputs.GetHeadPosition();
- while(pos && !ChapGetCount())
- {
+ while(pos && !ChapGetCount()) {
COggSplitterOutputPin* pOggPin = dynamic_cast<COggSplitterOutputPin*>((CBaseOutputPin*)m_pOutputs.GetNext(pos));
- if(!pOggPin) continue;
+ if(!pOggPin) {
+ continue;
+ }
- for(int i = 1; pOggPin; i++)
- {
- CStringW key;
+ for(int i = 1; pOggPin; i++) {
+ CStringW key;
key.Format(L"CHAPTER%02d", i);
CStringW time = pOggPin->GetComment(key);
- if(time.IsEmpty()) break;
+ if(time.IsEmpty()) {
+ break;
+ }
key.Format(L"CHAPTER%02dNAME", i);
CStringW name = pOggPin->GetComment(key);
- if(name.IsEmpty()) name.Format(L"Chapter %d", i);
+ if(name.IsEmpty()) {
+ name.Format(L"Chapter %d", i);
+ }
int h, m, s, ms;
WCHAR c;
- if(7 != swscanf(time, L"%d%c%d%c%d%c%d", &h, &c, &m, &c, &s, &c, &ms)) break;
+ if(7 != swscanf(time, L"%d%c%d%c%d%c%d", &h, &c, &m, &c, &s, &c, &ms)) {
+ break;
+ }
REFERENCE_TIME rt = ((((REFERENCE_TIME)h*60+m)*60+s)*1000+ms)*10000;
ChapAppend(rt, name);
}
@@ -348,19 +339,18 @@ HRESULT COggSplitterFilter::CreateOutputs(IAsyncReader* pAsyncReader)
bool COggSplitterFilter::DemuxInit()
{
SetThreadName((DWORD)-1, "COggSplitterFilter");
- if(!m_pFile) return(false);
+ if(!m_pFile) {
+ return(false);
+ }
return(true);
}
void COggSplitterFilter::DemuxSeek(REFERENCE_TIME rt)
{
- if(rt <= 0 )
- {
+ if(rt <= 0 ) {
m_pFile->Seek(0);
- }
- else if(m_rtDuration > 0)
- {
+ } else if(m_rtDuration > 0) {
// oh, the horror...
__int64 len = m_pFile->GetLength();
@@ -369,19 +359,22 @@ void COggSplitterFilter::DemuxSeek(REFERENCE_TIME rt)
REFERENCE_TIME rtMinDiff = _I64_MAX;
- while(1)
- {
+ while(1) {
__int64 endpos = startpos;
REFERENCE_TIME rtPos = -1;
OggPage page;
m_pFile->Seek(startpos);
- while(m_pFile->Read(page, false))
- {
- if(page.m_hdr.granule_position == -1) continue;
+ while(m_pFile->Read(page, false)) {
+ if(page.m_hdr.granule_position == -1) {
+ continue;
+ }
COggSplitterOutputPin* pOggPin = dynamic_cast<COggSplitterOutputPin*>(GetOutputPin(page.m_hdr.bitstream_serial_number));
- if(!pOggPin) {ASSERT(0); continue;}
+ if(!pOggPin) {
+ ASSERT(0);
+ continue;
+ }
rtPos = pOggPin->GetRefTime(page.m_hdr.granule_position);
endpos = m_pFile->GetPos();
@@ -391,12 +384,10 @@ void COggSplitterFilter::DemuxSeek(REFERENCE_TIME rt)
__int64 rtDiff = rtPos - rt;
- if(rtDiff < 0)
- {
+ if(rtDiff < 0) {
rtDiff = -rtDiff;
- if(rtDiff < 1000000 || rtDiff >= rtMinDiff)
- {
+ if(rtDiff < 1000000 || rtDiff >= rtMinDiff) {
m_pFile->Seek(startpos);
break;
}
@@ -406,23 +397,20 @@ void COggSplitterFilter::DemuxSeek(REFERENCE_TIME rt)
__int64 newpos = startpos;
- if(rtPos < rt && rtPos < m_rtDuration)
- {
+ if(rtPos < rt && rtPos < m_rtDuration) {
newpos = startpos + (__int64)((1.0*(rt - rtPos)/(m_rtDuration - rtPos)) * (len - startpos)) + 1024;
- if(newpos < endpos) newpos = endpos + 1024;
- }
- else if(rtPos > rt && rtPos > 0)
- {
+ if(newpos < endpos) {
+ newpos = endpos + 1024;
+ }
+ } else if(rtPos > rt && rtPos > 0) {
newpos = startpos - (__int64)((1.0*(rtPos - rt)/(rtPos - 0)) * (startpos - 0)) - 1024;
- if(newpos >= startpos) newpos = startpos - 1024;
- }
- else if(rtPos == rt)
- {
+ if(newpos >= startpos) {
+ newpos = startpos - 1024;
+ }
+ } else if(rtPos == rt) {
m_pFile->Seek(startpos);
break;
- }
- else
- {
+ } else {
ASSERT(0);
m_pFile->Seek(0);
break;
@@ -436,55 +424,51 @@ void COggSplitterFilter::DemuxSeek(REFERENCE_TIME rt)
m_pFile->Seek(startpos);
POSITION pos = m_pOutputs.GetHeadPosition();
- while(pos)
- {
+ while(pos) {
COggSplitterOutputPin* pPin = dynamic_cast<COggSplitterOutputPin*>(static_cast<CBaseSplitterOutputPin*>(m_pOutputs.GetNext(pos)));
- if(!dynamic_cast<COggVideoOutputPin*>(pPin) && !dynamic_cast<COggTheoraOutputPin*>(pPin))
+ if(!dynamic_cast<COggVideoOutputPin*>(pPin) && !dynamic_cast<COggTheoraOutputPin*>(pPin)) {
continue;
+ }
bool fKeyFrameFound = false, fSkipKeyFrame = true;
__int64 endpos = _I64_MAX;
- while(!(fKeyFrameFound && !fSkipKeyFrame) && startpos > 0)
- {
+ while(!(fKeyFrameFound && !fSkipKeyFrame) && startpos > 0) {
OggPage page;
- while(!(fKeyFrameFound && !fSkipKeyFrame) && m_pFile->GetPos() < endpos && m_pFile->Read(page))
- {
- if(page.m_hdr.granule_position == -1)
+ while(!(fKeyFrameFound && !fSkipKeyFrame) && m_pFile->GetPos() < endpos && m_pFile->Read(page)) {
+ if(page.m_hdr.granule_position == -1) {
continue;
+ }
- if(pPin != dynamic_cast<COggSplitterOutputPin*>(GetOutputPin(page.m_hdr.bitstream_serial_number)))
+ if(pPin != dynamic_cast<COggSplitterOutputPin*>(GetOutputPin(page.m_hdr.bitstream_serial_number))) {
continue;
+ }
- if(pPin->GetRefTime(page.m_hdr.granule_position) > rt)
+ if(pPin->GetRefTime(page.m_hdr.granule_position) > rt) {
break;
+ }
- if(!fKeyFrameFound)
- {
+ if(!fKeyFrameFound) {
pPin->UnpackPage(page);
CAutoPtr<OggPacket> p;
- while(p = pPin->GetPacket())
- {
- if(p->bSyncPoint)
- {
+ while(p = pPin->GetPacket()) {
+ if(p->bSyncPoint) {
fKeyFrameFound = true;
fSkipKeyFrame = p->fSkip;
}
}
- if(fKeyFrameFound) break;
- }
- else
- {
+ if(fKeyFrameFound) {
+ break;
+ }
+ } else {
pPin->UnpackPage(page);
CAutoPtr<OggPacket> p;
- while(p = pPin->GetPacket())
- {
- if(!p->fSkip)
- {
+ while(p = pPin->GetPacket()) {
+ if(!p->fSkip) {
fSkipKeyFrame = false;
break;
}
@@ -492,7 +476,10 @@ void COggSplitterFilter::DemuxSeek(REFERENCE_TIME rt)
}
}
- if(!(fKeyFrameFound && !fSkipKeyFrame)) {endpos = startpos; startpos = max(startpos - 10*65536, 0);}
+ if(!(fKeyFrameFound && !fSkipKeyFrame)) {
+ endpos = startpos;
+ startpos = max(startpos - 10*65536, 0);
+ }
m_pFile->Seek(startpos);
}
@@ -504,24 +491,25 @@ void COggSplitterFilter::DemuxSeek(REFERENCE_TIME rt)
fKeyFrameFound = false;
OggPage page;
- while(!fKeyFrameFound && m_pFile->Read(page))
- {
- if(page.m_hdr.granule_position == -1) continue;
+ while(!fKeyFrameFound && m_pFile->Read(page)) {
+ if(page.m_hdr.granule_position == -1) {
+ continue;
+ }
- if(pPin != dynamic_cast<COggSplitterOutputPin*>(GetOutputPin(page.m_hdr.bitstream_serial_number)))
+ if(pPin != dynamic_cast<COggSplitterOutputPin*>(GetOutputPin(page.m_hdr.bitstream_serial_number))) {
continue;
+ }
REFERENCE_TIME rtPos = pPin->GetRefTime(page.m_hdr.granule_position);
- if(rtPos > rt)
+ if(rtPos > rt) {
break;
+ }
pPin->UnpackPage(page);
CAutoPtr<OggPacket> p;
- while(p = pPin->GetPacket())
- {
- if(p->bSyncPoint)
- {
+ while(p = pPin->GetPacket()) {
+ if(p->bSyncPoint) {
fKeyFrameFound = true;
break;
}
@@ -543,17 +531,24 @@ bool COggSplitterFilter::DemuxLoop()
HRESULT hr = S_OK;
OggPage page;
- while(SUCCEEDED(hr) && !CheckRequest(NULL) && m_pFile->Read(page, true, GetRequestHandle()))
- {
+ while(SUCCEEDED(hr) && !CheckRequest(NULL) && m_pFile->Read(page, true, GetRequestHandle())) {
COggSplitterOutputPin* pOggPin = dynamic_cast<COggSplitterOutputPin*>(GetOutputPin(page.m_hdr.bitstream_serial_number));
- if(!pOggPin) {ASSERT(0); continue;}
- if(!pOggPin->IsConnected()) continue;
- if(FAILED(hr = pOggPin->UnpackPage(page))) {ASSERT(0); break;}
+ if(!pOggPin) {
+ ASSERT(0);
+ continue;
+ }
+ if(!pOggPin->IsConnected()) {
+ continue;
+ }
+ if(FAILED(hr = pOggPin->UnpackPage(page))) {
+ ASSERT(0);
+ break;
+ }
CAutoPtr<OggPacket> p;
- while(!CheckRequest(NULL) && SUCCEEDED(hr) && (p = pOggPin->GetPacket()))
- {
- if(!p->fSkip)
+ while(!CheckRequest(NULL) && SUCCEEDED(hr) && (p = pOggPin->GetPacket())) {
+ if(!p->fSkip) {
hr = DeliverPacket(p);
+ }
}
}
@@ -585,34 +580,27 @@ void COggSplitterOutputPin::AddComment(BYTE* p, int len)
{
bitstream bs(p, len);
bs.getbits(bs.getbits(32)*8);
- for(int n = bs.getbits(32); n-- > 0; )
- {
+ for(int n = bs.getbits(32); n-- > 0; ) {
CStringA str;
- for(int len = bs.getbits(32); len-- > 0; )
+ for(int len = bs.getbits(32); len-- > 0; ) {
str += (CHAR)bs.getbits(8);
+ }
CAtlList<CStringA> sl;
Explode(str, sl, '=', 2);
- if(sl.GetCount() == 2)
- {
+ if(sl.GetCount() == 2) {
CAutoPtr<CComment> p(DNew CComment(UTF8To16(sl.GetHead()), UTF8To16(sl.GetTail())));
- if(p->m_key == L"LANGUAGE")
- {
+ if(p->m_key == L"LANGUAGE") {
CString lang = ISO6392ToLanguage(sl.GetTail()), iso6392 = LanguageToISO6392(CString(p->m_value));
- if(p->m_value.GetLength() == 3 && !lang.IsEmpty())
- {
+ if(p->m_value.GetLength() == 3 && !lang.IsEmpty()) {
SetName(CStringW(lang));
SetProperty(L"LANG", p->m_value);
- }
- else if(!iso6392.IsEmpty())
- {
+ } else if(!iso6392.IsEmpty()) {
SetName(p->m_value);
SetProperty(L"LANG", CStringW(iso6392));
- }
- else
- {
+ } else {
SetName(p->m_value);
SetProperty(L"NAME", p->m_value);
}
@@ -629,10 +617,11 @@ CStringW COggSplitterOutputPin::GetComment(CStringW key)
key.MakeUpper();
CAtlList<CStringW> sl;
POSITION pos = m_pComments.GetHeadPosition();
- while(pos)
- {
+ while(pos) {
CComment* p = m_pComments.GetNext(pos);
- if(key == p->m_key) sl.AddTail(p->m_value);
+ if(key == p->m_key) {
+ sl.AddTail(p->m_value);
+ }
}
return Implode(sl, ';');
}
@@ -649,87 +638,88 @@ void COggSplitterOutputPin::ResetState(DWORD seqnum)
HRESULT COggSplitterOutputPin::UnpackPage(OggPage& page)
{
- if(m_lastseqnum != page.m_hdr.page_sequence_number-1)
- {
+ if(m_lastseqnum != page.m_hdr.page_sequence_number-1) {
ResetState(page.m_hdr.page_sequence_number);
return S_FALSE; // FIXME
- }
- else
- {
+ } else {
m_lastseqnum = page.m_hdr.page_sequence_number;
}
POSITION first = page.m_lens.GetHeadPosition();
- while(first && page.m_lens.GetAt(first) == 255) page.m_lens.GetNext(first);
- if(!first) first = page.m_lens.GetTailPosition();
+ while(first && page.m_lens.GetAt(first) == 255) {
+ page.m_lens.GetNext(first);
+ }
+ if(!first) {
+ first = page.m_lens.GetTailPosition();
+ }
POSITION last = page.m_lens.GetTailPosition();
- while(last && page.m_lens.GetAt(last) == 255) page.m_lens.GetPrev(last);
- if(!last) last = page.m_lens.GetTailPosition();
+ while(last && page.m_lens.GetAt(last) == 255) {
+ page.m_lens.GetPrev(last);
+ }
+ if(!last) {
+ last = page.m_lens.GetTailPosition();
+ }
BYTE* pData = page.GetData();
int i = 0, j = 0, len = 0;
- for(POSITION pos = page.m_lens.GetHeadPosition(); pos; page.m_lens.GetNext(pos))
- {
+ for(POSITION pos = page.m_lens.GetHeadPosition(); pos; page.m_lens.GetNext(pos)) {
len = page.m_lens.GetAt(pos);
j += len;
- if(len < 255 || pos == page.m_lens.GetTailPosition())
- {
- if(first == pos && (page.m_hdr.header_type_flag & OggPageHeader::continued))
- {
-// ASSERT(m_lastpacket);
+ if(len < 255 || pos == page.m_lens.GetTailPosition()) {
+ if(first == pos && (page.m_hdr.header_type_flag & OggPageHeader::continued)) {
+ // ASSERT(m_lastpacket);
- if(m_lastpacket)
- {
+ if(m_lastpacket) {
int size = m_lastpacket->GetCount();
m_lastpacket->SetCount(size + j-i);
memcpy(m_lastpacket->GetData() + size, pData + i, j-i);
CAutoLock csAutoLock(&m_csPackets);
- if(len < 255) m_packets.AddTail(m_lastpacket);
+ if(len < 255) {
+ m_packets.AddTail(m_lastpacket);
+ }
}
- }
- else
- {
+ } else {
CAutoPtr<OggPacket> p(DNew OggPacket());
- if(last == pos && page.m_hdr.granule_position != -1)
- {
+ if(last == pos && page.m_hdr.granule_position != -1) {
p->bDiscontinuity = m_fSkip;
-REFERENCE_TIME rtLast = m_rtLast;
+ REFERENCE_TIME rtLast = m_rtLast;
m_rtLast = GetRefTime(page.m_hdr.granule_position);
-// some bad encodings have a +/-1 frame difference from the normal timeline,
-// but these seem to cancel eachother out nicely so we can just ignore them
-// to make it play a bit more smooth.
-if(abs(rtLast - m_rtLast) == GetRefTime(1)) m_rtLast = rtLast; // FIXME
+ // some bad encodings have a +/-1 frame difference from the normal timeline,
+ // but these seem to cancel eachother out nicely so we can just ignore them
+ // to make it play a bit more smooth.
+ if(abs(rtLast - m_rtLast) == GetRefTime(1)) {
+ m_rtLast = rtLast; // FIXME
+ }
m_fSkip = false;
}
p->TrackNumber = page.m_hdr.bitstream_serial_number;
- if(S_OK == UnpackPacket(p, pData + i, j-i))
- {
-//if(p->TrackNumber == 1)
-//TRACE(_T("[%d]: %d, %I64d -> %I64d (skip=%d, disc=%d, sync=%d)\n"),
-// (int)p->TrackNumber, p->GetCount(), p->rtStart, p->rtStop,
-// (int)m_fSkip, (int)p->bDiscontinuity, (int)p->bSyncPoint);
+ if(S_OK == UnpackPacket(p, pData + i, j-i)) {
+ //if(p->TrackNumber == 1)
+ //TRACE(_T("[%d]: %d, %I64d -> %I64d (skip=%d, disc=%d, sync=%d)\n"),
+ // (int)p->TrackNumber, p->GetCount(), p->rtStart, p->rtStop,
+ // (int)m_fSkip, (int)p->bDiscontinuity, (int)p->bSyncPoint);
- if(p->rtStart <= p->rtStop && p->rtStop <= p->rtStart + 10000000i64*60)
- {
+ if(p->rtStart <= p->rtStop && p->rtStop <= p->rtStart + 10000000i64*60) {
CAutoLock csAutoLock(&m_csPackets);
m_rtLast = p->rtStop;
p->fSkip = m_fSkip;
- if(len < 255) m_packets.AddTail(p);
- else m_lastpacket = p;
- }
- else
- {
+ if(len < 255) {
+ m_packets.AddTail(p);
+ } else {
+ m_lastpacket = p;
+ }
+ } else {
ASSERT(0);
}
}
@@ -746,7 +736,9 @@ CAutoPtr<OggPacket> COggSplitterOutputPin::GetPacket()
{
CAutoPtr<OggPacket> p;
CAutoLock csAutoLock(&m_csPackets);
- if(m_packets.GetCount()) p = m_packets.RemoveHead();
+ if(m_packets.GetCount()) {
+ p = m_packets.RemoveHead();
+ }
return p;
}
@@ -807,17 +799,16 @@ HRESULT COggVorbisOutputPin::UnpackInitPage(OggPage& page)
{
HRESULT hr = __super::UnpackPage(page);
- while(m_packets.GetCount())
- {
+ while(m_packets.GetCount()) {
Packet* p = m_packets.GetHead();
- if(p->GetCount() >= 6 && p->GetAt(0) == 0x05)
- {
+ if(p->GetCount() >= 6 && p->GetAt(0) == 0x05) {
// yeah, right, we are going to be parsing this backwards! :P
bitstream bs(p->GetData(), p->GetCount(), true);
- while(bs.hasbits(-1) && bs.getbits(-1) != 1);
- for(int cnt = 0; bs.hasbits(-8-16-16-1-6); cnt++)
- {
+ while(bs.hasbits(-1) && bs.getbits(-1) != 1) {
+ ;
+ }
+ for(int cnt = 0; bs.hasbits(-8-16-16-1-6); cnt++) {
unsigned int modes = bs.showbits(-6)+1;
unsigned int mapping = bs.getbits(-8);
@@ -826,8 +817,7 @@ HRESULT COggVorbisOutputPin::UnpackInitPage(OggPage& page)
unsigned int blockflag = bs.getbits(-1);
UNUSED_ALWAYS(mapping);
- if(transformtype != 0 || windowtype != 0)
- {
+ if(transformtype != 0 || windowtype != 0) {
ASSERT(modes == cnt);
break;
}
@@ -837,14 +827,13 @@ HRESULT COggVorbisOutputPin::UnpackInitPage(OggPage& page)
}
int cnt = m_initpackets.GetCount();
- if(cnt <= 3)
- {
+ if(cnt <= 3) {
ASSERT(p->GetCount() >= 6 && p->GetAt(0) == 1+cnt*2);
VORBISFORMAT2* vf2 = (VORBISFORMAT2*)m_mts[0].Format();
vf2->HeaderSize[cnt] = p->GetCount();
int len = m_mts[0].FormatLength();
memcpy(
- m_mts[0].ReallocFormatBuffer(len + p->GetCount()) + len,
+ m_mts[0].ReallocFormatBuffer(len + p->GetCount()) + len,
p->GetData(), p->GetCount());
}
@@ -862,15 +851,18 @@ REFERENCE_TIME COggVorbisOutputPin::GetRefTime(__int64 granule_position)
HRESULT COggVorbisOutputPin::UnpackPacket(CAutoPtr<OggPacket>& p, BYTE* pData, int len)
{
- if(len > 0 && m_blockflags.GetCount())
- {
+ if(len > 0 && m_blockflags.GetCount()) {
bitstream bs(pData, len);
- if(bs.getbits(1) == 0)
- {
+ if(bs.getbits(1) == 0) {
int x = m_blockflags.GetCount()-1, n = 0;
- while(x) {n++; x >>= 1;}
+ while(x) {
+ n++;
+ x >>= 1;
+ }
DWORD blocksize = m_blocksize[m_blockflags[bs.getbits(n)]?1:0];
- if(m_lastblocksize) m_rtLast += GetRefTime((m_lastblocksize + blocksize) >> 2);
+ if(m_lastblocksize) {
+ m_rtLast += GetRefTime((m_lastblocksize + blocksize) >> 2);
+ }
m_lastblocksize = blocksize;
}
}
@@ -885,8 +877,9 @@ HRESULT COggVorbisOutputPin::UnpackPacket(CAutoPtr<OggPacket>& p, BYTE* pData, i
HRESULT COggVorbisOutputPin::DeliverPacket(CAutoPtr<OggPacket> p)
{
- if(p->GetCount() > 0 && (p->GetAt(0)&1))
+ if(p->GetCount() > 0 && (p->GetAt(0)&1)) {
return S_OK;
+ }
return __super::DeliverPacket(p);
}
@@ -897,11 +890,9 @@ HRESULT COggVorbisOutputPin::DeliverNewSegment(REFERENCE_TIME tStart, REFERENCE_
m_lastblocksize = 0;
- if(m_mt.subtype == MEDIASUBTYPE_Vorbis)
- {
+ if(m_mt.subtype == MEDIASUBTYPE_Vorbis) {
POSITION pos = m_initpackets.GetHeadPosition();
- while(pos)
- {
+ while(pos) {
Packet* pi = m_initpackets.GetNext(pos);
CAutoPtr<OggPacket> p(DNew OggPacket());
p->TrackNumber = pi->TrackNumber;
@@ -926,9 +917,10 @@ COggFlacOutputPin::COggFlacOutputPin(BYTE* h, int nCount, LPCWSTR pName, CBaseFi
Buffer.BitRead(1); // Last-metadata-block flag
- if (Buffer.BitRead(7) != 0) // Should be a STREAMINFO block
- {
- if(phr) *phr = VFW_E_INVALID_FILE_FORMAT;
+ if (Buffer.BitRead(7) != 0) { // Should be a STREAMINFO block
+ if(phr) {
+ *phr = VFW_E_INVALID_FILE_FORMAT;
+ }
return;
}
@@ -941,7 +933,7 @@ COggFlacOutputPin::COggFlacOutputPin(BYTE* h, int nCount, LPCWSTR pName, CBaseFi
m_nChannels = (int)Buffer.BitRead(3) + 1;
m_wBitsPerSample = (WORD)Buffer.BitRead(5) + 1;
Buffer.BitRead(36); // m_i64TotalNumSamples
- m_nAvgBytesPerSec = (m_nChannels * (m_wBitsPerSample >> 3)) * m_nSamplesPerSec;
+ m_nAvgBytesPerSec = (m_nChannels * (m_wBitsPerSample >> 3)) * m_nSamplesPerSec;
CMediaType mt;
@@ -971,8 +963,7 @@ REFERENCE_TIME COggFlacOutputPin::GetRefTime(__int64 granule_position)
HRESULT COggFlacOutputPin::UnpackPacket(CAutoPtr<OggPacket>& p, BYTE* pData, int len)
{
- if (pData[0] != 0xFF || (pData[1] & 0xFE) != 0xF8)
- {
+ if (pData[0] != 0xFF || (pData[1] & 0xFE) != 0xF8) {
return S_FALSE;
}
@@ -986,8 +977,9 @@ HRESULT COggFlacOutputPin::UnpackPacket(CAutoPtr<OggPacket>& p, BYTE* pData, int
HRESULT COggFlacOutputPin::DeliverPacket(CAutoPtr<OggPacket> p)
{
- if(p->GetCount() > 0 && (p->GetAt(0)&1))
+ if(p->GetCount() > 0 && (p->GetAt(0)&1)) {
return S_OK;
+ }
return __super::DeliverPacket(p);
}
@@ -998,11 +990,9 @@ HRESULT COggFlacOutputPin::DeliverNewSegment(REFERENCE_TIME tStart, REFERENCE_TI
m_lastblocksize = 0;
- if(m_mt.subtype == MEDIASUBTYPE_FLAC_FRAMED)
- {
+ if(m_mt.subtype == MEDIASUBTYPE_FLAC_FRAMED) {
POSITION pos = m_initpackets.GetHeadPosition();
- while(pos)
- {
+ while(pos) {
Packet* pi = m_initpackets.GetNext(pos);
CAutoPtr<OggPacket> p(DNew OggPacket());
p->TrackNumber = pi->TrackNumber;
@@ -1026,20 +1016,18 @@ COggDirectShowOutputPin::COggDirectShowOutputPin(AM_MEDIA_TYPE* pmt, LPCWSTR pNa
memcpy((AM_MEDIA_TYPE*)&mt, pmt, FIELD_OFFSET(AM_MEDIA_TYPE, pUnk));
mt.SetFormat((BYTE*)(pmt+1), pmt->cbFormat);
mt.SetSampleSize(1);
- if(mt.majortype == MEDIATYPE_Video) // TODO: find samples for audio and find out what to return in GetRefTime...
+ if(mt.majortype == MEDIATYPE_Video) { // TODO: find samples for audio and find out what to return in GetRefTime...
m_mts.Add(mt);
+ }
}
REFERENCE_TIME COggDirectShowOutputPin::GetRefTime(__int64 granule_position)
{
REFERENCE_TIME rt = 0;
- if(m_mt.majortype == MEDIATYPE_Video)
- {
+ if(m_mt.majortype == MEDIATYPE_Video) {
rt = granule_position * ((VIDEOINFOHEADER*)m_mt.Format())->AvgTimePerFrame;
- }
- else if(m_mt.majortype == MEDIATYPE_Audio)
- {
+ } else if(m_mt.majortype == MEDIATYPE_Audio) {
rt = granule_position; // ((WAVEFORMATEX*)m_mt.Format())-> // TODO
}
@@ -1052,15 +1040,18 @@ HRESULT COggDirectShowOutputPin::UnpackPacket(CAutoPtr<OggPacket>& p, BYTE* pDat
BYTE hdr = pData[i++];
- if(!(hdr&1))
- {
+ if(!(hdr&1)) {
// TODO: verify if this was still present in the old format (haven't found one sample yet)
BYTE nLenBytes = (hdr>>6)|((hdr&2)<<1);
__int64 Length = 0;
- for(int j = 0; j < nLenBytes; j++)
+ for(int j = 0; j < nLenBytes; j++) {
Length |= (__int64)pData[i++] << (j << 3);
+ }
- if(len < i) {ASSERT(0); return E_FAIL;}
+ if(len < i) {
+ ASSERT(0);
+ return E_FAIL;
+ }
p->bSyncPoint = !!(hdr&8);
p->rtStart = m_rtLast;
@@ -1096,14 +1087,17 @@ HRESULT COggStreamOutputPin::UnpackPacket(CAutoPtr<OggPacket>& p, BYTE* pData, i
BYTE hdr = pData[i++];
- if(!(hdr&1))
- {
+ if(!(hdr&1)) {
BYTE nLenBytes = (hdr>>6)|((hdr&2)<<1);
__int64 Length = 0;
- for(int j = 0; j < nLenBytes; j++)
+ for(int j = 0; j < nLenBytes; j++) {
Length |= (__int64)pData[i++] << (j << 3);
+ }
- if(len < i) {ASSERT(0); return E_FAIL;}
+ if(len < i) {
+ ASSERT(0);
+ return E_FAIL;
+ }
p->bSyncPoint = !!(hdr&8);
p->rtStart = m_rtLast;
@@ -1124,7 +1118,7 @@ COggVideoOutputPin::COggVideoOutputPin(OggStreamHeader* h, LPCWSTR pName, CBaseF
: COggStreamOutputPin(h, pName, pFilter, pLock, phr)
{
int extra = (int)h->size - sizeof(OggStreamHeader);
- extra = max(extra, 0);
+ extra = max(extra, 0);
CMediaType mt;
mt.majortype = MEDIATYPE_Video;
@@ -1138,19 +1132,24 @@ COggVideoOutputPin::COggVideoOutputPin(OggStreamHeader* h, LPCWSTR pName, CBaseF
pvih->bmiHeader.biHeight = h->v.h;
pvih->bmiHeader.biBitCount = (WORD)h->bps;
pvih->bmiHeader.biCompression = mt.subtype.Data1;
- switch(pvih->bmiHeader.biCompression)
- {
- case BI_RGB: case BI_BITFIELDS: mt.subtype =
- pvih->bmiHeader.biBitCount == 1 ? MEDIASUBTYPE_RGB1 :
- pvih->bmiHeader.biBitCount == 4 ? MEDIASUBTYPE_RGB4 :
- pvih->bmiHeader.biBitCount == 8 ? MEDIASUBTYPE_RGB8 :
- pvih->bmiHeader.biBitCount == 16 ? MEDIASUBTYPE_RGB565 :
- pvih->bmiHeader.biBitCount == 24 ? MEDIASUBTYPE_RGB24 :
- pvih->bmiHeader.biBitCount == 32 ? MEDIASUBTYPE_RGB32 :
- MEDIASUBTYPE_NULL;
- break;
- case BI_RLE8: mt.subtype = MEDIASUBTYPE_RGB8; break;
- case BI_RLE4: mt.subtype = MEDIASUBTYPE_RGB4; break;
+ switch(pvih->bmiHeader.biCompression) {
+ case BI_RGB:
+ case BI_BITFIELDS:
+ mt.subtype =
+ pvih->bmiHeader.biBitCount == 1 ? MEDIASUBTYPE_RGB1 :
+ pvih->bmiHeader.biBitCount == 4 ? MEDIASUBTYPE_RGB4 :
+ pvih->bmiHeader.biBitCount == 8 ? MEDIASUBTYPE_RGB8 :
+ pvih->bmiHeader.biBitCount == 16 ? MEDIASUBTYPE_RGB565 :
+ pvih->bmiHeader.biBitCount == 24 ? MEDIASUBTYPE_RGB24 :
+ pvih->bmiHeader.biBitCount == 32 ? MEDIASUBTYPE_RGB32 :
+ MEDIASUBTYPE_NULL;
+ break;
+ case BI_RLE8:
+ mt.subtype = MEDIASUBTYPE_RGB8;
+ break;
+ case BI_RLE4:
+ mt.subtype = MEDIASUBTYPE_RGB4;
+ break;
}
mt.SetSampleSize(max(h->buffersize, 1));
m_mts.Add(mt);
@@ -1164,7 +1163,7 @@ COggAudioOutputPin::COggAudioOutputPin(OggStreamHeader* h, LPCWSTR pName, CBaseF
: COggStreamOutputPin(h, pName, pFilter, pLock, phr)
{
int extra = (int)h->size - sizeof(OggStreamHeader);
- extra = max(extra, 0);
+ extra = max(extra, 0);
CMediaType mt;
mt.majortype = MEDIATYPE_Audio;
@@ -1218,18 +1217,19 @@ COggTheoraOutputPin::COggTheoraOutputPin(BYTE* p, LPCWSTR pName, CBaseFilter* pF
vih->hdr.bmiHeader.biBitCount = 24;
m_nFpsNum = (p[22]<<24)|(p[23]<<16)|(p[24]<<8)|p[25];
m_nFpsDenum = (p[26]<<24)|(p[27]<<16)|(p[28]<<8)|p[29];
- if(m_nFpsNum)
- {
+ if(m_nFpsNum) {
m_rtAvgTimePerFrame = (REFERENCE_TIME)(10000000.0 * m_nFpsDenum / m_nFpsNum);
vih->hdr.AvgTimePerFrame = m_rtAvgTimePerFrame;
}
vih->hdr.dwPictAspectRatioX = (p[14]<<16)|(p[15]<<8)|p[16];
vih->hdr.dwPictAspectRatioY = (p[17]<<16)|(p[18]<<8)|p[19];
-
+
m_KfgShift = (((p[40]<<8)+p[41]) &0x3E0) >> 5;
m_nIndexOffset = TH_VERSION_CHECK(p[7],p[8],p[9],3,2,1);
-
- if (m_KfgShift == 0) m_KfgShift = 6; // Is it really default value ?
+
+ if (m_KfgShift == 0) {
+ m_KfgShift = 6; // Is it really default value ?
+ }
mt.bFixedSizeSamples = 0;
m_mts.Add(mt);
@@ -1239,17 +1239,16 @@ HRESULT COggTheoraOutputPin::UnpackInitPage(OggPage& page)
{
HRESULT hr = __super::UnpackPage(page);
- while(m_packets.GetCount())
- {
+ while(m_packets.GetCount()) {
Packet* p = m_packets.GetHead();
CMediaType& mt = m_mts[0];
int size = p->GetCount();
ASSERT(size <= 0xffff);
MPEG2VIDEOINFO* vih = (MPEG2VIDEOINFO*)mt.ReallocFormatBuffer(
- FIELD_OFFSET(MPEG2VIDEOINFO, dwSequenceHeader) +
- ((MPEG2VIDEOINFO*)mt.Format())->cbSequenceHeader +
- 2 + size);
+ FIELD_OFFSET(MPEG2VIDEOINFO, dwSequenceHeader) +
+ ((MPEG2VIDEOINFO*)mt.Format())->cbSequenceHeader +
+ 2 + size);
*(WORD*)((BYTE*)vih->dwSequenceHeader + vih->cbSequenceHeader) = (size>>8)|(size<<8);
memcpy((BYTE*)vih->dwSequenceHeader + vih->cbSequenceHeader + 2, p->GetData(), size);
vih->cbSequenceHeader += 2 + size;
@@ -1262,15 +1261,15 @@ HRESULT COggTheoraOutputPin::UnpackInitPage(OggPage& page)
REFERENCE_TIME COggTheoraOutputPin::GetRefTime(__int64 granule_position)
{
- LONGLONG iframe;
- LONGLONG pframe;
+ LONGLONG iframe;
+ LONGLONG pframe;
- iframe=granule_position>>m_KfgShift;
- pframe=granule_position-(iframe<<m_KfgShift);
- /*3.2.0 streams store the frame index in the granule position.
- 3.2.1 and later store the frame count.
- We return the index, so adjust the value if we have a 3.2.1 or later
- stream.*/
+ iframe=granule_position>>m_KfgShift;
+ pframe=granule_position-(iframe<<m_KfgShift);
+ /*3.2.0 streams store the frame index in the granule position.
+ 3.2.1 and later store the frame count.
+ We return the index, so adjust the value if we have a 3.2.1 or later
+ stream.*/
REFERENCE_TIME rt = 0;
rt = (iframe+pframe-m_nIndexOffset) * m_rtAvgTimePerFrame;
@@ -1284,8 +1283,9 @@ HRESULT COggTheoraOutputPin::UnpackPacket(CAutoPtr<OggPacket>& p, BYTE* pData, i
p->rtStop = m_rtLast+1;
p->SetData(pData, len);
- if(!(*pData & 0x80) && m_mt.majortype == MEDIATYPE_Video)
+ if(!(*pData & 0x80) && m_mt.majortype == MEDIATYPE_Video) {
p->rtStop = p->rtStart + ((MPEG2VIDEOINFO*)m_mt.Format())->hdr.AvgTimePerFrame;
+ }
return S_OK;
}