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-04-09 18:12:59 +0400
committerXhmikosR <xhmikosr@users.sourceforge.net>2010-04-09 18:12:59 +0400
commitefbc9d9043ff8ff92716ddd00a5f61412d535593 (patch)
tree8f3e621f756cf1f5b4d64d97964c7e7abd8aaf08 /src/filters/source
parentdf6b139a6d9027156f614b68687e039e3a5854db (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/source')
-rw-r--r--src/filters/source/BaseSource/BaseSource.cpp130
-rw-r--r--src/filters/source/BaseSource/BaseSource.h135
-rw-r--r--src/filters/source/BaseSource/stdafx.cpp8
-rw-r--r--src/filters/source/BaseSource/stdafx.h8
-rw-r--r--src/filters/source/D2VSource/D2VSource.cpp264
-rw-r--r--src/filters/source/D2VSource/D2VSource.h22
-rw-r--r--src/filters/source/D2VSource/MPEG2Dec.h418
-rw-r--r--src/filters/source/D2VSource/idctfpu.cpp714
-rw-r--r--src/filters/source/D2VSource/idctref.cpp618
-rw-r--r--src/filters/source/D2VSource/resource.h2
-rw-r--r--src/filters/source/DTSAC3Source/DTSAC3Source.cpp624
-rw-r--r--src/filters/source/DTSAC3Source/DTSAC3Source.h36
-rw-r--r--src/filters/source/DTSAC3Source/resource.h2
-rw-r--r--src/filters/source/DTSAC3Source/stdafx.cpp8
-rw-r--r--src/filters/source/DTSAC3Source/stdafx.h8
-rw-r--r--src/filters/source/FLICSource/FLICSource.cpp975
-rw-r--r--src/filters/source/FLICSource/FLICSource.h157
-rw-r--r--src/filters/source/FLICSource/resource.h2
-rw-r--r--src/filters/source/FLICSource/stdafx.cpp8
-rw-r--r--src/filters/source/FLICSource/stdafx.h8
-rw-r--r--src/filters/source/FlacSource/FlacSource.cpp325
-rw-r--r--src/filters/source/FlacSource/FlacSource.h47
-rw-r--r--src/filters/source/FlacSource/resource.h2
-rw-r--r--src/filters/source/FlacSource/stdafx.cpp8
-rw-r--r--src/filters/source/FlacSource/stdafx.h8
-rw-r--r--src/filters/source/ShoutcastSource/ShoutcastSource.cpp850
-rw-r--r--src/filters/source/ShoutcastSource/ShoutcastSource.h240
-rw-r--r--src/filters/source/ShoutcastSource/resource.h2
-rw-r--r--src/filters/source/ShoutcastSource/stdafx.cpp8
-rw-r--r--src/filters/source/ShoutcastSource/stdafx.h8
-rw-r--r--src/filters/source/SubtitleSource/SubtitleSource.cpp865
-rw-r--r--src/filters/source/SubtitleSource/SubtitleSource.h95
-rw-r--r--src/filters/source/SubtitleSource/resource.h2
-rw-r--r--src/filters/source/SubtitleSource/stdafx.cpp8
-rw-r--r--src/filters/source/SubtitleSource/stdafx.h8
35 files changed, 3252 insertions, 3371 deletions
diff --git a/src/filters/source/BaseSource/BaseSource.cpp b/src/filters/source/BaseSource/BaseSource.cpp
index b5cf0c708..00ab0cc8e 100644
--- a/src/filters/source/BaseSource/BaseSource.cpp
+++ b/src/filters/source/BaseSource/BaseSource.cpp
@@ -1,4 +1,4 @@
-/*
+/*
* Copyright (C) 2003-2006 Gabest
* http://www.gabest.org
*
@@ -6,15 +6,15 @@
* 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.
+ * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
* http://www.gnu.org/copyleft/gpl.html
*
*/
@@ -31,68 +31,68 @@
// CBaseStream
//
-CBaseStream::CBaseStream(TCHAR* name, CSource* pParent, HRESULT* phr)
- : CSourceStream(name, phr, pParent, L"Output")
- , CSourceSeeking(name, (IPin*)this, phr, &m_cSharedState)
- , m_bDiscontinuity(FALSE), m_bFlushing(FALSE)
+CBaseStream::CBaseStream(TCHAR* name, CSource* pParent, HRESULT* phr)
+ : CSourceStream(name, phr, pParent, L"Output")
+ , CSourceSeeking(name, (IPin*)this, phr, &m_cSharedState)
+ , m_bDiscontinuity(FALSE), m_bFlushing(FALSE)
{
- CAutoLock cAutoLock(&m_cSharedState);
+ CAutoLock cAutoLock(&m_cSharedState);
- m_AvgTimePerFrame = 0;
- m_rtDuration = 0;
- m_rtStop = m_rtDuration;
+ m_AvgTimePerFrame = 0;
+ m_rtDuration = 0;
+ m_rtStop = m_rtDuration;
}
CBaseStream::~CBaseStream()
{
- CAutoLock cAutoLock(&m_cSharedState);
+ CAutoLock cAutoLock(&m_cSharedState);
}
STDMETHODIMP CBaseStream::NonDelegatingQueryInterface(REFIID riid, void** ppv)
{
CheckPointer(ppv, E_POINTER);
- return (riid == IID_IMediaSeeking) ? CSourceSeeking::NonDelegatingQueryInterface(riid, ppv)
- : CSourceStream::NonDelegatingQueryInterface(riid, ppv);
+ return (riid == IID_IMediaSeeking) ? CSourceSeeking::NonDelegatingQueryInterface(riid, ppv)
+ : CSourceStream::NonDelegatingQueryInterface(riid, ppv);
}
void CBaseStream::UpdateFromSeek()
{
- 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();
- // make sure we have stopped pushing
- Stop();
- // complete the flush
- DeliverEndFlush();
+ 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();
+ // make sure we have stopped pushing
+ Stop();
+ // complete the flush
+ DeliverEndFlush();
m_bFlushing = FALSE;
- // restart
- Run();
- }
+ // restart
+ Run();
+ }
}
HRESULT CBaseStream::SetRate(double dRate)
{
- if(dRate <= 0)
- return E_INVALIDARG;
+ if(dRate <= 0)
+ return E_INVALIDARG;
- {
- CAutoLock lock(CSourceSeeking::m_pLock);
- m_dRateSeeking = dRate;
- }
+ {
+ CAutoLock lock(CSourceSeeking::m_pLock);
+ m_dRateSeeking = dRate;
+ }
- UpdateFromSeek();
+ UpdateFromSeek();
- return S_OK;
+ return S_OK;
}
HRESULT CBaseStream::OnThreadStartPlay()
@@ -105,8 +105,8 @@ HRESULT CBaseStream::ChangeStart()
{
{
CAutoLock lock(CSourceSeeking::m_pLock);
- m_rtSampleTime = 0;
- m_rtPosition = m_rtStart;
+ m_rtSampleTime = 0;
+ m_rtPosition = m_rtStart;
}
UpdateFromSeek();
@@ -119,7 +119,7 @@ HRESULT CBaseStream::ChangeStop()
{
CAutoLock lock(CSourceSeeking::m_pLock);
if(m_rtPosition < m_rtStop)
- return S_OK;
+ return S_OK;
}
// We're already past the new stop time -- better flush the graph.
@@ -140,49 +140,49 @@ HRESULT CBaseStream::OnThreadCreate()
HRESULT CBaseStream::FillBuffer(IMediaSample* pSample)
{
- HRESULT hr;
+ HRESULT hr;
- {
- CAutoLock cAutoLockShared(&m_cSharedState);
+ {
+ CAutoLock cAutoLockShared(&m_cSharedState);
if(m_rtPosition >= m_rtStop)
- return S_FALSE;
+ return S_FALSE;
- BYTE* pOut = NULL;
- if(FAILED(hr = pSample->GetPointer(&pOut)) || !pOut)
- return S_FALSE;
+ BYTE* pOut = NULL;
+ if(FAILED(hr = pSample->GetPointer(&pOut)) || !pOut)
+ return S_FALSE;
- int nFrame = m_rtPosition / m_AvgTimePerFrame; // (int)(1.0 * m_rtPosition / m_AvgTimePerFrame + 0.5);
+ int nFrame = m_rtPosition / m_AvgTimePerFrame; // (int)(1.0 * m_rtPosition / m_AvgTimePerFrame + 0.5);
- long len = pSample->GetSize();
+ long len = pSample->GetSize();
- hr = FillBuffer(pSample, nFrame, pOut, len);
- if(hr != S_OK) return hr;
+ hr = FillBuffer(pSample, nFrame, pOut, len);
+ if(hr != S_OK) return hr;
- pSample->SetActualDataLength(len);
+ pSample->SetActualDataLength(len);
- REFERENCE_TIME rtStart, rtStop;
+ 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);
+ pSample->SetTime(&rtStart, &rtStop);
m_rtSampleTime += m_AvgTimePerFrame;
m_rtPosition += m_AvgTimePerFrame;
- }
+ }
- pSample->SetSyncPoint(TRUE);
+ pSample->SetSyncPoint(TRUE);
- if(m_bDiscontinuity)
+ if(m_bDiscontinuity)
{
- pSample->SetDiscontinuity(TRUE);
- m_bDiscontinuity = FALSE;
- }
+ pSample->SetDiscontinuity(TRUE);
+ m_bDiscontinuity = FALSE;
+ }
- return S_OK;
+ return S_OK;
}
STDMETHODIMP CBaseStream::Notify(IBaseFilter* pSender, Quality q)
{
- return E_NOTIMPL;
+ return E_NOTIMPL;
}
diff --git a/src/filters/source/BaseSource/BaseSource.h b/src/filters/source/BaseSource/BaseSource.h
index 07eed8751..91e2ccdb8 100644
--- a/src/filters/source/BaseSource/BaseSource.h
+++ b/src/filters/source/BaseSource/BaseSource.h
@@ -1,4 +1,4 @@
-/*
+/*
* Copyright (C) 2003-2006 Gabest
* http://www.gabest.org
*
@@ -6,15 +6,15 @@
* 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.
+ * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
* http://www.gnu.org/copyleft/gpl.html
*
*/
@@ -25,102 +25,99 @@
template<class TStream>
class CBaseSource
- : public CSource
- , public IFileSourceFilter
- , public IAMFilterMiscFlags
+ : public CSource
+ , public IFileSourceFilter
+ , public IAMFilterMiscFlags
{
protected:
- CStringW m_fn;
+ CStringW m_fn;
public:
- CBaseSource(TCHAR* name, LPUNKNOWN lpunk, HRESULT* phr, const CLSID& clsid)
- : CSource(name, lpunk, clsid)
- {
- if(phr) *phr = S_OK;
- }
+ CBaseSource(TCHAR* name, LPUNKNOWN lpunk, HRESULT* phr, const CLSID& clsid)
+ : CSource(name, lpunk, clsid)
+ {
+ if(phr) *phr = S_OK;
+ }
- DECLARE_IUNKNOWN;
+ DECLARE_IUNKNOWN;
STDMETHODIMP NonDelegatingQueryInterface(REFIID riid, void** ppv)
- {
- CheckPointer(ppv, E_POINTER);
-
- return
- QI(IFileSourceFilter)
- QI(IAMFilterMiscFlags)
- __super::NonDelegatingQueryInterface(riid, ppv);
- }
+ {
+ CheckPointer(ppv, E_POINTER);
- // IFileSourceFilter
+ return
+ QI(IFileSourceFilter)
+ QI(IAMFilterMiscFlags)
+ __super::NonDelegatingQueryInterface(riid, ppv);
+ }
- STDMETHODIMP Load(LPCOLESTR pszFileName, const AM_MEDIA_TYPE* pmt)
- {
- // TODO: destroy any already existing pins and create new, now we are just going die nicely instead of doing it :)
- if(GetPinCount() > 0)
- return VFW_E_ALREADY_CONNECTED;
+ // IFileSourceFilter
- HRESULT hr = S_OK;
- if(!(DNew TStream(pszFileName, this, &hr)))
- return E_OUTOFMEMORY;
+ STDMETHODIMP Load(LPCOLESTR pszFileName, const AM_MEDIA_TYPE* pmt)
+ {
+ // TODO: destroy any already existing pins and create new, now we are just going die nicely instead of doing it :)
+ if(GetPinCount() > 0)
+ return VFW_E_ALREADY_CONNECTED;
- if(FAILED(hr))
- return hr;
+ HRESULT hr = S_OK;
+ if(!(DNew TStream(pszFileName, this, &hr)))
+ return E_OUTOFMEMORY;
- m_fn = pszFileName;
+ if(FAILED(hr))
+ return hr;
- return S_OK;
- }
+ m_fn = pszFileName;
- STDMETHODIMP GetCurFile(LPOLESTR* ppszFileName, AM_MEDIA_TYPE* pmt)
- {
- size_t nCount;
- if(!ppszFileName) return E_POINTER;
+ return S_OK;
+ }
- nCount = m_fn.GetLength() + 1;
- if(!(*ppszFileName = (LPOLESTR)CoTaskMemAlloc(nCount * sizeof(WCHAR))))
- return E_OUTOFMEMORY;
+ STDMETHODIMP GetCurFile(LPOLESTR* ppszFileName, AM_MEDIA_TYPE* pmt)
+ {
+ size_t nCount;
+ if(!ppszFileName) return E_POINTER;
+
+ nCount = m_fn.GetLength()+1;
+ if(!(*ppszFileName = (LPOLESTR)CoTaskMemAlloc(nCount*sizeof(WCHAR))))
+ return E_OUTOFMEMORY;
- wcscpy_s(*ppszFileName, nCount, m_fn);
+ wcscpy_s(*ppszFileName, nCount, m_fn);
- return S_OK;
- }
+ return S_OK;
+ }
- // IAMFilterMiscFlags
+ // IAMFilterMiscFlags
- STDMETHODIMP_(ULONG) GetMiscFlags()
- {
- return AM_FILTER_MISC_FLAGS_IS_SOURCE;
- }
+ STDMETHODIMP_(ULONG) GetMiscFlags()
+ {
+ return AM_FILTER_MISC_FLAGS_IS_SOURCE;
+ }
};
-class CBaseStream
- : public CSourceStream
- , public CSourceSeeking
+class CBaseStream
+ : public CSourceStream
+ , public CSourceSeeking
{
protected:
- CCritSec m_cSharedState;
+ CCritSec m_cSharedState;
- REFERENCE_TIME m_AvgTimePerFrame;
- REFERENCE_TIME m_rtSampleTime, m_rtPosition;
+ REFERENCE_TIME m_AvgTimePerFrame;
+ REFERENCE_TIME m_rtSampleTime, m_rtPosition;
- BOOL m_bDiscontinuity, m_bFlushing;
+ BOOL m_bDiscontinuity, m_bFlushing;
- HRESULT OnThreadStartPlay();
- HRESULT OnThreadCreate();
+ HRESULT OnThreadStartPlay();
+ HRESULT OnThreadCreate();
private:
- void UpdateFromSeek();
- STDMETHODIMP SetRate(double dRate);
+ void UpdateFromSeek();
+ STDMETHODIMP SetRate(double dRate);
- HRESULT ChangeStart();
+ HRESULT ChangeStart();
HRESULT ChangeStop();
- HRESULT ChangeRate()
- {
- return S_OK;
- }
+ HRESULT ChangeRate() {return S_OK;}
public:
CBaseStream(TCHAR* name, CSource* pParent, HRESULT* phr);
- virtual ~CBaseStream();
+ virtual ~CBaseStream();
STDMETHODIMP NonDelegatingQueryInterface(REFIID riid, void** ppv);
@@ -128,5 +125,5 @@ public:
virtual HRESULT FillBuffer(IMediaSample* pSample, int nFrame, BYTE* pOut, long& len /*in+out*/) = 0;
- STDMETHODIMP Notify(IBaseFilter* pSender, Quality q);
+ STDMETHODIMP Notify(IBaseFilter* pSender, Quality q);
};
diff --git a/src/filters/source/BaseSource/stdafx.cpp b/src/filters/source/BaseSource/stdafx.cpp
index 8c08467b1..7407b6b89 100644
--- a/src/filters/source/BaseSource/stdafx.cpp
+++ b/src/filters/source/BaseSource/stdafx.cpp
@@ -1,4 +1,4 @@
-/*
+/*
* Copyright (C) 2003-2006 Gabest
* http://www.gabest.org
*
@@ -6,15 +6,15 @@
* 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.
+ * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
* http://www.gnu.org/copyleft/gpl.html
*
*/
diff --git a/src/filters/source/BaseSource/stdafx.h b/src/filters/source/BaseSource/stdafx.h
index 2bec11afc..22cb54295 100644
--- a/src/filters/source/BaseSource/stdafx.h
+++ b/src/filters/source/BaseSource/stdafx.h
@@ -1,4 +1,4 @@
-/*
+/*
* Copyright (C) 2003-2006 Gabest
* http://www.gabest.org
*
@@ -6,15 +6,15 @@
* 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.
+ * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
* http://www.gnu.org/copyleft/gpl.html
*
*/
diff --git a/src/filters/source/D2VSource/D2VSource.cpp b/src/filters/source/D2VSource/D2VSource.cpp
index 088aa3fdd..6806e440f 100644
--- a/src/filters/source/D2VSource/D2VSource.cpp
+++ b/src/filters/source/D2VSource/D2VSource.cpp
@@ -1,19 +1,19 @@
-/*
+/*
* Copyright (C) 2003-2006 Gabest
*
* This Program is free software; you can redistribute it and/or modify
* 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.
+ * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
*
*/
@@ -26,49 +26,49 @@
const AMOVIESETUP_MEDIATYPE sudPinTypesOut[] =
{
- {&MEDIATYPE_Video, &MEDIASUBTYPE_YUY2}
+ {&MEDIATYPE_Video, &MEDIASUBTYPE_YUY2}
};
const AMOVIESETUP_PIN sudOpPin[] =
{
- {L"Output", FALSE, TRUE, FALSE, FALSE, &CLSID_NULL, NULL, countof(sudPinTypesOut), sudPinTypesOut}
+ {L"Output", FALSE, TRUE, FALSE, FALSE, &CLSID_NULL, NULL, countof(sudPinTypesOut), sudPinTypesOut}
};
const AMOVIESETUP_FILTER sudFilter[] =
{
- {&__uuidof(CD2VSource), L"MPC - D2VSource", MERIT_NORMAL, countof(sudOpPin), sudOpPin, CLSID_LegacyAmFilterCategory}
+ {&__uuidof(CD2VSource), L"MPC - D2VSource", MERIT_NORMAL, countof(sudOpPin), sudOpPin, CLSID_LegacyAmFilterCategory}
};
CFactoryTemplate g_Templates[] =
{
- {sudFilter[0].strName, sudFilter[0].clsID, CreateInstance<CD2VSource>, NULL, &sudFilter[0]}
+ {sudFilter[0].strName, sudFilter[0].clsID, CreateInstance<CD2VSource>, NULL, &sudFilter[0]}
};
int g_cTemplates = countof(g_Templates);
STDAPI DllRegisterServer()
{
- SetRegKeyValue(
- _T("Media Type\\{e436eb83-524f-11ce-9f53-0020af0ba770}"), _T("{47CE0591-C4D5-4b41-BED7-28F59AD76228}"),
- _T("0"), _T("0,18,,4456443241564950726F6A65637446696C65")); // "DVD2AVIProjectFile"
+ SetRegKeyValue(
+ _T("Media Type\\{e436eb83-524f-11ce-9f53-0020af0ba770}"), _T("{47CE0591-C4D5-4b41-BED7-28F59AD76228}"),
+ _T("0"), _T("0,18,,4456443241564950726F6A65637446696C65")); // "DVD2AVIProjectFile"
- SetRegKeyValue(
- _T("Media Type\\{e436eb83-524f-11ce-9f53-0020af0ba770}"), _T("{47CE0591-C4D5-4b41-BED7-28F59AD76228}"),
- _T("Source Filter"), _T("{47CE0591-C4D5-4b41-BED7-28F59AD76228}"));
+ SetRegKeyValue(
+ _T("Media Type\\{e436eb83-524f-11ce-9f53-0020af0ba770}"), _T("{47CE0591-C4D5-4b41-BED7-28F59AD76228}"),
+ _T("Source Filter"), _T("{47CE0591-C4D5-4b41-BED7-28F59AD76228}"));
- SetRegKeyValue(
- _T("Media Type\\Extensions"), _T(".d2v"),
- _T("Source Filter"), _T("{47CE0591-C4D5-4b41-BED7-28F59AD76228}"));
+ SetRegKeyValue(
+ _T("Media Type\\Extensions"), _T(".d2v"),
+ _T("Source Filter"), _T("{47CE0591-C4D5-4b41-BED7-28F59AD76228}"));
- return AMovieDllRegisterServer2(TRUE);
+ return AMovieDllRegisterServer2(TRUE);
}
STDAPI DllUnregisterServer()
{
- DeleteRegKey(_T("Media Type\\{e436eb83-524f-11ce-9f53-0020af0ba770}"), _T("{47CE0591-C4D5-4b41-BED7-28F59AD76228}"));
- DeleteRegKey(_T("Media Type\\Extensions"), _T(".d2v"));
+ DeleteRegKey(_T("Media Type\\{e436eb83-524f-11ce-9f53-0020af0ba770}"), _T("{47CE0591-C4D5-4b41-BED7-28F59AD76228}"));
+ DeleteRegKey(_T("Media Type\\Extensions"), _T(".d2v"));
- return AMovieDllRegisterServer2(FALSE);
+ return AMovieDllRegisterServer2(FALSE);
}
#include "../../FilterApp.h"
@@ -82,9 +82,9 @@ CFilterApp theApp;
//
CD2VSource::CD2VSource(LPUNKNOWN lpunk, HRESULT* phr)
- : CBaseSource<CD2VStream>(NAME("CD2VSource"), lpunk, phr, __uuidof(this))
+ : CBaseSource<CD2VStream>(NAME("CD2VSource"), lpunk, phr, __uuidof(this))
{
- if(phr) *phr = S_OK;
+ if(phr) *phr = S_OK;
}
CD2VSource::~CD2VSource()
@@ -95,40 +95,40 @@ CD2VSource::~CD2VSource()
// CD2VStream
//
-CD2VStream::CD2VStream(const WCHAR* fn, CSource* pParent, HRESULT* phr)
- : CBaseStream(NAME("D2VSourceStream"), pParent, phr)
- , m_pFrameBuffer(NULL)
+CD2VStream::CD2VStream(const WCHAR* fn, CSource* pParent, HRESULT* phr)
+ : CBaseStream(NAME("D2VSourceStream"), pParent, phr)
+ , m_pFrameBuffer(NULL)
{
- CAutoLock cAutoLock(&m_cSharedState);
-
- m_pDecoder.Attach(DNew CMPEG2Dec());
- if(!m_pDecoder)
- {
- if(phr) *phr = E_OUTOFMEMORY;
- return;
- }
-
- if(!m_pDecoder->Open(CString(fn), CMPEG2Dec::YUY2))
- {
- if(phr) *phr = E_FAIL;
- return;
- }
-
- if(!m_pFrameBuffer.Allocate(m_pDecoder->Clip_Width * m_pDecoder->Clip_Height * 4))
- {
- if(phr) *phr = E_OUTOFMEMORY;
- return;
- }
-
- m_AvgTimePerFrame = 10000000000i64 / m_pDecoder->VF_FrameRate;
- m_rtDuration = m_rtStop = m_AvgTimePerFrame * m_pDecoder->VF_FrameLimit;
-
- if(phr) *phr = m_rtDuration > 0 ? S_OK : E_FAIL;
+ CAutoLock cAutoLock(&m_cSharedState);
+
+ m_pDecoder.Attach(DNew CMPEG2Dec());
+ if(!m_pDecoder)
+ {
+ if(phr) *phr = E_OUTOFMEMORY;
+ return;
+ }
+
+ if(!m_pDecoder->Open(CString(fn), CMPEG2Dec::YUY2))
+ {
+ if(phr) *phr = E_FAIL;
+ return;
+ }
+
+ if(!m_pFrameBuffer.Allocate(m_pDecoder->Clip_Width*m_pDecoder->Clip_Height*4))
+ {
+ if(phr) *phr = E_OUTOFMEMORY;
+ return;
+ }
+
+ m_AvgTimePerFrame = 10000000000i64/m_pDecoder->VF_FrameRate;
+ m_rtDuration = m_rtStop = m_AvgTimePerFrame*m_pDecoder->VF_FrameLimit;
+
+ if(phr) *phr = m_rtDuration > 0 ? S_OK : E_FAIL;
}
CD2VStream::~CD2VStream()
{
- CAutoLock cAutoLock(&m_cSharedState);
+ CAutoLock cAutoLock(&m_cSharedState);
}
HRESULT CD2VStream::DecideBufferSize(IMemAllocator* pAlloc, ALLOCATOR_PROPERTIES* pProperties)
@@ -140,12 +140,12 @@ HRESULT CD2VStream::DecideBufferSize(IMemAllocator* pAlloc, ALLOCATOR_PROPERTIES
HRESULT hr = NOERROR;
- int w, h, bpp;
- if(!GetDim(w, h, bpp))
- return E_FAIL;
+ int w, h, bpp;
+ if(!GetDim(w, h, bpp))
+ return E_FAIL;
- pProperties->cBuffers = 1;
- pProperties->cbBuffer = w * h * bpp >> 3;
+ pProperties->cBuffers = 1;
+ pProperties->cbBuffer = w*h*bpp>>3;
ALLOCATOR_PROPERTIES Actual;
if(FAILED(hr = pAlloc->SetProperties(pProperties, &Actual))) return hr;
@@ -158,41 +158,41 @@ HRESULT CD2VStream::DecideBufferSize(IMemAllocator* pAlloc, ALLOCATOR_PROPERTIES
HRESULT CD2VStream::FillBuffer(IMediaSample* pSample, int nFrame, BYTE* pOut, long& len)
{
- if(!m_pDecoder)
- return S_FALSE;
+ if(!m_pDecoder)
+ return S_FALSE;
- AM_MEDIA_TYPE* pmt;
- if(SUCCEEDED(pSample->GetMediaType(&pmt)) && pmt)
- {
- CMediaType mt(*pmt);
- SetMediaType(&mt);
+ AM_MEDIA_TYPE* pmt;
+ if(SUCCEEDED(pSample->GetMediaType(&pmt)) && pmt)
+ {
+ CMediaType mt(*pmt);
+ SetMediaType(&mt);
- DeleteMediaType(pmt);
- }
+ DeleteMediaType(pmt);
+ }
- int w, h, bpp;
- if(!GetDim(w, h, bpp))
- return S_FALSE;
+ int w, h, bpp;
+ if(!GetDim(w, h, bpp))
+ return S_FALSE;
- BYTE* pIn = m_pFrameBuffer;
+ BYTE* pIn = m_pFrameBuffer;
- int pitchIn, pitchOut = 0;
+ int pitchIn, pitchOut = 0;
- pitchIn = m_pDecoder->Clip_Width * bpp >> 3;
- pitchOut = w * bpp >> 3;
+ pitchIn = m_pDecoder->Clip_Width*bpp>>3;
+ pitchOut = w*bpp>>3;
- m_pDecoder->Decode(pIn, (unsigned long)(nFrame), pitchIn);
+ m_pDecoder->Decode(pIn, (unsigned long)(nFrame), pitchIn);
- for(int y = 0, p = min(pitchIn, pitchOut);
- y < h;
- y++, pIn += pitchIn, pOut += pitchOut)
- {
- memcpy(pOut, pIn, p);
- }
+ for(int y = 0, p = min(pitchIn, pitchOut);
+ y < h;
+ y++, pIn += pitchIn, pOut += pitchOut)
+ {
+ memcpy(pOut, pIn, p);
+ }
- len = pitchOut * h;
+ len = pitchOut*h;
- return S_OK;
+ return S_OK;
}
HRESULT CD2VStream::GetMediaType(int iPosition, CMediaType* pmt)
@@ -207,77 +207,77 @@ HRESULT CD2VStream::GetMediaType(int iPosition, CMediaType* pmt)
pmt->SetFormatType(&FORMAT_VideoInfo);
pmt->SetTemporalCompression(FALSE);
- VIDEOINFOHEADER* vih = (VIDEOINFOHEADER*)pmt->AllocFormatBuffer(sizeof(VIDEOINFOHEADER));
- memset(vih, 0, sizeof(VIDEOINFOHEADER));
- vih->AvgTimePerFrame = m_AvgTimePerFrame;
- vih->bmiHeader.biSize = sizeof(vih->bmiHeader);
- vih->bmiHeader.biWidth = m_pDecoder->Clip_Width;
- vih->bmiHeader.biHeight = m_pDecoder->Clip_Height;
- vih->bmiHeader.biPlanes = 1;
- vih->bmiHeader.biBitCount = 16;
- vih->bmiHeader.biCompression = '2YUY';
- vih->bmiHeader.biSizeImage = vih->bmiHeader.biWidth * abs(vih->bmiHeader.biHeight) * vih->bmiHeader.biBitCount >> 3;
+ VIDEOINFOHEADER* vih = (VIDEOINFOHEADER*)pmt->AllocFormatBuffer(sizeof(VIDEOINFOHEADER));
+ memset(vih, 0, sizeof(VIDEOINFOHEADER));
+ vih->AvgTimePerFrame = m_AvgTimePerFrame;
+ vih->bmiHeader.biSize = sizeof(vih->bmiHeader);
+ vih->bmiHeader.biWidth = m_pDecoder->Clip_Width;
+ vih->bmiHeader.biHeight = m_pDecoder->Clip_Height;
+ vih->bmiHeader.biPlanes = 1;
+ vih->bmiHeader.biBitCount = 16;
+ vih->bmiHeader.biCompression = '2YUY';
+ vih->bmiHeader.biSizeImage = vih->bmiHeader.biWidth*abs(vih->bmiHeader.biHeight)*vih->bmiHeader.biBitCount>>3;
- pmt->SetSampleSize(vih->bmiHeader.biSizeImage);
+ pmt->SetSampleSize(vih->bmiHeader.biSizeImage);
return NOERROR;
}
HRESULT CD2VStream::SetMediaType(const CMediaType* pmt)
{
- if(m_pDecoder)
- {
- if(pmt->subtype == MEDIASUBTYPE_YUY2)
- m_pDecoder->m_dstFormat = CMPEG2Dec::YUY2;
- else
- return E_FAIL;
- }
-
- return CSourceStream::SetMediaType(pmt);
+ if(m_pDecoder)
+ {
+ if(pmt->subtype == MEDIASUBTYPE_YUY2)
+ m_pDecoder->m_dstFormat = CMPEG2Dec::YUY2;
+ else
+ return E_FAIL;
+ }
+
+ return CSourceStream::SetMediaType(pmt);
}
HRESULT CD2VStream::CheckMediaType(const CMediaType* pmt)
{
- return pmt->majortype == MEDIATYPE_Video
- && pmt->subtype == MEDIASUBTYPE_YUY2
- && pmt->formattype == FORMAT_VideoInfo
- ? S_OK
- : E_INVALIDARG;
+ return pmt->majortype == MEDIATYPE_Video
+ && pmt->subtype == MEDIASUBTYPE_YUY2
+ && pmt->formattype == FORMAT_VideoInfo
+ ? S_OK
+ : E_INVALIDARG;
}
STDMETHODIMP CD2VStream::Notify(IBaseFilter* pSender, Quality q)
{
- if(q.Late > 0 && q.Late < 100000000)
- {
- CAutoLock cAutoLockShared(&m_cSharedState);
+ if(q.Late > 0 && q.Late < 100000000)
+ {
+ CAutoLock cAutoLockShared(&m_cSharedState);
- m_rtSampleTime += (q.Late / m_AvgTimePerFrame) * m_AvgTimePerFrame;
- m_rtPosition += (q.Late / m_AvgTimePerFrame) * m_AvgTimePerFrame;
- }
+ m_rtSampleTime += (q.Late/m_AvgTimePerFrame)*m_AvgTimePerFrame;
+ m_rtPosition += (q.Late/m_AvgTimePerFrame)*m_AvgTimePerFrame;
+ }
- return S_OK;
+ return S_OK;
}
//
bool CD2VStream::GetDim(int& w, int& h, int& bpp)
{
- 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)
- {
- w = ((VIDEOINFOHEADER2*)m_mt.pbFormat)->bmiHeader.biWidth;
- h = abs(((VIDEOINFOHEADER2*)m_mt.pbFormat)->bmiHeader.biHeight);
- bpp = ((VIDEOINFOHEADER2*)m_mt.pbFormat)->bmiHeader.biBitCount;
- }
- else
- {
- return(false);
- }
-
- return(true);
+ 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)
+ {
+ w = ((VIDEOINFOHEADER2*)m_mt.pbFormat)->bmiHeader.biWidth;
+ h = abs(((VIDEOINFOHEADER2*)m_mt.pbFormat)->bmiHeader.biHeight);
+ bpp = ((VIDEOINFOHEADER2*)m_mt.pbFormat)->bmiHeader.biBitCount;
+ }
+ else
+ {
+ return(false);
+ }
+
+ return(true);
}
diff --git a/src/filters/source/D2VSource/D2VSource.h b/src/filters/source/D2VSource/D2VSource.h
index ac0bddc2d..bf2e18f9a 100644
--- a/src/filters/source/D2VSource/D2VSource.h
+++ b/src/filters/source/D2VSource/D2VSource.h
@@ -1,19 +1,19 @@
-/*
+/*
* Copyright (C) 2003-2006 Gabest
*
* This Program is free software; you can redistribute it and/or modify
* 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.
+ * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
*
*/
@@ -27,8 +27,8 @@ class CD2VStream;
class CD2VSource : public CBaseSource<CD2VStream>
{
public:
- CD2VSource(LPUNKNOWN lpunk, HRESULT* phr);
- virtual ~CD2VSource();
+ CD2VSource(LPUNKNOWN lpunk, HRESULT* phr);
+ virtual ~CD2VSource();
};
class CMPEG2Dec;
@@ -36,14 +36,14 @@ class CMPEG2Dec;
class CD2VStream : public CBaseStream
{
private:
- CAutoPtr<CMPEG2Dec> m_pDecoder;
- CAutoVectorPtr<BYTE> m_pFrameBuffer;
+ CAutoPtr<CMPEG2Dec> m_pDecoder;
+ CAutoVectorPtr<BYTE> m_pFrameBuffer;
- bool GetDim(int& w, int& h, int& bpp);
+ bool GetDim(int& w, int& h, int& bpp);
public:
CD2VStream(const WCHAR* fn, CSource* pParent, HRESULT* phr);
- virtual ~CD2VStream();
+ virtual ~CD2VStream();
HRESULT FillBuffer(IMediaSample* pSample, int nFrame, BYTE* pOut, long& len /*in+out*/);
@@ -52,5 +52,5 @@ public:
HRESULT GetMediaType(int iPosition, CMediaType* pmt);
HRESULT SetMediaType(const CMediaType* pmt);
- STDMETHODIMP Notify(IBaseFilter* pSender, Quality q);
+ STDMETHODIMP Notify(IBaseFilter* pSender, Quality q);
};
diff --git a/src/filters/source/D2VSource/MPEG2Dec.h b/src/filters/source/D2VSource/MPEG2Dec.h
index aea3f4f07..34368208b 100644
--- a/src/filters/source/D2VSource/MPEG2Dec.h
+++ b/src/filters/source/D2VSource/MPEG2Dec.h
@@ -73,244 +73,232 @@
#define FO_SWAP 2
-typedef void (WINAPI *PBufferOp)(unsigned char*, int, int);
+typedef void (WINAPI *PBufferOp) (unsigned char*, int, int);
#define MAX_FRAME_NUMBER 1000000
#define MAX_GOP_SIZE 1024
-class CMPEG2Dec
+class CMPEG2Dec
{
protected:
- // getbit.cpp
- void Initialize_Buffer();
- void Fill_Buffer();
- void Next_Packet();
- void Flush_Buffer_All(unsigned int N);
- unsigned int Get_Bits_All(unsigned int N);
- void Next_File();
-
- unsigned int Show_Bits(unsigned int N);
- unsigned int Get_Bits(unsigned int N);
- void Flush_Buffer(unsigned int N);
- void Fill_Next();
- unsigned int Get_Byte();
- unsigned int Get_Short();
- void next_start_code();
-
- unsigned char Rdbfr[BUFFER_SIZE], *Rdptr, *Rdmax;
- unsigned int CurrentBfr, NextBfr, BitsLeft, Val, Read;
-
- // gethdr.cpp
- int Get_Hdr();
- void sequence_header();
- int slice_header();
+ // getbit.cpp
+ void Initialize_Buffer();
+ void Fill_Buffer();
+ void Next_Packet();
+ void Flush_Buffer_All(unsigned int N);
+ unsigned int Get_Bits_All(unsigned int N);
+ void Next_File();
+
+ unsigned int Show_Bits(unsigned int N);
+ unsigned int Get_Bits(unsigned int N);
+ void Flush_Buffer(unsigned int N);
+ void Fill_Next();
+ unsigned int Get_Byte();
+ unsigned int Get_Short();
+ void next_start_code();
+
+ unsigned char Rdbfr[BUFFER_SIZE], *Rdptr, *Rdmax;
+ unsigned int CurrentBfr, NextBfr, BitsLeft, Val, Read;
+
+ // gethdr.cpp
+ int Get_Hdr();
+ void sequence_header();
+ int slice_header();
private:
- void group_of_pictures_header();
- void picture_header();
- void sequence_extension();
- void sequence_display_extension();
- void quant_matrix_extension();
- void picture_display_extension();
- void picture_coding_extension();
- void copyright_extension();
- int extra_bit_information();
- void extension_and_user_data();
+ void group_of_pictures_header();
+ void picture_header();
+ void sequence_extension();
+ void sequence_display_extension();
+ void quant_matrix_extension();
+ void picture_display_extension();
+ void picture_coding_extension();
+ void copyright_extension();
+ int extra_bit_information();
+ void extension_and_user_data();
protected:
- // getpic.cpp
- void Decode_Picture(int ref, unsigned char *dst, int pitch);
+ // getpic.cpp
+ void Decode_Picture(int ref, unsigned char *dst, int pitch);
private:
- void Update_Picture_Buffers();
- void picture_data();
- int slice(int MBAmax);
- void macroblock_modes(int *pmacroblock_type, int *pmotion_type,
- int *pmotion_vector_count, int *pmv_format, int *pdmv, int *pmvscale, int *pdct_type);
- void Clear_Block(int count);
- void Add_Block(int count, int bx, int by, int dct_type, int addflag);
- void motion_compensation(int MBA, int macroblock_type, int motion_type,
- int PMV[2][2][2], int motion_vertical_field_select[2][2], int dmvector[2], int dct_type);
- void skipped_macroblock(int dc_dct_pred[3], int PMV[2][2][2],
- int *motion_type, int motion_vertical_field_select[2][2], int *macroblock_type);
- int start_of_slice(int *MBA, int *MBAinc, int dc_dct_pred[3], int PMV[2][2][2]);
- int decode_macroblock(int *macroblock_type, int *motion_type, int *dct_type,
- int PMV[2][2][2], int dc_dct_pred[3], int motion_vertical_field_select[2][2], int dmvector[2]);
- void Decode_MPEG2_Intra_Block(int comp, int dc_dct_pred[]);
- void Decode_MPEG2_Non_Intra_Block(int comp);
-
- int Get_macroblock_type();
- int Get_I_macroblock_type();
- int Get_P_macroblock_type();
- int Get_B_macroblock_type();
- int Get_D_macroblock_type();
- int Get_coded_block_pattern();
- int Get_macroblock_address_increment();
- int Get_Luma_DC_dct_diff();
- int Get_Chroma_DC_dct_diff();
-
- void form_predictions(int bx, int by, int macroblock_type, int motion_type,
- int PMV[2][2][2], int motion_vertical_field_select[2][2], int dmvector[2]);
- void form_prediction(unsigned char *src[], int sfield, unsigned char *dst[], int dfield,
- int lx, int lx2, int w, int h, int x, int y, int dx, int dy, int average_flag);
- void form_component_prediction(unsigned char *src, unsigned char *dst,
- int lx, int lx2, int w, int h, int x, int y, int dx, int dy, int average_flag);
-
- // motion.cpp
- void motion_vectors(int PMV[2][2][2], int dmvector[2], int motion_vertical_field_select[2][2],
- int s, int motion_vector_count, int mv_format,
- int h_r_size, int v_r_size, int dmv, int mvscale);
- void Dual_Prime_Arithmetic(int DMV[][2], int *dmvector, int mvx, int mvy);
+ void Update_Picture_Buffers();
+ void picture_data();
+ int slice(int MBAmax);
+ void macroblock_modes(int *pmacroblock_type, int *pmotion_type,
+ int *pmotion_vector_count, int *pmv_format, int *pdmv, int *pmvscale, int *pdct_type);
+ void Clear_Block(int count);
+ void Add_Block(int count, int bx, int by, int dct_type, int addflag);
+ void motion_compensation(int MBA, int macroblock_type, int motion_type,
+ int PMV[2][2][2], int motion_vertical_field_select[2][2], int dmvector[2], int dct_type);
+ void skipped_macroblock(int dc_dct_pred[3], int PMV[2][2][2],
+ int *motion_type, int motion_vertical_field_select[2][2], int *macroblock_type);
+ int start_of_slice(int *MBA, int *MBAinc, int dc_dct_pred[3], int PMV[2][2][2]);
+ int decode_macroblock(int *macroblock_type, int *motion_type, int *dct_type,
+ int PMV[2][2][2], int dc_dct_pred[3], int motion_vertical_field_select[2][2], int dmvector[2]);
+ void Decode_MPEG2_Intra_Block(int comp, int dc_dct_pred[]);
+ void Decode_MPEG2_Non_Intra_Block(int comp);
+
+ int Get_macroblock_type();
+ int Get_I_macroblock_type();
+ int Get_P_macroblock_type();
+ int Get_B_macroblock_type();
+ int Get_D_macroblock_type();
+ int Get_coded_block_pattern();
+ int Get_macroblock_address_increment();
+ int Get_Luma_DC_dct_diff();
+ int Get_Chroma_DC_dct_diff();
+
+ void form_predictions(int bx, int by, int macroblock_type, int motion_type,
+ int PMV[2][2][2], int motion_vertical_field_select[2][2], int dmvector[2]);
+ void form_prediction(unsigned char *src[], int sfield, unsigned char *dst[], int dfield,
+ int lx, int lx2, int w, int h, int x, int y, int dx, int dy, int average_flag);
+ void form_component_prediction(unsigned char *src, unsigned char *dst,
+ int lx, int lx2, int w, int h, int x, int y, int dx, int dy, int average_flag);
+
+ // motion.cpp
+ void motion_vectors(int PMV[2][2][2], int dmvector[2], int motion_vertical_field_select[2][2],
+ int s, int motion_vector_count, int mv_format,
+ int h_r_size, int v_r_size, int dmv, int mvscale);
+ void Dual_Prime_Arithmetic(int DMV[][2], int *dmvector, int mvx, int mvy);
private:
- void motion_vector(int *PMV, int *dmvector, int h_r_size, int v_r_size,
- int dmv, int mvscale, int full_pel_vector);
- void decode_motion_vector(int *pred, int r_size, int motion_code,
- int motion_residualesidual, int full_pel_vector);
- int Get_motion_code();
- int Get_dmvector();
+ void motion_vector(int *PMV, int *dmvector, int h_r_size, int v_r_size,
+ int dmv, int mvscale, int full_pel_vector);
+ void decode_motion_vector(int *pred, int r_size, int motion_code,
+ int motion_residualesidual, int full_pel_vector);
+ int Get_motion_code();
+ int Get_dmvector();
protected:
- // store.cpp
- void assembleFrame(unsigned char *src[], int pf, unsigned char *dst, int pitch);
+ // store.cpp
+ void assembleFrame(unsigned char *src[], int pf, unsigned char *dst, int pitch);
private:
- void Luminance_Filter(unsigned char *src, unsigned char *dst);
- void conv420to422(unsigned char *src, unsigned char *dst, int frame_type);
- void conv422to444(unsigned char *src, unsigned char *dst);
- void conv444toRGB24(unsigned char *py, unsigned char *pu, unsigned char *pv, unsigned char *dst, int pitch);
- void conv422toYUY2(unsigned char *py, unsigned char *pu, unsigned char *pv, unsigned char *dst, int pitch);
+ void Luminance_Filter(unsigned char *src, unsigned char *dst);
+ void conv420to422(unsigned char *src, unsigned char *dst, int frame_type);
+ void conv422to444(unsigned char *src, unsigned char *dst);
+ void conv444toRGB24(unsigned char *py, unsigned char *pu, unsigned char *pv, unsigned char *dst, int pitch);
+ void conv422toYUY2(unsigned char *py, unsigned char *pu, unsigned char *pv, unsigned char *dst, int pitch);
protected:
- // decoder operation control flags
- int Fault_Flag;
- int File_Flag;
- int File_Limit;
- int FO_Flag;
- int IDCT_Flag;
- int SystemStream_Flag;
-
- int Luminance_Flag;
- int Resize_Flag;
-
- int KeyOp_Flag;
- int lfsr0, lfsr1;
- PBufferOp BufferOp;
-
- int Infile[MAX_FILE_NUMBER];
- char *Infilename[MAX_FILE_NUMBER];
-
- int intra_quantizer_matrix[64];
- int non_intra_quantizer_matrix[64];
- int chroma_intra_quantizer_matrix[64];
- int chroma_non_intra_quantizer_matrix[64];
-
- int load_intra_quantizer_matrix;
- int load_non_intra_quantizer_matrix;
- int load_chroma_intra_quantizer_matrix;
- int load_chroma_non_intra_quantizer_matrix;
-
- int q_scale_type;
- int alternate_scan;
- int quantizer_scale;
-
- void *fTempArray, *p_fTempArray;
- short *block[8], *p_block[8];
- int pf_backward, pf_forward, pf_current;
-
- // global values
- unsigned char *backward_reference_frame[3], *forward_reference_frame[3];
- unsigned char *auxframe[3], *current_frame[3];
- unsigned char *u422, *v422, *u444, *v444, /* *rgb24,*/ *lum;
- unsigned char *dstFrame; // replaces rgb24
- __int64 RGB_Scale, RGB_Offset, RGB_CRV, RGB_CBU, RGB_CGX, LumOffsetMask, LumGainMask;
-
- int HALF_WIDTH, PROGRESSIVE_HEIGHT, INTERLACED_HEIGHT, DOUBLE_WIDTH;
- int /*TWIDTH, SWIDTH,*/ HALF_WIDTH_D8, LUM_AREA, CLIP_AREA, HALF_CLIP_AREA, CLIP_STEP;
- int DSTBYTES, DSTBYTES2; // these replace TWIDTH and SWIDTH
+ // decoder operation control flags
+ int Fault_Flag;
+ int File_Flag;
+ int File_Limit;
+ int FO_Flag;
+ int IDCT_Flag;
+ int SystemStream_Flag;
+
+ int Luminance_Flag;
+ int Resize_Flag;
+
+ int KeyOp_Flag;
+ int lfsr0, lfsr1;
+ PBufferOp BufferOp;
+
+ int Infile[MAX_FILE_NUMBER];
+ char *Infilename[MAX_FILE_NUMBER];
+
+ int intra_quantizer_matrix[64];
+ int non_intra_quantizer_matrix[64];
+ int chroma_intra_quantizer_matrix[64];
+ int chroma_non_intra_quantizer_matrix[64];
+
+ int load_intra_quantizer_matrix;
+ int load_non_intra_quantizer_matrix;
+ int load_chroma_intra_quantizer_matrix;
+ int load_chroma_non_intra_quantizer_matrix;
+
+ int q_scale_type;
+ int alternate_scan;
+ int quantizer_scale;
+
+ void *fTempArray, *p_fTempArray;
+ short *block[8], *p_block[8];
+ int pf_backward, pf_forward, pf_current;
+
+ // global values
+ unsigned char *backward_reference_frame[3], *forward_reference_frame[3];
+ unsigned char *auxframe[3], *current_frame[3];
+ unsigned char *u422, *v422, *u444, *v444, /* *rgb24,*/ *lum;
+ unsigned char *dstFrame; // replaces rgb24
+ __int64 RGB_Scale, RGB_Offset, RGB_CRV, RGB_CBU, RGB_CGX, LumOffsetMask, LumGainMask;
+
+ int HALF_WIDTH, PROGRESSIVE_HEIGHT, INTERLACED_HEIGHT, DOUBLE_WIDTH;
+ int /*TWIDTH, SWIDTH,*/ HALF_WIDTH_D8, LUM_AREA, CLIP_AREA, HALF_CLIP_AREA, CLIP_STEP;
+ int DSTBYTES, DSTBYTES2; // these replace TWIDTH and SWIDTH
public:
- int Clip_Width, Clip_Height, Resize_Width, Resize_Height;
+ int Clip_Width, Clip_Height, Resize_Width, Resize_Height;
protected:
- int Coded_Picture_Width, Coded_Picture_Height, Chroma_Width, Chroma_Height;
- int block_count, Second_Field;
- int horizontal_size, vertical_size, mb_width, mb_height;
-
- /* ISO/IEC 13818-2 section 6.2.2.3: sequence_extension() */
- int progressive_sequence;
- int chroma_format;
-
- /* ISO/IEC 13818-2 section 6.2.3: picture_header() */
- int picture_coding_type;
- int temporal_reference;
-
- /* ISO/IEC 13818-2 section 6.2.3.1: picture_coding_extension() header */
- int f_code[2][2];
- int picture_structure;
- int frame_pred_frame_dct;
- int progressive_frame;
- int concealment_motion_vectors;
- int intra_dc_precision;
- int top_field_first;
- int repeat_first_field;
- int intra_vlc_format;
-
- // interface
- typedef struct
- {
- DWORD number;
- int file;
- __int64 position;
- } GOPLIST;
- GOPLIST *GOPList[MAX_FRAME_NUMBER];
-
- typedef struct
- {
- DWORD top;
- DWORD bottom;
- char forward;
- char backward;
- } FRAMELIST;
- FRAMELIST *FrameList[MAX_FRAME_NUMBER];
-
- unsigned char *GOPBuffer[MAX_GOP_SIZE];
+ int Coded_Picture_Width, Coded_Picture_Height, Chroma_Width, Chroma_Height;
+ int block_count, Second_Field;
+ int horizontal_size, vertical_size, mb_width, mb_height;
+
+ /* ISO/IEC 13818-2 section 6.2.2.3: sequence_extension() */
+ int progressive_sequence;
+ int chroma_format;
+
+ /* ISO/IEC 13818-2 section 6.2.3: picture_header() */
+ int picture_coding_type;
+ int temporal_reference;
+
+ /* ISO/IEC 13818-2 section 6.2.3.1: picture_coding_extension() header */
+ int f_code[2][2];
+ int picture_structure;
+ int frame_pred_frame_dct;
+ int progressive_frame;
+ int concealment_motion_vectors;
+ int intra_dc_precision;
+ int top_field_first;
+ int repeat_first_field;
+ int intra_vlc_format;
+
+ // interface
+ typedef struct {
+ DWORD number;
+ int file;
+ __int64 position;
+ } GOPLIST;
+ GOPLIST *GOPList[MAX_FRAME_NUMBER];
+
+ typedef struct {
+ DWORD top;
+ DWORD bottom;
+ char forward;
+ char backward;
+ } FRAMELIST;
+ FRAMELIST *FrameList[MAX_FRAME_NUMBER];
+
+ unsigned char *GOPBuffer[MAX_GOP_SIZE];
public:
- BOOL Field_Order, Full_Frame;
+ BOOL Field_Order, Full_Frame;
protected:
- HINSTANCE hLibrary;
+ HINSTANCE hLibrary;
- void Copyodd(unsigned char *src, unsigned char *dst, int pitch, int forward);
- void Copyeven(unsigned char *src, unsigned char *dst, int pitch, int forward);
+ void Copyodd(unsigned char *src, unsigned char *dst, int pitch, int forward);
+ void Copyeven(unsigned char *src, unsigned char *dst, int pitch, int forward);
public:
- FILE *VF_File;
- int VF_FrameRate;
- DWORD VF_FrameLimit;
- DWORD VF_FrameBound;
- DWORD VF_GOPLimit;
- DWORD VF_GOPNow;
- DWORD VF_GOPSize;
- int VF_FrameSize;
- DWORD VF_OldFrame;
- DWORD VF_OldRef;
-
- enum DstFormat
- {
- RGB24, YUY2
- };
- DstFormat m_dstFormat;
-
- CMPEG2Dec();
- ~CMPEG2Dec()
- {
- Close();
- }
- int Open(LPCTSTR path, DstFormat);
- void Close();
- void Decode(unsigned char *dst, DWORD frame, int pitch);
- bool dstRGB24() const
- {
- return m_dstFormat == RGB24;
- }
- bool dstYUY2() const
- {
- return m_dstFormat == YUY2;
- }
+ FILE *VF_File;
+ int VF_FrameRate;
+ DWORD VF_FrameLimit;
+ DWORD VF_FrameBound;
+ DWORD VF_GOPLimit;
+ DWORD VF_GOPNow;
+ DWORD VF_GOPSize;
+ int VF_FrameSize;
+ DWORD VF_OldFrame;
+ DWORD VF_OldRef;
+
+ enum DstFormat {
+ RGB24, YUY2
+ };
+ DstFormat m_dstFormat;
+
+ CMPEG2Dec();
+ ~CMPEG2Dec() {Close();}
+ int Open(LPCTSTR path, DstFormat);
+ void Close();
+ void Decode(unsigned char *dst, DWORD frame, int pitch);
+ bool dstRGB24() const { return m_dstFormat == RGB24; }
+ bool dstYUY2() const { return m_dstFormat == YUY2; }
};
diff --git a/src/filters/source/D2VSource/idctfpu.cpp b/src/filters/source/D2VSource/idctfpu.cpp
index 0b92b0315..92fcd3954 100644
--- a/src/filters/source/D2VSource/idctfpu.cpp
+++ b/src/filters/source/D2VSource/idctfpu.cpp
@@ -33,7 +33,7 @@
#define FLOAT double
-const static double RC = 1.0 * 1024 * 1024 * 1024 * 1024 * 256 * 16 + 1024; // magic + clip center
+const static double RC = 1.0*1024*1024*1024*1024*256*16 + 1024; // magic + clip center
static FLOAT W1; // /* sqrt(2)*cos(1*pi/16) */
static FLOAT W2; // /* sqrt(2)*cos(2*pi/16) */
@@ -56,7 +56,7 @@ static FLOAT W2mW6; // W2-W6
static FLOAT W2pW6; // W2+W6
static FLOAT S2; // 1/sqrt(2)
-static FLOAT D8 = 1.0 / 8;
+static FLOAT D8 = 1.0/8;
static FLOAT W7_8;
static FLOAT W1mW7_8;
@@ -78,62 +78,56 @@ static short *iclp;
void Initialize_FPU_IDCT()
{
- int i;
-
- S2 = sqrt(0.5); // 1.0/sqrt(2);
-
- W1 = sqrt(2.0) * cos(PI * (1.0 / 16));
- W1_8 = W1 / 8;
- W2 = sqrt(2.0) * cos(PI * (2.0 / 16));
- W2_8 = W2 / 8;
- W3 = sqrt(2.0) * cos(PI * (3.0 / 16));
- W3_8 = W3 / 8;
- W5 = sqrt(2.0) * cos(PI * (5.0 / 16));
- W5_8 = W5 / 8;
- W6 = sqrt(2.0) * cos(PI * (6.0 / 16));
- W6_8 = W6 / 8;
- W7 = sqrt(2.0) * cos(PI * (7.0 / 16));
- W7_8 = W7 / 8;
-
- W1mW7 = W1 - W7;
- W1mW7_8 = W1mW7 / 8;
- W1pW7 = W1 + W7;
- W1pW7_8 = W1pW7 / 8;
- W3mW5 = W3 - W5;
- W3mW5_8 = W3mW5 / 8;
- W3pW5 = W3 + W5;
- W3pW5_8 = W3pW5 / 8;
- W2mW6 = W2 - W6;
- W2mW6_8 = W2mW6 / 8;
- W2pW6 = W2 + W6;
- W2pW6_8 = W2pW6 / 8;
-
- iclp = iclip + 1024;
- for(i = -1024; i < 1024; i++)
- iclp[i] = (i < -256) ? -256 : ((i > 255) ? 255 : i);
+ int i;
+
+ S2 = sqrt(0.5); // 1.0/sqrt(2);
+
+ W1 = sqrt(2.0)*cos(PI*(1.0/16));
+ W1_8 = W1/8;
+ W2 = sqrt(2.0)*cos(PI*(2.0/16));
+ W2_8 = W2/8;
+ W3 = sqrt(2.0)*cos(PI*(3.0/16));
+ W3_8 = W3/8;
+ W5 = sqrt(2.0)*cos(PI*(5.0/16));
+ W5_8 = W5/8;
+ W6 = sqrt(2.0)*cos(PI*(6.0/16));
+ W6_8 = W6/8;
+ W7 = sqrt(2.0)*cos(PI*(7.0/16));
+ W7_8 = W7/8;
+
+ W1mW7 = W1-W7; W1mW7_8 = W1mW7/8;
+ W1pW7 = W1+W7; W1pW7_8 = W1pW7/8;
+ W3mW5 = W3-W5; W3mW5_8 = W3mW5/8;
+ W3pW5 = W3+W5; W3pW5_8 = W3pW5/8;
+ W2mW6 = W2-W6; W2mW6_8 = W2mW6/8;
+ W2pW6 = W2+W6; W2pW6_8 = W2pW6/8;
+
+ iclp = iclip+1024;
+ for (i= -1024; i<1024; i++)
+ iclp[i] = (i<-256) ? -256 : ((i>255) ? 255 : i);
}
void FPU_IDCT(short *block)
{
- int *b = (int *) block;
- if(b[0] == 0 && (b[31] == 0x10000 || b[31] == 0))
- {
- if(b[ 1] | b[ 2] | b[ 3] | b[ 4] | b[ 5])
- goto normal;
- if(b[ 6] | b[ 7] | b[ 8] | b[ 9] | b[10])
- goto normal;
- if(b[11] | b[12] | b[13] | b[14] | b[15])
- goto normal;
- if(b[16] | b[17] | b[18] | b[19] | b[20])
- goto normal;
- if(b[21] | b[22] | b[23] | b[24] | b[25])
- goto normal;
- if(b[26] | b[27] | b[28] | b[29] | b[30])
- goto normal;
- b[31] = 0;
- ////empty++;
- return;
- }
+ int *b = (int *) block;
+ if( b[0]==0 && (b[31]==0x10000 || b[31]==0) )
+ {
+ if( b[ 1]|b[ 2]|b[ 3]|b[ 4]|b[ 5] )
+ goto normal;
+ if( b[ 6]|b[ 7]|b[ 8]|b[ 9]|b[10] )
+ goto normal;
+ if( b[11]|b[12]|b[13]|b[14]|b[15] )
+ goto normal;
+ if( b[16]|b[17]|b[18]|b[19]|b[20] )
+ goto normal;
+ if( b[21]|b[22]|b[23]|b[24]|b[25] )
+ goto normal;
+ if( b[26]|b[27]|b[28]|b[29]|b[30] )
+ goto normal;
+ b[31]=0;
+ ////empty++;
+ return;
+ }
normal:
#define tmp ebx
@@ -149,314 +143,314 @@ normal:
#define int6 ebx-3*8-7*4
#define int7 ebx-3*8-8*4
#define SIZE 8*8*8+3*8+8*4+16 // locals + 16-byte alignment area
- __asm
- {
- lea ebx, [esp-8*8*8]
- sub esp, SIZE
- and ebx, -16 // force 16-byte alignment of locals
+ __asm
+ {
+ lea ebx,[esp-8*8*8]
+ sub esp,SIZE
+ and ebx,-16 // force 16-byte alignment of locals
// rows
- mov esi, [block]
- lea edi, [tmp]
- mov ecx, 8
-
- align 16
- Lrows:
- movsx eax, word ptr [esi+2]
- or eax, [esi+4]
- or eax, [esi+8]
- or eax, [esi+12]
- jnz L1
-
- fild word ptr [esi+0*2]
- fst qword ptr [edi+7*8]
- fst qword ptr [edi+6*8]
- fst qword ptr [edi+5*8]
- fst qword ptr [edi+4*8]
- fst qword ptr [edi+3*8]
- fst qword ptr [edi+2*8]
- fst qword ptr [edi+1*8]
- fstp qword ptr [edi+0*8]
- jmp L2
-
- align 16
- L1:
-
- fild word ptr [esi+7*2]
- fld st(0)
- fild word ptr [esi+1*2]
- fadd st(1), st(0)
- fld qword ptr [W7]
- fxch st(1)
- fmul qword ptr [W1mW7]
- fxch st(1)
- fmulp st(2), st(0)
- fadd st(0), st(1)
- fstp qword ptr [tmp1]
- fild word ptr [esi+3*2]
- fld st(0)
- fxch st(3)
- fmul qword ptr [W1pW7]
- fild word ptr [esi+5*2]
- fadd st(4), st(0)
- fmul qword ptr [W3mW5]
- fxch st(1)
- fsubp st(3), st(0) //fsubrp
- fld qword ptr [W3]
- fmulp st(4), st(0)
- fsubr st(0), st(3)
- fstp qword ptr [tmp2]
- fmul qword ptr [W3pW5]
- fsubp st(2), st(0) //fsubrp
- fxch st(1)
- fstp qword ptr [tmp3]
- fild word ptr [esi+0*2]
- fild word ptr [esi+4*2]
- fild word ptr [esi+2*2]
- fld st(0)
- fmul qword ptr [W2mW6]
- fld st(3)
- fild word ptr [esi+6*2]
- fxch st(5)
- fsub st(0), st(4)
- fxch st(3)
- fadd st(0), st(5)
- fxch st(1)
- faddp st(4), st(0)
- fld qword ptr [W6]
- fmulp st(1), st(0)
- fxch st(4)
- fmul qword ptr [W2pW6]
- fld qword ptr [tmp1]
- fsub qword ptr [tmp2]
- fld st(5)
- fxch st(3)
- faddp st(6), st(0)
- fld qword ptr [tmp1]
- fxch st(1)
- fstp qword ptr [tmp1]
- fld st(6)
- fadd qword ptr [tmp3]
- fxch st(1)
- fadd qword ptr [tmp2]
- fxch st(7)
- fsub qword ptr [tmp3]
- fxch st(1)
- fstp qword ptr [tmp2]
- fld st(4)
- fxch st(3)
- fsubrp st(2), st(0) //fsubp
- fxch st(4)
- fsub st(0), st(5)
- fxch st(2)
- faddp st(5), st(0)
- fld st(2)
- fsub st(0), st(1)
- fxch st(5)
- fstp qword ptr [tmp3]
- fld qword ptr [tmp1]
- fld qword ptr [S2]
- fxch st(4)
- faddp st(2), st(0)
- fld st(3)
- fxch st(1)
- fadd st(0), st(5)
- fmulp st(1), st(0)
-
- fld qword ptr [tmp3]
- fadd st(0), st(7)
- fxch st(5)
- fsubr qword ptr [tmp1]
- fxch st(5)
- fstp qword ptr [edi+0*8]
- fxch st(6)
- fsubr qword ptr [tmp3]
- fld st(2)
- fxch st(1)
- fstp qword ptr [edi+7*8]
- fadd qword ptr [tmp2]
- fxch st(3)
- fmulp st(4), st(0)
- fxch st(2)
- fstp qword ptr [edi+3*8]
- fld st(1)
- fadd st(0), st(5)
- fxch st(1)
- fsub qword ptr [tmp2]
- fxch st(2)
- fsubrp st(5), st(0) //fsubp
- fstp qword ptr [edi+1*8]
- fld st(2)
- fxch st(1)
- fstp qword ptr [edi+4*8]
- fxch st(2)
- fsub st(0), st(1)
- fxch st(2)
- faddp st(1), st(0)
- fxch st(2)
- fstp qword ptr [edi+6*8]
- fstp qword ptr [edi+5*8]
- fstp qword ptr [edi+2*8]
- L2:
- add esi, 8*2
- add edi, 8*8
- dec ecx
- jnz Lrows
+ mov esi,[block]
+ lea edi,[tmp]
+ mov ecx,8
+
+ align 16
+Lrows:
+ movsx eax,word ptr [esi+2]
+ or eax, [esi+4]
+ or eax, [esi+8]
+ or eax, [esi+12]
+ jnz L1
+
+ fild word ptr [esi+0*2]
+ fst qword ptr [edi+7*8]
+ fst qword ptr [edi+6*8]
+ fst qword ptr [edi+5*8]
+ fst qword ptr [edi+4*8]
+ fst qword ptr [edi+3*8]
+ fst qword ptr [edi+2*8]
+ fst qword ptr [edi+1*8]
+ fstp qword ptr [edi+0*8]
+ jmp L2
+
+ align 16
+ L1:
+
+ fild word ptr [esi+7*2]
+ fld st(0)
+ fild word ptr [esi+1*2]
+ fadd st(1),st(0)
+ fld qword ptr [W7]
+ fxch st(1)
+ fmul qword ptr [W1mW7]
+ fxch st(1)
+ fmulp st(2),st(0)
+ fadd st(0),st(1)
+ fstp qword ptr [tmp1]
+ fild word ptr [esi+3*2]
+ fld st(0)
+ fxch st(3)
+ fmul qword ptr [W1pW7]
+ fild word ptr [esi+5*2]
+ fadd st(4),st(0)
+ fmul qword ptr [W3mW5]
+ fxch st(1)
+ fsubp st(3),st(0)//fsubrp
+ fld qword ptr [W3]
+ fmulp st(4),st(0)
+ fsubr st(0),st(3)
+ fstp qword ptr [tmp2]
+ fmul qword ptr [W3pW5]
+ fsubp st(2),st(0)//fsubrp
+ fxch st(1)
+ fstp qword ptr [tmp3]
+ fild word ptr [esi+0*2]
+ fild word ptr [esi+4*2]
+ fild word ptr [esi+2*2]
+ fld st(0)
+ fmul qword ptr [W2mW6]
+ fld st(3)
+ fild word ptr [esi+6*2]
+ fxch st(5)
+ fsub st(0),st(4)
+ fxch st(3)
+ fadd st(0),st(5)
+ fxch st(1)
+ faddp st(4),st(0)
+ fld qword ptr [W6]
+ fmulp st(1),st(0)
+ fxch st(4)
+ fmul qword ptr [W2pW6]
+ fld qword ptr [tmp1]
+ fsub qword ptr [tmp2]
+ fld st(5)
+ fxch st(3)
+ faddp st(6),st(0)
+ fld qword ptr [tmp1]
+ fxch st(1)
+ fstp qword ptr [tmp1]
+ fld st(6)
+ fadd qword ptr [tmp3]
+ fxch st(1)
+ fadd qword ptr [tmp2]
+ fxch st(7)
+ fsub qword ptr [tmp3]
+ fxch st(1)
+ fstp qword ptr [tmp2]
+ fld st(4)
+ fxch st(3)
+ fsubrp st(2),st(0)//fsubp
+ fxch st(4)
+ fsub st(0),st(5)
+ fxch st(2)
+ faddp st(5),st(0)
+ fld st(2)
+ fsub st(0),st(1)
+ fxch st(5)
+ fstp qword ptr [tmp3]
+ fld qword ptr [tmp1]
+ fld qword ptr [S2]
+ fxch st(4)
+ faddp st(2),st(0)
+ fld st(3)
+ fxch st(1)
+ fadd st(0),st(5)
+ fmulp st(1),st(0)
+
+ fld qword ptr [tmp3]
+ fadd st(0),st(7)
+ fxch st(5)
+ fsubr qword ptr [tmp1]
+ fxch st(5)
+ fstp qword ptr [edi+0*8]
+ fxch st(6)
+ fsubr qword ptr [tmp3]
+ fld st(2)
+ fxch st(1)
+ fstp qword ptr [edi+7*8]
+ fadd qword ptr [tmp2]
+ fxch st(3)
+ fmulp st(4),st(0)
+ fxch st(2)
+ fstp qword ptr [edi+3*8]
+ fld st(1)
+ fadd st(0),st(5)
+ fxch st(1)
+ fsub qword ptr [tmp2]
+ fxch st(2)
+ fsubrp st(5),st(0)//fsubp
+ fstp qword ptr [edi+1*8]
+ fld st(2)
+ fxch st(1)
+ fstp qword ptr [edi+4*8]
+ fxch st(2)
+ fsub st(0),st(1)
+ fxch st(2)
+ faddp st(1),st(0)
+ fxch st(2)
+ fstp qword ptr [edi+6*8]
+ fstp qword ptr [edi+5*8]
+ fstp qword ptr [edi+2*8]
+ L2:
+ add esi,8*2
+ add edi,8*8
+ dec ecx
+ jnz Lrows
// columns
- lea esi, [tmp]
- mov edi, [block]
- lea edx, [iclip+1024*2]
- mov ecx, 8
-
- align 16
- Lcols:
- fld qword ptr [esi+7*8*8]
- fld st(0)
- fld qword ptr [esi+1*8*8]
- fadd st(1), st(0)
- fld qword ptr [W7_8]
- fxch st(1)
- fmul qword ptr [W1mW7_8]
- fxch st(1)
- fmulp st(2), st(0)
- fadd st(0), st(1)
- fstp qword ptr [tmp2]
- fld qword ptr [esi+3*8*8]
- fld st(0)
- fxch st(3)
- fmul qword ptr [W1pW7_8]
- fld qword ptr [esi+5*8*8]
- fadd st(4), st(0)
- fmul qword ptr [W3mW5_8]
- fxch st(1)
- fsubp st(3), st(0) //fsubrp
- fld qword ptr [W3_8]
- fmulp st(4), st(0)
- fsubr st(0), st(3)
- fstp qword ptr [tmp3]
- fld qword ptr [D8]
- fld qword ptr [esi+0*8*8]
- fmul st(0), st(1)
- fxch st(2)
- fmul qword ptr [W3pW5_8]
- fld qword ptr [esi+4*8*8]
- fmulp st(2), st(0)
- fld qword ptr [esi+6*8*8]
- fld st(3)
- fxch st(6)
- fsubrp st(2), st(0) //fsubp
- fld qword ptr [esi+2*8*8]
- fld st(0)
- fxch st(5)
- fsub st(0), st(4)
- fxch st(7)
- faddp st(4), st(0)
- fxch st(4)
- fadd st(0), st(1)
- fld qword ptr [W6_8]
- fxch st(2)
- fmul qword ptr [W2pW6_8]
- fxch st(2)
- fmulp st(1), st(0)
- fxch st(4)
- fmul qword ptr [W2mW6_8]
- fld qword ptr [tmp2]
- fsub qword ptr [tmp3]
- fxch st(2)
- fsubr st(0), st(5)
- fxch st(1)
- faddp st(5), st(0)
- fld qword ptr [tmp2]
- fxch st(2)
- fstp qword ptr [tmp2]
- fld st(5)
- fxch st(2)
- fadd qword ptr [tmp3]
- fxch st(6)
- fsub st(0), st(3)
- fxch st(2)
- faddp st(3), st(0)
- fld st(3)
- fsub st(0), st(5)
- fxch st(3)
- fstp qword ptr [tmp3]
- fxch st(3)
- faddp st(4), st(0)
- fld st(5)
- fld qword ptr [tmp2]
- fxch st(7)
- fsub st(0), st(4)
- fxch st(7)
- fadd st(0), st(2)
- fxch st(1)
- faddp st(4), st(0)
- fld qword ptr [S2]
- fmul st(1), st(0)
- fxch st(1)
- fstp qword ptr [tmp1]
- fld st(4)
- fadd st(0), st(6)
- fxch st(2)
- fsubr qword ptr [tmp2]
- fxch st(5)
- fsubrp st(6), st(0) //fsubp
- fxch st(1)
- fistp dword ptr [int0]
- fxch st(4)
- mov eax, [int0]
- movsx eax, word ptr [edx+2*eax]
- mov [edi+0*8*2], ax
- fistp dword ptr [int7]
- mov eax, [int7]
- fld st(0)
- movsx eax, word ptr [edx+2*eax]
- mov [edi+7*8*2], ax
- fadd qword ptr [tmp3]
- fistp dword ptr [int3]
- mov eax, [int3]
- movsx eax, word ptr [edx+2*eax]
- mov [edi+3*8*2], ax
- fsub qword ptr [tmp3]
- fld st(1)
- fxch st(1)
- fistp dword ptr [int4]
- mov eax, [int4]
- movsx eax, word ptr [edx+2*eax]
- mov [edi+4*8*2], ax
- fadd qword ptr [tmp1]
- fxch st(3)
- fmulp st(2), st(0)
- fxch st(2)
- fistp dword ptr [int1]
- fxch st(1)
- mov eax, [int1]
- movsx eax, word ptr [edx+2*eax]
- mov [edi+1*8*2], ax
- fsub qword ptr [tmp1]
- fld st(2)
- fsub st(0), st(2)
- fxch st(1)
- fistp dword ptr [int6]
- fxch st(2)
- mov eax, [int6]
- faddp st(1), st(0)
- movsx eax, word ptr [edx+2*eax]
- mov [edi+6*8*2], ax
- fistp dword ptr [int2]
- mov eax, [int2]
- movsx eax, word ptr [edx+2*eax]
- mov [edi+2*8*2], ax
- fistp dword ptr [int5]
- mov eax, [int5]
- movsx eax, word ptr [edx+2*eax]
- mov [edi+5*8*2], ax
-
- add esi, 8
- add edi, 2
- dec ecx
- jnz Lcols
-
- add esp, SIZE
- }
+ lea esi,[tmp]
+ mov edi,[block]
+ lea edx,[iclip+1024*2]
+ mov ecx,8
+
+ align 16
+Lcols:
+ fld qword ptr [esi+7*8*8]
+ fld st(0)
+ fld qword ptr [esi+1*8*8]
+ fadd st(1),st(0)
+ fld qword ptr [W7_8]
+ fxch st(1)
+ fmul qword ptr [W1mW7_8]
+ fxch st(1)
+ fmulp st(2),st(0)
+ fadd st(0),st(1)
+ fstp qword ptr [tmp2]
+ fld qword ptr [esi+3*8*8]
+ fld st(0)
+ fxch st(3)
+ fmul qword ptr [W1pW7_8]
+ fld qword ptr [esi+5*8*8]
+ fadd st(4),st(0)
+ fmul qword ptr [W3mW5_8]
+ fxch st(1)
+ fsubp st(3),st(0)//fsubrp
+ fld qword ptr [W3_8]
+ fmulp st(4),st(0)
+ fsubr st(0),st(3)
+ fstp qword ptr [tmp3]
+ fld qword ptr [D8]
+ fld qword ptr [esi+0*8*8]
+ fmul st(0),st(1)
+ fxch st(2)
+ fmul qword ptr [W3pW5_8]
+ fld qword ptr [esi+4*8*8]
+ fmulp st(2),st(0)
+ fld qword ptr [esi+6*8*8]
+ fld st(3)
+ fxch st(6)
+ fsubrp st(2),st(0)//fsubp
+ fld qword ptr [esi+2*8*8]
+ fld st(0)
+ fxch st(5)
+ fsub st(0),st(4)
+ fxch st(7)
+ faddp st(4),st(0)
+ fxch st(4)
+ fadd st(0),st(1)
+ fld qword ptr [W6_8]
+ fxch st(2)
+ fmul qword ptr [W2pW6_8]
+ fxch st(2)
+ fmulp st(1),st(0)
+ fxch st(4)
+ fmul qword ptr [W2mW6_8]
+ fld qword ptr [tmp2]
+ fsub qword ptr [tmp3]
+ fxch st(2)
+ fsubr st(0),st(5)
+ fxch st(1)
+ faddp st(5),st(0)
+ fld qword ptr [tmp2]
+ fxch st(2)
+ fstp qword ptr [tmp2]
+ fld st(5)
+ fxch st(2)
+ fadd qword ptr [tmp3]
+ fxch st(6)
+ fsub st(0),st(3)
+ fxch st(2)
+ faddp st(3),st(0)
+ fld st(3)
+ fsub st(0),st(5)
+ fxch st(3)
+ fstp qword ptr [tmp3]
+ fxch st(3)
+ faddp st(4),st(0)
+ fld st(5)
+ fld qword ptr [tmp2]
+ fxch st(7)
+ fsub st(0),st(4)
+ fxch st(7)
+ fadd st(0),st(2)
+ fxch st(1)
+ faddp st(4),st(0)
+ fld qword ptr [S2]
+ fmul st(1),st(0)
+ fxch st(1)
+ fstp qword ptr [tmp1]
+ fld st(4)
+ fadd st(0),st(6)
+ fxch st(2)
+ fsubr qword ptr [tmp2]
+ fxch st(5)
+ fsubrp st(6),st(0)//fsubp
+ fxch st(1)
+ fistp dword ptr [int0]
+ fxch st(4)
+ mov eax,[int0]
+ movsx eax,word ptr [edx+2*eax]
+ mov [edi+0*8*2],ax
+ fistp dword ptr [int7]
+ mov eax,[int7]
+ fld st(0)
+ movsx eax,word ptr [edx+2*eax]
+ mov [edi+7*8*2],ax
+ fadd qword ptr [tmp3]
+ fistp dword ptr [int3]
+ mov eax,[int3]
+ movsx eax,word ptr [edx+2*eax]
+ mov [edi+3*8*2],ax
+ fsub qword ptr [tmp3]
+ fld st(1)
+ fxch st(1)
+ fistp dword ptr [int4]
+ mov eax,[int4]
+ movsx eax,word ptr [edx+2*eax]
+ mov [edi+4*8*2],ax
+ fadd qword ptr [tmp1]
+ fxch st(3)
+ fmulp st(2),st(0)
+ fxch st(2)
+ fistp dword ptr [int1]
+ fxch st(1)
+ mov eax,[int1]
+ movsx eax,word ptr [edx+2*eax]
+ mov [edi+1*8*2],ax
+ fsub qword ptr [tmp1]
+ fld st(2)
+ fsub st(0),st(2)
+ fxch st(1)
+ fistp dword ptr [int6]
+ fxch st(2)
+ mov eax,[int6]
+ faddp st(1),st(0)
+ movsx eax,word ptr [edx+2*eax]
+ mov [edi+6*8*2],ax
+ fistp dword ptr [int2]
+ mov eax,[int2]
+ movsx eax,word ptr [edx+2*eax]
+ mov [edi+2*8*2],ax
+ fistp dword ptr [int5]
+ mov eax,[int5]
+ movsx eax,word ptr [edx+2*eax]
+ mov [edi+5*8*2],ax
+
+ add esi,8
+ add edi,2
+ dec ecx
+ jnz Lcols
+
+ add esp,SIZE
+ }
}
diff --git a/src/filters/source/D2VSource/idctref.cpp b/src/filters/source/D2VSource/idctref.cpp
index 2c1024692..74b695ce1 100644
--- a/src/filters/source/D2VSource/idctref.cpp
+++ b/src/filters/source/D2VSource/idctref.cpp
@@ -40,323 +40,323 @@ static double c[8][8];
/* initialize DCT coefficient matrix */
void Initialize_REF_IDCT()
{
- int freq, time, i;
- double scale;
+ int freq, time, i;
+ double scale;
- for(freq = 0; freq < 8; freq++)
- {
- scale = (freq == 0) ? sqrt(0.125) : 0.5;
- for(time = 0; time < 8; time++)
- c[freq][time] = scale * cos((M_PI / 8.0) * freq * (time + 0.5));
- }
+ for (freq=0; freq < 8; freq++)
+ {
+ scale = (freq == 0) ? sqrt(0.125) : 0.5;
+ for (time=0; time<8; time++)
+ c[freq][time] = scale*cos((M_PI/8.0)*freq*(time + 0.5));
+ }
#ifdef ModelX
- iclp = iclip + 1024;
- for(i = -1024; i < 1024; i++)
- iclp[i] = (i < -256) ? -256 : ((i > 255) ? 255 : i);
+ iclp = iclip+1024;
+ for (i= -1024; i<1024; i++)
+ iclp[i] = (i<-256) ? -256 : ((i>255) ? 255 : i);
#endif
}
void REF_IDCT(short *block)
{
- double tmp[64];
- double rnd[64];
- int int0, int1, int2, int3, int4, int5, int6, int7;
- unsigned short fpold;
- unsigned short fpnew;
-
- int *b = (int *) block;
-
- if(!(b[0] | (b[31]&~0x10000)))
- {
- if(b[ 1] | b[ 2] | b[ 3] | b[ 4] | b[ 5] | b[ 6])
- goto normal;
- if(b[ 7] | b[ 8] | b[ 9] | b[10] | b[11] | b[12])
- goto normal;
- if(b[13] | b[14] | b[15] | b[16] | b[17] | b[18])
- goto normal;
- if(b[19] | b[20] | b[21] | b[22] | b[23] | b[24])
- goto normal;
- if(b[25] | b[26] | b[27] | b[28] | b[29] | b[30])
- goto normal;
- b[31] = 0;
- return;
- }
+ double tmp[64];
+ double rnd[64];
+ int int0, int1, int2, int3, int4, int5, int6, int7;
+ unsigned short fpold;
+ unsigned short fpnew;
+
+ int *b = (int *) block;
+
+ if( !(b[0]|(b[31]&~0x10000)) )
+ {
+ if( b[ 1]|b[ 2]|b[ 3]|b[ 4]|b[ 5]|b[ 6] )
+ goto normal;
+ if( b[ 7]|b[ 8]|b[ 9]|b[10]|b[11]|b[12] )
+ goto normal;
+ if( b[13]|b[14]|b[15]|b[16]|b[17]|b[18] )
+ goto normal;
+ if( b[19]|b[20]|b[21]|b[22]|b[23]|b[24] )
+ goto normal;
+ if( b[25]|b[26]|b[27]|b[28]|b[29]|b[30] )
+ goto normal;
+ b[31]=0;
+ return;
+ }
normal:
- __asm
- {
- // do the IDCT
- mov esi, [block]
- lea eax, [c]
- lea edi, [tmp]
- //mov ebx,8
- mov ebx, 8 // 0x77000000 // 8
- align 16
- __col1:
- movzx edx, [esi+1*2]
- mov ecx, [esi+2*2]
- or edx, [esi+4*2]
- or ecx, [esi+6*2]
- or edx, ecx
- //mov ecx,8
- mov ecx, 8/2 // 0x77000000 // 8
-
- jnz __row1
- fild word ptr [esi+0*2]
- fmul qword ptr [eax+0*8*8]
- fst qword ptr [edi+0*8]
- fst qword ptr [edi+1*8]
- fst qword ptr [edi+2*8]
- fst qword ptr [edi+3*8]
- fst qword ptr [edi+4*8]
- fst qword ptr [edi+5*8]
- fst qword ptr [edi+6*8]
- fstp qword ptr [edi+7*8]
- add edi, 8*8
- jmp __next1
- align 16
- __row1:
- fild word ptr [esi+0*2]
- fmul qword ptr [eax+0*8*8]
- fild word ptr [esi+1*2]
- fmul qword ptr [eax+1*8*8]
- fadd
- fild word ptr [esi+2*2]
- fmul qword ptr [eax+2*8*8]
- fadd
- fild word ptr [esi+3*2]
- fmul qword ptr [eax+3*8*8]
- fadd
- fild word ptr [esi+4*2]
- fmul qword ptr [eax+4*8*8]
- fadd
- fild word ptr [esi+5*2]
- fmul qword ptr [eax+5*8*8]
- fadd
- fild word ptr [esi+6*2]
- fmul qword ptr [eax+6*8*8]
- fadd
- fild word ptr [esi+7*2]
- fmul qword ptr [eax+7*8*8]
- fadd
-
- fild word ptr [esi+0*2]
- fmul qword ptr [eax+0*8*8+8]
- fild word ptr [esi+1*2]
- fmul qword ptr [eax+1*8*8+8]
- fadd
- fild word ptr [esi+2*2]
- fmul qword ptr [eax+2*8*8+8]
- fadd
- fild word ptr [esi+3*2]
- fmul qword ptr [eax+3*8*8+8]
- fadd
- fild word ptr [esi+4*2]
- fmul qword ptr [eax+4*8*8+8]
- fadd
- fild word ptr [esi+5*2]
- fmul qword ptr [eax+5*8*8+8]
- fadd
- fild word ptr [esi+6*2]
- fmul qword ptr [eax+6*8*8+8]
- fadd
- fild word ptr [esi+7*2]
- fmul qword ptr [eax+7*8*8+8]
- fadd
- add eax, 8*2
- fxch st(1)
- fstp qword ptr [edi]//
- fstp qword ptr [edi+8]
- add edi, 8*2
- dec ecx
-
- jnz __row1
- add eax, -8*8
- //align 16
- __next1:
- add esi, +8*2
-
- sub ebx, 0x80000001 // add ebx,ebx
- js __col1
- //align 16
- test ebx, ebx // align jump &| redo flags
- jnz __col1
-
- lea esi, [tmp]
- lea eax, [c]
- lea edi, [rnd]
- //mov edi,[block]
- fld qword ptr [HALF]
- mov ebx, 8
- __row2:
- mov ecx, 8/2
- align 16
- __col2:
- fld qword ptr [esi+0*8*8]
- fmul qword ptr [eax+0*8*8]
- fld qword ptr [esi+1*8*8]
- fmul qword ptr [eax+1*8*8]
- fadd
- fld qword ptr [esi+2*8*8]
- fmul qword ptr [eax+2*8*8]
- fadd
- fld qword ptr [esi+3*8*8]
- fmul qword ptr [eax+3*8*8]
- fadd
- fld qword ptr [esi+4*8*8]
- fmul qword ptr [eax+4*8*8]
- fadd
- fld qword ptr [esi+5*8*8]
- fmul qword ptr [eax+5*8*8]
- fadd
- fld qword ptr [esi+6*8*8]
- fmul qword ptr [eax+6*8*8]
- fadd
- fld qword ptr [esi+7*8*8]
- fmul qword ptr [eax+7*8*8]
- fadd
- fadd st(0), st(1)
-
- fxch st(1)
-
- fld qword ptr [esi+0*8*8]
- fmul qword ptr [eax+0*8*8+8]
- fld qword ptr [esi+1*8*8]
- fmul qword ptr [eax+1*8*8+8]
- fadd
- fld qword ptr [esi+2*8*8]
- fmul qword ptr [eax+2*8*8+8]
- fadd
- fld qword ptr [esi+3*8*8]
- fmul qword ptr [eax+3*8*8+8]
- fadd
- fld qword ptr [esi+4*8*8]
- fmul qword ptr [eax+4*8*8+8]
- fadd
- fld qword ptr [esi+5*8*8]
- fmul qword ptr [eax+5*8*8+8]
- fadd
- fld qword ptr [esi+6*8*8]
- fmul qword ptr [eax+6*8*8+8]
- fadd
- fld qword ptr [esi+7*8*8]
- fmul qword ptr [eax+7*8*8+8]
- fadd
- fadd st(0), st(1)
- add eax, 8*2
-
- fxch st(2)
- fstp qword ptr [edi]
- fxch st(1)
- fstp qword ptr [edi+8*8]
- add edi, 8*8*2
-
- dec ecx
-
- jnz __col2
- add eax, -8*8
- add esi, +8
- add edi, 8-8*8*8
-
- sub ebx, 0x80000001
- js __row2
- //align 16
- test ebx, ebx // align jump &| redo flags
- jnz __row2
- ffree st(0) // bye bye 0.5
-
- // set x87 to floor mode
- fstcw [fpold]
- movzx eax, [fpold]
-
- or eax, 0x0400 // round down - floor
- mov [fpnew], ax
- fldcw [fpnew]
-
- // now floor the damn array
- lea esi, [rnd]
- mov edi, [block]
- mov ebx, -256 // clip min
- mov edx, +255 // clip max
- mov ecx, 8
- align 16
- __floor:
- fld qword ptr [esi+0*8]
- fistp dword ptr [int0]
- mov eax, [int0]
- cmp eax, ebx
- cmovl eax, ebx
- cmp eax, edx
- cmovg eax, edx
- fld qword ptr [esi+1*8]
- fistp dword ptr [int1]
- mov word ptr [edi+0*2], ax
- mov eax, [int1]
- cmp eax, ebx
- cmovl eax, ebx
- cmp eax, edx
- cmovg eax, edx
- fld qword ptr [esi+2*8]
- fistp dword ptr [int2]
- mov word ptr [edi+1*2], ax
- mov eax, [int2]
- cmp eax, ebx
- cmovl eax, ebx
- cmp eax, edx
- cmovg eax, edx
- fld qword ptr [esi+3*8]
- fistp dword ptr [int3]
- mov word ptr [edi+2*2], ax
- mov eax, [int3]
- cmp eax, ebx
- cmovl eax, ebx
- cmp eax, edx
- cmovg eax, edx
- fld qword ptr [esi+4*8]
- fistp dword ptr [int4]
- mov word ptr [edi+3*2], ax
- mov eax, [int4]
- cmp eax, ebx
- cmovl eax, ebx
- cmp eax, edx
- cmovg eax, edx
- fld qword ptr [esi+5*8]
- fistp dword ptr [int5]
- mov word ptr [edi+4*2], ax
- mov eax, [int5]
- cmp eax, ebx
- cmovl eax, ebx
- cmp eax, edx
- cmovg eax, edx
- fld qword ptr [esi+6*8]
- fistp dword ptr [int6]
- mov word ptr [edi+5*2], ax
- mov eax, [int6]
- cmp eax, ebx
- cmovl eax, ebx
- cmp eax, edx
- cmovg eax, edx
- fld qword ptr [esi+7*8]
- fistp dword ptr [int7]
- mov word ptr [edi+6*2], ax
- mov eax, [int7]
- cmp eax, ebx
- cmovl eax, ebx
- cmp eax, edx
- cmovg eax, edx
- mov word ptr [edi+7*2], ax
-
- add esi, 8*8
- add edi, 8*2
-
- sub ecx, 0x80000001
- js __floor
- //align 16
- test ecx, ecx // align jump &| redo flags
- jnz __floor
-
- // set x87 to default mode
- fldcw [fpold]
- };
+ __asm
+ {
+ // do the IDCT
+ mov esi,[block]
+ lea eax,[c]
+ lea edi,[tmp]
+ //mov ebx,8
+ mov ebx,8 // 0x77000000 // 8
+ align 16
+ __col1:
+ movzx edx,[esi+1*2]
+ mov ecx,[esi+2*2]
+ or edx,[esi+4*2]
+ or ecx,[esi+6*2]
+ or edx,ecx
+ //mov ecx,8
+ mov ecx,8/2 // 0x77000000 // 8
+
+ jnz __row1
+ fild word ptr [esi+0*2]
+ fmul qword ptr [eax+0*8*8]
+ fst qword ptr [edi+0*8]
+ fst qword ptr [edi+1*8]
+ fst qword ptr [edi+2*8]
+ fst qword ptr [edi+3*8]
+ fst qword ptr [edi+4*8]
+ fst qword ptr [edi+5*8]
+ fst qword ptr [edi+6*8]
+ fstp qword ptr [edi+7*8]
+ add edi,8*8
+ jmp __next1
+ align 16
+ __row1:
+ fild word ptr [esi+0*2]
+ fmul qword ptr [eax+0*8*8]
+ fild word ptr [esi+1*2]
+ fmul qword ptr [eax+1*8*8]
+ fadd
+ fild word ptr [esi+2*2]
+ fmul qword ptr [eax+2*8*8]
+ fadd
+ fild word ptr [esi+3*2]
+ fmul qword ptr [eax+3*8*8]
+ fadd
+ fild word ptr [esi+4*2]
+ fmul qword ptr [eax+4*8*8]
+ fadd
+ fild word ptr [esi+5*2]
+ fmul qword ptr [eax+5*8*8]
+ fadd
+ fild word ptr [esi+6*2]
+ fmul qword ptr [eax+6*8*8]
+ fadd
+ fild word ptr [esi+7*2]
+ fmul qword ptr [eax+7*8*8]
+ fadd
+
+ fild word ptr [esi+0*2]
+ fmul qword ptr [eax+0*8*8+8]
+ fild word ptr [esi+1*2]
+ fmul qword ptr [eax+1*8*8+8]
+ fadd
+ fild word ptr [esi+2*2]
+ fmul qword ptr [eax+2*8*8+8]
+ fadd
+ fild word ptr [esi+3*2]
+ fmul qword ptr [eax+3*8*8+8]
+ fadd
+ fild word ptr [esi+4*2]
+ fmul qword ptr [eax+4*8*8+8]
+ fadd
+ fild word ptr [esi+5*2]
+ fmul qword ptr [eax+5*8*8+8]
+ fadd
+ fild word ptr [esi+6*2]
+ fmul qword ptr [eax+6*8*8+8]
+ fadd
+ fild word ptr [esi+7*2]
+ fmul qword ptr [eax+7*8*8+8]
+ fadd
+ add eax,8*2
+ fxch st(1)
+ fstp qword ptr [edi]//
+ fstp qword ptr [edi+8]
+ add edi,8*2
+ dec ecx
+
+ jnz __row1
+ add eax,-8*8
+ //align 16
+ __next1:
+ add esi,+8*2
+
+ sub ebx,0x80000001 // add ebx,ebx
+ js __col1
+ //align 16
+ test ebx,ebx // align jump &| redo flags
+ jnz __col1
+
+ lea esi,[tmp]
+ lea eax,[c]
+ lea edi,[rnd]
+ //mov edi,[block]
+ fld qword ptr [HALF]
+ mov ebx,8
+ __row2:
+ mov ecx,8/2
+ align 16
+ __col2:
+ fld qword ptr [esi+0*8*8]
+ fmul qword ptr [eax+0*8*8]
+ fld qword ptr [esi+1*8*8]
+ fmul qword ptr [eax+1*8*8]
+ fadd
+ fld qword ptr [esi+2*8*8]
+ fmul qword ptr [eax+2*8*8]
+ fadd
+ fld qword ptr [esi+3*8*8]
+ fmul qword ptr [eax+3*8*8]
+ fadd
+ fld qword ptr [esi+4*8*8]
+ fmul qword ptr [eax+4*8*8]
+ fadd
+ fld qword ptr [esi+5*8*8]
+ fmul qword ptr [eax+5*8*8]
+ fadd
+ fld qword ptr [esi+6*8*8]
+ fmul qword ptr [eax+6*8*8]
+ fadd
+ fld qword ptr [esi+7*8*8]
+ fmul qword ptr [eax+7*8*8]
+ fadd
+ fadd st(0),st(1)
+
+ fxch st(1)
+
+ fld qword ptr [esi+0*8*8]
+ fmul qword ptr [eax+0*8*8+8]
+ fld qword ptr [esi+1*8*8]
+ fmul qword ptr [eax+1*8*8+8]
+ fadd
+ fld qword ptr [esi+2*8*8]
+ fmul qword ptr [eax+2*8*8+8]
+ fadd
+ fld qword ptr [esi+3*8*8]
+ fmul qword ptr [eax+3*8*8+8]
+ fadd
+ fld qword ptr [esi+4*8*8]
+ fmul qword ptr [eax+4*8*8+8]
+ fadd
+ fld qword ptr [esi+5*8*8]
+ fmul qword ptr [eax+5*8*8+8]
+ fadd
+ fld qword ptr [esi+6*8*8]
+ fmul qword ptr [eax+6*8*8+8]
+ fadd
+ fld qword ptr [esi+7*8*8]
+ fmul qword ptr [eax+7*8*8+8]
+ fadd
+ fadd st(0),st(1)
+ add eax,8*2
+
+ fxch st(2)
+ fstp qword ptr [edi]
+ fxch st(1)
+ fstp qword ptr [edi+8*8]
+ add edi,8*8*2
+
+ dec ecx
+
+ jnz __col2
+ add eax,-8*8
+ add esi,+8
+ add edi,8-8*8*8
+
+ sub ebx,0x80000001
+ js __row2
+ //align 16
+ test ebx,ebx // align jump &| redo flags
+ jnz __row2
+ ffree st(0) // bye bye 0.5
+
+ // set x87 to floor mode
+ fstcw [fpold]
+ movzx eax, [fpold]
+
+ or eax, 0x0400 // round down - floor
+ mov [fpnew], ax
+ fldcw [fpnew]
+
+ // now floor the damn array
+ lea esi, [rnd]
+ mov edi, [block]
+ mov ebx, -256 // clip min
+ mov edx, +255 // clip max
+ mov ecx, 8
+ align 16
+ __floor:
+ fld qword ptr [esi+0*8]
+ fistp dword ptr [int0]
+ mov eax,[int0]
+ cmp eax,ebx
+ cmovl eax,ebx
+ cmp eax,edx
+ cmovg eax,edx
+ fld qword ptr [esi+1*8]
+ fistp dword ptr [int1]
+ mov word ptr [edi+0*2],ax
+ mov eax,[int1]
+ cmp eax,ebx
+ cmovl eax,ebx
+ cmp eax,edx
+ cmovg eax,edx
+ fld qword ptr [esi+2*8]
+ fistp dword ptr [int2]
+ mov word ptr [edi+1*2],ax
+ mov eax,[int2]
+ cmp eax,ebx
+ cmovl eax,ebx
+ cmp eax,edx
+ cmovg eax,edx
+ fld qword ptr [esi+3*8]
+ fistp dword ptr [int3]
+ mov word ptr [edi+2*2],ax
+ mov eax,[int3]
+ cmp eax,ebx
+ cmovl eax,ebx
+ cmp eax,edx
+ cmovg eax,edx
+ fld qword ptr [esi+4*8]
+ fistp dword ptr [int4]
+ mov word ptr [edi+3*2],ax
+ mov eax,[int4]
+ cmp eax,ebx
+ cmovl eax,ebx
+ cmp eax,edx
+ cmovg eax,edx
+ fld qword ptr [esi+5*8]
+ fistp dword ptr [int5]
+ mov word ptr [edi+4*2],ax
+ mov eax,[int5]
+ cmp eax,ebx
+ cmovl eax,ebx
+ cmp eax,edx
+ cmovg eax,edx
+ fld qword ptr [esi+6*8]
+ fistp dword ptr [int6]
+ mov word ptr [edi+5*2],ax
+ mov eax,[int6]
+ cmp eax,ebx
+ cmovl eax,ebx
+ cmp eax,edx
+ cmovg eax,edx
+ fld qword ptr [esi+7*8]
+ fistp dword ptr [int7]
+ mov word ptr [edi+6*2],ax
+ mov eax,[int7]
+ cmp eax,ebx
+ cmovl eax,ebx
+ cmp eax,edx
+ cmovg eax,edx
+ mov word ptr [edi+7*2],ax
+
+ add esi, 8*8
+ add edi, 8*2
+
+ sub ecx,0x80000001
+ js __floor
+ //align 16
+ test ecx,ecx // align jump &| redo flags
+ jnz __floor
+
+ // set x87 to default mode
+ fldcw [fpold]
+ };
}
diff --git a/src/filters/source/D2VSource/resource.h b/src/filters/source/D2VSource/resource.h
index 98cb5e018..1d1658441 100644
--- a/src/filters/source/D2VSource/resource.h
+++ b/src/filters/source/D2VSource/resource.h
@@ -3,7 +3,7 @@
// Used by d2vsource.rc
// Next default values for new objects
-//
+//
#ifdef APSTUDIO_INVOKED
#ifndef APSTUDIO_READONLY_SYMBOLS
#define _APS_NEXT_RESOURCE_VALUE 101
diff --git a/src/filters/source/DTSAC3Source/DTSAC3Source.cpp b/src/filters/source/DTSAC3Source/DTSAC3Source.cpp
index ffa885fef..fc6251abf 100644
--- a/src/filters/source/DTSAC3Source/DTSAC3Source.cpp
+++ b/src/filters/source/DTSAC3Source/DTSAC3Source.cpp
@@ -1,4 +1,4 @@
-/*
+/*
* Copyright (C) 2003-2006 Gabest
* http://www.gabest.org
*
@@ -6,15 +6,15 @@
* 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.
+ * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
* http://www.gnu.org/copyleft/gpl.html
*
*/
@@ -32,82 +32,82 @@
const AMOVIESETUP_MEDIATYPE sudPinTypesOut[] =
{
- {&MEDIATYPE_Audio, &MEDIASUBTYPE_DTS},
- {&MEDIATYPE_DVD_ENCRYPTED_PACK, &MEDIASUBTYPE_DTS},
- {&MEDIATYPE_Audio, &MEDIASUBTYPE_DOLBY_AC3},
- {&MEDIATYPE_DVD_ENCRYPTED_PACK, &MEDIASUBTYPE_DOLBY_AC3},
+ {&MEDIATYPE_Audio, &MEDIASUBTYPE_DTS},
+ {&MEDIATYPE_DVD_ENCRYPTED_PACK, &MEDIASUBTYPE_DTS},
+ {&MEDIATYPE_Audio, &MEDIASUBTYPE_DOLBY_AC3},
+ {&MEDIATYPE_DVD_ENCRYPTED_PACK, &MEDIASUBTYPE_DOLBY_AC3},
};
const AMOVIESETUP_PIN sudOpPin[] =
{
- {L"Output", FALSE, TRUE, FALSE, FALSE, &CLSID_NULL, NULL, countof(sudPinTypesOut), sudPinTypesOut}
+ {L"Output", FALSE, TRUE, FALSE, FALSE, &CLSID_NULL, NULL, countof(sudPinTypesOut), sudPinTypesOut}
};
const AMOVIESETUP_FILTER sudFilter[] =
{
#ifdef DDPLUS_ONLY
- {&__uuidof(CDTSAC3Source), L"MPC - DD+ Source", MERIT_NORMAL, countof(sudOpPin), sudOpPin}
+ {&__uuidof(CDTSAC3Source), L"MPC - DD+ Source", MERIT_NORMAL, countof(sudOpPin), sudOpPin}
#else
- {&__uuidof(CDTSAC3Source), L"MPC - DTS/AC3/DD+ Source", MERIT_NORMAL, countof(sudOpPin), sudOpPin, CLSID_LegacyAmFilterCategory}
+ {&__uuidof(CDTSAC3Source), L"MPC - DTS/AC3/DD+ Source", MERIT_NORMAL, countof(sudOpPin), sudOpPin, CLSID_LegacyAmFilterCategory}
#endif
};
CFactoryTemplate g_Templates[] =
{
- {sudFilter[0].strName, sudFilter[0].clsID, CreateInstance<CDTSAC3Source>, NULL, &sudFilter[0]}
+ {sudFilter[0].strName, sudFilter[0].clsID, CreateInstance<CDTSAC3Source>, NULL, &sudFilter[0]}
};
int g_cTemplates = countof(g_Templates);
STDAPI DllRegisterServer()
{
- SetRegKeyValue(
- _T("Media Type\\{e436eb83-524f-11ce-9f53-0020af0ba770}"), _T("{B4A7BE85-551D-4594-BDC7-832B09185041}"),
- _T("0"), _T("0,4,,7FFE8001"));
+ SetRegKeyValue(
+ _T("Media Type\\{e436eb83-524f-11ce-9f53-0020af0ba770}"), _T("{B4A7BE85-551D-4594-BDC7-832B09185041}"),
+ _T("0"), _T("0,4,,7FFE8001"));
- SetRegKeyValue(
- _T("Media Type\\{e436eb83-524f-11ce-9f53-0020af0ba770}"), _T("{B4A7BE85-551D-4594-BDC7-832B09185041}"),
- _T("1"), _T("0,2,,0B77"));
+ SetRegKeyValue(
+ _T("Media Type\\{e436eb83-524f-11ce-9f53-0020af0ba770}"), _T("{B4A7BE85-551D-4594-BDC7-832B09185041}"),
+ _T("1"), _T("0,2,,0B77"));
- SetRegKeyValue(
- _T("Media Type\\{e436eb83-524f-11ce-9f53-0020af0ba770}"), _T("{B4A7BE85-551D-4594-BDC7-832B09185041}"),
- _T("2"), _T("0,2,,770B"));
+ SetRegKeyValue(
+ _T("Media Type\\{e436eb83-524f-11ce-9f53-0020af0ba770}"), _T("{B4A7BE85-551D-4594-BDC7-832B09185041}"),
+ _T("2"), _T("0,2,,770B"));
- SetRegKeyValue(
- _T("Media Type\\{e436eb83-524f-11ce-9f53-0020af0ba770}"), _T("{B4A7BE85-551D-4594-BDC7-832B09185041}"),
- _T("Source Filter"), _T("{B4A7BE85-551D-4594-BDC7-832B09185041}"));
+ SetRegKeyValue(
+ _T("Media Type\\{e436eb83-524f-11ce-9f53-0020af0ba770}"), _T("{B4A7BE85-551D-4594-BDC7-832B09185041}"),
+ _T("Source Filter"), _T("{B4A7BE85-551D-4594-BDC7-832B09185041}"));
#ifndef DDPLUS_ONLY
- SetRegKeyValue(
- _T("Media Type\\Extensions"), _T(".dts"),
- _T("Source Filter"), _T("{B4A7BE85-551D-4594-BDC7-832B09185041}"));
+ SetRegKeyValue(
+ _T("Media Type\\Extensions"), _T(".dts"),
+ _T("Source Filter"), _T("{B4A7BE85-551D-4594-BDC7-832B09185041}"));
- SetRegKeyValue(
- _T("Media Type\\Extensions"), _T(".ac3"),
- _T("Source Filter"), _T("{B4A7BE85-551D-4594-BDC7-832B09185041}"));
+ SetRegKeyValue(
+ _T("Media Type\\Extensions"), _T(".ac3"),
+ _T("Source Filter"), _T("{B4A7BE85-551D-4594-BDC7-832B09185041}"));
#endif
- SetRegKeyValue(
- _T("Media Type\\Extensions"), _T(".ddp"),
- _T("Source Filter"), _T("{B4A7BE85-551D-4594-BDC7-832B09185041}"));
+ SetRegKeyValue(
+ _T("Media Type\\Extensions"), _T(".ddp"),
+ _T("Source Filter"), _T("{B4A7BE85-551D-4594-BDC7-832B09185041}"));
- SetRegKeyValue(
- _T("Media Type\\Extensions"), _T(".ec3"),
- _T("Source Filter"), _T("{B4A7BE85-551D-4594-BDC7-832B09185041}"));
+ SetRegKeyValue(
+ _T("Media Type\\Extensions"), _T(".ec3"),
+ _T("Source Filter"), _T("{B4A7BE85-551D-4594-BDC7-832B09185041}"));
- return AMovieDllRegisterServer2(TRUE);
+ return AMovieDllRegisterServer2(TRUE);
}
STDAPI DllUnregisterServer()
{
- DeleteRegKey(_T("Media Type\\{e436eb83-524f-11ce-9f53-0020af0ba770}"), _T("{B4A7BE85-551D-4594-BDC7-832B09185041}"));
+ DeleteRegKey(_T("Media Type\\{e436eb83-524f-11ce-9f53-0020af0ba770}"), _T("{B4A7BE85-551D-4594-BDC7-832B09185041}"));
#ifndef DDPLUS_ONLY
- DeleteRegKey(_T("Media Type\\Extensions"), _T(".dts"));
- DeleteRegKey(_T("Media Type\\Extensions"), _T(".ac3"));
+ DeleteRegKey(_T("Media Type\\Extensions"), _T(".dts"));
+ DeleteRegKey(_T("Media Type\\Extensions"), _T(".ac3"));
#endif
- DeleteRegKey(_T("Media Type\\Extensions"), _T(".ddp"));
- DeleteRegKey(_T("Media Type\\Extensions"), _T(".ec3"));
+ DeleteRegKey(_T("Media Type\\Extensions"), _T(".ddp"));
+ DeleteRegKey(_T("Media Type\\Extensions"), _T(".ec3"));
- return AMovieDllRegisterServer2(FALSE);
+ return AMovieDllRegisterServer2(FALSE);
}
#include "../../FilterApp.h"
@@ -121,7 +121,7 @@ CFilterApp theApp;
//
CDTSAC3Source::CDTSAC3Source(LPUNKNOWN lpunk, HRESULT* phr)
- : CBaseSource<CDTSAC3Stream>(NAME("CDTSAC3Source"), lpunk, phr, __uuidof(this))
+ : CBaseSource<CDTSAC3Stream>(NAME("CDTSAC3Source"), lpunk, phr, __uuidof(this))
{
}
@@ -131,165 +131,165 @@ CDTSAC3Source::~CDTSAC3Source()
// CDTSAC3Stream
-CDTSAC3Stream::CDTSAC3Stream(const WCHAR* wfn, CSource* pParent, HRESULT* phr)
- : CBaseStream(NAME("CDTSAC3Stream"), pParent, phr)
- , m_nFileOffset(0)
+CDTSAC3Stream::CDTSAC3Stream(const WCHAR* wfn, CSource* pParent, HRESULT* phr)
+ : CBaseStream(NAME("CDTSAC3Stream"), pParent, phr)
+ , m_nFileOffset(0)
{
- CAutoLock cAutoLock(&m_cSharedState);
-
- m_subtype = GUID_NULL;
- m_wFormatTag = 0;
- m_streamid = 0;
-
- CString fn(wfn);
-
- if(!m_file.Open(fn, CFile::modeRead | CFile::shareDenyNone))
- {
- if(phr) *phr = E_FAIL;
- return;
- }
-
- DWORD id = 0;
- if(m_file.Read(&id, sizeof(id)) != sizeof(id)
- || id != 0x0180FE7F && (WORD)id != 0x0b77 && (WORD)id != 0x770b)
- {
- if(phr) *phr = E_FAIL;
- return;
- }
-
- if(id == 0x0180FE7F)
- {
+ CAutoLock cAutoLock(&m_cSharedState);
+
+ m_subtype = GUID_NULL;
+ m_wFormatTag = 0;
+ m_streamid = 0;
+
+ CString fn(wfn);
+
+ if(!m_file.Open(fn, CFile::modeRead|CFile::shareDenyNone))
+ {
+ if(phr) *phr = E_FAIL;
+ return;
+ }
+
+ DWORD id = 0;
+ if(m_file.Read(&id, sizeof(id)) != sizeof(id)
+ || id != 0x0180FE7F && (WORD)id != 0x0b77 && (WORD)id != 0x770b)
+ {
+ if(phr) *phr = E_FAIL;
+ return;
+ }
+
+ if(id == 0x0180FE7F)
+ {
#ifdef DDPLUS_ONLY
-//Temporary patch to disable DTS source
- if(phr) *phr = E_FAIL;
- return;
+//Temporary patch to disable DTS source
+ if(phr) *phr = E_FAIL;
+ return;
#endif
- BYTE buff[8];
- m_file.Read(buff, 8);
-
- int frametype = (buff[0] >> 7); // 1
- int deficitsamplecount = (buff[0] >> 2) & 31; // 5
- int crcpresent = (buff[0] >> 1) & 1; // 1
- int npcmsampleblocks = ((buff[0] & 1) << 6) | (buff[1] >> 2); // 7
- int framebytes = (((buff[1] & 3) << 12) | (buff[2] << 4) | (buff[3] >> 4)) + 1; // 14
- int audiochannelarrangement = (buff[3] & 15) << 2 | (buff[4] >> 6); // 6
- int freq = (buff[4] >> 2) & 15; // 4
- int transbitrate = ((buff[4] & 3) << 3) | (buff[5] >> 5); // 5
-
- int freqtbl[] =
- {
- 0, 8000, 16000, 32000,
- 0, 0,
- 11025, 22050, 44100,
- 0, 0,
- 12000, 24000, 48000,
- 0, 0
- };
-
- int bitratetbl[] =
- {
- 32000, 56000, 64000, 96000, 112000, 128000, 192000, 224000,
- 256000, 320000, 384000, 448000, 512000, 576000, 640000, 754500,
- 960000, 1024000, 1152000, 1280000, 1344000, 1408000, 1411200, 1472000,
- 1509750, 1920000, 2048000, 3072000, 3840000, 0, 0, 0
- };
+ BYTE buff[8];
+ m_file.Read(buff, 8);
+
+ int frametype = (buff[0]>>7); // 1
+ int deficitsamplecount = (buff[0]>>2)&31; // 5
+ int crcpresent = (buff[0]>>1)&1; // 1
+ int npcmsampleblocks = ((buff[0]&1)<<6)|(buff[1]>>2); // 7
+ int framebytes = (((buff[1]&3)<<12)|(buff[2]<<4)|(buff[3]>>4)) + 1; // 14
+ int audiochannelarrangement = (buff[3]&15)<<2|(buff[4]>>6); // 6
+ int freq = (buff[4]>>2)&15; // 4
+ int transbitrate = ((buff[4]&3)<<3)|(buff[5]>>5); // 5
+
+ int freqtbl[] =
+ {
+ 0,8000,16000,32000,
+ 0,0,
+ 11025,22050,44100,
+ 0,0,
+ 12000,24000,48000,
+ 0,0
+ };
+
+ int bitratetbl[] =
+ {
+ 32000,56000,64000,96000,112000,128000,192000,224000,
+ 256000,320000,384000,448000,512000,576000,640000,754500,
+ 960000,1024000,1152000,1280000,1344000,1408000,1411200,1472000,
+ 1509750,1920000,2048000,3072000,3840000,0,0,0
+ };
#define DTS_MAGIC_NUMBER 6 //magic number to make sonic audio decoder 4.2 happy
- m_nSamplesPerSec = freqtbl[freq];
- m_nAvgBytesPerSec = (bitratetbl[transbitrate] + 4) / 8;
+ m_nSamplesPerSec = freqtbl[freq];
+ m_nAvgBytesPerSec = (bitratetbl[transbitrate] + 4) / 8;
// m_nBytesPerFrame = m_nAvgBytesPerSec*10.656063618290258449304174950298/1000 + 0.5;
- m_nBytesPerFrame = framebytes * DTS_MAGIC_NUMBER;
- if(framebytes == 2012)
- {
- // DTS and DTS-HD tracks from HD DVD and Blu-Ray sources have framesizes of 2012 bytes
- // but if we handle them mathematically "correctly", audio sync will slowly drift away
- // we have to handle them as if they had 2013 bytes
- m_AvgTimePerFrame = 10000000i64 * (2013 * DTS_MAGIC_NUMBER) * 8 / bitratetbl[transbitrate];
- }
- else
- m_AvgTimePerFrame = 10000000i64 * m_nBytesPerFrame * 8 / bitratetbl[transbitrate];
-
- m_subtype = MEDIASUBTYPE_DTS;
- m_wFormatTag = WAVE_FORMAT_DVD_DTS;
- m_streamid = 0x88;
- }
- else
- {
- BYTE info, info1, bsid;
- if((BYTE)id == 0x77) m_file.Seek(1, CFile::current); // LE
- m_file.Read(&info, 1);
- m_file.Read(&info1, 1);
- bsid = (info1 >> 3);
-
- if(bsid >= 0 && bsid <= 8) //AC3
- {
+ m_nBytesPerFrame = framebytes*DTS_MAGIC_NUMBER;
+ if (framebytes == 2012)
+ {
+ // DTS and DTS-HD tracks from HD DVD and Blu-Ray sources have framesizes of 2012 bytes
+ // but if we handle them mathematically "correctly", audio sync will slowly drift away
+ // we have to handle them as if they had 2013 bytes
+ m_AvgTimePerFrame = 10000000i64 * (2013*DTS_MAGIC_NUMBER) * 8 / bitratetbl[transbitrate];
+ }
+ else
+ m_AvgTimePerFrame = 10000000i64 * m_nBytesPerFrame * 8 / bitratetbl[transbitrate];
+
+ m_subtype = MEDIASUBTYPE_DTS;
+ m_wFormatTag = WAVE_FORMAT_DVD_DTS;
+ m_streamid = 0x88;
+ }
+ else
+ {
+ BYTE info, info1, bsid;
+ if((BYTE)id == 0x77) m_file.Seek(1, CFile::current); // LE
+ m_file.Read(&info, 1);
+ m_file.Read(&info1, 1);
+ bsid = (info1>>3);
+
+ if(bsid>=0 && bsid<=8) //AC3
+ {
#ifdef DDPLUS_ONLY
-//Temporary patch to disable AC3 source
- if(phr) *phr = E_FAIL;
- return;
+//Temporary patch to disable AC3 source
+ if(phr) *phr = E_FAIL;
+ return;
#endif
- BYTE freq = info >> 6;
- BYTE bitrate = info & 0x3f;
+ BYTE freq = info>>6;
+ BYTE bitrate = info&0x3f;
- if(bitrate >= 38)
- {
- if(phr) *phr = E_FAIL;
- return;
- }
+ if(bitrate >= 38)
+ {
+ if(phr) *phr = E_FAIL;
+ return;
+ }
- int freqtbl[] = {48000, 44100, 32000, 48000};
+ int freqtbl[] = {48000,44100,32000,48000};
- int bitratetbl[] =
- {
- 32000, 32000, 40000, 40000, 48000, 48000, 56000, 56000, 64000, 64000,
- 80000, 80000, 96000, 96000, 112000, 112000, 128000, 128000, 160000, 160000,
- 192000, 192000, 224000, 224000, 256000, 256000, 320000, 320000, 384000, 384000,
- 448000, 448000, 512000, 512000, 576000, 576000, 640000, 640000
- };
+ int bitratetbl[] =
+ {
+ 32000,32000,40000,40000,48000,48000,56000,56000,64000,64000,
+ 80000,80000,96000,96000,112000,112000,128000,128000,160000,160000,
+ 192000,192000,224000,224000,256000,256000,320000,320000,384000,384000,
+ 448000,448000,512000,512000,576000,576000,640000,640000
+ };
#define AC3_MAGIC_NUMBER 3 //magic number to make sonic audio decoder 4.2 happy
- m_nSamplesPerSec = freqtbl[freq];
- m_nAvgBytesPerSec = (bitratetbl[bitrate] + 4) / 8;
- m_nBytesPerFrame = m_nAvgBytesPerSec * 32 / 1000 * AC3_MAGIC_NUMBER;
- m_AvgTimePerFrame = 10000000i64 * m_nBytesPerFrame * 8 / bitratetbl[bitrate];
-
- m_subtype = MEDIASUBTYPE_DOLBY_AC3;
- m_wFormatTag = WAVE_FORMAT_DOLBY_AC3;
- m_streamid = 0x80;
-
- }
- else if(bsid >= 11 && bsid <= 16) //DD+
- {
- BYTE fscod = info >> 6;
- BYTE numblkscod = (info & 0x30) >> 4;
- if(fscod == 3)
- {
- fscod = numblkscod + 3;
- numblkscod = 3;
- }
-
- int freqtbl[] = {48000, 44100, 32000, 22400, 22050, 16000, 48000};
- m_nSamplesPerSec = freqtbl[fscod];
- m_nBytesPerFrame = (2 + (id >> 23) + ((id & 0x00070000) >> 7)) * 6;
- int timetbl[] = {320000, 640000, 960000, 1920000};
- m_AvgTimePerFrame = timetbl[numblkscod];
-
- m_subtype = MEDIASUBTYPE_DOLBY_AC3;
- m_wFormatTag = WAVE_FORMAT_DOLBY_AC3;
- m_streamid = 0xC0;
- }
- else
- {
- if(phr) *phr = E_FAIL;
- return;
- }
-
- }
-
- m_rtDuration = m_AvgTimePerFrame * m_file.GetLength() / m_nBytesPerFrame;
- m_rtStop = m_rtDuration;
+ m_nSamplesPerSec = freqtbl[freq];
+ m_nAvgBytesPerSec = (bitratetbl[bitrate] + 4) / 8;
+ m_nBytesPerFrame = m_nAvgBytesPerSec*32/1000*AC3_MAGIC_NUMBER;
+ m_AvgTimePerFrame = 10000000i64 * m_nBytesPerFrame * 8 / bitratetbl[bitrate];
+
+ m_subtype = MEDIASUBTYPE_DOLBY_AC3;
+ m_wFormatTag = WAVE_FORMAT_DOLBY_AC3;
+ m_streamid = 0x80;
+
+ }
+ else if(bsid>=11 && bsid <=16) //DD+
+ {
+ BYTE fscod = info>>6;
+ BYTE numblkscod = (info&0x30)>>4;
+ if(fscod == 3)
+ {
+ fscod = numblkscod+3;
+ numblkscod = 3;
+ }
+
+ int freqtbl[] = {48000,44100,32000,22400,22050,16000,48000};
+ m_nSamplesPerSec = freqtbl[fscod];
+ m_nBytesPerFrame = (2+(id >> 23)+((id&0x00070000)>>7))*6;
+ int timetbl[] = {320000, 640000, 960000, 1920000};
+ m_AvgTimePerFrame = timetbl[numblkscod];
+
+ m_subtype = MEDIASUBTYPE_DOLBY_AC3;
+ m_wFormatTag = WAVE_FORMAT_DOLBY_AC3;
+ m_streamid = 0xC0;
+ }
+ else
+ {
+ if(phr) *phr = E_FAIL;
+ return;
+ }
+
+ }
+
+ m_rtDuration = m_AvgTimePerFrame * m_file.GetLength() / m_nBytesPerFrame;
+ m_rtStop = m_rtDuration;
}
CDTSAC3Stream::~CDTSAC3Stream()
@@ -303,8 +303,8 @@ HRESULT CDTSAC3Stream::DecideBufferSize(IMemAllocator* pAlloc, ALLOCATOR_PROPERT
HRESULT hr = NOERROR;
- pProperties->cBuffers = 1;
- pProperties->cbBuffer = m_nBytesPerFrame + 35;
+ pProperties->cBuffers = 1;
+ pProperties->cbBuffer = m_nBytesPerFrame+35;
ALLOCATOR_PROPERTIES Actual;
if(FAILED(hr = pAlloc->SetProperties(pProperties, &Actual))) return hr;
@@ -317,157 +317,157 @@ HRESULT CDTSAC3Stream::DecideBufferSize(IMemAllocator* pAlloc, ALLOCATOR_PROPERT
HRESULT CDTSAC3Stream::FillBuffer(IMediaSample* pSample, int nFrame, BYTE* pOut, long& len)
{
- BYTE* pOutOrg = pOut;
-
- const GUID* majortype = &m_mt.majortype;
- const GUID* subtype = &m_mt.subtype;
-
- if(*majortype == MEDIATYPE_DVD_ENCRYPTED_PACK)
- {
- BYTE PESHeader[] =
- {
- 0x00, 0x00, 0x01, 0xBA, // PES id
- 0x44, 0x00, 0x04, 0x00, 0x04, 0x01, // SCR (0)
- 0x01, 0x89, 0xC3, 0xF8, // mux rate (1260000 bytes/sec, 22bits), marker (2bits), reserved (~0, 5bits), stuffing (0, 3bits)
- };
-
- memcpy(pOut, &PESHeader, sizeof(PESHeader));
- pOut += sizeof(PESHeader);
-
- majortype = &MEDIATYPE_MPEG2_PES;
- }
-
- if(*majortype == MEDIATYPE_MPEG2_PES)
- {
- BYTE Private1Header[] =
- {
- 0x00, 0x00, 0x01, 0xBD, // private stream 1 id
- (m_nBytesPerFrame + 15) >> 8, (m_nBytesPerFrame + 15) & 255, // packet length
- 0x81, 0x80, // marker, original, PTS - flags
- 0x08, // packet data starting offset
- 0x21, 0x00, 0x01, 0x00, 0x01, // PTS (0)
- 0xFF, 0xFF, 0xFF, // stuffing
- m_streamid, // stream id (0)
- 0x01, 0x00, 0x01, // no idea about this (might be the current sector on the disc), but dvd2avi doesn't output it to the ac3/dts file so we have to put it back
- };
-
- memcpy(pOut, &Private1Header, sizeof(Private1Header));
- pOut += sizeof(Private1Header);
-
- majortype = &MEDIATYPE_Audio;
- }
-
- if(*majortype == MEDIATYPE_Audio)
- {
- m_file.Seek(m_nFileOffset + nFrame * m_nBytesPerFrame, CFile::begin);
- if(m_file.Read(pOut, m_nBytesPerFrame) < m_nBytesPerFrame) return S_FALSE;
- pOut += m_nBytesPerFrame;
- }
-
- len = pOut - pOutOrg;
-
- return S_OK;
+ BYTE* pOutOrg = pOut;
+
+ const GUID* majortype = &m_mt.majortype;
+ const GUID* subtype = &m_mt.subtype;
+
+ if(*majortype == MEDIATYPE_DVD_ENCRYPTED_PACK)
+ {
+ BYTE PESHeader[] =
+ {
+ 0x00,0x00,0x01,0xBA, // PES id
+ 0x44,0x00,0x04,0x00,0x04,0x01, // SCR (0)
+ 0x01,0x89,0xC3,0xF8, // mux rate (1260000 bytes/sec, 22bits), marker (2bits), reserved (~0, 5bits), stuffing (0, 3bits)
+ };
+
+ memcpy(pOut, &PESHeader, sizeof(PESHeader));
+ pOut += sizeof(PESHeader);
+
+ majortype = &MEDIATYPE_MPEG2_PES;
+ }
+
+ if(*majortype == MEDIATYPE_MPEG2_PES)
+ {
+ BYTE Private1Header[] =
+ {
+ 0x00,0x00,0x01,0xBD, // private stream 1 id
+ (m_nBytesPerFrame+15)>>8,(m_nBytesPerFrame+15)&255, // packet length
+ 0x81,0x80, // marker, original, PTS - flags
+ 0x08, // packet data starting offset
+ 0x21,0x00,0x01,0x00,0x01, // PTS (0)
+ 0xFF,0xFF,0xFF, // stuffing
+ m_streamid, // stream id (0)
+ 0x01,0x00,0x01, // no idea about this (might be the current sector on the disc), but dvd2avi doesn't output it to the ac3/dts file so we have to put it back
+ };
+
+ memcpy(pOut, &Private1Header, sizeof(Private1Header));
+ pOut += sizeof(Private1Header);
+
+ majortype = &MEDIATYPE_Audio;
+ }
+
+ if(*majortype == MEDIATYPE_Audio)
+ {
+ m_file.Seek(m_nFileOffset + nFrame*m_nBytesPerFrame, CFile::begin);
+ if(m_file.Read(pOut, m_nBytesPerFrame) < m_nBytesPerFrame) return S_FALSE;
+ pOut += m_nBytesPerFrame;
+ }
+
+ len = pOut - pOutOrg;
+
+ return S_OK;
}
bool CDTSAC3Stream::CheckDTS(const CMediaType* pmt)
{
- return (pmt->majortype == MEDIATYPE_Audio
- || pmt->majortype == MEDIATYPE_MPEG2_PES
- || pmt->majortype == MEDIATYPE_DVD_ENCRYPTED_PACK)
- && pmt->subtype == MEDIASUBTYPE_DTS;
+ return (pmt->majortype == MEDIATYPE_Audio
+ || pmt->majortype == MEDIATYPE_MPEG2_PES
+ || pmt->majortype == MEDIATYPE_DVD_ENCRYPTED_PACK)
+ && pmt->subtype == MEDIASUBTYPE_DTS;
// return pmt->majortype == MEDIATYPE_Audio && pmt->subtype == MEDIASUBTYPE_DTS;
}
bool CDTSAC3Stream::CheckWAVEDTS(const CMediaType* pmt)
{
- return pmt->majortype == MEDIATYPE_Audio
- && pmt->subtype == MEDIASUBTYPE_WAVE_DTS
- && pmt->formattype == FORMAT_WaveFormatEx
- && ((WAVEFORMATEX*)pmt->pbFormat)->wFormatTag == WAVE_FORMAT_DVD_DTS;
+ return pmt->majortype == MEDIATYPE_Audio
+ && pmt->subtype == MEDIASUBTYPE_WAVE_DTS
+ && pmt->formattype == FORMAT_WaveFormatEx
+ && ((WAVEFORMATEX*)pmt->pbFormat)->wFormatTag == WAVE_FORMAT_DVD_DTS;
}
bool CDTSAC3Stream::CheckAC3(const CMediaType* pmt)
{
- return (pmt->majortype == MEDIATYPE_Audio
- || pmt->majortype == MEDIATYPE_MPEG2_PES
- || pmt->majortype == MEDIATYPE_DVD_ENCRYPTED_PACK)
- && pmt->subtype == MEDIASUBTYPE_DOLBY_AC3;
+ return (pmt->majortype == MEDIATYPE_Audio
+ || pmt->majortype == MEDIATYPE_MPEG2_PES
+ || pmt->majortype == MEDIATYPE_DVD_ENCRYPTED_PACK)
+ && pmt->subtype == MEDIASUBTYPE_DOLBY_AC3;
// return pmt->majortype == MEDIATYPE_Audio && pmt->subtype == MEDIASUBTYPE_DOLBY_AC3;
}
bool CDTSAC3Stream::CheckWAVEAC3(const CMediaType* pmt)
{
- return pmt->majortype == MEDIATYPE_Audio
- && pmt->subtype == MEDIASUBTYPE_DOLBY_AC3
- && pmt->formattype == FORMAT_WaveFormatEx
- && ((WAVEFORMATEX*)pmt->pbFormat)->wFormatTag == WAVE_FORMAT_DOLBY_AC3;
+ return pmt->majortype == MEDIATYPE_Audio
+ && pmt->subtype == MEDIASUBTYPE_DOLBY_AC3
+ && pmt->formattype == FORMAT_WaveFormatEx
+ && ((WAVEFORMATEX*)pmt->pbFormat)->wFormatTag == WAVE_FORMAT_DOLBY_AC3;
}
HRESULT CDTSAC3Stream::GetMediaType(int iPosition, CMediaType* pmt)
{
CAutoLock cAutoLock(m_pFilter->pStateLock());
- if(iPosition >= 0 && iPosition < 5)
- {
- pmt->subtype = m_subtype;
- pmt->formattype = FORMAT_WaveFormatEx;
- WAVEFORMATEX* wfe = (WAVEFORMATEX*)pmt->AllocFormatBuffer(sizeof(WAVEFORMATEX));
- memset(wfe, 0, sizeof(WAVEFORMATEX));
- wfe->cbSize = sizeof(WAVEFORMATEX);
- wfe->wFormatTag = WAVE_FORMAT_PCM;
- wfe->nSamplesPerSec = m_nSamplesPerSec;
- wfe->nAvgBytesPerSec = m_nAvgBytesPerSec;
- wfe->nChannels = 6;
-
- switch(iPosition)
- {
- case 0:
- pmt->majortype = MEDIATYPE_Audio;
- break;
- case 1:
- pmt->ResetFormatBuffer();
- pmt->formattype = FORMAT_None;
- case 2:
- pmt->majortype = MEDIATYPE_MPEG2_PES;
- break;
- case 3:
- pmt->ResetFormatBuffer();
- pmt->formattype = FORMAT_None;
- case 4:
- pmt->majortype = MEDIATYPE_DVD_ENCRYPTED_PACK;
- break;
- default:
- return E_INVALIDARG;
- }
- }
- else if(iPosition == 5)
- {
- pmt->majortype = MEDIATYPE_Audio;
- pmt->subtype = FOURCCMap(m_wFormatTag);
- pmt->formattype = FORMAT_WaveFormatEx;
- WAVEFORMATEX* wfe = (WAVEFORMATEX*)pmt->AllocFormatBuffer(sizeof(WAVEFORMATEX));
- memset(wfe, 0, sizeof(WAVEFORMATEX));
- wfe->cbSize = sizeof(WAVEFORMATEX);
- wfe->wFormatTag = m_wFormatTag;
- wfe->nSamplesPerSec = m_nSamplesPerSec;
- wfe->nAvgBytesPerSec = m_nAvgBytesPerSec;
- wfe->nChannels = 2;
- wfe->nBlockAlign = 1;
- }
- else
- {
- return VFW_S_NO_MORE_ITEMS;
- }
+ if(iPosition >= 0 && iPosition < 5)
+ {
+ pmt->subtype = m_subtype;
+ pmt->formattype = FORMAT_WaveFormatEx;
+ WAVEFORMATEX* wfe = (WAVEFORMATEX*)pmt->AllocFormatBuffer(sizeof(WAVEFORMATEX));
+ memset(wfe, 0, sizeof(WAVEFORMATEX));
+ wfe->cbSize = sizeof(WAVEFORMATEX);
+ wfe->wFormatTag = WAVE_FORMAT_PCM;
+ wfe->nSamplesPerSec = m_nSamplesPerSec;
+ wfe->nAvgBytesPerSec = m_nAvgBytesPerSec;
+ wfe->nChannels = 6;
+
+ switch(iPosition)
+ {
+ case 0:
+ pmt->majortype = MEDIATYPE_Audio;
+ break;
+ case 1:
+ pmt->ResetFormatBuffer();
+ pmt->formattype = FORMAT_None;
+ case 2:
+ pmt->majortype = MEDIATYPE_MPEG2_PES;
+ break;
+ case 3:
+ pmt->ResetFormatBuffer();
+ pmt->formattype = FORMAT_None;
+ case 4:
+ pmt->majortype = MEDIATYPE_DVD_ENCRYPTED_PACK;
+ break;
+ default:
+ return E_INVALIDARG;
+ }
+ }
+ else if(iPosition == 5)
+ {
+ pmt->majortype = MEDIATYPE_Audio;
+ pmt->subtype = FOURCCMap(m_wFormatTag);
+ pmt->formattype = FORMAT_WaveFormatEx;
+ WAVEFORMATEX* wfe = (WAVEFORMATEX*)pmt->AllocFormatBuffer(sizeof(WAVEFORMATEX));
+ memset(wfe, 0, sizeof(WAVEFORMATEX));
+ wfe->cbSize = sizeof(WAVEFORMATEX);
+ wfe->wFormatTag = m_wFormatTag;
+ wfe->nSamplesPerSec = m_nSamplesPerSec;
+ wfe->nAvgBytesPerSec = m_nAvgBytesPerSec;
+ wfe->nChannels = 2;
+ wfe->nBlockAlign = 1;
+ }
+ else
+ {
+ return VFW_S_NO_MORE_ITEMS;
+ }
pmt->SetTemporalCompression(FALSE);
- return S_OK;
+ return S_OK;
}
HRESULT CDTSAC3Stream::CheckMediaType(const CMediaType* pmt)
{
- return CheckDTS(pmt) || CheckWAVEDTS(pmt)
- || CheckAC3(pmt) || CheckWAVEAC3(pmt)
- ? S_OK
- : E_INVALIDARG;
+ return CheckDTS(pmt) || CheckWAVEDTS(pmt)
+ || CheckAC3(pmt) || CheckWAVEAC3(pmt)
+ ? S_OK
+ : E_INVALIDARG;
}
diff --git a/src/filters/source/DTSAC3Source/DTSAC3Source.h b/src/filters/source/DTSAC3Source/DTSAC3Source.h
index 4022d58db..6c9a30140 100644
--- a/src/filters/source/DTSAC3Source/DTSAC3Source.h
+++ b/src/filters/source/DTSAC3Source/DTSAC3Source.h
@@ -1,4 +1,4 @@
-/*
+/*
* Copyright (C) 2003-2006 Gabest
* http://www.gabest.org
*
@@ -6,15 +6,15 @@
* 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.
+ * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
* http://www.gnu.org/copyleft/gpl.html
*
*/
@@ -30,30 +30,30 @@ class CDTSAC3Stream;
class CDTSAC3Source : public CBaseSource<CDTSAC3Stream>
{
public:
- CDTSAC3Source(LPUNKNOWN lpunk, HRESULT* phr);
- virtual ~CDTSAC3Source();
+ CDTSAC3Source(LPUNKNOWN lpunk, HRESULT* phr);
+ virtual ~CDTSAC3Source();
};
class CDTSAC3Stream : public CBaseStream
{
- CFile m_file;
- int m_nFileOffset, m_nBytesPerFrame, m_nAvgBytesPerSec, m_nSamplesPerSec;
- GUID m_subtype;
- WORD m_wFormatTag;
- BYTE m_streamid;
+ CFile m_file;
+ int m_nFileOffset, m_nBytesPerFrame, m_nAvgBytesPerSec, m_nSamplesPerSec;
+ GUID m_subtype;
+ WORD m_wFormatTag;
+ BYTE m_streamid;
- bool CheckDTS(const CMediaType* pmt);
- bool CheckWAVEDTS(const CMediaType* pmt);
- bool CheckAC3(const CMediaType* pmt);
- bool CheckWAVEAC3(const CMediaType* pmt);
+ bool CheckDTS(const CMediaType* pmt);
+ bool CheckWAVEDTS(const CMediaType* pmt);
+ bool CheckAC3(const CMediaType* pmt);
+ bool CheckWAVEAC3(const CMediaType* pmt);
public:
CDTSAC3Stream(const WCHAR* wfn, CSource* pParent, HRESULT* phr);
- virtual ~CDTSAC3Stream();
+ virtual ~CDTSAC3Stream();
HRESULT FillBuffer(IMediaSample* pSample, int nFrame, BYTE* pOut, long& len);
-
- HRESULT DecideBufferSize(IMemAllocator* pIMemAlloc, ALLOCATOR_PROPERTIES* pProperties);
+
+ HRESULT DecideBufferSize(IMemAllocator* pIMemAlloc, ALLOCATOR_PROPERTIES* pProperties);
HRESULT CheckMediaType(const CMediaType* pMediaType);
HRESULT GetMediaType(int iPosition, CMediaType* pmt);
};
diff --git a/src/filters/source/DTSAC3Source/resource.h b/src/filters/source/DTSAC3Source/resource.h
index 6e541c0c4..3507c6e74 100644
--- a/src/filters/source/DTSAC3Source/resource.h
+++ b/src/filters/source/DTSAC3Source/resource.h
@@ -3,7 +3,7 @@
// Used by dtsac3source.rc
// Next default values for new objects
-//
+//
#ifdef APSTUDIO_INVOKED
#ifndef APSTUDIO_READONLY_SYMBOLS
#define _APS_NEXT_RESOURCE_VALUE 101
diff --git a/src/filters/source/DTSAC3Source/stdafx.cpp b/src/filters/source/DTSAC3Source/stdafx.cpp
index 4b148b3b2..396f14d73 100644
--- a/src/filters/source/DTSAC3Source/stdafx.cpp
+++ b/src/filters/source/DTSAC3Source/stdafx.cpp
@@ -1,4 +1,4 @@
-/*
+/*
* Copyright (C) 2003-2006 Gabest
* http://www.gabest.org
*
@@ -6,15 +6,15 @@
* 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.
+ * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
* http://www.gnu.org/copyleft/gpl.html
*
*/
diff --git a/src/filters/source/DTSAC3Source/stdafx.h b/src/filters/source/DTSAC3Source/stdafx.h
index a9f666228..c35359c38 100644
--- a/src/filters/source/DTSAC3Source/stdafx.h
+++ b/src/filters/source/DTSAC3Source/stdafx.h
@@ -1,4 +1,4 @@
-/*
+/*
* Copyright (C) 2003-2006 Gabest
* http://www.gabest.org
*
@@ -6,15 +6,15 @@
* 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.
+ * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
* http://www.gnu.org/copyleft/gpl.html
*
*/
diff --git a/src/filters/source/FLICSource/FLICSource.cpp b/src/filters/source/FLICSource/FLICSource.cpp
index 1d892df6f..1c291cd33 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,15 +6,15 @@
* 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.
+ * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
* http://www.gnu.org/copyleft/gpl.html
*
*/
@@ -27,58 +27,58 @@
const AMOVIESETUP_MEDIATYPE sudPinTypesOut[] =
{
- {&MEDIATYPE_Video, &MEDIASUBTYPE_RGB32},
+ {&MEDIATYPE_Video, &MEDIASUBTYPE_RGB32},
};
const AMOVIESETUP_PIN sudOpPin[] =
{
- {L"Output", FALSE, TRUE, FALSE, FALSE, &CLSID_NULL, NULL, countof(sudPinTypesOut), sudPinTypesOut}
+ {L"Output", FALSE, TRUE, FALSE, FALSE, &CLSID_NULL, NULL, countof(sudPinTypesOut), sudPinTypesOut}
};
const AMOVIESETUP_FILTER sudFilter[] =
{
- {&__uuidof(CFLICSource), L"MPC - FLICSource", MERIT_NORMAL, countof(sudOpPin), sudOpPin, CLSID_LegacyAmFilterCategory}
+ {&__uuidof(CFLICSource), L"MPC - FLICSource", MERIT_NORMAL, countof(sudOpPin), sudOpPin, CLSID_LegacyAmFilterCategory}
};
CFactoryTemplate g_Templates[] =
{
- {sudFilter[0].strName, sudFilter[0].clsID, CreateInstance<CFLICSource>, NULL, &sudFilter[0]}
+ {sudFilter[0].strName, sudFilter[0].clsID, CreateInstance<CFLICSource>, NULL, &sudFilter[0]}
};
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"));
+ SetRegKeyValue(
+ _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("1"), _T("4,2,,12AF"));
+ SetRegKeyValue(
+ _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("Source Filter"), _T("{17DB5CF6-39BB-4d5b-B0AA-BEBA44673AD4}"));
+ SetRegKeyValue(
+ _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("Source Filter"), _T("{17DB5CF6-39BB-4d5b-B0AA-BEBA44673AD4}"));
+ SetRegKeyValue(
+ _T("Media Type\\Extensions"), _T(".fli"),
+ _T("Source Filter"), _T("{17DB5CF6-39BB-4d5b-B0AA-BEBA44673AD4}"));
- SetRegKeyValue(
- _T("Media Type\\Extensions"), _T(".flc"),
- _T("Source Filter"), _T("{17DB5CF6-39BB-4d5b-B0AA-BEBA44673AD4}"));
+ SetRegKeyValue(
+ _T("Media Type\\Extensions"), _T(".flc"),
+ _T("Source Filter"), _T("{17DB5CF6-39BB-4d5b-B0AA-BEBA44673AD4}"));
- return AMovieDllRegisterServer2(TRUE);
+ return AMovieDllRegisterServer2(TRUE);
}
STDAPI DllUnregisterServer()
{
- DeleteRegKey(_T("Media Type\\{e436eb83-524f-11ce-9f53-0020af0ba770}"), _T("{17DB5CF6-39BB-4d5b-B0AA-BEBA44673AD4}"));
- DeleteRegKey(_T("Media Type\\Extensions"), _T(".fli"));
- DeleteRegKey(_T("Media Type\\Extensions"), _T(".flc"));
+ DeleteRegKey(_T("Media Type\\{e436eb83-524f-11ce-9f53-0020af0ba770}"), _T("{17DB5CF6-39BB-4d5b-B0AA-BEBA44673AD4}"));
+ DeleteRegKey(_T("Media Type\\Extensions"), _T(".fli"));
+ DeleteRegKey(_T("Media Type\\Extensions"), _T(".flc"));
- return AMovieDllRegisterServer2(FALSE);
+ return AMovieDllRegisterServer2(FALSE);
}
#include "../../FilterApp.h"
@@ -92,7 +92,7 @@ CFilterApp theApp;
//
CFLICSource::CFLICSource(LPUNKNOWN lpunk, HRESULT* phr)
- : CSource(NAME("CFLICSource"), lpunk, __uuidof(this))
+ : CSource(NAME("CFLICSource"), lpunk, __uuidof(this))
{
}
@@ -104,205 +104,205 @@ STDMETHODIMP CFLICSource::NonDelegatingQueryInterface(REFIID riid, void** ppv)
{
CheckPointer(ppv, E_POINTER);
- return
- QI(IFileSourceFilter)
- QI(IAMFilterMiscFlags)
- __super::NonDelegatingQueryInterface(riid, ppv);
+ return
+ QI(IFileSourceFilter)
+ QI(IAMFilterMiscFlags)
+ __super::NonDelegatingQueryInterface(riid, 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)
- return VFW_E_ALREADY_CONNECTED;
+ if(GetPinCount() > 0)
+ return VFW_E_ALREADY_CONNECTED;
- HRESULT hr = S_OK;
- if(!(DNew CFLICStream(pszFileName, this, &hr)))
- return E_OUTOFMEMORY;
+ HRESULT hr = S_OK;
+ if(!(DNew CFLICStream(pszFileName, this, &hr)))
+ return E_OUTOFMEMORY;
- if(FAILED(hr))
- return hr;
+ if(FAILED(hr))
+ return hr;
- m_fn = pszFileName;
+ m_fn = pszFileName;
- return S_OK;
+ return S_OK;
}
STDMETHODIMP CFLICSource::GetCurFile(LPOLESTR* ppszFileName, AM_MEDIA_TYPE* pmt)
{
- if(!ppszFileName) return E_POINTER;
-
- if(!(*ppszFileName = (LPOLESTR)CoTaskMemAlloc((m_fn.GetLength() + 1) * sizeof(WCHAR))))
- return E_OUTOFMEMORY;
+ if(!ppszFileName) return E_POINTER;
+
+ if(!(*ppszFileName = (LPOLESTR)CoTaskMemAlloc((m_fn.GetLength()+1)*sizeof(WCHAR))))
+ return E_OUTOFMEMORY;
- wcscpy(*ppszFileName, m_fn);
+ wcscpy(*ppszFileName, m_fn);
- return S_OK;
+ return S_OK;
}
// IAMFilterMiscFlags
ULONG CFLICSource::GetMiscFlags()
{
- return AM_FILTER_MISC_FLAGS_IS_SOURCE;
+ return AM_FILTER_MISC_FLAGS_IS_SOURCE;
}
// CFLICStream
-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)
-{
- CAutoLock cAutoLock(&m_cSharedState);
-
- CString fn(wfn);
-
- 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;
- return;
- }
-
- m_AvgTimePerFrame = (m_hdr.id == 0xaf11)
- ? 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)
- m_flic.Seek(pos, CFile::begin);
- else
- m_flic.Seek(pos + fp.size, CFile::begin);
- }
-
- do
- {
- FLIC_FRAME_ENTRY ffe;
- 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)
- {
- FLIC_CHUNK 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 =
- (/*fc.type == FLIC_256_COLOR
+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)
+{
+ CAutoLock cAutoLock(&m_cSharedState);
+
+ CString fn(wfn);
+
+ 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;
+ return;
+ }
+
+ m_AvgTimePerFrame = (m_hdr.id == 0xaf11)
+ ? 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)
+ m_flic.Seek(pos, CFile::begin);
+ else
+ m_flic.Seek(pos + fp.size, CFile::begin);
+ }
+
+ do
+ {
+ FLIC_FRAME_ENTRY ffe;
+ 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)
+ {
+ FLIC_CHUNK 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 =
+ (/*fc.type == FLIC_256_COLOR
|| fc.type == FLIC_64_COLOR
- ||*/ fc.type == FLIC_BRUN
- || fc.type == FLIC_BLACK
- || fc.type == FLIC_COPY);
-
- __int64 pos = m_flic.GetPosition() + fc.size - sizeof(fc);
- if(m_flic.Seek(pos, CFile::begin) != pos)
- break;
-
- chunk++;
- }
- if(chunk < ffe.hdr.chunks)
- break;
-
- __int64 pos = ffe.pos + ffe.hdr.size - sizeof(ffe.hdr);
- if(m_flic.Seek(pos, CFile::begin) != pos)
- break;
-
- m_frames.Add(ffe);
- }
- 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;
- return;
- }
-
- m_rtDuration = m_rtStop = m_AvgTimePerFrame * m_frames.GetCount();
-
- if(phr) *phr = m_rtDuration > 0 ? S_OK : E_FAIL;
+ ||*/ fc.type == FLIC_BRUN
+ || fc.type == FLIC_BLACK
+ || fc.type == FLIC_COPY);
+
+ __int64 pos = m_flic.GetPosition() + fc.size - sizeof(fc);
+ if(m_flic.Seek(pos, CFile::begin) != pos)
+ break;
+
+ chunk++;
+ }
+ if(chunk < ffe.hdr.chunks)
+ break;
+
+ __int64 pos = ffe.pos + ffe.hdr.size - sizeof(ffe.hdr);
+ if(m_flic.Seek(pos, CFile::begin) != pos)
+ break;
+
+ m_frames.Add(ffe);
+ }
+ 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;
+ return;
+ }
+
+ m_rtDuration = m_rtStop = m_AvgTimePerFrame*m_frames.GetCount();
+
+ if(phr) *phr = m_rtDuration > 0 ? S_OK : E_FAIL;
}
CFLICStream::~CFLICStream()
{
- CAutoLock cAutoLock(&m_cSharedState);
+ CAutoLock cAutoLock(&m_cSharedState);
}
STDMETHODIMP CFLICStream::NonDelegatingQueryInterface(REFIID riid, void** ppv)
{
CheckPointer(ppv, E_POINTER);
- return (riid == IID_IMediaSeeking) ? CSourceSeeking::NonDelegatingQueryInterface(riid, ppv) //GetInterface((IMediaSeeking*)this, ppv)
- : CSourceStream::NonDelegatingQueryInterface(riid, ppv);
+ return (riid == IID_IMediaSeeking) ? CSourceSeeking::NonDelegatingQueryInterface(riid, ppv) //GetInterface((IMediaSeeking*)this, ppv)
+ : CSourceStream::NonDelegatingQueryInterface(riid, ppv);
}
void CFLICStream::UpdateFromSeek()
{
- 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();
- // make sure we have stopped pushing
- Stop();
- // complete the flush
- DeliverEndFlush();
+ 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();
+ // make sure we have stopped pushing
+ Stop();
+ // complete the flush
+ DeliverEndFlush();
m_bFlushing = FALSE;
- // restart
- Run();
- }
+ // restart
+ Run();
+ }
}
HRESULT CFLICStream::SetRate(double dRate)
{
- if(dRate <= 0)
- return E_INVALIDARG;
+ if(dRate <= 0)
+ return E_INVALIDARG;
- {
- CAutoLock lock(CSourceSeeking::m_pLock);
- m_dRateSeeking = dRate;
- }
+ {
+ CAutoLock lock(CSourceSeeking::m_pLock);
+ m_dRateSeeking = dRate;
+ }
- UpdateFromSeek();
+ UpdateFromSeek();
- return S_OK;
+ return S_OK;
}
HRESULT CFLICStream::OnThreadStartPlay()
@@ -315,8 +315,8 @@ HRESULT CFLICStream::ChangeStart()
{
{
CAutoLock lock(CSourceSeeking::m_pLock);
- m_rtSampleTime = 0;
- m_rtPosition = m_rtStart;
+ m_rtSampleTime = 0;
+ m_rtPosition = m_rtStart;
}
UpdateFromSeek();
@@ -329,7 +329,7 @@ HRESULT CFLICStream::ChangeStop()
{
CAutoLock lock(CSourceSeeking::m_pLock);
if(m_rtPosition < m_rtStop)
- return S_OK;
+ return S_OK;
}
// We're already past the new stop time -- better flush the graph.
@@ -356,8 +356,8 @@ HRESULT CFLICStream::DecideBufferSize(IMemAllocator* pAlloc, ALLOCATOR_PROPERTIE
HRESULT hr = NOERROR;
- pProperties->cBuffers = 1;
- pProperties->cbBuffer = m_nBufferSize;
+ pProperties->cBuffers = 1;
+ pProperties->cbBuffer = m_nBufferSize;
ALLOCATOR_PROPERTIES Actual;
if(FAILED(hr = pAlloc->SetProperties(pProperties, &Actual))) return hr;
@@ -370,71 +370,71 @@ HRESULT CFLICStream::DecideBufferSize(IMemAllocator* pAlloc, ALLOCATOR_PROPERTIE
HRESULT CFLICStream::FillBuffer(IMediaSample* pSample)
{
- HRESULT hr;
+ HRESULT hr;
- {
- CAutoLock cAutoLockShared(&m_cSharedState);
+ {
+ CAutoLock cAutoLockShared(&m_cSharedState);
if(m_rtPosition >= m_rtStop)
- return S_FALSE;
-
- BYTE* pDataIn = m_pFrameBuffer;
- BYTE* pDataOut = NULL;
- if(!pDataIn || FAILED(hr = pSample->GetPointer(&pDataOut)) || !pDataOut)
- return S_FALSE;
-
- AM_MEDIA_TYPE* pmt;
- if(SUCCEEDED(pSample->GetMediaType(&pmt)) && pmt)
- {
- CMediaType mt(*pmt);
- SetMediaType(&mt);
-
- DeleteMediaType(pmt);
- }
-
- int w, h, bpp;
- 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)
- {
- w = ((VIDEOINFOHEADER2*)m_mt.pbFormat)->bmiHeader.biWidth;
- h = abs(((VIDEOINFOHEADER2*)m_mt.pbFormat)->bmiHeader.biHeight);
- bpp = ((VIDEOINFOHEADER2*)m_mt.pbFormat)->bmiHeader.biBitCount;
- }
- else
- {
- return S_FALSE;
- }
-
- int pitchIn = m_hdr.x;
- int pitchOut = w * bpp >> 3;
-
- int nFrame = m_rtPosition / m_AvgTimePerFrame; // (int)(1.0 * m_rtPosition / m_AvgTimePerFrame + 0.5);
-
- {
- SeekToNearestKeyFrame(nFrame);
-
- while(m_nLastFrameNum < nFrame && !m_bFlushing)
- ExtractFrame(++m_nLastFrameNum);
-
- 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++];
- }
- }
-
- pSample->SetActualDataLength(pitchOut * h);
-
- REFERENCE_TIME rtStart, rtStop;
+ return S_FALSE;
+
+ BYTE* pDataIn = m_pFrameBuffer;
+ BYTE* pDataOut = NULL;
+ if(!pDataIn || FAILED(hr = pSample->GetPointer(&pDataOut)) || !pDataOut)
+ return S_FALSE;
+
+ AM_MEDIA_TYPE* pmt;
+ if(SUCCEEDED(pSample->GetMediaType(&pmt)) && pmt)
+ {
+ CMediaType mt(*pmt);
+ SetMediaType(&mt);
+
+ DeleteMediaType(pmt);
+ }
+
+ int w, h, bpp;
+ 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)
+ {
+ w = ((VIDEOINFOHEADER2*)m_mt.pbFormat)->bmiHeader.biWidth;
+ h = abs(((VIDEOINFOHEADER2*)m_mt.pbFormat)->bmiHeader.biHeight);
+ bpp = ((VIDEOINFOHEADER2*)m_mt.pbFormat)->bmiHeader.biBitCount;
+ }
+ else
+ {
+ return S_FALSE;
+ }
+
+ int pitchIn = m_hdr.x;
+ int pitchOut = w*bpp>>3;
+
+ int nFrame = m_rtPosition / m_AvgTimePerFrame; // (int)(1.0 * m_rtPosition / m_AvgTimePerFrame + 0.5);
+
+ {
+ SeekToNearestKeyFrame(nFrame);
+
+ while(m_nLastFrameNum < nFrame && !m_bFlushing)
+ ExtractFrame(++m_nLastFrameNum);
+
+ 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++];
+ }
+ }
+
+ 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);
@@ -442,17 +442,17 @@ HRESULT CFLICStream::FillBuffer(IMediaSample* pSample)
m_rtSampleTime += m_AvgTimePerFrame;
m_rtPosition += m_AvgTimePerFrame;
- }
+ }
- pSample->SetSyncPoint(TRUE);
+ pSample->SetSyncPoint(TRUE);
- if(m_bDiscontinuity)
+ if(m_bDiscontinuity)
{
- pSample->SetDiscontinuity(TRUE);
- m_bDiscontinuity = FALSE;
- }
+ pSample->SetDiscontinuity(TRUE);
+ m_bDiscontinuity = FALSE;
+ }
- return S_OK;
+ return S_OK;
}
HRESULT CFLICStream::GetMediaType(int iPosition, CMediaType* pmt)
@@ -467,309 +467,290 @@ HRESULT CFLICStream::GetMediaType(int iPosition, CMediaType* pmt)
pmt->SetFormatType(&FORMAT_VideoInfo);
pmt->SetTemporalCompression(TRUE);
- VIDEOINFOHEADER* vih = (VIDEOINFOHEADER*)pmt->AllocFormatBuffer(sizeof(VIDEOINFOHEADER));
- memset(vih, 0, sizeof(VIDEOINFOHEADER));
- vih->AvgTimePerFrame = m_AvgTimePerFrame;
- vih->bmiHeader.biSize = sizeof(vih->bmiHeader);
- vih->bmiHeader.biWidth = m_hdr.x;
- vih->bmiHeader.biHeight = -m_hdr.y;
- vih->bmiHeader.biPlanes = 1;
- vih->bmiHeader.biBitCount = 32;
- vih->bmiHeader.biCompression = BI_RGB;
- vih->bmiHeader.biSizeImage = m_nBufferSize;
+ VIDEOINFOHEADER* vih = (VIDEOINFOHEADER*)pmt->AllocFormatBuffer(sizeof(VIDEOINFOHEADER));
+ memset(vih, 0, sizeof(VIDEOINFOHEADER));
+ vih->AvgTimePerFrame = m_AvgTimePerFrame;
+ vih->bmiHeader.biSize = sizeof(vih->bmiHeader);
+ vih->bmiHeader.biWidth = m_hdr.x;
+ vih->bmiHeader.biHeight = -m_hdr.y;
+ vih->bmiHeader.biPlanes = 1;
+ vih->bmiHeader.biBitCount = 32;
+ vih->bmiHeader.biCompression = BI_RGB;
+ vih->bmiHeader.biSizeImage = m_nBufferSize;
- pmt->SetSampleSize(vih->bmiHeader.biSizeImage);
+ pmt->SetSampleSize(vih->bmiHeader.biSizeImage);
return NOERROR;
}
HRESULT CFLICStream::CheckConnect(IPin* pPin)
{
- return CSourceStream::CheckConnect(pPin);
+ return CSourceStream::CheckConnect(pPin);
}
HRESULT CFLICStream::CheckMediaType(const CMediaType* pmt)
{
- if(pmt->majortype == MEDIATYPE_Video
- && pmt->subtype == MEDIASUBTYPE_RGB32
- && pmt->formattype == FORMAT_VideoInfo) return S_OK;
+ if(pmt->majortype == MEDIATYPE_Video
+ && pmt->subtype == MEDIASUBTYPE_RGB32
+ && pmt->formattype == FORMAT_VideoInfo) return S_OK;
- return E_INVALIDARG;
+ return E_INVALIDARG;
}
STDMETHODIMP CFLICStream::Notify(IBaseFilter* pSender, Quality q)
{
- return E_NOTIMPL;
+ return E_NOTIMPL;
}
////////
void CFLICStream::SeekToNearestKeyFrame(int nFrame)
{
- if(m_nLastFrameNum == nFrame)
- return;
+ if(m_nLastFrameNum == nFrame)
+ return;
- if(m_nLastFrameNum > nFrame)
- m_nLastFrameNum = -1;
+ if(m_nLastFrameNum > nFrame)
+ m_nLastFrameNum = -1;
- 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)
- m_nLastFrameNum = i - 1;
- }
+ 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)
+ m_nLastFrameNum = i-1;
+ }
}
void CFLICStream::ExtractFrame(int nFrame)
{
- FLIC_FRAME_ENTRY& ffe = m_frames[nFrame];
+ FLIC_FRAME_ENTRY& ffe = m_frames[nFrame];
- bool fNewPalette = false;
- bool fNewFrame = false;
+ bool fNewPalette = false;
+ bool fNewFrame = false;
- m_flic.Seek(ffe.pos, CFile::begin);
+ m_flic.Seek(ffe.pos, CFile::begin);
- int chunk = 0;
- while(chunk < ffe.hdr.chunks)
- {
- FLIC_CHUNK fc;
- if(m_flic.Read(&fc, sizeof(fc)) != sizeof(fc))
- break;
-
- __int64 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;
- }
-
- if(m_flic.Seek(next, CFile::begin) != next)
- break;
-
- chunk++;
- }
+ int chunk = 0;
+ while(chunk < ffe.hdr.chunks)
+ {
+ FLIC_CHUNK fc;
+ if(m_flic.Read(&fc, sizeof(fc)) != sizeof(fc))
+ break;
+
+ __int64 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;
+ }
+
+ if(m_flic.Seek(next, CFile::begin) != next)
+ break;
- if(chunk < ffe.hdr.chunks)
- ASSERT(0);
+ chunk++;
+ }
- ffe.fKeyframe = (fNewPalette && fNewFrame);
+ if(chunk < ffe.hdr.chunks)
+ ASSERT(0);
+
+ ffe.fKeyframe = (fNewPalette && fNewFrame);
}
void CFLICStream::_blackchunk()
{
- memset(m_pFrameBuffer, 0, m_nBufferSize);
+ memset(m_pFrameBuffer, 0, m_nBufferSize);
}
void CFLICStream::_copychunk()
{
- m_flic.Read(m_pFrameBuffer, m_nBufferSize);
+ m_flic.Read(m_pFrameBuffer, m_nBufferSize);
}
bool CFLICStream::_colorchunk(bool f64)
{
- int nColorsUpdated = 0;
-
- BYTE skip = 0;
-
- WORD packets;
- m_flic.Read(&packets, sizeof(packets));
-
- while(packets--)
- {
- BYTE skip2;
- m_flic.Read(&skip2, sizeof(skip2));
- skip += skip2;
-
- BYTE count;
- m_flic.Read(&count, sizeof(count));
-
- int len = (count == 0 ? (256 - skip) : count);
- 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);
- nColorsUpdated++;
- }
- }
-
- return(nColorsUpdated == 256);
+ int nColorsUpdated = 0;
+
+ BYTE skip = 0;
+
+ WORD packets;
+ m_flic.Read(&packets, sizeof(packets));
+
+ while(packets--)
+ {
+ BYTE skip2;
+ m_flic.Read(&skip2, sizeof(skip2));
+ skip += skip2;
+
+ BYTE count;
+ m_flic.Read(&count, sizeof(count));
+
+ int len = (count == 0 ? (256-skip) : count);
+ 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);
+ nColorsUpdated++;
+ }
+ }
+
+ return(nColorsUpdated == 256);
}
void CFLICStream::_brunchunk()
{
- BYTE* tmp = m_pFrameBuffer;
-
- int lines = m_hdr.y;
- while(lines--)
- {
- BYTE packets;
- m_flic.Read(&packets, sizeof(packets));
-
- BYTE* ptr = tmp;
-
- while(ptr < tmp + m_hdr.x)
- {
- signed char count;
- m_flic.Read(&count, sizeof(count));
-
- if(count >= 0)
- {
- BYTE c;
- m_flic.Read(&c, sizeof(c));
- memset(ptr, c, count);
- ptr += count;
- }
- else
- {
- m_flic.Read(ptr, -count);
- ptr += -count;
- }
- }
-
- tmp += m_hdr.x;
- }
+ BYTE* tmp = m_pFrameBuffer;
+
+ int lines = m_hdr.y;
+ while(lines--)
+ {
+ BYTE packets;
+ m_flic.Read(&packets, sizeof(packets));
+
+ BYTE* ptr = tmp;
+
+ while(ptr < tmp + m_hdr.x)
+ {
+ signed char count;
+ m_flic.Read(&count, sizeof(count));
+
+ if(count >= 0)
+ {
+ BYTE c;
+ m_flic.Read(&c, sizeof(c));
+ memset(ptr, c, count);
+ ptr += count;
+ }
+ else
+ {
+ m_flic.Read(ptr, -count);
+ ptr += -count;
+ }
+ }
+
+ tmp += m_hdr.x;
+ }
}
void CFLICStream::_lcchunk()
{
- WORD y;
- m_flic.Read(&y, sizeof(y));
+ WORD y;
+ m_flic.Read(&y, sizeof(y));
- BYTE* tmp = &m_pFrameBuffer[y*m_hdr.x];
+ BYTE* tmp = &m_pFrameBuffer[y*m_hdr.x];
- WORD lines;
- m_flic.Read(&lines, sizeof(lines));
+ WORD lines;
+ m_flic.Read(&lines, sizeof(lines));
- while(lines--)
- {
- BYTE* ptr = tmp;
-
- BYTE packets;
- m_flic.Read(&packets, sizeof(packets));
-
- while(packets--)
- {
- BYTE skip;
- m_flic.Read(&skip, sizeof(skip));
-
- ptr += skip;
-
- signed char count;
- m_flic.Read(&count, sizeof(count));
-
- if(count >= 0)
- {
- m_flic.Read(ptr, count);
- ptr += count;
- }
- else
- {
- BYTE c;
- m_flic.Read(&c, sizeof(c));
- memset(ptr, c, -count);
- ptr += -count;
- }
- }
-
- tmp += m_hdr.x;
- }
+ while(lines--)
+ {
+ BYTE* ptr = tmp;
+
+ BYTE packets;
+ m_flic.Read(&packets, sizeof(packets));
+
+ while(packets--)
+ {
+ BYTE skip;
+ m_flic.Read(&skip, sizeof(skip));
+
+ ptr += skip;
+
+ signed char count;
+ m_flic.Read(&count, sizeof(count));
+
+ if(count >= 0)
+ {
+ m_flic.Read(ptr, count);
+ ptr += count;
+ }
+ else
+ {
+ BYTE c;
+ m_flic.Read(&c, sizeof(c));
+ memset(ptr, c, -count);
+ ptr += -count;
+ }
+ }
+
+ tmp += m_hdr.x;
+ }
}
void CFLICStream::_deltachunk()
{
- BYTE* tmp = m_pFrameBuffer;
-
- WORD lines;
- m_flic.Read(&lines, sizeof(lines));
-
- while(lines--)
- {
- signed short packets;
- m_flic.Read(&packets, sizeof(packets));
-
- if(packets < 0)
- {
- if(packets & 0x4000)
- {
- tmp += -packets * m_hdr.x;
- lines++;
- }
- else
- {
- signed char count;
- m_flic.Read(&count, sizeof(count));
- tmp[m_hdr.x-1] = (BYTE)packets;
- }
- }
- else
- {
- BYTE* ptr = tmp;
-
- while(packets--)
- {
- BYTE skip;
- m_flic.Read(&skip, sizeof(skip));
-
- ptr += skip;
-
- signed char count;
- m_flic.Read(&count, sizeof(count));
-
- 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)
- m_flic.Read(ptr, count << 1);
- else
- ASSERT(FALSE);
- ptr += count << 1;
- }
- else
- {
- WORD c;
- m_flic.Read(&c, sizeof(c));
- count = -count;
- while(count-- > 0)
- {
- *ptr++ = c >> 8;
- *ptr++ = c & 0xff;
- }
- }
- }
-
- tmp += m_hdr.x;
- }
- }
+ BYTE* tmp = m_pFrameBuffer;
+
+ WORD lines;
+ m_flic.Read(&lines, sizeof(lines));
+
+ while(lines--)
+ {
+ signed short packets;
+ m_flic.Read(&packets, sizeof(packets));
+
+ if(packets < 0)
+ {
+ if(packets&0x4000)
+ {
+ tmp += -packets * m_hdr.x;
+ lines++;
+ }
+ else
+ {
+ signed char count;
+ m_flic.Read(&count, sizeof(count));
+ tmp[m_hdr.x-1] = (BYTE)packets;
+ }
+ }
+ else
+ {
+ BYTE* ptr = tmp;
+
+ while(packets--)
+ {
+ BYTE skip;
+ m_flic.Read(&skip, sizeof(skip));
+
+ ptr += skip;
+
+ signed char count;
+ m_flic.Read(&count, sizeof(count));
+
+ 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)
+ m_flic.Read(ptr, count << 1);
+ else
+ ASSERT(FALSE);
+ ptr += count << 1;
+ }
+ else
+ {
+ WORD c;
+ m_flic.Read(&c, sizeof(c));
+ count = -count;
+ while(count-- > 0)
+ {
+ *ptr++ = c>>8;
+ *ptr++ = c&0xff;
+ }
+ }
+ }
+
+ tmp += m_hdr.x;
+ }
+ }
}
diff --git a/src/filters/source/FLICSource/FLICSource.h b/src/filters/source/FLICSource/FLICSource.h
index 801f69286..acbade1e8 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,15 +6,15 @@
* 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.
+ * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
* http://www.gnu.org/copyleft/gpl.html
*
*/
@@ -26,134 +26,131 @@
#pragma pack(push, 1)
enum
{
- FLIC_256_COLOR = 4,
- FLIC_DELTA = 7,
- FLIC_64_COLOR = 11,
- FLIC_LC = 12,
- FLIC_BLACK = 13,
- FLIC_BRUN = 15,
- FLIC_COPY = 16,
- FLIC_MINI = 18
+ FLIC_256_COLOR = 4,
+ FLIC_DELTA = 7,
+ FLIC_64_COLOR = 11,
+ FLIC_LC = 12,
+ FLIC_BLACK = 13,
+ FLIC_BRUN = 15,
+ FLIC_COPY = 16,
+ FLIC_MINI = 18
};
-
+
struct FLIC
{
- DWORD size;
- WORD id; // 0xaf11 or 0xaf12
- WORD frames, x, y, bpp;
- WORD flags, ticks;
- DWORD next, frit;
- BYTE reserved[102];
+ DWORD size;
+ WORD id; // 0xaf11 or 0xaf12
+ WORD frames, x, y, bpp;
+ WORD flags, ticks;
+ DWORD next, frit;
+ BYTE reserved[102];
};
struct FLIC_PREFIX
{
- DWORD size;
- WORD id; // 0xf100
- WORD chunks;
- BYTE reserved[8];
+ DWORD size;
+ WORD id; // 0xf100
+ WORD chunks;
+ BYTE reserved[8];
};
struct FLIC_FRAME
{
- DWORD size;
- WORD id; // 0xf1fa
- WORD chunks;
- BYTE reserved[8];
+ DWORD size;
+ WORD id; // 0xf1fa
+ WORD chunks;
+ BYTE reserved[8];
};
struct FLIC_CHUNK
{
- DWORD size;
- WORD type;
+ DWORD size;
+ WORD type;
};
#pragma pack(pop)
struct FLIC_FRAME_ENTRY
{
- __int64 pos;
- bool fKeyframe;
- FLIC_FRAME hdr;
+ __int64 pos;
+ bool fKeyframe;
+ FLIC_FRAME hdr;
};
[uuid("17DB5CF6-39BB-4d5b-B0AA-BEBA44673AD4")]
class CFLICSource
- : public CSource
- , public IFileSourceFilter
- , public IAMFilterMiscFlags
+ : public CSource
+ , public IFileSourceFilter
+ , public IAMFilterMiscFlags
{
- CStringW m_fn;
+ CStringW m_fn;
public:
- CFLICSource(LPUNKNOWN lpunk, HRESULT* phr);
- virtual ~CFLICSource();
+ CFLICSource(LPUNKNOWN lpunk, HRESULT* phr);
+ virtual ~CFLICSource();
- DECLARE_IUNKNOWN;
+ DECLARE_IUNKNOWN;
STDMETHODIMP NonDelegatingQueryInterface(REFIID riid, void** ppv);
- // IFileSourceFilter
- STDMETHODIMP Load(LPCOLESTR pszFileName, const AM_MEDIA_TYPE* pmt);
- STDMETHODIMP GetCurFile(LPOLESTR* ppszFileName, AM_MEDIA_TYPE* pmt);
+ // IFileSourceFilter
+ STDMETHODIMP Load(LPCOLESTR pszFileName, const AM_MEDIA_TYPE* pmt);
+ STDMETHODIMP GetCurFile(LPOLESTR* ppszFileName, AM_MEDIA_TYPE* pmt);
- // IAMFilterMiscFlags
- STDMETHODIMP_(ULONG) GetMiscFlags();
+ // IAMFilterMiscFlags
+ STDMETHODIMP_(ULONG) GetMiscFlags();
};
-class CFLICStream
- : public CSourceStream
- , public CSourceSeeking
+class CFLICStream
+ : public CSourceStream
+ , public CSourceSeeking
{
- CFile m_flic;
- FLIC m_hdr;
- CAtlArray<FLIC_FRAME_ENTRY> m_frames;
+ CFile m_flic;
+ FLIC m_hdr;
+ CAtlArray<FLIC_FRAME_ENTRY> m_frames;
- CCritSec m_cSharedState;
+ CCritSec m_cSharedState;
- REFERENCE_TIME m_AvgTimePerFrame;
- REFERENCE_TIME m_rtSampleTime, m_rtPosition;
+ REFERENCE_TIME m_AvgTimePerFrame;
+ REFERENCE_TIME m_rtSampleTime, m_rtPosition;
- BOOL m_bDiscontinuity, m_bFlushing;
+ BOOL m_bDiscontinuity, m_bFlushing;
- HRESULT OnThreadStartPlay();
- HRESULT OnThreadCreate();
+ HRESULT OnThreadStartPlay();
+ HRESULT OnThreadCreate();
- void UpdateFromSeek();
- STDMETHODIMP SetRate(double dRate);
+ void UpdateFromSeek();
+ STDMETHODIMP SetRate(double dRate);
- HRESULT ChangeStart();
+ HRESULT ChangeStart();
HRESULT ChangeStop();
- HRESULT ChangeRate()
- {
- return S_OK;
- }
+ HRESULT ChangeRate() {return S_OK;}
private:
- int m_nLastFrameNum;
- DWORD m_pPalette[256];
- CAutoVectorPtr<BYTE> m_pFrameBuffer;
- int m_nBufferSize;
-
- void SeekToNearestKeyFrame(int nFrame);
- void ExtractFrame(int nFrame);
- void _blackchunk();
- void _copychunk();
- bool _colorchunk(bool f64);
- void _brunchunk();
- void _lcchunk();
- void _deltachunk();
+ int m_nLastFrameNum;
+ DWORD m_pPalette[256];
+ CAutoVectorPtr<BYTE> m_pFrameBuffer;
+ int m_nBufferSize;
+
+ void SeekToNearestKeyFrame(int nFrame);
+ void ExtractFrame(int nFrame);
+ void _blackchunk();
+ void _copychunk();
+ bool _colorchunk(bool f64);
+ void _brunchunk();
+ void _lcchunk();
+ void _deltachunk();
public:
CFLICStream(const WCHAR* wfn, CFLICSource* pParent, HRESULT* phr);
- virtual ~CFLICStream();
+ virtual ~CFLICStream();
STDMETHODIMP NonDelegatingQueryInterface(REFIID riid, void** ppv);
HRESULT DecideBufferSize(IMemAllocator* pIMemAlloc, ALLOCATOR_PROPERTIES* pProperties);
HRESULT FillBuffer(IMediaSample* pSample);
- HRESULT CheckConnect(IPin* pPin);
+ HRESULT CheckConnect(IPin* pPin);
HRESULT CheckMediaType(const CMediaType* pMediaType);
HRESULT GetMediaType(int iPosition, CMediaType* pmt);
-
- STDMETHODIMP Notify(IBaseFilter* pSender, Quality q);
+
+ STDMETHODIMP Notify(IBaseFilter* pSender, Quality q);
};
diff --git a/src/filters/source/FLICSource/resource.h b/src/filters/source/FLICSource/resource.h
index 4cd977803..43aa0620e 100644
--- a/src/filters/source/FLICSource/resource.h
+++ b/src/filters/source/FLICSource/resource.h
@@ -3,7 +3,7 @@
// Used by flicsource.rc
// Next default values for new objects
-//
+//
#ifdef APSTUDIO_INVOKED
#ifndef APSTUDIO_READONLY_SYMBOLS
#define _APS_NEXT_RESOURCE_VALUE 101
diff --git a/src/filters/source/FLICSource/stdafx.cpp b/src/filters/source/FLICSource/stdafx.cpp
index c60551b94..5158d6e51 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,15 +6,15 @@
* 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.
+ * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
* http://www.gnu.org/copyleft/gpl.html
*
*/
diff --git a/src/filters/source/FLICSource/stdafx.h b/src/filters/source/FLICSource/stdafx.h
index a9f666228..c35359c38 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,15 +6,15 @@
* 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.
+ * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
* http://www.gnu.org/copyleft/gpl.html
*
*/
diff --git a/src/filters/source/FlacSource/FlacSource.cpp b/src/filters/source/FlacSource/FlacSource.cpp
index a1e07d0b7..5283edfd1 100644
--- a/src/filters/source/FlacSource/FlacSource.cpp
+++ b/src/filters/source/FlacSource/FlacSource.cpp
@@ -1,4 +1,4 @@
-/*
+/*
* Copyright (C) 2003-2006 Gabest
* http://www.gabest.org
*
@@ -6,15 +6,15 @@
* 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.
+ * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
* http://www.gnu.org/copyleft/gpl.html
*
*/
@@ -35,49 +35,49 @@
const AMOVIESETUP_MEDIATYPE sudPinTypesOut[] =
{
- {&MEDIATYPE_Audio, &MEDIASUBTYPE_FLAC_FRAMED}
+ {&MEDIATYPE_Audio, &MEDIASUBTYPE_FLAC_FRAMED}
};
const AMOVIESETUP_PIN sudOpPin[] =
{
- {L"Output", FALSE, TRUE, FALSE, FALSE, &CLSID_NULL, NULL, countof(sudPinTypesOut), sudPinTypesOut}
+ {L"Output", FALSE, TRUE, FALSE, FALSE, &CLSID_NULL, NULL, countof(sudPinTypesOut), sudPinTypesOut}
};
const AMOVIESETUP_FILTER sudFilter[] =
{
- {&__uuidof(CFlacSource), L"MPC - Flac Source", MERIT_NORMAL, countof(sudOpPin), sudOpPin, CLSID_LegacyAmFilterCategory}
+ {&__uuidof(CFlacSource), L"MPC - Flac Source", MERIT_NORMAL, countof(sudOpPin), sudOpPin, CLSID_LegacyAmFilterCategory}
};
CFactoryTemplate g_Templates[] =
{
- {sudFilter[0].strName, sudFilter[0].clsID, CreateInstance<CFlacSource>, NULL, &sudFilter[0]}
+ {sudFilter[0].strName, sudFilter[0].clsID, CreateInstance<CFlacSource>, NULL, &sudFilter[0]}
};
int g_cTemplates = countof(g_Templates);
STDAPI DllRegisterServer()
{
- SetRegKeyValue(
- _T("Media Type\\{e436eb83-524f-11ce-9f53-0020af0ba770}"), _T("{1930D8FF-4739-4e42-9199-3B2EDEAA3BF2}"),
- _T("0"), _T("0,4,,664C6143"));
+ SetRegKeyValue(
+ _T("Media Type\\{e436eb83-524f-11ce-9f53-0020af0ba770}"), _T("{1930D8FF-4739-4e42-9199-3B2EDEAA3BF2}"),
+ _T("0"), _T("0,4,,664C6143"));
- SetRegKeyValue(
- _T("Media Type\\{e436eb83-524f-11ce-9f53-0020af0ba770}"), _T("{1930D8FF-4739-4e42-9199-3B2EDEAA3BF2}"),
- _T("Source Filter"), _T("{1930D8FF-4739-4e42-9199-3B2EDEAA3BF2}"));
+ SetRegKeyValue(
+ _T("Media Type\\{e436eb83-524f-11ce-9f53-0020af0ba770}"), _T("{1930D8FF-4739-4e42-9199-3B2EDEAA3BF2}"),
+ _T("Source Filter"), _T("{1930D8FF-4739-4e42-9199-3B2EDEAA3BF2}"));
- SetRegKeyValue(
- _T("Media Type\\Extensions"), _T(".flac"),
- _T("Source Filter"), _T("{1930D8FF-4739-4e42-9199-3B2EDEAA3BF2}"));
+ SetRegKeyValue(
+ _T("Media Type\\Extensions"), _T(".flac"),
+ _T("Source Filter"), _T("{1930D8FF-4739-4e42-9199-3B2EDEAA3BF2}"));
- return AMovieDllRegisterServer2(TRUE);
+ return AMovieDllRegisterServer2(TRUE);
}
STDAPI DllUnregisterServer()
{
- DeleteRegKey(_T("Media Type\\{e436eb83-524f-11ce-9f53-0020af0ba770}"), _T("{1930D8FF-4739-4e42-9199-3B2EDEAA3BF2}"));
- DeleteRegKey(_T("Media Type\\Extensions"), _T(".flac"));
+ DeleteRegKey(_T("Media Type\\{e436eb83-524f-11ce-9f53-0020af0ba770}"), _T("{1930D8FF-4739-4e42-9199-3B2EDEAA3BF2}"));
+ DeleteRegKey(_T("Media Type\\Extensions"), _T(".flac"));
- return AMovieDllRegisterServer2(FALSE);
+ return AMovieDllRegisterServer2(FALSE);
}
#include "../../FilterApp.h"
@@ -103,7 +103,7 @@ static void StreamDecoderMetadata(const FLAC__StreamDecoder *decoder, con
//
CFlacSource::CFlacSource(LPUNKNOWN lpunk, HRESULT* phr)
- : CBaseSource<CFlacStream>(NAME("CFlacSource"), lpunk, phr, __uuidof(this))
+ : CBaseSource<CFlacStream>(NAME("CFlacSource"), lpunk, phr, __uuidof(this))
{
}
@@ -113,52 +113,51 @@ CFlacSource::~CFlacSource()
// CFlacStream
-CFlacStream::CFlacStream(const WCHAR* wfn, CSource* pParent, HRESULT* phr)
- : CBaseStream(NAME("CFlacStream"), pParent, phr)
- , m_bIsEOF(false)
+CFlacStream::CFlacStream(const WCHAR* wfn, CSource* pParent, HRESULT* phr)
+ : CBaseStream(NAME("CFlacStream"), pParent, phr)
+ , m_bIsEOF (false)
{
- CAutoLock cAutoLock(&m_cSharedState);
- CString fn(wfn);
- CFileException ex;
- HRESULT hr = E_FAIL;
-
- do
- {
- if(!m_file.Open(fn, CFile::modeRead | CFile::shareDenyNone, &ex))
- {
- hr = AmHresultFromWin32(ex.m_lOsError);
- break;
- }
-
- m_pDecoder = FLAC__stream_decoder_new();
- if(!m_pDecoder) break;
-
- if(FLAC__STREAM_DECODER_INIT_STATUS_OK != FLAC__stream_decoder_init_stream(_DECODER_,
- StreamDecoderRead,
- StreamDecoderSeek,
- StreamDecoderTell,
- StreamDecoderLength,
- StreamDecoderEof,
- StreamDecoderWrite,
- StreamDecoderMetadata,
- StreamDecoderError,
- this))
- {
- break;
- }
-
-
- if(!FLAC__stream_decoder_process_until_end_of_metadata(_DECODER_) ||
- !FLAC__stream_decoder_seek_absolute(_DECODER_, 0))
- break;
-
- FLAC__stream_decoder_get_decode_position(_DECODER_, &m_llOffset);
-
- hr = S_OK;
- }
- while(false);
-
- if(phr) *phr = hr;
+ CAutoLock cAutoLock(&m_cSharedState);
+ CString fn(wfn);
+ CFileException ex;
+ HRESULT hr = E_FAIL;
+
+ do
+ {
+ if(!m_file.Open(fn, CFile::modeRead|CFile::shareDenyNone, &ex))
+ {
+ hr = AmHresultFromWin32 (ex.m_lOsError);
+ break;
+ }
+
+ m_pDecoder = FLAC__stream_decoder_new();
+ if (!m_pDecoder) break;
+
+ if (FLAC__STREAM_DECODER_INIT_STATUS_OK != FLAC__stream_decoder_init_stream (_DECODER_,
+ StreamDecoderRead,
+ StreamDecoderSeek,
+ StreamDecoderTell,
+ StreamDecoderLength,
+ StreamDecoderEof,
+ StreamDecoderWrite,
+ StreamDecoderMetadata,
+ StreamDecoderError,
+ this))
+ {
+ break;
+ }
+
+
+ if (!FLAC__stream_decoder_process_until_end_of_metadata (_DECODER_) ||
+ !FLAC__stream_decoder_seek_absolute (_DECODER_, 0))
+ break;
+
+ FLAC__stream_decoder_get_decode_position(_DECODER_, &m_llOffset);
+
+ hr = S_OK;
+ } while (false);
+
+ if(phr) *phr = hr;
}
CFlacStream::~CFlacStream()
@@ -173,8 +172,8 @@ HRESULT CFlacStream::DecideBufferSize(IMemAllocator* pAlloc, ALLOCATOR_PROPERTIE
HRESULT hr = NOERROR;
- pProperties->cBuffers = 1;
- pProperties->cbBuffer = m_nMaxFrameSize;
+ pProperties->cBuffers = 1;
+ pProperties->cbBuffer = m_nMaxFrameSize;
ALLOCATOR_PROPERTIES Actual;
if(FAILED(hr = pAlloc->SetProperties(pProperties, &Actual))) return hr;
@@ -187,33 +186,33 @@ HRESULT CFlacStream::DecideBufferSize(IMemAllocator* pAlloc, ALLOCATOR_PROPERTIE
HRESULT CFlacStream::FillBuffer(IMediaSample* pSample, int nFrame, BYTE* pOut, long& len)
{
- FLAC__uint64 llCurPos;
- FLAC__uint64 llNextPos;
+ FLAC__uint64 llCurPos;
+ FLAC__uint64 llNextPos;
- if(m_bDiscontinuity)
- {
- FLAC__stream_decoder_seek_absolute(_DECODER_, (m_rtPosition * m_i64TotalNumSamples) / m_rtDuration);
- }
+ if (m_bDiscontinuity)
+ {
+ FLAC__stream_decoder_seek_absolute (_DECODER_, (m_rtPosition * m_i64TotalNumSamples) / m_rtDuration);
+ }
- FLAC__stream_decoder_get_decode_position(_DECODER_, &llCurPos);
+ FLAC__stream_decoder_get_decode_position(_DECODER_, &llCurPos);
+
+ FLAC__stream_decoder_skip_single_frame (_DECODER_);
+ if (m_bIsEOF)
+ return S_FALSE;
+ FLAC__stream_decoder_get_decode_position(_DECODER_, &llNextPos);
- FLAC__stream_decoder_skip_single_frame(_DECODER_);
- if(m_bIsEOF)
- return S_FALSE;
- FLAC__stream_decoder_get_decode_position(_DECODER_, &llNextPos);
+ FLAC__uint64 llCurFile = m_file.GetPosition();
+ len = llNextPos - llCurPos;
+ ASSERT (len > 0);
+ if (len <= 0) return S_FALSE;
- FLAC__uint64 llCurFile = m_file.GetPosition();
- len = llNextPos - llCurPos;
- ASSERT(len > 0);
- if(len <= 0) return S_FALSE;
+ m_file.Seek (llCurPos, CFile::begin);
+ m_file.Read (pOut, len);
+ m_file.Seek (llCurFile, CFile::begin);
- m_file.Seek(llCurPos, CFile::begin);
- m_file.Read(pOut, len);
- m_file.Seek(llCurFile, CFile::begin);
+ m_AvgTimePerFrame = m_rtDuration * len / (m_llFileSize-m_llOffset);
- m_AvgTimePerFrame = m_rtDuration * len / (m_llFileSize - m_llOffset);
-
- return S_OK;
+ return S_OK;
}
@@ -222,118 +221,118 @@ HRESULT CFlacStream::GetMediaType(int iPosition, CMediaType* pmt)
{
CAutoLock cAutoLock(m_pFilter->pStateLock());
- if(iPosition == 0)
- {
- pmt->majortype = MEDIATYPE_Audio;
- pmt->subtype = MEDIASUBTYPE_FLAC_FRAMED;
- pmt->formattype = FORMAT_WaveFormatEx;
- WAVEFORMATEX* wfe = (WAVEFORMATEX*)pmt->AllocFormatBuffer(sizeof(WAVEFORMATEX));
- memset(wfe, 0, sizeof(WAVEFORMATEX));
- wfe->cbSize = sizeof(WAVEFORMATEX);
- wfe->wFormatTag = WAVE_FORMAT_FLAC;
- wfe->nSamplesPerSec = m_nSamplesPerSec;
- wfe->nAvgBytesPerSec = m_nAvgBytesPerSec;
- wfe->nChannels = m_nChannels;
- wfe->nBlockAlign = 1;
- wfe->wBitsPerSample = m_wBitsPerSample;
- }
- else
- {
- return VFW_S_NO_MORE_ITEMS;
- }
+ if(iPosition == 0)
+ {
+ pmt->majortype = MEDIATYPE_Audio;
+ pmt->subtype = MEDIASUBTYPE_FLAC_FRAMED;
+ pmt->formattype = FORMAT_WaveFormatEx;
+ WAVEFORMATEX* wfe = (WAVEFORMATEX*)pmt->AllocFormatBuffer(sizeof(WAVEFORMATEX));
+ memset(wfe, 0, sizeof(WAVEFORMATEX));
+ wfe->cbSize = sizeof(WAVEFORMATEX);
+ wfe->wFormatTag = WAVE_FORMAT_FLAC;
+ wfe->nSamplesPerSec = m_nSamplesPerSec;
+ wfe->nAvgBytesPerSec = m_nAvgBytesPerSec;
+ wfe->nChannels = m_nChannels;
+ wfe->nBlockAlign = 1;
+ wfe->wBitsPerSample = m_wBitsPerSample;
+ }
+ else
+ {
+ return VFW_S_NO_MORE_ITEMS;
+ }
pmt->SetTemporalCompression(FALSE);
- return S_OK;
+ return S_OK;
}
HRESULT CFlacStream::CheckMediaType(const CMediaType* pmt)
{
- if(pmt->majortype == MEDIATYPE_Audio
- && pmt->subtype == MEDIASUBTYPE_FLAC_FRAMED
- && pmt->formattype == FORMAT_WaveFormatEx
- && ((WAVEFORMATEX*)pmt->pbFormat)->wFormatTag == WAVE_FORMAT_FLAC)
- return S_OK;
- else
- return E_INVALIDARG;
+ if ( pmt->majortype == MEDIATYPE_Audio
+ && pmt->subtype == MEDIASUBTYPE_FLAC_FRAMED
+ && pmt->formattype == FORMAT_WaveFormatEx
+ && ((WAVEFORMATEX*)pmt->pbFormat)->wFormatTag == WAVE_FORMAT_FLAC)
+ return S_OK;
+ else
+ return E_INVALIDARG;
}
-void CFlacStream::UpdateFromMetadata(void* pBuffer)
+void CFlacStream::UpdateFromMetadata (void* pBuffer)
{
- const FLAC__StreamMetadata* pMetadata = (const FLAC__StreamMetadata*) pBuffer;
-
- m_nMaxFrameSize = pMetadata->data.stream_info.max_framesize;
- m_nSamplesPerSec = pMetadata->data.stream_info.sample_rate;
- m_nChannels = pMetadata->data.stream_info.channels;
- m_wBitsPerSample = pMetadata->data.stream_info.bits_per_sample;
- m_i64TotalNumSamples = pMetadata->data.stream_info.total_samples;
- m_nAvgBytesPerSec = (m_nChannels * (m_wBitsPerSample >> 3)) * m_nSamplesPerSec;
-
- // === Init members from base classes
- GetFileSizeEx(m_file.m_hFile, (LARGE_INTEGER*)&m_llFileSize);
- m_rtDuration = (m_i64TotalNumSamples * UNITS) / m_nSamplesPerSec;
- m_rtStop = m_rtDuration;
- m_AvgTimePerFrame = (m_nMaxFrameSize + pMetadata->data.stream_info.min_framesize) * m_rtDuration / 2 / m_llFileSize;
+ const FLAC__StreamMetadata* pMetadata = (const FLAC__StreamMetadata*) pBuffer;
+
+ m_nMaxFrameSize = pMetadata->data.stream_info.max_framesize;
+ m_nSamplesPerSec = pMetadata->data.stream_info.sample_rate;
+ m_nChannels = pMetadata->data.stream_info.channels;
+ m_wBitsPerSample = pMetadata->data.stream_info.bits_per_sample;
+ m_i64TotalNumSamples = pMetadata->data.stream_info.total_samples;
+ m_nAvgBytesPerSec = (m_nChannels * (m_wBitsPerSample >> 3)) * m_nSamplesPerSec;
+
+ // === Init members from base classes
+ GetFileSizeEx (m_file.m_hFile, (LARGE_INTEGER*)&m_llFileSize);
+ m_rtDuration = (m_i64TotalNumSamples * UNITS) / m_nSamplesPerSec;
+ m_rtStop = m_rtDuration;
+ m_AvgTimePerFrame = (m_nMaxFrameSize + pMetadata->data.stream_info.min_framesize) * m_rtDuration / 2 / m_llFileSize;
}
FLAC__StreamDecoderReadStatus StreamDecoderRead(const FLAC__StreamDecoder *decoder, FLAC__byte buffer[], size_t *bytes, void *client_data)
{
- CFlacStream* pThis = static_cast<CFlacStream*>(client_data);
- UINT nRead;
+ CFlacStream* pThis = static_cast<CFlacStream*> (client_data);
+ UINT nRead;
- nRead = pThis->GetFile()->Read(buffer, *bytes);
- pThis->m_bIsEOF = (nRead != *bytes);
- *bytes = nRead;
+ nRead = pThis->GetFile()->Read (buffer, *bytes);
+ pThis->m_bIsEOF = (nRead != *bytes);
+ *bytes = nRead;
- return (*bytes == 0) ? FLAC__STREAM_DECODER_READ_STATUS_END_OF_STREAM : FLAC__STREAM_DECODER_READ_STATUS_CONTINUE;
+ return (*bytes == 0) ? FLAC__STREAM_DECODER_READ_STATUS_END_OF_STREAM : FLAC__STREAM_DECODER_READ_STATUS_CONTINUE;
}
FLAC__StreamDecoderSeekStatus StreamDecoderSeek(const FLAC__StreamDecoder *decoder, FLAC__uint64 absolute_byte_offset, void *client_data)
{
- CFlacStream* pThis = static_cast<CFlacStream*>(client_data);
-
- pThis->m_bIsEOF = false;
- pThis->GetFile()->Seek(absolute_byte_offset, CFile::begin);
- return FLAC__STREAM_DECODER_SEEK_STATUS_OK;
+ CFlacStream* pThis = static_cast<CFlacStream*> (client_data);
+
+ pThis->m_bIsEOF = false;
+ pThis->GetFile()->Seek (absolute_byte_offset, CFile::begin);
+ return FLAC__STREAM_DECODER_SEEK_STATUS_OK;
}
FLAC__StreamDecoderTellStatus StreamDecoderTell(const FLAC__StreamDecoder *decoder, FLAC__uint64 *absolute_byte_offset, void *client_data)
{
- CFlacStream* pThis = static_cast<CFlacStream*>(client_data);
- *absolute_byte_offset = pThis->GetFile()->GetPosition();
- return FLAC__STREAM_DECODER_TELL_STATUS_OK;
+ CFlacStream* pThis = static_cast<CFlacStream*> (client_data);
+ *absolute_byte_offset = pThis->GetFile()->GetPosition();
+ return FLAC__STREAM_DECODER_TELL_STATUS_OK;
}
FLAC__StreamDecoderLengthStatus StreamDecoderLength(const FLAC__StreamDecoder *decoder, FLAC__uint64 *stream_length, void *client_data)
{
- CFlacStream* pThis = static_cast<CFlacStream*>(client_data);
- CFile* pFile = pThis->GetFile();
-
- if(pFile == NULL)
- return FLAC__STREAM_DECODER_LENGTH_STATUS_UNSUPPORTED;
- else
- {
- *stream_length = pFile->GetLength();
- return FLAC__STREAM_DECODER_LENGTH_STATUS_OK;
- }
+ CFlacStream* pThis = static_cast<CFlacStream*> (client_data);
+ CFile* pFile = pThis->GetFile();
+
+ if (pFile == NULL)
+ return FLAC__STREAM_DECODER_LENGTH_STATUS_UNSUPPORTED;
+ else
+ {
+ *stream_length = pFile->GetLength();
+ return FLAC__STREAM_DECODER_LENGTH_STATUS_OK;
+ }
}
FLAC__bool StreamDecoderEof(const FLAC__StreamDecoder *decoder, void *client_data)
{
- CFlacStream* pThis = static_cast<CFlacStream*>(client_data);
+ CFlacStream* pThis = static_cast<CFlacStream*> (client_data);
- return pThis->m_bIsEOF;
+ return pThis->m_bIsEOF;
}
FLAC__StreamDecoderWriteStatus StreamDecoderWrite(const FLAC__StreamDecoder *decoder, const FLAC__Frame *frame, const FLAC__int32 * const buffer[], void *client_data)
{
- CFlacStream* pThis = static_cast<CFlacStream*>(client_data);
+ CFlacStream* pThis = static_cast<CFlacStream*> (client_data);
- return FLAC__STREAM_DECODER_WRITE_STATUS_CONTINUE;
+ return FLAC__STREAM_DECODER_WRITE_STATUS_CONTINUE;
}
void StreamDecoderError(const FLAC__StreamDecoder *decoder, FLAC__StreamDecoderErrorStatus status, void *client_data)
@@ -343,8 +342,8 @@ void StreamDecoderError(const FLAC__StreamDecoder *decoder, FLAC__StreamDecoderE
void StreamDecoderMetadata(const FLAC__StreamDecoder *decoder, const FLAC__StreamMetadata *metadata, void *client_data)
{
- CFlacStream* pThis = static_cast<CFlacStream*>(client_data);
+ CFlacStream* pThis = static_cast<CFlacStream*> (client_data);
- if(pThis)
- pThis->UpdateFromMetadata((void*)metadata);
+ if (pThis)
+ pThis->UpdateFromMetadata ((void*)metadata);
}
diff --git a/src/filters/source/FlacSource/FlacSource.h b/src/filters/source/FlacSource/FlacSource.h
index f7c4ce5a0..3b7f87969 100644
--- a/src/filters/source/FlacSource/FlacSource.h
+++ b/src/filters/source/FlacSource/FlacSource.h
@@ -1,4 +1,4 @@
-/*
+/*
* Copyright (C) 2003-2006 Gabest
* http://www.gabest.org
*
@@ -6,15 +6,15 @@
* 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.
+ * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
* http://www.gnu.org/copyleft/gpl.html
*
*/
@@ -30,8 +30,8 @@ class CFlacStream;
class CFlacSource : public CBaseSource<CFlacStream>
{
public:
- CFlacSource(LPUNKNOWN lpunk, HRESULT* phr);
- virtual ~CFlacSource();
+ CFlacSource(LPUNKNOWN lpunk, HRESULT* phr);
+ virtual ~CFlacSource();
};
@@ -39,34 +39,31 @@ class CGolombBuffer;
class CFlacStream : public CBaseStream
{
- CFile m_file;
- void* m_pDecoder;
+ CFile m_file;
+ void* m_pDecoder;
- int m_nMaxFrameSize;
- int m_nSamplesPerSec;
- int m_nChannels;
- WORD m_wBitsPerSample;
- __int64 m_i64TotalNumSamples;
- int m_nAvgBytesPerSec;
+ int m_nMaxFrameSize;
+ int m_nSamplesPerSec;
+ int m_nChannels;
+ WORD m_wBitsPerSample;
+ __int64 m_i64TotalNumSamples;
+ int m_nAvgBytesPerSec;
- ULONGLONG m_llOffset; // Position of first frame in file
- ULONGLONG m_llFileSize; // Size of the file
+ ULONGLONG m_llOffset; // Position of first frame in file
+ ULONGLONG m_llFileSize; // Size of the file
public:
CFlacStream(const WCHAR* wfn, CSource* pParent, HRESULT* phr);
- virtual ~CFlacStream();
+ virtual ~CFlacStream();
HRESULT FillBuffer(IMediaSample* pSample, int nFrame, BYTE* pOut, long& len);
-
- HRESULT DecideBufferSize(IMemAllocator* pIMemAlloc, ALLOCATOR_PROPERTIES* pProperties);
+
+ HRESULT DecideBufferSize(IMemAllocator* pIMemAlloc, ALLOCATOR_PROPERTIES* pProperties);
HRESULT CheckMediaType(const CMediaType* pMediaType);
HRESULT GetMediaType(int iPosition, CMediaType* pmt);
- void UpdateFromMetadata(void* pBuffer);
- inline CFile* GetFile()
- {
- return &m_file;
- };
+ void UpdateFromMetadata (void* pBuffer);
+ inline CFile* GetFile() { return &m_file; };
- bool m_bIsEOF;
+ bool m_bIsEOF;
};
diff --git a/src/filters/source/FlacSource/resource.h b/src/filters/source/FlacSource/resource.h
index 6e541c0c4..3507c6e74 100644
--- a/src/filters/source/FlacSource/resource.h
+++ b/src/filters/source/FlacSource/resource.h
@@ -3,7 +3,7 @@
// Used by dtsac3source.rc
// Next default values for new objects
-//
+//
#ifdef APSTUDIO_INVOKED
#ifndef APSTUDIO_READONLY_SYMBOLS
#define _APS_NEXT_RESOURCE_VALUE 101
diff --git a/src/filters/source/FlacSource/stdafx.cpp b/src/filters/source/FlacSource/stdafx.cpp
index 4b148b3b2..396f14d73 100644
--- a/src/filters/source/FlacSource/stdafx.cpp
+++ b/src/filters/source/FlacSource/stdafx.cpp
@@ -1,4 +1,4 @@
-/*
+/*
* Copyright (C) 2003-2006 Gabest
* http://www.gabest.org
*
@@ -6,15 +6,15 @@
* 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.
+ * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
* http://www.gnu.org/copyleft/gpl.html
*
*/
diff --git a/src/filters/source/FlacSource/stdafx.h b/src/filters/source/FlacSource/stdafx.h
index a9f666228..c35359c38 100644
--- a/src/filters/source/FlacSource/stdafx.h
+++ b/src/filters/source/FlacSource/stdafx.h
@@ -1,4 +1,4 @@
-/*
+/*
* Copyright (C) 2003-2006 Gabest
* http://www.gabest.org
*
@@ -6,15 +6,15 @@
* 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.
+ * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
* http://www.gnu.org/copyleft/gpl.html
*
*/
diff --git a/src/filters/source/ShoutcastSource/ShoutcastSource.cpp b/src/filters/source/ShoutcastSource/ShoutcastSource.cpp
index a2b8c5ec7..75bdf8d51 100644
--- a/src/filters/source/ShoutcastSource/ShoutcastSource.cpp
+++ b/src/filters/source/ShoutcastSource/ShoutcastSource.cpp
@@ -1,4 +1,4 @@
-/*
+/*
* Copyright (C) 2003-2006 Gabest
* http://www.gabest.org
*
@@ -6,15 +6,15 @@
* 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.
+ * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
* http://www.gnu.org/copyleft/gpl.html
*
*/
@@ -33,47 +33,47 @@
static const DWORD s_bitrate[2][16] =
{
- {1, 8, 16, 24, 32, 40, 48, 56, 64, 80, 96, 112, 128, 144, 160, 0},
- {1, 32, 40, 48, 56, 64, 80, 96, 112, 128, 160, 192, 224, 256, 320, 0}
+ {1,8,16,24,32,40,48,56,64,80,96,112,128,144,160,0},
+ {1,32,40,48,56,64,80,96,112,128,160,192,224,256,320,0}
};
static const DWORD s_freq[4][4] =
{
- {11025, 12000, 8000, 0},
- {0, 0, 0, 0},
- {22050, 24000, 16000, 0},
- {44100, 48000, 32000, 0}
+ {11025,12000,8000,0},
+ {0,0,0,0},
+ {22050,24000,16000,0},
+ {44100,48000,32000,0}
};
static const BYTE s_channels[4] =
{
- 2, 2, 2, 1 // stereo, joint stereo, dual, mono
+ 2,2,2,1 // stereo, joint stereo, dual, mono
};
typedef struct
{
- WORD sync;
- BYTE version;
- BYTE layer;
- DWORD bitrate;
- DWORD freq;
- BYTE channels;
- DWORD framesize;
-
- bool ExtractHeader(CSocket& socket)
- {
- BYTE buff[4];
- if(4 != socket.Receive(buff, 4, MSG_PEEK))
- return(false);
-
- sync = (buff[0] << 4) | (buff[1] >> 4) | 1;
- version = (buff[1] >> 3) & 3;
- layer = 4 - ((buff[1] >> 1) & 3);
- bitrate = s_bitrate[version&1][buff[2] >> 4] * 1000;
- freq = s_freq[version][(buff[2] >> 2) & 3];
- channels = s_channels[(buff[3] >> 6) & 3];
- framesize = freq ? ((((version & 1) ? 144 : 72) * bitrate / freq) + ((buff[2] >> 1) & 1)) : 0;
-
- return(sync == 0xfff && layer == 3 && bitrate != 0 && freq != 0);
- }
+ WORD sync;
+ BYTE version;
+ BYTE layer;
+ DWORD bitrate;
+ DWORD freq;
+ BYTE channels;
+ DWORD framesize;
+
+ bool ExtractHeader(CSocket& socket)
+ {
+ BYTE buff[4];
+ if(4 != socket.Receive(buff, 4, MSG_PEEK))
+ return(false);
+
+ sync = (buff[0]<<4)|(buff[1]>>4)|1;
+ version = (buff[1]>>3)&3;
+ layer = 4 - ((buff[1]>>1)&3);
+ bitrate = s_bitrate[version&1][buff[2]>>4]*1000;
+ freq = s_freq[version][(buff[2]>>2)&3];
+ channels = s_channels[(buff[3]>>6)&3];
+ framesize = freq ? ((((version&1)?144:72) * bitrate / freq) + ((buff[2]>>1)&1)) : 0;
+
+ return(sync == 0xfff && layer == 3 && bitrate != 0 && freq != 0);
+ }
} mp3hdr;
@@ -81,34 +81,34 @@ typedef struct
const AMOVIESETUP_MEDIATYPE sudPinTypesOut[] =
{
- {&MEDIATYPE_Audio, &MEDIASUBTYPE_MP3},
+ {&MEDIATYPE_Audio, &MEDIASUBTYPE_MP3},
};
const AMOVIESETUP_PIN sudOpPin[] =
{
- {L"Output", FALSE, TRUE, FALSE, FALSE, &CLSID_NULL, NULL, countof(sudPinTypesOut), sudPinTypesOut}
+ {L"Output", FALSE, TRUE, FALSE, FALSE, &CLSID_NULL, NULL, countof(sudPinTypesOut), sudPinTypesOut}
};
const AMOVIESETUP_FILTER sudFilter[] =
{
- {&__uuidof(CShoutcastSource), L"MPC - ShoutcastSource", MERIT_NORMAL, countof(sudOpPin), sudOpPin, CLSID_LegacyAmFilterCategory}
+ {&__uuidof(CShoutcastSource), L"MPC - ShoutcastSource", MERIT_NORMAL, countof(sudOpPin), sudOpPin, CLSID_LegacyAmFilterCategory}
};
CFactoryTemplate g_Templates[] =
{
- {sudFilter[0].strName, sudFilter[0].clsID, CreateInstance<CShoutcastSource>, NULL, &sudFilter[0]}
+ {sudFilter[0].strName, sudFilter[0].clsID, CreateInstance<CShoutcastSource>, NULL, &sudFilter[0]}
};
int g_cTemplates = countof(g_Templates);
STDAPI DllRegisterServer()
{
- return AMovieDllRegisterServer2(TRUE);
+ return AMovieDllRegisterServer2(TRUE);
}
STDAPI DllUnregisterServer()
{
- return AMovieDllRegisterServer2(FALSE);
+ return AMovieDllRegisterServer2(FALSE);
}
#include "../../FilterApp.h"
@@ -116,24 +116,24 @@ STDAPI DllUnregisterServer()
class CShoutcastSourceApp : public CFilterApp
{
public:
- BOOL InitInstance()
- {
- if(!__super::InitInstance()) return FALSE;
- /*
- if(!AfxWinInit(::GetModuleHandle(NULL), NULL, ::GetCommandLine(), 0))
- {
- AfxMessageBox(_T("AfxWinInit failed!"));
- return FALSE;
- }
- */
- if(!AfxSocketInit(NULL))
- {
- AfxMessageBox(_T("AfxSocketInit failed!"));
- return FALSE;
- }
-
- return TRUE;
- }
+ BOOL InitInstance()
+ {
+ if(!__super::InitInstance()) return FALSE;
+/*
+ if(!AfxWinInit(::GetModuleHandle(NULL), NULL, ::GetCommandLine(), 0))
+ {
+ AfxMessageBox(_T("AfxWinInit failed!"));
+ return FALSE;
+ }
+*/
+ if(!AfxSocketInit(NULL))
+ {
+ AfxMessageBox(_T("AfxSocketInit failed!"));
+ return FALSE;
+ }
+
+ return TRUE;
+ }
};
CShoutcastSourceApp theApp;
@@ -145,10 +145,10 @@ CShoutcastSourceApp theApp;
//
CShoutcastSource::CShoutcastSource(LPUNKNOWN lpunk, HRESULT* phr)
- : CSource(NAME("CShoutcastSource"), lpunk, __uuidof(this))
+ : CSource(NAME("CShoutcastSource"), lpunk, __uuidof(this))
{
#ifndef REGISTER_FILTER
- AfxSocketInit();
+ AfxSocketInit();
#endif
}
@@ -160,96 +160,96 @@ STDMETHODIMP CShoutcastSource::NonDelegatingQueryInterface(REFIID riid, void** p
{
CheckPointer(ppv, E_POINTER);
- return
- QI(IFileSourceFilter)
- QI(IAMFilterMiscFlags)
- QI(IAMOpenProgress)
- QI2(IAMMediaContent)
- __super::NonDelegatingQueryInterface(riid, ppv);
+ return
+ QI(IFileSourceFilter)
+ QI(IAMFilterMiscFlags)
+ QI(IAMOpenProgress)
+ QI2(IAMMediaContent)
+ __super::NonDelegatingQueryInterface(riid, ppv);
}
// IFileSourceFilter
-STDMETHODIMP CShoutcastSource::Load(LPCOLESTR pszFileName, const AM_MEDIA_TYPE* pmt)
+STDMETHODIMP CShoutcastSource::Load(LPCOLESTR pszFileName, const AM_MEDIA_TYPE* pmt)
{
- if(GetPinCount() > 0)
- return VFW_E_ALREADY_CONNECTED;
+ if(GetPinCount() > 0)
+ return VFW_E_ALREADY_CONNECTED;
- HRESULT hr = E_OUTOFMEMORY;
+ HRESULT hr = E_OUTOFMEMORY;
- if(!(DNew CShoutcastStream(pszFileName, this, &hr)) || FAILED(hr))
- return hr;
+ if(!(DNew CShoutcastStream(pszFileName, this, &hr)) || FAILED(hr))
+ return hr;
- m_fn = pszFileName;
+ m_fn = pszFileName;
- return S_OK;
+ return S_OK;
}
STDMETHODIMP CShoutcastSource::GetCurFile(LPOLESTR* ppszFileName, AM_MEDIA_TYPE* pmt)
{
- if(!ppszFileName) return E_POINTER;
-
- if(!(*ppszFileName = (LPOLESTR)CoTaskMemAlloc((m_fn.GetLength() + 1) * sizeof(WCHAR))))
- return E_OUTOFMEMORY;
+ if(!ppszFileName) return E_POINTER;
+
+ if(!(*ppszFileName = (LPOLESTR)CoTaskMemAlloc((m_fn.GetLength()+1)*sizeof(WCHAR))))
+ return E_OUTOFMEMORY;
- wcscpy(*ppszFileName, m_fn);
+ wcscpy(*ppszFileName, m_fn);
- return S_OK;
+ return S_OK;
}
// IAMFilterMiscFlags
ULONG CShoutcastSource::GetMiscFlags()
{
- return AM_FILTER_MISC_FLAGS_IS_SOURCE;
+ return AM_FILTER_MISC_FLAGS_IS_SOURCE;
}
// IAMOpenProgress
STDMETHODIMP CShoutcastSource::QueryProgress(LONGLONG* pllTotal, LONGLONG* pllCurrent)
{
- if(m_iPins == 1)
- {
+ if(m_iPins == 1)
+ {
if(pllTotal) *pllTotal = 100;
- if(pllCurrent) *pllCurrent = (static_cast<CShoutcastStream*>(m_paStreams[0]))->GetBufferFullness();
- return S_OK;
- }
+ if(pllCurrent) *pllCurrent = (static_cast<CShoutcastStream*>(m_paStreams[0]))->GetBufferFullness();
+ return S_OK;
+ }
- return E_UNEXPECTED;
+ return E_UNEXPECTED;
}
STDMETHODIMP CShoutcastSource::AbortOperation()
{
- return E_NOTIMPL;
+ return E_NOTIMPL;
}
// IAMMediaContent
STDMETHODIMP CShoutcastSource::get_Title(BSTR* pbstrTitle)
{
- CheckPointer(pbstrTitle, E_POINTER);
+ CheckPointer(pbstrTitle, E_POINTER);
- if(m_iPins == 1)
- {
- *pbstrTitle = (static_cast<CShoutcastStream*>(m_paStreams[0]))->GetTitle().AllocSysString();
- return S_OK;
- }
+ if(m_iPins == 1)
+ {
+ *pbstrTitle = (static_cast<CShoutcastStream*>(m_paStreams[0]))->GetTitle().AllocSysString();
+ return S_OK;
+ }
- return E_UNEXPECTED;
+ return E_UNEXPECTED;
}
// CShoutcastStream
CShoutcastStream::CShoutcastStream(const WCHAR* wfn, CShoutcastSource* pParent, HRESULT* phr)
- : CSourceStream(NAME("ShoutcastStream"), phr, pParent, L"Output")
- , m_fBuffering(false)
+ : CSourceStream(NAME("ShoutcastStream"), phr, pParent, L"Output")
+ , m_fBuffering(false)
{
- ASSERT(phr);
+ ASSERT(phr);
- *phr = S_OK;
+ *phr = S_OK;
- CString fn(wfn);
- if(fn.Find(_T("://")) < 0) fn = _T("http://") + fn;
+ CString fn(wfn);
+ if(fn.Find(_T("://")) < 0) fn = _T("http://") + fn;
#if defined(REGISTER_FILTER) && defined(DEBUG)
//fn = _T("http://localhost:8000/");
@@ -257,37 +257,37 @@ CShoutcastStream::CShoutcastStream(const WCHAR* wfn, CShoutcastSource* pParent,
//fn = _T("http://218.145.30.106:11000"); // 128kbps korean
//fn = _T("http://65.206.46.110:8020"); // 96kbps
//fn = _T("http://64.236.34.72:80/stream/1003");
- fn = _T("http://64.236.34.72:80/stream/1011");
+fn = _T("http://64.236.34.72:80/stream/1011");
//fn = _T("http://218.145.30.106:11000");
//fn = _T("http://radio.sluchaj.com:8000/radio.ogg"); // ogg
// http://www.oddsock.org/icecast2yp/ // more ogg via icecast2
#endif
- if(!m_url.CrackUrl(fn))
- {
- *phr = E_FAIL;
- return;
- }
+ if(!m_url.CrackUrl(fn))
+ {
+ *phr = E_FAIL;
+ return;
+ }
- if(m_url.GetUrlPathLength() == 0)
- m_url.SetUrlPath(_T("/"));
+ if(m_url.GetUrlPathLength() == 0)
+ m_url.SetUrlPath(_T("/"));
- if(m_url.GetPortNumber() == ATL_URL_INVALID_PORT_NUMBER)
- m_url.SetPortNumber(ATL_URL_DEFAULT_HTTP_PORT);
+ if(m_url.GetPortNumber() == ATL_URL_INVALID_PORT_NUMBER)
+ m_url.SetPortNumber(ATL_URL_DEFAULT_HTTP_PORT);
- if(m_url.GetScheme() != ATL_URL_SCHEME_HTTP)
- {
- *phr = E_FAIL;
- return;
- }
+ if(m_url.GetScheme() != ATL_URL_SCHEME_HTTP)
+ {
+ *phr = E_FAIL;
+ return;
+ }
- if(!m_socket.Create() || !m_socket.Connect(m_url))
- {
- *phr = E_FAIL;
- return;
- }
+ if(!m_socket.Create() || !m_socket.Connect(m_url))
+ {
+ *phr = E_FAIL;
+ return;
+ }
- m_socket.Close();
+ m_socket.Close();
}
CShoutcastStream::~CShoutcastStream()
@@ -296,23 +296,23 @@ CShoutcastStream::~CShoutcastStream()
void CShoutcastStream::EmptyBuffer()
{
- CAutoLock cAutoLock(&m_queue);
- m_queue.RemoveAll();
+ CAutoLock cAutoLock(&m_queue);
+ m_queue.RemoveAll();
}
LONGLONG CShoutcastStream::GetBufferFullness()
{
- CAutoLock cAutoLock(&m_queue);
- if(!m_fBuffering) return 100;
- if(m_queue.IsEmpty()) return 0;
- LONGLONG ret = 100i64 * (m_queue.GetTail().rtStart - m_queue.GetHead().rtStart) / AVGBUFFERLENGTH;
- return(min(ret, 100));
+ CAutoLock cAutoLock(&m_queue);
+ if(!m_fBuffering) return 100;
+ if(m_queue.IsEmpty()) return 0;
+ LONGLONG ret = 100i64*(m_queue.GetTail().rtStart - m_queue.GetHead().rtStart) / AVGBUFFERLENGTH;
+ return(min(ret, 100));
}
CString CShoutcastStream::GetTitle()
{
- CAutoLock cAutoLock(&m_queue);
- return(m_title);
+ CAutoLock cAutoLock(&m_queue);
+ return(m_title);
}
HRESULT CShoutcastStream::DecideBufferSize(IMemAllocator* pAlloc, ALLOCATOR_PROPERTIES* pProperties)
@@ -322,8 +322,8 @@ HRESULT CShoutcastStream::DecideBufferSize(IMemAllocator* pAlloc, ALLOCATOR_PROP
HRESULT hr = NOERROR;
- pProperties->cBuffers = BUFFERS;
- pProperties->cbBuffer = MAXFRAMESIZE;
+ pProperties->cBuffers = BUFFERS;
+ pProperties->cbBuffer = MAXFRAMESIZE;
ALLOCATOR_PROPERTIES Actual;
if(FAILED(hr = pAlloc->SetProperties(pProperties, &Actual))) return hr;
@@ -336,65 +336,65 @@ HRESULT CShoutcastStream::DecideBufferSize(IMemAllocator* pAlloc, ALLOCATOR_PROP
HRESULT CShoutcastStream::FillBuffer(IMediaSample* pSample)
{
- HRESULT hr;
-
- BYTE* pData = NULL;
- if(FAILED(hr = pSample->GetPointer(&pData)) || !pData)
- return S_FALSE;
-
- do
- {
- // do we have to refill our buffer?
- {
- CAutoLock cAutoLock(&m_queue);
- if(!m_queue.IsEmpty() && m_queue.GetHead().rtStart < m_queue.GetTail().rtStart - MINBUFFERLENGTH)
- break; // nope, that's great
- }
-
- TRACE(_T("START BUFFERING\n"));
- m_fBuffering = true;
-
- while(1)
- {
- if(fExitThread) // playback stopped?
- return S_FALSE;
-
- Sleep(50);
-
- CAutoLock cAutoLock(&m_queue);
- if(!m_queue.IsEmpty() && m_queue.GetHead().rtStart < m_queue.GetTail().rtStart - AVGBUFFERLENGTH)
- break; // this is enough
- }
-
- pSample->SetDiscontinuity(TRUE);
-
- DeliverBeginFlush();
- DeliverEndFlush();
-
- DeliverNewSegment(0, ~0, 1.0);
-
- TRACE(_T("END BUFFERING\n"));
- m_fBuffering = false;
- }
- while(false);
-
- {
- CAutoLock cAutoLock(&m_queue);
- ASSERT(!m_queue.IsEmpty());
- if(!m_queue.IsEmpty())
- {
- mp3frame f = m_queue.RemoveHead();
- DWORD len = min(pSample->GetSize(), f.len);
- memcpy(pData, f.pData, len);
- pSample->SetActualDataLength(len);
- pSample->SetTime(&f.rtStart, &f.rtStop);
- m_title = f.title;
- }
- }
-
- pSample->SetSyncPoint(TRUE);
-
- return S_OK;
+ HRESULT hr;
+
+ BYTE* pData = NULL;
+ if(FAILED(hr = pSample->GetPointer(&pData)) || !pData)
+ return S_FALSE;
+
+ do
+ {
+ // do we have to refill our buffer?
+ {
+ CAutoLock cAutoLock(&m_queue);
+ if(!m_queue.IsEmpty() && m_queue.GetHead().rtStart < m_queue.GetTail().rtStart - MINBUFFERLENGTH)
+ break; // nope, that's great
+ }
+
+ TRACE(_T("START BUFFERING\n"));
+ m_fBuffering = true;
+
+ while(1)
+ {
+ if(fExitThread) // playback stopped?
+ return S_FALSE;
+
+ Sleep(50);
+
+ CAutoLock cAutoLock(&m_queue);
+ if(!m_queue.IsEmpty() && m_queue.GetHead().rtStart < m_queue.GetTail().rtStart - AVGBUFFERLENGTH)
+ break; // this is enough
+ }
+
+ pSample->SetDiscontinuity(TRUE);
+
+ DeliverBeginFlush();
+ DeliverEndFlush();
+
+ DeliverNewSegment(0, ~0, 1.0);
+
+ TRACE(_T("END BUFFERING\n"));
+ m_fBuffering = false;
+ }
+ while(false);
+
+ {
+ CAutoLock cAutoLock(&m_queue);
+ ASSERT(!m_queue.IsEmpty());
+ if(!m_queue.IsEmpty())
+ {
+ mp3frame f = m_queue.RemoveHead();
+ DWORD len = min(pSample->GetSize(), f.len);
+ memcpy(pData, f.pData, len);
+ pSample->SetActualDataLength(len);
+ pSample->SetTime(&f.rtStart, &f.rtStop);
+ m_title = f.title;
+ }
+ }
+
+ pSample->SetSyncPoint(TRUE);
+
+ return S_OK;
}
HRESULT CShoutcastStream::GetMediaType(int iPosition, CMediaType* pmt)
@@ -408,290 +408,286 @@ HRESULT CShoutcastStream::GetMediaType(int iPosition, CMediaType* pmt)
pmt->SetSubtype(&MEDIASUBTYPE_MP3);
pmt->SetFormatType(&FORMAT_WaveFormatEx);
- WAVEFORMATEX* wfe = (WAVEFORMATEX*)pmt->AllocFormatBuffer(sizeof(WAVEFORMATEX));
- memset(wfe, 0, sizeof(WAVEFORMATEX));
- wfe->wFormatTag = (WORD)MEDIASUBTYPE_MP3.Data1;
- wfe->nChannels = (WORD)m_socket.m_channels;
- wfe->nSamplesPerSec = m_socket.m_freq;
- wfe->nAvgBytesPerSec = m_socket.m_bitrate / 8;
- wfe->nBlockAlign = 1;
- wfe->wBitsPerSample = 0;
+ WAVEFORMATEX* wfe = (WAVEFORMATEX*)pmt->AllocFormatBuffer(sizeof(WAVEFORMATEX));
+ memset(wfe, 0, sizeof(WAVEFORMATEX));
+ wfe->wFormatTag = (WORD)MEDIASUBTYPE_MP3.Data1;
+ wfe->nChannels = (WORD)m_socket.m_channels;
+ wfe->nSamplesPerSec = m_socket.m_freq;
+ wfe->nAvgBytesPerSec = m_socket.m_bitrate/8;
+ wfe->nBlockAlign = 1;
+ wfe->wBitsPerSample = 0;
return NOERROR;
}
HRESULT CShoutcastStream::CheckMediaType(const CMediaType* pmt)
{
- if(pmt->majortype == MEDIATYPE_Audio
- && pmt->subtype == MEDIASUBTYPE_MP3
- && pmt->formattype == FORMAT_WaveFormatEx) return S_OK;
+ if(pmt->majortype == MEDIATYPE_Audio
+ && pmt->subtype == MEDIASUBTYPE_MP3
+ && pmt->formattype == FORMAT_WaveFormatEx) return S_OK;
- return E_INVALIDARG;
+ return E_INVALIDARG;
}
static UINT SocketThreadProc(LPVOID pParam)
{
- return (static_cast<CShoutcastStream*>(pParam))->SocketThreadProc();
+ return (static_cast<CShoutcastStream*>(pParam))->SocketThreadProc();
}
UINT CShoutcastStream::SocketThreadProc()
{
- fExitThread = false;
+ fExitThread = false;
- SetThreadPriority(GetCurrentThread(), THREAD_PRIORITY_TIME_CRITICAL);
+ SetThreadPriority(GetCurrentThread(), THREAD_PRIORITY_TIME_CRITICAL);
- AfxSocketInit();
+ AfxSocketInit();
- CAutoVectorPtr<BYTE> pData;
- if(!m_socket.Create() || !m_socket.Connect(m_url)
- || !pData.Allocate(max(m_socket.m_metaint, MAXFRAMESIZE)))
- {
- m_socket.Close();
- return 1;
- }
+ CAutoVectorPtr<BYTE> pData;
+ if(!m_socket.Create() || !m_socket.Connect(m_url)
+ || !pData.Allocate(max(m_socket.m_metaint, MAXFRAMESIZE)))
+ {
+ m_socket.Close();
+ return 1;
+ }
- REFERENCE_TIME m_rtSampleTime = 0;
+ REFERENCE_TIME m_rtSampleTime = 0;
+
+ while(!fExitThread)
+ {
+ int len = MAXFRAMESIZE;
+ len = m_socket.Receive(pData, len);
+ if(len <= 0) break;
- while(!fExitThread)
- {
- int len = MAXFRAMESIZE;
- len = m_socket.Receive(pData, len);
- if(len <= 0) break;
+ mp3frame f(len);
+ memcpy(f.pData, pData, len);
+ f.rtStop = (f.rtStart = m_rtSampleTime) + (10000000i64 * len * 8/m_socket.m_bitrate);
+ m_rtSampleTime = f.rtStop;
+ f.title = m_socket.m_title;
+ if(f.title.IsEmpty()) f.title = m_socket.m_url;
- mp3frame f(len);
- memcpy(f.pData, pData, len);
- f.rtStop = (f.rtStart = m_rtSampleTime) + (10000000i64 * len * 8 / m_socket.m_bitrate);
- m_rtSampleTime = f.rtStop;
- f.title = m_socket.m_title;
- if(f.title.IsEmpty()) f.title = m_socket.m_url;
+ CAutoLock cAutoLock(&m_queue);
+ m_queue.AddTail(f);
+ }
- CAutoLock cAutoLock(&m_queue);
- m_queue.AddTail(f);
- }
+ m_socket.Close();
- m_socket.Close();
-
- return 0;
+ return 0;
}
HRESULT CShoutcastStream::OnThreadCreate()
{
- EmptyBuffer();
+ EmptyBuffer();
- fExitThread = true;
- m_hSocketThread = AfxBeginThread(::SocketThreadProc, this)->m_hThread;
- while(fExitThread) Sleep(10);
+ fExitThread = true;
+ m_hSocketThread = AfxBeginThread(::SocketThreadProc, this)->m_hThread;
+ while(fExitThread) Sleep(10);
- return NOERROR;
+ return NOERROR;
}
HRESULT CShoutcastStream::OnThreadDestroy()
{
- EmptyBuffer();
+ EmptyBuffer();
+
+ fExitThread = true;
+ m_socket.CancelBlockingCall();
+ WaitForSingleObject(m_hSocketThread, -1);
- fExitThread = true;
- m_socket.CancelBlockingCall();
- WaitForSingleObject(m_hSocketThread, -1);
-
- return NOERROR;
+ return NOERROR;
}
HRESULT CShoutcastStream::Inactive()
{
- fExitThread = true;
- return __super::Inactive();
+ fExitThread = true;
+ return __super::Inactive();
}
//
int CShoutcastStream::CShoutcastSocket::Receive(void* lpBuf, int nBufLen, int nFlags)
{
- if(nFlags & MSG_PEEK)
- return __super::Receive(lpBuf, nBufLen, nFlags);
-
- if(m_metaint > 0 && m_nBytesRead + nBufLen > m_metaint)
- nBufLen = m_metaint - m_nBytesRead;
-
- int len = __super::Receive(lpBuf, nBufLen, nFlags);
- if(len <= 0) return len;
-
- if((m_nBytesRead += len) == m_metaint)
- {
- m_nBytesRead = 0;
-
- static BYTE buff[255*16], b = 0;
- memset(buff, 0, sizeof(buff));
- if(1 == __super::Receive(&b, 1) && b && b * 16 == __super::Receive(buff, b * 16))
- {
- CStringA str = (LPCSTR)buff;
-
- TRACE(_T("Metainfo: %s\n"), CString(str));
-
- CStringA title("StreamTitle='"), url("StreamUrl='");
-
- int i = str.Find(title);
- if(i >= 0)
- {
- i += title.GetLength();
- int j = str.Find('\'', i);
- if(j > i) m_title = str.Mid(i, j - i);
- }
- else
- {
- TRACE(_T("!!!!!!!!!Missing StreamTitle!!!!!!!!!\n"));
- }
-
- i = str.Find(url);
- if(i >= 0)
- {
- i += url.GetLength();
- int j = str.Find('\'', i);
- if(j > i) m_url = str.Mid(i, j - i);
- }
- }
- }
- else if(m_metaint > 0)
- {
- char* p = (char*)lpBuf;
- char* p0 = p;
- char* pend = p + len - 13;
- for(; p < pend; p++)
- {
- if(strncmp(p, "StreamTitle='", 13))
- continue;
-
- TRACE(_T("!!!!!!!!!StreamTitle found inside mp3 data!!!!!!!!! offset=%d\n"), p - p0);
- TRACE(_T("resyncing...\n"));
- while(p-- > p0)
- {
- if((BYTE)*p >= 0x20)
- continue;
-
- TRACE(_T("found possible length byte: %d, skipping %d bytes\n"), *p, 1 + *p * 16);
- p += 1 + *p * 16;
- len = (p0 + len) - p;
- TRACE(_T("returning the remaining bytes in the packet: %d\n"), len);
- if(len <= 0)
- {
- TRACE(_T("nothing to return, reading a bit more in\n"));
- if(len < 0) __super::Receive(lpBuf, -len, nFlags);
-
- int len = __super::Receive(lpBuf, nBufLen, nFlags);
- if(len <= 0) return len;
- }
-
- m_nBytesRead = len;
- memcpy(lpBuf, p, len);
-
- break;
- }
-
- break;
- }
- }
-
- return len;
+ if(nFlags&MSG_PEEK)
+ return __super::Receive(lpBuf, nBufLen, nFlags);
+
+ if(m_metaint > 0 && m_nBytesRead + nBufLen > m_metaint)
+ nBufLen = m_metaint - m_nBytesRead;
+
+ int len = __super::Receive(lpBuf, nBufLen, nFlags);
+ if(len <= 0) return len;
+
+ if((m_nBytesRead += len) == m_metaint)
+ {
+ m_nBytesRead = 0;
+
+ static BYTE buff[255*16], b = 0;
+ memset(buff, 0, sizeof(buff));
+ if(1 == __super::Receive(&b, 1) && b && b*16 == __super::Receive(buff, b*16))
+ {
+ CStringA str = (LPCSTR)buff;
+
+ TRACE(_T("Metainfo: %s\n"), CString(str));
+
+ CStringA title("StreamTitle='"), url("StreamUrl='");
+
+ int i = str.Find(title);
+ if(i >= 0)
+ {
+ i += title.GetLength();
+ int j = str.Find('\'', i);
+ if(j > i) m_title = str.Mid(i, j - i);
+ }
+ else
+ {
+ TRACE(_T("!!!!!!!!!Missing StreamTitle!!!!!!!!!\n"));
+ }
+
+ i = str.Find(url);
+ if(i >= 0)
+ {
+ i += url.GetLength();
+ int j = str.Find('\'', i);
+ if(j > i) m_url = str.Mid(i, j - i);
+ }
+ }
+ }
+ else if(m_metaint > 0)
+ {
+ char* p = (char*)lpBuf;
+ char* p0 = p;
+ char* pend = p + len - 13;
+ for(; p < pend; p++)
+ {
+ if(strncmp(p, "StreamTitle='", 13))
+ continue;
+
+TRACE(_T("!!!!!!!!!StreamTitle found inside mp3 data!!!!!!!!! offset=%d\n"), p - p0);
+TRACE(_T("resyncing...\n"));
+ while(p-- > p0)
+ {
+ if((BYTE)*p >= 0x20)
+ continue;
+
+TRACE(_T("found possible length byte: %d, skipping %d bytes\n"), *p, 1 + *p*16);
+ p += 1 + *p*16;
+ len = (p0 + len) - p;
+TRACE(_T("returning the remaining bytes in the packet: %d\n"), len);
+ if(len <= 0)
+ {
+TRACE(_T("nothing to return, reading a bit more in\n"));
+ if(len < 0) __super::Receive(lpBuf, -len, nFlags);
+
+ int len = __super::Receive(lpBuf, nBufLen, nFlags);
+ if(len <= 0) return len;
+ }
+
+ m_nBytesRead = len;
+ memcpy(lpBuf, p, len);
+
+ break;
+ }
+
+ break;
+ }
+ }
+
+ return len;
}
bool CShoutcastStream::CShoutcastSocket::Connect(CUrl& url)
{
- if(!__super::Connect(url.GetHostName(), url.GetPortNumber()))
- return(false);
-
- CStringA str;
- str.Format(
- "GET %s HTTP/1.0\r\n"
- "Icy-MetaData:1\r\n"
- "User-Agent: shoutcastsource\r\n"
- "Host: %s\r\n"
- "Accept: */*\r\n"
- "Connection: Keep-Alive\r\n"
- "\r\n", CStringA(url.GetUrlPath()), CStringA(url.GetHostName()));
-
- bool fOK = false;
- bool fTryAgain = false;
- int metaint = 0;
-
- do
- {
- int len = Send((BYTE*)(LPCSTR)str, str.GetLength());
-
- m_nBytesRead = 0;
- m_metaint = metaint = 0;
- m_bitrate = 0;
-
- str.Empty();
- BYTE cur = 0, prev = 0;
- while(Receive(&cur, 1) == 1 && cur && !(cur == '\n' && prev == '\n'))
- {
- if(cur == '\r')
- continue;
-
- if(cur == '\n')
- {
- str.MakeLower();
- if(str.Find("icy 200 ok") >= 0) fOK = true;
- else if(1 == sscanf(str, "icy-br:%d", &m_bitrate)) m_bitrate *= 1000;
- else if(1 == sscanf(str, "icy-metaint:%d", &metaint)) metaint = metaint;
- str.Empty();
- }
- else
- {
- str += cur;
- }
-
- prev = cur;
- cur = 0;
- }
-
- if(!fOK && GetLastError() == WSAECONNRESET && !fTryAgain)
- {
- str.Format(
- "GET %s HTTP/1.0\r\n"
- "Icy-MetaData:1\r\n"
- "Host: %s\r\n"
- "Accept: */*\r\n"
- "Connection: Keep-Alive\r\n"
- "\r\n", CStringA(url.GetUrlPath()), CStringA(url.GetHostName()));
-
- fTryAgain = true;
- }
- else
- {
- fTryAgain = false;
- }
- }
- while(fTryAgain);
-
- if(!fOK || m_bitrate == 0)
- {
- Close();
- return(false);
- }
-
- m_metaint = metaint;
- m_nBytesRead = 0;
-
- return(FindSync());
+ if(!__super::Connect(url.GetHostName(), url.GetPortNumber()))
+ return(false);
+
+ CStringA str;
+ str.Format(
+ "GET %s HTTP/1.0\r\n"
+ "Icy-MetaData:1\r\n"
+ "User-Agent: shoutcastsource\r\n"
+ "Host: %s\r\n"
+ "Accept: */*\r\n"
+ "Connection: Keep-Alive\r\n"
+ "\r\n", CStringA(url.GetUrlPath()), CStringA(url.GetHostName()));
+
+ bool fOK = false;
+ bool fTryAgain = false;
+ int metaint = 0;
+
+ do
+ {
+ int len = Send((BYTE*)(LPCSTR)str, str.GetLength());
+
+ m_nBytesRead = 0;
+ m_metaint = metaint = 0;
+ m_bitrate = 0;
+
+ str.Empty();
+ BYTE cur = 0, prev = 0;
+ while(Receive(&cur, 1) == 1 && cur && !(cur == '\n' && prev == '\n'))
+ {
+ if(cur == '\r')
+ continue;
+
+ if(cur == '\n')
+ {
+ str.MakeLower();
+ if(str.Find("icy 200 ok") >= 0) fOK = true;
+ else if(1 == sscanf(str, "icy-br:%d", &m_bitrate)) m_bitrate *= 1000;
+ else if(1 == sscanf(str, "icy-metaint:%d", &metaint)) metaint = metaint;
+ str.Empty();
+ }
+ else
+ {
+ str += cur;
+ }
+
+ prev = cur;
+ cur = 0;
+ }
+
+ if(!fOK && GetLastError() == WSAECONNRESET && !fTryAgain)
+ {
+ str.Format(
+ "GET %s HTTP/1.0\r\n"
+ "Icy-MetaData:1\r\n"
+ "Host: %s\r\n"
+ "Accept: */*\r\n"
+ "Connection: Keep-Alive\r\n"
+ "\r\n", CStringA(url.GetUrlPath()), CStringA(url.GetHostName()));
+
+ fTryAgain = true;
+ }
+ else
+ {
+ fTryAgain = false;
+ }
+ }
+ while(fTryAgain);
+
+ if(!fOK || m_bitrate == 0) {Close(); return(false);}
+
+ m_metaint = metaint;
+ m_nBytesRead = 0;
+
+ return(FindSync());
}
bool CShoutcastStream::CShoutcastSocket::FindSync()
{
- m_freq = -1;
- m_channels = -1;
-
- BYTE b;
- for(int i = MAXFRAMESIZE; i > 0; i--, Receive(&b, 1))
- {
- mp3hdr h;
- if(h.ExtractHeader(*this) && m_bitrate == h.bitrate)
- {
- if(h.bitrate > 1) m_bitrate = h.bitrate;
- m_freq = h.freq;
- m_channels = h.channels;
- return(true);
- }
- }
-
- return(false);
+ m_freq = -1;
+ m_channels = -1;
+
+ BYTE b;
+ for(int i = MAXFRAMESIZE; i > 0; i--, Receive(&b, 1))
+ {
+ mp3hdr h;
+ if(h.ExtractHeader(*this) && m_bitrate == h.bitrate)
+ {
+ if(h.bitrate > 1) m_bitrate = h.bitrate;
+ m_freq = h.freq;
+ m_channels = h.channels;
+ return(true);
+ }
+ }
+
+ return(false);
}
diff --git a/src/filters/source/ShoutcastSource/ShoutcastSource.h b/src/filters/source/ShoutcastSource/ShoutcastSource.h
index 080b6f198..ab45dbf4f 100644
--- a/src/filters/source/ShoutcastSource/ShoutcastSource.h
+++ b/src/filters/source/ShoutcastSource/ShoutcastSource.h
@@ -1,4 +1,4 @@
-/*
+/*
* Copyright (C) 2003-2006 Gabest
* http://www.gabest.org
*
@@ -6,15 +6,15 @@
* 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.
+ * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
* http://www.gnu.org/copyleft/gpl.html
*
*/
@@ -29,182 +29,118 @@
[uuid("68F540E9-766F-44d2-AB07-E26CC6D27A79")]
class CShoutcastSource
- : public CSource
- , public IFileSourceFilter
- , public IAMFilterMiscFlags
- , public IAMOpenProgress
- , public IAMMediaContent
+ : public CSource
+ , public IFileSourceFilter
+ , public IAMFilterMiscFlags
+ , public IAMOpenProgress
+ , public IAMMediaContent
{
- CStringW m_fn;
+ CStringW m_fn;
public:
- CShoutcastSource(LPUNKNOWN lpunk, HRESULT* phr);
- virtual ~CShoutcastSource();
+ CShoutcastSource(LPUNKNOWN lpunk, HRESULT* phr);
+ virtual ~CShoutcastSource();
- DECLARE_IUNKNOWN;
+ DECLARE_IUNKNOWN;
STDMETHODIMP NonDelegatingQueryInterface(REFIID riid, void** ppv);
- // IFileSourceFilter
- STDMETHODIMP Load(LPCOLESTR pszFileName, const AM_MEDIA_TYPE* pmt);
- STDMETHODIMP GetCurFile(LPOLESTR* ppszFileName, AM_MEDIA_TYPE* pmt);
+ // IFileSourceFilter
+ STDMETHODIMP Load(LPCOLESTR pszFileName, const AM_MEDIA_TYPE* pmt);
+ STDMETHODIMP GetCurFile(LPOLESTR* ppszFileName, AM_MEDIA_TYPE* pmt);
- // IAMFilterMiscFlags
- STDMETHODIMP_(ULONG) GetMiscFlags();
+ // IAMFilterMiscFlags
+ STDMETHODIMP_(ULONG) GetMiscFlags();
- // IAMOpenProgress
+ // IAMOpenProgress
STDMETHODIMP QueryProgress(LONGLONG* pllTotal, LONGLONG* pllCurrent);
STDMETHODIMP AbortOperation();
- // IAMMediaContent
- STDMETHODIMP GetTypeInfoCount(UINT* pctinfo)
- {
- return E_NOTIMPL;
- }
- STDMETHODIMP GetTypeInfo(UINT itinfo, LCID lcid, ITypeInfo** pptinfo)
- {
- return E_NOTIMPL;
- }
- STDMETHODIMP GetIDsOfNames(REFIID riid, OLECHAR** rgszNames, UINT cNames, LCID lcid, DISPID* rgdispid)
- {
- return E_NOTIMPL;
- }
- STDMETHODIMP Invoke(DISPID dispidMember, REFIID riid, LCID lcid, WORD wFlags, DISPPARAMS* pdispparams, VARIANT* pvarResult, EXCEPINFO* pexcepinfo, UINT* puArgErr)
- {
- return E_NOTIMPL;
- }
- STDMETHODIMP get_AuthorName(BSTR* pbstrAuthorName)
- {
- return E_NOTIMPL;
- }
- STDMETHODIMP get_Title(BSTR* pbstrTitle);
- STDMETHODIMP get_Rating(BSTR* pbstrRating)
- {
- return E_NOTIMPL;
- }
- STDMETHODIMP get_Description(BSTR* pbstrDescription)
- {
- return E_NOTIMPL;
- }
- STDMETHODIMP get_Copyright(BSTR* pbstrCopyright)
- {
- return E_NOTIMPL;
- }
- STDMETHODIMP get_BaseURL(BSTR* pbstrBaseURL)
- {
- return E_NOTIMPL;
- }
- STDMETHODIMP get_LogoURL(BSTR* pbstrLogoURL)
- {
- return E_NOTIMPL;
- }
- STDMETHODIMP get_LogoIconURL(BSTR* pbstrLogoURL)
- {
- return E_NOTIMPL;
- }
- STDMETHODIMP get_WatermarkURL(BSTR* pbstrWatermarkURL)
- {
- return E_NOTIMPL;
- }
- STDMETHODIMP get_MoreInfoURL(BSTR* pbstrMoreInfoURL)
- {
- return E_NOTIMPL;
- }
- STDMETHODIMP get_MoreInfoBannerImage(BSTR* pbstrMoreInfoBannerImage)
- {
- return E_NOTIMPL;
- }
- STDMETHODIMP get_MoreInfoBannerURL(BSTR* pbstrMoreInfoBannerURL)
- {
- return E_NOTIMPL;
- }
- STDMETHODIMP get_MoreInfoText(BSTR* pbstrMoreInfoText)
- {
- return E_NOTIMPL;
- }
+ // IAMMediaContent
+ STDMETHODIMP GetTypeInfoCount(UINT* pctinfo) {return E_NOTIMPL;}
+ STDMETHODIMP GetTypeInfo(UINT itinfo, LCID lcid, ITypeInfo** pptinfo) {return E_NOTIMPL;}
+ STDMETHODIMP GetIDsOfNames(REFIID riid, OLECHAR** rgszNames, UINT cNames, LCID lcid, DISPID* rgdispid) {return E_NOTIMPL;}
+ STDMETHODIMP Invoke(DISPID dispidMember, REFIID riid, LCID lcid, WORD wFlags, DISPPARAMS* pdispparams, VARIANT* pvarResult, EXCEPINFO* pexcepinfo, UINT* puArgErr) {return E_NOTIMPL;}
+ STDMETHODIMP get_AuthorName(BSTR* pbstrAuthorName) {return E_NOTIMPL;}
+ STDMETHODIMP get_Title(BSTR* pbstrTitle);
+ STDMETHODIMP get_Rating(BSTR* pbstrRating) {return E_NOTIMPL;}
+ STDMETHODIMP get_Description(BSTR* pbstrDescription) {return E_NOTIMPL;}
+ STDMETHODIMP get_Copyright(BSTR* pbstrCopyright) {return E_NOTIMPL;}
+ STDMETHODIMP get_BaseURL(BSTR* pbstrBaseURL) {return E_NOTIMPL;}
+ STDMETHODIMP get_LogoURL(BSTR* pbstrLogoURL) {return E_NOTIMPL;}
+ STDMETHODIMP get_LogoIconURL(BSTR* pbstrLogoURL) {return E_NOTIMPL;}
+ STDMETHODIMP get_WatermarkURL(BSTR* pbstrWatermarkURL) {return E_NOTIMPL;}
+ STDMETHODIMP get_MoreInfoURL(BSTR* pbstrMoreInfoURL) {return E_NOTIMPL;}
+ STDMETHODIMP get_MoreInfoBannerImage(BSTR* pbstrMoreInfoBannerImage) {return E_NOTIMPL;}
+ STDMETHODIMP get_MoreInfoBannerURL(BSTR* pbstrMoreInfoBannerURL) {return E_NOTIMPL;}
+ STDMETHODIMP get_MoreInfoText(BSTR* pbstrMoreInfoText) {return E_NOTIMPL;}
};
class CShoutcastStream : public CSourceStream
{
- class mp3frame
- {
- public:
- DWORD len;
- BYTE* pData;
- REFERENCE_TIME rtStart, rtStop;
- CString title;
- mp3frame(DWORD len = 0)
- {
- pData = (this->len = len) ? DNew BYTE[len] : NULL;
- rtStart = rtStop = 0;
- }
- mp3frame(const mp3frame& f)
- {
- *this = f;
- }
- ~mp3frame()
- {
- delete pData;
- }
- void operator = (const mp3frame& f)
- {
- len = f.len;
- pData = f.pData;
- rtStart = f.rtStart;
- rtStop = f.rtStop;
- title = f.title;
- ((mp3frame*)&f)->pData = NULL;
- }
- };
-
- class mp3queue : public CAtlList<mp3frame>, public CCritSec {} m_queue;
-
- class CShoutcastSocket : public CSocket
- {
- DWORD m_nBytesRead;
-
- public:
- CShoutcastSocket()
- {
- m_metaint = m_bitrate = m_freq = m_channels = 0;
- }
- int Receive(void* lpBuf, int nBufLen, int nFlags = 0);
-
- DWORD m_metaint, m_bitrate, m_freq, m_channels;
- CString m_title, m_url;
- bool Connect(CUrl& url);
- bool FindSync();
- } m_socket;
-
- HANDLE m_hSocketThread;
-
- CUrl m_url;
-
- bool m_fBuffering;
- CString m_title;
+ class mp3frame
+ {
+ public:
+ DWORD len;
+ BYTE* pData;
+ REFERENCE_TIME rtStart, rtStop;
+ CString title;
+ mp3frame(DWORD len = 0) {pData = (this->len = len) ? DNew BYTE[len] : NULL; rtStart = rtStop = 0;}
+ mp3frame(const mp3frame& f) {*this = f;}
+ ~mp3frame() {delete pData;}
+ void operator = (const mp3frame& f)
+ {
+ len = f.len;
+ pData = f.pData;
+ rtStart = f.rtStart;
+ rtStop = f.rtStop;
+ title = f.title;
+ ((mp3frame*)&f)->pData = NULL;
+ }
+ };
+
+ class mp3queue : public CAtlList<mp3frame>, public CCritSec {} m_queue;
+
+ class CShoutcastSocket : public CSocket
+ {
+ DWORD m_nBytesRead;
+
+ public:
+ CShoutcastSocket() {m_metaint = m_bitrate = m_freq = m_channels = 0;}
+ int Receive(void* lpBuf, int nBufLen, int nFlags = 0);
+
+ DWORD m_metaint, m_bitrate, m_freq, m_channels;
+ CString m_title, m_url;
+ bool Connect(CUrl& url);
+ bool FindSync();
+ } m_socket;
+
+ HANDLE m_hSocketThread;
+
+ CUrl m_url;
+
+ bool m_fBuffering;
+ CString m_title;
public:
CShoutcastStream(const WCHAR* wfn, CShoutcastSource* pParent, HRESULT* phr);
- virtual ~CShoutcastStream();
+ virtual ~CShoutcastStream();
- bool fExitThread;
- UINT SocketThreadProc();
+ bool fExitThread;
+ UINT SocketThreadProc();
- void EmptyBuffer();
- LONGLONG GetBufferFullness();
- CString GetTitle();
+ void EmptyBuffer();
+ LONGLONG GetBufferFullness();
+ CString GetTitle();
HRESULT DecideBufferSize(IMemAllocator* pIMemAlloc, ALLOCATOR_PROPERTIES* pProperties);
HRESULT FillBuffer(IMediaSample* pSample);
HRESULT CheckMediaType(const CMediaType* pMediaType);
HRESULT GetMediaType(int iPosition, CMediaType* pmt);
- STDMETHODIMP Notify(IBaseFilter* pSender, Quality q)
- {
- return E_NOTIMPL;
- }
+ STDMETHODIMP Notify(IBaseFilter* pSender, Quality q) {return E_NOTIMPL;}
HRESULT OnThreadCreate();
HRESULT OnThreadDestroy();
- HRESULT Inactive();
+ HRESULT Inactive();
HRESULT Pause();
};
diff --git a/src/filters/source/ShoutcastSource/resource.h b/src/filters/source/ShoutcastSource/resource.h
index 8a12dbf0d..ae3ca9687 100644
--- a/src/filters/source/ShoutcastSource/resource.h
+++ b/src/filters/source/ShoutcastSource/resource.h
@@ -3,7 +3,7 @@
// Used by shoutcastsource.rc
// Next default values for new objects
-//
+//
#ifdef APSTUDIO_INVOKED
#ifndef APSTUDIO_READONLY_SYMBOLS
#define _APS_NEXT_RESOURCE_VALUE 101
diff --git a/src/filters/source/ShoutcastSource/stdafx.cpp b/src/filters/source/ShoutcastSource/stdafx.cpp
index 0385cc615..8905f2db5 100644
--- a/src/filters/source/ShoutcastSource/stdafx.cpp
+++ b/src/filters/source/ShoutcastSource/stdafx.cpp
@@ -1,4 +1,4 @@
-/*
+/*
* Copyright (C) 2003-2006 Gabest
* http://www.gabest.org
*
@@ -6,15 +6,15 @@
* 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.
+ * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
* http://www.gnu.org/copyleft/gpl.html
*
*/
diff --git a/src/filters/source/ShoutcastSource/stdafx.h b/src/filters/source/ShoutcastSource/stdafx.h
index a9f666228..c35359c38 100644
--- a/src/filters/source/ShoutcastSource/stdafx.h
+++ b/src/filters/source/ShoutcastSource/stdafx.h
@@ -1,4 +1,4 @@
-/*
+/*
* Copyright (C) 2003-2006 Gabest
* http://www.gabest.org
*
@@ -6,15 +6,15 @@
* 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.
+ * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
* http://www.gnu.org/copyleft/gpl.html
*
*/
diff --git a/src/filters/source/SubtitleSource/SubtitleSource.cpp b/src/filters/source/SubtitleSource/SubtitleSource.cpp
index db9b9aa4d..0bddf17a8 100644
--- a/src/filters/source/SubtitleSource/SubtitleSource.cpp
+++ b/src/filters/source/SubtitleSource/SubtitleSource.cpp
@@ -1,4 +1,4 @@
-/*
+/*
* Copyright (C) 2003-2006 Gabest
* http://www.gabest.org
*
@@ -6,15 +6,15 @@
* 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.
+ * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
* http://www.gnu.org/copyleft/gpl.html
*
*/
@@ -34,87 +34,87 @@ static int _ATPF = 400000;
const AMOVIESETUP_MEDIATYPE sudPinTypesOut[] =
{
- {&MEDIATYPE_Subtitle, &MEDIASUBTYPE_NULL},
- {&MEDIATYPE_Text, &MEDIASUBTYPE_NULL},
- {&MEDIATYPE_Video, &MEDIASUBTYPE_RGB32},
+ {&MEDIATYPE_Subtitle, &MEDIASUBTYPE_NULL},
+ {&MEDIATYPE_Text, &MEDIASUBTYPE_NULL},
+ {&MEDIATYPE_Video, &MEDIASUBTYPE_RGB32},
};
const AMOVIESETUP_PIN sudOpPin[] =
{
- {L"Output", FALSE, TRUE, FALSE, FALSE, &CLSID_NULL, NULL, countof(sudPinTypesOut), sudPinTypesOut},
+ {L"Output", FALSE, TRUE, FALSE, FALSE, &CLSID_NULL, NULL, countof(sudPinTypesOut), sudPinTypesOut},
};
const AMOVIESETUP_FILTER sudFilter[] =
{
- {&__uuidof(CSubtitleSourceASCII), L"MPC - SubtitleSource (S_TEXT/ASCII)", MERIT_NORMAL, countof(sudOpPin), sudOpPin, CLSID_LegacyAmFilterCategory},
- {&__uuidof(CSubtitleSourceUTF8), L"MPC - SubtitleSource (S_TEXT/UTF8)", MERIT_NORMAL, countof(sudOpPin), sudOpPin, CLSID_LegacyAmFilterCategory},
- {&__uuidof(CSubtitleSourceSSA), L"MPC - SubtitleSource (S_TEXT/SSA)", MERIT_NORMAL, countof(sudOpPin), sudOpPin, CLSID_LegacyAmFilterCategory},
- {&__uuidof(CSubtitleSourceASS), L"MPC - SubtitleSource (S_TEXT/ASS)", MERIT_NORMAL, countof(sudOpPin), sudOpPin, CLSID_LegacyAmFilterCategory},
- {&__uuidof(CSubtitleSourceUSF), L"MPC - SubtitleSource (S_TEXT/USF)", MERIT_NORMAL, countof(sudOpPin), sudOpPin, CLSID_LegacyAmFilterCategory},
- {&__uuidof(CSubtitleSourcePreview), L"MPC - SubtitleSource (Preview)", MERIT_NORMAL, countof(sudOpPin), sudOpPin, CLSID_LegacyAmFilterCategory},
- {&__uuidof(CSubtitleSourceARGB), L"MPC - SubtitleSource (ARGB)", MERIT_NORMAL, countof(sudOpPin), sudOpPin, CLSID_LegacyAmFilterCategory},
+ {&__uuidof(CSubtitleSourceASCII), L"MPC - SubtitleSource (S_TEXT/ASCII)", MERIT_NORMAL, countof(sudOpPin), sudOpPin, CLSID_LegacyAmFilterCategory},
+ {&__uuidof(CSubtitleSourceUTF8), L"MPC - SubtitleSource (S_TEXT/UTF8)", MERIT_NORMAL, countof(sudOpPin), sudOpPin, CLSID_LegacyAmFilterCategory},
+ {&__uuidof(CSubtitleSourceSSA), L"MPC - SubtitleSource (S_TEXT/SSA)", MERIT_NORMAL, countof(sudOpPin), sudOpPin, CLSID_LegacyAmFilterCategory},
+ {&__uuidof(CSubtitleSourceASS), L"MPC - SubtitleSource (S_TEXT/ASS)", MERIT_NORMAL, countof(sudOpPin), sudOpPin, CLSID_LegacyAmFilterCategory},
+ {&__uuidof(CSubtitleSourceUSF), L"MPC - SubtitleSource (S_TEXT/USF)", MERIT_NORMAL, countof(sudOpPin), sudOpPin, CLSID_LegacyAmFilterCategory},
+ {&__uuidof(CSubtitleSourcePreview), L"MPC - SubtitleSource (Preview)", MERIT_NORMAL, countof(sudOpPin), sudOpPin, CLSID_LegacyAmFilterCategory},
+ {&__uuidof(CSubtitleSourceARGB), L"MPC - SubtitleSource (ARGB)", MERIT_NORMAL, countof(sudOpPin), sudOpPin, CLSID_LegacyAmFilterCategory},
};
CFactoryTemplate g_Templates[] =
{
- {sudFilter[0].strName, sudFilter[0].clsID, CreateInstance<CSubtitleSourceASCII>, NULL, &sudFilter[0]},
- {sudFilter[1].strName, sudFilter[1].clsID, CreateInstance<CSubtitleSourceUTF8>, NULL, &sudFilter[1]},
- {sudFilter[2].strName, sudFilter[2].clsID, CreateInstance<CSubtitleSourceSSA>, NULL, &sudFilter[2]},
- {sudFilter[3].strName, sudFilter[3].clsID, CreateInstance<CSubtitleSourceASS>, NULL, &sudFilter[3]},
+ {sudFilter[0].strName, sudFilter[0].clsID, CreateInstance<CSubtitleSourceASCII>, NULL, &sudFilter[0]},
+ {sudFilter[1].strName, sudFilter[1].clsID, CreateInstance<CSubtitleSourceUTF8>, NULL, &sudFilter[1]},
+ {sudFilter[2].strName, sudFilter[2].clsID, CreateInstance<CSubtitleSourceSSA>, NULL, &sudFilter[2]},
+ {sudFilter[3].strName, sudFilter[3].clsID, CreateInstance<CSubtitleSourceASS>, NULL, &sudFilter[3]},
// {sudFilter[4].strName, sudFilter[4].clsID, CreateInstance<CSubtitleSourceUSF>, NULL, &sudFilter[4]},
- {sudFilter[5].strName, sudFilter[5].clsID, CreateInstance<CSubtitleSourcePreview>, NULL, &sudFilter[5]},
- {sudFilter[6].strName, sudFilter[6].clsID, CreateInstance<CSubtitleSourceARGB>, NULL, &sudFilter[6]},
+ {sudFilter[5].strName, sudFilter[5].clsID, CreateInstance<CSubtitleSourcePreview>, NULL, &sudFilter[5]},
+ {sudFilter[6].strName, sudFilter[6].clsID, CreateInstance<CSubtitleSourceARGB>, NULL, &sudFilter[6]},
};
int g_cTemplates = countof(g_Templates);
STDAPI DllRegisterServer()
{
- /*
- CString clsid = CStringFromGUID(__uuidof(CSubtitleSourcePreview));
+/*
+ CString clsid = CStringFromGUID(__uuidof(CSubtitleSourcePreview));
- SetRegKeyValue(
- _T("Media Type\\Extensions"), _T(".sub"),
- _T("Source Filter"), clsid);
+ SetRegKeyValue(
+ _T("Media Type\\Extensions"), _T(".sub"),
+ _T("Source Filter"), clsid);
- SetRegKeyValue(
- _T("Media Type\\Extensions"), _T(".srt"),
- _T("Source Filter"), clsid);
+ SetRegKeyValue(
+ _T("Media Type\\Extensions"), _T(".srt"),
+ _T("Source Filter"), clsid);
- SetRegKeyValue(
- _T("Media Type\\Extensions"), _T(".smi"),
- _T("Source Filter"), clsid);
+ SetRegKeyValue(
+ _T("Media Type\\Extensions"), _T(".smi"),
+ _T("Source Filter"), clsid);
- SetRegKeyValue(
- _T("Media Type\\Extensions"), _T(".ssa"),
- _T("Source Filter"), clsid);
+ SetRegKeyValue(
+ _T("Media Type\\Extensions"), _T(".ssa"),
+ _T("Source Filter"), clsid);
- SetRegKeyValue(
- _T("Media Type\\Extensions"), _T(".ass"),
- _T("Source Filter"), clsid);
+ SetRegKeyValue(
+ _T("Media Type\\Extensions"), _T(".ass"),
+ _T("Source Filter"), clsid);
- SetRegKeyValue(
- _T("Media Type\\Extensions"), _T(".xss"),
- _T("Source Filter"), clsid);
+ SetRegKeyValue(
+ _T("Media Type\\Extensions"), _T(".xss"),
+ _T("Source Filter"), clsid);
- SetRegKeyValue(
- _T("Media Type\\Extensions"), _T(".usf"),
- _T("Source Filter"), clsid);
- */
- return AMovieDllRegisterServer2(TRUE);
+ SetRegKeyValue(
+ _T("Media Type\\Extensions"), _T(".usf"),
+ _T("Source Filter"), clsid);
+*/
+ return AMovieDllRegisterServer2(TRUE);
}
STDAPI DllUnregisterServer()
{
- DeleteRegKey(_T("Media Type\\Extensions"), _T(".sub"));
- DeleteRegKey(_T("Media Type\\Extensions"), _T(".srt"));
- DeleteRegKey(_T("Media Type\\Extensions"), _T(".smi"));
- DeleteRegKey(_T("Media Type\\Extensions"), _T(".ssa"));
- DeleteRegKey(_T("Media Type\\Extensions"), _T(".ass"));
- DeleteRegKey(_T("Media Type\\Extensions"), _T(".xss"));
- DeleteRegKey(_T("Media Type\\Extensions"), _T(".usf"));
- /**/
- return AMovieDllRegisterServer2(FALSE);
+ DeleteRegKey(_T("Media Type\\Extensions"), _T(".sub"));
+ DeleteRegKey(_T("Media Type\\Extensions"), _T(".srt"));
+ DeleteRegKey(_T("Media Type\\Extensions"), _T(".smi"));
+ DeleteRegKey(_T("Media Type\\Extensions"), _T(".ssa"));
+ DeleteRegKey(_T("Media Type\\Extensions"), _T(".ass"));
+ DeleteRegKey(_T("Media Type\\Extensions"), _T(".xss"));
+ DeleteRegKey(_T("Media Type\\Extensions"), _T(".usf"));
+/**/
+ return AMovieDllRegisterServer2(FALSE);
}
#include "../../FilterApp.h"
@@ -122,20 +122,20 @@ STDAPI DllUnregisterServer()
class CSubtitleSourceApp : public CFilterApp
{
public:
- BOOL InitInstance()
- {
- if(!__super::InitInstance()) return FALSE;
-
- _WIDTH = GetProfileInt(_T("SubtitleSource"), _T("w"), 640);
- _HEIGHT = GetProfileInt(_T("SubtitleSource"), _T("h"), 480);
- _ATPF = GetProfileInt(_T("SubtitleSource"), _T("atpf"), 400000);
- if(_ATPF <= 0) _ATPF = 400000;
- WriteProfileInt(_T("SubtitleSource"), _T("w"), _WIDTH);
- WriteProfileInt(_T("SubtitleSource"), _T("h"), _HEIGHT);
- WriteProfileInt(_T("SubtitleSource"), _T("atpf"), _ATPF);
-
- return TRUE;
- }
+ BOOL InitInstance()
+ {
+ if(!__super::InitInstance()) return FALSE;
+
+ _WIDTH = GetProfileInt(_T("SubtitleSource"), _T("w"), 640);
+ _HEIGHT = GetProfileInt(_T("SubtitleSource"), _T("h"), 480);
+ _ATPF = GetProfileInt(_T("SubtitleSource"), _T("atpf"), 400000);
+ if(_ATPF <= 0) _ATPF = 400000;
+ WriteProfileInt(_T("SubtitleSource"), _T("w"), _WIDTH);
+ WriteProfileInt(_T("SubtitleSource"), _T("h"), _HEIGHT);
+ WriteProfileInt(_T("SubtitleSource"), _T("atpf"), _ATPF);
+
+ return TRUE;
+ }
};
CSubtitleSourceApp theApp;
@@ -147,7 +147,7 @@ CSubtitleSourceApp theApp;
//
CSubtitleSource::CSubtitleSource(LPUNKNOWN lpunk, HRESULT* phr, const CLSID& clsid)
- : CSource(NAME("CSubtitleSource"), lpunk, clsid)
+ : CSource(NAME("CSubtitleSource"), lpunk, clsid)
{
}
@@ -159,134 +159,134 @@ STDMETHODIMP CSubtitleSource::NonDelegatingQueryInterface(REFIID riid, void** pp
{
CheckPointer(ppv, E_POINTER);
- return
- QI(IFileSourceFilter)
- QI(IAMFilterMiscFlags)
- __super::NonDelegatingQueryInterface(riid, ppv);
+ return
+ QI(IFileSourceFilter)
+ QI(IAMFilterMiscFlags)
+ __super::NonDelegatingQueryInterface(riid, ppv);
}
// IFileSourceFilter
-STDMETHODIMP CSubtitleSource::Load(LPCOLESTR pszFileName, const AM_MEDIA_TYPE* pmt)
+STDMETHODIMP CSubtitleSource::Load(LPCOLESTR pszFileName, const AM_MEDIA_TYPE* pmt)
{
- if(GetPinCount() > 0)
- return VFW_E_ALREADY_CONNECTED;
+ if(GetPinCount() > 0)
+ return VFW_E_ALREADY_CONNECTED;
- HRESULT hr = S_OK;
- if(!(DNew CSubtitleStream(pszFileName, this, &hr)))
- return E_OUTOFMEMORY;
+ HRESULT hr = S_OK;
+ if(!(DNew CSubtitleStream(pszFileName, this, &hr)))
+ return E_OUTOFMEMORY;
- if(FAILED(hr))
- return hr;
+ if(FAILED(hr))
+ return hr;
- m_fn = pszFileName;
+ m_fn = pszFileName;
- return S_OK;
+ return S_OK;
}
STDMETHODIMP CSubtitleSource::GetCurFile(LPOLESTR* ppszFileName, AM_MEDIA_TYPE* pmt)
{
- if(!ppszFileName) return E_POINTER;
+ if(!ppszFileName) return E_POINTER;
+
+ if(!(*ppszFileName = (LPOLESTR)CoTaskMemAlloc((m_fn.GetLength()+1)*sizeof(WCHAR))))
+ return E_OUTOFMEMORY;
- if(!(*ppszFileName = (LPOLESTR)CoTaskMemAlloc((m_fn.GetLength() + 1) * sizeof(WCHAR))))
- return E_OUTOFMEMORY;
+ wcscpy(*ppszFileName, m_fn);
- wcscpy(*ppszFileName, m_fn);
-
- return S_OK;
+ return S_OK;
}
// IAMFilterMiscFlags
ULONG CSubtitleSource::GetMiscFlags()
{
- return AM_FILTER_MISC_FLAGS_IS_SOURCE;
+ return AM_FILTER_MISC_FLAGS_IS_SOURCE;
}
//
// CSubtitleStream
//
-CSubtitleStream::CSubtitleStream(const WCHAR* wfn, CSubtitleSource* pParent, HRESULT* phr)
- : CSourceStream(NAME("SubtitleStream"), phr, pParent, L"Output")
- , CSourceSeeking(NAME("SubtitleStream"), (IPin*)this, phr, &m_cSharedState)
- , m_bDiscontinuity(FALSE), m_bFlushing(FALSE)
- , m_nPosition(0)
- , m_rts(NULL)
+CSubtitleStream::CSubtitleStream(const WCHAR* wfn, CSubtitleSource* pParent, HRESULT* phr)
+ : CSourceStream(NAME("SubtitleStream"), phr, pParent, L"Output")
+ , CSourceSeeking(NAME("SubtitleStream"), (IPin*)this, phr, &m_cSharedState)
+ , m_bDiscontinuity(FALSE), m_bFlushing(FALSE)
+ , m_nPosition(0)
+ , m_rts(NULL)
{
- CAutoLock cAutoLock(&m_cSharedState);
+ CAutoLock cAutoLock(&m_cSharedState);
- CString fn(wfn);
+ CString fn(wfn);
- if(!m_rts.Open(fn, DEFAULT_CHARSET))
- {
- if(phr) *phr = E_FAIL;
- return;
- }
+ if(!m_rts.Open(fn, DEFAULT_CHARSET))
+ {
+ if(phr) *phr = E_FAIL;
+ return;
+ }
- m_rts.CreateDefaultStyle(DEFAULT_CHARSET);
- m_rts.ConvertToTimeBased(25);
- m_rts.Sort();
+ m_rts.CreateDefaultStyle(DEFAULT_CHARSET);
+ m_rts.ConvertToTimeBased(25);
+ m_rts.Sort();
- m_rtDuration = 0;
- for(int i = 0, cnt = m_rts.GetCount(); i < cnt; i++)
- m_rtDuration = max(m_rtDuration, 10000i64 * m_rts[i].end);
+ m_rtDuration = 0;
+ for(int i = 0, cnt = m_rts.GetCount(); i < cnt; i++)
+ m_rtDuration = max(m_rtDuration, 10000i64*m_rts[i].end);
- m_rtStop = m_rtDuration;
+ m_rtStop = m_rtDuration;
- if(phr) *phr = m_rtDuration > 0 ? S_OK : E_FAIL;
+ if(phr) *phr = m_rtDuration > 0 ? S_OK : E_FAIL;
}
CSubtitleStream::~CSubtitleStream()
{
- CAutoLock cAutoLock(&m_cSharedState);
+ CAutoLock cAutoLock(&m_cSharedState);
}
STDMETHODIMP CSubtitleStream::NonDelegatingQueryInterface(REFIID riid, void** ppv)
{
CheckPointer(ppv, E_POINTER);
- return (riid == IID_IMediaSeeking) ? CSourceSeeking::NonDelegatingQueryInterface(riid, ppv) //GetInterface((IMediaSeeking*)this, ppv)
- : CSourceStream::NonDelegatingQueryInterface(riid, ppv);
+ return (riid == IID_IMediaSeeking) ? CSourceSeeking::NonDelegatingQueryInterface(riid, ppv) //GetInterface((IMediaSeeking*)this, ppv)
+ : CSourceStream::NonDelegatingQueryInterface(riid, ppv);
}
void CSubtitleStream::UpdateFromSeek()
{
- 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();
- // make sure we have stopped pushing
- Stop();
- // complete the flush
- DeliverEndFlush();
+ 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();
+ // make sure we have stopped pushing
+ Stop();
+ // complete the flush
+ DeliverEndFlush();
m_bFlushing = FALSE;
- // restart
- Run();
- }
+ // restart
+ Run();
+ }
}
HRESULT CSubtitleStream::SetRate(double dRate)
{
- if(dRate <= 0)
- return E_INVALIDARG;
+ if(dRate <= 0)
+ return E_INVALIDARG;
- {
- CAutoLock lock(CSourceSeeking::m_pLock);
- m_dRateSeeking = dRate;
- }
+ {
+ CAutoLock lock(CSourceSeeking::m_pLock);
+ m_dRateSeeking = dRate;
+ }
- UpdateFromSeek();
+ UpdateFromSeek();
- return S_OK;
+ return S_OK;
}
HRESULT CSubtitleStream::OnThreadStartPlay()
@@ -300,26 +300,25 @@ HRESULT CSubtitleStream::ChangeStart()
{
CAutoLock lock(CSourceSeeking::m_pLock);
- OnThreadCreate();
- /*
- if(m_mt.majortype == MEDIATYPE_Video && m_mt.subtype == MEDIASUBTYPE_ARGB32)
- {
- m_nPosition = (int)(m_rtStart/10000)*1/1000;
- }
- else if(m_mt.majortype == MEDIATYPE_Video && m_mt.subtype == MEDIASUBTYPE_RGB32)
- {
- int m_nSegments = 0;
- if(!m_rts.SearchSubs((int)(m_rtStart/10000), 25, &m_nPosition, &m_nSegments))
- m_nPosition = m_nSegments;
- }
- else
- {
- m_nPosition = m_rts.SearchSub((int)(m_rtStart/10000), 25);
- if(m_nPosition < 0) m_nPosition = 0;
- else if(m_rts[m_nPosition].end <= (int)(m_rtStart/10000)) m_nPosition++;
- }
- */
- }
+ OnThreadCreate();
+/*
+ if(m_mt.majortype == MEDIATYPE_Video && m_mt.subtype == MEDIASUBTYPE_ARGB32)
+ {
+ m_nPosition = (int)(m_rtStart/10000)*1/1000;
+ }
+ else if(m_mt.majortype == MEDIATYPE_Video && m_mt.subtype == MEDIASUBTYPE_RGB32)
+ {
+ int m_nSegments = 0;
+ if(!m_rts.SearchSubs((int)(m_rtStart/10000), 25, &m_nPosition, &m_nSegments))
+ m_nPosition = m_nSegments;
+ }
+ else
+ {
+ m_nPosition = m_rts.SearchSub((int)(m_rtStart/10000), 25);
+ if(m_nPosition < 0) m_nPosition = 0;
+ else if(m_rts[m_nPosition].end <= (int)(m_rtStart/10000)) m_nPosition++;
+ }
+*/ }
UpdateFromSeek();
@@ -328,13 +327,13 @@ HRESULT CSubtitleStream::ChangeStart()
HRESULT CSubtitleStream::ChangeStop()
{
- /*
- {
- CAutoLock lock(CSourceSeeking::m_pLock);
- if(m_rtPosition < m_rtStop)
- return S_OK;
- }
- */
+/*
+ {
+ 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();
@@ -345,22 +344,22 @@ HRESULT CSubtitleStream::OnThreadCreate()
{
CAutoLock cAutoLockShared(&m_cSharedState);
- if(m_mt.majortype == MEDIATYPE_Video && m_mt.subtype == MEDIASUBTYPE_ARGB32)
- {
- m_nPosition = m_rtStart / _ATPF;
- }
- else if(m_mt.majortype == MEDIATYPE_Video && m_mt.subtype == MEDIASUBTYPE_RGB32)
- {
- int m_nSegments = 0;
- if(!m_rts.SearchSubs((int)(m_rtStart / 10000), 10000000 / _ATPF, &m_nPosition, &m_nSegments))
- m_nPosition = m_nSegments;
- }
- else
- {
- m_nPosition = m_rts.SearchSub((int)(m_rtStart / 10000), 25);
- if(m_nPosition < 0) m_nPosition = 0;
- else if(m_rts[m_nPosition].end <= (int)(m_rtStart / 10000)) m_nPosition++;
- }
+ if(m_mt.majortype == MEDIATYPE_Video && m_mt.subtype == MEDIASUBTYPE_ARGB32)
+ {
+ m_nPosition = m_rtStart/_ATPF;
+ }
+ else if(m_mt.majortype == MEDIATYPE_Video && m_mt.subtype == MEDIASUBTYPE_RGB32)
+ {
+ int m_nSegments = 0;
+ if(!m_rts.SearchSubs((int)(m_rtStart/10000), 10000000/_ATPF, &m_nPosition, &m_nSegments))
+ m_nPosition = m_nSegments;
+ }
+ else
+ {
+ m_nPosition = m_rts.SearchSub((int)(m_rtStart/10000), 25);
+ if(m_nPosition < 0) m_nPosition = 0;
+ else if(m_rts[m_nPosition].end <= (int)(m_rtStart/10000)) m_nPosition++;
+ }
return CSourceStream::OnThreadCreate();
}
@@ -374,16 +373,16 @@ HRESULT CSubtitleStream::DecideBufferSize(IMemAllocator* pAlloc, ALLOCATOR_PROPE
HRESULT hr = NOERROR;
- if(m_mt.majortype == MEDIATYPE_Video)
- {
- pProperties->cBuffers = 2;
- pProperties->cbBuffer = ((VIDEOINFOHEADER*)m_mt.pbFormat)->bmiHeader.biSizeImage;
- }
- else
- {
- pProperties->cBuffers = 1;
- pProperties->cbBuffer = 0x10000;
- }
+ if(m_mt.majortype == MEDIATYPE_Video)
+ {
+ pProperties->cBuffers = 2;
+ pProperties->cbBuffer = ((VIDEOINFOHEADER*)m_mt.pbFormat)->bmiHeader.biSizeImage;
+ }
+ else
+ {
+ pProperties->cBuffers = 1;
+ pProperties->cbBuffer = 0x10000;
+ }
ALLOCATOR_PROPERTIES Actual;
if(FAILED(hr = pAlloc->SetProperties(pProperties, &Actual))) return hr;
@@ -396,148 +395,148 @@ HRESULT CSubtitleStream::DecideBufferSize(IMemAllocator* pAlloc, ALLOCATOR_PROPE
HRESULT CSubtitleStream::FillBuffer(IMediaSample* pSample)
{
- HRESULT hr;
-
+ HRESULT hr;
+
+ {
+ CAutoLock cAutoLockShared(&m_cSharedState);
+
+ BYTE* pData = NULL;
+ if(FAILED(hr = pSample->GetPointer(&pData)) || !pData)
+ return S_FALSE;
+
+ AM_MEDIA_TYPE* pmt;
+ if(SUCCEEDED(pSample->GetMediaType(&pmt)) && pmt)
+ {
+ CMediaType mt(*pmt);
+ SetMediaType(&mt);
+ DeleteMediaType(pmt);
+ }
+
+ int len = 0;
+ REFERENCE_TIME rtStart, rtStop;
+
+ if(m_mt.majortype == MEDIATYPE_Video && m_mt.subtype == MEDIASUBTYPE_ARGB32)
+ {
+ rtStart = (REFERENCE_TIME)((m_nPosition*_ATPF - m_rtStart) / m_dRateSeeking);
+ rtStop = (REFERENCE_TIME)(((m_nPosition+1)*_ATPF - m_rtStart) / m_dRateSeeking);
+ if(m_rtStart+rtStart >= m_rtDuration)
+ return S_FALSE;
+
+ BITMAPINFOHEADER& bmi = ((VIDEOINFOHEADER*)m_mt.pbFormat)->bmiHeader;
+
+ SubPicDesc spd;
+ spd.w = _WIDTH;
+ spd.h = _HEIGHT;
+ spd.bpp = 32;
+ spd.pitch = bmi.biWidth*4;
+ spd.bits = pData;
+
+ len = spd.h*spd.pitch;
+
+ for(int y = 0; y < spd.h; y++)
+ memsetd((DWORD*)(pData + spd.pitch*y), 0xff000000, spd.w*4);
+
+ RECT bbox;
+ m_rts.Render(spd, m_nPosition*_ATPF, 10000000.0/_ATPF, bbox);
+
+ for(int y = 0; y < spd.h; y++)
+ {
+ DWORD* p = (DWORD*)(pData + spd.pitch*y);
+ for(int x = 0; x < spd.w; x++, p++)
+ *p = (0xff000000-(*p&0xff000000))|(*p&0xffffff);
+ }
+ }
+ else if(m_mt.majortype == MEDIATYPE_Video && m_mt.subtype == MEDIASUBTYPE_RGB32)
+ {
+ const STSSegment* stss = m_rts.GetSegment(m_nPosition);
+ if(!stss) return S_FALSE;
+
+ BITMAPINFOHEADER& bmi = ((VIDEOINFOHEADER*)m_mt.pbFormat)->bmiHeader;
+
+ SubPicDesc spd;
+ spd.w = _WIDTH;
+ spd.h = _HEIGHT;
+ spd.bpp = 32;
+ spd.pitch = bmi.biWidth*4;
+ spd.bits = pData;
+
+ len = spd.h*spd.pitch;
+
+ for(int y = 0; y < spd.h; y++)
+ {
+ DWORD c1 = 0xff606060, c2 = 0xffa0a0a0;
+ if(y&32) c1 ^= c2, c2 ^= c1, c1 ^= c2;
+ DWORD* p = (DWORD*)(pData + spd.pitch*y);
+ for(int x = 0; x < spd.w; x+=32, p+=32)
+ memsetd(p, (x&32) ? c1 : c2, min(spd.w-x,32)*4);
+ }
+
+ RECT bbox;
+ m_rts.Render(spd, 10000i64*(stss->start+stss->end)/2, 10000000.0/_ATPF, bbox);
+
+ rtStart = (REFERENCE_TIME)((10000i64*stss->start - m_rtStart) / m_dRateSeeking);
+ rtStop = (REFERENCE_TIME)((10000i64*stss->end - m_rtStart) / m_dRateSeeking);
+ }
+ else
+ {
+ if(m_nPosition >= m_rts.GetCount())
+ return S_FALSE;
+
+ STSEntry& stse = m_rts[m_nPosition];
+
+ if(stse.start >= m_rtStop/10000)
+ return S_FALSE;
+
+ if(m_mt.majortype == MEDIATYPE_Subtitle && m_mt.subtype == MEDIASUBTYPE_UTF8)
+ {
+ CStringA str = UTF16To8(m_rts.GetStrW(m_nPosition, false));
+ memcpy((char*)pData, str, len = str.GetLength());
+ }
+ else if(m_mt.majortype == MEDIATYPE_Subtitle && (m_mt.subtype == MEDIASUBTYPE_SSA || m_mt.subtype == MEDIASUBTYPE_ASS))
+ {
+ CStringW line;
+ line.Format(L"%d,%d,%s,%s,%d,%d,%d,%s,%s",
+ stse.readorder, stse.layer, CStringW(stse.style), CStringW(stse.actor),
+ stse.marginRect.left, stse.marginRect.right, (stse.marginRect.top+stse.marginRect.bottom)/2,
+ CStringW(stse.effect), m_rts.GetStrW(m_nPosition, true));
+
+ CStringA str = UTF16To8(line);
+ memcpy((char*)pData, str, len = str.GetLength());
+ }
+ else if(m_mt.majortype == MEDIATYPE_Text && m_mt.subtype == MEDIASUBTYPE_NULL)
+ {
+ CStringA str = m_rts.GetStrA(m_nPosition, false);
+ memcpy((char*)pData, str, len = str.GetLength());
+ }
+ else
+ {
+ return S_FALSE;
+ }
+
+ rtStart = (REFERENCE_TIME)((10000i64*stse.start - m_rtStart) / m_dRateSeeking);
+ rtStop = (REFERENCE_TIME)((10000i64*stse.end - m_rtStart) / m_dRateSeeking);
+ }
+
+ pSample->SetTime(&rtStart, &rtStop);
+ pSample->SetActualDataLength(len);
+
+ m_nPosition++;
+ }
+
+ pSample->SetSyncPoint(TRUE);
+
+ if(m_bDiscontinuity)
{
- CAutoLock cAutoLockShared(&m_cSharedState);
-
- BYTE* pData = NULL;
- if(FAILED(hr = pSample->GetPointer(&pData)) || !pData)
- return S_FALSE;
-
- AM_MEDIA_TYPE* pmt;
- if(SUCCEEDED(pSample->GetMediaType(&pmt)) && pmt)
- {
- CMediaType mt(*pmt);
- SetMediaType(&mt);
- DeleteMediaType(pmt);
- }
-
- int len = 0;
- REFERENCE_TIME rtStart, rtStop;
-
- if(m_mt.majortype == MEDIATYPE_Video && m_mt.subtype == MEDIASUBTYPE_ARGB32)
- {
- rtStart = (REFERENCE_TIME)((m_nPosition * _ATPF - m_rtStart) / m_dRateSeeking);
- rtStop = (REFERENCE_TIME)(((m_nPosition + 1) * _ATPF - m_rtStart) / m_dRateSeeking);
- if(m_rtStart + rtStart >= m_rtDuration)
- return S_FALSE;
-
- BITMAPINFOHEADER& bmi = ((VIDEOINFOHEADER*)m_mt.pbFormat)->bmiHeader;
-
- SubPicDesc spd;
- spd.w = _WIDTH;
- spd.h = _HEIGHT;
- spd.bpp = 32;
- spd.pitch = bmi.biWidth * 4;
- spd.bits = pData;
-
- len = spd.h * spd.pitch;
-
- for(int y = 0; y < spd.h; y++)
- memsetd((DWORD*)(pData + spd.pitch * y), 0xff000000, spd.w * 4);
-
- RECT bbox;
- m_rts.Render(spd, m_nPosition * _ATPF, 10000000.0 / _ATPF, bbox);
-
- for(int y = 0; y < spd.h; y++)
- {
- DWORD* p = (DWORD*)(pData + spd.pitch * y);
- for(int x = 0; x < spd.w; x++, p++)
- *p = (0xff000000 - (*p & 0xff000000)) | (*p & 0xffffff);
- }
- }
- else if(m_mt.majortype == MEDIATYPE_Video && m_mt.subtype == MEDIASUBTYPE_RGB32)
- {
- const STSSegment* stss = m_rts.GetSegment(m_nPosition);
- if(!stss) return S_FALSE;
-
- BITMAPINFOHEADER& bmi = ((VIDEOINFOHEADER*)m_mt.pbFormat)->bmiHeader;
-
- SubPicDesc spd;
- spd.w = _WIDTH;
- spd.h = _HEIGHT;
- spd.bpp = 32;
- spd.pitch = bmi.biWidth * 4;
- spd.bits = pData;
-
- len = spd.h * spd.pitch;
-
- for(int y = 0; y < spd.h; y++)
- {
- DWORD c1 = 0xff606060, c2 = 0xffa0a0a0;
- if(y & 32) c1 ^= c2, c2 ^= c1, c1 ^= c2;
- DWORD* p = (DWORD*)(pData + spd.pitch * y);
- for(int x = 0; x < spd.w; x += 32, p += 32)
- memsetd(p, (x & 32) ? c1 : c2, min(spd.w - x, 32) * 4);
- }
-
- RECT bbox;
- m_rts.Render(spd, 10000i64 *(stss->start + stss->end) / 2, 10000000.0 / _ATPF, bbox);
-
- rtStart = (REFERENCE_TIME)((10000i64 * stss->start - m_rtStart) / m_dRateSeeking);
- rtStop = (REFERENCE_TIME)((10000i64 * stss->end - m_rtStart) / m_dRateSeeking);
- }
- else
- {
- if(m_nPosition >= m_rts.GetCount())
- return S_FALSE;
-
- STSEntry& stse = m_rts[m_nPosition];
-
- if(stse.start >= m_rtStop / 10000)
- return S_FALSE;
-
- if(m_mt.majortype == MEDIATYPE_Subtitle && m_mt.subtype == MEDIASUBTYPE_UTF8)
- {
- CStringA str = UTF16To8(m_rts.GetStrW(m_nPosition, false));
- memcpy((char*)pData, str, len = str.GetLength());
- }
- else if(m_mt.majortype == MEDIATYPE_Subtitle && (m_mt.subtype == MEDIASUBTYPE_SSA || m_mt.subtype == MEDIASUBTYPE_ASS))
- {
- CStringW line;
- line.Format(L"%d,%d,%s,%s,%d,%d,%d,%s,%s",
- stse.readorder, stse.layer, CStringW(stse.style), CStringW(stse.actor),
- stse.marginRect.left, stse.marginRect.right, (stse.marginRect.top + stse.marginRect.bottom) / 2,
- CStringW(stse.effect), m_rts.GetStrW(m_nPosition, true));
-
- CStringA str = UTF16To8(line);
- memcpy((char*)pData, str, len = str.GetLength());
- }
- else if(m_mt.majortype == MEDIATYPE_Text && m_mt.subtype == MEDIASUBTYPE_NULL)
- {
- CStringA str = m_rts.GetStrA(m_nPosition, false);
- memcpy((char*)pData, str, len = str.GetLength());
- }
- else
- {
- return S_FALSE;
- }
-
- rtStart = (REFERENCE_TIME)((10000i64 * stse.start - m_rtStart) / m_dRateSeeking);
- rtStop = (REFERENCE_TIME)((10000i64 * stse.end - m_rtStart) / m_dRateSeeking);
- }
-
- pSample->SetTime(&rtStart, &rtStop);
- pSample->SetActualDataLength(len);
-
- m_nPosition++;
- }
-
- pSample->SetSyncPoint(TRUE);
+ pSample->SetDiscontinuity(TRUE);
+ m_bDiscontinuity = FALSE;
+ }
- if(m_bDiscontinuity)
- {
- pSample->SetDiscontinuity(TRUE);
- m_bDiscontinuity = FALSE;
- }
-
- return S_OK;
+ return S_OK;
}
HRESULT CSubtitleStream::GetMediaType(CMediaType* pmt)
{
- return (static_cast<CSubtitleSource*>(m_pFilter))->GetMediaType(pmt);
+ return (static_cast<CSubtitleSource*>(m_pFilter))->GetMediaType(pmt);
}
HRESULT CSubtitleStream::CheckMediaType(const CMediaType* pmt)
@@ -547,8 +546,8 @@ HRESULT CSubtitleStream::CheckMediaType(const CMediaType* pmt)
CMediaType mt;
GetMediaType(&mt);
- if(mt.majortype == pmt->majortype && mt.subtype == pmt->subtype)
- {
+ if(mt.majortype == pmt->majortype && mt.subtype == pmt->subtype)
+ {
return NOERROR;
}
@@ -557,7 +556,7 @@ HRESULT CSubtitleStream::CheckMediaType(const CMediaType* pmt)
STDMETHODIMP CSubtitleStream::Notify(IBaseFilter* pSender, Quality q)
{
- return E_NOTIMPL;
+ return E_NOTIMPL;
}
//
@@ -565,7 +564,7 @@ STDMETHODIMP CSubtitleStream::Notify(IBaseFilter* pSender, Quality q)
//
CSubtitleSourceASCII::CSubtitleSourceASCII(LPUNKNOWN lpunk, HRESULT* phr)
- : CSubtitleSource(lpunk, phr, __uuidof(this))
+ : CSubtitleSource(lpunk, phr, __uuidof(this))
{
}
@@ -573,11 +572,11 @@ HRESULT CSubtitleSourceASCII::GetMediaType(CMediaType* pmt)
{
CAutoLock cAutoLock(pStateLock());
- pmt->InitMediaType();
- pmt->SetType(&MEDIATYPE_Text);
- pmt->SetSubtype(&MEDIASUBTYPE_NULL);
- pmt->SetFormatType(&FORMAT_None);
- pmt->ResetFormatBuffer();
+ pmt->InitMediaType();
+ pmt->SetType(&MEDIATYPE_Text);
+ pmt->SetSubtype(&MEDIASUBTYPE_NULL);
+ pmt->SetFormatType(&FORMAT_None);
+ pmt->ResetFormatBuffer();
return NOERROR;
}
@@ -587,7 +586,7 @@ HRESULT CSubtitleSourceASCII::GetMediaType(CMediaType* pmt)
//
CSubtitleSourceUTF8::CSubtitleSourceUTF8(LPUNKNOWN lpunk, HRESULT* phr)
- : CSubtitleSource(lpunk, phr, __uuidof(this))
+ : CSubtitleSource(lpunk, phr, __uuidof(this))
{
}
@@ -595,13 +594,13 @@ HRESULT CSubtitleSourceUTF8::GetMediaType(CMediaType* pmt)
{
CAutoLock cAutoLock(pStateLock());
- pmt->InitMediaType();
- pmt->SetType(&MEDIATYPE_Subtitle);
- pmt->SetSubtype(&MEDIASUBTYPE_UTF8);
- pmt->SetFormatType(&FORMAT_SubtitleInfo);
- SUBTITLEINFO* psi = (SUBTITLEINFO*)pmt->AllocFormatBuffer(sizeof(SUBTITLEINFO));
- memset(psi, 0, pmt->FormatLength());
- strcpy(psi->IsoLang, "eng");
+ pmt->InitMediaType();
+ pmt->SetType(&MEDIATYPE_Subtitle);
+ pmt->SetSubtype(&MEDIASUBTYPE_UTF8);
+ pmt->SetFormatType(&FORMAT_SubtitleInfo);
+ SUBTITLEINFO* psi = (SUBTITLEINFO*)pmt->AllocFormatBuffer(sizeof(SUBTITLEINFO));
+ memset(psi, 0, pmt->FormatLength());
+ strcpy(psi->IsoLang, "eng");
return NOERROR;
}
@@ -611,7 +610,7 @@ HRESULT CSubtitleSourceUTF8::GetMediaType(CMediaType* pmt)
//
CSubtitleSourceSSA::CSubtitleSourceSSA(LPUNKNOWN lpunk, HRESULT* phr)
- : CSubtitleSource(lpunk, phr, __uuidof(this))
+ : CSubtitleSource(lpunk, phr, __uuidof(this))
{
}
@@ -619,38 +618,38 @@ HRESULT CSubtitleSourceSSA::GetMediaType(CMediaType* pmt)
{
CAutoLock cAutoLock(pStateLock());
- pmt->InitMediaType();
- pmt->SetType(&MEDIATYPE_Subtitle);
- pmt->SetSubtype(&MEDIASUBTYPE_SSA);
- pmt->SetFormatType(&FORMAT_SubtitleInfo);
+ pmt->InitMediaType();
+ pmt->SetType(&MEDIATYPE_Subtitle);
+ pmt->SetSubtype(&MEDIASUBTYPE_SSA);
+ pmt->SetFormatType(&FORMAT_SubtitleInfo);
- CSimpleTextSubtitle sts;
- sts.Open(CString(m_fn), DEFAULT_CHARSET);
- sts.RemoveAll();
+ CSimpleTextSubtitle sts;
+ sts.Open(CString(m_fn), DEFAULT_CHARSET);
+ sts.RemoveAll();
- CFile f;
- TCHAR path[_MAX_PATH], fn[_MAX_PATH];
- if(!GetTempPath(MAX_PATH, path) || !GetTempFileName(path, _T("mpc_sts"), 0, fn))
- return E_FAIL;
+ CFile f;
+ TCHAR path[_MAX_PATH], fn[_MAX_PATH];
+ if(!GetTempPath(MAX_PATH, path) || !GetTempFileName(path, _T("mpc_sts"), 0, fn))
+ return E_FAIL;
- _tremove(fn);
+ _tremove(fn);
- _tcscat(fn, _T(".ssa"));
+ _tcscat(fn, _T(".ssa"));
- if(!sts.SaveAs(fn, EXTSSA, -1, CTextFile::UTF8) || !f.Open(fn, CFile::modeRead))
- return E_FAIL;
+ if(!sts.SaveAs(fn, EXTSSA, -1, CTextFile::UTF8) || !f.Open(fn, CFile::modeRead))
+ return E_FAIL;
- int len = (int)f.GetLength() - 3;
- f.Seek(3, CFile::begin);
+ int len = (int)f.GetLength()-3;
+ f.Seek(3, CFile::begin);
- SUBTITLEINFO* psi = (SUBTITLEINFO*)pmt->AllocFormatBuffer(sizeof(SUBTITLEINFO) + len);
- memset(psi, 0, pmt->FormatLength());
- psi->dwOffset = sizeof(SUBTITLEINFO);
- strcpy(psi->IsoLang, "eng");
- f.Read(pmt->pbFormat + psi->dwOffset, len);
- f.Close();
+ SUBTITLEINFO* psi = (SUBTITLEINFO*)pmt->AllocFormatBuffer(sizeof(SUBTITLEINFO) + len);
+ memset(psi, 0, pmt->FormatLength());
+ psi->dwOffset = sizeof(SUBTITLEINFO);
+ strcpy(psi->IsoLang, "eng");
+ f.Read(pmt->pbFormat + psi->dwOffset, len);
+ f.Close();
- _tremove(fn);
+ _tremove(fn);
return NOERROR;
}
@@ -660,7 +659,7 @@ HRESULT CSubtitleSourceSSA::GetMediaType(CMediaType* pmt)
//
CSubtitleSourceASS::CSubtitleSourceASS(LPUNKNOWN lpunk, HRESULT* phr)
- : CSubtitleSource(lpunk, phr, __uuidof(this))
+ : CSubtitleSource(lpunk, phr, __uuidof(this))
{
}
@@ -668,37 +667,37 @@ HRESULT CSubtitleSourceASS::GetMediaType(CMediaType* pmt)
{
CAutoLock cAutoLock(pStateLock());
- pmt->InitMediaType();
- pmt->SetType(&MEDIATYPE_Subtitle);
- pmt->SetSubtype(&MEDIASUBTYPE_ASS);
- pmt->SetFormatType(&FORMAT_SubtitleInfo);
+ pmt->InitMediaType();
+ pmt->SetType(&MEDIATYPE_Subtitle);
+ pmt->SetSubtype(&MEDIASUBTYPE_ASS);
+ pmt->SetFormatType(&FORMAT_SubtitleInfo);
- CSimpleTextSubtitle sts;
- sts.Open(CString(m_fn), DEFAULT_CHARSET);
- sts.RemoveAll();
+ CSimpleTextSubtitle sts;
+ sts.Open(CString(m_fn), DEFAULT_CHARSET);
+ sts.RemoveAll();
- CFile f;
- TCHAR path[_MAX_PATH], fn[_MAX_PATH];
- if(!GetTempPath(MAX_PATH, path) || !GetTempFileName(path, _T("mpc_sts"), 0, fn))
- return E_FAIL;
+ CFile f;
+ TCHAR path[_MAX_PATH], fn[_MAX_PATH];
+ if(!GetTempPath(MAX_PATH, path) || !GetTempFileName(path, _T("mpc_sts"), 0, fn))
+ return E_FAIL;
- _tremove(fn);
+ _tremove(fn);
- _tcscat(fn, _T(".ass"));
+ _tcscat(fn, _T(".ass"));
- if(!sts.SaveAs(fn, EXTASS, -1, CTextFile::UTF8) || !f.Open(fn, CFile::modeRead))
- return E_FAIL;
+ if(!sts.SaveAs(fn, EXTASS, -1, CTextFile::UTF8) || !f.Open(fn, CFile::modeRead))
+ return E_FAIL;
- int len = (int)f.GetLength();
+ int len = (int)f.GetLength();
- SUBTITLEINFO* psi = (SUBTITLEINFO*)pmt->AllocFormatBuffer(sizeof(SUBTITLEINFO) + len);
- memset(psi, 0, pmt->FormatLength());
- psi->dwOffset = sizeof(SUBTITLEINFO);
- strcpy(psi->IsoLang, "eng");
- f.Read(pmt->pbFormat + psi->dwOffset, len);
- f.Close();
+ SUBTITLEINFO* psi = (SUBTITLEINFO*)pmt->AllocFormatBuffer(sizeof(SUBTITLEINFO) + len);
+ memset(psi, 0, pmt->FormatLength());
+ psi->dwOffset = sizeof(SUBTITLEINFO);
+ strcpy(psi->IsoLang, "eng");
+ f.Read(pmt->pbFormat + psi->dwOffset, len);
+ f.Close();
- _tremove(fn);
+ _tremove(fn);
return NOERROR;
}
@@ -708,7 +707,7 @@ HRESULT CSubtitleSourceASS::GetMediaType(CMediaType* pmt)
//
CSubtitleSourceUSF::CSubtitleSourceUSF(LPUNKNOWN lpunk, HRESULT* phr)
- : CSubtitleSource(lpunk, phr, __uuidof(this))
+ : CSubtitleSource(lpunk, phr, __uuidof(this))
{
}
@@ -716,14 +715,14 @@ HRESULT CSubtitleSourceUSF::GetMediaType(CMediaType* pmt)
{
CAutoLock cAutoLock(pStateLock());
- pmt->InitMediaType();
- pmt->SetType(&MEDIATYPE_Subtitle);
- pmt->SetSubtype(&MEDIASUBTYPE_USF);
- pmt->SetFormatType(&FORMAT_SubtitleInfo);
- SUBTITLEINFO* psi = (SUBTITLEINFO*)pmt->AllocFormatBuffer(sizeof(SUBTITLEINFO));
- memset(psi, 0, pmt->FormatLength());
- strcpy(psi->IsoLang, "eng");
- // TODO: ...
+ pmt->InitMediaType();
+ pmt->SetType(&MEDIATYPE_Subtitle);
+ pmt->SetSubtype(&MEDIASUBTYPE_USF);
+ pmt->SetFormatType(&FORMAT_SubtitleInfo);
+ SUBTITLEINFO* psi = (SUBTITLEINFO*)pmt->AllocFormatBuffer(sizeof(SUBTITLEINFO));
+ memset(psi, 0, pmt->FormatLength());
+ strcpy(psi->IsoLang, "eng");
+ // TODO: ...
return NOERROR;
}
@@ -733,7 +732,7 @@ HRESULT CSubtitleSourceUSF::GetMediaType(CMediaType* pmt)
//
CSubtitleSourcePreview::CSubtitleSourcePreview(LPUNKNOWN lpunk, HRESULT* phr)
- : CSubtitleSource(lpunk, phr, __uuidof(this))
+ : CSubtitleSource(lpunk, phr, __uuidof(this))
{
}
@@ -741,19 +740,19 @@ HRESULT CSubtitleSourcePreview::GetMediaType(CMediaType* pmt)
{
CAutoLock cAutoLock(pStateLock());
- pmt->InitMediaType();
- pmt->SetType(&MEDIATYPE_Video);
- pmt->SetSubtype(&MEDIASUBTYPE_RGB32);
- pmt->SetFormatType(&FORMAT_VideoInfo);
- VIDEOINFOHEADER* pvih = (VIDEOINFOHEADER*)pmt->AllocFormatBuffer(sizeof(VIDEOINFOHEADER));
- memset(pvih, 0, pmt->FormatLength());
- pvih->bmiHeader.biSize = sizeof(pvih->bmiHeader);
- pvih->bmiHeader.biWidth = _WIDTH;
- pvih->bmiHeader.biHeight = _HEIGHT;
- pvih->bmiHeader.biBitCount = 32;
- pvih->bmiHeader.biCompression = BI_RGB;
- pvih->bmiHeader.biPlanes = 1;
- pvih->bmiHeader.biSizeImage = pvih->bmiHeader.biWidth * abs(pvih->bmiHeader.biHeight) * pvih->bmiHeader.biBitCount >> 3;
+ pmt->InitMediaType();
+ pmt->SetType(&MEDIATYPE_Video);
+ pmt->SetSubtype(&MEDIASUBTYPE_RGB32);
+ pmt->SetFormatType(&FORMAT_VideoInfo);
+ VIDEOINFOHEADER* pvih = (VIDEOINFOHEADER*)pmt->AllocFormatBuffer(sizeof(VIDEOINFOHEADER));
+ memset(pvih, 0, pmt->FormatLength());
+ pvih->bmiHeader.biSize = sizeof(pvih->bmiHeader);
+ pvih->bmiHeader.biWidth = _WIDTH;
+ pvih->bmiHeader.biHeight = _HEIGHT;
+ pvih->bmiHeader.biBitCount = 32;
+ pvih->bmiHeader.biCompression = BI_RGB;
+ pvih->bmiHeader.biPlanes = 1;
+ pvih->bmiHeader.biSizeImage = pvih->bmiHeader.biWidth*abs(pvih->bmiHeader.biHeight)*pvih->bmiHeader.biBitCount>>3;
return NOERROR;
}
@@ -763,7 +762,7 @@ HRESULT CSubtitleSourcePreview::GetMediaType(CMediaType* pmt)
//
CSubtitleSourceARGB::CSubtitleSourceARGB(LPUNKNOWN lpunk, HRESULT* phr)
- : CSubtitleSource(lpunk, phr, __uuidof(this))
+ : CSubtitleSource(lpunk, phr, __uuidof(this))
{
}
@@ -771,20 +770,20 @@ HRESULT CSubtitleSourceARGB::GetMediaType(CMediaType* pmt)
{
CAutoLock cAutoLock(pStateLock());
- pmt->InitMediaType();
- pmt->SetType(&MEDIATYPE_Video);
- pmt->SetSubtype(&MEDIASUBTYPE_ARGB32);
- pmt->SetFormatType(&FORMAT_VideoInfo);
- VIDEOINFOHEADER* pvih = (VIDEOINFOHEADER*)pmt->AllocFormatBuffer(sizeof(VIDEOINFOHEADER));
- memset(pvih, 0, pmt->FormatLength());
- pvih->bmiHeader.biSize = sizeof(pvih->bmiHeader);
- // TODO: read w,h,fps from a config file or registry
- pvih->bmiHeader.biWidth = _WIDTH;
- pvih->bmiHeader.biHeight = _HEIGHT;
- pvih->bmiHeader.biBitCount = 32;
- pvih->bmiHeader.biCompression = BI_RGB;
- pvih->bmiHeader.biPlanes = 1;
- pvih->bmiHeader.biSizeImage = pvih->bmiHeader.biWidth * abs(pvih->bmiHeader.biHeight) * pvih->bmiHeader.biBitCount >> 3;
+ pmt->InitMediaType();
+ pmt->SetType(&MEDIATYPE_Video);
+ pmt->SetSubtype(&MEDIASUBTYPE_ARGB32);
+ pmt->SetFormatType(&FORMAT_VideoInfo);
+ VIDEOINFOHEADER* pvih = (VIDEOINFOHEADER*)pmt->AllocFormatBuffer(sizeof(VIDEOINFOHEADER));
+ memset(pvih, 0, pmt->FormatLength());
+ pvih->bmiHeader.biSize = sizeof(pvih->bmiHeader);
+ // TODO: read w,h,fps from a config file or registry
+ pvih->bmiHeader.biWidth = _WIDTH;
+ pvih->bmiHeader.biHeight = _HEIGHT;
+ pvih->bmiHeader.biBitCount = 32;
+ pvih->bmiHeader.biCompression = BI_RGB;
+ pvih->bmiHeader.biPlanes = 1;
+ pvih->bmiHeader.biSizeImage = pvih->bmiHeader.biWidth*abs(pvih->bmiHeader.biHeight)*pvih->bmiHeader.biBitCount>>3;
return NOERROR;
}
diff --git a/src/filters/source/SubtitleSource/SubtitleSource.h b/src/filters/source/SubtitleSource/SubtitleSource.h
index 8fc2acb91..77ef35581 100644
--- a/src/filters/source/SubtitleSource/SubtitleSource.h
+++ b/src/filters/source/SubtitleSource/SubtitleSource.h
@@ -1,4 +1,4 @@
-/*
+/*
* Copyright (C) 2003-2006 Gabest
* http://www.gabest.org
*
@@ -6,15 +6,15 @@
* 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.
+ * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
* http://www.gnu.org/copyleft/gpl.html
*
*/
@@ -25,130 +25,127 @@
#include "../../../subtitles/RTS.h"
class CSubtitleSource
- : public CSource
- , public IFileSourceFilter
- , public IAMFilterMiscFlags
+ : public CSource
+ , public IFileSourceFilter
+ , public IAMFilterMiscFlags
{
protected:
- CStringW m_fn;
+ CStringW m_fn;
public:
- CSubtitleSource(LPUNKNOWN lpunk, HRESULT* phr, const CLSID& clsid);
- virtual ~CSubtitleSource();
+ CSubtitleSource(LPUNKNOWN lpunk, HRESULT* phr, const CLSID& clsid);
+ virtual ~CSubtitleSource();
- DECLARE_IUNKNOWN;
+ DECLARE_IUNKNOWN;
STDMETHODIMP NonDelegatingQueryInterface(REFIID riid, void** ppv);
- // IFileSourceFilter
- STDMETHODIMP Load(LPCOLESTR pszFileName, const AM_MEDIA_TYPE* pmt);
- STDMETHODIMP GetCurFile(LPOLESTR* ppszFileName, AM_MEDIA_TYPE* pmt);
+ // IFileSourceFilter
+ STDMETHODIMP Load(LPCOLESTR pszFileName, const AM_MEDIA_TYPE* pmt);
+ STDMETHODIMP GetCurFile(LPOLESTR* ppszFileName, AM_MEDIA_TYPE* pmt);
- // IAMFilterMiscFlags
- STDMETHODIMP_(ULONG) GetMiscFlags();
+ // IAMFilterMiscFlags
+ STDMETHODIMP_(ULONG) GetMiscFlags();
virtual HRESULT GetMediaType(CMediaType* pmt) = 0;
};
-class CSubtitleStream
- : public CSourceStream
- , public CSourceSeeking
+class CSubtitleStream
+ : public CSourceStream
+ , public CSourceSeeking
{
- CCritSec m_cSharedState;
+ CCritSec m_cSharedState;
- int m_nPosition;
+ int m_nPosition;
- BOOL m_bDiscontinuity, m_bFlushing;
+ BOOL m_bDiscontinuity, m_bFlushing;
- HRESULT OnThreadStartPlay();
- HRESULT OnThreadCreate();
+ HRESULT OnThreadStartPlay();
+ HRESULT OnThreadCreate();
- void UpdateFromSeek();
- STDMETHODIMP SetRate(double dRate);
+ void UpdateFromSeek();
+ STDMETHODIMP SetRate(double dRate);
- HRESULT ChangeStart();
+ HRESULT ChangeStart();
HRESULT ChangeStop();
- HRESULT ChangeRate()
- {
- return S_OK;
- }
+ HRESULT ChangeRate() {return S_OK;}
protected:
- CRenderedTextSubtitle m_rts;
+ CRenderedTextSubtitle m_rts;
public:
CSubtitleStream(const WCHAR* wfn, CSubtitleSource* pParent, HRESULT* phr);
- virtual ~CSubtitleStream();
+ virtual ~CSubtitleStream();
STDMETHODIMP NonDelegatingQueryInterface(REFIID riid, void** ppv);
HRESULT DecideBufferSize(IMemAllocator* pIMemAlloc, ALLOCATOR_PROPERTIES* pProperties);
HRESULT FillBuffer(IMediaSample* pSample);
HRESULT GetMediaType(CMediaType* pmt);
- HRESULT CheckMediaType(const CMediaType* pmt);
+ HRESULT CheckMediaType(const CMediaType* pmt);
- STDMETHODIMP Notify(IBaseFilter* pSender, Quality q);
+ STDMETHODIMP Notify(IBaseFilter* pSender, Quality q);
};
[uuid("E44CA3B5-A0FF-41A0-AF16-42429B1095EA")]
class CSubtitleSourceASCII : public CSubtitleSource
{
public:
- CSubtitleSourceASCII(LPUNKNOWN lpunk, HRESULT* phr);
+ CSubtitleSourceASCII(LPUNKNOWN lpunk, HRESULT* phr);
- HRESULT GetMediaType(CMediaType* pmt);
+ HRESULT GetMediaType(CMediaType* pmt);
};
[uuid("87864E0F-7073-4E39-B802-143DE0ED4964")]
class CSubtitleSourceUTF8 : public CSubtitleSource
{
public:
- CSubtitleSourceUTF8(LPUNKNOWN lpunk, HRESULT* phr);
+ CSubtitleSourceUTF8(LPUNKNOWN lpunk, HRESULT* phr);
- HRESULT GetMediaType(CMediaType* pmt);
+ HRESULT GetMediaType(CMediaType* pmt);
};
[uuid("18316B1A-5877-4CC4-85FD-EDE65CD489EC")]
class CSubtitleSourceSSA : public CSubtitleSource
{
public:
- CSubtitleSourceSSA(LPUNKNOWN lpunk, HRESULT* phr);
+ CSubtitleSourceSSA(LPUNKNOWN lpunk, HRESULT* phr);
- HRESULT GetMediaType(CMediaType* pmt);
+ HRESULT GetMediaType(CMediaType* pmt);
};
[uuid("416782BC-1D87-48C0-8F65-F113A5CB8E15")]
class CSubtitleSourceASS : public CSubtitleSource
{
public:
- CSubtitleSourceASS(LPUNKNOWN lpunk, HRESULT* phr);
+ CSubtitleSourceASS(LPUNKNOWN lpunk, HRESULT* phr);
- HRESULT GetMediaType(CMediaType* pmt);
+ HRESULT GetMediaType(CMediaType* pmt);
};
[uuid("D7215AFC-DFE6-483B-9AF3-6BBECFF14CF4")]
class CSubtitleSourceUSF : public CSubtitleSource
{
public:
- CSubtitleSourceUSF(LPUNKNOWN lpunk, HRESULT* phr);
+ CSubtitleSourceUSF(LPUNKNOWN lpunk, HRESULT* phr);
- HRESULT GetMediaType(CMediaType* pmt);
+ HRESULT GetMediaType(CMediaType* pmt);
};
[uuid("932E75D4-BBD4-4A0F-9071-6728FBDC4C98")]
class CSubtitleSourcePreview : public CSubtitleSource
{
public:
- CSubtitleSourcePreview(LPUNKNOWN lpunk, HRESULT* phr);
+ CSubtitleSourcePreview(LPUNKNOWN lpunk, HRESULT* phr);
- HRESULT GetMediaType(CMediaType* pmt);
+ HRESULT GetMediaType(CMediaType* pmt);
};
[uuid("CF0D7280-527D-415E-BA02-56017484D73E")]
class CSubtitleSourceARGB : public CSubtitleSource
{
public:
- CSubtitleSourceARGB(LPUNKNOWN lpunk, HRESULT* phr);
+ CSubtitleSourceARGB(LPUNKNOWN lpunk, HRESULT* phr);
- HRESULT GetMediaType(CMediaType* pmt);
+ HRESULT GetMediaType(CMediaType* pmt);
};
diff --git a/src/filters/source/SubtitleSource/resource.h b/src/filters/source/SubtitleSource/resource.h
index 2dcb23529..fb6ab9443 100644
--- a/src/filters/source/SubtitleSource/resource.h
+++ b/src/filters/source/SubtitleSource/resource.h
@@ -3,7 +3,7 @@
// Used by subtitlesource.rc
// Next default values for new objects
-//
+//
#ifdef APSTUDIO_INVOKED
#ifndef APSTUDIO_READONLY_SYMBOLS
#define _APS_NEXT_RESOURCE_VALUE 101
diff --git a/src/filters/source/SubtitleSource/stdafx.cpp b/src/filters/source/SubtitleSource/stdafx.cpp
index a51424de6..f08539cb9 100644
--- a/src/filters/source/SubtitleSource/stdafx.cpp
+++ b/src/filters/source/SubtitleSource/stdafx.cpp
@@ -1,4 +1,4 @@
-/*
+/*
* Copyright (C) 2003-2006 Gabest
* http://www.gabest.org
*
@@ -6,15 +6,15 @@
* 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.
+ * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
* http://www.gnu.org/copyleft/gpl.html
*
*/
diff --git a/src/filters/source/SubtitleSource/stdafx.h b/src/filters/source/SubtitleSource/stdafx.h
index a9f666228..c35359c38 100644
--- a/src/filters/source/SubtitleSource/stdafx.h
+++ b/src/filters/source/SubtitleSource/stdafx.h
@@ -1,4 +1,4 @@
-/*
+/*
* Copyright (C) 2003-2006 Gabest
* http://www.gabest.org
*
@@ -6,15 +6,15 @@
* 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.
+ * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
* http://www.gnu.org/copyleft/gpl.html
*
*/