diff options
author | povaddict <povaddict@users.sourceforge.net> | 2010-02-10 02:16:44 +0300 |
---|---|---|
committer | povaddict <povaddict@users.sourceforge.net> | 2010-02-10 02:16:44 +0300 |
commit | 726a91b12a7524e45e7a901c9e4883af5b1bffe6 (patch) | |
tree | f5d25e3b2e84c92f4901280c73d5d3d7e6c3cd19 /src/filters/parser/DSMSplitter | |
parent | 02183f6e47ad4ea1057de9950482f291f2ae4290 (diff) |
Rename several directories to use MixedCase instead of lowercase.
They now mostly match the case used in #includes,
and they're consistent with the names of the .h files they contain.
git-svn-id: https://mpc-hc.svn.sourceforge.net/svnroot/mpc-hc/trunk@1648 10f7b99b-c216-0410-bff0-8a66a9350fd8
Diffstat (limited to 'src/filters/parser/DSMSplitter')
-rw-r--r-- | src/filters/parser/DSMSplitter/DSMSplitter.cpp | 258 | ||||
-rw-r--r-- | src/filters/parser/DSMSplitter/DSMSplitter.def | 7 | ||||
-rw-r--r-- | src/filters/parser/DSMSplitter/DSMSplitter.h | 55 | ||||
-rw-r--r-- | src/filters/parser/DSMSplitter/DSMSplitter.rc | 105 | ||||
-rw-r--r-- | src/filters/parser/DSMSplitter/DSMSplitter.vcproj | 763 | ||||
-rw-r--r-- | src/filters/parser/DSMSplitter/DSMSplitterFile.cpp | 397 | ||||
-rw-r--r-- | src/filters/parser/DSMSplitter/DSMSplitterFile.h | 35 | ||||
-rw-r--r-- | src/filters/parser/DSMSplitter/resource.h | 14 | ||||
-rw-r--r-- | src/filters/parser/DSMSplitter/stdafx.cpp | 29 | ||||
-rw-r--r-- | src/filters/parser/DSMSplitter/stdafx.h | 45 |
10 files changed, 1708 insertions, 0 deletions
diff --git a/src/filters/parser/DSMSplitter/DSMSplitter.cpp b/src/filters/parser/DSMSplitter/DSMSplitter.cpp new file mode 100644 index 000000000..fef9a9044 --- /dev/null +++ b/src/filters/parser/DSMSplitter/DSMSplitter.cpp @@ -0,0 +1,258 @@ +/*
+ * Copyright (C) 2003-2006 Gabest
+ * http://www.gabest.org
+ *
+ * This Program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2, or (at your option)
+ * any later version.
+ *
+ * This Program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with GNU Make; see the file COPYING. If not, write to
+ * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
+ * http://www.gnu.org/copyleft/gpl.html
+ *
+ */
+
+#include "StdAfx.h"
+#include "DSMSplitter.h"
+#include "../../../DSUtil/DSUtil.h"
+
+#include <initguid.h>
+#include <moreuuids.h>
+
+#ifdef REGISTER_FILTER
+
+const AMOVIESETUP_MEDIATYPE sudPinTypesIn[] =
+{
+ {&MEDIATYPE_Stream, &MEDIASUBTYPE_DirectShowMedia},
+ {&MEDIATYPE_Stream, &MEDIASUBTYPE_NULL},
+};
+
+const AMOVIESETUP_PIN sudpPins[] =
+{
+ {L"Input", FALSE, FALSE, FALSE, FALSE, &CLSID_NULL, NULL, countof(sudPinTypesIn), sudPinTypesIn},
+ {L"Output", FALSE, TRUE, FALSE, FALSE, &CLSID_NULL, NULL, 0, NULL}
+};
+
+const AMOVIESETUP_FILTER sudFilter[] =
+{
+ {&__uuidof(CDSMSplitterFilter), L"MPC - DSM Splitter", MERIT_NORMAL, countof(sudpPins), sudpPins, CLSID_LegacyAmFilterCategory},
+ {&__uuidof(CDSMSourceFilter), L"MPC - DSM Source", MERIT_NORMAL, 0, NULL, CLSID_LegacyAmFilterCategory},
+};
+
+CFactoryTemplate g_Templates[] =
+{
+ {sudFilter[0].strName, sudFilter[0].clsID, CreateInstance<CDSMSplitterFilter>, NULL, &sudFilter[0]},
+ {sudFilter[1].strName, sudFilter[1].clsID, CreateInstance<CDSMSourceFilter>, NULL, &sudFilter[1]},
+};
+
+int g_cTemplates = countof(g_Templates);
+
+STDAPI DllRegisterServer()
+{
+ CString str;
+ str.Format(_T("0,%d,,%%0%dI64x"), DSMSW_SIZE, DSMSW_SIZE*2);
+ str.Format(CString(str), DSMSW);
+
+ RegisterSourceFilter(
+ CLSID_AsyncReader,
+ MEDIASUBTYPE_DirectShowMedia,
+ str, NULL);
+
+ return AMovieDllRegisterServer2(TRUE);
+}
+
+STDAPI DllUnregisterServer()
+{
+ UnRegisterSourceFilter(MEDIASUBTYPE_DirectShowMedia);
+
+ return AMovieDllRegisterServer2(FALSE);
+}
+
+#include "../../FilterApp.h"
+
+CFilterApp theApp;
+
+#endif
+
+//
+// CDSMSplitterFilter
+//
+
+CDSMSplitterFilter::CDSMSplitterFilter(LPUNKNOWN pUnk, HRESULT* phr)
+ : CBaseSplitterFilter(NAME("CDSMSplitterFilter"), pUnk, phr, __uuidof(this))
+{
+}
+
+CDSMSplitterFilter::~CDSMSplitterFilter()
+{
+}
+
+static int compare_id(const void* id1, const void* id2) {return (int)*(BYTE*)id1 - (int)*(BYTE*)id2;}
+
+HRESULT CDSMSplitterFilter::CreateOutputs(IAsyncReader* pAsyncReader)
+{
+ CheckPointer(pAsyncReader, E_POINTER);
+
+ HRESULT hr = E_FAIL;
+
+ m_pFile.Free();
+ m_pFile.Attach(DNew CDSMSplitterFile(pAsyncReader, hr, *this, *this));
+ if(!m_pFile) return E_OUTOFMEMORY;
+ if(FAILED(hr)) {m_pFile.Free(); return hr;}
+
+ m_rtNewStart = m_rtCurrent = 0;
+ m_rtNewStop = m_rtStop = m_rtDuration = m_pFile->m_rtDuration;
+
+ CAtlArray<BYTE> ids;
+
+ POSITION pos = m_pFile->m_mts.GetStartPosition();
+ while(pos)
+ {
+ BYTE id;
+ CMediaType mt;
+ m_pFile->m_mts.GetNextAssoc(pos, id, mt);
+ ids.Add(id);
+ }
+
+ qsort(ids.GetData(), ids.GetCount(), sizeof(BYTE), compare_id);
+
+ for(int i = 0; i < ids.GetCount(); i++)
+ {
+ BYTE id = ids[i];
+ CMediaType& mt = m_pFile->m_mts[id];
+
+ CStringW name, lang;
+ name.Format(L"Output %02d", id);
+
+ CAtlArray<CMediaType> mts;
+ mts.Add(mt);
+
+ CAutoPtr<CBaseSplitterOutputPin> pPinOut(DNew CBaseSplitterOutputPin(mts, name, this, this, &hr));
+
+ name.Empty();
+
+ pos = m_pFile->m_sim[id].GetStartPosition();
+ while(pos)
+ {
+ CStringA key; CStringW value;
+ m_pFile->m_sim[id].GetNextAssoc(pos, key, value);
+ pPinOut->SetProperty(CStringW(key), value);
+
+ if(key == "NAME") name = value;
+ if(key == "LANG") if((lang = ISO6392ToLanguage(CStringA(CString(value)))).IsEmpty()) lang = value;
+ }
+
+ if(!name.IsEmpty() || !lang.IsEmpty())
+ {
+ if(!name.IsEmpty()) {if(!lang.IsEmpty()) name += L" (" + lang + L")";}
+ else if(!lang.IsEmpty()) name = lang;
+ pPinOut->SetName(name);
+ }
+
+ EXECUTE_ASSERT(SUCCEEDED(AddOutputPin(id, pPinOut)));
+ }
+
+ pos = m_pFile->m_fim.GetStartPosition();
+ while(pos)
+ {
+ CStringA key; CStringW value;
+ m_pFile->m_fim.GetNextAssoc(pos, key, value);
+ SetProperty(CStringW(key), value);
+ }
+
+ for(int i = 0; i < m_resources.GetCount(); i++)
+ {
+ const CDSMResource& r = m_resources[i];
+ if(r.mime == "application/x-truetype-font")
+ m_fontinst.InstallFont(r.data);
+ }
+
+ return m_pOutputs.GetCount() > 0 ? S_OK : E_FAIL;
+}
+
+bool CDSMSplitterFilter::DemuxInit()
+{
+ return true;
+}
+
+void CDSMSplitterFilter::DemuxSeek(REFERENCE_TIME rt)
+{
+ m_pFile->Seek(m_pFile->FindSyncPoint(rt));
+}
+
+bool CDSMSplitterFilter::DemuxLoop()
+{
+ HRESULT hr = S_OK;
+
+ while(SUCCEEDED(hr) && !CheckRequest(NULL) && m_pFile->GetRemaining())
+ {
+ dsmp_t type;
+ UINT64 len;
+
+ if(!m_pFile->Sync(type, len))
+ continue;
+
+ __int64 pos = m_pFile->GetPos();
+
+ if(type == DSMP_SAMPLE)
+ {
+ CAutoPtr<Packet> p(DNew Packet());
+ if(m_pFile->Read(len, p))
+ {
+ if(p->rtStart != Packet::INVALID_TIME)
+ {
+ p->rtStart -= m_pFile->m_rtFirst;
+ p->rtStop -= m_pFile->m_rtFirst;
+ }
+
+ hr = DeliverPacket(p);
+ }
+ }
+
+ m_pFile->Seek(pos + len);
+ }
+
+ return(true);
+}
+
+// IKeyFrameInfo
+
+STDMETHODIMP CDSMSplitterFilter::GetKeyFrameCount(UINT& nKFs)
+{
+ CheckPointer(m_pFile, E_UNEXPECTED);
+ nKFs = m_pFile->m_sps.GetCount();
+ return S_OK;
+}
+
+STDMETHODIMP CDSMSplitterFilter::GetKeyFrames(const GUID* pFormat, REFERENCE_TIME* pKFs, UINT& nKFs)
+{
+ CheckPointer(pFormat, E_POINTER);
+ CheckPointer(pKFs, E_POINTER);
+ CheckPointer(m_pFile, E_UNEXPECTED);
+
+ if(*pFormat != TIME_FORMAT_MEDIA_TIME) return E_INVALIDARG;
+
+ // these aren't really the keyframes, but quicky accessable points in the stream
+ for(nKFs = 0; nKFs < m_pFile->m_sps.GetCount(); nKFs++)
+ pKFs[nKFs] = m_pFile->m_sps[nKFs].rt;
+
+ return S_OK;
+}
+
+//
+// CDSMSourceFilter
+//
+
+CDSMSourceFilter::CDSMSourceFilter(LPUNKNOWN pUnk, HRESULT* phr)
+ : CDSMSplitterFilter(pUnk, phr)
+{
+ m_clsid = __uuidof(this);
+ m_pInput.Free();
+}
diff --git a/src/filters/parser/DSMSplitter/DSMSplitter.def b/src/filters/parser/DSMSplitter/DSMSplitter.def new file mode 100644 index 000000000..c5768b981 --- /dev/null +++ b/src/filters/parser/DSMSplitter/DSMSplitter.def @@ -0,0 +1,7 @@ +LIBRARY "DSMSplitter.ax"
+
+EXPORTS
+ DllCanUnloadNow PRIVATE
+ DllGetClassObject PRIVATE
+ DllRegisterServer PRIVATE
+ DllUnregisterServer PRIVATE
diff --git a/src/filters/parser/DSMSplitter/DSMSplitter.h b/src/filters/parser/DSMSplitter/DSMSplitter.h new file mode 100644 index 000000000..77bc53cad --- /dev/null +++ b/src/filters/parser/DSMSplitter/DSMSplitter.h @@ -0,0 +1,55 @@ +/*
+ * Copyright (C) 2003-2006 Gabest
+ * http://www.gabest.org
+ *
+ * This Program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2, or (at your option)
+ * any later version.
+ *
+ * This Program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with GNU Make; see the file COPYING. If not, write to
+ * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
+ * http://www.gnu.org/copyleft/gpl.html
+ *
+ */
+
+#pragma once
+
+#include <atlbase.h>
+#include <atlcoll.h>
+#include "DSMSplitterFile.h"
+#include "../BaseSplitter/BaseSplitter.h"
+
+[uuid("0912B4DD-A30A-4568-B590-7179EBB420EC")]
+class CDSMSplitterFilter : public CBaseSplitterFilter
+{
+protected:
+ CAutoPtr<CDSMSplitterFile> m_pFile;
+ HRESULT CreateOutputs(IAsyncReader* pAsyncReader);
+
+ bool DemuxInit();
+ void DemuxSeek(REFERENCE_TIME rt);
+ bool DemuxLoop();
+
+public:
+ CDSMSplitterFilter(LPUNKNOWN pUnk, HRESULT* phr);
+ virtual ~CDSMSplitterFilter();
+
+ // IKeyFrameInfo
+
+ STDMETHODIMP_(HRESULT) GetKeyFrameCount(UINT& nKFs);
+ STDMETHODIMP_(HRESULT) GetKeyFrames(const GUID* pFormat, REFERENCE_TIME* pKFs, UINT& nKFs);
+};
+
+[uuid("803E8280-F3CE-4201-982C-8CD8FB512004")]
+class CDSMSourceFilter : public CDSMSplitterFilter
+{
+public:
+ CDSMSourceFilter(LPUNKNOWN pUnk, HRESULT* phr);
+};
diff --git a/src/filters/parser/DSMSplitter/DSMSplitter.rc b/src/filters/parser/DSMSplitter/DSMSplitter.rc new file mode 100644 index 000000000..381bb8c70 --- /dev/null +++ b/src/filters/parser/DSMSplitter/DSMSplitter.rc @@ -0,0 +1,105 @@ +// Microsoft Visual C++ generated resource script.
+//
+#include "resource.h"
+#include "..\..\..\..\include\Version.h"
+
+#define APSTUDIO_READONLY_SYMBOLS
+/////////////////////////////////////////////////////////////////////////////
+//
+// Generated from the TEXTINCLUDE 2 resource.
+//
+#include "afxres.h"
+
+/////////////////////////////////////////////////////////////////////////////
+#undef APSTUDIO_READONLY_SYMBOLS
+
+/////////////////////////////////////////////////////////////////////////////
+// English (U.S.) resources
+
+#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU)
+#ifdef _WIN32
+LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US
+#pragma code_page(1252)
+#endif //_WIN32
+
+/////////////////////////////////////////////////////////////////////////////
+//
+// Version
+//
+
+VS_VERSION_INFO VERSIONINFO
+ FILEVERSION VERSION_MAJOR,VERSION_MINOR,VERSION_REV,VERSION_PATCH
+ PRODUCTVERSION VERSION_MAJOR,VERSION_MINOR,VERSION_REV,VERSION_PATCH
+ FILEFLAGSMASK 0x17L
+#ifdef _DEBUG
+ FILEFLAGS 0x1L
+#else
+ FILEFLAGS 0x0L
+#endif
+ FILEOS 0x4L
+ FILETYPE 0x7L
+ FILESUBTYPE 0x0L
+BEGIN
+ BLOCK "StringFileInfo"
+ BEGIN
+ BLOCK "040904b0"
+ BEGIN
+ VALUE "Comments", "http://sourceforge.net/projects/mpc-hc/"
+ VALUE "CompanyName", "MPC-HC Team"
+ VALUE "FileDescription", "DSM Splitter"
+ VALUE "FileVersion", "1, 1, 0, 0"
+ VALUE "InternalName", "DSM Splitter"
+ VALUE "LegalCopyright", "Copyright (C) 2002-2010 see AUTHORS file"
+ VALUE "OriginalFilename", "DSMSplitter.ax"
+ VALUE "ProductName", "DSM Splitter"
+ VALUE "ProductVersion", "1, 1, 0, 0"
+ END
+ END
+ BLOCK "VarFileInfo"
+ BEGIN
+ VALUE "Translation", 0x409, 1200
+ END
+END
+
+
+#ifdef APSTUDIO_INVOKED
+/////////////////////////////////////////////////////////////////////////////
+//
+// TEXTINCLUDE
+//
+
+1 TEXTINCLUDE
+BEGIN
+ "resource.h\0"
+END
+
+2 TEXTINCLUDE
+BEGIN
+ "#include ""afxres.h""\r\n"
+ "\0"
+END
+
+3 TEXTINCLUDE
+BEGIN
+ "\r\n"
+ "\0"
+END
+
+#endif // APSTUDIO_INVOKED
+
+#endif // English (U.S.) resources
+/////////////////////////////////////////////////////////////////////////////
+
+
+
+#ifndef APSTUDIO_INVOKED
+/////////////////////////////////////////////////////////////////////////////
+//
+// Generated from the TEXTINCLUDE 3 resource.
+//
+
+
+/////////////////////////////////////////////////////////////////////////////
+#endif // not APSTUDIO_INVOKED
+
+
diff --git a/src/filters/parser/DSMSplitter/DSMSplitter.vcproj b/src/filters/parser/DSMSplitter/DSMSplitter.vcproj new file mode 100644 index 000000000..afed70409 --- /dev/null +++ b/src/filters/parser/DSMSplitter/DSMSplitter.vcproj @@ -0,0 +1,763 @@ +<?xml version="1.0" encoding="windows-1250"?>
+<VisualStudioProject
+ ProjectType="Visual C++"
+ Version="9,00"
+ Name="DSMSplitter"
+ ProjectGUID="{1E91F58C-0BAE-4021-8087-D1864D8EC066}"
+ RootNamespace="DSMSplitter"
+ Keyword="Win32Proj"
+ TargetFrameworkVersion="131072"
+ >
+ <Platforms>
+ <Platform
+ Name="Win32"
+ />
+ <Platform
+ Name="x64"
+ />
+ </Platforms>
+ <ToolFiles>
+ </ToolFiles>
+ <Configurations>
+ <Configuration
+ Name="Debug Unicode lib|Win32"
+ ConfigurationType="4"
+ InheritedPropertySheets="..\..\..\common.vsprops;..\..\..\debug.vsprops"
+ UseOfMFC="1"
+ CharacterSet="1"
+ >
+ <Tool
+ Name="VCPreBuildEventTool"
+ />
+ <Tool
+ Name="VCCustomBuildTool"
+ />
+ <Tool
+ Name="VCXMLDataGeneratorTool"
+ />
+ <Tool
+ Name="VCWebServiceProxyGeneratorTool"
+ />
+ <Tool
+ Name="VCMIDLTool"
+ />
+ <Tool
+ Name="VCCLCompilerTool"
+ AdditionalOptions="/MP"
+ AdditionalIncludeDirectories="..\..\..\..\include;..\..\BaseClasses"
+ PreprocessorDefinitions="WIN32;_DEBUG;_LIB"
+ />
+ <Tool
+ Name="VCManagedResourceCompilerTool"
+ />
+ <Tool
+ Name="VCResourceCompilerTool"
+ />
+ <Tool
+ Name="VCPreLinkEventTool"
+ />
+ <Tool
+ Name="VCLibrarianTool"
+ OutputFile="..\..\..\..\lib\$(ProjectName)DU.lib"
+ />
+ <Tool
+ Name="VCALinkTool"
+ />
+ <Tool
+ Name="VCXDCMakeTool"
+ />
+ <Tool
+ Name="VCBscMakeTool"
+ />
+ <Tool
+ Name="VCFxCopTool"
+ />
+ <Tool
+ Name="VCPostBuildEventTool"
+ />
+ </Configuration>
+ <Configuration
+ Name="Debug Unicode lib|x64"
+ OutputDirectory="$(PlatformName)\$(ConfigurationName)"
+ IntermediateDirectory="$(PlatformName)\$(ConfigurationName)"
+ ConfigurationType="4"
+ InheritedPropertySheets="..\..\..\common.vsprops;..\..\..\debug.vsprops"
+ UseOfMFC="1"
+ CharacterSet="1"
+ >
+ <Tool
+ Name="VCPreBuildEventTool"
+ />
+ <Tool
+ Name="VCCustomBuildTool"
+ />
+ <Tool
+ Name="VCXMLDataGeneratorTool"
+ />
+ <Tool
+ Name="VCWebServiceProxyGeneratorTool"
+ />
+ <Tool
+ Name="VCMIDLTool"
+ TargetEnvironment="3"
+ />
+ <Tool
+ Name="VCCLCompilerTool"
+ AdditionalOptions="/MP"
+ AdditionalIncludeDirectories="..\..\..\..\include;..\..\BaseClasses"
+ PreprocessorDefinitions="_WIN64;_DEBUG;_LIB"
+ DebugInformationFormat="3"
+ />
+ <Tool
+ Name="VCManagedResourceCompilerTool"
+ />
+ <Tool
+ Name="VCResourceCompilerTool"
+ />
+ <Tool
+ Name="VCPreLinkEventTool"
+ />
+ <Tool
+ Name="VCLibrarianTool"
+ OutputFile="..\..\..\..\lib64\$(ProjectName)DU.lib"
+ />
+ <Tool
+ Name="VCALinkTool"
+ />
+ <Tool
+ Name="VCXDCMakeTool"
+ />
+ <Tool
+ Name="VCBscMakeTool"
+ />
+ <Tool
+ Name="VCFxCopTool"
+ />
+ <Tool
+ Name="VCPostBuildEventTool"
+ />
+ </Configuration>
+ <Configuration
+ Name="Release Unicode lib|Win32"
+ ConfigurationType="4"
+ InheritedPropertySheets="..\..\..\common.vsprops;..\..\..\release.vsprops"
+ UseOfMFC="1"
+ CharacterSet="1"
+ >
+ <Tool
+ Name="VCPreBuildEventTool"
+ />
+ <Tool
+ Name="VCCustomBuildTool"
+ />
+ <Tool
+ Name="VCXMLDataGeneratorTool"
+ />
+ <Tool
+ Name="VCWebServiceProxyGeneratorTool"
+ />
+ <Tool
+ Name="VCMIDLTool"
+ />
+ <Tool
+ Name="VCCLCompilerTool"
+ AdditionalOptions="/MP"
+ AdditionalIncludeDirectories="..\..\..\..\include;..\..\BaseClasses"
+ PreprocessorDefinitions="WIN32;NDEBUG;_LIB"
+ BufferSecurityCheck="true"
+ EnableEnhancedInstructionSet="1"
+ DisableSpecificWarnings="4244"
+ />
+ <Tool
+ Name="VCManagedResourceCompilerTool"
+ />
+ <Tool
+ Name="VCResourceCompilerTool"
+ />
+ <Tool
+ Name="VCPreLinkEventTool"
+ />
+ <Tool
+ Name="VCLibrarianTool"
+ OutputFile="..\..\..\..\lib\$(ProjectName)RU.lib"
+ />
+ <Tool
+ Name="VCALinkTool"
+ />
+ <Tool
+ Name="VCXDCMakeTool"
+ />
+ <Tool
+ Name="VCBscMakeTool"
+ />
+ <Tool
+ Name="VCFxCopTool"
+ />
+ <Tool
+ Name="VCPostBuildEventTool"
+ />
+ </Configuration>
+ <Configuration
+ Name="Release Unicode lib|x64"
+ OutputDirectory="$(PlatformName)\$(ConfigurationName)"
+ IntermediateDirectory="$(PlatformName)\$(ConfigurationName)"
+ ConfigurationType="4"
+ InheritedPropertySheets="..\..\..\common.vsprops;..\..\..\release.vsprops"
+ UseOfMFC="1"
+ CharacterSet="1"
+ >
+ <Tool
+ Name="VCPreBuildEventTool"
+ />
+ <Tool
+ Name="VCCustomBuildTool"
+ />
+ <Tool
+ Name="VCXMLDataGeneratorTool"
+ />
+ <Tool
+ Name="VCWebServiceProxyGeneratorTool"
+ />
+ <Tool
+ Name="VCMIDLTool"
+ TargetEnvironment="3"
+ />
+ <Tool
+ Name="VCCLCompilerTool"
+ AdditionalOptions="/MP"
+ AdditionalIncludeDirectories="..\..\..\..\include;..\..\BaseClasses"
+ PreprocessorDefinitions="_WIN64;NDEBUG;_LIB"
+ BufferSecurityCheck="true"
+ EnableEnhancedInstructionSet="0"
+ />
+ <Tool
+ Name="VCManagedResourceCompilerTool"
+ />
+ <Tool
+ Name="VCResourceCompilerTool"
+ />
+ <Tool
+ Name="VCPreLinkEventTool"
+ />
+ <Tool
+ Name="VCLibrarianTool"
+ OutputFile="..\..\..\..\lib64\$(ProjectName)RU.lib"
+ />
+ <Tool
+ Name="VCALinkTool"
+ />
+ <Tool
+ Name="VCXDCMakeTool"
+ />
+ <Tool
+ Name="VCBscMakeTool"
+ />
+ <Tool
+ Name="VCFxCopTool"
+ />
+ <Tool
+ Name="VCPostBuildEventTool"
+ />
+ </Configuration>
+ <Configuration
+ Name="Debug Unicode|Win32"
+ ConfigurationType="2"
+ InheritedPropertySheets="..\..\..\common.vsprops;..\..\..\debug.vsprops"
+ UseOfMFC="1"
+ CharacterSet="1"
+ >
+ <Tool
+ Name="VCPreBuildEventTool"
+ />
+ <Tool
+ Name="VCCustomBuildTool"
+ />
+ <Tool
+ Name="VCXMLDataGeneratorTool"
+ />
+ <Tool
+ Name="VCWebServiceProxyGeneratorTool"
+ />
+ <Tool
+ Name="VCMIDLTool"
+ />
+ <Tool
+ Name="VCCLCompilerTool"
+ AdditionalIncludeDirectories="..\..\..\..\include;..\..\BaseClasses"
+ PreprocessorDefinitions="REGISTER_FILTER;WIN32;_DEBUG;_USRDLL"
+ />
+ <Tool
+ Name="VCManagedResourceCompilerTool"
+ />
+ <Tool
+ Name="VCResourceCompilerTool"
+ />
+ <Tool
+ Name="VCPreLinkEventTool"
+ />
+ <Tool
+ Name="VCLinkerTool"
+ RegisterOutput="true"
+ AdditionalDependencies="strmbaseDU.lib dsutilDU.lib basesplitterDU.lib Winmm.lib"
+ OutputFile="$(OutDir)\$(ProjectName).ax"
+ AdditionalLibraryDirectories="..\..\..\..\lib"
+ IgnoreDefaultLibraryNames="libc.lib"
+ ModuleDefinitionFile="$(ProjectName).def"
+ DelayLoadDLLs=""
+ SubSystem="2"
+ RandomizedBaseAddress="1"
+ DataExecutionPrevention="0"
+ TargetMachine="1"
+ />
+ <Tool
+ Name="VCALinkTool"
+ />
+ <Tool
+ Name="VCManifestTool"
+ />
+ <Tool
+ Name="VCXDCMakeTool"
+ />
+ <Tool
+ Name="VCBscMakeTool"
+ />
+ <Tool
+ Name="VCFxCopTool"
+ />
+ <Tool
+ Name="VCAppVerifierTool"
+ />
+ <Tool
+ Name="VCPostBuildEventTool"
+ />
+ </Configuration>
+ <Configuration
+ Name="Debug Unicode|x64"
+ OutputDirectory="$(PlatformName)\$(ConfigurationName)"
+ IntermediateDirectory="$(PlatformName)\$(ConfigurationName)"
+ ConfigurationType="2"
+ InheritedPropertySheets="..\..\..\common.vsprops;..\..\..\debug.vsprops"
+ UseOfMFC="1"
+ CharacterSet="1"
+ >
+ <Tool
+ Name="VCPreBuildEventTool"
+ />
+ <Tool
+ Name="VCCustomBuildTool"
+ />
+ <Tool
+ Name="VCXMLDataGeneratorTool"
+ />
+ <Tool
+ Name="VCWebServiceProxyGeneratorTool"
+ />
+ <Tool
+ Name="VCMIDLTool"
+ TargetEnvironment="3"
+ />
+ <Tool
+ Name="VCCLCompilerTool"
+ AdditionalIncludeDirectories="..\..\..\..\include;..\..\BaseClasses"
+ PreprocessorDefinitions="REGISTER_FILTER;WIN32;_DEBUG;_USRDLL"
+ DebugInformationFormat="3"
+ />
+ <Tool
+ Name="VCManagedResourceCompilerTool"
+ />
+ <Tool
+ Name="VCResourceCompilerTool"
+ />
+ <Tool
+ Name="VCPreLinkEventTool"
+ />
+ <Tool
+ Name="VCLinkerTool"
+ AdditionalDependencies="strmbaseDU.lib dsutilDU.lib basesplitterDU.lib Winmm.lib"
+ OutputFile="$(OutDir)\$(ProjectName).ax"
+ AdditionalLibraryDirectories="..\..\..\..\lib64"
+ IgnoreDefaultLibraryNames="libc.lib"
+ ModuleDefinitionFile="$(ProjectName).def"
+ DelayLoadDLLs=""
+ SubSystem="2"
+ RandomizedBaseAddress="1"
+ DataExecutionPrevention="0"
+ TargetMachine="17"
+ />
+ <Tool
+ Name="VCALinkTool"
+ />
+ <Tool
+ Name="VCManifestTool"
+ />
+ <Tool
+ Name="VCXDCMakeTool"
+ />
+ <Tool
+ Name="VCBscMakeTool"
+ />
+ <Tool
+ Name="VCFxCopTool"
+ />
+ <Tool
+ Name="VCAppVerifierTool"
+ />
+ <Tool
+ Name="VCPostBuildEventTool"
+ />
+ </Configuration>
+ <Configuration
+ Name="Release Unicode|Win32"
+ ConfigurationType="2"
+ InheritedPropertySheets="..\..\..\common.vsprops;..\..\..\release.vsprops"
+ UseOfMFC="1"
+ CharacterSet="1"
+ >
+ <Tool
+ Name="VCPreBuildEventTool"
+ />
+ <Tool
+ Name="VCCustomBuildTool"
+ />
+ <Tool
+ Name="VCXMLDataGeneratorTool"
+ />
+ <Tool
+ Name="VCWebServiceProxyGeneratorTool"
+ />
+ <Tool
+ Name="VCMIDLTool"
+ />
+ <Tool
+ Name="VCCLCompilerTool"
+ AdditionalIncludeDirectories="..\..\..\..\include;..\..\BaseClasses"
+ PreprocessorDefinitions="REGISTER_FILTER;WIN32;NDEBUG;_USRDLL"
+ BufferSecurityCheck="true"
+ EnableEnhancedInstructionSet="1"
+ />
+ <Tool
+ Name="VCManagedResourceCompilerTool"
+ />
+ <Tool
+ Name="VCResourceCompilerTool"
+ />
+ <Tool
+ Name="VCPreLinkEventTool"
+ />
+ <Tool
+ Name="VCLinkerTool"
+ AdditionalDependencies="strmbaseRU.lib dsutilRU.lib basesplitterRU.lib Winmm.lib"
+ OutputFile="..\..\..\..\bin\x86\$(ProjectName).ax"
+ AdditionalLibraryDirectories="..\..\..\..\lib"
+ ModuleDefinitionFile="$(ProjectName).def"
+ GenerateDebugInformation="true"
+ SubSystem="2"
+ LargeAddressAware="2"
+ RandomizedBaseAddress="2"
+ DataExecutionPrevention="2"
+ TargetMachine="1"
+ />
+ <Tool
+ Name="VCALinkTool"
+ />
+ <Tool
+ Name="VCManifestTool"
+ />
+ <Tool
+ Name="VCXDCMakeTool"
+ />
+ <Tool
+ Name="VCBscMakeTool"
+ />
+ <Tool
+ Name="VCFxCopTool"
+ />
+ <Tool
+ Name="VCAppVerifierTool"
+ />
+ <Tool
+ Name="VCPostBuildEventTool"
+ />
+ </Configuration>
+ <Configuration
+ Name="Release Unicode|x64"
+ OutputDirectory="$(PlatformName)\$(ConfigurationName)"
+ IntermediateDirectory="$(PlatformName)\$(ConfigurationName)"
+ ConfigurationType="2"
+ InheritedPropertySheets="..\..\..\common.vsprops;..\..\..\release.vsprops"
+ UseOfMFC="1"
+ CharacterSet="1"
+ >
+ <Tool
+ Name="VCPreBuildEventTool"
+ />
+ <Tool
+ Name="VCCustomBuildTool"
+ />
+ <Tool
+ Name="VCXMLDataGeneratorTool"
+ />
+ <Tool
+ Name="VCWebServiceProxyGeneratorTool"
+ />
+ <Tool
+ Name="VCMIDLTool"
+ TargetEnvironment="3"
+ />
+ <Tool
+ Name="VCCLCompilerTool"
+ AdditionalIncludeDirectories="..\..\..\..\include;..\..\BaseClasses"
+ PreprocessorDefinitions="REGISTER_FILTER;WIN32;NDEBUG;_USRDLL"
+ BufferSecurityCheck="true"
+ />
+ <Tool
+ Name="VCManagedResourceCompilerTool"
+ />
+ <Tool
+ Name="VCResourceCompilerTool"
+ />
+ <Tool
+ Name="VCPreLinkEventTool"
+ />
+ <Tool
+ Name="VCLinkerTool"
+ AdditionalDependencies="strmbaseRU.lib dsutilRU.lib basesplitterRU.lib Winmm.lib"
+ OutputFile="..\..\..\..\bin\x64\$(ProjectName).ax"
+ AdditionalLibraryDirectories="..\..\..\..\lib64"
+ ModuleDefinitionFile="$(ProjectName).def"
+ GenerateDebugInformation="true"
+ SubSystem="2"
+ LargeAddressAware="2"
+ RandomizedBaseAddress="2"
+ DataExecutionPrevention="2"
+ TargetMachine="17"
+ />
+ <Tool
+ Name="VCALinkTool"
+ />
+ <Tool
+ Name="VCManifestTool"
+ />
+ <Tool
+ Name="VCXDCMakeTool"
+ />
+ <Tool
+ Name="VCBscMakeTool"
+ />
+ <Tool
+ Name="VCFxCopTool"
+ />
+ <Tool
+ Name="VCAppVerifierTool"
+ />
+ <Tool
+ Name="VCPostBuildEventTool"
+ />
+ </Configuration>
+ </Configurations>
+ <References>
+ </References>
+ <Files>
+ <Filter
+ Name="Source Files"
+ Filter="cpp;c;cxx;def;odl;idl;hpj;bat;asm"
+ >
+ <File
+ RelativePath="DSMSplitter.cpp"
+ >
+ <FileConfiguration
+ Name="Debug Unicode|Win32"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ GeneratePreprocessedFile="0"
+ />
+ </FileConfiguration>
+ <FileConfiguration
+ Name="Debug Unicode|x64"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ GeneratePreprocessedFile="0"
+ />
+ </FileConfiguration>
+ </File>
+ <File
+ RelativePath="DSMSplitter.def"
+ >
+ </File>
+ <File
+ RelativePath=".\DSMSplitterFile.cpp"
+ >
+ </File>
+ <File
+ RelativePath="stdafx.cpp"
+ >
+ <FileConfiguration
+ Name="Debug Unicode lib|Win32"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ UsePrecompiledHeader="1"
+ />
+ </FileConfiguration>
+ <FileConfiguration
+ Name="Debug Unicode lib|x64"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ UsePrecompiledHeader="1"
+ />
+ </FileConfiguration>
+ <FileConfiguration
+ Name="Release Unicode lib|Win32"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ UsePrecompiledHeader="1"
+ />
+ </FileConfiguration>
+ <FileConfiguration
+ Name="Release Unicode lib|x64"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ UsePrecompiledHeader="1"
+ />
+ </FileConfiguration>
+ <FileConfiguration
+ Name="Debug Unicode|Win32"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ UsePrecompiledHeader="1"
+ />
+ </FileConfiguration>
+ <FileConfiguration
+ Name="Debug Unicode|x64"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ UsePrecompiledHeader="1"
+ />
+ </FileConfiguration>
+ <FileConfiguration
+ Name="Release Unicode|Win32"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ UsePrecompiledHeader="1"
+ />
+ </FileConfiguration>
+ <FileConfiguration
+ Name="Release Unicode|x64"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ UsePrecompiledHeader="1"
+ />
+ </FileConfiguration>
+ </File>
+ </Filter>
+ <Filter
+ Name="Header Files"
+ Filter="h;hpp;hxx;hm;inl;inc"
+ >
+ <File
+ RelativePath="DSMSplitter.h"
+ >
+ </File>
+ <File
+ RelativePath=".\DSMSplitterFile.h"
+ >
+ </File>
+ <File
+ RelativePath=".\resource.h"
+ >
+ <FileConfiguration
+ Name="Debug Unicode lib|Win32"
+ ExcludedFromBuild="true"
+ >
+ <Tool
+ Name="VCCustomBuildTool"
+ />
+ </FileConfiguration>
+ <FileConfiguration
+ Name="Debug Unicode lib|x64"
+ ExcludedFromBuild="true"
+ >
+ <Tool
+ Name="VCCustomBuildTool"
+ />
+ </FileConfiguration>
+ <FileConfiguration
+ Name="Release Unicode lib|Win32"
+ ExcludedFromBuild="true"
+ >
+ <Tool
+ Name="VCCustomBuildTool"
+ />
+ </FileConfiguration>
+ <FileConfiguration
+ Name="Release Unicode lib|x64"
+ ExcludedFromBuild="true"
+ >
+ <Tool
+ Name="VCCustomBuildTool"
+ />
+ </FileConfiguration>
+ </File>
+ <File
+ RelativePath="stdafx.h"
+ >
+ </File>
+ </Filter>
+ <Filter
+ Name="Resource Files"
+ Filter="rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe"
+ >
+ <File
+ RelativePath=".\DSMSplitter.rc"
+ >
+ <FileConfiguration
+ Name="Debug Unicode lib|Win32"
+ ExcludedFromBuild="true"
+ >
+ <Tool
+ Name="VCResourceCompilerTool"
+ />
+ </FileConfiguration>
+ <FileConfiguration
+ Name="Debug Unicode lib|x64"
+ ExcludedFromBuild="true"
+ >
+ <Tool
+ Name="VCResourceCompilerTool"
+ />
+ </FileConfiguration>
+ <FileConfiguration
+ Name="Release Unicode lib|Win32"
+ ExcludedFromBuild="true"
+ >
+ <Tool
+ Name="VCResourceCompilerTool"
+ />
+ </FileConfiguration>
+ <FileConfiguration
+ Name="Release Unicode lib|x64"
+ ExcludedFromBuild="true"
+ >
+ <Tool
+ Name="VCResourceCompilerTool"
+ />
+ </FileConfiguration>
+ </File>
+ </Filter>
+ </Files>
+ <Globals>
+ <Global
+ Name="DevPartner_IsInstrumented"
+ Value="0"
+ />
+ </Globals>
+</VisualStudioProject>
diff --git a/src/filters/parser/DSMSplitter/DSMSplitterFile.cpp b/src/filters/parser/DSMSplitter/DSMSplitterFile.cpp new file mode 100644 index 000000000..58aed9f67 --- /dev/null +++ b/src/filters/parser/DSMSplitter/DSMSplitterFile.cpp @@ -0,0 +1,397 @@ +#include "StdAfx.h"
+#include "DSMSplitterFile.h"
+#include "../../../DSUtil/DSUtil.h"
+#include <moreuuids.h>
+
+CDSMSplitterFile::CDSMSplitterFile(IAsyncReader* pReader, HRESULT& hr, IDSMResourceBagImpl& res, IDSMChapterBagImpl& chap)
+ : CBaseSplitterFile(pReader, hr, DEFAULT_CACHE_LENGTH, false)
+ , m_rtFirst(0)
+ , m_rtDuration(0)
+{
+ if(FAILED(hr)) return;
+
+ hr = Init(res, chap);
+}
+
+HRESULT CDSMSplitterFile::Init(IDSMResourceBagImpl& res, IDSMChapterBagImpl& chap)
+{
+ Seek(0);
+
+ if(BitRead(DSMSW_SIZE<<3) != DSMSW || BitRead(5) != DSMP_FILEINFO)
+ return E_FAIL;
+
+ Seek(0);
+
+ m_mts.RemoveAll();
+ m_rtFirst = m_rtDuration = 0;
+ m_fim.RemoveAll();
+ m_sim.RemoveAll();
+ res.ResRemoveAll();
+ chap.ChapRemoveAll();
+
+ dsmp_t type;
+ UINT64 len;
+ int limit = 65536;
+
+ // examine the beginning of the file ...
+
+ while(Sync(type, len, 0))
+ {
+ __int64 pos = GetPos();
+
+ if(type == DSMP_MEDIATYPE)
+ {
+ BYTE id;
+ CMediaType mt;
+ if(Read(len, id, mt)) m_mts[id] = mt;
+ }
+ else if(type == DSMP_SAMPLE)
+ {
+ Packet p;
+ if(Read(len, &p, false) && p.rtStart != Packet::INVALID_TIME)
+ {
+ m_rtFirst = p.rtStart;
+ break;
+ }
+ }
+ else if(type == DSMP_FILEINFO) {if((BYTE)BitRead(8) > DSMF_VERSION) return E_FAIL; Read(len-1, m_fim);}
+ else if(type == DSMP_STREAMINFO) {Read(len-1, m_sim[(BYTE)BitRead(8)]);}
+ else if(type == DSMP_SYNCPOINTS) {Read(len, m_sps);}
+ else if(type == DSMP_RESOURCE) {Read(len, res);}
+ else if(type == DSMP_CHAPTERS) {Read(len, chap);}
+
+ Seek(pos + len);
+ }
+
+ if(type != DSMP_SAMPLE)
+ return E_FAIL;
+
+ // ... and the end
+
+ if(IsRandomAccess())
+ for(int i = 1, j = (int)((GetLength()+limit/2)/limit); i <= j; i++)
+ {
+ __int64 seekpos = max(0, (__int64)GetLength()-i*limit);
+ Seek(seekpos);
+
+ while(Sync(type, len, limit) && GetPos() < seekpos+limit)
+ {
+ __int64 pos = GetPos();
+
+ if(type == DSMP_SAMPLE)
+ {
+ Packet p;
+ if(Read(len, &p, false) && p.rtStart != Packet::INVALID_TIME)
+ {
+ m_rtDuration = max(m_rtDuration, p.rtStop - m_rtFirst); // max isn't really needed, only for safety
+ i = j;
+ }
+ }
+ else if(type == DSMP_SYNCPOINTS) {Read(len, m_sps);}
+ else if(type == DSMP_RESOURCE) {Read(len, res);}
+ else if(type == DSMP_CHAPTERS) {Read(len, chap);}
+
+ Seek(pos + len);
+ }
+ }
+
+ if(m_rtFirst < 0)
+ {
+ m_rtDuration += m_rtFirst;
+ m_rtFirst = 0;
+ }
+
+ return m_mts.GetCount() > 0 ? S_OK : E_FAIL;
+}
+
+bool CDSMSplitterFile::Sync(dsmp_t& type, UINT64& len, __int64 limit)
+{
+ UINT64 pos;
+ return Sync(pos, type, len, limit);
+}
+
+bool CDSMSplitterFile::Sync(UINT64& syncpos, dsmp_t& type, UINT64& len, __int64 limit)
+{
+ BitByteAlign();
+
+ limit += DSMSW_SIZE;
+
+ for(UINT64 id = 0; (id&((1ui64<<(DSMSW_SIZE<<3))-1)) != DSMSW; id = (id << 8) | (BYTE)BitRead(8))
+ {
+ if(limit-- <= 0 || GetRemaining() <= 2)
+ return(false);
+ }
+
+ syncpos = GetPos() - (DSMSW_SIZE<<3);
+ type = (dsmp_t)BitRead(5);
+ len = BitRead(((int)BitRead(3)+1)<<3);
+
+ return(true);
+}
+
+bool CDSMSplitterFile::Read(__int64 len, BYTE& id, CMediaType& mt)
+{
+ id = (BYTE)BitRead(8);
+ ByteRead((BYTE*)&mt.majortype, sizeof(mt.majortype));
+ ByteRead((BYTE*)&mt.subtype, sizeof(mt.subtype));
+ mt.bFixedSizeSamples = (BOOL)BitRead(1);
+ mt.bTemporalCompression = (BOOL)BitRead(1);
+ mt.lSampleSize = (ULONG)BitRead(30);
+ ByteRead((BYTE*)&mt.formattype, sizeof(mt.formattype));
+ len -= 5 + sizeof(GUID)*3;
+ ASSERT(len >= 0);
+ if(len > 0) {mt.AllocFormatBuffer((LONG)len); ByteRead(mt.Format(), mt.FormatLength());}
+ else mt.ResetFormatBuffer();
+ return true;
+}
+
+bool CDSMSplitterFile::Read(__int64 len, Packet* p, bool fData)
+{
+ if(!p) return false;
+
+ p->TrackNumber = (DWORD)BitRead(8);
+ p->bSyncPoint = (BOOL)BitRead(1);
+ bool fSign = !!BitRead(1);
+ int iTimeStamp = (int)BitRead(3);
+ int iDuration = (int)BitRead(3);
+
+ if(fSign && !iTimeStamp)
+ {
+ ASSERT(!iDuration);
+ p->rtStart = Packet::INVALID_TIME;
+ p->rtStop = Packet::INVALID_TIME + 1;
+ }
+ else
+ {
+ p->rtStart = (REFERENCE_TIME)BitRead(iTimeStamp<<3) * (fSign ? -1 : 1);
+ p->rtStop = p->rtStart + BitRead(iDuration<<3);
+ }
+
+ if(fData)
+ {
+ p->SetCount((INT_PTR)len - (2 + iTimeStamp + iDuration));
+ ByteRead(p->GetData(), p->GetCount());
+ }
+
+ return true;
+}
+
+bool CDSMSplitterFile::Read(__int64 len, CAtlArray<SyncPoint>& sps)
+{
+ SyncPoint sp = {0, 0};
+ sps.RemoveAll();
+
+ while(len > 0)
+ {
+ bool fSign = !!BitRead(1);
+ int iTimeStamp = (int)BitRead(3);
+ int iFilePos = (int)BitRead(3);
+ BitRead(1); // reserved
+
+ sp.rt += (REFERENCE_TIME)BitRead(iTimeStamp<<3) * (fSign ? -1 : 1);
+ sp.fp += BitRead(iFilePos<<3);
+ sps.Add(sp);
+
+ len -= 1 + iTimeStamp + iFilePos;
+ }
+
+ if(len != 0)
+ {
+ sps.RemoveAll();
+ return false;
+ }
+
+ // TODO: sort sps
+
+ return true;
+}
+
+bool CDSMSplitterFile::Read(__int64 len, CStreamInfoMap& im)
+{
+ while(len >= 5)
+ {
+ CStringA key;
+ ByteRead((BYTE*)key.GetBufferSetLength(4), 4);
+ len -= 4;
+ len -= Read(len, im[key]);
+ }
+
+ return len == 0;
+}
+
+bool CDSMSplitterFile::Read(__int64 len, IDSMResourceBagImpl& res)
+{
+ BYTE compression = (BYTE)BitRead(2);
+ BYTE reserved = (BYTE)BitRead(6);
+ len--;
+
+ CDSMResource r;
+ len -= Read(len, r.name);
+ len -= Read(len, r.desc);
+ len -= Read(len, r.mime);
+
+ if(compression != 0) return false; // TODO
+
+ r.data.SetCount(len);
+ ByteRead(r.data.GetData(), r.data.GetCount());
+
+ res += r;
+
+ return true;
+}
+
+bool CDSMSplitterFile::Read(__int64 len, IDSMChapterBagImpl& chap)
+{
+ CDSMChapter c(0, L"");
+
+ while(len > 0)
+ {
+ bool fSign = !!BitRead(1);
+ int iTimeStamp = (int)BitRead(3);
+ BitRead(4); // reserved
+ len--;
+
+ c.rt += (REFERENCE_TIME)BitRead(iTimeStamp<<3) * (fSign ? -1 : 1);
+ len -= iTimeStamp;
+ len -= Read(len, c.name);
+
+ chap += c;
+ }
+
+ chap.ChapSort();
+
+ return len == 0;
+}
+
+__int64 CDSMSplitterFile::Read(__int64 len, CStringW& str)
+{
+ char c;
+ CStringA s;
+ __int64 i = 0;
+ while(i++ < len && (c = (char)BitRead(8)) != 0) s += c;
+ str = UTF8To16(s);
+ return i;
+}
+
+__int64 CDSMSplitterFile::FindSyncPoint(REFERENCE_TIME rt)
+{
+ if(/*!m_sps.IsEmpty()*/ m_sps.GetCount() > 1)
+ {
+ int i = range_bsearch(m_sps, m_rtFirst + rt);
+ return i >= 0 ? m_sps[i].fp : 0;
+ }
+
+ if(m_rtDuration <= 0 || rt <= m_rtFirst)
+ return 0;
+
+ // ok, do the hard way then
+
+ dsmp_t type;
+ UINT64 syncpos, len;
+
+ // 1. find some boundaries close to rt's position (minpos, maxpos)
+
+ __int64 minpos = 0, maxpos = GetLength();
+
+ for(int i = 0; i < 10 && (maxpos - minpos) >= 1024*1024; i++)
+ {
+ Seek((minpos + maxpos) / 2);
+
+ while(GetPos() < maxpos)
+ {
+ if(!Sync(syncpos, type, len))
+ continue;
+
+ __int64 pos = GetPos();
+
+ if(type == DSMP_SAMPLE)
+ {
+ Packet p;
+ if(Read(len, &p, false) && p.rtStart != Packet::INVALID_TIME)
+ {
+ REFERENCE_TIME dt = (p.rtStart -= m_rtFirst) - rt;
+ if(dt >= 0) maxpos = max((__int64)syncpos - 65536, minpos);
+ else minpos = syncpos;
+ break;
+ }
+ }
+
+ Seek(pos + len);
+ }
+ }
+
+ // 2. find the first packet just after rt (maxpos)
+
+ Seek(minpos);
+
+ while(GetRemaining())
+ {
+ if(!Sync(syncpos, type, len))
+ continue;
+
+ __int64 pos = GetPos();
+
+ if(type == DSMP_SAMPLE)
+ {
+ Packet p;
+ if(Read(len, &p, false) && p.rtStart != Packet::INVALID_TIME)
+ {
+ REFERENCE_TIME dt = (p.rtStart -= m_rtFirst) - rt;
+ if(dt >= 0) {maxpos = (__int64)syncpos; break;}
+ }
+ }
+
+ Seek(pos + len);
+ }
+
+ // 3. iterate backwards from maxpos and find at least one syncpoint for every stream, except for subtitle streams
+
+ CAtlMap<BYTE,BYTE> ids;
+
+ {
+ POSITION pos = m_mts.GetStartPosition();
+ while(pos)
+ {
+ BYTE id;
+ CMediaType mt;
+ m_mts.GetNextAssoc(pos, id, mt);
+ if(mt.majortype != MEDIATYPE_Text && mt.majortype != MEDIATYPE_Subtitle)
+ ids[id] = 0;
+ }
+ }
+
+ __int64 ret = maxpos;
+
+ while(maxpos > 0 && !ids.IsEmpty())
+ {
+ minpos = max(0, maxpos - 65536);
+
+ Seek(minpos);
+
+ while(Sync(syncpos, type, len) && GetPos() < maxpos)
+ {
+ UINT64 pos = GetPos();
+
+ if(type == DSMP_SAMPLE)
+ {
+ Packet p;
+ if(Read(len, &p, false) && p.rtStart != Packet::INVALID_TIME && p.bSyncPoint)
+ {
+ BYTE id = (BYTE)p.TrackNumber, tmp;
+ if(ids.Lookup(id, tmp))
+ {
+ ids.RemoveKey((BYTE)p.TrackNumber);
+ ret = min(ret, (__int64)syncpos);
+ }
+ }
+ }
+
+ Seek(pos + len);
+ }
+
+ maxpos = minpos;
+ }
+
+ return ret;
+}
+
diff --git a/src/filters/parser/DSMSplitter/DSMSplitterFile.h b/src/filters/parser/DSMSplitter/DSMSplitterFile.h new file mode 100644 index 000000000..7c350db2f --- /dev/null +++ b/src/filters/parser/DSMSplitter/DSMSplitterFile.h @@ -0,0 +1,35 @@ +#pragma once
+
+#include "../BaseSplitter/BaseSplitter.h"
+#include <dsm/dsm.h>
+#include "../../../DSUtil/DSMPropertyBag.h"
+
+class CDSMSplitterFile : public CBaseSplitterFile
+{
+ HRESULT Init(IDSMResourceBagImpl& res, IDSMChapterBagImpl& chap);
+
+public:
+ CDSMSplitterFile(IAsyncReader* pReader, HRESULT& hr, IDSMResourceBagImpl& res, IDSMChapterBagImpl& chap);
+
+ CAtlMap<BYTE, CMediaType> m_mts;
+ REFERENCE_TIME m_rtFirst, m_rtDuration;
+
+ struct SyncPoint {REFERENCE_TIME rt; __int64 fp;};
+ CAtlArray<SyncPoint> m_sps;
+
+ typedef CAtlMap<CStringA, CStringW, CStringElementTraits<CStringA>, CStringElementTraits<CStringW> > CStreamInfoMap;
+ CStreamInfoMap m_fim;
+ CAtlMap<BYTE, CStreamInfoMap> m_sim;
+
+ bool Sync(dsmp_t& type, UINT64& len, __int64 limit = 65536);
+ bool Sync(UINT64& syncpos, dsmp_t& type, UINT64& len, __int64 limit = 65536);
+ bool Read(__int64 len, BYTE& id, CMediaType& mt);
+ bool Read(__int64 len, Packet* p, bool fData = true);
+ bool Read(__int64 len, CAtlArray<SyncPoint>& sps);
+ bool Read(__int64 len, CStreamInfoMap& im);
+ bool Read(__int64 len, IDSMResourceBagImpl& res);
+ bool Read(__int64 len, IDSMChapterBagImpl& chap);
+ __int64 Read(__int64 len, CStringW& str);
+
+ __int64 FindSyncPoint(REFERENCE_TIME rt);
+};
diff --git a/src/filters/parser/DSMSplitter/resource.h b/src/filters/parser/DSMSplitter/resource.h new file mode 100644 index 000000000..66d1331cb --- /dev/null +++ b/src/filters/parser/DSMSplitter/resource.h @@ -0,0 +1,14 @@ +//{{NO_DEPENDENCIES}}
+// Microsoft Visual C++ generated include file.
+// Used by DSMSplitter.rc
+
+// Next default values for new objects
+//
+#ifdef APSTUDIO_INVOKED
+#ifndef APSTUDIO_READONLY_SYMBOLS
+#define _APS_NEXT_RESOURCE_VALUE 101
+#define _APS_NEXT_COMMAND_VALUE 40001
+#define _APS_NEXT_CONTROL_VALUE 1001
+#define _APS_NEXT_SYMED_VALUE 101
+#endif
+#endif
diff --git a/src/filters/parser/DSMSplitter/stdafx.cpp b/src/filters/parser/DSMSplitter/stdafx.cpp new file mode 100644 index 000000000..0a00e1846 --- /dev/null +++ b/src/filters/parser/DSMSplitter/stdafx.cpp @@ -0,0 +1,29 @@ +/*
+ * Copyright (C) 2003-2006 Gabest
+ * http://www.gabest.org
+ *
+ * This Program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2, or (at your option)
+ * any later version.
+ *
+ * This Program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with GNU Make; see the file COPYING. If not, write to
+ * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
+ * http://www.gnu.org/copyleft/gpl.html
+ *
+ */
+
+// stdafx.cpp : source file that includes just the standard includes
+// DSMSplitter.pch will be the pre-compiled header
+// stdafx.obj will contain the pre-compiled type information
+
+#include "stdafx.h"
+
+// TODO: reference any additional headers you need in STDAFX.H
+// and not in this file
diff --git a/src/filters/parser/DSMSplitter/stdafx.h b/src/filters/parser/DSMSplitter/stdafx.h new file mode 100644 index 000000000..e8beccd47 --- /dev/null +++ b/src/filters/parser/DSMSplitter/stdafx.h @@ -0,0 +1,45 @@ +/*
+ * Copyright (C) 2003-2006 Gabest
+ * http://www.gabest.org
+ *
+ * This Program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2, or (at your option)
+ * any later version.
+ *
+ * This Program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with GNU Make; see the file COPYING. If not, write to
+ * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
+ * http://www.gnu.org/copyleft/gpl.html
+ *
+ */
+
+// stdafx.h : include file for standard system include files,
+// or project specific include files that are used frequently, but
+// are changed infrequently
+//
+
+#pragma once
+#include "../../../DSUtil/SharedInclude.h"
+
+#define WIN32_LEAN_AND_MEAN // Exclude rarely-used stuff from Windows headers
+#define _ATL_CSTRING_EXPLICIT_CONSTRUCTORS // some CString constructors will be explicit
+
+#ifndef VC_EXTRALEAN
+#define VC_EXTRALEAN // Exclude rarely-used stuff from Windows headers
+#endif
+
+#include <afx.h>
+#include <afxwin.h> // MFC core and standard components
+#include <atlcoll.h>
+
+// TODO: reference additional headers your program requires here
+
+#include <dshow.h>
+#include <streams.h>
+#include <dvdmedia.h>
|