diff options
author | XhmikosR <xhmikosr@users.sourceforge.net> | 2010-12-17 19:42:55 +0300 |
---|---|---|
committer | XhmikosR <xhmikosr@users.sourceforge.net> | 2010-12-17 19:42:55 +0300 |
commit | 7359bd509afa235acc2ac2f7f95fc9cb5cafd1a4 (patch) | |
tree | b5bb90eeca58fdeb9fde6825f21a25a319823cb4 /src/filters/source/FLICSource | |
parent | d30b15ed4b98c28951d6d45b8928f4c2b6a11129 (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/source/FLICSource')
-rw-r--r-- | src/filters/source/FLICSource/FLICSource.cpp | 437 | ||||
-rw-r--r-- | src/filters/source/FLICSource/FLICSource.h | 52 | ||||
-rw-r--r-- | src/filters/source/FLICSource/stdafx.cpp | 6 | ||||
-rw-r--r-- | src/filters/source/FLICSource/stdafx.h | 6 |
4 files changed, 257 insertions, 244 deletions
diff --git a/src/filters/source/FLICSource/FLICSource.cpp b/src/filters/source/FLICSource/FLICSource.cpp index 696103f59..16e92a992 100644 --- a/src/filters/source/FLICSource/FLICSource.cpp +++ b/src/filters/source/FLICSource/FLICSource.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.
@@ -25,23 +25,19 @@ #ifdef REGISTER_FILTER
-const AMOVIESETUP_MEDIATYPE sudPinTypesOut[] =
-{
+const AMOVIESETUP_MEDIATYPE sudPinTypesOut[] = {
{&MEDIATYPE_Video, &MEDIASUBTYPE_RGB32},
};
-const AMOVIESETUP_PIN sudOpPin[] =
-{
+const AMOVIESETUP_PIN sudOpPin[] = {
{L"Output", FALSE, TRUE, FALSE, FALSE, &CLSID_NULL, NULL, countof(sudPinTypesOut), sudPinTypesOut}
};
-const AMOVIESETUP_FILTER sudFilter[] =
-{
+const AMOVIESETUP_FILTER sudFilter[] = {
{&__uuidof(CFLICSource), L"MPC - FLICSource", MERIT_NORMAL, countof(sudOpPin), sudOpPin, CLSID_LegacyAmFilterCategory}
};
-CFactoryTemplate g_Templates[] =
-{
+CFactoryTemplate g_Templates[] = {
{sudFilter[0].strName, sudFilter[0].clsID, CreateInstance<CFLICSource>, NULL, &sudFilter[0]}
};
@@ -50,23 +46,23 @@ int g_cTemplates = countof(g_Templates); STDAPI DllRegisterServer()
{
SetRegKeyValue(
- _T("Media Type\\{e436eb83-524f-11ce-9f53-0020af0ba770}"), _T("{17DB5CF6-39BB-4d5b-B0AA-BEBA44673AD4}"),
- _T("0"), _T("4,2,,11AF"));
+ _T("Media Type\\{e436eb83-524f-11ce-9f53-0020af0ba770}"), _T("{17DB5CF6-39BB-4d5b-B0AA-BEBA44673AD4}"),
+ _T("0"), _T("4,2,,11AF"));
SetRegKeyValue(
- _T("Media Type\\{e436eb83-524f-11ce-9f53-0020af0ba770}"), _T("{17DB5CF6-39BB-4d5b-B0AA-BEBA44673AD4}"),
+ _T("Media Type\\{e436eb83-524f-11ce-9f53-0020af0ba770}"), _T("{17DB5CF6-39BB-4d5b-B0AA-BEBA44673AD4}"),
_T("1"), _T("4,2,,12AF"));
SetRegKeyValue(
- _T("Media Type\\{e436eb83-524f-11ce-9f53-0020af0ba770}"), _T("{17DB5CF6-39BB-4d5b-B0AA-BEBA44673AD4}"),
+ _T("Media Type\\{e436eb83-524f-11ce-9f53-0020af0ba770}"), _T("{17DB5CF6-39BB-4d5b-B0AA-BEBA44673AD4}"),
_T("Source Filter"), _T("{17DB5CF6-39BB-4d5b-B0AA-BEBA44673AD4}"));
SetRegKeyValue(
- _T("Media Type\\Extensions"), _T(".fli"),
+ _T("Media Type\\Extensions"), _T(".fli"),
_T("Source Filter"), _T("{17DB5CF6-39BB-4d5b-B0AA-BEBA44673AD4}"));
SetRegKeyValue(
- _T("Media Type\\Extensions"), _T(".flc"),
+ _T("Media Type\\Extensions"), _T(".flc"),
_T("Source Filter"), _T("{17DB5CF6-39BB-4d5b-B0AA-BEBA44673AD4}"));
return AMovieDllRegisterServer2(TRUE);
@@ -102,9 +98,9 @@ CFLICSource::~CFLICSource() STDMETHODIMP CFLICSource::NonDelegatingQueryInterface(REFIID riid, void** ppv)
{
- CheckPointer(ppv, E_POINTER);
+ CheckPointer(ppv, E_POINTER);
- return
+ return
QI(IFileSourceFilter)
QI(IAMFilterMiscFlags)
__super::NonDelegatingQueryInterface(riid, ppv);
@@ -112,17 +108,20 @@ STDMETHODIMP CFLICSource::NonDelegatingQueryInterface(REFIID riid, void** ppv) // IFileSourceFilter
-STDMETHODIMP CFLICSource::Load(LPCOLESTR pszFileName, const AM_MEDIA_TYPE* pmt)
+STDMETHODIMP CFLICSource::Load(LPCOLESTR pszFileName, const AM_MEDIA_TYPE* pmt)
{
- if(GetPinCount() > 0)
+ if(GetPinCount() > 0) {
return VFW_E_ALREADY_CONNECTED;
+ }
HRESULT hr = S_OK;
- if(!(DNew CFLICStream(pszFileName, this, &hr)))
+ if(!(DNew CFLICStream(pszFileName, this, &hr))) {
return E_OUTOFMEMORY;
+ }
- if(FAILED(hr))
+ if(FAILED(hr)) {
return hr;
+ }
m_fn = pszFileName;
@@ -131,11 +130,14 @@ STDMETHODIMP CFLICSource::Load(LPCOLESTR pszFileName, const AM_MEDIA_TYPE* pmt) STDMETHODIMP CFLICSource::GetCurFile(LPOLESTR* ppszFileName, AM_MEDIA_TYPE* pmt)
{
- if(!ppszFileName) return E_POINTER;
-
+ if(!ppszFileName) {
+ return E_POINTER;
+ }
+
*ppszFileName = (LPOLESTR)CoTaskMemAlloc((m_fn.GetLength()+1)*sizeof(WCHAR));
- if(!(*ppszFileName))
+ if(!(*ppszFileName)) {
return E_OUTOFMEMORY;
+ }
wcscpy(*ppszFileName, m_fn);
@@ -151,7 +153,7 @@ ULONG CFLICSource::GetMiscFlags() // CFLICStream
-CFLICStream::CFLICStream(const WCHAR* wfn, CFLICSource* pParent, HRESULT* phr)
+CFLICStream::CFLICStream(const WCHAR* wfn, CFLICSource* pParent, HRESULT* phr)
: CSourceStream(NAME("FLICStream"), phr, pParent, L"Output")
, CSourceSeeking(NAME("FLICStream"), (IPin*)this, phr, &m_cSharedState)
, m_bDiscontinuity(FALSE), m_bFlushing(FALSE)
@@ -160,98 +162,106 @@ CFLICStream::CFLICStream(const WCHAR* wfn, CFLICSource* pParent, HRESULT* phr) CString fn(wfn);
- if(!m_flic.Open(fn, CFile::modeRead|CFile::shareDenyNone))
- {
- if(phr) *phr = E_FAIL;
+ if(!m_flic.Open(fn, CFile::modeRead|CFile::shareDenyNone)) {
+ if(phr) {
+ *phr = E_FAIL;
+ }
return;
}
if(m_flic.Read(&m_hdr, sizeof(m_hdr)) != sizeof(m_hdr)
- || (m_hdr.id != 0xaf11 && m_hdr.id != 0xaf12)
- || m_hdr.bpp != 8)
- {
- if(phr) *phr = E_FAIL;
+ || (m_hdr.id != 0xaf11 && m_hdr.id != 0xaf12)
+ || m_hdr.bpp != 8) {
+ if(phr) {
+ *phr = E_FAIL;
+ }
return;
}
m_AvgTimePerFrame = (m_hdr.id == 0xaf11)
- ? 10000000i64 * max(m_hdr.ticks, 1) / 70
- : 10000000i64 * max(m_hdr.ticks, 1) / 1000;
+ ? 10000000i64 * max(m_hdr.ticks, 1) / 70
+ : 10000000i64 * max(m_hdr.ticks, 1) / 1000;
// not tested (lack of test files)
{
__int64 pos = m_flic.GetPosition();
FLIC_PREFIX fp;
- if(m_flic.Read(&fp, sizeof(fp)) != sizeof(fp) || fp.id != 0xf100)
+ if(m_flic.Read(&fp, sizeof(fp)) != sizeof(fp) || fp.id != 0xf100) {
m_flic.Seek(pos, CFile::begin);
- else
+ } else {
m_flic.Seek(pos + fp.size, CFile::begin);
+ }
}
- do
- {
+ do {
FLIC_FRAME_ENTRY ffe;
- if(m_flic.Read(&ffe.hdr, sizeof(ffe.hdr)) != sizeof(ffe.hdr) || ffe.hdr.id != 0xf1fa)
+ if(m_flic.Read(&ffe.hdr, sizeof(ffe.hdr)) != sizeof(ffe.hdr) || ffe.hdr.id != 0xf1fa) {
break;
+ }
ffe.pos = m_flic.GetPosition();
ffe.fKeyframe = (m_frames.GetCount() == 0);
int chunk = 0;
- while(chunk < ffe.hdr.chunks)
- {
+ while(chunk < ffe.hdr.chunks) {
FLIC_CHUNK fc;
- if(m_flic.Read(&fc, sizeof(fc)) != sizeof(fc))
+ if(m_flic.Read(&fc, sizeof(fc)) != sizeof(fc)) {
break;
-/*
- switch(fc.type)
- {
- case FLIC_COLOR: _colorchunk(); break;
- case FLIC_256_COLOR: _color256chunk(); break;
- case FLIC_BRUN: _brunchunk(); break;
- case FLIC_LC: _lcchunk(); break;
- case FLIC_DELTA: _deltachunk(); break;
- case FLIC_BLACK: _blackchunk(); break;
- case FLIC_COPY: _copychunk(); break;
- case FLIC_MINI: break;
- default: break;
}
-*/
- ffe.fKeyframe =
+ /*
+ switch(fc.type)
+ {
+ case FLIC_COLOR: _colorchunk(); break;
+ case FLIC_256_COLOR: _color256chunk(); break;
+ case FLIC_BRUN: _brunchunk(); break;
+ case FLIC_LC: _lcchunk(); break;
+ case FLIC_DELTA: _deltachunk(); break;
+ case FLIC_BLACK: _blackchunk(); break;
+ case FLIC_COPY: _copychunk(); break;
+ case FLIC_MINI: break;
+ default: break;
+ }
+ */
+ ffe.fKeyframe =
(/*fc.type == FLIC_256_COLOR
|| fc.type == FLIC_64_COLOR
- ||*/ fc.type == FLIC_BRUN
- || fc.type == FLIC_BLACK
- || fc.type == FLIC_COPY);
+ ||*/ fc.type == FLIC_BRUN
+ || fc.type == FLIC_BLACK
+ || fc.type == FLIC_COPY);
ULONGLONG pos = m_flic.GetPosition() + fc.size - sizeof(fc);
- if(m_flic.Seek(pos, CFile::begin) != pos)
+ if(m_flic.Seek(pos, CFile::begin) != pos) {
break;
+ }
chunk++;
}
- if(chunk < ffe.hdr.chunks)
+ if(chunk < ffe.hdr.chunks) {
break;
+ }
ULONGLONG pos = ffe.pos + ffe.hdr.size - sizeof(ffe.hdr);
- if(m_flic.Seek(pos, CFile::begin) != pos)
+ if(m_flic.Seek(pos, CFile::begin) != pos) {
break;
+ }
m_frames.Add(ffe);
- }
- while(1);
+ } while(1);
m_nLastFrameNum = -1;
memset(m_pPalette, 0, sizeof(m_pPalette));
m_nBufferSize = m_hdr.x*m_hdr.y*32>>3;
- if(!m_pFrameBuffer.Allocate(m_nBufferSize))
- {
- if(phr) *phr = E_OUTOFMEMORY;
+ if(!m_pFrameBuffer.Allocate(m_nBufferSize)) {
+ if(phr) {
+ *phr = E_OUTOFMEMORY;
+ }
return;
}
m_rtDuration = m_rtStop = m_AvgTimePerFrame*m_frames.GetCount();
- if(phr) *phr = m_rtDuration > 0 ? S_OK : E_FAIL;
+ if(phr) {
+ *phr = m_rtDuration > 0 ? S_OK : E_FAIL;
+ }
}
CFLICStream::~CFLICStream()
@@ -261,21 +271,20 @@ CFLICStream::~CFLICStream() STDMETHODIMP CFLICStream::NonDelegatingQueryInterface(REFIID riid, void** ppv)
{
- CheckPointer(ppv, E_POINTER);
+ CheckPointer(ppv, E_POINTER);
return (riid == IID_IMediaSeeking) ? CSourceSeeking::NonDelegatingQueryInterface(riid, ppv) //GetInterface((IMediaSeeking*)this, ppv)
- : CSourceStream::NonDelegatingQueryInterface(riid, ppv);
+ : CSourceStream::NonDelegatingQueryInterface(riid, ppv);
}
void CFLICStream::UpdateFromSeek()
{
- if(ThreadExists())
- {
+ if(ThreadExists()) {
// next time around the loop, the worker thread will
// pick up the position change.
// We need to flush all the existing data - we must do that here
// as our thread will probably be blocked in GetBuffer otherwise
-
+
m_bFlushing = TRUE;
DeliverBeginFlush();
@@ -284,7 +293,7 @@ void CFLICStream::UpdateFromSeek() // complete the flush
DeliverEndFlush();
- m_bFlushing = FALSE;
+ m_bFlushing = FALSE;
// restart
Run();
@@ -293,8 +302,9 @@ void CFLICStream::UpdateFromSeek() HRESULT CFLICStream::SetRate(double dRate)
{
- if(dRate <= 0)
+ if(dRate <= 0) {
return E_INVALIDARG;
+ }
{
CAutoLock lock(CSourceSeeking::m_pLock);
@@ -308,65 +318,70 @@ HRESULT CFLICStream::SetRate(double dRate) HRESULT CFLICStream::OnThreadStartPlay()
{
- m_bDiscontinuity = TRUE;
- return DeliverNewSegment(m_rtStart, m_rtStop, m_dRateSeeking);
+ m_bDiscontinuity = TRUE;
+ return DeliverNewSegment(m_rtStart, m_rtStop, m_dRateSeeking);
}
HRESULT CFLICStream::ChangeStart()
{
- {
- CAutoLock lock(CSourceSeeking::m_pLock);
+ {
+ CAutoLock lock(CSourceSeeking::m_pLock);
m_rtSampleTime = 0;
m_rtPosition = m_rtStart;
- }
+ }
- UpdateFromSeek();
+ UpdateFromSeek();
- return S_OK;
+ return S_OK;
}
HRESULT CFLICStream::ChangeStop()
{
- {
- CAutoLock lock(CSourceSeeking::m_pLock);
- if(m_rtPosition < m_rtStop)
+ {
+ CAutoLock lock(CSourceSeeking::m_pLock);
+ if(m_rtPosition < m_rtStop) {
return S_OK;
- }
+ }
+ }
- // We're already past the new stop time -- better flush the graph.
- UpdateFromSeek();
+ // We're already past the new stop time -- better flush the graph.
+ UpdateFromSeek();
- return S_OK;
+ return S_OK;
}
HRESULT CFLICStream::OnThreadCreate()
{
- CAutoLock cAutoLockShared(&m_cSharedState);
- m_rtSampleTime = 0;
- m_rtPosition = m_rtStart;
+ CAutoLock cAutoLockShared(&m_cSharedState);
+ m_rtSampleTime = 0;
+ m_rtPosition = m_rtStart;
- return CSourceStream::OnThreadCreate();
+ return CSourceStream::OnThreadCreate();
}
HRESULT CFLICStream::DecideBufferSize(IMemAllocator* pAlloc, ALLOCATOR_PROPERTIES* pProperties)
{
-// CAutoLock cAutoLock(m_pFilter->pStateLock());
+ // CAutoLock cAutoLock(m_pFilter->pStateLock());
- ASSERT(pAlloc);
- ASSERT(pProperties);
+ ASSERT(pAlloc);
+ ASSERT(pProperties);
- HRESULT hr = NOERROR;
+ HRESULT hr = NOERROR;
pProperties->cBuffers = 1;
pProperties->cbBuffer = m_nBufferSize;
- ALLOCATOR_PROPERTIES Actual;
- if(FAILED(hr = pAlloc->SetProperties(pProperties, &Actual))) return hr;
+ ALLOCATOR_PROPERTIES Actual;
+ if(FAILED(hr = pAlloc->SetProperties(pProperties, &Actual))) {
+ return hr;
+ }
- if(Actual.cbBuffer < pProperties->cbBuffer) return E_FAIL;
- ASSERT(Actual.cBuffers == pProperties->cBuffers);
+ if(Actual.cbBuffer < pProperties->cbBuffer) {
+ return E_FAIL;
+ }
+ ASSERT(Actual.cBuffers == pProperties->cBuffers);
- return NOERROR;
+ return NOERROR;
}
HRESULT CFLICStream::FillBuffer(IMediaSample* pSample)
@@ -376,17 +391,18 @@ HRESULT CFLICStream::FillBuffer(IMediaSample* pSample) {
CAutoLock cAutoLockShared(&m_cSharedState);
- if(m_rtPosition >= m_rtStop)
+ if(m_rtPosition >= m_rtStop) {
return S_FALSE;
+ }
BYTE* pDataIn = m_pFrameBuffer;
BYTE* pDataOut = NULL;
- if(!pDataIn || FAILED(hr = pSample->GetPointer(&pDataOut)) || !pDataOut)
+ if(!pDataIn || FAILED(hr = pSample->GetPointer(&pDataOut)) || !pDataOut) {
return S_FALSE;
+ }
AM_MEDIA_TYPE* pmt;
- if(SUCCEEDED(pSample->GetMediaType(&pmt)) && pmt)
- {
+ if(SUCCEEDED(pSample->GetMediaType(&pmt)) && pmt) {
CMediaType mt(*pmt);
SetMediaType(&mt);
@@ -394,20 +410,15 @@ HRESULT CFLICStream::FillBuffer(IMediaSample* pSample) }
int w, h, bpp;
- if(m_mt.formattype == FORMAT_VideoInfo)
- {
+ if(m_mt.formattype == FORMAT_VideoInfo) {
w = ((VIDEOINFOHEADER*)m_mt.pbFormat)->bmiHeader.biWidth;
h = abs(((VIDEOINFOHEADER*)m_mt.pbFormat)->bmiHeader.biHeight);
bpp = ((VIDEOINFOHEADER*)m_mt.pbFormat)->bmiHeader.biBitCount;
- }
- else if(m_mt.formattype == FORMAT_VideoInfo2)
- {
+ } else if(m_mt.formattype == FORMAT_VideoInfo2) {
w = ((VIDEOINFOHEADER2*)m_mt.pbFormat)->bmiHeader.biWidth;
h = abs(((VIDEOINFOHEADER2*)m_mt.pbFormat)->bmiHeader.biHeight);
bpp = ((VIDEOINFOHEADER2*)m_mt.pbFormat)->bmiHeader.biBitCount;
- }
- else
- {
+ } else {
return S_FALSE;
}
@@ -419,36 +430,37 @@ HRESULT CFLICStream::FillBuffer(IMediaSample* pSample) {
SeekToNearestKeyFrame(nFrame);
- while(m_nLastFrameNum < nFrame && !m_bFlushing)
+ while(m_nLastFrameNum < nFrame && !m_bFlushing) {
ExtractFrame(++m_nLastFrameNum);
+ }
- for(int y = 0, p = min(pitchIn, pitchOut);
- y < h;
- y++, pDataIn += pitchIn, pDataOut += pitchOut)
- {
+ for(int y = 0, p = min(pitchIn, pitchOut);
+ y < h;
+ y++, pDataIn += pitchIn, pDataOut += pitchOut) {
BYTE* src = pDataIn;
BYTE* end = src + p;
DWORD* dst = (DWORD*)pDataOut;
- while(src < end) *dst++ = m_pPalette[*src++];
+ while(src < end) {
+ *dst++ = m_pPalette[*src++];
+ }
}
}
pSample->SetActualDataLength(pitchOut*h);
REFERENCE_TIME rtStart, rtStop;
- // The sample times are modified by the current rate.
- rtStart = static_cast<REFERENCE_TIME>(m_rtSampleTime / m_dRateSeeking);
- rtStop = rtStart + static_cast<int>(m_AvgTimePerFrame / m_dRateSeeking);
- pSample->SetTime(&rtStart, &rtStop);
+ // The sample times are modified by the current rate.
+ rtStart = static_cast<REFERENCE_TIME>(m_rtSampleTime / m_dRateSeeking);
+ rtStop = rtStart + static_cast<int>(m_AvgTimePerFrame / m_dRateSeeking);
+ pSample->SetTime(&rtStart, &rtStop);
- m_rtSampleTime += m_AvgTimePerFrame;
- m_rtPosition += m_AvgTimePerFrame;
+ m_rtSampleTime += m_AvgTimePerFrame;
+ m_rtPosition += m_AvgTimePerFrame;
}
pSample->SetSyncPoint(TRUE);
- if(m_bDiscontinuity)
- {
+ if(m_bDiscontinuity) {
pSample->SetDiscontinuity(TRUE);
m_bDiscontinuity = FALSE;
}
@@ -458,15 +470,19 @@ HRESULT CFLICStream::FillBuffer(IMediaSample* pSample) HRESULT CFLICStream::GetMediaType(int iPosition, CMediaType* pmt)
{
- CAutoLock cAutoLock(m_pFilter->pStateLock());
+ CAutoLock cAutoLock(m_pFilter->pStateLock());
- if(iPosition < 0) return E_INVALIDARG;
- if(iPosition > 0) return VFW_S_NO_MORE_ITEMS;
+ if(iPosition < 0) {
+ return E_INVALIDARG;
+ }
+ if(iPosition > 0) {
+ return VFW_S_NO_MORE_ITEMS;
+ }
- pmt->SetType(&MEDIATYPE_Video);
- pmt->SetSubtype(&MEDIASUBTYPE_RGB32);
- pmt->SetFormatType(&FORMAT_VideoInfo);
- pmt->SetTemporalCompression(TRUE);
+ pmt->SetType(&MEDIATYPE_Video);
+ pmt->SetSubtype(&MEDIASUBTYPE_RGB32);
+ pmt->SetFormatType(&FORMAT_VideoInfo);
+ pmt->SetTemporalCompression(TRUE);
VIDEOINFOHEADER* vih = (VIDEOINFOHEADER*)pmt->AllocFormatBuffer(sizeof(VIDEOINFOHEADER));
memset(vih, 0, sizeof(VIDEOINFOHEADER));
@@ -481,7 +497,7 @@ HRESULT CFLICStream::GetMediaType(int iPosition, CMediaType* pmt) pmt->SetSampleSize(vih->bmiHeader.biSizeImage);
- return NOERROR;
+ return NOERROR;
}
HRESULT CFLICStream::CheckConnect(IPin* pPin)
@@ -492,8 +508,10 @@ HRESULT CFLICStream::CheckConnect(IPin* pPin) HRESULT CFLICStream::CheckMediaType(const CMediaType* pmt)
{
if(pmt->majortype == MEDIATYPE_Video
- && pmt->subtype == MEDIASUBTYPE_RGB32
- && pmt->formattype == FORMAT_VideoInfo) return S_OK;
+ && pmt->subtype == MEDIASUBTYPE_RGB32
+ && pmt->formattype == FORMAT_VideoInfo) {
+ return S_OK;
+ }
return E_INVALIDARG;
}
@@ -507,17 +525,19 @@ STDMETHODIMP CFLICStream::Notify(IBaseFilter* pSender, Quality q) void CFLICStream::SeekToNearestKeyFrame(int nFrame)
{
- if(m_nLastFrameNum == nFrame)
+ if(m_nLastFrameNum == nFrame) {
return;
+ }
- if(m_nLastFrameNum > nFrame)
+ if(m_nLastFrameNum > nFrame) {
m_nLastFrameNum = -1;
+ }
- for(int i = m_nLastFrameNum+1, j = min(m_frames.GetCount(), nFrame); i < j; i++)
- {
+ for(int i = m_nLastFrameNum+1, j = min(m_frames.GetCount(), nFrame); i < j; i++) {
FLIC_FRAME_ENTRY& ffe = m_frames[i];
- if(ffe.fKeyframe)
+ if(ffe.fKeyframe) {
m_nLastFrameNum = i-1;
+ }
}
}
@@ -531,35 +551,55 @@ void CFLICStream::ExtractFrame(int nFrame) m_flic.Seek(ffe.pos, CFile::begin);
int chunk = 0;
- while(chunk < ffe.hdr.chunks)
- {
+ while(chunk < ffe.hdr.chunks) {
FLIC_CHUNK fc;
- if(m_flic.Read(&fc, sizeof(fc)) != sizeof(fc))
+ if(m_flic.Read(&fc, sizeof(fc)) != sizeof(fc)) {
break;
+ }
ULONGLONG next = m_flic.GetPosition() + fc.size - sizeof(fc);
- switch(fc.type)
- {
- case FLIC_64_COLOR: fNewPalette = _colorchunk(true); break;
- case FLIC_256_COLOR: fNewPalette = _colorchunk(false); break;
- case FLIC_BRUN: _brunchunk(); fNewFrame = true; break;
- case FLIC_LC: _lcchunk(); break;
- case FLIC_DELTA: _deltachunk(); break;
- case FLIC_BLACK: _blackchunk(); fNewFrame = true; break;
- case FLIC_COPY: _copychunk(); fNewFrame = true; break;
- case FLIC_MINI: break;
- default: break;
+ switch(fc.type) {
+ case FLIC_64_COLOR:
+ fNewPalette = _colorchunk(true);
+ break;
+ case FLIC_256_COLOR:
+ fNewPalette = _colorchunk(false);
+ break;
+ case FLIC_BRUN:
+ _brunchunk();
+ fNewFrame = true;
+ break;
+ case FLIC_LC:
+ _lcchunk();
+ break;
+ case FLIC_DELTA:
+ _deltachunk();
+ break;
+ case FLIC_BLACK:
+ _blackchunk();
+ fNewFrame = true;
+ break;
+ case FLIC_COPY:
+ _copychunk();
+ fNewFrame = true;
+ break;
+ case FLIC_MINI:
+ break;
+ default:
+ break;
}
- if(m_flic.Seek(next, CFile::begin) != next)
+ if(m_flic.Seek(next, CFile::begin) != next) {
break;
+ }
chunk++;
}
- if(chunk < ffe.hdr.chunks)
+ if(chunk < ffe.hdr.chunks) {
ASSERT(0);
+ }
ffe.fKeyframe = (fNewPalette && fNewFrame);
}
@@ -583,8 +623,7 @@ bool CFLICStream::_colorchunk(bool f64) WORD packets;
m_flic.Read(&packets, sizeof(packets));
- while(packets--)
- {
+ while(packets--) {
BYTE skip2;
m_flic.Read(&skip2, sizeof(skip2));
skip += skip2;
@@ -593,15 +632,14 @@ bool CFLICStream::_colorchunk(bool f64) m_flic.Read(&count, sizeof(count));
int len = (count == 0 ? (256-skip) : count);
- while(len-- > 0)
- {
+ while(len-- > 0) {
BYTE r, g, b;
m_flic.Read(&r, sizeof(r));
m_flic.Read(&g, sizeof(g));
m_flic.Read(&b, sizeof(b));
- m_pPalette[skip++] = f64
- ? ((r << 18)&0xff0000) | ((g << 10)&0xff00) | ((b << 2)&0xff)
- : ((r << 16)&0xff0000) | ((g << 8)&0xff00) | ((b << 0)&0xff);
+ m_pPalette[skip++] = f64
+ ? ((r << 18)&0xff0000) | ((g << 10)&0xff00) | ((b << 2)&0xff)
+ : ((r << 16)&0xff0000) | ((g << 8)&0xff00) | ((b << 0)&0xff);
nColorsUpdated++;
}
}
@@ -614,27 +652,22 @@ void CFLICStream::_brunchunk() BYTE* tmp = m_pFrameBuffer;
int lines = m_hdr.y;
- while(lines--)
- {
+ while(lines--) {
BYTE packets;
m_flic.Read(&packets, sizeof(packets));
-
+
BYTE* ptr = tmp;
- while(ptr < tmp + m_hdr.x)
- {
+ while(ptr < tmp + m_hdr.x) {
signed char count;
m_flic.Read(&count, sizeof(count));
- if(count >= 0)
- {
+ if(count >= 0) {
BYTE c;
m_flic.Read(&c, sizeof(c));
memset(ptr, c, count);
ptr += count;
- }
- else
- {
+ } else {
m_flic.Read(ptr, -count);
ptr += -count;
}
@@ -654,15 +687,13 @@ void CFLICStream::_lcchunk() WORD lines;
m_flic.Read(&lines, sizeof(lines));
- while(lines--)
- {
+ while(lines--) {
BYTE* ptr = tmp;
BYTE packets;
m_flic.Read(&packets, sizeof(packets));
- while(packets--)
- {
+ while(packets--) {
BYTE skip;
m_flic.Read(&skip, sizeof(skip));
@@ -671,13 +702,10 @@ void CFLICStream::_lcchunk() signed char count;
m_flic.Read(&count, sizeof(count));
- if(count >= 0)
- {
+ if(count >= 0) {
m_flic.Read(ptr, count);
ptr += count;
- }
- else
- {
+ } else {
BYTE c;
m_flic.Read(&c, sizeof(c));
memset(ptr, c, -count);
@@ -696,31 +724,23 @@ void CFLICStream::_deltachunk() WORD lines;
m_flic.Read(&lines, sizeof(lines));
- while(lines--)
- {
+ while(lines--) {
signed short packets;
m_flic.Read(&packets, sizeof(packets));
- if(packets < 0)
- {
- if(packets&0x4000)
- {
+ if(packets < 0) {
+ if(packets&0x4000) {
tmp += -packets * m_hdr.x;
lines++;
- }
- else
- {
+ } else {
signed char count;
m_flic.Read(&count, sizeof(count));
tmp[m_hdr.x-1] = (BYTE)packets;
}
- }
- else
- {
+ } else {
BYTE* ptr = tmp;
- while(packets--)
- {
+ while(packets--) {
BYTE skip;
m_flic.Read(&skip, sizeof(skip));
@@ -729,22 +749,19 @@ void CFLICStream::_deltachunk() signed char count;
m_flic.Read(&count, sizeof(count));
- if(count >= 0)
- {
+ if(count >= 0) {
// Fix vulnerability : http://www.team509.com/modules.php?name=News&file=article&sid=38
- if ((count << 1) + (long)(ptr - m_pFrameBuffer) < m_nBufferSize)
+ if ((count << 1) + (long)(ptr - m_pFrameBuffer) < m_nBufferSize) {
m_flic.Read(ptr, count << 1);
- else
+ } else {
ASSERT(FALSE);
+ }
ptr += count << 1;
- }
- else
- {
+ } else {
WORD c;
m_flic.Read(&c, sizeof(c));
count = -count;
- while(count-- > 0)
- {
+ while(count-- > 0) {
*ptr++ = c>>8;
*ptr++ = c&0xff;
}
diff --git a/src/filters/source/FLICSource/FLICSource.h b/src/filters/source/FLICSource/FLICSource.h index 5038fb0a6..6df23ec7e 100644 --- a/src/filters/source/FLICSource/FLICSource.h +++ b/src/filters/source/FLICSource/FLICSource.h @@ -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.
@@ -24,8 +24,7 @@ #include <atlcoll.h>
#pragma pack(push, 1)
-enum
-{
+enum {
FLIC_256_COLOR = 4,
FLIC_DELTA = 7,
FLIC_64_COLOR = 11,
@@ -35,9 +34,8 @@ enum FLIC_COPY = 16,
FLIC_MINI = 18
};
-
-struct FLIC
-{
+
+struct FLIC {
DWORD size;
WORD id; // 0xaf11 or 0xaf12
WORD frames, x, y, bpp;
@@ -46,38 +44,34 @@ struct FLIC BYTE reserved[102];
};
-struct FLIC_PREFIX
-{
+struct FLIC_PREFIX {
DWORD size;
WORD id; // 0xf100
WORD chunks;
BYTE reserved[8];
};
-struct FLIC_FRAME
-{
+struct FLIC_FRAME {
DWORD size;
WORD id; // 0xf1fa
WORD chunks;
BYTE reserved[8];
};
-struct FLIC_CHUNK
-{
+struct FLIC_CHUNK {
DWORD size;
WORD type;
};
#pragma pack(pop)
-struct FLIC_FRAME_ENTRY
-{
+struct FLIC_FRAME_ENTRY {
__int64 pos;
bool fKeyframe;
FLIC_FRAME hdr;
};
class __declspec(uuid("17DB5CF6-39BB-4d5b-B0AA-BEBA44673AD4"))
-CFLICSource
+ CFLICSource
: public CSource
, public IFileSourceFilter
, public IAMFilterMiscFlags
@@ -89,7 +83,7 @@ public: virtual ~CFLICSource();
DECLARE_IUNKNOWN;
- STDMETHODIMP NonDelegatingQueryInterface(REFIID riid, void** ppv);
+ STDMETHODIMP NonDelegatingQueryInterface(REFIID riid, void** ppv);
// IFileSourceFilter
STDMETHODIMP Load(LPCOLESTR pszFileName, const AM_MEDIA_TYPE* pmt);
@@ -99,7 +93,7 @@ public: STDMETHODIMP_(ULONG) GetMiscFlags();
};
-class CFLICStream
+class CFLICStream
: public CSourceStream
, public CSourceSeeking
{
@@ -121,8 +115,10 @@ class CFLICStream STDMETHODIMP SetRate(double dRate);
HRESULT ChangeStart();
- HRESULT ChangeStop();
- HRESULT ChangeRate() {return S_OK;}
+ HRESULT ChangeStop();
+ HRESULT ChangeRate() {
+ return S_OK;
+ }
private:
int m_nLastFrameNum;
@@ -140,17 +136,17 @@ private: void _deltachunk();
public:
- CFLICStream(const WCHAR* wfn, CFLICSource* pParent, HRESULT* phr);
+ CFLICStream(const WCHAR* wfn, CFLICSource* pParent, HRESULT* phr);
virtual ~CFLICStream();
- STDMETHODIMP NonDelegatingQueryInterface(REFIID riid, void** ppv);
+ STDMETHODIMP NonDelegatingQueryInterface(REFIID riid, void** ppv);
- HRESULT DecideBufferSize(IMemAllocator* pIMemAlloc, ALLOCATOR_PROPERTIES* pProperties);
- HRESULT FillBuffer(IMediaSample* pSample);
+ HRESULT DecideBufferSize(IMemAllocator* pIMemAlloc, ALLOCATOR_PROPERTIES* pProperties);
+ HRESULT FillBuffer(IMediaSample* pSample);
HRESULT CheckConnect(IPin* pPin);
- HRESULT CheckMediaType(const CMediaType* pMediaType);
- HRESULT GetMediaType(int iPosition, CMediaType* pmt);
-
+ HRESULT CheckMediaType(const CMediaType* pMediaType);
+ HRESULT GetMediaType(int iPosition, CMediaType* pmt);
+
STDMETHODIMP Notify(IBaseFilter* pSender, Quality q);
};
diff --git a/src/filters/source/FLICSource/stdafx.cpp b/src/filters/source/FLICSource/stdafx.cpp index 13934d005..bea3f980a 100644 --- a/src/filters/source/FLICSource/stdafx.cpp +++ b/src/filters/source/FLICSource/stdafx.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.
diff --git a/src/filters/source/FLICSource/stdafx.h b/src/filters/source/FLICSource/stdafx.h index 62d50a36b..d1c3768d8 100644 --- a/src/filters/source/FLICSource/stdafx.h +++ b/src/filters/source/FLICSource/stdafx.h @@ -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.
|