├── .gitattributes ├── .github └── workflows │ └── c-cpp.yml ├── .gitignore ├── 7zr.exe ├── LICENSE ├── README.md ├── VSFilterMod.sln ├── include ├── IFilterVersion.h ├── Version.h ├── VersionMod.h ├── avisynth │ ├── avisynth1.h │ └── avisynth25.h ├── decss │ ├── VobDec.h │ └── VobFile.h ├── dx │ ├── d3d.h │ ├── d3d8.h │ ├── d3d8caps.h │ ├── d3d8types.h │ ├── d3dcaps.h │ ├── d3drm.h │ ├── d3drmdef.h │ ├── d3drmobj.h │ ├── d3drmwin.h │ ├── d3dtypes.h │ ├── d3dx7.h │ ├── d3dx9.h │ ├── d3dx9anim.h │ ├── d3dx9core.h │ ├── d3dx9effect.h │ ├── d3dx9math.h │ ├── d3dx9math.inl │ ├── d3dx9mesh.h │ ├── d3dx9shader.h │ ├── d3dx9shape.h │ ├── d3dx9tex.h │ ├── d3dx9xof.h │ └── dxtrans.h ├── moreuuids.h ├── stdint.h ├── unrar │ ├── UNRAR.H │ └── UNRARDLL.TXT ├── vd2 │ ├── Copying │ ├── OldFilterSDK │ │ ├── Filter.h │ │ ├── ScriptError.h │ │ ├── ScriptInterpreter.h │ │ ├── ScriptValue.h │ │ ├── VBitmap.h │ │ └── VirtualDub.h │ ├── PluginSDK.chm │ ├── VDXFrame │ │ ├── Unknown.h │ │ ├── VideoFilter.h │ │ ├── VideoFilterDialog.h │ │ └── VideoFilterEntry.h │ ├── extras │ │ └── FilterSDK │ │ │ ├── Filter.h │ │ │ ├── ScriptError.h │ │ │ ├── ScriptInterpreter.h │ │ │ ├── ScriptValue.h │ │ │ ├── VBitmap.h │ │ │ ├── VirtualDub.h │ │ │ └── readme.txt │ └── plugin │ │ ├── vdaudiofilt.h │ │ ├── vdinputdriver.h │ │ ├── vdplugin.h │ │ ├── vdvideofilt.h │ │ └── vdvideoutil.h └── winddk │ ├── devioctl.h │ ├── ntddcdrm.h │ ├── ntddcdvd.h │ ├── ntdddisk.h │ └── ntddstor.h ├── publish.bat ├── src ├── BaseClasses │ ├── LICENSE │ ├── Readme.md │ ├── amextra.cpp │ ├── amextra.h │ ├── amfilter.cpp │ ├── amfilter.h │ ├── amvideo.cpp │ ├── arithutil.cpp │ ├── baseclasses.vcxproj │ ├── baseclasses.vcxproj.filters │ ├── cache.h │ ├── checkbmi.h │ ├── combase.cpp │ ├── combase.h │ ├── cprop.cpp │ ├── cprop.h │ ├── ctlutil.cpp │ ├── ctlutil.h │ ├── ddmm.cpp │ ├── ddmm.h │ ├── dllentry.cpp │ ├── dllsetup.cpp │ ├── dllsetup.h │ ├── dxmperf.h │ ├── fourcc.h │ ├── measure.h │ ├── msgthrd.h │ ├── mtype.cpp │ ├── mtype.h │ ├── outputq.cpp │ ├── outputq.h │ ├── perflog.cpp │ ├── perflog.h │ ├── perfstruct.h │ ├── pstream.cpp │ ├── pstream.h │ ├── pullpin.cpp │ ├── pullpin.h │ ├── refclock.cpp │ ├── refclock.h │ ├── reftime.h │ ├── renbase.cpp │ ├── renbase.h │ ├── schedule.cpp │ ├── schedule.h │ ├── seekpt.cpp │ ├── seekpt.h │ ├── source.cpp │ ├── source.h │ ├── streams.h │ ├── strmctl.cpp │ ├── strmctl.h │ ├── sysclock.cpp │ ├── sysclock.h │ ├── transfrm.cpp │ ├── transfrm.h │ ├── transip.cpp │ ├── transip.h │ ├── videoctl.cpp │ ├── videoctl.h │ ├── vtrans.cpp │ ├── vtrans.h │ ├── winctrl.cpp │ ├── winctrl.h │ ├── winutil.cpp │ ├── winutil.h │ ├── wxdebug.cpp │ ├── wxdebug.h │ ├── wxlist.cpp │ ├── wxlist.h │ ├── wxutil.cpp │ └── wxutil.h ├── basevideofilter │ ├── BaseVideoFilter.cpp │ ├── BaseVideoFilter.h │ ├── basevideofilter.vcxproj │ ├── basevideofilter.vcxproj.filters │ ├── stdafx.cpp │ └── stdafx.h ├── common.props ├── dsutil │ ├── DSMPropertyBag.cpp │ ├── DSMPropertyBag.h │ ├── DSUtil.cpp │ ├── DSUtil.h │ ├── FontInstaller.cpp │ ├── FontInstaller.h │ ├── GolombBuffer.cpp │ ├── GolombBuffer.h │ ├── H264Nalu.cpp │ ├── H264Nalu.h │ ├── HdmvClipInfo.cpp │ ├── HdmvClipInfo.h │ ├── MediaTypeEx.cpp │ ├── MediaTypeEx.h │ ├── MediaTypes.cpp │ ├── MediaTypes.h │ ├── Mpeg2Def.h │ ├── NullRenderers.cpp │ ├── NullRenderers.h │ ├── SharedInclude.h │ ├── a_yuv2rgb.asm │ ├── a_yuvtable.asm │ ├── convert_a.asm │ ├── csimd.h │ ├── dsutil.vcxproj │ ├── dsutil.vcxproj.filters │ ├── mmintrin64.c │ ├── simd.h │ ├── simd_common.h │ ├── simd_instructions.h │ ├── stdafx.cpp │ ├── stdafx.h │ ├── text.cpp │ ├── text.h │ ├── vd.cpp │ ├── vd.h │ ├── vd_asm.cpp │ └── vd_asm.h ├── libpng │ ├── ANNOUNCE │ ├── CHANGES │ ├── LICENSE │ ├── README │ ├── libpng.vcxproj │ ├── libpng.vcxproj.filters │ ├── png.c │ ├── png.h │ ├── pngconf.h │ ├── pngerror.c │ ├── pngget.c │ ├── pngmem.c │ ├── pngpread.c │ ├── pngpriv.h │ ├── pngread.c │ ├── pngrio.c │ ├── pngrtran.c │ ├── pngrutil.c │ ├── pngset.c │ ├── pngtest.c │ ├── pngtrans.c │ ├── pngwio.c │ ├── pngwrite.c │ ├── pngwtran.c │ └── pngwutil.c ├── subpic │ ├── CoordGeom.cpp │ ├── CoordGeom.h │ ├── DX7SubPic.cpp │ ├── DX7SubPic.h │ ├── DX9SubPic.cpp │ ├── DX9SubPic.h │ ├── ISubPic.cpp │ ├── ISubPic.h │ ├── MemSubPic.cpp │ ├── MemSubPic.h │ ├── stdafx.cpp │ ├── stdafx.h │ ├── subpic.vcxproj │ └── subpic.vcxproj.filters ├── subtitles │ ├── BaseSub.cpp │ ├── BaseSub.h │ ├── CCDecoder.cpp │ ├── CCDecoder.h │ ├── CompositionObject.cpp │ ├── CompositionObject.h │ ├── DVBSub.cpp │ ├── DVBSub.h │ ├── GFN.cpp │ ├── GFN.h │ ├── HdmvSub.cpp │ ├── HdmvSub.h │ ├── RTS.cpp │ ├── RTS.h │ ├── Rasterizer.cpp │ ├── Rasterizer.h │ ├── RealTextParser.cpp │ ├── RealTextParser.h │ ├── RenderedHdmvSubtitle.cpp │ ├── RenderedHdmvSubtitle.h │ ├── SSF.cpp │ ├── SSF.h │ ├── STS.cpp │ ├── STS.h │ ├── SeparableFilter.h │ ├── SubtitleInputPin.cpp │ ├── SubtitleInputPin.h │ ├── TextFile.cpp │ ├── TextFile.h │ ├── USFSubtitles.cpp │ ├── USFSubtitles.h │ ├── VobSubFile.cpp │ ├── VobSubFile.h │ ├── VobSubFileRipper.cpp │ ├── VobSubFileRipper.h │ ├── VobSubImage.cpp │ ├── VobSubImage.h │ ├── libssf │ │ ├── Arabic.cpp │ │ ├── Arabic.h │ │ ├── Array.cpp │ │ ├── Array.h │ │ ├── Exception.cpp │ │ ├── Exception.h │ │ ├── File.cpp │ │ ├── File.h │ │ ├── FontWrapper.cpp │ │ ├── FontWrapper.h │ │ ├── Glyph.cpp │ │ ├── Glyph.h │ │ ├── GlyphPath.cpp │ │ ├── GlyphPath.h │ │ ├── Node.cpp │ │ ├── Node.h │ │ ├── NodeFactory.cpp │ │ ├── NodeFactory.h │ │ ├── Rasterizer.cpp │ │ ├── Rasterizer.h │ │ ├── Renderer.cpp │ │ ├── Renderer.h │ │ ├── Split.cpp │ │ ├── Split.h │ │ ├── Stream.cpp │ │ ├── Stream.h │ │ ├── StringMap.cpp │ │ ├── StringMap.h │ │ ├── Subtitle.cpp │ │ ├── Subtitle.h │ │ ├── SubtitleFile.cpp │ │ ├── SubtitleFile.h │ │ ├── demo │ │ │ ├── demo.ssa │ │ │ └── demo.ssf │ │ ├── libssf.vcxproj │ │ ├── libssf.vcxproj.filters │ │ ├── stdafx.cpp │ │ └── stdafx.h │ ├── stdafx.cpp │ ├── stdafx.h │ ├── subtitles.vcxproj │ └── subtitles.vcxproj.filters ├── vsfilter │ ├── Copy.cpp │ ├── DirectVobSub.cpp │ ├── DirectVobSub.h │ ├── DirectVobSubFilter.cpp │ ├── DirectVobSubFilter.h │ ├── DirectVobSubPropPage.cpp │ ├── DirectVobSubPropPage.h │ ├── IDirectVobSub.h │ ├── StdAfx.cpp │ ├── StdAfx.h │ ├── StyleEditorDialog.cpp │ ├── StyleEditorDialog.h │ ├── Systray.h │ ├── TextInputPin.cpp │ ├── TextInputPin.h │ ├── VSFilter.cpp │ ├── VSFilter.def │ ├── VSFilter.h │ ├── VSFilter.rc │ ├── VSFilter.vcxproj │ ├── VSFilter.vcxproj.filters │ ├── VSFilter64.def │ ├── VSFilterMod.def │ ├── VSFilterMod.rc │ ├── VSFilterMod64.def │ ├── csri.h │ ├── csriapi.cpp │ ├── plugins.cpp │ ├── res │ │ ├── Icon_147.ico │ │ ├── Icon_147m.ico │ │ └── VSFilter.manifest │ ├── resource.h │ ├── systray.cpp │ ├── vfr.cpp │ └── vfr.h └── zlib │ ├── ChangeLog │ ├── FAQ │ ├── README │ ├── ZLIB.DEF │ ├── ZLIB.RC │ ├── adler32.c │ ├── compress.c │ ├── crc32.c │ ├── crc32.h │ ├── deflate.c │ ├── deflate.h │ ├── doc │ ├── algorithm.txt │ ├── rfc1950.txt │ ├── rfc1951.txt │ ├── rfc1952.txt │ └── txtvsbin.txt │ ├── gzclose.c │ ├── gzguts.h │ ├── gzlib.c │ ├── gzread.c │ ├── gzwrite.c │ ├── infback.c │ ├── inffast.c │ ├── inffast.h │ ├── inffixed.h │ ├── inflate.c │ ├── inflate.h │ ├── inftrees.c │ ├── inftrees.h │ ├── trees.c │ ├── trees.h │ ├── uncompr.c │ ├── zconf.h │ ├── zlib.h │ ├── zlib.vcxproj │ ├── zlib.vcxproj.filters │ ├── zutil.c │ └── zutil.h └── vapoursynth └── sdk ├── examples ├── filter_skeleton.c ├── invert_example.c └── vsscript_example.c ├── include └── vapoursynth │ ├── VSHelper.h │ ├── VSScript.h │ └── VapourSynth.h ├── lib32 ├── vapoursynth.lib └── vsscript.lib └── lib64 ├── vapoursynth.lib └── vsscript.lib /.gitattributes: -------------------------------------------------------------------------------- 1 | # Auto detect text files and perform LF normalization 2 | * text=auto 3 | 4 | # Custom for Visual Studio 5 | *.cs diff=csharp 6 | 7 | # Standard to msysgit 8 | *.doc diff=astextplain 9 | *.DOC diff=astextplain 10 | *.docx diff=astextplain 11 | *.DOCX diff=astextplain 12 | *.dot diff=astextplain 13 | *.DOT diff=astextplain 14 | *.pdf diff=astextplain 15 | *.PDF diff=astextplain 16 | *.rtf diff=astextplain 17 | *.RTF diff=astextplain 18 | -------------------------------------------------------------------------------- /.github/workflows/c-cpp.yml: -------------------------------------------------------------------------------- 1 | name: C/C++ CI 2 | 3 | on: [push] 4 | 5 | jobs: 6 | build: 7 | 8 | runs-on: windows-2019 9 | 10 | steps: 11 | - uses: actions/checkout@v2 12 | - name: build 13 | shell: cmd 14 | run: ("C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\MSBuild\Current\Bin\amd64\msbuild" /t:Rebuild /p:WindowsTargetPlatformVersion=10.0.18362.0 /p:PlatformToolset=v142 /m /p:"Configuration=Release (MOD)" /p:Platform=Win32) 15 | - name: build-x64 16 | shell: cmd 17 | run: ("C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\MSBuild\Current\Bin\amd64\msbuild" /t:Rebuild /p:WindowsTargetPlatformVersion=10.0.18362.0 /p:PlatformToolset=v142 /m /p:"Configuration=Release (MOD)" /p:Platform=x64) 18 | - name: copy 19 | shell: cmd 20 | run: cmake -E copy "bin\Win32\VSFilter\Release (MOD)\VSFilterMod.dll" dist\x86\VSFilterMod.dll && cmake -E copy "bin\x64\VSFilter\Release (MOD)\VSFilterMod.dll" dist\x64\VSFilterMod.dll 21 | - name: upload 22 | uses: actions/upload-artifact@v2 23 | with: 24 | name: VSFilterMod_bin 25 | path: dist 26 | -------------------------------------------------------------------------------- /7zr.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sorayuki/VSFilterMod/643b3def0970eb9dedaa5e6d9be6c3c492ce970d/7zr.exe -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | I can spare little energy on this repository so please 2 | # Check here for newer releases: 3 | https://github.com/sorayuki/VSFilterMod/network 4 | 5 | --- 6 | 7 | Usage 8 | ===== 9 | 10 | vsfm.TextSubMod(clip clip, string file[, int charset=1, float fps=-1.0, string vfr='', int accurate=0]) 11 | vsfm.VobSub(clip clip, string file) 12 | 13 | * clip: Clip to process. Only YUV420P8, YUV420P10, YUV420P16 and RGB24 are supported. 14 | * accurate: 1: enable accurate render for 10/16bit (~2x slower). / 0: disable (default) 15 | 16 | Knowing Issues 17 | ===== 18 | * Opentype font (such as Source Han Sans) has a much smaller size when displayed vertically (used like @Source Han Sans). (subtitle renders which origin from VSFilter use GDI to render fonts, but GDI performs badly on opentype fonts.) 19 | 20 | Use VSFilterMod in MPC-BE 21 | ==== 22 | 1. run `regsvr32.exe VSFilterMod.dll` with administrator privileges 23 | 2. Select "VSFilter/xy-VSFilter" on the select of Options/Subtitles/Subtitle renderer 24 | -------------------------------------------------------------------------------- /include/IFilterVersion.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2003-2006 Gabest 3 | * http://www.gabest.org 4 | * 5 | * This Program is free software; you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation; either version 2, or (at your option) 8 | * any later version. 9 | * 10 | * This Program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License 16 | * along with GNU Make; see the file COPYING. If not, write to 17 | * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. 18 | * http://www.gnu.org/copyleft/gpl.html 19 | * 20 | */ 21 | 22 | #pragma once 23 | 24 | [uuid("A0DD28E1-61C0-4539-A7E6-14544AFF092E")] 25 | interface IFilterVersion : 26 | public IUnknown 27 | { 28 | STDMETHOD_(DWORD, GetFilterVersion)() = 0; 29 | }; -------------------------------------------------------------------------------- /include/Version.h: -------------------------------------------------------------------------------- 1 | //* VSFilterMod 1.1 *// 2 | 3 | #define DO_MAKE_STR(x) #x 4 | #define MAKE_STR(x) DO_MAKE_STR(x) 5 | 6 | #define VERSION_MAJOR 3 7 | #define VERSION_MINOR 4 8 | #define VERSION_REV 0 9 | #define VERSION_PATCH 0 10 | -------------------------------------------------------------------------------- /include/VersionMod.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #define DO_MAKE_STR(x) #x 4 | #define MAKE_STR(x) DO_MAKE_STR(x) 5 | 6 | #define VERSION_MAJOR 1 7 | #define VERSION_MINOR 1 8 | #define VERSION_REV 90 9 | #define VERSION_PATCH 0 10 | -------------------------------------------------------------------------------- /include/decss/VobDec.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | class CVobDec 4 | { 5 | int m_lfsr0, m_lfsr1; 6 | 7 | void ClockLfsr0Forward(int& lfsr0); 8 | void ClockLfsr1Forward(int& lfsr1); 9 | void ClockBackward(int& lfsr0, int& lfsr1); 10 | void Salt(const BYTE salt[5], int& lfsr0, int& lfsr1); 11 | int FindLfsr(const BYTE* crypt, int offset, const BYTE* plain); 12 | 13 | public: 14 | CVobDec(); 15 | virtual ~CVobDec(); 16 | 17 | bool m_fFoundKey; 18 | 19 | bool FindKey(BYTE* buff); 20 | void Decrypt(BYTE* buff); 21 | }; 22 | -------------------------------------------------------------------------------- /include/decss/VobFile.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #pragma warning(disable : 4200) 4 | 5 | #include 6 | #include 7 | //#include // platform sdk 8 | #include 9 | 10 | class CDVDSession 11 | { 12 | protected: 13 | HANDLE m_hDrive; 14 | 15 | DVD_SESSION_ID m_session; 16 | bool BeginSession(); 17 | void EndSession(); 18 | 19 | BYTE m_SessionKey[5]; 20 | bool Authenticate(); 21 | 22 | BYTE m_DiscKey[6], m_TitleKey[6]; 23 | bool GetDiscKey(); 24 | bool GetTitleKey(int lba, BYTE* pKey); 25 | 26 | public: 27 | CDVDSession(); 28 | virtual ~CDVDSession(); 29 | 30 | bool Open(LPCTSTR path); 31 | void Close(); 32 | 33 | operator HANDLE() const 34 | { 35 | return m_hDrive; 36 | } 37 | operator DVD_SESSION_ID() const 38 | { 39 | return m_session; 40 | } 41 | 42 | bool SendKey(DVD_KEY_TYPE KeyType, BYTE* pKeyData); 43 | bool ReadKey(DVD_KEY_TYPE KeyType, BYTE* pKeyData, int lba = 0); 44 | }; 45 | 46 | class CLBAFile : private CFile 47 | { 48 | public: 49 | CLBAFile(); 50 | virtual ~CLBAFile(); 51 | 52 | bool IsOpen(); 53 | 54 | bool Open(LPCTSTR path); 55 | void Close(); 56 | 57 | int GetLength(); 58 | int GetPosition(); 59 | int Seek(int lba); 60 | bool Read(BYTE* buff); 61 | }; 62 | 63 | class CVobFile : public CDVDSession 64 | { 65 | // all files 66 | typedef struct 67 | { 68 | CString fn; 69 | int size; 70 | } file_t; 71 | CAtlArray m_files; 72 | int m_iFile; 73 | int m_pos, m_size, m_offset; 74 | 75 | // currently opened file 76 | CLBAFile m_file; 77 | 78 | // attribs 79 | bool m_fDVD, m_fHasDiscKey, m_fHasTitleKey; 80 | 81 | public: 82 | CVobFile(); 83 | virtual ~CVobFile(); 84 | 85 | bool IsDVD(); 86 | bool HasDiscKey(BYTE* key); 87 | bool HasTitleKey(BYTE* key); 88 | 89 | bool Open(CString fn, CAtlList& files /* out */); // vts ifo 90 | bool Open(CAtlList& files, int offset = -1); // vts vobs, video vob offset in lba 91 | void Close(); 92 | 93 | int GetLength(); 94 | int GetPosition(); 95 | int Seek(int pos); 96 | bool Read(BYTE* buff); 97 | }; 98 | -------------------------------------------------------------------------------- /include/dx/d3drmwin.h: -------------------------------------------------------------------------------- 1 | /*==========================================================================; 2 | * 3 | * Copyright (c) Microsoft Corporation. All rights reserved. 4 | * 5 | * File: d3drm.h 6 | * Content: Direct3DRM include file 7 | * 8 | ***************************************************************************/ 9 | 10 | #ifndef __D3DRMWIN_H__ 11 | #define __D3DRMWIN_H__ 12 | 13 | #ifndef WIN32 14 | #define WIN32 15 | #endif 16 | 17 | #include "d3drm.h" 18 | 19 | #include "ddraw.h" 20 | #include "d3d.h" 21 | 22 | /* 23 | * GUIDS used by Direct3DRM Windows interface 24 | */ 25 | DEFINE_GUID(IID_IDirect3DRMWinDevice, 0xc5016cc0, 0xd273, 0x11ce, 0xac, 0x48, 0x0, 0x0, 0xc0, 0x38, 0x25, 0xa1); 26 | 27 | WIN_TYPES(IDirect3DRMWinDevice, DIRECT3DRMWINDEVICE); 28 | 29 | #undef INTERFACE 30 | #define INTERFACE IDirect3DRMWinDevice 31 | 32 | DECLARE_INTERFACE_(IDirect3DRMWinDevice, IDirect3DRMObject) 33 | { 34 | IUNKNOWN_METHODS(PURE); 35 | IDIRECT3DRMOBJECT_METHODS(PURE); 36 | 37 | /* 38 | * IDirect3DRMWinDevice methods 39 | */ 40 | 41 | /* Repaint the window with the last frame which was rendered. */ 42 | STDMETHOD(HandlePaint)(THIS_ HDC hdc) PURE; 43 | 44 | /* Respond to a WM_ACTIVATE message. */ 45 | STDMETHOD(HandleActivate)(THIS_ WORD wparam) PURE; 46 | }; 47 | 48 | 49 | #endif 50 | 51 | -------------------------------------------------------------------------------- /include/dx/d3dx9.h: -------------------------------------------------------------------------------- 1 | ////////////////////////////////////////////////////////////////////////////// 2 | // 3 | // Copyright (C) Microsoft Corporation. All Rights Reserved. 4 | // 5 | // File: d3dx9.h 6 | // Content: D3DX utility library 7 | // 8 | ////////////////////////////////////////////////////////////////////////////// 9 | 10 | #ifdef __D3DX_INTERNAL__ 11 | #error Incorrect D3DX header used 12 | #endif 13 | 14 | #ifndef __D3DX9_H__ 15 | #define __D3DX9_H__ 16 | 17 | 18 | // Defines 19 | #include 20 | 21 | #define D3DX_DEFAULT ((UINT) -1) 22 | #define D3DX_DEFAULT_NONPOW2 ((UINT) -2) 23 | #define D3DX_DEFAULT_FLOAT FLT_MAX 24 | #define D3DX_FROM_FILE ((UINT) -3) 25 | #define D3DFMT_FROM_FILE ((D3DFORMAT) -3) 26 | 27 | #ifndef D3DXINLINE 28 | #ifdef _MSC_VER 29 | #if (_MSC_VER >= 1200) 30 | #define D3DXINLINE __forceinline 31 | #else 32 | #define D3DXINLINE __inline 33 | #endif 34 | #else 35 | #ifdef __cplusplus 36 | #define D3DXINLINE inline 37 | #else 38 | #define D3DXINLINE 39 | #endif 40 | #endif 41 | #endif 42 | 43 | 44 | 45 | // Includes 46 | #include "d3d9.h" 47 | #include "d3dx9math.h" 48 | #include "d3dx9core.h" 49 | #include "d3dx9xof.h" 50 | #include "d3dx9mesh.h" 51 | #include "d3dx9shader.h" 52 | #include "d3dx9effect.h" 53 | 54 | #include "d3dx9tex.h" 55 | #include "d3dx9shape.h" 56 | #include "d3dx9anim.h" 57 | 58 | 59 | 60 | // Errors 61 | #define _FACDD 0x876 62 | #define MAKE_DDHRESULT( code ) MAKE_HRESULT( 1, _FACDD, code ) 63 | 64 | enum _D3DXERR { 65 | D3DXERR_CANNOTMODIFYINDEXBUFFER = MAKE_DDHRESULT(2900), 66 | D3DXERR_INVALIDMESH = MAKE_DDHRESULT(2901), 67 | D3DXERR_CANNOTATTRSORT = MAKE_DDHRESULT(2902), 68 | D3DXERR_SKINNINGNOTSUPPORTED = MAKE_DDHRESULT(2903), 69 | D3DXERR_TOOMANYINFLUENCES = MAKE_DDHRESULT(2904), 70 | D3DXERR_INVALIDDATA = MAKE_DDHRESULT(2905), 71 | D3DXERR_LOADEDMESHASNODATA = MAKE_DDHRESULT(2906), 72 | D3DXERR_DUPLICATENAMEDFRAGMENT = MAKE_DDHRESULT(2907), 73 | D3DXERR_CANNOTREMOVELASTITEM = MAKE_DDHRESULT(2908), 74 | }; 75 | 76 | 77 | #endif //__D3DX9_H__ 78 | 79 | -------------------------------------------------------------------------------- /include/vd2/OldFilterSDK/Filter.h: -------------------------------------------------------------------------------- 1 | #ifndef f_FILTER_H 2 | #define f_FILTER_H 3 | 4 | #include 5 | #include 6 | 7 | // This is really dumb, but necessary to support VTbls in C++. 8 | 9 | typedef struct VDXFilterVTbls 10 | { 11 | void *pvtblVBitmap; 12 | } FilterVTbls; 13 | 14 | #ifdef VDEXT_MAIN 15 | VDXFilterVTbls g_vtbls; 16 | #elif defined(VDEXT_NOTMAIN) 17 | extern VDXFilterVTbls g_vtbls; 18 | #endif 19 | 20 | #define INITIALIZE_VTBLS ff->InitVTables(&g_vtbls) 21 | 22 | #include "VBitmap.h" 23 | 24 | typedef ::VDXFilterInitProc FilterInitProc; 25 | typedef ::VDXFilterDeinitProc FilterDeinitProc; 26 | typedef ::VDXFilterRunProc FilterRunProc; 27 | typedef ::VDXFilterParamProc FilterParamProc; 28 | typedef ::VDXFilterConfigProc FilterConfigProc; 29 | typedef ::VDXFilterStringProc FilterStringProc; 30 | typedef ::VDXFilterStartProc FilterStartProc; 31 | typedef ::VDXFilterEndProc FilterEndProc; 32 | typedef ::VDXFilterScriptStrProc FilterScriptStrProc; 33 | typedef ::VDXFilterStringProc2 FilterStringProc2; 34 | typedef ::VDXFilterSerialize FilterSerialize; 35 | typedef ::VDXFilterDeserialize FilterDeserialize; 36 | typedef ::VDXFilterCopy FilterCopy; 37 | 38 | typedef ::VDXFilterModuleInitProc FilterModuleInitProc; 39 | typedef ::VDXFilterModuleDeinitProc FilterModuleDeinitProc; 40 | 41 | ////////// 42 | 43 | typedef ::VDXFilterPreviewButtonCallback FilterPreviewButtonCallback; 44 | typedef ::VDXFilterPreviewSampleCallback FilterPreviewSampleCallback; 45 | 46 | typedef ::IVDXFilterPreview IFilterPreview; 47 | 48 | ////////// 49 | 50 | typedef ::VDXFilterModule FilterModule; 51 | typedef ::VDXFilterDefinition FilterDefinition; 52 | typedef ::VDXFilterStateInfo FilterStateInfo; 53 | typedef ::VDXFBitmap VFBitmap; 54 | 55 | typedef ::VDXFilterActivation FilterActivation; 56 | typedef ::VDXFilterFunctions FilterFunctions; 57 | 58 | #endif 59 | -------------------------------------------------------------------------------- /include/vd2/OldFilterSDK/ScriptError.h: -------------------------------------------------------------------------------- 1 | #ifndef f_SYLIA_SCRIPTERROR_H 2 | #define f_SYLIA_SCRIPTERROR_H 3 | 4 | #include 5 | 6 | typedef ::VDXScriptError CScriptError; 7 | 8 | #endif 9 | -------------------------------------------------------------------------------- /include/vd2/OldFilterSDK/ScriptInterpreter.h: -------------------------------------------------------------------------------- 1 | #ifndef f_SYLIA_SCRIPTINTERPRETER_H 2 | #define f_SYLIA_SCRIPTINTERPRETER_H 3 | 4 | #include 5 | 6 | typedef ::VDXScriptValue CScriptValue; 7 | typedef ::VDXScriptError CScriptError; 8 | typedef ::VDXScriptObject CScriptObject; 9 | typedef ::IVDXScriptInterpreter IScriptInterpreter; 10 | 11 | #endif 12 | -------------------------------------------------------------------------------- /include/vd2/OldFilterSDK/ScriptValue.h: -------------------------------------------------------------------------------- 1 | #ifndef f_SYLIA_SCRIPTVALUE_H 2 | #define f_SYLIA_SCRIPTVALUE_H 3 | 4 | #include 5 | 6 | typedef ::VDXScriptObject CScriptObject; 7 | typedef ::VDXScriptValue CScriptValue; 8 | typedef ::IVDXScriptInterpreter IScriptInterpreter; 9 | 10 | typedef ::VDXScriptFunctionPtr ScriptFunctionPtr; 11 | typedef ::VDXVoidScriptFunctionPtr ScriptVoidFunctionPtr; 12 | typedef ::VDXIntScriptFunctionPtr ScriptIntFunctionPtr; 13 | 14 | typedef ::VDXScriptFunctionDef ScriptFunctionDef; 15 | typedef ::VDXScriptObject CScriptObject; 16 | 17 | #endif 18 | -------------------------------------------------------------------------------- /include/vd2/OldFilterSDK/VBitmap.h: -------------------------------------------------------------------------------- 1 | #ifndef f_VIRTUALDUB_VBITMAP_H 2 | #define f_VIRTUALDUB_VBITMAP_H 3 | 4 | #include 5 | #include 6 | 7 | typedef unsigned Pixel; 8 | typedef unsigned Pixel32; 9 | typedef unsigned char Pixel8; 10 | typedef int PixCoord; 11 | typedef int PixDim; 12 | typedef ptrdiff_t PixOffset; 13 | 14 | typedef ::VDXBitmap VBitmap; 15 | 16 | #endif 17 | -------------------------------------------------------------------------------- /include/vd2/OldFilterSDK/VirtualDub.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "Filter.h" 4 | #include "ScriptInterpreter.h" 5 | #include "ScriptError.h" 6 | #include "ScriptValue.h" 7 | #include "VBitmap.h" 8 | -------------------------------------------------------------------------------- /include/vd2/PluginSDK.chm: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sorayuki/VSFilterMod/643b3def0970eb9dedaa5e6d9be6c3c492ce970d/include/vd2/PluginSDK.chm -------------------------------------------------------------------------------- /include/vd2/VDXFrame/VideoFilterDialog.h: -------------------------------------------------------------------------------- 1 | // VDXFrame - Helper library for VirtualDub plugins 2 | // Copyright (C) 2008 Avery Lee 3 | // 4 | // The plugin headers in the VirtualDub plugin SDK are licensed differently 5 | // differently than VirtualDub and the Plugin SDK themselves. This 6 | // particular file is thus licensed as follows (the "zlib" license): 7 | // 8 | // This software is provided 'as-is', without any express or implied 9 | // warranty. In no event will the authors be held liable for any 10 | // damages arising from the use of this software. 11 | // 12 | // Permission is granted to anyone to use this software for any purpose, 13 | // including commercial applications, and to alter it and redistribute it 14 | // freely, subject to the following restrictions: 15 | // 16 | // 1. The origin of this software must not be misrepresented; you must 17 | // not claim that you wrote the original software. If you use this 18 | // software in a product, an acknowledgment in the product 19 | // documentation would be appreciated but is not required. 20 | // 2. Altered source versions must be plainly marked as such, and must 21 | // not be misrepresented as being the original software. 22 | // 3. This notice may not be removed or altered from any source 23 | // distribution. 24 | 25 | #ifndef f_VD2_VDXFRAME_VIDEOFILTERDIALOG_H 26 | #define f_VD2_VDXFRAME_VIDEOFILTERDIALOG_H 27 | 28 | #include 29 | 30 | class VDXVideoFilterDialog 31 | { 32 | public: 33 | VDXVideoFilterDialog(); 34 | 35 | protected: 36 | HWND mhdlg; 37 | 38 | LRESULT Show(HINSTANCE hInst, LPCSTR templName, HWND parent); 39 | LRESULT Show(HINSTANCE hInst, LPCWSTR templName, HWND parent); 40 | HWND ShowModeless(HINSTANCE hInst, LPCSTR templName, HWND parent); 41 | HWND ShowModeless(HINSTANCE hInst, LPCWSTR templName, HWND parent); 42 | 43 | static INT_PTR CALLBACK StaticDlgProc(HWND hdlg, UINT msg, WPARAM wParam, LPARAM lParam); 44 | virtual INT_PTR DlgProc(UINT msg, WPARAM wParam, LPARAM lParam); 45 | }; 46 | 47 | #endif 48 | -------------------------------------------------------------------------------- /include/vd2/extras/FilterSDK/ScriptError.h: -------------------------------------------------------------------------------- 1 | // VirtualDub - Video processing and capture application 2 | // Copyright (C) 1998-2002 Avery Lee 3 | // 4 | // This program is free software; you can redistribute it and/or modify 5 | // it under the terms of the GNU General Public License as published by 6 | // the Free Software Foundation; either version 2 of the License, or 7 | // (at your option) any later version. 8 | // 9 | // This program is distributed in the hope that it will be useful, 10 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | // GNU General Public License for more details. 13 | // 14 | // You should have received a copy of the GNU General Public License 15 | // along with this program; if not, write to the Free Software 16 | // Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 17 | // 18 | // 19 | // FILTER EXEMPTION: 20 | // 21 | // As a special exemption to the GPL in order to permit creation of 22 | // filters that work with multiple programs as well as VirtualDub, 23 | // compiling with this header file shall not be considered creation 24 | // of a derived work; that is, the act of compiling with this header 25 | // file does not require your source code or the resulting module 26 | // to be released in source code form or under a GPL-compatible 27 | // license according to parts (2) and (3) of the GPL. A filter built 28 | // using this header file may thus be licensed or dual-licensed so 29 | // that it may be used with VirtualDub as well as an alternative 30 | // product whose license is incompatible with the GPL. 31 | // 32 | // Nothing in this exemption shall be construed as applying to 33 | // VirtualDub itself -- that is, this exemption does not give you 34 | // permission to use parts of VirtualDub's source besides this 35 | // header file, or to dynamically link with VirtualDub as part 36 | // of the filter load process, in a fashion not permitted by the 37 | // GPL. 38 | 39 | #ifndef f_SYLIA_SCRIPTERROR_H 40 | #define f_SYLIA_SCRIPTERROR_H 41 | 42 | class CScriptError 43 | { 44 | public: 45 | int err; 46 | 47 | enum 48 | { 49 | PARSE_ERROR = 1, 50 | SEMICOLON_EXPECTED, 51 | IDENTIFIER_EXPECTED, 52 | 53 | TYPE_INT_REQUIRED, 54 | TYPE_ARRAY_REQUIRED, 55 | TYPE_FUNCTION_REQUIRED, 56 | TYPE_OBJECT_REQUIRED, 57 | 58 | OBJECT_MEMBER_NAME_REQUIRED, 59 | FUNCCALLEND_EXPECTED, 60 | TOO_MANY_PARAMS, 61 | DIVIDE_BY_ZERO, 62 | VAR_NOT_FOUND, 63 | MEMBER_NOT_FOUND, 64 | OVERLOADED_FUNCTION_NOT_FOUND, 65 | IDENT_TOO_LONG, 66 | OPERATOR_EXPECTED, 67 | CLOSEPARENS_EXPECTED, 68 | CLOSEBRACKET_EXPECTED, 69 | 70 | VAR_UNDEFINED, 71 | 72 | OUT_OF_STRING_SPACE, 73 | OUT_OF_MEMORY, 74 | INTERNAL_ERROR, 75 | EXTERNAL_ERROR, 76 | 77 | FCALL_OUT_OF_RANGE, 78 | FCALL_INVALID_PTYPE, 79 | FCALL_UNKNOWN_STR, 80 | }; 81 | 82 | CScriptError(int err_num) : err(err_num) { } 83 | 84 | int getErr() 85 | { 86 | return err; 87 | } 88 | }; 89 | 90 | #define SCRIPT_ERROR(x) throw CScriptError(CScriptError::##x) 91 | 92 | extern "C" __declspec(dllexport) char * __stdcall TranslateScriptError(int); 93 | 94 | char inline *TranslateScriptError(CScriptError cse) 95 | { 96 | return TranslateScriptError(cse.getErr()); 97 | } 98 | 99 | #endif 100 | -------------------------------------------------------------------------------- /include/vd2/extras/FilterSDK/ScriptInterpreter.h: -------------------------------------------------------------------------------- 1 | // VirtualDub - Video processing and capture application 2 | // Copyright (C) 1998-2002 Avery Lee 3 | // 4 | // This program is free software; you can redistribute it and/or modify 5 | // it under the terms of the GNU General Public License as published by 6 | // the Free Software Foundation; either version 2 of the License, or 7 | // (at your option) any later version. 8 | // 9 | // This program is distributed in the hope that it will be useful, 10 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | // GNU General Public License for more details. 13 | // 14 | // You should have received a copy of the GNU General Public License 15 | // along with this program; if not, write to the Free Software 16 | // Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 17 | // 18 | // 19 | // FILTER EXEMPTION: 20 | // 21 | // As a special exemption to the GPL in order to permit creation of 22 | // filters that work with multiple programs as well as VirtualDub, 23 | // compiling with this header file shall not be considered creation 24 | // of a derived work; that is, the act of compiling with this header 25 | // file does not require your source code or the resulting module 26 | // to be released in source code form or under a GPL-compatible 27 | // license according to parts (2) and (3) of the GPL. A filter built 28 | // using this header file may thus be licensed or dual-licensed so 29 | // that it may be used with VirtualDub as well as an alternative 30 | // product whose license is incompatible with the GPL. 31 | // 32 | // Nothing in this exemption shall be construed as applying to 33 | // VirtualDub itself -- that is, this exemption does not give you 34 | // permission to use parts of VirtualDub's source besides this 35 | // header file, or to dynamically link with VirtualDub as part 36 | // of the filter load process, in a fashion not permitted by the 37 | // GPL. 38 | 39 | #ifndef f_SYLIA_SCRIPTINTERPRETER_H 40 | #define f_SYLIA_SCRIPTINTERPRETER_H 41 | 42 | class CScriptValue; 43 | class CScriptError; 44 | struct CScriptObject; 45 | class IScriptInterpreter; 46 | 47 | typedef CScriptValue(*ScriptRootHandlerPtr)(IScriptInterpreter *, char *, void *); 48 | 49 | class IScriptInterpreter 50 | { 51 | public: 52 | virtual void Destroy() = 0; 53 | 54 | virtual void SetRootHandler(ScriptRootHandlerPtr, void *) = 0; 55 | 56 | virtual void ExecuteLine(char *s) = 0; 57 | 58 | virtual void ScriptError(int e) = 0; 59 | virtual char* TranslateScriptError(CScriptError& cse) = 0; 60 | virtual char** AllocTempString(long l) = 0; 61 | 62 | virtual CScriptValue LookupObjectMember(CScriptObject *obj, void *, char *szIdent) = 0; 63 | }; 64 | 65 | extern "C" __declspec(dllexport) IScriptInterpreter * __stdcall CreateScriptInterpreter(); 66 | 67 | #define GETPROC_CREATESCRIPTINTERPRETER(hInst) ((IScriptInterpreter *(__stdcall *)())GetProcAddress(hInst, "_CreateScriptInterpreter@0")) 68 | 69 | #define EXT_SCRIPT_ERROR(x) (isi->ScriptError((CScriptError::x))) 70 | 71 | #endif 72 | -------------------------------------------------------------------------------- /include/vd2/extras/FilterSDK/VirtualDub.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "Filter.h" 4 | #include "ScriptInterpreter.h" 5 | #include "ScriptError.h" 6 | #include "ScriptValue.h" 7 | #include "VBitmap.h" 8 | -------------------------------------------------------------------------------- /include/vd2/extras/FilterSDK/readme.txt: -------------------------------------------------------------------------------- 1 | There are the header files that were included with the last version of the 2 | Filter SDK. You can use these if you need to rebuild a filter that doesn't 3 | compile with the new headers, or otherwise need to know the full API supported 4 | by that SDK (such as if you are building a new filter host). If possible, 5 | you should use the migration headers in include/vd2/OldFilterSDK instead, 6 | and new filters should use directly. 7 | -------------------------------------------------------------------------------- /publish.bat: -------------------------------------------------------------------------------- 1 | rem if "%VS160COMNTOOLS%"=="" goto end 2 | 3 | rem call "%VS160COMNTOOLS%vsdevcmd.bat" 4 | cd /d "%~dp0" 5 | 6 | echo y | rd /s tmp 7 | 8 | msbuild /t:Rebuild /p:WindowsTargetPlatformVersion=10.0.18362.0 /p:PlatformToolset=v141 /m /p:"Configuration=Release (MOD)" /p:Platform=Win32 9 | if errorlevel 1 goto end 10 | 11 | msbuild /t:Rebuild /p:WindowsTargetPlatformVersion=10.0.18362.0 /p:PlatformToolset=v141 /m /p:"Configuration=Release (MOD)" /p:Platform=x64 12 | if errorlevel 1 goto end 13 | 14 | mkdir tmp 15 | mkdir tmp\x86 16 | mkdir tmp\x64 17 | copy "bin\Win32\VSFilter\Release (MOD)\VSFilterMod.dll" "tmp\x86\VSFilterMod.dll" 18 | copy "bin\x64\VSFilter\Release (MOD)\VSFilterMod.dll" "tmp\x64\VSFilterMod.dll" 19 | 20 | del VSFilterMod_bin.7z 21 | 22 | cd tmp 23 | ..\7zr.exe a -r -mx=9 -myx=9 ..\VSFilterMod_bin.7z . 24 | cd .. 25 | 26 | :end 27 | -------------------------------------------------------------------------------- /src/BaseClasses/LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) Microsoft Corporation 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in 13 | all copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 21 | THE SOFTWARE. 22 | 23 | Portions of this repo are provided under the SIL Open Font License. 24 | See the LICENSE file in individual samples for additional details. 25 | -------------------------------------------------------------------------------- /src/BaseClasses/Readme.md: -------------------------------------------------------------------------------- 1 | DirectShow Base Classes 2 | ======================= 3 | 4 | The DirectShow base classes are a set of C++ classes and utility functions designed for implementing DirectShow filters. 5 | 6 | The base class library is provided as a SDK sample in the Microsoft Windows Software Development Kit (SDK). 7 | 8 | + Docs: [DirectShow Base Classes - Win32 apps | Microsoft Docs](https://docs.microsoft.com/en-us/windows/win32/directshow/directshow-base-classes) 9 | + Source code: [Windows-classic-samples/Samples/Win7Samples/multimedia/directshow/baseclasses](https://github.com/microsoft/Windows-classic-samples/tree/master/Samples/Win7Samples/multimedia/directshow/baseclasses) 10 | + [LICENSE](LICENSE) Copy from: [Windows-classic-samples/LICENSE](https://github.com/microsoft/Windows-classic-samples/blob/master/LICENSE) 11 | -------------------------------------------------------------------------------- /src/BaseClasses/amextra.cpp: -------------------------------------------------------------------------------- 1 | //------------------------------------------------------------------------------ 2 | // File: AMExtra.cpp 3 | // 4 | // Desc: DirectShow base classes - implements CRenderedInputPin class. 5 | // 6 | // Copyright (c) 1992-2001 Microsoft Corporation. All rights reserved. 7 | //------------------------------------------------------------------------------ 8 | 9 | 10 | #include // DirectShow base class definitions 11 | #include // Needed for definition of timeGetTime 12 | #include // Standard data type limit definitions 13 | #include // Used for time critical log functions 14 | 15 | #include "amextra.h" 16 | 17 | #pragma warning(disable:4355) 18 | 19 | // Implements CRenderedInputPin class 20 | 21 | CRenderedInputPin::CRenderedInputPin(__in_opt LPCTSTR pObjectName, 22 | __in CBaseFilter *pFilter, 23 | __in CCritSec *pLock, 24 | __inout HRESULT *phr, 25 | __in_opt LPCWSTR pName) : 26 | CBaseInputPin(pObjectName, pFilter, pLock, phr, pName), 27 | m_bAtEndOfStream(FALSE), 28 | m_bCompleteNotified(FALSE) 29 | { 30 | } 31 | #ifdef UNICODE 32 | CRenderedInputPin::CRenderedInputPin(__in_opt LPCSTR pObjectName, 33 | __in CBaseFilter *pFilter, 34 | __in CCritSec *pLock, 35 | __inout HRESULT *phr, 36 | __in_opt LPCWSTR pName) : 37 | CBaseInputPin(pObjectName, pFilter, pLock, phr, pName), 38 | m_bAtEndOfStream(FALSE), 39 | m_bCompleteNotified(FALSE) 40 | { 41 | } 42 | #endif 43 | 44 | // Flush end of stream condition - caller should do any 45 | // necessary stream level locking before calling this 46 | 47 | STDMETHODIMP CRenderedInputPin::EndOfStream() 48 | { 49 | HRESULT hr = CheckStreaming(); 50 | 51 | // Do EC_COMPLETE handling for rendered pins 52 | if(S_OK == hr && !m_bAtEndOfStream) 53 | { 54 | m_bAtEndOfStream = TRUE; 55 | FILTER_STATE fs; 56 | EXECUTE_ASSERT(SUCCEEDED(m_pFilter->GetState(0, &fs))); 57 | if(fs == State_Running) 58 | { 59 | DoCompleteHandling(); 60 | } 61 | } 62 | return hr; 63 | } 64 | 65 | 66 | // Called to complete the flush 67 | 68 | STDMETHODIMP CRenderedInputPin::EndFlush() 69 | { 70 | CAutoLock lck(m_pLock); 71 | 72 | // Clean up renderer state 73 | m_bAtEndOfStream = FALSE; 74 | m_bCompleteNotified = FALSE; 75 | 76 | return CBaseInputPin::EndFlush(); 77 | } 78 | 79 | 80 | // Notify of Run() from filter 81 | 82 | HRESULT CRenderedInputPin::Run(REFERENCE_TIME tStart) 83 | { 84 | UNREFERENCED_PARAMETER(tStart); 85 | m_bCompleteNotified = FALSE; 86 | if(m_bAtEndOfStream) 87 | { 88 | DoCompleteHandling(); 89 | } 90 | return S_OK; 91 | } 92 | 93 | 94 | // Clear status on going into paused state 95 | 96 | HRESULT CRenderedInputPin::Active() 97 | { 98 | m_bAtEndOfStream = FALSE; 99 | m_bCompleteNotified = FALSE; 100 | return CBaseInputPin::Active(); 101 | } 102 | 103 | 104 | // Do stuff to deliver end of stream 105 | 106 | void CRenderedInputPin::DoCompleteHandling() 107 | { 108 | ASSERT(m_bAtEndOfStream); 109 | if(!m_bCompleteNotified) 110 | { 111 | m_bCompleteNotified = TRUE; 112 | m_pFilter->NotifyEvent(EC_COMPLETE, S_OK, (LONG_PTR)(IBaseFilter *)m_pFilter); 113 | } 114 | } 115 | 116 | -------------------------------------------------------------------------------- /src/BaseClasses/amextra.h: -------------------------------------------------------------------------------- 1 | //------------------------------------------------------------------------------ 2 | // File: AMExtra.h 3 | // 4 | // Desc: DirectShow base classes. 5 | // 6 | // Copyright (c) 1992-2001 Microsoft Corporation. All rights reserved. 7 | //------------------------------------------------------------------------------ 8 | 9 | 10 | #ifndef __AMEXTRA__ 11 | #define __AMEXTRA__ 12 | 13 | // Simple rendered input pin 14 | // 15 | // NOTE if your filter queues stuff before rendering then it may not be 16 | // appropriate to use this class 17 | // 18 | // In that case queue the end of stream condition until the last sample 19 | // is actually rendered and flush the condition appropriately 20 | 21 | class CRenderedInputPin : public CBaseInputPin 22 | { 23 | public: 24 | 25 | CRenderedInputPin(__in_opt LPCTSTR pObjectName, 26 | __in CBaseFilter *pFilter, 27 | __in CCritSec *pLock, 28 | __inout HRESULT *phr, 29 | __in_opt LPCWSTR pName); 30 | #ifdef UNICODE 31 | CRenderedInputPin(__in_opt LPCSTR pObjectName, 32 | __in CBaseFilter *pFilter, 33 | __in CCritSec *pLock, 34 | __inout HRESULT *phr, 35 | __in_opt LPCWSTR pName); 36 | #endif 37 | 38 | // Override methods to track end of stream state 39 | STDMETHODIMP EndOfStream(); 40 | STDMETHODIMP EndFlush(); 41 | 42 | HRESULT Active(); 43 | HRESULT Run(REFERENCE_TIME tStart); 44 | 45 | protected: 46 | 47 | // Member variables to track state 48 | BOOL m_bAtEndOfStream; // Set by EndOfStream 49 | BOOL m_bCompleteNotified; // Set when we notify for EC_COMPLETE 50 | 51 | private: 52 | void DoCompleteHandling(); 53 | }; 54 | 55 | #endif // __AMEXTRA__ 56 | 57 | -------------------------------------------------------------------------------- /src/BaseClasses/cache.h: -------------------------------------------------------------------------------- 1 | //------------------------------------------------------------------------------ 2 | // File: Cache.h 3 | // 4 | // Desc: DirectShow base classes - efines a non-MFC generic cache class. 5 | // 6 | // Copyright (c) 1992-2001 Microsoft Corporation. All rights reserved. 7 | //------------------------------------------------------------------------------ 8 | 9 | 10 | /* This class implements a simple cache. A cache object is instantiated 11 | with the number of items it is to hold. An item is a pointer to an 12 | object derived from CBaseObject (helps reduce memory leaks). The cache 13 | can then have objects added to it and removed from it. The cache size 14 | is fixed at construction time and may therefore run out or be flooded. 15 | If it runs out it returns a NULL pointer, if it fills up it also returns 16 | a NULL pointer instead of a pointer to the object just inserted */ 17 | 18 | /* Making these classes inherit from CBaseObject does nothing for their 19 | functionality but it allows us to check there are no memory leaks */ 20 | 21 | /* WARNING Be very careful when using this class, what it lets you do is 22 | store and retrieve objects so that you can minimise object creation 23 | which in turns improves efficiency. However the object you store is 24 | exactly the same as the object you get back which means that it short 25 | circuits the constructor initialisation phase. This means any class 26 | variables the object has (eg pointers) are highly likely to be invalid. 27 | Therefore ensure you reinitialise the object before using it again */ 28 | 29 | 30 | #ifndef __CACHE__ 31 | #define __CACHE__ 32 | 33 | 34 | class CCache : CBaseObject 35 | { 36 | 37 | /* Make copy constructor and assignment operator inaccessible */ 38 | 39 | CCache(const CCache &refCache); 40 | CCache &operator=(const CCache &refCache); 41 | 42 | private: 43 | 44 | /* These are initialised in the constructor. The first variable points to 45 | an array of pointers, each of which points to a CBaseObject derived 46 | object. The m_iCacheSize is the static fixed size for the cache and the 47 | m_iUsed defines the number of places filled with objects at any time. 48 | We fill the array of pointers from the start (ie m_ppObjects[0] first) 49 | and then only add and remove objects from the end position, so in this 50 | respect the array of object pointers should be treated as a stack */ 51 | 52 | CBaseObject **m_ppObjects; 53 | const INT m_iCacheSize; 54 | INT m_iUsed; 55 | 56 | public: 57 | 58 | CCache(__in_opt LPCTSTR pName, INT iItems); 59 | virtual ~CCache(); 60 | 61 | /* Add an item to the cache */ 62 | CBaseObject *AddToCache(__in CBaseObject *pObject); 63 | 64 | /* Remove an item from the cache */ 65 | CBaseObject *RemoveFromCache(); 66 | 67 | /* Delete all the objects held in the cache */ 68 | void RemoveAll(void); 69 | 70 | /* Return the cache size which is set during construction */ 71 | INT GetCacheSize(void) const 72 | { 73 | return m_iCacheSize; 74 | }; 75 | }; 76 | 77 | #endif /* __CACHE__ */ 78 | 79 | -------------------------------------------------------------------------------- /src/BaseClasses/ddmm.h: -------------------------------------------------------------------------------- 1 | //------------------------------------------------------------------------------ 2 | // File: DDMM.h 3 | // 4 | // Desc: DirectShow base classes - efines routines for using DirectDraw 5 | // on a multimonitor system. 6 | // 7 | // Copyright (c) 1995-2001 Microsoft Corporation. All rights reserved. 8 | //------------------------------------------------------------------------------ 9 | 10 | 11 | #ifdef __cplusplus 12 | extern "C" { /* Assume C declarations for C++ */ 13 | #endif /* __cplusplus */ 14 | 15 | // DDRAW.H might not include these 16 | #ifndef DDENUM_ATTACHEDSECONDARYDEVICES 17 | #define DDENUM_ATTACHEDSECONDARYDEVICES 0x00000001L 18 | #endif 19 | 20 | typedef HRESULT(*PDRAWCREATE)(IID *, LPDIRECTDRAW *, LPUNKNOWN); 21 | typedef HRESULT(*PDRAWENUM)(LPDDENUMCALLBACKA, LPVOID); 22 | 23 | IDirectDraw * DirectDrawCreateFromDevice(__in_opt LPSTR, PDRAWCREATE, PDRAWENUM); 24 | IDirectDraw * DirectDrawCreateFromDeviceEx(__in_opt LPSTR, PDRAWCREATE, LPDIRECTDRAWENUMERATEEXA); 25 | 26 | #ifdef __cplusplus 27 | } 28 | #endif /* __cplusplus */ 29 | -------------------------------------------------------------------------------- /src/BaseClasses/dllsetup.h: -------------------------------------------------------------------------------- 1 | //------------------------------------------------------------------------------ 2 | // File: DllSetup.h 3 | // 4 | // Desc: DirectShow base classes. 5 | // 6 | // Copyright (c) 1992-2001 Microsoft Corporation. All rights reserved. 7 | //------------------------------------------------------------------------------ 8 | 9 | 10 | // To be self registering, OLE servers must 11 | // export functions named DllRegisterServer 12 | // and DllUnregisterServer. To allow use of 13 | // custom and default implementations the 14 | // defaults are named AMovieDllRegisterServer 15 | // and AMovieDllUnregisterServer. 16 | // 17 | // To the use the default implementation you 18 | // must provide stub functions. 19 | // 20 | // i.e. STDAPI DllRegisterServer() 21 | // { 22 | // return AMovieDllRegisterServer(); 23 | // } 24 | // 25 | // STDAPI DllUnregisterServer() 26 | // { 27 | // return AMovieDllUnregisterServer(); 28 | // } 29 | // 30 | // 31 | // AMovieDllRegisterServer calls IAMovieSetup.Register(), and 32 | // AMovieDllUnregisterServer calls IAMovieSetup.Unregister(). 33 | 34 | STDAPI AMovieDllRegisterServer2(BOOL); 35 | STDAPI AMovieDllRegisterServer(); 36 | STDAPI AMovieDllUnregisterServer(); 37 | 38 | // helper functions 39 | STDAPI EliminateSubKey(HKEY, LPCTSTR); 40 | 41 | 42 | STDAPI 43 | AMovieSetupRegisterFilter2(const AMOVIESETUP_FILTER * const psetupdata 44 | , IFilterMapper2 * pIFM2 45 | , BOOL bRegister); 46 | 47 | -------------------------------------------------------------------------------- /src/BaseClasses/fourcc.h: -------------------------------------------------------------------------------- 1 | //------------------------------------------------------------------------------ 2 | // File: FourCC.h 3 | // 4 | // Desc: DirectShow base classes. 5 | // 6 | // Copyright (c) 1992-2001 Microsoft Corporation. All rights reserved. 7 | //------------------------------------------------------------------------------ 8 | 9 | 10 | // FOURCCMap 11 | // 12 | // provides a mapping between old-style multimedia format DWORDs 13 | // and new-style GUIDs. 14 | // 15 | // A range of 4 billion GUIDs has been allocated to ensure that this 16 | // mapping can be done straightforwardly one-to-one in both directions. 17 | // 18 | // January 95 19 | 20 | 21 | #ifndef __FOURCC__ 22 | #define __FOURCC__ 23 | 24 | 25 | // Multimedia format types are marked with DWORDs built from four 8-bit 26 | // chars and known as FOURCCs. New multimedia AM_MEDIA_TYPE definitions include 27 | // a subtype GUID. In order to simplify the mapping, GUIDs in the range: 28 | // XXXXXXXX-0000-0010-8000-00AA00389B71 29 | // are reserved for FOURCCs. 30 | 31 | class FOURCCMap : public GUID 32 | { 33 | 34 | public: 35 | FOURCCMap(); 36 | FOURCCMap(DWORD Fourcc); 37 | FOURCCMap(const GUID *); 38 | 39 | 40 | DWORD GetFOURCC(void); 41 | void SetFOURCC(DWORD fourcc); 42 | void SetFOURCC(const GUID *); 43 | 44 | private: 45 | void InitGUID(); 46 | }; 47 | 48 | #define GUID_Data2 0 49 | #define GUID_Data3 0x10 50 | #define GUID_Data4_1 0xaa000080 51 | #define GUID_Data4_2 0x719b3800 52 | 53 | inline void 54 | FOURCCMap::InitGUID() 55 | { 56 | Data2 = GUID_Data2; 57 | Data3 = GUID_Data3; 58 | ((DWORD *)Data4)[0] = GUID_Data4_1; 59 | ((DWORD *)Data4)[1] = GUID_Data4_2; 60 | } 61 | 62 | inline 63 | FOURCCMap::FOURCCMap() 64 | { 65 | InitGUID(); 66 | SetFOURCC(DWORD(0)); 67 | } 68 | 69 | inline 70 | FOURCCMap::FOURCCMap(DWORD fourcc) 71 | { 72 | InitGUID(); 73 | SetFOURCC(fourcc); 74 | } 75 | 76 | inline 77 | FOURCCMap::FOURCCMap(const GUID * pGuid) 78 | { 79 | InitGUID(); 80 | SetFOURCC(pGuid); 81 | } 82 | 83 | inline void 84 | FOURCCMap::SetFOURCC(const GUID * pGuid) 85 | { 86 | FOURCCMap * p = (FOURCCMap*) pGuid; 87 | SetFOURCC(p->GetFOURCC()); 88 | } 89 | 90 | inline void 91 | FOURCCMap::SetFOURCC(DWORD fourcc) 92 | { 93 | Data1 = fourcc; 94 | } 95 | 96 | inline DWORD 97 | FOURCCMap::GetFOURCC(void) 98 | { 99 | return Data1; 100 | } 101 | 102 | #endif /* __FOURCC__ */ 103 | 104 | -------------------------------------------------------------------------------- /src/BaseClasses/mtype.h: -------------------------------------------------------------------------------- 1 | //------------------------------------------------------------------------------ 2 | // File: MtType.h 3 | // 4 | // Desc: DirectShow base classes - defines a class that holds and manages 5 | // media type information. 6 | // 7 | // Copyright (c) 1992-2001 Microsoft Corporation. All rights reserved. 8 | //------------------------------------------------------------------------------ 9 | 10 | 11 | #ifndef __MTYPE__ 12 | #define __MTYPE__ 13 | 14 | /* Helper class that derived pin objects can use to compare media 15 | types etc. Has same data members as the struct AM_MEDIA_TYPE defined 16 | in the streams IDL file, but also has (non-virtual) functions */ 17 | 18 | class CMediaType : public _AMMediaType 19 | { 20 | 21 | public: 22 | 23 | ~CMediaType(); 24 | CMediaType(); 25 | CMediaType(const GUID * majortype); 26 | CMediaType(const AM_MEDIA_TYPE&, __out_opt HRESULT* phr = NULL); 27 | CMediaType(const CMediaType&, __out_opt HRESULT* phr = NULL); 28 | 29 | CMediaType& operator=(const CMediaType&); 30 | CMediaType& operator=(const AM_MEDIA_TYPE&); 31 | 32 | BOOL operator == (const CMediaType&) const; 33 | BOOL operator != (const CMediaType&) const; 34 | 35 | HRESULT Set(const CMediaType& rt); 36 | HRESULT Set(const AM_MEDIA_TYPE& rt); 37 | 38 | BOOL IsValid() const; 39 | 40 | const GUID *Type() const 41 | { 42 | return &majortype; 43 | } ; 44 | void SetType(const GUID *); 45 | const GUID *Subtype() const 46 | { 47 | return &subtype; 48 | } ; 49 | void SetSubtype(const GUID *); 50 | 51 | BOOL IsFixedSize() const 52 | { 53 | return bFixedSizeSamples; 54 | }; 55 | BOOL IsTemporalCompressed() const 56 | { 57 | return bTemporalCompression; 58 | }; 59 | ULONG GetSampleSize() const; 60 | 61 | void SetSampleSize(ULONG sz); 62 | void SetVariableSize(); 63 | void SetTemporalCompression(BOOL bCompressed); 64 | 65 | // read/write pointer to format - can't change length without 66 | // calling SetFormat, AllocFormatBuffer or ReallocFormatBuffer 67 | 68 | BYTE* Format() const 69 | { 70 | return pbFormat; 71 | }; 72 | ULONG FormatLength() const 73 | { 74 | return cbFormat; 75 | }; 76 | 77 | void SetFormatType(const GUID *); 78 | const GUID *FormatType() const 79 | { 80 | return &formattype; 81 | }; 82 | BOOL SetFormat(__in_bcount(length) BYTE *pFormat, ULONG length); 83 | void ResetFormatBuffer(); 84 | BYTE* AllocFormatBuffer(ULONG length); 85 | BYTE* ReallocFormatBuffer(ULONG length); 86 | 87 | void InitMediaType(); 88 | 89 | BOOL MatchesPartial(const CMediaType* ppartial) const; 90 | BOOL IsPartiallySpecified(void) const; 91 | }; 92 | 93 | 94 | /* General purpose functions to copy and delete a task allocated AM_MEDIA_TYPE 95 | structure which is useful when using the IEnumMediaFormats interface as 96 | the implementation allocates the structures which you must later delete */ 97 | 98 | void WINAPI DeleteMediaType(__inout_opt AM_MEDIA_TYPE *pmt); 99 | AM_MEDIA_TYPE * WINAPI CreateMediaType(AM_MEDIA_TYPE const *pSrc); 100 | HRESULT WINAPI CopyMediaType(__out AM_MEDIA_TYPE *pmtTarget, const AM_MEDIA_TYPE *pmtSource); 101 | void WINAPI FreeMediaType(__inout AM_MEDIA_TYPE& mt); 102 | 103 | // Initialize a media type from a WAVEFORMATEX 104 | 105 | STDAPI CreateAudioMediaType( 106 | const WAVEFORMATEX *pwfx, 107 | __out AM_MEDIA_TYPE *pmt, 108 | BOOL bSetFormat); 109 | 110 | #endif /* __MTYPE__ */ 111 | 112 | -------------------------------------------------------------------------------- /src/BaseClasses/perflog.h: -------------------------------------------------------------------------------- 1 | //------------------------------------------------------------------------------ 2 | // File: perflog.h 3 | // 4 | // Desc: Performance logging framework. 5 | // 6 | // Copyright (c) 1992-2001 Microsoft Corporation. All rights reserved. 7 | //------------------------------------------------------------------------------ 8 | 9 | typedef struct _PERFLOG_LOGGING_PARAMS 10 | { 11 | GUID ControlGuid; 12 | void (*OnStateChanged)(void); 13 | ULONG NumberOfTraceGuids; 14 | TRACE_GUID_REGISTRATION TraceGuids[ANYSIZE_ARRAY]; 15 | } PERFLOG_LOGGING_PARAMS, *PPERFLOG_LOGGING_PARAMS; 16 | 17 | BOOL 18 | PerflogInitIfEnabled( 19 | IN HINSTANCE hInstance, 20 | __in PPERFLOG_LOGGING_PARAMS LogParams 21 | ); 22 | 23 | BOOL 24 | PerflogInitialize( 25 | __in PPERFLOG_LOGGING_PARAMS LogParams 26 | ); 27 | 28 | VOID 29 | PerflogShutdown( 30 | VOID 31 | ); 32 | 33 | VOID 34 | PerflogTraceEvent( 35 | __in PEVENT_TRACE_HEADER Event 36 | ); 37 | 38 | extern ULONG PerflogEnableFlags; 39 | extern UCHAR PerflogEnableLevel; 40 | extern ULONG PerflogModuleLevel; 41 | extern TRACEHANDLE PerflogTraceHandle; 42 | extern TRACEHANDLE PerflogRegHandle; 43 | 44 | #define PerflogTracingEnabled() (PerflogTraceHandle != 0) 45 | 46 | #define PerflogEvent( _x_ ) PerflogTraceEventLevel _x_ 47 | 48 | VOID 49 | PerflogTraceEventLevel( 50 | ULONG Level, 51 | __in PEVENT_TRACE_HEADER Event 52 | ); 53 | 54 | VOID 55 | PerflogTraceEvent( 56 | __in PEVENT_TRACE_HEADER Event 57 | ); 58 | -------------------------------------------------------------------------------- /src/BaseClasses/reftime.h: -------------------------------------------------------------------------------- 1 | //------------------------------------------------------------------------------ 2 | // File: RefTime.h 3 | // 4 | // Desc: DirectShow base classes - defines CRefTime, a class that manages 5 | // reference times. 6 | // 7 | // Copyright (c) 1992-2001 Microsoft Corporation. All rights reserved. 8 | //------------------------------------------------------------------------------ 9 | 10 | 11 | // 12 | // CRefTime 13 | // 14 | // Manage reference times. 15 | // Shares same data layout as REFERENCE_TIME, but adds some (nonvirtual) 16 | // functions providing simple comparison, conversion and arithmetic. 17 | // 18 | // A reference time (at the moment) is a unit of seconds represented in 19 | // 100ns units as is used in the Win32 FILETIME structure. BUT the time 20 | // a REFERENCE_TIME represents is NOT the time elapsed since 1/1/1601 it 21 | // will either be stream time or reference time depending upon context 22 | // 23 | // This class provides simple arithmetic operations on reference times 24 | // 25 | // keep non-virtual otherwise the data layout will not be the same as 26 | // REFERENCE_TIME 27 | 28 | 29 | // ----- 30 | // note that you are safe to cast a CRefTime* to a REFERENCE_TIME*, but 31 | // you will need to do so explicitly 32 | // ----- 33 | 34 | 35 | #ifndef __REFTIME__ 36 | #define __REFTIME__ 37 | 38 | 39 | const LONGLONG MILLISECONDS = (1000); // 10 ^ 3 40 | const LONGLONG NANOSECONDS = (1000000000); // 10 ^ 9 41 | const LONGLONG UNITS = (NANOSECONDS / 100); // 10 ^ 7 42 | 43 | /* Unfortunately an inline function here generates a call to __allmul 44 | - even for constants! 45 | */ 46 | #define MILLISECONDS_TO_100NS_UNITS(lMs) \ 47 | Int32x32To64((lMs), (UNITS / MILLISECONDS)) 48 | 49 | class CRefTime 50 | { 51 | public: 52 | 53 | // *MUST* be the only data member so that this class is exactly 54 | // equivalent to a REFERENCE_TIME. 55 | // Also, must be *no virtual functions* 56 | 57 | REFERENCE_TIME m_time; 58 | 59 | inline CRefTime() 60 | { 61 | // default to 0 time 62 | m_time = 0; 63 | }; 64 | 65 | inline CRefTime(LONG msecs) 66 | { 67 | m_time = MILLISECONDS_TO_100NS_UNITS(msecs); 68 | }; 69 | 70 | inline CRefTime(REFERENCE_TIME rt) 71 | { 72 | m_time = rt; 73 | }; 74 | 75 | inline operator REFERENCE_TIME() const 76 | { 77 | return m_time; 78 | }; 79 | 80 | inline CRefTime& operator=(const CRefTime& rt) 81 | { 82 | m_time = rt.m_time; 83 | return *this; 84 | }; 85 | 86 | inline CRefTime& operator=(const LONGLONG ll) 87 | { 88 | m_time = ll; 89 | return *this; 90 | }; 91 | 92 | inline CRefTime& operator+=(const CRefTime& rt) 93 | { 94 | return (*this = *this + rt); 95 | }; 96 | 97 | inline CRefTime& operator-=(const CRefTime& rt) 98 | { 99 | return (*this = *this - rt); 100 | }; 101 | 102 | inline LONG Millisecs(void) 103 | { 104 | return (LONG)(m_time / (UNITS / MILLISECONDS)); 105 | }; 106 | 107 | inline LONGLONG GetUnits(void) 108 | { 109 | return m_time; 110 | }; 111 | }; 112 | 113 | const LONGLONG TimeZero = 0; 114 | 115 | #endif /* __REFTIME__ */ 116 | 117 | -------------------------------------------------------------------------------- /src/BaseClasses/seekpt.cpp: -------------------------------------------------------------------------------- 1 | //------------------------------------------------------------------------------ 2 | // File: SeekPT.cpp 3 | // 4 | // Desc: DirectShow base classes. 5 | // 6 | // Copyright (c) 1992-2001 Microsoft Corporation. All rights reserved. 7 | //------------------------------------------------------------------------------ 8 | 9 | 10 | #include 11 | #include "seekpt.h" 12 | 13 | //================================================================== 14 | // CreateInstance 15 | // This goes in the factory template table to create new instances 16 | // If there is already a mapper instance - return that, else make one 17 | // and save it in a static variable so that forever after we can return that. 18 | //================================================================== 19 | 20 | CUnknown * CSeekingPassThru::CreateInstance(__inout_opt LPUNKNOWN pUnk, __inout HRESULT *phr) 21 | { 22 | return new CSeekingPassThru(NAME("Seeking PassThru"), pUnk, phr); 23 | } 24 | 25 | 26 | STDMETHODIMP CSeekingPassThru::NonDelegatingQueryInterface(REFIID riid, __deref_out void ** ppv) 27 | { 28 | if(riid == IID_ISeekingPassThru) 29 | { 30 | return GetInterface((ISeekingPassThru *) this, ppv); 31 | } 32 | else 33 | { 34 | if(m_pPosPassThru && 35 | (riid == IID_IMediaSeeking || 36 | riid == IID_IMediaPosition)) 37 | { 38 | return m_pPosPassThru->NonDelegatingQueryInterface(riid, ppv); 39 | } 40 | else 41 | { 42 | return CUnknown::NonDelegatingQueryInterface(riid, ppv); 43 | } 44 | } 45 | } 46 | 47 | 48 | CSeekingPassThru::CSeekingPassThru(__in_opt LPCTSTR pName, __inout_opt LPUNKNOWN pUnk, __inout HRESULT *phr) 49 | : CUnknown(pName, pUnk, phr), 50 | m_pPosPassThru(NULL) 51 | { 52 | } 53 | 54 | 55 | CSeekingPassThru::~CSeekingPassThru() 56 | { 57 | delete m_pPosPassThru; 58 | } 59 | 60 | STDMETHODIMP CSeekingPassThru::Init(BOOL bRendererSeeking, IPin *pPin) 61 | { 62 | HRESULT hr = NOERROR; 63 | if(m_pPosPassThru) 64 | { 65 | hr = E_FAIL; 66 | } 67 | else 68 | { 69 | m_pPosPassThru = 70 | bRendererSeeking ? 71 | new CRendererPosPassThru( 72 | NAME("Render Seeking COM object"), 73 | (IUnknown *)this, 74 | &hr, 75 | pPin) : 76 | new CPosPassThru( 77 | NAME("Render Seeking COM object"), 78 | (IUnknown *)this, 79 | &hr, 80 | pPin); 81 | if(!m_pPosPassThru) 82 | { 83 | hr = E_OUTOFMEMORY; 84 | } 85 | else 86 | { 87 | if(FAILED(hr)) 88 | { 89 | delete m_pPosPassThru; 90 | m_pPosPassThru = NULL; 91 | } 92 | } 93 | } 94 | return hr; 95 | } 96 | 97 | -------------------------------------------------------------------------------- /src/BaseClasses/seekpt.h: -------------------------------------------------------------------------------- 1 | //------------------------------------------------------------------------------ 2 | // File: SeekPT.h 3 | // 4 | // Desc: DirectShow base classes. 5 | // 6 | // Copyright (c) 1992-2001 Microsoft Corporation. All rights reserved. 7 | //------------------------------------------------------------------------------ 8 | 9 | 10 | #ifndef __seekpt_h__ 11 | #define __seekpt_h__ 12 | 13 | 14 | class CSeekingPassThru : public ISeekingPassThru, public CUnknown 15 | { 16 | public: 17 | static CUnknown *CreateInstance(__inout_opt LPUNKNOWN pUnk, __inout HRESULT *phr); 18 | CSeekingPassThru(__in_opt LPCTSTR pName, __inout_opt LPUNKNOWN pUnk, __inout HRESULT *phr); 19 | ~CSeekingPassThru(); 20 | 21 | DECLARE_IUNKNOWN; 22 | STDMETHODIMP NonDelegatingQueryInterface(REFIID riid, __deref_out void ** ppv); 23 | 24 | STDMETHODIMP Init(BOOL bSupportRendering, IPin *pPin); 25 | 26 | private: 27 | CPosPassThru *m_pPosPassThru; 28 | }; 29 | 30 | #endif 31 | -------------------------------------------------------------------------------- /src/BaseClasses/sysclock.cpp: -------------------------------------------------------------------------------- 1 | //------------------------------------------------------------------------------ 2 | // File: SysClock.cpp 3 | // 4 | // Desc: DirectShow base classes - implements a system clock based on 5 | // IReferenceClock. 6 | // 7 | // Copyright (c) 1992-2001 Microsoft Corporation. All rights reserved. 8 | //------------------------------------------------------------------------------ 9 | 10 | 11 | #include 12 | #include 13 | 14 | 15 | #ifdef FILTER_DLL 16 | 17 | /* List of class IDs and creator functions for the class factory. This 18 | provides the link between the OLE entry point in the DLL and an object 19 | being created. The class factory will call the static CreateInstance 20 | function when it is asked to create a CLSID_SystemClock object */ 21 | 22 | CFactoryTemplate g_Templates[1] = 23 | { 24 | {&CLSID_SystemClock, CSystemClock::CreateInstance} 25 | }; 26 | 27 | int g_cTemplates = sizeof(g_Templates) / sizeof(g_Templates[0]); 28 | #endif 29 | 30 | /* This goes in the factory template table to create new instances */ 31 | CUnknown * WINAPI CSystemClock::CreateInstance(__inout_opt LPUNKNOWN pUnk, __inout HRESULT *phr) 32 | { 33 | return new CSystemClock(NAME("System reference clock"), pUnk, phr); 34 | } 35 | 36 | 37 | CSystemClock::CSystemClock(__in_opt LPCTSTR pName, __inout_opt LPUNKNOWN pUnk, __inout HRESULT *phr) : 38 | CBaseReferenceClock(pName, pUnk, phr) 39 | { 40 | } 41 | 42 | STDMETHODIMP CSystemClock::NonDelegatingQueryInterface( 43 | REFIID riid, 44 | __deref_out void ** ppv) 45 | { 46 | if(riid == IID_IPersist) 47 | { 48 | return GetInterface(static_cast(this), ppv); 49 | } 50 | else if(riid == IID_IAMClockAdjust) 51 | { 52 | return GetInterface(static_cast(this), ppv); 53 | } 54 | else 55 | { 56 | return CBaseReferenceClock::NonDelegatingQueryInterface(riid, ppv); 57 | } 58 | } 59 | 60 | /* Return the clock's clsid */ 61 | STDMETHODIMP 62 | CSystemClock::GetClassID(__out CLSID *pClsID) 63 | { 64 | CheckPointer(pClsID, E_POINTER); 65 | ValidateReadWritePtr(pClsID, sizeof(CLSID)); 66 | *pClsID = CLSID_SystemClock; 67 | return NOERROR; 68 | } 69 | 70 | 71 | STDMETHODIMP 72 | CSystemClock::SetClockDelta(REFERENCE_TIME rtDelta) 73 | { 74 | return SetTimeDelta(rtDelta); 75 | } 76 | -------------------------------------------------------------------------------- /src/BaseClasses/sysclock.h: -------------------------------------------------------------------------------- 1 | //------------------------------------------------------------------------------ 2 | // File: SysClock.h 3 | // 4 | // Desc: DirectShow base classes - defines a system clock implementation of 5 | // IReferenceClock. 6 | // 7 | // Copyright (c) 1992-2001 Microsoft Corporation. All rights reserved. 8 | //------------------------------------------------------------------------------ 9 | 10 | 11 | #ifndef __SYSTEMCLOCK__ 12 | #define __SYSTEMCLOCK__ 13 | 14 | // 15 | // Base clock. Uses timeGetTime ONLY 16 | // Uses most of the code in the base reference clock. 17 | // Provides GetTime 18 | // 19 | 20 | class CSystemClock : public CBaseReferenceClock, public IAMClockAdjust, public IPersist 21 | { 22 | public: 23 | // We must be able to create an instance of ourselves 24 | static CUnknown * WINAPI CreateInstance(__inout_opt LPUNKNOWN pUnk, __inout HRESULT *phr); 25 | CSystemClock(__in_opt LPCTSTR pName, __inout_opt LPUNKNOWN pUnk, __inout HRESULT *phr); 26 | 27 | DECLARE_IUNKNOWN 28 | 29 | STDMETHODIMP NonDelegatingQueryInterface(REFIID riid, __deref_out void ** ppv); 30 | 31 | // Yield up our class id so that we can be persisted 32 | // Implement required Ipersist method 33 | STDMETHODIMP GetClassID(__out CLSID *pClsID); 34 | 35 | // IAMClockAdjust methods 36 | STDMETHODIMP SetClockDelta(REFERENCE_TIME rtDelta); 37 | }; //CSystemClock 38 | 39 | #endif /* __SYSTEMCLOCK__ */ 40 | -------------------------------------------------------------------------------- /src/basevideofilter/basevideofilter.vcxproj.filters: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | {4011d485-ff5c-4c01-b166-8a14a85504f3} 6 | cpp;c;cxx;def;odl;idl;hpj;bat;asm 7 | 8 | 9 | {e6d2ff5a-9c21-49be-a36f-45b466ddcc80} 10 | h;hpp;hxx;hm;inl;inc 11 | 12 | 13 | 14 | 15 | Source Files 16 | 17 | 18 | Source Files 19 | 20 | 21 | 22 | 23 | Header Files 24 | 25 | 26 | Header Files 27 | 28 | 29 | -------------------------------------------------------------------------------- /src/basevideofilter/stdafx.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2003-2006 Gabest 3 | * http://www.gabest.org 4 | * 5 | * This Program is free software; you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation; either version 2, or (at your option) 8 | * any later version. 9 | * 10 | * This Program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License 16 | * along with GNU Make; see the file COPYING. If not, write to 17 | * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. 18 | * http://www.gnu.org/copyleft/gpl.html 19 | * 20 | */ 21 | 22 | // stdafx.cpp : source file that includes just the standard includes 23 | // mpeg2decds.pch will be the pre-compiled header 24 | // stdafx.obj will contain the pre-compiled type information 25 | 26 | #include "stdafx.h" 27 | 28 | // TODO: reference any additional headers you need in STDAFX.H 29 | // and not in this file 30 | -------------------------------------------------------------------------------- /src/basevideofilter/stdafx.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2003-2006 Gabest 3 | * http://www.gabest.org 4 | * 5 | * This Program is free software; you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation; either version 2, or (at your option) 8 | * any later version. 9 | * 10 | * This Program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License 16 | * along with GNU Make; see the file COPYING. If not, write to 17 | * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. 18 | * http://www.gnu.org/copyleft/gpl.html 19 | * 20 | */ 21 | 22 | // stdafx.h : include file for standard system include files, 23 | // or project specific include files that are used frequently, but 24 | // are changed infrequently 25 | // 26 | 27 | #pragma once 28 | #include "..\DSUtil\SharedInclude.h" 29 | 30 | #ifndef _WIN32_WINNT 31 | #define _WIN32_WINNT 0x0600 32 | #endif 33 | 34 | #define WIN32_LEAN_AND_MEAN // Exclude rarely-used stuff from Windows headers 35 | #define _ATL_CSTRING_EXPLICIT_CONSTRUCTORS // some CString constructors will be explicit 36 | 37 | #ifndef VC_EXTRALEAN 38 | #define VC_EXTRALEAN // Exclude rarely-used stuff from Windows headers 39 | #endif 40 | 41 | #include 42 | #include // MFC core and standard components 43 | 44 | // TODO: reference additional headers your program requires here 45 | 46 | #include 47 | #include 48 | #include 49 | 50 | -------------------------------------------------------------------------------- /src/common.props: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | WINVER=0x0600;%(PreprocessorDefinitions) 6 | 7 | 8 | -------------------------------------------------------------------------------- /src/dsutil/DSUtil.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sorayuki/VSFilterMod/643b3def0970eb9dedaa5e6d9be6c3c492ce970d/src/dsutil/DSUtil.cpp -------------------------------------------------------------------------------- /src/dsutil/FontInstaller.cpp: -------------------------------------------------------------------------------- 1 | #include "StdAfx.h" 2 | #include ".\fontinstaller.h" 3 | 4 | CFontInstaller::CFontInstaller() 5 | { 6 | if(HMODULE hGdi = GetModuleHandle(_T("gdi32.dll"))) 7 | { 8 | pAddFontMemResourceEx = (HANDLE(WINAPI *)(PVOID, DWORD, PVOID, DWORD*))GetProcAddress(hGdi, "AddFontMemResourceEx"); 9 | pAddFontResourceEx = (int (WINAPI *)(LPCTSTR, DWORD, PVOID))GetProcAddress(hGdi, "AddFontResourceExA"); 10 | pRemoveFontMemResourceEx = (BOOL (WINAPI *)(HANDLE))GetProcAddress(hGdi, "RemoveFontMemResourceEx"); 11 | pRemoveFontResourceEx = (BOOL (WINAPI *)(LPCTSTR, DWORD, PVOID))GetProcAddress(hGdi, "RemoveFontResourceExA"); 12 | } 13 | 14 | if(HMODULE hGdi = GetModuleHandle(_T("kernel32.dll"))) 15 | { 16 | pMoveFileEx = (BOOL (WINAPI *)(LPCTSTR, LPCTSTR, DWORD))GetProcAddress(hGdi, "MoveFileExA"); 17 | } 18 | } 19 | 20 | CFontInstaller::~CFontInstaller() 21 | { 22 | UninstallFonts(); 23 | } 24 | 25 | bool CFontInstaller::InstallFont(const CAtlArray& data) 26 | { 27 | return InstallFont(data.GetData(), data.GetCount()); 28 | } 29 | 30 | bool CFontInstaller::InstallFont(const void* pData, UINT len) 31 | { 32 | return InstallFontFile(pData, len) || InstallFontMemory(pData, len); 33 | } 34 | 35 | void CFontInstaller::UninstallFonts() 36 | { 37 | if(pRemoveFontMemResourceEx) 38 | { 39 | POSITION pos = m_fonts.GetHeadPosition(); 40 | while(pos) pRemoveFontMemResourceEx(m_fonts.GetNext(pos)); 41 | m_fonts.RemoveAll(); 42 | } 43 | 44 | if(pRemoveFontResourceEx) 45 | { 46 | POSITION pos = m_files.GetHeadPosition(); 47 | while(pos) 48 | { 49 | CString fn = m_files.GetNext(pos); 50 | pRemoveFontResourceEx(fn, FR_PRIVATE, 0); 51 | if(!DeleteFile(fn) && pMoveFileEx) 52 | pMoveFileEx(fn, NULL, MOVEFILE_DELAY_UNTIL_REBOOT); 53 | } 54 | 55 | m_files.RemoveAll(); 56 | } 57 | } 58 | 59 | bool CFontInstaller::InstallFontMemory(const void* pData, UINT len) 60 | { 61 | if(!pAddFontMemResourceEx) 62 | return false; 63 | 64 | DWORD nFonts = 0; 65 | HANDLE hFont = pAddFontMemResourceEx((PVOID)pData, len, NULL, &nFonts); 66 | if(hFont && nFonts > 0) m_fonts.AddTail(hFont); 67 | return hFont && nFonts > 0; 68 | } 69 | 70 | bool CFontInstaller::InstallFontFile(const void* pData, UINT len) 71 | { 72 | if(!pAddFontResourceEx) 73 | return false; 74 | 75 | CFile f; 76 | TCHAR path[MAX_PATH], fn[MAX_PATH]; 77 | if(!GetTempPath(MAX_PATH, path) || !GetTempFileName(path, _T("g_font"), 0, fn)) 78 | return false; 79 | 80 | if(f.Open(fn, CFile::modeWrite)) 81 | { 82 | f.Write(pData, len); 83 | f.Close(); 84 | 85 | if(pAddFontResourceEx(fn, FR_PRIVATE, 0) > 0) 86 | { 87 | m_files.AddTail(fn); 88 | return true; 89 | } 90 | } 91 | 92 | DeleteFile(fn); 93 | return false; 94 | } 95 | -------------------------------------------------------------------------------- /src/dsutil/FontInstaller.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | class CFontInstaller 6 | { 7 | HANDLE(WINAPI *pAddFontMemResourceEx)(PVOID, DWORD, PVOID, DWORD*); 8 | BOOL (WINAPI *pRemoveFontMemResourceEx)(HANDLE); 9 | int (WINAPI *pAddFontResourceEx)(LPCTSTR, DWORD, PVOID); 10 | BOOL (WINAPI *pRemoveFontResourceEx)(LPCTSTR, DWORD, PVOID); 11 | BOOL (WINAPI *pMoveFileEx)(LPCTSTR, LPCTSTR, DWORD); 12 | 13 | CAtlList m_fonts; 14 | CAtlList m_files; 15 | bool InstallFontMemory(const void* pData, UINT len); 16 | bool InstallFontFile(const void* pData, UINT len); 17 | 18 | public: 19 | CFontInstaller(); 20 | virtual ~CFontInstaller(); 21 | 22 | bool InstallFont(const CAtlArray& data); 23 | bool InstallFont(const void* pData, UINT len); 24 | void UninstallFonts(); 25 | }; 26 | -------------------------------------------------------------------------------- /src/dsutil/GolombBuffer.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * $Id: GolombBuffer.cpp 1457 2010-01-01 03:13:59Z xhmikosr $ 3 | * 4 | * (C) 2006-2010 see AUTHORS 5 | * 6 | * This file is part of mplayerc. 7 | * 8 | * Mplayerc is free software; you can redistribute it and/or modify 9 | * it under the terms of the GNU General Public License as published by 10 | * the Free Software Foundation; either version 3 of the License, or 11 | * (at your option) any later version. 12 | * 13 | * Mplayerc is distributed in the hope that it will be useful, 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | * GNU General Public License for more details. 17 | * 18 | * You should have received a copy of the GNU General Public License 19 | * along with this program. If not, see . 20 | * 21 | */ 22 | 23 | 24 | #include "StdAfx.h" 25 | #include "GolombBuffer.h" 26 | 27 | CGolombBuffer::CGolombBuffer(BYTE* pBuffer, int nSize) 28 | { 29 | m_pBuffer = pBuffer; 30 | m_nSize = nSize; 31 | 32 | Reset(); 33 | } 34 | 35 | 36 | UINT64 CGolombBuffer::BitRead(int nBits, bool fPeek) 37 | { 38 | // ASSERT(nBits >= 0 && nBits <= 64); 39 | 40 | while(m_bitlen < nBits) 41 | { 42 | m_bitbuff <<= 8; 43 | 44 | if(m_nBitPos >= m_nSize) return 0; 45 | 46 | *(BYTE*)&m_bitbuff = m_pBuffer[m_nBitPos++]; 47 | m_bitlen += 8; 48 | } 49 | 50 | int bitlen = m_bitlen - nBits; 51 | 52 | UINT64 ret = (m_bitbuff >> bitlen) & ((1ui64 << nBits) - 1); 53 | 54 | if(!fPeek) 55 | { 56 | m_bitbuff &= ((1ui64 << bitlen) - 1); 57 | m_bitlen = bitlen; 58 | } 59 | 60 | return ret; 61 | } 62 | 63 | 64 | UINT64 CGolombBuffer::UExpGolombRead() 65 | { 66 | int n = -1; 67 | for(BYTE b = 0; !b; n++) b = (BYTE)BitRead(1); 68 | return (1ui64 << n) - 1 + BitRead(n); 69 | } 70 | 71 | INT64 CGolombBuffer::SExpGolombRead() 72 | { 73 | UINT64 k = UExpGolombRead(); 74 | return ((k & 1) ? 1 : -1) * ((k + 1) >> 1); 75 | } 76 | 77 | 78 | void CGolombBuffer::BitByteAlign() 79 | { 80 | m_bitlen &= ~7; 81 | } 82 | 83 | __int64 CGolombBuffer::GetPos() 84 | { 85 | return m_nBitPos - (m_bitlen >> 3); 86 | } 87 | 88 | 89 | void CGolombBuffer::ReadBuffer(BYTE* pDest, int nSize) 90 | { 91 | ASSERT(m_nBitPos + nSize <= m_nSize); 92 | ASSERT(m_bitlen == 0); 93 | nSize = min(nSize, m_nSize - m_nBitPos); 94 | 95 | memcpy(pDest, m_pBuffer + m_nBitPos, nSize); 96 | m_nBitPos += nSize; 97 | } 98 | 99 | void CGolombBuffer::Reset() 100 | { 101 | m_nBitPos = 0; 102 | m_bitlen = 0; 103 | m_bitbuff = 0; 104 | } 105 | 106 | void CGolombBuffer::Reset(BYTE* pNewBuffer, int nNewSize) 107 | { 108 | m_pBuffer = pNewBuffer; 109 | m_nSize = nNewSize; 110 | 111 | Reset(); 112 | } 113 | 114 | void CGolombBuffer::SkipBytes(int nCount) 115 | { 116 | m_nBitPos += nCount; 117 | m_bitlen = 0; 118 | m_bitbuff = 0; 119 | } 120 | -------------------------------------------------------------------------------- /src/dsutil/GolombBuffer.h: -------------------------------------------------------------------------------- 1 | /* 2 | * $Id: GolombBuffer.h 1457 2010-01-01 03:13:59Z xhmikosr $ 3 | * 4 | * (C) 2006-2010 see AUTHORS 5 | * 6 | * This file is part of mplayerc. 7 | * 8 | * Mplayerc is free software; you can redistribute it and/or modify 9 | * it under the terms of the GNU General Public License as published by 10 | * the Free Software Foundation; either version 3 of the License, or 11 | * (at your option) any later version. 12 | * 13 | * Mplayerc is distributed in the hope that it will be useful, 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | * GNU General Public License for more details. 17 | * 18 | * You should have received a copy of the GNU General Public License 19 | * along with this program. If not, see . 20 | * 21 | */ 22 | 23 | 24 | #pragma once 25 | 26 | 27 | class CGolombBuffer 28 | { 29 | public: 30 | CGolombBuffer(BYTE* pBuffer, int nSize); 31 | 32 | UINT64 BitRead(int nBits, bool fPeek = false); 33 | UINT64 UExpGolombRead(); 34 | INT64 SExpGolombRead(); 35 | void BitByteAlign(); 36 | 37 | inline BYTE ReadByte() 38 | { 39 | return (BYTE) BitRead(8); 40 | }; 41 | inline SHORT ReadShort() 42 | { 43 | return (SHORT)BitRead(16); 44 | }; 45 | inline DWORD ReadDword() 46 | { 47 | return (DWORD)BitRead(32); 48 | }; 49 | void ReadBuffer(BYTE* pDest, int nSize); 50 | 51 | void Reset(); 52 | void Reset(BYTE* pNewBuffer, int nNewSize); 53 | 54 | void SetSize(int nValue) 55 | { 56 | m_nSize = nValue; 57 | }; 58 | int GetSize() 59 | { 60 | return m_nSize; 61 | }; 62 | int RemainingSize() 63 | { 64 | return m_nSize - m_nBitPos; 65 | }; 66 | bool IsEOF() 67 | { 68 | return m_nBitPos >= m_nSize; 69 | }; 70 | INT64 GetPos(); 71 | BYTE* GetBufferPos() 72 | { 73 | return m_pBuffer + m_nBitPos; 74 | }; 75 | 76 | void SkipBytes(int nCount); 77 | 78 | private : 79 | BYTE* m_pBuffer; 80 | int m_nSize; 81 | int m_nBitPos; 82 | int m_bitlen; 83 | INT64 m_bitbuff; 84 | }; 85 | -------------------------------------------------------------------------------- /src/dsutil/H264Nalu.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * $Id: H264Nalu.cpp 1775 2010-04-02 19:28:08Z Spec-Chum $ 3 | * 4 | * (C) 2006-2010 see AUTHORS 5 | * 6 | * This file is part of mplayerc. 7 | * 8 | * Mplayerc is free software; you can redistribute it and/or modify 9 | * it under the terms of the GNU General Public License as published by 10 | * the Free Software Foundation; either version 3 of the License, or 11 | * (at your option) any later version. 12 | * 13 | * Mplayerc is distributed in the hope that it will be useful, 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | * GNU General Public License for more details. 17 | * 18 | * You should have received a copy of the GNU General Public License 19 | * along with this program. If not, see . 20 | * 21 | */ 22 | 23 | #include "stdafx.h" 24 | #include "H264Nalu.h" 25 | 26 | void CH264Nalu::SetBuffer(BYTE* pBuffer, int nSize, int nNALSize) 27 | { 28 | m_pBuffer = pBuffer; 29 | m_nSize = nSize; 30 | m_nNALSize = nNALSize; 31 | m_nCurPos = 0; 32 | m_nNextRTP = 0; 33 | 34 | m_nNALStartPos = 0; 35 | m_nNALDataPos = 0; 36 | } 37 | 38 | bool CH264Nalu::MoveToNextStartcode() 39 | { 40 | int nBuffEnd = (m_nNextRTP > 0) ? min(m_nNextRTP, m_nSize - 4) : m_nSize - 4; 41 | 42 | for(int i = m_nCurPos; i < nBuffEnd; i++) 43 | { 44 | if((*((DWORD*)(m_pBuffer + i)) & 0x00FFFFFF) == 0x00010000) 45 | { 46 | // Find next AnnexB Nal 47 | m_nCurPos = i; 48 | return true; 49 | } 50 | } 51 | 52 | if((m_nNALSize != 0) && (m_nNextRTP < m_nSize)) 53 | { 54 | m_nCurPos = m_nNextRTP; 55 | return true; 56 | } 57 | 58 | m_nCurPos = m_nSize; 59 | return false; 60 | } 61 | 62 | bool CH264Nalu::ReadNext() 63 | { 64 | 65 | if(m_nCurPos >= m_nSize) return false; 66 | 67 | if((m_nNALSize != 0) && (m_nCurPos == m_nNextRTP)) 68 | { 69 | // RTP Nalu type : (XX XX) XX XX NAL..., with XX XX XX XX or XX XX equal to NAL size 70 | m_nNALStartPos = m_nCurPos; 71 | m_nNALDataPos = m_nCurPos + m_nNALSize; 72 | int nTemp = 0; 73 | for(int i = 0; i < m_nNALSize; i++) 74 | { 75 | nTemp = (nTemp << 8) + m_pBuffer[m_nCurPos++]; 76 | } 77 | m_nNextRTP += nTemp + m_nNALSize; 78 | MoveToNextStartcode(); 79 | } 80 | else 81 | { 82 | // Remove trailing bits 83 | while(m_pBuffer[m_nCurPos] == 0x00 && ((*((DWORD*)(m_pBuffer + m_nCurPos)) & 0x00FFFFFF) != 0x00010000)) 84 | m_nCurPos++; 85 | 86 | // AnnexB Nalu : 00 00 01 NAL... 87 | m_nNALStartPos = m_nCurPos; 88 | m_nCurPos += 3; 89 | m_nNALDataPos = m_nCurPos; 90 | MoveToNextStartcode(); 91 | } 92 | 93 | forbidden_bit = (m_pBuffer[m_nNALDataPos] >> 7) & 1; 94 | nal_reference_idc = (m_pBuffer[m_nNALDataPos] >> 5) & 3; 95 | nal_unit_type = (NALU_TYPE)(m_pBuffer[m_nNALDataPos] & 0x1f); 96 | 97 | return true; 98 | } -------------------------------------------------------------------------------- /src/dsutil/H264Nalu.h: -------------------------------------------------------------------------------- 1 | /* 2 | * $Id: H264Nalu.h 1775 2010-04-02 19:28:08Z Spec-Chum $ 3 | * 4 | * (C) 2006-2010 see AUTHORS 5 | * 6 | * This file is part of mplayerc. 7 | * 8 | * Mplayerc is free software; you can redistribute it and/or modify 9 | * it under the terms of the GNU General Public License as published by 10 | * the Free Software Foundation; either version 3 of the License, or 11 | * (at your option) any later version. 12 | * 13 | * Mplayerc is distributed in the hope that it will be useful, 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | * GNU General Public License for more details. 17 | * 18 | * You should have received a copy of the GNU General Public License 19 | * along with this program. If not, see . 20 | * 21 | */ 22 | 23 | #pragma once 24 | 25 | 26 | typedef enum 27 | { 28 | NALU_TYPE_SLICE = 1, 29 | NALU_TYPE_DPA = 2, 30 | NALU_TYPE_DPB = 3, 31 | NALU_TYPE_DPC = 4, 32 | NALU_TYPE_IDR = 5, 33 | NALU_TYPE_SEI = 6, 34 | NALU_TYPE_SPS = 7, 35 | NALU_TYPE_PPS = 8, 36 | NALU_TYPE_AUD = 9, 37 | NALU_TYPE_EOSEQ = 10, 38 | NALU_TYPE_EOSTREAM = 11, 39 | NALU_TYPE_FILL = 12 40 | } NALU_TYPE; 41 | 42 | 43 | class CH264Nalu 44 | { 45 | private : 46 | int forbidden_bit; //! should be always FALSE 47 | int nal_reference_idc; //! NALU_PRIORITY_xxxx 48 | NALU_TYPE nal_unit_type; //! NALU_TYPE_xxxx 49 | 50 | int m_nNALStartPos; //! NALU start (including startcode / size) 51 | int m_nNALDataPos; //! Useful part 52 | unsigned m_nDataLen; //! Length of the NAL unit (Excluding the start code, which does not belong to the NALU) 53 | 54 | BYTE* m_pBuffer; 55 | int m_nCurPos; 56 | int m_nNextRTP; 57 | int m_nSize; 58 | int m_nNALSize; 59 | 60 | bool MoveToNextStartcode(); 61 | 62 | public : 63 | NALU_TYPE GetType() const 64 | { 65 | return nal_unit_type; 66 | }; 67 | bool IsRefFrame() const 68 | { 69 | return (nal_reference_idc != 0); 70 | }; 71 | 72 | int GetDataLength() const 73 | { 74 | return m_nCurPos - m_nNALDataPos; 75 | }; 76 | BYTE* GetDataBuffer() 77 | { 78 | return m_pBuffer + m_nNALDataPos; 79 | }; 80 | int GetRoundedDataLength() const 81 | { 82 | int nSize = m_nCurPos - m_nNALDataPos; 83 | return nSize + 128 - (nSize % 128); 84 | } 85 | 86 | int GetLength() const 87 | { 88 | return m_nCurPos - m_nNALStartPos; 89 | }; 90 | BYTE* GetNALBuffer() 91 | { 92 | return m_pBuffer + m_nNALStartPos; 93 | }; 94 | bool IsEOF() const 95 | { 96 | return m_nCurPos >= m_nSize; 97 | }; 98 | 99 | void SetBuffer(BYTE* pBuffer, int nSize, int nNALSize); 100 | bool ReadNext(); 101 | }; 102 | -------------------------------------------------------------------------------- /src/dsutil/MediaTypeEx.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | class CMediaTypeEx : public CMediaType 4 | { 5 | public: 6 | CMediaTypeEx(); 7 | CMediaTypeEx(const CMediaType& mt) 8 | { 9 | CMediaType::operator = (mt); 10 | } 11 | 12 | CString ToString(IPin* pPin = NULL); 13 | 14 | static CString GetVideoCodecName(const GUID& subtype, DWORD biCompression); 15 | static CString GetAudioCodecName(const GUID& subtype, WORD wFormatTag); 16 | static CString GetSubtitleCodecName(const GUID& subtype); 17 | 18 | void Dump(CAtlList& sl); 19 | }; 20 | -------------------------------------------------------------------------------- /src/dsutil/MediaTypes.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2003-2006 Gabest 3 | * http://www.gabest.org 4 | * 5 | * This Program is free software; you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation; either version 2, or (at your option) 8 | * any later version. 9 | * 10 | * This Program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License 16 | * along with GNU Make; see the file COPYING. If not, write to 17 | * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. 18 | * http://www.gnu.org/copyleft/gpl.html 19 | * 20 | */ 21 | 22 | #pragma once 23 | 24 | #pragma pack(1) 25 | struct VIH 26 | { 27 | VIDEOINFOHEADER vih; 28 | UINT mask[3]; 29 | int size; 30 | const GUID* subtype; 31 | }; 32 | struct VIH2 33 | { 34 | VIDEOINFOHEADER2 vih; 35 | UINT mask[3]; 36 | int size; 37 | const GUID* subtype; 38 | }; 39 | #pragma pack() 40 | 41 | extern VIH vihs[]; 42 | extern VIH2 vih2s[]; 43 | 44 | extern int VIHSIZE; 45 | 46 | extern CString VIH2String(int i), Subtype2String(const GUID& subtype); 47 | extern void CorrectMediaType(AM_MEDIA_TYPE* pmt); 48 | -------------------------------------------------------------------------------- /src/dsutil/NullRenderers.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2003-2006 Gabest 3 | * http://www.gabest.org 4 | * 5 | * This Program is free software; you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation; either version 2, or (at your option) 8 | * any later version. 9 | * 10 | * This Program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License 16 | * along with GNU Make; see the file COPYING. If not, write to 17 | * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. 18 | * http://www.gnu.org/copyleft/gpl.html 19 | * 20 | */ 21 | 22 | #pragma once 23 | 24 | #include 25 | 26 | class CNullRenderer : public CBaseRenderer 27 | { 28 | protected: 29 | virtual HRESULT DoRenderSample(IMediaSample* pSample) 30 | { 31 | return S_OK; 32 | } 33 | 34 | public: 35 | CNullRenderer(REFCLSID clsid, TCHAR* pName, LPUNKNOWN pUnk, HRESULT* phr); 36 | }; 37 | 38 | [uuid("579883A0-4E2D-481F-9436-467AAFAB7DE8")] 39 | class CNullVideoRenderer : public CNullRenderer 40 | { 41 | protected: 42 | HRESULT CheckMediaType(const CMediaType* pmt); 43 | 44 | public: 45 | CNullVideoRenderer(LPUNKNOWN pUnk, HRESULT* phr); 46 | }; 47 | 48 | [uuid("DD9ED57D-6ABF-42E8-89A2-11D04798DC58")] 49 | class CNullUVideoRenderer : public CNullRenderer 50 | { 51 | protected: 52 | HRESULT CheckMediaType(const CMediaType* pmt); 53 | 54 | public: 55 | CNullUVideoRenderer(LPUNKNOWN pUnk, HRESULT* phr); 56 | virtual HRESULT DoRenderSample(IMediaSample* pSample); 57 | }; 58 | 59 | [uuid("0C38BDFD-8C17-4E00-A344-F89397D3E22A")] 60 | class CNullAudioRenderer : public CNullRenderer 61 | { 62 | protected: 63 | HRESULT CheckMediaType(const CMediaType* pmt); 64 | 65 | public: 66 | CNullAudioRenderer(LPUNKNOWN pUnk, HRESULT* phr); 67 | }; 68 | 69 | [uuid("64A45125-7343-4772-9DA4-179FAC9D462C")] 70 | class CNullUAudioRenderer : public CNullRenderer 71 | { 72 | protected: 73 | HRESULT CheckMediaType(const CMediaType* pmt); 74 | 75 | public: 76 | CNullUAudioRenderer(LPUNKNOWN pUnk, HRESULT* phr); 77 | }; 78 | 79 | [uuid("655D7613-C26C-4A25-BBBD-3C9C516122CC")] 80 | class CNullTextRenderer : public CBaseFilter, public CCritSec 81 | { 82 | class CTextInputPin : public CBaseInputPin 83 | { 84 | public: 85 | CTextInputPin(CBaseFilter* pFilter, CCritSec* pLock, HRESULT* phr) 86 | : CBaseInputPin(NAME("CTextInputPin"), pFilter, pLock, phr, L"In") {} 87 | HRESULT CheckMediaType(const CMediaType* pmt); 88 | }; 89 | 90 | CAutoPtr m_pInput; 91 | 92 | public: 93 | CNullTextRenderer(LPUNKNOWN pUnk, HRESULT* phr); 94 | int GetPinCount() 95 | { 96 | return (int)!!m_pInput; 97 | } 98 | CBasePin* GetPin(int n) 99 | { 100 | return n == 0 ? (CBasePin*)m_pInput : NULL; 101 | } 102 | }; 103 | 104 | -------------------------------------------------------------------------------- /src/dsutil/SharedInclude.h: -------------------------------------------------------------------------------- 1 | #ifndef IncDSUtil_SharedInclude_h 2 | #define IncDSUtil_SharedInclude_h 3 | 4 | #pragma warning(disable:4018) 5 | #pragma warning(disable:4800) 6 | #pragma warning(disable:4355) 7 | #pragma warning(disable:4244) 8 | #pragma warning(disable:4995) 9 | #pragma warning(disable:4996) 10 | #pragma warning(disable:4305) 11 | #pragma warning(disable:4200) 12 | #pragma warning(disable:4101) 13 | #pragma warning(disable:4101) 14 | #pragma warning(disable:4267) 15 | 16 | #ifdef _DEBUG 17 | #define _CRTDBG_MAP_ALLOC // include Microsoft memory leak detection procedures 18 | 19 | #if 0 20 | #include 21 | #define DNew new(_NORMAL_BLOCK, __FILE__, __LINE__) 22 | #else 23 | #define DNew new(__FILE__, __LINE__) 24 | #endif 25 | 26 | #else 27 | 28 | #define DNew new 29 | 30 | #endif 31 | #endif // IncDSUtil_SharedInclude_h 32 | 33 | 34 | -------------------------------------------------------------------------------- /src/dsutil/simd_common.h: -------------------------------------------------------------------------------- 1 | #ifndef _SIMD_COMMON_H_ 2 | #define _SIMD_COMMON_H_ 3 | 4 | #if !defined(__GNUC__) 5 | #define __SSE2__ 6 | #endif 7 | 8 | #ifdef __GNUC__ 9 | #ifndef __forceinline 10 | #define __forceinline __attribute__((__always_inline__)) inline 11 | #endif 12 | #endif 13 | 14 | #ifdef __GNUC__ 15 | #define __inline __forceinline // GCC needs to force inlining of intrinsics functions 16 | #endif 17 | 18 | #include 19 | #include 20 | #ifdef __SSE2__ 21 | #include 22 | #endif 23 | 24 | #ifdef __GNUC__ 25 | #undef __inline 26 | #endif 27 | 28 | #ifdef __GNUC__ 29 | #define __align8(t,v) t v __attribute__ ((aligned (8))) 30 | #define __align16(t,v) t v __attribute__ ((aligned (16))) 31 | #else 32 | #define __align8(t,v) __declspec(align(8)) t v 33 | #define __align16(t,v) __declspec(align(16)) t v 34 | #endif 35 | 36 | #endif 37 | -------------------------------------------------------------------------------- /src/dsutil/simd_instructions.h: -------------------------------------------------------------------------------- 1 | MMX_INSTRUCTION(paddb,_mm_add_pi8) 2 | MMX_INSTRUCTION(paddsb,_mm_adds_pi8) 3 | MMX_INSTRUCTION(paddusb,_mm_adds_pu8) 4 | MMX_INSTRUCTION(paddw,_mm_add_pi16) 5 | MMX_INSTRUCTION(paddsw,_mm_adds_pi16) 6 | MMX_INSTRUCTION(paddusw,_mm_adds_pu16) 7 | MMX_INSTRUCTION(paddd,_mm_add_pi32) 8 | 9 | MMX_INSTRUCTION(pmaddwd,_mm_madd_pi16) 10 | 11 | MMX_INSTRUCTION(psubb,_mm_sub_pi8) 12 | MMX_INSTRUCTION(psubsb,_mm_subs_pi8) 13 | MMX_INSTRUCTION(psubusb,_mm_subs_pu8) 14 | MMX_INSTRUCTION(psubw,_mm_sub_pi16) 15 | MMX_INSTRUCTION(psubsw,_mm_subs_pi16) 16 | MMX_INSTRUCTION(psubusw,_mm_subs_pu16) 17 | MMX_INSTRUCTION(psubd,_mm_sub_pi32) 18 | 19 | MMX_INSTRUCTION(pmullw,_mm_mullo_pi16) 20 | MMX_INSTRUCTION(pmulhw,_mm_mulhi_pi16) 21 | 22 | MMX_INSTRUCTION(pand,_mm_and_si64) 23 | MMX_INSTRUCTION(pandn,_mm_andnot_si64) 24 | MMX_INSTRUCTION(por,_mm_or_si64) 25 | MMX_INSTRUCTION(pxor,_mm_xor_si64) 26 | 27 | MMX_INSTRUCTION(pcmpeqb,_mm_cmpeq_pi8) 28 | MMX_INSTRUCTION(pcmpeqw,_mm_cmpeq_pi16) 29 | MMX_INSTRUCTION(pcmpeqd,_mm_cmpeq_pi32) 30 | MMX_INSTRUCTION(pcmpgtb,_mm_cmpgt_pi8) 31 | MMX_INSTRUCTION(pcmpgtw,_mm_cmpgt_pi16) 32 | MMX_INSTRUCTION(pcmpgtd,_mm_cmpgt_pi32) 33 | 34 | MMX_INSTRUCTION(packuswb,_mm_packs_pu16) 35 | MMX_INSTRUCTION(packsswb,_mm_packs_pi16) 36 | MMX_INSTRUCTION(packssdw,_mm_packs_pi32) 37 | 38 | MMX_INSTRUCTION(punpcklbw,_mm_unpacklo_pi8) 39 | MMX_INSTRUCTION(punpckhbw,_mm_unpackhi_pi8) 40 | 41 | MMX_INSTRUCTION(punpcklwd,_mm_unpacklo_pi16) 42 | MMX_INSTRUCTION(punpckhwd,_mm_unpackhi_pi16) 43 | MMX_INSTRUCTION(punpckldq,_mm_unpacklo_pi32) 44 | MMX_INSTRUCTION(punpckhdq,_mm_unpackhi_pi32) 45 | 46 | MMX_INSTRUCTION(pminub,_mm_min_pu8) 47 | MMX_INSTRUCTION(pminsw,_mm_min_pi16) 48 | MMX_INSTRUCTION(pmaxub,_mm_max_pu8) 49 | MMX_INSTRUCTION(pmaxsw,_mm_max_pi16) 50 | 51 | MMX_INSTRUCTION(pavgb,_mm_avg_pu8) 52 | 53 | MMX_INSTRUCTION(psadbw,_mm_sad_pu8) 54 | 55 | #ifdef __SSE2__ 56 | 57 | SSE2I_INSTRUCTION(pand,_mm_and_si128) 58 | SSE2I_INSTRUCTION(por,_mm_or_si128) 59 | SSE2I_INSTRUCTION(pxor,_mm_xor_si128) 60 | SSE2I_INSTRUCTION(packuswb,_mm_packus_epi16) 61 | SSE2I_INSTRUCTION(packsswb,_mm_packs_epi16) 62 | SSE2I_INSTRUCTION(packssdw,_mm_packs_epi32) 63 | SSE2I_INSTRUCTION(punpcklbw,_mm_unpacklo_epi8) 64 | SSE2I_INSTRUCTION(punpckhbw,_mm_unpackhi_epi8) 65 | SSE2I_INSTRUCTION(punpcklwd,_mm_unpacklo_epi16) 66 | SSE2I_INSTRUCTION(punpckhwd,_mm_unpackhi_epi16) 67 | SSE2I_INSTRUCTION(punpckldq,_mm_unpacklo_epi32) 68 | SSE2I_INSTRUCTION(pmullw,_mm_mullo_epi16) 69 | SSE2I_INSTRUCTION(pmulhw,_mm_mulhi_epi16) 70 | SSE2I_INSTRUCTION(paddsb,_mm_adds_epi8) 71 | SSE2I_INSTRUCTION(paddb,_mm_add_epi8) 72 | SSE2I_INSTRUCTION(paddw,_mm_add_epi16) 73 | SSE2I_INSTRUCTION(paddsw,_mm_adds_epi16) 74 | SSE2I_INSTRUCTION(paddusw,_mm_adds_epu16) 75 | SSE2I_INSTRUCTION(paddd,_mm_add_epi32) 76 | SSE2I_INSTRUCTION(psubw,_mm_sub_epi16) 77 | SSE2I_INSTRUCTION(psubsw,_mm_subs_epi16) 78 | SSE2I_INSTRUCTION(psubusb,_mm_subs_epu8) 79 | SSE2I_INSTRUCTION(psubd,_mm_sub_epi32) 80 | SSE2I_INSTRUCTION(pmaddwd,_mm_madd_epi16) 81 | SSE2I_INSTRUCTION(pavgb,_mm_avg_epu8) 82 | SSE2I_INSTRUCTION(pcmpeqb,_mm_cmpeq_epi8) 83 | SSE2I_INSTRUCTION(pcmpeqw,_mm_cmpeq_epi16) 84 | SSE2I_INSTRUCTION(pcmpgtb,_mm_cmpgt_epi8) 85 | SSE2I_INSTRUCTION(pcmpgtw,_mm_cmpgt_epi16) 86 | 87 | #endif -------------------------------------------------------------------------------- /src/dsutil/stdafx.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2003-2006 Gabest 3 | * http://www.gabest.org 4 | * 5 | * This Program is free software; you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation; either version 2, or (at your option) 8 | * any later version. 9 | * 10 | * This Program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License 16 | * along with GNU Make; see the file COPYING. If not, write to 17 | * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. 18 | * http://www.gnu.org/copyleft/gpl.html 19 | * 20 | */ 21 | 22 | // stdafx.cpp : source file that includes just the standard includes 23 | // dsutil.pch will be the pre-compiled header 24 | // stdafx.obj will contain the pre-compiled type information 25 | 26 | #include "stdafx.h" 27 | 28 | // TODO: reference any additional headers you need in STDAFX.H 29 | // and not in this file 30 | -------------------------------------------------------------------------------- /src/dsutil/stdafx.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2003-2006 Gabest 3 | * http://www.gabest.org 4 | * 5 | * This Program is free software; you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation; either version 2, or (at your option) 8 | * any later version. 9 | * 10 | * This Program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License 16 | * along with GNU Make; see the file COPYING. If not, write to 17 | * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. 18 | * http://www.gnu.org/copyleft/gpl.html 19 | * 20 | */ 21 | 22 | // stdafx.h : include file for standard system include files, 23 | // or project specific include files that are used frequently, but 24 | // are changed infrequently 25 | // 26 | 27 | #pragma once 28 | #include "SharedInclude.h" 29 | 30 | #define WIN32_LEAN_AND_MEAN // Exclude rarely-used stuff from Windows headers 31 | #define _ATL_CSTRING_EXPLICIT_CONSTRUCTORS // some CString constructors will be explicit 32 | #define WINVER 0x0600 33 | 34 | #ifndef VC_EXTRALEAN 35 | #define VC_EXTRALEAN // Exclude rarely-used stuff from Windows headers 36 | #endif 37 | 38 | #include 39 | #include // MFC core and standard components 40 | 41 | // TODO: reference additional headers your program requires here 42 | 43 | #include 44 | 45 | #include 46 | #include 47 | 48 | #include 49 | #include 50 | 51 | -------------------------------------------------------------------------------- /src/dsutil/text.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | // extern CString ExplodeMin(CString str, CAtlList& sl, TCHAR sep, int limit = 0); 6 | // extern CString Explode(CString str, CAtlList& sl, TCHAR sep, int limit = 0); 7 | // extern CString Implode(CAtlList& sl, TCHAR sep); 8 | 9 | template 10 | T Explode(T str, CAtlList& sl, SEP sep, size_t limit = 0) 11 | { 12 | sl.RemoveAll(); 13 | 14 | for(ptrdiff_t i = 0, j = 0; ; i = j + 1) 15 | { 16 | j = str.Find(sep, i); 17 | 18 | if(j < 0 || sl.GetCount() == limit - 1) 19 | { 20 | sl.AddTail(str.Mid(i).Trim()); 21 | break; 22 | } 23 | else 24 | { 25 | sl.AddTail(str.Mid(i, j - i).Trim()); 26 | } 27 | } 28 | 29 | return sl.GetHead(); 30 | } 31 | 32 | template 33 | T ExplodeMin(T str, CAtlList& sl, SEP sep, size_t limit = 0) 34 | { 35 | Explode(str, sl, sep, limit); 36 | POSITION pos = sl.GetHeadPosition(); 37 | while(pos) 38 | { 39 | POSITION tmp = pos; 40 | if(sl.GetNext(pos).IsEmpty()) 41 | sl.RemoveAt(tmp); 42 | } 43 | if(sl.IsEmpty()) sl.AddTail(T()); // eh 44 | 45 | return sl.GetHead(); 46 | } 47 | 48 | template 49 | T Implode(CAtlList& sl, SEP sep) 50 | { 51 | T ret; 52 | POSITION pos = sl.GetHeadPosition(); 53 | while(pos) 54 | { 55 | ret += sl.GetNext(pos); 56 | if(pos) ret += sep; 57 | } 58 | return(ret); 59 | } 60 | 61 | extern CString ExtractTag(CString tag, CMapStringToString& attribs, bool& fClosing); 62 | extern CStringA ConvertMBCS(CStringA str, DWORD SrcCharSet, DWORD DstCharSet); 63 | extern CStringA UrlEncode(CStringA str, bool fRaw = false); 64 | extern CStringA UrlDecode(CStringA str, bool fRaw = false); 65 | extern DWORD CharSetToCodePage(DWORD dwCharSet); 66 | extern CAtlList& MakeLower(CAtlList& sl); 67 | extern CAtlList& MakeUpper(CAtlList& sl); 68 | extern CAtlList& RemoveStrings(CAtlList& sl, int minlen, int maxlen); 69 | 70 | -------------------------------------------------------------------------------- /src/dsutil/vd.h: -------------------------------------------------------------------------------- 1 | // VirtualDub - Video processing and capture application 2 | // Copyright (C) 1998-2001 Avery Lee 3 | // 4 | // This program is free software; you can redistribute it and/or modify 5 | // it under the terms of the GNU General Public License as published by 6 | // the Free Software Foundation; either version 2 of the License, or 7 | // (at your option) any later version. 8 | // 9 | // This program is distributed in the hope that it will be useful, 10 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | // GNU General Public License for more details. 13 | // 14 | // You should have received a copy of the GNU General Public License 15 | // along with this program; if not, write to the Free Software 16 | // Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 17 | // 18 | // Notes: 19 | // - BitBltFromI420ToRGB is from VirtualDub 20 | // - BitBltFromYUY2ToRGB is from AviSynth 2.52 21 | // (- vd.cpp/h should be renamed to something more sensible already :) 22 | 23 | #pragma once 24 | 25 | class CCpuID 26 | { 27 | public: 28 | CCpuID(); 29 | enum flag_t {mmx = 1, ssemmx = 2, ssefpu = 4, sse2 = 8, _3dnow = 16, sse3 = 32} m_flags; 30 | }; 31 | extern CCpuID g_cpuid; 32 | 33 | extern bool BitBltFromI420ToI420(int w, int h, BYTE* dsty, BYTE* dstu, BYTE* dstv, int dstpitch, BYTE* srcy, BYTE* srcu, BYTE* srcv, int srcpitch); 34 | extern bool BitBltFromI420ToYUY2(int w, int h, BYTE* dst, int dstpitch, BYTE* srcy, BYTE* srcu, BYTE* srcv, int srcpitch, bool fInterlaced = false); 35 | extern bool BitBltFromI420ToRGB(int w, int h, BYTE* dst, int dstpitch, int dbpp, BYTE* srcy, BYTE* srcu, BYTE* srcv, int srcpitch /* TODO: , bool fInterlaced = false */); 36 | extern bool BitBltFromYUY2ToYUY2(int w, int h, BYTE* dst, int dstpitch, BYTE* src, int srcpitch); 37 | extern bool BitBltFromYUY2ToRGB(int w, int h, BYTE* dst, int dstpitch, int dbpp, BYTE* src, int srcpitch); 38 | extern bool BitBltFromRGBToRGB(int w, int h, BYTE* dst, int dstpitch, int dbpp, BYTE* src, int srcpitch, int sbpp); 39 | 40 | extern void DeinterlaceBlend(BYTE* dst, BYTE* src, DWORD rowbytes, DWORD h, DWORD dstpitch, DWORD srcpitch); 41 | extern void DeinterlaceBob(BYTE* dst, BYTE* src, DWORD rowbytes, DWORD h, DWORD dstpitch, DWORD srcpitch, bool topfield); 42 | 43 | extern void AvgLines8(BYTE* dst, DWORD h, DWORD pitch); 44 | extern void AvgLines555(BYTE* dst, DWORD h, DWORD pitch); 45 | extern void AvgLines565(BYTE* dst, DWORD h, DWORD pitch); -------------------------------------------------------------------------------- /src/dsutil/vd_asm.h: -------------------------------------------------------------------------------- 1 | // VirtualDub - Video processing and capture application 2 | // Copyright (C) 1998-2001 Avery Lee 3 | // 4 | // This program is free software; you can redistribute it and/or modify 5 | // it under the terms of the GNU General Public License as published by 6 | // the Free Software Foundation; either version 2 of the License, or 7 | // (at your option) any later version. 8 | // 9 | // This program is distributed in the hope that it will be useful, 10 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | // GNU General Public License for more details. 13 | // 14 | // You should have received a copy of the GNU General Public License 15 | // along with this program; if not, write to the Free Software 16 | // Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 17 | // 18 | // Notes: 19 | // - BitBltFromI420ToRGB is from VirtualDub 20 | // - BitBltFromYUY2ToRGB is from AviSynth 2.52 21 | // (- vd.cpp/h should be renamed to something more sensible already :) 22 | 23 | #pragma once 24 | 25 | #ifndef _WIN64 26 | void yuvtoyuy2row_MMX(BYTE* dst, BYTE* srcy, BYTE* srcu, BYTE* srcv, DWORD width); 27 | void yuvtoyuy2row_avg_MMX(BYTE* dst, BYTE* srcy, BYTE* srcu, BYTE* srcv, DWORD width, DWORD pitchuv); 28 | 29 | void yv12_yuy2_row_sse2(); 30 | void yv12_yuy2_row_sse2_linear(); 31 | void yv12_yuy2_row_sse2_linear_interlaced(); 32 | void yv12_yuy2_sse2(const BYTE *Y, const BYTE *U, const BYTE *V, int halfstride, unsigned halfwidth, unsigned height, BYTE *YUY2, int d_stride); 33 | void yv12_yuy2_sse2_interlaced(const BYTE *Y, const BYTE *U, const BYTE *V, int halfstride, unsigned halfwidth, unsigned height, BYTE *YUY2, int d_stride); 34 | 35 | void asm_blend_row_clipped_MMX(BYTE* dst, BYTE* src, DWORD w, DWORD srcpitch); 36 | void asm_blend_row_MMX(BYTE* dst, BYTE* src, DWORD w, DWORD srcpitch); 37 | void asm_blend_row_SSE2(BYTE* dst, BYTE* src, DWORD w, DWORD srcpitch); 38 | void asm_blend_row_clipped_SSE2(BYTE* dst, BYTE* src, DWORD w, DWORD srcpitch); 39 | #endif 40 | -------------------------------------------------------------------------------- /src/libpng/ANNOUNCE: -------------------------------------------------------------------------------- 1 | 2 | Libpng 1.4.2 - May 6, 2010 3 | 4 | This is a public release of libpng, intended for use in production codes. 5 | 6 | Files available for download: 7 | 8 | Source files with LF line endings (for Unix/Linux) and with a 9 | "configure" script 10 | 11 | libpng-1.4.2.tar.xz (LZMA-compressed, recommended) 12 | libpng-1.4.2.tar.gz 13 | libpng-1.4.2.tar.bz2 14 | 15 | Source files with CRLF line endings (for Windows), without the 16 | "configure" script 17 | 18 | lpng142.zip 19 | lpng142.7z 20 | 21 | Other information: 22 | 23 | libpng-1.4.2-README.txt 24 | libpng-1.4.2-LICENSE.txt 25 | 26 | Changes since the last public release (1.4.1): 27 | Restored the macro definition of png_check_sig(). 28 | Conditionally compile an "else" statement in png_decompress_chunk(). 29 | Documented the fact that png_set_dither() was disabled since libpng-1.4.0. 30 | Reenabled png_set_dither() but renamed it to png_set_quantize() to reflect 31 | more accurately what it actually does. At the same time, renamed 32 | the PNG_DITHER_[RED,GREEN_BLUE]_BITS macros to 33 | PNG_QUANTIZE_[RED,GREEN,BLUE]_BITS. 34 | Added some "(long)" typecasts to printf calls in png_handle_cHRM(). 35 | Relaxed the overly-restrictive permissions of some files. 36 | Added the "vstudio" project to replace "visualc6" and "visualc71" which 37 | will be removed from libpng-1.5.0. 38 | Demonstrate in example.c that lang_key should be initialized. 39 | Set PNG_NO_READ_BGR, PNG_NO_IO_STATE, and PNG_NO_TIME_RFC1123 in 40 | contrib/pngminim/decoder/pngusr.h to make a smaller decoder application. 41 | Include png_reset_zstream() in png.c only when PNG_READ_SUPPORTED is defined. 42 | Removed dummy_inflate.c and uncompr.c from contrib/pngminim/encoder 43 | Corrected PNG_UNKNOWN_CHUNKS_SUPPORTED to PNG_HANDLE_AS_UNKNOWN_SUPPORTED 44 | in gregbook/readpng2.c 45 | Corrected protection of png_get_user_transform_ptr. The API declaration in 46 | png.h is removed if both READ and WRITE USER_TRANSFORM are turned off 47 | but was left defined in pngtrans.c 48 | Moved declarations of umsg[] inside the proper #ifdef blocks in pngrutil.c 49 | 50 | Send comments/corrections/commendations to glennrp at users.sourceforge.net 51 | or to png-mng-implement at lists.sf.net (subscription required; visit 52 | https://lists.sourceforge.net/lists/listinfo/png-mng-implement). 53 | 54 | Glenn R-P 55 | -------------------------------------------------------------------------------- /src/libpng/libpng.vcxproj.filters: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | {4FC737F1-C7A5-4376-A066-2A32D752A2FF} 6 | cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx 7 | 8 | 9 | {93995380-89BD-4b04-88EB-625FBE52EBFB} 10 | h;hpp;hxx;hm;inl;inc;xsd 11 | 12 | 13 | 14 | 15 | Source Files 16 | 17 | 18 | Source Files 19 | 20 | 21 | Source Files 22 | 23 | 24 | Source Files 25 | 26 | 27 | Source Files 28 | 29 | 30 | Source Files 31 | 32 | 33 | Source Files 34 | 35 | 36 | Source Files 37 | 38 | 39 | Source Files 40 | 41 | 42 | Source Files 43 | 44 | 45 | Source Files 46 | 47 | 48 | Source Files 49 | 50 | 51 | Source Files 52 | 53 | 54 | Source Files 55 | 56 | 57 | Source Files 58 | 59 | 60 | Source Files 61 | 62 | 63 | 64 | 65 | Header Files 66 | 67 | 68 | Header Files 69 | 70 | 71 | Header Files 72 | 73 | 74 | -------------------------------------------------------------------------------- /src/subpic/DX7SubPic.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2003-2006 Gabest 3 | * http://www.gabest.org 4 | * 5 | * This Program is free software; you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation; either version 2, or (at your option) 8 | * any later version. 9 | * 10 | * This Program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License 16 | * along with GNU Make; see the file COPYING. If not, write to 17 | * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. 18 | * http://www.gnu.org/copyleft/gpl.html 19 | * 20 | */ 21 | 22 | #pragma once 23 | 24 | #include "ISubPic.h" 25 | #include 26 | 27 | // CDX7SubPic 28 | 29 | class CDX7SubPic : public ISubPicImpl 30 | { 31 | CComPtr m_pD3DDev; 32 | CComPtr m_pSurface; 33 | 34 | protected: 35 | STDMETHODIMP_(void*) GetObject(); // returns IDirectDrawSurface7* 36 | 37 | public: 38 | CDX7SubPic(IDirect3DDevice7* pD3DDev, IDirectDrawSurface7* pSurface); 39 | 40 | // ISubPic 41 | STDMETHODIMP GetDesc(SubPicDesc& spd); 42 | STDMETHODIMP CopyTo(ISubPic* pSubPic); 43 | STDMETHODIMP ClearDirtyRect(DWORD color); 44 | STDMETHODIMP Lock(SubPicDesc& spd); 45 | STDMETHODIMP Unlock(RECT* pDirtyRect); 46 | STDMETHODIMP AlphaBlt(RECT* pSrc, RECT* pDst, SubPicDesc* pTarget); 47 | }; 48 | 49 | // CDX7SubPicAllocator 50 | 51 | class CDX7SubPicAllocator : public ISubPicAllocatorImpl, public CCritSec 52 | { 53 | CComPtr m_pD3DDev; 54 | CSize m_maxsize; 55 | 56 | bool Alloc(bool fStatic, ISubPic** ppSubPic); 57 | 58 | public: 59 | CDX7SubPicAllocator(IDirect3DDevice7* pD3DDev, SIZE maxsize, bool fPow2Textures); 60 | 61 | // ISubPicAllocator 62 | STDMETHODIMP ChangeDevice(IUnknown* pDev); 63 | }; 64 | -------------------------------------------------------------------------------- /src/subpic/MemSubPic.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2003-2006 Gabest 3 | * http://www.gabest.org 4 | * 5 | * This Program is free software; you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation; either version 2, or (at your option) 8 | * any later version. 9 | * 10 | * This Program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License 16 | * along with GNU Make; see the file COPYING. If not, write to 17 | * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. 18 | * http://www.gnu.org/copyleft/gpl.html 19 | * 20 | */ 21 | 22 | #pragma once 23 | 24 | #include "ISubPic.h" 25 | 26 | enum {MSP_RGB32, MSP_RGB24, MSP_RGB16, MSP_RGB15, MSP_YUY2, MSP_YV12, MSP_IYUV, MSP_AYUV, MSP_RGBA}; 27 | enum YCbCrMatrix 28 | { 29 | YCbCrMatrix_BT601, 30 | YCbCrMatrix_BT709, 31 | YCbCrMatrix_BT2020, 32 | YCbCrMatrix_AUTO 33 | }; 34 | enum YCbCrRange 35 | { 36 | YCbCrRange_PC, 37 | YCbCrRange_TV, 38 | YCbCrRange_AUTO 39 | }; 40 | // CMemSubPic 41 | 42 | class CMemSubPic : public ISubPicImpl 43 | { 44 | #pragma warning(disable: 4799) 45 | SubPicDesc m_spd; 46 | int m_eYCbCrMatrix; 47 | int m_eYCbCrRange; 48 | 49 | protected: 50 | STDMETHODIMP_(void*) GetObject(); // returns SubPicDesc* 51 | 52 | public: 53 | CMemSubPic(SubPicDesc& spd, int inYCbCrMatrix, int inYCbCrRange); 54 | virtual ~CMemSubPic(); 55 | 56 | // ISubPic 57 | STDMETHODIMP GetDesc(SubPicDesc& spd); 58 | STDMETHODIMP CopyTo(ISubPic* pSubPic); 59 | STDMETHODIMP ClearDirtyRect(DWORD color); 60 | STDMETHODIMP Lock(SubPicDesc& spd); 61 | STDMETHODIMP Unlock(RECT* pDirtyRect); 62 | STDMETHODIMP AlphaBlt(RECT* pSrc, RECT* pDst, SubPicDesc* pTarget); 63 | }; 64 | 65 | // CMemSubPicAllocator 66 | 67 | class CMemSubPicAllocator : public ISubPicAllocatorImpl 68 | { 69 | int m_type; 70 | CSize m_maxsize; 71 | int m_eYCbCrMatrix; 72 | int m_eYCbCrRange; 73 | 74 | bool Alloc(bool fStatic, ISubPic** ppSubPic); 75 | 76 | public: 77 | CMemSubPicAllocator(int type, SIZE maxsize, int inYCbCrMatrix=YCbCrMatrix_BT601, int inYCbCrRange=YCbCrRange_TV); 78 | }; 79 | 80 | -------------------------------------------------------------------------------- /src/subpic/stdafx.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2003-2006 Gabest 3 | * http://www.gabest.org 4 | * 5 | * This Program is free software; you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation; either version 2, or (at your option) 8 | * any later version. 9 | * 10 | * This Program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License 16 | * along with GNU Make; see the file COPYING. If not, write to 17 | * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. 18 | * http://www.gnu.org/copyleft/gpl.html 19 | * 20 | */ 21 | 22 | // stdafx.cpp : source file that includes just the standard includes 23 | // subpic.pch will be the pre-compiled header 24 | // stdafx.obj will contain the pre-compiled type information 25 | 26 | #include "stdafx.h" 27 | 28 | // TODO: reference any additional headers you need in STDAFX.H 29 | // and not in this file 30 | -------------------------------------------------------------------------------- /src/subpic/stdafx.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2003-2006 Gabest 3 | * http://www.gabest.org 4 | * 5 | * This Program is free software; you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation; either version 2, or (at your option) 8 | * any later version. 9 | * 10 | * This Program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License 16 | * along with GNU Make; see the file COPYING. If not, write to 17 | * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. 18 | * http://www.gnu.org/copyleft/gpl.html 19 | * 20 | */ 21 | 22 | // stdafx.h : include file for standard system include files, 23 | // or project specific include files that are used frequently, but 24 | // are changed infrequently 25 | // 26 | 27 | #pragma once 28 | #include "..\DSUtil\SharedInclude.h" 29 | 30 | #define WIN32_LEAN_AND_MEAN // Exclude rarely-used stuff from Windows headers 31 | #define _ATL_CSTRING_EXPLICIT_CONSTRUCTORS // some CString constructors will be explicit 32 | #define WINVER 0x0600 33 | 34 | #ifndef VC_EXTRALEAN 35 | #define VC_EXTRALEAN // Exclude rarely-used stuff from Windows headers 36 | #endif 37 | 38 | #include 39 | #include // MFC core and standard components 40 | 41 | // TODO: reference additional headers your program requires here 42 | 43 | #include 44 | #include 45 | #include "..\DSUtil\DSUtil.h" 46 | -------------------------------------------------------------------------------- /src/subpic/subpic.vcxproj.filters: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | {29cec234-5359-489f-964a-a914a991917e} 6 | cpp;c;cxx;def;odl;idl;hpj;bat;asm 7 | 8 | 9 | {8d5c2ea8-38ce-4c88-bd96-8eb2bf1414de} 10 | h;hpp;hxx;hm;inl;inc 11 | 12 | 13 | 14 | 15 | Source Files 16 | 17 | 18 | Source Files 19 | 20 | 21 | Source Files 22 | 23 | 24 | Source Files 25 | 26 | 27 | Source Files 28 | 29 | 30 | Source Files 31 | 32 | 33 | 34 | 35 | Header Files 36 | 37 | 38 | Header Files 39 | 40 | 41 | Header Files 42 | 43 | 44 | Header Files 45 | 46 | 47 | Header Files 48 | 49 | 50 | Header Files 51 | 52 | 53 | -------------------------------------------------------------------------------- /src/subtitles/BaseSub.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * $Id: BaseSub.cpp 1457 2010-01-01 03:13:59Z xhmikosr $ 3 | * 4 | * (C) 2006-2010 see AUTHORS 5 | * 6 | * This file is part of mplayerc. 7 | * 8 | * Mplayerc is free software; you can redistribute it and/or modify 9 | * it under the terms of the GNU General Public License as published by 10 | * the Free Software Foundation; either version 3 of the License, or 11 | * (at your option) any later version. 12 | * 13 | * Mplayerc is distributed in the hope that it will be useful, 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | * GNU General Public License for more details. 17 | * 18 | * You should have received a copy of the GNU General Public License 19 | * along with this program. If not, see . 20 | * 21 | */ 22 | 23 | #include "stdafx.h" 24 | #include "BaseSub.h" 25 | 26 | CBaseSub::CBaseSub(SUBTITLE_TYPE nType) 27 | : m_nType(nType) 28 | { 29 | } 30 | 31 | CBaseSub::~CBaseSub() 32 | { 33 | } -------------------------------------------------------------------------------- /src/subtitles/BaseSub.h: -------------------------------------------------------------------------------- 1 | /* 2 | * $Id: BaseSub.h 1457 2010-01-01 03:13:59Z xhmikosr $ 3 | * 4 | * (C) 2006-2010 see AUTHORS 5 | * 6 | * This file is part of mplayerc. 7 | * 8 | * Mplayerc is free software; you can redistribute it and/or modify 9 | * it under the terms of the GNU General Public License as published by 10 | * the Free Software Foundation; either version 3 of the License, or 11 | * (at your option) any later version. 12 | * 13 | * Mplayerc is distributed in the hope that it will be useful, 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | * GNU General Public License for more details. 17 | * 18 | * You should have received a copy of the GNU General Public License 19 | * along with this program. If not, see . 20 | * 21 | */ 22 | 23 | 24 | #pragma once 25 | 26 | #include "CompositionObject.h" 27 | 28 | enum SUBTITLE_TYPE 29 | { 30 | ST_DVB, 31 | ST_HDMV 32 | }; 33 | 34 | class CBaseSub 35 | { 36 | public: 37 | 38 | static const REFERENCE_TIME INVALID_TIME = _I64_MIN; 39 | 40 | CBaseSub(SUBTITLE_TYPE nType); 41 | virtual ~CBaseSub(); 42 | 43 | virtual HRESULT ParseSample(IMediaSample* pSample) = NULL; 44 | virtual void Reset() = NULL; 45 | virtual POSITION GetStartPosition(REFERENCE_TIME rt, double fps) = NULL; 46 | virtual POSITION GetNext(POSITION pos) = NULL; 47 | virtual REFERENCE_TIME GetStart(POSITION nPos) = NULL; 48 | virtual REFERENCE_TIME GetStop(POSITION nPos) = NULL; 49 | virtual void Render(SubPicDesc& spd, REFERENCE_TIME rt, RECT& bbox) = NULL; 50 | virtual HRESULT GetTextureSize(POSITION pos, SIZE& MaxTextureSize, SIZE& VideoSize, POINT& VideoTopLeft) = NULL; 51 | 52 | protected : 53 | SUBTITLE_TYPE m_nType; 54 | }; 55 | -------------------------------------------------------------------------------- /src/subtitles/CCDecoder.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2003-2006 Gabest 3 | * http://www.gabest.org 4 | * 5 | * This Program is free software; you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation; either version 2, or (at your option) 8 | * any later version. 9 | * 10 | * This Program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License 16 | * along with GNU Make; see the file COPYING. If not, write to 17 | * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. 18 | * http://www.gnu.org/copyleft/gpl.html 19 | * 20 | */ 21 | 22 | #pragma once 23 | 24 | #include "STS.h" 25 | 26 | class CCDecoder 27 | { 28 | CSimpleTextSubtitle m_sts; 29 | CString m_fn, m_rawfn; 30 | __int64 m_time; 31 | bool m_fEndOfCaption; 32 | WCHAR m_buff[16][33], m_disp[16][33]; 33 | CPoint m_cursor; 34 | 35 | void SaveDisp(__int64 time); 36 | void MoveCursor(int x, int y); 37 | void OffsetCursor(int x, int y); 38 | void PutChar(WCHAR c); 39 | 40 | public: 41 | CCDecoder(CString fn = _T(""), CString rawfn = _T("")); 42 | virtual ~CCDecoder(); 43 | void DecodeCC(BYTE* buff, int len, __int64 time); 44 | void ExtractCC(BYTE* buff, int len, __int64 time); 45 | CSimpleTextSubtitle& GetSTS() 46 | { 47 | return m_sts; 48 | } 49 | }; 50 | 51 | 52 | -------------------------------------------------------------------------------- /src/subtitles/CompositionObject.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sorayuki/VSFilterMod/643b3def0970eb9dedaa5e6d9be6c3c492ce970d/src/subtitles/CompositionObject.cpp -------------------------------------------------------------------------------- /src/subtitles/CompositionObject.h: -------------------------------------------------------------------------------- 1 | /* 2 | * $Id: CompositionObject.h 1457 2010-01-01 03:13:59Z xhmikosr $ 3 | * 4 | * (C) 2006-2010 see AUTHORS 5 | * 6 | * This file is part of mplayerc. 7 | * 8 | * Mplayerc is free software; you can redistribute it and/or modify 9 | * it under the terms of the GNU General Public License as published by 10 | * the Free Software Foundation; either version 3 of the License, or 11 | * (at your option) any later version. 12 | * 13 | * Mplayerc is distributed in the hope that it will be useful, 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | * GNU General Public License for more details. 17 | * 18 | * You should have received a copy of the GNU General Public License 19 | * along with this program. If not, see . 20 | * 21 | */ 22 | 23 | 24 | #pragma once 25 | 26 | #include "Rasterizer.h" 27 | 28 | 29 | struct HDMV_PALETTE 30 | { 31 | BYTE entry_id; 32 | BYTE Y; 33 | BYTE Cr; 34 | BYTE Cb; 35 | BYTE T; // HDMV rule : 0 transparent, 255 opaque (compatible DirectX) 36 | }; 37 | 38 | class CGolombBuffer; 39 | 40 | class CompositionObject : Rasterizer 41 | { 42 | public : 43 | SHORT m_object_id_ref; 44 | BYTE m_window_id_ref; 45 | bool m_object_cropped_flag; 46 | bool m_forced_on_flag; 47 | BYTE m_version_number; 48 | 49 | SHORT m_horizontal_position; 50 | SHORT m_vertical_position; 51 | SHORT m_width; 52 | SHORT m_height; 53 | 54 | SHORT m_cropping_horizontal_position; 55 | SHORT m_cropping_vertical_position; 56 | SHORT m_cropping_width; 57 | SHORT m_cropping_height; 58 | 59 | REFERENCE_TIME m_rtStart; 60 | REFERENCE_TIME m_rtStop; 61 | 62 | CompositionObject(); 63 | ~CompositionObject(); 64 | 65 | void SetRLEData(BYTE* pBuffer, int nSize, int nTotalSize); 66 | void AppendRLEData(BYTE* pBuffer, int nSize); 67 | int GetRLEDataSize() 68 | { 69 | return m_nRLEDataSize; 70 | }; 71 | bool IsRLEComplete() 72 | { 73 | return m_nRLEPos >= m_nRLEDataSize; 74 | }; 75 | void RenderHdmv(SubPicDesc& spd); 76 | void RenderDvb(SubPicDesc& spd, SHORT nX, SHORT nY); 77 | void WriteSeg(SubPicDesc& spd, SHORT nX, SHORT nY, SHORT nCount, SHORT nPaletteIndex); 78 | void SetPalette(int nNbEntry, HDMV_PALETTE* pPalette, bool bIsHD); 79 | void SetPalette(int nNbEntry, DWORD* dwColors); 80 | bool HavePalette() 81 | { 82 | return m_nColorNumber > 0; 83 | }; 84 | 85 | private : 86 | BYTE* m_pRLEData; 87 | int m_nRLEDataSize; 88 | int m_nRLEPos; 89 | int m_nColorNumber; 90 | DWORD m_Colors[256]; 91 | 92 | void DvbRenderField(SubPicDesc& spd, CGolombBuffer& gb, SHORT nXStart, SHORT nYStart, SHORT nLength); 93 | void Dvb2PixelsCodeString(SubPicDesc& spd, CGolombBuffer& gb, SHORT& nX, SHORT& nY); 94 | void Dvb4PixelsCodeString(SubPicDesc& spd, CGolombBuffer& gb, SHORT& nX, SHORT& nY); 95 | void Dvb8PixelsCodeString(SubPicDesc& spd, CGolombBuffer& gb, SHORT& nX, SHORT& nY); 96 | }; 97 | -------------------------------------------------------------------------------- /src/subtitles/DVBSub.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sorayuki/VSFilterMod/643b3def0970eb9dedaa5e6d9be6c3c492ce970d/src/subtitles/DVBSub.h -------------------------------------------------------------------------------- /src/subtitles/GFN.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2003-2006 Gabest 3 | * http://www.gabest.org 4 | * 5 | * This Program is free software; you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation; either version 2, or (at your option) 8 | * any later version. 9 | * 10 | * This Program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License 16 | * along with GNU Make; see the file COPYING. If not, write to 17 | * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. 18 | * http://www.gnu.org/copyleft/gpl.html 19 | * 20 | */ 21 | 22 | #pragma once 23 | 24 | #include 25 | 26 | enum exttype {EXTSRT = 0, EXTSUB, EXTSMI, EXTPSB, EXTSSA, EXTASS, EXTIDX, EXTUSF, EXTXSS, EXTRT}; 27 | extern TCHAR* exttypestr[]; 28 | typedef struct 29 | { 30 | CString fn; /*exttype ext;*/ 31 | } SubFile; 32 | extern void GetSubFileNames(CString fn, CAtlArray& paths, CAtlArray& ret); 33 | -------------------------------------------------------------------------------- /src/subtitles/RealTextParser.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | using std::wostream; 5 | using std::wostringstream; 6 | using std::endl; 7 | 8 | #include 9 | using std::wstring; 10 | 11 | #include 12 | using std::map; 13 | using std::pair; 14 | 15 | #include 16 | using std::vector; 17 | 18 | #include 19 | using std::list; 20 | 21 | #include 22 | using std::towlower; 23 | 24 | class CRealTextParser 25 | { 26 | public: 27 | CRealTextParser(); 28 | virtual ~CRealTextParser(void); 29 | 30 | struct Tag 31 | { 32 | Tag(): m_bOpen(false), m_bClose(false), m_bComment(false), m_bText(false) {} 33 | 34 | wstring m_szName; 35 | 36 | bool m_bOpen; 37 | bool m_bClose; 38 | 39 | bool m_bComment; 40 | bool m_bText; 41 | 42 | map m_mapAttributes; 43 | }; 44 | 45 | struct Subtitles 46 | { 47 | Subtitles(): m_WindowTag(), m_FontTag(), m_bCenter(false) {} 48 | 49 | Tag m_WindowTag; 50 | Tag m_FontTag; 51 | 52 | bool m_bCenter; 53 | 54 | map, wstring> m_mapLines; 55 | }; 56 | 57 | bool ParseRealText(wstring p_szFile); 58 | 59 | const Subtitles& GetParsedSubtitles(); 60 | 61 | bool OutputSRT(wostream& p_rOutput); 62 | 63 | private: 64 | bool ExtractTag(wstring& p_rszLine, Tag& p_rTag); 65 | bool ExtractTextTag(wstring& p_rszLine, Tag& p_rTag); 66 | bool ExtractString(wstring& p_rszLine, wstring& p_rszString); 67 | bool SkipSpaces(wstring& p_rszLine, unsigned int& p_riPos); 68 | bool GetString(wstring& p_rszLine, unsigned int& p_riPos, wstring& p_rszString, const wstring& p_crszEndChars); 69 | bool GetAttributes(wstring& p_rszLine, unsigned int& p_riPos, map& p_rmapAttributes); 70 | 71 | int GetTimecode(const wstring& p_crszTimecode); 72 | wstring FormatTimecode(int iTimecode, 73 | int iMillisecondPrecision = 3, 74 | bool p_bPadZeroes = true, 75 | const wstring& p_crszSeparator = L":", 76 | const wstring& p_crszMillisecondSeparator = L"."); 77 | 78 | wstring StringToLower(const wstring& p_crszString); 79 | 80 | wstring RenderTags(const list& p_crlTags); 81 | 82 | void PopTag(list& p_rlistTags, const wstring& p_crszTagName); 83 | 84 | // Filter out for example multiple font tags opened previously (font tags are not always terminated properly in realtext and can build up) 85 | void FilterReduntantTags(list& p_rlistTags); 86 | 87 | 88 | Subtitles m_RealText; 89 | 90 | bool m_bIgnoreFont; 91 | bool m_bIgnoreFontSize; 92 | bool m_bIgnoreFontColor; 93 | bool m_bIgnoreFontWeight; 94 | bool m_bIgnoreFontFace; 95 | 96 | int m_iMinFontSize; 97 | int m_iMaxFontSize; 98 | 99 | int m_iDefaultSubtitleDurationInMillisecs; 100 | 101 | bool m_bTryToIgnoreErrors; 102 | }; 103 | -------------------------------------------------------------------------------- /src/subtitles/RenderedHdmvSubtitle.h: -------------------------------------------------------------------------------- 1 | /* 2 | * $Id: RenderedHdmvSubtitle.h 1457 2010-01-01 03:13:59Z xhmikosr $ 3 | * 4 | * (C) 2006-2010 see AUTHORS 5 | * 6 | * This file is part of mplayerc. 7 | * 8 | * Mplayerc is free software; you can redistribute it and/or modify 9 | * it under the terms of the GNU General Public License as published by 10 | * the Free Software Foundation; either version 3 of the License, or 11 | * (at your option) any later version. 12 | * 13 | * Mplayerc is distributed in the hope that it will be useful, 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | * GNU General Public License for more details. 17 | * 18 | * You should have received a copy of the GNU General Public License 19 | * along with this program. If not, see . 20 | * 21 | */ 22 | 23 | 24 | #pragma once 25 | 26 | #include "Rasterizer.h" 27 | #include "..\SubPic\ISubPic.h" 28 | #include "HdmvSub.h" 29 | #include "BaseSub.h" 30 | 31 | 32 | [uuid("FCA68599-C83E-4ea5-94A3-C2E1B0E326B9")] 33 | class CRenderedHdmvSubtitle : public ISubPicProviderImpl, public ISubStream 34 | { 35 | public: 36 | CRenderedHdmvSubtitle(CCritSec* pLock, SUBTITLE_TYPE nType); 37 | ~CRenderedHdmvSubtitle(void); 38 | 39 | DECLARE_IUNKNOWN 40 | STDMETHODIMP NonDelegatingQueryInterface(REFIID riid, void** ppv); 41 | 42 | // ISubPicProvider 43 | STDMETHODIMP_(POSITION) GetStartPosition(REFERENCE_TIME rt, double fps); 44 | STDMETHODIMP_(POSITION) GetNext(POSITION pos); 45 | STDMETHODIMP_(REFERENCE_TIME) GetStart(POSITION pos, double fps); 46 | STDMETHODIMP_(REFERENCE_TIME) GetStop(POSITION pos, double fps); 47 | STDMETHODIMP_(bool) IsAnimated(POSITION pos); 48 | STDMETHODIMP Render(SubPicDesc& spd, REFERENCE_TIME rt, double fps, RECT& bbox); 49 | STDMETHODIMP GetTextureSize(POSITION pos, SIZE& MaxTextureSize, SIZE& VirtualSize, POINT& VirtualTopLeft); 50 | 51 | // IPersist 52 | STDMETHODIMP GetClassID(CLSID* pClassID); 53 | 54 | // ISubStream 55 | STDMETHODIMP_(int) GetStreamCount(); 56 | STDMETHODIMP GetStreamInfo(int i, WCHAR** ppName, LCID* pLCID); 57 | STDMETHODIMP_(int) GetStream(); 58 | STDMETHODIMP SetStream(int iStream); 59 | STDMETHODIMP Reload(); 60 | 61 | HRESULT ParseSample(IMediaSample* pSample); 62 | HRESULT NewSegment(REFERENCE_TIME tStart, REFERENCE_TIME tStop, double dRate); 63 | 64 | private : 65 | CString m_name; 66 | LCID m_lcid; 67 | REFERENCE_TIME m_rtStart; 68 | 69 | CBaseSub* m_pSub; 70 | CCritSec m_csCritSec; 71 | }; 72 | -------------------------------------------------------------------------------- /src/subtitles/SSF.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2003-2006 Gabest 3 | * http://www.gabest.org 4 | * 5 | * This Program is free software; you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation; either version 2, or (at your option) 8 | * any later version. 9 | * 10 | * This Program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License 16 | * along with GNU Make; see the file COPYING. If not, write to 17 | * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. 18 | * http://www.gnu.org/copyleft/gpl.html 19 | * 20 | */ 21 | 22 | #pragma once 23 | 24 | #include "..\SubPic\ISubPic.h" 25 | #include ".\libssf\SubtitleFile.h" 26 | #include ".\libssf\Renderer.h" 27 | 28 | #pragma once 29 | 30 | namespace ssf 31 | { 32 | [uuid("E0593632-0AB7-47CA-8BE1-E9D2A6A4825E")] 33 | class CRenderer : public ISubPicProviderImpl, public ISubStream 34 | { 35 | CString m_fn, m_name; 36 | CAutoPtr m_file; 37 | CAutoPtr m_renderer; 38 | 39 | public: 40 | CRenderer(CCritSec* pLock); 41 | virtual ~CRenderer(); 42 | 43 | bool Open(CString fn, CString name = _T("")); 44 | bool Open(InputStream& s, CString name); 45 | 46 | void Append(REFERENCE_TIME rtStart, REFERENCE_TIME rtStop, LPCWSTR str); 47 | 48 | DECLARE_IUNKNOWN 49 | STDMETHODIMP NonDelegatingQueryInterface(REFIID riid, void** ppv); 50 | 51 | // ISubPicProvider 52 | STDMETHODIMP_(POSITION) GetStartPosition(REFERENCE_TIME rt, double fps); 53 | STDMETHODIMP_(POSITION) GetNext(POSITION pos); 54 | STDMETHODIMP_(REFERENCE_TIME) GetStart(POSITION pos, double fps); 55 | STDMETHODIMP_(REFERENCE_TIME) GetStop(POSITION pos, double fps); 56 | STDMETHODIMP_(bool) IsAnimated(POSITION pos); 57 | STDMETHODIMP Render(SubPicDesc& spd, REFERENCE_TIME rt, double fps, RECT& bbox); 58 | 59 | // IPersist 60 | STDMETHODIMP GetClassID(CLSID* pClassID); 61 | 62 | // ISubStream 63 | STDMETHODIMP_(int) GetStreamCount(); 64 | STDMETHODIMP GetStreamInfo(int i, WCHAR** ppName, LCID* pLCID); 65 | STDMETHODIMP_(int) GetStream(); 66 | STDMETHODIMP SetStream(int iStream); 67 | STDMETHODIMP Reload(); 68 | }; 69 | 70 | } -------------------------------------------------------------------------------- /src/subtitles/SubtitleInputPin.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2003-2006 Gabest 3 | * http://www.gabest.org 4 | * 5 | * This Program is free software; you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation; either version 2, or (at your option) 8 | * any later version. 9 | * 10 | * This Program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License 16 | * along with GNU Make; see the file COPYING. If not, write to 17 | * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. 18 | * http://www.gnu.org/copyleft/gpl.html 19 | * 20 | */ 21 | 22 | #pragma once 23 | 24 | #include "..\subpic\ISubPic.h" 25 | 26 | // 27 | // CSubtitleInputPin 28 | // 29 | 30 | class CSubtitleInputPin : public CBaseInputPin 31 | { 32 | CCritSec m_csReceive; 33 | 34 | CCritSec* m_pSubLock; 35 | CComPtr m_pSubStream; 36 | 37 | protected: 38 | virtual void AddSubStream(ISubStream* pSubStream) = 0; 39 | virtual void RemoveSubStream(ISubStream* pSubStream) = 0; 40 | virtual void InvalidateSubtitle(REFERENCE_TIME rtStart, ISubStream* pSubStream) = 0; 41 | 42 | public: 43 | CSubtitleInputPin(CBaseFilter* pFilter, CCritSec* pLock, CCritSec* pSubLock, HRESULT* phr); 44 | 45 | HRESULT CheckMediaType(const CMediaType* pmt); 46 | HRESULT CompleteConnect(IPin* pReceivePin); 47 | HRESULT BreakConnect(); 48 | STDMETHODIMP ReceiveConnection(IPin* pConnector, const AM_MEDIA_TYPE* pmt); 49 | STDMETHODIMP NewSegment(REFERENCE_TIME tStart, REFERENCE_TIME tStop, double dRate); 50 | STDMETHODIMP Receive(IMediaSample* pSample); 51 | 52 | ISubStream* GetSubStream() 53 | { 54 | return m_pSubStream; 55 | } 56 | }; 57 | -------------------------------------------------------------------------------- /src/subtitles/TextFile.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2003-2006 Gabest 3 | * http://www.gabest.org 4 | * 5 | * This Program is free software; you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation; either version 2, or (at your option) 8 | * any later version. 9 | * 10 | * This Program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License 16 | * along with GNU Make; see the file COPYING. If not, write to 17 | * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. 18 | * http://www.gnu.org/copyleft/gpl.html 19 | * 20 | */ 21 | 22 | #pragma once 23 | 24 | #include 25 | 26 | class CTextFile : protected CStdioFile 27 | { 28 | public: 29 | typedef enum {ASCII, UTF8, LE16, BE16, ANSI} enc; 30 | 31 | private: 32 | enc m_encoding, m_defaultencoding; 33 | int m_offset; 34 | 35 | public: 36 | CTextFile(enc e = ASCII); 37 | 38 | virtual bool Open(LPCTSTR lpszFileName); 39 | virtual bool Save(LPCTSTR lpszFileName, enc e /*= ASCII*/); 40 | 41 | void SetEncoding(enc e); 42 | enc GetEncoding(); 43 | bool IsUnicode(); 44 | 45 | // CFile 46 | 47 | CString GetFilePath() const; 48 | 49 | // CStdioFile 50 | 51 | ULONGLONG GetPosition() const; 52 | ULONGLONG GetLength() const; 53 | ULONGLONG Seek(LONGLONG lOff, UINT nFrom); 54 | 55 | void WriteString(LPCSTR lpsz/*CStringA str*/); 56 | void WriteString(LPCWSTR lpsz/*CStringW str*/); 57 | BOOL ReadString(CStringA& str); 58 | BOOL ReadString(CStringW& str); 59 | }; 60 | 61 | class CWebTextFile : public CTextFile 62 | { 63 | LONGLONG m_llMaxSize; 64 | CString m_tempfn; 65 | 66 | public: 67 | CWebTextFile(LONGLONG llMaxSize = 1024 * 1024); 68 | 69 | bool Open(LPCTSTR lpszFileName); 70 | bool Save(LPCTSTR lpszFileName, enc e /*= ASCII*/); 71 | void Close(); 72 | }; 73 | 74 | extern CStringW AToW(CStringA str); 75 | extern CStringA WToA(CStringW str); 76 | extern CString AToT(CStringA str); 77 | extern CString WToT(CStringW str); 78 | extern CStringA TToA(CString str); 79 | extern CStringW TToW(CString str); 80 | -------------------------------------------------------------------------------- /src/subtitles/USFSubtitles.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2003-2006 Gabest 3 | * http://www.gabest.org 4 | * 5 | * This Program is free software; you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation; either version 2, or (at your option) 8 | * any later version. 9 | * 10 | * This Program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License 16 | * along with GNU Make; see the file COPYING. If not, write to 17 | * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. 18 | * http://www.gnu.org/copyleft/gpl.html 19 | * 20 | */ 21 | 22 | #pragma once 23 | 24 | #include 25 | #include "STS.h" 26 | 27 | // metadata 28 | typedef struct 29 | { 30 | CStringW name, email, url; 31 | } author_t; 32 | typedef struct 33 | { 34 | CStringW code, text; 35 | } language_t; 36 | typedef struct 37 | { 38 | CStringW title, date, comment; 39 | author_t author; 40 | language_t language, languageext; 41 | } metadata_t; 42 | // style 43 | typedef struct 44 | { 45 | CStringW alignment, relativeto, horizontal_margin, vertical_margin, rotate[3]; 46 | } posattriblist_t; 47 | typedef struct 48 | { 49 | CStringW face, size, color[4], weight, italic, underline, alpha, outline, shadow, wrap; 50 | } fontstyle_t; 51 | typedef struct 52 | { 53 | CStringW name; 54 | fontstyle_t fontstyle; 55 | posattriblist_t pal; 56 | } style_t; 57 | // effect 58 | typedef struct 59 | { 60 | CStringW position; 61 | fontstyle_t fontstyle; 62 | posattriblist_t pal; 63 | } keyframe_t; 64 | typedef struct 65 | { 66 | CStringW name; 67 | CAutoPtrList keyframes; 68 | } effect_t; 69 | // subtitle/text 70 | typedef struct 71 | { 72 | int start, stop; 73 | CStringW effect, style, str; 74 | posattriblist_t pal; 75 | } text_t; 76 | 77 | class CUSFSubtitles 78 | { 79 | bool ParseUSFSubtitles(CComPtr pNode); 80 | void ParseMetadata(CComPtr pNode, metadata_t& m); 81 | void ParseStyle(CComPtr pNode, style_t* s); 82 | void ParseFontstyle(CComPtr pNode, fontstyle_t& fs); 83 | void ParsePal(CComPtr pNode, posattriblist_t& pal); 84 | void ParseEffect(CComPtr pNode, effect_t* e); 85 | void ParseKeyframe(CComPtr pNode, keyframe_t* k); 86 | void ParseSubtitle(CComPtr pNode, int start, int stop); 87 | void ParseText(CComPtr pNode, CStringW& assstr); 88 | void ParseShape(CComPtr pNode); 89 | 90 | public: 91 | CUSFSubtitles(); 92 | virtual ~CUSFSubtitles(); 93 | 94 | bool Read(LPCTSTR fn); 95 | // bool Write(LPCTSTR fn); // TODO 96 | 97 | metadata_t metadata; 98 | CAutoPtrList styles; 99 | CAutoPtrList effects; 100 | CAutoPtrList texts; 101 | 102 | bool ConvertToSTS(CSimpleTextSubtitle& sts); 103 | // bool ConvertFromSTS(CSimpleTextSubtitle& sts); // TODO 104 | }; 105 | -------------------------------------------------------------------------------- /src/subtitles/VobSubImage.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2003-2006 Gabest 3 | * http://www.gabest.org 4 | * 5 | * This Program is free software; you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation; either version 2, or (at your option) 8 | * any later version. 9 | * 10 | * This Program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License 16 | * along with GNU Make; see the file COPYING. If not, write to 17 | * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. 18 | * http://www.gnu.org/copyleft/gpl.html 19 | * 20 | */ 21 | 22 | #pragma once 23 | 24 | #include 25 | 26 | typedef struct 27 | { 28 | CAtlArray pa; 29 | CAtlArray da; 30 | void RemoveAll() 31 | { 32 | pa.RemoveAll(); 33 | da.RemoveAll(); 34 | } 35 | void Add(CPoint p, int d) 36 | { 37 | pa.Add(p); 38 | da.Add(d); 39 | } 40 | } COutline; 41 | 42 | class CVobSubImage 43 | { 44 | friend class CVobSubFile; 45 | 46 | private: 47 | CSize org; 48 | RGBQUAD* lpTemp1; 49 | RGBQUAD* lpTemp2; 50 | 51 | WORD nOffset[2], nPlane; 52 | bool fCustomPal; 53 | char fAligned; // we are also using this for calculations, that's why it is char instead of bool... 54 | int tridx; 55 | RGBQUAD* orgpal /*[16]*/, * cuspal /*[4]*/; 56 | 57 | bool Alloc(int w, int h); 58 | void Free(); 59 | 60 | BYTE GetNibble(BYTE* lpData); 61 | void DrawPixels(CPoint p, int length, int colorid); 62 | void TrimSubImage(); 63 | 64 | public: 65 | int iLang, iIdx; 66 | bool fForced; 67 | __int64 start, delay; 68 | CRect rect; 69 | typedef struct 70 | { 71 | BYTE pal: 4, tr: 4; 72 | } SubPal; 73 | SubPal pal[4]; 74 | RGBQUAD* lpPixels; 75 | 76 | CVobSubImage(); 77 | virtual ~CVobSubImage(); 78 | 79 | void Invalidate() 80 | { 81 | iLang = iIdx = -1; 82 | } 83 | 84 | void GetPacketInfo(BYTE* lpData, int packetsize, int datasize); 85 | bool Decode(BYTE* lpData, int packetsize, int datasize, 86 | bool fCustomPal, 87 | int tridx, 88 | RGBQUAD* orgpal /*[16]*/, RGBQUAD* cuspal /*[4]*/, 89 | bool fTrim); 90 | 91 | ///////// 92 | 93 | private: 94 | CAutoPtrList* GetOutlineList(CPoint& topleft); 95 | int GrabSegment(int start, COutline& o, COutline& ret); 96 | void SplitOutline(COutline& o, COutline& o1, COutline& o2); 97 | void AddSegment(COutline& o, CAtlArray& pathTypes, CAtlArray& pathPoints); 98 | 99 | public: 100 | bool Polygonize(CAtlArray& pathTypes, CAtlArray& pathPoints, bool fSmooth, int scale); 101 | bool Polygonize(CStringW& assstr, bool fSmooth = true, int scale = 3); 102 | 103 | void Scale2x(); 104 | }; 105 | -------------------------------------------------------------------------------- /src/subtitles/libssf/Arabic.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2003-2006 Gabest 3 | * http://www.gabest.org 4 | * 5 | * This Program is free software; you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation; either version 2, or (at your option) 8 | * any later version. 9 | * 10 | * This Program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License 16 | * along with GNU Make; see the file COPYING. If not, write to 17 | * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. 18 | * http://www.gnu.org/copyleft/gpl.html 19 | * 20 | */ 21 | 22 | #pragma once 23 | 24 | namespace ssf 25 | { 26 | class Arabic 27 | { 28 | public: 29 | enum pres_form_t {isol, init, medi, fina}; 30 | static bool IsArabic(WCHAR c); 31 | static bool Replace(WCHAR& c, pres_form_t pf); 32 | static bool Replace(WCHAR& c, WCHAR prev, WCHAR next); 33 | }; 34 | } -------------------------------------------------------------------------------- /src/subtitles/libssf/Array.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2003-2006 Gabest 3 | * http://www.gabest.org 4 | * 5 | * This Program is free software; you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation; either version 2, or (at your option) 8 | * any later version. 9 | * 10 | * This Program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License 16 | * along with GNU Make; see the file COPYING. If not, write to 17 | * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. 18 | * http://www.gnu.org/copyleft/gpl.html 19 | * 20 | */ 21 | 22 | #include "stdafx.h" 23 | #include "Array.h" 24 | 25 | namespace ssf 26 | { 27 | 28 | } -------------------------------------------------------------------------------- /src/subtitles/libssf/Exception.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2003-2006 Gabest 3 | * http://www.gabest.org 4 | * 5 | * This Program is free software; you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation; either version 2, or (at your option) 8 | * any later version. 9 | * 10 | * This Program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License 16 | * along with GNU Make; see the file COPYING. If not, write to 17 | * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. 18 | * http://www.gnu.org/copyleft/gpl.html 19 | * 20 | */ 21 | 22 | #include "stdafx.h" 23 | #include "Exception.h" 24 | 25 | namespace ssf 26 | { 27 | Exception::Exception(LPCTSTR fmt, ...) 28 | { 29 | va_list args; 30 | va_start(args, fmt); 31 | int len = _vsctprintf(fmt, args) + 1; 32 | if(len > 0) _vstprintf_s(m_msg.GetBufferSetLength(len), len, fmt, args); 33 | va_end(args); 34 | } 35 | } -------------------------------------------------------------------------------- /src/subtitles/libssf/Exception.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2003-2006 Gabest 3 | * http://www.gabest.org 4 | * 5 | * This Program is free software; you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation; either version 2, or (at your option) 8 | * any later version. 9 | * 10 | * This Program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License 16 | * along with GNU Make; see the file COPYING. If not, write to 17 | * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. 18 | * http://www.gnu.org/copyleft/gpl.html 19 | * 20 | */ 21 | 22 | #pragma once 23 | 24 | namespace ssf 25 | { 26 | class Exception 27 | { 28 | CString m_msg; 29 | 30 | public: 31 | Exception(LPCTSTR fmt, ...); 32 | 33 | CString ToString() 34 | { 35 | return m_msg; 36 | } 37 | }; 38 | } -------------------------------------------------------------------------------- /src/subtitles/libssf/File.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2003-2006 Gabest 3 | * http://www.gabest.org 4 | * 5 | * This Program is free software; you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation; either version 2, or (at your option) 8 | * any later version. 9 | * 10 | * This Program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License 16 | * along with GNU Make; see the file COPYING. If not, write to 17 | * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. 18 | * http://www.gnu.org/copyleft/gpl.html 19 | * 20 | */ 21 | 22 | #pragma once 23 | 24 | #include "Stream.h" 25 | #include "NodeFactory.h" 26 | 27 | namespace ssf 28 | { 29 | class File : public NodeFactory 30 | { 31 | public: 32 | File(); 33 | virtual ~File(); 34 | 35 | void Parse(InputStream& s, LPCWSTR predef = NULL); 36 | 37 | void ParseDefs(InputStream& s, Reference* pParentRef); 38 | void ParseTypes(InputStream& s, CAtlList& types); 39 | void ParseName(InputStream& s, CStringW& name); 40 | void ParseQuotedString(InputStream& s, Definition* pDef); 41 | void ParseNumber(InputStream& s, Definition* pDef); 42 | void ParseBlock(InputStream& s, Definition* pDef); 43 | void ParseRefs(InputStream& s, Definition* pParentDef, LPCWSTR term = L";}]"); 44 | }; 45 | } -------------------------------------------------------------------------------- /src/subtitles/libssf/FontWrapper.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2003-2006 Gabest 3 | * http://www.gabest.org 4 | * 5 | * This Program is free software; you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation; either version 2, or (at your option) 8 | * any later version. 9 | * 10 | * This Program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License 16 | * along with GNU Make; see the file COPYING. If not, write to 17 | * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. 18 | * http://www.gnu.org/copyleft/gpl.html 19 | * 20 | */ 21 | 22 | #include "stdafx.h" 23 | #include "FontWrapper.h" 24 | 25 | namespace ssf 26 | { 27 | FontWrapper::FontWrapper(HDC hDC, HFONT hFont, const CStringW& key) 28 | : m_hFont(hFont) 29 | , m_key(key) 30 | { 31 | HFONT hFontOld = SelectFont(hDC, hFont); 32 | 33 | GetTextMetrics(hDC, &m_tm); 34 | 35 | if(DWORD nNumPairs = GetKerningPairs(hDC, 0, NULL)) 36 | { 37 | KERNINGPAIR* kp = DNew KERNINGPAIR[nNumPairs]; 38 | GetKerningPairs(hDC, nNumPairs, kp); 39 | for(DWORD i = 0; i < nNumPairs; i++) 40 | m_kerning[(kp[i].wFirst << 16) | kp[i].wSecond] = kp[i].iKernAmount; 41 | delete [] kp; 42 | } 43 | 44 | SelectFont(hDC, hFontOld); 45 | } 46 | 47 | FontWrapper::~FontWrapper() 48 | { 49 | DeleteFont(m_hFont); 50 | } 51 | 52 | int FontWrapper::GetKernAmount(WCHAR c1, WCHAR c2) 53 | { 54 | int size = 0; 55 | return m_kerning.Lookup((c1 << 16) | c2, size) ? size : 0; 56 | } 57 | } -------------------------------------------------------------------------------- /src/subtitles/libssf/FontWrapper.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2003-2006 Gabest 3 | * http://www.gabest.org 4 | * 5 | * This Program is free software; you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation; either version 2, or (at your option) 8 | * any later version. 9 | * 10 | * This Program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License 16 | * along with GNU Make; see the file COPYING. If not, write to 17 | * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. 18 | * http://www.gnu.org/copyleft/gpl.html 19 | * 20 | */ 21 | 22 | #pragma once 23 | 24 | namespace ssf 25 | { 26 | class FontWrapper 27 | { 28 | HFONT m_hFont; 29 | CStringW m_key; 30 | TEXTMETRIC m_tm; 31 | CAtlMap m_kerning; 32 | 33 | public: 34 | FontWrapper(HDC hDC, HFONT hFont, const CStringW& key); 35 | virtual ~FontWrapper(); 36 | operator HFONT() const 37 | { 38 | return m_hFont; 39 | } 40 | operator LPCWSTR() const 41 | { 42 | return m_key; 43 | } 44 | const TEXTMETRIC& GetTextMetric() 45 | { 46 | return m_tm; 47 | } 48 | int GetKernAmount(WCHAR c1, WCHAR c2); 49 | }; 50 | } -------------------------------------------------------------------------------- /src/subtitles/libssf/Glyph.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2003-2006 Gabest 3 | * http://www.gabest.org 4 | * 5 | * This Program is free software; you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation; either version 2, or (at your option) 8 | * any later version. 9 | * 10 | * This Program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License 16 | * along with GNU Make; see the file COPYING. If not, write to 17 | * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. 18 | * http://www.gnu.org/copyleft/gpl.html 19 | * 20 | */ 21 | 22 | #pragma once 23 | 24 | #include 25 | #include "GlyphPath.h" 26 | #include "FontWrapper.h" 27 | #include "Rasterizer.h" 28 | 29 | namespace ssf 30 | { 31 | class Glyph 32 | { 33 | void Transform(GlyphPath& path, CPoint org, const CRect& subrect); 34 | 35 | struct SplineCoeffs 36 | { 37 | float cx[4], cy[4]; 38 | }; 39 | 40 | public: 41 | WCHAR c; 42 | Style style; 43 | CAtlArray spline; 44 | Size scale; 45 | bool vertical; 46 | FontWrapper* font; 47 | int ascent, descent, width, spacing, fill; 48 | int row_ascent, row_descent; 49 | GlyphPath path, path_bkg; 50 | CRect bbox; 51 | CPoint tl, tls; 52 | Rasterizer ras, ras_bkg, ras_shadow; 53 | 54 | public: 55 | Glyph(); 56 | 57 | void CreateBkg(); 58 | void CreateSplineCoeffs(const CRect& spdrc); 59 | void Transform(CPoint org, const CRect& subrect); 60 | void Rasterize(); 61 | 62 | float GetBackgroundSize() const; 63 | float GetShadowDepth() const; 64 | CRect GetClipRect() const; 65 | }; 66 | } -------------------------------------------------------------------------------- /src/subtitles/libssf/GlyphPath.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2003-2006 Gabest 3 | * http://www.gabest.org 4 | * 5 | * This Program is free software; you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation; either version 2, or (at your option) 8 | * any later version. 9 | * 10 | * This Program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License 16 | * along with GNU Make; see the file COPYING. If not, write to 17 | * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. 18 | * http://www.gnu.org/copyleft/gpl.html 19 | * 20 | */ 21 | 22 | #pragma once 23 | 24 | #include 25 | 26 | namespace ssf 27 | { 28 | class GlyphPath 29 | { 30 | public: 31 | GlyphPath() {} 32 | virtual ~GlyphPath() {} 33 | 34 | GlyphPath(const GlyphPath& path); 35 | void operator = (const GlyphPath& path); 36 | 37 | bool IsEmpty(); 38 | void RemoveAll(); 39 | void MovePoints(const CPoint& o); 40 | void Enlarge(const GlyphPath& src, float size); 41 | 42 | CAtlArray types; 43 | CAtlArray points; 44 | }; 45 | } -------------------------------------------------------------------------------- /src/subtitles/libssf/NodeFactory.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2003-2006 Gabest 3 | * http://www.gabest.org 4 | * 5 | * This Program is free software; you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation; either version 2, or (at your option) 8 | * any later version. 9 | * 10 | * This Program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License 16 | * along with GNU Make; see the file COPYING. If not, write to 17 | * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. 18 | * http://www.gnu.org/copyleft/gpl.html 19 | * 20 | */ 21 | 22 | #pragma once 23 | 24 | #include "Node.h" 25 | 26 | namespace ssf 27 | { 28 | class NodeFactory 29 | { 30 | Reference* m_root; 31 | StringMapW m_nodes; 32 | CAtlList m_newnodes; 33 | bool m_predefined; 34 | 35 | unsigned __int64 m_counter; 36 | CStringW GenName(); 37 | 38 | public: 39 | NodeFactory(); 40 | virtual ~NodeFactory(); 41 | 42 | virtual void RemoveAll(); 43 | 44 | void SetPredefined(bool predefined) 45 | { 46 | m_predefined = predefined; 47 | } 48 | 49 | void Commit(); 50 | void Rollback(); 51 | 52 | Reference* CreateRootRef(); 53 | Reference* GetRootRef() const; 54 | Reference* CreateRef(Definition* pParentDef); 55 | Definition* CreateDef(Reference* pParentRef = NULL, CStringW type = L"", CStringW name = L"", NodePriority priority = PNormal); 56 | Definition* GetDefByName(CStringW name) const; 57 | void GetNewDefs(CAtlList& defs); 58 | 59 | void Dump(OutputStream& s) const; 60 | }; 61 | } 62 | -------------------------------------------------------------------------------- /src/subtitles/libssf/Rasterizer.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2003-2006 Gabest 3 | * http://www.gabest.org 4 | * 5 | * This Program is free software; you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation; either version 2, or (at your option) 8 | * any later version. 9 | * 10 | * This Program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License 16 | * along with GNU Make; see the file COPYING. If not, write to 17 | * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. 18 | * http://www.gnu.org/copyleft/gpl.html 19 | * 20 | */ 21 | 22 | #pragma once 23 | 24 | #include 25 | #include "SubtitleFile.h" 26 | #include "Array.h" 27 | #include "GlyphPath.h" 28 | #include "..\..\SubPic\ISubPic.h" 29 | 30 | namespace ssf 31 | { 32 | class Rasterizer 33 | { 34 | bool fFirstSet; 35 | CPoint firstp, lastp; 36 | 37 | private: 38 | int mWidth, mHeight; 39 | 40 | union Span 41 | { 42 | struct 43 | { 44 | int x1, y1, x2, y2; 45 | }; 46 | struct 47 | { 48 | unsigned __int64 first, second; 49 | }; 50 | union Span() {} 51 | union Span(int _x1, int _y1, int _x2, int _y2) 52 | { 53 | x1 = _x1; 54 | y1 = _y1; 55 | x2 = _x2; 56 | y2 = _y2; 57 | } 58 | union Span(unsigned __int64 _first, unsigned __int64 _second) 59 | { 60 | first = _first; 61 | second = _second; 62 | } 63 | }; 64 | 65 | Array mOutline, mWideOutline, mWideOutlineTmp; 66 | int mWideBorder; 67 | 68 | struct Edge 69 | { 70 | int next, posandflag; 71 | }* mpEdgeBuffer; 72 | unsigned int mEdgeHeapSize; 73 | unsigned int mEdgeNext; 74 | unsigned int* mpScanBuffer; 75 | 76 | protected: 77 | BYTE* mpOverlayBuffer; 78 | int mOverlayWidth, mOverlayHeight; 79 | int mPathOffsetX, mPathOffsetY; 80 | int mOffsetX, mOffsetY; 81 | 82 | private: 83 | void _TrashOverlay(); 84 | void _ReallocEdgeBuffer(int edges); 85 | void _EvaluateBezier(const CPoint& p0, const CPoint& p1, const CPoint& p2, const CPoint& p3); 86 | void _EvaluateLine(CPoint p0, CPoint p1); 87 | void _OverlapRegion(Array& dst, Array& src, int dx, int dy); 88 | 89 | public: 90 | Rasterizer(); 91 | virtual ~Rasterizer(); 92 | 93 | bool ScanConvert(GlyphPath& path, const CRect& bbox); 94 | bool CreateWidenedRegion(int r); 95 | bool Rasterize(int xsub, int ysub); 96 | void Reuse(Rasterizer& r); 97 | 98 | void Blur(float n, int plane); 99 | CRect Draw(const SubPicDesc& spd, const CRect& clip, int xsub, int ysub, const DWORD* switchpts, int plane); 100 | }; 101 | } -------------------------------------------------------------------------------- /src/subtitles/libssf/Split.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2003-2006 Gabest 3 | * http://www.gabest.org 4 | * 5 | * This Program is free software; you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation; either version 2, or (at your option) 8 | * any later version. 9 | * 10 | * This Program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License 16 | * along with GNU Make; see the file COPYING. If not, write to 17 | * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. 18 | * http://www.gnu.org/copyleft/gpl.html 19 | * 20 | */ 21 | 22 | #include "stdafx.h" 23 | #include "Split.h" 24 | #include "Exception.h" 25 | 26 | namespace ssf 27 | { 28 | Split::Split(LPCWSTR sep, CStringW str, size_t limit, SplitType type) 29 | { 30 | DoSplit(sep, str, limit, type); 31 | } 32 | 33 | Split::Split(WCHAR sep, CStringW str, size_t limit, SplitType type) 34 | { 35 | DoSplit(CStringW(sep), str, limit, type); 36 | } 37 | 38 | void Split::DoSplit(LPCWSTR sep, CStringW str, size_t limit, SplitType type) 39 | { 40 | RemoveAll(); 41 | 42 | if(size_t seplen = wcslen(sep)) 43 | { 44 | for(ptrdiff_t i = 0, j = 0, len = str.GetLength(); 45 | i <= len && (limit == 0 || GetCount() < limit); 46 | i = j + (int)seplen) 47 | { 48 | j = str.Find(sep, i); 49 | if(j < 0) j = len; 50 | 51 | CStringW s = i < j ? str.Mid(i, j - i) : L""; 52 | 53 | switch(type) 54 | { 55 | case Min: 56 | s.Trim(); // fall through 57 | case Def: 58 | if(s.IsEmpty()) break; // else fall through 59 | case Max: 60 | Add(s); 61 | break; 62 | } 63 | } 64 | } 65 | } 66 | 67 | int Split::GetAtInt(size_t i) 68 | { 69 | if(i >= GetCount()) throw Exception(_T("Index out of bounds")); 70 | return _wtoi(GetAt(i)); 71 | } 72 | 73 | float Split::GetAtFloat(size_t i) 74 | { 75 | if(i >= GetCount()) throw Exception(_T("Index out of bounds")); 76 | return (float)_wtof(GetAt(i)); 77 | } 78 | } -------------------------------------------------------------------------------- /src/subtitles/libssf/Split.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2003-2006 Gabest 3 | * http://www.gabest.org 4 | * 5 | * This Program is free software; you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation; either version 2, or (at your option) 8 | * any later version. 9 | * 10 | * This Program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License 16 | * along with GNU Make; see the file COPYING. If not, write to 17 | * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. 18 | * http://www.gnu.org/copyleft/gpl.html 19 | * 20 | */ 21 | 22 | #pragma once 23 | 24 | namespace ssf 25 | { 26 | class Split : public CAtlArray 27 | { 28 | public: 29 | enum SplitType {Min, Def, Max}; 30 | Split(); 31 | Split(LPCWSTR sep, CStringW str, size_t limit = 0, SplitType type = Def); 32 | Split(WCHAR sep, CStringW str, size_t limit = 0, SplitType type = Def); 33 | operator size_t() 34 | { 35 | return GetCount(); 36 | } 37 | void DoSplit(LPCWSTR sep, CStringW str, size_t limit, SplitType type); 38 | int GetAtInt(size_t i); 39 | float GetAtFloat(size_t i); 40 | }; 41 | } -------------------------------------------------------------------------------- /src/subtitles/libssf/Stream.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2003-2006 Gabest 3 | * http://www.gabest.org 4 | * 5 | * This Program is free software; you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation; either version 2, or (at your option) 8 | * any later version. 9 | * 10 | * This Program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License 16 | * along with GNU Make; see the file COPYING. If not, write to 17 | * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. 18 | * http://www.gnu.org/copyleft/gpl.html 19 | * 20 | */ 21 | 22 | #pragma once 23 | 24 | #include "Exception.h" 25 | 26 | namespace ssf 27 | { 28 | class Stream 29 | { 30 | public: 31 | enum {EOS = -1}; 32 | enum encoding_t {none, unknown, utf8, utf16le, utf16be, wchar}; 33 | 34 | protected: 35 | int m_line, m_col; 36 | encoding_t m_encoding; 37 | 38 | public: 39 | Stream(); 40 | virtual ~Stream(); 41 | 42 | static bool IsWhiteSpace(int c, LPCWSTR morechars = NULL); 43 | 44 | void ThrowError(LPCTSTR fmt, ...); 45 | }; 46 | 47 | class InputStream : public Stream 48 | { 49 | CAtlList m_queue; 50 | int PushChar(), PopChar(); 51 | 52 | int NextChar(); 53 | 54 | protected: 55 | virtual int NextByte() = 0; 56 | 57 | public: 58 | InputStream(); 59 | ~InputStream(); 60 | 61 | int PeekChar(), GetChar(); 62 | 63 | int SkipWhiteSpace(LPCWSTR morechars = NULL); 64 | }; 65 | 66 | class FileInputStream : public InputStream 67 | { 68 | FILE* m_file; 69 | 70 | protected: 71 | int NextByte(); 72 | 73 | public: 74 | FileInputStream(const TCHAR* fn); 75 | ~FileInputStream(); 76 | }; 77 | 78 | class MemoryInputStream : public InputStream 79 | { 80 | BYTE* m_pBytes; 81 | int m_pos, m_len; 82 | bool m_fFree; 83 | 84 | protected: 85 | int NextByte(); 86 | 87 | public: 88 | MemoryInputStream(BYTE* pBytes, int len, bool fCopy, bool fFree); 89 | ~MemoryInputStream(); 90 | }; 91 | 92 | class WCharInputStream : public InputStream 93 | { 94 | CStringW m_str; 95 | int m_pos; 96 | 97 | protected: 98 | int NextByte(); 99 | 100 | public: 101 | WCharInputStream(CStringW str); 102 | }; 103 | 104 | class OutputStream : public Stream 105 | { 106 | bool m_bof; 107 | 108 | protected: 109 | virtual void NextByte(int b) = 0; 110 | 111 | public: 112 | OutputStream(encoding_t e); 113 | virtual ~OutputStream(); 114 | 115 | void PutChar(WCHAR c); 116 | void PutString(LPCWSTR fmt, ...); 117 | }; 118 | 119 | class WCharOutputStream : public OutputStream 120 | { 121 | CStringW m_str; 122 | 123 | protected: 124 | void NextByte(int b); 125 | 126 | public: 127 | WCharOutputStream(); 128 | 129 | const CStringW& GetString() 130 | { 131 | return m_str; 132 | } 133 | }; 134 | 135 | class DebugOutputStream : public OutputStream 136 | { 137 | CStringW m_str; 138 | 139 | protected: 140 | void NextByte(int b); 141 | 142 | public: 143 | DebugOutputStream(); 144 | ~DebugOutputStream(); 145 | }; 146 | } -------------------------------------------------------------------------------- /src/subtitles/libssf/StringMap.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2003-2006 Gabest 3 | * http://www.gabest.org 4 | * 5 | * This Program is free software; you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation; either version 2, or (at your option) 8 | * any later version. 9 | * 10 | * This Program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License 16 | * along with GNU Make; see the file COPYING. If not, write to 17 | * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. 18 | * http://www.gnu.org/copyleft/gpl.html 19 | * 20 | */ 21 | 22 | #include "stdafx.h" 23 | #include "Exception.h" 24 | 25 | namespace ssf 26 | { 27 | 28 | } -------------------------------------------------------------------------------- /src/subtitles/libssf/StringMap.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2003-2006 Gabest 3 | * http://www.gabest.org 4 | * 5 | * This Program is free software; you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation; either version 2, or (at your option) 8 | * any later version. 9 | * 10 | * This Program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License 16 | * along with GNU Make; see the file COPYING. If not, write to 17 | * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. 18 | * http://www.gnu.org/copyleft/gpl.html 19 | * 20 | */ 21 | 22 | #pragma once 23 | 24 | namespace ssf 25 | { 26 | template < class T = CString, class S = CString > 27 | class StringMap : public CAtlMap > 28 | { 29 | public: 30 | StringMap() {} 31 | StringMap(const StringMap& s2t) 32 | { 33 | *this = s2t; 34 | } 35 | StringMap& operator = (const StringMap& s2t) 36 | { 37 | RemoveAll(); 38 | POSITION pos = s2t.GetStartPosition(); 39 | while(pos) 40 | { 41 | const StringMap::CPair* p = s2t.GetNext(pos); 42 | SetAt(p->m_key, p->m_value); 43 | } 44 | return *this; 45 | } 46 | }; 47 | 48 | template < class T = CStringA, class S = CStringA > 49 | class StringMapA : public StringMap {}; 50 | 51 | template < class T = CStringW, class S = CStringW > 52 | class StringMapW : public StringMap {}; 53 | } -------------------------------------------------------------------------------- /src/subtitles/libssf/SubtitleFile.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2003-2006 Gabest 3 | * http://www.gabest.org 4 | * 5 | * This Program is free software; you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation; either version 2, or (at your option) 8 | * any later version. 9 | * 10 | * This Program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License 16 | * along with GNU Make; see the file COPYING. If not, write to 17 | * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. 18 | * http://www.gnu.org/copyleft/gpl.html 19 | * 20 | */ 21 | 22 | #pragma once 23 | 24 | #include "File.h" 25 | #include "Subtitle.h" 26 | 27 | namespace ssf 28 | { 29 | class SubtitleFile : public File 30 | { 31 | static LPCWSTR s_predef; 32 | 33 | public: 34 | struct SegmentItem 35 | { 36 | Definition* pDef; 37 | float start, stop; 38 | }; 39 | 40 | class Segment : public CAtlList 41 | { 42 | public: 43 | float m_start, m_stop; 44 | Segment() {} 45 | Segment(float start, float stop, const SegmentItem* si = NULL); 46 | Segment(const Segment& s); 47 | void operator = (const Segment& s); 48 | }; 49 | 50 | class SegmentList : public CAtlList 51 | { 52 | CAtlArray m_index; 53 | size_t Index(bool fForce = false); 54 | 55 | public: 56 | void RemoveAll(); 57 | void Insert(float start, float stop, Definition* pDef); 58 | void Lookup(float at, CAtlList& sis); 59 | bool Lookup(float at, size_t& k); 60 | const Segment* GetSegment(size_t k); 61 | }; 62 | 63 | SegmentList m_segments; 64 | 65 | public: 66 | SubtitleFile(); 67 | virtual ~SubtitleFile(); 68 | 69 | void Parse(InputStream& s); 70 | void Append(InputStream& s, float start, float stop, bool fSetTime = false); 71 | bool Lookup(float at, CAutoPtrList& subs); 72 | }; 73 | } -------------------------------------------------------------------------------- /src/subtitles/libssf/demo/demo.ssa: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sorayuki/VSFilterMod/643b3def0970eb9dedaa5e6d9be6c3c492ce970d/src/subtitles/libssf/demo/demo.ssa -------------------------------------------------------------------------------- /src/subtitles/libssf/stdafx.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2003-2006 Gabest 3 | * http://www.gabest.org 4 | * 5 | * This Program is free software; you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation; either version 2, or (at your option) 8 | * any later version. 9 | * 10 | * This Program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License 16 | * along with GNU Make; see the file COPYING. If not, write to 17 | * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. 18 | * http://www.gnu.org/copyleft/gpl.html 19 | * 20 | */ 21 | 22 | // stdafx.cpp : source file that includes just the standard includes 23 | // libssf.pch will be the pre-compiled header 24 | // stdafx.obj will contain the pre-compiled type information 25 | 26 | #include "stdafx.h" 27 | 28 | // TODO: reference any additional headers you need in STDAFX.H 29 | // and not in this file 30 | -------------------------------------------------------------------------------- /src/subtitles/libssf/stdafx.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2003-2006 Gabest 3 | * http://www.gabest.org 4 | * 5 | * This Program is free software; you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation; either version 2, or (at your option) 8 | * any later version. 9 | * 10 | * This Program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License 16 | * along with GNU Make; see the file COPYING. If not, write to 17 | * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. 18 | * http://www.gnu.org/copyleft/gpl.html 19 | * 20 | */ 21 | 22 | // stdafx.h : include file for standard system include files, 23 | // or project specific include files that are used frequently, but 24 | // are changed infrequently 25 | // 26 | 27 | #pragma once 28 | #include "..\..\DSUtil\SharedInclude.h" 29 | 30 | // Modify the following defines if you have to target a platform prior to the ones specified below. 31 | // Refer to MSDN for the latest info on corresponding values for different platforms. 32 | #ifndef WINVER // Allow use of features specific to Windows XP or later. 33 | #define WINVER 0x0600 34 | #endif 35 | 36 | #ifndef _WIN32_WINNT // Allow use of features specific to Windows XP or later. 37 | #define _WIN32_WINNT 0x0501 // Change this to the appropriate value to target other versions of Windows. 38 | #endif 39 | 40 | #ifndef _WIN32_WINDOWS // Allow use of features specific to Windows 98 or later. 41 | #define _WIN32_WINDOWS 0x0410 // Change this to the appropriate value to target Windows Me or later. 42 | #endif 43 | 44 | #ifndef _WIN32_IE // Allow use of features specific to IE 6.0 or later. 45 | #define _WIN32_IE 0x0600 // Change this to the appropriate value to target other versions of IE. 46 | #endif 47 | 48 | #define WIN32_LEAN_AND_MEAN // Exclude rarely-used stuff from Windows headers 49 | #define _ATL_CSTRING_EXPLICIT_CONSTRUCTORS // some CString constructors will be explicit 50 | 51 | #ifndef VC_EXTRALEAN 52 | #define VC_EXTRALEAN // Exclude rarely-used stuff from Windows headers 53 | #endif 54 | 55 | #include 56 | #include // MFC core and standard components 57 | #include // MFC core and standard components 58 | 59 | // TODO: reference additional headers your program requires here 60 | 61 | #include 62 | #include "..\..\DSUtil\DSUtil.h" 63 | #include "..\..\dsutil\vd.h" 64 | 65 | #include 66 | #include 67 | 68 | #define _USE_MATH_DEFINES 69 | #include 70 | -------------------------------------------------------------------------------- /src/subtitles/stdafx.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2003-2006 Gabest 3 | * http://www.gabest.org 4 | * 5 | * This Program is free software; you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation; either version 2, or (at your option) 8 | * any later version. 9 | * 10 | * This Program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License 16 | * along with GNU Make; see the file COPYING. If not, write to 17 | * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. 18 | * http://www.gnu.org/copyleft/gpl.html 19 | * 20 | */ 21 | 22 | // stdafx.cpp : source file that includes just the standard includes 23 | // subtitles.pch will be the pre-compiled header 24 | // stdafx.obj will contain the pre-compiled type information 25 | 26 | #include "stdafx.h" 27 | 28 | // TODO: reference any additional headers you need in STDAFX.H 29 | // and not in this file 30 | -------------------------------------------------------------------------------- /src/subtitles/stdafx.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2003-2006 Gabest 3 | * http://www.gabest.org 4 | * 5 | * This Program is free software; you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation; either version 2, or (at your option) 8 | * any later version. 9 | * 10 | * This Program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License 16 | * along with GNU Make; see the file COPYING. If not, write to 17 | * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. 18 | * http://www.gnu.org/copyleft/gpl.html 19 | * 20 | */ 21 | 22 | // stdafx.h : include file for standard system include files, 23 | // or project specific include files that are used frequently, but 24 | // are changed infrequently 25 | // 26 | 27 | #pragma once 28 | #include "..\DSUtil\SharedInclude.h" 29 | 30 | #define WIN32_LEAN_AND_MEAN // Exclude rarely-used stuff from Windows headers 31 | #define _ATL_CSTRING_EXPLICIT_CONSTRUCTORS // some CString constructors will be explicit 32 | #define WINVER 0x0600 33 | 34 | #ifndef VC_EXTRALEAN 35 | #define VC_EXTRALEAN // Exclude rarely-used stuff from Windows headers 36 | #endif 37 | 38 | #include 39 | #include // MFC core and standard components 40 | 41 | // TODO: reference additional headers your program requires here 42 | 43 | #include 44 | #include "..\DSUtil\DSUtil.h" 45 | -------------------------------------------------------------------------------- /src/vsfilter/StdAfx.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2003-2006 Gabest 3 | * http://www.gabest.org 4 | * 5 | * This Program is free software; you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation; either version 2, or (at your option) 8 | * any later version. 9 | * 10 | * This Program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License 16 | * along with GNU Make; see the file COPYING. If not, write to 17 | * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. 18 | * http://www.gnu.org/copyleft/gpl.html 19 | * 20 | */ 21 | 22 | // stdafx.cpp : source file that includes just the standard includes 23 | // stdafx.pch will be the pre-compiled header 24 | // stdafx.obj will contain the pre-compiled type information 25 | 26 | #include "stdafx.h" 27 | -------------------------------------------------------------------------------- /src/vsfilter/StdAfx.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2003-2006 Gabest 3 | * http://www.gabest.org 4 | * 5 | * This Program is free software; you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation; either version 2, or (at your option) 8 | * any later version. 9 | * 10 | * This Program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License 16 | * along with GNU Make; see the file COPYING. If not, write to 17 | * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. 18 | * http://www.gnu.org/copyleft/gpl.html 19 | * 20 | */ 21 | 22 | // stdafx.h : include file for standard system include files, 23 | // or project specific include files that are used frequently, 24 | // but are changed infrequently 25 | 26 | #if !defined(AFX_STDAFX_H__E8AD1C3F_323D_4812_A1DE_AA2419CE2AF3__INCLUDED_) 27 | #define AFX_STDAFX_H__E8AD1C3F_323D_4812_A1DE_AA2419CE2AF3__INCLUDED_ 28 | 29 | #if _MSC_VER > 1000 30 | #pragma once 31 | #endif // _MSC_VER > 1000 32 | 33 | #define STRICT 34 | #ifndef _WIN32_WINNT 35 | #define _WIN32_WINNT 0x0400 36 | #endif 37 | #define _ATL_APARTMENT_THREADED 38 | 39 | #include "..\DSUtil\SharedInclude.h" 40 | 41 | #include 42 | #include 43 | 44 | #include 45 | //You may derive a class from CComModule and use it if you want to override 46 | //something, but do not change the name of _Module 47 | extern CComModule _Module; 48 | #include 49 | 50 | #define AFX_CLASS AFX_CLASS_IMPORT 51 | 52 | #include 53 | #include 54 | #include "..\DSUtil\DSUtil.h" 55 | 56 | //{{AFX_INSERT_LOCATION}} 57 | // Microsoft Visual C++ will insert additional declarations immediately before the previous line. 58 | 59 | #endif // !defined(AFX_STDAFX_H__E8AD1C3F_323D_4812_A1DE_AA2419CE2AF3__INCLUDED) 60 | -------------------------------------------------------------------------------- /src/vsfilter/StyleEditorDialog.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2003-2006 Gabest 3 | * http://www.gabest.org 4 | * 5 | * This Program is free software; you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation; either version 2, or (at your option) 8 | * any later version. 9 | * 10 | * This Program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License 16 | * along with GNU Make; see the file COPYING. If not, write to 17 | * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. 18 | * http://www.gnu.org/copyleft/gpl.html 19 | * 20 | */ 21 | 22 | #pragma once 23 | #include "resource.h" 24 | #include "afxwin.h" 25 | #include "afxcmn.h" 26 | #include "..\subtitles\STS.h" 27 | 28 | // CColorStatic dialog 29 | 30 | class CColorStatic : public CStatic 31 | { 32 | DECLARE_DYNAMIC(CColorStatic) 33 | 34 | COLORREF* m_pColor; 35 | 36 | public: 37 | CColorStatic(CWnd* pParent = NULL) : m_pColor(NULL) {} 38 | virtual ~CColorStatic() {} 39 | 40 | void SetColorPtr(COLORREF* pColor) 41 | { 42 | m_pColor = pColor; 43 | } 44 | 45 | DECLARE_MESSAGE_MAP() 46 | 47 | protected: 48 | virtual void DrawItem(LPDRAWITEMSTRUCT lpDrawItemStruct) 49 | { 50 | CRect r; 51 | GetClientRect(r); 52 | CDC::FromHandle(lpDrawItemStruct->hDC)->FillSolidRect(r, m_pColor ? *m_pColor : ::GetSysColor(COLOR_BTNFACE)); 53 | } 54 | }; 55 | 56 | // CStyleEditorDialog dialog 57 | 58 | class CStyleEditorDialog : public CDialog 59 | { 60 | DECLARE_DYNAMIC(CStyleEditorDialog) 61 | 62 | CString m_title; 63 | CWnd* m_pParent; 64 | 65 | void UpdateControlData(bool fSave); 66 | void AskColor(int i); 67 | 68 | public: 69 | CStyleEditorDialog(CString title, STSStyle* pstss, CWnd* pParent = NULL); // standard constructor 70 | virtual ~CStyleEditorDialog(); 71 | 72 | // Dialog Data 73 | enum { IDD = IDD_STYLEDIALOG }; 74 | 75 | STSStyle m_stss; 76 | 77 | protected: 78 | virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support 79 | virtual BOOL OnInitDialog(); 80 | virtual void OnOK(); 81 | 82 | DECLARE_MESSAGE_MAP() 83 | 84 | public: 85 | CButton m_font; 86 | int m_iCharset; 87 | CComboBox m_charset; 88 | int m_spacing; 89 | CSpinButtonCtrl m_spacingspin; 90 | int m_angle; 91 | CSpinButtonCtrl m_anglespin; 92 | int m_scalex; 93 | CSpinButtonCtrl m_scalexspin; 94 | int m_scaley; 95 | CSpinButtonCtrl m_scaleyspin; 96 | int m_borderstyle; 97 | int m_borderwidth; 98 | CSpinButtonCtrl m_borderwidthspin; 99 | int m_shadowdepth; 100 | CSpinButtonCtrl m_shadowdepthspin; 101 | int m_screenalignment; 102 | CRect m_margin; 103 | CSpinButtonCtrl m_marginleftspin; 104 | CSpinButtonCtrl m_marginrightspin; 105 | CSpinButtonCtrl m_margintopspin; 106 | CSpinButtonCtrl m_marginbottomspin; 107 | CColorStatic m_color[4]; 108 | int m_alpha[4]; 109 | CSliderCtrl m_alphasliders[4]; 110 | BOOL m_linkalphasliders; 111 | 112 | afx_msg void OnBnClickedButton1(); 113 | afx_msg void OnStnClickedColorpri(); 114 | afx_msg void OnStnClickedColorsec(); 115 | afx_msg void OnStnClickedColoroutl(); 116 | afx_msg void OnStnClickedColorshad(); 117 | afx_msg void OnBnClickedCheck1(); 118 | afx_msg void OnHScroll(UINT nSBCode, UINT nPos, CScrollBar* pScrollBar); 119 | }; 120 | -------------------------------------------------------------------------------- /src/vsfilter/Systray.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2003-2006 Gabest 3 | * http://www.gabest.org 4 | * 5 | * This Program is free software; you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation; either version 2, or (at your option) 8 | * any later version. 9 | * 10 | * This Program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License 16 | * along with GNU Make; see the file COPYING. If not, write to 17 | * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. 18 | * http://www.gnu.org/copyleft/gpl.html 19 | * 20 | */ 21 | 22 | #pragma once 23 | 24 | extern DWORD CALLBACK SystrayThreadProc(void* pParam); 25 | -------------------------------------------------------------------------------- /src/vsfilter/TextInputPin.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2003-2006 Gabest 3 | * http://www.gabest.org 4 | * 5 | * This Program is free software; you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation; either version 2, or (at your option) 8 | * any later version. 9 | * 10 | * This Program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License 16 | * along with GNU Make; see the file COPYING. If not, write to 17 | * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. 18 | * http://www.gnu.org/copyleft/gpl.html 19 | * 20 | */ 21 | 22 | #include "stdafx.h" 23 | #include "DirectVobSubFilter.h" 24 | #include "TextInputPin.h" 25 | #include "..\DSUtil\DSUtil.h" 26 | 27 | CTextInputPin::CTextInputPin(CDirectVobSubFilter* pFilter, CCritSec* pLock, CCritSec* pSubLock, HRESULT* phr) 28 | : CSubtitleInputPin(pFilter, pLock, pSubLock, phr) 29 | , m_pDVS(pFilter) 30 | { 31 | } 32 | 33 | void CTextInputPin::AddSubStream(ISubStream* pSubStream) 34 | { 35 | m_pDVS->AddSubStream(pSubStream); 36 | } 37 | 38 | void CTextInputPin::RemoveSubStream(ISubStream* pSubStream) 39 | { 40 | m_pDVS->RemoveSubStream(pSubStream); 41 | } 42 | 43 | void CTextInputPin::InvalidateSubtitle(REFERENCE_TIME rtStart, ISubStream* pSubStream) 44 | { 45 | m_pDVS->InvalidateSubtitle(rtStart, (DWORD_PTR)(ISubStream*)pSubStream); 46 | } 47 | -------------------------------------------------------------------------------- /src/vsfilter/TextInputPin.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2003-2006 Gabest 3 | * http://www.gabest.org 4 | * 5 | * This Program is free software; you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation; either version 2, or (at your option) 8 | * any later version. 9 | * 10 | * This Program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License 16 | * along with GNU Make; see the file COPYING. If not, write to 17 | * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. 18 | * http://www.gnu.org/copyleft/gpl.html 19 | * 20 | */ 21 | 22 | #pragma once 23 | 24 | #include "..\subtitles\SubtitleInputPin.h" 25 | 26 | class CDirectVobSubFilter; 27 | 28 | class CTextInputPin : public CSubtitleInputPin 29 | { 30 | CDirectVobSubFilter* m_pDVS; 31 | 32 | protected: 33 | void AddSubStream(ISubStream* pSubStream); 34 | void RemoveSubStream(ISubStream* pSubStream); 35 | void InvalidateSubtitle(REFERENCE_TIME rtStart, ISubStream* pSubStream); 36 | 37 | public: 38 | CTextInputPin(CDirectVobSubFilter* pFilter, CCritSec* pLock, CCritSec* pSubLock, HRESULT* phr); 39 | }; 40 | 41 | -------------------------------------------------------------------------------- /src/vsfilter/VSFilter.def: -------------------------------------------------------------------------------- 1 | EXPORTS 2 | DllCanUnloadNow PRIVATE 3 | DllGetClassObject PRIVATE 4 | DllRegisterServer PRIVATE 5 | DllUnregisterServer PRIVATE 6 | DirectVobSub 7 | -------------------------------------------------------------------------------- /src/vsfilter/VSFilter.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2003-2006 Gabest 3 | * http://www.gabest.org 4 | * 5 | * This Program is free software; you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation; either version 2, or (at your option) 8 | * any later version. 9 | * 10 | * This Program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License 16 | * along with GNU Make; see the file COPYING. If not, write to 17 | * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. 18 | * http://www.gnu.org/copyleft/gpl.html 19 | * 20 | */ 21 | 22 | #pragma once 23 | 24 | #include "resource.h" 25 | 26 | class CVSFilterApp : public CWinApp 27 | { 28 | public: 29 | CVSFilterApp(); 30 | 31 | CString m_AppName; 32 | 33 | protected: 34 | HINSTANCE LoadAppLangResourceDLL(); 35 | 36 | public: 37 | BOOL InitInstance(); 38 | BOOL ExitInstance(); 39 | 40 | DECLARE_MESSAGE_MAP() 41 | }; 42 | 43 | extern CVSFilterApp theApp; 44 | 45 | #define ResStr(id) CString(MAKEINTRESOURCE(id)) 46 | -------------------------------------------------------------------------------- /src/vsfilter/VSFilter.rc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sorayuki/VSFilterMod/643b3def0970eb9dedaa5e6d9be6c3c492ce970d/src/vsfilter/VSFilter.rc -------------------------------------------------------------------------------- /src/vsfilter/VSFilter64.def: -------------------------------------------------------------------------------- 1 | EXPORTS 2 | DllCanUnloadNow PRIVATE 3 | DllGetClassObject PRIVATE 4 | DllRegisterServer PRIVATE 5 | DllUnregisterServer PRIVATE 6 | DirectVobSub 7 | -------------------------------------------------------------------------------- /src/vsfilter/VSFilterMod.def: -------------------------------------------------------------------------------- 1 | EXPORTS 2 | DllCanUnloadNow PRIVATE 3 | DllGetClassObject PRIVATE 4 | DllRegisterServer PRIVATE 5 | DllUnregisterServer PRIVATE 6 | DirectVobSub 7 | -------------------------------------------------------------------------------- /src/vsfilter/VSFilterMod.rc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sorayuki/VSFilterMod/643b3def0970eb9dedaa5e6d9be6c3c492ce970d/src/vsfilter/VSFilterMod.rc -------------------------------------------------------------------------------- /src/vsfilter/VSFilterMod64.def: -------------------------------------------------------------------------------- 1 | EXPORTS 2 | DllCanUnloadNow PRIVATE 3 | DllGetClassObject PRIVATE 4 | DllRegisterServer PRIVATE 5 | DllUnregisterServer PRIVATE 6 | DirectVobSub 7 | -------------------------------------------------------------------------------- /src/vsfilter/res/Icon_147.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sorayuki/VSFilterMod/643b3def0970eb9dedaa5e6d9be6c3c492ce970d/src/vsfilter/res/Icon_147.ico -------------------------------------------------------------------------------- /src/vsfilter/res/Icon_147m.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sorayuki/VSFilterMod/643b3def0970eb9dedaa5e6d9be6c3c492ce970d/src/vsfilter/res/Icon_147m.ico -------------------------------------------------------------------------------- /src/vsfilter/res/VSFilter.manifest: -------------------------------------------------------------------------------- 1 | 2 | 3 | 9 | DirectVobSub 10 | 11 | 12 | 20 | 21 | 22 | 23 | 24 | -------------------------------------------------------------------------------- /src/vsfilter/resource.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sorayuki/VSFilterMod/643b3def0970eb9dedaa5e6d9be6c3c492ce970d/src/vsfilter/resource.h -------------------------------------------------------------------------------- /src/vsfilter/vfr.h: -------------------------------------------------------------------------------- 1 | /* 2 | * VFR translation functions for OverLua 3 | * 4 | * (C) 2003-2006 Gabest 5 | * (C) 2006-2010 see AUTHORS 6 | * 7 | * This file is part of mplayerc. 8 | * 9 | * Mplayerc is free software; you can redistribute it and/or modify 10 | * it under the terms of the GNU General Public License as published by 11 | * the Free Software Foundation; either version 3 of the License, or 12 | * (at your option) any later version. 13 | * 14 | * Mplayerc is distributed in the hope that it will be useful, 15 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 | * GNU General Public License for more details. 18 | * 19 | * You should have received a copy of the GNU General Public License 20 | * along with this program. If not, see . 21 | * 22 | */ 23 | 24 | #ifndef VFR_H 25 | #define VFR_H 26 | 27 | class VFRTranslator 28 | { 29 | public: 30 | virtual double TimeStampFromFrameNumber(int n) = 0; 31 | }; 32 | 33 | VFRTranslator *GetVFRTranslator(const char *vfrfile); 34 | 35 | #endif -------------------------------------------------------------------------------- /src/zlib/ChangeLog: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sorayuki/VSFilterMod/643b3def0970eb9dedaa5e6d9be6c3c492ce970d/src/zlib/ChangeLog -------------------------------------------------------------------------------- /src/zlib/ZLIB.DEF: -------------------------------------------------------------------------------- 1 | LIBRARY 2 | ; zlib data compression library 3 | 4 | EXPORTS 5 | ; basic functions 6 | zlibVersion 7 | deflate 8 | deflateEnd 9 | inflate 10 | inflateEnd 11 | ; advanced functions 12 | deflateSetDictionary 13 | deflateCopy 14 | deflateReset 15 | deflateParams 16 | deflateTune 17 | deflateBound 18 | deflatePrime 19 | deflateSetHeader 20 | inflateSetDictionary 21 | inflateSync 22 | inflateCopy 23 | inflateReset 24 | inflateReset2 25 | inflatePrime 26 | inflateMark 27 | inflateGetHeader 28 | inflateBack 29 | inflateBackEnd 30 | zlibCompileFlags 31 | ; utility functions 32 | compress 33 | compress2 34 | compressBound 35 | uncompress 36 | gzopen 37 | gzdopen 38 | gzbuffer 39 | gzsetparams 40 | gzread 41 | gzwrite 42 | gzprintf 43 | gzputs 44 | gzgets 45 | gzputc 46 | gzgetc 47 | gzungetc 48 | gzflush 49 | gzseek 50 | gzrewind 51 | gztell 52 | gzoffset 53 | gzeof 54 | gzdirect 55 | gzclose 56 | gzclose_r 57 | gzclose_w 58 | gzerror 59 | gzclearerr 60 | ; checksum functions 61 | adler32 62 | crc32 63 | adler32_combine 64 | crc32_combine 65 | ; various hacks, don't look :) 66 | deflateInit_ 67 | deflateInit2_ 68 | inflateInit_ 69 | inflateInit2_ 70 | inflateBackInit_ 71 | zError 72 | inflateSyncPoint 73 | get_crc_table 74 | inflateUndermine 75 | -------------------------------------------------------------------------------- /src/zlib/ZLIB.RC: -------------------------------------------------------------------------------- 1 | #include 2 | #include "zlib.h" 3 | 4 | #ifdef GCC_WINDRES 5 | VS_VERSION_INFO VERSIONINFO 6 | #else 7 | VS_VERSION_INFO VERSIONINFO MOVEABLE IMPURE LOADONCALL DISCARDABLE 8 | #endif 9 | FILEVERSION ZLIB_VER_MAJOR,ZLIB_VER_MINOR,ZLIB_VER_REVISION,0 10 | PRODUCTVERSION ZLIB_VER_MAJOR,ZLIB_VER_MINOR,ZLIB_VER_REVISION,0 11 | FILEFLAGSMASK VS_FFI_FILEFLAGSMASK 12 | #ifdef _DEBUG 13 | FILEFLAGS 1 14 | #else 15 | FILEFLAGS 0 16 | #endif 17 | FILEOS VOS__WINDOWS32 18 | FILETYPE VFT_DLL 19 | FILESUBTYPE 0 // not used 20 | BEGIN 21 | BLOCK "StringFileInfo" 22 | BEGIN 23 | BLOCK "040904E4" 24 | //language ID = U.S. English, char set = Windows, Multilingual 25 | BEGIN 26 | VALUE "FileDescription", "zlib data compression library\0" 27 | VALUE "FileVersion", ZLIB_VERSION "\0" 28 | VALUE "InternalName", "zlib1.dll\0" 29 | VALUE "LegalCopyright", "(C) 1995-2006 Jean-loup Gailly & Mark Adler\0" 30 | VALUE "OriginalFilename", "zlib1.dll\0" 31 | VALUE "ProductName", "zlib\0" 32 | VALUE "ProductVersion", ZLIB_VERSION "\0" 33 | VALUE "Comments", "For more information visit http://www.zlib.net/\0" 34 | END 35 | END 36 | BLOCK "VarFileInfo" 37 | BEGIN 38 | VALUE "Translation", 0x0409, 1252 39 | END 40 | END 41 | -------------------------------------------------------------------------------- /src/zlib/compress.c: -------------------------------------------------------------------------------- 1 | /* compress.c -- compress a memory buffer 2 | * Copyright (C) 1995-2005 Jean-loup Gailly. 3 | * For conditions of distribution and use, see copyright notice in zlib.h 4 | */ 5 | 6 | /* @(#) $Id$ */ 7 | 8 | #define ZLIB_INTERNAL 9 | #include "zlib.h" 10 | 11 | /* =========================================================================== 12 | Compresses the source buffer into the destination buffer. The level 13 | parameter has the same meaning as in deflateInit. sourceLen is the byte 14 | length of the source buffer. Upon entry, destLen is the total size of the 15 | destination buffer, which must be at least 0.1% larger than sourceLen plus 16 | 12 bytes. Upon exit, destLen is the actual size of the compressed buffer. 17 | 18 | compress2 returns Z_OK if success, Z_MEM_ERROR if there was not enough 19 | memory, Z_BUF_ERROR if there was not enough room in the output buffer, 20 | Z_STREAM_ERROR if the level parameter is invalid. 21 | */ 22 | int ZEXPORT compress2(dest, destLen, source, sourceLen, level) 23 | Bytef *dest; 24 | uLongf *destLen; 25 | const Bytef *source; 26 | uLong sourceLen; 27 | int level; 28 | { 29 | z_stream stream; 30 | int err; 31 | 32 | stream.next_in = (Bytef*)source; 33 | stream.avail_in = (uInt)sourceLen; 34 | #ifdef MAXSEG_64K 35 | /* Check for source > 64K on 16-bit machine: */ 36 | if((uLong)stream.avail_in != sourceLen) return Z_BUF_ERROR; 37 | #endif 38 | stream.next_out = dest; 39 | stream.avail_out = (uInt) * destLen; 40 | if((uLong)stream.avail_out != *destLen) return Z_BUF_ERROR; 41 | 42 | stream.zalloc = (alloc_func)0; 43 | stream.zfree = (free_func)0; 44 | stream.opaque = (voidpf)0; 45 | 46 | err = deflateInit(&stream, level); 47 | if(err != Z_OK) return err; 48 | 49 | err = deflate(&stream, Z_FINISH); 50 | if(err != Z_STREAM_END) 51 | { 52 | deflateEnd(&stream); 53 | return err == Z_OK ? Z_BUF_ERROR : err; 54 | } 55 | *destLen = stream.total_out; 56 | 57 | err = deflateEnd(&stream); 58 | return err; 59 | } 60 | 61 | /* =========================================================================== 62 | */ 63 | int ZEXPORT compress(dest, destLen, source, sourceLen) 64 | Bytef *dest; 65 | uLongf *destLen; 66 | const Bytef *source; 67 | uLong sourceLen; 68 | { 69 | return compress2(dest, destLen, source, sourceLen, Z_DEFAULT_COMPRESSION); 70 | } 71 | 72 | /* =========================================================================== 73 | If the default memLevel or windowBits for deflateInit() is changed, then 74 | this function needs to be updated. 75 | */ 76 | uLong ZEXPORT compressBound(sourceLen) 77 | uLong sourceLen; 78 | { 79 | return sourceLen + (sourceLen >> 12) + (sourceLen >> 14) + 80 | (sourceLen >> 25) + 13; 81 | } 82 | -------------------------------------------------------------------------------- /src/zlib/gzclose.c: -------------------------------------------------------------------------------- 1 | /* gzclose.c -- zlib gzclose() function 2 | * Copyright (C) 2004, 2010 Mark Adler 3 | * For conditions of distribution and use, see copyright notice in zlib.h 4 | */ 5 | 6 | #include "gzguts.h" 7 | 8 | /* gzclose() is in a separate file so that it is linked in only if it is used. 9 | That way the other gzclose functions can be used instead to avoid linking in 10 | unneeded compression or decompression routines. */ 11 | int ZEXPORT gzclose(file) 12 | gzFile file; 13 | { 14 | #ifndef NO_GZCOMPRESS 15 | gz_statep state; 16 | 17 | if(file == NULL) 18 | return Z_STREAM_ERROR; 19 | state = (gz_statep)file; 20 | 21 | return state->mode == GZ_READ ? gzclose_r(file) : gzclose_w(file); 22 | #else 23 | return gzclose_r(file); 24 | #endif 25 | } 26 | -------------------------------------------------------------------------------- /src/zlib/inffast.h: -------------------------------------------------------------------------------- 1 | /* inffast.h -- header to use inffast.c 2 | * Copyright (C) 1995-2003, 2010 Mark Adler 3 | * For conditions of distribution and use, see copyright notice in zlib.h 4 | */ 5 | 6 | /* WARNING: this file should *not* be used by applications. It is 7 | part of the implementation of the compression library and is 8 | subject to change. Applications should only use zlib.h. 9 | */ 10 | 11 | void ZLIB_INTERNAL inflate_fast OF((z_streamp strm, unsigned start)); 12 | -------------------------------------------------------------------------------- /src/zlib/inftrees.h: -------------------------------------------------------------------------------- 1 | /* inftrees.h -- header to use inftrees.c 2 | * Copyright (C) 1995-2005, 2010 Mark Adler 3 | * For conditions of distribution and use, see copyright notice in zlib.h 4 | */ 5 | 6 | /* WARNING: this file should *not* be used by applications. It is 7 | part of the implementation of the compression library and is 8 | subject to change. Applications should only use zlib.h. 9 | */ 10 | 11 | /* Structure for decoding tables. Each entry provides either the 12 | information needed to do the operation requested by the code that 13 | indexed that table entry, or it provides a pointer to another 14 | table that indexes more bits of the code. op indicates whether 15 | the entry is a pointer to another table, a literal, a length or 16 | distance, an end-of-block, or an invalid code. For a table 17 | pointer, the low four bits of op is the number of index bits of 18 | that table. For a length or distance, the low four bits of op 19 | is the number of extra bits to get after the code. bits is 20 | the number of bits in this code or part of the code to drop off 21 | of the bit buffer. val is the actual byte to output in the case 22 | of a literal, the base length or distance, or the offset from 23 | the current table to the next table. Each entry is four bytes. */ 24 | typedef struct 25 | { 26 | unsigned char op; /* operation, extra bits, table bits */ 27 | unsigned char bits; /* bits in this part of the code */ 28 | unsigned short val; /* offset in table or code value */ 29 | } code; 30 | 31 | /* op values as set by inflate_table(): 32 | 00000000 - literal 33 | 0000tttt - table link, tttt != 0 is the number of table index bits 34 | 0001eeee - length or distance, eeee is the number of extra bits 35 | 01100000 - end of block 36 | 01000000 - invalid code 37 | */ 38 | 39 | /* Maximum size of the dynamic table. The maximum number of code structures is 40 | 1444, which is the sum of 852 for literal/length codes and 592 for distance 41 | codes. These values were found by exhaustive searches using the program 42 | examples/enough.c found in the zlib distribtution. The arguments to that 43 | program are the number of symbols, the initial root table size, and the 44 | maximum bit length of a code. "enough 286 9 15" for literal/length codes 45 | returns returns 852, and "enough 30 6 15" for distance codes returns 592. 46 | The initial root table size (9 or 6) is found in the fifth argument of the 47 | inflate_table() calls in inflate.c and infback.c. If the root table size is 48 | changed, then these maximum sizes would be need to be recalculated and 49 | updated. */ 50 | #define ENOUGH_LENS 852 51 | #define ENOUGH_DISTS 592 52 | #define ENOUGH (ENOUGH_LENS+ENOUGH_DISTS) 53 | 54 | /* Type of code to build for inflate_table() */ 55 | typedef enum 56 | { 57 | CODES, 58 | LENS, 59 | DISTS 60 | } codetype; 61 | 62 | int ZLIB_INTERNAL inflate_table OF((codetype type, unsigned short FAR *lens, 63 | unsigned codes, code FAR * FAR *table, 64 | unsigned FAR *bits, unsigned short FAR *work)); 65 | -------------------------------------------------------------------------------- /src/zlib/uncompr.c: -------------------------------------------------------------------------------- 1 | /* uncompr.c -- decompress a memory buffer 2 | * Copyright (C) 1995-2003, 2010 Jean-loup Gailly. 3 | * For conditions of distribution and use, see copyright notice in zlib.h 4 | */ 5 | 6 | /* @(#) $Id$ */ 7 | 8 | #define ZLIB_INTERNAL 9 | #include "zlib.h" 10 | 11 | /* =========================================================================== 12 | Decompresses the source buffer into the destination buffer. sourceLen is 13 | the byte length of the source buffer. Upon entry, destLen is the total 14 | size of the destination buffer, which must be large enough to hold the 15 | entire uncompressed data. (The size of the uncompressed data must have 16 | been saved previously by the compressor and transmitted to the decompressor 17 | by some mechanism outside the scope of this compression library.) 18 | Upon exit, destLen is the actual size of the compressed buffer. 19 | 20 | uncompress returns Z_OK if success, Z_MEM_ERROR if there was not 21 | enough memory, Z_BUF_ERROR if there was not enough room in the output 22 | buffer, or Z_DATA_ERROR if the input data was corrupted. 23 | */ 24 | int ZEXPORT uncompress(dest, destLen, source, sourceLen) 25 | Bytef *dest; 26 | uLongf *destLen; 27 | const Bytef *source; 28 | uLong sourceLen; 29 | { 30 | z_stream stream; 31 | int err; 32 | 33 | stream.next_in = (Bytef*)source; 34 | stream.avail_in = (uInt)sourceLen; 35 | /* Check for source > 64K on 16-bit machine: */ 36 | if((uLong)stream.avail_in != sourceLen) return Z_BUF_ERROR; 37 | 38 | stream.next_out = dest; 39 | stream.avail_out = (uInt) * destLen; 40 | if((uLong)stream.avail_out != *destLen) return Z_BUF_ERROR; 41 | 42 | stream.zalloc = (alloc_func)0; 43 | stream.zfree = (free_func)0; 44 | 45 | err = inflateInit(&stream); 46 | if(err != Z_OK) return err; 47 | 48 | err = inflate(&stream, Z_FINISH); 49 | if(err != Z_STREAM_END) 50 | { 51 | inflateEnd(&stream); 52 | if(err == Z_NEED_DICT || (err == Z_BUF_ERROR && stream.avail_in == 0)) 53 | return Z_DATA_ERROR; 54 | return err; 55 | } 56 | *destLen = stream.total_out; 57 | 58 | err = inflateEnd(&stream); 59 | return err; 60 | } 61 | -------------------------------------------------------------------------------- /src/zlib/zlib.vcxproj.filters: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | {d440de28-26c6-4b36-b115-c53e50915ed2} 6 | cpp;c;cxx;rc;def;r;odl;hpj;bat;for;f90 7 | 8 | 9 | {290c62e2-9a87-41c2-842d-82cf066ae4e2} 10 | h;hpp;hxx;hm;inl;fi;fd 11 | 12 | 13 | {a89a87b0-6ffa-4994-a22a-332c22a033cd} 14 | ico;cur;bmp;dlg;rc2;rct;bin;cnt;rtf;gif;jpg;jpeg;jpe 15 | 16 | 17 | 18 | 19 | Source Files 20 | 21 | 22 | Source Files 23 | 24 | 25 | Source Files 26 | 27 | 28 | Source Files 29 | 30 | 31 | Source Files 32 | 33 | 34 | Source Files 35 | 36 | 37 | Source Files 38 | 39 | 40 | Source Files 41 | 42 | 43 | Source Files 44 | 45 | 46 | Source Files 47 | 48 | 49 | Source Files 50 | 51 | 52 | Source Files 53 | 54 | 55 | Source Files 56 | 57 | 58 | Source Files 59 | 60 | 61 | Source Files 62 | 63 | 64 | 65 | 66 | Header Files 67 | 68 | 69 | Header Files 70 | 71 | 72 | Header Files 73 | 74 | 75 | Header Files 76 | 77 | 78 | Header Files 79 | 80 | 81 | Header Files 82 | 83 | 84 | Header Files 85 | 86 | 87 | Header Files 88 | 89 | 90 | Header Files 91 | 92 | 93 | Header Files 94 | 95 | 96 | Header Files 97 | 98 | 99 | 100 | 101 | Resource Files 102 | 103 | 104 | -------------------------------------------------------------------------------- /vapoursynth/sdk/examples/filter_skeleton.c: -------------------------------------------------------------------------------- 1 | ////////////////////////////////////////// 2 | // This file contains a simple filter 3 | // skeleton you can use to get started. 4 | // With no changes it simply passes 5 | // frames through. 6 | 7 | #include "VapourSynth.h" 8 | #include "VSHelper.h" 9 | 10 | typedef struct { 11 | VSNodeRef *node; 12 | const VSVideoInfo *vi; 13 | } FilterData; 14 | 15 | static void VS_CC filterInit(VSMap *in, VSMap *out, void **instanceData, VSNode *node, VSCore *core, const VSAPI *vsapi) { 16 | FilterData *d = (FilterData *) * instanceData; 17 | vsapi->setVideoInfo(d->vi, 1, node); 18 | } 19 | 20 | static const VSFrameRef *VS_CC filterGetFrame(int n, int activationReason, void **instanceData, void **frameData, VSFrameContext *frameCtx, VSCore *core, const VSAPI *vsapi) { 21 | FilterData *d = (FilterData *) * instanceData; 22 | 23 | if (activationReason == arInitial) { 24 | vsapi->requestFrameFilter(n, d->node, frameCtx); 25 | } else if (activationReason == arAllFramesReady) { 26 | const VSFrameRef *frame = vsapi->getFrameFilter(n, d->node, frameCtx); 27 | 28 | // your code here... 29 | 30 | return frame; 31 | } 32 | 33 | return 0; 34 | } 35 | 36 | static void VS_CC filterFree(void *instanceData, VSCore *core, const VSAPI *vsapi) { 37 | FilterData *d = (FilterData *)instanceData; 38 | vsapi->freeNode(d->node); 39 | free(d); 40 | } 41 | 42 | static void VS_CC filterCreate(const VSMap *in, VSMap *out, void *userData, VSCore *core, const VSAPI *vsapi) { 43 | FilterData d; 44 | FilterData *data; 45 | 46 | d.node = vsapi->propGetNode(in, "clip", 0, 0); 47 | d.vi = vsapi->getVideoInfo(d.node); 48 | 49 | data = malloc(sizeof(d)); 50 | *data = d; 51 | 52 | vsapi->createFilter(in, out, "Filter", filterInit, filterGetFrame, filterFree, fmParallel, 0, data, core); 53 | } 54 | 55 | ////////////////////////////////////////// 56 | // Init 57 | 58 | VS_EXTERNAL_API(void) VapourSynthPluginInit(VSConfigPlugin configFunc, VSRegisterFunction registerFunc, VSPlugin *plugin) { 59 | configFunc("com.example.filter", "filter", "VapourSynth Filter Skeleton", VAPOURSYNTH_API_VERSION, 1, plugin); 60 | registerFunc("Filter", "clip:clip;", filterCreate, 0, plugin); 61 | } 62 | -------------------------------------------------------------------------------- /vapoursynth/sdk/include/vapoursynth/VSScript.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2013-2015 Fredrik Mellbin 3 | * 4 | * This file is part of VapourSynth. 5 | * 6 | * VapourSynth is free software; you can redistribute it and/or 7 | * modify it under the terms of the GNU Lesser General Public 8 | * License as published by the Free Software Foundation; either 9 | * version 2.1 of the License, or (at your option) any later version. 10 | * 11 | * VapourSynth is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 | * Lesser General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public 17 | * License along with VapourSynth; if not, write to the Free Software 18 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 19 | */ 20 | 21 | #ifndef VSSCRIPT_H 22 | #define VSSCRIPT_H 23 | 24 | #include "VapourSynth.h" 25 | 26 | typedef struct VSScript VSScript; 27 | 28 | typedef enum VSEvalFlags { 29 | efSetWorkingDir = 1, 30 | } VSEvalFlags; 31 | 32 | /* Initialize the available scripting runtimes, returns zero on failure */ 33 | VS_API(int) vsscript_init(void); 34 | 35 | /* Free all scripting runtimes */ 36 | VS_API(int) vsscript_finalize(void); 37 | 38 | /* 39 | * Pass a pointer to a null handle to create a new one 40 | * The values returned by the query functions are only valid during the lifetime of the VSScript 41 | * scriptFilename is if the error message should reference a certain file, NULL allowed in vsscript_evaluateScript() 42 | * core is to pass in an already created instance so that mixed environments can be used, 43 | * NULL creates a new core that can be fetched with vsscript_getCore() later OR implicitly uses the one associated with an already existing handle when passed 44 | * If efSetWorkingDir is passed to flags the current working directory will be changed to the path of the script 45 | * note that if scriptFilename is NULL in vsscript_evaluateScript() then __file__ won't be set and the working directory won't be changed 46 | * Set efSetWorkingDir to get the default and recommended behavior 47 | */ 48 | VS_API(int) vsscript_evaluateScript(VSScript **handle, const char *script, const char *scriptFilename, int flags); 49 | /* Convenience version of the above function that loads the script from a file */ 50 | VS_API(int) vsscript_evaluateFile(VSScript **handle, const char *scriptFilename, int flags); 51 | /* Create an empty environment for use in later invocations, mostly useful to set script variables before execution */ 52 | VS_API(int) vsscript_createScript(VSScript **handle); 53 | 54 | VS_API(void) vsscript_freeScript(VSScript *handle); 55 | VS_API(const char *) vsscript_getError(VSScript *handle); 56 | /* The node returned must be freed using freeNode() before calling vsscript_freeScript() */ 57 | VS_API(VSNodeRef *) vsscript_getOutput(VSScript *handle, int index); 58 | VS_API(int) vsscript_clearOutput(VSScript *handle, int index); 59 | /* The core is valid as long as the environment exists */ 60 | VS_API(VSCore *) vsscript_getCore(VSScript *handle); 61 | VS_API(const VSAPI *) vsscript_getVSApi(void); 62 | 63 | /* Variables names that are not set or not of a convertible type will return an error */ 64 | VS_API(int) vsscript_getVariable(VSScript *handle, const char *name, VSMap *dst); 65 | VS_API(int) vsscript_setVariable(VSScript *handle, const VSMap *vars); 66 | VS_API(int) vsscript_clearVariable(VSScript *handle, const char *name); 67 | /* Tries to clear everything set in an environment, normally it is better to simply free an environment completely and create a new one */ 68 | VS_API(void) vsscript_clearEnvironment(VSScript *handle); 69 | 70 | #endif /* VSSCRIPT_H */ 71 | -------------------------------------------------------------------------------- /vapoursynth/sdk/lib32/vapoursynth.lib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sorayuki/VSFilterMod/643b3def0970eb9dedaa5e6d9be6c3c492ce970d/vapoursynth/sdk/lib32/vapoursynth.lib -------------------------------------------------------------------------------- /vapoursynth/sdk/lib32/vsscript.lib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sorayuki/VSFilterMod/643b3def0970eb9dedaa5e6d9be6c3c492ce970d/vapoursynth/sdk/lib32/vsscript.lib -------------------------------------------------------------------------------- /vapoursynth/sdk/lib64/vapoursynth.lib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sorayuki/VSFilterMod/643b3def0970eb9dedaa5e6d9be6c3c492ce970d/vapoursynth/sdk/lib64/vapoursynth.lib -------------------------------------------------------------------------------- /vapoursynth/sdk/lib64/vsscript.lib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sorayuki/VSFilterMod/643b3def0970eb9dedaa5e6d9be6c3c492ce970d/vapoursynth/sdk/lib64/vsscript.lib --------------------------------------------------------------------------------