Fix naming.
[xy_vsfilter.git] / src / filters / transform / vsfilter / DirectVobSub.cpp
bloba533266473d905f6354427303f1ac2f35cea7495
1 /*
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)
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.
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
22 #include "stdafx.h"
23 #include "DirectVobSub.h"
24 #include "VSFilter.h"
26 using namespace DirectVobSubXyOptions;
28 CDirectVobSub::CDirectVobSub()
30 AFX_MANAGE_STATE(AfxGetStaticModuleState());
32 BYTE* pData = NULL;
33 UINT nSize = 0;
35 m_supported_filter_verion = theApp.GetProfileInt(ResStr(IDS_R_GENERAL), ResStr(IDS_RG_SUPPORTED_VERSION), 0);
36 m_config_info_version = theApp.GetProfileInt(ResStr(IDS_R_GENERAL), ResStr(IDS_RG_VERSION), 0);
38 m_iSelectedLanguage = 0;
39 m_fHideSubtitles = !!theApp.GetProfileInt(ResStr(IDS_R_GENERAL), ResStr(IDS_RG_HIDE), 0);
40 m_fDoPreBuffering = !!theApp.GetProfileInt(ResStr(IDS_R_GENERAL), ResStr(IDS_RG_DOPREBUFFERING), 1);
42 m_xy_int_opt[INT_COLOR_SPACE] = GetCompatibleProfileInt(ResStr(IDS_R_GENERAL), ResStr(IDS_RG_COLOR_SPACE), CDirectVobSub::YuvMatrix_AUTO);
43 if( m_xy_int_opt[INT_COLOR_SPACE]!=CDirectVobSub::YuvMatrix_AUTO &&
44 m_xy_int_opt[INT_COLOR_SPACE]!=CDirectVobSub::BT_601 &&
45 m_xy_int_opt[INT_COLOR_SPACE]!=CDirectVobSub::BT_709 &&
46 m_xy_int_opt[INT_COLOR_SPACE]!=CDirectVobSub::GUESS)
48 m_xy_int_opt[INT_COLOR_SPACE] = CDirectVobSub::YuvMatrix_AUTO;
50 m_xy_int_opt[INT_YUV_RANGE] = GetCompatibleProfileInt(ResStr(IDS_R_GENERAL), ResStr(IDS_RG_YUV_RANGE), CDirectVobSub::YuvRange_Auto);
51 if( m_xy_int_opt[INT_YUV_RANGE]!=CDirectVobSub::YuvRange_Auto &&
52 m_xy_int_opt[INT_YUV_RANGE]!=CDirectVobSub::YuvRange_PC &&
53 m_xy_int_opt[INT_YUV_RANGE]!=CDirectVobSub::YuvRange_TV )
55 m_xy_int_opt[INT_YUV_RANGE] = CDirectVobSub::YuvRange_Auto;
58 m_bt601Width = theApp.GetProfileInt(ResStr(IDS_R_GENERAL), ResStr(IDS_RG_BT601_WIDTH), 1024);
59 m_bt601Height = theApp.GetProfileInt(ResStr(IDS_R_GENERAL), ResStr(IDS_RG_BT601_HEIGHT), 600);
61 m_fOverridePlacement = !!theApp.GetProfileInt(ResStr(IDS_R_TEXT), ResStr(IDS_RT_OVERRIDEPLACEMENT), 0);
62 m_PlacementXperc = theApp.GetProfileInt(ResStr(IDS_R_TEXT), ResStr(IDS_RT_XPERC), 50);
63 m_PlacementYperc = theApp.GetProfileInt(ResStr(IDS_R_TEXT), ResStr(IDS_RT_YPERC), 90);
64 m_fBufferVobSub = !!theApp.GetProfileInt(ResStr(IDS_R_VOBSUB), ResStr(IDS_RV_BUFFER), 1);
65 m_fOnlyShowForcedVobSubs = !!theApp.GetProfileInt(ResStr(IDS_R_VOBSUB), ResStr(IDS_RV_ONLYSHOWFORCEDSUBS), 0);
66 m_fPolygonize = !!theApp.GetProfileInt(ResStr(IDS_R_VOBSUB), ResStr(IDS_RV_POLYGONIZE), 0);
67 m_defStyle <<= theApp.GetProfileString(ResStr(IDS_R_TEXT), ResStr(IDS_RT_STYLE), _T(""));
68 m_fFlipPicture = !!theApp.GetProfileInt(ResStr(IDS_R_GENERAL), ResStr(IDS_RG_FLIPPICTURE), 0);
69 m_fFlipSubtitles = !!theApp.GetProfileInt(ResStr(IDS_R_GENERAL), ResStr(IDS_RG_FLIPSUBTITLES), 0);
70 m_fOSD = !!theApp.GetProfileInt(ResStr(IDS_R_GENERAL), ResStr(IDS_RG_SHOWOSDSTATS), 0);
71 m_fSaveFullPath = !!theApp.GetProfileInt(ResStr(IDS_R_GENERAL), ResStr(IDS_RG_SAVEFULLPATH), 0);
72 m_nReloaderDisableCount = !!theApp.GetProfileInt(ResStr(IDS_R_GENERAL), ResStr(IDS_RG_DISABLERELOADER), 0) ? 1 : 0;
73 m_SubtitleDelay = theApp.GetProfileInt(ResStr(IDS_R_TIMING), ResStr(IDS_RTM_SUBTITLEDELAY), 0);
74 m_SubtitleSpeedMul = theApp.GetProfileInt(ResStr(IDS_R_TIMING), ResStr(IDS_RTM_SUBTITLESPEEDMUL), 1000);
75 m_SubtitleSpeedDiv = theApp.GetProfileInt(ResStr(IDS_R_TIMING), ResStr(IDS_RTM_SUBTITLESPEEDDIV), 1000);
76 m_fMediaFPSEnabled = !!theApp.GetProfileInt(ResStr(IDS_R_TIMING), ResStr(IDS_RTM_MEDIAFPSENABLED), 0);
77 m_ePARCompensationType = static_cast<CSimpleTextSubtitle::EPARCompensationType>(theApp.GetProfileInt(ResStr(IDS_R_TEXT), ResStr(IDS_RT_AUTOPARCOMPENSATION), 0));
78 m_xy_bool_opt[BOOL_HIDE_TRAY_ICON] = !!theApp.GetProfileInt(ResStr(IDS_R_GENERAL), ResStr(IDS_RG_HIDE_TRAY_ICON), 0);
80 m_xy_int_opt[INT_OVERLAY_CACHE_MAX_ITEM_NUM] = theApp.GetProfileInt(ResStr(IDS_R_PERFORMANCE), ResStr(IDS_RP_OVERLAY_CACHE_MAX_ITEM_NUM)
81 , CacheManager::OVERLAY_CACHE_ITEM_NUM);
82 if(m_xy_int_opt[INT_OVERLAY_CACHE_MAX_ITEM_NUM]<0) m_xy_int_opt[INT_OVERLAY_CACHE_MAX_ITEM_NUM] = 0;
84 m_xy_int_opt[INT_OVERLAY_NO_BLUR_CACHE_MAX_ITEM_NUM] = theApp.GetProfileInt(ResStr(IDS_R_PERFORMANCE), ResStr(IDS_RP_OVERLAY_NO_BLUR_CACHE_MAX_ITEM_NUM)
85 , CacheManager::OVERLAY_NO_BLUR_CACHE_ITEM_NUM);
86 if(m_xy_int_opt[INT_OVERLAY_NO_BLUR_CACHE_MAX_ITEM_NUM]<0) m_xy_int_opt[INT_OVERLAY_NO_BLUR_CACHE_MAX_ITEM_NUM] = 0;
88 m_xy_int_opt[INT_SCAN_LINE_DATA_CACHE_MAX_ITEM_NUM] = theApp.GetProfileInt(ResStr(IDS_R_PERFORMANCE), ResStr(IDS_RP_SCAN_LINE_DATA_CACHE_MAX_ITEM_NUM)
89 , CacheManager::SCAN_LINE_DATA_CACHE_ITEM_NUM);
90 if(m_xy_int_opt[INT_SCAN_LINE_DATA_CACHE_MAX_ITEM_NUM]<0) m_xy_int_opt[INT_SCAN_LINE_DATA_CACHE_MAX_ITEM_NUM] = 0;
92 m_xy_int_opt[INT_PATH_DATA_CACHE_MAX_ITEM_NUM] = theApp.GetProfileInt(ResStr(IDS_R_PERFORMANCE), ResStr(IDS_RP_PATH_DATA_CACHE_MAX_ITEM_NUM)
93 , CacheManager::PATH_CACHE_ITEM_NUM);
94 if(m_xy_int_opt[INT_PATH_DATA_CACHE_MAX_ITEM_NUM]<0) m_xy_int_opt[INT_PATH_DATA_CACHE_MAX_ITEM_NUM] = 0;
96 m_xy_int_opt[INT_BITMAP_MRU_CACHE_ITEM_NUM] = theApp.GetProfileInt(ResStr(IDS_R_PERFORMANCE), ResStr(IDS_RP_BITMAP_MRU_CACHE_ITEM_NUM)
97 , CacheManager::BITMAP_MRU_CACHE_ITEM_NUM);
98 if(m_xy_int_opt[INT_BITMAP_MRU_CACHE_ITEM_NUM]<0) m_xy_int_opt[INT_BITMAP_MRU_CACHE_ITEM_NUM] = 0;
100 m_xy_int_opt[INT_CLIPPER_MRU_CACHE_ITEM_NUM] = theApp.GetProfileInt(ResStr(IDS_R_PERFORMANCE), ResStr(IDS_RP_CLIPPER_MRU_CACHE_ITEM_NUM)
101 , CacheManager::CLIPPER_MRU_CACHE_ITEM_NUM);
102 if(m_xy_int_opt[INT_CLIPPER_MRU_CACHE_ITEM_NUM]<0) m_xy_int_opt[INT_CLIPPER_MRU_CACHE_ITEM_NUM] = 0;
104 m_xy_int_opt[INT_TEXT_INFO_CACHE_ITEM_NUM] = theApp.GetProfileInt(ResStr(IDS_R_PERFORMANCE), ResStr(IDS_RP_TEXT_INFO_CACHE_ITEM_NUM)
105 , CacheManager::TEXT_INFO_CACHE_ITEM_NUM);
106 if(m_xy_int_opt[INT_TEXT_INFO_CACHE_ITEM_NUM]<0) m_xy_int_opt[INT_TEXT_INFO_CACHE_ITEM_NUM] = 0;
108 m_xy_int_opt[INT_ASS_TAG_LIST_CACHE_ITEM_NUM] = theApp.GetProfileInt(ResStr(IDS_R_PERFORMANCE), ResStr(IDS_RP_ASS_TAG_LIST_CACHE_ITEM_NUM)
109 , CacheManager::ASS_TAG_LIST_CACHE_ITEM_NUM);
110 if(m_xy_int_opt[INT_ASS_TAG_LIST_CACHE_ITEM_NUM]<0) m_xy_int_opt[INT_ASS_TAG_LIST_CACHE_ITEM_NUM] = 0;
112 m_xy_int_opt[INT_SUBPIXEL_POS_LEVEL] = theApp.GetProfileInt(ResStr(IDS_R_PERFORMANCE), ResStr(IDS_RP_SUBPIXEL_POS_LEVEL), SubpixelPositionControler::EIGHT_X_EIGHT);
113 if(m_xy_int_opt[INT_SUBPIXEL_POS_LEVEL]<0) m_xy_int_opt[INT_SUBPIXEL_POS_LEVEL]=0;
114 else if(m_xy_int_opt[INT_SUBPIXEL_POS_LEVEL]>=SubpixelPositionControler::MAX_COUNT) m_xy_int_opt[INT_SUBPIXEL_POS_LEVEL]=SubpixelPositionControler::EIGHT_X_EIGHT;
116 m_xy_int_opt[INT_LAYOUT_SIZE_OPT] = theApp.GetProfileInt(ResStr(IDS_R_GENERAL), ResStr(IDS_RG_LAYOUT_SIZE_OPT), LAYOUT_SIZE_OPT_FOLLOW_ORIGINAL_VIDEO_SIZE);
117 switch(m_xy_int_opt[INT_LAYOUT_SIZE_OPT])
119 case LAYOUT_SIZE_OPT_FOLLOW_ORIGINAL_VIDEO_SIZE:
120 case LAYOUT_SIZE_OPT_USER_SPECIFIED:
121 break;
122 default:
123 m_xy_int_opt[INT_LAYOUT_SIZE_OPT] = LAYOUT_SIZE_OPT_FOLLOW_ORIGINAL_VIDEO_SIZE;
124 break;
127 m_xy_size_opt[SIZE_USER_SPECIFIED_LAYOUT_SIZE].cx = theApp.GetProfileInt(ResStr(IDS_R_GENERAL), ResStr(IDS_RG_USER_SPECIFIED_LAYOUT_SIZE_X), 0);
128 m_xy_size_opt[SIZE_USER_SPECIFIED_LAYOUT_SIZE].cy = theApp.GetProfileInt(ResStr(IDS_R_GENERAL), ResStr(IDS_RG_USER_SPECIFIED_LAYOUT_SIZE_Y), 0);
129 if (m_xy_size_opt[SIZE_USER_SPECIFIED_LAYOUT_SIZE].cx<=0 || m_xy_size_opt[SIZE_USER_SPECIFIED_LAYOUT_SIZE].cy<=0)
131 m_xy_size_opt[SIZE_USER_SPECIFIED_LAYOUT_SIZE].cx = 1280;
132 m_xy_size_opt[SIZE_USER_SPECIFIED_LAYOUT_SIZE].cy = 720;
135 m_xy_size_opt[SIZE_ASS_PLAY_RESOLUTION] = CSize(0,0);
136 m_xy_size_opt[SIZE_ORIGINAL_VIDEO] = CSize(0,0);
138 m_xy_bool_opt[BOOL_FOLLOW_UPSTREAM_PREFERRED_ORDER] = !!theApp.GetProfileInt(ResStr(IDS_R_GENERAL), ResStr(IDS_RG_USE_UPSTREAM_PREFERRED_ORDER), true);
139 // get output colorspace config
140 if(pData)
142 delete [] pData;
143 pData = NULL;
145 if(theApp.GetProfileBinary(ResStr(IDS_R_GENERAL), ResStr(IDS_RG_OUTPUT_COLORFORMATS), &pData, &nSize)
146 && pData && nSize == 2*GetOutputColorSpaceNumber())
148 for (unsigned i=0;i<nSize/2;i++)
150 m_outputColorSpace[i].color_space = static_cast<ColorSpaceId>(pData[2*i]);
151 m_outputColorSpace[i].selected = !!pData[2*i+1];
154 else
156 for (unsigned i=0;i<GetOutputColorSpaceNumber();i++)
158 m_outputColorSpace[i].color_space = static_cast<ColorSpaceId>(i);
159 m_outputColorSpace[i].selected = true;
163 // get input colorspace config
164 if(pData)
166 delete [] pData;
167 pData = NULL;
169 if(theApp.GetProfileBinary(ResStr(IDS_R_GENERAL), ResStr(IDS_RG_INPUT_COLORFORMATS), &pData, &nSize)
170 && pData && nSize == 2*GetInputColorSpaceNumber())
172 for (unsigned i=0;i<nSize/2;i++)
174 m_inputColorSpace[i].color_space = static_cast<ColorSpaceId>(pData[2*i]);
175 m_inputColorSpace[i].selected = !!pData[2*i+1];
178 else
180 for (unsigned i=0;i<GetOutputColorSpaceNumber();i++)
182 m_inputColorSpace[i].color_space = static_cast<ColorSpaceId>(i);
183 m_inputColorSpace[i].selected = true;
188 if(pData)
190 delete [] pData;
191 pData = NULL;
193 if(theApp.GetProfileBinary(ResStr(IDS_R_TIMING), ResStr(IDS_RTM_MEDIAFPS), &pData, &nSize) && pData)
195 if(nSize != sizeof(m_MediaFPS)) m_MediaFPS = 25.0;
196 else memcpy(&m_MediaFPS, pData, sizeof(m_MediaFPS));
198 m_ZoomRect.left = m_ZoomRect.top = 0;
199 m_ZoomRect.right = m_ZoomRect.bottom = 1;
201 m_fForced = false;
202 if(pData)
204 delete [] pData;
205 pData = NULL;
209 CDirectVobSub::~CDirectVobSub()
211 CAutoLock cAutoLock(&m_propsLock);
214 STDMETHODIMP CDirectVobSub::get_FileName(WCHAR* fn)
216 CAutoLock cAutoLock(&m_propsLock);
218 if(!fn) return E_POINTER;
220 #ifdef UNICODE
221 wcscpy(fn, m_FileName);
222 #else
223 mbstowcs(fn, m_FileName, m_FileName.GetLength()+1);
224 #endif
226 return S_OK;
229 STDMETHODIMP CDirectVobSub::put_FileName(WCHAR* fn)
231 CAutoLock cAutoLock(&m_propsLock);
233 if(!fn) return E_POINTER;
235 CString tmp = fn;
236 if(!m_FileName.Left(m_FileName.ReverseFind('.')+1).CompareNoCase(tmp.Left(tmp.ReverseFind('.')+1))) return S_FALSE;
238 #ifdef UNICODE
239 m_FileName = fn;
240 #else
241 CHARSETINFO cs={0};
242 ::TranslateCharsetInfo((DWORD *)DEFAULT_CHARSET, &cs, TCI_SRCCHARSET);
243 CHAR* buff = m_FileName.GetBuffer(MAX_PATH*2);
244 int len = WideCharToMultiByte(cs.ciACP/*CP_OEMCP*/, NULL, fn, -1, buff, MAX_PATH*2, NULL, NULL);
245 m_FileName.ReleaseBuffer(len+1);
246 #endif
248 return S_OK;
251 STDMETHODIMP CDirectVobSub::get_LanguageCount(int* nLangs)
253 CAutoLock cAutoLock(&m_propsLock);
255 return nLangs ? *nLangs = 0, S_OK : E_POINTER;
258 STDMETHODIMP CDirectVobSub::get_LanguageName(int iLanguage, WCHAR** ppName)
260 return S_OK;
263 STDMETHODIMP CDirectVobSub::get_SelectedLanguage(int* iSelected)
265 CAutoLock cAutoLock(&m_propsLock);
267 return iSelected ? *iSelected = m_iSelectedLanguage, S_OK : E_POINTER;
270 STDMETHODIMP CDirectVobSub::put_SelectedLanguage(int iSelected)
272 CAutoLock cAutoLock(&m_propsLock);
274 if(m_iSelectedLanguage == iSelected) return S_FALSE;
276 int nCount;
277 if(FAILED(get_LanguageCount(&nCount))
278 || iSelected < 0
279 || iSelected >= nCount)
280 return E_FAIL;
282 m_iSelectedLanguage = iSelected;
284 return S_OK;
287 STDMETHODIMP CDirectVobSub::get_HideSubtitles(bool* fHideSubtitles)
289 CAutoLock cAutoLock(&m_propsLock);
291 return fHideSubtitles ? *fHideSubtitles = m_fHideSubtitles, S_OK : E_POINTER;
294 STDMETHODIMP CDirectVobSub::put_HideSubtitles(bool fHideSubtitles)
296 CAutoLock cAutoLock(&m_propsLock);
298 if(m_fHideSubtitles == fHideSubtitles) return S_FALSE;
300 m_fHideSubtitles = fHideSubtitles;
302 return S_OK;
305 STDMETHODIMP CDirectVobSub::get_PreBuffering(bool* fDoPreBuffering)
307 CAutoLock cAutoLock(&m_propsLock);
309 //return fDoPreBuffering ? *fDoPreBuffering = m_fDoPreBuffering, S_OK : E_POINTER;
310 return fDoPreBuffering ? *fDoPreBuffering = false, S_OK : E_POINTER;
313 STDMETHODIMP CDirectVobSub::put_PreBuffering(bool fDoPreBuffering)
315 return E_NOTIMPL;
316 //CAutoLock cAutoLock(&m_propsLock);
318 //if(m_fDoPreBuffering == fDoPreBuffering) return S_FALSE;
320 //m_fDoPreBuffering = fDoPreBuffering;
322 //return S_OK;
326 STDMETHODIMP CDirectVobSub::get_Placement(bool* fOverridePlacement, int* xperc, int* yperc)
328 CAutoLock cAutoLock(&m_propsLock);
330 if(fOverridePlacement) *fOverridePlacement = m_fOverridePlacement;
331 if(xperc) *xperc = m_PlacementXperc;
332 if(yperc) *yperc = m_PlacementYperc;
334 return S_OK;
337 STDMETHODIMP CDirectVobSub::put_Placement(bool fOverridePlacement, int xperc, int yperc)
339 DbgLog((LOG_TRACE, 3, "%s(%d): %s", __FILE__, __LINE__, __FUNCTION__));
340 CAutoLock cAutoLock(&m_propsLock);
342 DbgLog((LOG_TRACE, 3, "\tfOverridePlacement:%d xperc:%d yperc:%d", (int)fOverridePlacement, xperc, yperc));
343 DbgLog((LOG_TRACE, 3, "\tm_fOverridePlacement:%d m_PlacementXperc:%d m_PlacementYperc:%d", (int)m_fOverridePlacement, m_PlacementXperc, m_PlacementYperc));
344 if(m_fOverridePlacement == fOverridePlacement && m_PlacementXperc == xperc && m_PlacementYperc == yperc) return S_FALSE;
346 m_fOverridePlacement = fOverridePlacement;
347 m_PlacementXperc = xperc;
348 m_PlacementYperc = yperc;
350 return S_OK;
353 STDMETHODIMP CDirectVobSub::get_VobSubSettings(bool* fBuffer, bool* fOnlyShowForcedSubs, bool* fPolygonize)
355 CAutoLock cAutoLock(&m_propsLock);
357 if(fBuffer) *fBuffer = m_fBufferVobSub;
358 if(fOnlyShowForcedSubs) *fOnlyShowForcedSubs = m_fOnlyShowForcedVobSubs;
359 if(fPolygonize) *fPolygonize = m_fPolygonize;
361 return S_OK;
364 STDMETHODIMP CDirectVobSub::put_VobSubSettings(bool fBuffer, bool fOnlyShowForcedSubs, bool fPolygonize)
366 CAutoLock cAutoLock(&m_propsLock);
368 if(m_fBufferVobSub == fBuffer && m_fOnlyShowForcedVobSubs == fOnlyShowForcedSubs && m_fPolygonize == fPolygonize) return S_FALSE;
370 m_fBufferVobSub = fBuffer;
371 m_fOnlyShowForcedVobSubs = fOnlyShowForcedSubs;
372 m_fPolygonize = fPolygonize;
374 return S_OK;
377 STDMETHODIMP CDirectVobSub::get_TextSettings(void* lf, int lflen, COLORREF* color, bool* fShadow, bool* fOutline, bool* fAdvancedRenderer)
379 CAutoLock cAutoLock(&m_propsLock);
381 if(lf)
383 if(lflen == sizeof(LOGFONTA))
384 strncpy_s(((LOGFONTA*)lf)->lfFaceName, LF_FACESIZE, CStringA(m_defStyle.fontName), _TRUNCATE);
385 else if(lflen == sizeof(LOGFONTW))
386 wcsncpy_s(((LOGFONTW*)lf)->lfFaceName, LF_FACESIZE, CStringW(m_defStyle.fontName), _TRUNCATE);
387 else
388 return E_INVALIDARG;
390 ((LOGFONT*)lf)->lfCharSet = m_defStyle.charSet;
391 ((LOGFONT*)lf)->lfItalic = m_defStyle.fItalic;
392 ((LOGFONT*)lf)->lfHeight = m_defStyle.fontSize;
393 ((LOGFONT*)lf)->lfWeight = m_defStyle.fontWeight;
394 ((LOGFONT*)lf)->lfStrikeOut = m_defStyle.fStrikeOut;
395 ((LOGFONT*)lf)->lfUnderline = m_defStyle.fUnderline;
398 if(color) *color = m_defStyle.colors[0];
399 if(fShadow) *fShadow = (m_defStyle.shadowDepthX>0) || (m_defStyle.shadowDepthY>0);
400 if(fOutline) *fOutline = (m_defStyle.outlineWidthX>0) || (m_defStyle.outlineWidthY>0);
401 if(fAdvancedRenderer) *fAdvancedRenderer = m_fAdvancedRenderer;
403 return S_OK;
406 STDMETHODIMP CDirectVobSub::put_TextSettings(void* lf, int lflen, COLORREF color, bool fShadow, bool fOutline, bool fAdvancedRenderer)
408 CAutoLock cAutoLock(&m_propsLock);
409 STSStyle tmp = m_defStyle;
410 if(lf)
412 if(lflen == sizeof(LOGFONTA))
413 tmp.fontName = ((LOGFONTA*)lf)->lfFaceName;
414 else if(lflen == sizeof(LOGFONTW))
415 tmp.fontName = ((LOGFONTW*)lf)->lfFaceName;
416 else
417 return E_INVALIDARG;
419 tmp.charSet = ((LOGFONT*)lf)->lfCharSet;
420 tmp.fItalic = !!((LOGFONT*)lf)->lfItalic;
421 tmp.fontSize = ((LOGFONT*)lf)->lfHeight;
422 tmp.fontWeight = ((LOGFONT*)lf)->lfWeight;
423 tmp.fStrikeOut = !!((LOGFONT*)lf)->lfStrikeOut;
424 tmp.fUnderline = !!((LOGFONT*)lf)->lfUnderline;
426 if(tmp.fontSize < 0)
428 HDC hdc = ::GetDC(0);
429 m_defStyle.fontSize = -m_defStyle.fontSize * 72 / GetDeviceCaps(hdc, LOGPIXELSY);
430 ::ReleaseDC(0, hdc);
435 tmp.colors[0] = color;
436 tmp.shadowDepthX = tmp.shadowDepthY = fShadow?2:0;
437 tmp.outlineWidthX = tmp.outlineWidthY = fOutline?2:0;
439 if(tmp==m_defStyle)
441 return S_FALSE;//Important! Avoid unnecessary deinit
443 else
445 m_defStyle = tmp;
446 return S_OK;
451 STDMETHODIMP CDirectVobSub::get_Flip(bool* fPicture, bool* fSubtitles)
453 CAutoLock cAutoLock(&m_propsLock);
455 if(fPicture) *fPicture = m_fFlipPicture;
456 if(fSubtitles) *fSubtitles = m_fFlipSubtitles;
458 return S_OK;
461 STDMETHODIMP CDirectVobSub::put_Flip(bool fPicture, bool fSubtitles)
463 CAutoLock cAutoLock(&m_propsLock);
465 if(m_fFlipPicture == fPicture && m_fFlipSubtitles == fSubtitles) return S_FALSE;
467 m_fFlipPicture = fPicture;
468 m_fFlipSubtitles = fSubtitles;
470 return S_OK;
473 STDMETHODIMP CDirectVobSub::get_OSD(bool* fOSD)
475 CAutoLock cAutoLock(&m_propsLock);
477 return fOSD ? *fOSD = m_fOSD, S_OK : E_POINTER;
480 STDMETHODIMP CDirectVobSub::put_OSD(bool fOSD)
482 CAutoLock cAutoLock(&m_propsLock);
484 if(m_fOSD == fOSD) return S_FALSE;
486 m_fOSD = fOSD;
488 return S_OK;
491 STDMETHODIMP CDirectVobSub::get_SaveFullPath(bool* fSaveFullPath)
493 CAutoLock cAutoLock(&m_propsLock);
495 return fSaveFullPath ? *fSaveFullPath = m_fSaveFullPath, S_OK : E_POINTER;
498 STDMETHODIMP CDirectVobSub::put_SaveFullPath(bool fSaveFullPath)
500 CAutoLock cAutoLock(&m_propsLock);
502 if(m_fSaveFullPath == fSaveFullPath) return S_FALSE;
504 m_fSaveFullPath = fSaveFullPath;
506 return S_OK;
509 STDMETHODIMP CDirectVobSub::get_SubtitleTiming(int* delay, int* speedmul, int* speeddiv)
511 CAutoLock cAutoLock(&m_propsLock);
513 if(delay) *delay = m_SubtitleDelay;
514 if(speedmul) *speedmul = m_SubtitleSpeedMul;
515 if(speeddiv) *speeddiv = m_SubtitleSpeedDiv;
517 return S_OK;
520 STDMETHODIMP CDirectVobSub::put_SubtitleTiming(int delay, int speedmul, int speeddiv)
522 CAutoLock cAutoLock(&m_propsLock);
524 if(m_SubtitleDelay == delay && m_SubtitleSpeedMul == speedmul && m_SubtitleSpeedDiv == speeddiv) return S_FALSE;
526 m_SubtitleDelay = delay;
527 m_SubtitleSpeedMul = speedmul;
528 if(speeddiv > 0) m_SubtitleSpeedDiv = speeddiv;
530 return S_OK;
533 STDMETHODIMP CDirectVobSub::get_MediaFPS(bool* fEnabled, double* fps)
535 CAutoLock cAutoLock(&m_propsLock);
537 if(fEnabled) *fEnabled = m_fMediaFPSEnabled;
538 if(fps) *fps = m_MediaFPS;
540 return S_OK;
543 STDMETHODIMP CDirectVobSub::put_MediaFPS(bool fEnabled, double fps)
545 CAutoLock cAutoLock(&m_propsLock);
547 if(m_fMediaFPSEnabled == fEnabled && m_MediaFPS == fps) return S_FALSE;
549 m_fMediaFPSEnabled = fEnabled;
550 if(fps > 0) m_MediaFPS = fps;
552 return S_OK;
555 STDMETHODIMP CDirectVobSub::get_ZoomRect(NORMALIZEDRECT* rect)
557 CAutoLock cAutoLock(&m_propsLock);
559 if(!rect) return E_POINTER;
561 *rect = m_ZoomRect;
563 return S_OK;
566 STDMETHODIMP CDirectVobSub::put_ZoomRect(NORMALIZEDRECT* rect)
568 CAutoLock cAutoLock(&m_propsLock);
570 if(!rect) return E_POINTER;
572 if(!memcmp(&m_ZoomRect, rect, sizeof(m_ZoomRect))) return S_FALSE;
574 m_ZoomRect = *rect;
576 return S_OK;
579 STDMETHODIMP CDirectVobSub::get_CachesInfo(CachesInfo* caches_info)
581 CAutoLock cAutoLock(&m_propsLock);
582 if(caches_info)
584 caches_info->path_cache_cur_item_num = 0;
585 caches_info->path_cache_hit_count = 0;
586 caches_info->path_cache_query_count = 0;
587 caches_info->scanline_cache2_cur_item_num= 0;
588 caches_info->scanline_cache2_hit_count = 0;
589 caches_info->scanline_cache2_query_count = 0;
590 caches_info->non_blur_cache_cur_item_num= 0;
591 caches_info->non_blur_cache_hit_count = 0;
592 caches_info->non_blur_cache_query_count = 0;
593 caches_info->overlay_cache_cur_item_num = 0;
594 caches_info->overlay_cache_hit_count = 0;
595 caches_info->overlay_cache_query_count = 0;
596 caches_info->interpolate_cache_cur_item_num = 0;
597 caches_info->interpolate_cache_query_count = 0;
598 caches_info->interpolate_cache_hit_count = 0;
599 caches_info->text_info_cache_cur_item_num = 0;
600 caches_info->text_info_cache_query_count = 0;
601 caches_info->text_info_cache_hit_count = 0;
602 caches_info->word_info_cache_cur_item_num = 0;
603 caches_info->word_info_cache_query_count = 0;
604 caches_info->word_info_cache_hit_count = 0;
605 return S_OK;
607 else
609 return S_FALSE;
613 STDMETHODIMP CDirectVobSub::get_XyFlyWeightInfo(XyFlyWeightInfo* xy_fw_info)
615 CAutoLock cAutoLock(&m_propsLock);
616 if(xy_fw_info)
618 xy_fw_info->xy_fw_string_w.cur_item_num = 0;
619 xy_fw_info->xy_fw_string_w.hit_count = 0;
620 xy_fw_info->xy_fw_string_w.query_count = 0;
622 xy_fw_info->xy_fw_grouped_draw_items_hash_key.cur_item_num = 0;
623 xy_fw_info->xy_fw_grouped_draw_items_hash_key.hit_count = 0;
624 xy_fw_info->xy_fw_grouped_draw_items_hash_key.query_count = 0;
626 return S_OK;
628 return S_FALSE;
631 STDMETHODIMP CDirectVobSub::UpdateRegistry()
633 AFX_MANAGE_STATE(AfxGetStaticModuleState());
635 CAutoLock cAutoLock(&m_propsLock);
637 theApp.WriteProfileInt(ResStr(IDS_R_GENERAL), ResStr(IDS_RG_HIDE), m_fHideSubtitles);
638 theApp.WriteProfileInt(ResStr(IDS_R_GENERAL), ResStr(IDS_RG_DOPREBUFFERING), m_fDoPreBuffering);
640 theApp.WriteProfileInt(ResStr(IDS_R_GENERAL), ResStr(IDS_RG_YUV_RANGE), m_xy_int_opt[INT_YUV_RANGE]);
642 theApp.WriteProfileInt(ResStr(IDS_R_GENERAL), ResStr(IDS_RG_COLOR_SPACE), m_xy_int_opt[INT_COLOR_SPACE]);
643 theApp.WriteProfileInt(ResStr(IDS_R_GENERAL), ResStr(IDS_RG_BT601_WIDTH), 1024);
644 theApp.WriteProfileInt(ResStr(IDS_R_GENERAL), ResStr(IDS_RG_BT601_HEIGHT), 600);
646 theApp.WriteProfileInt(ResStr(IDS_R_TEXT), ResStr(IDS_RT_OVERRIDEPLACEMENT), m_fOverridePlacement);
647 theApp.WriteProfileInt(ResStr(IDS_R_TEXT), ResStr(IDS_RT_XPERC), m_PlacementXperc);
648 theApp.WriteProfileInt(ResStr(IDS_R_TEXT), ResStr(IDS_RT_YPERC), m_PlacementYperc);
649 theApp.WriteProfileInt(ResStr(IDS_R_VOBSUB), ResStr(IDS_RV_BUFFER), m_fBufferVobSub);
650 theApp.WriteProfileInt(ResStr(IDS_R_VOBSUB), ResStr(IDS_RV_ONLYSHOWFORCEDSUBS), m_fOnlyShowForcedVobSubs);
651 theApp.WriteProfileInt(ResStr(IDS_R_VOBSUB), ResStr(IDS_RV_POLYGONIZE), m_fPolygonize);
652 CString style;
653 theApp.WriteProfileString(ResStr(IDS_R_TEXT), ResStr(IDS_RT_STYLE), style <<= m_defStyle);
654 theApp.WriteProfileInt(ResStr(IDS_R_GENERAL), ResStr(IDS_RG_FLIPPICTURE), m_fFlipPicture);
655 theApp.WriteProfileInt(ResStr(IDS_R_GENERAL), ResStr(IDS_RG_FLIPSUBTITLES), m_fFlipSubtitles);
656 theApp.WriteProfileInt(ResStr(IDS_R_GENERAL), ResStr(IDS_RG_SHOWOSDSTATS), m_fOSD);
657 theApp.WriteProfileInt(ResStr(IDS_R_GENERAL), ResStr(IDS_RG_SAVEFULLPATH), m_fSaveFullPath);
658 theApp.WriteProfileInt(ResStr(IDS_R_TIMING), ResStr(IDS_RTM_SUBTITLEDELAY), m_SubtitleDelay);
659 theApp.WriteProfileInt(ResStr(IDS_R_TIMING), ResStr(IDS_RTM_SUBTITLESPEEDMUL), m_SubtitleSpeedMul);
660 theApp.WriteProfileInt(ResStr(IDS_R_TIMING), ResStr(IDS_RTM_SUBTITLESPEEDDIV), m_SubtitleSpeedDiv);
661 theApp.WriteProfileInt(ResStr(IDS_R_TIMING), ResStr(IDS_RTM_MEDIAFPSENABLED), m_fMediaFPSEnabled);
662 theApp.WriteProfileBinary(ResStr(IDS_R_TIMING), ResStr(IDS_RTM_MEDIAFPS), (BYTE*)&m_MediaFPS, sizeof(m_MediaFPS));
663 theApp.WriteProfileInt(ResStr(IDS_R_TEXT), ResStr(IDS_RT_AUTOPARCOMPENSATION), m_ePARCompensationType);
664 theApp.WriteProfileInt(ResStr(IDS_R_GENERAL), ResStr(IDS_RG_HIDE_TRAY_ICON), m_xy_bool_opt[BOOL_HIDE_TRAY_ICON]);
666 theApp.WriteProfileInt(ResStr(IDS_R_PERFORMANCE), ResStr(IDS_RP_BITMAP_MRU_CACHE_ITEM_NUM), m_xy_int_opt[INT_BITMAP_MRU_CACHE_ITEM_NUM]);
667 theApp.WriteProfileInt(ResStr(IDS_R_PERFORMANCE), ResStr(IDS_RP_CLIPPER_MRU_CACHE_ITEM_NUM), m_xy_int_opt[INT_CLIPPER_MRU_CACHE_ITEM_NUM]);
668 theApp.WriteProfileInt(ResStr(IDS_R_PERFORMANCE), ResStr(IDS_RP_TEXT_INFO_CACHE_ITEM_NUM), m_xy_int_opt[INT_TEXT_INFO_CACHE_ITEM_NUM]);
669 theApp.WriteProfileInt(ResStr(IDS_R_PERFORMANCE), ResStr(IDS_RP_ASS_TAG_LIST_CACHE_ITEM_NUM), m_xy_int_opt[INT_ASS_TAG_LIST_CACHE_ITEM_NUM]);
671 theApp.WriteProfileInt(ResStr(IDS_R_PERFORMANCE), ResStr(IDS_RP_OVERLAY_CACHE_MAX_ITEM_NUM), m_xy_int_opt[INT_OVERLAY_CACHE_MAX_ITEM_NUM]);
672 theApp.WriteProfileInt(ResStr(IDS_R_PERFORMANCE), ResStr(IDS_RP_OVERLAY_NO_BLUR_CACHE_MAX_ITEM_NUM), m_xy_int_opt[INT_OVERLAY_NO_BLUR_CACHE_MAX_ITEM_NUM]);
673 theApp.WriteProfileInt(ResStr(IDS_R_PERFORMANCE), ResStr(IDS_RP_SCAN_LINE_DATA_CACHE_MAX_ITEM_NUM), m_xy_int_opt[INT_SCAN_LINE_DATA_CACHE_MAX_ITEM_NUM]);
674 theApp.WriteProfileInt(ResStr(IDS_R_PERFORMANCE), ResStr(IDS_RP_PATH_DATA_CACHE_MAX_ITEM_NUM), m_xy_int_opt[INT_PATH_DATA_CACHE_MAX_ITEM_NUM]);
675 theApp.WriteProfileInt(ResStr(IDS_R_PERFORMANCE), ResStr(IDS_RP_SUBPIXEL_POS_LEVEL), m_xy_int_opt[INT_SUBPIXEL_POS_LEVEL]);
676 theApp.WriteProfileInt(ResStr(IDS_R_GENERAL), ResStr(IDS_RG_USE_UPSTREAM_PREFERRED_ORDER), m_xy_bool_opt[BOOL_FOLLOW_UPSTREAM_PREFERRED_ORDER]);
678 theApp.WriteProfileInt(ResStr(IDS_R_GENERAL), ResStr(IDS_RG_LAYOUT_SIZE_OPT), m_xy_int_opt[INT_LAYOUT_SIZE_OPT]);
679 theApp.WriteProfileInt(ResStr(IDS_R_GENERAL), ResStr(IDS_RG_USER_SPECIFIED_LAYOUT_SIZE_X), m_xy_size_opt[SIZE_USER_SPECIFIED_LAYOUT_SIZE].cx);
680 theApp.WriteProfileInt(ResStr(IDS_R_GENERAL), ResStr(IDS_RG_USER_SPECIFIED_LAYOUT_SIZE_Y), m_xy_size_opt[SIZE_USER_SPECIFIED_LAYOUT_SIZE].cy);
682 //save output color config
684 int count = GetOutputColorSpaceNumber();
685 BYTE* pData = new BYTE[2*count];
686 for(int i = 0; i < count; i++)
688 pData[2*i] = static_cast<BYTE>(m_outputColorSpace[i].color_space);
689 pData[2*i+1] = static_cast<BYTE>(m_outputColorSpace[i].selected);
691 theApp.WriteProfileBinary(ResStr(IDS_R_GENERAL), ResStr(IDS_RG_OUTPUT_COLORFORMATS), pData, 2*count);
693 delete [] pData;
696 //save input color config
698 int count = GetInputColorSpaceNumber();
699 BYTE* pData = new BYTE[2*count];
700 for(int i = 0; i < count; i++)
702 pData[2*i] = static_cast<BYTE>(m_inputColorSpace[i].color_space);
703 pData[2*i+1] = static_cast<BYTE>(m_inputColorSpace[i].selected);
705 theApp.WriteProfileBinary(ResStr(IDS_R_GENERAL), ResStr(IDS_RG_INPUT_COLORFORMATS), pData, 2*count);
707 delete [] pData;
710 theApp.WriteProfileInt(ResStr(IDS_R_GENERAL), ResStr(IDS_RG_SUPPORTED_VERSION), CUR_SUPPORTED_FILTER_VERSION);
711 theApp.WriteProfileInt(ResStr(IDS_R_GENERAL), ResStr(IDS_RG_VERSION), XY_VSFILTER_VERSION_COMMIT);
713 return S_OK;
716 STDMETHODIMP CDirectVobSub::HasConfigDialog(int iSelected)
718 return E_NOTIMPL;
721 STDMETHODIMP CDirectVobSub::ShowConfigDialog(int iSelected, HWND hWndParent)
723 return E_NOTIMPL;
726 STDMETHODIMP CDirectVobSub::IsSubtitleReloaderLocked(bool* fLocked)
728 CAutoLock cAutoLock(&m_propsLock);
730 if(!fLocked) return E_POINTER;
732 bool fDisabled;
733 get_SubtitleReloader(&fDisabled);
735 *fLocked = fDisabled || m_nReloaderDisableCount > 0;
737 return S_OK;
740 STDMETHODIMP CDirectVobSub::LockSubtitleReloader(bool fLock)
742 CAutoLock cAutoLock(&m_propsLock);
744 if(fLock) m_nReloaderDisableCount++;
745 else m_nReloaderDisableCount--;
747 ASSERT(m_nReloaderDisableCount >= 0);
748 if(m_nReloaderDisableCount < 0) m_nReloaderDisableCount = 0;
750 return S_OK;
753 STDMETHODIMP CDirectVobSub::get_SubtitleReloader(bool* fDisabled)
755 AFX_MANAGE_STATE(AfxGetStaticModuleState());
757 CAutoLock cAutoLock(&m_propsLock);
759 if(fDisabled) *fDisabled = !!theApp.GetProfileInt(ResStr(IDS_R_GENERAL), ResStr(IDS_RG_DISABLERELOADER), 0);
761 return S_OK;
764 STDMETHODIMP CDirectVobSub::put_SubtitleReloader(bool fDisable)
766 AFX_MANAGE_STATE(AfxGetStaticModuleState());
768 CAutoLock cAutoLock(&m_propsLock);
770 bool b;
771 get_SubtitleReloader(&b);
772 if(b == fDisable) return S_FALSE;
774 theApp.WriteProfileInt(ResStr(IDS_R_GENERAL), ResStr(IDS_RG_DISABLERELOADER), fDisable);
776 return S_OK;
779 STDMETHODIMP CDirectVobSub::get_ExtendPicture(int* horizontal, int* vertical, int* resx2, int* resx2minw, int* resx2minh)
781 AFX_MANAGE_STATE(AfxGetStaticModuleState());
783 CAutoLock cAutoLock(&m_propsLock);
785 if(horizontal) *horizontal = theApp.GetProfileInt(ResStr(IDS_R_GENERAL), ResStr(IDS_RG_MOD32FIX), 0) & 1;
786 if(vertical) *vertical = theApp.GetProfileInt(ResStr(IDS_R_GENERAL), ResStr(IDS_RG_EXTPIC), 0);
787 //if(resx2) *resx2 = theApp.GetProfileInt(ResStr(IDS_R_GENERAL), ResStr(IDS_RG_RESX2), 2) & 3;
788 if(resx2) *resx2 = 0;
789 if(resx2minw) *resx2minw = theApp.GetProfileInt(ResStr(IDS_R_GENERAL), ResStr(IDS_RG_RESX2MINW), 384);
790 if(resx2minh) *resx2minh = theApp.GetProfileInt(ResStr(IDS_R_GENERAL), ResStr(IDS_RG_RESX2MINH), 288);
792 return S_OK;
795 STDMETHODIMP CDirectVobSub::put_ExtendPicture(int horizontal, int vertical, int resx2, int resx2minw, int resx2minh)
797 AFX_MANAGE_STATE(AfxGetStaticModuleState());
799 CAutoLock cAutoLock(&m_propsLock);
800 if(resx2==0)
802 int i[5];
803 get_ExtendPicture(i, i+1, i+2, i+3, i+4);
804 if(i[0] == horizontal && i[1] == vertical && i[2] == resx2 && i[3] == resx2minw && i[4] == resx2minh) return S_FALSE;
806 theApp.WriteProfileInt(ResStr(IDS_R_GENERAL), ResStr(IDS_RG_MOD32FIX), horizontal & 1);
807 theApp.WriteProfileInt(ResStr(IDS_R_GENERAL), ResStr(IDS_RG_EXTPIC), vertical);
808 theApp.WriteProfileInt(ResStr(IDS_R_GENERAL), ResStr(IDS_RG_RESX2), resx2 & 3);
809 theApp.WriteProfileInt(ResStr(IDS_R_GENERAL), ResStr(IDS_RG_RESX2MINW), resx2minw);
810 theApp.WriteProfileInt(ResStr(IDS_R_GENERAL), ResStr(IDS_RG_RESX2MINH), resx2minh);
812 return S_OK;
814 else
816 return S_FALSE;
820 STDMETHODIMP CDirectVobSub::get_LoadSettings(int* level, bool* fExternalLoad, bool* fWebLoad, bool* fEmbeddedLoad)
822 AFX_MANAGE_STATE(AfxGetStaticModuleState());
824 CAutoLock cAutoLock(&m_propsLock);
826 if(level) *level = theApp.GetProfileInt(ResStr(IDS_R_GENERAL), ResStr(IDS_RG_LOADLEVEL), 0) & 3;
827 if(fExternalLoad) *fExternalLoad = !!theApp.GetProfileInt(ResStr(IDS_R_GENERAL), ResStr(IDS_RG_EXTERNALLOAD), 1);
828 if(fWebLoad) *fWebLoad = !!theApp.GetProfileInt(ResStr(IDS_R_GENERAL), ResStr(IDS_RG_WEBLOAD), 0);
829 if(fEmbeddedLoad) *fEmbeddedLoad = !!theApp.GetProfileInt(ResStr(IDS_R_GENERAL), ResStr(IDS_RG_EMBEDDEDLOAD), 1);
831 return S_OK;
834 STDMETHODIMP CDirectVobSub::put_LoadSettings(int level, bool fExternalLoad, bool fWebLoad, bool fEmbeddedLoad)
836 AFX_MANAGE_STATE(AfxGetStaticModuleState());
838 CAutoLock cAutoLock(&m_propsLock);
840 int i;
841 bool b[3];
842 get_LoadSettings(&i, b, b+1, b+2);
843 if(i == level && b[0] == fExternalLoad && b[1] == fWebLoad && b[2] == fEmbeddedLoad) return S_FALSE;
845 theApp.WriteProfileInt(ResStr(IDS_R_GENERAL), ResStr(IDS_RG_LOADLEVEL), level & 3);
846 theApp.WriteProfileInt(ResStr(IDS_R_GENERAL), ResStr(IDS_RG_EXTERNALLOAD), fExternalLoad);
847 theApp.WriteProfileInt(ResStr(IDS_R_GENERAL), ResStr(IDS_RG_WEBLOAD), fWebLoad);
848 theApp.WriteProfileInt(ResStr(IDS_R_GENERAL), ResStr(IDS_RG_EMBEDDEDLOAD), fEmbeddedLoad);
850 return S_OK;
853 // IDirectVobSub2
855 STDMETHODIMP CDirectVobSub::AdviseSubClock(ISubClock* pSubClock)
857 m_pSubClock = pSubClock;
858 return S_OK;
861 STDMETHODIMP_(bool) CDirectVobSub::get_Forced()
863 return m_fForced;
866 STDMETHODIMP CDirectVobSub::put_Forced(bool fForced)
868 if(m_fForced==fForced)
869 return S_FALSE;
871 m_fForced = fForced;
872 return S_OK;
875 STDMETHODIMP CDirectVobSub::get_TextSettings(STSStyle* pDefStyle)
877 CheckPointer(pDefStyle, E_POINTER);
879 CAutoLock cAutoLock(&m_propsLock);
881 *pDefStyle = m_defStyle;
883 return S_OK;
886 STDMETHODIMP CDirectVobSub::put_TextSettings(STSStyle* pDefStyle)
888 CheckPointer(pDefStyle, E_POINTER);
890 CAutoLock cAutoLock(&m_propsLock);
892 if(m_defStyle==*pDefStyle)
893 return S_FALSE;
894 if(!memcmp(&m_defStyle, pDefStyle, sizeof(m_defStyle)))
895 return S_FALSE;
897 m_defStyle = *pDefStyle;
899 return S_OK;
902 STDMETHODIMP CDirectVobSub::get_AspectRatioSettings(CSimpleTextSubtitle::EPARCompensationType* ePARCompensationType)
904 CAutoLock cAutoLock(&m_propsLock);
906 *ePARCompensationType = m_ePARCompensationType;
908 return S_OK;
911 STDMETHODIMP CDirectVobSub::put_AspectRatioSettings(CSimpleTextSubtitle::EPARCompensationType* ePARCompensationType)
913 CAutoLock cAutoLock(&m_propsLock);
915 if(m_ePARCompensationType==*ePARCompensationType)
916 return S_FALSE;
918 m_ePARCompensationType = *ePARCompensationType;
920 return S_OK;
923 // IFilterVersion
925 STDMETHODIMP_(DWORD) CDirectVobSub::GetFilterVersion()
927 return 0x0234;
930 bool CDirectVobSub::is_compatible()
932 bool compatible = false;
933 if ( m_config_info_version>XY_VSFILTER_VERSION_COMMIT )
935 compatible = m_supported_filter_verion<=XY_VSFILTER_VERSION_COMMIT;
937 else
939 compatible = REQUIRED_CONFIG_VERSION<=m_config_info_version;
941 return compatible;
944 UINT CDirectVobSub::GetCompatibleProfileInt( LPCTSTR lpszSection, LPCTSTR lpszEntry, int nDefault )
946 UINT result = nDefault;
947 if (is_compatible())
949 result = theApp.GetProfileInt(lpszSection, lpszEntry, nDefault);
951 return result;
954 // IDirectVobSubXy
956 STDMETHODIMP CDirectVobSub::XyGetBool( int field, bool *value )
958 CAutoLock cAutoLock(&m_propsLock);
959 if (field<0 || field>=DirectVobSubXyOptions::BOOL_COUNT)
961 return E_NOTIMPL;
963 return value ? *value = m_xy_bool_opt[field], S_OK : E_POINTER;
966 STDMETHODIMP CDirectVobSub::XyGetInt( int field, int *value )
968 CAutoLock cAutoLock(&m_propsLock);
969 if (field<0 || field>=DirectVobSubXyOptions::INT_COUNT)
971 return E_NOTIMPL;
973 return value ? *value = m_xy_int_opt[field], S_OK : E_POINTER;
976 STDMETHODIMP CDirectVobSub::XyGetSize( int field, SIZE *value )
978 CAutoLock cAutoLock(&m_propsLock);
979 if (field<0 || field>=DirectVobSubXyOptions::SIZE_COUNT)
981 return E_NOTIMPL;
983 if (!value)
985 return E_POINTER;
987 switch(field)
989 case SIZE_LAYOUT_WITH:
990 switch(m_xy_int_opt[DirectVobSubXyOptions::INT_LAYOUT_SIZE_OPT])
992 case LAYOUT_SIZE_OPT_FOLLOW_ORIGINAL_VIDEO_SIZE:
993 *value = m_xy_size_opt[DirectVobSubXyOptions::SIZE_ORIGINAL_VIDEO];
994 break;
995 case LAYOUT_SIZE_OPT_USER_SPECIFIED:
996 *value = m_xy_size_opt[DirectVobSubXyOptions::SIZE_USER_SPECIFIED_LAYOUT_SIZE];
997 break;
998 default:
999 *value = m_xy_size_opt[DirectVobSubXyOptions::SIZE_ASS_PLAY_RESOLUTION];
1000 break;
1002 if (value->cx * value->cy == 0)
1004 *value = m_xy_size_opt[DirectVobSubXyOptions::SIZE_ORIGINAL_VIDEO];
1006 break;
1007 default:
1008 *value = m_xy_size_opt[field];
1009 break;
1011 return S_OK;
1014 STDMETHODIMP CDirectVobSub::XyGetRect( int field, RECT *value )
1016 return E_NOTIMPL;
1019 STDMETHODIMP CDirectVobSub::XyGetUlonglong( int field, ULONGLONG *value )
1021 return E_NOTIMPL;
1024 STDMETHODIMP CDirectVobSub::XyGetDouble( int field, double *value )
1026 return E_NOTIMPL;
1029 STDMETHODIMP CDirectVobSub::XyGetString( int field, LPWSTR *value, int *chars )
1031 return E_NOTIMPL;
1034 STDMETHODIMP CDirectVobSub::XyGetBin( int field, LPVOID *value, int *size )
1036 CAutoLock cAutoLock(&m_propsLock);
1037 if (field<0 || field>=DirectVobSubXyOptions::BIN_COUNT)
1039 return E_NOTIMPL;
1041 if (!size)
1043 return E_INVALIDARG;
1045 *size = 0;
1046 if (value)
1048 *value = NULL;
1050 switch(field)
1052 case BIN_OUTPUT_COLOR_FORMAT:
1053 if(size)
1055 *size = GetOutputColorSpaceNumber();
1057 if(value && size)
1059 *value = new ColorSpaceOpt[*size];
1060 ASSERT(*value);
1061 memcpy(*value, m_outputColorSpace, GetOutputColorSpaceNumber()*sizeof(m_outputColorSpace[0]));
1063 return S_OK;
1064 case BIN_INPUT_COLOR_FORMAT:
1065 if(size)
1067 *size = GetInputColorSpaceNumber();
1069 if(value && size)
1071 *value = new ColorSpaceOpt[*size];
1072 ASSERT(*value);
1073 memcpy(*value, m_inputColorSpace, GetInputColorSpaceNumber()*sizeof(m_inputColorSpace[0]));
1075 return S_OK;
1076 case BIN_CACHES_INFO:
1077 if (size)
1079 *size=1;
1081 if (value)
1083 *value = new CachesInfo[1];
1085 return get_CachesInfo(reinterpret_cast<CachesInfo*>(*value));
1086 case BIN_XY_FLY_WEIGHT_INFO:
1087 if (size)
1089 *size=1;
1091 if (value)
1093 *value = new XyFlyWeightInfo[1];
1095 return get_XyFlyWeightInfo(reinterpret_cast<XyFlyWeightInfo*>(*value));
1098 return E_NOTIMPL;
1101 STDMETHODIMP CDirectVobSub::XySetBool( int field, bool value )
1103 if (field<0 || field>=DirectVobSubXyOptions::BOOL_COUNT)
1105 return E_NOTIMPL;
1108 CAutoLock cAutoLock(&m_propsLock);
1110 if(m_xy_bool_opt[field] == value) return S_FALSE;
1111 m_xy_bool_opt[field] = value;
1113 return S_OK;
1116 STDMETHODIMP CDirectVobSub::XySetInt( int field, int value )
1118 if (field<0 || field>=DirectVobSubXyOptions::INT_COUNT)
1120 return E_NOTIMPL;
1122 switch (field)
1124 case DirectVobSubXyOptions::INT_LAYOUT_SIZE_OPT:
1125 if (value<0 || value>=DirectVobSubXyOptions::LAYOUT_SIZE_OPT_COUNT)
1127 return E_INVALIDARG;
1129 break;
1131 CAutoLock cAutoLock(&m_propsLock);
1133 if(m_xy_int_opt[field] == value) return S_FALSE;
1134 m_xy_int_opt[field] = value;
1136 return S_OK;
1139 STDMETHODIMP CDirectVobSub::XySetSize( int field, SIZE value )
1141 if (field<0 || field>=DirectVobSubXyOptions::SIZE_COUNT)
1143 return E_NOTIMPL;
1145 switch (field)
1147 case DirectVobSubXyOptions::SIZE_LAYOUT_WITH:
1148 return E_INVALIDARG;
1151 CAutoLock cAutoLock(&m_propsLock);
1153 if(m_xy_size_opt[field].cx == value.cx && m_xy_size_opt[field].cy == value.cy) return S_FALSE;
1154 m_xy_size_opt[field] = value;
1156 return S_OK;
1159 STDMETHODIMP CDirectVobSub::XySetRect( int field, RECT value )
1161 return E_NOTIMPL;
1164 STDMETHODIMP CDirectVobSub::XySetUlonglong( int field, ULONGLONG value )
1166 return E_NOTIMPL;
1169 STDMETHODIMP CDirectVobSub::XySetDouble( int field, double value )
1171 return E_NOTIMPL;
1174 STDMETHODIMP CDirectVobSub::XySetString( int field, LPWSTR value, int chars )
1176 return E_NOTIMPL;
1179 STDMETHODIMP CDirectVobSub::XySetBin( int field, LPVOID value, int size )
1181 CAutoLock cAutoLock(&m_propsLock);
1182 if (field<0 || field>=DirectVobSubXyOptions::BIN_COUNT)
1184 return E_NOTIMPL;
1186 switch(field)
1188 case BIN_OUTPUT_COLOR_FORMAT:
1189 if( size!=GetOutputColorSpaceNumber() )
1190 return E_INVALIDARG;
1191 if(value && memcmp(m_outputColorSpace, value, size*sizeof(m_outputColorSpace[0])))
1193 memcpy(m_outputColorSpace, value, size*sizeof(m_outputColorSpace[0]));
1194 return S_OK;
1196 return S_FALSE;
1197 case BIN_INPUT_COLOR_FORMAT:
1198 if( size!=GetInputColorSpaceNumber() )
1199 return S_FALSE;
1200 if( value && memcmp(m_inputColorSpace, value, size*sizeof(m_inputColorSpace[0])))
1202 memcpy(m_inputColorSpace, value, size*sizeof(m_inputColorSpace[0]));
1203 return S_OK;
1205 return S_FALSE;
1207 return E_NOTIMPL;