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

github.com/mpc-hc/mpc-hc.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'src/filters/transform/VSFilter')
-rw-r--r--src/filters/transform/VSFilter/AvgLines.cpp75
-rw-r--r--src/filters/transform/VSFilter/Copy.cpp111
-rw-r--r--src/filters/transform/VSFilter/DirectVobSub.cpp248
-rw-r--r--src/filters/transform/VSFilter/DirectVobSub.h8
-rw-r--r--src/filters/transform/VSFilter/DirectVobSubFilter.cpp848
-rw-r--r--src/filters/transform/VSFilter/DirectVobSubFilter.h3
-rw-r--r--src/filters/transform/VSFilter/DirectVobSubPropPage.cpp851
-rw-r--r--src/filters/transform/VSFilter/IDirectVobSub.h9
-rw-r--r--src/filters/transform/VSFilter/Scale2x.cpp65
-rw-r--r--src/filters/transform/VSFilter/StyleEditorDialog.cpp60
-rw-r--r--src/filters/transform/VSFilter/StyleEditorDialog.h5
-rw-r--r--src/filters/transform/VSFilter/Systray.cpp335
-rw-r--r--src/filters/transform/VSFilter/VSFilter.cpp40
-rw-r--r--src/filters/transform/VSFilter/csri.h532
-rw-r--r--src/filters/transform/VSFilter/csriapi.cpp43
-rw-r--r--src/filters/transform/VSFilter/plugins.cpp1828
-rw-r--r--src/filters/transform/VSFilter/vfr.cpp39
-rw-r--r--src/filters/transform/VSFilter/vfr.h3
18 files changed, 2542 insertions, 2561 deletions
diff --git a/src/filters/transform/VSFilter/AvgLines.cpp b/src/filters/transform/VSFilter/AvgLines.cpp
index 19e80a305..2a0b89311 100644
--- a/src/filters/transform/VSFilter/AvgLines.cpp
+++ b/src/filters/transform/VSFilter/AvgLines.cpp
@@ -20,28 +20,26 @@
void AvgLines8(BYTE* dst, DWORD h, DWORD pitch)
{
- if(h <= 1)
+ if(h <= 1) {
return;
+ }
BYTE* s = dst;
BYTE* d = dst + (h-2)*pitch;
- for(; s < d; s += pitch*2)
- {
+ for(; s < d; s += pitch*2) {
BYTE* tmp = s;
#ifndef _WIN64
- if((g_cpuid.m_flags & CCpuID::sse2) && !((DWORD)tmp&0xf) && !((DWORD)pitch&0xf))
- {
- __asm
- {
+ if((g_cpuid.m_flags & CCpuID::sse2) && !((DWORD)tmp&0xf) && !((DWORD)pitch&0xf)) {
+ __asm {
mov esi, tmp
mov ebx, pitch
mov ecx, ebx
shr ecx, 4
-AvgLines8_sse2_loop:
+ AvgLines8_sse2_loop:
movdqa xmm0, [esi]
pavgb xmm0, [esi+ebx*2]
movdqa [esi+ebx], xmm0
@@ -53,15 +51,11 @@ AvgLines8_sse2_loop:
mov tmp, esi
}
- for(ptrdiff_t i = pitch&7; i--; tmp++)
- {
+ for(ptrdiff_t i = pitch&7; i--; tmp++) {
tmp[pitch] = (tmp[0] + tmp[pitch<<1] + 1) >> 1;
}
- }
- else if(g_cpuid.m_flags & CCpuID::mmx)
- {
- __asm
- {
+ } else if(g_cpuid.m_flags & CCpuID::mmx) {
+ __asm {
mov esi, tmp
mov ebx, pitch
@@ -69,7 +63,7 @@ AvgLines8_sse2_loop:
shr ecx, 3
pxor mm7, mm7
-AvgLines8_mmx_loop:
+ AvgLines8_mmx_loop:
movq mm0, [esi]
movq mm1, mm0
@@ -100,23 +94,19 @@ AvgLines8_mmx_loop:
mov tmp, esi
}
- for(ptrdiff_t i = pitch&7; i--; tmp++)
- {
+ for(ptrdiff_t i = pitch&7; i--; tmp++) {
tmp[pitch] = (tmp[0] + tmp[pitch<<1] + 1) >> 1;
}
- }
- else
+ } else
#endif
{
- for(ptrdiff_t i = pitch; i--; tmp++)
- {
+ for(ptrdiff_t i = pitch; i--; tmp++) {
tmp[pitch] = (tmp[0] + tmp[pitch<<1] + 1) >> 1;
}
}
}
- if(!(h&1) && h >= 2)
- {
+ if(!(h&1) && h >= 2) {
dst += (h-2)*pitch;
memcpy(dst + pitch, dst, pitch);
}
@@ -128,8 +118,9 @@ AvgLines8_mmx_loop:
void AvgLines555(BYTE* dst, DWORD h, DWORD pitch)
{
- if(h <= 1)
+ if(h <= 1) {
return;
+ }
unsigned __int64 __0x03e003e003e003e0 = 0x03e003e003e003e0;
unsigned __int64 __0x001f001f001f001f = 0x001f001f001f001f;
@@ -137,13 +128,11 @@ void AvgLines555(BYTE* dst, DWORD h, DWORD pitch)
BYTE* s = dst;
BYTE* d = dst + (h-2)*pitch;
- for(; s < d; s += pitch*2)
- {
+ for(; s < d; s += pitch*2) {
BYTE* tmp = s;
#ifndef _WIN64
- __asm
- {
+ __asm {
mov esi, tmp
mov ebx, pitch
@@ -153,7 +142,7 @@ void AvgLines555(BYTE* dst, DWORD h, DWORD pitch)
movq mm6, __0x03e003e003e003e0
movq mm7, __0x001f001f001f001f
-AvgLines555_loop:
+ AvgLines555_loop:
movq mm0, [esi]
movq mm1, mm0
movq mm2, mm0
@@ -196,8 +185,7 @@ AvgLines555_loop:
}
#endif
- for(ptrdiff_t i = (pitch&7)>>1; i--; tmp++)
- {
+ for(ptrdiff_t i = (pitch&7)>>1; i--; tmp++) {
tmp[pitch] =
((((*tmp&0x7c00) + (tmp[pitch<<1]&0x7c00)) >> 1)&0x7c00)|
((((*tmp&0x03e0) + (tmp[pitch<<1]&0x03e0)) >> 1)&0x03e0)|
@@ -205,8 +193,7 @@ AvgLines555_loop:
}
}
- if(!(h&1) && h >= 2)
- {
+ if(!(h&1) && h >= 2) {
dst += (h-2)*pitch;
memcpy(dst + pitch, dst, pitch);
}
@@ -218,8 +205,9 @@ AvgLines555_loop:
void AvgLines565(BYTE* dst, DWORD h, DWORD pitch)
{
- if(h <= 1)
+ if(h <= 1) {
return;
+ }
unsigned __int64 __0x07e007e007e007e0 = 0x07e007e007e007e0;
unsigned __int64 __0x001f001f001f001f = 0x001f001f001f001f;
@@ -227,13 +215,11 @@ void AvgLines565(BYTE* dst, DWORD h, DWORD pitch)
BYTE* s = dst;
BYTE* d = dst + (h-2)*pitch;
- for(; s < d; s += pitch*2)
- {
+ for(; s < d; s += pitch*2) {
WORD* tmp = (WORD*)s;
#ifndef _WIN64
- __asm
- {
+ __asm {
mov esi, tmp
mov ebx, pitch
@@ -243,7 +229,7 @@ void AvgLines565(BYTE* dst, DWORD h, DWORD pitch)
movq mm6, __0x07e007e007e007e0
movq mm7, __0x001f001f001f001f
-AvgLines565_loop:
+ AvgLines565_loop:
movq mm0, [esi]
movq mm1, mm0
movq mm2, mm0
@@ -285,8 +271,7 @@ AvgLines565_loop:
mov tmp, esi
}
#else
- for(ptrdiff_t wd=(pitch>>3); wd--; tmp++)
- {
+ for(ptrdiff_t wd=(pitch>>3); wd--; tmp++) {
tmp[0] =
((((*tmp&0xf800) + (tmp[pitch<<1]&0xf800)) >> 1)&0xf800)|
((((*tmp&0x07e0) + (tmp[pitch<<1]&0x07e0)) >> 1)&0x07e0)|
@@ -294,8 +279,7 @@ AvgLines565_loop:
}
#endif
- for(ptrdiff_t i = (pitch&7)>>1; i--; tmp++)
- {
+ for(ptrdiff_t i = (pitch&7)>>1; i--; tmp++) {
tmp[pitch] =
((((*tmp&0xf800) + (tmp[pitch<<1]&0xf800)) >> 1)&0xf800)|
((((*tmp&0x07e0) + (tmp[pitch<<1]&0x07e0)) >> 1)&0x07e0)|
@@ -303,8 +287,7 @@ AvgLines565_loop:
}
}
- if(!(h&1) && h >= 2)
- {
+ if(!(h&1) && h >= 2) {
dst += (h-2)*pitch;
memcpy(dst + pitch, dst, pitch);
}
diff --git a/src/filters/transform/VSFilter/Copy.cpp b/src/filters/transform/VSFilter/Copy.cpp
index 7c6e077ea..575b2103d 100644
--- a/src/filters/transform/VSFilter/Copy.cpp
+++ b/src/filters/transform/VSFilter/Copy.cpp
@@ -33,82 +33,62 @@ extern void ColorConvInit();
void BltLineRGB32(DWORD* d, BYTE* sub, int w, const GUID& subtype)
{
- if(subtype == MEDIASUBTYPE_YV12 || subtype == MEDIASUBTYPE_I420 || subtype == MEDIASUBTYPE_IYUV)
- {
+ if(subtype == MEDIASUBTYPE_YV12 || subtype == MEDIASUBTYPE_I420 || subtype == MEDIASUBTYPE_IYUV) {
BYTE* db = (BYTE*)d;
BYTE* dbtend = db + w;
- for(; db < dbtend; sub+=4, db++)
- {
- if(sub[3] < 0xff)
- {
+ for(; db < dbtend; sub+=4, db++) {
+ if(sub[3] < 0xff) {
int y = (c2y_yb[sub[0]] + c2y_yg[sub[1]] + c2y_yr[sub[2]] + 0x108000) >> 16;
*db = y; // w/o colors
}
}
- }
- else if(subtype == MEDIASUBTYPE_YUY2)
- {
+ } else if(subtype == MEDIASUBTYPE_YUY2) {
WORD* ds = (WORD*)d;
WORD* dstend = ds + w;
- for(; ds < dstend; sub+=4, ds++)
- {
- if(sub[3] < 0xff)
- {
+ for(; ds < dstend; sub+=4, ds++) {
+ if(sub[3] < 0xff) {
int y = (c2y_yb[sub[0]] + c2y_yg[sub[1]] + c2y_yr[sub[2]] + 0x108000) >> 16;
*ds = 0x8000|y; // w/o colors
}
}
- }
- else if(subtype == MEDIASUBTYPE_RGB555)
- {
+ } else if(subtype == MEDIASUBTYPE_RGB555) {
WORD* ds = (WORD*)d;
WORD* dstend = ds + w;
- for(; ds < dstend; sub+=4, ds++)
- {
- if(sub[3] < 0xff)
- {
+ for(; ds < dstend; sub+=4, ds++) {
+ if(sub[3] < 0xff) {
*ds = ((*((DWORD*)sub)>>9)&0x7c00)|((*((DWORD*)sub)>>6)&0x03e0)|((*((DWORD*)sub)>>3)&0x001f);
}
}
- }
- else if(subtype == MEDIASUBTYPE_RGB565)
- {
+ } else if(subtype == MEDIASUBTYPE_RGB565) {
WORD* ds = (WORD*)d;
WORD* dstend = ds + w;
- for(; ds < dstend; sub+=4, ds++)
- {
- if(sub[3] < 0xff)
- {
+ for(; ds < dstend; sub+=4, ds++) {
+ if(sub[3] < 0xff) {
*ds = ((*((DWORD*)sub)>>8)&0xf800)|((*((DWORD*)sub)>>5)&0x07e0)|((*((DWORD*)sub)>>3)&0x001f);
}
}
- }
- else if(subtype == MEDIASUBTYPE_RGB24)
- {
+ } else if(subtype == MEDIASUBTYPE_RGB24) {
BYTE* dt = (BYTE*)d;
BYTE* dstend = dt + w*3;
- for(; dt < dstend; sub+=4, dt+=3)
- {
- if(sub[3] < 0xff)
- {
+ for(; dt < dstend; sub+=4, dt+=3) {
+ if(sub[3] < 0xff) {
dt[0] = sub[0];
dt[1] = sub[1];
dt[2] = sub[2];
}
}
- }
- else if(subtype == MEDIASUBTYPE_RGB32 || subtype == MEDIASUBTYPE_ARGB32)
- {
+ } else if(subtype == MEDIASUBTYPE_RGB32 || subtype == MEDIASUBTYPE_ARGB32) {
DWORD* dstend = d + w;
- for(; d < dstend; sub+=4, d++)
- {
- if(sub[3] < 0xff) *d = *((DWORD*)sub)&0xffffff;
+ for(; d < dstend; sub+=4, d++) {
+ if(sub[3] < 0xff) {
+ *d = *((DWORD*)sub)&0xffffff;
+ }
}
}
}
@@ -119,7 +99,9 @@ HRESULT CDirectVobSubFilter::Copy(BYTE* pSub, BYTE* pIn, CSize sub, CSize in, in
int wSub = sub.cx, hSub = sub.cy, pitchSub = wSub*bpp>>3;
bool fScale2x = wIn*2 <= wSub;
- if(fScale2x) wIn <<= 1, hIn <<= 1;
+ if(fScale2x) {
+ wIn <<= 1, hIn <<= 1;
+ }
int left = ((wSub - wIn)>>1)&~1;
int mid = wIn;
@@ -136,32 +118,27 @@ HRESULT CDirectVobSubFilter::Copy(BYTE* pSub, BYTE* pIn, CSize sub, CSize in, in
j += (hSub - hIn) >> 1;
- for(; i < j; i++, pSub += pitchSub)
- {
+ for(; i < j; i++, pSub += pitchSub) {
memsetd(pSub, black, dpLeft+dpMid+dpRight);
}
j += hIn;
- if(hIn > hSub)
+ if(hIn > hSub) {
pIn += pitchIn * ((hIn - hSub) >> (fScale2x?2:1));
+ }
- if(fScale2x)
- {
+ if(fScale2x) {
Scale2x(subtype,
pSub + dpLeft, pitchSub, pIn, pitchIn,
in.cx, (min(j, hSub) - i) >> 1);
- for(ptrdiff_t k = min(j, hSub); i < k; i++, pIn += pitchIn, pSub += pitchSub)
- {
+ for(ptrdiff_t k = min(j, hSub); i < k; i++, pIn += pitchIn, pSub += pitchSub) {
memsetd(pSub, black, dpLeft);
memsetd(pSub + dpLeft+dpMid, black, dpRight);
}
- }
- else
- {
- for(ptrdiff_t k = min(j, hSub); i < k; i++, pIn += pitchIn, pSub += pitchSub)
- {
+ } else {
+ for(ptrdiff_t k = min(j, hSub); i < k; i++, pIn += pitchIn, pSub += pitchSub) {
memsetd(pSub, black, dpLeft);
memcpy(pSub + dpLeft, pIn, dpMid);
memsetd(pSub + dpLeft+dpMid, black, dpRight);
@@ -170,8 +147,7 @@ HRESULT CDirectVobSubFilter::Copy(BYTE* pSub, BYTE* pIn, CSize sub, CSize in, in
j = hSub;
- for(; i < j; i++, pSub += pitchSub)
- {
+ for(; i < j; i++, pSub += pitchSub) {
memsetd(pSub, black, dpLeft+dpMid+dpRight);
}
}
@@ -181,8 +157,9 @@ HRESULT CDirectVobSubFilter::Copy(BYTE* pSub, BYTE* pIn, CSize sub, CSize in, in
void CDirectVobSubFilter::PrintMessages(BYTE* pOut)
{
- if(!m_hdc || !m_hbm)
+ if(!m_hdc || !m_hbm) {
return;
+ }
ColorConvInit();
@@ -193,8 +170,7 @@ void CDirectVobSubFilter::PrintMessages(BYTE* pOut)
CString msg, tmp;
- if(m_fOSD)
- {
+ if(m_fOSD) {
tmp.Format(_T("in: %dx%d %s\nout: %dx%d %s\n"),
m_w, m_h,
Subtype2String(m_pInput->CurrentMediaType().subtype),
@@ -211,16 +187,14 @@ void CDirectVobSubFilter::PrintMessages(BYTE* pOut)
CAutoLock cAutoLock(&m_csQueueLock);
- if(m_pSubPicQueue)
- {
+ if(m_pSubPicQueue) {
int nSubPics = -1;
REFERENCE_TIME rtNow = -1, rtStart = -1, rtStop = -1;
m_pSubPicQueue->GetStats(nSubPics, rtNow, rtStart, rtStop);
tmp.Format(_T("queue stats: %I64d - %I64d [ms]\n"), rtStart/10000, rtStop/10000);
msg += tmp;
- for(ptrdiff_t i = 0; i < nSubPics; i++)
- {
+ for(ptrdiff_t i = 0; i < nSubPics; i++) {
m_pSubPicQueue->GetStats(i, rtStart, rtStop);
tmp.Format(_T("%d: %I64d - %I64d [ms]\n"), i, rtStart/10000, rtStop/10000);
msg += tmp;
@@ -229,7 +203,9 @@ void CDirectVobSubFilter::PrintMessages(BYTE* pOut)
}
}
- if(msg.IsEmpty()) return;
+ if(msg.IsEmpty()) {
+ return;
+ }
HANDLE hOldBitmap = SelectObject(m_hdc, m_hbm);
HANDLE hOldFont = SelectObject(m_hdc, m_hfont);
@@ -253,14 +229,14 @@ void CDirectVobSubFilter::PrintMessages(BYTE* pOut)
int pitchIn = bm.bmWidthBytes;
int pitchOut = bihOut.biWidth * bihOut.biBitCount >> 3;
- if(subtype == MEDIASUBTYPE_YV12 || subtype == MEDIASUBTYPE_I420 || subtype == MEDIASUBTYPE_IYUV)
+ if(subtype == MEDIASUBTYPE_YV12 || subtype == MEDIASUBTYPE_I420 || subtype == MEDIASUBTYPE_IYUV) {
pitchOut = bihOut.biWidth;
+ }
pitchIn = (pitchIn+3)&~3;
pitchOut = (pitchOut+3)&~3;
- if(bihOut.biHeight > 0 && bihOut.biCompression <= 3) // flip if the dst bitmap is flipped rgb (m_hbm is a top-down bitmap, not like the subpictures)
- {
+ if(bihOut.biHeight > 0 && bihOut.biCompression <= 3) { // flip if the dst bitmap is flipped rgb (m_hbm is a top-down bitmap, not like the subpictures)
pOut += pitchOut * (abs(bihOut.biHeight)-1);
pitchOut = -pitchOut;
}
@@ -268,8 +244,7 @@ void CDirectVobSubFilter::PrintMessages(BYTE* pOut)
pIn += pitchIn * r.top;
pOut += pitchOut * r.top;
- for(ptrdiff_t w = min(r.right, m_w), h = r.Height(); h--; pIn += pitchIn, pOut += pitchOut)
- {
+ for(ptrdiff_t w = min(r.right, m_w), h = r.Height(); h--; pIn += pitchIn, pOut += pitchOut) {
BltLineRGB32((DWORD*)pOut, pIn, w, subtype);
memsetd(pIn, 0xff000000, r.right*4);
}
diff --git a/src/filters/transform/VSFilter/DirectVobSub.cpp b/src/filters/transform/VSFilter/DirectVobSub.cpp
index 59d3a8ec1..8ae4bba69 100644
--- a/src/filters/transform/VSFilter/DirectVobSub.cpp
+++ b/src/filters/transform/VSFilter/DirectVobSub.cpp
@@ -53,10 +53,12 @@ CDirectVobSub::CDirectVobSub()
m_fMediaFPSEnabled = !!theApp.GetProfileInt(ResStr(IDS_R_TIMING), ResStr(IDS_RTM_MEDIAFPSENABLED), 0);
m_ePARCompensationType = static_cast<CSimpleTextSubtitle::EPARCompensationType>(theApp.GetProfileInt(ResStr(IDS_R_TEXT), ResStr(IDS_RT_AUTOPARCOMPENSATION), 0));
pData = NULL;
- if(theApp.GetProfileBinary(ResStr(IDS_R_TIMING), ResStr(IDS_RTM_MEDIAFPS), &pData, &nSize) && pData)
- {
- if(nSize != sizeof(m_MediaFPS)) m_MediaFPS = 25.0;
- else memcpy(&m_MediaFPS, pData, sizeof(m_MediaFPS));
+ if(theApp.GetProfileBinary(ResStr(IDS_R_TIMING), ResStr(IDS_RTM_MEDIAFPS), &pData, &nSize) && pData) {
+ if(nSize != sizeof(m_MediaFPS)) {
+ m_MediaFPS = 25.0;
+ } else {
+ memcpy(&m_MediaFPS, pData, sizeof(m_MediaFPS));
+ }
delete [] pData;
}
m_ZoomRect.left = m_ZoomRect.top = 0;
@@ -74,7 +76,9 @@ STDMETHODIMP CDirectVobSub::get_FileName(WCHAR* fn)
{
CAutoLock cAutoLock(&m_propsLock);
- if(!fn) return E_POINTER;
+ if(!fn) {
+ return E_POINTER;
+ }
#ifdef UNICODE
wcscpy(fn, m_FileName);
@@ -89,10 +93,14 @@ STDMETHODIMP CDirectVobSub::put_FileName(WCHAR* fn)
{
CAutoLock cAutoLock(&m_propsLock);
- if(!fn) return E_POINTER;
+ if(!fn) {
+ return E_POINTER;
+ }
CString tmp = fn;
- if(!m_FileName.Left(m_FileName.ReverseFind('.')+1).CompareNoCase(tmp.Left(tmp.ReverseFind('.')+1))) return S_FALSE;
+ if(!m_FileName.Left(m_FileName.ReverseFind('.')+1).CompareNoCase(tmp.Left(tmp.ReverseFind('.')+1))) {
+ return S_FALSE;
+ }
#ifdef UNICODE
m_FileName = fn;
@@ -130,13 +138,16 @@ STDMETHODIMP CDirectVobSub::put_SelectedLanguage(int iSelected)
{
CAutoLock cAutoLock(&m_propsLock);
- if(m_iSelectedLanguage == iSelected) return S_FALSE;
+ if(m_iSelectedLanguage == iSelected) {
+ return S_FALSE;
+ }
int nCount;
if(FAILED(get_LanguageCount(&nCount))
- || iSelected < 0
- || iSelected >= nCount)
+ || iSelected < 0
+ || iSelected >= nCount) {
return E_FAIL;
+ }
m_iSelectedLanguage = iSelected;
@@ -154,7 +165,9 @@ STDMETHODIMP CDirectVobSub::put_HideSubtitles(bool fHideSubtitles)
{
CAutoLock cAutoLock(&m_propsLock);
- if(m_fHideSubtitles == fHideSubtitles) return S_FALSE;
+ if(m_fHideSubtitles == fHideSubtitles) {
+ return S_FALSE;
+ }
m_fHideSubtitles = fHideSubtitles;
@@ -172,7 +185,9 @@ STDMETHODIMP CDirectVobSub::put_PreBuffering(bool fDoPreBuffering)
{
CAutoLock cAutoLock(&m_propsLock);
- if(m_fDoPreBuffering == fDoPreBuffering) return S_FALSE;
+ if(m_fDoPreBuffering == fDoPreBuffering) {
+ return S_FALSE;
+ }
m_fDoPreBuffering = fDoPreBuffering;
@@ -183,9 +198,15 @@ STDMETHODIMP CDirectVobSub::get_Placement(bool* fOverridePlacement, int* xperc,
{
CAutoLock cAutoLock(&m_propsLock);
- if(fOverridePlacement) *fOverridePlacement = m_fOverridePlacement;
- if(xperc) *xperc = m_PlacementXperc;
- if(yperc) *yperc = m_PlacementYperc;
+ if(fOverridePlacement) {
+ *fOverridePlacement = m_fOverridePlacement;
+ }
+ if(xperc) {
+ *xperc = m_PlacementXperc;
+ }
+ if(yperc) {
+ *yperc = m_PlacementYperc;
+ }
return S_OK;
}
@@ -194,7 +215,9 @@ STDMETHODIMP CDirectVobSub::put_Placement(bool fOverridePlacement, int xperc, in
{
CAutoLock cAutoLock(&m_propsLock);
- if(m_fOverridePlacement == fOverridePlacement && m_PlacementXperc == xperc && m_PlacementYperc == yperc) return S_FALSE;
+ if(m_fOverridePlacement == fOverridePlacement && m_PlacementXperc == xperc && m_PlacementYperc == yperc) {
+ return S_FALSE;
+ }
m_fOverridePlacement = fOverridePlacement;
m_PlacementXperc = xperc;
@@ -207,9 +230,15 @@ STDMETHODIMP CDirectVobSub::get_VobSubSettings(bool* fBuffer, bool* fOnlyShowFor
{
CAutoLock cAutoLock(&m_propsLock);
- if(fBuffer) *fBuffer = m_fBufferVobSub;
- if(fOnlyShowForcedSubs) *fOnlyShowForcedSubs = m_fOnlyShowForcedVobSubs;
- if(fPolygonize) *fPolygonize = m_fPolygonize;
+ if(fBuffer) {
+ *fBuffer = m_fBufferVobSub;
+ }
+ if(fOnlyShowForcedSubs) {
+ *fOnlyShowForcedSubs = m_fOnlyShowForcedVobSubs;
+ }
+ if(fPolygonize) {
+ *fPolygonize = m_fPolygonize;
+ }
return S_OK;
}
@@ -218,7 +247,9 @@ STDMETHODIMP CDirectVobSub::put_VobSubSettings(bool fBuffer, bool fOnlyShowForce
{
CAutoLock cAutoLock(&m_propsLock);
- if(m_fBufferVobSub == fBuffer && m_fOnlyShowForcedVobSubs == fOnlyShowForcedSubs && m_fPolygonize == fPolygonize) return S_FALSE;
+ if(m_fBufferVobSub == fBuffer && m_fOnlyShowForcedVobSubs == fOnlyShowForcedSubs && m_fPolygonize == fPolygonize) {
+ return S_FALSE;
+ }
m_fBufferVobSub = fBuffer;
m_fOnlyShowForcedVobSubs = fOnlyShowForcedSubs;
@@ -231,14 +262,14 @@ STDMETHODIMP CDirectVobSub::get_TextSettings(void* lf, int lflen, COLORREF* colo
{
CAutoLock cAutoLock(&m_propsLock);
- if(lf)
- {
- if(lflen == sizeof(LOGFONTA))
+ if(lf) {
+ if(lflen == sizeof(LOGFONTA)) {
strncpy_s(((LOGFONTA*)lf)->lfFaceName, LF_FACESIZE, CStringA(m_defStyle.fontName), _TRUNCATE);
- else if(lflen == sizeof(LOGFONTW))
+ } else if(lflen == sizeof(LOGFONTW)) {
wcsncpy_s(((LOGFONTW*)lf)->lfFaceName, LF_FACESIZE, CStringW(m_defStyle.fontName), _TRUNCATE);
- else
+ } else {
return E_INVALIDARG;
+ }
((LOGFONT*)lf)->lfCharSet = m_defStyle.charSet;
((LOGFONT*)lf)->lfItalic = m_defStyle.fItalic;
@@ -248,10 +279,18 @@ STDMETHODIMP CDirectVobSub::get_TextSettings(void* lf, int lflen, COLORREF* colo
((LOGFONT*)lf)->lfUnderline = m_defStyle.fUnderline;
}
- if(color) *color = m_defStyle.colors[0];
- if(fShadow) *fShadow = (m_defStyle.shadowDepthX!=0) || (m_defStyle.shadowDepthY!=0);
- if(fOutline) *fOutline = (m_defStyle.outlineWidthX+m_defStyle.outlineWidthY)>0;
- if(fAdvancedRenderer) *fAdvancedRenderer = m_fAdvancedRenderer;
+ if(color) {
+ *color = m_defStyle.colors[0];
+ }
+ if(fShadow) {
+ *fShadow = (m_defStyle.shadowDepthX!=0) || (m_defStyle.shadowDepthY!=0);
+ }
+ if(fOutline) {
+ *fOutline = (m_defStyle.outlineWidthX+m_defStyle.outlineWidthY)>0;
+ }
+ if(fAdvancedRenderer) {
+ *fAdvancedRenderer = m_fAdvancedRenderer;
+ }
return S_OK;
}
@@ -260,14 +299,14 @@ STDMETHODIMP CDirectVobSub::put_TextSettings(void* lf, int lflen, COLORREF color
{
CAutoLock cAutoLock(&m_propsLock);
- if(lf)
- {
- if(lflen == sizeof(LOGFONTA))
+ if(lf) {
+ if(lflen == sizeof(LOGFONTA)) {
m_defStyle.fontName = ((LOGFONTA*)lf)->lfFaceName;
- else if(lflen == sizeof(LOGFONTW))
+ } else if(lflen == sizeof(LOGFONTW)) {
m_defStyle.fontName = ((LOGFONTW*)lf)->lfFaceName;
- else
+ } else {
return E_INVALIDARG;
+ }
m_defStyle.charSet = ((LOGFONT*)lf)->lfCharSet;
m_defStyle.fItalic = !!((LOGFONT*)lf)->lfItalic;
@@ -276,8 +315,7 @@ STDMETHODIMP CDirectVobSub::put_TextSettings(void* lf, int lflen, COLORREF color
m_defStyle.fStrikeOut = !!((LOGFONT*)lf)->lfStrikeOut;
m_defStyle.fUnderline = !!((LOGFONT*)lf)->lfUnderline;
- if(m_defStyle.fontSize < 0)
- {
+ if(m_defStyle.fontSize < 0) {
HDC hdc = ::GetDC(0);
m_defStyle.fontSize = -m_defStyle.fontSize * 72 / GetDeviceCaps(hdc, LOGPIXELSY);
::ReleaseDC(0, hdc);
@@ -297,8 +335,12 @@ STDMETHODIMP CDirectVobSub::get_Flip(bool* fPicture, bool* fSubtitles)
{
CAutoLock cAutoLock(&m_propsLock);
- if(fPicture) *fPicture = m_fFlipPicture;
- if(fSubtitles) *fSubtitles = m_fFlipSubtitles;
+ if(fPicture) {
+ *fPicture = m_fFlipPicture;
+ }
+ if(fSubtitles) {
+ *fSubtitles = m_fFlipSubtitles;
+ }
return S_OK;
}
@@ -307,7 +349,9 @@ STDMETHODIMP CDirectVobSub::put_Flip(bool fPicture, bool fSubtitles)
{
CAutoLock cAutoLock(&m_propsLock);
- if(m_fFlipPicture == fPicture && m_fFlipSubtitles == fSubtitles) return S_FALSE;
+ if(m_fFlipPicture == fPicture && m_fFlipSubtitles == fSubtitles) {
+ return S_FALSE;
+ }
m_fFlipPicture = fPicture;
m_fFlipSubtitles = fSubtitles;
@@ -326,7 +370,9 @@ STDMETHODIMP CDirectVobSub::put_OSD(bool fOSD)
{
CAutoLock cAutoLock(&m_propsLock);
- if(m_fOSD == fOSD) return S_FALSE;
+ if(m_fOSD == fOSD) {
+ return S_FALSE;
+ }
m_fOSD = fOSD;
@@ -344,7 +390,9 @@ STDMETHODIMP CDirectVobSub::put_SaveFullPath(bool fSaveFullPath)
{
CAutoLock cAutoLock(&m_propsLock);
- if(m_fSaveFullPath == fSaveFullPath) return S_FALSE;
+ if(m_fSaveFullPath == fSaveFullPath) {
+ return S_FALSE;
+ }
m_fSaveFullPath = fSaveFullPath;
@@ -355,9 +403,15 @@ STDMETHODIMP CDirectVobSub::get_SubtitleTiming(int* delay, int* speedmul, int* s
{
CAutoLock cAutoLock(&m_propsLock);
- if(delay) *delay = m_SubtitleDelay;
- if(speedmul) *speedmul = m_SubtitleSpeedMul;
- if(speeddiv) *speeddiv = m_SubtitleSpeedDiv;
+ if(delay) {
+ *delay = m_SubtitleDelay;
+ }
+ if(speedmul) {
+ *speedmul = m_SubtitleSpeedMul;
+ }
+ if(speeddiv) {
+ *speeddiv = m_SubtitleSpeedDiv;
+ }
return S_OK;
}
@@ -366,11 +420,15 @@ STDMETHODIMP CDirectVobSub::put_SubtitleTiming(int delay, int speedmul, int spee
{
CAutoLock cAutoLock(&m_propsLock);
- if(m_SubtitleDelay == delay && m_SubtitleSpeedMul == speedmul && m_SubtitleSpeedDiv == speeddiv) return S_FALSE;
+ if(m_SubtitleDelay == delay && m_SubtitleSpeedMul == speedmul && m_SubtitleSpeedDiv == speeddiv) {
+ return S_FALSE;
+ }
m_SubtitleDelay = delay;
m_SubtitleSpeedMul = speedmul;
- if(speeddiv > 0) m_SubtitleSpeedDiv = speeddiv;
+ if(speeddiv > 0) {
+ m_SubtitleSpeedDiv = speeddiv;
+ }
return S_OK;
}
@@ -379,8 +437,12 @@ STDMETHODIMP CDirectVobSub::get_MediaFPS(bool* fEnabled, double* fps)
{
CAutoLock cAutoLock(&m_propsLock);
- if(fEnabled) *fEnabled = m_fMediaFPSEnabled;
- if(fps) *fps = m_MediaFPS;
+ if(fEnabled) {
+ *fEnabled = m_fMediaFPSEnabled;
+ }
+ if(fps) {
+ *fps = m_MediaFPS;
+ }
return S_OK;
}
@@ -389,10 +451,14 @@ STDMETHODIMP CDirectVobSub::put_MediaFPS(bool fEnabled, double fps)
{
CAutoLock cAutoLock(&m_propsLock);
- if(m_fMediaFPSEnabled == fEnabled && m_MediaFPS == fps) return S_FALSE;
+ if(m_fMediaFPSEnabled == fEnabled && m_MediaFPS == fps) {
+ return S_FALSE;
+ }
m_fMediaFPSEnabled = fEnabled;
- if(fps > 0) m_MediaFPS = fps;
+ if(fps > 0) {
+ m_MediaFPS = fps;
+ }
return S_OK;
}
@@ -401,7 +467,9 @@ STDMETHODIMP CDirectVobSub::get_ZoomRect(NORMALIZEDRECT* rect)
{
CAutoLock cAutoLock(&m_propsLock);
- if(!rect) return E_POINTER;
+ if(!rect) {
+ return E_POINTER;
+ }
*rect = m_ZoomRect;
@@ -412,9 +480,13 @@ STDMETHODIMP CDirectVobSub::put_ZoomRect(NORMALIZEDRECT* rect)
{
CAutoLock cAutoLock(&m_propsLock);
- if(!rect) return E_POINTER;
+ if(!rect) {
+ return E_POINTER;
+ }
- if(!memcmp(&m_ZoomRect, rect, sizeof(m_ZoomRect))) return S_FALSE;
+ if(!memcmp(&m_ZoomRect, rect, sizeof(m_ZoomRect))) {
+ return S_FALSE;
+ }
m_ZoomRect = *rect;
@@ -465,7 +537,9 @@ STDMETHODIMP CDirectVobSub::IsSubtitleReloaderLocked(bool* fLocked)
{
CAutoLock cAutoLock(&m_propsLock);
- if(!fLocked) return E_POINTER;
+ if(!fLocked) {
+ return E_POINTER;
+ }
bool fDisabled;
get_SubtitleReloader(&fDisabled);
@@ -479,11 +553,16 @@ STDMETHODIMP CDirectVobSub::LockSubtitleReloader(bool fLock)
{
CAutoLock cAutoLock(&m_propsLock);
- if(fLock) m_nReloaderDisableCount++;
- else m_nReloaderDisableCount--;
+ if(fLock) {
+ m_nReloaderDisableCount++;
+ } else {
+ m_nReloaderDisableCount--;
+ }
ASSERT(m_nReloaderDisableCount >= 0);
- if(m_nReloaderDisableCount < 0) m_nReloaderDisableCount = 0;
+ if(m_nReloaderDisableCount < 0) {
+ m_nReloaderDisableCount = 0;
+ }
return S_OK;
}
@@ -494,7 +573,9 @@ STDMETHODIMP CDirectVobSub::get_SubtitleReloader(bool* fDisabled)
CAutoLock cAutoLock(&m_propsLock);
- if(fDisabled) *fDisabled = !!theApp.GetProfileInt(ResStr(IDS_R_GENERAL), ResStr(IDS_RG_DISABLERELOADER), 0);
+ if(fDisabled) {
+ *fDisabled = !!theApp.GetProfileInt(ResStr(IDS_R_GENERAL), ResStr(IDS_RG_DISABLERELOADER), 0);
+ }
return S_OK;
}
@@ -507,7 +588,9 @@ STDMETHODIMP CDirectVobSub::put_SubtitleReloader(bool fDisable)
bool b;
get_SubtitleReloader(&b);
- if(b == fDisable) return S_FALSE;
+ if(b == fDisable) {
+ return S_FALSE;
+ }
theApp.WriteProfileInt(ResStr(IDS_R_GENERAL), ResStr(IDS_RG_DISABLERELOADER), fDisable);
@@ -520,11 +603,21 @@ STDMETHODIMP CDirectVobSub::get_ExtendPicture(int* horizontal, int* vertical, in
CAutoLock cAutoLock(&m_propsLock);
- if(horizontal) *horizontal = theApp.GetProfileInt(ResStr(IDS_R_GENERAL), ResStr(IDS_RG_MOD32FIX), 0) & 1;
- if(vertical) *vertical = theApp.GetProfileInt(ResStr(IDS_R_GENERAL), ResStr(IDS_RG_EXTPIC), 0);
- if(resx2) *resx2 = theApp.GetProfileInt(ResStr(IDS_R_GENERAL), ResStr(IDS_RG_RESX2), 2) & 3;
- if(resx2minw) *resx2minw = theApp.GetProfileInt(ResStr(IDS_R_GENERAL), ResStr(IDS_RG_RESX2MINW), 384);
- if(resx2minh) *resx2minh = theApp.GetProfileInt(ResStr(IDS_R_GENERAL), ResStr(IDS_RG_RESX2MINH), 288);
+ if(horizontal) {
+ *horizontal = theApp.GetProfileInt(ResStr(IDS_R_GENERAL), ResStr(IDS_RG_MOD32FIX), 0) & 1;
+ }
+ if(vertical) {
+ *vertical = theApp.GetProfileInt(ResStr(IDS_R_GENERAL), ResStr(IDS_RG_EXTPIC), 0);
+ }
+ if(resx2) {
+ *resx2 = theApp.GetProfileInt(ResStr(IDS_R_GENERAL), ResStr(IDS_RG_RESX2), 2) & 3;
+ }
+ if(resx2minw) {
+ *resx2minw = theApp.GetProfileInt(ResStr(IDS_R_GENERAL), ResStr(IDS_RG_RESX2MINW), 384);
+ }
+ if(resx2minh) {
+ *resx2minh = theApp.GetProfileInt(ResStr(IDS_R_GENERAL), ResStr(IDS_RG_RESX2MINH), 288);
+ }
return S_OK;
}
@@ -537,7 +630,9 @@ STDMETHODIMP CDirectVobSub::put_ExtendPicture(int horizontal, int vertical, int
int i[5];
get_ExtendPicture(i, i+1, i+2, i+3, i+4);
- if(i[0] == horizontal && i[1] == vertical && i[2] == resx2 && i[3] == resx2minw && i[4] == resx2minh) return S_FALSE;
+ if(i[0] == horizontal && i[1] == vertical && i[2] == resx2 && i[3] == resx2minw && i[4] == resx2minh) {
+ return S_FALSE;
+ }
theApp.WriteProfileInt(ResStr(IDS_R_GENERAL), ResStr(IDS_RG_MOD32FIX), horizontal & 1);
theApp.WriteProfileInt(ResStr(IDS_R_GENERAL), ResStr(IDS_RG_EXTPIC), vertical);
@@ -554,10 +649,18 @@ STDMETHODIMP CDirectVobSub::get_LoadSettings(int* level, bool* fExternalLoad, bo
CAutoLock cAutoLock(&m_propsLock);
- if(level) *level = theApp.GetProfileInt(ResStr(IDS_R_GENERAL), ResStr(IDS_RG_LOADLEVEL), 0) & 3;
- if(fExternalLoad) *fExternalLoad = !!theApp.GetProfileInt(ResStr(IDS_R_GENERAL), ResStr(IDS_RG_EXTERNALLOAD), 1);
- if(fWebLoad) *fWebLoad = !!theApp.GetProfileInt(ResStr(IDS_R_GENERAL), ResStr(IDS_RG_WEBLOAD), 0);
- if(fEmbeddedLoad) *fEmbeddedLoad = !!theApp.GetProfileInt(ResStr(IDS_R_GENERAL), ResStr(IDS_RG_EMBEDDEDLOAD), 1);
+ if(level) {
+ *level = theApp.GetProfileInt(ResStr(IDS_R_GENERAL), ResStr(IDS_RG_LOADLEVEL), 0) & 3;
+ }
+ if(fExternalLoad) {
+ *fExternalLoad = !!theApp.GetProfileInt(ResStr(IDS_R_GENERAL), ResStr(IDS_RG_EXTERNALLOAD), 1);
+ }
+ if(fWebLoad) {
+ *fWebLoad = !!theApp.GetProfileInt(ResStr(IDS_R_GENERAL), ResStr(IDS_RG_WEBLOAD), 0);
+ }
+ if(fEmbeddedLoad) {
+ *fEmbeddedLoad = !!theApp.GetProfileInt(ResStr(IDS_R_GENERAL), ResStr(IDS_RG_EMBEDDEDLOAD), 1);
+ }
return S_OK;
}
@@ -571,7 +674,9 @@ STDMETHODIMP CDirectVobSub::put_LoadSettings(int level, bool fExternalLoad, bool
int i;
bool b[3];
get_LoadSettings(&i, b, b+1, b+2);
- if(i == level && b[0] == fExternalLoad && b[1] == fWebLoad && b[2] == fEmbeddedLoad) return S_FALSE;
+ if(i == level && b[0] == fExternalLoad && b[1] == fWebLoad && b[2] == fEmbeddedLoad) {
+ return S_FALSE;
+ }
theApp.WriteProfileInt(ResStr(IDS_R_GENERAL), ResStr(IDS_RG_LOADLEVEL), level & 3);
theApp.WriteProfileInt(ResStr(IDS_R_GENERAL), ResStr(IDS_RG_EXTERNALLOAD), fExternalLoad);
@@ -617,8 +722,9 @@ STDMETHODIMP CDirectVobSub::put_TextSettings(STSStyle* pDefStyle)
CAutoLock cAutoLock(&m_propsLock);
- if(!memcmp(&m_defStyle, pDefStyle, sizeof(m_defStyle)))
+ if(!memcmp(&m_defStyle, pDefStyle, sizeof(m_defStyle))) {
return S_FALSE;
+ }
m_defStyle = *pDefStyle;
diff --git a/src/filters/transform/VSFilter/DirectVobSub.h b/src/filters/transform/VSFilter/DirectVobSub.h
index 7f6edcba4..1c3917707 100644
--- a/src/filters/transform/VSFilter/DirectVobSub.h
+++ b/src/filters/transform/VSFilter/DirectVobSub.h
@@ -91,8 +91,12 @@ public:
STDMETHODIMP put_MediaFPS(bool fEnabled, double fps);
STDMETHODIMP get_ZoomRect(NORMALIZEDRECT* rect);
STDMETHODIMP put_ZoomRect(NORMALIZEDRECT* rect);
- STDMETHODIMP get_ColorFormat(int* iPosition) {return E_NOTIMPL;}
- STDMETHODIMP put_ColorFormat(int iPosition) {return E_NOTIMPL;}
+ STDMETHODIMP get_ColorFormat(int* iPosition) {
+ return E_NOTIMPL;
+ }
+ STDMETHODIMP put_ColorFormat(int iPosition) {
+ return E_NOTIMPL;
+ }
STDMETHODIMP UpdateRegistry();
diff --git a/src/filters/transform/VSFilter/DirectVobSubFilter.cpp b/src/filters/transform/VSFilter/DirectVobSubFilter.cpp
index 1d0726364..935e29b57 100644
--- a/src/filters/transform/VSFilter/DirectVobSubFilter.cpp
+++ b/src/filters/transform/VSFilter/DirectVobSubFilter.cpp
@@ -100,7 +100,9 @@ CDirectVobSubFilter::CDirectVobSubFilter(LPUNKNOWN punk, HRESULT* phr, const GUI
CDirectVobSubFilter::~CDirectVobSubFilter()
{
CAutoLock cAutoLock(&m_csQueueLock);
- if(m_pSubPicQueue) m_pSubPicQueue->Invalidate();
+ if(m_pSubPicQueue) {
+ m_pSubPicQueue->Invalidate();
+ }
m_pSubPicQueue = NULL;
if(m_hfont) {
@@ -116,8 +118,9 @@ CDirectVobSubFilter::~CDirectVobSubFilter()
m_hdc = 0;
}
- for(ptrdiff_t i = 0; i < m_pTextInput.GetCount(); i++)
+ for(ptrdiff_t i = 0; i < m_pTextInput.GetCount(); i++) {
delete m_pTextInput[i];
+ }
m_frd.EndThreadEvent.Set();
CAMThread::Close();
@@ -145,15 +148,17 @@ void CDirectVobSubFilter::GetOutputSize(int& w, int& h, int& arx, int& ary)
w = s.cx;
h = s.cy;
- if(w != os.cx)
- {
- while(arx < 100) arx *= 10, ary *= 10;
+ if(w != os.cx) {
+ while(arx < 100) {
+ arx *= 10, ary *= 10;
+ }
arx = arx * w / os.cx;
}
- if(h != os.cy)
- {
- while(ary < 100) arx *= 10, ary *= 10;
+ if(h != os.cy) {
+ while(ary < 100) {
+ arx *= 10, ary *= 10;
+ }
ary = ary * h / os.cy;
}
}
@@ -164,18 +169,17 @@ HRESULT CDirectVobSubFilter::Transform(IMediaSample* pIn)
REFERENCE_TIME rtStart, rtStop;
- if(SUCCEEDED(pIn->GetTime(&rtStart, &rtStop)))
- {
+ if(SUCCEEDED(pIn->GetTime(&rtStart, &rtStop))) {
double dRate = m_pInput->CurrentRate();
m_tPrev = m_pInput->CurrentStartTime() + dRate*rtStart;
REFERENCE_TIME rtAvgTimePerFrame = rtStop - rtStart;
- if(CComQIPtr<ISubClock2> pSC2 = m_pSubClock)
- {
+ if(CComQIPtr<ISubClock2> pSC2 = m_pSubClock) {
REFERENCE_TIME rt;
- if(S_OK == pSC2->GetAvgTimePerFrame(&rt))
+ if(S_OK == pSC2->GetAvgTimePerFrame(&rt)) {
rtAvgTimePerFrame = rt;
+ }
}
m_fps = 10000000.0/rtAvgTimePerFrame / dRate;
@@ -186,8 +190,7 @@ HRESULT CDirectVobSubFilter::Transform(IMediaSample* pIn)
{
CAutoLock cAutoLock(&m_csQueueLock);
- if(m_pSubPicQueue)
- {
+ if(m_pSubPicQueue) {
m_pSubPicQueue->SetTime(CalcCurrentTime());
m_pSubPicQueue->SetFPS(m_fps);
}
@@ -196,8 +199,9 @@ HRESULT CDirectVobSubFilter::Transform(IMediaSample* pIn)
//
BYTE* pDataIn = NULL;
- if(FAILED(pIn->GetPointer(&pDataIn)) || !pDataIn)
+ if(FAILED(pIn->GetPointer(&pDataIn)) || !pDataIn) {
return S_FALSE;
+ }
const CMediaType& mt = m_pInput->CurrentMediaType();
@@ -211,11 +215,11 @@ HRESULT CDirectVobSubFilter::Transform(IMediaSample* pIn)
CSize sub(m_w, m_h);
CSize in(bihIn.biWidth, bihIn.biHeight);
- if(FAILED(Copy((BYTE*)m_pTempPicBuff, pDataIn, sub, in, bpp, mt.subtype, black)))
+ if(FAILED(Copy((BYTE*)m_pTempPicBuff, pDataIn, sub, in, bpp, mt.subtype, black))) {
return E_FAIL;
+ }
- if(fYV12)
- {
+ if(fYV12) {
BYTE* pSubV = (BYTE*)m_pTempPicBuff + (sub.cx*bpp>>3)*sub.cy;
BYTE* pInV = pDataIn + (in.cx*bpp>>3)*in.cy;
sub.cx >>= 1;
@@ -224,10 +228,12 @@ HRESULT CDirectVobSubFilter::Transform(IMediaSample* pIn)
in.cy >>= 1;
BYTE* pSubU = pSubV + (sub.cx*bpp>>3)*sub.cy;
BYTE* pInU = pInV + (in.cx*bpp>>3)*in.cy;
- if(FAILED(Copy(pSubV, pInV, sub, in, bpp, mt.subtype, 0x80808080)))
+ if(FAILED(Copy(pSubV, pInV, sub, in, bpp, mt.subtype, 0x80808080))) {
return E_FAIL;
- if(FAILED(Copy(pSubU, pInU, sub, in, bpp, mt.subtype, 0x80808080)))
+ }
+ if(FAILED(Copy(pSubU, pInU, sub, in, bpp, mt.subtype, 0x80808080))) {
return E_FAIL;
+ }
}
//
@@ -237,8 +243,9 @@ HRESULT CDirectVobSubFilter::Transform(IMediaSample* pIn)
CComPtr<IMediaSample> pOut;
BYTE* pDataOut = NULL;
if(FAILED(hr = GetDeliveryBuffer(spd.w, spd.h, &pOut))
- || FAILED(hr = pOut->GetPointer(&pDataOut)))
+ || FAILED(hr = pOut->GetPointer(&pDataOut))) {
return hr;
+ }
pOut->SetTime(&rtStart, &rtStop);
pOut->SetMediaTime(NULL, NULL);
@@ -256,27 +263,32 @@ HRESULT CDirectVobSubFilter::Transform(IMediaSample* pIn)
bool fOutputFlipped = bihOut.biHeight >= 0 && bihOut.biCompression <= 3;
bool fFlip = fInputFlipped != fOutputFlipped;
- if(m_fFlipPicture) fFlip = !fFlip;
- if(m_fMSMpeg4Fix) fFlip = !fFlip;
+ if(m_fFlipPicture) {
+ fFlip = !fFlip;
+ }
+ if(m_fMSMpeg4Fix) {
+ fFlip = !fFlip;
+ }
bool fFlipSub = fOutputFlipped;
- if(m_fFlipSubtitles) fFlipSub = !fFlipSub;
+ if(m_fFlipSubtitles) {
+ fFlipSub = !fFlipSub;
+ }
//
{
CAutoLock cAutoLock(&m_csQueueLock);
- if(m_pSubPicQueue)
- {
+ if(m_pSubPicQueue) {
CComPtr<ISubPic> pSubPic;
- if(SUCCEEDED(m_pSubPicQueue->LookupSubPic(CalcCurrentTime(), pSubPic)) && pSubPic)
- {
+ if(SUCCEEDED(m_pSubPicQueue->LookupSubPic(CalcCurrentTime(), pSubPic)) && pSubPic) {
CRect r;
pSubPic->GetDirtyRect(r);
- if(fFlip ^ fFlipSub)
+ if(fFlip ^ fFlipSub) {
spd.h = -spd.h;
+ }
pSubPic->AlphaBlt(r, r, &spd);
}
@@ -294,13 +306,15 @@ HRESULT CDirectVobSubFilter::Transform(IMediaSample* pIn)
CBasePin* CDirectVobSubFilter::GetPin(int n)
{
- if(n < __super::GetPinCount())
+ if(n < __super::GetPinCount()) {
return __super::GetPin(n);
+ }
n -= __super::GetPinCount();
- if(n >= 0 && n < m_pTextInput.GetCount())
+ if(n >= 0 && n < m_pTextInput.GetCount()) {
return m_pTextInput[n];
+ }
n -= m_pTextInput.GetCount();
@@ -314,21 +328,17 @@ int CDirectVobSubFilter::GetPinCount()
HRESULT CDirectVobSubFilter::JoinFilterGraph(IFilterGraph* pGraph, LPCWSTR pName)
{
- if(pGraph)
- {
+ if(pGraph) {
AFX_MANAGE_STATE(AfxGetStaticModuleState());
- if(!theApp.GetProfileInt(ResStr(IDS_R_GENERAL), ResStr(IDS_RG_SEENDIVXWARNING), 0))
- {
+ if(!theApp.GetProfileInt(ResStr(IDS_R_GENERAL), ResStr(IDS_RG_SEENDIVXWARNING), 0)) {
unsigned __int64 ver = GetFileVersion(_T("divx_c32.ax"));
- if(((ver >> 48)&0xffff) == 4 && ((ver >> 32)&0xffff) == 2)
- {
+ if(((ver >> 48)&0xffff) == 4 && ((ver >> 32)&0xffff) == 2) {
DWORD dwVersion = GetVersion();
DWORD dwWindowsMajorVersion = (DWORD)(LOBYTE(LOWORD(dwVersion)));
DWORD dwWindowsMinorVersion = (DWORD)(HIBYTE(LOWORD(dwVersion)));
- if(dwVersion < 0x80000000 && dwWindowsMajorVersion >= 5)
- {
+ if(dwVersion < 0x80000000 && dwWindowsMajorVersion >= 5) {
AfxMessageBox(IDS_DIVX_WARNING);
theApp.WriteProfileInt(ResStr(IDS_R_GENERAL), ResStr(IDS_RG_SEENDIVXWARNING), 1);
}
@@ -336,20 +346,15 @@ HRESULT CDirectVobSubFilter::JoinFilterGraph(IFilterGraph* pGraph, LPCWSTR pName
}
/*removeme*/
- if(!g_RegOK)
- {
+ if(!g_RegOK) {
DllRegisterServer();
g_RegOK = true;
}
- }
- else
- {
- if(m_hSystrayThread)
- {
+ } else {
+ if(m_hSystrayThread) {
SendMessage(m_tbid.hSystrayWnd, WM_CLOSE, 0, 0);
- if(WaitForSingleObject(m_hSystrayThread, 10000) != WAIT_OBJECT_0)
- {
+ if(WaitForSingleObject(m_hSystrayThread, 10000) != WAIT_OBJECT_0) {
DbgLog((LOG_TRACE, 0, _T("CALL THE AMBULANCE!!!")));
TerminateThread(m_hSystrayThread, (DWORD)-1);
}
@@ -366,13 +371,15 @@ STDMETHODIMP CDirectVobSubFilter::QueryFilterInfo(FILTER_INFO* pInfo)
CheckPointer(pInfo, E_POINTER);
ValidateReadWritePtr(pInfo, sizeof(FILTER_INFO));
- if(!get_Forced())
+ if(!get_Forced()) {
return __super::QueryFilterInfo(pInfo);
+ }
wcscpy(pInfo->achName, L"DirectVobSub (forced auto-loading version)");
pInfo->pGraph = m_pGraph;
- if(m_pGraph)
+ if(m_pGraph) {
m_pGraph->AddRef();
+ }
return S_OK;
}
@@ -382,10 +389,11 @@ STDMETHODIMP CDirectVobSubFilter::QueryFilterInfo(FILTER_INFO* pInfo)
HRESULT CDirectVobSubFilter::SetMediaType(PIN_DIRECTION dir, const CMediaType* pmt)
{
HRESULT hr = __super::SetMediaType(dir, pmt);
- if(FAILED(hr)) return hr;
+ if(FAILED(hr)) {
+ return hr;
+ }
- if(dir == PINDIR_INPUT)
- {
+ if(dir == PINDIR_INPUT) {
CAutoLock cAutoLock(&m_csReceive);
REFERENCE_TIME atpf =
@@ -395,13 +403,12 @@ HRESULT CDirectVobSubFilter::SetMediaType(PIN_DIRECTION dir, const CMediaType* p
m_fps = atpf ? 10000000.0 / atpf : 25;
- if (pmt->formattype == FORMAT_VideoInfo2)
+ if (pmt->formattype == FORMAT_VideoInfo2) {
m_CurrentVIH2 = *(VIDEOINFOHEADER2*)pmt->Format();
+ }
InitSubPicQueue();
- }
- else if(dir == PINDIR_OUTPUT)
- {
+ } else if(dir == PINDIR_OUTPUT) {
}
@@ -410,11 +417,8 @@ HRESULT CDirectVobSubFilter::SetMediaType(PIN_DIRECTION dir, const CMediaType* p
HRESULT CDirectVobSubFilter::CheckConnect(PIN_DIRECTION dir, IPin* pPin)
{
- if(dir == PINDIR_INPUT)
- {
- }
- else if(dir == PINDIR_OUTPUT)
- {
+ if(dir == PINDIR_INPUT) {
+ } else if(dir == PINDIR_OUTPUT) {
}
return __super::CheckConnect(dir, pPin);
@@ -422,24 +426,19 @@ HRESULT CDirectVobSubFilter::CheckConnect(PIN_DIRECTION dir, IPin* pPin)
HRESULT CDirectVobSubFilter::CompleteConnect(PIN_DIRECTION dir, IPin* pReceivePin)
{
- if(dir == PINDIR_INPUT)
- {
+ if(dir == PINDIR_INPUT) {
CComPtr<IBaseFilter> pFilter;
// needed when we have a decoder with a version number of 3.x
if(SUCCEEDED(m_pGraph->FindFilterByName(L"DivX MPEG-4 DVD Video Decompressor ", &pFilter))
- && (GetFileVersion(_T("divx_c32.ax")) >> 48) <= 4
- || SUCCEEDED(m_pGraph->FindFilterByName(L"Microcrap MPEG-4 Video Decompressor", &pFilter))
- || SUCCEEDED(m_pGraph->FindFilterByName(L"Microsoft MPEG-4 Video Decompressor", &pFilter))
- && (GetFileVersion(_T("mpg4ds32.ax")) >> 48) <= 3)
- {
+ && (GetFileVersion(_T("divx_c32.ax")) >> 48) <= 4
+ || SUCCEEDED(m_pGraph->FindFilterByName(L"Microcrap MPEG-4 Video Decompressor", &pFilter))
+ || SUCCEEDED(m_pGraph->FindFilterByName(L"Microsoft MPEG-4 Video Decompressor", &pFilter))
+ && (GetFileVersion(_T("mpg4ds32.ax")) >> 48) <= 3) {
m_fMSMpeg4Fix = true;
}
- }
- else if(dir == PINDIR_OUTPUT)
- {
- if(!m_hSystrayThread)
- {
+ } else if(dir == PINDIR_OUTPUT) {
+ if(!m_hSystrayThread) {
m_tbid.graph = m_pGraph;
m_tbid.dvs = static_cast<IDirectVobSub*>(this);
@@ -456,16 +455,12 @@ HRESULT CDirectVobSubFilter::CompleteConnect(PIN_DIRECTION dir, IPin* pReceivePi
HRESULT CDirectVobSubFilter::BreakConnect(PIN_DIRECTION dir)
{
- if(dir == PINDIR_INPUT)
- {
- if(m_pOutput->IsConnected())
- {
+ if(dir == PINDIR_INPUT) {
+ if(m_pOutput->IsConnected()) {
m_pOutput->GetConnected()->Disconnect();
m_pOutput->Disconnect();
}
- }
- else if(dir == PINDIR_OUTPUT)
- {
+ } else if(dir == PINDIR_OUTPUT) {
// not really needed, but may free up a little memory
CAutoLock cAutoLock(&m_csQueueLock);
m_pSubPicQueue = NULL;
@@ -526,13 +521,21 @@ void CDirectVobSubFilter::InitSubPicQueue()
ExtractBIH(&m_pInput->CurrentMediaType(), &bihIn);
m_spd.type = -1;
- if(subtype == MEDIASUBTYPE_YV12) m_spd.type = MSP_YV12;
- else if(subtype == MEDIASUBTYPE_I420 || subtype == MEDIASUBTYPE_IYUV) m_spd.type = MSP_IYUV;
- else if(subtype == MEDIASUBTYPE_YUY2) m_spd.type = MSP_YUY2;
- else if(subtype == MEDIASUBTYPE_RGB32) m_spd.type = MSP_RGB32;
- else if(subtype == MEDIASUBTYPE_RGB24) m_spd.type = MSP_RGB24;
- else if(subtype == MEDIASUBTYPE_RGB565) m_spd.type = MSP_RGB16;
- else if(subtype == MEDIASUBTYPE_RGB555) m_spd.type = MSP_RGB15;
+ if(subtype == MEDIASUBTYPE_YV12) {
+ m_spd.type = MSP_YV12;
+ } else if(subtype == MEDIASUBTYPE_I420 || subtype == MEDIASUBTYPE_IYUV) {
+ m_spd.type = MSP_IYUV;
+ } else if(subtype == MEDIASUBTYPE_YUY2) {
+ m_spd.type = MSP_YUY2;
+ } else if(subtype == MEDIASUBTYPE_RGB32) {
+ m_spd.type = MSP_RGB32;
+ } else if(subtype == MEDIASUBTYPE_RGB24) {
+ m_spd.type = MSP_RGB24;
+ } else if(subtype == MEDIASUBTYPE_RGB565) {
+ m_spd.type = MSP_RGB16;
+ } else if(subtype == MEDIASUBTYPE_RGB555) {
+ m_spd.type = MSP_RGB15;
+ }
m_spd.w = m_w;
m_spd.h = m_h;
m_spd.bpp = (m_spd.type == MSP_YV12 || m_spd.type == MSP_IYUV) ? 8 : bihIn.biBitCount;
@@ -542,7 +545,9 @@ void CDirectVobSubFilter::InitSubPicQueue()
CComPtr<ISubPicAllocator> pSubPicAllocator = new CMemSubPicAllocator(m_spd.type, CSize(m_w, m_h));
CSize video(bihIn.biWidth, bihIn.biHeight), window = video;
- if(AdjustFrameSize(window)) video += video;
+ if(AdjustFrameSize(window)) {
+ video += video;
+ }
ASSERT(window == CSize(m_w, m_h));
pSubPicAllocator->SetCurSize(window);
@@ -553,7 +558,9 @@ void CDirectVobSubFilter::InitSubPicQueue()
? (ISubPicQueue*)new CSubPicQueue(10, false, pSubPicAllocator, &hr)
: (ISubPicQueue*)new CSubPicQueueNoThread(pSubPicAllocator, &hr);
- if(FAILED(hr)) m_pSubPicQueue = NULL;
+ if(FAILED(hr)) {
+ m_pSubPicQueue = NULL;
+ }
UpdateSubtitle(false);
@@ -585,35 +592,40 @@ bool CDirectVobSubFilter::AdjustFrameSize(CSize& s)
bool fRet = (resx2 == 1) || (resx2 == 2 && s.cx*s.cy <= resx2minw*resx2minh);
- if(fRet)
- {
+ if(fRet) {
s.cx <<= 1;
s.cy <<= 1;
}
int h;
- switch(vertical&0x7f)
- {
- case 1:
- h = s.cx * 9 / 16;
- if(s.cy < h || !!(vertical&0x80)) s.cy = (h + 3) & ~3;
- break;
- case 2:
- h = s.cx * 3 / 4;
- if(s.cy < h || !!(vertical&0x80)) s.cy = (h + 3) & ~3;
- break;
- case 3:
- h = 480;
- if(s.cy < h || !!(vertical&0x80)) s.cy = (h + 3) & ~3;
- break;
- case 4:
- h = 576;
- if(s.cy < h || !!(vertical&0x80)) s.cy = (h + 3) & ~3;
- break;
- }
-
- if(horizontal == 1)
- {
+ switch(vertical&0x7f) {
+ case 1:
+ h = s.cx * 9 / 16;
+ if(s.cy < h || !!(vertical&0x80)) {
+ s.cy = (h + 3) & ~3;
+ }
+ break;
+ case 2:
+ h = s.cx * 3 / 4;
+ if(s.cy < h || !!(vertical&0x80)) {
+ s.cy = (h + 3) & ~3;
+ }
+ break;
+ case 3:
+ h = 480;
+ if(s.cy < h || !!(vertical&0x80)) {
+ s.cy = (h + 3) & ~3;
+ }
+ break;
+ case 4:
+ h = 576;
+ if(s.cy < h || !!(vertical&0x80)) {
+ s.cy = (h + 3) & ~3;
+ }
+ break;
+ }
+
+ if(horizontal == 1) {
s.cx = (s.cx + 31) & ~31;
s.cy = (s.cy + 1) & ~1;
}
@@ -623,13 +635,16 @@ bool CDirectVobSubFilter::AdjustFrameSize(CSize& s)
STDMETHODIMP CDirectVobSubFilter::Count(DWORD* pcStreams)
{
- if(!pcStreams) return E_POINTER;
+ if(!pcStreams) {
+ return E_POINTER;
+ }
*pcStreams = 0;
int nLangs = 0;
- if(SUCCEEDED(get_LanguageCount(&nLangs)))
+ if(SUCCEEDED(get_LanguageCount(&nLangs))) {
(*pcStreams) += nLangs;
+ }
(*pcStreams) += 2; // enable ... disable
@@ -647,26 +662,27 @@ int CDirectVobSubFilter::FindPreferedLanguage(bool fHideToo)
int nLangs;
get_LanguageCount(&nLangs);
- if(nLangs <= 0) return(0);
+ if(nLangs <= 0) {
+ return(0);
+ }
- for(ptrdiff_t i = 0; i < MAXPREFLANGS; i++)
- {
+ for(ptrdiff_t i = 0; i < MAXPREFLANGS; i++) {
CString tmp;
tmp.Format(IDS_RL_LANG, i);
CString lang = theApp.GetProfileString(ResStr(IDS_R_PREFLANGS), tmp);
- if(!lang.IsEmpty())
- {
- for(ptrdiff_t ret = 0; ret < nLangs; ret++)
- {
+ if(!lang.IsEmpty()) {
+ for(ptrdiff_t ret = 0; ret < nLangs; ret++) {
CString l;
WCHAR* pName = NULL;
get_LanguageName(ret, &pName);
l = pName;
CoTaskMemFree(pName);
- if(!l.CompareNoCase(lang)) return(ret);
+ if(!l.CompareNoCase(lang)) {
+ return(ret);
+ }
}
}
}
@@ -681,30 +697,28 @@ void CDirectVobSubFilter::UpdatePreferedLanguages(CString l)
CString langs[MAXPREFLANGS+1];
int i = 0, j = 0, k = -1;
- for(; i < MAXPREFLANGS; i++)
- {
+ for(; i < MAXPREFLANGS; i++) {
CString tmp;
tmp.Format(IDS_RL_LANG, i);
langs[j] = theApp.GetProfileString(ResStr(IDS_R_PREFLANGS), tmp);
- if(!langs[j].IsEmpty())
- {
- if(!langs[j].CompareNoCase(l)) k = j;
+ if(!langs[j].IsEmpty()) {
+ if(!langs[j].CompareNoCase(l)) {
+ k = j;
+ }
j++;
}
}
- if(k == -1)
- {
+ if(k == -1) {
langs[k = j] = l;
j++;
}
// move the selected to the top of the list
- while(k > 0)
- {
+ while(k > 0) {
CString tmp = langs[k];
langs[k] = langs[k-1];
langs[k-1] = tmp;
@@ -716,21 +730,20 @@ void CDirectVobSubFilter::UpdatePreferedLanguages(CString l)
CString hidesubs;
hidesubs.LoadString(IDS_M_HIDESUBTITLES);
- for(k = 1; k < j; k++)
- {
- if(!langs[k].CompareNoCase(hidesubs)) break;
+ for(k = 1; k < j; k++) {
+ if(!langs[k].CompareNoCase(hidesubs)) {
+ break;
+ }
}
- while(k < j-1)
- {
+ while(k < j-1) {
CString tmp = langs[k];
langs[k] = langs[k+1];
langs[k+1] = tmp;
k++;
}
- for(i = 0; i < j; i++)
- {
+ for(i = 0; i < j; i++) {
CString tmp;
tmp.Format(IDS_RL_LANG, i);
@@ -740,39 +753,35 @@ void CDirectVobSubFilter::UpdatePreferedLanguages(CString l)
STDMETHODIMP CDirectVobSubFilter::Enable(long lIndex, DWORD dwFlags)
{
- if(!(dwFlags & AMSTREAMSELECTENABLE_ENABLE))
+ if(!(dwFlags & AMSTREAMSELECTENABLE_ENABLE)) {
return E_NOTIMPL;
+ }
int nLangs = 0;
get_LanguageCount(&nLangs);
- if(!(lIndex >= 0 && lIndex < nLangs+2+2))
+ if(!(lIndex >= 0 && lIndex < nLangs+2+2)) {
return E_INVALIDARG;
+ }
int i = lIndex-1;
- if(i == -1 && !m_fLoading) // we need this because when loading something stupid media player pushes the first stream it founds, which is "enable" in our case
- {
+ if(i == -1 && !m_fLoading) { // we need this because when loading something stupid media player pushes the first stream it founds, which is "enable" in our case
put_HideSubtitles(false);
- }
- else if(i >= 0 && i < nLangs)
- {
+ } else if(i >= 0 && i < nLangs) {
put_HideSubtitles(false);
put_SelectedLanguage(i);
WCHAR* pName = NULL;
- if(SUCCEEDED(get_LanguageName(i, &pName)))
- {
+ if(SUCCEEDED(get_LanguageName(i, &pName))) {
UpdatePreferedLanguages(CString(pName));
- if(pName) CoTaskMemFree(pName);
+ if(pName) {
+ CoTaskMemFree(pName);
+ }
}
- }
- else if(i == nLangs && !m_fLoading)
- {
+ } else if(i == nLangs && !m_fLoading) {
put_HideSubtitles(true);
- }
- else if((i == nLangs+1 || i == nLangs+2) && !m_fLoading)
- {
+ } else if((i == nLangs+1 || i == nLangs+2) && !m_fLoading) {
put_Flip(i == nLangs+2, m_fFlipSubtitles);
}
@@ -786,66 +795,83 @@ STDMETHODIMP CDirectVobSubFilter::Info(long lIndex, AM_MEDIA_TYPE** ppmt, DWORD*
int nLangs = 0;
get_LanguageCount(&nLangs);
- if(!(lIndex >= 0 && lIndex < nLangs+2+2))
+ if(!(lIndex >= 0 && lIndex < nLangs+2+2)) {
return E_INVALIDARG;
+ }
int i = lIndex-1;
- if(ppmt) *ppmt = CreateMediaType(&m_pInput->CurrentMediaType());
+ if(ppmt) {
+ *ppmt = CreateMediaType(&m_pInput->CurrentMediaType());
+ }
- if(pdwFlags)
- {
+ if(pdwFlags) {
*pdwFlags = 0;
if(i == -1 && !m_fHideSubtitles
- || i >= 0 && i < nLangs && i == m_iSelectedLanguage
- || i == nLangs && m_fHideSubtitles
- || i == nLangs+1 && !m_fFlipPicture
- || i == nLangs+2 && m_fFlipPicture)
- {
+ || i >= 0 && i < nLangs && i == m_iSelectedLanguage
+ || i == nLangs && m_fHideSubtitles
+ || i == nLangs+1 && !m_fFlipPicture
+ || i == nLangs+2 && m_fFlipPicture) {
*pdwFlags |= AMSTREAMSELECTINFO_ENABLED;
}
}
- if(plcid) *plcid = 0;
+ if(plcid) {
+ *plcid = 0;
+ }
- if(pdwGroup) *pdwGroup = 0x648E51;
+ if(pdwGroup) {
+ *pdwGroup = 0x648E51;
+ }
- if(ppszName)
- {
+ if(ppszName) {
*ppszName = NULL;
CStringW str;
- if(i == -1) str = ResStr(IDS_M_SHOWSUBTITLES);
- else if(i >= 0 && i < nLangs) get_LanguageName(i, ppszName);
- else if(i == nLangs) str = ResStr(IDS_M_HIDESUBTITLES);
- else if(i == nLangs+1) {
+ if(i == -1) {
+ str = ResStr(IDS_M_SHOWSUBTITLES);
+ } else if(i >= 0 && i < nLangs) {
+ get_LanguageName(i, ppszName);
+ } else if(i == nLangs) {
+ str = ResStr(IDS_M_HIDESUBTITLES);
+ } else if(i == nLangs+1) {
str = ResStr(IDS_M_ORIGINALPICTURE);
- if(pdwGroup) (*pdwGroup)++;
- }
- else if(i == nLangs+2) {
+ if(pdwGroup) {
+ (*pdwGroup)++;
+ }
+ } else if(i == nLangs+2) {
str = ResStr(IDS_M_FLIPPEDPICTURE);
- if(pdwGroup) (*pdwGroup)++;
+ if(pdwGroup) {
+ (*pdwGroup)++;
+ }
}
- if(!str.IsEmpty())
- {
+ if(!str.IsEmpty()) {
*ppszName = (WCHAR*)CoTaskMemAlloc((str.GetLength()+1)*sizeof(WCHAR));
- if(*ppszName == NULL) return S_FALSE;
+ if(*ppszName == NULL) {
+ return S_FALSE;
+ }
wcscpy(*ppszName, str);
}
}
- if(ppObject) *ppObject = NULL;
+ if(ppObject) {
+ *ppObject = NULL;
+ }
- if(ppUnk) *ppUnk = NULL;
+ if(ppUnk) {
+ *ppUnk = NULL;
+ }
return S_OK;
}
STDMETHODIMP CDirectVobSubFilter::GetClassID(CLSID* pClsid)
{
- if(pClsid == NULL) return E_POINTER;
+ if(pClsid == NULL) {
+ return E_POINTER;
+ }
*pClsid = m_clsid;
return NOERROR;
}
@@ -857,7 +883,9 @@ STDMETHODIMP CDirectVobSubFilter::GetPages(CAUUID* pPages)
pPages->cElems = 7;
pPages->pElems = (GUID*)CoTaskMemAlloc(sizeof(GUID)*pPages->cElems);
- if(pPages->pElems == NULL) return E_OUTOFMEMORY;
+ if(pPages->pElems == NULL) {
+ return E_OUTOFMEMORY;
+ }
int i = 0;
pPages->pElems[i++] = __uuidof(CDVSMainPPage);
@@ -877,8 +905,7 @@ STDMETHODIMP CDirectVobSubFilter::put_FileName(WCHAR* fn)
{
HRESULT hr = CDirectVobSub::put_FileName(fn);
- if(hr == S_OK && !Open())
- {
+ if(hr == S_OK && !Open()) {
m_FileName.Empty();
hr = E_FAIL;
}
@@ -890,13 +917,14 @@ STDMETHODIMP CDirectVobSubFilter::get_LanguageCount(int* nLangs)
{
HRESULT hr = CDirectVobSub::get_LanguageCount(nLangs);
- if(hr == NOERROR && nLangs)
- {
+ if(hr == NOERROR && nLangs) {
CAutoLock cAutolock(&m_csQueueLock);
*nLangs = 0;
POSITION pos = m_pSubStreams.GetHeadPosition();
- while(pos) (*nLangs) += m_pSubStreams.GetNext(pos)->GetStreamCount();
+ while(pos) {
+ (*nLangs) += m_pSubStreams.GetNext(pos)->GetStreamCount();
+ }
}
return hr;
@@ -906,10 +934,11 @@ STDMETHODIMP CDirectVobSubFilter::get_LanguageName(int iLanguage, WCHAR** ppName
{
HRESULT hr = CDirectVobSub::get_LanguageName(iLanguage, ppName);
- if(!ppName) return E_POINTER;
+ if(!ppName) {
+ return E_POINTER;
+ }
- if(hr == NOERROR)
- {
+ if(hr == NOERROR) {
CAutoLock cAutolock(&m_csQueueLock);
hr = E_INVALIDARG;
@@ -917,12 +946,10 @@ STDMETHODIMP CDirectVobSubFilter::get_LanguageName(int iLanguage, WCHAR** ppName
int i = iLanguage;
POSITION pos = m_pSubStreams.GetHeadPosition();
- while(i >= 0 && pos)
- {
+ while(i >= 0 && pos) {
CComPtr<ISubStream> pSubStream = m_pSubStreams.GetNext(pos);
- if(i < pSubStream->GetStreamCount())
- {
+ if(i < pSubStream->GetStreamCount()) {
pSubStream->GetStreamInfo(i, ppName, NULL);
hr = NOERROR;
break;
@@ -939,8 +966,7 @@ STDMETHODIMP CDirectVobSubFilter::put_SelectedLanguage(int iSelected)
{
HRESULT hr = CDirectVobSub::put_SelectedLanguage(iSelected);
- if(hr == NOERROR)
- {
+ if(hr == NOERROR) {
UpdateSubtitle(false);
}
@@ -951,8 +977,7 @@ STDMETHODIMP CDirectVobSubFilter::put_HideSubtitles(bool fHideSubtitles)
{
HRESULT hr = CDirectVobSub::put_HideSubtitles(fHideSubtitles);
- if(hr == NOERROR)
- {
+ if(hr == NOERROR) {
UpdateSubtitle(false);
}
@@ -963,8 +988,7 @@ STDMETHODIMP CDirectVobSubFilter::put_PreBuffering(bool fDoPreBuffering)
{
HRESULT hr = CDirectVobSub::put_PreBuffering(fDoPreBuffering);
- if(hr == NOERROR)
- {
+ if(hr == NOERROR) {
InitSubPicQueue();
}
@@ -975,8 +999,7 @@ STDMETHODIMP CDirectVobSubFilter::put_Placement(bool fOverridePlacement, int xpe
{
HRESULT hr = CDirectVobSub::put_Placement(fOverridePlacement, xperc, yperc);
- if(hr == NOERROR)
- {
+ if(hr == NOERROR) {
UpdateSubtitle(true);
}
@@ -987,9 +1010,8 @@ STDMETHODIMP CDirectVobSubFilter::put_VobSubSettings(bool fBuffer, bool fOnlySho
{
HRESULT hr = CDirectVobSub::put_VobSubSettings(fBuffer, fOnlyShowForcedSubs, fReserved);
- if(hr == NOERROR)
- {
-// UpdateSubtitle(false);
+ if(hr == NOERROR) {
+ // UpdateSubtitle(false);
InvalidateSubtitle();
}
@@ -1000,9 +1022,8 @@ STDMETHODIMP CDirectVobSubFilter::put_TextSettings(void* lf, int lflen, COLORREF
{
HRESULT hr = CDirectVobSub::put_TextSettings(lf, lflen, color, fShadow, fOutline, fAdvancedRenderer);
- if(hr == NOERROR)
- {
-// UpdateSubtitle(true);
+ if(hr == NOERROR) {
+ // UpdateSubtitle(true);
InvalidateSubtitle();
}
@@ -1013,8 +1034,7 @@ STDMETHODIMP CDirectVobSubFilter::put_SubtitleTiming(int delay, int speedmul, in
{
HRESULT hr = CDirectVobSub::put_SubtitleTiming(delay, speedmul, speeddiv);
- if(hr == NOERROR)
- {
+ if(hr == NOERROR) {
InvalidateSubtitle();
}
@@ -1027,10 +1047,11 @@ STDMETHODIMP CDirectVobSubFilter::get_MediaFPS(bool* fEnabled, double* fps)
CComQIPtr<IMediaSeeking> pMS = m_pGraph;
double rate;
- if(pMS && SUCCEEDED(pMS->GetRate(&rate)))
- {
+ if(pMS && SUCCEEDED(pMS->GetRate(&rate))) {
m_MediaFPS = rate * m_fps;
- if(fps) *fps = m_MediaFPS;
+ if(fps) {
+ *fps = m_MediaFPS;
+ }
}
return hr;
@@ -1041,16 +1062,15 @@ STDMETHODIMP CDirectVobSubFilter::put_MediaFPS(bool fEnabled, double fps)
HRESULT hr = CDirectVobSub::put_MediaFPS(fEnabled, fps);
CComQIPtr<IMediaSeeking> pMS = m_pGraph;
- if(pMS)
- {
- if(hr == NOERROR)
- {
+ if(pMS) {
+ if(hr == NOERROR) {
hr = pMS->SetRate(m_fMediaFPSEnabled ? m_MediaFPS / m_fps : 1.0);
}
double dRate;
- if(SUCCEEDED(pMS->GetRate(&dRate)))
+ if(SUCCEEDED(pMS->GetRate(&dRate))) {
m_MediaFPS = dRate * m_fps;
+ }
}
return hr;
@@ -1072,8 +1092,7 @@ STDMETHODIMP CDirectVobSubFilter::put_TextSettings(STSStyle* pDefStyle)
{
HRESULT hr = CDirectVobSub::put_TextSettings(pDefStyle);
- if(hr == NOERROR)
- {
+ if(hr == NOERROR) {
UpdateSubtitle(true);
}
@@ -1084,8 +1103,7 @@ STDMETHODIMP CDirectVobSubFilter::put_AspectRatioSettings(CSimpleTextSubtitle::E
{
HRESULT hr = CDirectVobSub::put_AspectRatioSettings(ePARCompensationType);
- if(hr == NOERROR)
- {
+ if(hr == NOERROR) {
UpdateSubtitle(true);
}
@@ -1097,10 +1115,12 @@ STDMETHODIMP CDirectVobSubFilter::put_AspectRatioSettings(CSimpleTextSubtitle::E
STDMETHODIMP CDirectVobSubFilter::HasConfigDialog(int iSelected)
{
int nLangs;
- if(FAILED(get_LanguageCount(&nLangs))) return E_FAIL;
+ if(FAILED(get_LanguageCount(&nLangs))) {
+ return E_FAIL;
+ }
return E_FAIL;
// TODO: temporally disabled since we don't have a new textsub/vobsub editor dlg for dvs yet
-// return(nLangs >= 0 && iSelected < nLangs ? S_OK : E_FAIL);
+ // return(nLangs >= 0 && iSelected < nLangs ? S_OK : E_FAIL);
}
STDMETHODIMP CDirectVobSubFilter::ShowConfigDialog(int iSelected, HWND hWndParent)
@@ -1119,19 +1139,21 @@ CDirectVobSubFilter2::CDirectVobSubFilter2(LPUNKNOWN punk, HRESULT* phr, const G
HRESULT CDirectVobSubFilter2::CheckConnect(PIN_DIRECTION dir, IPin* pPin)
{
CPinInfo pi;
- if(FAILED(pPin->QueryPinInfo(&pi))) return E_FAIL;
+ if(FAILED(pPin->QueryPinInfo(&pi))) {
+ return E_FAIL;
+ }
- if(CComQIPtr<IDirectVobSub>(pi.pFilter)) return E_FAIL;
+ if(CComQIPtr<IDirectVobSub>(pi.pFilter)) {
+ return E_FAIL;
+ }
- if(dir == PINDIR_INPUT)
- {
+ if(dir == PINDIR_INPUT) {
CFilterInfo fi;
if(SUCCEEDED(pi.pFilter->QueryFilterInfo(&fi))
- && !wcsnicmp(fi.achName, L"Overlay Mixer", 13))
+ && !wcsnicmp(fi.achName, L"Overlay Mixer", 13)) {
return(E_FAIL);
- }
- else
- {
+ }
+ } else {
}
return __super::CheckConnect(dir, pPin);
@@ -1139,12 +1161,11 @@ HRESULT CDirectVobSubFilter2::CheckConnect(PIN_DIRECTION dir, IPin* pPin)
HRESULT CDirectVobSubFilter2::JoinFilterGraph(IFilterGraph* pGraph, LPCWSTR pName)
{
- if(pGraph)
- {
- BeginEnumFilters(pGraph, pEF, pBF)
- {
- if(pBF != (IBaseFilter*)this && CComQIPtr<IDirectVobSub>(pBF))
+ if(pGraph) {
+ BeginEnumFilters(pGraph, pEF, pBF) {
+ if(pBF != (IBaseFilter*)this && CComQIPtr<IDirectVobSub>(pBF)) {
return E_FAIL;
+ }
}
EndEnumFilters
@@ -1158,31 +1179,32 @@ HRESULT CDirectVobSubFilter2::JoinFilterGraph(IFilterGraph* pGraph, LPCWSTR pNam
// This whole workaround is needed because the video stream will always be connected
// to the pre-added filters first, no matter how high merit we have.
- if(!get_Forced())
- {
- BeginEnumFilters(pGraph, pEF, pBF)
- {
- if(CComQIPtr<IDirectVobSub>(pBF))
+ if(!get_Forced()) {
+ BeginEnumFilters(pGraph, pEF, pBF) {
+ if(CComQIPtr<IDirectVobSub>(pBF)) {
continue;
+ }
CComPtr<IPin> pInPin = GetFirstPin(pBF, PINDIR_INPUT);
CComPtr<IPin> pOutPin = GetFirstPin(pBF, PINDIR_OUTPUT);
- if(!pInPin)
+ if(!pInPin) {
continue;
+ }
CComPtr<IPin> pPin;
if(pInPin && SUCCEEDED(pInPin->ConnectedTo(&pPin))
- || pOutPin && SUCCEEDED(pOutPin->ConnectedTo(&pPin)))
+ || pOutPin && SUCCEEDED(pOutPin->ConnectedTo(&pPin))) {
continue;
+ }
- if(pOutPin && GetFilterName(pBF) == _T("Overlay Mixer"))
+ if(pOutPin && GetFilterName(pBF) == _T("Overlay Mixer")) {
continue;
+ }
bool fVideoInputPin = false;
- do
- {
+ do {
BITMAPINFOHEADER bih = {sizeof(BITMAPINFOHEADER), 384, 288, 1, 16, '2YUY', 384*288*2, 0, 0, 0, 0};
CMediaType cmt;
@@ -1198,8 +1220,7 @@ HRESULT CDirectVobSubFilter2::JoinFilterGraph(IFilterGraph* pGraph, LPCWSTR pNam
memcpy(&vih->bmiHeader, &bih, sizeof(bih));
vih->AvgTimePerFrame = 400000;
- if(SUCCEEDED(pInPin->QueryAccept(&cmt)))
- {
+ if(SUCCEEDED(pInPin->QueryAccept(&cmt))) {
fVideoInputPin = true;
break;
}
@@ -1211,19 +1232,15 @@ HRESULT CDirectVobSubFilter2::JoinFilterGraph(IFilterGraph* pGraph, LPCWSTR pNam
vih2->dwPictAspectRatioX = 384;
vih2->dwPictAspectRatioY = 288;
- if(SUCCEEDED(pInPin->QueryAccept(&cmt)))
- {
+ if(SUCCEEDED(pInPin->QueryAccept(&cmt))) {
fVideoInputPin = true;
break;
}
- }
- while(false);
+ } while(false);
- if(fVideoInputPin)
- {
+ if(fVideoInputPin) {
CComPtr<IBaseFilter> pDVS;
- if(ShouldWeAutoload(pGraph) && SUCCEEDED(pDVS.CoCreateInstance(__uuidof(CDirectVobSubFilter2))))
- {
+ if(ShouldWeAutoload(pGraph) && SUCCEEDED(pDVS.CoCreateInstance(__uuidof(CDirectVobSubFilter2)))) {
CComQIPtr<IDirectVobSub2>(pDVS)->put_Forced(true);
CComQIPtr<IGraphConfig>(pGraph)->AddFilterToCache(pDVS);
}
@@ -1233,9 +1250,7 @@ HRESULT CDirectVobSubFilter2::JoinFilterGraph(IFilterGraph* pGraph, LPCWSTR pNam
}
EndEnumFilters
}
- }
- else
- {
+ } else {
}
return __super::JoinFilterGraph(pGraph, pName);
@@ -1245,9 +1260,13 @@ HRESULT CDirectVobSubFilter2::CheckInputType(const CMediaType* mtIn)
{
HRESULT hr = __super::CheckInputType(mtIn);
- if(FAILED(hr) || m_pInput->IsConnected()) return hr;
+ if(FAILED(hr) || m_pInput->IsConnected()) {
+ return hr;
+ }
- if(!ShouldWeAutoload(m_pGraph)) return VFW_E_TYPE_NOT_ACCEPTED;
+ if(!ShouldWeAutoload(m_pGraph)) {
+ return VFW_E_TYPE_NOT_ACCEPTED;
+ }
GetRidOfInternalScriptRenderer();
@@ -1256,8 +1275,7 @@ HRESULT CDirectVobSubFilter2::CheckInputType(const CMediaType* mtIn)
bool CDirectVobSubFilter2::ShouldWeAutoload(IFilterGraph* pGraph)
{
- TCHAR blacklistedapps[][32] =
- {
+ TCHAR blacklistedapps[][32] = {
_T("WM8EUTIL."), // wmp8 encoder's dummy renderer releases the outputted media sample after calling Receive on its input pin (yes, even when dvobsub isn't registered at all)
_T("explorer."), // as some users reported thumbnail preview loads dvobsub, I've never experienced this yet...
_T("producer."), // this is real's producer
@@ -1266,54 +1284,54 @@ bool CDirectVobSubFilter2::ShouldWeAutoload(IFilterGraph* pGraph)
_T("GoogleDesktopCrawl."), // Google Desktop
};
- for(ptrdiff_t i = 0; i < countof(blacklistedapps); i++)
- {
- if(theApp.m_AppName.Find(blacklistedapps[i]) >= 0)
+ for(ptrdiff_t i = 0; i < countof(blacklistedapps); i++) {
+ if(theApp.m_AppName.Find(blacklistedapps[i]) >= 0) {
return(false);
+ }
}
int level;
bool m_fExternalLoad, m_fWebLoad, m_fEmbeddedLoad;
get_LoadSettings(&level, &m_fExternalLoad, &m_fWebLoad, &m_fEmbeddedLoad);
- if(level < 0 || level >= 2) return(false);
+ if(level < 0 || level >= 2) {
+ return(false);
+ }
bool fRet = false;
- if(level == 1)
+ if(level == 1) {
fRet = m_fExternalLoad = m_fWebLoad = m_fEmbeddedLoad = true;
+ }
// find text stream on known splitters
- if(!fRet && m_fEmbeddedLoad)
- {
+ if(!fRet && m_fEmbeddedLoad) {
CComPtr<IBaseFilter> pBF;
if((pBF = FindFilter(CLSID_OggSplitter, pGraph)) || (pBF = FindFilter(CLSID_AviSplitter, pGraph))
- || (pBF = FindFilter(L"{34293064-02F2-41D5-9D75-CC5967ACA1AB}", pGraph)) // matroska demux
- || (pBF = FindFilter(L"{0A68C3B5-9164-4a54-AFAF-995B2FF0E0D4}", pGraph)) // matroska source
- || (pBF = FindFilter(L"{149D2E01-C32E-4939-80F6-C07B81015A7A}", pGraph)) // matroska splitter
- || (pBF = FindFilter(L"{9AB95E90-1F37-427e-9B3D-257FB0CB25F7}", pGraph)) // Haali's matroska splitter (?)
- || (pBF = FindFilter(L"{55DA30FC-F16B-49fc-BAA5-AE59FC65F82D}", pGraph)) // Haali's matroska splitter
- || (pBF = FindFilter(L"{52B63861-DC93-11CE-A099-00AA00479A58}", pGraph)) // 3ivx splitter
- || (pBF = FindFilter(L"{6D3688CE-3E9D-42F4-92CA-8A11119D25CD}", pGraph)) // our ogg source
- || (pBF = FindFilter(L"{9FF48807-E133-40AA-826F-9B2959E5232D}", pGraph)) // our ogg splitter
- || (pBF = FindFilter(L"{803E8280-F3CE-4201-982C-8CD8FB512004}", pGraph)) // dsm source
- || (pBF = FindFilter(L"{0912B4DD-A30A-4568-B590-7179EBB420EC}", pGraph)) // dsm splitter
- || (pBF = FindFilter(L"{3CCC052E-BDEE-408a-BEA7-90914EF2964B}", pGraph)) // mp4 source
- || (pBF = FindFilter(L"{61F47056-E400-43d3-AF1E-AB7DFFD4C4AD}", pGraph))) // mp4 splitter
- {
- BeginEnumPins(pBF, pEP, pPin)
- {
- BeginEnumMediaTypes(pPin, pEM, pmt)
- {
- if(pmt->majortype == MEDIATYPE_Text || pmt->majortype == MEDIATYPE_Subtitle)
- {
+ || (pBF = FindFilter(L"{34293064-02F2-41D5-9D75-CC5967ACA1AB}", pGraph)) // matroska demux
+ || (pBF = FindFilter(L"{0A68C3B5-9164-4a54-AFAF-995B2FF0E0D4}", pGraph)) // matroska source
+ || (pBF = FindFilter(L"{149D2E01-C32E-4939-80F6-C07B81015A7A}", pGraph)) // matroska splitter
+ || (pBF = FindFilter(L"{9AB95E90-1F37-427e-9B3D-257FB0CB25F7}", pGraph)) // Haali's matroska splitter (?)
+ || (pBF = FindFilter(L"{55DA30FC-F16B-49fc-BAA5-AE59FC65F82D}", pGraph)) // Haali's matroska splitter
+ || (pBF = FindFilter(L"{52B63861-DC93-11CE-A099-00AA00479A58}", pGraph)) // 3ivx splitter
+ || (pBF = FindFilter(L"{6D3688CE-3E9D-42F4-92CA-8A11119D25CD}", pGraph)) // our ogg source
+ || (pBF = FindFilter(L"{9FF48807-E133-40AA-826F-9B2959E5232D}", pGraph)) // our ogg splitter
+ || (pBF = FindFilter(L"{803E8280-F3CE-4201-982C-8CD8FB512004}", pGraph)) // dsm source
+ || (pBF = FindFilter(L"{0912B4DD-A30A-4568-B590-7179EBB420EC}", pGraph)) // dsm splitter
+ || (pBF = FindFilter(L"{3CCC052E-BDEE-408a-BEA7-90914EF2964B}", pGraph)) // mp4 source
+ || (pBF = FindFilter(L"{61F47056-E400-43d3-AF1E-AB7DFFD4C4AD}", pGraph))) { // mp4 splitter
+ BeginEnumPins(pBF, pEP, pPin) {
+ BeginEnumMediaTypes(pPin, pEM, pmt) {
+ if(pmt->majortype == MEDIATYPE_Text || pmt->majortype == MEDIATYPE_Subtitle) {
fRet = true;
break;
}
}
EndEnumMediaTypes(pmt)
- if(fRet) break;
+ if(fRet) {
+ break;
+ }
}
EndEnumFilters
}
@@ -1323,13 +1341,12 @@ bool CDirectVobSubFilter2::ShouldWeAutoload(IFilterGraph* pGraph)
CStringW fn;
- BeginEnumFilters(pGraph, pEF, pBF)
- {
- if(CComQIPtr<IFileSourceFilter> pFSF = pBF)
- {
+ BeginEnumFilters(pGraph, pEF, pBF) {
+ if(CComQIPtr<IFileSourceFilter> pFSF = pBF) {
LPOLESTR fnw = NULL;
- if(!pFSF || FAILED(pFSF->GetCurFile(&fnw, NULL)) || !fnw)
+ if(!pFSF || FAILED(pFSF->GetCurFile(&fnw, NULL)) || !fnw) {
continue;
+ }
fn = CString(fnw);
CoTaskMemFree(fnw);
break;
@@ -1337,13 +1354,14 @@ bool CDirectVobSubFilter2::ShouldWeAutoload(IFilterGraph* pGraph)
}
EndEnumFilters
- if((m_fExternalLoad || m_fWebLoad) && (m_fWebLoad || !(wcsstr(fn, L"http://") || wcsstr(fn, L"mms://"))))
- {
+ if((m_fExternalLoad || m_fWebLoad) && (m_fWebLoad || !(wcsstr(fn, L"http://") || wcsstr(fn, L"mms://")))) {
bool fTemp = m_fHideSubtitles;
fRet = !fn.IsEmpty() && SUCCEEDED(put_FileName((LPWSTR)(LPCWSTR)fn))
|| SUCCEEDED(put_FileName(L"c:\\tmp.srt"))
|| fRet;
- if(fTemp) m_fHideSubtitles = true;
+ if(fTemp) {
+ m_fHideSubtitles = true;
+ }
}
return(fRet);
@@ -1351,16 +1369,13 @@ bool CDirectVobSubFilter2::ShouldWeAutoload(IFilterGraph* pGraph)
void CDirectVobSubFilter2::GetRidOfInternalScriptRenderer()
{
- while(CComPtr<IBaseFilter> pBF = FindFilter(L"{48025243-2D39-11CE-875D-00608CB78066}", m_pGraph))
- {
- BeginEnumPins(pBF, pEP, pPin)
- {
+ while(CComPtr<IBaseFilter> pBF = FindFilter(L"{48025243-2D39-11CE-875D-00608CB78066}", m_pGraph)) {
+ BeginEnumPins(pBF, pEP, pPin) {
PIN_DIRECTION dir;
CComPtr<IPin> pPinTo;
if(SUCCEEDED(pPin->QueryDirection(&dir)) && dir == PINDIR_INPUT
- && SUCCEEDED(pPin->ConnectedTo(&pPinTo)))
- {
+ && SUCCEEDED(pPin->ConnectedTo(&pPinTo))) {
m_pGraph->Disconnect(pPinTo);
m_pGraph->Disconnect(pPin);
m_pGraph->ConnectDirect(pPinTo, GetPin(2 + m_pTextInput.GetCount()-1), NULL);
@@ -1368,8 +1383,9 @@ void CDirectVobSubFilter2::GetRidOfInternalScriptRenderer()
}
EndEnumPins
- if(FAILED(m_pGraph->RemoveFilter(pBF)))
+ if(FAILED(m_pGraph->RemoveFilter(pBF))) {
break;
+ }
}
}
@@ -1387,68 +1403,63 @@ bool CDirectVobSubFilter::Open()
CAtlArray<CString> paths;
- for(ptrdiff_t i = 0; i < 10; i++)
- {
+ for(ptrdiff_t i = 0; i < 10; i++) {
CString tmp;
tmp.Format(IDS_RP_PATH, i);
CString path = theApp.GetProfileString(ResStr(IDS_R_DEFTEXTPATHES), tmp);
- if(!path.IsEmpty()) paths.Add(path);
+ if(!path.IsEmpty()) {
+ paths.Add(path);
+ }
}
CAtlArray<SubFile> ret;
GetSubFileNames(m_FileName, paths, ret);
- for(ptrdiff_t i = 0; i < ret.GetCount(); i++)
- {
- if(m_frd.files.Find(ret[i].fn))
+ for(ptrdiff_t i = 0; i < ret.GetCount(); i++) {
+ if(m_frd.files.Find(ret[i].fn)) {
continue;
+ }
CComPtr<ISubStream> pSubStream;
- if(!pSubStream)
- {
+ if(!pSubStream) {
CAutoPtr<CVobSubFile> pVSF(new CVobSubFile(&m_csSubLock));
- if(pVSF && pVSF->Open(ret[i].fn) && pVSF->GetStreamCount() > 0)
- {
+ if(pVSF && pVSF->Open(ret[i].fn) && pVSF->GetStreamCount() > 0) {
pSubStream = pVSF.Detach();
m_frd.files.AddTail(ret[i].fn.Left(ret[i].fn.GetLength()-4) + _T(".sub"));
}
}
- if(!pSubStream)
- {
+ if(!pSubStream) {
CAutoPtr<ssf::CRenderer> pSSF(new ssf::CRenderer(&m_csSubLock));
- if(pSSF && pSSF->Open(ret[i].fn) && pSSF->GetStreamCount() > 0)
- {
+ if(pSSF && pSSF->Open(ret[i].fn) && pSSF->GetStreamCount() > 0) {
pSubStream = pSSF.Detach();
}
}
- if(!pSubStream)
- {
+ if(!pSubStream) {
CAutoPtr<CRenderedTextSubtitle> pRTS(new CRenderedTextSubtitle(&m_csSubLock));
- if(pRTS && pRTS->Open(ret[i].fn, DEFAULT_CHARSET) && pRTS->GetStreamCount() > 0)
- {
+ if(pRTS && pRTS->Open(ret[i].fn, DEFAULT_CHARSET) && pRTS->GetStreamCount() > 0) {
pSubStream = pRTS.Detach();
m_frd.files.AddTail(ret[i].fn + _T(".style"));
}
}
- if(pSubStream)
- {
+ if(pSubStream) {
m_pSubStreams.AddTail(pSubStream);
m_frd.files.AddTail(ret[i].fn);
}
}
- for(ptrdiff_t i = 0; i < m_pTextInput.GetCount(); i++)
- {
- if(m_pTextInput[i]->IsConnected())
+ for(ptrdiff_t i = 0; i < m_pTextInput.GetCount(); i++) {
+ if(m_pTextInput[i]->IsConnected()) {
m_pSubStreams.AddTail(m_pTextInput[i]->GetSubStream());
+ }
}
- if(S_FALSE == put_SelectedLanguage(FindPreferedLanguage()))
- UpdateSubtitle(false); // make sure pSubPicProvider of our queue gets updated even if the stream number hasn't changed
+ if(S_FALSE == put_SelectedLanguage(FindPreferedLanguage())) {
+ UpdateSubtitle(false); // make sure pSubPicProvider of our queue gets updated even if the stream number hasn't changed
+ }
m_frd.RefreshEvent.Set();
@@ -1459,22 +1470,21 @@ void CDirectVobSubFilter::UpdateSubtitle(bool fApplyDefStyle)
{
CAutoLock cAutolock(&m_csQueueLock);
- if(!m_pSubPicQueue) return;
+ if(!m_pSubPicQueue) {
+ return;
+ }
InvalidateSubtitle();
CComPtr<ISubStream> pSubStream;
- if(!m_fHideSubtitles)
- {
+ if(!m_fHideSubtitles) {
int i = m_iSelectedLanguage;
- for(POSITION pos = m_pSubStreams.GetHeadPosition(); i >= 0 && pos; pSubStream = NULL)
- {
+ for(POSITION pos = m_pSubStreams.GetHeadPosition(); i >= 0 && pos; pSubStream = NULL) {
pSubStream = m_pSubStreams.GetNext(pos);
- if(i < pSubStream->GetStreamCount())
- {
+ if(i < pSubStream->GetStreamCount()) {
CAutoLock cAutoLock(&m_csSubLock);
pSubStream->SetStream(i);
break;
@@ -1491,43 +1501,33 @@ void CDirectVobSubFilter::SetSubtitle(ISubStream* pSubStream, bool fApplyDefStyl
{
CAutoLock cAutolock(&m_csQueueLock);
- if(pSubStream)
- {
+ if(pSubStream) {
CAutoLock cAutolock(&m_csSubLock);
CLSID clsid;
pSubStream->GetClassID(&clsid);
- if(clsid == __uuidof(CVobSubFile))
- {
+ if(clsid == __uuidof(CVobSubFile)) {
CVobSubSettings* pVSS = (CVobSubFile*)(ISubStream*)pSubStream;
- if(fApplyDefStyle)
- {
+ if(fApplyDefStyle) {
pVSS->SetAlignment(m_fOverridePlacement, m_PlacementXperc, m_PlacementYperc, 1, 1);
pVSS->m_fOnlyShowForcedSubs = m_fOnlyShowForcedVobSubs;
}
- }
- else if(clsid == __uuidof(CVobSubStream))
- {
+ } else if(clsid == __uuidof(CVobSubStream)) {
CVobSubSettings* pVSS = (CVobSubStream*)(ISubStream*)pSubStream;
- if(fApplyDefStyle)
- {
+ if(fApplyDefStyle) {
pVSS->SetAlignment(m_fOverridePlacement, m_PlacementXperc, m_PlacementYperc, 1, 1);
pVSS->m_fOnlyShowForcedSubs = m_fOnlyShowForcedVobSubs;
}
- }
- else if(clsid == __uuidof(CRenderedTextSubtitle))
- {
+ } else if(clsid == __uuidof(CRenderedTextSubtitle)) {
CRenderedTextSubtitle* pRTS = (CRenderedTextSubtitle*)(ISubStream*)pSubStream;
- if(fApplyDefStyle || pRTS->m_fUsingAutoGeneratedDefaultStyle)
- {
+ if(fApplyDefStyle || pRTS->m_fUsingAutoGeneratedDefaultStyle) {
STSStyle s = m_defStyle;
- if(m_fOverridePlacement)
- {
+ if(m_fOverridePlacement) {
s.scrAlignment = 2;
int w = pRTS->m_dstScreenSize.cx;
int h = pRTS->m_dstScreenSize.cy;
@@ -1541,14 +1541,11 @@ void CDirectVobSubFilter::SetSubtitle(ISubStream* pSubStream, bool fApplyDefStyl
}
pRTS->m_ePARCompensationType = m_ePARCompensationType;
- if (m_CurrentVIH2.dwPictAspectRatioX != 0 && m_CurrentVIH2.dwPictAspectRatioY != 0&& m_CurrentVIH2.bmiHeader.biWidth != 0 && m_CurrentVIH2.bmiHeader.biHeight != 0)
- {
+ if (m_CurrentVIH2.dwPictAspectRatioX != 0 && m_CurrentVIH2.dwPictAspectRatioY != 0&& m_CurrentVIH2.bmiHeader.biWidth != 0 && m_CurrentVIH2.bmiHeader.biHeight != 0) {
pRTS->m_dPARCompensation = ((double)abs(m_CurrentVIH2.bmiHeader.biWidth) / (double)abs(m_CurrentVIH2.bmiHeader.biHeight)) /
((double)abs((long)m_CurrentVIH2.dwPictAspectRatioX) / (double)abs((long)m_CurrentVIH2.dwPictAspectRatioY));
- }
- else
- {
+ } else {
pRTS->m_dPARCompensation = 1.00;
}
@@ -1556,17 +1553,14 @@ void CDirectVobSubFilter::SetSubtitle(ISubStream* pSubStream, bool fApplyDefStyl
}
}
- if(!fApplyDefStyle)
- {
+ if(!fApplyDefStyle) {
int i = 0;
POSITION pos = m_pSubStreams.GetHeadPosition();
- while(pos)
- {
+ while(pos) {
CComPtr<ISubStream> pSubStream2 = m_pSubStreams.GetNext(pos);
- if(pSubStream == pSubStream2)
- {
+ if(pSubStream == pSubStream2) {
m_iSelectedLanguage = i + pSubStream2->GetStream();
break;
}
@@ -1577,18 +1571,19 @@ void CDirectVobSubFilter::SetSubtitle(ISubStream* pSubStream, bool fApplyDefStyl
m_nSubtitleId = (DWORD_PTR)pSubStream;
- if(m_pSubPicQueue)
+ if(m_pSubPicQueue) {
m_pSubPicQueue->SetSubPicProvider(CComQIPtr<ISubPicProvider>(pSubStream));
+ }
}
void CDirectVobSubFilter::InvalidateSubtitle(REFERENCE_TIME rtInvalidate, DWORD_PTR nSubtitleId)
{
CAutoLock cAutolock(&m_csQueueLock);
- if(m_pSubPicQueue)
- {
- if(nSubtitleId == -1 || nSubtitleId == m_nSubtitleId)
+ if(m_pSubPicQueue) {
+ if(nSubtitleId == -1 || nSubtitleId == m_nSubtitleId) {
m_pSubPicQueue->Invalidate(rtInvalidate);
+ }
}
}
@@ -1599,14 +1594,17 @@ void CDirectVobSubFilter::AddSubStream(ISubStream* pSubStream)
CAutoLock cAutoLock(&m_csQueueLock);
POSITION pos = m_pSubStreams.Find(pSubStream);
- if(!pos) m_pSubStreams.AddTail(pSubStream);
+ if(!pos) {
+ m_pSubStreams.AddTail(pSubStream);
+ }
int len = m_pTextInput.GetCount();
for(ptrdiff_t i = 0; i < m_pTextInput.GetCount(); i++)
- if(m_pTextInput[i]->IsConnected()) len--;
+ if(m_pTextInput[i]->IsConnected()) {
+ len--;
+ }
- if(len == 0)
- {
+ if(len == 0) {
HRESULT hr = S_OK;
m_pTextInput.Add(new CTextInputPin(this, m_pLock, &m_csSubLock, &hr));
}
@@ -1617,21 +1615,28 @@ void CDirectVobSubFilter::RemoveSubStream(ISubStream* pSubStream)
CAutoLock cAutoLock(&m_csQueueLock);
POSITION pos = m_pSubStreams.Find(pSubStream);
- if(pos) m_pSubStreams.RemoveAt(pos);
+ if(pos) {
+ m_pSubStreams.RemoveAt(pos);
+ }
}
void CDirectVobSubFilter::Post_EC_OLE_EVENT(CString str, DWORD_PTR nSubtitleId)
{
- if(nSubtitleId != -1 && nSubtitleId != m_nSubtitleId)
+ if(nSubtitleId != -1 && nSubtitleId != m_nSubtitleId) {
return;
+ }
CComQIPtr<IMediaEventSink> pMES = m_pGraph;
- if(!pMES) return;
+ if(!pMES) {
+ return;
+ }
CComBSTR bstr1("Text"), bstr2(" ");
str.Trim();
- if(!str.IsEmpty()) bstr2 = CStringA(str);
+ if(!str.IsEmpty()) {
+ bstr2 = CStringA(str);
+ }
pMES->Notify(EC_OLE_EVENT, (LONG_PTR)bstr1.Detach(), (LONG_PTR)bstr2.Detach());
}
@@ -1642,8 +1647,7 @@ void CDirectVobSubFilter::SetupFRD(CStringArray& paths, CAtlArray<HANDLE>& handl
{
CAutoLock cAutolock(&m_csSubLock);
- for(ptrdiff_t i = 2; i < handles.GetCount(); i++)
- {
+ for(ptrdiff_t i = 2; i < handles.GetCount(); i++) {
FindCloseChangeNotification(handles[i]);
}
@@ -1656,30 +1660,32 @@ void CDirectVobSubFilter::SetupFRD(CStringArray& paths, CAtlArray<HANDLE>& handl
m_frd.mtime.SetCount(m_frd.files.GetCount());
POSITION pos = m_frd.files.GetHeadPosition();
- for(ptrdiff_t i = 0; pos; i++)
- {
+ for(ptrdiff_t i = 0; pos; i++) {
CString fn = m_frd.files.GetNext(pos);
CFileStatus status;
- if(CFileGetStatus(fn, status))
+ if(CFileGetStatus(fn, status)) {
m_frd.mtime[i] = status.m_mtime;
+ }
fn.Replace('\\', '/');
fn = fn.Left(fn.ReverseFind('/')+1);
bool fFound = false;
- for(ptrdiff_t j = 0; !fFound && j < paths.GetCount(); j++)
- {
- if(paths[j] == fn) fFound = true;
+ for(ptrdiff_t j = 0; !fFound && j < paths.GetCount(); j++) {
+ if(paths[j] == fn) {
+ fFound = true;
+ }
}
- if(!fFound)
- {
+ if(!fFound) {
paths.Add(fn);
HANDLE h = FindFirstChangeNotification(fn, FALSE, FILE_NOTIFY_CHANGE_LAST_WRITE);
- if(h != INVALID_HANDLE_VALUE) handles.Add(h);
+ if(h != INVALID_HANDLE_VALUE) {
+ handles.Add(h);
+ }
}
}
}
@@ -1693,47 +1699,39 @@ DWORD CDirectVobSubFilter::ThreadProc()
SetupFRD(paths, handles);
- while(1)
- {
+ while(1) {
DWORD idx = WaitForMultipleObjects(handles.GetCount(), handles.GetData(), FALSE, INFINITE);
- if(idx == (WAIT_OBJECT_0 + 0)) // m_frd.hEndThreadEvent
- {
+ if(idx == (WAIT_OBJECT_0 + 0)) { // m_frd.hEndThreadEvent
break;
}
- if(idx == (WAIT_OBJECT_0 + 1)) // m_frd.hRefreshEvent
- {
+ if(idx == (WAIT_OBJECT_0 + 1)) { // m_frd.hRefreshEvent
SetupFRD(paths, handles);
- }
- else if(idx >= (WAIT_OBJECT_0 + 2) && idx < (WAIT_OBJECT_0 + handles.GetCount()))
- {
+ } else if(idx >= (WAIT_OBJECT_0 + 2) && idx < (WAIT_OBJECT_0 + handles.GetCount())) {
bool fLocked = true;
IsSubtitleReloaderLocked(&fLocked);
- if(fLocked) continue;
+ if(fLocked) {
+ continue;
+ }
- if(FindNextChangeNotification(handles[idx - WAIT_OBJECT_0]) == FALSE)
+ if(FindNextChangeNotification(handles[idx - WAIT_OBJECT_0]) == FALSE) {
break;
+ }
int j = 0;
POSITION pos = m_frd.files.GetHeadPosition();
- for(ptrdiff_t i = 0; pos && j == 0; i++)
- {
+ for(ptrdiff_t i = 0; pos && j == 0; i++) {
CString fn = m_frd.files.GetNext(pos);
CFileStatus status;
- if(CFileGetStatus(fn, status) && m_frd.mtime[i] != status.m_mtime)
- {
- for(j = 0; j < 10; j++)
- {
- if(FILE* f = _tfopen(fn, _T("rb+")))
- {
+ if(CFileGetStatus(fn, status) && m_frd.mtime[i] != status.m_mtime) {
+ for(j = 0; j < 10; j++) {
+ if(FILE* f = _tfopen(fn, _T("rb+"))) {
fclose(f);
j = 0;
break;
- }
- else
- {
+ } else {
Sleep(100);
j++;
}
@@ -1741,36 +1739,28 @@ DWORD CDirectVobSubFilter::ThreadProc()
}
}
- if(j > 0)
- {
+ if(j > 0) {
SetupFRD(paths, handles);
- }
- else
- {
+ } else {
Sleep(500);
POSITION pos = m_frd.files.GetHeadPosition();
- for(ptrdiff_t i = 0; pos; i++)
- {
+ for(ptrdiff_t i = 0; pos; i++) {
CFileStatus status;
if(CFileGetStatus(m_frd.files.GetNext(pos), status)
- && m_frd.mtime[i] != status.m_mtime)
- {
+ && m_frd.mtime[i] != status.m_mtime) {
Open();
SetupFRD(paths, handles);
break;
}
}
}
- }
- else
- {
+ } else {
break;
}
}
- for(ptrdiff_t i = 2; i < handles.GetCount(); i++)
- {
+ for(ptrdiff_t i = 2; i < handles.GetCount(); i++) {
FindCloseChangeNotification(handles[i]);
}
diff --git a/src/filters/transform/VSFilter/DirectVobSubFilter.h b/src/filters/transform/VSFilter/DirectVobSubFilter.h
index 6552d5f17..82932bd2c 100644
--- a/src/filters/transform/VSFilter/DirectVobSubFilter.h
+++ b/src/filters/transform/VSFilter/DirectVobSubFilter.h
@@ -30,8 +30,7 @@
#include "../../../Subtitles/RTS.h"
#include "../../../Subtitles/SSF.h"
-typedef struct
-{
+typedef struct {
HWND hSystrayWnd;
IFilterGraph* graph;
IDirectVobSub* dvs;
diff --git a/src/filters/transform/VSFilter/DirectVobSubPropPage.cpp b/src/filters/transform/VSFilter/DirectVobSubPropPage.cpp
index 4b4713a64..79196273c 100644
--- a/src/filters/transform/VSFilter/DirectVobSubPropPage.cpp
+++ b/src/filters/transform/VSFilter/DirectVobSubPropPage.cpp
@@ -48,7 +48,9 @@ BOOL WINAPI MyGetDialogSize(int iResourceID, DLGPROC pDlgProc, LPARAM lParam, SI
pDlgProc,
lParam);
- if(hwnd == NULL) return FALSE;
+ if(hwnd == NULL) {
+ return FALSE;
+ }
RECT rc;
GetWindowRect(hwnd, &rc);
@@ -65,7 +67,9 @@ STDMETHODIMP CDVSBasePPage::GetPageInfo(LPPROPPAGEINFO pPageInfo)
AFX_MANAGE_STATE(AfxGetStaticModuleState());
CString str;
- if(!str.LoadString(m_TitleId)) return E_FAIL;
+ if(!str.LoadString(m_TitleId)) {
+ return E_FAIL;
+ }
WCHAR wszTitle[STR_MAX_LENGTH];
#ifdef UNICODE
@@ -104,16 +108,20 @@ STDMETHODIMP CDVSBasePPage::Activate(HWND hwndParent, LPCRECT pRect, BOOL fModal
AFX_MANAGE_STATE(AfxGetStaticModuleState());
CheckPointer(pRect,E_POINTER);
-/*
- // Return failure if SetObject has not been called.
- if (m_bObjectSet == FALSE) {
+ /*
+ // Return failure if SetObject has not been called.
+ if (m_bObjectSet == FALSE) {
+ return E_UNEXPECTED;
+ }
+ */
+ if(m_hwnd) {
return E_UNEXPECTED;
}
-*/
- if(m_hwnd) return E_UNEXPECTED;
m_hwnd = CreateDialogParam(AfxGetResourceHandle(), MAKEINTRESOURCE(m_DialogId), hwndParent, DialogProc, (LPARAM)this);
- if(m_hwnd == NULL) return E_OUTOFMEMORY;
+ if(m_hwnd == NULL) {
+ return E_OUTOFMEMORY;
+ }
OnActivate();
Move(pRect);
@@ -132,36 +140,34 @@ CDVSBasePPage::CDVSBasePPage(TCHAR* pName, LPUNKNOWN lpunk, int DialogId, int Ti
INT_PTR CDVSBasePPage::OnReceiveMessage(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
{
- switch(uMsg)
- {
- case WM_COMMAND:
- {
- if(m_bIsInitialized)
- {
- m_bDirty = TRUE;
- if(m_pPageSite) m_pPageSite->OnStatusChange(PROPPAGESTATUS_DIRTY);
-
- switch(HIWORD(wParam))
- {
- case BN_CLICKED:
- case CBN_SELCHANGE:
- case EN_CHANGE:
- {
- AFX_MANAGE_STATE(AfxGetStaticModuleState());
-
- if(!m_fDisableInstantUpdate
- && !(HIWORD(wParam) == BN_CLICKED && LOWORD(wParam) == IDC_INSTANTUPDATE)
- && !!theApp.GetProfileInt(ResStr(IDS_R_GENERAL), ResStr(IDS_RG_INSTANTUPDATE), 1))
- OnApplyChanges();
- }
+ switch(uMsg) {
+ case WM_COMMAND: {
+ if(m_bIsInitialized) {
+ m_bDirty = TRUE;
+ if(m_pPageSite) {
+ m_pPageSite->OnStatusChange(PROPPAGESTATUS_DIRTY);
+ }
+
+ switch(HIWORD(wParam)) {
+ case BN_CLICKED:
+ case CBN_SELCHANGE:
+ case EN_CHANGE: {
+ AFX_MANAGE_STATE(AfxGetStaticModuleState());
+
+ if(!m_fDisableInstantUpdate
+ && !(HIWORD(wParam) == BN_CLICKED && LOWORD(wParam) == IDC_INSTANTUPDATE)
+ && !!theApp.GetProfileInt(ResStr(IDS_R_GENERAL), ResStr(IDS_RG_INSTANTUPDATE), 1)) {
+ OnApplyChanges();
+ }
+ }
+ }
}
}
- }
- break;
-
- case WM_NCDESTROY:
- DetachControls();
break;
+
+ case WM_NCDESTROY:
+ DetachControls();
+ break;
}
return OnMessage(uMsg, wParam, lParam)
@@ -171,7 +177,9 @@ INT_PTR CDVSBasePPage::OnReceiveMessage(HWND hwnd, UINT uMsg, WPARAM wParam, LPA
HRESULT CDVSBasePPage::OnConnect(IUnknown* pUnknown)
{
- if(!(m_pDirectVobSub = pUnknown)) return E_NOINTERFACE;
+ if(!(m_pDirectVobSub = pUnknown)) {
+ return E_NOINTERFACE;
+ }
m_pDirectVobSub->LockSubtitleReloader(true); // *
@@ -186,7 +194,9 @@ HRESULT CDVSBasePPage::OnConnect(IUnknown* pUnknown)
HRESULT CDVSBasePPage::OnDisconnect()
{
- if(m_pDirectVobSub == NULL) return E_UNEXPECTED;
+ if(m_pDirectVobSub == NULL) {
+ return E_UNEXPECTED;
+ }
m_pDirectVobSub->LockSubtitleReloader(false); // *
@@ -233,8 +243,7 @@ HRESULT CDVSBasePPage::OnApplyChanges()
AFX_MANAGE_STATE(AfxGetStaticModuleState());
- if(m_bIsInitialized)
- {
+ if(m_bIsInitialized) {
OnDeactivate();
UpdateObjectData(true);
m_pDirectVobSub->UpdateRegistry(); // *
@@ -251,13 +260,11 @@ void CDVSBasePPage::AttachControls()
AFX_MANAGE_STATE(AfxGetStaticModuleState());
POSITION pos = m_controls.GetStartPosition();
- while(pos)
- {
+ while(pos) {
UINT id;
CWnd* pControl;
m_controls.GetNextAssoc(pos, id, pControl);
- if(pControl)
- {
+ if(pControl) {
BOOL fRet = pControl->Attach(GetDlgItem(m_Dlg, id));
ASSERT(fRet);
}
@@ -268,17 +275,20 @@ void CDVSBasePPage::AttachControls()
void CDVSBasePPage::DetachControls()
{
- if(!m_fAttached) return;
+ if(!m_fAttached) {
+ return;
+ }
AFX_MANAGE_STATE(AfxGetStaticModuleState());
POSITION pos = m_controls.GetStartPosition();
- while(pos)
- {
+ while(pos) {
UINT id;
CWnd* pControl;
m_controls.GetNextAssoc(pos, id, pControl);
- if(pControl) pControl->Detach();
+ if(pControl) {
+ pControl->Detach();
+ }
}
m_fAttached = false;
@@ -313,9 +323,10 @@ CDVSMainPPage::~CDVSMainPPage()
void CDVSMainPPage::FreeLangs()
{
- if(m_nLangs > 0 && m_ppLangs)
- {
- for(ptrdiff_t i = 0; i < m_nLangs; i++) CoTaskMemFree(m_ppLangs[i]);
+ if(m_nLangs > 0 && m_ppLangs) {
+ for(ptrdiff_t i = 0; i < m_nLangs; i++) {
+ CoTaskMemFree(m_ppLangs[i]);
+ }
CoTaskMemFree(m_ppLangs);
m_nLangs = 0;
m_ppLangs = NULL;
@@ -330,52 +341,45 @@ void CDVSMainPPage::AllocLangs(int nLangs)
bool CDVSMainPPage::OnMessage(UINT uMsg, WPARAM wParam, LPARAM lParam)
{
- switch(uMsg)
- {
- case WM_COMMAND:
- {
- switch(HIWORD(wParam))
- {
- case BN_CLICKED:
- {
- if(LOWORD(wParam) == IDC_OPEN)
- {
- AFX_MANAGE_STATE(AfxGetStaticModuleState());
-
- CFileDialog fd(TRUE, NULL, NULL,
- OFN_EXPLORER|OFN_ENABLESIZING|OFN_HIDEREADONLY|OFN_FILEMUSTEXIST|OFN_PATHMUSTEXIST,
- _T(".idx .smi .sub .srt .psb .ssa .ass .usf .ssf|*.idx;*.smi;*.sub;*.srt;*.psb;*.ssa;*.ass;*.usf;*.ssf|")
- _T("All files (*.*)|*.*||"),
- CDialog::FromHandle(m_Dlg), 0);
-
- if(fd.DoModal() == IDOK)
- {
- m_fnedit.SetWindowText(fd.GetPathName());
- }
-
- return(true);
- }
- else if(LOWORD(wParam) == IDC_FONT)
- {
- AFX_MANAGE_STATE(AfxGetStaticModuleState());
-
- CStyleEditorDialog dlg(_T("Default"), &m_defStyle, CWnd::FromHandle(m_hwnd));
-
- if(dlg.DoModal() == IDOK)
- {
- m_defStyle = dlg.m_stss;
- CString str = m_defStyle.fontName;
- if(str.GetLength() > 18) str = str.Left(16).TrimRight() + _T("...");
- m_font.SetWindowText(str);
+ switch(uMsg) {
+ case WM_COMMAND: {
+ switch(HIWORD(wParam)) {
+ case BN_CLICKED: {
+ if(LOWORD(wParam) == IDC_OPEN) {
+ AFX_MANAGE_STATE(AfxGetStaticModuleState());
+
+ CFileDialog fd(TRUE, NULL, NULL,
+ OFN_EXPLORER|OFN_ENABLESIZING|OFN_HIDEREADONLY|OFN_FILEMUSTEXIST|OFN_PATHMUSTEXIST,
+ _T(".idx .smi .sub .srt .psb .ssa .ass .usf .ssf|*.idx;*.smi;*.sub;*.srt;*.psb;*.ssa;*.ass;*.usf;*.ssf|")
+ _T("All files (*.*)|*.*||"),
+ CDialog::FromHandle(m_Dlg), 0);
+
+ if(fd.DoModal() == IDOK) {
+ m_fnedit.SetWindowText(fd.GetPathName());
+ }
+
+ return(true);
+ } else if(LOWORD(wParam) == IDC_FONT) {
+ AFX_MANAGE_STATE(AfxGetStaticModuleState());
+
+ CStyleEditorDialog dlg(_T("Default"), &m_defStyle, CWnd::FromHandle(m_hwnd));
+
+ if(dlg.DoModal() == IDOK) {
+ m_defStyle = dlg.m_stss;
+ CString str = m_defStyle.fontName;
+ if(str.GetLength() > 18) {
+ str = str.Left(16).TrimRight() + _T("...");
+ }
+ m_font.SetWindowText(str);
+ }
+
+ return(true);
+ }
}
-
- return(true);
+ break;
}
}
break;
- }
- }
- break;
}
return(false);
@@ -383,14 +387,14 @@ bool CDVSMainPPage::OnMessage(UINT uMsg, WPARAM wParam, LPARAM lParam)
void CDVSMainPPage::UpdateObjectData(bool fSave)
{
- if(fSave)
- {
- if(m_pDirectVobSub->put_FileName(m_fn) == S_OK)
- {
+ if(fSave) {
+ if(m_pDirectVobSub->put_FileName(m_fn) == S_OK) {
int nLangs;
m_pDirectVobSub->get_LanguageCount(&nLangs);
AllocLangs(nLangs);
- for(ptrdiff_t i = 0; i < m_nLangs; i++) m_pDirectVobSub->get_LanguageName(i, &m_ppLangs[i]);
+ for(ptrdiff_t i = 0; i < m_nLangs; i++) {
+ m_pDirectVobSub->get_LanguageName(i, &m_ppLangs[i]);
+ }
m_pDirectVobSub->get_SelectedLanguage(&m_iSelectedLanguage);
}
@@ -399,14 +403,14 @@ void CDVSMainPPage::UpdateObjectData(bool fSave)
m_pDirectVobSub->put_VobSubSettings(true, m_fOnlyShowForcedVobSubs, false);
m_pDirectVobSub->put_TextSettings(&m_defStyle);
m_pDirectVobSub->put_AspectRatioSettings(&m_ePARCompensationType);
- }
- else
- {
+ } else {
m_pDirectVobSub->get_FileName(m_fn);
int nLangs;
m_pDirectVobSub->get_LanguageCount(&nLangs);
AllocLangs(nLangs);
- for(ptrdiff_t i = 0; i < m_nLangs; i++) m_pDirectVobSub->get_LanguageName(i, &m_ppLangs[i]);
+ for(ptrdiff_t i = 0; i < m_nLangs; i++) {
+ m_pDirectVobSub->get_LanguageName(i, &m_ppLangs[i]);
+ }
m_pDirectVobSub->get_SelectedLanguage(&m_iSelectedLanguage);
m_pDirectVobSub->get_Placement(&m_fOverridePlacement, &m_PlacementXperc, &m_PlacementYperc);
m_pDirectVobSub->get_VobSubSettings(NULL, &m_fOnlyShowForcedVobSubs, NULL);
@@ -417,8 +421,7 @@ void CDVSMainPPage::UpdateObjectData(bool fSave)
void CDVSMainPPage::UpdateControlData(bool fSave)
{
- if(fSave)
- {
+ if(fSave) {
CString fn;
m_fnedit.GetWindowText(fn);
#ifdef UNICODE
@@ -431,13 +434,12 @@ void CDVSMainPPage::UpdateControlData(bool fSave)
m_PlacementXperc = m_subposx.GetPos();
m_PlacementYperc = m_subposy.GetPos();
m_fOnlyShowForcedVobSubs = !!m_forcedsubs.GetCheck();
- if (m_PARCombo.GetCurSel() != CB_ERR)
+ if (m_PARCombo.GetCurSel() != CB_ERR) {
m_ePARCompensationType = static_cast<CSimpleTextSubtitle::EPARCompensationType>(m_PARCombo.GetItemData(m_PARCombo.GetCurSel()));
- else
+ } else {
m_ePARCompensationType = CSimpleTextSubtitle::EPCTDisabled;
- }
- else
- {
+ }
+ } else {
m_fnedit.SetWindowText(CString(m_fn));
m_oplacement.SetCheck(m_fOverridePlacement);
m_subposx.SetRange(-20, 120);
@@ -450,29 +452,35 @@ void CDVSMainPPage::UpdateControlData(bool fSave)
m_forcedsubs.SetCheck(m_fOnlyShowForcedVobSubs);
m_langs.ResetContent();
m_langs.EnableWindow(m_nLangs > 0);
- for(ptrdiff_t i = 0; i < m_nLangs; i++) m_langs.AddString(CString(m_ppLangs[i]));
+ for(ptrdiff_t i = 0; i < m_nLangs; i++) {
+ m_langs.AddString(CString(m_ppLangs[i]));
+ }
m_langs.SetCurSel(m_iSelectedLanguage);
m_PARCombo.ResetContent();
m_PARCombo.InsertString(0, ResStr(IDS_RT_PAR_DISABLED));
m_PARCombo.SetItemData(0, CSimpleTextSubtitle::EPCTDisabled);
- if (m_ePARCompensationType == CSimpleTextSubtitle::EPCTDisabled)
+ if (m_ePARCompensationType == CSimpleTextSubtitle::EPCTDisabled) {
m_PARCombo.SetCurSel(0);
+ }
m_PARCombo.InsertString(1, ResStr(IDS_RT_PAR_DOWNSCALE));
m_PARCombo.SetItemData(1, CSimpleTextSubtitle::EPCTDownscale);
- if (m_ePARCompensationType == CSimpleTextSubtitle::EPCTDownscale)
+ if (m_ePARCompensationType == CSimpleTextSubtitle::EPCTDownscale) {
m_PARCombo.SetCurSel(1);
+ }
m_PARCombo.InsertString(2, ResStr(IDS_RT_PAR_UPSCALE));
m_PARCombo.SetItemData(2, CSimpleTextSubtitle::EPCTUpscale);
- if (m_ePARCompensationType == CSimpleTextSubtitle::EPCTUpscale)
+ if (m_ePARCompensationType == CSimpleTextSubtitle::EPCTUpscale) {
m_PARCombo.SetCurSel(2);
+ }
m_PARCombo.InsertString(3, ResStr(IDS_RT_PAR_ACCURATE_SIZE));
m_PARCombo.SetItemData(3, CSimpleTextSubtitle::EPCTAccurateSize);
- if (m_ePARCompensationType == CSimpleTextSubtitle::EPCTAccurateSize)
+ if (m_ePARCompensationType == CSimpleTextSubtitle::EPCTAccurateSize) {
m_PARCombo.SetCurSel(3);
+ }
}
}
@@ -494,34 +502,27 @@ CDVSGeneralPPage::CDVSGeneralPPage(LPUNKNOWN pUnk, HRESULT* phr) :
bool CDVSGeneralPPage::OnMessage(UINT uMsg, WPARAM wParam, LPARAM lParam)
{
- switch(uMsg)
- {
- case WM_COMMAND:
- {
- switch(HIWORD(wParam))
- {
- case CBN_SELCHANGE:
- {
- AFX_MANAGE_STATE(AfxGetStaticModuleState());
-
- if(LOWORD(wParam) == IDC_RESX2COMBO)
- {
- m_resx2w.EnableWindow(m_resx2.GetCurSel() == 2);
- m_resx2h.EnableWindow(m_resx2.GetCurSel() == 2);
- return(true);
- }
- else if(LOWORD(wParam) == IDC_LOADCOMBO)
- {
- m_extload.EnableWindow(m_load.GetCurSel() == 1);
- m_webload.EnableWindow(m_load.GetCurSel() == 1);
- m_embload.EnableWindow(m_load.GetCurSel() == 1);
- return(true);
+ switch(uMsg) {
+ case WM_COMMAND: {
+ switch(HIWORD(wParam)) {
+ case CBN_SELCHANGE: {
+ AFX_MANAGE_STATE(AfxGetStaticModuleState());
+
+ if(LOWORD(wParam) == IDC_RESX2COMBO) {
+ m_resx2w.EnableWindow(m_resx2.GetCurSel() == 2);
+ m_resx2h.EnableWindow(m_resx2.GetCurSel() == 2);
+ return(true);
+ } else if(LOWORD(wParam) == IDC_LOADCOMBO) {
+ m_extload.EnableWindow(m_load.GetCurSel() == 1);
+ m_webload.EnableWindow(m_load.GetCurSel() == 1);
+ m_embload.EnableWindow(m_load.GetCurSel() == 1);
+ return(true);
+ }
+ }
+ break;
}
}
break;
- }
- }
- break;
}
return(false);
@@ -529,13 +530,10 @@ bool CDVSGeneralPPage::OnMessage(UINT uMsg, WPARAM wParam, LPARAM lParam)
void CDVSGeneralPPage::UpdateObjectData(bool fSave)
{
- if(fSave)
- {
+ if(fSave) {
m_pDirectVobSub->put_ExtendPicture(m_HorExt, m_VerExt, m_ResX2, m_ResX2minw, m_ResX2minh);
m_pDirectVobSub->put_LoadSettings(m_LoadLevel, m_fExternalLoad, m_fWebLoad, m_fEmbeddedLoad);
- }
- else
- {
+ } else {
m_pDirectVobSub->get_ExtendPicture(&m_HorExt, &m_VerExt, &m_ResX2, &m_ResX2minw, &m_ResX2minh);
m_pDirectVobSub->get_LoadSettings(&m_LoadLevel, &m_fExternalLoad, &m_fWebLoad, &m_fEmbeddedLoad);
}
@@ -543,20 +541,23 @@ void CDVSGeneralPPage::UpdateObjectData(bool fSave)
void CDVSGeneralPPage::UpdateControlData(bool fSave)
{
- if(fSave)
- {
- if(m_verext.GetCurSel() >= 0) m_VerExt = m_verext.GetItemData(m_verext.GetCurSel());
+ if(fSave) {
+ if(m_verext.GetCurSel() >= 0) {
+ m_VerExt = m_verext.GetItemData(m_verext.GetCurSel());
+ }
m_HorExt = !!m_mod32fix.GetCheck();
- if(m_resx2.GetCurSel() >= 0) m_ResX2 = m_resx2.GetItemData(m_resx2.GetCurSel());
+ if(m_resx2.GetCurSel() >= 0) {
+ m_ResX2 = m_resx2.GetItemData(m_resx2.GetCurSel());
+ }
m_ResX2minw = m_resx2w.GetPos();
m_ResX2minh = m_resx2h.GetPos();
- if(m_load.GetCurSel() >= 0) m_LoadLevel = m_load.GetItemData(m_load.GetCurSel());
+ if(m_load.GetCurSel() >= 0) {
+ m_LoadLevel = m_load.GetItemData(m_load.GetCurSel());
+ }
m_fExternalLoad = !!m_extload.GetCheck();
m_fWebLoad = !!m_webload.GetCheck();
m_fEmbeddedLoad = !!m_embload.GetCheck();
- }
- else
- {
+ } else {
m_verext.ResetContent();
m_verext.AddString(ResStr(IDS_ORGHEIGHT));
m_verext.SetItemData(0, 0);
@@ -622,25 +623,20 @@ CDVSMiscPPage::CDVSMiscPPage(LPUNKNOWN pUnk, HRESULT* phr) :
bool CDVSMiscPPage::OnMessage(UINT uMsg, WPARAM wParam, LPARAM lParam)
{
- switch(uMsg)
- {
- case WM_COMMAND:
- {
- switch(HIWORD(wParam))
- {
- case BN_CLICKED:
- {
- if(LOWORD(wParam) == IDC_INSTANTUPDATE)
- {
- AFX_MANAGE_STATE(AfxGetStaticModuleState());
- theApp.WriteProfileInt(ResStr(IDS_R_GENERAL), ResStr(IDS_RG_INSTANTUPDATE), !!m_instupd.GetCheck());
- return(true);
+ switch(uMsg) {
+ case WM_COMMAND: {
+ switch(HIWORD(wParam)) {
+ case BN_CLICKED: {
+ if(LOWORD(wParam) == IDC_INSTANTUPDATE) {
+ AFX_MANAGE_STATE(AfxGetStaticModuleState());
+ theApp.WriteProfileInt(ResStr(IDS_R_GENERAL), ResStr(IDS_RG_INSTANTUPDATE), !!m_instupd.GetCheck());
+ return(true);
+ }
+ }
+ break;
}
}
break;
- }
- }
- break;
}
return(false);
@@ -648,17 +644,14 @@ bool CDVSMiscPPage::OnMessage(UINT uMsg, WPARAM wParam, LPARAM lParam)
void CDVSMiscPPage::UpdateObjectData(bool fSave)
{
- if(fSave)
- {
+ if(fSave) {
m_pDirectVobSub->put_Flip(m_fFlipPicture, m_fFlipSubtitles);
m_pDirectVobSub->put_HideSubtitles(m_fHideSubtitles);
m_pDirectVobSub->put_OSD(m_fOSD);
m_pDirectVobSub->put_PreBuffering(m_fDoPreBuffering);
m_pDirectVobSub->put_SubtitleReloader(m_fReloaderDisabled);
m_pDirectVobSub->put_SaveFullPath(m_fSaveFullPath);
- }
- else
- {
+ } else {
m_pDirectVobSub->get_Flip(&m_fFlipPicture, &m_fFlipSubtitles);
m_pDirectVobSub->get_HideSubtitles(&m_fHideSubtitles);
m_pDirectVobSub->get_OSD(&m_fOSD);
@@ -670,8 +663,7 @@ void CDVSMiscPPage::UpdateObjectData(bool fSave)
void CDVSMiscPPage::UpdateControlData(bool fSave)
{
- if(fSave)
- {
+ if(fSave) {
m_fFlipPicture = !!m_flippic.GetCheck();
m_fFlipSubtitles = !!m_flipsub.GetCheck();
m_fHideSubtitles = !!m_hidesub.GetCheck();
@@ -679,9 +671,7 @@ void CDVSMiscPPage::UpdateControlData(bool fSave)
m_fDoPreBuffering = !!m_prebuff.GetCheck();
m_fOSD = !!m_showosd.GetCheck();
m_fReloaderDisabled = !m_autoreload.GetCheck();
- }
- else
- {
+ } else {
m_flippic.SetCheck(m_fFlipPicture);
m_flipsub.SetCheck(m_fFlipSubtitles);
m_hidesub.SetCheck(m_fHideSubtitles);
@@ -707,25 +697,20 @@ CDVSTimingPPage::CDVSTimingPPage(LPUNKNOWN pUnk, HRESULT* phr) :
bool CDVSTimingPPage::OnMessage(UINT uMsg, WPARAM wParam, LPARAM lParam)
{
- switch(uMsg)
- {
- case WM_COMMAND:
- {
- switch(HIWORD(wParam))
- {
- case BN_CLICKED:
- {
- if(LOWORD(wParam) == IDC_MODFPS)
- {
- AFX_MANAGE_STATE(AfxGetStaticModuleState());
- m_fps.EnableWindow(!!m_modfps.GetCheck());
- return(true);
+ switch(uMsg) {
+ case WM_COMMAND: {
+ switch(HIWORD(wParam)) {
+ case BN_CLICKED: {
+ if(LOWORD(wParam) == IDC_MODFPS) {
+ AFX_MANAGE_STATE(AfxGetStaticModuleState());
+ m_fps.EnableWindow(!!m_modfps.GetCheck());
+ return(true);
+ }
+ }
+ break;
}
}
break;
- }
- }
- break;
}
return(false);
@@ -733,13 +718,10 @@ bool CDVSTimingPPage::OnMessage(UINT uMsg, WPARAM wParam, LPARAM lParam)
void CDVSTimingPPage::UpdateObjectData(bool fSave)
{
- if(fSave)
- {
+ if(fSave) {
m_pDirectVobSub->put_SubtitleTiming(m_SubtitleDelay, m_SubtitleSpeedMul, m_SubtitleSpeedDiv);
m_pDirectVobSub->put_MediaFPS(m_fMediaFPSEnabled, m_MediaFPS);
- }
- else
- {
+ } else {
m_pDirectVobSub->get_SubtitleTiming(&m_SubtitleDelay, &m_SubtitleSpeedMul, &m_SubtitleSpeedDiv);
m_pDirectVobSub->get_MediaFPS(&m_fMediaFPSEnabled, &m_MediaFPS);
}
@@ -747,13 +729,14 @@ void CDVSTimingPPage::UpdateObjectData(bool fSave)
void CDVSTimingPPage::UpdateControlData(bool fSave)
{
- if(fSave)
- {
+ if(fSave) {
m_fMediaFPSEnabled = !!m_modfps.GetCheck();
CString fpsstr;
m_fps.GetWindowText(fpsstr);
float fps;
- if(_stscanf(fpsstr, _T("%f"), &fps) == 1) m_MediaFPS = fps;
+ if(_stscanf(fpsstr, _T("%f"), &fps) == 1) {
+ m_MediaFPS = fps;
+ }
#if _MFC_VER >= 0x0700
m_SubtitleDelay = m_subdelay.GetPos32();
m_SubtitleSpeedMul = m_subspeedmul.GetPos32();
@@ -763,9 +746,7 @@ void CDVSTimingPPage::UpdateControlData(bool fSave)
m_SubtitleSpeedMul = SendMessage(GetDlgItem(m_Dlg, IDC_SPIN6), UDM_GETPOS32, 0, 0);
m_SubtitleSpeedDiv = SendMessage(GetDlgItem(m_Dlg, IDC_SPIN9), UDM_GETPOS32, 0, 0);
#endif
- }
- else
- {
+ } else {
m_modfps.SetCheck(m_fMediaFPSEnabled);
CString fpsstr;
fpsstr.Format(_T("%.4f"), m_MediaFPS);
@@ -796,40 +777,32 @@ CDVSAboutPPage::CDVSAboutPPage(LPUNKNOWN lpunk, HRESULT* phr) :
bool CDVSAboutPPage::OnMessage(UINT uMsg, WPARAM wParam, LPARAM lParam)
{
- switch(uMsg)
- {
- case WM_INITDIALOG:
- {
+ switch(uMsg) {
+ case WM_INITDIALOG: {
#ifdef _VSMOD
- SetDlgItemTextA( m_Dlg, IDC_VERSION, "DirectVobSub 2.40."MAKE_STR(MPC_VERSION_REV)"."MAKE_STR(MPC_VERSION_PATCH)" "MAKE_STR(VERSION_ARCH)", MOD\nCopyright 2001-2010 MPC-HC & VSFilterMod Teams" );
+ SetDlgItemTextA( m_Dlg, IDC_VERSION, "DirectVobSub 2.40."MAKE_STR(MPC_VERSION_REV)"."MAKE_STR(MPC_VERSION_PATCH)" "MAKE_STR(VERSION_ARCH)", MOD\nCopyright 2001-2010 MPC-HC & VSFilterMod Teams" );
#else
- SetDlgItemTextA( m_Dlg, IDC_VERSION, "DirectVobSub 2.40."MAKE_STR(MPC_VERSION_REV)"."MAKE_STR(MPC_VERSION_PATCH)" "MAKE_STR(VERSION_ARCH)"\nCopyright 2001-2010 MPC-HC Team" );
+ SetDlgItemTextA( m_Dlg, IDC_VERSION, "DirectVobSub 2.40."MAKE_STR(MPC_VERSION_REV)"."MAKE_STR(MPC_VERSION_PATCH)" "MAKE_STR(VERSION_ARCH)"\nCopyright 2001-2010 MPC-HC Team" );
#endif
- }
- break;
- case WM_COMMAND:
- {
- switch(HIWORD(wParam))
- {
- case BN_CLICKED:
- {
- if(LOWORD(wParam) == IDC_HOMEPAGEBTN)
- {
- AFX_MANAGE_STATE(AfxGetStaticModuleState());
- ShellExecute(m_Dlg, _T("open"), ResStr(IDS_URL_HOMEPAGE), NULL, NULL, SW_SHOWNORMAL);
- return(true);
- }
- else if(LOWORD(wParam) == IDC_BUGREPORTBTN)
- {
- AFX_MANAGE_STATE(AfxGetStaticModuleState());
- ShellExecute(m_Dlg, _T("open"), ResStr(IDS_URL_EMAIL), NULL, NULL, SW_SHOWNORMAL);
- return(true);
- }
}
break;
+ case WM_COMMAND: {
+ switch(HIWORD(wParam)) {
+ case BN_CLICKED: {
+ if(LOWORD(wParam) == IDC_HOMEPAGEBTN) {
+ AFX_MANAGE_STATE(AfxGetStaticModuleState());
+ ShellExecute(m_Dlg, _T("open"), ResStr(IDS_URL_HOMEPAGE), NULL, NULL, SW_SHOWNORMAL);
+ return(true);
+ } else if(LOWORD(wParam) == IDC_BUGREPORTBTN) {
+ AFX_MANAGE_STATE(AfxGetStaticModuleState());
+ ShellExecute(m_Dlg, _T("open"), ResStr(IDS_URL_EMAIL), NULL, NULL, SW_SHOWNORMAL);
+ return(true);
+ }
+ }
+ break;
+ }
}
- }
- break;
+ break;
}
return(false);
@@ -848,28 +821,23 @@ CDVSZoomPPage::CDVSZoomPPage(LPUNKNOWN pUnk, HRESULT* phr) :
bool CDVSZoomPPage::OnMessage(UINT uMsg, WPARAM wParam, LPARAM lParam)
{
- switch(uMsg)
- {
- case WM_COMMAND:
- {
- switch(HIWORD(wParam))
- {
- case EN_CHANGE:
- {
- if(LOWORD(wParam) == IDC_EDIT1 || LOWORD(wParam) == IDC_EDIT2
- || LOWORD(wParam) == IDC_EDIT7 || LOWORD(wParam) == IDC_EDIT8)
- {
- AFX_MANAGE_STATE(AfxGetStaticModuleState());
- UpdateControlData(true);
- UpdateObjectData(true);
- return(true);
+ switch(uMsg) {
+ case WM_COMMAND: {
+ switch(HIWORD(wParam)) {
+ case EN_CHANGE: {
+ if(LOWORD(wParam) == IDC_EDIT1 || LOWORD(wParam) == IDC_EDIT2
+ || LOWORD(wParam) == IDC_EDIT7 || LOWORD(wParam) == IDC_EDIT8) {
+ AFX_MANAGE_STATE(AfxGetStaticModuleState());
+ UpdateControlData(true);
+ UpdateObjectData(true);
+ return(true);
+ }
+ }
+
+ break;
}
}
-
break;
- }
- }
- break;
}
return(false);
@@ -877,15 +845,12 @@ bool CDVSZoomPPage::OnMessage(UINT uMsg, WPARAM wParam, LPARAM lParam)
void CDVSZoomPPage::UpdateControlData(bool fSave)
{
- if(fSave)
- {
+ if(fSave) {
m_rect.left = 1.0f * (short)m_posx.GetPos() / 100;
m_rect.top = 1.0f * (short)m_posy.GetPos() / 100;
m_rect.right = m_rect.left + 1.0f * (short)m_scalex.GetPos() / 100;
m_rect.bottom = m_rect.top + 1.0f * (short)m_scaley.GetPos() / 100;
- }
- else
- {
+ } else {
m_posx.SetRange(-100, 100);
m_posx.SetPos((int)(m_rect.left*100));
m_posy.SetRange(-100, 100);
@@ -899,12 +864,9 @@ void CDVSZoomPPage::UpdateControlData(bool fSave)
void CDVSZoomPPage::UpdateObjectData(bool fSave)
{
- if(fSave)
- {
+ if(fSave) {
m_pDirectVobSub->put_ZoomRect(&m_rect);
- }
- else
- {
+ } else {
m_pDirectVobSub->get_ZoomRect(&m_rect);
}
}
@@ -925,77 +887,68 @@ CDVSColorPPage::CDVSColorPPage(LPUNKNOWN pUnk, HRESULT* phr) :
bool CDVSColorPPage::OnMessage(UINT uMsg, WPARAM wParam, LPARAM lParam)
{
- switch(uMsg)
- {
- case WM_COMMAND:
- {
- switch(HIWORD(wParam))
- {
- case LBN_DBLCLK:
- if((HWND)lParam == m_dynchglist.m_hWnd)
- {
- int old = -1;
- m_pDirectVobSub->get_ColorFormat(&old);
- if(FAILED(m_pDirectVobSub->put_ColorFormat(m_dynchglist.GetCurSel())))
- m_dynchglist.SetCurSel(old);
-
- return(true);
- }
- break;
-
- case BN_CLICKED:
- {
- switch(LOWORD(wParam))
- {
- case IDC_COLORCHANGE:
- {
- int old = -1;
- m_pDirectVobSub->get_ColorFormat(&old);
- if(FAILED(m_pDirectVobSub->put_ColorFormat(m_dynchglist.GetCurSel())))
- m_dynchglist.SetCurSel(old);
-
- return(true);
- }
- case IDC_COLORUP:
- {
- int sel = m_preflist.GetCurSel();
- if(sel > 0)
- {
- CString str;
- m_preflist.GetText(sel, str);
- int iPos = (int)m_preflist.GetItemData(sel);
- m_preflist.DeleteString(sel);
- sel--;
- m_preflist.InsertString(sel, str);
- m_preflist.SetItemData(sel, iPos);
- m_preflist.SetCurSel(sel);
- }
-
- return(true);
- }
- case IDC_COLORDOWN:
- {
- int sel = m_preflist.GetCurSel();
- if(sel >= 0 && sel < m_preflist.GetCount()-1)
- {
- CString str;
- m_preflist.GetText(sel, str);
- int iPos = (int)m_preflist.GetItemData(sel);
- m_preflist.DeleteString(sel);
- sel++;
- m_preflist.InsertString(sel, str);
- m_preflist.SetItemData(sel, iPos);
- m_preflist.SetCurSel(sel);
+ switch(uMsg) {
+ case WM_COMMAND: {
+ switch(HIWORD(wParam)) {
+ case LBN_DBLCLK:
+ if((HWND)lParam == m_dynchglist.m_hWnd) {
+ int old = -1;
+ m_pDirectVobSub->get_ColorFormat(&old);
+ if(FAILED(m_pDirectVobSub->put_ColorFormat(m_dynchglist.GetCurSel()))) {
+ m_dynchglist.SetCurSel(old);
+ }
+
+ return(true);
+ }
+ break;
+
+ case BN_CLICKED: {
+ switch(LOWORD(wParam)) {
+ case IDC_COLORCHANGE: {
+ int old = -1;
+ m_pDirectVobSub->get_ColorFormat(&old);
+ if(FAILED(m_pDirectVobSub->put_ColorFormat(m_dynchglist.GetCurSel()))) {
+ m_dynchglist.SetCurSel(old);
+ }
+
+ return(true);
+ }
+ case IDC_COLORUP: {
+ int sel = m_preflist.GetCurSel();
+ if(sel > 0) {
+ CString str;
+ m_preflist.GetText(sel, str);
+ int iPos = (int)m_preflist.GetItemData(sel);
+ m_preflist.DeleteString(sel);
+ sel--;
+ m_preflist.InsertString(sel, str);
+ m_preflist.SetItemData(sel, iPos);
+ m_preflist.SetCurSel(sel);
+ }
+
+ return(true);
+ }
+ case IDC_COLORDOWN: {
+ int sel = m_preflist.GetCurSel();
+ if(sel >= 0 && sel < m_preflist.GetCount()-1) {
+ CString str;
+ m_preflist.GetText(sel, str);
+ int iPos = (int)m_preflist.GetItemData(sel);
+ m_preflist.DeleteString(sel);
+ sel++;
+ m_preflist.InsertString(sel, str);
+ m_preflist.SetItemData(sel, iPos);
+ m_preflist.SetCurSel(sel);
+ }
+
+ return(true);
+ }
+ }
}
-
- return(true);
- }
+ break;
}
}
break;
- }
- }
- break;
}
return(false);
@@ -1003,35 +956,30 @@ bool CDVSColorPPage::OnMessage(UINT uMsg, WPARAM wParam, LPARAM lParam)
void CDVSColorPPage::UpdateObjectData(bool fSave)
{
- if(fSave)
- {
- }
- else
- {
+ if(fSave) {
+ } else {
}
}
void CDVSColorPPage::UpdateControlData(bool fSave)
{
- if(fSave)
- {
- if((UINT)m_preflist.GetCount() == VIHSIZE)
- {
+ if(fSave) {
+ if((UINT)m_preflist.GetCount() == VIHSIZE) {
BYTE* pData = new BYTE[VIHSIZE];
- for(ptrdiff_t i = 0; i < m_preflist.GetCount(); i++)
+ for(ptrdiff_t i = 0; i < m_preflist.GetCount(); i++) {
pData[i] = (BYTE)m_preflist.GetItemData(i);
+ }
theApp.WriteProfileBinary(ResStr(IDS_R_GENERAL), ResStr(IDS_RG_COLORFORMATS), pData, VIHSIZE);
delete [] pData;
+ } else {
+ ASSERT(0);
}
- else ASSERT(0);
theApp.WriteProfileInt(ResStr(IDS_R_GENERAL), ResStr(IDS_RG_FORCERGB), !!m_forcergb.GetCheck());
- }
- else
- {
+ } else {
m_preflist.ResetContent();
m_dynchglist.ResetContent();
@@ -1039,19 +987,20 @@ void CDVSColorPPage::UpdateControlData(bool fSave)
UINT nSize;
if(!theApp.GetProfileBinary(ResStr(IDS_R_GENERAL), ResStr(IDS_RG_COLORFORMATS), &pData, &nSize)
- || !pData || nSize != VIHSIZE)
- {
- if(pData) delete [] pData, pData = NULL;
+ || !pData || nSize != VIHSIZE) {
+ if(pData) {
+ delete [] pData, pData = NULL;
+ }
nSize = VIHSIZE;
pData = new BYTE[VIHSIZE];
- for(ptrdiff_t i = 0; i < VIHSIZE; i++) pData[i] = i;
+ for(ptrdiff_t i = 0; i < VIHSIZE; i++) {
+ pData[i] = i;
+ }
}
- if(pData)
- {
- for(ptrdiff_t i = 0; i < (int)nSize; i++)
- {
+ if(pData) {
+ for(ptrdiff_t i = 0; i < (int)nSize; i++) {
m_dynchglist.AddString(VIH2String(pData[i]));
m_dynchglist.SetItemData(i, pData[i]);
m_preflist.AddString(VIH2String(pData[i]));
@@ -1085,98 +1034,85 @@ CDVSPathsPPage::CDVSPathsPPage(LPUNKNOWN pUnk, HRESULT* phr) :
bool CDVSPathsPPage::OnMessage(UINT uMsg, WPARAM wParam, LPARAM lParam)
{
- switch(uMsg)
- {
- case WM_COMMAND:
- {
- switch(HIWORD(wParam))
- {
- case LBN_SELCHANGE:
- if((HWND)lParam == m_pathlist.m_hWnd)
- {
- int i = m_pathlist.GetCurSel();
- m_remove.EnableWindow(i >= 3 ? TRUE : FALSE);
- if(i >= 0)
- {
- CString path;
- m_pathlist.GetText(i, path);
- m_path.SetWindowText(path);
- }
- return(true);
- }
- break;
-
- case LBN_SELCANCEL:
- if((HWND)lParam == m_pathlist.m_hWnd)
- {
- m_remove.EnableWindow(FALSE);
- return(true);
- }
- break;
-
- case BN_CLICKED:
- {
- switch(LOWORD(wParam))
- {
- case IDC_BROWSE:
- {
- TCHAR pathbuff[MAX_PATH];
-
- BROWSEINFO bi;
- bi.hwndOwner = m_Dlg;
- bi.pidlRoot = NULL;
- bi.pszDisplayName = pathbuff;
- bi.lpszTitle = _T("");
- bi.ulFlags = BIF_RETURNONLYFSDIRS | BIF_EDITBOX | BIF_VALIDATE | BIF_USENEWUI;
- bi.lpfn = NULL;
- bi.lParam = 0;
- bi.iImage = 0;
-
- LPITEMIDLIST iil = SHBrowseForFolder(&bi);
- if(iil)
- {
- SHGetPathFromIDList(iil, pathbuff);
- m_path.SetWindowText(pathbuff);
- }
-
- return(true);
- }
- break;
-
- case IDC_REMOVE:
- {
- int i = m_pathlist.GetCurSel();
- if(i >= 0)
- {
- m_pathlist.DeleteString(i);
- i = min(i, m_pathlist.GetCount()-1);
- if(i >= 0 && m_pathlist.GetCount() > 0)
- {
- m_pathlist.SetCurSel(i);
+ switch(uMsg) {
+ case WM_COMMAND: {
+ switch(HIWORD(wParam)) {
+ case LBN_SELCHANGE:
+ if((HWND)lParam == m_pathlist.m_hWnd) {
+ int i = m_pathlist.GetCurSel();
m_remove.EnableWindow(i >= 3 ? TRUE : FALSE);
+ if(i >= 0) {
+ CString path;
+ m_pathlist.GetText(i, path);
+ m_path.SetWindowText(path);
+ }
+ return(true);
}
- }
-
- return(true);
- }
- break;
+ break;
- case IDC_ADD:
- {
- CString path;
- m_path.GetWindowText(path);
- if(!path.IsEmpty() && m_pathlist.FindString(-1, path) < 0)
- m_pathlist.AddString(path);
-
- return(true);
- }
- break;
+ case LBN_SELCANCEL:
+ if((HWND)lParam == m_pathlist.m_hWnd) {
+ m_remove.EnableWindow(FALSE);
+ return(true);
+ }
+ break;
+
+ case BN_CLICKED: {
+ switch(LOWORD(wParam)) {
+ case IDC_BROWSE: {
+ TCHAR pathbuff[MAX_PATH];
+
+ BROWSEINFO bi;
+ bi.hwndOwner = m_Dlg;
+ bi.pidlRoot = NULL;
+ bi.pszDisplayName = pathbuff;
+ bi.lpszTitle = _T("");
+ bi.ulFlags = BIF_RETURNONLYFSDIRS | BIF_EDITBOX | BIF_VALIDATE | BIF_USENEWUI;
+ bi.lpfn = NULL;
+ bi.lParam = 0;
+ bi.iImage = 0;
+
+ LPITEMIDLIST iil = SHBrowseForFolder(&bi);
+ if(iil) {
+ SHGetPathFromIDList(iil, pathbuff);
+ m_path.SetWindowText(pathbuff);
+ }
+
+ return(true);
+ }
+ break;
+
+ case IDC_REMOVE: {
+ int i = m_pathlist.GetCurSel();
+ if(i >= 0) {
+ m_pathlist.DeleteString(i);
+ i = min(i, m_pathlist.GetCount()-1);
+ if(i >= 0 && m_pathlist.GetCount() > 0) {
+ m_pathlist.SetCurSel(i);
+ m_remove.EnableWindow(i >= 3 ? TRUE : FALSE);
+ }
+ }
+
+ return(true);
+ }
+ break;
+
+ case IDC_ADD: {
+ CString path;
+ m_path.GetWindowText(path);
+ if(!path.IsEmpty() && m_pathlist.FindString(-1, path) < 0) {
+ m_pathlist.AddString(path);
+ }
+
+ return(true);
+ }
+ break;
+ }
+ }
+ break;
}
}
break;
- }
- }
- break;
}
return(false);
@@ -1184,55 +1120,48 @@ bool CDVSPathsPPage::OnMessage(UINT uMsg, WPARAM wParam, LPARAM lParam)
void CDVSPathsPPage::UpdateObjectData(bool fSave)
{
- if(fSave)
- {
+ if(fSave) {
CString chk(_T("123456789")), path, tmp;
int i = 0;
- do
- {
+ do {
tmp.Format(ResStr(IDS_RP_PATH), i++);
path = theApp.GetProfileString(ResStr(IDS_R_DEFTEXTPATHES), tmp, chk);
- if(path != chk) theApp.WriteProfileString(ResStr(IDS_R_DEFTEXTPATHES), tmp, _T(""));
- }
- while(path != chk);
+ if(path != chk) {
+ theApp.WriteProfileString(ResStr(IDS_R_DEFTEXTPATHES), tmp, _T(""));
+ }
+ } while(path != chk);
- for(i = 0; i < m_paths.GetSize(); i++)
- {
+ for(i = 0; i < m_paths.GetSize(); i++) {
tmp.Format(ResStr(IDS_RP_PATH), i);
theApp.WriteProfileString(ResStr(IDS_R_DEFTEXTPATHES), tmp, m_paths[i]);
}
- }
- else
- {
+ } else {
CString chk(_T("123456789")), path, tmp;
int i = 0;
- do
- {
- if(!path.IsEmpty()) m_paths.Add(path);
+ do {
+ if(!path.IsEmpty()) {
+ m_paths.Add(path);
+ }
tmp.Format(ResStr(IDS_RP_PATH), i++);
path = theApp.GetProfileString(ResStr(IDS_R_DEFTEXTPATHES), tmp, chk);
- }
- while(path != chk);
+ } while(path != chk);
}
}
void CDVSPathsPPage::UpdateControlData(bool fSave)
{
- if(fSave)
- {
+ if(fSave) {
m_paths.RemoveAll();
- for(ptrdiff_t i = 0; i < m_pathlist.GetCount(); i++)
- {
+ for(ptrdiff_t i = 0; i < m_pathlist.GetCount(); i++) {
CString path;
m_pathlist.GetText(i, path);
m_paths.Add(path);
}
- }
- else
- {
+ } else {
m_pathlist.ResetContent();
- for(ptrdiff_t i = 0; i < m_paths.GetSize(); i++)
+ for(ptrdiff_t i = 0; i < m_paths.GetSize(); i++) {
m_pathlist.AddString(m_paths[i]);
+ }
m_remove.EnableWindow(FALSE);
m_add.EnableWindow(TRUE);
diff --git a/src/filters/transform/VSFilter/IDirectVobSub.h b/src/filters/transform/VSFilter/IDirectVobSub.h
index b917f87c3..37fefc6d1 100644
--- a/src/filters/transform/VSFilter/IDirectVobSub.h
+++ b/src/filters/transform/VSFilter/IDirectVobSub.h
@@ -253,24 +253,21 @@ IDirectVobSub :
interface __declspec(uuid("FE6EC6A0-21CA-4970-9EF0-B296F7F38AF0"))
ISubClock :
- public IUnknown
- {
+ public IUnknown {
STDMETHOD(SetTime)(REFERENCE_TIME rt) PURE;
STDMETHOD_(REFERENCE_TIME, GetTime)() PURE;
};
interface __declspec(uuid("0665B760-FBC1-46C3-A35F-E471527C96A4"))
ISubClock2 :
- public ISubClock
- {
+ public ISubClock {
STDMETHOD(SetAvgTimePerFrame)(REFERENCE_TIME rt) PURE;
STDMETHOD(GetAvgTimePerFrame)(REFERENCE_TIME* prt) PURE; // return S_OK only if *prt was set and is valid
};
interface __declspec(uuid("AB52FC9C-2415-4dca-BC1C-8DCC2EAE8150"))
IDirectVobSub2 :
- public IDirectVobSub
- {
+ public IDirectVobSub {
STDMETHOD(AdviseSubClock) (THIS_
ISubClock* pSubClock
) PURE;
diff --git a/src/filters/transform/VSFilter/Scale2x.cpp b/src/filters/transform/VSFilter/Scale2x.cpp
index 71cf01f24..f05773520 100644
--- a/src/filters/transform/VSFilter/Scale2x.cpp
+++ b/src/filters/transform/VSFilter/Scale2x.cpp
@@ -37,13 +37,11 @@ void Scale2x_YV( int w, int h, BYTE* d, int dpitch, BYTE* s, int spitch )
BYTE* s2;
BYTE* d1;
- for(s1 = s, s2 = s + h*spitch, d1 = d; s1 < s2; d1 += dpitch) // TODO: replace this mess with mmx code
- {
+ for(s1 = s, s2 = s + h*spitch, d1 = d; s1 < s2; d1 += dpitch) { // TODO: replace this mess with mmx code
BYTE* stmp = s1 + spitch;
BYTE* dtmp = d1 + dpitch;
- for(BYTE* s3 = s1 + (w-1); s1 < s3; s1 += 1, d1 += 2)
- {
+ for(BYTE* s3 = s1 + (w-1); s1 < s3; s1 += 1, d1 += 2) {
d1[0] = s1[0];
d1[1] = (s1[0]+s1[1])>>1;
}
@@ -70,8 +68,7 @@ void Scale2x_YUY2_SSE2( BYTE* s1, BYTE* d1, int w )
__m128i mm4 = _mm_cvtsi64_si128(__0x00ff00ff00ff00ff);
__m128i mm5 = _mm_cvtsi64_si128(__0x00000000ffffffff);
__m128i mm6 = _mm_cvtsi64_si128(__0xffffffff00000000);
- for(BYTE* s3 = s1 + ((w>>1)-1)*4; s1 < s3; s1 += 4, d1 += 8)
- {
+ for(BYTE* s3 = s1 + ((w>>1)-1)*4; s1 < s3; s1 += 4, d1 += 8) {
__m128i mm0 = _mm_cvtsi64_si128(*(size_t*)s1); //movq mm0, [esi]
__m128i mm2 = _mm_move_epi64(mm0); //movq mm2, mm0
mm0 = _mm_and_si128(mm0, mm4); //pand mm0, mm4 // mm0 = 00y400y300y200y1
@@ -112,8 +109,7 @@ void Scale2x_YUY2_MMX( BYTE* s1, BYTE* d1, int w )
unsigned __int64 __0x00000000ffffffff = 0x00000000ffffffff;
unsigned __int64 __0x00ff00ff00ff00ff = 0x00ff00ff00ff00ff;
- __asm
- {
+ __asm {
mov esi, s1
mov edi, d1
@@ -124,7 +120,7 @@ void Scale2x_YUY2_MMX( BYTE* s1, BYTE* d1, int w )
movq mm4, __0x00ff00ff00ff00ff
movq mm5, __0x00000000ffffffff
movq mm6, __0xffffffff00000000
-row_loop1:
+ row_loop1:
movq mm0, [esi]
movq mm2, mm0
@@ -185,8 +181,7 @@ row_loop1:
void Scale2x_YUY2_c( BYTE* s1, BYTE* d1, int w )
{
- for(BYTE* s3 = s1 + ((w>>1)-1)*4; s1 < s3; s1 += 4, d1 += 8)
- {
+ for(BYTE* s3 = s1 + ((w>>1)-1)*4; s1 < s3; s1 += 4, d1 += 8) {
d1[0] = s1[0];
d1[1] = s1[1];
d1[2] = (s1[0]+s1[2])>>1;
@@ -229,8 +224,7 @@ void Scale2x_YUY2( int w, int h, BYTE* d, int dpitch, BYTE* s, int spitch )
BYTE* s2;
BYTE* d1;
- for(s1 = s, s2 = s + h*spitch, d1 = d; s1 < s2; d1 += dpitch)
- {
+ for(s1 = s, s2 = s + h*spitch, d1 = d; s1 < s2; d1 += dpitch) {
// row0, 4 pixels: y1|u1|y2|v1|y3|u2|y4|v2
// ->
// row0, 8 pixels: y1|u1|(y1+y2)/2|v1|y2|(u1+u2)/2|(y2+y3)/2|(v1+v2)/2
@@ -254,13 +248,11 @@ void Scale2x_RGB555( int w, int h, BYTE* d, int dpitch, BYTE* s, int spitch )
BYTE* s2;
BYTE* d1;
- for(s1 = s, s2 = s + h*spitch, d1 = d; s1 < s2; d1 += dpitch) // TODO: replace this mess with mmx code
- {
+ for(s1 = s, s2 = s + h*spitch, d1 = d; s1 < s2; d1 += dpitch) { // TODO: replace this mess with mmx code
BYTE* stmp = s1 + spitch;
BYTE* dtmp = d1 + dpitch;
- for(BYTE* s3 = s1 + (w-1)*2; s1 < s3; s1 += 2, d1 += 4)
- {
+ for(BYTE* s3 = s1 + (w-1)*2; s1 < s3; s1 += 2, d1 += 4) {
*((WORD*)d1) = *((WORD*)s1);
*((WORD*)d1+1) =
((((*((WORD*)s1)&0x7c00) + (*((WORD*)s1+1)&0x7c00)) >> 1)&0x7c00)|
@@ -287,13 +279,11 @@ void Scale2x_RGB565( int w, int h, BYTE* d, int dpitch, BYTE* s, int spitch )
BYTE* s2;
BYTE* d1;
- for(s1 = s, s2 = s + h*spitch, d1 = d; s1 < s2; d1 += dpitch) // TODO: replace this mess with mmx code
- {
+ for(s1 = s, s2 = s + h*spitch, d1 = d; s1 < s2; d1 += dpitch) { // TODO: replace this mess with mmx code
BYTE* stmp = s1 + spitch;
BYTE* dtmp = d1 + dpitch;
- for(BYTE* s3 = s1 + (w-1)*2; s1 < s3; s1 += 2, d1 += 4)
- {
+ for(BYTE* s3 = s1 + (w-1)*2; s1 < s3; s1 += 2, d1 += 4) {
*((WORD*)d1) = *((WORD*)s1);
*((WORD*)d1+1) =
((((*((WORD*)s1)&0xf800) + (*((WORD*)s1+1)&0xf800)) >> 1)&0xf800)|
@@ -320,13 +310,11 @@ void Scale2x_RGB24( int w, int h, BYTE* d, int dpitch, BYTE* s, int spitch )
BYTE* s2;
BYTE* d1;
- for(s1 = s, s2 = s + h*spitch, d1 = d; s1 < s2; d1 += dpitch) // TODO: replace this mess with mmx code
- {
+ for(s1 = s, s2 = s + h*spitch, d1 = d; s1 < s2; d1 += dpitch) { // TODO: replace this mess with mmx code
BYTE* stmp = s1 + spitch;
BYTE* dtmp = d1 + dpitch;
- for(BYTE* s3 = s1 + (w-1)*3; s1 < s3; s1 += 3, d1 += 6)
- {
+ for(BYTE* s3 = s1 + (w-1)*3; s1 < s3; s1 += 3, d1 += 6) {
d1[0] = s1[0];
d1[1] = s1[1];
d1[2] = s1[2];
@@ -353,8 +341,7 @@ void Scale2x_RGB24( int w, int h, BYTE* d, int dpitch, BYTE* s, int spitch )
void Scale2x_XRGB32_SSE2( BYTE* s1, BYTE* d1, int w )
{
__m128i mm_zero = _mm_setzero_si128();//pxor mm0, mm0
- for(BYTE* s3 = s1 + (w-1)*4; s1 < s3; s1 += 4, d1 += 8)
- {
+ for(BYTE* s3 = s1 + (w-1)*4; s1 < s3; s1 += 4, d1 += 8) {
__m128i mm1 = _mm_cvtsi64_si128(*(size_t*)s1); //movq mm1, [esi]
__m128i mm2 = _mm_move_epi64(mm1); //movq mm2, mm1
@@ -379,8 +366,7 @@ void Scale2x_XRGB32_SSE2( BYTE* s1, BYTE* d1, int w )
#else
void Scale2x_XRGB32_MMX( BYTE* s1, BYTE* d1, int w )
{
- __asm
- {
+ __asm {
mov esi, s1
mov edi, d1
@@ -388,7 +374,7 @@ void Scale2x_XRGB32_MMX( BYTE* s1, BYTE* d1, int w )
dec ecx
pxor mm0, mm0
-row_loop3:
+ row_loop3:
movq mm1, [esi]
movq mm2, mm1
@@ -422,8 +408,7 @@ row_loop3:
void Scale2x_XRGB32_c( BYTE* s1, BYTE* d1, int w )
{
- for(BYTE* s3 = s1 + (w-1)*4; s1 < s3; s1 += 3, d1 += 6)
- {
+ for(BYTE* s3 = s1 + (w-1)*4; s1 < s3; s1 += 3, d1 += 6) {
d1[0] = s1[0];
d1[1] = s1[1];
d1[2] = s1[2];
@@ -456,8 +441,7 @@ void Scale2x_XRGB32( int w, int h, BYTE* d, int dpitch, BYTE* s, int spitch )
BYTE* s2;
BYTE* d1;
- for(s1 = s, s2 = s + h*spitch, d1 = d; s1 < s2; d1 += dpitch)
- {
+ for(s1 = s, s2 = s + h*spitch, d1 = d; s1 < s2; d1 += dpitch) {
scale_func(s1, d1, w);
s1 += spitch;
@@ -474,16 +458,17 @@ void Scale2x_XRGB32( int w, int h, BYTE* d, int dpitch, BYTE* s, int spitch )
/* ResX2 */
void Scale2x(const GUID& subtype, BYTE* d, int dpitch, BYTE* s, int spitch, int w, int h)
{
- if(subtype == MEDIASUBTYPE_YV12 || subtype == MEDIASUBTYPE_I420 || subtype == MEDIASUBTYPE_IYUV)
+ if(subtype == MEDIASUBTYPE_YV12 || subtype == MEDIASUBTYPE_I420 || subtype == MEDIASUBTYPE_IYUV) {
Scale2x_YV(w, h, d, dpitch, s, spitch);
- else if(subtype == MEDIASUBTYPE_YUY2)
+ } else if(subtype == MEDIASUBTYPE_YUY2) {
Scale2x_YUY2(w, h, d, dpitch, s, spitch);
- else if(subtype == MEDIASUBTYPE_RGB555)
+ } else if(subtype == MEDIASUBTYPE_RGB555) {
Scale2x_RGB555(w, h, d, dpitch, s, spitch);
- else if(subtype == MEDIASUBTYPE_RGB565)
+ } else if(subtype == MEDIASUBTYPE_RGB565) {
Scale2x_RGB565(w, h, d, dpitch, s, spitch);
- else if(subtype == MEDIASUBTYPE_RGB24)
+ } else if(subtype == MEDIASUBTYPE_RGB24) {
Scale2x_RGB24(w, h, d, dpitch, s, spitch);
- else if(subtype == MEDIASUBTYPE_RGB32 || subtype == MEDIASUBTYPE_ARGB32)
+ } else if(subtype == MEDIASUBTYPE_RGB32 || subtype == MEDIASUBTYPE_ARGB32) {
Scale2x_XRGB32(w, h, d, dpitch, s, spitch);
+ }
}
diff --git a/src/filters/transform/VSFilter/StyleEditorDialog.cpp b/src/filters/transform/VSFilter/StyleEditorDialog.cpp
index b31fa4b9c..0cd270f06 100644
--- a/src/filters/transform/VSFilter/StyleEditorDialog.cpp
+++ b/src/filters/transform/VSFilter/StyleEditorDialog.cpp
@@ -106,11 +106,12 @@ void CStyleEditorDialog::DoDataExchange(CDataExchange* pDX)
void CStyleEditorDialog::UpdateControlData(bool fSave)
{
- if(fSave)
- {
+ if(fSave) {
UpdateData();
- if(m_iCharset >= 0) m_stss.charSet = m_charset.GetItemData(m_iCharset);
+ if(m_iCharset >= 0) {
+ m_stss.charSet = m_charset.GetItemData(m_iCharset);
+ }
m_stss.fontSpacing = m_spacing;
m_stss.fontAngleZ = m_angle;
m_stss.fontScaleX = m_scalex;
@@ -123,24 +124,27 @@ void CStyleEditorDialog::UpdateControlData(bool fSave)
m_stss.scrAlignment = m_screenalignment+1;
m_stss.marginRect = m_margin;
- for(ptrdiff_t i = 0; i < 4; i++) m_stss.alpha[i] = 255-m_alpha[i];
- }
- else
- {
+ for(ptrdiff_t i = 0; i < 4; i++) {
+ m_stss.alpha[i] = 255-m_alpha[i];
+ }
+ } else {
m_font.SetWindowText(m_stss.fontName);
m_iCharset = -1;
- for(ptrdiff_t i = 0; i < CharSetLen; i++)
- {
+ for(ptrdiff_t i = 0; i < CharSetLen; i++) {
CString str;
str.Format(_T("%s (%d)"), CharSetNames[i], CharSetList[i]);
m_charset.AddString(str);
m_charset.SetItemData(i, CharSetList[i]);
- if(m_stss.charSet == CharSetList[i]) m_iCharset = i;
+ if(m_stss.charSet == CharSetList[i]) {
+ m_iCharset = i;
+ }
}
// TODO: allow floats in these edit boxes
m_spacing = m_stss.fontSpacing;
m_spacingspin.SetRange32(-10000, 10000);
- while(m_stss.fontAngleZ < 0) m_stss.fontAngleZ += 360;
+ while(m_stss.fontAngleZ < 0) {
+ m_stss.fontAngleZ += 360;
+ }
m_angle = fmod(m_stss.fontAngleZ, 360);
m_anglespin.SetRange32(0, 359);
m_scalex = m_stss.fontScaleX;
@@ -161,8 +165,7 @@ void CStyleEditorDialog::UpdateControlData(bool fSave)
m_margintopspin.SetRange32(-10000, 10000);
m_marginbottomspin.SetRange32(-10000, 10000);
- for(ptrdiff_t i = 0; i < 4; i++)
- {
+ for(ptrdiff_t i = 0; i < 4; i++) {
m_color[i].SetColorPtr(&m_stss.colors[i]);
m_alpha[i] = 255-m_stss.alpha[i];
m_alphasliders[i].SetRange(0, 255);
@@ -178,8 +181,7 @@ void CStyleEditorDialog::AskColor(int i)
{
CColorDialog dlg(m_stss.colors[i]);
dlg.m_cc.Flags |= CC_FULLOPEN;
- if(dlg.DoModal() == IDOK)
- {
+ if(dlg.DoModal() == IDOK) {
m_stss.colors[i] = dlg.m_cc.rgbResult;
m_color[i].Invalidate();
}
@@ -223,16 +225,15 @@ void CStyleEditorDialog::OnBnClickedButton1()
lf <<= m_stss;
CFontDialog dlg(&lf, CF_SCREENFONTS|CF_INITTOLOGFONTSTRUCT|CF_FORCEFONTEXIST|CF_SCALABLEONLY|CF_EFFECTS);
- if(dlg.DoModal() == IDOK)
- {
+ if(dlg.DoModal() == IDOK) {
CString str(lf.lfFaceName);
- if(str.GetLength() > 16) str = str.Left(14) + _T("...");
+ if(str.GetLength() > 16) {
+ str = str.Left(14) + _T("...");
+ }
m_font.SetWindowText(str);
- for(ptrdiff_t i = 0, j = m_charset.GetCount(); i < j; i++)
- {
- if(m_charset.GetItemData(i) == lf.lfCharSet)
- {
+ for(ptrdiff_t i = 0, j = m_charset.GetCount(); i < j; i++) {
+ if(m_charset.GetItemData(i) == lf.lfCharSet) {
m_charset.SetCurSel(i);
break;
}
@@ -267,17 +268,22 @@ void CStyleEditorDialog::OnBnClickedCheck1()
UpdateData();
int avg = 0;
- for(ptrdiff_t i = 0; i < 4; i++) avg += m_alphasliders[i].GetPos();
+ for(ptrdiff_t i = 0; i < 4; i++) {
+ avg += m_alphasliders[i].GetPos();
+ }
avg /= 4;
- for(ptrdiff_t i = 0; i < 4; i++) m_alphasliders[i].SetPos(avg);
+ for(ptrdiff_t i = 0; i < 4; i++) {
+ m_alphasliders[i].SetPos(avg);
+ }
}
void CStyleEditorDialog::OnHScroll(UINT nSBCode, UINT nPos, CScrollBar* pScrollBar)
{
- if(m_linkalphasliders && pScrollBar)
- {
+ if(m_linkalphasliders && pScrollBar) {
int pos = ((CSliderCtrl*)pScrollBar)->GetPos();
- for(ptrdiff_t i = 0; i < 4; i++) m_alphasliders[i].SetPos(pos);
+ for(ptrdiff_t i = 0; i < 4; i++) {
+ m_alphasliders[i].SetPos(pos);
+ }
}
CDialog::OnHScroll(nSBCode, nPos, pScrollBar);
diff --git a/src/filters/transform/VSFilter/StyleEditorDialog.h b/src/filters/transform/VSFilter/StyleEditorDialog.h
index b0760539d..ce6585d4b 100644
--- a/src/filters/transform/VSFilter/StyleEditorDialog.h
+++ b/src/filters/transform/VSFilter/StyleEditorDialog.h
@@ -46,8 +46,7 @@ public:
DECLARE_MESSAGE_MAP()
protected:
- virtual void DrawItem(LPDRAWITEMSTRUCT lpDrawItemStruct)
- {
+ virtual void DrawItem(LPDRAWITEMSTRUCT lpDrawItemStruct) {
CRect r;
GetClientRect(r);
CDC::FromHandle(lpDrawItemStruct->hDC)->FillSolidRect(r, m_pColor ? *m_pColor : ::GetSysColor(COLOR_BTNFACE));
@@ -70,7 +69,7 @@ public:
CStyleEditorDialog(CString title, STSStyle* pstss, CWnd* pParent = NULL); // standard constructor
virtual ~CStyleEditorDialog();
-// Dialog Data
+ // Dialog Data
enum { IDD = IDD_STYLEDIALOG };
STSStyle m_stss;
diff --git a/src/filters/transform/VSFilter/Systray.cpp b/src/filters/transform/VSFilter/Systray.cpp
index 63a4aa0fa..8fcb10948 100644
--- a/src/filters/transform/VSFilter/Systray.cpp
+++ b/src/filters/transform/VSFilter/Systray.cpp
@@ -43,27 +43,25 @@ LRESULT CALLBACK HookProc(UINT code, WPARAM wParam, LPARAM lParam)
{
MSG* msg = (MSG*)lParam;
- if(msg->message == WM_KEYDOWN)
- {
- switch(msg->wParam)
- {
- case VK_F13:
- PostMessage(HWND_BROADCAST, WM_DVSPREVSUB, 0, 0);
- break;
- case VK_F14:
- PostMessage(HWND_BROADCAST, WM_DVSNEXTSUB, 0, 0);
- break;
- case VK_F15:
- PostMessage(HWND_BROADCAST, WM_DVSHIDESUB, 0, 0);
- break;
- case VK_F16:
- PostMessage(HWND_BROADCAST, WM_DVSSHOWSUB, 0, 0);
- break;
- case VK_F17:
- PostMessage(HWND_BROADCAST, WM_DVSSHOWHIDESUB, 0, 0);
- break;
- default:
- break;
+ if(msg->message == WM_KEYDOWN) {
+ switch(msg->wParam) {
+ case VK_F13:
+ PostMessage(HWND_BROADCAST, WM_DVSPREVSUB, 0, 0);
+ break;
+ case VK_F14:
+ PostMessage(HWND_BROADCAST, WM_DVSNEXTSUB, 0, 0);
+ break;
+ case VK_F15:
+ PostMessage(HWND_BROADCAST, WM_DVSHIDESUB, 0, 0);
+ break;
+ case VK_F16:
+ PostMessage(HWND_BROADCAST, WM_DVSSHOWSUB, 0, 0);
+ break;
+ case VK_F17:
+ PostMessage(HWND_BROADCAST, WM_DVSSHOWHIDESUB, 0, 0);
+ break;
+ default:
+ break;
}
}
@@ -75,23 +73,28 @@ class CSystrayWindow : public CWnd
{
SystrayIconData* m_tbid;
- void StepSub(int dir)
- {
+ void StepSub(int dir) {
int iSelected, nLangs;
- if(FAILED(m_tbid->dvs->get_LanguageCount(&nLangs))) return;
- if(FAILED(m_tbid->dvs->get_SelectedLanguage(&iSelected))) return;
- if(nLangs > 0) m_tbid->dvs->put_SelectedLanguage((iSelected+dir+nLangs)%nLangs);
+ if(FAILED(m_tbid->dvs->get_LanguageCount(&nLangs))) {
+ return;
+ }
+ if(FAILED(m_tbid->dvs->get_SelectedLanguage(&iSelected))) {
+ return;
+ }
+ if(nLangs > 0) {
+ m_tbid->dvs->put_SelectedLanguage((iSelected+dir+nLangs)%nLangs);
+ }
}
- void ShowSub(bool fShow)
- {
+ void ShowSub(bool fShow) {
m_tbid->dvs->put_HideSubtitles(!fShow);
}
- void ToggleSub()
- {
+ void ToggleSub() {
bool fShow;
- if(FAILED(m_tbid->dvs->get_HideSubtitles(&fShow))) return;
+ if(FAILED(m_tbid->dvs->get_HideSubtitles(&fShow))) {
+ return;
+ }
m_tbid->dvs->put_HideSubtitles(!fShow);
}
@@ -131,13 +134,13 @@ END_MESSAGE_MAP()
int CSystrayWindow::OnCreate(LPCREATESTRUCT lpCreateStruct)
{
- if(CWnd::OnCreate(lpCreateStruct) == -1)
+ if(CWnd::OnCreate(lpCreateStruct) == -1) {
return -1;
+ }
- if(g_hHook == INVALID_HANDLE_VALUE)
- {
+ if(g_hHook == INVALID_HANDLE_VALUE) {
AFX_MANAGE_STATE(AfxGetStaticModuleState());
-// g_hHook = SetWindowsHookEx(WH_GETMESSAGE, (HOOKPROC)HookProc, AfxGetInstanceHandle(), 0);
+ // g_hHook = SetWindowsHookEx(WH_GETMESSAGE, (HOOKPROC)HookProc, AfxGetInstanceHandle(), 0);
}
SetTimer(1, 5000, NULL);
@@ -160,8 +163,7 @@ void CSystrayWindow::OnDestroy()
tnid.uID = IDI_ICON1;
Shell_NotifyIcon(NIM_DELETE, &tnid);
- if(g_hHook != INVALID_HANDLE_VALUE)
- {
+ if(g_hHook != INVALID_HANDLE_VALUE) {
UnhookWindowsHookEx(g_hHook);
g_hHook = (HHOOK)INVALID_HANDLE_VALUE;
}
@@ -171,11 +173,9 @@ void CSystrayWindow::OnDestroy()
void CSystrayWindow::OnTimer(UINT_PTR nIDEvent)
{
- if(nIDEvent == 1)
- {
+ if(nIDEvent == 1) {
UINT fScreenSaver = 0;
- if(SystemParametersInfo(SPI_GETSCREENSAVEACTIVE, 0, (PVOID)&fScreenSaver, 0))
- {
+ if(SystemParametersInfo(SPI_GETSCREENSAVEACTIVE, 0, (PVOID)&fScreenSaver, 0)) {
SystemParametersInfo(SPI_SETSCREENSAVEACTIVE, 0, 0, SPIF_SENDWININICHANGE); // this might not be needed at all...
SystemParametersInfo(SPI_SETSCREENSAVEACTIVE, fScreenSaver, 0, SPIF_SENDWININICHANGE);
}
@@ -214,21 +214,22 @@ LRESULT CSystrayWindow::OnTaskBarRestart(WPARAM, LPARAM)
{
AFX_MANAGE_STATE(AfxGetStaticModuleState());
- if(m_tbid->fShowIcon)
- {
+ if(m_tbid->fShowIcon) {
NOTIFYICONDATA tnid;
tnid.cbSize = sizeof(NOTIFYICONDATA);
tnid.hWnd = m_hWnd;
tnid.uID = IDI_ICON1;
tnid.hIcon = (HICON)LoadIcon(AfxGetResourceHandle(), MAKEINTRESOURCE(IDI_ICON1));
-// tnid.hIcon = (HICON)LoadImage(AfxGetResourceHandle(), MAKEINTRESOURCE(IDI_ICON1), IMAGE_ICON, 0, 0, LR_LOADTRANSPARENT);
+ // tnid.hIcon = (HICON)LoadImage(AfxGetResourceHandle(), MAKEINTRESOURCE(IDI_ICON1), IMAGE_ICON, 0, 0, LR_LOADTRANSPARENT);
tnid.uFlags = NIF_MESSAGE | NIF_ICON | NIF_TIP;
tnid.uCallbackMessage = WM_NOTIFYICON;
lstrcpyn(tnid.szTip, TEXT("DirectVobSub"), sizeof(tnid.szTip));
BOOL res = Shell_NotifyIcon(NIM_ADD, &tnid);
- if(tnid.hIcon) DestroyIcon(tnid.hIcon);
+ if(tnid.hIcon) {
+ DestroyIcon(tnid.hIcon);
+ }
return res?0:-1;
}
@@ -238,145 +239,138 @@ LRESULT CSystrayWindow::OnTaskBarRestart(WPARAM, LPARAM)
LRESULT CSystrayWindow::OnNotifyIcon(WPARAM wParam, LPARAM lParam)
{
- if((UINT)wParam != IDI_ICON1)
+ if((UINT)wParam != IDI_ICON1) {
return -1;
+ }
HWND hWnd = m_hWnd;
- switch((UINT)lParam)
- {
- case WM_LBUTTONDBLCLK:
- {
- // IMPORTANT: we must not hold the graph at the same time as showing the property page
- // or else when closing the app the graph doesn't get released and dvobsub's JoinFilterGraph
- // is never called to close us down.
-
- CComPtr<IBaseFilter> pBF2;
-
- BeginEnumFilters(m_tbid->graph, pEF, pBF)
- {
- if(!CComQIPtr<IDirectVobSub>(pBF))
- continue;
-
- if(CComQIPtr<IVideoWindow> pVW = m_tbid->graph)
- {
- HWND hwnd;
- if(SUCCEEDED(pVW->get_Owner((OAHWND*)&hwnd))
- || SUCCEEDED(pVW->get_MessageDrain((OAHWND*)&hwnd)))
- hWnd = hwnd;
- }
+ switch((UINT)lParam) {
+ case WM_LBUTTONDBLCLK: {
+ // IMPORTANT: we must not hold the graph at the same time as showing the property page
+ // or else when closing the app the graph doesn't get released and dvobsub's JoinFilterGraph
+ // is never called to close us down.
- pBF2 = pBF;
+ CComPtr<IBaseFilter> pBF2;
- break;
- }
- EndEnumFilters
-
- if(pBF2)
- ShowPPage(pBF2, hWnd);
- }
- break;
+ BeginEnumFilters(m_tbid->graph, pEF, pBF) {
+ if(!CComQIPtr<IDirectVobSub>(pBF)) {
+ continue;
+ }
- case WM_RBUTTONDOWN:
- {
- POINT p;
- GetCursorPos(&p);
+ if(CComQIPtr<IVideoWindow> pVW = m_tbid->graph) {
+ HWND hwnd;
+ if(SUCCEEDED(pVW->get_Owner((OAHWND*)&hwnd))
+ || SUCCEEDED(pVW->get_MessageDrain((OAHWND*)&hwnd))) {
+ hWnd = hwnd;
+ }
+ }
- CInterfaceArray<IAMStreamSelect> pStreams;
- CStringArray names;
+ pBF2 = pBF;
- BeginEnumFilters(m_tbid->graph, pEF, pBF)
- {
- CString name = GetFilterName(pBF);
- if(name.IsEmpty()) continue;
+ break;
+ }
+ EndEnumFilters
- if(CComQIPtr<IAMStreamSelect> pSS = pBF)
- {
- pStreams.Add(pSS);
- names.Add(name);
+ if(pBF2) {
+ ShowPPage(pBF2, hWnd);
}
}
- EndEnumFilters
+ break;
- CMenu popup;
- popup.CreatePopupMenu();
+ case WM_RBUTTONDOWN: {
+ POINT p;
+ GetCursorPos(&p);
- for(ptrdiff_t j = 0; j < pStreams.GetCount(); j++)
- {
- bool fMMSwitcher = !names[j].Compare(_T("Morgan Stream Switcher"));
+ CInterfaceArray<IAMStreamSelect> pStreams;
+ CStringArray names;
+
+ BeginEnumFilters(m_tbid->graph, pEF, pBF) {
+ CString name = GetFilterName(pBF);
+ if(name.IsEmpty()) {
+ continue;
+ }
+
+ if(CComQIPtr<IAMStreamSelect> pSS = pBF) {
+ pStreams.Add(pSS);
+ names.Add(name);
+ }
+ }
+ EndEnumFilters
- DWORD cStreams = 0;
- pStreams[j]->Count(&cStreams);
+ CMenu popup;
+ popup.CreatePopupMenu();
- DWORD flags, group, prevgroup = (DWORD)-1;
+ for(ptrdiff_t j = 0; j < pStreams.GetCount(); j++) {
+ bool fMMSwitcher = !names[j].Compare(_T("Morgan Stream Switcher"));
- for(UINT i = 0; i < cStreams; i++)
- {
- WCHAR* pName = NULL;
+ DWORD cStreams = 0;
+ pStreams[j]->Count(&cStreams);
- if(S_OK == pStreams[j]->Info(i, 0, &flags, 0, &group, &pName, 0, 0))
- {
- if(prevgroup != group && i > 1)
- {
- if(fMMSwitcher) {
- cStreams = i;
- break;
+ DWORD flags, group, prevgroup = (DWORD)-1;
+
+ for(UINT i = 0; i < cStreams; i++) {
+ WCHAR* pName = NULL;
+
+ if(S_OK == pStreams[j]->Info(i, 0, &flags, 0, &group, &pName, 0, 0)) {
+ if(prevgroup != group && i > 1) {
+ if(fMMSwitcher) {
+ cStreams = i;
+ break;
+ }
+ popup.AppendMenu(MF_SEPARATOR);
}
- popup.AppendMenu(MF_SEPARATOR);
- }
- prevgroup = group;
+ prevgroup = group;
- if(pName)
- {
- popup.AppendMenu(MF_ENABLED|MF_STRING|(flags?MF_CHECKED:MF_UNCHECKED), (1<<15)|(j<<8)|(i), CString(pName));
- CoTaskMemFree(pName);
+ if(pName) {
+ popup.AppendMenu(MF_ENABLED|MF_STRING|(flags?MF_CHECKED:MF_UNCHECKED), (1<<15)|(j<<8)|(i), CString(pName));
+ CoTaskMemFree(pName);
+ }
}
}
- }
-
- if(cStreams > 0) popup.AppendMenu(MF_SEPARATOR);
- }
- int i = 0;
-
- TCHAR* str;
- str = CallPPage(m_tbid->graph, i, (HWND)INVALID_HANDLE_VALUE);
- while(str)
- {
- if(_tcsncmp(str, _T("DivX MPEG"), 9) || m_tbid->fRunOnce) // divx3's ppage will crash if the graph hasn't been run at least once yet
- popup.AppendMenu(MF_ENABLED|MF_STRING|MF_UNCHECKED, (1<<14)|(i), str);
+ if(cStreams > 0) {
+ popup.AppendMenu(MF_SEPARATOR);
+ }
+ }
- delete [] str;
+ int i = 0;
- i++;
+ TCHAR* str;
str = CallPPage(m_tbid->graph, i, (HWND)INVALID_HANDLE_VALUE);
- }
+ while(str) {
+ if(_tcsncmp(str, _T("DivX MPEG"), 9) || m_tbid->fRunOnce) { // divx3's ppage will crash if the graph hasn't been run at least once yet
+ popup.AppendMenu(MF_ENABLED|MF_STRING|MF_UNCHECKED, (1<<14)|(i), str);
+ }
- SetForegroundWindow();
- UINT id = popup.TrackPopupMenu(TPM_LEFTBUTTON|TPM_RETURNCMD, p.x, p.y, CWnd::FromHandle(hWnd), 0);
- PostMessage(WM_NULL);
+ delete [] str;
- if(id & (1<<15))
- {
- pStreams[(id>>8)&0x3f]->Enable(id&0xff, AMSTREAMSELECTENABLE_ENABLE);
- }
- else if(id & (1<<14))
- {
- if(CComQIPtr<IVideoWindow> pVW = m_tbid->graph)
- {
- HWND hwnd;
- if(SUCCEEDED(pVW->get_Owner((OAHWND*)&hwnd))
- || SUCCEEDED(pVW->get_MessageDrain((OAHWND*)&hwnd)))
- hWnd = hwnd;
+ i++;
+ str = CallPPage(m_tbid->graph, i, (HWND)INVALID_HANDLE_VALUE);
}
- CallPPage(m_tbid->graph, id&0xff, hWnd);
- }
- }
- break;
+ SetForegroundWindow();
+ UINT id = popup.TrackPopupMenu(TPM_LEFTBUTTON|TPM_RETURNCMD, p.x, p.y, CWnd::FromHandle(hWnd), 0);
+ PostMessage(WM_NULL);
+
+ if(id & (1<<15)) {
+ pStreams[(id>>8)&0x3f]->Enable(id&0xff, AMSTREAMSELECTENABLE_ENABLE);
+ } else if(id & (1<<14)) {
+ if(CComQIPtr<IVideoWindow> pVW = m_tbid->graph) {
+ HWND hwnd;
+ if(SUCCEEDED(pVW->get_Owner((OAHWND*)&hwnd))
+ || SUCCEEDED(pVW->get_MessageDrain((OAHWND*)&hwnd))) {
+ hWnd = hwnd;
+ }
+ }
- default:
+ CallPPage(m_tbid->graph, id&0xff, hWnd);
+ }
+ }
break;
+
+ default:
+ break;
}
return 0;
@@ -389,14 +383,14 @@ DWORD CALLBACK SystrayThreadProc(void* pParam)
AFX_MANAGE_STATE(AfxGetStaticModuleState());
CSystrayWindow wnd((SystrayIconData*)pParam);
- if(!wnd.CreateEx(0, AfxRegisterWndClass(0), _T("DVSWND"), WS_OVERLAPPED, CRect(0, 0, 0, 0), NULL, 0, NULL))
+ if(!wnd.CreateEx(0, AfxRegisterWndClass(0), _T("DVSWND"), WS_OVERLAPPED, CRect(0, 0, 0, 0), NULL, 0, NULL)) {
return (DWORD)-1;
+ }
((SystrayIconData*)pParam)->hSystrayWnd = wnd.m_hWnd;
MSG msg;
- while(GetMessage(&msg, NULL/*wnd.m_hWnd*/, 0, 0))
- {
+ while(GetMessage(&msg, NULL/*wnd.m_hWnd*/, 0, 0)) {
TranslateMessage(&msg);
DispatchMessage(&msg);
}
@@ -417,13 +411,13 @@ static TCHAR* CallPPage(IFilterGraph* pGraph, int idx, HWND hWnd)
CAUUID caGUID;
caGUID.pElems = NULL;
- BeginEnumFilters(pGraph, pEF, pBF)
- {
+ BeginEnumFilters(pGraph, pEF, pBF) {
CComQIPtr<ISpecifyPropertyPages> pSPS = pBF;
- if(!pSPS) continue;
+ if(!pSPS) {
+ continue;
+ }
- if(i == idx)
- {
+ if(i == idx) {
pFilter = pBF;
pSPS->GetPages(&caGUID);
wstr = _wcsdup(CStringW(GetFilterName(pBF))); // double char-wchar conversion happens in the non-unicode build, but anyway... :)
@@ -436,22 +430,23 @@ static TCHAR* CallPPage(IFilterGraph* pGraph, int idx, HWND hWnd)
TCHAR* ret = NULL;
- if(pFilter)
- {
- if(hWnd != INVALID_HANDLE_VALUE)
- {
+ if(pFilter) {
+ if(hWnd != INVALID_HANDLE_VALUE) {
ShowPPage(pFilter, hWnd);
- }
- else
- {
+ } else {
ret = new TCHAR[wcslen(wstr)+1];
- if(ret)
+ if(ret) {
_tcscpy(ret, CString(wstr));
+ }
}
}
- if(caGUID.pElems) CoTaskMemFree(caGUID.pElems);
- if(wstr) free(wstr);
+ if(caGUID.pElems) {
+ CoTaskMemFree(caGUID.pElems);
+ }
+ if(wstr) {
+ free(wstr);
+ }
return(ret);
}
diff --git a/src/filters/transform/VSFilter/VSFilter.cpp b/src/filters/transform/VSFilter/VSFilter.cpp
index 12ae93e67..2bb1d23fb 100644
--- a/src/filters/transform/VSFilter/VSFilter.cpp
+++ b/src/filters/transform/VSFilter/VSFilter.cpp
@@ -44,8 +44,9 @@ extern "C" BOOL WINAPI DllEntryPoint(HINSTANCE, ULONG, LPVOID);
BOOL CVSFilterApp::InitInstance()
{
- if(!CWinApp::InitInstance())
+ if(!CWinApp::InitInstance()) {
return FALSE;
+ }
SetRegistryKey(_T("Gabest"));
@@ -82,8 +83,7 @@ CVSFilterApp theApp;
//////////////////////////////////////////////////////////////////////////
-const AMOVIESETUP_MEDIATYPE sudPinTypesIn[] =
-{
+const AMOVIESETUP_MEDIATYPE sudPinTypesIn[] = {
{&MEDIATYPE_NULL, &MEDIASUBTYPE_NULL},
{&MEDIATYPE_Video, &MEDIASUBTYPE_YUY2},
{&MEDIATYPE_Video, &MEDIASUBTYPE_YV12},
@@ -95,31 +95,27 @@ const AMOVIESETUP_MEDIATYPE sudPinTypesIn[] =
{&MEDIATYPE_Video, &MEDIASUBTYPE_RGB24},
};
-const AMOVIESETUP_MEDIATYPE sudPinTypesIn2[] =
-{
+const AMOVIESETUP_MEDIATYPE sudPinTypesIn2[] = {
{&MEDIATYPE_Text, &MEDIASUBTYPE_None},
};
-const AMOVIESETUP_MEDIATYPE sudPinTypesOut[] =
-{
+const AMOVIESETUP_MEDIATYPE sudPinTypesOut[] = {
{&MEDIATYPE_Video, &MEDIASUBTYPE_None},
};
-const AMOVIESETUP_PIN sudpPins[] =
-{
+const AMOVIESETUP_PIN sudpPins[] = {
{L"Input", FALSE, FALSE, FALSE, FALSE, &CLSID_NULL, NULL, countof(sudPinTypesIn), sudPinTypesIn},
{L"Output", FALSE, TRUE, FALSE, FALSE, &CLSID_NULL, NULL, countof(sudPinTypesOut), sudPinTypesOut},
{L"Input2", TRUE, FALSE, FALSE, TRUE, &CLSID_NULL, NULL, countof(sudPinTypesIn2), sudPinTypesIn2}
};
-/*const*/ AMOVIESETUP_FILTER sudFilter[] =
-{
+/*const*/
+AMOVIESETUP_FILTER sudFilter[] = {
{&__uuidof(CDirectVobSubFilter), L"DirectVobSub", MERIT_DO_NOT_USE, countof(sudpPins), sudpPins, CLSID_LegacyAmFilterCategory},
{&__uuidof(CDirectVobSubFilter2), L"DirectVobSub (auto-loading version)", MERIT_PREFERRED+2, countof(sudpPins), sudpPins, CLSID_LegacyAmFilterCategory},
};
-CFactoryTemplate g_Templates[] =
-{
+CFactoryTemplate g_Templates[] = {
{sudFilter[0].strName, sudFilter[0].clsID, CreateInstance<CDirectVobSubFilter>, NULL, &sudFilter[0]},
{sudFilter[1].strName, sudFilter[1].clsID, CreateInstance<CDirectVobSubFilter2>, NULL, &sudFilter[1]},
{L"DVSMainPPage", &__uuidof(CDVSMainPPage), CreateInstance<CDVSMainPPage>},
@@ -140,34 +136,38 @@ STDAPI DllRegisterServer()
{
AFX_MANAGE_STATE(AfxGetStaticModuleState());
- if(theApp.GetProfileInt(ResStr(IDS_R_GENERAL), ResStr(IDS_RG_SEENDIVXWARNING), 0) != 1)
+ if(theApp.GetProfileInt(ResStr(IDS_R_GENERAL), ResStr(IDS_RG_SEENDIVXWARNING), 0) != 1) {
theApp.WriteProfileInt(ResStr(IDS_R_GENERAL), ResStr(IDS_RG_SEENDIVXWARNING), 0);
+ }
- if(theApp.GetProfileInt(ResStr(IDS_R_GENERAL), ResStr(IDS_RG_VMRZOOMENABLED), -1) == -1)
+ if(theApp.GetProfileInt(ResStr(IDS_R_GENERAL), ResStr(IDS_RG_VMRZOOMENABLED), -1) == -1) {
theApp.WriteProfileInt(ResStr(IDS_R_GENERAL), ResStr(IDS_RG_VMRZOOMENABLED), 0);
+ }
- if(theApp.GetProfileInt(ResStr(IDS_R_GENERAL), ResStr(IDS_RG_ENABLEZPICON), -1) == -1)
+ if(theApp.GetProfileInt(ResStr(IDS_R_GENERAL), ResStr(IDS_RG_ENABLEZPICON), -1) == -1) {
theApp.WriteProfileInt(ResStr(IDS_R_GENERAL), ResStr(IDS_RG_ENABLEZPICON), 0);
+ }
return AMovieDllRegisterServer2(TRUE);
}
STDAPI DllUnregisterServer()
{
-// DVS_WriteProfileInt2(IDS_R_GENERAL, IDS_RG_SEENDIVXWARNING, 0);
+ // DVS_WriteProfileInt2(IDS_R_GENERAL, IDS_RG_SEENDIVXWARNING, 0);
return AMovieDllRegisterServer2(FALSE);
}
void CALLBACK DirectVobSub(HWND hwnd, HINSTANCE hinst, LPSTR lpszCmdLine, int nCmdShow)
{
- if(FAILED(::CoInitialize(0))) return;
+ if(FAILED(::CoInitialize(0))) {
+ return;
+ }
CComPtr<IBaseFilter> pFilter;
CComQIPtr<ISpecifyPropertyPages> pSpecify;
- if(SUCCEEDED(pFilter.CoCreateInstance(__uuidof(CDirectVobSubFilter))) && (pSpecify = pFilter))
- {
+ if(SUCCEEDED(pFilter.CoCreateInstance(__uuidof(CDirectVobSubFilter))) && (pSpecify = pFilter)) {
ShowPPage(pFilter, hwnd);
}
diff --git a/src/filters/transform/VSFilter/csri.h b/src/filters/transform/VSFilter/csri.h
index 83ee828fa..7d67bae96 100644
--- a/src/filters/transform/VSFilter/csri.h
+++ b/src/filters/transform/VSFilter/csri.h
@@ -43,39 +43,39 @@ extern "C" {
#endif
#ifndef CSRIAPI
-/** CSRI API attributes.
- * defaults to \c extern.
-*/
+ /** CSRI API attributes.
+ * defaults to \c extern.
+ */
#define CSRIAPI extern
#endif
-/** \defgroup base CSRI base API. */
-/*@{*/
+ /** \defgroup base CSRI base API. */
+ /*@{*/
-/** pixel format specification for frames */
-enum csri_pixfmt {
- CSRI_F_RGBA = 0,
- CSRI_F_ARGB,
- CSRI_F_BGRA,
- CSRI_F_ABGR,
+ /** pixel format specification for frames */
+ enum csri_pixfmt {
+ CSRI_F_RGBA = 0,
+ CSRI_F_ARGB,
+ CSRI_F_BGRA,
+ CSRI_F_ABGR,
- CSRI_F_RGB_ = 0x100,
- CSRI_F__RGB,
- CSRI_F_BGR_, /**< Windows "RGB32" */
- CSRI_F__BGR,
+ CSRI_F_RGB_ = 0x100,
+ CSRI_F__RGB,
+ CSRI_F_BGR_, /**< Windows "RGB32" */
+ CSRI_F__BGR,
- CSRI_F_RGB = 0x200,
- CSRI_F_BGR, /**< Windows "RGB24" */
+ CSRI_F_RGB = 0x200,
+ CSRI_F_BGR, /**< Windows "RGB24" */
- CSRI_F_AYUV = 0x1000,
- CSRI_F_YUVA,
- CSRI_F_YVUA,
+ CSRI_F_AYUV = 0x1000,
+ CSRI_F_YUVA,
+ CSRI_F_YVUA,
- CSRI_F_YUY2 = 0x1100,
+ CSRI_F_YUY2 = 0x1100,
- CSRI_F_YV12A = 0x2011, /**< planar YUV 2x2 + alpha plane */
- CSRI_F_YV12 = 0x2111 /**< planar YUV 2x2 */
- };
+ CSRI_F_YV12A = 0x2011, /**< planar YUV 2x2 + alpha plane */
+ CSRI_F_YV12 = 0x2111 /**< planar YUV 2x2 */
+ };
#define csri_is_rgb(x) ((x) < 0x1000)
#define csri_is_yuv(x) ((x) >= 0x1000)
@@ -85,261 +85,261 @@ enum csri_pixfmt {
#define csri_is_yuv_packed(x) ((x) >= 0x1000 && (x) < 0x2000)
#define csri_has_alpha(x) (((x) & 0xfff) < 0x100)
-/** frame/image format specification pre-fed to the renderer */
-struct csri_fmt {
- /** format to be used */
- enum csri_pixfmt pixfmt;
- /** image width, full frame.
- *
- * This should specify the full size of the frame.
- * Specifying the video sub-size (in case of added black
- * borders) is left to an extension.
- */
- unsigned width;
- /** image height */
- unsigned height;
-};
-
-/** single frame to be fed to the renderer. */
-struct csri_frame {
- /** frame format.
- * It is an application bug if this differs from the one
- * passed in struct #csri_fmt to csri_query_fmt()
- */
- enum csri_pixfmt pixfmt;
- /** the frame's data.
- * Packed formats only use planes[0]; planar formats
- * have the data ordered as Y, U, V[, A].
- *
- * Also note that the topmost line always comes first.
- * The Windows biHeight strange-ity is \a NOT duplicated.
- */
- unsigned char *planes[4];
- /** strides for the individual planes.
- * Stride means full byte offset, i.e. do \a not add
- * frame width
- */
- ptrdiff_t strides[4];
-};
+ /** frame/image format specification pre-fed to the renderer */
+ struct csri_fmt {
+ /** format to be used */
+ enum csri_pixfmt pixfmt;
+ /** image width, full frame.
+ *
+ * This should specify the full size of the frame.
+ * Specifying the video sub-size (in case of added black
+ * borders) is left to an extension.
+ */
+ unsigned width;
+ /** image height */
+ unsigned height;
+ };
+
+ /** single frame to be fed to the renderer. */
+ struct csri_frame {
+ /** frame format.
+ * It is an application bug if this differs from the one
+ * passed in struct #csri_fmt to csri_query_fmt()
+ */
+ enum csri_pixfmt pixfmt;
+ /** the frame's data.
+ * Packed formats only use planes[0]; planar formats
+ * have the data ordered as Y, U, V[, A].
+ *
+ * Also note that the topmost line always comes first.
+ * The Windows biHeight strange-ity is \a NOT duplicated.
+ */
+ unsigned char *planes[4];
+ /** strides for the individual planes.
+ * Stride means full byte offset, i.e. do \a not add
+ * frame width
+ */
+ ptrdiff_t strides[4];
+ };
#ifndef CSRI_OWN_HANDLES
-/** opaque renderer data */
-typedef void csri_rend;
-/** opaque instance data */
-typedef void csri_inst;
+ /** opaque renderer data */
+ typedef void csri_rend;
+ /** opaque instance data */
+ typedef void csri_inst;
#endif
#ifdef DOXYGEN
-/** disable the emission of the csri_rend and csri_inst typedefs.
- * define this if you are in a renderer and are typedef'ing
- * csri_rend and csri_inst to your own structs.
-*/
+ /** disable the emission of the csri_rend and csri_inst typedefs.
+ * define this if you are in a renderer and are typedef'ing
+ * csri_rend and csri_inst to your own structs.
+ */
#define CSRI_OWN_HANDLES
#endif
-/** renderer description.
- * \ingroup loader
- */
-struct csri_info {
- /** an identifier for the renderer.
- * - MUST match the regular expression
- * \code ^[a-zA-Z]([a-zA-Z0-9_]*[a-zA-Z0-9])? \endcode
- * i.e. consists only of letters, numbers and underscores;
- * must start with a letter and doesnt have an underscore
- * as the last character.
+ /** renderer description.
+ * \ingroup loader
+ */
+ struct csri_info {
+ /** an identifier for the renderer.
+ * - MUST match the regular expression
+ * \code ^[a-zA-Z]([a-zA-Z0-9_]*[a-zA-Z0-9])? \endcode
+ * i.e. consists only of letters, numbers and underscores;
+ * must start with a letter and doesnt have an underscore
+ * as the last character.
+ */
+ const char *name;
+ /** an identifier to the exact version of the renderer.
+ * most likely a version number or revision identifier.
+ *
+ * The helper library does a strcmp over this field in order
+ * to order multiple instances of the same renderer. Use
+ * higher-byte-value strings for newer renderers.
+ */
+ const char *specific;
+
+ /** a nice name to be presented to the user */
+ const char *longname;
+ /** the renderer's author */
+ const char *author;
+ /** a copyright string. Copyright (c) 2042 by Mr. Nice Guy */
+ const char *copyright;
+ };
+
+ /** data of extension-dependent type.
+ * The field to be used MUST be specified in the extension where it is used.
*/
- const char *name;
- /** an identifier to the exact version of the renderer.
- * most likely a version number or revision identifier.
+ union csri_vardata {
+ long lval;
+ double dval;
+ const char *utf8val;
+ void *otherval;
+ };
+
+ /** extension identifier.
+ * This follows reverse DNS syntax, i.e.:
+ * \code root.branch.leaf \endcode
+ * you can either reverse a registered domain name, e.g.
+ * \code com.microsoft.csri.usegdiplus \endcode
+ * or ask the CSRI maintainers to assign a namespace to you.
*
- * The helper library does a strcmp over this field in order
- * to order multiple instances of the same renderer. Use
- * higher-byte-value strings for newer renderers.
+ * currently registered namespaces are:
+ *
+ * \code
+ * csri.* - official extensions
+ * asa.* - custom extensions of the asa renderer
+ * \endcode
*/
- const char *specific;
-
- /** a nice name to be presented to the user */
- const char *longname;
- /** the renderer's author */
- const char *author;
- /** a copyright string. Copyright (c) 2042 by Mr. Nice Guy */
- const char *copyright;
-};
-
-/** data of extension-dependent type.
- * The field to be used MUST be specified in the extension where it is used.
- */
-union csri_vardata {
- long lval;
- double dval;
- const char *utf8val;
- void *otherval;
-};
-
-/** extension identifier.
- * This follows reverse DNS syntax, i.e.:
- * \code root.branch.leaf \endcode
- * you can either reverse a registered domain name, e.g.
- * \code com.microsoft.csri.usegdiplus \endcode
- * or ask the CSRI maintainers to assign a namespace to you.
- *
- * currently registered namespaces are:
- *
- * \code
- * csri.* - official extensions
- * asa.* - custom extensions of the asa renderer
- * \endcode
- */
-typedef const char *csri_ext_id;
-
-/** script loading parameters.
- * each flag MUST have an associated extension, which can be queried
- * with csri_query_ext(). If the open flag constitutes an extension on its
- * sole own, csri_query_ext() can return a meaningless non-NULL value for
- * it.
- *
- * The data field used must be specified.
- *
- * An extension can have multiple flags. In that case, the flags should have
- * the extension name as common prefix, separated with a dot.
- *
- * A renderer MUST ignore unknown open flags. It MUST NOT return an error
- * just because it does not support a particular flag.
- */
-struct csri_openflag {
- /** flag name */
- csri_ext_id name;
- /** flag data argument */
- union csri_vardata data;
- /** link to next flag */
- struct csri_openflag *next;
-};
-
-/** load a script from a file.
- * \param renderer the handle to the renderer
- * \param filename the path to the file to be loaded. \n
- * The filename should be encoded as UTF-8. Windows renderers are
- * expected to convert it to UTF-16 and use the Unicode Windows API
- * functions.
- * \param flags a linked list of open flags. \n
- * The caller manages memory allocation, i.e. static allocation is OK.
- * \return the renderer instance handle, or NULL on error.
- */
-CSRIAPI csri_inst *csri_open_file(csri_rend *renderer,
- const char *filename, struct csri_openflag *flags);
-
-/** load a script from memory.
- * \param renderer the handle to the renderer
- * \param data pointer to the first data byte. \n
- * The caller manages memory allocation and should free the data after
- * calling csri_open_mem(). If the renderer needs to keep the data, it
- * must copy it. \n
- * The renderer is not allowed to write to the data.
- * \param length length, in bytes, of the data
- * \param flags see csri_open_file()
- * \return the render instance handle, or NULL on error.
- */
-
-CSRIAPI csri_inst *csri_open_mem(csri_rend *renderer,
- const void *data, size_t length, struct csri_openflag *flags);
-
-/** close a renderer instance.
- * \param inst the instance handle.
- */
-CSRIAPI void csri_close(csri_inst *inst);
-
-
-/** query / set the image format and size.
- * \param inst the renderer instance handle
- * \param fmt the format and image size to be used
- * \return 0 if the format was successfully set,
- * any other value in case of error.
- */
-CSRIAPI int csri_request_fmt(csri_inst *inst, const struct csri_fmt *fmt);
-
-/** render a single frame
- * \param inst the renderer instance handle
- * \param frame frame data to render to
- * \param time associated timestamp of the frame
- */
-CSRIAPI void csri_render(csri_inst *inst, struct csri_frame *frame,
- double time);
-
-
-/** query for an extension.
- * \param rend the renderer handle
- * \param extname the extension's identifier
- * \return NULL if the extension is not supported,
- * a pointer to extension-specific data otherwise
- *
- * The data pointed to by the return value does not neccessarily need to
- * have any meaning; An extension that does not need to return data
- * can return a pointer to whatever it wants, as long as that pointer is
- * not NULL.
- *
- * In the usual case, the pointer is supposed to point to a struct with
- * function pointers and other information as needed.
- */
-CSRIAPI void *csri_query_ext(csri_rend *rend, csri_ext_id extname);
+ typedef const char *csri_ext_id;
-/*@}*/
+ /** script loading parameters.
+ * each flag MUST have an associated extension, which can be queried
+ * with csri_query_ext(). If the open flag constitutes an extension on its
+ * sole own, csri_query_ext() can return a meaningless non-NULL value for
+ * it.
+ *
+ * The data field used must be specified.
+ *
+ * An extension can have multiple flags. In that case, the flags should have
+ * the extension name as common prefix, separated with a dot.
+ *
+ * A renderer MUST ignore unknown open flags. It MUST NOT return an error
+ * just because it does not support a particular flag.
+ */
+ struct csri_openflag {
+ /** flag name */
+ csri_ext_id name;
+ /** flag data argument */
+ union csri_vardata data;
+ /** link to next flag */
+ struct csri_openflag *next;
+ };
+
+ /** load a script from a file.
+ * \param renderer the handle to the renderer
+ * \param filename the path to the file to be loaded. \n
+ * The filename should be encoded as UTF-8. Windows renderers are
+ * expected to convert it to UTF-16 and use the Unicode Windows API
+ * functions.
+ * \param flags a linked list of open flags. \n
+ * The caller manages memory allocation, i.e. static allocation is OK.
+ * \return the renderer instance handle, or NULL on error.
+ */
+ CSRIAPI csri_inst *csri_open_file(csri_rend *renderer,
+ const char *filename, struct csri_openflag *flags);
+
+ /** load a script from memory.
+ * \param renderer the handle to the renderer
+ * \param data pointer to the first data byte. \n
+ * The caller manages memory allocation and should free the data after
+ * calling csri_open_mem(). If the renderer needs to keep the data, it
+ * must copy it. \n
+ * The renderer is not allowed to write to the data.
+ * \param length length, in bytes, of the data
+ * \param flags see csri_open_file()
+ * \return the render instance handle, or NULL on error.
+ */
-/** \defgroup loader CSRI loader API.
- *
- * These functions locate renderers based on given parameters.
- *
- * <b>Renderers must implement these functions as well.</b>
- *
- * They are used by the library to grab renderer information
- * from a shared object; and also this way a single renderer
- * can be linked directly into an appliaction.
- */
-/*@{*/
-
-/** get renderer information
- * \param rend the renderer handle
- * \return information about the renderer, or NULL in case the renderer
- * encountered an internal error.
- */
-CSRIAPI struct csri_info *csri_renderer_info(csri_rend *rend);
-
-/** try to load a given renderer
- * \param name the name of the renderer, as in csri_info.name
- * \param specific the specific version of the renderer,
- * as in csri_info.specific;\n
- * alternatively NULL if any version of the renderer is ok.
- * \return a handle to the renderer if it was successfully loaded,
- * NULL otherwise.
- */
-CSRIAPI csri_rend *csri_renderer_byname(const char *name,
- const char *specific);
-
-/** try to find an implementation of the given extensions.
- * \param next number of extensions pointed to by ext
- * \param ext array of extensions to search for
- * \return a handle to a renderer supporting ALL of the
- * extensions, NULL if none was found.
- */
-CSRIAPI csri_rend *csri_renderer_byext(unsigned n_ext, csri_ext_id *ext);
-
-/** get the default (highest priority) renderer
- * \return a handle to the default renderer, or NULL if
- * no renderer is installed.
- *
- * Together with csri_renderer_next(), this can be used
- * to enumerate all installed renderers.
- */
-CSRIAPI csri_rend *csri_renderer_default();
-
-/** get the next lower priority renderer
- * \param prev the current renderer
- * \return the renderer with the next lower priority than
- * the one named in prev, or NULL if prev is the last
- * renderer installed.
- */
-CSRIAPI csri_rend *csri_renderer_next(csri_rend *prev);
-
-/*@}*/
+ CSRIAPI csri_inst *csri_open_mem(csri_rend *renderer,
+ const void *data, size_t length, struct csri_openflag *flags);
+
+ /** close a renderer instance.
+ * \param inst the instance handle.
+ */
+ CSRIAPI void csri_close(csri_inst *inst);
+
+
+ /** query / set the image format and size.
+ * \param inst the renderer instance handle
+ * \param fmt the format and image size to be used
+ * \return 0 if the format was successfully set,
+ * any other value in case of error.
+ */
+ CSRIAPI int csri_request_fmt(csri_inst *inst, const struct csri_fmt *fmt);
+
+ /** render a single frame
+ * \param inst the renderer instance handle
+ * \param frame frame data to render to
+ * \param time associated timestamp of the frame
+ */
+ CSRIAPI void csri_render(csri_inst *inst, struct csri_frame *frame,
+ double time);
+
+
+ /** query for an extension.
+ * \param rend the renderer handle
+ * \param extname the extension's identifier
+ * \return NULL if the extension is not supported,
+ * a pointer to extension-specific data otherwise
+ *
+ * The data pointed to by the return value does not neccessarily need to
+ * have any meaning; An extension that does not need to return data
+ * can return a pointer to whatever it wants, as long as that pointer is
+ * not NULL.
+ *
+ * In the usual case, the pointer is supposed to point to a struct with
+ * function pointers and other information as needed.
+ */
+ CSRIAPI void *csri_query_ext(csri_rend *rend, csri_ext_id extname);
+
+ /*@}*/
+
+ /** \defgroup loader CSRI loader API.
+ *
+ * These functions locate renderers based on given parameters.
+ *
+ * <b>Renderers must implement these functions as well.</b>
+ *
+ * They are used by the library to grab renderer information
+ * from a shared object; and also this way a single renderer
+ * can be linked directly into an appliaction.
+ */
+ /*@{*/
+
+ /** get renderer information
+ * \param rend the renderer handle
+ * \return information about the renderer, or NULL in case the renderer
+ * encountered an internal error.
+ */
+ CSRIAPI struct csri_info *csri_renderer_info(csri_rend *rend);
+
+ /** try to load a given renderer
+ * \param name the name of the renderer, as in csri_info.name
+ * \param specific the specific version of the renderer,
+ * as in csri_info.specific;\n
+ * alternatively NULL if any version of the renderer is ok.
+ * \return a handle to the renderer if it was successfully loaded,
+ * NULL otherwise.
+ */
+ CSRIAPI csri_rend *csri_renderer_byname(const char *name,
+ const char *specific);
+
+ /** try to find an implementation of the given extensions.
+ * \param next number of extensions pointed to by ext
+ * \param ext array of extensions to search for
+ * \return a handle to a renderer supporting ALL of the
+ * extensions, NULL if none was found.
+ */
+ CSRIAPI csri_rend *csri_renderer_byext(unsigned n_ext, csri_ext_id *ext);
+
+ /** get the default (highest priority) renderer
+ * \return a handle to the default renderer, or NULL if
+ * no renderer is installed.
+ *
+ * Together with csri_renderer_next(), this can be used
+ * to enumerate all installed renderers.
+ */
+ CSRIAPI csri_rend *csri_renderer_default();
+
+ /** get the next lower priority renderer
+ * \param prev the current renderer
+ * \return the renderer with the next lower priority than
+ * the one named in prev, or NULL if prev is the last
+ * renderer installed.
+ */
+ CSRIAPI csri_rend *csri_renderer_next(csri_rend *prev);
+
+ /*@}*/
#ifdef __cplusplus
}
diff --git a/src/filters/transform/VSFilter/csriapi.cpp b/src/filters/transform/VSFilter/csriapi.cpp
index 059c02c84..498c1d592 100644
--- a/src/filters/transform/VSFilter/csriapi.cpp
+++ b/src/filters/transform/VSFilter/csriapi.cpp
@@ -54,8 +54,9 @@ CSRIAPI csri_inst *csri_open_file(csri_rend *renderer, const char *filename, str
wchar_t *namebuf;
namesize = MultiByteToWideChar(CP_UTF8, 0, filename, -1, NULL, 0);
- if (!namesize)
+ if (!namesize) {
return 0;
+ }
namesize++;
namebuf = new wchar_t[namesize];
MultiByteToWideChar(CP_UTF8, 0, filename, -1, namebuf, namesize);
@@ -98,7 +99,9 @@ CSRIAPI csri_inst *csri_open_mem(csri_rend *renderer, const void *data, size_t l
CSRIAPI void csri_close(csri_inst *inst)
{
- if (!inst) return;
+ if (!inst) {
+ return;
+ }
delete inst->rts;
delete inst->cs;
@@ -108,10 +111,13 @@ CSRIAPI void csri_close(csri_inst *inst)
CSRIAPI int csri_request_fmt(csri_inst *inst, const struct csri_fmt *fmt)
{
- if (!inst) return -1;
+ if (!inst) {
+ return -1;
+ }
- if (!fmt->width || !fmt->height)
+ if (!fmt->width || !fmt->height) {
return -1;
+ }
// Check if pixel format is supported
switch (fmt->pixfmt) {
@@ -188,18 +194,18 @@ CSRIAPI void *csri_query_ext(csri_rend *rend, csri_ext_id extname)
// Get info for renderer
static struct csri_info csri_vsfilter_info = {
#ifdef _DEBUG
- #ifdef _VSMOD
- "vsfiltermod_textsub_debug", // name
- #else
- "vsfilter_textsub_debug", // name
- #endif
+#ifdef _VSMOD
+ "vsfiltermod_textsub_debug", // name
+#else
+ "vsfilter_textsub_debug", // name
+#endif
"2.40", // version (assumed version number, svn revision, patchlevel)
#else
- #ifdef _VSMOD
- "vsfiltermod_textsub", // name
- #else
- "vsfilter_textsub", // name
- #endif
+#ifdef _VSMOD
+ "vsfiltermod_textsub", // name
+#else
+ "vsfilter_textsub", // name
+#endif
"2.40", // version (assumed version number, svn revision, patchlevel)
#endif
// 2.38-0611 is base svn 611
@@ -216,17 +222,18 @@ static struct csri_info csri_vsfilter_info = {
"Gabest", // author
"Copyright (c) 2003-2010 by Gabest and others" // copyright
};
-CSRIAPI struct csri_info *csri_renderer_info(csri_rend *rend)
-{
+CSRIAPI struct csri_info *csri_renderer_info(csri_rend *rend) {
return &csri_vsfilter_info;
}
// Only one supported, obviously
CSRIAPI csri_rend *csri_renderer_byname(const char *name, const char *specific)
{
- if (strcmp(name, csri_vsfilter_info.name))
+ if (strcmp(name, csri_vsfilter_info.name)) {
return 0;
- if (specific && strcmp(specific, csri_vsfilter_info.specific))
+ }
+ if (specific && strcmp(specific, csri_vsfilter_info.specific)) {
return 0;
+ }
return &csri_vsfilter;
}
// Still just one
diff --git a/src/filters/transform/VSFilter/plugins.cpp b/src/filters/transform/VSFilter/plugins.cpp
index 9f7146b1f..6e4732c0c 100644
--- a/src/filters/transform/VSFilter/plugins.cpp
+++ b/src/filters/transform/VSFilter/plugins.cpp
@@ -39,1104 +39,1102 @@
namespace Plugin
{
-class CFilter : public CAMThread, public CCritSec
-{
-private:
- CString m_fn;
-
-protected:
- float m_fps;
- CCritSec m_csSubLock;
- CComPtr<ISubPicQueue> m_pSubPicQueue;
- CComPtr<ISubPicProvider> m_pSubPicProvider;
- DWORD_PTR m_SubPicProviderId;
-
-public:
- CFilter() : m_fps(-1), m_SubPicProviderId(0) {
- CAMThread::Create();
- }
- virtual ~CFilter() {
- CAMThread::CallWorker(0);
- }
+ class CFilter : public CAMThread, public CCritSec
+ {
+ private:
+ CString m_fn;
+
+ protected:
+ float m_fps;
+ CCritSec m_csSubLock;
+ CComPtr<ISubPicQueue> m_pSubPicQueue;
+ CComPtr<ISubPicProvider> m_pSubPicProvider;
+ DWORD_PTR m_SubPicProviderId;
+
+ public:
+ CFilter() : m_fps(-1), m_SubPicProviderId(0) {
+ CAMThread::Create();
+ }
+ virtual ~CFilter() {
+ CAMThread::CallWorker(0);
+ }
- CString GetFileName() {
- CAutoLock cAutoLock(this);
- return m_fn;
- }
- void SetFileName(CString fn) {
- CAutoLock cAutoLock(this);
- m_fn = fn;
- }
+ CString GetFileName() {
+ CAutoLock cAutoLock(this);
+ return m_fn;
+ }
+ void SetFileName(CString fn) {
+ CAutoLock cAutoLock(this);
+ m_fn = fn;
+ }
- bool Render(SubPicDesc& dst, REFERENCE_TIME rt, float fps)
- {
- if(!m_pSubPicProvider)
- return(false);
+ bool Render(SubPicDesc& dst, REFERENCE_TIME rt, float fps) {
+ if(!m_pSubPicProvider) {
+ return(false);
+ }
- CSize size(dst.w, dst.h);
+ CSize size(dst.w, dst.h);
- if(!m_pSubPicQueue)
- {
- CComPtr<ISubPicAllocator> pAllocator = new CMemSubPicAllocator(dst.type, size);
+ if(!m_pSubPicQueue) {
+ CComPtr<ISubPicAllocator> pAllocator = new CMemSubPicAllocator(dst.type, size);
+
+ HRESULT hr;
+ if(!(m_pSubPicQueue = new CSubPicQueueNoThread(pAllocator, &hr)) || FAILED(hr)) {
+ m_pSubPicQueue = NULL;
+ return(false);
+ }
+ }
+
+ if(m_SubPicProviderId != (DWORD_PTR)(ISubPicProvider*)m_pSubPicProvider) {
+ m_pSubPicQueue->SetSubPicProvider(m_pSubPicProvider);
+ m_SubPicProviderId = (DWORD_PTR)(ISubPicProvider*)m_pSubPicProvider;
+ }
- HRESULT hr;
- if(!(m_pSubPicQueue = new CSubPicQueueNoThread(pAllocator, &hr)) || FAILED(hr))
- {
- m_pSubPicQueue = NULL;
+ CComPtr<ISubPic> pSubPic;
+ if(!m_pSubPicQueue->LookupSubPic(rt, pSubPic)) {
return(false);
}
- }
- if(m_SubPicProviderId != (DWORD_PTR)(ISubPicProvider*)m_pSubPicProvider)
- {
- m_pSubPicQueue->SetSubPicProvider(m_pSubPicProvider);
- m_SubPicProviderId = (DWORD_PTR)(ISubPicProvider*)m_pSubPicProvider;
- }
+ CRect r;
+ pSubPic->GetDirtyRect(r);
- CComPtr<ISubPic> pSubPic;
- if(!m_pSubPicQueue->LookupSubPic(rt, pSubPic))
- return(false);
+ if(dst.type == MSP_RGB32 || dst.type == MSP_RGB24 || dst.type == MSP_RGB16 || dst.type == MSP_RGB15) {
+ dst.h = -dst.h;
+ }
- CRect r;
- pSubPic->GetDirtyRect(r);
+ pSubPic->AlphaBlt(r, r, &dst);
- if(dst.type == MSP_RGB32 || dst.type == MSP_RGB24 || dst.type == MSP_RGB16 || dst.type == MSP_RGB15)
- dst.h = -dst.h;
+ return(true);
+ }
- pSubPic->AlphaBlt(r, r, &dst);
+ DWORD ThreadProc() {
+ SetThreadPriority(m_hThread, THREAD_PRIORITY_LOWEST);
- return(true);
- }
+ CAtlArray<HANDLE> handles;
+ handles.Add(GetRequestHandle());
- DWORD ThreadProc()
- {
- SetThreadPriority(m_hThread, THREAD_PRIORITY_LOWEST);
+ CString fn = GetFileName();
+ CFileStatus fs;
+ fs.m_mtime = 0;
+ CFileGetStatus(fn, fs);
- CAtlArray<HANDLE> handles;
- handles.Add(GetRequestHandle());
+ while(1) {
+ DWORD i = WaitForMultipleObjects(handles.GetCount(), handles.GetData(), FALSE, 1000);
- CString fn = GetFileName();
- CFileStatus fs;
- fs.m_mtime = 0;
- CFileGetStatus(fn, fs);
+ if(WAIT_OBJECT_0 == i) {
+ Reply(S_OK);
+ break;
+ } else if(WAIT_OBJECT_0 + 1 >= i && i <= WAIT_OBJECT_0 + handles.GetCount()) {
+ if(FindNextChangeNotification(handles[i - WAIT_OBJECT_0])) {
+ CFileStatus fs2;
+ fs2.m_mtime = 0;
+ CFileGetStatus(fn, fs2);
- while(1)
- {
- DWORD i = WaitForMultipleObjects(handles.GetCount(), handles.GetData(), FALSE, 1000);
+ if(fs.m_mtime < fs2.m_mtime) {
+ fs.m_mtime = fs2.m_mtime;
- if(WAIT_OBJECT_0 == i)
- {
- Reply(S_OK);
- break;
- }
- else if(WAIT_OBJECT_0 + 1 >= i && i <= WAIT_OBJECT_0 + handles.GetCount())
- {
- if(FindNextChangeNotification(handles[i - WAIT_OBJECT_0]))
- {
- CFileStatus fs2;
- fs2.m_mtime = 0;
- CFileGetStatus(fn, fs2);
-
- if(fs.m_mtime < fs2.m_mtime)
- {
- fs.m_mtime = fs2.m_mtime;
-
- if(CComQIPtr<ISubStream> pSubStream = m_pSubPicProvider)
- {
- CAutoLock cAutoLock(&m_csSubLock);
- pSubStream->Reload();
+ if(CComQIPtr<ISubStream> pSubStream = m_pSubPicProvider) {
+ CAutoLock cAutoLock(&m_csSubLock);
+ pSubStream->Reload();
+ }
}
}
- }
- }
- else if(WAIT_TIMEOUT == i)
- {
- CString fn2 = GetFileName();
-
- if(fn != fn2)
- {
- CPath p(fn2);
- p.RemoveFileSpec();
- HANDLE h = FindFirstChangeNotification(p, FALSE, FILE_NOTIFY_CHANGE_LAST_WRITE);
- if(h != INVALID_HANDLE_VALUE)
- {
- fn = fn2;
- handles.SetCount(1);
- handles.Add(h);
+ } else if(WAIT_TIMEOUT == i) {
+ CString fn2 = GetFileName();
+
+ if(fn != fn2) {
+ CPath p(fn2);
+ p.RemoveFileSpec();
+ HANDLE h = FindFirstChangeNotification(p, FALSE, FILE_NOTIFY_CHANGE_LAST_WRITE);
+ if(h != INVALID_HANDLE_VALUE) {
+ fn = fn2;
+ handles.SetCount(1);
+ handles.Add(h);
+ }
}
+ } else { // if(WAIT_ABANDONED_0 == i || WAIT_FAILED == i)
+ break;
}
}
- else // if(WAIT_ABANDONED_0 == i || WAIT_FAILED == i)
- {
- break;
- }
- }
- m_hThread = 0;
+ m_hThread = 0;
- for(ptrdiff_t i = 1; i < handles.GetCount(); i++)
- FindCloseChangeNotification(handles[i]);
-
- return 0;
- }
-};
+ for(ptrdiff_t i = 1; i < handles.GetCount(); i++) {
+ FindCloseChangeNotification(handles[i]);
+ }
-class CVobSubFilter : virtual public CFilter
-{
-public:
- CVobSubFilter(CString fn = _T(""))
- {
- if(!fn.IsEmpty()) Open(fn);
- }
+ return 0;
+ }
+ };
- bool Open(CString fn)
+ class CVobSubFilter : virtual public CFilter
{
- SetFileName(_T(""));
- m_pSubPicProvider = NULL;
-
- if(CVobSubFile* vsf = new CVobSubFile(&m_csSubLock))
- {
- m_pSubPicProvider = (ISubPicProvider*)vsf;
- if(vsf->Open(CString(fn))) SetFileName(fn);
- else m_pSubPicProvider = NULL;
+ public:
+ CVobSubFilter(CString fn = _T("")) {
+ if(!fn.IsEmpty()) {
+ Open(fn);
+ }
}
- return !!m_pSubPicProvider;
- }
-};
-
-class CTextSubFilter : virtual public CFilter
-{
- int m_CharSet;
+ bool Open(CString fn) {
+ SetFileName(_T(""));
+ m_pSubPicProvider = NULL;
-public:
- CTextSubFilter(CString fn = _T(""), int CharSet = DEFAULT_CHARSET, float fps = -1)
- : m_CharSet(CharSet)
- {
- m_fps = fps;
- if(!fn.IsEmpty()) Open(fn, CharSet);
- }
+ if(CVobSubFile* vsf = new CVobSubFile(&m_csSubLock)) {
+ m_pSubPicProvider = (ISubPicProvider*)vsf;
+ if(vsf->Open(CString(fn))) {
+ SetFileName(fn);
+ } else {
+ m_pSubPicProvider = NULL;
+ }
+ }
- int GetCharSet() {
- return(m_CharSet);
- }
+ return !!m_pSubPicProvider;
+ }
+ };
- bool Open(CString fn, int CharSet = DEFAULT_CHARSET)
+ class CTextSubFilter : virtual public CFilter
{
- SetFileName(_T(""));
- m_pSubPicProvider = NULL;
-
- if(!m_pSubPicProvider)
- {
- if(ssf::CRenderer* ssf = new ssf::CRenderer(&m_csSubLock))
- {
- m_pSubPicProvider = (ISubPicProvider*)ssf;
- if(ssf->Open(CString(fn))) SetFileName(fn);
- else m_pSubPicProvider = NULL;
+ int m_CharSet;
+
+ public:
+ CTextSubFilter(CString fn = _T(""), int CharSet = DEFAULT_CHARSET, float fps = -1)
+ : m_CharSet(CharSet) {
+ m_fps = fps;
+ if(!fn.IsEmpty()) {
+ Open(fn, CharSet);
}
}
- if(!m_pSubPicProvider)
- {
- if(CRenderedTextSubtitle* rts = new CRenderedTextSubtitle(&m_csSubLock))
- {
- m_pSubPicProvider = (ISubPicProvider*)rts;
- if(rts->Open(CString(fn), CharSet)) SetFileName(fn);
- else m_pSubPicProvider = NULL;
- }
+ int GetCharSet() {
+ return(m_CharSet);
}
- return !!m_pSubPicProvider;
- }
-};
-
-#ifndef WIN64
-//
-// old VirtualDub interface
-//
-
-namespace VirtualDub
-{
-//#include <VirtualDub\VirtualDub.h>
-//#include <vd2/OldFilterSDK/VirtualDub.h>
-#include <vd2/extras/FilterSDK/VirtualDub.h>
-
-class CVirtualDubFilter : virtual public CFilter
-{
-public:
- CVirtualDubFilter() {}
- virtual ~CVirtualDubFilter() {}
-
- virtual int RunProc(const FilterActivation* fa, const FilterFunctions* ff)
- {
- SubPicDesc dst;
- dst.type = MSP_RGB32;
- dst.w = fa->src.w;
- dst.h = fa->src.h;
- dst.bpp = 32;
- dst.pitch = fa->src.pitch;
- dst.bits = (LPVOID)fa->src.data;
-
- Render(dst, 10000i64*fa->pfsi->lSourceFrameMS, (float)1000 / fa->pfsi->lMicrosecsPerFrame);
-
- return 0;
- }
-
- virtual long ParamProc(FilterActivation* fa, const FilterFunctions* ff)
- {
- fa->dst.offset = fa->src.offset;
- fa->dst.modulo = fa->src.modulo;
- fa->dst.pitch = fa->src.pitch;
+ bool Open(CString fn, int CharSet = DEFAULT_CHARSET) {
+ SetFileName(_T(""));
+ m_pSubPicProvider = NULL;
+
+ if(!m_pSubPicProvider) {
+ if(ssf::CRenderer* ssf = new ssf::CRenderer(&m_csSubLock)) {
+ m_pSubPicProvider = (ISubPicProvider*)ssf;
+ if(ssf->Open(CString(fn))) {
+ SetFileName(fn);
+ } else {
+ m_pSubPicProvider = NULL;
+ }
+ }
+ }
- return 0;
- }
+ if(!m_pSubPicProvider) {
+ if(CRenderedTextSubtitle* rts = new CRenderedTextSubtitle(&m_csSubLock)) {
+ m_pSubPicProvider = (ISubPicProvider*)rts;
+ if(rts->Open(CString(fn), CharSet)) {
+ SetFileName(fn);
+ } else {
+ m_pSubPicProvider = NULL;
+ }
+ }
+ }
- virtual int ConfigProc(FilterActivation* fa, const FilterFunctions* ff, HWND hwnd) = 0;
- virtual void StringProc(const FilterActivation* fa, const FilterFunctions* ff, char* str) = 0;
- virtual bool FssProc(FilterActivation* fa, const FilterFunctions* ff, char* buf, int buflen) = 0;
-};
+ return !!m_pSubPicProvider;
+ }
+ };
-class CVobSubVirtualDubFilter : public CVobSubFilter, public CVirtualDubFilter
-{
-public:
- CVobSubVirtualDubFilter(CString fn = _T(""))
- : CVobSubFilter(fn) {}
+#ifndef WIN64
+ //
+ // old VirtualDub interface
+ //
- int ConfigProc(FilterActivation* fa, const FilterFunctions* ff, HWND hwnd)
+ namespace VirtualDub
{
- AFX_MANAGE_STATE(AfxGetStaticModuleState());
+ //#include <VirtualDub\VirtualDub.h>
+ //#include <vd2/OldFilterSDK/VirtualDub.h>
+#include <vd2/extras/FilterSDK/VirtualDub.h>
- CFileDialog fd(TRUE, NULL, GetFileName(), OFN_EXPLORER|OFN_ENABLESIZING|OFN_HIDEREADONLY,
- _T("VobSub files (*.idx;*.sub)|*.idx;*.sub||"), CWnd::FromHandle(hwnd), 0);
+ class CVirtualDubFilter : virtual public CFilter
+ {
+ public:
+ CVirtualDubFilter() {}
+ virtual ~CVirtualDubFilter() {}
+
+ virtual int RunProc(const FilterActivation* fa, const FilterFunctions* ff) {
+ SubPicDesc dst;
+ dst.type = MSP_RGB32;
+ dst.w = fa->src.w;
+ dst.h = fa->src.h;
+ dst.bpp = 32;
+ dst.pitch = fa->src.pitch;
+ dst.bits = (LPVOID)fa->src.data;
+
+ Render(dst, 10000i64*fa->pfsi->lSourceFrameMS, (float)1000 / fa->pfsi->lMicrosecsPerFrame);
+
+ return 0;
+ }
- if(fd.DoModal() != IDOK) return 1;
+ virtual long ParamProc(FilterActivation* fa, const FilterFunctions* ff) {
+ fa->dst.offset = fa->src.offset;
+ fa->dst.modulo = fa->src.modulo;
+ fa->dst.pitch = fa->src.pitch;
- return Open(fd.GetPathName()) ? 0 : 1;
- }
+ return 0;
+ }
- void StringProc(const FilterActivation* fa, const FilterFunctions* ff, char* str)
- {
- sprintf(str, " (%s)", !GetFileName().IsEmpty() ? CStringA(GetFileName()) : " (empty)");
- }
+ virtual int ConfigProc(FilterActivation* fa, const FilterFunctions* ff, HWND hwnd) = 0;
+ virtual void StringProc(const FilterActivation* fa, const FilterFunctions* ff, char* str) = 0;
+ virtual bool FssProc(FilterActivation* fa, const FilterFunctions* ff, char* buf, int buflen) = 0;
+ };
- bool FssProc(FilterActivation* fa, const FilterFunctions* ff, char* buf, int buflen)
- {
- CStringA fn(GetFileName());
- fn.Replace("\\", "\\\\");
- _snprintf(buf, buflen, "Config(\"%s\")", fn);
- return(true);
- }
-};
+ class CVobSubVirtualDubFilter : public CVobSubFilter, public CVirtualDubFilter
+ {
+ public:
+ CVobSubVirtualDubFilter(CString fn = _T(""))
+ : CVobSubFilter(fn) {}
-class CTextSubVirtualDubFilter : public CTextSubFilter, public CVirtualDubFilter
-{
-public:
- CTextSubVirtualDubFilter(CString fn = _T(""), int CharSet = DEFAULT_CHARSET)
- : CTextSubFilter(fn, CharSet) {}
+ int ConfigProc(FilterActivation* fa, const FilterFunctions* ff, HWND hwnd) {
+ AFX_MANAGE_STATE(AfxGetStaticModuleState());
- int ConfigProc(FilterActivation* fa, const FilterFunctions* ff, HWND hwnd)
- {
- AFX_MANAGE_STATE(AfxGetStaticModuleState());
+ CFileDialog fd(TRUE, NULL, GetFileName(), OFN_EXPLORER|OFN_ENABLESIZING|OFN_HIDEREADONLY,
+ _T("VobSub files (*.idx;*.sub)|*.idx;*.sub||"), CWnd::FromHandle(hwnd), 0);
- const TCHAR formats[] = _T("TextSub files (*.sub;*.srt;*.smi;*.ssa;*.ass;*.xss;*.psb;*.txt)|*.sub;*.srt;*.smi;*.ssa;*.ass;*.xss;*.psb;*.txt||");
- CFileDialog fd(TRUE, NULL, GetFileName(), OFN_EXPLORER|OFN_ENABLESIZING|OFN_HIDEREADONLY|OFN_ENABLETEMPLATE|OFN_ENABLEHOOK,
- formats, CWnd::FromHandle(hwnd), sizeof(OPENFILENAME));
- //OPENFILENAME_SIZE_VERSION_400 /*0* /);
- UINT_PTR CALLBACK OpenHookProc(HWND hDlg, UINT uiMsg, WPARAM wParam, LPARAM lParam);
+ if(fd.DoModal() != IDOK) {
+ return 1;
+ }
- fd.m_pOFN->hInstance = AfxGetResourceHandle();
- fd.m_pOFN->lpTemplateName = MAKEINTRESOURCE(IDD_TEXTSUBOPENTEMPLATE);
- fd.m_pOFN->lpfnHook = (LPOFNHOOKPROC)OpenHookProc;
- fd.m_pOFN->lCustData = (LPARAM)DEFAULT_CHARSET;
+ return Open(fd.GetPathName()) ? 0 : 1;
+ }
- if(fd.DoModal() != IDOK) return 1;
+ void StringProc(const FilterActivation* fa, const FilterFunctions* ff, char* str) {
+ sprintf(str, " (%s)", !GetFileName().IsEmpty() ? CStringA(GetFileName()) : " (empty)");
+ }
- return Open(fd.GetPathName(), fd.m_pOFN->lCustData) ? 0 : 1;
- }
+ bool FssProc(FilterActivation* fa, const FilterFunctions* ff, char* buf, int buflen) {
+ CStringA fn(GetFileName());
+ fn.Replace("\\", "\\\\");
+ _snprintf(buf, buflen, "Config(\"%s\")", fn);
+ return(true);
+ }
+ };
- void StringProc(const FilterActivation* fa, const FilterFunctions* ff, char* str)
- {
- if(!GetFileName().IsEmpty()) sprintf(str, " (%s, %d)", CStringA(GetFileName()), GetCharSet());
- else sprintf(str, " (empty)");
- }
+ class CTextSubVirtualDubFilter : public CTextSubFilter, public CVirtualDubFilter
+ {
+ public:
+ CTextSubVirtualDubFilter(CString fn = _T(""), int CharSet = DEFAULT_CHARSET)
+ : CTextSubFilter(fn, CharSet) {}
+
+ int ConfigProc(FilterActivation* fa, const FilterFunctions* ff, HWND hwnd) {
+ AFX_MANAGE_STATE(AfxGetStaticModuleState());
+
+ const TCHAR formats[] = _T("TextSub files (*.sub;*.srt;*.smi;*.ssa;*.ass;*.xss;*.psb;*.txt)|*.sub;*.srt;*.smi;*.ssa;*.ass;*.xss;*.psb;*.txt||");
+ CFileDialog fd(TRUE, NULL, GetFileName(), OFN_EXPLORER|OFN_ENABLESIZING|OFN_HIDEREADONLY|OFN_ENABLETEMPLATE|OFN_ENABLEHOOK,
+ formats, CWnd::FromHandle(hwnd), sizeof(OPENFILENAME));
+ //OPENFILENAME_SIZE_VERSION_400 /*0* /);
+ UINT_PTR CALLBACK OpenHookProc(HWND hDlg, UINT uiMsg, WPARAM wParam, LPARAM lParam);
+
+ fd.m_pOFN->hInstance = AfxGetResourceHandle();
+ fd.m_pOFN->lpTemplateName = MAKEINTRESOURCE(IDD_TEXTSUBOPENTEMPLATE);
+ fd.m_pOFN->lpfnHook = (LPOFNHOOKPROC)OpenHookProc;
+ fd.m_pOFN->lCustData = (LPARAM)DEFAULT_CHARSET;
+
+ if(fd.DoModal() != IDOK) {
+ return 1;
+ }
- bool FssProc(FilterActivation* fa, const FilterFunctions* ff, char* buf, int buflen)
- {
- CStringA fn(GetFileName());
- fn.Replace("\\", "\\\\");
- _snprintf(buf, buflen, "Config(\"%s\", %d)", fn, GetCharSet());
- return(true);
- }
-};
+ return Open(fd.GetPathName(), fd.m_pOFN->lCustData) ? 0 : 1;
+ }
-int vobsubInitProc(FilterActivation* fa, const FilterFunctions* ff)
-{
- *(CVirtualDubFilter**)fa->filter_data = new CVobSubVirtualDubFilter();
- return !(*(CVirtualDubFilter**)fa->filter_data);
-}
+ void StringProc(const FilterActivation* fa, const FilterFunctions* ff, char* str) {
+ if(!GetFileName().IsEmpty()) {
+ sprintf(str, " (%s, %d)", CStringA(GetFileName()), GetCharSet());
+ } else {
+ sprintf(str, " (empty)");
+ }
+ }
-int textsubInitProc(FilterActivation* fa, const FilterFunctions* ff)
-{
- *(CVirtualDubFilter**)fa->filter_data = new CTextSubVirtualDubFilter();
- return !(*(CVirtualDubFilter**)fa->filter_data);
-}
+ bool FssProc(FilterActivation* fa, const FilterFunctions* ff, char* buf, int buflen) {
+ CStringA fn(GetFileName());
+ fn.Replace("\\", "\\\\");
+ _snprintf(buf, buflen, "Config(\"%s\", %d)", fn, GetCharSet());
+ return(true);
+ }
+ };
-void baseDeinitProc(FilterActivation* fa, const FilterFunctions* ff)
-{
- CVirtualDubFilter* f = *(CVirtualDubFilter**)fa->filter_data;
- if(f) delete f, f = NULL;
-}
+ int vobsubInitProc(FilterActivation* fa, const FilterFunctions* ff)
+ {
+ *(CVirtualDubFilter**)fa->filter_data = new CVobSubVirtualDubFilter();
+ return !(*(CVirtualDubFilter**)fa->filter_data);
+ }
-int baseRunProc(const FilterActivation* fa, const FilterFunctions* ff)
-{
- CVirtualDubFilter* f = *(CVirtualDubFilter**)fa->filter_data;
- return f ? f->RunProc(fa, ff) : 1;
-}
+ int textsubInitProc(FilterActivation* fa, const FilterFunctions* ff)
+ {
+ *(CVirtualDubFilter**)fa->filter_data = new CTextSubVirtualDubFilter();
+ return !(*(CVirtualDubFilter**)fa->filter_data);
+ }
-long baseParamProc(FilterActivation* fa, const FilterFunctions* ff)
-{
- CVirtualDubFilter* f = *(CVirtualDubFilter**)fa->filter_data;
- return f ? f->ParamProc(fa, ff) : 1;
-}
+ void baseDeinitProc(FilterActivation* fa, const FilterFunctions* ff)
+ {
+ CVirtualDubFilter* f = *(CVirtualDubFilter**)fa->filter_data;
+ if(f) {
+ delete f, f = NULL;
+ }
+ }
-int baseConfigProc(FilterActivation* fa, const FilterFunctions* ff, HWND hwnd)
-{
- CVirtualDubFilter* f = *(CVirtualDubFilter**)fa->filter_data;
- return f ? f->ConfigProc(fa, ff, hwnd) : 1;
-}
+ int baseRunProc(const FilterActivation* fa, const FilterFunctions* ff)
+ {
+ CVirtualDubFilter* f = *(CVirtualDubFilter**)fa->filter_data;
+ return f ? f->RunProc(fa, ff) : 1;
+ }
-void baseStringProc(const FilterActivation* fa, const FilterFunctions* ff, char* str)
-{
- CVirtualDubFilter* f = *(CVirtualDubFilter**)fa->filter_data;
- if(f) f->StringProc(fa, ff, str);
-}
+ long baseParamProc(FilterActivation* fa, const FilterFunctions* ff)
+ {
+ CVirtualDubFilter* f = *(CVirtualDubFilter**)fa->filter_data;
+ return f ? f->ParamProc(fa, ff) : 1;
+ }
-bool baseFssProc(FilterActivation* fa, const FilterFunctions* ff, char* buf, int buflen)
-{
- CVirtualDubFilter* f = *(CVirtualDubFilter**)fa->filter_data;
- return f ? f->FssProc(fa, ff, buf, buflen) : false;
-}
+ int baseConfigProc(FilterActivation* fa, const FilterFunctions* ff, HWND hwnd)
+ {
+ CVirtualDubFilter* f = *(CVirtualDubFilter**)fa->filter_data;
+ return f ? f->ConfigProc(fa, ff, hwnd) : 1;
+ }
-void vobsubScriptConfig(IScriptInterpreter* isi, void* lpVoid, CScriptValue* argv, int argc)
-{
- FilterActivation* fa = (FilterActivation*)lpVoid;
- CVirtualDubFilter* f = *(CVirtualDubFilter**)fa->filter_data;
- if(f) delete f;
- f = new CVobSubVirtualDubFilter(CString(*argv[0].asString()));
- *(CVirtualDubFilter**)fa->filter_data = f;
-}
+ void baseStringProc(const FilterActivation* fa, const FilterFunctions* ff, char* str)
+ {
+ CVirtualDubFilter* f = *(CVirtualDubFilter**)fa->filter_data;
+ if(f) {
+ f->StringProc(fa, ff, str);
+ }
+ }
-void textsubScriptConfig(IScriptInterpreter* isi, void* lpVoid, CScriptValue* argv, int argc)
-{
- FilterActivation* fa = (FilterActivation*)lpVoid;
- CVirtualDubFilter* f = *(CVirtualDubFilter**)fa->filter_data;
- if(f) delete f;
- f = new CTextSubVirtualDubFilter(CString(*argv[0].asString()), argv[1].asInt());
- *(CVirtualDubFilter**)fa->filter_data = f;
-}
+ bool baseFssProc(FilterActivation* fa, const FilterFunctions* ff, char* buf, int buflen)
+ {
+ CVirtualDubFilter* f = *(CVirtualDubFilter**)fa->filter_data;
+ return f ? f->FssProc(fa, ff, buf, buflen) : false;
+ }
-ScriptFunctionDef vobsub_func_defs[]= {
- { (ScriptFunctionPtr)vobsubScriptConfig, "Config", "0s" },
- { NULL },
-};
+ void vobsubScriptConfig(IScriptInterpreter* isi, void* lpVoid, CScriptValue* argv, int argc)
+ {
+ FilterActivation* fa = (FilterActivation*)lpVoid;
+ CVirtualDubFilter* f = *(CVirtualDubFilter**)fa->filter_data;
+ if(f) {
+ delete f;
+ }
+ f = new CVobSubVirtualDubFilter(CString(*argv[0].asString()));
+ *(CVirtualDubFilter**)fa->filter_data = f;
+ }
-CScriptObject vobsub_obj= {
- NULL, vobsub_func_defs
-};
+ void textsubScriptConfig(IScriptInterpreter* isi, void* lpVoid, CScriptValue* argv, int argc)
+ {
+ FilterActivation* fa = (FilterActivation*)lpVoid;
+ CVirtualDubFilter* f = *(CVirtualDubFilter**)fa->filter_data;
+ if(f) {
+ delete f;
+ }
+ f = new CTextSubVirtualDubFilter(CString(*argv[0].asString()), argv[1].asInt());
+ *(CVirtualDubFilter**)fa->filter_data = f;
+ }
-struct FilterDefinition filterDef_vobsub =
-{
- NULL, NULL, NULL, // next, prev, module
- "VobSub", // name
- "Adds subtitles from a vob sequence.", // desc
- "Gabest", // maker
- NULL, // private_data
- sizeof(CVirtualDubFilter**), // inst_data_size
- vobsubInitProc, // initProc
- baseDeinitProc, // deinitProc
- baseRunProc, // runProc
- baseParamProc, // paramProc
- baseConfigProc, // configProc
- baseStringProc, // stringProc
- NULL, // startProc
- NULL, // endProc
- &vobsub_obj, // script_obj
- baseFssProc, // fssProc
-};
-
-ScriptFunctionDef textsub_func_defs[]= {
- { (ScriptFunctionPtr)textsubScriptConfig, "Config", "0si" },
- { NULL },
-};
-
-CScriptObject textsub_obj= {
- NULL, textsub_func_defs
-};
-
-struct FilterDefinition filterDef_textsub =
-{
- NULL, NULL, NULL, // next, prev, module
+ ScriptFunctionDef vobsub_func_defs[]= {
+ { (ScriptFunctionPtr)vobsubScriptConfig, "Config", "0s" },
+ { NULL },
+ };
+
+ CScriptObject vobsub_obj= {
+ NULL, vobsub_func_defs
+ };
+
+ struct FilterDefinition filterDef_vobsub = {
+ NULL, NULL, NULL, // next, prev, module
+ "VobSub", // name
+ "Adds subtitles from a vob sequence.", // desc
+ "Gabest", // maker
+ NULL, // private_data
+ sizeof(CVirtualDubFilter**), // inst_data_size
+ vobsubInitProc, // initProc
+ baseDeinitProc, // deinitProc
+ baseRunProc, // runProc
+ baseParamProc, // paramProc
+ baseConfigProc, // configProc
+ baseStringProc, // stringProc
+ NULL, // startProc
+ NULL, // endProc
+ &vobsub_obj, // script_obj
+ baseFssProc, // fssProc
+ };
+
+ ScriptFunctionDef textsub_func_defs[]= {
+ { (ScriptFunctionPtr)textsubScriptConfig, "Config", "0si" },
+ { NULL },
+ };
+
+ CScriptObject textsub_obj= {
+ NULL, textsub_func_defs
+ };
+
+ struct FilterDefinition filterDef_textsub = {
+ NULL, NULL, NULL, // next, prev, module
#ifdef _VSMOD
- "TextSubMod", // name
+ "TextSubMod", // name
#else
- "TextSub", // name
+ "TextSub", // name
#endif
- "Adds subtitles from srt, sub, psb, smi, ssa, ass file formats.", // desc
- "Gabest", // maker
- NULL, // private_data
- sizeof(CVirtualDubFilter**), // inst_data_size
- textsubInitProc, // initProc
- baseDeinitProc, // deinitProc
- baseRunProc, // runProc
- baseParamProc, // paramProc
- baseConfigProc, // configProc
- baseStringProc, // stringProc
- NULL, // startProc
- NULL, // endProc
- &textsub_obj, // script_obj
- baseFssProc, // fssProc
-};
-
-static FilterDefinition* fd_vobsub;
-static FilterDefinition* fd_textsub;
-
-extern "C" __declspec(dllexport) int __cdecl VirtualdubFilterModuleInit2(FilterModule *fm, const FilterFunctions *ff, int& vdfd_ver, int& vdfd_compat)
-{
- fd_vobsub = ff->addFilter(fm, &filterDef_vobsub, sizeof(FilterDefinition));
- if(!fd_vobsub)
- return 1;
- fd_textsub = ff->addFilter(fm, &filterDef_textsub, sizeof(FilterDefinition));
- if(!fd_textsub)
- return 1;
+ "Adds subtitles from srt, sub, psb, smi, ssa, ass file formats.", // desc
+ "Gabest", // maker
+ NULL, // private_data
+ sizeof(CVirtualDubFilter**), // inst_data_size
+ textsubInitProc, // initProc
+ baseDeinitProc, // deinitProc
+ baseRunProc, // runProc
+ baseParamProc, // paramProc
+ baseConfigProc, // configProc
+ baseStringProc, // stringProc
+ NULL, // startProc
+ NULL, // endProc
+ &textsub_obj, // script_obj
+ baseFssProc, // fssProc
+ };
+
+ static FilterDefinition* fd_vobsub;
+ static FilterDefinition* fd_textsub;
+
+ extern "C" __declspec(dllexport) int __cdecl VirtualdubFilterModuleInit2(FilterModule *fm, const FilterFunctions *ff, int& vdfd_ver, int& vdfd_compat)
+ {
+ fd_vobsub = ff->addFilter(fm, &filterDef_vobsub, sizeof(FilterDefinition));
+ if(!fd_vobsub) {
+ return 1;
+ }
+ fd_textsub = ff->addFilter(fm, &filterDef_textsub, sizeof(FilterDefinition));
+ if(!fd_textsub) {
+ return 1;
+ }
- vdfd_ver = VIRTUALDUB_FILTERDEF_VERSION;
- vdfd_compat = VIRTUALDUB_FILTERDEF_COMPATIBLE;
+ vdfd_ver = VIRTUALDUB_FILTERDEF_VERSION;
+ vdfd_compat = VIRTUALDUB_FILTERDEF_COMPATIBLE;
- return 0;
-}
+ return 0;
+ }
-extern "C" __declspec(dllexport) void __cdecl VirtualdubFilterModuleDeinit(FilterModule *fm, const FilterFunctions *ff)
-{
- ff->removeFilter(fd_textsub);
- ff->removeFilter(fd_vobsub);
-}
-}/**/
+ extern "C" __declspec(dllexport) void __cdecl VirtualdubFilterModuleDeinit(FilterModule *fm, const FilterFunctions *ff)
+ {
+ ff->removeFilter(fd_textsub);
+ ff->removeFilter(fd_vobsub);
+ }
+ }/**/
#else
-//
-// VirtualDub new plugin interface sdk 1.1
-//
-namespace VirtualDubNew
-{
+ //
+ // VirtualDub new plugin interface sdk 1.1
+ //
+ namespace VirtualDubNew
+ {
#include <vd2/plugin/vdplugin.h>
#include <vd2/plugin/vdvideofilt.h>
-class CVirtualDubFilter : virtual public CFilter
-{
-public:
- CVirtualDubFilter() {}
- virtual ~CVirtualDubFilter() {}
-
- virtual int RunProc(const VDXFilterActivation* fa, const VDXFilterFunctions* ff)
- {
- SubPicDesc dst;
- dst.type = MSP_RGB32;
- dst.w = fa->src.w;
- dst.h = fa->src.h;
- dst.bpp = 32;
- dst.pitch = fa->src.pitch;
- dst.bits = (LPVOID)fa->src.data;
-
- Render(dst, 10000i64*fa->pfsi->lSourceFrameMS, (float)1000 / fa->pfsi->lMicrosecsPerFrame);
-
- return 0;
- }
+ class CVirtualDubFilter : virtual public CFilter
+ {
+ public:
+ CVirtualDubFilter() {}
+ virtual ~CVirtualDubFilter() {}
+
+ virtual int RunProc(const VDXFilterActivation* fa, const VDXFilterFunctions* ff) {
+ SubPicDesc dst;
+ dst.type = MSP_RGB32;
+ dst.w = fa->src.w;
+ dst.h = fa->src.h;
+ dst.bpp = 32;
+ dst.pitch = fa->src.pitch;
+ dst.bits = (LPVOID)fa->src.data;
+
+ Render(dst, 10000i64*fa->pfsi->lSourceFrameMS, (float)1000 / fa->pfsi->lMicrosecsPerFrame);
+
+ return 0;
+ }
- virtual long ParamProc(VDXFilterActivation* fa, const VDXFilterFunctions* ff)
- {
- fa->dst.offset = fa->src.offset;
- fa->dst.modulo = fa->src.modulo;
- fa->dst.pitch = fa->src.pitch;
+ virtual long ParamProc(VDXFilterActivation* fa, const VDXFilterFunctions* ff) {
+ fa->dst.offset = fa->src.offset;
+ fa->dst.modulo = fa->src.modulo;
+ fa->dst.pitch = fa->src.pitch;
- return 0;
- }
+ return 0;
+ }
- virtual int ConfigProc(VDXFilterActivation* fa, const VDXFilterFunctions* ff, VDXHWND hwnd) = 0;
- virtual void StringProc(const VDXFilterActivation* fa, const VDXFilterFunctions* ff, char* str) = 0;
- virtual bool FssProc(VDXFilterActivation* fa, const VDXFilterFunctions* ff, char* buf, int buflen) = 0;
-};
+ virtual int ConfigProc(VDXFilterActivation* fa, const VDXFilterFunctions* ff, VDXHWND hwnd) = 0;
+ virtual void StringProc(const VDXFilterActivation* fa, const VDXFilterFunctions* ff, char* str) = 0;
+ virtual bool FssProc(VDXFilterActivation* fa, const VDXFilterFunctions* ff, char* buf, int buflen) = 0;
+ };
-class CVobSubVirtualDubFilter : public CVobSubFilter, public CVirtualDubFilter
-{
-public:
- CVobSubVirtualDubFilter(CString fn = _T(""))
- : CVobSubFilter(fn) {}
+ class CVobSubVirtualDubFilter : public CVobSubFilter, public CVirtualDubFilter
+ {
+ public:
+ CVobSubVirtualDubFilter(CString fn = _T(""))
+ : CVobSubFilter(fn) {}
- int ConfigProc(VDXFilterActivation* fa, const VDXFilterFunctions* ff, VDXHWND hwnd)
- {
- AFX_MANAGE_STATE(AfxGetStaticModuleState());
+ int ConfigProc(VDXFilterActivation* fa, const VDXFilterFunctions* ff, VDXHWND hwnd) {
+ AFX_MANAGE_STATE(AfxGetStaticModuleState());
- CFileDialog fd(TRUE, NULL, GetFileName(), OFN_EXPLORER|OFN_ENABLESIZING|OFN_HIDEREADONLY,
- _T("VobSub files (*.idx;*.sub)|*.idx;*.sub||"), CWnd::FromHandle((HWND)hwnd), 0);
+ CFileDialog fd(TRUE, NULL, GetFileName(), OFN_EXPLORER|OFN_ENABLESIZING|OFN_HIDEREADONLY,
+ _T("VobSub files (*.idx;*.sub)|*.idx;*.sub||"), CWnd::FromHandle((HWND)hwnd), 0);
- if(fd.DoModal() != IDOK) return 1;
+ if(fd.DoModal() != IDOK) {
+ return 1;
+ }
- return Open(fd.GetPathName()) ? 0 : 1;
- }
+ return Open(fd.GetPathName()) ? 0 : 1;
+ }
- void StringProc(const VDXFilterActivation* fa, const VDXFilterFunctions* ff, char* str)
- {
- sprintf(str, " (%s)", !GetFileName().IsEmpty() ? CStringA(GetFileName()) : " (empty)");
- }
+ void StringProc(const VDXFilterActivation* fa, const VDXFilterFunctions* ff, char* str) {
+ sprintf(str, " (%s)", !GetFileName().IsEmpty() ? CStringA(GetFileName()) : " (empty)");
+ }
- bool FssProc(VDXFilterActivation* fa, const VDXFilterFunctions* ff, char* buf, int buflen)
- {
- CStringA fn(GetFileName());
- fn.Replace("\\", "\\\\");
- _snprintf(buf, buflen, "Config(\"%s\")", fn);
- return(true);
- }
-};
+ bool FssProc(VDXFilterActivation* fa, const VDXFilterFunctions* ff, char* buf, int buflen) {
+ CStringA fn(GetFileName());
+ fn.Replace("\\", "\\\\");
+ _snprintf(buf, buflen, "Config(\"%s\")", fn);
+ return(true);
+ }
+ };
-class CTextSubVirtualDubFilter : public CTextSubFilter, public CVirtualDubFilter
-{
-public:
- CTextSubVirtualDubFilter(CString fn = _T(""), int CharSet = DEFAULT_CHARSET)
- : CTextSubFilter(fn, CharSet) {}
+ class CTextSubVirtualDubFilter : public CTextSubFilter, public CVirtualDubFilter
+ {
+ public:
+ CTextSubVirtualDubFilter(CString fn = _T(""), int CharSet = DEFAULT_CHARSET)
+ : CTextSubFilter(fn, CharSet) {}
- int ConfigProc(VDXFilterActivation* fa, const VDXFilterFunctions* ff, VDXHWND hwnd)
- {
- AFX_MANAGE_STATE(AfxGetStaticModuleState());
+ int ConfigProc(VDXFilterActivation* fa, const VDXFilterFunctions* ff, VDXHWND hwnd) {
+ AFX_MANAGE_STATE(AfxGetStaticModuleState());
- /* off encoding changing */
+ /* off encoding changing */
#ifndef _DEBUG
- const TCHAR formats[] = _T("TextSub files (*.sub;*.srt;*.smi;*.ssa;*.ass;*.xss;*.psb;*.txt)|*.sub;*.srt;*.smi;*.ssa;*.ass;*.xss;*.psb;*.txt||");
- CFileDialog fd(TRUE, NULL, GetFileName(), OFN_EXPLORER|OFN_ENABLESIZING|OFN_HIDEREADONLY|OFN_ENABLETEMPLATE|OFN_ENABLEHOOK,
- formats, CWnd::FromHandle((HWND)hwnd), sizeof(OPENFILENAME));
- //OPENFILENAME_SIZE_VERSION_400 /*0*/);
- UINT_PTR CALLBACK OpenHookProc(HWND hDlg, UINT uiMsg, WPARAM wParam, LPARAM lParam);
-
- fd.m_pOFN->hInstance = AfxGetResourceHandle();
- fd.m_pOFN->lpTemplateName = MAKEINTRESOURCE(IDD_TEXTSUBOPENTEMPLATE);
- fd.m_pOFN->lpfnHook = (LPOFNHOOKPROC)OpenHookProc;
- fd.m_pOFN->lCustData = (LPARAM)DEFAULT_CHARSET;
+ const TCHAR formats[] = _T("TextSub files (*.sub;*.srt;*.smi;*.ssa;*.ass;*.xss;*.psb;*.txt)|*.sub;*.srt;*.smi;*.ssa;*.ass;*.xss;*.psb;*.txt||");
+ CFileDialog fd(TRUE, NULL, GetFileName(), OFN_EXPLORER|OFN_ENABLESIZING|OFN_HIDEREADONLY|OFN_ENABLETEMPLATE|OFN_ENABLEHOOK,
+ formats, CWnd::FromHandle((HWND)hwnd), sizeof(OPENFILENAME));
+ //OPENFILENAME_SIZE_VERSION_400 /*0*/);
+ UINT_PTR CALLBACK OpenHookProc(HWND hDlg, UINT uiMsg, WPARAM wParam, LPARAM lParam);
+
+ fd.m_pOFN->hInstance = AfxGetResourceHandle();
+ fd.m_pOFN->lpTemplateName = MAKEINTRESOURCE(IDD_TEXTSUBOPENTEMPLATE);
+ fd.m_pOFN->lpfnHook = (LPOFNHOOKPROC)OpenHookProc;
+ fd.m_pOFN->lCustData = (LPARAM)DEFAULT_CHARSET;
#else
-const TCHAR formats[] = _T("TextSub files (*.sub;*.srt;*.smi;*.ssa;*.ass;*.xss;*.psb;*.txt)|*.sub;*.srt;*.smi;*.ssa;*.ass;*.xss;*.psb;*.txt||");
-CFileDialog fd(TRUE, NULL, GetFileName(), OFN_ENABLESIZING|OFN_HIDEREADONLY,
- formats, CWnd::FromHandle((HWND)hwnd), sizeof(OPENFILENAME));
+ const TCHAR formats[] = _T("TextSub files (*.sub;*.srt;*.smi;*.ssa;*.ass;*.xss;*.psb;*.txt)|*.sub;*.srt;*.smi;*.ssa;*.ass;*.xss;*.psb;*.txt||");
+ CFileDialog fd(TRUE, NULL, GetFileName(), OFN_ENABLESIZING|OFN_HIDEREADONLY,
+ formats, CWnd::FromHandle((HWND)hwnd), sizeof(OPENFILENAME));
#endif
- if(fd.DoModal() != IDOK) return 1;
-
- return Open(fd.GetPathName(), fd.m_pOFN->lCustData) ? 0 : 1;
- }
-
- void StringProc(const VDXFilterActivation* fa, const VDXFilterFunctions* ff, char* str)
- {
- if(!GetFileName().IsEmpty()) sprintf(str, " (%s, %d)", CStringA(GetFileName()), GetCharSet());
- else sprintf(str, " (empty)");
- }
+ if(fd.DoModal() != IDOK) {
+ return 1;
+ }
- bool FssProc(VDXFilterActivation* fa, const VDXFilterFunctions* ff, char* buf, int buflen)
- {
- CStringA fn(GetFileName());
- fn.Replace("\\", "\\\\");
- _snprintf(buf, buflen, "Config(\"%s\", %d)", fn, GetCharSet());
- return(true);
- }
-};
+ return Open(fd.GetPathName(), fd.m_pOFN->lCustData) ? 0 : 1;
+ }
-int vobsubInitProc(VDXFilterActivation* fa, const VDXFilterFunctions* ff)
-{
- return !(*(CVirtualDubFilter**)fa->filter_data = new CVobSubVirtualDubFilter());
-}
+ void StringProc(const VDXFilterActivation* fa, const VDXFilterFunctions* ff, char* str) {
+ if(!GetFileName().IsEmpty()) {
+ sprintf(str, " (%s, %d)", CStringA(GetFileName()), GetCharSet());
+ } else {
+ sprintf(str, " (empty)");
+ }
+ }
-int textsubInitProc(VDXFilterActivation* fa, const VDXFilterFunctions* ff)
-{
- return !(*(CVirtualDubFilter**)fa->filter_data = new CTextSubVirtualDubFilter());
-}
+ bool FssProc(VDXFilterActivation* fa, const VDXFilterFunctions* ff, char* buf, int buflen) {
+ CStringA fn(GetFileName());
+ fn.Replace("\\", "\\\\");
+ _snprintf(buf, buflen, "Config(\"%s\", %d)", fn, GetCharSet());
+ return(true);
+ }
+ };
-void baseDeinitProc(VDXFilterActivation* fa, const VDXFilterFunctions* ff)
-{
- CVirtualDubFilter* f = *(CVirtualDubFilter**)fa->filter_data;
- if(f) delete f, f = NULL;
-}
+ int vobsubInitProc(VDXFilterActivation* fa, const VDXFilterFunctions* ff)
+ {
+ return !(*(CVirtualDubFilter**)fa->filter_data = new CVobSubVirtualDubFilter());
+ }
-int baseRunProc(const VDXFilterActivation* fa, const VDXFilterFunctions* ff)
-{
- CVirtualDubFilter* f = *(CVirtualDubFilter**)fa->filter_data;
- return f ? f->RunProc(fa, ff) : 1;
-}
+ int textsubInitProc(VDXFilterActivation* fa, const VDXFilterFunctions* ff)
+ {
+ return !(*(CVirtualDubFilter**)fa->filter_data = new CTextSubVirtualDubFilter());
+ }
-long baseParamProc(VDXFilterActivation* fa, const VDXFilterFunctions* ff)
-{
- CVirtualDubFilter* f = *(CVirtualDubFilter**)fa->filter_data;
- return f ? f->ParamProc(fa, ff) : 1;
-}
+ void baseDeinitProc(VDXFilterActivation* fa, const VDXFilterFunctions* ff)
+ {
+ CVirtualDubFilter* f = *(CVirtualDubFilter**)fa->filter_data;
+ if(f) {
+ delete f, f = NULL;
+ }
+ }
-int baseConfigProc(VDXFilterActivation* fa, const VDXFilterFunctions* ff, VDXHWND hwnd)
-{
- CVirtualDubFilter* f = *(CVirtualDubFilter**)fa->filter_data;
- return f ? f->ConfigProc(fa, ff, hwnd) : 1;
-}
+ int baseRunProc(const VDXFilterActivation* fa, const VDXFilterFunctions* ff)
+ {
+ CVirtualDubFilter* f = *(CVirtualDubFilter**)fa->filter_data;
+ return f ? f->RunProc(fa, ff) : 1;
+ }
-void baseStringProc(const VDXFilterActivation* fa, const VDXFilterFunctions* ff, char* str)
-{
- CVirtualDubFilter* f = *(CVirtualDubFilter**)fa->filter_data;
- if(f) f->StringProc(fa, ff, str);
-}
+ long baseParamProc(VDXFilterActivation* fa, const VDXFilterFunctions* ff)
+ {
+ CVirtualDubFilter* f = *(CVirtualDubFilter**)fa->filter_data;
+ return f ? f->ParamProc(fa, ff) : 1;
+ }
-bool baseFssProc(VDXFilterActivation* fa, const VDXFilterFunctions* ff, char* buf, int buflen)
-{
- CVirtualDubFilter* f = *(CVirtualDubFilter**)fa->filter_data;
- return f ? f->FssProc(fa, ff, buf, buflen) : false;
-}
+ int baseConfigProc(VDXFilterActivation* fa, const VDXFilterFunctions* ff, VDXHWND hwnd)
+ {
+ CVirtualDubFilter* f = *(CVirtualDubFilter**)fa->filter_data;
+ return f ? f->ConfigProc(fa, ff, hwnd) : 1;
+ }
-void vobsubScriptConfig(IVDXScriptInterpreter* isi, void* lpVoid, VDXScriptValue* argv, int argc)
-{
- VDXFilterActivation* fa = (VDXFilterActivation*)lpVoid;
- CVirtualDubFilter* f = *(CVirtualDubFilter**)fa->filter_data;
- if(f) delete f;
- f = new CVobSubVirtualDubFilter(CString(*argv[0].asString()));
- *(CVirtualDubFilter**)fa->filter_data = f;
-}
+ void baseStringProc(const VDXFilterActivation* fa, const VDXFilterFunctions* ff, char* str)
+ {
+ CVirtualDubFilter* f = *(CVirtualDubFilter**)fa->filter_data;
+ if(f) {
+ f->StringProc(fa, ff, str);
+ }
+ }
-void textsubScriptConfig(IVDXScriptInterpreter* isi, void* lpVoid, VDXScriptValue* argv, int argc)
-{
- VDXFilterActivation* fa = (VDXFilterActivation*)lpVoid;
- CVirtualDubFilter* f = *(CVirtualDubFilter**)fa->filter_data;
- if(f) delete f;
- f = new CTextSubVirtualDubFilter(CString(*argv[0].asString()), argv[1].asInt());
- *(CVirtualDubFilter**)fa->filter_data = f;
-}
+ bool baseFssProc(VDXFilterActivation* fa, const VDXFilterFunctions* ff, char* buf, int buflen)
+ {
+ CVirtualDubFilter* f = *(CVirtualDubFilter**)fa->filter_data;
+ return f ? f->FssProc(fa, ff, buf, buflen) : false;
+ }
-VDXScriptFunctionDef vobsub_func_defs[]= {
- { (VDXScriptFunctionPtr)vobsubScriptConfig, "Config", "0s" },
- { NULL },
-};
+ void vobsubScriptConfig(IVDXScriptInterpreter* isi, void* lpVoid, VDXScriptValue* argv, int argc)
+ {
+ VDXFilterActivation* fa = (VDXFilterActivation*)lpVoid;
+ CVirtualDubFilter* f = *(CVirtualDubFilter**)fa->filter_data;
+ if(f) {
+ delete f;
+ }
+ f = new CVobSubVirtualDubFilter(CString(*argv[0].asString()));
+ *(CVirtualDubFilter**)fa->filter_data = f;
+ }
-VDXScriptObject vobsub_obj= {
- NULL, vobsub_func_defs
-};
+ void textsubScriptConfig(IVDXScriptInterpreter* isi, void* lpVoid, VDXScriptValue* argv, int argc)
+ {
+ VDXFilterActivation* fa = (VDXFilterActivation*)lpVoid;
+ CVirtualDubFilter* f = *(CVirtualDubFilter**)fa->filter_data;
+ if(f) {
+ delete f;
+ }
+ f = new CTextSubVirtualDubFilter(CString(*argv[0].asString()), argv[1].asInt());
+ *(CVirtualDubFilter**)fa->filter_data = f;
+ }
-struct VDXFilterDefinition filterDef_vobsub =
-{
- NULL, NULL, NULL, // next, prev, module
- "VobSub", // name
- "Adds subtitles from a vob sequence.", // desc
- "Gabest", // maker
- NULL, // private_data
- sizeof(CVirtualDubFilter**), // inst_data_size
- vobsubInitProc, // initProc
- baseDeinitProc, // deinitProc
- baseRunProc, // runProc
- baseParamProc, // paramProc
- baseConfigProc, // configProc
- baseStringProc, // stringProc
- NULL, // startProc
- NULL, // endProc
- &vobsub_obj, // script_obj
- baseFssProc, // fssProc
-};
-
-VDXScriptFunctionDef textsub_func_defs[]= {
- { (VDXScriptFunctionPtr)textsubScriptConfig, "Config", "0si" },
- { NULL },
-};
-
-VDXScriptObject textsub_obj= {
- NULL, textsub_func_defs
-};
-
-struct VDXFilterDefinition filterDef_textsub =
-{
- NULL, NULL, NULL, // next, prev, module
+ VDXScriptFunctionDef vobsub_func_defs[]= {
+ { (VDXScriptFunctionPtr)vobsubScriptConfig, "Config", "0s" },
+ { NULL },
+ };
+
+ VDXScriptObject vobsub_obj= {
+ NULL, vobsub_func_defs
+ };
+
+ struct VDXFilterDefinition filterDef_vobsub = {
+ NULL, NULL, NULL, // next, prev, module
+ "VobSub", // name
+ "Adds subtitles from a vob sequence.", // desc
+ "Gabest", // maker
+ NULL, // private_data
+ sizeof(CVirtualDubFilter**), // inst_data_size
+ vobsubInitProc, // initProc
+ baseDeinitProc, // deinitProc
+ baseRunProc, // runProc
+ baseParamProc, // paramProc
+ baseConfigProc, // configProc
+ baseStringProc, // stringProc
+ NULL, // startProc
+ NULL, // endProc
+ &vobsub_obj, // script_obj
+ baseFssProc, // fssProc
+ };
+
+ VDXScriptFunctionDef textsub_func_defs[]= {
+ { (VDXScriptFunctionPtr)textsubScriptConfig, "Config", "0si" },
+ { NULL },
+ };
+
+ VDXScriptObject textsub_obj= {
+ NULL, textsub_func_defs
+ };
+
+ struct VDXFilterDefinition filterDef_textsub = {
+ NULL, NULL, NULL, // next, prev, module
#ifdef _VSMOD
- "TextSubMod", // name
+ "TextSubMod", // name
#else
-"TextSub", // name
+ "TextSub", // name
#endif
- "Adds subtitles from srt, sub, psb, smi, ssa, ass file formats.", // desc
- "Gabest", // maker
- NULL, // private_data
- sizeof(CVirtualDubFilter**), // inst_data_size
- textsubInitProc, // initProc
- baseDeinitProc, // deinitProc
- baseRunProc, // runProc
- baseParamProc, // paramProc
- baseConfigProc, // configProc
- baseStringProc, // stringProc
- NULL, // startProc
- NULL, // endProc
- &textsub_obj, // script_obj
- baseFssProc, // fssProc
-};
-
-static VDXFilterDefinition* fd_vobsub;
-static VDXFilterDefinition* fd_textsub;
-
-extern "C" __declspec(dllexport) int __cdecl VirtualdubFilterModuleInit2(VDXFilterModule *fm, const VDXFilterFunctions *ff, int& vdfd_ver, int& vdfd_compat)
-{
- if(!(fd_vobsub = ff->addFilter(fm, &filterDef_vobsub, sizeof(VDXFilterDefinition)))
- || !(fd_textsub = ff->addFilter(fm, &filterDef_textsub, sizeof(VDXFilterDefinition))))
- return 1;
+ "Adds subtitles from srt, sub, psb, smi, ssa, ass file formats.", // desc
+ "Gabest", // maker
+ NULL, // private_data
+ sizeof(CVirtualDubFilter**), // inst_data_size
+ textsubInitProc, // initProc
+ baseDeinitProc, // deinitProc
+ baseRunProc, // runProc
+ baseParamProc, // paramProc
+ baseConfigProc, // configProc
+ baseStringProc, // stringProc
+ NULL, // startProc
+ NULL, // endProc
+ &textsub_obj, // script_obj
+ baseFssProc, // fssProc
+ };
+
+ static VDXFilterDefinition* fd_vobsub;
+ static VDXFilterDefinition* fd_textsub;
+
+ extern "C" __declspec(dllexport) int __cdecl VirtualdubFilterModuleInit2(VDXFilterModule *fm, const VDXFilterFunctions *ff, int& vdfd_ver, int& vdfd_compat)
+ {
+ if(!(fd_vobsub = ff->addFilter(fm, &filterDef_vobsub, sizeof(VDXFilterDefinition)))
+ || !(fd_textsub = ff->addFilter(fm, &filterDef_textsub, sizeof(VDXFilterDefinition)))) {
+ return 1;
+ }
- vdfd_ver = VIRTUALDUB_FILTERDEF_VERSION;
- vdfd_compat = VIRTUALDUB_FILTERDEF_COMPATIBLE;
+ vdfd_ver = VIRTUALDUB_FILTERDEF_VERSION;
+ vdfd_compat = VIRTUALDUB_FILTERDEF_COMPATIBLE;
- return 0;
-}
+ return 0;
+ }
-extern "C" __declspec(dllexport) void __cdecl VirtualdubFilterModuleDeinit(VDXFilterModule *fm, const VDXFilterFunctions *ff)
-{
- ff->removeFilter(fd_textsub);
- ff->removeFilter(fd_vobsub);
-}
-}
+ extern "C" __declspec(dllexport) void __cdecl VirtualdubFilterModuleDeinit(VDXFilterModule *fm, const VDXFilterFunctions *ff)
+ {
+ ff->removeFilter(fd_textsub);
+ ff->removeFilter(fd_vobsub);
+ }
+ }
#endif
-//
-// Avisynth interface
-//
+ //
+ // Avisynth interface
+ //
-namespace AviSynth1
-{
+ namespace AviSynth1
+ {
#include <avisynth\avisynth1.h>
-class CAvisynthFilter : public GenericVideoFilter, virtual public CFilter
-{
-public:
- CAvisynthFilter(PClip c, IScriptEnvironment* env) : GenericVideoFilter(c) {}
+ class CAvisynthFilter : public GenericVideoFilter, virtual public CFilter
+ {
+ public:
+ CAvisynthFilter(PClip c, IScriptEnvironment* env) : GenericVideoFilter(c) {}
- PVideoFrame __stdcall GetFrame(int n, IScriptEnvironment* env)
- {
- PVideoFrame frame = child->GetFrame(n, env);
+ PVideoFrame __stdcall GetFrame(int n, IScriptEnvironment* env) {
+ PVideoFrame frame = child->GetFrame(n, env);
- env->MakeWritable(&frame);
+ env->MakeWritable(&frame);
- SubPicDesc dst;
- dst.w = vi.width;
- dst.h = vi.height;
- dst.pitch = frame->GetPitch();
- dst.bits = (void**)frame->GetWritePtr();
- dst.bpp = vi.BitsPerPixel();
- dst.type =
- vi.IsRGB32() ? ( env->GetVar("RGBA").AsBool() ? MSP_RGBA :MSP_RGB32) :
- vi.IsRGB24() ? MSP_RGB24 :
- vi.IsYUY2() ? MSP_YUY2 :
- -1;
+ SubPicDesc dst;
+ dst.w = vi.width;
+ dst.h = vi.height;
+ dst.pitch = frame->GetPitch();
+ dst.bits = (void**)frame->GetWritePtr();
+ dst.bpp = vi.BitsPerPixel();
+ dst.type =
+ vi.IsRGB32() ? ( env->GetVar("RGBA").AsBool() ? MSP_RGBA :MSP_RGB32) :
+ vi.IsRGB24() ? MSP_RGB24 :
+ vi.IsYUY2() ? MSP_YUY2 :
+ -1;
- float fps = m_fps > 0 ? m_fps : (float)vi.fps_numerator / vi.fps_denominator;
+ float fps = m_fps > 0 ? m_fps : (float)vi.fps_numerator / vi.fps_denominator;
- Render(dst, (REFERENCE_TIME)(10000000i64 * n / fps), fps);
+ Render(dst, (REFERENCE_TIME)(10000000i64 * n / fps), fps);
- return(frame);
- }
-};
+ return(frame);
+ }
+ };
-class CVobSubAvisynthFilter : public CVobSubFilter, public CAvisynthFilter
-{
-public:
- CVobSubAvisynthFilter(PClip c, const char* fn, IScriptEnvironment* env)
- : CVobSubFilter(CString(fn))
- , CAvisynthFilter(c, env)
- {
- if(!m_pSubPicProvider)
- env->ThrowError("VobSub: Can't open \"%s\"", fn);
- }
-};
+ class CVobSubAvisynthFilter : public CVobSubFilter, public CAvisynthFilter
+ {
+ public:
+ CVobSubAvisynthFilter(PClip c, const char* fn, IScriptEnvironment* env)
+ : CVobSubFilter(CString(fn))
+ , CAvisynthFilter(c, env) {
+ if(!m_pSubPicProvider) {
+ env->ThrowError("VobSub: Can't open \"%s\"", fn);
+ }
+ }
+ };
-AVSValue __cdecl VobSubCreateS(AVSValue args, void* user_data, IScriptEnvironment* env)
-{
- return(new CVobSubAvisynthFilter(args[0].AsClip(), args[1].AsString(), env));
-}
+ AVSValue __cdecl VobSubCreateS(AVSValue args, void* user_data, IScriptEnvironment* env)
+ {
+ return(new CVobSubAvisynthFilter(args[0].AsClip(), args[1].AsString(), env));
+ }
-class CTextSubAvisynthFilter : public CTextSubFilter, public CAvisynthFilter
-{
-public:
- CTextSubAvisynthFilter(PClip c, IScriptEnvironment* env, const char* fn, int CharSet = DEFAULT_CHARSET, float fps = -1)
- : CTextSubFilter(CString(fn), CharSet, fps)
- , CAvisynthFilter(c, env)
- {
- if(!m_pSubPicProvider)
+ class CTextSubAvisynthFilter : public CTextSubFilter, public CAvisynthFilter
+ {
+ public:
+ CTextSubAvisynthFilter(PClip c, IScriptEnvironment* env, const char* fn, int CharSet = DEFAULT_CHARSET, float fps = -1)
+ : CTextSubFilter(CString(fn), CharSet, fps)
+ , CAvisynthFilter(c, env) {
+ if(!m_pSubPicProvider)
#ifdef _VSMOD
- env->ThrowError("TextSubMod: Can't open \"%s\"", fn);
+ env->ThrowError("TextSubMod: Can't open \"%s\"", fn);
#else
- env->ThrowError("TextSub: Can't open \"%s\"", fn);
+ env->ThrowError("TextSub: Can't open \"%s\"", fn);
#endif
- }
-};
+ }
+ };
-AVSValue __cdecl TextSubCreateS(AVSValue args, void* user_data, IScriptEnvironment* env)
-{
- return(new CTextSubAvisynthFilter(args[0].AsClip(), env, args[1].AsString()));
-}
+ AVSValue __cdecl TextSubCreateS(AVSValue args, void* user_data, IScriptEnvironment* env)
+ {
+ return(new CTextSubAvisynthFilter(args[0].AsClip(), env, args[1].AsString()));
+ }
-AVSValue __cdecl TextSubCreateSI(AVSValue args, void* user_data, IScriptEnvironment* env)
-{
- return(new CTextSubAvisynthFilter(args[0].AsClip(), env, args[1].AsString(), args[2].AsInt()));
-}
+ AVSValue __cdecl TextSubCreateSI(AVSValue args, void* user_data, IScriptEnvironment* env)
+ {
+ return(new CTextSubAvisynthFilter(args[0].AsClip(), env, args[1].AsString(), args[2].AsInt()));
+ }
-AVSValue __cdecl TextSubCreateSIF(AVSValue args, void* user_data, IScriptEnvironment* env)
-{
- return(new CTextSubAvisynthFilter(args[0].AsClip(), env, args[1].AsString(), args[2].AsInt(), args[3].AsFloat()));
-}
+ AVSValue __cdecl TextSubCreateSIF(AVSValue args, void* user_data, IScriptEnvironment* env)
+ {
+ return(new CTextSubAvisynthFilter(args[0].AsClip(), env, args[1].AsString(), args[2].AsInt(), args[3].AsFloat()));
+ }
-AVSValue __cdecl MaskSubCreateSIIFI(AVSValue args, void* user_data, IScriptEnvironment* env)
-{
- AVSValue rgb32("RGB32");
- AVSValue tab[5] = {
- args[1],
- args[2],
- args[3],
- args[4],
- rgb32
- };
- AVSValue value(tab,5);
- const char * nom[5]= {
- "width",
- "height",
- "fps",
- "length",
- "pixel_type"
- };
- AVSValue clip(env->Invoke("Blackness",value,nom));
- env->SetVar(env->SaveString("RGBA"),true);
- return(new CTextSubAvisynthFilter(clip.AsClip(), env, args[0].AsString()));
-}
+ AVSValue __cdecl MaskSubCreateSIIFI(AVSValue args, void* user_data, IScriptEnvironment* env)
+ {
+ AVSValue rgb32("RGB32");
+ AVSValue tab[5] = {
+ args[1],
+ args[2],
+ args[3],
+ args[4],
+ rgb32
+ };
+ AVSValue value(tab,5);
+ const char * nom[5]= {
+ "width",
+ "height",
+ "fps",
+ "length",
+ "pixel_type"
+ };
+ AVSValue clip(env->Invoke("Blackness",value,nom));
+ env->SetVar(env->SaveString("RGBA"),true);
+ return(new CTextSubAvisynthFilter(clip.AsClip(), env, args[0].AsString()));
+ }
-extern "C" __declspec(dllexport) const char* __stdcall AvisynthPluginInit(IScriptEnvironment* env)
-{
- env->AddFunction("VobSub", "cs", VobSubCreateS, 0);
+ extern "C" __declspec(dllexport) const char* __stdcall AvisynthPluginInit(IScriptEnvironment* env)
+ {
+ env->AddFunction("VobSub", "cs", VobSubCreateS, 0);
#ifdef _VSMOD
- env->AddFunction("TextSubMod", "cs", TextSubCreateS, 0);
- env->AddFunction("TextSubMod", "csi", TextSubCreateSI, 0);
- env->AddFunction("TextSubMod", "csif", TextSubCreateSIF, 0);
- env->AddFunction("MaskSubMod", "siifi", MaskSubCreateSIIFI, 0);
+ env->AddFunction("TextSubMod", "cs", TextSubCreateS, 0);
+ env->AddFunction("TextSubMod", "csi", TextSubCreateSI, 0);
+ env->AddFunction("TextSubMod", "csif", TextSubCreateSIF, 0);
+ env->AddFunction("MaskSubMod", "siifi", MaskSubCreateSIIFI, 0);
#else
- env->AddFunction("TextSub", "cs", TextSubCreateS, 0);
- env->AddFunction("TextSub", "csi", TextSubCreateSI, 0);
- env->AddFunction("TextSub", "csif", TextSubCreateSIF, 0);
- env->AddFunction("MaskSub", "siifi", MaskSubCreateSIIFI, 0);
+ env->AddFunction("TextSub", "cs", TextSubCreateS, 0);
+ env->AddFunction("TextSub", "csi", TextSubCreateSI, 0);
+ env->AddFunction("TextSub", "csif", TextSubCreateSIF, 0);
+ env->AddFunction("MaskSub", "siifi", MaskSubCreateSIIFI, 0);
#endif
- env->SetVar(env->SaveString("RGBA"),false);
- return(NULL);
-}
-}
+ env->SetVar(env->SaveString("RGBA"),false);
+ return(NULL);
+ }
+ }
-namespace AviSynth25
-{
+ namespace AviSynth25
+ {
#include <avisynth\avisynth25.h>
-static bool s_fSwapUV = false;
+ static bool s_fSwapUV = false;
-class CAvisynthFilter : public GenericVideoFilter, virtual public CFilter
-{
-public:
- VFRTranslator *vfr;
+ class CAvisynthFilter : public GenericVideoFilter, virtual public CFilter
+ {
+ public:
+ VFRTranslator *vfr;
+
+ CAvisynthFilter(PClip c, IScriptEnvironment* env, VFRTranslator *_vfr=0) : GenericVideoFilter(c), vfr(_vfr) {}
+
+ PVideoFrame __stdcall GetFrame(int n, IScriptEnvironment* env) {
+ PVideoFrame frame = child->GetFrame(n, env);
+
+ env->MakeWritable(&frame);
+
+ SubPicDesc dst;
+ dst.w = vi.width;
+ dst.h = vi.height;
+ dst.pitch = frame->GetPitch();
+ dst.pitchUV = frame->GetPitch(PLANAR_U);
+ dst.bits = (void**)frame->GetWritePtr();
+ dst.bitsU = frame->GetWritePtr(PLANAR_U);
+ dst.bitsV = frame->GetWritePtr(PLANAR_V);
+ dst.bpp = dst.pitch/dst.w*8; //vi.BitsPerPixel();
+ dst.type =
+ vi.IsRGB32() ?( env->GetVar("RGBA").AsBool() ? MSP_RGBA : MSP_RGB32) :
+ vi.IsRGB24() ? MSP_RGB24 :
+ vi.IsYUY2() ? MSP_YUY2 :
+ /*vi.IsYV12()*/ vi.pixel_type == VideoInfo::CS_YV12 ? (s_fSwapUV?MSP_IYUV:MSP_YV12) :
+ /*vi.IsIYUV()*/ vi.pixel_type == VideoInfo::CS_IYUV ? (s_fSwapUV?MSP_YV12:MSP_IYUV) :
+ -1;
+
+ float fps = m_fps > 0 ? m_fps : (float)vi.fps_numerator / vi.fps_denominator;
+
+ REFERENCE_TIME timestamp;
+
+ if (!vfr) {
+ timestamp = (REFERENCE_TIME)(10000000i64 * n / fps);
+ } else {
+ timestamp = (REFERENCE_TIME)(10000000 * vfr->TimeStampFromFrameNumber(n));
+ }
- CAvisynthFilter(PClip c, IScriptEnvironment* env, VFRTranslator *_vfr=0) : GenericVideoFilter(c), vfr(_vfr) {}
+ Render(dst, timestamp, fps);
- PVideoFrame __stdcall GetFrame(int n, IScriptEnvironment* env)
- {
- PVideoFrame frame = child->GetFrame(n, env);
-
- env->MakeWritable(&frame);
-
- SubPicDesc dst;
- dst.w = vi.width;
- dst.h = vi.height;
- dst.pitch = frame->GetPitch();
- dst.pitchUV = frame->GetPitch(PLANAR_U);
- dst.bits = (void**)frame->GetWritePtr();
- dst.bitsU = frame->GetWritePtr(PLANAR_U);
- dst.bitsV = frame->GetWritePtr(PLANAR_V);
- dst.bpp = dst.pitch/dst.w*8; //vi.BitsPerPixel();
- dst.type =
- vi.IsRGB32() ?( env->GetVar("RGBA").AsBool() ? MSP_RGBA : MSP_RGB32) :
- vi.IsRGB24() ? MSP_RGB24 :
- vi.IsYUY2() ? MSP_YUY2 :
- /*vi.IsYV12()*/ vi.pixel_type == VideoInfo::CS_YV12 ? (s_fSwapUV?MSP_IYUV:MSP_YV12) :
- /*vi.IsIYUV()*/ vi.pixel_type == VideoInfo::CS_IYUV ? (s_fSwapUV?MSP_YV12:MSP_IYUV) :
- -1;
-
- float fps = m_fps > 0 ? m_fps : (float)vi.fps_numerator / vi.fps_denominator;
-
- REFERENCE_TIME timestamp;
-
- if (!vfr)
- timestamp = (REFERENCE_TIME)(10000000i64 * n / fps);
- else
- timestamp = (REFERENCE_TIME)(10000000 * vfr->TimeStampFromFrameNumber(n));
-
- Render(dst, timestamp, fps);
-
- return(frame);
- }
-};
+ return(frame);
+ }
+ };
-class CVobSubAvisynthFilter : public CVobSubFilter, public CAvisynthFilter
-{
-public:
- CVobSubAvisynthFilter(PClip c, const char* fn, IScriptEnvironment* env)
- : CVobSubFilter(CString(fn))
- , CAvisynthFilter(c, env)
- {
- if(!m_pSubPicProvider)
- env->ThrowError("VobSub: Can't open \"%s\"", fn);
- }
-};
+ class CVobSubAvisynthFilter : public CVobSubFilter, public CAvisynthFilter
+ {
+ public:
+ CVobSubAvisynthFilter(PClip c, const char* fn, IScriptEnvironment* env)
+ : CVobSubFilter(CString(fn))
+ , CAvisynthFilter(c, env) {
+ if(!m_pSubPicProvider) {
+ env->ThrowError("VobSub: Can't open \"%s\"", fn);
+ }
+ }
+ };
-AVSValue __cdecl VobSubCreateS(AVSValue args, void* user_data, IScriptEnvironment* env)
-{
- return(new CVobSubAvisynthFilter(args[0].AsClip(), args[1].AsString(), env));
-}
+ AVSValue __cdecl VobSubCreateS(AVSValue args, void* user_data, IScriptEnvironment* env)
+ {
+ return(new CVobSubAvisynthFilter(args[0].AsClip(), args[1].AsString(), env));
+ }
-class CTextSubAvisynthFilter : public CTextSubFilter, public CAvisynthFilter
-{
-public:
- CTextSubAvisynthFilter(PClip c, IScriptEnvironment* env, const char* fn, int CharSet = DEFAULT_CHARSET, float fps = -1, VFRTranslator *vfr = 0) //vfr patch
- : CTextSubFilter(CString(fn), CharSet, fps)
- , CAvisynthFilter(c, env, vfr)
- {
- if(!m_pSubPicProvider)
+ class CTextSubAvisynthFilter : public CTextSubFilter, public CAvisynthFilter
+ {
+ public:
+ CTextSubAvisynthFilter(PClip c, IScriptEnvironment* env, const char* fn, int CharSet = DEFAULT_CHARSET, float fps = -1, VFRTranslator *vfr = 0) //vfr patch
+ : CTextSubFilter(CString(fn), CharSet, fps)
+ , CAvisynthFilter(c, env, vfr) {
+ if(!m_pSubPicProvider)
#ifdef _VSMOD
- env->ThrowError("TextSubMod: Can't open \"%s\"", fn);
+ env->ThrowError("TextSubMod: Can't open \"%s\"", fn);
#else
- env->ThrowError("TextSub: Can't open \"%s\"", fn);
+ env->ThrowError("TextSub: Can't open \"%s\"", fn);
#endif
- }
-};
+ }
+ };
-AVSValue __cdecl TextSubCreateGeneral(AVSValue args, void* user_data, IScriptEnvironment* env)
-{
- if (!args[1].Defined())
+ AVSValue __cdecl TextSubCreateGeneral(AVSValue args, void* user_data, IScriptEnvironment* env)
+ {
+ if (!args[1].Defined())
#ifdef _VSMOD
- env->ThrowError("TextSubMod: You must specify a subtitle file to use");
+ env->ThrowError("TextSubMod: You must specify a subtitle file to use");
#else
- env->ThrowError("TextSub: You must specify a subtitle file to use");
+ env->ThrowError("TextSub: You must specify a subtitle file to use");
#endif
- VFRTranslator *vfr = 0;
- if (args[4].Defined())
- vfr = GetVFRTranslator(args[4].AsString());
-
- return(new CTextSubAvisynthFilter(
- args[0].AsClip(),
- env,
- args[1].AsString(),
- args[2].AsInt(DEFAULT_CHARSET),
- args[3].AsFloat(-1),
- vfr));
-}
+ VFRTranslator *vfr = 0;
+ if (args[4].Defined()) {
+ vfr = GetVFRTranslator(args[4].AsString());
+ }
-AVSValue __cdecl TextSubSwapUV(AVSValue args, void* user_data, IScriptEnvironment* env)
-{
- s_fSwapUV = args[0].AsBool(false);
- return(AVSValue());
-}
+ return(new CTextSubAvisynthFilter(
+ args[0].AsClip(),
+ env,
+ args[1].AsString(),
+ args[2].AsInt(DEFAULT_CHARSET),
+ args[3].AsFloat(-1),
+ vfr));
+ }
-AVSValue __cdecl MaskSubCreate(AVSValue args, void* user_data, IScriptEnvironment* env)/*SIIFI*/
-{
- if (!args[0].Defined())
+ AVSValue __cdecl TextSubSwapUV(AVSValue args, void* user_data, IScriptEnvironment* env)
+ {
+ s_fSwapUV = args[0].AsBool(false);
+ return(AVSValue());
+ }
+
+ AVSValue __cdecl MaskSubCreate(AVSValue args, void* user_data, IScriptEnvironment* env)/*SIIFI*/
+ {
+ if (!args[0].Defined())
#ifdef _VSMOD
- env->ThrowError("MaskSubMod: You must specify a subtitle file to use");
+ env->ThrowError("MaskSubMod: You must specify a subtitle file to use");
#else
- env->ThrowError("MaskSub: You must specify a subtitle file to use");
+ env->ThrowError("MaskSub: You must specify a subtitle file to use");
#endif
- if (!args[3].Defined() && !args[6].Defined())
+ if (!args[3].Defined() && !args[6].Defined())
#ifdef _VSMOD
- env->ThrowError("MaskSubMod: You must specify either FPS or a VFR timecodes file");
+ env->ThrowError("MaskSubMod: You must specify either FPS or a VFR timecodes file");
#else
- env->ThrowError("MaskSub: You must specify either FPS or a VFR timecodes file");
+ env->ThrowError("MaskSub: You must specify either FPS or a VFR timecodes file");
#endif
- VFRTranslator *vfr = 0;
- if (args[6].Defined())
- vfr = GetVFRTranslator(args[6].AsString());
-
- AVSValue rgb32("RGB32");
- AVSValue fps(args[3].AsFloat(25));
- AVSValue tab[6] = {
- args[1],
- args[2],
- args[3],
- args[4],
- rgb32
- };
- AVSValue value(tab,5);
- const char * nom[5]= {
- "width",
- "height",
- "fps",
- "length",
- "pixel_type"
- };
- AVSValue clip(env->Invoke("Blackness",value,nom));
- env->SetVar(env->SaveString("RGBA"),true);
- //return(new CTextSubAvisynthFilter(clip.AsClip(), env, args[0].AsString()));
- return(new CTextSubAvisynthFilter(
- clip.AsClip(),
- env,
- args[0].AsString(),
- args[5].AsInt(DEFAULT_CHARSET),
- args[3].AsFloat(-1),
- vfr));
-}
+ VFRTranslator *vfr = 0;
+ if (args[6].Defined()) {
+ vfr = GetVFRTranslator(args[6].AsString());
+ }
-extern "C" __declspec(dllexport) const char* __stdcall AvisynthPluginInit2(IScriptEnvironment* env)
-{
- env->AddFunction("VobSub", "cs", VobSubCreateS, 0);
+ AVSValue rgb32("RGB32");
+ AVSValue fps(args[3].AsFloat(25));
+ AVSValue tab[6] = {
+ args[1],
+ args[2],
+ args[3],
+ args[4],
+ rgb32
+ };
+ AVSValue value(tab,5);
+ const char * nom[5]= {
+ "width",
+ "height",
+ "fps",
+ "length",
+ "pixel_type"
+ };
+ AVSValue clip(env->Invoke("Blackness",value,nom));
+ env->SetVar(env->SaveString("RGBA"),true);
+ //return(new CTextSubAvisynthFilter(clip.AsClip(), env, args[0].AsString()));
+ return(new CTextSubAvisynthFilter(
+ clip.AsClip(),
+ env,
+ args[0].AsString(),
+ args[5].AsInt(DEFAULT_CHARSET),
+ args[3].AsFloat(-1),
+ vfr));
+ }
+
+ extern "C" __declspec(dllexport) const char* __stdcall AvisynthPluginInit2(IScriptEnvironment* env)
+ {
+ env->AddFunction("VobSub", "cs", VobSubCreateS, 0);
#ifdef _VSMOD
- env->AddFunction("TextSubMod", "c[file]s[charset]i[fps]f[vfr]s", TextSubCreateGeneral, 0);
- env->AddFunction("TextSubModSwapUV", "b", TextSubSwapUV, 0);
- env->AddFunction("MaskSubMod", "[file]s[width]i[height]i[fps]f[length]i[charset]i[vfr]s", MaskSubCreate, 0);
+ env->AddFunction("TextSubMod", "c[file]s[charset]i[fps]f[vfr]s", TextSubCreateGeneral, 0);
+ env->AddFunction("TextSubModSwapUV", "b", TextSubSwapUV, 0);
+ env->AddFunction("MaskSubMod", "[file]s[width]i[height]i[fps]f[length]i[charset]i[vfr]s", MaskSubCreate, 0);
#else
- env->AddFunction("TextSub", "c[file]s[charset]i[fps]f[vfr]s", TextSubCreateGeneral, 0);
- env->AddFunction("TextSubSwapUV", "b", TextSubSwapUV, 0);
- env->AddFunction("MaskSub", "[file]s[width]i[height]i[fps]f[length]i[charset]i[vfr]s", MaskSubCreate, 0);
+ env->AddFunction("TextSub", "c[file]s[charset]i[fps]f[vfr]s", TextSubCreateGeneral, 0);
+ env->AddFunction("TextSubSwapUV", "b", TextSubSwapUV, 0);
+ env->AddFunction("MaskSub", "[file]s[width]i[height]i[fps]f[length]i[charset]i[vfr]s", MaskSubCreate, 0);
#endif
- env->SetVar(env->SaveString("RGBA"),false);
- return(NULL);
-}
-}
+ env->SetVar(env->SaveString("RGBA"),false);
+ return(NULL);
+ }
+ }
}
UINT_PTR CALLBACK OpenHookProc(HWND hDlg, UINT uiMsg, WPARAM wParam, LPARAM lParam)
{
- switch(uiMsg)
- {
- case WM_NOTIFY:
- {
- OPENFILENAME* ofn = ((OFNOTIFY *)lParam)->lpOFN;
+ switch(uiMsg) {
+ case WM_NOTIFY: {
+ OPENFILENAME* ofn = ((OFNOTIFY *)lParam)->lpOFN;
- if(((NMHDR *)lParam)->code == CDN_FILEOK)
- {
- ofn->lCustData = (LPARAM)CharSetList[SendMessage(GetDlgItem(hDlg, IDC_COMBO1), CB_GETCURSEL, 0, 0)];
- }
+ if(((NMHDR *)lParam)->code == CDN_FILEOK) {
+ ofn->lCustData = (LPARAM)CharSetList[SendMessage(GetDlgItem(hDlg, IDC_COMBO1), CB_GETCURSEL, 0, 0)];
+ }
- break;
- }
+ break;
+ }
- case WM_INITDIALOG:
- {
+ case WM_INITDIALOG: {
#ifdef WIN64
- SetWindowLongPtr(hDlg, GWLP_USERDATA, lParam);
+ SetWindowLongPtr(hDlg, GWLP_USERDATA, lParam);
#else
- SetWindowLongPtr(hDlg, GWL_USERDATA, lParam);
+ SetWindowLongPtr(hDlg, GWL_USERDATA, lParam);
#endif
- for(ptrdiff_t i = 0; i < CharSetLen; i++)
- {
- CString s;
- s.Format(_T("%s (%d)"), CharSetNames[i], CharSetList[i]);
- SendMessage(GetDlgItem(hDlg, IDC_COMBO1), CB_ADDSTRING, 0, (LONG)(LPCTSTR)s);
- if(CharSetList[i] == (int)((OPENFILENAME*)lParam)->lCustData)
- SendMessage(GetDlgItem(hDlg, IDC_COMBO1), CB_SETCURSEL, i, 0);
- }
+ for(ptrdiff_t i = 0; i < CharSetLen; i++) {
+ CString s;
+ s.Format(_T("%s (%d)"), CharSetNames[i], CharSetList[i]);
+ SendMessage(GetDlgItem(hDlg, IDC_COMBO1), CB_ADDSTRING, 0, (LONG)(LPCTSTR)s);
+ if(CharSetList[i] == (int)((OPENFILENAME*)lParam)->lCustData) {
+ SendMessage(GetDlgItem(hDlg, IDC_COMBO1), CB_SETCURSEL, i, 0);
+ }
+ }
- break;
- }
+ break;
+ }
- default:
- break;
+ default:
+ break;
}
return FALSE;
diff --git a/src/filters/transform/VSFilter/vfr.cpp b/src/filters/transform/VSFilter/vfr.cpp
index bb56a6126..0c0eb36a5 100644
--- a/src/filters/transform/VSFilter/vfr.cpp
+++ b/src/filters/transform/VSFilter/vfr.cpp
@@ -32,7 +32,8 @@
// Work with seconds per frame (spf) here instead of fps since that's more natural for the translation we're doing
-class TimecodesV1 : public VFRTranslator {
+class TimecodesV1 : public VFRTranslator
+{
private:
// Used when sections run out
double default_spf;
@@ -50,8 +51,7 @@ private:
std::vector<FrameRateSection> sections;
public:
- virtual double TimeStampFromFrameNumber(int n)
- {
+ virtual double TimeStampFromFrameNumber(int n) {
// Find correct section
for (size_t i = 0; i < sections.size(); i++) {
FrameRateSection &sect = sections[i];
@@ -60,12 +60,13 @@ public:
}
}
// Not in a section
- if (n < 0) return 0.0;
+ if (n < 0) {
+ return 0.0;
+ }
return first_non_section_timestamp + (n - first_non_section_frame) * default_spf;
}
- TimecodesV1(FILE *vfrfile)
- {
+ TimecodesV1(FILE *vfrfile) {
char buf[100];
default_spf = -1;
@@ -79,15 +80,18 @@ public:
while (fgets(buf, 100, vfrfile)) {
// Comment?
- if (buf[0] == '#') continue;
+ if (buf[0] == '#') {
+ continue;
+ }
if (_strnicmp(buf, "Assume ", 7) == 0 && default_spf < 0) {
char *num = buf+7;
default_spf = atof(num);
- if (default_spf > 0)
+ if (default_spf > 0) {
default_spf = 1 / default_spf;
- else
+ } else {
default_spf = -1;
+ }
temp_section.spf = default_spf;
continue;
}
@@ -123,7 +127,8 @@ public:
};
-class TimecodesV2 : public VFRTranslator {
+class TimecodesV2 : public VFRTranslator
+{
private:
// Main data
std::vector<double> timestamps;
@@ -133,24 +138,26 @@ private:
double assumed_spf;
public:
- virtual double TimeStampFromFrameNumber(int n)
- {
+ virtual double TimeStampFromFrameNumber(int n) {
if (n < (int)timestamps.size() && n >= 0) {
return timestamps[n];
}
- if (n < 0) return 0.0;
+ if (n < 0) {
+ return 0.0;
+ }
return last_known_timestamp + (n - last_known_frame) * assumed_spf;
}
- TimecodesV2(FILE *vfrfile)
- {
+ TimecodesV2(FILE *vfrfile) {
char buf[50];
timestamps.reserve(8192); // should be enough for most cases
while (fgets(buf, 50, vfrfile)) {
// Comment?
- if (buf[0] == '#') continue;
+ if (buf[0] == '#') {
+ continue;
+ }
// Otherwise assume it's a good timestamp
timestamps.push_back(atof(buf)/1000);
}
diff --git a/src/filters/transform/VSFilter/vfr.h b/src/filters/transform/VSFilter/vfr.h
index a4aafffd4..837577b6e 100644
--- a/src/filters/transform/VSFilter/vfr.h
+++ b/src/filters/transform/VSFilter/vfr.h
@@ -26,7 +26,8 @@
#ifndef VFR_H
#define VFR_H
-class VFRTranslator {
+class VFRTranslator
+{
public:
virtual double TimeStampFromFrameNumber(int n) = 0;
};