diff options
author | tetsuo55 <tetsuo55@users.sourceforge.net> | 2010-04-09 01:14:58 +0400 |
---|---|---|
committer | tetsuo55 <tetsuo55@users.sourceforge.net> | 2010-04-09 01:14:58 +0400 |
commit | a9b7bf3fb3e1334d8defd05ca4cfae870b4912e5 (patch) | |
tree | 2dab453d94d5e003379a6cc895eceb84c80e23ec /src/filters/parser/SSFSplitter | |
parent | aafd49a91f7c2fa9c7103971c16fa6e1b29e8bfd (diff) |
astyle formatting cleanup to make the sourcecode more accessible
switch used: astyle --style=ansi --min-conditional-indent=0 --pad=oper --unpad=paren
http://astyle.sourceforge.net/
git-svn-id: https://mpc-hc.svn.sourceforge.net/svnroot/mpc-hc/trunk@1783 10f7b99b-c216-0410-bff0-8a66a9350fd8
Diffstat (limited to 'src/filters/parser/SSFSplitter')
-rw-r--r-- | src/filters/parser/SSFSplitter/SSFSplitter.cpp | 316 | ||||
-rw-r--r-- | src/filters/parser/SSFSplitter/SSFSplitter.h | 34 | ||||
-rw-r--r-- | src/filters/parser/SSFSplitter/resource.h | 2 | ||||
-rw-r--r-- | src/filters/parser/SSFSplitter/stdafx.cpp | 8 | ||||
-rw-r--r-- | src/filters/parser/SSFSplitter/stdafx.h | 8 |
5 files changed, 190 insertions, 178 deletions
diff --git a/src/filters/parser/SSFSplitter/SSFSplitter.cpp b/src/filters/parser/SSFSplitter/SSFSplitter.cpp index d4cafd14e..5858ae13f 100644 --- a/src/filters/parser/SSFSplitter/SSFSplitter.cpp +++ b/src/filters/parser/SSFSplitter/SSFSplitter.cpp @@ -1,4 +1,4 @@ -/*
+/*
* Copyright (C) 2003-2006 Gabest
* http://www.gabest.org
*
@@ -6,15 +6,15 @@ * it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2, or (at your option)
* any later version.
- *
+ *
* This Program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
- *
+ *
* You should have received a copy of the GNU General Public License
* along with GNU Make; see the file COPYING. If not, write to
- * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
+ * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
* http://www.gnu.org/copyleft/gpl.html
*
*/
@@ -28,8 +28,8 @@ const AMOVIESETUP_MEDIATYPE sudPinTypesIn[] =
{
- {&MEDIATYPE_Stream, &MEDIASUBTYPE_SSF},
- {&MEDIATYPE_Stream, &MEDIASUBTYPE_NULL},
+ {&MEDIATYPE_Stream, &MEDIASUBTYPE_SSF},
+ {&MEDIATYPE_Stream, &MEDIASUBTYPE_NULL},
};
const AMOVIESETUP_PIN sudpPins[] =
@@ -40,30 +40,30 @@ const AMOVIESETUP_PIN sudpPins[] = const AMOVIESETUP_FILTER sudFilter[] =
{
- {&__uuidof(CSSFSplitterFilter), L"MPC - SSF Splitter", MERIT_NORMAL, countof(sudpPins), sudpPins, CLSID_LegacyAmFilterCategory},
- {&__uuidof(CSSFSourceFilter), L"MPC - SSF Source", MERIT_NORMAL, 0, NULL, CLSID_LegacyAmFilterCategory},
+ {&__uuidof(CSSFSplitterFilter), L"MPC - SSF Splitter", MERIT_NORMAL, countof(sudpPins), sudpPins, CLSID_LegacyAmFilterCategory},
+ {&__uuidof(CSSFSourceFilter), L"MPC - SSF Source", MERIT_NORMAL, 0, NULL, CLSID_LegacyAmFilterCategory},
};
CFactoryTemplate g_Templates[] =
{
- {sudFilter[0].strName, sudFilter[0].clsID, CreateInstance<CSSFSplitterFilter>, NULL, &sudFilter[0]},
- {sudFilter[1].strName, sudFilter[1].clsID, CreateInstance<CSSFSourceFilter>, NULL, &sudFilter[1]},
+ {sudFilter[0].strName, sudFilter[0].clsID, CreateInstance<CSSFSplitterFilter>, NULL, &sudFilter[0]},
+ {sudFilter[1].strName, sudFilter[1].clsID, CreateInstance<CSSFSourceFilter>, NULL, &sudFilter[1]},
};
int g_cTemplates = countof(g_Templates);
STDAPI DllRegisterServer()
{
- SetRegKeyValue(_T("Media Type\\Extensions"), _T(".ssf"), _T("Source Filter"), CStringFromGUID(__uuidof(CSSFSourceFilter)));
+ SetRegKeyValue(_T("Media Type\\Extensions"), _T(".ssf"), _T("Source Filter"), CStringFromGUID(__uuidof(CSSFSourceFilter)));
- return AMovieDllRegisterServer2(TRUE);
+ return AMovieDllRegisterServer2(TRUE);
}
STDAPI DllUnregisterServer()
{
- DeleteRegKey(_T("Media Type\\Extensions"), _T(".ssf"));
+ DeleteRegKey(_T("Media Type\\Extensions"), _T(".ssf"));
- return AMovieDllRegisterServer2(FALSE);
+ return AMovieDllRegisterServer2(FALSE);
}
#include "../../FilterApp.h"
@@ -74,33 +74,33 @@ CFilterApp theApp; namespace ssf
{
- class InputStreamBSF : public InputStream
- {
- CBaseSplitterFile* m_pFile;
-
- public:
- InputStreamBSF(CBaseSplitterFile* pFile)
- : m_pFile(pFile)
- {
- ASSERT(m_pFile);
- }
-
- int InputStreamBSF::NextByte()
- {
- if(!m_pFile) ThrowError(_T("m_pFile is NULL"));
- if(!m_pFile->GetRemaining()) return EOS;
- return (int)m_pFile->BitRead(8);
- }
- };
+class InputStreamBSF : public InputStream
+{
+ CBaseSplitterFile* m_pFile;
+
+public:
+ InputStreamBSF(CBaseSplitterFile* pFile)
+ : m_pFile(pFile)
+ {
+ ASSERT(m_pFile);
+ }
+
+ int InputStreamBSF::NextByte()
+ {
+ if(!m_pFile) ThrowError(_T("m_pFile is NULL"));
+ if(!m_pFile->GetRemaining()) return EOS;
+ return (int)m_pFile->BitRead(8);
+ }
+};
}
int CSSFSplitterFilter::SegmentItemEx::Compare(const void* a, const void* b)
{
- const SegmentItemEx* si1 = (const SegmentItemEx*)a;
- const SegmentItemEx* si2 = (const SegmentItemEx*)b;
- if(si1->start < si2->start) return -1;
- if(si2->start < si1->start) return +1;
- return 0;
+ const SegmentItemEx* si1 = (const SegmentItemEx*)a;
+ const SegmentItemEx* si2 = (const SegmentItemEx*)b;
+ if(si1->start < si2->start) return -1;
+ if(si2->start < si1->start) return +1;
+ return 0;
}
//
@@ -108,142 +108,154 @@ int CSSFSplitterFilter::SegmentItemEx::Compare(const void* a, const void* b) //
CSSFSplitterFilter::CSSFSplitterFilter(LPUNKNOWN pUnk, HRESULT* phr)
- : CBaseSplitterFilter(NAME("CSSFSplitterFilter"), pUnk, phr, __uuidof(this))
+ : CBaseSplitterFilter(NAME("CSSFSplitterFilter"), pUnk, phr, __uuidof(this))
{
}
HRESULT CSSFSplitterFilter::CreateOutputs(IAsyncReader* pAsyncReader)
{
- CheckPointer(pAsyncReader, E_POINTER);
-
- HRESULT hr = E_FAIL;
-
- m_pFile.Free();
- m_pFile.Attach(DNew CBaseSplitterFile(pAsyncReader, hr));
- if(!m_pFile) return E_OUTOFMEMORY;
- if(FAILED(hr)) {m_pFile.Free(); return hr;}
-
- try {m_ssf.Parse(ssf::InputStreamBSF(m_pFile));}
- catch(ssf::Exception&) {return E_FAIL;}
-
- //
-
- m_rtNewStart = m_rtCurrent = 0;
- m_rtNewStop = m_rtStop = m_rtDuration = 0;
-
- if(ssf::Reference* pRootRef = m_ssf.GetRootRef())
- {
- ssf::WCharOutputStream s;
- ssf::StringMapW<float> offset;
-
- POSITION pos = pRootRef->m_nodes.GetHeadPosition();
- while(pos)
- {
- if(ssf::Definition* pDef = dynamic_cast<ssf::Definition*>(pRootRef->m_nodes.GetNext(pos)))
- {
- try
- {
- ssf::Definition::Time time;
-
- if(pDef->m_type == L"subtitle" && pDef->GetAsTime(time, offset) && (*pDef)[L"@"].IsValue())
- {
- SegmentItemEx si;
- si.pDef = pDef;
- si.start = time.start.value;
- si.stop = time.stop.value;
- m_subs.AddTail(si);
-
- // m_ssf.SetTime(pDef, si.start, si.stop);
-
- continue;
- }
- }
- catch(ssf::Exception&)
- {
- }
-
- pDef->Dump(s);
- }
- }
-
- CStringA hdr = UTF16To8(s.GetString());
-
- CAtlArray<CMediaType> mts;
-
- CMediaType mt;
- mt.majortype = MEDIATYPE_Subtitle;
- mt.subtype = MEDIASUBTYPE_SSF;
- mt.formattype = FORMAT_SubtitleInfo;
- SUBTITLEINFO* si = (SUBTITLEINFO*)mt.AllocFormatBuffer(sizeof(SUBTITLEINFO) + hdr.GetLength() + 3);
- memset(si, 0, sizeof(*si));
- si->dwOffset = sizeof(*si);
- BYTE* p = (BYTE*)(si+1);
- p[0] = 0xef; p[1] = 0xbb; p[2] = 0xbf;
- memcpy(&p[3], (LPCSTR)hdr, hdr.GetLength());
- mts.Add(mt);
-
- CAutoPtr<CBaseSplitterOutputPin> pPinOut(DNew CBaseSplitterOutputPin(mts, L"Output", this, this, &hr));
- EXECUTE_ASSERT(SUCCEEDED(AddOutputPin(0, pPinOut)));
-
- CAtlArray<SegmentItemEx> subs;
- subs.SetCount(m_subs.GetCount());
- pos = m_subs.GetHeadPosition();
- for(size_t i = 0; pos; i++) subs.SetAt(i, m_subs.GetNext(pos));
- qsort(subs.GetData(), subs.GetCount(), sizeof(SegmentItemEx), SegmentItemEx::Compare);
- m_subs.RemoveAll();
- for(size_t i = 0; i < subs.GetCount(); i++) m_subs.AddTail(subs[i]);
-
- if(!m_ssf.m_segments.IsEmpty())
- {
- m_rtNewStop = m_rtStop = m_rtDuration = 10000000i64*m_ssf.m_segments.GetTail().m_stop;
- }
- }
-
- return m_pOutputs.GetCount() > 0 ? S_OK : E_FAIL;
+ CheckPointer(pAsyncReader, E_POINTER);
+
+ HRESULT hr = E_FAIL;
+
+ m_pFile.Free();
+ m_pFile.Attach(DNew CBaseSplitterFile(pAsyncReader, hr));
+ if(!m_pFile) return E_OUTOFMEMORY;
+ if(FAILED(hr))
+ {
+ m_pFile.Free();
+ return hr;
+ }
+
+ try
+ {
+ m_ssf.Parse(ssf::InputStreamBSF(m_pFile));
+ }
+ catch(ssf::Exception&)
+ {
+ return E_FAIL;
+ }
+
+ //
+
+ m_rtNewStart = m_rtCurrent = 0;
+ m_rtNewStop = m_rtStop = m_rtDuration = 0;
+
+ if(ssf::Reference* pRootRef = m_ssf.GetRootRef())
+ {
+ ssf::WCharOutputStream s;
+ ssf::StringMapW<float> offset;
+
+ POSITION pos = pRootRef->m_nodes.GetHeadPosition();
+ while(pos)
+ {
+ if(ssf::Definition* pDef = dynamic_cast<ssf::Definition*>(pRootRef->m_nodes.GetNext(pos)))
+ {
+ try
+ {
+ ssf::Definition::Time time;
+
+ if(pDef->m_type == L"subtitle" && pDef->GetAsTime(time, offset) && (*pDef)[L"@"].IsValue())
+ {
+ SegmentItemEx si;
+ si.pDef = pDef;
+ si.start = time.start.value;
+ si.stop = time.stop.value;
+ m_subs.AddTail(si);
+
+ // m_ssf.SetTime(pDef, si.start, si.stop);
+
+ continue;
+ }
+ }
+ catch(ssf::Exception&)
+ {
+ }
+
+ pDef->Dump(s);
+ }
+ }
+
+ CStringA hdr = UTF16To8(s.GetString());
+
+ CAtlArray<CMediaType> mts;
+
+ CMediaType mt;
+ mt.majortype = MEDIATYPE_Subtitle;
+ mt.subtype = MEDIASUBTYPE_SSF;
+ mt.formattype = FORMAT_SubtitleInfo;
+ SUBTITLEINFO* si = (SUBTITLEINFO*)mt.AllocFormatBuffer(sizeof(SUBTITLEINFO) + hdr.GetLength() + 3);
+ memset(si, 0, sizeof(*si));
+ si->dwOffset = sizeof(*si);
+ BYTE* p = (BYTE*)(si + 1);
+ p[0] = 0xef;
+ p[1] = 0xbb;
+ p[2] = 0xbf;
+ memcpy(&p[3], (LPCSTR)hdr, hdr.GetLength());
+ mts.Add(mt);
+
+ CAutoPtr<CBaseSplitterOutputPin> pPinOut(DNew CBaseSplitterOutputPin(mts, L"Output", this, this, &hr));
+ EXECUTE_ASSERT(SUCCEEDED(AddOutputPin(0, pPinOut)));
+
+ CAtlArray<SegmentItemEx> subs;
+ subs.SetCount(m_subs.GetCount());
+ pos = m_subs.GetHeadPosition();
+ for(size_t i = 0; pos; i++) subs.SetAt(i, m_subs.GetNext(pos));
+ qsort(subs.GetData(), subs.GetCount(), sizeof(SegmentItemEx), SegmentItemEx::Compare);
+ m_subs.RemoveAll();
+ for(size_t i = 0; i < subs.GetCount(); i++) m_subs.AddTail(subs[i]);
+
+ if(!m_ssf.m_segments.IsEmpty())
+ {
+ m_rtNewStop = m_rtStop = m_rtDuration = 10000000i64 * m_ssf.m_segments.GetTail().m_stop;
+ }
+ }
+
+ return m_pOutputs.GetCount() > 0 ? S_OK : E_FAIL;
}
bool CSSFSplitterFilter::DemuxInit()
{
- return true;
+ return true;
}
void CSSFSplitterFilter::DemuxSeek(REFERENCE_TIME rt)
{
- if(rt <= 0)
- {
- }
- else
- {
- // TODO
- }
+ if(rt <= 0)
+ {
+ }
+ else
+ {
+ // TODO
+ }
}
bool CSSFSplitterFilter::DemuxLoop()
{
- HRESULT hr = S_OK;
+ HRESULT hr = S_OK;
- POSITION pos = m_subs.GetHeadPosition();
+ POSITION pos = m_subs.GetHeadPosition();
- while(pos && SUCCEEDED(hr) && !CheckRequest(NULL))
- {
- SegmentItemEx& si = m_subs.GetNext(pos);
+ while(pos && SUCCEEDED(hr) && !CheckRequest(NULL))
+ {
+ SegmentItemEx& si = m_subs.GetNext(pos);
- ssf::WCharOutputStream s;
- si.pDef->Dump(s);
- CStringA& str = UTF16To8(s.GetString());
+ ssf::WCharOutputStream s;
+ si.pDef->Dump(s);
+ CStringA& str = UTF16To8(s.GetString());
- CAutoPtr<Packet> p(DNew Packet());
+ CAutoPtr<Packet> p(DNew Packet());
- p->TrackNumber = 0;
- p->bSyncPoint = TRUE; // TODO
- p->rtStart = 10000000i64*si.start;
- p->rtStop = 10000000i64*si.stop;
- p->SetData((LPCSTR)str, str.GetLength());
+ p->TrackNumber = 0;
+ p->bSyncPoint = TRUE; // TODO
+ p->rtStart = 10000000i64 * si.start;
+ p->rtStop = 10000000i64 * si.stop;
+ p->SetData((LPCSTR)str, str.GetLength());
- hr = DeliverPacket(p);
- }
+ hr = DeliverPacket(p);
+ }
- return true;
+ return true;
}
//
@@ -251,8 +263,8 @@ bool CSSFSplitterFilter::DemuxLoop() //
CSSFSourceFilter::CSSFSourceFilter(LPUNKNOWN pUnk, HRESULT* phr)
- : CSSFSplitterFilter(pUnk, phr)
+ : CSSFSplitterFilter(pUnk, phr)
{
- m_clsid = __uuidof(this);
- m_pInput.Free();
+ m_clsid = __uuidof(this);
+ m_pInput.Free();
}
diff --git a/src/filters/parser/SSFSplitter/SSFSplitter.h b/src/filters/parser/SSFSplitter/SSFSplitter.h index abd82b5fe..26b6ae48a 100644 --- a/src/filters/parser/SSFSplitter/SSFSplitter.h +++ b/src/filters/parser/SSFSplitter/SSFSplitter.h @@ -1,4 +1,4 @@ -/*
+/*
* Copyright (C) 2003-2006 Gabest
* http://www.gabest.org
*
@@ -6,15 +6,15 @@ * it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2, or (at your option)
* any later version.
- *
+ *
* This Program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
- *
+ *
* You should have received a copy of the GNU General Public License
* along with GNU Make; see the file COPYING. If not, write to
- * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
+ * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
* http://www.gnu.org/copyleft/gpl.html
*
*/
@@ -27,31 +27,31 @@ [uuid("95C3F9F6-1E05-4C34-8122-504476EACB51")]
class CSSFSplitterFilter : public CBaseSplitterFilter
{
- CAutoPtr<CBaseSplitterFile> m_pFile;
+ CAutoPtr<CBaseSplitterFile> m_pFile;
- ssf::SubtitleFile m_ssf;
+ ssf::SubtitleFile m_ssf;
- struct SegmentItemEx : public ssf::SubtitleFile::SegmentItem
- {
- static int Compare(const void* a, const void* b);
- };
+ struct SegmentItemEx : public ssf::SubtitleFile::SegmentItem
+ {
+ static int Compare(const void* a, const void* b);
+ };
- CAtlList<SegmentItemEx> m_subs;
+ CAtlList<SegmentItemEx> m_subs;
protected:
- HRESULT CreateOutputs(IAsyncReader* pAsyncReader);
+ HRESULT CreateOutputs(IAsyncReader* pAsyncReader);
- bool DemuxInit();
- void DemuxSeek(REFERENCE_TIME rt);
- bool DemuxLoop();
+ bool DemuxInit();
+ void DemuxSeek(REFERENCE_TIME rt);
+ bool DemuxLoop();
public:
- CSSFSplitterFilter(LPUNKNOWN pUnk, HRESULT* phr);
+ CSSFSplitterFilter(LPUNKNOWN pUnk, HRESULT* phr);
};
[uuid("57F46A2A-6DC9-4A9F-B5FA-DFDD62B8BAFB")]
class CSSFSourceFilter : public CSSFSplitterFilter
{
public:
- CSSFSourceFilter(LPUNKNOWN pUnk, HRESULT* phr);
+ CSSFSourceFilter(LPUNKNOWN pUnk, HRESULT* phr);
};
diff --git a/src/filters/parser/SSFSplitter/resource.h b/src/filters/parser/SSFSplitter/resource.h index ac2936f6e..67ed4aab3 100644 --- a/src/filters/parser/SSFSplitter/resource.h +++ b/src/filters/parser/SSFSplitter/resource.h @@ -3,7 +3,7 @@ // Used by SSFSplitter.rc
// Next default values for new objects
-//
+//
#ifdef APSTUDIO_INVOKED
#ifndef APSTUDIO_READONLY_SYMBOLS
#define _APS_NEXT_RESOURCE_VALUE 101
diff --git a/src/filters/parser/SSFSplitter/stdafx.cpp b/src/filters/parser/SSFSplitter/stdafx.cpp index 924d2f316..b52e42b40 100644 --- a/src/filters/parser/SSFSplitter/stdafx.cpp +++ b/src/filters/parser/SSFSplitter/stdafx.cpp @@ -1,4 +1,4 @@ -/*
+/*
* Copyright (C) 2003-2006 Gabest
* http://www.gabest.org
*
@@ -6,15 +6,15 @@ * it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2, or (at your option)
* any later version.
- *
+ *
* This Program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
- *
+ *
* You should have received a copy of the GNU General Public License
* along with GNU Make; see the file COPYING. If not, write to
- * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
+ * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
* http://www.gnu.org/copyleft/gpl.html
*
*/
diff --git a/src/filters/parser/SSFSplitter/stdafx.h b/src/filters/parser/SSFSplitter/stdafx.h index 043e18b3c..5eae4881c 100644 --- a/src/filters/parser/SSFSplitter/stdafx.h +++ b/src/filters/parser/SSFSplitter/stdafx.h @@ -1,4 +1,4 @@ -/*
+/*
* Copyright (C) 2003-2006 Gabest
* http://www.gabest.org
*
@@ -6,15 +6,15 @@ * it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2, or (at your option)
* any later version.
- *
+ *
* This Program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
- *
+ *
* You should have received a copy of the GNU General Public License
* along with GNU Make; see the file COPYING. If not, write to
- * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
+ * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
* http://www.gnu.org/copyleft/gpl.html
*
*/
|