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

github.com/mpc-hc/mpc-hc.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorXhmikosR <xhmikosr@users.sourceforge.net>2010-04-09 18:12:59 +0400
committerXhmikosR <xhmikosr@users.sourceforge.net>2010-04-09 18:12:59 +0400
commitefbc9d9043ff8ff92716ddd00a5f61412d535593 (patch)
tree8f3e621f756cf1f5b4d64d97964c7e7abd8aaf08 /src/filters/parser/SSFSplitter
parentdf6b139a6d9027156f614b68687e039e3a5854db (diff)
revert r1783
git-svn-id: https://mpc-hc.svn.sourceforge.net/svnroot/mpc-hc/trunk@1785 10f7b99b-c216-0410-bff0-8a66a9350fd8
Diffstat (limited to 'src/filters/parser/SSFSplitter')
-rw-r--r--src/filters/parser/SSFSplitter/SSFSplitter.cpp316
-rw-r--r--src/filters/parser/SSFSplitter/SSFSplitter.h34
-rw-r--r--src/filters/parser/SSFSplitter/resource.h2
-rw-r--r--src/filters/parser/SSFSplitter/stdafx.cpp8
-rw-r--r--src/filters/parser/SSFSplitter/stdafx.h8
5 files changed, 178 insertions, 190 deletions
diff --git a/src/filters/parser/SSFSplitter/SSFSplitter.cpp b/src/filters/parser/SSFSplitter/SSFSplitter.cpp
index 5858ae13f..d4cafd14e 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,154 +108,142 @@ 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;
}
//
@@ -263,8 +251,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 26b6ae48a..abd82b5fe 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 67ed4aab3..ac2936f6e 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 b52e42b40..924d2f316 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 5eae4881c..043e18b3c 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
*
*/