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:
Diffstat (limited to 'src/filters/parser/BaseSplitter')
-rw-r--r--src/filters/parser/BaseSplitter/AsyncReader.cpp117
-rw-r--r--src/filters/parser/BaseSplitter/AsyncReader.h56
-rw-r--r--src/filters/parser/BaseSplitter/BaseSplitter.cpp723
-rw-r--r--src/filters/parser/BaseSplitter/BaseSplitter.h154
-rw-r--r--src/filters/parser/BaseSplitter/BaseSplitterFile.cpp88
-rw-r--r--src/filters/parser/BaseSplitter/BaseSplitterFile.h18
-rw-r--r--src/filters/parser/BaseSplitter/BaseSplitterFileEx.cpp924
-rw-r--r--src/filters/parser/BaseSplitter/BaseSplitterFileEx.h44
-rw-r--r--src/filters/parser/BaseSplitter/MultiFiles.cpp85
-rw-r--r--src/filters/parser/BaseSplitter/MultiFiles.h12
-rw-r--r--src/filters/parser/BaseSplitter/stdafx.cpp6
-rw-r--r--src/filters/parser/BaseSplitter/stdafx.h6
12 files changed, 1260 insertions, 973 deletions
diff --git a/src/filters/parser/BaseSplitter/AsyncReader.cpp b/src/filters/parser/BaseSplitter/AsyncReader.cpp
index deb21fd1d..cfe36e69a 100644
--- a/src/filters/parser/BaseSplitter/AsyncReader.cpp
+++ b/src/filters/parser/BaseSplitter/AsyncReader.cpp
@@ -1,4 +1,4 @@
-/*
+/*
* Copyright (C) 2003-2006 Gabest
* http://www.gabest.org
*
@@ -6,12 +6,12 @@
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2, or (at your option)
* any later version.
- *
+ *
* This Program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
- *
+ *
* You should have received a copy of the GNU General Public License
* along with GNU Make; see the file COPYING. If not, write to
* the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
@@ -30,30 +30,34 @@
// CAsyncFileReader
//
-CAsyncFileReader::CAsyncFileReader(CString fn, HRESULT& hr)
+CAsyncFileReader::CAsyncFileReader(CString fn, HRESULT& hr)
: CUnknown(NAME("CAsyncFileReader"), NULL, &hr)
, m_len((ULONGLONG)-1)
, m_hBreakEvent(NULL)
, m_lOsError(0)
{
hr = Open(fn, modeRead|shareDenyNone|typeBinary|osSequentialScan) ? S_OK : E_FAIL;
- if(SUCCEEDED(hr)) m_len = GetLength();
+ if(SUCCEEDED(hr)) {
+ m_len = GetLength();
+ }
}
-CAsyncFileReader::CAsyncFileReader(CAtlList<CHdmvClipInfo::PlaylistItem>& Items, HRESULT& hr)
+CAsyncFileReader::CAsyncFileReader(CAtlList<CHdmvClipInfo::PlaylistItem>& Items, HRESULT& hr)
: CUnknown(NAME("CAsyncFileReader"), NULL, &hr)
, m_len((ULONGLONG)-1)
, m_hBreakEvent(NULL)
, m_lOsError(0)
{
hr = OpenFiles(Items, modeRead|shareDenyNone|typeBinary|osSequentialScan) ? S_OK : E_FAIL;
- if(SUCCEEDED(hr)) m_len = GetLength();
+ if(SUCCEEDED(hr)) {
+ m_len = GetLength();
+ }
}
STDMETHODIMP CAsyncFileReader::NonDelegatingQueryInterface(REFIID riid, void** ppv)
{
CheckPointer(ppv, E_POINTER);
- return
+ return
QI(IAsyncReader)
QI(ISyncReader)
QI(IFileHandle)
@@ -64,36 +68,46 @@ STDMETHODIMP CAsyncFileReader::NonDelegatingQueryInterface(REFIID riid, void** p
STDMETHODIMP CAsyncFileReader::SyncRead(LONGLONG llPosition, LONG lLength, BYTE* pBuffer)
{
- do
- {
- try
- {
- if((ULONGLONG)llPosition+lLength > GetLength()) return E_FAIL; // strange, but the Seek below can return llPosition even if the file is not that big (?)
- if((ULONGLONG)llPosition != Seek(llPosition, begin)) return E_FAIL;
- if((UINT)lLength < Read(pBuffer, lLength)) return E_FAIL;
+ do {
+ try {
+ if((ULONGLONG)llPosition+lLength > GetLength()) {
+ return E_FAIL; // strange, but the Seek below can return llPosition even if the file is not that big (?)
+ }
+ if((ULONGLONG)llPosition != Seek(llPosition, begin)) {
+ return E_FAIL;
+ }
+ if((UINT)lLength < Read(pBuffer, lLength)) {
+ return E_FAIL;
+ }
#if 0 // def DEBUG
static __int64 s_total = 0, s_laststoppos = 0;
s_total += lLength;
- if(s_laststoppos > llPosition)
+ if(s_laststoppos > llPosition) {
TRACE(_T("[%I64d - %I64d] %d (%I64d)\n"), llPosition, llPosition + lLength, lLength, s_total);
+ }
s_laststoppos = llPosition + lLength;
#endif
return S_OK;
- }
- catch(CFileException* e)
- {
+ } catch(CFileException* e) {
m_lOsError = e->m_lOsError;
e->Delete();
Sleep(1);
CString fn = m_strFileName;
- try {Close();} catch(CFileException* e) {e->Delete();}
- try {Open(fn, modeRead|shareDenyNone|typeBinary|osSequentialScan);} catch(CFileException* e) {e->Delete();}
+ try {
+ Close();
+ } catch(CFileException* e) {
+ e->Delete();
+ }
+ try {
+ Open(fn, modeRead|shareDenyNone|typeBinary|osSequentialScan);
+ } catch(CFileException* e) {
+ e->Delete();
+ }
m_strFileName = fn;
}
- }
- while(m_hBreakEvent && WaitForSingleObject(m_hBreakEvent, 0) == WAIT_TIMEOUT);
+ } while(m_hBreakEvent && WaitForSingleObject(m_hBreakEvent, 0) == WAIT_TIMEOUT);
return E_FAIL;
}
@@ -101,8 +115,12 @@ STDMETHODIMP CAsyncFileReader::SyncRead(LONGLONG llPosition, LONG lLength, BYTE*
STDMETHODIMP CAsyncFileReader::Length(LONGLONG* pTotal, LONGLONG* pAvailable)
{
LONGLONG len = m_len >= 0 ? m_len : GetLength();
- if(pTotal) *pTotal = len;
- if(pAvailable) *pAvailable = len;
+ if(pTotal) {
+ *pTotal = len;
+ }
+ if(pAvailable) {
+ *pAvailable = len;
+ }
return S_OK;
}
@@ -122,15 +140,18 @@ STDMETHODIMP_(LPCTSTR) CAsyncFileReader::GetFileName()
// CAsyncUrlReader
//
-CAsyncUrlReader::CAsyncUrlReader(CString url, HRESULT& hr)
+CAsyncUrlReader::CAsyncUrlReader(CString url, HRESULT& hr)
: CAsyncFileReader(url, hr)
{
- if(SUCCEEDED(hr)) return;
+ if(SUCCEEDED(hr)) {
+ return;
+ }
m_url = url;
- if(CAMThread::Create())
+ if(CAMThread::Create()) {
CallWorker(CMD_INIT);
+ }
hr = Open(m_fn, modeRead|shareDenyRead|typeBinary|osSequentialScan) ? S_OK : E_FAIL;
m_len = (ULONGLONG)-1; // force GetLength() return actual length always
@@ -138,11 +159,11 @@ CAsyncUrlReader::CAsyncUrlReader(CString url, HRESULT& hr)
CAsyncUrlReader::~CAsyncUrlReader()
{
- if(ThreadExists())
+ if(ThreadExists()) {
CallWorker(CMD_EXIT);
+ }
- if(!m_fn.IsEmpty())
- {
+ if(!m_fn.IsEmpty()) {
CMultiFiles::Close();
DeleteFile(m_fn);
}
@@ -152,7 +173,9 @@ CAsyncUrlReader::~CAsyncUrlReader()
STDMETHODIMP CAsyncUrlReader::Length(LONGLONG* pTotal, LONGLONG* pAvailable)
{
- if(pTotal) *pTotal = 0;
+ if(pTotal) {
+ *pTotal = 0;
+ }
return __super::Length(NULL, pAvailable);
}
@@ -163,41 +186,41 @@ DWORD CAsyncUrlReader::ThreadProc()
AfxSocketInit(NULL);
DWORD cmd = GetRequest();
- if(cmd != CMD_INIT) {Reply((DWORD)E_FAIL); return (DWORD)-1;}
+ if(cmd != CMD_INIT) {
+ Reply((DWORD)E_FAIL);
+ return (DWORD)-1;
+ }
- try
- {
+ try {
CInternetSession is;
CAutoPtr<CStdioFile> fin(is.OpenURL(m_url, 1, INTERNET_FLAG_TRANSFER_BINARY|INTERNET_FLAG_EXISTING_CONNECT|INTERNET_FLAG_NO_CACHE_WRITE));
TCHAR path[_MAX_PATH], fn[_MAX_PATH];
CFile fout;
if(GetTempPath(MAX_PATH, path) && GetTempFileName(path, _T("mpc_http"), 0, fn)
- && fout.Open(fn, modeCreate|modeWrite|shareDenyWrite|typeBinary))
- {
+ && fout.Open(fn, modeCreate|modeWrite|shareDenyWrite|typeBinary)) {
m_fn = fn;
char buff[1024];
int len = fin->Read(buff, sizeof(buff));
- if(len > 0) fout.Write(buff, len);
+ if(len > 0) {
+ fout.Write(buff, len);
+ }
Reply(S_OK);
- while(!CheckRequest(&cmd))
- {
+ while(!CheckRequest(&cmd)) {
int len = fin->Read(buff, sizeof(buff));
- if(len > 0) fout.Write(buff, len);
+ if(len > 0) {
+ fout.Write(buff, len);
+ }
}
- }
- else
- {
+ } else {
Reply((DWORD)E_FAIL);
}
fin->Close(); // must close it because the destructor doesn't seem to do it and we will get an exception when "is" is destroying
- }
- catch(CInternetException* ie)
- {
+ } catch(CInternetException* ie) {
ie->Delete();
Reply((DWORD)E_FAIL);
}
diff --git a/src/filters/parser/BaseSplitter/AsyncReader.h b/src/filters/parser/BaseSplitter/AsyncReader.h
index 64c4e9113..f649ac102 100644
--- a/src/filters/parser/BaseSplitter/AsyncReader.h
+++ b/src/filters/parser/BaseSplitter/AsyncReader.h
@@ -1,4 +1,4 @@
-/*
+/*
* Copyright (C) 2003-2006 Gabest
* http://www.gabest.org
*
@@ -6,12 +6,12 @@
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2, or (at your option)
* any later version.
- *
+ *
* This Program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
- *
+ *
* You should have received a copy of the GNU General Public License
* along with GNU Make; see the file COPYING. If not, write to
* the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
@@ -24,8 +24,8 @@
#include "MultiFiles.h"
interface __declspec(uuid("6DDB4EE7-45A0-4459-A508-BD77B32C91B2"))
-ISyncReader : public IUnknown
-{
+ISyncReader :
+public IUnknown {
STDMETHOD_(void, SetBreakEvent) (HANDLE hBreakEvent) = 0;
STDMETHOD_(bool, HasErrors) () = 0;
STDMETHOD_(void, ClearErrors) () = 0;
@@ -33,8 +33,8 @@ ISyncReader : public IUnknown
};
interface __declspec(uuid("7D55F67A-826E-40B9-8A7D-3DF0CBBD272D"))
-IFileHandle : public IUnknown
-{
+IFileHandle :
+public IUnknown {
STDMETHOD_(HANDLE, GetFileHandle)() = 0;
STDMETHOD_(LPCTSTR, GetFileName)() = 0;
};
@@ -55,21 +55,41 @@ public:
// IAsyncReader
- STDMETHODIMP RequestAllocator(IMemAllocator* pPreferred, ALLOCATOR_PROPERTIES* pProps, IMemAllocator** ppActual) {return E_NOTIMPL;}
- STDMETHODIMP Request(IMediaSample* pSample, DWORD_PTR dwUser) {return E_NOTIMPL;}
- STDMETHODIMP WaitForNext(DWORD dwTimeout, IMediaSample** ppSample, DWORD_PTR* pdwUser) {return E_NOTIMPL;}
- STDMETHODIMP SyncReadAligned(IMediaSample* pSample) {return E_NOTIMPL;}
+ STDMETHODIMP RequestAllocator(IMemAllocator* pPreferred, ALLOCATOR_PROPERTIES* pProps, IMemAllocator** ppActual) {
+ return E_NOTIMPL;
+ }
+ STDMETHODIMP Request(IMediaSample* pSample, DWORD_PTR dwUser) {
+ return E_NOTIMPL;
+ }
+ STDMETHODIMP WaitForNext(DWORD dwTimeout, IMediaSample** ppSample, DWORD_PTR* pdwUser) {
+ return E_NOTIMPL;
+ }
+ STDMETHODIMP SyncReadAligned(IMediaSample* pSample) {
+ return E_NOTIMPL;
+ }
STDMETHODIMP SyncRead(LONGLONG llPosition, LONG lLength, BYTE* pBuffer);
STDMETHODIMP Length(LONGLONG* pTotal, LONGLONG* pAvailable);
- STDMETHODIMP BeginFlush() {return E_NOTIMPL;}
- STDMETHODIMP EndFlush() {return E_NOTIMPL;}
+ STDMETHODIMP BeginFlush() {
+ return E_NOTIMPL;
+ }
+ STDMETHODIMP EndFlush() {
+ return E_NOTIMPL;
+ }
// ISyncReader
- STDMETHODIMP_(void) SetBreakEvent(HANDLE hBreakEvent) {m_hBreakEvent = hBreakEvent;}
- STDMETHODIMP_(bool) HasErrors() {return m_lOsError != 0;}
- STDMETHODIMP_(void) ClearErrors() {m_lOsError = 0;}
- STDMETHODIMP_(void) SetPTSOffset (REFERENCE_TIME* rtPTSOffset) { m_pCurrentPTSOffset = rtPTSOffset;};
+ STDMETHODIMP_(void) SetBreakEvent(HANDLE hBreakEvent) {
+ m_hBreakEvent = hBreakEvent;
+ }
+ STDMETHODIMP_(bool) HasErrors() {
+ return m_lOsError != 0;
+ }
+ STDMETHODIMP_(void) ClearErrors() {
+ m_lOsError = 0;
+ }
+ STDMETHODIMP_(void) SetPTSOffset (REFERENCE_TIME* rtPTSOffset) {
+ m_pCurrentPTSOffset = rtPTSOffset;
+ };
// IFileHandle
@@ -84,7 +104,7 @@ class CAsyncUrlReader : public CAsyncFileReader, protected CAMThread
protected:
enum {CMD_EXIT, CMD_INIT};
- DWORD ThreadProc();
+ DWORD ThreadProc();
public:
CAsyncUrlReader(CString url, HRESULT& hr);
diff --git a/src/filters/parser/BaseSplitter/BaseSplitter.cpp b/src/filters/parser/BaseSplitter/BaseSplitter.cpp
index 173442b29..c23a2cd8a 100644
--- a/src/filters/parser/BaseSplitter/BaseSplitter.cpp
+++ b/src/filters/parser/BaseSplitter/BaseSplitter.cpp
@@ -1,4 +1,4 @@
-/*
+/*
* Copyright (C) 2003-2006 Gabest
* http://www.gabest.org
*
@@ -6,12 +6,12 @@
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2, or (at your option)
* any later version.
- *
+ *
* This Program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
- *
+ *
* You should have received a copy of the GNU General Public License
* along with GNU Make; see the file COPYING. If not, write to
* the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
@@ -45,15 +45,13 @@ void CPacketQueue::Add(CAutoPtr<Packet> p)
{
CAutoLock cAutoLock(this);
- if(p)
- {
+ if(p) {
m_size += p->GetDataSize();
if(p->bAppendable && !p->bDiscontinuity && !p->pmt
- && p->rtStart == Packet::INVALID_TIME
- && !IsEmpty() && GetTail()->rtStart != Packet::INVALID_TIME)
- {
- Packet* tail = GetTail();
+ && p->rtStart == Packet::INVALID_TIME
+ && !IsEmpty() && GetTail()->rtStart != Packet::INVALID_TIME) {
+ Packet* tail = GetTail();
int oldsize = tail->GetCount();
int newsize = tail->GetCount() + p->GetCount();
tail->SetCount(newsize, max(1024, newsize)); // doubles the reserved buffer size
@@ -73,7 +71,9 @@ CAutoPtr<Packet> CPacketQueue::Remove()
CAutoLock cAutoLock(this);
ASSERT(__super::GetCount() > 0);
CAutoPtr<Packet> p = RemoveHead();
- if(p) m_size -= p->GetDataSize();
+ if(p) {
+ m_size -= p->GetDataSize();
+ }
return p;
}
@@ -86,13 +86,13 @@ void CPacketQueue::RemoveAll()
int CPacketQueue::GetCount()
{
- CAutoLock cAutoLock(this);
+ CAutoLock cAutoLock(this);
return __super::GetCount();
}
int CPacketQueue::GetSize()
{
- CAutoLock cAutoLock(this);
+ CAutoLock cAutoLock(this);
return m_size;
}
@@ -122,25 +122,26 @@ STDMETHODIMP CBaseSplitterInputPin::NonDelegatingQueryInterface(REFIID riid, voi
{
CheckPointer(ppv, E_POINTER);
- return
+ return
__super::NonDelegatingQueryInterface(riid, ppv);
}
HRESULT CBaseSplitterInputPin::CheckMediaType(const CMediaType* pmt)
{
return S_OK;
-/*
- return pmt->majortype == MEDIATYPE_Stream
- ? S_OK
- : E_INVALIDARG;
-*/
+ /*
+ return pmt->majortype == MEDIATYPE_Stream
+ ? S_OK
+ : E_INVALIDARG;
+ */
}
HRESULT CBaseSplitterInputPin::CheckConnect(IPin* pPin)
{
HRESULT hr;
- if(FAILED(hr = __super::CheckConnect(pPin)))
+ if(FAILED(hr = __super::CheckConnect(pPin))) {
return hr;
+ }
return CComQIPtr<IAsyncReader>(pPin) ? S_OK : E_NOINTERFACE;
}
@@ -149,11 +150,13 @@ HRESULT CBaseSplitterInputPin::BreakConnect()
{
HRESULT hr;
- if(FAILED(hr = __super::BreakConnect()))
+ if(FAILED(hr = __super::BreakConnect())) {
return hr;
+ }
- if(FAILED(hr = (static_cast<CBaseSplitterFilter*>(m_pFilter))->BreakConnect(PINDIR_INPUT, this)))
+ if(FAILED(hr = (static_cast<CBaseSplitterFilter*>(m_pFilter))->BreakConnect(PINDIR_INPUT, this))) {
return hr;
+ }
m_pAsyncReader.Release();
@@ -164,15 +167,17 @@ HRESULT CBaseSplitterInputPin::CompleteConnect(IPin* pPin)
{
HRESULT hr;
- if(FAILED(hr = __super::CompleteConnect(pPin)))
+ if(FAILED(hr = __super::CompleteConnect(pPin))) {
return hr;
+ }
CheckPointer(pPin, E_POINTER);
m_pAsyncReader = pPin;
CheckPointer(m_pAsyncReader, E_NOINTERFACE);
- if(FAILED(hr = (static_cast<CBaseSplitterFilter*>(m_pFilter))->CompleteConnect(PINDIR_INPUT, this)))
+ if(FAILED(hr = (static_cast<CBaseSplitterFilter*>(m_pFilter))->CompleteConnect(PINDIR_INPUT, this))) {
return hr;
+ }
return S_OK;
}
@@ -222,8 +227,8 @@ STDMETHODIMP CBaseSplitterOutputPin::NonDelegatingQueryInterface(REFIID riid, vo
{
CheckPointer(ppv, E_POINTER);
- return
-// riid == __uuidof(IMediaSeeking) ? m_pFilter->QueryInterface(riid, ppv) :
+ return
+ // riid == __uuidof(IMediaSeeking) ? m_pFilter->QueryInterface(riid, ppv) :
QI(IMediaSeeking)
QI(IPropertyBag)
QI(IPropertyBag2)
@@ -235,7 +240,9 @@ STDMETHODIMP CBaseSplitterOutputPin::NonDelegatingQueryInterface(REFIID riid, vo
HRESULT CBaseSplitterOutputPin::SetName(LPCWSTR pName)
{
CheckPointer(pName, E_POINTER);
- if(m_pName) delete [] m_pName;
+ if(m_pName) {
+ delete [] m_pName;
+ }
m_pName = DNew WCHAR[wcslen(pName)+1];
CheckPointer(m_pName, E_OUTOFMEMORY);
wcscpy(m_pName, pName);
@@ -244,35 +251,38 @@ HRESULT CBaseSplitterOutputPin::SetName(LPCWSTR pName)
HRESULT CBaseSplitterOutputPin::DecideBufferSize(IMemAllocator* pAlloc, ALLOCATOR_PROPERTIES* pProperties)
{
- ASSERT(pAlloc);
- ASSERT(pProperties);
+ ASSERT(pAlloc);
+ ASSERT(pProperties);
- HRESULT hr = NOERROR;
+ HRESULT hr = NOERROR;
pProperties->cBuffers = m_nBuffers;
pProperties->cbBuffer = max(m_mt.lSampleSize, 1);
- if(m_mt.subtype == MEDIASUBTYPE_Vorbis && m_mt.formattype == FORMAT_VorbisFormat)
- {
+ if(m_mt.subtype == MEDIASUBTYPE_Vorbis && m_mt.formattype == FORMAT_VorbisFormat) {
// oh great, the oggds vorbis decoder assumes there will be two at least, stupid thing...
pProperties->cBuffers = max(pProperties->cBuffers, 2);
}
- ALLOCATOR_PROPERTIES Actual;
- if(FAILED(hr = pAlloc->SetProperties(pProperties, &Actual))) return hr;
+ ALLOCATOR_PROPERTIES Actual;
+ if(FAILED(hr = pAlloc->SetProperties(pProperties, &Actual))) {
+ return hr;
+ }
- if(Actual.cbBuffer < pProperties->cbBuffer) return E_FAIL;
- ASSERT(Actual.cBuffers == pProperties->cBuffers);
+ if(Actual.cbBuffer < pProperties->cbBuffer) {
+ return E_FAIL;
+ }
+ ASSERT(Actual.cBuffers == pProperties->cBuffers);
- return NOERROR;
+ return NOERROR;
}
HRESULT CBaseSplitterOutputPin::CheckMediaType(const CMediaType* pmt)
{
- for(int i = 0; i < m_mts.GetCount(); i++)
- {
- if(*pmt == m_mts[i])
+ for(int i = 0; i < m_mts.GetCount(); i++) {
+ if(*pmt == m_mts[i]) {
return S_OK;
+ }
}
return E_INVALIDARG;
@@ -280,10 +290,14 @@ HRESULT CBaseSplitterOutputPin::CheckMediaType(const CMediaType* pmt)
HRESULT CBaseSplitterOutputPin::GetMediaType(int iPosition, CMediaType* pmt)
{
- CAutoLock cAutoLock(m_pLock);
+ CAutoLock cAutoLock(m_pLock);
- if(iPosition < 0) return E_INVALIDARG;
- if(iPosition >= m_mts.GetCount()) return VFW_S_NO_MORE_ITEMS;
+ if(iPosition < 0) {
+ return E_INVALIDARG;
+ }
+ if(iPosition >= m_mts.GetCount()) {
+ return VFW_S_NO_MORE_ITEMS;
+ }
*pmt = m_mts[iPosition];
@@ -299,20 +313,22 @@ STDMETHODIMP CBaseSplitterOutputPin::Notify(IBaseFilter* pSender, Quality q)
HRESULT CBaseSplitterOutputPin::Active()
{
- CAutoLock cAutoLock(m_pLock);
+ CAutoLock cAutoLock(m_pLock);
- if(m_Connected)
+ if(m_Connected) {
Create();
+ }
return __super::Active();
}
HRESULT CBaseSplitterOutputPin::Inactive()
{
- CAutoLock cAutoLock(m_pLock);
+ CAutoLock cAutoLock(m_pLock);
- if(ThreadExists())
+ if(ThreadExists()) {
CallWorker(CMD_EXIT);
+ }
return __super::Inactive();
}
@@ -325,13 +341,17 @@ HRESULT CBaseSplitterOutputPin::DeliverBeginFlush()
m_hrDeliver = S_FALSE;
m_queue.RemoveAll();
HRESULT hr = IsConnected() ? GetConnected()->BeginFlush() : S_OK;
- if(S_OK != hr) m_eEndFlush.Set();
+ if(S_OK != hr) {
+ m_eEndFlush.Set();
+ }
return(hr);
}
HRESULT CBaseSplitterOutputPin::DeliverEndFlush()
{
- if(!ThreadExists()) return S_FALSE;
+ if(!ThreadExists()) {
+ return S_FALSE;
+ }
HRESULT hr = IsConnected() ? GetConnected()->EndFlush() : S_OK;
m_hrDeliver = S_OK;
m_fFlushing = false;
@@ -343,11 +363,17 @@ HRESULT CBaseSplitterOutputPin::DeliverEndFlush()
HRESULT CBaseSplitterOutputPin::DeliverNewSegment(REFERENCE_TIME tStart, REFERENCE_TIME tStop, double dRate)
{
m_brs.rtLastDeliverTime = Packet::INVALID_TIME;
- if(m_fFlushing) return S_FALSE;
+ if(m_fFlushing) {
+ return S_FALSE;
+ }
m_rtStart = tStart;
- if(!ThreadExists()) return S_FALSE;
+ if(!ThreadExists()) {
+ return S_FALSE;
+ }
HRESULT hr = __super::DeliverNewSegment(tStart, tStop, dRate);
- if(S_OK != hr) return hr;
+ if(S_OK != hr) {
+ return hr;
+ }
MakeISCRHappy();
return hr;
}
@@ -369,15 +395,19 @@ HRESULT CBaseSplitterOutputPin::QueueEndOfStream()
HRESULT CBaseSplitterOutputPin::QueuePacket(CAutoPtr<Packet> p)
{
- if(!ThreadExists()) return S_FALSE;
+ if(!ThreadExists()) {
+ return S_FALSE;
+ }
- while(S_OK == m_hrDeliver
- && (!(static_cast<CBaseSplitterFilter*>(m_pFilter))->IsAnyPinDrying()
- || m_queue.GetSize() > MAXPACKETSIZE*100))
+ while(S_OK == m_hrDeliver
+ && (!(static_cast<CBaseSplitterFilter*>(m_pFilter))->IsAnyPinDrying()
+ || m_queue.GetSize() > MAXPACKETSIZE*100)) {
Sleep(1);
+ }
- if(S_OK != m_hrDeliver)
+ if(S_OK != m_hrDeliver) {
return m_hrDeliver;
+ }
m_queue.Add(p);
@@ -387,25 +417,24 @@ HRESULT CBaseSplitterOutputPin::QueuePacket(CAutoPtr<Packet> p)
bool CBaseSplitterOutputPin::IsDiscontinuous()
{
return m_mt.majortype == MEDIATYPE_Text
- || m_mt.majortype == MEDIATYPE_ScriptCommand
- || m_mt.majortype == MEDIATYPE_Subtitle
- || m_mt.subtype == MEDIASUBTYPE_DVD_SUBPICTURE
- || m_mt.subtype == MEDIASUBTYPE_CVD_SUBPICTURE
- || m_mt.subtype == MEDIASUBTYPE_SVCD_SUBPICTURE;
+ || m_mt.majortype == MEDIATYPE_ScriptCommand
+ || m_mt.majortype == MEDIATYPE_Subtitle
+ || m_mt.subtype == MEDIASUBTYPE_DVD_SUBPICTURE
+ || m_mt.subtype == MEDIASUBTYPE_CVD_SUBPICTURE
+ || m_mt.subtype == MEDIASUBTYPE_SVCD_SUBPICTURE;
}
bool CBaseSplitterOutputPin::IsActive()
{
CComPtr<IPin> pPin = this;
- do
- {
+ do {
CComPtr<IPin> pPinTo;
CComQIPtr<IStreamSwitcherInputPin> pSSIP;
- if(S_OK == pPin->ConnectedTo(&pPinTo) && (pSSIP = pPinTo) && !pSSIP->IsActive())
+ if(S_OK == pPin->ConnectedTo(&pPinTo) && (pSSIP = pPinTo) && !pSSIP->IsActive()) {
return(false);
+ }
pPin = GetFirstPin(GetFilterFromPin(pPinTo), PINDIR_OUTPUT);
- }
- while(pPin);
+ } while(pPin);
return(true);
}
@@ -417,13 +446,11 @@ DWORD CBaseSplitterOutputPin::ThreadProc()
m_fFlushing = m_fFlushed = false;
m_eEndFlush.Set();
- while(1)
- {
+ while(1) {
Sleep(1);
DWORD cmd;
- if(CheckRequest(&cmd))
- {
+ if(CheckRequest(&cmd)) {
m_hThread = NULL;
cmd = GetRequest();
Reply(S_OK);
@@ -432,39 +459,36 @@ DWORD CBaseSplitterOutputPin::ThreadProc()
}
int cnt = 0;
- do
- {
+ do {
CAutoPtr<Packet> p;
{
CAutoLock cAutoLock(&m_queue);
- if((cnt = m_queue.GetCount()) > 0)
+ if((cnt = m_queue.GetCount()) > 0) {
p = m_queue.Remove();
+ }
}
- if(S_OK == m_hrDeliver && cnt > 0)
- {
+ if(S_OK == m_hrDeliver && cnt > 0) {
ASSERT(!m_fFlushing);
m_fFlushed = false;
// flushing can still start here, to release a blocked deliver call
- HRESULT hr = p
- ? DeliverPacket(p)
- : DeliverEndOfStream();
+ HRESULT hr = p
+ ? DeliverPacket(p)
+ : DeliverEndOfStream();
m_eEndFlush.Wait(); // .. so we have to wait until it is done
- if(hr != S_OK && !m_fFlushed) // and only report the error in m_hrDeliver if we didn't flush the stream
- {
+ if(hr != S_OK && !m_fFlushed) { // and only report the error in m_hrDeliver if we didn't flush the stream
// CAutoLock cAutoLock(&m_csQueueLock);
m_hrDeliver = hr;
break;
}
}
- }
- while(--cnt > 0);
+ } while(--cnt > 0);
}
}
@@ -474,23 +498,19 @@ HRESULT CBaseSplitterOutputPin::DeliverPacket(CAutoPtr<Packet> p)
INT_PTR nBytes = p->GetCount();
- if(nBytes == 0)
- {
+ if(nBytes == 0) {
return S_OK;
}
m_brs.nBytesSinceLastDeliverTime += nBytes;
- if(p->rtStart != Packet::INVALID_TIME)
- {
- if(m_brs.rtLastDeliverTime == Packet::INVALID_TIME)
- {
+ if(p->rtStart != Packet::INVALID_TIME) {
+ if(m_brs.rtLastDeliverTime == Packet::INVALID_TIME) {
m_brs.rtLastDeliverTime = p->rtStart;
m_brs.nBytesSinceLastDeliverTime = 0;
}
- if(m_brs.rtLastDeliverTime + 10000000 < p->rtStart)
- {
+ if(m_brs.rtLastDeliverTime + 10000000 < p->rtStart) {
REFERENCE_TIME rtDiff = p->rtStart - m_brs.rtLastDeliverTime;
double secs, bits;
@@ -508,80 +528,106 @@ HRESULT CBaseSplitterOutputPin::DeliverPacket(CAutoPtr<Packet> p)
m_brs.rtLastDeliverTime = p->rtStart;
m_brs.nBytesSinceLastDeliverTime = 0;
-/*
- TRACE(_T("[%d] c: %d kbps, a: %d kbps\n"),
- p->TrackNumber,
- (m_brs.nCurrentBitRate+500)/1000,
- (m_brs.nAverageBitRate+500)/1000);
-*/
+ /*
+ TRACE(_T("[%d] c: %d kbps, a: %d kbps\n"),
+ p->TrackNumber,
+ (m_brs.nCurrentBitRate+500)/1000,
+ (m_brs.nAverageBitRate+500)/1000);
+ */
}
double dRate = 1.0;
- if(SUCCEEDED((static_cast<CBaseSplitterFilter*>(m_pFilter))->GetRate(&dRate)))
- {
+ if(SUCCEEDED((static_cast<CBaseSplitterFilter*>(m_pFilter))->GetRate(&dRate))) {
p->rtStart = (REFERENCE_TIME)((double)p->rtStart / dRate);
p->rtStop = (REFERENCE_TIME)((double)p->rtStop / dRate);
}
}
- do
- {
+ do {
CComPtr<IMediaSample> pSample;
- if(S_OK != (hr = GetDeliveryBuffer(&pSample, NULL, NULL, 0))) break;
+ if(S_OK != (hr = GetDeliveryBuffer(&pSample, NULL, NULL, 0))) {
+ break;
+ }
- if(nBytes > pSample->GetSize())
- {
+ if(nBytes > pSample->GetSize()) {
pSample.Release();
ALLOCATOR_PROPERTIES props, actual;
- if(S_OK != (hr = m_pAllocator->GetProperties(&props))) break;
+ if(S_OK != (hr = m_pAllocator->GetProperties(&props))) {
+ break;
+ }
props.cbBuffer = nBytes*3/2;
- if(props.cBuffers > 1)
- {
- if(S_OK != (hr = __super::DeliverBeginFlush())) break;
- if(S_OK != (hr = __super::DeliverEndFlush())) break;
+ if(props.cBuffers > 1) {
+ if(S_OK != (hr = __super::DeliverBeginFlush())) {
+ break;
+ }
+ if(S_OK != (hr = __super::DeliverEndFlush())) {
+ break;
+ }
}
- if(S_OK != (hr = m_pAllocator->Decommit())) break;
- if(S_OK != (hr = m_pAllocator->SetProperties(&props, &actual))) break;
- if(S_OK != (hr = m_pAllocator->Commit())) break;
- if(S_OK != (hr = GetDeliveryBuffer(&pSample, NULL, NULL, 0))) break;
+ if(S_OK != (hr = m_pAllocator->Decommit())) {
+ break;
+ }
+ if(S_OK != (hr = m_pAllocator->SetProperties(&props, &actual))) {
+ break;
+ }
+ if(S_OK != (hr = m_pAllocator->Commit())) {
+ break;
+ }
+ if(S_OK != (hr = GetDeliveryBuffer(&pSample, NULL, NULL, 0))) {
+ break;
+ }
}
- if(p->pmt)
- {
+ if(p->pmt) {
pSample->SetMediaType(p->pmt);
p->bDiscontinuity = true;
- CAutoLock cAutoLock(m_pLock);
+ CAutoLock cAutoLock(m_pLock);
m_mts.RemoveAll();
m_mts.Add(*p->pmt);
}
bool fTimeValid = p->rtStart != Packet::INVALID_TIME;
-/*
-//if(p->TrackNumber == 1)
-//if(p->rtStart != Packet::INVALID_TIME)
-TRACE(_T("[%d]: d%d s%d p%d, b=%d, %I64d-%I64d \n"),
- p->TrackNumber,
- p->bDiscontinuity, p->bSyncPoint, fTimeValid && p->rtStart < 0,
- nBytes, p->rtStart, p->rtStop);
-*/
+ /*
+ //if(p->TrackNumber == 1)
+ //if(p->rtStart != Packet::INVALID_TIME)
+ TRACE(_T("[%d]: d%d s%d p%d, b=%d, %I64d-%I64d \n"),
+ p->TrackNumber,
+ p->bDiscontinuity, p->bSyncPoint, fTimeValid && p->rtStart < 0,
+ nBytes, p->rtStart, p->rtStop);
+ */
ASSERT(!p->bSyncPoint || fTimeValid);
BYTE* pData = NULL;
- if(S_OK != (hr = pSample->GetPointer(&pData)) || !pData) break;
+ if(S_OK != (hr = pSample->GetPointer(&pData)) || !pData) {
+ break;
+ }
memcpy(pData, p->GetData(), nBytes);
- if(S_OK != (hr = pSample->SetActualDataLength(nBytes))) break;
- if(S_OK != (hr = pSample->SetTime(fTimeValid ? &p->rtStart : NULL, fTimeValid ? &p->rtStop : NULL))) break;
- if(S_OK != (hr = pSample->SetMediaTime(NULL, NULL))) break;
- if(S_OK != (hr = pSample->SetDiscontinuity(p->bDiscontinuity))) break;
- if(S_OK != (hr = pSample->SetSyncPoint(p->bSyncPoint))) break;
- if(S_OK != (hr = pSample->SetPreroll(fTimeValid && p->rtStart < 0))) break;
- if(S_OK != (hr = Deliver(pSample))) break;
- }
- while(false);
+ if(S_OK != (hr = pSample->SetActualDataLength(nBytes))) {
+ break;
+ }
+ if(S_OK != (hr = pSample->SetTime(fTimeValid ? &p->rtStart : NULL, fTimeValid ? &p->rtStop : NULL))) {
+ break;
+ }
+ if(S_OK != (hr = pSample->SetMediaTime(NULL, NULL))) {
+ break;
+ }
+ if(S_OK != (hr = pSample->SetDiscontinuity(p->bDiscontinuity))) {
+ break;
+ }
+ if(S_OK != (hr = pSample->SetSyncPoint(p->bSyncPoint))) {
+ break;
+ }
+ if(S_OK != (hr = pSample->SetPreroll(fTimeValid && p->rtStart < 0))) {
+ break;
+ }
+ if(S_OK != (hr = Deliver(pSample))) {
+ break;
+ }
+ } while(false);
return hr;
}
@@ -589,17 +635,16 @@ TRACE(_T("[%d]: d%d s%d p%d, b=%d, %I64d-%I64d \n"),
void CBaseSplitterOutputPin::MakeISCRHappy()
{
CComPtr<IPin> pPinTo = this, pTmp;
- while(pPinTo && SUCCEEDED(pPinTo->ConnectedTo(&pTmp)) && (pPinTo = pTmp))
- {
+ while(pPinTo && SUCCEEDED(pPinTo->ConnectedTo(&pTmp)) && (pPinTo = pTmp)) {
pTmp = NULL;
CComPtr<IBaseFilter> pBF = GetFilterFromPin(pPinTo);
- if(GetCLSID(pBF) == GUIDFromCString(_T("{48025243-2D39-11CE-875D-00608CB78066}"))) // ISCR
- {
+ if(GetCLSID(pBF) == GUIDFromCString(_T("{48025243-2D39-11CE-875D-00608CB78066}"))) { // ISCR
CAutoPtr<Packet> p(DNew Packet());
p->TrackNumber = (DWORD)-1;
- p->rtStart = -1; p->rtStop = 0;
+ p->rtStart = -1;
+ p->rtStop = 0;
p->bSyncPoint = FALSE;
p->SetData(" ", 2);
QueuePacket(p);
@@ -705,7 +750,9 @@ CBaseSplitterFilter::CBaseSplitterFilter(LPCTSTR pName, LPUNKNOWN pUnk, HRESULT*
, m_rtLastStop(_I64_MIN)
, m_priority(THREAD_PRIORITY_NORMAL)
{
- if(phr) *phr = S_OK;
+ if(phr) {
+ *phr = S_OK;
+ }
m_pInput.Attach(DNew CBaseSplitterInputPin(NAME("CBaseSplitterInputPin"), this, this, phr));
}
@@ -724,10 +771,11 @@ STDMETHODIMP CBaseSplitterFilter::NonDelegatingQueryInterface(REFIID riid, void*
*ppv = NULL;
- if(m_pInput && riid == __uuidof(IFileSourceFilter))
+ if(m_pInput && riid == __uuidof(IFileSourceFilter)) {
return E_NOINTERFACE;
+ }
- return
+ return
QI(IFileSourceFilter)
QI(IMediaSeeking)
QI(IAMOpenProgress)
@@ -747,7 +795,7 @@ CBaseSplitterOutputPin* CBaseSplitterFilter::GetOutputPin(DWORD TrackNum)
{
CAutoLock cAutoLock(&m_csPinMap);
- CBaseSplitterOutputPin* pPin = NULL;
+ CBaseSplitterOutputPin* pPin = NULL;
m_pPinMap.Lookup(TrackNum, pPin);
return pPin;
}
@@ -757,12 +805,13 @@ DWORD CBaseSplitterFilter::GetOutputTrackNum(CBaseSplitterOutputPin* pPin)
CAutoLock cAutoLock(&m_csPinMap);
POSITION pos = m_pPinMap.GetStartPosition();
- while(pos)
- {
+ while(pos) {
DWORD TrackNum;
CBaseSplitterOutputPin* pPinTmp;
m_pPinMap.GetNextAssoc(pos, TrackNum, pPinTmp);
- if(pPinTmp == pPin) return TrackNum;
+ if(pPinTmp == pPin) {
+ return TrackNum;
+ }
}
return (DWORD)-1;
@@ -773,19 +822,17 @@ HRESULT CBaseSplitterFilter::RenameOutputPin(DWORD TrackNumSrc, DWORD TrackNumDs
CAutoLock cAutoLock(&m_csPinMap);
CBaseSplitterOutputPin* pPin;
- if(m_pPinMap.Lookup(TrackNumSrc, pPin))
- {
- if(CComQIPtr<IPin> pPinTo = pPin->GetConnected())
- {
- if(pmt && S_OK != pPinTo->QueryAccept(pmt))
+ if(m_pPinMap.Lookup(TrackNumSrc, pPin)) {
+ if(CComQIPtr<IPin> pPinTo = pPin->GetConnected()) {
+ if(pmt && S_OK != pPinTo->QueryAccept(pmt)) {
return VFW_E_TYPE_NOT_ACCEPTED;
+ }
}
m_pPinMap.RemoveKey(TrackNumSrc);
m_pPinMap[TrackNumDst] = pPin;
- if(pmt)
- {
+ if(pmt) {
CAutoLock cAutoLock(&m_csmtnew);
m_mtnew[TrackNumDst] = *pmt;
}
@@ -800,7 +847,9 @@ HRESULT CBaseSplitterFilter::AddOutputPin(DWORD TrackNum, CAutoPtr<CBaseSplitter
{
CAutoLock cAutoLock(&m_csPinMap);
- if(!pPin) return E_INVALIDARG;
+ if(!pPin) {
+ return E_INVALIDARG;
+ }
m_pPinMap[TrackNum] = pPin;
m_pOutputs.AddTail(pPin);
return S_OK;
@@ -813,12 +862,15 @@ HRESULT CBaseSplitterFilter::DeleteOutputs()
m_pRetiredOutputs.RemoveAll();
CAutoLock cAutoLockF(this);
- if(m_State != State_Stopped) return VFW_E_NOT_STOPPED;
+ if(m_State != State_Stopped) {
+ return VFW_E_NOT_STOPPED;
+ }
- while(m_pOutputs.GetCount())
- {
+ while(m_pOutputs.GetCount()) {
CAutoPtr<CBaseSplitterOutputPin> pPin = m_pOutputs.RemoveHead();
- if(IPin* pPinTo = pPin->GetConnected()) pPinTo->Disconnect();
+ if(IPin* pPinTo = pPin->GetConnected()) {
+ pPinTo->Disconnect();
+ }
pPin->Disconnect();
// we can't just let it be deleted now, something might have AddRefed on it (graphedit...)
m_pRetiredOutputs.AddTail(pPin);
@@ -845,40 +897,45 @@ void CBaseSplitterFilter::DeliverBeginFlush()
{
m_fFlushing = true;
POSITION pos = m_pOutputs.GetHeadPosition();
- while(pos) m_pOutputs.GetNext(pos)->DeliverBeginFlush();
+ while(pos) {
+ m_pOutputs.GetNext(pos)->DeliverBeginFlush();
+ }
}
void CBaseSplitterFilter::DeliverEndFlush()
{
POSITION pos = m_pOutputs.GetHeadPosition();
- while(pos) m_pOutputs.GetNext(pos)->DeliverEndFlush();
+ while(pos) {
+ m_pOutputs.GetNext(pos)->DeliverEndFlush();
+ }
m_fFlushing = false;
m_eEndFlush.Set();
}
DWORD CBaseSplitterFilter::ThreadProc()
{
- if(m_pSyncReader)
+ if(m_pSyncReader) {
m_pSyncReader->SetBreakEvent(GetRequestHandle());
+ }
- if(!DemuxInit())
- {
- while(1)
- {
+ if(!DemuxInit()) {
+ while(1) {
DWORD cmd = GetRequest();
- if(cmd == CMD_EXIT) CAMThread::m_hThread = NULL;
+ if(cmd == CMD_EXIT) {
+ CAMThread::m_hThread = NULL;
+ }
Reply(S_OK);
- if(cmd == CMD_EXIT) return 0;
+ if(cmd == CMD_EXIT) {
+ return 0;
+ }
}
}
m_eEndFlush.Set();
m_fFlushing = false;
- for(DWORD cmd = (DWORD)-1; ; cmd = GetRequest())
- {
- if(cmd == CMD_EXIT)
- {
+ for(DWORD cmd = (DWORD)-1; ; cmd = GetRequest()) {
+ if(cmd == CMD_EXIT) {
m_hThread = NULL;
Reply(S_OK);
return 0;
@@ -891,30 +948,31 @@ DWORD CBaseSplitterFilter::ThreadProc()
DemuxSeek(m_rtStart);
- if(cmd != (DWORD)-1)
+ if(cmd != (DWORD)-1) {
Reply(S_OK);
+ }
m_eEndFlush.Wait();
m_pActivePins.RemoveAll();
POSITION pos = m_pOutputs.GetHeadPosition();
- while(pos && !m_fFlushing)
- {
+ while(pos && !m_fFlushing) {
CBaseSplitterOutputPin* pPin = m_pOutputs.GetNext(pos);
- if(pPin->IsConnected() && pPin->IsActive())
- {
+ if(pPin->IsConnected() && pPin->IsActive()) {
m_pActivePins.AddTail(pPin);
pPin->DeliverNewSegment(m_rtStart, m_rtStop, m_dRate);
}
}
- do {m_bDiscontinuitySent.RemoveAll();}
- while(!DemuxLoop());
+ do {
+ m_bDiscontinuitySent.RemoveAll();
+ } while(!DemuxLoop());
pos = m_pActivePins.GetHeadPosition();
- while(pos && !CheckRequest(&cmd))
+ while(pos && !CheckRequest(&cmd)) {
m_pActivePins.GetNext(pos)->QueueEndOfStream();
+ }
}
ASSERT(0); // we should only exit via CMD_EXIT
@@ -928,11 +986,11 @@ HRESULT CBaseSplitterFilter::DeliverPacket(CAutoPtr<Packet> p)
HRESULT hr = S_FALSE;
CBaseSplitterOutputPin* pPin = GetOutputPin(p->TrackNumber);
- if(!pPin || !pPin->IsConnected() || !m_pActivePins.Find(pPin))
+ if(!pPin || !pPin->IsConnected() || !m_pActivePins.Find(pPin)) {
return S_FALSE;
+ }
- if(p->rtStart != Packet::INVALID_TIME)
- {
+ if(p->rtStart != Packet::INVALID_TIME) {
m_rtCurrent = p->rtStart;
p->rtStart -= m_rtStart;
@@ -945,42 +1003,44 @@ HRESULT CBaseSplitterFilter::DeliverPacket(CAutoPtr<Packet> p)
CAutoLock cAutoLock(&m_csmtnew);
CMediaType mt;
- if(m_mtnew.Lookup(p->TrackNumber, mt))
- {
+ if(m_mtnew.Lookup(p->TrackNumber, mt)) {
p->pmt = CreateMediaType(&mt);
m_mtnew.RemoveKey(p->TrackNumber);
}
}
- if(!m_bDiscontinuitySent.Find(p->TrackNumber))
+ if(!m_bDiscontinuitySent.Find(p->TrackNumber)) {
p->bDiscontinuity = TRUE;
+ }
DWORD TrackNumber = p->TrackNumber;
BOOL bDiscontinuity = p->bDiscontinuity;
-/*
-//if(p->TrackNumber == 1)
-//if(p->rtStart != Packet::INVALID_TIME)
-TRACE(_T("[%d]: d%d s%d p%d, b=%d, %I64d-%I64d \n"),
- p->TrackNumber,
- p->bDiscontinuity, p->bSyncPoint, p->rtStart != Packet::INVALID_TIME && p->rtStart < 0,
- p->GetCount(), p->rtStart, p->rtStop);
-*/
+ /*
+ //if(p->TrackNumber == 1)
+ //if(p->rtStart != Packet::INVALID_TIME)
+ TRACE(_T("[%d]: d%d s%d p%d, b=%d, %I64d-%I64d \n"),
+ p->TrackNumber,
+ p->bDiscontinuity, p->bSyncPoint, p->rtStart != Packet::INVALID_TIME && p->rtStart < 0,
+ p->GetCount(), p->rtStart, p->rtStop);
+ */
hr = pPin->QueuePacket(p);
- if(S_OK != hr)
- {
- if(POSITION pos = m_pActivePins.Find(pPin))
+ if(S_OK != hr) {
+ if(POSITION pos = m_pActivePins.Find(pPin)) {
m_pActivePins.RemoveAt(pos);
+ }
- if(!m_pActivePins.IsEmpty()) // only die when all pins are down
+ if(!m_pActivePins.IsEmpty()) { // only die when all pins are down
hr = S_OK;
+ }
return hr;
}
- if(bDiscontinuity)
+ if(bDiscontinuity) {
m_bDiscontinuitySent.AddTail(TrackNumber);
+ }
return hr;
}
@@ -990,19 +1050,18 @@ bool CBaseSplitterFilter::IsAnyPinDrying()
int totalcount = 0, totalsize = 0;
POSITION pos = m_pActivePins.GetHeadPosition();
- while(pos)
- {
+ while(pos) {
CBaseSplitterOutputPin* pPin = m_pActivePins.GetNext(pos);
int count = pPin->QueueCount();
int size = pPin->QueueSize();
- if(!pPin->IsDiscontinuous() && (count < MINPACKETS || size < MINPACKETSIZE))
- {
-// if(m_priority != THREAD_PRIORITY_ABOVE_NORMAL && (count < MINPACKETS/3 || size < MINPACKETSIZE/3))
- if(m_priority != THREAD_PRIORITY_BELOW_NORMAL && (count < MINPACKETS/3 || size < MINPACKETSIZE/3))
- {
+ if(!pPin->IsDiscontinuous() && (count < MINPACKETS || size < MINPACKETSIZE)) {
+ // if(m_priority != THREAD_PRIORITY_ABOVE_NORMAL && (count < MINPACKETS/3 || size < MINPACKETSIZE/3))
+ if(m_priority != THREAD_PRIORITY_BELOW_NORMAL && (count < MINPACKETS/3 || size < MINPACKETSIZE/3)) {
// SetThreadPriority(m_hThread, m_priority = THREAD_PRIORITY_ABOVE_NORMAL);
POSITION pos = m_pOutputs.GetHeadPosition();
- while(pos) m_pOutputs.GetNext(pos)->SetThreadPriority(THREAD_PRIORITY_BELOW_NORMAL);
+ while(pos) {
+ m_pOutputs.GetNext(pos)->SetThreadPriority(THREAD_PRIORITY_BELOW_NORMAL);
+ }
m_priority = THREAD_PRIORITY_BELOW_NORMAL;
}
return(true);
@@ -1011,16 +1070,18 @@ bool CBaseSplitterFilter::IsAnyPinDrying()
totalsize += size;
}
- if(m_priority != THREAD_PRIORITY_NORMAL && (totalcount > MAXPACKETS*2/3 || totalsize > MAXPACKETSIZE*2/3))
- {
-// SetThreadPriority(m_hThread, m_priority = THREAD_PRIORITY_NORMAL);
+ if(m_priority != THREAD_PRIORITY_NORMAL && (totalcount > MAXPACKETS*2/3 || totalsize > MAXPACKETSIZE*2/3)) {
+ // SetThreadPriority(m_hThread, m_priority = THREAD_PRIORITY_NORMAL);
POSITION pos = m_pOutputs.GetHeadPosition();
- while(pos) m_pOutputs.GetNext(pos)->SetThreadPriority(THREAD_PRIORITY_NORMAL);
+ while(pos) {
+ m_pOutputs.GetNext(pos)->SetThreadPriority(THREAD_PRIORITY_NORMAL);
+ }
m_priority = THREAD_PRIORITY_NORMAL;
}
- if(totalcount < MAXPACKETS && totalsize < MAXPACKETSIZE)
+ if(totalcount < MAXPACKETS && totalsize < MAXPACKETSIZE) {
return(true);
+ }
return(false);
}
@@ -1029,15 +1090,10 @@ HRESULT CBaseSplitterFilter::BreakConnect(PIN_DIRECTION dir, CBasePin* pPin)
{
CheckPointer(pPin, E_POINTER);
- if(dir == PINDIR_INPUT)
- {
+ if(dir == PINDIR_INPUT) {
DeleteOutputs();
- }
- else if(dir == PINDIR_OUTPUT)
- {
- }
- else
- {
+ } else if(dir == PINDIR_OUTPUT) {
+ } else {
return E_UNEXPECTED;
}
@@ -1048,28 +1104,24 @@ HRESULT CBaseSplitterFilter::CompleteConnect(PIN_DIRECTION dir, CBasePin* pPin)
{
CheckPointer(pPin, E_POINTER);
- if(dir == PINDIR_INPUT)
- {
+ if(dir == PINDIR_INPUT) {
CBaseSplitterInputPin* pIn = static_cast<CBaseSplitterInputPin*>(pPin);
HRESULT hr;
CComPtr<IAsyncReader> pAsyncReader;
if(FAILED(hr = pIn->GetAsyncReader(&pAsyncReader))
- || FAILED(hr = DeleteOutputs())
- || FAILED(hr = CreateOutputs(pAsyncReader)))
+ || FAILED(hr = DeleteOutputs())
+ || FAILED(hr = CreateOutputs(pAsyncReader))) {
return hr;
+ }
ChapSort();
m_pSyncReader = pAsyncReader;
- }
- else if(dir == PINDIR_OUTPUT)
- {
+ } else if(dir == PINDIR_OUTPUT) {
m_pRetiredOutputs.RemoveAll();
- }
- else
- {
+ } else {
return E_UNEXPECTED;
}
@@ -1083,16 +1135,15 @@ int CBaseSplitterFilter::GetPinCount()
CBasePin* CBaseSplitterFilter::GetPin(int n)
{
- CAutoLock cAutoLock(this);
+ CAutoLock cAutoLock(this);
- if(n >= 0 && n < (int)m_pOutputs.GetCount())
- {
- if(POSITION pos = m_pOutputs.FindIndex(n))
+ if(n >= 0 && n < (int)m_pOutputs.GetCount()) {
+ if(POSITION pos = m_pOutputs.FindIndex(n)) {
return m_pOutputs.GetAt(pos);
+ }
}
- if(n == (int)m_pOutputs.GetCount() && m_pInput)
- {
+ if(n == (int)m_pOutputs.GetCount() && m_pInput) {
return m_pInput;
}
@@ -1108,8 +1159,9 @@ STDMETHODIMP CBaseSplitterFilter::Stop()
DeliverEndFlush();
HRESULT hr;
- if(FAILED(hr = __super::Stop()))
+ if(FAILED(hr = __super::Stop())) {
return hr;
+ }
return S_OK;
}
@@ -1121,11 +1173,11 @@ STDMETHODIMP CBaseSplitterFilter::Pause()
FILTER_STATE fs = m_State;
HRESULT hr;
- if(FAILED(hr = __super::Pause()))
+ if(FAILED(hr = __super::Pause())) {
return hr;
+ }
- if(fs == State_Stopped)
- {
+ if(fs == State_Stopped) {
Create();
}
@@ -1137,8 +1189,9 @@ STDMETHODIMP CBaseSplitterFilter::Run(REFERENCE_TIME tStart)
CAutoLock cAutoLock(this);
HRESULT hr;
- if(FAILED(hr = __super::Run(tStart)))
+ if(FAILED(hr = __super::Run(tStart))) {
return hr;
+ }
return S_OK;
}
@@ -1153,14 +1206,14 @@ STDMETHODIMP CBaseSplitterFilter::Load(LPCOLESTR pszFileName, const AM_MEDIA_TYP
HRESULT hr = E_FAIL;
CComPtr<IAsyncReader> pAsyncReader;
CAtlList<CHdmvClipInfo::PlaylistItem> Items;
- if (BuildPlaylist (pszFileName, Items))
+ if (BuildPlaylist (pszFileName, Items)) {
pAsyncReader = (IAsyncReader*)DNew CAsyncFileReader(Items, hr);
- else
+ } else {
pAsyncReader = (IAsyncReader*)DNew CAsyncFileReader(CString(pszFileName), hr);
+ }
if(FAILED(hr)
- || FAILED(hr = DeleteOutputs())
- || FAILED(hr = CreateOutputs(pAsyncReader)))
- {
+ || FAILED(hr = DeleteOutputs())
+ || FAILED(hr = CreateOutputs(pAsyncReader))) {
m_fn = "";
return hr;
}
@@ -1176,8 +1229,9 @@ STDMETHODIMP CBaseSplitterFilter::GetCurFile(LPOLESTR* ppszFileName, AM_MEDIA_TY
{
CheckPointer(ppszFileName, E_POINTER);
*ppszFileName = (LPOLESTR)CoTaskMemAlloc((m_fn.GetLength()+1)*sizeof(WCHAR));
- if(!(*ppszFileName))
+ if(!(*ppszFileName)) {
return E_OUTOFMEMORY;
+ }
wcscpy(*ppszFileName, m_fn);
return S_OK;
}
@@ -1192,87 +1246,150 @@ LPCTSTR CBaseSplitterFilter::GetPartFilename(IAsyncReader* pAsyncReader)
STDMETHODIMP CBaseSplitterFilter::GetCapabilities(DWORD* pCapabilities)
{
- return pCapabilities ? *pCapabilities =
- AM_SEEKING_CanGetStopPos|
- AM_SEEKING_CanGetDuration|
- AM_SEEKING_CanSeekAbsolute|
- AM_SEEKING_CanSeekForwards|
- AM_SEEKING_CanSeekBackwards, S_OK : E_POINTER;
+ return pCapabilities ? *pCapabilities =
+ AM_SEEKING_CanGetStopPos|
+ AM_SEEKING_CanGetDuration|
+ AM_SEEKING_CanSeekAbsolute|
+ AM_SEEKING_CanSeekForwards|
+ AM_SEEKING_CanSeekBackwards, S_OK : E_POINTER;
}
STDMETHODIMP CBaseSplitterFilter::CheckCapabilities(DWORD* pCapabilities)
{
CheckPointer(pCapabilities, E_POINTER);
- if(*pCapabilities == 0) return S_OK;
+ if(*pCapabilities == 0) {
+ return S_OK;
+ }
DWORD caps;
GetCapabilities(&caps);
- if((caps&*pCapabilities) == 0) return E_FAIL;
- if(caps == *pCapabilities) return S_OK;
+ if((caps&*pCapabilities) == 0) {
+ return E_FAIL;
+ }
+ if(caps == *pCapabilities) {
+ return S_OK;
+ }
return S_FALSE;
}
-STDMETHODIMP CBaseSplitterFilter::IsFormatSupported(const GUID* pFormat) {return !pFormat ? E_POINTER : *pFormat == TIME_FORMAT_MEDIA_TIME ? S_OK : S_FALSE;}
-STDMETHODIMP CBaseSplitterFilter::QueryPreferredFormat(GUID* pFormat) {return GetTimeFormat(pFormat);}
-STDMETHODIMP CBaseSplitterFilter::GetTimeFormat(GUID* pFormat) {return pFormat ? *pFormat = TIME_FORMAT_MEDIA_TIME, S_OK : E_POINTER;}
-STDMETHODIMP CBaseSplitterFilter::IsUsingTimeFormat(const GUID* pFormat) {return IsFormatSupported(pFormat);}
-STDMETHODIMP CBaseSplitterFilter::SetTimeFormat(const GUID* pFormat) {return S_OK == IsFormatSupported(pFormat) ? S_OK : E_INVALIDARG;}
-STDMETHODIMP CBaseSplitterFilter::GetDuration(LONGLONG* pDuration) {CheckPointer(pDuration, E_POINTER); *pDuration = m_rtDuration; return S_OK;}
-STDMETHODIMP CBaseSplitterFilter::GetStopPosition(LONGLONG* pStop) {return GetDuration(pStop);}
-STDMETHODIMP CBaseSplitterFilter::GetCurrentPosition(LONGLONG* pCurrent) {return E_NOTIMPL;}
-STDMETHODIMP CBaseSplitterFilter::ConvertTimeFormat(LONGLONG* pTarget, const GUID* pTargetFormat, LONGLONG Source, const GUID* pSourceFormat) {return E_NOTIMPL;}
+STDMETHODIMP CBaseSplitterFilter::IsFormatSupported(const GUID* pFormat)
+{
+ return !pFormat ? E_POINTER : *pFormat == TIME_FORMAT_MEDIA_TIME ? S_OK : S_FALSE;
+}
+STDMETHODIMP CBaseSplitterFilter::QueryPreferredFormat(GUID* pFormat)
+{
+ return GetTimeFormat(pFormat);
+}
+STDMETHODIMP CBaseSplitterFilter::GetTimeFormat(GUID* pFormat)
+{
+ return pFormat ? *pFormat = TIME_FORMAT_MEDIA_TIME, S_OK : E_POINTER;
+}
+STDMETHODIMP CBaseSplitterFilter::IsUsingTimeFormat(const GUID* pFormat)
+{
+ return IsFormatSupported(pFormat);
+}
+STDMETHODIMP CBaseSplitterFilter::SetTimeFormat(const GUID* pFormat)
+{
+ return S_OK == IsFormatSupported(pFormat) ? S_OK : E_INVALIDARG;
+}
+STDMETHODIMP CBaseSplitterFilter::GetDuration(LONGLONG* pDuration)
+{
+ CheckPointer(pDuration, E_POINTER);
+ *pDuration = m_rtDuration;
+ return S_OK;
+}
+STDMETHODIMP CBaseSplitterFilter::GetStopPosition(LONGLONG* pStop)
+{
+ return GetDuration(pStop);
+}
+STDMETHODIMP CBaseSplitterFilter::GetCurrentPosition(LONGLONG* pCurrent)
+{
+ return E_NOTIMPL;
+}
+STDMETHODIMP CBaseSplitterFilter::ConvertTimeFormat(LONGLONG* pTarget, const GUID* pTargetFormat, LONGLONG Source, const GUID* pSourceFormat)
+{
+ return E_NOTIMPL;
+}
STDMETHODIMP CBaseSplitterFilter::SetPositions(LONGLONG* pCurrent, DWORD dwCurrentFlags, LONGLONG* pStop, DWORD dwStopFlags)
{
return SetPositionsInternal(this, pCurrent, dwCurrentFlags, pStop, dwStopFlags);
}
STDMETHODIMP CBaseSplitterFilter::GetPositions(LONGLONG* pCurrent, LONGLONG* pStop)
{
- if(pCurrent) *pCurrent = m_rtCurrent;
- if(pStop) *pStop = m_rtStop;
+ if(pCurrent) {
+ *pCurrent = m_rtCurrent;
+ }
+ if(pStop) {
+ *pStop = m_rtStop;
+ }
return S_OK;
}
STDMETHODIMP CBaseSplitterFilter::GetAvailable(LONGLONG* pEarliest, LONGLONG* pLatest)
{
- if(pEarliest) *pEarliest = 0;
+ if(pEarliest) {
+ *pEarliest = 0;
+ }
return GetDuration(pLatest);
}
-STDMETHODIMP CBaseSplitterFilter::SetRate(double dRate) {return dRate > 0 ? m_dRate = dRate, S_OK : E_INVALIDARG;}
-STDMETHODIMP CBaseSplitterFilter::GetRate(double* pdRate) {return pdRate ? *pdRate = m_dRate, S_OK : E_POINTER;}
-STDMETHODIMP CBaseSplitterFilter::GetPreroll(LONGLONG* pllPreroll) {return pllPreroll ? *pllPreroll = 0, S_OK : E_POINTER;}
+STDMETHODIMP CBaseSplitterFilter::SetRate(double dRate)
+{
+ return dRate > 0 ? m_dRate = dRate, S_OK : E_INVALIDARG;
+}
+STDMETHODIMP CBaseSplitterFilter::GetRate(double* pdRate)
+{
+ return pdRate ? *pdRate = m_dRate, S_OK : E_POINTER;
+}
+STDMETHODIMP CBaseSplitterFilter::GetPreroll(LONGLONG* pllPreroll)
+{
+ return pllPreroll ? *pllPreroll = 0, S_OK : E_POINTER;
+}
HRESULT CBaseSplitterFilter::SetPositionsInternal(void* id, LONGLONG* pCurrent, DWORD dwCurrentFlags, LONGLONG* pStop, DWORD dwStopFlags)
{
CAutoLock cAutoLock(this);
if(!pCurrent && !pStop
- || (dwCurrentFlags&AM_SEEKING_PositioningBitsMask) == AM_SEEKING_NoPositioning
- && (dwStopFlags&AM_SEEKING_PositioningBitsMask) == AM_SEEKING_NoPositioning)
+ || (dwCurrentFlags&AM_SEEKING_PositioningBitsMask) == AM_SEEKING_NoPositioning
+ && (dwStopFlags&AM_SEEKING_PositioningBitsMask) == AM_SEEKING_NoPositioning) {
return S_OK;
+ }
- REFERENCE_TIME
- rtCurrent = m_rtCurrent,
- rtStop = m_rtStop;
+ REFERENCE_TIME
+ rtCurrent = m_rtCurrent,
+ rtStop = m_rtStop;
if(pCurrent)
- switch(dwCurrentFlags&AM_SEEKING_PositioningBitsMask)
- {
- case AM_SEEKING_NoPositioning: break;
- case AM_SEEKING_AbsolutePositioning: rtCurrent = *pCurrent; break;
- case AM_SEEKING_RelativePositioning: rtCurrent = rtCurrent + *pCurrent; break;
- case AM_SEEKING_IncrementalPositioning: rtCurrent = rtCurrent + *pCurrent; break;
- }
+ switch(dwCurrentFlags&AM_SEEKING_PositioningBitsMask) {
+ case AM_SEEKING_NoPositioning:
+ break;
+ case AM_SEEKING_AbsolutePositioning:
+ rtCurrent = *pCurrent;
+ break;
+ case AM_SEEKING_RelativePositioning:
+ rtCurrent = rtCurrent + *pCurrent;
+ break;
+ case AM_SEEKING_IncrementalPositioning:
+ rtCurrent = rtCurrent + *pCurrent;
+ break;
+ }
if(pStop)
- switch(dwStopFlags&AM_SEEKING_PositioningBitsMask)
- {
- case AM_SEEKING_NoPositioning: break;
- case AM_SEEKING_AbsolutePositioning: rtStop = *pStop; break;
- case AM_SEEKING_RelativePositioning: rtStop += *pStop; break;
- case AM_SEEKING_IncrementalPositioning: rtStop = rtCurrent + *pStop; break;
- }
+ switch(dwStopFlags&AM_SEEKING_PositioningBitsMask) {
+ case AM_SEEKING_NoPositioning:
+ break;
+ case AM_SEEKING_AbsolutePositioning:
+ rtStop = *pStop;
+ break;
+ case AM_SEEKING_RelativePositioning:
+ rtStop += *pStop;
+ break;
+ case AM_SEEKING_IncrementalPositioning:
+ rtStop = rtCurrent + *pStop;
+ break;
+ }
- if(m_rtCurrent == rtCurrent && m_rtStop == rtStop)
+ if(m_rtCurrent == rtCurrent && m_rtStop == rtStop) {
return S_OK;
+ }
- if(m_rtLastStart == rtCurrent && m_rtLastStop == rtStop && !m_LastSeekers.Find(id))
- {
+ if(m_rtLastStart == rtCurrent && m_rtLastStop == rtStop && !m_LastSeekers.Find(id)) {
m_LastSeekers.AddTail(id);
return S_OK;
}
@@ -1282,19 +1399,18 @@ HRESULT CBaseSplitterFilter::SetPositionsInternal(void* id, LONGLONG* pCurrent,
m_LastSeekers.RemoveAll();
m_LastSeekers.AddTail(id);
-DbgLog((LOG_TRACE, 0, _T("Seek Started %I64d"), rtCurrent));
+ DbgLog((LOG_TRACE, 0, _T("Seek Started %I64d"), rtCurrent));
m_rtNewStart = m_rtCurrent = rtCurrent;
m_rtNewStop = rtStop;
- if(ThreadExists())
- {
+ if(ThreadExists()) {
DeliverBeginFlush();
CallWorker(CMD_SEEK);
DeliverEndFlush();
}
-DbgLog((LOG_TRACE, 0, _T("Seek Ended")));
+ DbgLog((LOG_TRACE, 0, _T("Seek Ended")));
return S_OK;
}
@@ -1351,7 +1467,9 @@ STDMETHODIMP CBaseSplitterFilter::get_ExSeekCapabilities(long* pExCapabilities)
{
CheckPointer(pExCapabilities, E_POINTER);
*pExCapabilities = AM_EXSEEK_CANSEEK;
- if(ChapGetCount()) *pExCapabilities |= AM_EXSEEK_MARKERSEEK;
+ if(ChapGetCount()) {
+ *pExCapabilities |= AM_EXSEEK_MARKERSEEK;
+ }
return S_OK;
}
@@ -1367,7 +1485,9 @@ STDMETHODIMP CBaseSplitterFilter::get_CurrentMarker(long* pCurrentMarker)
CheckPointer(pCurrentMarker, E_POINTER);
REFERENCE_TIME rt = m_rtCurrent;
long i = ChapLookup(&rt);
- if(i < 0) return E_FAIL;
+ if(i < 0) {
+ return E_FAIL;
+ }
*pCurrentMarker = i+1;
return S_OK;
}
@@ -1376,7 +1496,9 @@ STDMETHODIMP CBaseSplitterFilter::GetMarkerTime(long MarkerNum, double* pMarkerT
{
CheckPointer(pMarkerTime, E_POINTER);
REFERENCE_TIME rt;
- if(FAILED(ChapGet((int)MarkerNum-1, &rt))) return E_FAIL;
+ if(FAILED(ChapGet((int)MarkerNum-1, &rt))) {
+ return E_FAIL;
+ }
*pMarkerTime = (double)rt / 10000000;
return S_OK;
}
@@ -1411,8 +1533,7 @@ STDMETHODIMP CBaseSplitterFilter::GetStatus(int i, int& samples, int& size)
{
CAutoLock cAutoLock(m_pLock);
- if(POSITION pos = m_pOutputs.FindIndex(i))
- {
+ if(POSITION pos = m_pOutputs.FindIndex(i)) {
CBaseSplitterOutputPin* pPin = m_pOutputs.GetAt(pos);
samples = pPin->QueueCount();
size = pPin->QueueSize();
@@ -1424,5 +1545,5 @@ STDMETHODIMP CBaseSplitterFilter::GetStatus(int i, int& samples, int& size)
STDMETHODIMP_(DWORD) CBaseSplitterFilter::GetPriority()
{
- return m_priority;
+ return m_priority;
}
diff --git a/src/filters/parser/BaseSplitter/BaseSplitter.h b/src/filters/parser/BaseSplitter/BaseSplitter.h
index 656fafa81..e030187c1 100644
--- a/src/filters/parser/BaseSplitter/BaseSplitter.h
+++ b/src/filters/parser/BaseSplitter/BaseSplitter.h
@@ -1,4 +1,4 @@
-/*
+/*
* Copyright (C) 2003-2006 Gabest
* http://www.gabest.org
*
@@ -6,12 +6,12 @@
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2, or (at your option)
* any later version.
- *
+ *
* This Program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
- *
+ *
* You should have received a copy of the GNU General Public License
* along with GNU Make; see the file COPYING. If not, write to
* the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
@@ -40,13 +40,25 @@ public:
static const REFERENCE_TIME INVALID_TIME = _I64_MIN;
REFERENCE_TIME rtStart, rtStop;
AM_MEDIA_TYPE* pmt;
- Packet() {pmt = NULL; bDiscontinuity = bAppendable = FALSE;}
- virtual ~Packet() {if(pmt) DeleteMediaType(pmt);}
- virtual int GetDataSize() {return GetCount();}
- void SetData(const void* ptr, DWORD len) {SetCount(len); memcpy(GetData(), ptr, len);}
+ Packet() {
+ pmt = NULL;
+ bDiscontinuity = bAppendable = FALSE;
+ }
+ virtual ~Packet() {
+ if(pmt) {
+ DeleteMediaType(pmt);
+ }
+ }
+ virtual int GetDataSize() {
+ return GetCount();
+ }
+ void SetData(const void* ptr, DWORD len) {
+ SetCount(len);
+ memcpy(GetData(), ptr, len);
+ }
};
-class CPacketQueue
+class CPacketQueue
: public CCritSec
, protected CAutoPtrList<Packet>
{
@@ -62,7 +74,7 @@ public:
class CBaseSplitterFilter;
-class CBaseSplitterInputPin
+class CBaseSplitterInputPin
: public CBasePin
{
protected:
@@ -75,19 +87,19 @@ public:
HRESULT GetAsyncReader(IAsyncReader** ppAsyncReader);
DECLARE_IUNKNOWN;
- STDMETHODIMP NonDelegatingQueryInterface(REFIID riid, void** ppv);
+ STDMETHODIMP NonDelegatingQueryInterface(REFIID riid, void** ppv);
- HRESULT CheckMediaType(const CMediaType* pmt);
+ HRESULT CheckMediaType(const CMediaType* pmt);
- HRESULT CheckConnect(IPin* pPin);
- HRESULT BreakConnect();
+ HRESULT CheckConnect(IPin* pPin);
+ HRESULT BreakConnect();
HRESULT CompleteConnect(IPin* pPin);
STDMETHODIMP BeginFlush();
STDMETHODIMP EndFlush();
};
-class CBaseSplitterOutputPin
+class CBaseSplitterOutputPin
: public CBaseOutputPin
, public IDSMPropertyBagImpl
, protected CAMThread
@@ -107,18 +119,17 @@ private:
CAMEvent m_eEndFlush;
enum {CMD_EXIT};
- DWORD ThreadProc();
+ DWORD ThreadProc();
void MakeISCRHappy();
// please only use DeliverPacket from the derived class
- HRESULT GetDeliveryBuffer(IMediaSample** ppSample, REFERENCE_TIME* pStartTime, REFERENCE_TIME* pEndTime, DWORD dwFlags);
- HRESULT Deliver(IMediaSample* pSample);
+ HRESULT GetDeliveryBuffer(IMediaSample** ppSample, REFERENCE_TIME* pStartTime, REFERENCE_TIME* pEndTime, DWORD dwFlags);
+ HRESULT Deliver(IMediaSample* pSample);
// bitrate stats
- struct
- {
+ struct {
UINT64 nTotalBytesDelivered;
REFERENCE_TIME rtTotalTimeDelivered;
UINT64 nBytesSinceLastDeliverTime;
@@ -160,32 +171,41 @@ public:
virtual ~CBaseSplitterOutputPin();
DECLARE_IUNKNOWN;
- STDMETHODIMP NonDelegatingQueryInterface(REFIID riid, void** ppv);
+ STDMETHODIMP NonDelegatingQueryInterface(REFIID riid, void** ppv);
HRESULT SetName(LPCWSTR pName);
- HRESULT DecideBufferSize(IMemAllocator* pAlloc, ALLOCATOR_PROPERTIES* pProperties);
- HRESULT CheckMediaType(const CMediaType* pmt);
- HRESULT GetMediaType(int iPosition, CMediaType* pmt);
- CMediaType& CurrentMediaType() {return m_mt;}
+ HRESULT DecideBufferSize(IMemAllocator* pAlloc, ALLOCATOR_PROPERTIES* pProperties);
+ HRESULT CheckMediaType(const CMediaType* pmt);
+ HRESULT GetMediaType(int iPosition, CMediaType* pmt);
+ CMediaType& CurrentMediaType() {
+ return m_mt;
+ }
STDMETHODIMP Notify(IBaseFilter* pSender, Quality q);
// Queueing
- HANDLE GetThreadHandle() {ASSERT(m_hThread != NULL); return m_hThread;}
- void SetThreadPriority(int nPriority) {if(m_hThread) ::SetThreadPriority(m_hThread, nPriority);}
+ HANDLE GetThreadHandle() {
+ ASSERT(m_hThread != NULL);
+ return m_hThread;
+ }
+ void SetThreadPriority(int nPriority) {
+ if(m_hThread) {
+ ::SetThreadPriority(m_hThread, nPriority);
+ }
+ }
HRESULT Active();
- HRESULT Inactive();
+ HRESULT Inactive();
- HRESULT DeliverBeginFlush();
+ HRESULT DeliverBeginFlush();
HRESULT DeliverEndFlush();
- HRESULT DeliverNewSegment(REFERENCE_TIME tStart, REFERENCE_TIME tStop, double dRate);
+ HRESULT DeliverNewSegment(REFERENCE_TIME tStart, REFERENCE_TIME tStop, double dRate);
int QueueCount();
int QueueSize();
- HRESULT QueueEndOfStream();
+ HRESULT QueueEndOfStream();
HRESULT QueuePacket(CAutoPtr<Packet> p);
// returns true for everything which (the lack of) would not block other streams (subtitle streams, basically)
@@ -196,11 +216,15 @@ public:
// IBitRateInfo
- STDMETHODIMP_(DWORD) GetCurrentBitRate() {return m_brs.nCurrentBitRate;}
- STDMETHODIMP_(DWORD) GetAverageBitRate() {return m_brs.nAverageBitRate;}
+ STDMETHODIMP_(DWORD) GetCurrentBitRate() {
+ return m_brs.nCurrentBitRate;
+ }
+ STDMETHODIMP_(DWORD) GetAverageBitRate() {
+ return m_brs.nAverageBitRate;
+ }
};
-class CBaseSplitterFilter
+class CBaseSplitterFilter
: public CBaseFilter
, public CCritSec
, public IDSMPropertyBagImpl
@@ -262,20 +286,22 @@ protected:
protected:
enum {CMD_EXIT, CMD_SEEK};
- DWORD ThreadProc();
+ DWORD ThreadProc();
// ... and also override all these too
virtual bool DemuxInit() = 0;
virtual void DemuxSeek(REFERENCE_TIME rt) = 0;
virtual bool DemuxLoop() = 0;
- virtual bool BuildPlaylist(LPCTSTR pszFileName, CAtlList<CHdmvClipInfo::PlaylistItem>& Items) { return false; };
+ virtual bool BuildPlaylist(LPCTSTR pszFileName, CAtlList<CHdmvClipInfo::PlaylistItem>& Items) {
+ return false;
+ };
public:
CBaseSplitterFilter(LPCTSTR pName, LPUNKNOWN pUnk, HRESULT* phr, const CLSID& clsid);
virtual ~CBaseSplitterFilter();
DECLARE_IUNKNOWN;
- STDMETHODIMP NonDelegatingQueryInterface(REFIID riid, void** ppv);
+ STDMETHODIMP NonDelegatingQueryInterface(REFIID riid, void** ppv);
bool IsAnyPinDrying();
@@ -330,10 +356,18 @@ public:
// IDispatch
- 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 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;
+ }
// IAMMediaContent
@@ -342,14 +376,30 @@ public:
STDMETHODIMP get_Rating(BSTR* pbstrRating);
STDMETHODIMP get_Description(BSTR* pbstrDescription);
STDMETHODIMP get_Copyright(BSTR* pbstrCopyright);
- 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;}
+ 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;
+ }
// IAMExtendedSeeking
@@ -358,8 +408,12 @@ public:
STDMETHODIMP get_CurrentMarker(long* pCurrentMarker);
STDMETHODIMP GetMarkerTime(long MarkerNum, double* pMarkerTime);
STDMETHODIMP GetMarkerName(long MarkerNum, BSTR* pbstrMarkerName);
- STDMETHODIMP put_PlaybackSpeed(double Speed) {return E_NOTIMPL;}
- STDMETHODIMP get_PlaybackSpeed(double* pSpeed) {return E_NOTIMPL;}
+ STDMETHODIMP put_PlaybackSpeed(double Speed) {
+ return E_NOTIMPL;
+ }
+ STDMETHODIMP get_PlaybackSpeed(double* pSpeed) {
+ return E_NOTIMPL;
+ }
// IKeyFrameInfo
diff --git a/src/filters/parser/BaseSplitter/BaseSplitterFile.cpp b/src/filters/parser/BaseSplitter/BaseSplitterFile.cpp
index 483c3c7a2..36521c465 100644
--- a/src/filters/parser/BaseSplitter/BaseSplitterFile.cpp
+++ b/src/filters/parser/BaseSplitter/BaseSplitterFile.cpp
@@ -1,4 +1,4 @@
-/*
+/*
* Copyright (C) 2003-2006 Gabest
* http://www.gabest.org
*
@@ -6,12 +6,12 @@
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2, or (at your option)
* any later version.
- *
+ *
* This Program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
- *
+ *
* You should have received a copy of the GNU General Public License
* along with GNU Make; see the file COPYING. If not, write to
* the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
@@ -35,7 +35,10 @@ CBaseSplitterFile::CBaseSplitterFile(IAsyncReader* pAsyncReader, HRESULT& hr, in
, m_bitbuff(0), m_bitlen(0)
, m_cachepos(0), m_cachelen(0)
{
- if(!m_pAsyncReader) {hr = E_UNEXPECTED; return;}
+ if(!m_pAsyncReader) {
+ hr = E_UNEXPECTED;
+ return;
+ }
LONGLONG total = 0, available;
hr = m_pAsyncReader->Length(&total, &available);
@@ -44,15 +47,13 @@ CBaseSplitterFile::CBaseSplitterFile(IAsyncReader* pAsyncReader, HRESULT& hr, in
m_fRandomAccess = total > 0 && total == available;
m_len = total;
- if(FAILED(hr) || fRandomAccess && !m_fRandomAccess || !fStreaming && m_fStreaming || m_len < 0)
- {
+ if(FAILED(hr) || fRandomAccess && !m_fRandomAccess || !fStreaming && m_fStreaming || m_len < 0) {
hr = E_FAIL;
return;
}
- if(!SetCacheSize(cachelen))
- {
- hr = E_OUTOFMEMORY;
+ if(!SetCacheSize(cachelen)) {
+ hr = E_OUTOFMEMORY;
return;
}
@@ -64,7 +65,9 @@ bool CBaseSplitterFile::SetCacheSize(int cachelen)
m_pCache.Free();
m_cachetotal = 0;
m_pCache.Allocate((size_t)cachelen);
- if(!m_pCache) return false;
+ if(!m_pCache) {
+ return false;
+ }
m_cachetotal = cachelen;
m_cachelen = 0;
return true;
@@ -84,12 +87,9 @@ __int64 CBaseSplitterFile::GetAvailable()
__int64 CBaseSplitterFile::GetLength(bool fUpdate)
{
- if(m_fStreaming)
- {
+ if(m_fStreaming) {
m_len = GetAvailable();
- }
- else if(fUpdate)
- {
+ } else if(fUpdate) {
LONGLONG total = 0, available;
m_pAsyncReader->Length(&total, &available);
m_len = total;
@@ -111,15 +111,16 @@ HRESULT CBaseSplitterFile::Read(BYTE* pData, __int64 len)
HRESULT hr = S_OK;
- if(!m_fRandomAccess)
- {
+ if(!m_fRandomAccess) {
LONGLONG total = 0, available = -1;
m_pAsyncReader->Length(&total, &available);
- if(total == available) {m_fRandomAccess = true; OnComplete();}
+ if(total == available) {
+ m_fRandomAccess = true;
+ OnComplete();
+ }
}
- if(m_cachetotal == 0 || !m_pCache)
- {
+ if(m_cachetotal == 0 || !m_pCache) {
hr = m_pAsyncReader->SyncRead(m_pos, (long)len, pData);
m_pos += len;
return hr;
@@ -127,8 +128,7 @@ HRESULT CBaseSplitterFile::Read(BYTE* pData, __int64 len)
BYTE* pCache = m_pCache;
- if(m_cachepos <= m_pos && m_pos < m_cachepos + m_cachelen)
- {
+ if(m_cachepos <= m_pos && m_pos < m_cachepos + m_cachelen) {
__int64 minlen = min(len, m_cachelen - (m_pos - m_cachepos));
memcpy(pData, &pCache[m_pos - m_cachepos], (size_t)minlen);
@@ -138,25 +138,29 @@ HRESULT CBaseSplitterFile::Read(BYTE* pData, __int64 len)
pData += minlen;
}
- while(len > m_cachetotal)
- {
+ while(len > m_cachetotal) {
hr = m_pAsyncReader->SyncRead(m_pos, (long)m_cachetotal, pData);
- if(S_OK != hr) return hr;
+ if(S_OK != hr) {
+ return hr;
+ }
len -= m_cachetotal;
m_pos += m_cachetotal;
pData += m_cachetotal;
}
- while(len > 0)
- {
+ while(len > 0) {
__int64 tmplen = GetLength();
__int64 maxlen = min(tmplen - m_pos, m_cachetotal);
__int64 minlen = min(len, maxlen);
- if(minlen <= 0) return S_FALSE;
+ if(minlen <= 0) {
+ return S_FALSE;
+ }
hr = m_pAsyncReader->SyncRead(m_pos, (long)maxlen, pCache);
- if(S_OK != hr) return hr;
+ if(S_OK != hr) {
+ return hr;
+ }
m_cachepos = m_pos;
m_cachelen = maxlen;
@@ -175,10 +179,11 @@ UINT64 CBaseSplitterFile::BitRead(int nBits, bool fPeek)
{
ASSERT(nBits >= 0 && nBits <= 64);
- while(m_bitlen < nBits)
- {
+ while(m_bitlen < nBits) {
m_bitbuff <<= 8;
- if(S_OK != Read((BYTE*)&m_bitbuff, 1)) {return 0;} // EOF? // ASSERT(0);
+ if(S_OK != Read((BYTE*)&m_bitbuff, 1)) {
+ return 0; // EOF? // ASSERT(0);
+ }
m_bitlen += 8;
}
@@ -186,8 +191,7 @@ UINT64 CBaseSplitterFile::BitRead(int nBits, bool fPeek)
UINT64 ret = (m_bitbuff >> bitlen) & ((1ui64 << nBits) - 1);
- if(!fPeek)
- {
+ if(!fPeek) {
m_bitbuff &= ((1ui64 << bitlen) - 1);
m_bitlen = bitlen;
}
@@ -207,14 +211,16 @@ void CBaseSplitterFile::BitFlush()
HRESULT CBaseSplitterFile::ByteRead(BYTE* pData, __int64 len)
{
- Seek(GetPos());
+ Seek(GetPos());
return Read(pData, len);
}
UINT64 CBaseSplitterFile::UExpGolombRead()
{
int n = -1;
- for(BYTE b = 0; !b; n++) b = BitRead(1);
+ for(BYTE b = 0; !b; n++) {
+ b = BitRead(1);
+ }
return (1ui64 << n) - 1 + BitRead(n);
}
@@ -228,14 +234,14 @@ HRESULT CBaseSplitterFile::HasMoreData(__int64 len, DWORD ms)
{
__int64 available = GetLength() - GetPos();
- if(!m_fStreaming)
- {
+ if(!m_fStreaming) {
return available < 1 ? E_FAIL : S_OK;
}
- if(available < len)
- {
- if(ms > 0) Sleep(ms);
+ if(available < len) {
+ if(ms > 0) {
+ Sleep(ms);
+ }
return S_FALSE;
}
diff --git a/src/filters/parser/BaseSplitter/BaseSplitterFile.h b/src/filters/parser/BaseSplitter/BaseSplitterFile.h
index 8b61961e1..279471748 100644
--- a/src/filters/parser/BaseSplitter/BaseSplitterFile.h
+++ b/src/filters/parser/BaseSplitter/BaseSplitterFile.h
@@ -1,4 +1,4 @@
-/*
+/*
* Copyright (C) 2003-2006 Gabest
* http://www.gabest.org
*
@@ -6,12 +6,12 @@
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2, or (at your option)
* any later version.
- *
+ *
* This Program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
- *
+ *
* You should have received a copy of the GNU General Public License
* along with GNU Make; see the file COPYING. If not, write to
* the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
@@ -51,7 +51,9 @@ public:
__int64 GetPos();
__int64 GetAvailable();
__int64 GetLength(bool fUpdate = false);
- __int64 GetRemaining() {return max(0, GetLength() - GetPos());}
+ __int64 GetRemaining() {
+ return max(0, GetLength() - GetPos());
+ }
virtual void Seek(__int64 pos);
UINT64 UExpGolombRead();
@@ -61,8 +63,12 @@ public:
void BitByteAlign(), BitFlush();
HRESULT ByteRead(BYTE* pData, __int64 len);
- bool IsStreaming() const {return m_fStreaming;}
- bool IsRandomAccess() const {return m_fRandomAccess;}
+ bool IsStreaming() const {
+ return m_fStreaming;
+ }
+ bool IsRandomAccess() const {
+ return m_fRandomAccess;
+ }
HRESULT HasMoreData(__int64 len = 1, DWORD ms = 1);
};
diff --git a/src/filters/parser/BaseSplitter/BaseSplitterFileEx.cpp b/src/filters/parser/BaseSplitter/BaseSplitterFileEx.cpp
index 85e259fc3..3a0df88ee 100644
--- a/src/filters/parser/BaseSplitter/BaseSplitterFileEx.cpp
+++ b/src/filters/parser/BaseSplitter/BaseSplitterFileEx.cpp
@@ -1,4 +1,4 @@
-/*
+/*
* Copyright (C) 2003-2006 Gabest
* http://www.gabest.org
*
@@ -6,12 +6,12 @@
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2, or (at your option)
* any later version.
- *
+ *
* This Program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
- *
+ *
* You should have received a copy of the GNU General Public License
* along with GNU Make; see the file COPYING. If not, write to
* the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
@@ -50,12 +50,12 @@ bool CBaseSplitterFileEx::NextMpegStartCode(BYTE& code, __int64 len)
{
BitByteAlign();
DWORD dw = (DWORD)-1;
- do
- {
- if(len-- == 0 || !GetRemaining()) return(false);
+ do {
+ if(len-- == 0 || !GetRemaining()) {
+ return(false);
+ }
dw = (dw << 8) | (BYTE)BitRead(8);
- }
- while((dw&0xffffff00) != 0x00000100);
+ } while((dw&0xffffff00) != 0x00000100);
code = (BYTE)(dw&0xff);
return(true);
}
@@ -70,36 +70,44 @@ bool CBaseSplitterFileEx::Read(pshdr& h)
BYTE b = (BYTE)BitRead(8, true);
- if((b&0xf1) == 0x21)
- {
+ if((b&0xf1) == 0x21) {
h.type = mpeg1;
EXECUTE_ASSERT(BitRead(4) == 2);
h.scr = 0;
- h.scr |= BitRead(3) << 30; MARKER; // 32..30
- h.scr |= BitRead(15) << 15; MARKER; // 29..15
- h.scr |= BitRead(15); MARKER; MARKER; // 14..0
- h.bitrate = BitRead(22); MARKER;
- }
- else if((b&0xc4) == 0x44)
- {
+ h.scr |= BitRead(3) << 30;
+ MARKER; // 32..30
+ h.scr |= BitRead(15) << 15;
+ MARKER; // 29..15
+ h.scr |= BitRead(15);
+ MARKER;
+ MARKER; // 14..0
+ h.bitrate = BitRead(22);
+ MARKER;
+ } else if((b&0xc4) == 0x44) {
h.type = mpeg2;
EXECUTE_ASSERT(BitRead(2) == 1);
h.scr = 0;
- h.scr |= BitRead(3) << 30; MARKER; // 32..30
- h.scr |= BitRead(15) << 15; MARKER; // 29..15
- h.scr |= BitRead(15); MARKER; // 14..0
- h.scr = (h.scr*300 + BitRead(9)) * 10 / 27; MARKER;
- h.bitrate = BitRead(22); MARKER; MARKER;
+ h.scr |= BitRead(3) << 30;
+ MARKER; // 32..30
+ h.scr |= BitRead(15) << 15;
+ MARKER; // 29..15
+ h.scr |= BitRead(15);
+ MARKER; // 14..0
+ h.scr = (h.scr*300 + BitRead(9)) * 10 / 27;
+ MARKER;
+ h.bitrate = BitRead(22);
+ MARKER;
+ MARKER;
BitRead(5); // reserved
UINT64 stuffing = BitRead(3);
- while(stuffing-- > 0) EXECUTE_ASSERT(BitRead(8) == 0xff);
- }
- else
- {
+ while(stuffing-- > 0) {
+ EXECUTE_ASSERT(BitRead(8) == 0xff);
+ }
+ } else {
return(false);
}
@@ -112,19 +120,21 @@ bool CBaseSplitterFileEx::Read(pssyshdr& h)
{
memset(&h, 0, sizeof(h));
- WORD len = (WORD)BitRead(16); MARKER;
- h.rate_bound = (DWORD)BitRead(22); MARKER;
+ WORD len = (WORD)BitRead(16);
+ MARKER;
+ h.rate_bound = (DWORD)BitRead(22);
+ MARKER;
h.audio_bound = (BYTE)BitRead(6);
h.fixed_rate = !!BitRead(1);
h.csps = !!BitRead(1);
h.sys_audio_loc_flag = !!BitRead(1);
- h.sys_video_loc_flag = !!BitRead(1); MARKER;
+ h.sys_video_loc_flag = !!BitRead(1);
+ MARKER;
h.video_bound = (BYTE)BitRead(5);
EXECUTE_ASSERT((BitRead(8)&0x7f) == 0x7f); // reserved (should be 0xff, but not in reality)
- for(len -= 6; len > 3; len -= 3) // TODO: also store these, somewhere, if needed
- {
+ for(len -= 6; len > 3; len -= 3) { // TODO: also store these, somewhere, if needed
UINT64 stream_id = BitRead(8);
UNUSED_ALWAYS(stream_id);
EXECUTE_ASSERT(BitRead(2) == 3);
@@ -139,42 +149,42 @@ bool CBaseSplitterFileEx::Read(peshdr& h, BYTE code)
{
memset(&h, 0, sizeof(h));
- if(!(code >= 0xbd && code < 0xf0 || code == 0xfd)) // 0xfd => blu-ray (.m2ts)
+ if(!(code >= 0xbd && code < 0xf0 || code == 0xfd)) { // 0xfd => blu-ray (.m2ts)
return(false);
+ }
h.len = (WORD)BitRead(16);
- if(code == 0xbe || code == 0xbf)
+ if(code == 0xbe || code == 0xbf) {
return(true);
+ }
// mpeg1 stuffing (ff ff .. , max 16x)
- for(int i = 0; i < 16 && BitRead(8, true) == 0xff; i++)
- {
- BitRead(8);
- if(h.len) h.len--;
+ for(int i = 0; i < 16 && BitRead(8, true) == 0xff; i++) {
+ BitRead(8);
+ if(h.len) {
+ h.len--;
+ }
}
h.type = (BYTE)BitRead(2, true) == mpeg2 ? mpeg2 : mpeg1;
- if(h.type == mpeg1)
- {
+ if(h.type == mpeg1) {
BYTE b = (BYTE)BitRead(2);
- if(b == 1)
- {
+ if(b == 1) {
h.std_buff_size = (BitRead(1)?1024:128)*BitRead(13);
- if(h.len) h.len -= 2;
+ if(h.len) {
+ h.len -= 2;
+ }
b = (BYTE)BitRead(2);
}
- if(b == 0)
- {
+ if(b == 0) {
h.fpts = (BYTE)BitRead(1);
h.fdts = (BYTE)BitRead(1);
}
- }
- else if(h.type == mpeg2)
- {
+ } else if(h.type == mpeg2) {
EXECUTE_ASSERT(BitRead(2) == mpeg2);
h.scrambling = (BYTE)BitRead(2);
h.priority = (BYTE)BitRead(1);
@@ -190,17 +200,15 @@ bool CBaseSplitterFileEx::Read(peshdr& h, BYTE code)
h.crc = (BYTE)BitRead(1);
h.extension = (BYTE)BitRead(1);
h.hdrlen = (BYTE)BitRead(8);
- }
- else
- {
- if(h.len) while(h.len-- > 0) BitRead(8);
+ } else {
+ if(h.len) while(h.len-- > 0) {
+ BitRead(8);
+ }
return(false);
}
- if(h.fpts)
- {
- if(h.type == mpeg2)
- {
+ if(h.fpts) {
+ if(h.type == mpeg2) {
// Temporary(dirty) fix - needs more testing
//BYTE b = (BYTE)BitRead(4);
//if(!(h.fdts && b == 3 || !h.fdts && b == 2)) {ASSERT(0); return(false);}
@@ -208,57 +216,73 @@ bool CBaseSplitterFileEx::Read(peshdr& h, BYTE code)
}
h.pts = 0;
- h.pts |= BitRead(3) << 30; MARKER; // 32..30
- h.pts |= BitRead(15) << 15; MARKER; // 29..15
- h.pts |= BitRead(15); MARKER; // 14..0
+ h.pts |= BitRead(3) << 30;
+ MARKER; // 32..30
+ h.pts |= BitRead(15) << 15;
+ MARKER; // 29..15
+ h.pts |= BitRead(15);
+ MARKER; // 14..0
h.pts = 10000*h.pts/90 + m_rtPTSOffset;
}
- if(h.fdts)
- {
+ if(h.fdts) {
// Temporary(dirty) fix - needs more testing
//if((BYTE)BitRead(4) != 1) {ASSERT(0); return(false);}
BitRead(4);
h.dts = 0;
- h.dts |= BitRead(3) << 30; MARKER; // 32..30
- h.dts |= BitRead(15) << 15; MARKER; // 29..15
- h.dts |= BitRead(15); MARKER; // 14..0
+ h.dts |= BitRead(3) << 30;
+ MARKER; // 32..30
+ h.dts |= BitRead(15) << 15;
+ MARKER; // 29..15
+ h.dts |= BitRead(15);
+ MARKER; // 14..0
h.dts = 10000*h.dts/90 + m_rtPTSOffset;
}
// skip to the end of header
- if(h.type == mpeg1)
- {
- if(!h.fpts && !h.fdts && BitRead(4) != 0xf) {/*ASSERT(0);*/ return(false);}
+ if(h.type == mpeg1) {
+ if(!h.fpts && !h.fdts && BitRead(4) != 0xf) {
+ /*ASSERT(0);*/ return(false);
+ }
- if(h.len)
- {
+ if(h.len) {
h.len--;
- if(h.pts) h.len -= 4;
- if(h.dts) h.len -= 5;
+ if(h.pts) {
+ h.len -= 4;
+ }
+ if(h.dts) {
+ h.len -= 5;
+ }
}
}
- if(h.type == mpeg2)
- {
- if(h.len) h.len -= 3+h.hdrlen;
+ if(h.type == mpeg2) {
+ if(h.len) {
+ h.len -= 3+h.hdrlen;
+ }
int left = h.hdrlen;
- if(h.fpts) left -= 5;
- if(h.fdts) left -= 5;
- while(left-- > 0) BitRead(8);
-/*
- // mpeg2 stuffing (ff ff .. , max 32x)
- while(BitRead(8, true) == 0xff) {BitRead(8); if(h.len) h.len--;}
- Seek(GetPos()); // put last peeked byte back for Read()
-
- // FIXME: this doesn't seems to be here,
- // infact there can be ff's as part of the data
- // right at the beginning of the packet, which
- // we should not skip...
-*/
+ if(h.fpts) {
+ left -= 5;
+ }
+ if(h.fdts) {
+ left -= 5;
+ }
+ while(left-- > 0) {
+ BitRead(8);
+ }
+ /*
+ // mpeg2 stuffing (ff ff .. , max 32x)
+ while(BitRead(8, true) == 0xff) {BitRead(8); if(h.len) h.len--;}
+ Seek(GetPos()); // put last peeked byte back for Read()
+
+ // FIXME: this doesn't seems to be here,
+ // infact there can be ff's as part of the data
+ // right at the beginning of the packet, which
+ // we should not skip...
+ */
}
return(true);
@@ -270,40 +294,43 @@ bool CBaseSplitterFileEx::Read(seqhdr& h, int len, CMediaType* pmt)
BYTE id = 0;
- while(GetPos() < endpos && id != 0xb3)
- {
- if(!NextMpegStartCode(id, len))
+ while(GetPos() < endpos && id != 0xb3) {
+ if(!NextMpegStartCode(id, len)) {
return(false);
+ }
}
- if(id != 0xb3)
+ if(id != 0xb3) {
return(false);
+ }
__int64 shpos = GetPos() - 4;
h.width = (WORD)BitRead(12);
h.height = (WORD)BitRead(12);
h.ar = BitRead(4);
- static int ifps[16] = {0, 1126125, 1125000, 1080000, 900900, 900000, 540000, 450450, 450000, 0, 0, 0, 0, 0, 0, 0};
+ static int ifps[16] = {0, 1126125, 1125000, 1080000, 900900, 900000, 540000, 450450, 450000, 0, 0, 0, 0, 0, 0, 0};
h.ifps = ifps[BitRead(4)];
- h.bitrate = (DWORD)BitRead(18); MARKER;
+ h.bitrate = (DWORD)BitRead(18);
+ MARKER;
h.vbv = (DWORD)BitRead(10);
h.constrained = BitRead(1);
h.fiqm = BitRead(1);
if(h.fiqm)
- for(int i = 0; i < countof(h.iqm); i++)
+ for(int i = 0; i < countof(h.iqm); i++) {
h.iqm[i] = (BYTE)BitRead(8);
+ }
h.fniqm = BitRead(1);
if(h.fniqm)
- for(int i = 0; i < countof(h.niqm); i++)
+ for(int i = 0; i < countof(h.niqm); i++) {
h.niqm[i] = (BYTE)BitRead(8);
+ }
__int64 shlen = GetPos() - shpos;
- static float ar[] =
- {
+ static float ar[] = {
1.0000f,1.0000f,0.6735f,0.7031f,0.7615f,0.8055f,0.8437f,0.8935f,
0.9157f,0.9815f,1.0255f,1.0695f,1.0950f,1.1575f,1.2015f,1.0000f
};
@@ -315,8 +342,7 @@ bool CBaseSplitterFileEx::Read(seqhdr& h, int len, CMediaType* pmt)
__int64 shextpos = 0, shextlen = 0;
- if(NextMpegStartCode(id, 8) && id == 0xb5) // sequence header ext
- {
+ if(NextMpegStartCode(id, 8) && id == 0xb5) { // sequence header ext
shextpos = GetPos() - 4;
h.startcodeid = BitRead(4);
@@ -327,14 +353,17 @@ bool CBaseSplitterFileEx::Read(seqhdr& h, int len, CMediaType* pmt)
h.chroma = BitRead(2);
h.width |= (BitRead(2)<<12);
h.height |= (BitRead(2)<<12);
- h.bitrate |= (BitRead(12)<<18); MARKER;
+ h.bitrate |= (BitRead(12)<<18);
+ MARKER;
h.vbv |= (BitRead(8)<<10);
h.lowdelay = BitRead(1);
h.ifps = (DWORD)(h.ifps * (BitRead(2)+1) / (BitRead(5)+1));
shextlen = GetPos() - shextpos;
- struct {DWORD x, y;} ar[] = {{h.width,h.height},{4,3},{16,9},{221,100},{h.width,h.height}};
+ struct {
+ DWORD x, y;
+ } ar[] = {{h.width,h.height},{4,3},{16,9},{221,100},{h.width,h.height}};
int i = min(max(h.ar, 1), 5)-1;
h.arx = ar[i].x;
h.ary = ar[i].y;
@@ -346,15 +375,22 @@ bool CBaseSplitterFileEx::Read(seqhdr& h, int len, CMediaType* pmt)
h.bitrate = h.bitrate == (1<<30)-1 ? 0 : h.bitrate * 400;
DWORD a = h.arx, b = h.ary;
- while(a) {DWORD tmp = a; a = b % tmp; b = tmp;}
- if(b) h.arx /= b, h.ary /= b;
+ while(a) {
+ DWORD tmp = a;
+ a = b % tmp;
+ b = tmp;
+ }
+ if(b) {
+ h.arx /= b, h.ary /= b;
+ }
- if(!pmt) return(true);
+ if(!pmt) {
+ return(true);
+ }
pmt->majortype = MEDIATYPE_Video;
- if(type == mpeg1)
- {
+ if(type == mpeg1) {
pmt->subtype = MEDIASUBTYPE_MPEG1Payload;
pmt->formattype = FORMAT_MPEGVideo;
int len = FIELD_OFFSET(MPEG1VIDEOINFO, bSequenceHeader) + shlen + shextlen;
@@ -370,13 +406,13 @@ bool CBaseSplitterFileEx::Read(seqhdr& h, int len, CMediaType* pmt)
vi->cbSequenceHeader = shlen + shextlen;
Seek(shpos);
ByteRead((BYTE*)&vi->bSequenceHeader[0], shlen);
- if(shextpos && shextlen) Seek(shextpos);
+ if(shextpos && shextlen) {
+ Seek(shextpos);
+ }
ByteRead((BYTE*)&vi->bSequenceHeader[0] + shlen, shextlen);
pmt->SetFormat((BYTE*)vi, len);
delete [] vi;
- }
- else if(type == mpeg2)
- {
+ } else if(type == mpeg2) {
pmt->subtype = MEDIASUBTYPE_MPEG2_VIDEO;
pmt->formattype = FORMAT_MPEG2_VIDEO;
int len = FIELD_OFFSET(MPEG2VIDEOINFO, dwSequenceHeader) + shlen + shextlen;
@@ -394,13 +430,13 @@ bool CBaseSplitterFileEx::Read(seqhdr& h, int len, CMediaType* pmt)
vi->cbSequenceHeader = shlen + shextlen;
Seek(shpos);
ByteRead((BYTE*)&vi->dwSequenceHeader[0], shlen);
- if(shextpos && shextlen) Seek(shextpos);
+ if(shextpos && shextlen) {
+ Seek(shextpos);
+ }
ByteRead((BYTE*)&vi->dwSequenceHeader[0] + shlen, shextlen);
pmt->SetFormat((BYTE*)vi, len);
delete [] vi;
- }
- else
- {
+ } else {
return(false);
}
@@ -413,11 +449,13 @@ bool CBaseSplitterFileEx::Read(mpahdr& h, int len, bool fAllowV25, CMediaType* p
int syncbits = fAllowV25 ? 11 : 12;
- for(; len >= 4 && BitRead(syncbits, true) != (1<<syncbits) - 1; len--)
+ for(; len >= 4 && BitRead(syncbits, true) != (1<<syncbits) - 1; len--) {
BitRead(8);
+ }
- if(len < 4)
+ if(len < 4) {
return(false);
+ }
h.sync = BitRead(11);
h.version = BitRead(2);
@@ -433,22 +471,22 @@ bool CBaseSplitterFileEx::Read(mpahdr& h, int len, bool fAllowV25, CMediaType* p
h.original = BitRead(1);
h.emphasis = BitRead(2);
- if(h.version == 1 || h.layer == 0 || h.freq == 3 || h.bitrate == 15 || h.emphasis == 2)
+ if(h.version == 1 || h.layer == 0 || h.freq == 3 || h.bitrate == 15 || h.emphasis == 2) {
return(false);
+ }
- if(h.version == 3 && h.layer == 2)
- {
+ if(h.version == 3 && h.layer == 2) {
if((h.bitrate == 1 || h.bitrate == 2 || h.bitrate == 3 || h.bitrate == 5) && h.channels != 3
- && (h.bitrate >= 11 && h.bitrate <= 14) && h.channels == 3)
+ && (h.bitrate >= 11 && h.bitrate <= 14) && h.channels == 3) {
return(false);
+ }
}
h.layer = 4 - h.layer;
//
- static int brtbl[][5] =
- {
+ static int brtbl[][5] = {
{0,0,0,0,0},
{32,32,32,32,8},
{64,48,40,48,16},
@@ -469,7 +507,9 @@ bool CBaseSplitterFileEx::Read(mpahdr& h, int len, bool fAllowV25, CMediaType* p
static int brtblcol[][4] = {{0,3,4,4},{0,0,1,2}};
int bitrate = 1000*brtbl[h.bitrate][brtblcol[h.version&1][h.layer]];
- if(bitrate == 0) return(false);
+ if(bitrate == 0) {
+ return(false);
+ }
static int freq[][4] = {{11025,0,22050,44100},{12000,0,24000,48000},{8000,0,16000,32000}};
@@ -477,42 +517,51 @@ bool CBaseSplitterFileEx::Read(mpahdr& h, int len, bool fAllowV25, CMediaType* p
h.nSamplesPerSec = freq[h.freq][h.version];
h.FrameSize = h.layer == 1
- ? (12 * bitrate / h.nSamplesPerSec + h.padding) * 4
- : (l3ext ? 72 : 144) * bitrate / h.nSamplesPerSec + h.padding;
+ ? (12 * bitrate / h.nSamplesPerSec + h.padding) * 4
+ : (l3ext ? 72 : 144) * bitrate / h.nSamplesPerSec + h.padding;
h.rtDuration = 10000000i64 * (h.layer == 1 ? 384 : l3ext ? 576 : 1152) / h.nSamplesPerSec;// / (h.channels == 3 ? 1 : 2);
h.nBytesPerSec = bitrate / 8;
- if(!pmt) return(true);
+ if(!pmt) {
+ return(true);
+ }
- /*int*/ len = h.layer == 3
- ? sizeof(WAVEFORMATEX/*MPEGLAYER3WAVEFORMAT*/) // no need to overcomplicate this...
- : sizeof(MPEG1WAVEFORMAT);
+ /*int*/ len = h.layer == 3
+ ? sizeof(WAVEFORMATEX/*MPEGLAYER3WAVEFORMAT*/) // no need to overcomplicate this...
+ : sizeof(MPEG1WAVEFORMAT);
WAVEFORMATEX* wfe = (WAVEFORMATEX*)DNew BYTE[len];
memset(wfe, 0, len);
wfe->cbSize = len - sizeof(WAVEFORMATEX);
- if(h.layer == 3)
- {
+ if(h.layer == 3) {
wfe->wFormatTag = WAVE_FORMAT_MP3;
-/* MPEGLAYER3WAVEFORMAT* f = (MPEGLAYER3WAVEFORMAT*)wfe;
- f->wfx.wFormatTag = WAVE_FORMAT_MP3;
- f->wID = MPEGLAYER3_ID_UNKNOWN;
- f->fdwFlags = h.padding ? MPEGLAYER3_FLAG_PADDING_ON : MPEGLAYER3_FLAG_PADDING_OFF; // _OFF or _ISO ?
-*/
- }
- else
- {
+ /* MPEGLAYER3WAVEFORMAT* f = (MPEGLAYER3WAVEFORMAT*)wfe;
+ f->wfx.wFormatTag = WAVE_FORMAT_MP3;
+ f->wID = MPEGLAYER3_ID_UNKNOWN;
+ f->fdwFlags = h.padding ? MPEGLAYER3_FLAG_PADDING_ON : MPEGLAYER3_FLAG_PADDING_OFF; // _OFF or _ISO ?
+ */
+ } else {
MPEG1WAVEFORMAT* f = (MPEG1WAVEFORMAT*)wfe;
f->wfx.wFormatTag = WAVE_FORMAT_MPEG;
f->fwHeadMode = 1 << h.channels;
f->fwHeadModeExt = 1 << h.modeext;
f->wHeadEmphasis = h.emphasis+1;
- if(h.privatebit) f->fwHeadFlags |= ACM_MPEG_PRIVATEBIT;
- if(h.copyright) f->fwHeadFlags |= ACM_MPEG_COPYRIGHT;
- if(h.original) f->fwHeadFlags |= ACM_MPEG_ORIGINALHOME;
- if(h.crc == 0) f->fwHeadFlags |= ACM_MPEG_PROTECTIONBIT;
- if(h.version == 3) f->fwHeadFlags |= ACM_MPEG_ID_MPEG1;
+ if(h.privatebit) {
+ f->fwHeadFlags |= ACM_MPEG_PRIVATEBIT;
+ }
+ if(h.copyright) {
+ f->fwHeadFlags |= ACM_MPEG_COPYRIGHT;
+ }
+ if(h.original) {
+ f->fwHeadFlags |= ACM_MPEG_ORIGINALHOME;
+ }
+ if(h.crc == 0) {
+ f->fwHeadFlags |= ACM_MPEG_PROTECTIONBIT;
+ }
+ if(h.version == 3) {
+ f->fwHeadFlags |= ACM_MPEG_ID_MPEG1;
+ }
f->fwHeadLayer = 1 << (h.layer-1);
f->dwHeadBitrate = bitrate;
}
@@ -536,11 +585,13 @@ bool CBaseSplitterFileEx::Read(aachdr& h, int len, CMediaType* pmt)
{
memset(&h, 0, sizeof(h));
- for(; len >= 7 && BitRead(12, true) != 0xfff; len--)
+ for(; len >= 7 && BitRead(12, true) != 0xfff; len--) {
BitRead(8);
+ }
- if(len < 7)
+ if(len < 7) {
return(false);
+ }
h.sync = BitRead(12);
h.version = BitRead(1);
@@ -559,17 +610,22 @@ bool CBaseSplitterFileEx::Read(aachdr& h, int len, CMediaType* pmt)
h.adts_buffer_fullness = BitRead(11);
h.no_raw_data_blocks_in_frame = BitRead(2);
- if(h.fcrc == 0) h.crc = BitRead(16);
+ if(h.fcrc == 0) {
+ h.crc = BitRead(16);
+ }
- if(h.layer != 0 || h.freq >= 12 || h.aac_frame_length <= (h.fcrc == 0 ? 9 : 7))
+ if(h.layer != 0 || h.freq >= 12 || h.aac_frame_length <= (h.fcrc == 0 ? 9 : 7)) {
return(false);
+ }
h.FrameSize = h.aac_frame_length - (h.fcrc == 0 ? 9 : 7);
- static int freq[] = {96000, 88200, 64000, 48000, 44100, 32000, 24000, 22050, 16000, 12000, 11025, 8000};
+ static int freq[] = {96000, 88200, 64000, 48000, 44100, 32000, 24000, 22050, 16000, 12000, 11025, 8000};
h.nBytesPerSec = h.aac_frame_length * freq[h.freq] / 1024; // ok?
h.rtDuration = 10000000i64 * 1024 / freq[h.freq]; // ok?
- if(!pmt) return(true);
+ if(!pmt) {
+ return(true);
+ }
WAVEFORMATEX* wfe = (WAVEFORMATEX*)DNew BYTE[sizeof(WAVEFORMATEX)+5];
memset(wfe, 0, sizeof(WAVEFORMATEX)+5);
@@ -597,33 +653,45 @@ bool CBaseSplitterFileEx::Read(ac3hdr& h, int len, CMediaType* pmt)
memset(&h, 0, sizeof(h));
- for(; len >= 7 && BitRead(16, true) != 0x0b77; len--)
+ for(; len >= 7 && BitRead(16, true) != 0x0b77; len--) {
BitRead(8);
+ }
- if(len < 7)
+ if(len < 7) {
return(false);
+ }
h.sync = (WORD)BitRead(16);
- if(h.sync != 0x0B77)
+ if(h.sync != 0x0B77) {
return(false);
+ }
_int64 pos = GetPos();
h.crc1 = (WORD)BitRead(16);
h.fscod = BitRead(2);
h.frmsizecod = BitRead(6);
h.bsid = BitRead(5);
- if(h.bsid > 16)
+ if(h.bsid > 16) {
return(false);
+ }
if(h.bsid <= 10) {
/* Normal AC-3 */
- if(h.fscod == 3)
+ if(h.fscod == 3) {
return(false);
- if(h.frmsizecod > 37)
+ }
+ if(h.frmsizecod > 37) {
return(false);
+ }
h.bsmod = BitRead(3);
h.acmod = BitRead(3);
- if(h.acmod == 2) h.dsurmod = BitRead(2);
- if((h.acmod & 1) && h.acmod != 1) h.cmixlev = BitRead(2);
- if(h.acmod & 4) h.surmixlev = BitRead(2);
+ if(h.acmod == 2) {
+ h.dsurmod = BitRead(2);
+ }
+ if((h.acmod & 1) && h.acmod != 1) {
+ h.cmixlev = BitRead(2);
+ }
+ if(h.acmod & 4) {
+ h.surmixlev = BitRead(2);
+ }
h.lfeon = BitRead(1);
h.sr_shift = max(h.bsid, 8) - 8;
} else {
@@ -632,22 +700,22 @@ bool CBaseSplitterFileEx::Read(ac3hdr& h, int len, CMediaType* pmt)
Seek(pos);
h.frame_type = BitRead(2);
h.substreamid = BitRead(3);
- if(h.frame_type || h.substreamid)
+ if(h.frame_type || h.substreamid) {
return(false);
+ }
h.frame_size = (BitRead(11) + 1) << 1;
- if(h.frame_size < 7)
+ if(h.frame_size < 7) {
return(false);
+ }
h.sr_code = BitRead(2);
- if(h.sr_code == 3)
- {
+ if(h.sr_code == 3) {
int sr_code2 = BitRead(2);
- if(sr_code2 == 3)
+ if(sr_code2 == 3) {
return(false);
+ }
h.sample_rate = freq[sr_code2] / 2;
h.sr_shift = 1;
- }
- else
- {
+ } else {
static int eac3_blocks[4] = {1, 2, 3, 6};
h.num_blocks = eac3_blocks[BitRead(2)];
h.sample_rate = freq[h.sr_code];
@@ -657,34 +725,34 @@ bool CBaseSplitterFileEx::Read(ac3hdr& h, int len, CMediaType* pmt)
h.lfeon = BitRead(1);
}
- if(!pmt) return(true);
+ if(!pmt) {
+ return(true);
+ }
WAVEFORMATEX wfe;
memset(&wfe, 0, sizeof(wfe));
wfe.wFormatTag = WAVE_FORMAT_DOLBY_AC3;
-
+
static int channels[] = {2, 1, 2, 3, 3, 4, 4, 5};
wfe.nChannels = channels[h.acmod] + h.lfeon;
- if(h.bsid <= 10)
- {
+ if(h.bsid <= 10) {
wfe.nSamplesPerSec = freq[h.fscod] >> h.sr_shift;
static int rate[] = {32, 40, 48, 56, 64, 80, 96, 112, 128, 160, 192, 224, 256, 320, 384, 448, 512, 576, 640, 768, 896, 1024, 1152, 1280};
wfe.nAvgBytesPerSec = ((rate[h.frmsizecod>>1] * 1000) >> h.sr_shift) / 8;
- }
- else
- {
+ } else {
wfe.nSamplesPerSec = h.sample_rate;
wfe.nAvgBytesPerSec = h.frame_size * h.sample_rate / (h.num_blocks * 256);
}
-
+
wfe.nBlockAlign = (WORD)(1536 * wfe.nAvgBytesPerSec / wfe.nSamplesPerSec);
pmt->majortype = MEDIATYPE_Audio;
- if(e_ac3)
+ if(e_ac3) {
pmt->subtype = MEDIASUBTYPE_DOLBY_DDPLUS;
- else
+ } else {
pmt->subtype = MEDIASUBTYPE_DOLBY_AC3;
+ }
pmt->formattype = FORMAT_WaveFormatEx;
pmt->SetFormat((BYTE*)&wfe, sizeof(wfe));
@@ -695,11 +763,13 @@ bool CBaseSplitterFileEx::Read(dtshdr& h, int len, CMediaType* pmt)
{
memset(&h, 0, sizeof(h));
- for(; len >= 10 && BitRead(32, true) != 0x7ffe8001; len--)
+ for(; len >= 10 && BitRead(32, true) != 0x7ffe8001; len--) {
BitRead(8);
+ }
- if(len < 10)
+ if(len < 10) {
return(false);
+ }
h.sync = (DWORD)BitRead(32);
h.frametype = BitRead(1);
@@ -711,19 +781,21 @@ bool CBaseSplitterFileEx::Read(dtshdr& h, int len, CMediaType* pmt)
h.sfreq = BitRead(4);
h.rate = BitRead(5);
- h.downmix = BitRead(1);
- h.dynrange = BitRead(1);
- h.timestamp = BitRead(1);
- h.aux_data = BitRead(1);
- h.hdcd = BitRead(1);
- h.ext_descr = BitRead(3);
- h.ext_coding = BitRead(1);
- h.aspf = BitRead(1);
- h.lfe = BitRead(2);
- h.predictor_history = BitRead(1);
+ h.downmix = BitRead(1);
+ h.dynrange = BitRead(1);
+ h.timestamp = BitRead(1);
+ h.aux_data = BitRead(1);
+ h.hdcd = BitRead(1);
+ h.ext_descr = BitRead(3);
+ h.ext_coding = BitRead(1);
+ h.aspf = BitRead(1);
+ h.lfe = BitRead(2);
+ h.predictor_history = BitRead(1);
- if(!pmt) return(true);
+ if(!pmt) {
+ return(true);
+ }
WAVEFORMATEX wfe;
memset(&wfe, 0, sizeof(wfe));
@@ -731,18 +803,17 @@ bool CBaseSplitterFileEx::Read(dtshdr& h, int len, CMediaType* pmt)
static int channels[] = {1, 2, 2, 2, 2, 3, 3, 4, 4, 5, 6, 6, 6, 7, 8, 8};
- if(h.amode < countof(channels))
- {
+ if(h.amode < countof(channels)) {
wfe.nChannels = channels[h.amode];
- if (h.lfe > 0)
+ if (h.lfe > 0) {
++wfe.nChannels;
+ }
}
static int freq[] = {0,8000,16000,32000,0,0,11025,22050,44100,0,0,12000,24000,48000,0,0};
wfe.nSamplesPerSec = freq[h.sfreq];
- static int rate[] =
- {
+ static int rate[] = {
32000,56000,64000,96000,112000,128000,192000,224000,
256000,320000,384000,448000,512000,576000,640000,754500,
960000,1024000,1152000,1280000,1344000,1408000,1411200,1472000,
@@ -769,12 +840,15 @@ bool CBaseSplitterFileEx::Read(hdmvlpcmhdr& h, CMediaType* pmt)
h.samplerate = BitRead(4);
h.bitpersample = BitRead(2);
- if (h.channels==0 || h.channels==2 ||
- (h.samplerate != 1 && h.samplerate!= 4 && h.samplerate!= 5) ||
- h.bitpersample<0 || h.bitpersample>3)
+ if (h.channels==0 || h.channels==2 ||
+ (h.samplerate != 1 && h.samplerate!= 4 && h.samplerate!= 5) ||
+ h.bitpersample<0 || h.bitpersample>3) {
return(false);
+ }
- if(!pmt) return(true);
+ if(!pmt) {
+ return(true);
+ }
WAVEFORMATEX_HDMV_LPCM wfe;
wfe.wFormatTag = WAVE_FORMAT_PCM;
@@ -814,10 +888,13 @@ bool CBaseSplitterFileEx::Read(lpcmhdr& h, CMediaType* pmt)
h.channels = BitRead(3);
h.drc = (BYTE)BitRead(8);
- if(h.quantwordlen == 3 || h.reserved1 || h.reserved2)
+ if(h.quantwordlen == 3 || h.reserved1 || h.reserved2) {
return(false);
+ }
- if(!pmt) return(true);
+ if(!pmt) {
+ return(true);
+ }
WAVEFORMATEX wfe;
memset(&wfe, 0, sizeof(wfe));
@@ -825,17 +902,16 @@ bool CBaseSplitterFileEx::Read(lpcmhdr& h, CMediaType* pmt)
wfe.nChannels = h.channels+1;
static int freq[] = {48000, 96000, 44100, 32000};
wfe.nSamplesPerSec = freq[h.freq];
- switch (h.quantwordlen)
- {
- case 0:
- wfe.wBitsPerSample = 16;
- break;
- case 1:
- wfe.wBitsPerSample = 20;
- break;
- case 2:
- wfe.wBitsPerSample = 24;
- break;
+ switch (h.quantwordlen) {
+ case 0:
+ wfe.wBitsPerSample = 16;
+ break;
+ case 1:
+ wfe.wBitsPerSample = 20;
+ break;
+ case 2:
+ wfe.wBitsPerSample = 24;
+ break;
}
wfe.nBlockAlign = (wfe.nChannels*2*wfe.wBitsPerSample) / 8;
wfe.nAvgBytesPerSec = (wfe.nBlockAlign*wfe.nSamplesPerSec) / 2;
@@ -854,7 +930,9 @@ bool CBaseSplitterFileEx::Read(dvdspuhdr& h, CMediaType* pmt)
{
memset(&h, 0, sizeof(h));
- if(!pmt) return(true);
+ if(!pmt) {
+ return(true);
+ }
pmt->majortype = MEDIATYPE_Video;
pmt->subtype = MEDIASUBTYPE_DVD_SUBPICTURE;
@@ -867,15 +945,16 @@ bool CBaseSplitterFileEx::Read(hdmvsubhdr& h, CMediaType* pmt, const char* langu
{
memset(&h, 0, sizeof(h));
- if(!pmt) return(true);
+ if(!pmt) {
+ return(true);
+ }
pmt->majortype = MEDIATYPE_Subtitle;
pmt->subtype = MEDIASUBTYPE_HDMVSUB;
pmt->formattype = FORMAT_None;
SUBTITLEINFO* psi = (SUBTITLEINFO*)pmt->AllocFormatBuffer(sizeof(SUBTITLEINFO));
- if (psi)
- {
+ if (psi) {
memset(psi, 0, pmt->FormatLength());
strcpy(psi->IsoLang, language_code ? language_code : "eng");
}
@@ -887,7 +966,9 @@ bool CBaseSplitterFileEx::Read(svcdspuhdr& h, CMediaType* pmt)
{
memset(&h, 0, sizeof(h));
- if(!pmt) return(true);
+ if(!pmt) {
+ return(true);
+ }
pmt->majortype = MEDIATYPE_Video;
pmt->subtype = MEDIASUBTYPE_SVCD_SUBPICTURE;
@@ -900,7 +981,9 @@ bool CBaseSplitterFileEx::Read(cvdspuhdr& h, CMediaType* pmt)
{
memset(&h, 0, sizeof(h));
- if(!pmt) return(true);
+ if(!pmt) {
+ return(true);
+ }
pmt->majortype = MEDIATYPE_Video;
pmt->subtype = MEDIASUBTYPE_CVD_SUBPICTURE;
@@ -913,26 +996,23 @@ bool CBaseSplitterFileEx::Read(ps2audhdr& h, CMediaType* pmt)
{
memset(&h, 0, sizeof(h));
- if(BitRead(16, true) != 'SS')
+ if(BitRead(16, true) != 'SS') {
return(false);
+ }
__int64 pos = GetPos();
- while(BitRead(16, true) == 'SS')
- {
+ while(BitRead(16, true) == 'SS') {
DWORD tag = (DWORD)BitRead(32, true);
DWORD size = 0;
-
- if(tag == 'SShd')
- {
+
+ if(tag == 'SShd') {
BitRead(32);
ByteRead((BYTE*)&size, sizeof(size));
ASSERT(size == 0x18);
Seek(GetPos());
ByteRead((BYTE*)&h, sizeof(h));
- }
- else if(tag == 'SSbd')
- {
+ } else if(tag == 'SSbd') {
BitRead(32);
ByteRead((BYTE*)&size, sizeof(size));
break;
@@ -941,11 +1021,13 @@ bool CBaseSplitterFileEx::Read(ps2audhdr& h, CMediaType* pmt)
Seek(pos);
- if(!pmt) return(true);
+ if(!pmt) {
+ return(true);
+ }
WAVEFORMATEXPS2 wfe;
- wfe.wFormatTag =
- h.unk1 == 0x01 ? WAVE_FORMAT_PS2_PCM :
+ wfe.wFormatTag =
+ h.unk1 == 0x01 ? WAVE_FORMAT_PS2_PCM :
h.unk1 == 0x10 ? WAVE_FORMAT_PS2_ADPCM :
WAVE_FORMAT_UNKNOWN;
wfe.nChannels = (WORD)h.channels;
@@ -967,7 +1049,9 @@ bool CBaseSplitterFileEx::Read(ps2subhdr& h, CMediaType* pmt)
{
memset(&h, 0, sizeof(h));
- if(!pmt) return(true);
+ if(!pmt) {
+ return(true);
+ }
pmt->majortype = MEDIATYPE_Subtitle;
pmt->subtype = MEDIASUBTYPE_PS2_SUB;
@@ -982,19 +1066,22 @@ bool CBaseSplitterFileEx::Read(trhdr& h, bool fSync)
BitByteAlign();
- if(m_tslen == 0)
- {
+ if(m_tslen == 0) {
__int64 pos = GetPos();
- for(int i = 0; i < 192; i++)
- {
- if(BitRead(8, true) == 0x47)
- {
+ for(int i = 0; i < 192; i++) {
+ if(BitRead(8, true) == 0x47) {
__int64 pos = GetPos();
Seek(pos + 188);
- if(BitRead(8, true) == 0x47) {m_tslen = 188; break;} // TS stream
+ if(BitRead(8, true) == 0x47) {
+ m_tslen = 188; // TS stream
+ break;
+ }
Seek(pos + 192);
- if(BitRead(8, true) == 0x47) {m_tslen = 192; break;} // M2TS stream
+ if(BitRead(8, true) == 0x47) {
+ m_tslen = 192; // M2TS stream
+ break;
+ }
}
BitRead(8);
@@ -1002,32 +1089,35 @@ bool CBaseSplitterFileEx::Read(trhdr& h, bool fSync)
Seek(pos);
- if(m_tslen == 0)
- {
+ if(m_tslen == 0) {
return(false);
}
}
- if(fSync)
- {
- for(int i = 0; i < m_tslen; i++)
- {
- if(BitRead(8, true) == 0x47)
- {
- if(i == 0) break;
+ if(fSync) {
+ for(int i = 0; i < m_tslen; i++) {
+ if(BitRead(8, true) == 0x47) {
+ if(i == 0) {
+ break;
+ }
Seek(GetPos()+m_tslen);
- if(BitRead(8, true) == 0x47) {Seek(GetPos()-m_tslen); break;}
+ if(BitRead(8, true) == 0x47) {
+ Seek(GetPos()-m_tslen);
+ break;
+ }
}
BitRead(8);
- if(i == m_tslen-1)
+ if(i == m_tslen-1) {
return(false);
+ }
}
}
- if(BitRead(8, true) != 0x47)
+ if(BitRead(8, true) != 0x47) {
return(false);
+ }
h.next = GetPos() + m_tslen;
@@ -1043,12 +1133,10 @@ bool CBaseSplitterFileEx::Read(trhdr& h, bool fSync)
h.bytes = 188 - 4;
- if(h.adapfield)
- {
+ if(h.adapfield) {
h.length = (BYTE)BitRead(8);
- if(h.length > 0)
- {
+ if(h.length > 0) {
h.discontinuity = BitRead(1);
h.randomaccess = BitRead(1);
h.priority = BitRead(1);
@@ -1060,8 +1148,7 @@ bool CBaseSplitterFileEx::Read(trhdr& h, bool fSync)
int i = 1;
- if(h.fPCR)
- {
+ if(h.fPCR) {
h.PCR = BitRead(33);
BitRead(6);
UINT64 PCRExt = BitRead(9);
@@ -1071,13 +1158,17 @@ bool CBaseSplitterFileEx::Read(trhdr& h, bool fSync)
ASSERT(i <= h.length);
- for(; i < h.length; i++)
+ for(; i < h.length; i++) {
BitRead(8);
+ }
}
h.bytes -= h.length+1;
- if(h.bytes < 0) {ASSERT(0); return false;}
+ if(h.bytes < 0) {
+ ASSERT(0);
+ return false;
+ }
}
return true;
@@ -1086,7 +1177,9 @@ bool CBaseSplitterFileEx::Read(trhdr& h, bool fSync)
bool CBaseSplitterFileEx::Read(trsechdr& h)
{
BYTE pointer_field = BitRead(8);
- while(pointer_field-- > 0) BitRead(8);
+ while(pointer_field-- > 0) {
+ BitRead(8);
+ }
h.table_id = BitRead(8);
h.section_syntax_indicator = BitRead(1);
h.zero = BitRead(1);
@@ -1107,18 +1200,18 @@ bool CBaseSplitterFileEx::Read(pvahdr& h, bool fSync)
BitByteAlign();
- if(fSync)
- {
- for(int i = 0; i < 65536; i++)
- {
- if((BitRead(64, true)&0xfffffc00ffe00000i64) == 0x4156000055000000i64)
+ if(fSync) {
+ for(int i = 0; i < 65536; i++) {
+ if((BitRead(64, true)&0xfffffc00ffe00000i64) == 0x4156000055000000i64) {
break;
+ }
BitRead(8);
}
}
- if((BitRead(64, true)&0xfffffc00ffe00000i64) != 0x4156000055000000i64)
+ if((BitRead(64, true)&0xfffffc00ffe00000i64) != 0x4156000055000000i64) {
return(false);
+ }
h.sync = (WORD)BitRead(16);
h.streamid = (BYTE)BitRead(8);
@@ -1130,24 +1223,28 @@ bool CBaseSplitterFileEx::Read(pvahdr& h, bool fSync)
h.prebytes = BitRead(2);
h.length = (WORD)BitRead(16);
- if(h.length > 6136)
+ if(h.length > 6136) {
return(false);
+ }
__int64 pos = GetPos();
- if(h.streamid == 1 && h.fpts)
- {
+ if(h.streamid == 1 && h.fpts) {
h.pts = 10000*BitRead(32)/90 + m_rtPTSOffset;
- }
- else if(h.streamid == 2 && (h.fpts || (BitRead(32, true)&0xffffffe0) == 0x000001c0))
- {
+ } else if(h.streamid == 2 && (h.fpts || (BitRead(32, true)&0xffffffe0) == 0x000001c0)) {
BYTE b;
- if(!NextMpegStartCode(b, 4)) return(false);
+ if(!NextMpegStartCode(b, 4)) {
+ return(false);
+ }
peshdr h2;
- if(!Read(h2, b)) return(false);
+ if(!Read(h2, b)) {
+ return(false);
+ }
// Maybe bug, code before: if(h.fpts = h2.fpts) h.pts = h2.pts;
h.fpts = h2.fpts;
- if(h.fpts) h.pts = h2.pts;
+ if(h.fpts) {
+ h.pts = h2.pts;
+ }
}
BitRead(8*h.prebytes);
@@ -1159,26 +1256,27 @@ bool CBaseSplitterFileEx::Read(pvahdr& h, bool fSync)
void CBaseSplitterFileEx::RemoveMpegEscapeCode(BYTE* dst, BYTE* src, int length)
-{
- int si=0;
+{
+ int si=0;
int di=0;
- while(si+2<length){
- //remove escapes (very rare 1:2^22)
- if(src[si+2]>3){
- dst[di++]= src[si++];
- dst[di++]= src[si++];
- }else if(src[si]==0 && src[si+1]==0){
- if(src[si+2]==3){ //escape
- dst[di++]= 0;
- dst[di++]= 0;
- si+=3;
- continue;
- }else //next start code
- return;
- }
-
- dst[di++]= src[si++];
- }
+ while(si+2<length) {
+ //remove escapes (very rare 1:2^22)
+ if(src[si+2]>3) {
+ dst[di++]= src[si++];
+ dst[di++]= src[si++];
+ } else if(src[si]==0 && src[si+1]==0) {
+ if(src[si+2]==3) { //escape
+ dst[di++]= 0;
+ dst[di++]= 0;
+ si+=3;
+ continue;
+ } else { //next start code
+ return;
+ }
+ }
+
+ dst[di++]= src[si++];
+ }
}
bool CBaseSplitterFileEx::Read(avchdr& h, int len, CMediaType* pmt)
@@ -1187,10 +1285,8 @@ bool CBaseSplitterFileEx::Read(avchdr& h, int len, CMediaType* pmt)
DWORD dwStartCode;
- while(GetPos() < endpos+4 /*&& BitRead(32, true) == 0x00000001*/ && (!h.spslen || !h.ppslen))
- {
- if (BitRead(32, true) != 0x00000001)
- {
+ while(GetPos() < endpos+4 /*&& BitRead(32, true) == 0x00000001*/ && (!h.spslen || !h.ppslen)) {
+ if (BitRead(32, true) != 0x00000001) {
BitRead(8);
continue;
}
@@ -1198,9 +1294,8 @@ bool CBaseSplitterFileEx::Read(avchdr& h, int len, CMediaType* pmt)
BitRead(32);
BYTE id = BitRead(8);
-
- if((id&0x9f) == 0x07 && (id&0x60) != 0)
- {
+
+ if((id&0x9f) == 0x07 && (id&0x60) != 0) {
#if 1
BYTE SPSTemp[MAX_SPS];
BYTE SPSBuff[MAX_SPS];
@@ -1221,10 +1316,8 @@ bool CBaseSplitterFileEx::Read(avchdr& h, int len, CMediaType* pmt)
gb.UExpGolombRead(); // seq_parameter_set_id
- if(h.profile >= 100) // high profile
- {
- if(gb.UExpGolombRead() == 3) // chroma_format_idc
- {
+ if(h.profile >= 100) { // high profile
+ if(gb.UExpGolombRead() == 3) { // chroma_format_idc
gb.BitRead(1); // residue_transform_flag
}
@@ -1236,26 +1329,25 @@ bool CBaseSplitterFileEx::Read(avchdr& h, int len, CMediaType* pmt)
if(gb.BitRead(1)) // seq_scaling_matrix_present_flag
for(int i = 0; i < 8; i++)
if(gb.BitRead(1)) // seq_scaling_list_present_flag
- for(int j = 0, size = i < 6 ? 16 : 64, next = 8; j < size && next != 0; ++j)
+ for(int j = 0, size = i < 6 ? 16 : 64, next = 8; j < size && next != 0; ++j) {
next = (next + gb.SExpGolombRead() + 256) & 255;
+ }
}
gb.UExpGolombRead(); // log2_max_frame_num_minus4
UINT64 pic_order_cnt_type = gb.UExpGolombRead();
- if(pic_order_cnt_type == 0)
- {
+ if(pic_order_cnt_type == 0) {
gb.UExpGolombRead(); // log2_max_pic_order_cnt_lsb_minus4
- }
- else if(pic_order_cnt_type == 1)
- {
+ } else if(pic_order_cnt_type == 1) {
gb.BitRead(1); // delta_pic_order_always_zero_flag
gb.SExpGolombRead(); // offset_for_non_ref_pic
gb.SExpGolombRead(); // offset_for_top_to_bottom_field
UINT64 num_ref_frames_in_pic_order_cnt_cycle = gb.UExpGolombRead();
- for(int i = 0; i < num_ref_frames_in_pic_order_cnt_cycle; i++)
- gb.SExpGolombRead(); // offset_for_ref_frame[i]
+ for(int i = 0; i < num_ref_frames_in_pic_order_cnt_cycle; i++) {
+ gb.SExpGolombRead(); // offset_for_ref_frame[i]
+ }
}
gb.UExpGolombRead(); // num_ref_frames
@@ -1268,75 +1360,66 @@ bool CBaseSplitterFileEx::Read(avchdr& h, int len, CMediaType* pmt)
h.width = (pic_width_in_mbs_minus1 + 1) * 16;
h.height = (2 - frame_mbs_only_flag) * (pic_height_in_map_units_minus1 + 1) * 16;
- if (h.height == 1088) h.height = 1080; // Prevent blur lines
+ if (h.height == 1088) {
+ h.height = 1080; // Prevent blur lines
+ }
- if (!frame_mbs_only_flag)
- gb.BitRead(1); // mb_adaptive_frame_field_flag
+ if (!frame_mbs_only_flag) {
+ gb.BitRead(1); // mb_adaptive_frame_field_flag
+ }
gb.BitRead(1); // direct_8x8_inference_flag
- if (gb.BitRead(1)) // frame_cropping_flag
- {
+ if (gb.BitRead(1)) { // frame_cropping_flag
gb.UExpGolombRead(); // frame_cropping_rect_left_offset
gb.UExpGolombRead(); // frame_cropping_rect_right_offset
gb.UExpGolombRead(); // frame_cropping_rect_top_offset
gb.UExpGolombRead(); // frame_cropping_rect_bottom_offset
}
-
- if (gb.BitRead(1)) // vui_parameters_present_flag
- {
- if (gb.BitRead(1)) // aspect_ratio_info_present_flag
- {
- if (255==(BYTE)gb.BitRead(8)) // aspect_ratio_idc)
- {
+
+ if (gb.BitRead(1)) { // vui_parameters_present_flag
+ if (gb.BitRead(1)) { // aspect_ratio_info_present_flag
+ if (255==(BYTE)gb.BitRead(8)) { // aspect_ratio_idc)
gb.BitRead(16); // sar_width
gb.BitRead(16); // sar_height
}
}
- if (gb.BitRead(1)) // overscan_info_present_flag
- {
+ if (gb.BitRead(1)) { // overscan_info_present_flag
gb.BitRead(1); // overscan_appropriate_flag
}
- if (gb.BitRead(1)) // video_signal_type_present_flag
- {
+ if (gb.BitRead(1)) { // video_signal_type_present_flag
gb.BitRead(3); // video_format
gb.BitRead(1); // video_full_range_flag
- if(gb.BitRead(1)) // colour_description_present_flag
- {
+ if(gb.BitRead(1)) { // colour_description_present_flag
gb.BitRead(8); // colour_primaries
gb.BitRead(8); // transfer_characteristics
gb.BitRead(8); // matrix_coefficients
}
}
- if(gb.BitRead(1)) // chroma_location_info_present_flag
- {
+ if(gb.BitRead(1)) { // chroma_location_info_present_flag
gb.UExpGolombRead(); // chroma_sample_loc_type_top_field
gb.UExpGolombRead(); // chroma_sample_loc_type_bottom_field
}
- if (gb.BitRead(1)) // timing_info_present_flag
- {
+ if (gb.BitRead(1)) { // timing_info_present_flag
num_units_in_tick = gb.BitRead(32);
time_scale = gb.BitRead(32);
fixed_frame_rate_flag = gb.BitRead(1);
// Trick for weird parameters (10x to Madshi)!
- if ((num_units_in_tick < 1000) || (num_units_in_tick > 1001))
- {
- if ((time_scale % num_units_in_tick != 0) && ((time_scale*1001) % num_units_in_tick == 0))
- {
+ if ((num_units_in_tick < 1000) || (num_units_in_tick > 1001)) {
+ if ((time_scale % num_units_in_tick != 0) && ((time_scale*1001) % num_units_in_tick == 0)) {
time_scale = (time_scale * 1001) / num_units_in_tick;
num_units_in_tick = 1001;
- }
- else
- {
+ } else {
time_scale = (time_scale * 1000) / num_units_in_tick;
num_units_in_tick = 1000;
}
}
time_scale = time_scale / 2; // VUI consider fields even for progressive stream : divide by 2!
- if (time_scale)
+ if (time_scale) {
h.AvgTimePerFrame = (10000000I64*num_units_in_tick)/time_scale;
+ }
}
}
@@ -1354,10 +1437,8 @@ bool CBaseSplitterFileEx::Read(avchdr& h, int len, CMediaType* pmt)
UExpGolombRead(); // seq_parameter_set_id
- if(h.profile >= 100) // high profile
- {
- if(UExpGolombRead() == 3) // chroma_format_idc
- {
+ if(h.profile >= 100) { // high profile
+ if(UExpGolombRead() == 3) { // chroma_format_idc
BitRead(1); // residue_transform_flag
}
@@ -1369,26 +1450,25 @@ bool CBaseSplitterFileEx::Read(avchdr& h, int len, CMediaType* pmt)
if(BitRead(1)) // seq_scaling_matrix_present_flag
for(int i = 0; i < 8; i++)
if(BitRead(1)) // seq_scaling_list_present_flag
- for(int j = 0, size = i < 6 ? 16 : 64, next = 8; j < size && next != 0; ++j)
+ for(int j = 0, size = i < 6 ? 16 : 64, next = 8; j < size && next != 0; ++j) {
next = (next + SExpGolombRead() + 256) & 255;
+ }
}
UExpGolombRead(); // log2_max_frame_num_minus4
UINT64 pic_order_cnt_type = UExpGolombRead();
- if(pic_order_cnt_type == 0)
- {
+ if(pic_order_cnt_type == 0) {
UExpGolombRead(); // log2_max_pic_order_cnt_lsb_minus4
- }
- else if(pic_order_cnt_type == 1)
- {
+ } else if(pic_order_cnt_type == 1) {
BitRead(1); // delta_pic_order_always_zero_flag
SExpGolombRead(); // offset_for_non_ref_pic
SExpGolombRead(); // offset_for_top_to_bottom_field
UINT64 num_ref_frames_in_pic_order_cnt_cycle = UExpGolombRead();
- for(int i = 0; i < num_ref_frames_in_pic_order_cnt_cycle; i++)
- SExpGolombRead(); // offset_for_ref_frame[i]
+ for(int i = 0; i < num_ref_frames_in_pic_order_cnt_cycle; i++) {
+ SExpGolombRead(); // offset_for_ref_frame[i]
+ }
}
UExpGolombRead(); // num_ref_frames
@@ -1401,119 +1481,112 @@ bool CBaseSplitterFileEx::Read(avchdr& h, int len, CMediaType* pmt)
h.width = (pic_width_in_mbs_minus1 + 1) * 16;
h.height = (2 - frame_mbs_only_flag) * (pic_height_in_map_units_minus1 + 1) * 16;
- if (h.height == 1088) h.height = 1080; // Prevent blur lines
+ if (h.height == 1088) {
+ h.height = 1080; // Prevent blur lines
+ }
- if (!frame_mbs_only_flag)
- BitRead(1); // mb_adaptive_frame_field_flag
+ if (!frame_mbs_only_flag) {
+ BitRead(1); // mb_adaptive_frame_field_flag
+ }
BitRead(1); // direct_8x8_inference_flag
- if (BitRead(1)) // frame_cropping_flag
- {
+ if (BitRead(1)) { // frame_cropping_flag
UExpGolombRead(); // frame_cropping_rect_left_offset
UExpGolombRead(); // frame_cropping_rect_right_offset
UExpGolombRead(); // frame_cropping_rect_top_offset
UExpGolombRead(); // frame_cropping_rect_bottom_offset
}
-
- if (BitRead(1)) // vui_parameters_present_flag
- {
- if (BitRead(1)) // aspect_ratio_info_present_flag
- {
- if (255==(BYTE)BitRead(8)) // aspect_ratio_idc)
- {
+
+ if (BitRead(1)) { // vui_parameters_present_flag
+ if (BitRead(1)) { // aspect_ratio_info_present_flag
+ if (255==(BYTE)BitRead(8)) { // aspect_ratio_idc)
BitRead(16); // sar_width
BitRead(16); // sar_height
}
}
- if (BitRead(1)) // overscan_info_present_flag
- {
+ if (BitRead(1)) { // overscan_info_present_flag
BitRead(1); // overscan_appropriate_flag
}
- if (BitRead(1)) // video_signal_type_present_flag
- {
+ if (BitRead(1)) { // video_signal_type_present_flag
BitRead(3); // video_format
BitRead(1); // video_full_range_flag
- if(BitRead(1)) // colour_description_present_flag
- {
+ if(BitRead(1)) { // colour_description_present_flag
BitRead(8); // colour_primaries
BitRead(8); // transfer_characteristics
BitRead(8); // matrix_coefficients
}
}
- if(BitRead(1)) // chroma_location_info_present_flag
- {
+ if(BitRead(1)) { // chroma_location_info_present_flag
UExpGolombRead(); // chroma_sample_loc_type_top_field
UExpGolombRead(); // chroma_sample_loc_type_bottom_field
}
- if (BitRead(1)) // timing_info_present_flag
- {
+ if (BitRead(1)) { // timing_info_present_flag
num_units_in_tick = BitRead(32);
time_scale = BitRead(32);
fixed_frame_rate_flag = BitRead(1);
// Trick for weird parameters (10x to Madshi)!
- if ((num_units_in_tick < 1000) || (num_units_in_tick > 1001))
- {
- if ((time_scale % num_units_in_tick != 0) && ((time_scale*1001) % num_units_in_tick == 0))
- {
+ if ((num_units_in_tick < 1000) || (num_units_in_tick > 1001)) {
+ if ((time_scale % num_units_in_tick != 0) && ((time_scale*1001) % num_units_in_tick == 0)) {
time_scale = (time_scale * 1001) / num_units_in_tick;
num_units_in_tick = 1001;
- }
- else
- {
+ } else {
time_scale = (time_scale * 1000) / num_units_in_tick;
num_units_in_tick = 1000;
}
}
time_scale = time_scale / 2; // VUI consider fields even for progressive stream : divide by 2!
- if (time_scale)
+ if (time_scale) {
h.AvgTimePerFrame = (10000000I64*num_units_in_tick)/time_scale;
+ }
}
}
#endif
- }
- else if((id&0x9f) == 0x08 && (id&0x60) != 0)
- {
+ } else if((id&0x9f) == 0x08 && (id&0x60) != 0) {
h.ppspos = pos;
}
BitByteAlign();
dwStartCode = BitRead(32, true);
- while(GetPos() < endpos+4 && (dwStartCode != 0x00000001) && (dwStartCode & 0xFFFFFF00) != 0x00000100)
- {
+ while(GetPos() < endpos+4 && (dwStartCode != 0x00000001) && (dwStartCode & 0xFFFFFF00) != 0x00000100) {
BitRead(8);
dwStartCode = BitRead(32, true);
}
- if(h.spspos != 0 && h.spslen == 0)
+ if(h.spspos != 0 && h.spslen == 0) {
h.spslen = GetPos() - h.spspos;
- else if(h.ppspos != 0 && h.ppslen == 0)
+ } else if(h.ppspos != 0 && h.ppslen == 0) {
h.ppslen = GetPos() - h.ppspos;
+ }
}
- if(!h.spspos || !h.spslen || !h.ppspos || !h.ppslen)
+ if(!h.spspos || !h.spslen || !h.ppspos || !h.ppslen) {
return(false);
-
+ }
+
if(!h.AvgTimePerFrame || !(
- (h.level == 10) || (h.level == 11) || (h.level == 12) || (h.level == 13) ||
- (h.level == 20) || (h.level == 21) || (h.level == 22) ||
- (h.level == 30) || (h.level == 31) || (h.level == 32) ||
- (h.level == 40) || (h.level == 41) || (h.level == 42) ||
- (h.level == 50) || (h.level == 51)))
+ (h.level == 10) || (h.level == 11) || (h.level == 12) || (h.level == 13) ||
+ (h.level == 20) || (h.level == 21) || (h.level == 22) ||
+ (h.level == 30) || (h.level == 31) || (h.level == 32) ||
+ (h.level == 40) || (h.level == 41) || (h.level == 42) ||
+ (h.level == 50) || (h.level == 51))) {
return(false);
+ }
- if(!pmt) return(true);
+ if(!pmt) {
+ return(true);
+ }
{
int extra = 2+h.spslen-4 + 2+h.ppslen-4;
pmt->majortype = MEDIATYPE_Video;
pmt->subtype = FOURCCMap('1CVA');
-//pmt->subtype = MEDIASUBTYPE_H264; // TODO : put MEDIASUBTYPE_H264 to support Windows 7 decoder !
+ //pmt->subtype = MEDIASUBTYPE_H264; // TODO : put MEDIASUBTYPE_H264 to support Windows 7 decoder !
pmt->formattype = FORMAT_MPEG2_VIDEO;
int len = FIELD_OFFSET(MPEG2VIDEOINFO, dwSequenceHeader) + extra;
MPEG2VIDEOINFO* vi = (MPEG2VIDEOINFO*)DNew BYTE[len];
@@ -1555,8 +1628,7 @@ bool CBaseSplitterFileEx::Read(vc1hdr& h, int len, CMediaType* pmt)
__int64 extrapos = 0, extralen = 0;
int nFrameRateNum = 0, nFrameRateDen = 1;
- if (GetPos() < endpos+4 && BitRead(32, true) == 0x0000010F)
- {
+ if (GetPos() < endpos+4 && BitRead(32, true) == 0x0000010F) {
extrapos = GetPos();
BitRead(32);
@@ -1564,7 +1636,9 @@ bool CBaseSplitterFileEx::Read(vc1hdr& h, int len, CMediaType* pmt)
h.profile = BitRead(2);
// Check if advanced profile
- if (h.profile != 3) return(false);
+ if (h.profile != 3) {
+ return(false);
+ }
h.level = BitRead (3);
h.chromaformat = BitRead (2);
@@ -1584,41 +1658,36 @@ bool CBaseSplitterFileEx::Read(vc1hdr& h, int len, CMediaType* pmt)
h.finterpflag = BitRead (1);
BitRead (1); // reserved
h.psf = BitRead (1);
- if(BitRead (1))
- {
+ if(BitRead (1)) {
int ar = 0;
h.ArX = BitRead (14) + 1;
h.ArY = BitRead (14) + 1;
- if(BitRead (1))
+ if(BitRead (1)) {
ar = BitRead (4);
- // TODO : next is not the true A/R!
- if(ar && ar < 14)
- {
-// h.ArX = ff_vc1_pixel_aspect[ar].num;
-// h.ArY = ff_vc1_pixel_aspect[ar].den;
}
- else if(ar == 15)
- {
+ // TODO : next is not the true A/R!
+ if(ar && ar < 14) {
+ // h.ArX = ff_vc1_pixel_aspect[ar].num;
+ // h.ArY = ff_vc1_pixel_aspect[ar].den;
+ } else if(ar == 15) {
/*h.ArX =*/ BitRead (8);
- /*h.ArY =*/ BitRead (8);
+ /*h.ArY =*/
+ BitRead (8);
}
// Read framerate
const int ff_vc1_fps_nr[5] = { 24, 25, 30, 50, 60 },
- ff_vc1_fps_dr[2] = { 1000, 1001 };
+ ff_vc1_fps_dr[2] = { 1000, 1001 };
- if(BitRead (1))
- {
- if(BitRead (1))
- {
+ if(BitRead (1)) {
+ if(BitRead (1)) {
nFrameRateNum = 32;
nFrameRateDen = BitRead (16) + 1;
} else {
int nr, dr;
nr = BitRead (8);
dr = BitRead (4);
- if(nr && nr < 8 && dr && dr < 3)
- {
+ if(nr && nr < 8 && dr && dr < 3) {
nFrameRateNum = ff_vc1_fps_dr[dr - 1];
nFrameRateDen = ff_vc1_fps_nr[nr - 1] * 1000;
}
@@ -1631,17 +1700,19 @@ bool CBaseSplitterFileEx::Read(vc1hdr& h, int len, CMediaType* pmt)
extralen = 0;
long parse = 0;
- while (GetPos() < endpos+4 && ((parse == 0x0000010E) || (parse & 0xFFFFFF00) != 0x00000100))
- {
+ while (GetPos() < endpos+4 && ((parse == 0x0000010E) || (parse & 0xFFFFFF00) != 0x00000100)) {
parse = (parse<<8) | BitRead(8);
extralen++;
}
}
- if(!extrapos || !extralen)
+ if(!extrapos || !extralen) {
return(false);
+ }
- if(!pmt) return(true);
+ if(!pmt) {
+ return(true);
+ }
{
//pmt->majortype = MEDIATYPE_Video;
@@ -1695,8 +1766,7 @@ bool CBaseSplitterFileEx::Read(vc1hdr& h, int len, CMediaType* pmt)
bool CBaseSplitterFileEx::Read(dvbsub& h, int len, CMediaType* pmt)
{
- if ((BitRead(32, true) & 0xFFFFFF00) == 0x20000f00)
- {
+ if ((BitRead(32, true) & 0xFFFFFF00) == 0x20000f00) {
static const SUBTITLEINFO SubFormat = { 0, "", L"" };
pmt->majortype = MEDIATYPE_Subtitle;
diff --git a/src/filters/parser/BaseSplitter/BaseSplitterFileEx.h b/src/filters/parser/BaseSplitter/BaseSplitterFileEx.h
index 0d55a9366..942cfa4bc 100644
--- a/src/filters/parser/BaseSplitter/BaseSplitterFileEx.h
+++ b/src/filters/parser/BaseSplitter/BaseSplitterFileEx.h
@@ -1,4 +1,4 @@
-/*
+/*
* Copyright (C) 2003-2006 Gabest
* http://www.gabest.org
*
@@ -6,12 +6,12 @@
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2, or (at your option)
* any later version.
- *
+ *
* This Program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
- *
+ *
* You should have received a copy of the GNU General Public License
* along with GNU Make; see the file COPYING. If not, write to
* the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
@@ -42,22 +42,19 @@ public:
enum mpeg_t {mpegunk, mpeg1, mpeg2};
- struct pshdr
- {
+ struct pshdr {
mpeg_t type;
UINT64 scr, bitrate;
};
- struct pssyshdr
- {
+ struct pssyshdr {
DWORD rate_bound;
BYTE video_bound, audio_bound;
bool fixed_rate, csps;
bool sys_video_loc_flag, sys_audio_loc_flag;
};
- struct peshdr
- {
+ struct peshdr {
WORD len;
BYTE type:2, fpts:1, fdts:1;
@@ -71,7 +68,9 @@ public:
BYTE escr:1, esrate:1, dsmtrickmode:1, morecopyright:1, crc:1, extension:1;
BYTE hdrlen;
- struct peshdr() {memset(this, 0, sizeof(*this));}
+ struct peshdr() {
+ memset(this, 0, sizeof(*this));
+ }
};
class seqhdr
@@ -116,7 +115,7 @@ public:
WORD copyright:1;
WORD original:1;
WORD emphasis:2;
-
+
int nSamplesPerSec, FrameSize, nBytesPerSec;
REFERENCE_TIME rtDuration;
};
@@ -232,7 +231,7 @@ public:
public:
// nothing ;)
};
-
+
class svcdspuhdr
{
public:
@@ -264,8 +263,7 @@ public:
// nothing ;)
};
- struct trhdr
- {
+ struct trhdr {
BYTE sync; // 0x47
BYTE error:1;
BYTE payloadstart:1;
@@ -292,8 +290,7 @@ public:
__int64 next;
};
- struct trsechdr
- {
+ struct trsechdr {
BYTE table_id;
WORD section_syntax_indicator:1;
WORD zero:1;
@@ -309,8 +306,7 @@ public:
// http://www.technotrend.de/download/av_format_v1.pdf
- struct pvahdr
- {
+ struct pvahdr {
WORD sync; // 'VA'
BYTE streamid; // 1 - video, 2 - audio
BYTE counter;
@@ -323,16 +319,14 @@ public:
REFERENCE_TIME pts;
};
- struct avchdr
- {
+ struct avchdr {
BYTE profile, level;
unsigned int width, height;
__int64 spspos, spslen;
__int64 ppspos, ppslen;
__int64 AvgTimePerFrame;
- avchdr()
- {
+ avchdr() {
spspos = 0;
spslen = 0;
ppspos = 0;
@@ -341,8 +335,7 @@ public:
}
};
- struct vc1hdr
- {
+ struct vc1hdr {
BYTE profile;
BYTE level;
BYTE chromaformat;
@@ -359,8 +352,7 @@ public:
unsigned int width, height;
};
- struct dvbsub
- {
+ struct dvbsub {
};
#pragma pack(pop)
diff --git a/src/filters/parser/BaseSplitter/MultiFiles.cpp b/src/filters/parser/BaseSplitter/MultiFiles.cpp
index beb3a2e84..853fca54c 100644
--- a/src/filters/parser/BaseSplitter/MultiFiles.cpp
+++ b/src/filters/parser/BaseSplitter/MultiFiles.cpp
@@ -28,10 +28,10 @@
IMPLEMENT_DYNAMIC(CMultiFiles, CObject)
CMultiFiles::CMultiFiles()
- : m_hFile(INVALID_HANDLE_VALUE)
- , m_llTotalLength(0)
- , m_nCurPart(-1)
- , m_pCurrentPTSOffset(NULL)
+ : m_hFile(INVALID_HANDLE_VALUE)
+ , m_llTotalLength(0)
+ , m_nCurPart(-1)
+ , m_pCurrentPTSOffset(NULL)
{
}
@@ -59,11 +59,12 @@ BOOL CMultiFiles::OpenFiles(CAtlList<CHdmvClipInfo::PlaylistItem>& files, UINT n
REFERENCE_TIME rtDur = 0;
Reset();
- while(pos)
- {
+ while(pos) {
CHdmvClipInfo::PlaylistItem& s = files.GetNext(pos);
m_strFiles.Add(s.m_strFileName);
- if (!OpenPart(nPos)) return false;
+ if (!OpenPart(nPos)) {
+ return false;
+ }
llSize.QuadPart = 0;
GetFileSizeEx (m_hFile, &llSize);
@@ -74,8 +75,10 @@ BOOL CMultiFiles::OpenFiles(CAtlList<CHdmvClipInfo::PlaylistItem>& files, UINT n
nPos++;
}
- if (files.GetCount() > 1) ClosePart();
-
+ if (files.GetCount() > 1) {
+ ClosePart();
+ }
+
return TRUE;
}
@@ -85,21 +88,17 @@ ULONGLONG CMultiFiles::Seek(LONGLONG lOff, UINT nFrom)
LARGE_INTEGER llNewPos;
LARGE_INTEGER llOff;
- if (m_strFiles.GetCount() == 1)
- {
+ if (m_strFiles.GetCount() == 1) {
llOff.QuadPart = lOff;
SetFilePointerEx (m_hFile, llOff, &llNewPos, nFrom);
return llNewPos.QuadPart;
- }
- else
- {
+ } else {
LONGLONG lAbsolutePos = GetAbsolutePosition(lOff, nFrom);
int nNewPart = 0;
ULONGLONG llSum = 0;
- while (m_FilesSize[nNewPart]+llSum <= lAbsolutePos)
- {
+ while (m_FilesSize[nNewPart]+llSum <= lAbsolutePos) {
llSum += m_FilesSize[nNewPart];
nNewPart++;
}
@@ -117,42 +116,39 @@ ULONGLONG CMultiFiles::GetAbsolutePosition(LONGLONG lOff, UINT nFrom)
LARGE_INTEGER llNoMove = {0, 0};
LARGE_INTEGER llCurPos;
- switch (nFrom)
- {
- case begin :
- return lOff;
- case current :
- SetFilePointerEx (m_hFile, llNoMove, &llCurPos, FILE_CURRENT);
- return llCurPos.QuadPart + lOff;
- case end :
- return m_llTotalLength - lOff;
- default:
- return 0; // just used to quash "not all control paths return a value" warning
+ switch (nFrom) {
+ case begin :
+ return lOff;
+ case current :
+ SetFilePointerEx (m_hFile, llNoMove, &llCurPos, FILE_CURRENT);
+ return llCurPos.QuadPart + lOff;
+ case end :
+ return m_llTotalLength - lOff;
+ default:
+ return 0; // just used to quash "not all control paths return a value" warning
}
}
ULONGLONG CMultiFiles::GetLength() const
{
- if (m_strFiles.GetCount() == 1)
- {
+ if (m_strFiles.GetCount() == 1) {
LARGE_INTEGER llSize;
GetFileSizeEx (m_hFile, &llSize);
return llSize.QuadPart;
- }
- else
+ } else {
return m_llTotalLength;
+ }
}
UINT CMultiFiles::Read(void* lpBuf, UINT nCount)
{
DWORD dwRead;
- do
- {
- if (!ReadFile(m_hFile, lpBuf, nCount, &dwRead, NULL))
+ do {
+ if (!ReadFile(m_hFile, lpBuf, nCount, &dwRead, NULL)) {
break;
-
- if (dwRead != nCount && m_nCurPart < m_strFiles.GetCount()-1)
- {
+ }
+
+ if (dwRead != nCount && m_nCurPart < m_strFiles.GetCount()-1) {
OpenPart (m_nCurPart+1);
lpBuf = (void*)((BYTE*)lpBuf + dwRead);
nCount -= dwRead;
@@ -174,10 +170,9 @@ CMultiFiles::~CMultiFiles()
BOOL CMultiFiles::OpenPart(int nPart)
{
- if (m_nCurPart == nPart)
+ if (m_nCurPart == nPart) {
return TRUE;
- else
- {
+ } else {
CString fn;
ClosePart();
@@ -185,10 +180,11 @@ BOOL CMultiFiles::OpenPart(int nPart)
fn = m_strFiles.GetAt(nPart);
m_hFile = CreateFile (fn, GENERIC_READ, FILE_SHARE_DELETE|FILE_SHARE_READ|FILE_SHARE_WRITE, NULL, OPEN_EXISTING, 0, NULL);
- if (m_hFile != INVALID_HANDLE_VALUE)
- {
+ if (m_hFile != INVALID_HANDLE_VALUE) {
m_nCurPart = nPart;
- if (m_pCurrentPTSOffset != NULL) *m_pCurrentPTSOffset = m_rtPtsOffsets[nPart];
+ if (m_pCurrentPTSOffset != NULL) {
+ *m_pCurrentPTSOffset = m_rtPtsOffsets[nPart];
+ }
}
return (m_hFile != INVALID_HANDLE_VALUE);
@@ -198,8 +194,7 @@ BOOL CMultiFiles::OpenPart(int nPart)
void CMultiFiles::ClosePart()
{
- if (m_hFile != INVALID_HANDLE_VALUE)
- {
+ if (m_hFile != INVALID_HANDLE_VALUE) {
CloseHandle (m_hFile);
m_hFile = INVALID_HANDLE_VALUE;
m_nCurPart = -1;
diff --git a/src/filters/parser/BaseSplitter/MultiFiles.h b/src/filters/parser/BaseSplitter/MultiFiles.h
index b07862a0a..dbb700fed 100644
--- a/src/filters/parser/BaseSplitter/MultiFiles.h
+++ b/src/filters/parser/BaseSplitter/MultiFiles.h
@@ -31,7 +31,7 @@ class CMultiFiles : public CObject
DECLARE_DYNAMIC(CMultiFiles)
public:
-// Flag values
+ // Flag values
enum OpenFlags {
modeRead = (int) 0x00000,
modeWrite = (int) 0x00001,
@@ -50,7 +50,7 @@ public:
osWriteThrough = (int) 0x20000,
osRandomAccess = (int) 0x40000,
osSequentialScan = (int) 0x80000,
- };
+ };
enum Attribute {
normal = 0x00,
@@ -60,16 +60,16 @@ public:
volume = 0x08,
directory = 0x10,
archive = 0x20
- };
+ };
enum SeekPosition { begin = 0x0, current = 0x1, end = 0x2 };
-// Constructors
+ // Constructors
CMultiFiles();
CString m_strFileName;
-// Operations
+ // Operations
virtual BOOL Open(LPCTSTR lpszFileName, UINT nOpenFlags);
virtual BOOL OpenFiles(CAtlList<CHdmvClipInfo::PlaylistItem>& files, UINT nOpenFlags);
@@ -80,7 +80,7 @@ public:
virtual UINT Read(void* lpBuf, UINT nCount);
virtual void Close();
-// Implementation
+ // Implementation
public:
virtual ~CMultiFiles();
diff --git a/src/filters/parser/BaseSplitter/stdafx.cpp b/src/filters/parser/BaseSplitter/stdafx.cpp
index 13934d005..bea3f980a 100644
--- a/src/filters/parser/BaseSplitter/stdafx.cpp
+++ b/src/filters/parser/BaseSplitter/stdafx.cpp
@@ -1,4 +1,4 @@
-/*
+/*
* Copyright (C) 2003-2006 Gabest
* http://www.gabest.org
*
@@ -6,12 +6,12 @@
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2, or (at your option)
* any later version.
- *
+ *
* This Program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
- *
+ *
* You should have received a copy of the GNU General Public License
* along with GNU Make; see the file COPYING. If not, write to
* the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
diff --git a/src/filters/parser/BaseSplitter/stdafx.h b/src/filters/parser/BaseSplitter/stdafx.h
index 4811c9499..eb1a0a29e 100644
--- a/src/filters/parser/BaseSplitter/stdafx.h
+++ b/src/filters/parser/BaseSplitter/stdafx.h
@@ -1,4 +1,4 @@
-/*
+/*
* Copyright (C) 2003-2006 Gabest
* http://www.gabest.org
*
@@ -6,12 +6,12 @@
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2, or (at your option)
* any later version.
- *
+ *
* This Program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
- *
+ *
* You should have received a copy of the GNU General Public License
* along with GNU Make; see the file COPYING. If not, write to
* the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.