2 * Copyright (C) 2003-2006 Gabest
3 * http://www.gabest.org
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)
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.
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
25 #include "DirectVobSub.h"
26 #include "../BaseVideoFilter/BaseVideoFilter.h"
27 #include "../../../subtitles/VobSubFile.h"
28 #include "../../../subtitles/RTS.h"
29 #include "../../../subtitles/SSF.h"
30 #include "../../../subpic/ISimpleSubPic.h"
37 bool fRunOnce
, fShowIcon
;
40 /* This is for graphedit */
42 [uuid("93A22E7A-5091-45ef-BA61-6DA26156A5D0")]
43 class CDirectVobSubFilter
44 : public CBaseVideoFilter
45 , public CDirectVobSub
46 , public ISpecifyPropertyPages
47 , public IAMStreamSelect
50 friend class CTextInputPin
;
52 CCritSec m_csQueueLock
;
53 CComPtr
<ISimpleSubPicProvider
> m_simple_provider
;
55 void InitSubPicQueue();
58 bool AdjustFrameSize(CSize
& s
);
60 HRESULT
TryNotCopy( IMediaSample
* pIn
, const CMediaType
& mt
, const BITMAPINFOHEADER
& bihIn
);
62 CSimpleTextSubtitle::YCbCrMatrix m_script_selected_yuv
;
63 CSimpleTextSubtitle::YCbCrRange m_script_selected_range
;
66 void GetOutputSize(int& w
, int& h
, int& arx
, int& ary
);
67 HRESULT
Transform(IMediaSample
* pIn
);
68 HRESULT
GetIsEmbeddedSubStream(int iSelected
, bool *fIsEmbedded
);
70 CDirectVobSubFilter(LPUNKNOWN punk
, HRESULT
* phr
, const GUID
& clsid
= __uuidof(CDirectVobSubFilter
));
71 virtual ~CDirectVobSubFilter();
74 STDMETHODIMP
NonDelegatingQueryInterface(REFIID riid
, void** ppv
);
78 CBasePin
* GetPin(int n
);
81 STDMETHODIMP
JoinFilterGraph(IFilterGraph
* pGraph
, LPCWSTR pName
);
82 STDMETHODIMP
QueryFilterInfo(FILTER_INFO
* pInfo
);
85 HRESULT
SetMediaType(PIN_DIRECTION dir
, const CMediaType
* pMediaType
),
86 CheckConnect(PIN_DIRECTION dir
, IPin
* pPin
),
87 CompleteConnect(PIN_DIRECTION dir
, IPin
* pReceivePin
),
88 BreakConnect(PIN_DIRECTION dir
),
91 NewSegment(REFERENCE_TIME tStart
, REFERENCE_TIME tStop
, double dRate
);
93 CAtlArray
<CTextInputPin
*> m_pTextInput
;
96 void GetInputColorspaces(ColorSpaceId
*preferredOrder
, UINT
*count
);
97 void GetOutputColorspaces(ColorSpaceId
*preferredOrder
, UINT
*count
);
100 STDMETHODIMP
put_FileName(WCHAR
* fn
);
101 STDMETHODIMP
get_LanguageCount(int* nLangs
);
102 STDMETHODIMP
get_LanguageName(int iLanguage
, WCHAR
** ppName
);
103 STDMETHODIMP
put_SelectedLanguage(int iSelected
);
104 STDMETHODIMP
put_HideSubtitles(bool fHideSubtitles
);
105 STDMETHODIMP
put_PreBuffering(bool fDoPreBuffering
);
106 STDMETHODIMP
put_ColorSpace(int colorSpace
);
107 STDMETHODIMP
put_YuvRange(int yuvRange
);
108 STDMETHODIMP
put_Placement(bool fOverridePlacement
, int xperc
, int yperc
);
109 STDMETHODIMP
put_VobSubSettings(bool fBuffer
, bool fOnlyShowForcedSubs
, bool fPolygonize
);
110 STDMETHODIMP
put_TextSettings(void* lf
, int lflen
, COLORREF color
, bool fShadow
, bool fOutline
, bool fAdvancedRenderer
);
111 STDMETHODIMP
put_SubtitleTiming(int delay
, int speedmul
, int speeddiv
);
113 STDMETHODIMP
put_OverlayCacheMaxItemNum(int overlay_cache_max_item_num
);
114 STDMETHODIMP
put_ScanLineDataCacheMaxItemNum(int scan_line_data_cache_max_item_num
);
115 STDMETHODIMP
put_PathDataCacheMaxItemNum(int path_data_cache_max_item_num
);
116 STDMETHODIMP
put_OverlayNoBlurCacheMaxItemNum(int overlay_no_blur_cache_max_item_num
);
118 STDMETHODIMP
get_CachesInfo(CachesInfo
* caches_info
);
120 STDMETHODIMP
put_SubpixelPositionLevel(int subpixel_pos_level
);
122 STDMETHODIMP
put_FollowUpstreamPreferredOrder(bool fFollowUpstreamPreferredOrder
);
124 STDMETHODIMP
get_MediaFPS(bool* fEnabled
, double* fps
);
125 STDMETHODIMP
put_MediaFPS(bool fEnabled
, double fps
);
126 STDMETHODIMP
get_ZoomRect(NORMALIZEDRECT
* rect
);
127 STDMETHODIMP
put_ZoomRect(NORMALIZEDRECT
* rect
);
128 STDMETHODIMP
HasConfigDialog(int iSelected
);
129 STDMETHODIMP
ShowConfigDialog(int iSelected
, HWND hWndParent
);
132 STDMETHODIMP
put_TextSettings(STSStyle
* pDefStyle
);
133 STDMETHODIMP
put_AspectRatioSettings(CSimpleTextSubtitle::EPARCompensationType
* ePARCompensationType
);
135 // ISpecifyPropertyPages
136 STDMETHODIMP
GetPages(CAUUID
* pPages
);
139 STDMETHODIMP
Count(DWORD
* pcStreams
);
140 STDMETHODIMP
Enable(long lIndex
, DWORD dwFlags
);
141 STDMETHODIMP
Info(long lIndex
, AM_MEDIA_TYPE
** ppmt
, DWORD
* pdwFlags
, LCID
* plcid
, DWORD
* pdwGroup
, WCHAR
** ppszName
, IUnknown
** ppObject
, IUnknown
** ppUnk
);
144 STDMETHODIMP
GetClassID(CLSID
* pClsid
);
147 HRESULT
ChangeMediaType(int iPosition
);
152 void PrintMessages(BYTE
* pOut
);
155 CAutoVectorPtr
<BYTE
> m_pTempPicBuff
;
156 HRESULT
Copy(BYTE
* pSub
, BYTE
* pIn
, CSize sub
, CSize in
, int bpp
, const GUID
& subtype
, DWORD black
);
157 // segment start time, absolute time
159 REFERENCE_TIME
CalcCurrentTime();
163 // 3.x- versions of microsoft's mpeg4 codec output flipped image
166 // don't set the "hide subtitles" stream until we are finished with loading
171 int FindPreferedLanguage(bool fHideToo
= true);
172 void UpdatePreferedLanguages(CString lang
);
174 CCritSec m_csSubLock
;
176 CInterfaceList
<ISubStream
> m_pSubStreams
;
177 CAtlList
<bool> m_fIsSubStreamEmbeded
;
179 DWORD_PTR m_nSubtitleId
;
180 void UpdateSubtitle(bool fApplyDefStyle
= true);
181 void SetSubtitle(ISubStream
* pSubStream
, bool fApplyDefStyle
= true);
182 void InvalidateSubtitle(REFERENCE_TIME rtInvalidate
= -1, DWORD_PTR nSubtitleId
= -1);
184 // the text input pin is using these
185 void AddSubStream(ISubStream
* pSubStream
);
186 void RemoveSubStream(ISubStream
* pSubStream
);
187 void Post_EC_OLE_EVENT(CString str
, DWORD_PTR nSubtitleId
= -1);
190 class CFileReloaderData
193 ATL::CEvent EndThreadEvent
, RefreshEvent
;
194 CAtlList
<CString
> files
;
195 CAtlArray
<CTime
> mtime
;
198 void SetupFRD(CStringArray
& paths
, CAtlArray
<HANDLE
>& handles
);
202 HANDLE m_hSystrayThread
;
203 SystrayIconData m_tbid
;
205 VIDEOINFOHEADER2 m_CurrentVIH2
;
208 long m_time_rasterization
, m_time_alphablt
;
211 /* The "auto-loading" version */
213 [uuid("9852A670-F845-491b-9BE6-EBD841B8A613")]
214 class CDirectVobSubFilter2
: public CDirectVobSubFilter
216 bool ShouldWeAutoload(IFilterGraph
* pGraph
);
217 void GetRidOfInternalScriptRenderer();
220 CDirectVobSubFilter2(LPUNKNOWN punk
, HRESULT
* phr
, const GUID
& clsid
= __uuidof(CDirectVobSubFilter2
));
222 HRESULT
CheckConnect(PIN_DIRECTION dir
, IPin
* pPin
);
223 STDMETHODIMP
JoinFilterGraph(IFilterGraph
* pGraph
, LPCWSTR pName
);
224 HRESULT
CheckInputType(const CMediaType
* mtIn
);