diff options
author | XhmikosR <xhmikosr@users.sourceforge.net> | 2012-02-05 13:27:07 +0400 |
---|---|---|
committer | XhmikosR <xhmikosr@users.sourceforge.net> | 2012-02-05 13:27:07 +0400 |
commit | 6cb2939b677159a85147c6500835c194ee1ccf86 (patch) | |
tree | 54994b57d8df3203b276d15ee73c46d227ea6826 | |
parent | e736ccc10964dfcd571d1b0f07327819c31a63a9 (diff) |
apply astyle
git-svn-id: https://mpc-hc.svn.sourceforge.net/svnroot/mpc-hc/trunk@4039 10f7b99b-c216-0410-bff0-8a66a9350fd8
192 files changed, 9422 insertions, 9407 deletions
diff --git a/include/moreuuids.h b/include/moreuuids.h index db67f31df..6e44ced5f 100644 --- a/include/moreuuids.h +++ b/include/moreuuids.h @@ -899,11 +899,11 @@ DEFINE_GUID(MEDIASUBTYPE_WVC1, // D979F77B-DBEA-4BF6-9E6D-1D7E57FBAD53
DEFINE_GUID(MEDIASUBTYPE_WVC1_CYBERLINK,
- 0xD979F77B, 0xDBEA, 0x4BF6, 0x9E, 0x6D, 0x1D, 0x7E, 0x57, 0xFB, 0xAD, 0x53);
+ 0xD979F77B, 0xDBEA, 0x4BF6, 0x9E, 0x6D, 0x1D, 0x7E, 0x57, 0xFB, 0xAD, 0x53);
// 629B40AD-AD74-4EF4-A985-F0C8D92E5ECA
DEFINE_GUID(MEDIASUBTYPE_WVC1_ARCSOFT,
- 0x629B40AD, 0xAD74, 0x4EF4, 0xA9, 0x85, 0xF0, 0xC8, 0xD9, 0x2E, 0x5E, 0xCA);
+ 0x629B40AD, 0xAD74, 0x4EF4, 0xA9, 0x85, 0xF0, 0xC8, 0xD9, 0x2E, 0x5E, 0xCA);
// 31637677-0000-0010-8000-00AA00389B71
DEFINE_GUID(MEDIASUBTYPE_wvc1,
@@ -1095,12 +1095,12 @@ DEFINE_GUID(MEDIASUBTYPE_MLP, // {AFBC2343-3DCB-4047-9655-E1E62A61B1C5}
DEFINE_GUID(MEDIASUBTYPE_FFMPEG_AUDIO,
-0xafbc2343, 0x3dcb, 0x4047, 0x96, 0x55, 0xe1, 0xe6, 0x2a, 0x61, 0xb1, 0xc5);
+ 0xafbc2343, 0x3dcb, 0x4047, 0x96, 0x55, 0xe1, 0xe6, 0x2a, 0x61, 0xb1, 0xc5);
// {35189950-CAC9-4C8D-819D-B6FAEE15DD9D}
DEFINE_GUID(FORMAT_WaveFormatExFFMPEG,
-0x35189950, 0xcac9, 0x4c8d, 0x81, 0x9d, 0xb6, 0xfa, 0xee, 0x15, 0xdd, 0x9d);
+ 0x35189950, 0xcac9, 0x4c8d, 0x81, 0x9d, 0xb6, 0xfa, 0xee, 0x15, 0xdd, 0x9d);
struct WAVEFORMATEXFFMPEG
{
diff --git a/src/CmdUI/CmdUI.cpp b/src/CmdUI/CmdUI.cpp index 262aca22c..d96bcb2cc 100644 --- a/src/CmdUI/CmdUI.cpp +++ b/src/CmdUI/CmdUI.cpp @@ -52,7 +52,7 @@ LRESULT CCmdUIDialog::DefWindowProc(UINT message, WPARAM wParam, LPARAM lParam) {
LRESULT ret = __super::DefWindowProc(message, wParam, lParam);
- if(message == WM_INITDIALOG) {
+ if (message == WM_INITDIALOG) {
SendMessage(WM_KICKIDLE);
}
@@ -161,8 +161,8 @@ CCmdUIPropertyPage::~CCmdUIPropertyPage() LRESULT CCmdUIPropertyPage::DefWindowProc(UINT message, WPARAM wParam, LPARAM lParam)
{
- if(message == WM_COMMAND) {
- switch(HIWORD(wParam)) {
+ if (message == WM_COMMAND) {
+ switch (HIWORD(wParam)) {
case BN_CLICKED:
case CBN_SELCHANGE:
case EN_CHANGE:
@@ -174,7 +174,7 @@ LRESULT CCmdUIPropertyPage::DefWindowProc(UINT message, WPARAM wParam, LPARAM lP LRESULT ret = __super::DefWindowProc(message, wParam, lParam);
- if(message == WM_INITDIALOG) {
+ if (message == WM_INITDIALOG) {
SendMessage(WM_KICKIDLE);
}
diff --git a/src/DSUtil/AudioParser.cpp b/src/DSUtil/AudioParser.cpp index 670d9ea58..424732659 100644 --- a/src/DSUtil/AudioParser.cpp +++ b/src/DSUtil/AudioParser.cpp @@ -27,7 +27,7 @@ int GetAC3FrameSize(const BYTE *buf) static const int rates[] = {32, 40, 48, 56, 64, 80, 96, 112, 128, 160, 192, 224, 256, 320, 384, 448, 512, 576, 640};
int frmsizecod = buf[4] & 0x3F;
- if (frmsizecod >= 38)
+ if (frmsizecod >= 38)
return 0;
int rate = rates[frmsizecod >> 1];
@@ -73,7 +73,7 @@ int ParseAC3Header(const BYTE *buf, int *samplerate, int *channels, int *framele static const unsigned char halfrate[12] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 2, 3};
int frmsizecod = buf[4] & 0x3F;
- if (frmsizecod >= 38)
+ if (frmsizecod >= 38)
return 0;
int half = halfrate[buf[5] >> 3];
@@ -96,7 +96,7 @@ int ParseAC3Header(const BYTE *buf, int *samplerate, int *channels, int *framele default:
return 0;
}
-
+
unsigned char acmod = buf[6] >> 5;
unsigned char flags = ((((buf[6] & 0xf8) == 0x50) ? AC3_DOLBY : acmod) | ((buf[6] & lfeon[acmod]) ? AC3_LFE : 0));
switch (flags & AC3_CHANNEL_MASK) {
@@ -123,7 +123,7 @@ int ParseAC3Header(const BYTE *buf, int *samplerate, int *channels, int *framele break;
}
if (flags & AC3_LFE) (*channels)++;
-
+
*framelength = 1536;
return frame_size;
}
@@ -141,10 +141,10 @@ int ParseEAC3Header(const BYTE *buf, int *samplerate, int *channels, int *framel static const int samples_tbl[] = { 256, 512, 768, 1536 };
int frame_size = (((buf[2] & 0x03) << 8) + buf[3] + 1) * 2;
-
+
int fscod = buf[4] >> 6;
int fscod2 = (buf[4] >> 4) & 0x03;
-
+
if (fscod == 0x03 && fscod2 == 0x03)
return 0;
@@ -166,14 +166,15 @@ int ParseTrueHDHeader(const BYTE *buf, int *samplerate, int *channels, int *fram {
static const int sampling_rates[] = { 48000, 96000, 192000, 0, 0, 0, 0, 0, 44100, 88200, 176400, 0, 0, 0, 0, 0 };
static const int channel_count[13] = {// LR C LFE LRs LRvh LRc LRrs Cs Ts LRsd LRw Cvh LFE2
- 2, 1, 1, 2, 2, 2, 2, 1, 1, 2, 2, 1, 1 };
-
+ 2, 1, 1, 2, 2, 2, 2, 1, 1, 2, 2, 1, 1
+ };
+
DWORD sync = *(DWORD*)(buf+4);
if (sync != TRUEHD_SYNC_WORD)
return 0;
int frame_size = (((buf[0] << 8) | buf[1]) & 0xfff) * 2;
-
+
*samplerate = sampling_rates[buf[8] >> 4];
*framelength = 40 << ((buf[8] >> 4) & 0x07);
int chanmap_substream_1 = ((buf[ 9] & 0x0f) << 1) | (buf[10] >> 7);
diff --git a/src/DSUtil/DSMPropertyBag.cpp b/src/DSUtil/DSMPropertyBag.cpp index 09869c19c..26a058ad8 100644 --- a/src/DSUtil/DSMPropertyBag.cpp +++ b/src/DSUtil/DSMPropertyBag.cpp @@ -19,11 +19,11 @@ IDSMPropertyBagImpl::~IDSMPropertyBagImpl() STDMETHODIMP IDSMPropertyBagImpl::Read(LPCOLESTR pszPropName, VARIANT* pVar, IErrorLog* pErrorLog)
{
CheckPointer(pVar, E_POINTER);
- if(pVar->vt != VT_EMPTY) {
+ if (pVar->vt != VT_EMPTY) {
return E_INVALIDARG;
}
CStringW value = Lookup(pszPropName);
- if(value.IsEmpty()) {
+ if (value.IsEmpty()) {
return E_FAIL;
}
CComVariant(value).Detach(pVar);
@@ -42,7 +42,7 @@ STDMETHODIMP IDSMPropertyBagImpl::Read(ULONG cProperties, PROPBAG2* pPropBag, IE CheckPointer(pPropBag, E_POINTER);
CheckPointer(pvarValue, E_POINTER);
CheckPointer(phrError, E_POINTER);
- for(ULONG i = 0; i < cProperties; phrError[i] = S_OK, i++) {
+ for (ULONG i = 0; i < cProperties; phrError[i] = S_OK, i++) {
CComVariant(Lookup(pPropBag[i].pstrName)).Detach(pvarValue);
}
return S_OK;
@@ -52,7 +52,7 @@ STDMETHODIMP IDSMPropertyBagImpl::Write(ULONG cProperties, PROPBAG2* pPropBag, V {
CheckPointer(pPropBag, E_POINTER);
CheckPointer(pvarValue, E_POINTER);
- for(ULONG i = 0; i < cProperties; i++) {
+ for (ULONG i = 0; i < cProperties; i++) {
SetProperty(pPropBag[i].pstrName, &pvarValue[i]);
}
return S_OK;
@@ -69,10 +69,10 @@ STDMETHODIMP IDSMPropertyBagImpl::GetPropertyInfo(ULONG iProperty, ULONG cProper {
CheckPointer(pPropBag, E_POINTER);
CheckPointer(pcProperties, E_POINTER);
- for(ULONG i = 0; i < cProperties; i++, iProperty++, (*pcProperties)++) {
+ for (ULONG i = 0; i < cProperties; i++, iProperty++, (*pcProperties)++) {
CStringW key = GetKeyAt(iProperty);
pPropBag[i].pstrName = (BSTR)CoTaskMemAlloc((key.GetLength()+1)*sizeof(WCHAR));
- if(!pPropBag[i].pstrName) {
+ if (!pPropBag[i].pstrName) {
return E_FAIL;
}
wcscpy_s(pPropBag[i].pstrName, key.GetLength()+1, key);
@@ -91,7 +91,7 @@ HRESULT IDSMPropertyBagImpl::SetProperty(LPCWSTR key, LPCWSTR value) {
CheckPointer(key, E_POINTER);
CheckPointer(value, E_POINTER);
- if(!Lookup(key).IsEmpty()) {
+ if (!Lookup(key).IsEmpty()) {
SetAt(key, value);
} else {
Add(key, value);
@@ -103,7 +103,7 @@ HRESULT IDSMPropertyBagImpl::SetProperty(LPCWSTR key, VARIANT* var) {
CheckPointer(key, E_POINTER);
CheckPointer(var, E_POINTER);
- if((var->vt & (VT_BSTR | VT_BYREF)) != VT_BSTR) {
+ if ((var->vt & (VT_BSTR | VT_BYREF)) != VT_BSTR) {
return E_INVALIDARG;
}
return SetProperty(key, var->bstrVal);
@@ -114,7 +114,7 @@ HRESULT IDSMPropertyBagImpl::GetProperty(LPCWSTR key, BSTR* value) CheckPointer(key, E_POINTER);
CheckPointer(value, E_POINTER);
int i = FindKey(key);
- if(i < 0) {
+ if (i < 0) {
return E_FAIL;
}
*value = GetValueAt(i).AllocSysString();
@@ -176,7 +176,7 @@ CDSMResource::~CDSMResource() CDSMResource& CDSMResource::operator = (const CDSMResource& r)
{
- if( this != &r ) {
+ if ( this != &r ) {
tag = r.tag;
name = r.name;
desc = r.desc;
@@ -203,30 +203,30 @@ STDMETHODIMP_(DWORD) IDSMResourceBagImpl::ResGetCount() STDMETHODIMP IDSMResourceBagImpl::ResGet(DWORD iIndex, BSTR* ppName, BSTR* ppDesc, BSTR* ppMime, BYTE** ppData, DWORD* pDataLen, DWORD_PTR* pTag)
{
- if(ppData) {
+ if (ppData) {
CheckPointer(pDataLen, E_POINTER);
}
- if((INT_PTR)iIndex >= m_resources.GetCount()) {
+ if ((INT_PTR)iIndex >= m_resources.GetCount()) {
return E_INVALIDARG;
}
CDSMResource& r = m_resources[iIndex];
- if(ppName) {
+ if (ppName) {
*ppName = r.name.AllocSysString();
}
- if(ppDesc) {
+ if (ppDesc) {
*ppDesc = r.desc.AllocSysString();
}
- if(ppMime) {
+ if (ppMime) {
*ppMime = r.mime.AllocSysString();
}
- if(ppData) {
+ if (ppData) {
*pDataLen = r.data.GetCount();
memcpy(*ppData = (BYTE*)CoTaskMemAlloc(*pDataLen), r.data.GetData(), *pDataLen);
}
- if(pTag) {
+ if (pTag) {
*pTag = r.tag;
}
@@ -235,24 +235,24 @@ STDMETHODIMP IDSMResourceBagImpl::ResGet(DWORD iIndex, BSTR* ppName, BSTR* ppDes STDMETHODIMP IDSMResourceBagImpl::ResSet(DWORD iIndex, LPCWSTR pName, LPCWSTR pDesc, LPCWSTR pMime, BYTE* pData, DWORD len, DWORD_PTR tag)
{
- if((INT_PTR)iIndex >= m_resources.GetCount()) {
+ if ((INT_PTR)iIndex >= m_resources.GetCount()) {
return E_INVALIDARG;
}
CDSMResource& r = m_resources[iIndex];
- if(pName) {
+ if (pName) {
r.name = pName;
}
- if(pDesc) {
+ if (pDesc) {
r.desc = pDesc;
}
- if(pMime) {
+ if (pMime) {
r.mime = pMime;
}
- if(pData || len == 0) {
+ if (pData || len == 0) {
r.data.SetCount(len);
- if(pData) {
+ if (pData) {
memcpy(r.data.GetData(), pData, r.data.GetCount());
}
}
@@ -268,7 +268,7 @@ STDMETHODIMP IDSMResourceBagImpl::ResAppend(LPCWSTR pName, LPCWSTR pDesc, LPCWST STDMETHODIMP IDSMResourceBagImpl::ResRemoveAt(DWORD iIndex)
{
- if((INT_PTR)iIndex >= m_resources.GetCount()) {
+ if ((INT_PTR)iIndex >= m_resources.GetCount()) {
return E_INVALIDARG;
}
@@ -279,9 +279,9 @@ STDMETHODIMP IDSMResourceBagImpl::ResRemoveAt(DWORD iIndex) STDMETHODIMP IDSMResourceBagImpl::ResRemoveAll(DWORD_PTR tag)
{
- if(tag) {
- for(ptrdiff_t i = m_resources.GetCount() - 1; i >= 0; i--)
- if(m_resources[i].tag == tag) {
+ if (tag) {
+ for (ptrdiff_t i = m_resources.GetCount() - 1; i >= 0; i--)
+ if (m_resources[i].tag == tag) {
m_resources.RemoveAt(i);
}
} else {
@@ -310,7 +310,7 @@ CDSMChapter::CDSMChapter(REFERENCE_TIME rt, LPCWSTR name) CDSMChapter& CDSMChapter::operator = (const CDSMChapter& c)
{
- if( this != &c ) {
+ if ( this != &c ) {
order = c.counter;
rt = c.rt;
name = c.name;
@@ -325,9 +325,9 @@ int CDSMChapter::Compare(const void* a, const void* b) const CDSMChapter* ca = static_cast<const CDSMChapter*>(a);
const CDSMChapter* cb = static_cast<const CDSMChapter*>(b);
- if(ca->rt > cb->rt) {
+ if (ca->rt > cb->rt) {
return 1;
- } else if(ca->rt < cb->rt) {
+ } else if (ca->rt < cb->rt) {
return -1;
}
@@ -352,16 +352,16 @@ STDMETHODIMP_(DWORD) IDSMChapterBagImpl::ChapGetCount() STDMETHODIMP IDSMChapterBagImpl::ChapGet(DWORD iIndex, REFERENCE_TIME* prt, BSTR* ppName)
{
- if((INT_PTR)iIndex >= m_chapters.GetCount()) {
+ if ((INT_PTR)iIndex >= m_chapters.GetCount()) {
return E_INVALIDARG;
}
CDSMChapter& c = m_chapters[iIndex];
- if(prt) {
+ if (prt) {
*prt = c.rt;
}
- if(ppName) {
+ if (ppName) {
*ppName = c.name.AllocSysString();
}
@@ -370,14 +370,14 @@ STDMETHODIMP IDSMChapterBagImpl::ChapGet(DWORD iIndex, REFERENCE_TIME* prt, BSTR STDMETHODIMP IDSMChapterBagImpl::ChapSet(DWORD iIndex, REFERENCE_TIME rt, LPCWSTR pName)
{
- if((INT_PTR)iIndex >= m_chapters.GetCount()) {
+ if ((INT_PTR)iIndex >= m_chapters.GetCount()) {
return E_INVALIDARG;
}
CDSMChapter& c = m_chapters[iIndex];
c.rt = rt;
- if(pName) {
+ if (pName) {
c.name = pName;
}
@@ -393,7 +393,7 @@ STDMETHODIMP IDSMChapterBagImpl::ChapAppend(REFERENCE_TIME rt, LPCWSTR pName) STDMETHODIMP IDSMChapterBagImpl::ChapRemoveAt(DWORD iIndex)
{
- if((INT_PTR)iIndex >= m_chapters.GetCount()) {
+ if ((INT_PTR)iIndex >= m_chapters.GetCount()) {
return E_INVALIDARG;
}
@@ -418,12 +418,12 @@ STDMETHODIMP_(long) IDSMChapterBagImpl::ChapLookup(REFERENCE_TIME* prt, BSTR* pp ChapSort();
int i = range_bsearch(m_chapters, *prt);
- if(i < 0) {
+ if (i < 0) {
return -1;
}
*prt = m_chapters[i].rt;
- if(ppName) {
+ if (ppName) {
*ppName = m_chapters[i].name.AllocSysString();
}
@@ -432,7 +432,7 @@ STDMETHODIMP_(long) IDSMChapterBagImpl::ChapLookup(REFERENCE_TIME* prt, BSTR* pp STDMETHODIMP IDSMChapterBagImpl::ChapSort()
{
- if(m_fSorted) {
+ if (m_fSorted) {
return S_FALSE;
}
qsort(m_chapters.GetData(), m_chapters.GetCount(), sizeof(CDSMChapter), CDSMChapter::Compare);
diff --git a/src/DSUtil/DSMPropertyBag.h b/src/DSUtil/DSMPropertyBag.h index 638e38b31..c0da974cb 100644 --- a/src/DSUtil/DSMPropertyBag.h +++ b/src/DSUtil/DSMPropertyBag.h @@ -169,24 +169,24 @@ template<class T> int range_bsearch(const CAtlArray<T>& array, REFERENCE_TIME rt)
{
int i = 0, j = array.GetCount() - 1, ret = -1;
- if(j >= 0 && rt >= array[j].rt) {
+ if (j >= 0 && rt >= array[j].rt) {
return j;
}
- while(i < j) {
+ while (i < j) {
int mid = (i + j) >> 1;
REFERENCE_TIME midrt = array[mid].rt;
- if(rt == midrt) {
+ if (rt == midrt) {
ret = mid;
break;
- } else if(rt < midrt) {
+ } else if (rt < midrt) {
ret = -1;
- if(j == mid) {
+ if (j == mid) {
mid--;
}
j = mid;
- } else if(rt > midrt) {
+ } else if (rt > midrt) {
ret = mid;
- if(i == mid) {
+ if (i == mid) {
mid++;
}
i = mid;
diff --git a/src/DSUtil/DSUtil.cpp b/src/DSUtil/DSUtil.cpp index 952740d29..c682e3820 100644 --- a/src/DSUtil/DSUtil.cpp +++ b/src/DSUtil/DSUtil.cpp @@ -40,12 +40,12 @@ void DumpStreamConfig(TCHAR* fn, IAMStreamConfig* pAMVSCCap) {
CString s;
CStdioFile f;
- if(!f.Open(fn, CFile::modeCreate|CFile::modeWrite|CFile::typeText)) {
+ if (!f.Open(fn, CFile::modeCreate|CFile::modeWrite|CFile::typeText)) {
return;
}
int cnt = 0, size = 0;
- if(FAILED(pAMVSCCap->GetNumberOfCapabilities(&cnt, &size))) {
+ if (FAILED(pAMVSCCap->GetNumberOfCapabilities(&cnt, &size))) {
return;
}
@@ -53,9 +53,9 @@ void DumpStreamConfig(TCHAR* fn, IAMStreamConfig* pAMVSCCap) s.Format(_T("cnt %d, size %d\n"), cnt, size);
f.WriteString(s);
- if(size == sizeof(VIDEO_STREAM_CONFIG_CAPS)) {
+ if (size == sizeof(VIDEO_STREAM_CONFIG_CAPS)) {
CString ss;
- for(ptrdiff_t i = 0; i < cnt; i++) {
+ for (ptrdiff_t i = 0; i < cnt; i++) {
AM_MEDIA_TYPE* pmt = NULL;
VIDEO_STREAM_CONFIG_CAPS caps;
@@ -66,7 +66,7 @@ void DumpStreamConfig(TCHAR* fn, IAMStreamConfig* pAMVSCCap) s += ss;
f.WriteString(s);
- if(FAILED(pAMVSCCap->GetStreamCaps(i, &pmt, (BYTE*)&caps))) {
+ if (FAILED(pAMVSCCap->GetStreamCaps(i, &pmt, (BYTE*)&caps))) {
continue;
}
@@ -102,7 +102,7 @@ void DumpStreamConfig(TCHAR* fn, IAMStreamConfig* pAMVSCCap) }
BITMAPINFOHEADER* pbh;
- if(pmt->formattype == FORMAT_VideoInfo) {
+ if (pmt->formattype == FORMAT_VideoInfo) {
VIDEOINFOHEADER* vih = (VIDEOINFOHEADER*)pmt->pbFormat;
pbh = &vih->bmiHeader;
@@ -116,7 +116,7 @@ void DumpStreamConfig(TCHAR* fn, IAMStreamConfig* pAMVSCCap) ss.Format(_T("\trcTarget %d,%d,%d,%d\n"), vih->rcTarget);
s += ss;
f.WriteString(s);
- } else if(pmt->formattype == FORMAT_VideoInfo2) {
+ } else if (pmt->formattype == FORMAT_VideoInfo2) {
VIDEOINFOHEADER2* vih = (VIDEOINFOHEADER2*)pmt->pbFormat;
pbh = &vih->bmiHeader;
@@ -158,7 +158,7 @@ void DumpStreamConfig(TCHAR* fn, IAMStreamConfig* pAMVSCCap) DeleteMediaType(pmt);
}
- } else if(size == sizeof(AUDIO_STREAM_CONFIG_CAPS)) {
+ } else if (size == sizeof(AUDIO_STREAM_CONFIG_CAPS)) {
// TODO
}
}
@@ -170,18 +170,18 @@ int CountPins(IBaseFilter* pBF, int& nIn, int& nOut, int& nInC, int& nOutC) BeginEnumPins(pBF, pEP, pPin) {
PIN_DIRECTION dir;
- if(SUCCEEDED(pPin->QueryDirection(&dir))) {
+ if (SUCCEEDED(pPin->QueryDirection(&dir))) {
CComPtr<IPin> pPinConnectedTo;
pPin->ConnectedTo(&pPinConnectedTo);
- if(dir == PINDIR_INPUT) {
+ if (dir == PINDIR_INPUT) {
nIn++;
- if(pPinConnectedTo) {
+ if (pPinConnectedTo) {
nInC++;
}
- } else if(dir == PINDIR_OUTPUT) {
+ } else if (dir == PINDIR_OUTPUT) {
nOut++;
- if(pPinConnectedTo) {
+ if (pPinConnectedTo) {
nOutC++;
}
}
@@ -209,7 +209,7 @@ bool IsMultiplexer(IBaseFilter* pBF, bool fCountConnectedOnly) bool IsStreamStart(IBaseFilter* pBF)
{
CComQIPtr<IAMFilterMiscFlags> pAMMF(pBF);
- if(pAMMF && pAMMF->GetMiscFlags()&AM_FILTER_MISC_FLAGS_IS_SOURCE) {
+ if (pAMMF && pAMMF->GetMiscFlags()&AM_FILTER_MISC_FLAGS_IS_SOURCE) {
return true;
}
@@ -233,10 +233,10 @@ bool IsVideoRenderer(IBaseFilter* pBF) int nIn, nOut, nInC, nOutC;
CountPins(pBF, nIn, nOut, nInC, nOutC);
- if(nInC > 0 && nOut == 0) {
+ if (nInC > 0 && nOut == 0) {
BeginEnumPins(pBF, pEP, pPin) {
AM_MEDIA_TYPE mt;
- if(S_OK != pPin->ConnectionMediaType(&mt)) {
+ if (S_OK != pPin->ConnectionMediaType(&mt)) {
continue;
}
@@ -263,10 +263,10 @@ bool IsAudioWaveRenderer(IBaseFilter* pBF) int nIn, nOut, nInC, nOutC;
CountPins(pBF, nIn, nOut, nInC, nOutC);
- if(nInC > 0 && nOut == 0 && CComQIPtr<IBasicAudio>(pBF)) {
+ if (nInC > 0 && nOut == 0 && CComQIPtr<IBasicAudio>(pBF)) {
BeginEnumPins(pBF, pEP, pPin) {
AM_MEDIA_TYPE mt;
- if(S_OK != pPin->ConnectionMediaType(&mt)) {
+ if (S_OK != pPin->ConnectionMediaType(&mt)) {
continue;
}
@@ -294,13 +294,13 @@ IBaseFilter* GetUpStreamFilter(IBaseFilter* pBF, IPin* pInputPin) IPin* GetUpStreamPin(IBaseFilter* pBF, IPin* pInputPin)
{
BeginEnumPins(pBF, pEP, pPin) {
- if(pInputPin && pInputPin != pPin) {
+ if (pInputPin && pInputPin != pPin) {
continue;
}
PIN_DIRECTION dir;
CComPtr<IPin> pPinConnectedTo;
- if(SUCCEEDED(pPin->QueryDirection(&dir)) && dir == PINDIR_INPUT
+ if (SUCCEEDED(pPin->QueryDirection(&dir)) && dir == PINDIR_INPUT
&& SUCCEEDED(pPin->ConnectedTo(&pPinConnectedTo))) {
IPin* pRet = pPinConnectedTo.Detach();
pRet->Release();
@@ -314,14 +314,14 @@ IPin* GetUpStreamPin(IBaseFilter* pBF, IPin* pInputPin) IPin* GetFirstPin(IBaseFilter* pBF, PIN_DIRECTION dir)
{
- if(!pBF) {
+ if (!pBF) {
return(NULL);
}
BeginEnumPins(pBF, pEP, pPin) {
PIN_DIRECTION dir2;
pPin->QueryDirection(&dir2);
- if(dir == dir2) {
+ if (dir == dir2) {
IPin* pRet = pPin.Detach();
pRet->Release();
return(pRet);
@@ -334,7 +334,7 @@ IPin* GetFirstPin(IBaseFilter* pBF, PIN_DIRECTION dir) IPin* GetFirstDisconnectedPin(IBaseFilter* pBF, PIN_DIRECTION dir)
{
- if(!pBF) {
+ if (!pBF) {
return(NULL);
}
@@ -342,7 +342,7 @@ IPin* GetFirstDisconnectedPin(IBaseFilter* pBF, PIN_DIRECTION dir) PIN_DIRECTION dir2;
pPin->QueryDirection(&dir2);
CComPtr<IPin> pPinTo;
- if(dir == dir2 && (S_OK != pPin->ConnectedTo(&pPinTo))) {
+ if (dir == dir2 && (S_OK != pPin->ConnectedTo(&pPinTo))) {
IPin* pRet = pPin.Detach();
pRet->Release();
return(pRet);
@@ -364,7 +364,7 @@ IBaseFilter* FindFilter(const CLSID& clsid, IFilterGraph* pFG) {
BeginEnumFilters(pFG, pEF, pBF) {
CLSID clsid2;
- if(SUCCEEDED(pBF->GetClassID(&clsid2)) && clsid == clsid2) {
+ if (SUCCEEDED(pBF->GetClassID(&clsid2)) && clsid == clsid2) {
return(pBF);
}
}
@@ -398,23 +398,23 @@ CStringW GetFilterName(IBaseFilter* pBF) {
CStringW name = _T("");
- if(pBF) {
+ if (pBF) {
CLSID clsid = GetCLSID(pBF);
- if(clsid == CLSID_AsyncReader) {
+ if (clsid == CLSID_AsyncReader) {
name = _T("File Source (Async.)");
- } else if(clsid == CLSID_URLReader) {
+ } else if (clsid == CLSID_URLReader) {
name = _T("File Source (URL)");
- } else if(clsid == CLSID_WMAsfReader) {
+ } else if (clsid == CLSID_WMAsfReader) {
name = _T("WM ASF Reader");
- } else if(clsid == GUIDFromCString(_T("{D8980E15-E1F6-4916-A10F-D7EB4E9E10B8}"))) {
+ } else if (clsid == GUIDFromCString(_T("{D8980E15-E1F6-4916-A10F-D7EB4E9E10B8}"))) {
name = _T("AV Source");
- } else if(clsid == GUIDFromCString(_T("{B98D13E7-55DB-4385-A33D-09FD1BA26338}"))) {
+ } else if (clsid == GUIDFromCString(_T("{B98D13E7-55DB-4385-A33D-09FD1BA26338}"))) {
name = _T("LAV Splitter Source");
- } else if(clsid == GUIDFromCString(_T("{55DA30FC-F16B-49FC-BAA5-AE59FC65F82D}"))) {
+ } else if (clsid == GUIDFromCString(_T("{55DA30FC-F16B-49FC-BAA5-AE59FC65F82D}"))) {
name = _T("Haali Media Source");
} else {
CFilterInfo fi;
- if(SUCCEEDED(pBF->QueryFilterInfo(&fi))) {
+ if (SUCCEEDED(pBF->QueryFilterInfo(&fi))) {
name = fi.achName;
}
}
@@ -427,21 +427,21 @@ CStringW GetPinName(IPin* pPin) {
CStringW name;
CPinInfo pi;
- if(pPin && SUCCEEDED(pPin->QueryPinInfo(&pi))) {
+ if (pPin && SUCCEEDED(pPin->QueryPinInfo(&pi))) {
name = pi.achName;
}
-
+
return(name);
}
IFilterGraph* GetGraphFromFilter(IBaseFilter* pBF)
{
- if(!pBF) {
+ if (!pBF) {
return NULL;
}
IFilterGraph* pGraph = NULL;
CFilterInfo fi;
- if(pBF && SUCCEEDED(pBF->QueryFilterInfo(&fi))) {
+ if (pBF && SUCCEEDED(pBF->QueryFilterInfo(&fi))) {
pGraph = fi.pGraph;
}
return(pGraph);
@@ -449,12 +449,12 @@ IFilterGraph* GetGraphFromFilter(IBaseFilter* pBF) IBaseFilter* GetFilterFromPin(IPin* pPin)
{
- if(!pPin) {
+ if (!pPin) {
return NULL;
}
IBaseFilter* pBF = NULL;
CPinInfo pi;
- if(pPin && SUCCEEDED(pPin->QueryPinInfo(&pi))) {
+ if (pPin && SUCCEEDED(pPin->QueryPinInfo(&pi))) {
pBF = pi.pFilter;
}
return(pBF);
@@ -467,13 +467,13 @@ IPin* AppendFilter(IPin* pPin, CString DisplayName, IGraphBuilder* pGB) CInterfaceList<IBaseFilter> pFilters;
do {
- if(!pPin || DisplayName.IsEmpty() || !pGB) {
+ if (!pPin || DisplayName.IsEmpty() || !pGB) {
break;
}
CComPtr<IPin> pPinTo;
PIN_DIRECTION dir;
- if(FAILED(pPin->QueryDirection(&dir)) || dir != PINDIR_OUTPUT || SUCCEEDED(pPin->ConnectedTo(&pPinTo))) {
+ if (FAILED(pPin->QueryDirection(&dir)) || dir != PINDIR_OUTPUT || SUCCEEDED(pPin->ConnectedTo(&pPinTo))) {
break;
}
@@ -482,22 +482,22 @@ IPin* AppendFilter(IPin* pPin, CString DisplayName, IGraphBuilder* pGB) CComPtr<IMoniker> pMoniker;
ULONG chEaten;
- if(S_OK != MkParseDisplayName(pBindCtx, CComBSTR(DisplayName), &chEaten, &pMoniker)) {
+ if (S_OK != MkParseDisplayName(pBindCtx, CComBSTR(DisplayName), &chEaten, &pMoniker)) {
break;
}
CComPtr<IBaseFilter> pBF;
- if(FAILED(pMoniker->BindToObject(pBindCtx, 0, IID_IBaseFilter, (void**)&pBF)) || !pBF) {
+ if (FAILED(pMoniker->BindToObject(pBindCtx, 0, IID_IBaseFilter, (void**)&pBF)) || !pBF) {
break;
}
CComPtr<IPropertyBag> pPB;
- if(FAILED(pMoniker->BindToStorage(pBindCtx, 0, IID_IPropertyBag, (void**)&pPB))) {
+ if (FAILED(pMoniker->BindToStorage(pBindCtx, 0, IID_IPropertyBag, (void**)&pPB))) {
break;
}
CComVariant var;
- if(FAILED(pPB->Read(CComBSTR(_T("FriendlyName")), &var, NULL))) {
+ if (FAILED(pPB->Read(CComBSTR(_T("FriendlyName")), &var, NULL))) {
break;
}
@@ -506,42 +506,42 @@ IPin* AppendFilter(IPin* pPin, CString DisplayName, IGraphBuilder* pGB) pFilters.AddTail(pBF2);
EndEnumFilters
- if(FAILED(pGB->AddFilter(pBF, CStringW(var.bstrVal)))) {
+ if (FAILED(pGB->AddFilter(pBF, CStringW(var.bstrVal)))) {
break;
}
BeginEnumFilters(pGB, pEnum, pBF2)
- if(!pFilters.Find(pBF2) && SUCCEEDED(pGB->RemoveFilter(pBF2))) {
+ if (!pFilters.Find(pBF2) && SUCCEEDED(pGB->RemoveFilter(pBF2))) {
pEnum->Reset();
}
EndEnumFilters
pPinTo = GetFirstPin(pBF, PINDIR_INPUT);
- if(!pPinTo) {
+ if (!pPinTo) {
pGB->RemoveFilter(pBF);
break;
}
HRESULT hr;
- if(FAILED(hr = pGB->ConnectDirect(pPin, pPinTo, NULL))) {
+ if (FAILED(hr = pGB->ConnectDirect(pPin, pPinTo, NULL))) {
hr = pGB->Connect(pPin, pPinTo);
pGB->RemoveFilter(pBF);
break;
}
BeginEnumFilters(pGB, pEnum, pBF2)
- if(!pFilters.Find(pBF2) && SUCCEEDED(pGB->RemoveFilter(pBF2))) {
+ if (!pFilters.Find(pBF2) && SUCCEEDED(pGB->RemoveFilter(pBF2))) {
pEnum->Reset();
}
EndEnumFilters
pRet = GetFirstPin(pBF, PINDIR_OUTPUT);
- if(!pRet) {
+ if (!pRet) {
pRet = pPin;
pGB->RemoveFilter(pBF);
break;
}
- } while(false);
+ } while (false);
return(pRet);
}
@@ -549,26 +549,26 @@ IPin* AppendFilter(IPin* pPin, CString DisplayName, IGraphBuilder* pGB) IPin* InsertFilter(IPin* pPin, CString DisplayName, IGraphBuilder* pGB)
{
do {
- if(!pPin || DisplayName.IsEmpty() || !pGB) {
+ if (!pPin || DisplayName.IsEmpty() || !pGB) {
break;
}
PIN_DIRECTION dir;
- if(FAILED(pPin->QueryDirection(&dir))) {
+ if (FAILED(pPin->QueryDirection(&dir))) {
break;
}
CComPtr<IPin> pFrom, pTo;
- if(dir == PINDIR_INPUT) {
+ if (dir == PINDIR_INPUT) {
pPin->ConnectedTo(&pFrom);
pTo = pPin;
- } else if(dir == PINDIR_OUTPUT) {
+ } else if (dir == PINDIR_OUTPUT) {
pFrom = pPin;
pPin->ConnectedTo(&pTo);
}
- if(!pFrom || !pTo) {
+ if (!pFrom || !pTo) {
break;
}
@@ -577,63 +577,63 @@ IPin* InsertFilter(IPin* pPin, CString DisplayName, IGraphBuilder* pGB) CComPtr<IMoniker> pMoniker;
ULONG chEaten;
- if(S_OK != MkParseDisplayName(pBindCtx, CComBSTR(DisplayName), &chEaten, &pMoniker)) {
+ if (S_OK != MkParseDisplayName(pBindCtx, CComBSTR(DisplayName), &chEaten, &pMoniker)) {
break;
}
CComPtr<IBaseFilter> pBF;
- if(FAILED(pMoniker->BindToObject(pBindCtx, 0, IID_IBaseFilter, (void**)&pBF)) || !pBF) {
+ if (FAILED(pMoniker->BindToObject(pBindCtx, 0, IID_IBaseFilter, (void**)&pBF)) || !pBF) {
break;
}
CComPtr<IPropertyBag> pPB;
- if(FAILED(pMoniker->BindToStorage(pBindCtx, 0, IID_IPropertyBag, (void**)&pPB))) {
+ if (FAILED(pMoniker->BindToStorage(pBindCtx, 0, IID_IPropertyBag, (void**)&pPB))) {
break;
}
CComVariant var;
- if(FAILED(pPB->Read(CComBSTR(_T("FriendlyName")), &var, NULL))) {
+ if (FAILED(pPB->Read(CComBSTR(_T("FriendlyName")), &var, NULL))) {
break;
}
- if(FAILED(pGB->AddFilter(pBF, CStringW(var.bstrVal)))) {
+ if (FAILED(pGB->AddFilter(pBF, CStringW(var.bstrVal)))) {
break;
}
CComPtr<IPin> pFromTo = GetFirstPin(pBF, PINDIR_INPUT);
- if(!pFromTo) {
+ if (!pFromTo) {
pGB->RemoveFilter(pBF);
break;
}
- if(FAILED(pGB->Disconnect(pFrom)) || FAILED(pGB->Disconnect(pTo))) {
+ if (FAILED(pGB->Disconnect(pFrom)) || FAILED(pGB->Disconnect(pTo))) {
pGB->RemoveFilter(pBF);
pGB->ConnectDirect(pFrom, pTo, NULL);
break;
}
HRESULT hr;
- if(FAILED(hr = pGB->ConnectDirect(pFrom, pFromTo, NULL))) {
+ if (FAILED(hr = pGB->ConnectDirect(pFrom, pFromTo, NULL))) {
pGB->RemoveFilter(pBF);
pGB->ConnectDirect(pFrom, pTo, NULL);
break;
}
CComPtr<IPin> pToFrom = GetFirstPin(pBF, PINDIR_OUTPUT);
- if(!pToFrom) {
+ if (!pToFrom) {
pGB->RemoveFilter(pBF);
pGB->ConnectDirect(pFrom, pTo, NULL);
break;
}
- if(FAILED(pGB->ConnectDirect(pToFrom, pTo, NULL))) {
+ if (FAILED(pGB->ConnectDirect(pToFrom, pTo, NULL))) {
pGB->RemoveFilter(pBF);
pGB->ConnectDirect(pFrom, pTo, NULL);
break;
}
pPin = pToFrom;
- } while(false);
+ } while (false);
return(pPin);
}
@@ -645,13 +645,13 @@ void ExtractMediaTypes(IPin* pPin, CAtlArray<GUID>& types) BeginEnumMediaTypes(pPin, pEM, pmt) {
bool fFound = false;
- for(ptrdiff_t i = 0; !fFound && i < (int)types.GetCount(); i += 2) {
- if(types[i] == pmt->majortype && types[i+1] == pmt->subtype) {
+ for (ptrdiff_t i = 0; !fFound && i < (int)types.GetCount(); i += 2) {
+ if (types[i] == pmt->majortype && types[i+1] == pmt->subtype) {
fFound = true;
}
}
- if(!fFound) {
+ if (!fFound) {
types.Add(pmt->majortype);
types.Add(pmt->subtype);
}
@@ -667,14 +667,14 @@ void ExtractMediaTypes(IPin* pPin, CAtlList<CMediaType>& mts) bool fFound = false;
POSITION pos = mts.GetHeadPosition();
- while(!fFound && pos) {
+ while (!fFound && pos) {
CMediaType& mt = mts.GetNext(pos);
- if(mt.majortype == pmt->majortype && mt.subtype == pmt->subtype) {
+ if (mt.majortype == pmt->majortype && mt.subtype == pmt->subtype) {
fFound = true;
}
}
- if(!fFound) {
+ if (!fFound) {
mts.AddTail(CMediaType(*pmt));
}
}
@@ -683,7 +683,7 @@ void ExtractMediaTypes(IPin* pPin, CAtlList<CMediaType>& mts) int Eval_Exception(int n_except)
{
- if(n_except == STATUS_ACCESS_VIOLATION) {
+ if (n_except == STATUS_ACCESS_VIOLATION) {
AfxMessageBox(_T("The property page of this filter has just caused a\nmemory access violation. The application will gently die now :)"));
}
@@ -695,7 +695,7 @@ void MyOleCreatePropertyFrame(HWND hwndOwner, UINT x, UINT y, LPCOLESTR lpszCapt __try {
OleCreatePropertyFrame(hwndOwner, x, y, lpszCaption, cObjects, lplpUnk, cPages, lpPageClsID, lcid, dwReserved, lpvReserved);
}
- __except(Eval_Exception(GetExceptionCode())) {
+ __except (Eval_Exception(GetExceptionCode())) {
// No code; this block never executed.
}
}
@@ -707,12 +707,12 @@ void ShowPPage(CString DisplayName, HWND hParentWnd) CComPtr<IMoniker> pMoniker;
ULONG chEaten;
- if(S_OK != MkParseDisplayName(pBindCtx, CStringW(DisplayName), &chEaten, &pMoniker)) {
+ if (S_OK != MkParseDisplayName(pBindCtx, CStringW(DisplayName), &chEaten, &pMoniker)) {
return;
}
CComPtr<IBaseFilter> pBF;
- if(FAILED(pMoniker->BindToObject(pBindCtx, 0, IID_IBaseFilter, (void**)&pBF)) || !pBF) {
+ if (FAILED(pMoniker->BindToObject(pBindCtx, 0, IID_IBaseFilter, (void**)&pBF)) || !pBF) {
return;
}
@@ -722,7 +722,7 @@ void ShowPPage(CString DisplayName, HWND hParentWnd) void ShowPPage(IUnknown* pUnk, HWND hParentWnd)
{
CComQIPtr<ISpecifyPropertyPages> pSPP = pUnk;
- if(!pSPP) {
+ if (!pSPP) {
return;
}
@@ -732,15 +732,15 @@ void ShowPPage(IUnknown* pUnk, HWND hParentWnd) CFilterInfo fi;
CComQIPtr<IPin> pPin = pSPP;
CPinInfo pi;
- if(pBF && SUCCEEDED(pBF->QueryFilterInfo(&fi))) {
+ if (pBF && SUCCEEDED(pBF->QueryFilterInfo(&fi))) {
str = fi.achName;
- } else if(pPin && SUCCEEDED(pPin->QueryPinInfo(&pi))) {
+ } else if (pPin && SUCCEEDED(pPin->QueryPinInfo(&pi))) {
str = pi.achName;
}
CAUUID caGUID;
caGUID.pElems = NULL;
- if(SUCCEEDED(pSPP->GetPages(&caGUID))) {
+ if (SUCCEEDED(pSPP->GetPages(&caGUID))) {
IUnknown* lpUnk = NULL;
pSPP.QueryInterface(&lpUnk);
MyOleCreatePropertyFrame(
@@ -750,7 +750,7 @@ void ShowPPage(IUnknown* pUnk, HWND hParentWnd) 0, 0, NULL);
lpUnk->Release();
- if(caGUID.pElems) {
+ if (caGUID.pElems) {
CoTaskMemFree(caGUID.pElems);
}
}
@@ -759,7 +759,7 @@ void ShowPPage(IUnknown* pUnk, HWND hParentWnd) CLSID GetCLSID(IBaseFilter* pBF)
{
CLSID clsid = GUID_NULL;
- if(pBF) {
+ if (pBF) {
pBF->GetClassID(&clsid);
}
return(clsid);
@@ -784,7 +784,7 @@ bool IsCLSIDRegistered(const CLSID& clsid) bool fRet = false;
LPOLESTR pStr = NULL;
- if(S_OK == StringFromCLSID(clsid, &pStr) && pStr) {
+ if (S_OK == StringFromCLSID(clsid, &pStr) && pStr) {
fRet = IsCLSIDRegistered(CString(pStr));
CoTaskMemFree(pStr);
}
@@ -801,16 +801,16 @@ void CStringToBin(CString str, CAtlArray<BYTE>& data) BYTE b = 0;
str.MakeUpper();
- for(size_t i = 0, j = str.GetLength(); i < j; i++) {
+ for (size_t i = 0, j = str.GetLength(); i < j; i++) {
TCHAR c = str[i];
- if(c >= '0' && c <= '9') {
- if(!(i&1)) {
+ if (c >= '0' && c <= '9') {
+ if (!(i&1)) {
b = ((char(c-'0')<<4)&0xf0)|(b&0x0f);
} else {
b = (char(c-'0')&0x0f)|(b&0xf0);
}
- } else if(c >= 'A' && c <= 'F') {
- if(!(i&1)) {
+ } else if (c >= 'A' && c <= 'F') {
+ if (!(i&1)) {
b = ((char(c-'A'+10)<<4)&0xf0)|(b&0x0f);
} else {
b = (char(c-'A'+10)&0x0f)|(b&0xf0);
@@ -819,7 +819,7 @@ void CStringToBin(CString str, CAtlArray<BYTE>& data) break;
}
- if(i&1) {
+ if (i&1) {
data[i>>1] = b;
b = 0;
}
@@ -830,7 +830,7 @@ CString BinToCString(BYTE* ptr, int len) {
CString ret;
- while(len-- > 0) {
+ while (len-- > 0) {
TCHAR high, low;
high = (*ptr>>4) >= 10 ? (*ptr>>4)-10 + 'A' : (*ptr>>4) + '0';
low = (*ptr&0xf) >= 10 ? (*ptr&0xf)-10 + 'A' : (*ptr&0xf) + '0';
@@ -853,10 +853,10 @@ static void FindFiles(CString fn, CAtlList<CString>& files) WIN32_FIND_DATA findData;
HANDLE h = FindFirstFile(fn, &findData);
- if(h != INVALID_HANDLE_VALUE) {
+ if (h != INVALID_HANDLE_VALUE) {
do {
files.AddTail(path + findData.cFileName);
- } while(FindNextFile(h, &findData));
+ } while (FindNextFile(h, &findData));
FindClose(h);
}
@@ -869,7 +869,7 @@ cdrom_t GetCDROMType(TCHAR drive, CAtlList<CString>& files) CString path;
path.Format(_T("%c:"), drive);
- if(GetDriveType(path + _T("\\")) == DRIVE_CDROM) {
+ if (GetDriveType(path + _T("\\")) == DRIVE_CDROM) {
// CDROM_VideoCD
FindFiles(path + _T("\\mpegav\\avseq??.dat"), files);
FindFiles(path + _T("\\mpegav\\avseq??.mpg"), files);
@@ -879,28 +879,28 @@ cdrom_t GetCDROMType(TCHAR drive, CAtlList<CString>& files) FindFiles(path + _T("\\mpegav\\music??.mpg"), files);
FindFiles(path + _T("\\mpeg2\\music??.dat"), files);
FindFiles(path + _T("\\mpeg2\\music??.mpg"), files);
- if(files.GetCount() > 0) {
+ if (files.GetCount() > 0) {
return CDROM_VideoCD;
}
// CDROM_DVDVideo
FindFiles(path + _T("\\VIDEO_TS\\video_ts.ifo"), files);
- if(files.GetCount() > 0) {
+ if (files.GetCount() > 0) {
return CDROM_DVDVideo;
}
// CDROM_Audio
- if(!(GetVersion()&0x80000000)) {
+ if (!(GetVersion()&0x80000000)) {
HANDLE hDrive = CreateFile(CString(_T("\\\\.\\")) + path, GENERIC_READ, FILE_SHARE_READ, NULL,
OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, (HANDLE)NULL);
- if(hDrive != INVALID_HANDLE_VALUE) {
+ if (hDrive != INVALID_HANDLE_VALUE) {
DWORD BytesReturned;
CDROM_TOC TOC;
- if(DeviceIoControl(hDrive, IOCTL_CDROM_READ_TOC, NULL, 0, &TOC, sizeof(TOC), &BytesReturned, 0)) {
- for(ptrdiff_t i = TOC.FirstTrack; i <= TOC.LastTrack; i++) {
+ if (DeviceIoControl(hDrive, IOCTL_CDROM_READ_TOC, NULL, 0, &TOC, sizeof(TOC), &BytesReturned, 0)) {
+ for (ptrdiff_t i = TOC.FirstTrack; i <= TOC.LastTrack; i++) {
// MMC-3 Draft Revision 10g: Table 222 – Q Sub-channel control field
TOC.TrackData[i-1].Control &= 5;
- if(TOC.TrackData[i-1].Control == 0 || TOC.TrackData[i-1].Control == 1) {
+ if (TOC.TrackData[i-1].Control == 0 || TOC.TrackData[i-1].Control == 1) {
CString fn;
fn.Format(_T("%s\\track%02d.cda"), path, i);
files.AddTail(fn);
@@ -911,7 +911,7 @@ cdrom_t GetCDROMType(TCHAR drive, CAtlList<CString>& files) CloseHandle(hDrive);
}
}
- if(files.GetCount() > 0) {
+ if (files.GetCount() > 0) {
return CDROM_Audio;
}
@@ -930,9 +930,9 @@ CString GetDriveLabel(TCHAR drive) path.Format(_T("%c:\\"), drive);
TCHAR VolumeNameBuffer[MAX_PATH], FileSystemNameBuffer[MAX_PATH];
DWORD VolumeSerialNumber, MaximumComponentLength, FileSystemFlags;
- if(GetVolumeInformation(path,
- VolumeNameBuffer, MAX_PATH, &VolumeSerialNumber, &MaximumComponentLength,
- &FileSystemFlags, FileSystemNameBuffer, MAX_PATH)) {
+ if (GetVolumeInformation(path,
+ VolumeNameBuffer, MAX_PATH, &VolumeSerialNumber, &MaximumComponentLength,
+ &FileSystemFlags, FileSystemNameBuffer, MAX_PATH)) {
label = VolumeNameBuffer;
}
@@ -944,35 +944,35 @@ bool GetKeyFrames(CString fn, CUIntArray& kfs) kfs.RemoveAll();
CString fn2 = CString(fn).MakeLower();
- if(fn2.Mid(fn2.ReverseFind('.')+1) == _T("avi")) {
+ if (fn2.Mid(fn2.ReverseFind('.')+1) == _T("avi")) {
AVIFileInit();
PAVIFILE pfile;
- if(AVIFileOpen(&pfile, fn, OF_SHARE_DENY_WRITE, 0L) == 0) {
+ if (AVIFileOpen(&pfile, fn, OF_SHARE_DENY_WRITE, 0L) == 0) {
AVIFILEINFO afi;
memset(&afi, 0, sizeof(afi));
AVIFileInfo(pfile, &afi, sizeof(AVIFILEINFO));
CComPtr<IAVIStream> pavi;
- if(AVIFileGetStream(pfile, &pavi, streamtypeVIDEO, 0) == AVIERR_OK) {
+ if (AVIFileGetStream(pfile, &pavi, streamtypeVIDEO, 0) == AVIERR_OK) {
AVISTREAMINFO si;
AVIStreamInfo(pavi, &si, sizeof(si));
- if(afi.dwCaps&AVIFILECAPS_ALLKEYFRAMES) {
+ if (afi.dwCaps&AVIFILECAPS_ALLKEYFRAMES) {
kfs.SetSize(si.dwLength);
- for(ptrdiff_t kf = 0; kf < (int)si.dwLength; kf++) {
+ for (ptrdiff_t kf = 0; kf < (int)si.dwLength; kf++) {
kfs[kf] = kf;
}
} else {
- for(ptrdiff_t kf = 0; ; kf++) {
+ for (ptrdiff_t kf = 0; ; kf++) {
kf = pavi->FindSample(kf, FIND_KEY|FIND_NEXT);
- if(kf < 0 || kfs.GetCount() > 0 && kfs[kfs.GetCount()-1] >= (UINT)kf) {
+ if (kf < 0 || kfs.GetCount() > 0 && kfs[kfs.GetCount()-1] >= (UINT)kf) {
break;
}
kfs.Add(kf);
}
- if(kfs.GetCount() > 0 && kfs[kfs.GetCount()-1] < si.dwLength-1) {
+ if (kfs.GetCount() > 0 && kfs[kfs.GetCount()-1] < si.dwLength-1) {
kfs.Add(si.dwLength-1);
}
}
@@ -1014,7 +1014,7 @@ DVD_HMSF_TIMECODE RT2HMS_r(REFERENCE_TIME rt) // use only for information (for d REFERENCE_TIME HMSF2RT(DVD_HMSF_TIMECODE hmsf, double fps)
{
- if(fps == 0) {
+ if (fps == 0) {
hmsf.bFrames = 0;
fps = 1;
}
@@ -1050,7 +1050,7 @@ void memsetd(void* dst, unsigned int c, size_t nbytes) }
}
- switch(n - o) {
+ switch (n - o) {
case 3:
((DWORD*)dst)[o + 2] = c;
case 2:
@@ -1073,26 +1073,26 @@ void memsetw(void* dst, unsigned short c, size_t nbytes) bool ExtractBIH(const AM_MEDIA_TYPE* pmt, BITMAPINFOHEADER* bih)
{
- if(pmt && bih) {
+ if (pmt && bih) {
memset(bih, 0, sizeof(*bih));
- if(pmt->formattype == FORMAT_VideoInfo) {
+ if (pmt->formattype == FORMAT_VideoInfo) {
VIDEOINFOHEADER* vih = (VIDEOINFOHEADER*)pmt->pbFormat;
memcpy(bih, &vih->bmiHeader, sizeof(BITMAPINFOHEADER));
return true;
- } else if(pmt->formattype == FORMAT_VideoInfo2) {
+ } else if (pmt->formattype == FORMAT_VideoInfo2) {
VIDEOINFOHEADER2* vih = (VIDEOINFOHEADER2*)pmt->pbFormat;
memcpy(bih, &vih->bmiHeader, sizeof(BITMAPINFOHEADER));
return true;
- } else if(pmt->formattype == FORMAT_MPEGVideo) {
+ } else if (pmt->formattype == FORMAT_MPEGVideo) {
VIDEOINFOHEADER* vih = &((MPEG1VIDEOINFO*)pmt->pbFormat)->hdr;
memcpy(bih, &vih->bmiHeader, sizeof(BITMAPINFOHEADER));
return true;
- } else if(pmt->formattype == FORMAT_MPEG2_VIDEO) {
+ } else if (pmt->formattype == FORMAT_MPEG2_VIDEO) {
VIDEOINFOHEADER2* vih = &((MPEG2VIDEOINFO*)pmt->pbFormat)->hdr;
memcpy(bih, &vih->bmiHeader, sizeof(BITMAPINFOHEADER));
return true;
- } else if(pmt->formattype == FORMAT_DiracVideoInfo) {
+ } else if (pmt->formattype == FORMAT_DiracVideoInfo) {
VIDEOINFOHEADER2* vih = &((DIRACINFOHEADER*)pmt->pbFormat)->hdr;
memcpy(bih, &vih->bmiHeader, sizeof(BITMAPINFOHEADER));
return true;
@@ -1123,7 +1123,7 @@ bool ExtractBIH(IMediaSample* pMS, BITMAPINFOHEADER* bih) {
AM_MEDIA_TYPE* pmt = NULL;
pMS->GetMediaType(&pmt);
- if(pmt) {
+ if (pmt) {
bool fRet = ExtractBIH(pmt, bih);
DeleteMediaType(pmt);
return(fRet);
@@ -1136,13 +1136,13 @@ bool ExtractDim(const AM_MEDIA_TYPE* pmt, int& w, int& h, int& arx, int& ary) {
w = h = arx = ary = 0;
- if(pmt->formattype == FORMAT_VideoInfo || pmt->formattype == FORMAT_MPEGVideo) {
+ if (pmt->formattype == FORMAT_VideoInfo || pmt->formattype == FORMAT_MPEGVideo) {
VIDEOINFOHEADER* vih = (VIDEOINFOHEADER*)pmt->pbFormat;
w = vih->bmiHeader.biWidth;
h = abs(vih->bmiHeader.biHeight);
arx = w * vih->bmiHeader.biYPelsPerMeter;
ary = h * vih->bmiHeader.biXPelsPerMeter;
- } else if(pmt->formattype == FORMAT_VideoInfo2 || pmt->formattype == FORMAT_MPEG2_VIDEO || pmt->formattype == FORMAT_DiracVideoInfo) {
+ } else if (pmt->formattype == FORMAT_VideoInfo2 || pmt->formattype == FORMAT_MPEG2_VIDEO || pmt->formattype == FORMAT_DiracVideoInfo) {
VIDEOINFOHEADER2* vih = (VIDEOINFOHEADER2*)pmt->pbFormat;
w = vih->bmiHeader.biWidth;
h = abs(vih->bmiHeader.biHeight);
@@ -1152,15 +1152,15 @@ bool ExtractDim(const AM_MEDIA_TYPE* pmt, int& w, int& h, int& arx, int& ary) return false;
}
- if(!arx || !ary) {
+ if (!arx || !ary) {
BYTE* ptr = NULL;
DWORD len = 0;
- if(pmt->formattype == FORMAT_MPEGVideo) {
+ if (pmt->formattype == FORMAT_MPEGVideo) {
ptr = ((MPEG1VIDEOINFO*)pmt->pbFormat)->bSequenceHeader;
len = ((MPEG1VIDEOINFO*)pmt->pbFormat)->cbSequenceHeader;
- if(ptr && len >= 8 && *(DWORD*)ptr == 0xb3010000) {
+ if (ptr && len >= 8 && *(DWORD*)ptr == 0xb3010000) {
w = (ptr[4]<<4)|(ptr[5]>>4);
h = ((ptr[5]&0xf)<<8)|ptr[6];
float ar[] = {
@@ -1172,11 +1172,11 @@ bool ExtractDim(const AM_MEDIA_TYPE* pmt, int& w, int& h, int& arx, int& ary) arx = (int)((float)w / ar[ptr[7]>>4] + 0.5);
ary = h;
}
- } else if(pmt->formattype == FORMAT_MPEG2_VIDEO) {
+ } else if (pmt->formattype == FORMAT_MPEG2_VIDEO) {
ptr = (BYTE*)((MPEG2VIDEOINFO*)pmt->pbFormat)->dwSequenceHeader;
len = ((MPEG2VIDEOINFO*)pmt->pbFormat)->cbSequenceHeader;
- if(ptr && len >= 8 && *(DWORD*)ptr == 0xb3010000) {
+ if (ptr && len >= 8 && *(DWORD*)ptr == 0xb3010000) {
w = (ptr[4]<<4)|(ptr[5]>>4);
h = ((ptr[5]&0xf)<<8)|ptr[6];
struct {
@@ -1189,18 +1189,18 @@ bool ExtractDim(const AM_MEDIA_TYPE* pmt, int& w, int& h, int& arx, int& ary) }
}
- if(!arx || !ary) {
+ if (!arx || !ary) {
arx = w;
ary = h;
}
DWORD a = arx, b = ary;
- while(a) {
+ while (a) {
int tmp = a;
a = b % tmp;
b = tmp;
}
- if(b) {
+ if (b) {
arx /= b, ary /= b;
}
@@ -1209,7 +1209,7 @@ bool ExtractDim(const AM_MEDIA_TYPE* pmt, int& w, int& h, int& arx, int& ary) bool MakeMPEG2MediaType(CMediaType& mt, BYTE* seqhdr, DWORD len, int w, int h)
{
- if(len < 4 || *(DWORD*)seqhdr != 0xb3010000) {
+ if (len < 4 || *(DWORD*)seqhdr != 0xb3010000) {
mt = CMediaType();
mt.majortype = MEDIATYPE_Video;
@@ -1231,8 +1231,8 @@ bool MakeMPEG2MediaType(CMediaType& mt, BYTE* seqhdr, DWORD len, int w, int h) BYTE* seqhdr_end = seqhdr + 7;
- while(seqhdr_end < (seqhdr + len - 6)) {
- if(*(DWORD*)seqhdr_end == 0xb5010000) {
+ while (seqhdr_end < (seqhdr + len - 6)) {
+ if (*(DWORD*)seqhdr_end == 0xb5010000) {
seqhdr_ext = seqhdr_end;
seqhdr_end += 10;
len = seqhdr_end - seqhdr;
@@ -1269,7 +1269,7 @@ bool MakeMPEG2MediaType(CMediaType& mt, BYTE* seqhdr, DWORD len, int w, int h) 0, 0, 0, 0
};
- if(seqhdr_ext && (seqhdr_ext[4] & 0xf0) == 0x10) {
+ if (seqhdr_ext && (seqhdr_ext[4] & 0xf0) == 0x10) {
vih->dwProfile = profile[seqhdr_ext[4] & 0x07];
vih->dwLevel = level[seqhdr_ext[5] >> 4];
}
@@ -1286,11 +1286,11 @@ unsigned __int64 GetFileVersion(LPCTSTR fn) DWORD d; // a variable that GetFileVersionInfoSize sets to zero (but why is it needed ?????????????????????????????? :)
DWORD len = GetFileVersionInfoSize((TCHAR*)fn, &d);
- if(len) {
+ if (len) {
TCHAR* b1 = DNew TCHAR[len];
- if(b1) {
+ if (b1) {
UINT uLen;
- if(GetFileVersionInfo((TCHAR*)fn, 0, len, b1) && VerQueryValue(b1, _T("\\"), (void**)&pvsf, &uLen)) {
+ if (GetFileVersionInfo((TCHAR*)fn, 0, len, b1) && VerQueryValue(b1, _T("\\"), (void**)&pvsf, &uLen)) {
ret = ((unsigned __int64)pvsf->dwFileVersionMS<<32) | pvsf->dwFileVersionLS;
}
@@ -1303,7 +1303,7 @@ unsigned __int64 GetFileVersion(LPCTSTR fn) bool CreateFilter(CStringW DisplayName, IBaseFilter** ppBF, CStringW& FriendlyName)
{
- if(!ppBF) {
+ if (!ppBF) {
return false;
}
@@ -1315,17 +1315,17 @@ bool CreateFilter(CStringW DisplayName, IBaseFilter** ppBF, CStringW& FriendlyNa CComPtr<IMoniker> pMoniker;
ULONG chEaten;
- if(S_OK != MkParseDisplayName(pBindCtx, CComBSTR(DisplayName), &chEaten, &pMoniker)) {
+ if (S_OK != MkParseDisplayName(pBindCtx, CComBSTR(DisplayName), &chEaten, &pMoniker)) {
return false;
}
- if(FAILED(pMoniker->BindToObject(pBindCtx, 0, IID_IBaseFilter, (void**)ppBF)) || !*ppBF) {
+ if (FAILED(pMoniker->BindToObject(pBindCtx, 0, IID_IBaseFilter, (void**)ppBF)) || !*ppBF) {
return false;
}
CComPtr<IPropertyBag> pPB;
CComVariant var;
- if(SUCCEEDED(pMoniker->BindToStorage(pBindCtx, 0, IID_IPropertyBag, (void**)&pPB))
+ if (SUCCEEDED(pMoniker->BindToStorage(pBindCtx, 0, IID_IPropertyBag, (void**)&pPB))
&& SUCCEEDED(pPB->Read(CComBSTR(_T("FriendlyName")), &var, NULL))) {
FriendlyName = var.bstrVal;
}
@@ -1336,13 +1336,13 @@ bool CreateFilter(CStringW DisplayName, IBaseFilter** ppBF, CStringW& FriendlyNa IBaseFilter* AppendFilter(IPin* pPin, IMoniker* pMoniker, IGraphBuilder* pGB)
{
do {
- if(!pPin || !pMoniker || !pGB) {
+ if (!pPin || !pMoniker || !pGB) {
break;
}
CComPtr<IPin> pPinTo;
PIN_DIRECTION dir;
- if(FAILED(pPin->QueryDirection(&dir)) || dir != PINDIR_OUTPUT || SUCCEEDED(pPin->ConnectedTo(&pPinTo))) {
+ if (FAILED(pPin->QueryDirection(&dir)) || dir != PINDIR_OUTPUT || SUCCEEDED(pPin->ConnectedTo(&pPinTo))) {
break;
}
@@ -1350,38 +1350,38 @@ IBaseFilter* AppendFilter(IPin* pPin, IMoniker* pMoniker, IGraphBuilder* pGB) CreateBindCtx(0, &pBindCtx);
CComPtr<IPropertyBag> pPB;
- if(FAILED(pMoniker->BindToStorage(pBindCtx, 0, IID_IPropertyBag, (void**)&pPB))) {
+ if (FAILED(pMoniker->BindToStorage(pBindCtx, 0, IID_IPropertyBag, (void**)&pPB))) {
break;
}
CComVariant var;
- if(FAILED(pPB->Read(CComBSTR(_T("FriendlyName")), &var, NULL))) {
+ if (FAILED(pPB->Read(CComBSTR(_T("FriendlyName")), &var, NULL))) {
break;
}
CComPtr<IBaseFilter> pBF;
- if(FAILED(pMoniker->BindToObject(pBindCtx, 0, IID_IBaseFilter, (void**)&pBF)) || !pBF) {
+ if (FAILED(pMoniker->BindToObject(pBindCtx, 0, IID_IBaseFilter, (void**)&pBF)) || !pBF) {
break;
}
- if(FAILED(pGB->AddFilter(pBF, CStringW(var.bstrVal)))) {
+ if (FAILED(pGB->AddFilter(pBF, CStringW(var.bstrVal)))) {
break;
}
BeginEnumPins(pBF, pEP, pPinTo) {
PIN_DIRECTION dir;
- if(FAILED(pPinTo->QueryDirection(&dir)) || dir != PINDIR_INPUT) {
+ if (FAILED(pPinTo->QueryDirection(&dir)) || dir != PINDIR_INPUT) {
continue;
}
- if(SUCCEEDED(pGB->ConnectDirect(pPin, pPinTo, NULL))) {
+ if (SUCCEEDED(pGB->ConnectDirect(pPin, pPinTo, NULL))) {
return(pBF);
}
}
EndEnumFilters
pGB->RemoveFilter(pBF);
- } while(false);
+ } while (false);
return(NULL);
}
@@ -1395,13 +1395,13 @@ CStringW GetFriendlyName(CStringW DisplayName) CComPtr<IMoniker> pMoniker;
ULONG chEaten;
- if(S_OK != MkParseDisplayName(pBindCtx, CComBSTR(DisplayName), &chEaten, &pMoniker)) {
+ if (S_OK != MkParseDisplayName(pBindCtx, CComBSTR(DisplayName), &chEaten, &pMoniker)) {
return false;
}
CComPtr<IPropertyBag> pPB;
CComVariant var;
- if(SUCCEEDED(pMoniker->BindToStorage(pBindCtx, 0, IID_IPropertyBag, (void**)&pPB))
+ if (SUCCEEDED(pMoniker->BindToStorage(pBindCtx, 0, IID_IPropertyBag, (void**)&pPB))
&& SUCCEEDED(pPB->Read(CComBSTR(_T("FriendlyName")), &var, NULL))) {
FriendlyName = var.bstrVal;
}
@@ -1427,9 +1427,9 @@ HRESULT LoadExternalObject(LPCTSTR path, REFCLSID clsid, REFIID iid, void** ppv) bool fFound = false;
POSITION pos = s_extobjs.GetHeadPosition();
- while(pos) {
+ while (pos) {
ExternalObject& eo = s_extobjs.GetNext(pos);
- if(!eo.path.CompareNoCase(fullpath)) {
+ if (!eo.path.CompareNoCase(fullpath)) {
hInst = eo.hInst;
fFound = true;
break;
@@ -1438,27 +1438,27 @@ HRESULT LoadExternalObject(LPCTSTR path, REFCLSID clsid, REFIID iid, void** ppv) HRESULT hr = E_FAIL;
- if(!hInst) {
+ if (!hInst) {
hInst = CoLoadLibrary(CComBSTR(fullpath), TRUE);
}
- if(hInst) {
+ if (hInst) {
typedef HRESULT (__stdcall * PDllGetClassObject)(REFCLSID rclsid, REFIID riid, LPVOID* ppv);
PDllGetClassObject p = (PDllGetClassObject)GetProcAddress(hInst, "DllGetClassObject");
- if(p && FAILED(hr = p(clsid, iid, ppv))) {
+ if (p && FAILED(hr = p(clsid, iid, ppv))) {
CComPtr<IClassFactory> pCF;
- if(SUCCEEDED(hr = p(clsid, __uuidof(IClassFactory), (void**)&pCF))) {
+ if (SUCCEEDED(hr = p(clsid, __uuidof(IClassFactory), (void**)&pCF))) {
hr = pCF->CreateInstance(NULL, iid, ppv);
}
}
}
- if(FAILED(hr) && hInst && !fFound) {
+ if (FAILED(hr) && hInst && !fFound) {
CoFreeLibrary(hInst);
return hr;
}
- if(hInst && !fFound) {
+ if (hInst && !fFound) {
ExternalObject eo;
eo.path = fullpath;
eo.hInst = hInst;
@@ -1477,14 +1477,14 @@ HRESULT LoadExternalFilter(LPCTSTR path, REFCLSID clsid, IBaseFilter** ppBF) HRESULT LoadExternalPropertyPage(IPersist* pP, REFCLSID clsid, IPropertyPage** ppPP)
{
CLSID clsid2 = GUID_NULL;
- if(FAILED(pP->GetClassID(&clsid2))) {
+ if (FAILED(pP->GetClassID(&clsid2))) {
return E_FAIL;
}
POSITION pos = s_extobjs.GetHeadPosition();
- while(pos) {
+ while (pos) {
ExternalObject& eo = s_extobjs.GetNext(pos);
- if(eo.clsid == clsid2) {
+ if (eo.clsid == clsid2) {
return LoadExternalObject(eo.path, clsid, __uuidof(IPropertyPage), (void**)ppPP);
}
}
@@ -1495,7 +1495,7 @@ HRESULT LoadExternalPropertyPage(IPersist* pP, REFCLSID clsid, IPropertyPage** p void UnloadExternalObjects()
{
POSITION pos = s_extobjs.GetHeadPosition();
- while(pos) {
+ while (pos) {
ExternalObject& eo = s_extobjs.GetNext(pos);
CoFreeLibrary(eo.hInst);
}
@@ -1511,10 +1511,10 @@ CString MakeFullPath(LPCTSTR path) fn.ReleaseBuffer(GetModuleFileName(AfxGetInstanceHandle(), fn.GetBuffer(MAX_PATH), MAX_PATH));
CPath p(fn);
- if(full.GetLength() >= 2 && full[0] == '\\' && full[1] != '\\') {
+ if (full.GetLength() >= 2 && full[0] == '\\' && full[1] != '\\') {
p.StripToRoot();
full = CString(p) + full.Mid(1);
- } else if(full.Find(_T(":\\")) < 0) {
+ } else if (full.Find(_T(":\\")) < 0) {
p.RemoveFileSpec();
p.AddBackslash();
full = CString(p) + full;
@@ -1533,15 +1533,15 @@ CString GetMediaTypeName(const GUID& guid) ? _T("Any type")
: CString(GuidNames[guid]);
- if(ret == _T("FOURCC GUID")) {
+ if (ret == _T("FOURCC GUID")) {
CString str;
- if(guid.Data1 >= 0x10000) {
+ if (guid.Data1 >= 0x10000) {
str.Format(_T("Video: %c%c%c%c"), (guid.Data1>>0)&0xff, (guid.Data1>>8)&0xff, (guid.Data1>>16)&0xff, (guid.Data1>>24)&0xff);
} else {
str.Format(_T("Audio: 0x%08x"), guid.Data1);
}
ret = str;
- } else if(ret == _T("Unknown GUID Name")) {
+ } else if (ret == _T("Unknown GUID Name")) {
WCHAR null[128] = {0}, buff[128];
StringFromGUID2(GUID_NULL, null, 127);
ret = CString(CStringW(StringFromGUID2(guid, buff, 127) ? buff : null));
@@ -1576,7 +1576,7 @@ CStringW UTF8To16(LPCSTR utf8) {
CStringW str;
int n = MultiByteToWideChar(CP_UTF8, 0, utf8, -1, NULL, 0)-1;
- if(n < 0) {
+ if (n < 0) {
return str;
}
str.ReleaseBuffer(MultiByteToWideChar(CP_UTF8, 0, utf8, -1, str.GetBuffer(n), n+1)-1);
@@ -1587,7 +1587,7 @@ CStringA UTF16To8(LPCWSTR utf16) {
CStringA str;
int n = WideCharToMultiByte(CP_UTF8, 0, utf16, -1, NULL, 0, NULL, NULL)-1;
- if(n < 0) {
+ if (n < 0) {
return str;
}
str.ReleaseBuffer(WideCharToMultiByte(CP_UTF8, 0, utf16, -1, str.GetBuffer(n), n+1, NULL, NULL)-1);
@@ -2135,11 +2135,11 @@ CString ISO6391ToLanguage(LPCSTR code) strncpy_s(tmp, code, 2);
tmp[2] = 0;
_strlwr_s(tmp);
- for(ptrdiff_t i = 0, j = countof(s_isolangs); i < j; i++)
- if(!strcmp(s_isolangs[i].iso6391, tmp)) {
+ for (ptrdiff_t i = 0, j = countof(s_isolangs); i < j; i++)
+ if (!strcmp(s_isolangs[i].iso6391, tmp)) {
CString ret = CString(CStringA(s_isolangs[i].name));
int i = ret.Find(';');
- if(i > 0) {
+ if (i > 0) {
ret = ret.Left(i);
}
return ret;
@@ -2153,11 +2153,11 @@ CString ISO6392ToLanguage(LPCSTR code) strncpy_s(tmp, code, 3);
tmp[3] = 0;
_strlwr_s(tmp);
- for(ptrdiff_t i = 0, j = countof(s_isolangs); i < j; i++) {
- if(!strcmp(s_isolangs[i].iso6392, tmp)) {
+ for (ptrdiff_t i = 0, j = countof(s_isolangs); i < j; i++) {
+ if (!strcmp(s_isolangs[i].iso6392, tmp)) {
CString ret = CString(CStringA(s_isolangs[i].name));
int i = ret.Find(';');
- if(i > 0) {
+ if (i > 0) {
ret = ret.Left(i);
}
return ret;
@@ -2172,8 +2172,8 @@ LCID ISO6391ToLcid(LPCSTR code) strncpy_s(tmp, code, 3);
tmp[3] = 0;
_strlwr_s(tmp);
- for(ptrdiff_t i = 0, j = countof(s_isolangs); i < j; i++) {
- if(!strcmp(s_isolangs[i].iso6391, code)) {
+ for (ptrdiff_t i = 0, j = countof(s_isolangs); i < j; i++) {
+ if (!strcmp(s_isolangs[i].iso6391, code)) {
return s_isolangs[i].lcid;
}
}
@@ -2186,8 +2186,8 @@ LCID ISO6392ToLcid(LPCSTR code) strncpy_s(tmp, code, 3);
tmp[3] = 0;
_strlwr_s(tmp);
- for(ptrdiff_t i = 0, j = countof(s_isolangs); i < j; i++) {
- if(!strcmp(s_isolangs[i].iso6392, tmp)) {
+ for (ptrdiff_t i = 0, j = countof(s_isolangs); i < j; i++) {
+ if (!strcmp(s_isolangs[i].iso6392, tmp)) {
return s_isolangs[i].lcid;
}
}
@@ -2200,8 +2200,8 @@ CString ISO6391To6392(LPCSTR code) strncpy_s(tmp, code, 2);
tmp[2] = 0;
_strlwr_s(tmp);
- for(ptrdiff_t i = 0, j = countof(s_isolangs); i < j; i++)
- if(!strcmp(s_isolangs[i].iso6391, tmp)) {
+ for (ptrdiff_t i = 0, j = countof(s_isolangs); i < j; i++)
+ if (!strcmp(s_isolangs[i].iso6391, tmp)) {
return CString(CStringA(s_isolangs[i].iso6392));
}
return _T("");
@@ -2213,8 +2213,8 @@ CString ISO6392To6391(LPCSTR code) strncpy_s(tmp, code, 3);
tmp[3] = 0;
_strlwr_s(tmp);
- for(ptrdiff_t i = 0, j = countof(s_isolangs); i < j; i++)
- if(!strcmp(s_isolangs[i].iso6392, tmp)) {
+ for (ptrdiff_t i = 0, j = countof(s_isolangs); i < j; i++)
+ if (!strcmp(s_isolangs[i].iso6392, tmp)) {
return CString(CStringA(s_isolangs[i].iso6391));
}
return _T("");
@@ -2224,12 +2224,12 @@ CString LanguageToISO6392(LPCTSTR lang) {
CString str = lang;
str.MakeLower();
- for(ptrdiff_t i = 0, j = countof(s_isolangs); i < j; i++) {
+ for (ptrdiff_t i = 0, j = countof(s_isolangs); i < j; i++) {
CAtlList<CString> sl;
Explode(CString(s_isolangs[i].name), sl, ';');
POSITION pos = sl.GetHeadPosition();
- while(pos) {
- if(!str.CompareNoCase(sl.GetNext(pos))) {
+ while (pos) {
+ if (!str.CompareNoCase(sl.GetNext(pos))) {
return CString(s_isolangs[i].iso6392);
}
}
@@ -2241,27 +2241,27 @@ int MakeAACInitData(BYTE* pData, int profile, int freq, int channels) {
int srate_idx;
- if(92017 <= freq) {
+ if (92017 <= freq) {
srate_idx = 0;
- } else if(75132 <= freq) {
+ } else if (75132 <= freq) {
srate_idx = 1;
- } else if(55426 <= freq) {
+ } else if (55426 <= freq) {
srate_idx = 2;
- } else if(46009 <= freq) {
+ } else if (46009 <= freq) {
srate_idx = 3;
- } else if(37566 <= freq) {
+ } else if (37566 <= freq) {
srate_idx = 4;
- } else if(27713 <= freq) {
+ } else if (27713 <= freq) {
srate_idx = 5;
- } else if(23004 <= freq) {
+ } else if (23004 <= freq) {
srate_idx = 6;
- } else if(18783 <= freq) {
+ } else if (18783 <= freq) {
srate_idx = 7;
- } else if(13856 <= freq) {
+ } else if (13856 <= freq) {
srate_idx = 8;
- } else if(11502 <= freq) {
+ } else if (11502 <= freq) {
srate_idx = 9;
- } else if(9391 <= freq) {
+ } else if (9391 <= freq) {
srate_idx = 10;
} else {
srate_idx = 11;
@@ -2272,30 +2272,30 @@ int MakeAACInitData(BYTE* pData, int profile, int freq, int channels) int ret = 2;
- if(profile < 0) {
+ if (profile < 0) {
freq *= 2;
- if(92017 <= freq) {
+ if (92017 <= freq) {
srate_idx = 0;
- } else if(75132 <= freq) {
+ } else if (75132 <= freq) {
srate_idx = 1;
- } else if(55426 <= freq) {
+ } else if (55426 <= freq) {
srate_idx = 2;
- } else if(46009 <= freq) {
+ } else if (46009 <= freq) {
srate_idx = 3;
- } else if(37566 <= freq) {
+ } else if (37566 <= freq) {
srate_idx = 4;
- } else if(27713 <= freq) {
+ } else if (27713 <= freq) {
srate_idx = 5;
- } else if(23004 <= freq) {
+ } else if (23004 <= freq) {
srate_idx = 6;
- } else if(18783 <= freq) {
+ } else if (18783 <= freq) {
srate_idx = 7;
- } else if(13856 <= freq) {
+ } else if (13856 <= freq) {
srate_idx = 8;
- } else if(11502 <= freq) {
+ } else if (11502 <= freq) {
srate_idx = 9;
- } else if(9391 <= freq) {
+ } else if (9391 <= freq) {
srate_idx = 10;
} else {
srate_idx = 11;
@@ -2315,7 +2315,7 @@ BOOL CFileGetStatus(LPCTSTR lpszFileName, CFileStatus& status) {
try {
return CFile::GetStatus(lpszFileName, status);
- } catch(CException* e) {
+ } catch (CException* e) {
// MFCBUG: E_INVALIDARG / "Parameter is incorrect" is thrown for certain cds (vs2003)
// http://groups.google.co.uk/groups?hl=en&lr=&ie=UTF-8&threadm=OZuXYRzWDHA.536%40TK2MSFTNGP10.phx.gbl&rnum=1&prev=/groups%3Fhl%3Den%26lr%3D%26ie%3DISO-8859-1
TRACE(_T("CFile::GetStatus has thrown an exception\n"));
@@ -2332,8 +2332,8 @@ bool DeleteRegKey(LPCTSTR pszKey, LPCTSTR pszSubkey) HKEY hKey;
LONG ec = ::RegOpenKeyEx(HKEY_CLASSES_ROOT, pszKey, 0, KEY_ALL_ACCESS, &hKey);
- if(ec == ERROR_SUCCESS) {
- if(pszSubkey != 0) {
+ if (ec == ERROR_SUCCESS) {
+ if (pszSubkey != 0) {
ec = ::RegDeleteKey(hKey, pszSubkey);
}
@@ -2350,14 +2350,14 @@ bool SetRegKeyValue(LPCTSTR pszKey, LPCTSTR pszSubkey, LPCTSTR pszValueName, LPC bool bOK = false;
CString szKey(pszKey);
- if(pszSubkey != 0) {
+ if (pszSubkey != 0) {
szKey += CString(_T("\\")) + pszSubkey;
}
HKEY hKey;
LONG ec = ::RegCreateKeyEx(HKEY_CLASSES_ROOT, szKey, 0, 0, REG_OPTION_NON_VOLATILE, KEY_ALL_ACCESS, 0, &hKey, 0);
- if(ec == ERROR_SUCCESS) {
- if(pszValue != 0) {
+ if (ec == ERROR_SUCCESS) {
+ if (pszValue != 0) {
ec = ::RegSetValueEx(hKey, pszValueName, 0, REG_SZ,
reinterpret_cast<BYTE*>(const_cast<LPTSTR>(pszValue)),
(_tcslen(pszValue) + 1) * sizeof(TCHAR));
@@ -2389,7 +2389,7 @@ void RegisterSourceFilter(const CLSID& clsid, const GUID& subtype2, LPCTSTR chkb va_list marker;
va_start(marker, ext);
- for(; ext; ext = va_arg(marker, LPCTSTR)) {
+ for (; ext; ext = va_arg(marker, LPCTSTR)) {
DeleteRegKey(_T("Media Type\\Extensions"), ext);
}
va_end(marker);
@@ -2402,7 +2402,7 @@ void RegisterSourceFilter(const CLSID& clsid, const GUID& subtype2, const CAtlLi CString subtype = CStringFromGUID(subtype2);
POSITION pos = chkbytes.GetHeadPosition();
- for(ptrdiff_t i = 0; pos; i++) {
+ for (ptrdiff_t i = 0; pos; i++) {
CString idx;
idx.Format(_T("%d"), i);
SetRegKeyValue(_T("Media Type\\") + majortype, subtype, idx, chkbytes.GetNext(pos));
@@ -2414,7 +2414,7 @@ void RegisterSourceFilter(const CLSID& clsid, const GUID& subtype2, const CAtlLi va_list marker;
va_start(marker, ext);
- for(; ext; ext = va_arg(marker, LPCTSTR)) {
+ for (; ext; ext = va_arg(marker, LPCTSTR)) {
DeleteRegKey(_T("Media Type\\Extensions"), ext);
}
va_end(marker);
@@ -2487,7 +2487,8 @@ static const DXVA2_DECODER DXVA2Decoder[] = { {&DXVA2_NoEncrypt, _T("No encryption")},
{&DXVA2_VideoProcProgressiveDevice, _T("Progressive scan")},
{&DXVA2_VideoProcBobDevice, _T("Bob deinterlacing")},
- {&DXVA2_VideoProcSoftwareDevice, _T("Software processing")}};
+ {&DXVA2_VideoProcSoftwareDevice, _T("Software processing")}
+};
LPCTSTR GetDXVAMode(const GUID* guidDecoder)
{
@@ -2735,13 +2736,13 @@ void SetThreadName( DWORD dwThreadID, LPCSTR szThreadName) __try {
RaiseException( 0x406D1388, 0, sizeof(info)/sizeof(DWORD), (ULONG_PTR*)&info );
}
- __except(EXCEPTION_CONTINUE_EXECUTION) {
+ __except (EXCEPTION_CONTINUE_EXECUTION) {
}
}
void HexDump(CString fileName, BYTE* buf, int size)
{
- if(size<=0) {
+ if (size<=0) {
return;
}
@@ -2749,13 +2750,13 @@ void HexDump(CString fileName, BYTE* buf, int size) dump_str.Format(_T("Dump size = %d\n"), size);
int len, i, j, c;
- for(i=0; i<size; i+=16) {
+ for (i=0; i<size; i+=16) {
len = size - i;
if (len > 16) {
len = 16;
}
dump_str.AppendFormat(_T("%08x "), i);
- for(j=0; j<16; j++) {
+ for (j=0; j<16; j++) {
if (j < len) {
dump_str.AppendFormat(_T(" %02x"), buf[i+j]);
}
@@ -2764,7 +2765,7 @@ void HexDump(CString fileName, BYTE* buf, int size) }
}
dump_str.Append(_T(" "));
- for(j=0; j<len; j++) {
+ for (j=0; j<len; j++) {
c = buf[i+j];
if (c < ' ' || c > '~') {
c = '.';
@@ -2775,9 +2776,9 @@ void HexDump(CString fileName, BYTE* buf, int size) }
dump_str.Append(_T("\n"));
- if(!fileName.IsEmpty()) {
+ if (!fileName.IsEmpty()) {
CStdioFile file;
- if(file.Open(fileName, CFile::modeCreate|CFile::modeWrite)) {
+ if (file.Open(fileName, CFile::modeCreate|CFile::modeWrite)) {
file.WriteString(dump_str);
file.Close();
}
@@ -2791,42 +2792,42 @@ DWORD GetDefChannelMask(WORD nChannels) {
switch (nChannels) {
case 1: // 1.0 Mono
- return SPEAKER_FRONT_CENTER;
+ return SPEAKER_FRONT_CENTER;
case 2: // 2.0 Stereo
- return SPEAKER_FRONT_LEFT | SPEAKER_FRONT_RIGHT;
+ return SPEAKER_FRONT_LEFT | SPEAKER_FRONT_RIGHT;
case 3: // 2.1 Stereo
- return SPEAKER_FRONT_LEFT | SPEAKER_FRONT_RIGHT | SPEAKER_LOW_FREQUENCY;
+ return SPEAKER_FRONT_LEFT | SPEAKER_FRONT_RIGHT | SPEAKER_LOW_FREQUENCY;
case 4: // 4.0 Quad
- return SPEAKER_FRONT_LEFT | SPEAKER_FRONT_RIGHT
- | SPEAKER_BACK_LEFT | SPEAKER_BACK_RIGHT;
+ return SPEAKER_FRONT_LEFT | SPEAKER_FRONT_RIGHT
+ | SPEAKER_BACK_LEFT | SPEAKER_BACK_RIGHT;
case 5: // 4.1
- return SPEAKER_FRONT_LEFT | SPEAKER_FRONT_RIGHT | SPEAKER_LOW_FREQUENCY
- | SPEAKER_BACK_LEFT | SPEAKER_BACK_RIGHT;
+ return SPEAKER_FRONT_LEFT | SPEAKER_FRONT_RIGHT | SPEAKER_LOW_FREQUENCY
+ | SPEAKER_BACK_LEFT | SPEAKER_BACK_RIGHT;
case 6: // 5.1 Side (KSAUDIO_SPEAKER_5POINT1_SURROUND)
- return SPEAKER_FRONT_LEFT | SPEAKER_FRONT_RIGHT | SPEAKER_FRONT_CENTER
- | SPEAKER_LOW_FREQUENCY | SPEAKER_SIDE_LEFT | SPEAKER_SIDE_RIGHT;
+ return SPEAKER_FRONT_LEFT | SPEAKER_FRONT_RIGHT | SPEAKER_FRONT_CENTER
+ | SPEAKER_LOW_FREQUENCY | SPEAKER_SIDE_LEFT | SPEAKER_SIDE_RIGHT;
case 7: // 6.1 Side
- return SPEAKER_FRONT_LEFT | SPEAKER_FRONT_RIGHT | SPEAKER_FRONT_CENTER
- | SPEAKER_LOW_FREQUENCY | SPEAKER_SIDE_LEFT | SPEAKER_SIDE_RIGHT
- | SPEAKER_BACK_CENTER;
+ return SPEAKER_FRONT_LEFT | SPEAKER_FRONT_RIGHT | SPEAKER_FRONT_CENTER
+ | SPEAKER_LOW_FREQUENCY | SPEAKER_SIDE_LEFT | SPEAKER_SIDE_RIGHT
+ | SPEAKER_BACK_CENTER;
case 8: // 7.1 Surround (KSAUDIO_SPEAKER_7POINT1_SURROUND)
- return SPEAKER_FRONT_LEFT | SPEAKER_FRONT_RIGHT | SPEAKER_FRONT_CENTER
- | SPEAKER_LOW_FREQUENCY | SPEAKER_BACK_LEFT | SPEAKER_BACK_RIGHT
- | SPEAKER_SIDE_LEFT | SPEAKER_SIDE_RIGHT;
+ return SPEAKER_FRONT_LEFT | SPEAKER_FRONT_RIGHT | SPEAKER_FRONT_CENTER
+ | SPEAKER_LOW_FREQUENCY | SPEAKER_BACK_LEFT | SPEAKER_BACK_RIGHT
+ | SPEAKER_SIDE_LEFT | SPEAKER_SIDE_RIGHT;
case 10: // 9.1 Surround
- return SPEAKER_FRONT_LEFT | SPEAKER_FRONT_RIGHT | SPEAKER_FRONT_CENTER
- | SPEAKER_LOW_FREQUENCY | SPEAKER_BACK_LEFT | SPEAKER_BACK_RIGHT
- | SPEAKER_SIDE_LEFT | SPEAKER_SIDE_RIGHT
- | SPEAKER_TOP_FRONT_LEFT | SPEAKER_TOP_FRONT_RIGHT;
+ return SPEAKER_FRONT_LEFT | SPEAKER_FRONT_RIGHT | SPEAKER_FRONT_CENTER
+ | SPEAKER_LOW_FREQUENCY | SPEAKER_BACK_LEFT | SPEAKER_BACK_RIGHT
+ | SPEAKER_SIDE_LEFT | SPEAKER_SIDE_RIGHT
+ | SPEAKER_TOP_FRONT_LEFT | SPEAKER_TOP_FRONT_RIGHT;
default:
- return 0;
+ return 0;
}
}
void CorrectComboListWidth(CComboBox& m_pComboBox)
{
// Find the longest string in the combo box.
- if(m_pComboBox.GetCount() <=0 )
+ if (m_pComboBox.GetCount() <=0 )
return;
CString str;
@@ -2843,14 +2844,14 @@ void CorrectComboListWidth(CComboBox& m_pComboBox) for (int i = 0; i < m_pComboBox.GetCount(); i++)
{
- m_pComboBox.GetLBText(i, str);
- sz = pDC->GetTextExtent(str);
+ m_pComboBox.GetLBText(i, str);
+ sz = pDC->GetTextExtent(str);
- // Add the avg width to prevent clipping
- sz.cx += tm.tmAveCharWidth;
+ // Add the avg width to prevent clipping
+ sz.cx += tm.tmAveCharWidth;
- if (sz.cx > dx)
- dx = sz.cx;
+ if (sz.cx > dx)
+ dx = sz.cx;
}
// Select the old font back into the DC
pDC->SelectObject(pOldFont);
@@ -2865,88 +2866,88 @@ void CorrectComboListWidth(CComboBox& m_pComboBox) unsigned int lav_xiphlacing(unsigned char *s, unsigned int v)
{
- unsigned int n = 0;
+ unsigned int n = 0;
- while(v >= 0xff) {
- *s++ = 0xff;
- v -= 0xff;
- n++;
- }
- *s = v;
- n++;
- return n;
+ while (v >= 0xff) {
+ *s++ = 0xff;
+ v -= 0xff;
+ n++;
+ }
+ *s = v;
+ n++;
+ return n;
}
void getExtraData(const BYTE *format, const GUID *formattype, const size_t formatlen, BYTE *extra, unsigned int *extralen)
{
- const BYTE *extraposition = NULL;
- unsigned extralength = 0;
- if (*formattype == FORMAT_WaveFormatEx) {
- WAVEFORMATEX *wfex = (WAVEFORMATEX *)format;
- extraposition = format + sizeof(WAVEFORMATEX);
- // Protected against over-reads
- extralength = formatlen - sizeof(WAVEFORMATEX);
- } else if (*formattype == FORMAT_VorbisFormat2) {
- VORBISFORMAT2 *vf2 = (VORBISFORMAT2 *)format;
- BYTE *start = NULL, *end = NULL;
- unsigned offset = 1;
- if (extra) {
- *extra = 2;
- offset += lav_xiphlacing(extra+offset, vf2->HeaderSize[0]);
- offset += lav_xiphlacing(extra+offset, vf2->HeaderSize[1]);
- extra += offset;
- } else {
- BYTE dummy[100];
- offset += lav_xiphlacing(dummy, vf2->HeaderSize[0]);
- offset += lav_xiphlacing(dummy, vf2->HeaderSize[1]);
- }
- extralength = vf2->HeaderSize[0] + vf2->HeaderSize[1] + vf2->HeaderSize[2];
- extralength = min(extralength, formatlen - sizeof(VORBISFORMAT2));
-
- if (extra && extralength)
- memcpy(extra, format + sizeof(VORBISFORMAT2), extralength);
- if (extralen)
- *extralen = extralength + offset;
-
- return;
- }
-
- if (extra && extralength)
- memcpy(extra, extraposition, extralength);
- if (extralen)
- *extralen = extralength;
+ const BYTE *extraposition = NULL;
+ unsigned extralength = 0;
+ if (*formattype == FORMAT_WaveFormatEx) {
+ WAVEFORMATEX *wfex = (WAVEFORMATEX *)format;
+ extraposition = format + sizeof(WAVEFORMATEX);
+ // Protected against over-reads
+ extralength = formatlen - sizeof(WAVEFORMATEX);
+ } else if (*formattype == FORMAT_VorbisFormat2) {
+ VORBISFORMAT2 *vf2 = (VORBISFORMAT2 *)format;
+ BYTE *start = NULL, *end = NULL;
+ unsigned offset = 1;
+ if (extra) {
+ *extra = 2;
+ offset += lav_xiphlacing(extra+offset, vf2->HeaderSize[0]);
+ offset += lav_xiphlacing(extra+offset, vf2->HeaderSize[1]);
+ extra += offset;
+ } else {
+ BYTE dummy[100];
+ offset += lav_xiphlacing(dummy, vf2->HeaderSize[0]);
+ offset += lav_xiphlacing(dummy, vf2->HeaderSize[1]);
+ }
+ extralength = vf2->HeaderSize[0] + vf2->HeaderSize[1] + vf2->HeaderSize[2];
+ extralength = min(extralength, formatlen - sizeof(VORBISFORMAT2));
+
+ if (extra && extralength)
+ memcpy(extra, format + sizeof(VORBISFORMAT2), extralength);
+ if (extralen)
+ *extralen = extralength + offset;
+
+ return;
+ }
+
+ if (extra && extralength)
+ memcpy(extra, extraposition, extralength);
+ if (extralen)
+ *extralen = extralength;
}
void audioFormatTypeHandler(const BYTE *format, const GUID *formattype, DWORD *pnSamples, WORD *pnChannels, WORD *pnBitsPerSample, WORD *pnBlockAlign, DWORD *pnBytesPerSec)
{
- DWORD nSamples = 0;
- WORD nChannels = 0;
- WORD nBitsPerSample = 0;
- WORD nBlockAlign = 0;
- DWORD nBytesPerSec = 0;
-
- if (*formattype == FORMAT_WaveFormatEx) {
- WAVEFORMATEX *wfex = (WAVEFORMATEX *)format;
- nSamples = wfex->nSamplesPerSec;
- nChannels = wfex->nChannels;
- nBitsPerSample = wfex->wBitsPerSample;
- nBlockAlign = wfex->nBlockAlign;
- nBytesPerSec = wfex->nAvgBytesPerSec;
- } else if (*formattype == FORMAT_VorbisFormat2) {
- VORBISFORMAT2 *vf2 = (VORBISFORMAT2 *)format;
- nSamples = vf2->SamplesPerSec;
- nChannels = (WORD)vf2->Channels;
- nBitsPerSample = (WORD)vf2->BitsPerSample;
- }
-
- if (pnSamples)
- *pnSamples = nSamples;
- if (pnChannels)
- *pnChannels = nChannels;
- if (pnBitsPerSample)
- *pnBitsPerSample = nBitsPerSample;
- if (pnBlockAlign)
- *pnBlockAlign = nBlockAlign;
- if (pnBytesPerSec)
- *pnBytesPerSec = nBytesPerSec;
+ DWORD nSamples = 0;
+ WORD nChannels = 0;
+ WORD nBitsPerSample = 0;
+ WORD nBlockAlign = 0;
+ DWORD nBytesPerSec = 0;
+
+ if (*formattype == FORMAT_WaveFormatEx) {
+ WAVEFORMATEX *wfex = (WAVEFORMATEX *)format;
+ nSamples = wfex->nSamplesPerSec;
+ nChannels = wfex->nChannels;
+ nBitsPerSample = wfex->wBitsPerSample;
+ nBlockAlign = wfex->nBlockAlign;
+ nBytesPerSec = wfex->nAvgBytesPerSec;
+ } else if (*formattype == FORMAT_VorbisFormat2) {
+ VORBISFORMAT2 *vf2 = (VORBISFORMAT2 *)format;
+ nSamples = vf2->SamplesPerSec;
+ nChannels = (WORD)vf2->Channels;
+ nBitsPerSample = (WORD)vf2->BitsPerSample;
+ }
+
+ if (pnSamples)
+ *pnSamples = nSamples;
+ if (pnChannels)
+ *pnChannels = nChannels;
+ if (pnBitsPerSample)
+ *pnBitsPerSample = nBitsPerSample;
+ if (pnBlockAlign)
+ *pnBlockAlign = nBlockAlign;
+ if (pnBytesPerSec)
+ *pnBytesPerSec = nBytesPerSec;
}
diff --git a/src/DSUtil/DSUtil.h b/src/DSUtil/DSUtil.h index 5834f7755..6f68c7a80 100644 --- a/src/DSUtil/DSUtil.h +++ b/src/DSUtil/DSUtil.h @@ -136,7 +136,7 @@ public: pFilter = NULL;
}
~CPinInfo() {
- if(pFilter) {
+ if (pFilter) {
pFilter->Release();
}
}
@@ -149,7 +149,7 @@ public: pGraph = NULL;
}
~CFilterInfo() {
- if(pGraph) {
+ if (pGraph) {
pGraph->Release();
}
}
@@ -220,7 +220,7 @@ static CUnknown* WINAPI CreateInstance(LPUNKNOWN lpunk, HRESULT* phr) {
*phr = S_OK;
CUnknown* punk = DNew T(lpunk, phr);
- if(punk == NULL) {
+ if (punk == NULL) {
*phr = E_OUTOFMEMORY;
}
return punk;
@@ -232,13 +232,13 @@ static CUnknown* WINAPI CreateInstance(LPUNKNOWN lpunk, HRESULT* phr) inline int LNKO(int a, int b)
{
- if(a == 0 || b == 0) {
+ if (a == 0 || b == 0) {
return(1);
}
- while(a != b) {
- if(a < b) {
+ while (a != b) {
+ if (a < b) {
b -= a;
- } else if(a > b) {
+ } else if (a > b) {
a -= b;
}
}
diff --git a/src/DSUtil/FontInstaller.cpp b/src/DSUtil/FontInstaller.cpp index d32747556..6471795d1 100644 --- a/src/DSUtil/FontInstaller.cpp +++ b/src/DSUtil/FontInstaller.cpp @@ -3,14 +3,14 @@ CFontInstaller::CFontInstaller()
{
- if(HMODULE hGdi = GetModuleHandle(_T("gdi32.dll"))) {
+ if (HMODULE hGdi = GetModuleHandle(_T("gdi32.dll"))) {
pAddFontMemResourceEx = (HANDLE (WINAPI *)(PVOID,DWORD,PVOID,DWORD*))GetProcAddress(hGdi, "AddFontMemResourceEx");
pAddFontResourceEx = (int (WINAPI *)(LPCTSTR,DWORD,PVOID))GetProcAddress(hGdi, "AddFontResourceExW");
pRemoveFontMemResourceEx = (BOOL (WINAPI *)(HANDLE))GetProcAddress(hGdi, "RemoveFontMemResourceEx");
pRemoveFontResourceEx = (BOOL (WINAPI *)(LPCTSTR,DWORD,PVOID))GetProcAddress(hGdi, "RemoveFontResourceExW");
}
- if(HMODULE hGdi = GetModuleHandle(_T("kernel32.dll"))) {
+ if (HMODULE hGdi = GetModuleHandle(_T("kernel32.dll"))) {
pMoveFileEx = (BOOL (WINAPI *)(LPCTSTR, LPCTSTR, DWORD))GetProcAddress(hGdi, "MoveFileExW");
}
}
@@ -32,20 +32,20 @@ bool CFontInstaller::InstallFont(const void* pData, UINT len) void CFontInstaller::UninstallFonts()
{
- if(pRemoveFontMemResourceEx) {
+ if (pRemoveFontMemResourceEx) {
POSITION pos = m_fonts.GetHeadPosition();
- while(pos) {
+ while (pos) {
pRemoveFontMemResourceEx(m_fonts.GetNext(pos));
}
m_fonts.RemoveAll();
}
- if(pRemoveFontResourceEx) {
+ if (pRemoveFontResourceEx) {
POSITION pos = m_files.GetHeadPosition();
- while(pos) {
+ while (pos) {
CString fn = m_files.GetNext(pos);
pRemoveFontResourceEx(fn, FR_PRIVATE, 0);
- if(!DeleteFile(fn) && pMoveFileEx) {
+ if (!DeleteFile(fn) && pMoveFileEx) {
pMoveFileEx(fn, NULL, MOVEFILE_DELAY_UNTIL_REBOOT);
}
}
@@ -56,13 +56,13 @@ void CFontInstaller::UninstallFonts() bool CFontInstaller::InstallFontMemory(const void* pData, UINT len)
{
- if(!pAddFontMemResourceEx) {
+ if (!pAddFontMemResourceEx) {
return false;
}
DWORD nFonts = 0;
HANDLE hFont = pAddFontMemResourceEx((PVOID)pData, len, NULL, &nFonts);
- if(hFont && nFonts > 0) {
+ if (hFont && nFonts > 0) {
m_fonts.AddTail(hFont);
}
return hFont && nFonts > 0;
@@ -70,21 +70,21 @@ bool CFontInstaller::InstallFontMemory(const void* pData, UINT len) bool CFontInstaller::InstallFontFile(const void* pData, UINT len)
{
- if(!pAddFontResourceEx) {
+ if (!pAddFontResourceEx) {
return false;
}
CFile f;
TCHAR path[MAX_PATH], fn[MAX_PATH];
- if(!GetTempPath(MAX_PATH, path) || !GetTempFileName(path, _T("g_font"), 0, fn)) {
+ if (!GetTempPath(MAX_PATH, path) || !GetTempFileName(path, _T("g_font"), 0, fn)) {
return false;
}
- if(f.Open(fn, CFile::modeWrite)) {
+ if (f.Open(fn, CFile::modeWrite)) {
f.Write(pData, len);
f.Close();
- if(pAddFontResourceEx(fn, FR_PRIVATE, 0) > 0) {
+ if (pAddFontResourceEx(fn, FR_PRIVATE, 0) > 0) {
m_files.AddTail(fn);
return true;
}
diff --git a/src/DSUtil/GolombBuffer.cpp b/src/DSUtil/GolombBuffer.cpp index 38a630617..7535285ee 100644 --- a/src/DSUtil/GolombBuffer.cpp +++ b/src/DSUtil/GolombBuffer.cpp @@ -36,7 +36,7 @@ UINT64 CGolombBuffer::BitRead(int nBits, bool fPeek) {
// ASSERT(nBits >= 0 && nBits <= 64);
- while(m_bitlen < nBits) {
+ while (m_bitlen < nBits) {
m_bitbuff <<= 8;
if (m_nBitPos >= m_nSize) {
@@ -51,7 +51,7 @@ UINT64 CGolombBuffer::BitRead(int nBits, bool fPeek) UINT64 ret = (m_bitbuff >> bitlen) & ((1ui64 << nBits) - 1);
- if(!fPeek) {
+ if (!fPeek) {
m_bitbuff &= ((1ui64 << bitlen) - 1);
m_bitlen = bitlen;
}
@@ -62,7 +62,7 @@ UINT64 CGolombBuffer::BitRead(int nBits, bool fPeek) UINT64 CGolombBuffer::UExpGolombRead()
{
int n = -1;
- for(BYTE b = 0; !b; n++) {
+ for (BYTE b = 0; !b; n++) {
b = (BYTE)BitRead(1);
}
return (1ui64 << n) - 1 + BitRead(n);
diff --git a/src/DSUtil/HdmvClipInfo.cpp b/src/DSUtil/HdmvClipInfo.cpp index 1ef21d221..2b695b5da 100644 --- a/src/DSUtil/HdmvClipInfo.cpp +++ b/src/DSUtil/HdmvClipInfo.cpp @@ -169,7 +169,7 @@ HRESULT CHdmvClipInfo::ReadInfo(LPCTSTR strFile) m_hFile = CreateFile(strFile, GENERIC_READ, FILE_SHARE_READ|FILE_SHARE_WRITE, NULL,
OPEN_EXISTING, FILE_ATTRIBUTE_READONLY|FILE_FLAG_SEQUENTIAL_SCAN, NULL);
- if(m_hFile != INVALID_HANDLE_VALUE) {
+ if (m_hFile != INVALID_HANDLE_VALUE) {
ReadBuffer(Buff, 4);
if (memcmp (Buff, "HDMV", 4)) {
return CloseFile(VFW_E_INVALID_FILE_FORMAT);
@@ -264,7 +264,7 @@ HRESULT CHdmvClipInfo::ReadPlaylist(CString strPlaylistFile, REFERENCE_TIME& rtD m_hFile = CreateFile(strPlaylistFile, GENERIC_READ, FILE_SHARE_READ|FILE_SHARE_WRITE, NULL,
OPEN_EXISTING, FILE_ATTRIBUTE_READONLY|FILE_FLAG_SEQUENTIAL_SCAN, NULL);
- if(m_hFile != INVALID_HANDLE_VALUE) {
+ if (m_hFile != INVALID_HANDLE_VALUE) {
ReadBuffer(Buff, 4);
if (memcmp (Buff, "MPLS", 4)) {
return CloseFile(VFW_E_INVALID_FILE_FORMAT);
@@ -339,14 +339,14 @@ HRESULT CHdmvClipInfo::ReadChapters(CString strPlaylistFile, CAtlList<CHdmvClipI m_hFile = CreateFile(strPlaylistFile, GENERIC_READ, FILE_SHARE_READ|FILE_SHARE_WRITE, NULL,
OPEN_EXISTING, FILE_ATTRIBUTE_READONLY|FILE_FLAG_SEQUENTIAL_SCAN, NULL);
- if(m_hFile != INVALID_HANDLE_VALUE)
+ if (m_hFile != INVALID_HANDLE_VALUE)
{
REFERENCE_TIME* rtOffset = new REFERENCE_TIME[PlaylistItems.GetCount()];
REFERENCE_TIME rtSum = 0;
int nIndex = 0;
POSITION pos = PlaylistItems.GetHeadPosition();
- while(pos)
+ while (pos)
{
CHdmvClipInfo::PlaylistItem& PI = PlaylistItems.GetNext(pos);
@@ -414,14 +414,14 @@ HRESULT CHdmvClipInfo::FindMainMovie(LPCTSTR strFolder, CString& strPlaylistFile CAtlList<PlaylistItem> Playlist;
WIN32_FIND_DATA fd = {0};
-
+
strPath.Replace(_T("\\PLAYLIST\\"), _T("\\"));
strPath.Replace(_T("\\STREAM\\"), _T("\\"));
strPath += _T("\\BDMV\\");
strFilter.Format (_T("%sPLAYLIST\\*.mpls"), strPath);
HANDLE hFind = FindFirstFile(strFilter, &fd);
- if(hFind != INVALID_HANDLE_VALUE) {
+ if (hFind != INVALID_HANDLE_VALUE) {
REFERENCE_TIME rtMax = 0;
REFERENCE_TIME rtCurrent;
CString strCurrentPlaylist;
@@ -431,17 +431,17 @@ HRESULT CHdmvClipInfo::FindMainMovie(LPCTSTR strFolder, CString& strPlaylistFile // Main movie shouldn't have duplicate M2TS filename...
if (ReadPlaylist(strCurrentPlaylist, rtCurrent, Playlist) == S_OK) {
- if(rtCurrent > rtMax) {
+ if (rtCurrent > rtMax) {
rtMax = rtCurrent;
strPlaylistFile = strCurrentPlaylist;
MainPlaylist.RemoveAll();
POSITION pos = Playlist.GetHeadPosition();
- while(pos) {
+ while (pos) {
MainPlaylist.AddTail(Playlist.GetNext(pos));
}
hr = S_OK;
}
- if(rtCurrent >= (REFERENCE_TIME)MIN_LIMIT*600000000) {
+ if (rtCurrent >= (REFERENCE_TIME)MIN_LIMIT*600000000) {
PlaylistItem Item;
Item.m_strFileName = strCurrentPlaylist;
Item.m_rtIn = 0;
@@ -450,15 +450,15 @@ HRESULT CHdmvClipInfo::FindMainMovie(LPCTSTR strFolder, CString& strPlaylistFile }
}
- } while(FindNextFile(hFind, &fd));
+ } while (FindNextFile(hFind, &fd));
FindClose(hFind);
}
- if(MPLSPlaylists.GetCount() > 1) {
+ if (MPLSPlaylists.GetCount() > 1) {
// bubble sort
for (size_t j=0; j<MPLSPlaylists.GetCount(); j++) {
- for(size_t i=0; i<MPLSPlaylists.GetCount()-1; i++) {
+ for (size_t i=0; i<MPLSPlaylists.GetCount()-1; i++) {
if (MPLSPlaylists.GetAt(MPLSPlaylists.FindIndex(i)).Duration() < MPLSPlaylists.GetAt(MPLSPlaylists.FindIndex(i+1)).Duration()) {
MPLSPlaylists.SwapElements(MPLSPlaylists.FindIndex(i), MPLSPlaylists.FindIndex(i+1));
}
diff --git a/src/DSUtil/MediaTypeEx.cpp b/src/DSUtil/MediaTypeEx.cpp index e39ce824f..cfb7ba461 100644 --- a/src/DSUtil/MediaTypeEx.cpp +++ b/src/DSUtil/MediaTypeEx.cpp @@ -27,15 +27,15 @@ CString CMediaTypeEx::ToString(IPin* pPin) // TODO
- if(majortype == MEDIATYPE_DVD_ENCRYPTED_PACK) {
+ if (majortype == MEDIATYPE_DVD_ENCRYPTED_PACK) {
packing = _T("Encrypted MPEG2 Pack");
- } else if(majortype == MEDIATYPE_MPEG2_PACK) {
+ } else if (majortype == MEDIATYPE_MPEG2_PACK) {
packing = _T("MPEG2 Pack");
- } else if(majortype == MEDIATYPE_MPEG2_PES) {
+ } else if (majortype == MEDIATYPE_MPEG2_PES) {
packing = _T("MPEG2 PES");
}
- if(majortype == MEDIATYPE_Video) {
+ if (majortype == MEDIATYPE_Video) {
type = _T("Video");
BITMAPINFOHEADER bih;
@@ -44,151 +44,151 @@ CString CMediaTypeEx::ToString(IPin* pPin) int w, h, arx, ary;
bool fDim = ExtractDim(this, w, h, arx, ary);
- if(fBIH && bih.biCompression) {
+ if (fBIH && bih.biCompression) {
codec = GetVideoCodecName(subtype, bih.biCompression);
}
- if(codec.IsEmpty()) {
- if(formattype == FORMAT_MPEGVideo) {
+ if (codec.IsEmpty()) {
+ if (formattype == FORMAT_MPEGVideo) {
codec = _T("MPEG1 Video");
- } else if(formattype == FORMAT_MPEG2_VIDEO) {
+ } else if (formattype == FORMAT_MPEG2_VIDEO) {
codec = _T("MPEG2 Video");
- } else if(formattype == FORMAT_DiracVideoInfo) {
+ } else if (formattype == FORMAT_DiracVideoInfo) {
codec = _T("Dirac Video");
}
}
- if(fDim) {
+ if (fDim) {
dim.Format(_T("%dx%d"), w, h);
- if(w*ary != h*arx) {
+ if (w*ary != h*arx) {
dim.AppendFormat(_T(" (%d:%d)"), arx, ary);
}
}
- if(formattype == FORMAT_VideoInfo || formattype == FORMAT_MPEGVideo) {
+ if (formattype == FORMAT_VideoInfo || formattype == FORMAT_MPEGVideo) {
VIDEOINFOHEADER* vih = (VIDEOINFOHEADER*)pbFormat;
- if(vih->AvgTimePerFrame) {
+ if (vih->AvgTimePerFrame) {
rate.Format(_T("%0.3f"), 10000000.0f / vih->AvgTimePerFrame);
rate.TrimRight(_T('0')); // remove trailing zeros
rate.TrimRight(_T('.')); // remove the trailing dot
rate += _T("fps ");
}
- if(vih->dwBitRate) {
+ if (vih->dwBitRate) {
rate.AppendFormat(_T("%dkbps"), vih->dwBitRate/1000);
}
- } else if(formattype == FORMAT_VideoInfo2 || formattype == FORMAT_MPEG2_VIDEO || formattype == FORMAT_DiracVideoInfo) {
+ } else if (formattype == FORMAT_VideoInfo2 || formattype == FORMAT_MPEG2_VIDEO || formattype == FORMAT_DiracVideoInfo) {
VIDEOINFOHEADER2* vih = (VIDEOINFOHEADER2*)pbFormat;
- if(vih->AvgTimePerFrame) {
+ if (vih->AvgTimePerFrame) {
rate.Format(_T("%0.3f"), 10000000.0f / vih->AvgTimePerFrame);
rate.TrimRight(_T('0')); // remove trailing zeros
rate.TrimRight(_T('.')); // remove the trailing dot
rate += _T("fps ");
}
- if(vih->dwBitRate) {
+ if (vih->dwBitRate) {
rate.AppendFormat(_T("%dkbps"), vih->dwBitRate/1000);
}
}
rate.TrimRight();
- if(subtype == MEDIASUBTYPE_DVD_SUBPICTURE) {
+ if (subtype == MEDIASUBTYPE_DVD_SUBPICTURE) {
type = _T("Subtitle");
codec = _T("DVD Subpicture");
}
- } else if(majortype == MEDIATYPE_Audio) {
+ } else if (majortype == MEDIATYPE_Audio) {
type = _T("Audio");
- if(formattype == FORMAT_WaveFormatEx) {
+ if (formattype == FORMAT_WaveFormatEx) {
WAVEFORMATEX* wfe = (WAVEFORMATEX*)Format();
- if(wfe->wFormatTag/* > WAVE_FORMAT_PCM && wfe->wFormatTag < WAVE_FORMAT_EXTENSIBLE
+ if (wfe->wFormatTag/* > WAVE_FORMAT_PCM && wfe->wFormatTag < WAVE_FORMAT_EXTENSIBLE
&& wfe->wFormatTag != WAVE_FORMAT_IEEE_FLOAT*/
|| subtype != GUID_NULL) {
codec = GetAudioCodecName(subtype, wfe->wFormatTag);
dim.Format(_T("%dHz"), wfe->nSamplesPerSec);
- if(wfe->nChannels == 1) {
+ if (wfe->nChannels == 1) {
dim += _T(" mono");
- } else if(wfe->nChannels == 2) {
+ } else if (wfe->nChannels == 2) {
dim += _T(" stereo");
} else {
dim.AppendFormat(_T(" %dch"), wfe->nChannels);
}
- if(wfe->nAvgBytesPerSec) {
+ if (wfe->nAvgBytesPerSec) {
rate.Format(_T("%dkbps"), wfe->nAvgBytesPerSec*8/1000);
}
}
- } else if(formattype == FORMAT_VorbisFormat) {
+ } else if (formattype == FORMAT_VorbisFormat) {
VORBISFORMAT* vf = (VORBISFORMAT*)Format();
codec = GetAudioCodecName(subtype, 0);
dim.Format(_T("%dHz"), vf->nSamplesPerSec);
- if(vf->nChannels == 1) {
+ if (vf->nChannels == 1) {
dim += _T(" mono");
- } else if(vf->nChannels == 2) {
+ } else if (vf->nChannels == 2) {
dim += _T(" stereo");
} else {
dim.AppendFormat(_T(" %dch"), vf->nChannels);
}
- if(vf->nAvgBitsPerSec) {
+ if (vf->nAvgBitsPerSec) {
rate.Format(_T("%dkbps"), vf->nAvgBitsPerSec/1000);
}
- } else if(formattype == FORMAT_VorbisFormat2) {
+ } else if (formattype == FORMAT_VorbisFormat2) {
VORBISFORMAT2* vf = (VORBISFORMAT2*)Format();
codec = GetAudioCodecName(subtype, 0);
dim.Format(_T("%dHz"), vf->SamplesPerSec);
- if(vf->Channels == 1) {
+ if (vf->Channels == 1) {
dim += _T(" mono");
- } else if(vf->Channels == 2) {
+ } else if (vf->Channels == 2) {
dim += _T(" stereo");
} else {
dim.AppendFormat(_T(" %dch"), vf->Channels);
}
}
- } else if(majortype == MEDIATYPE_Text) {
+ } else if (majortype == MEDIATYPE_Text) {
type = _T("Text");
- } else if(majortype == MEDIATYPE_Subtitle) {
+ } else if (majortype == MEDIATYPE_Subtitle) {
type = _T("Subtitle");
codec = GetSubtitleCodecName(subtype);
} else {
type = _T("Unknown");
}
- if(CComQIPtr<IMediaSeeking> pMS = pPin) {
+ if (CComQIPtr<IMediaSeeking> pMS = pPin) {
REFERENCE_TIME rtDur = 0;
- if(SUCCEEDED(pMS->GetDuration(&rtDur)) && rtDur) {
+ if (SUCCEEDED(pMS->GetDuration(&rtDur)) && rtDur) {
rtDur /= 10000000;
int s = rtDur%60;
rtDur /= 60;
int m = rtDur%60;
rtDur /= 60;
int h = (int)rtDur;
- if(h) {
+ if (h) {
dur.Format(_T("%d:%02d:%02d"), h, m, s);
- } else if(m) {
+ } else if (m) {
dur.Format(_T("%02d:%02d"), m, s);
- } else if(s) {
+ } else if (s) {
dur.Format(_T("%ds"), s);
}
}
}
CString str;
- if(!codec.IsEmpty()) {
+ if (!codec.IsEmpty()) {
str += codec + _T(" ");
}
- if(!dim.IsEmpty()) {
+ if (!dim.IsEmpty()) {
str += dim + _T(" ");
}
- if(!rate.IsEmpty()) {
+ if (!rate.IsEmpty()) {
str += rate + _T(" ");
}
- if(!dur.IsEmpty()) {
+ if (!dur.IsEmpty()) {
str += dur + _T(" ");
}
str.Trim(_T(" ,"));
- if(!str.IsEmpty()) {
+ if (!str.IsEmpty()) {
str = type + _T(": ") + str;
} else {
str = type;
@@ -203,7 +203,7 @@ CString CMediaTypeEx::GetVideoCodecName(const GUID& subtype, DWORD biCompression static CAtlMap<DWORD, CString> names;
- if(names.IsEmpty()) {
+ if (names.IsEmpty()) {
names['WMV1'] = _T("Windows Media Video 7");
names['WMV2'] = _T("Windows Media Video 8");
names['WMV3'] = _T("Windows Media Video 9");
@@ -231,20 +231,20 @@ CString CMediaTypeEx::GetVideoCodecName(const GUID& subtype, DWORD biCompression // names[''] = _T("");
}
- if(biCompression) {
+ if (biCompression) {
BYTE* b = (BYTE*)&biCompression;
- for(ptrdiff_t i = 0; i < 4; i++)
- if(b[i] >= 'a' && b[i] <= 'z') {
+ for (ptrdiff_t i = 0; i < 4; i++)
+ if (b[i] >= 'a' && b[i] <= 'z') {
b[i] = toupper(b[i]);
}
- if(!names.Lookup(MAKEFOURCC(b[3], b[2], b[1], b[0]), str)) {
- if(subtype == MEDIASUBTYPE_DiracVideo) {
+ if (!names.Lookup(MAKEFOURCC(b[3], b[2], b[1], b[0]), str)) {
+ if (subtype == MEDIASUBTYPE_DiracVideo) {
str = _T("Dirac Video");
}
// else if(subtype == ) str = _T("");
- else if(biCompression < 256) {
+ else if (biCompression < 256) {
str.Format(_T("%d"), biCompression);
} else {
str.Format(_T("%4.4hs"), &biCompression);
@@ -261,7 +261,7 @@ CString CMediaTypeEx::GetAudioCodecName(const GUID& subtype, WORD wFormatTag) static CAtlMap<WORD, CString> names;
- if(names.IsEmpty()) {
+ if (names.IsEmpty()) {
names[WAVE_FORMAT_PCM] = _T("PCM");
names[WAVE_FORMAT_EXTENSIBLE] = _T("WAVE_FORMAT_EXTENSIBLE");
names[WAVE_FORMAT_IEEE_FLOAT] = _T("IEEE Float");
@@ -331,25 +331,25 @@ CString CMediaTypeEx::GetAudioCodecName(const GUID& subtype, WORD wFormatTag) // names[] = _T("");
}
- if(!names.Lookup(wFormatTag, str)) {
- if(subtype == MEDIASUBTYPE_Vorbis) {
+ if (!names.Lookup(wFormatTag, str)) {
+ if (subtype == MEDIASUBTYPE_Vorbis) {
str = _T("Vorbis (deprecated)");
- } else if(subtype == MEDIASUBTYPE_Vorbis2) {
+ } else if (subtype == MEDIASUBTYPE_Vorbis2) {
str = _T("Vorbis");
- } else if(subtype == MEDIASUBTYPE_MP4A) {
+ } else if (subtype == MEDIASUBTYPE_MP4A) {
str = _T("MPEG4 Audio");
- } else if(subtype == MEDIASUBTYPE_FLAC_FRAMED) {
+ } else if (subtype == MEDIASUBTYPE_FLAC_FRAMED) {
str = _T("FLAC (framed)");
- } else if(subtype == MEDIASUBTYPE_DOLBY_AC3) {
+ } else if (subtype == MEDIASUBTYPE_DOLBY_AC3) {
str += _T("Dolby AC3");
- } else if(subtype == MEDIASUBTYPE_DTS) {
+ } else if (subtype == MEDIASUBTYPE_DTS) {
str += _T("DTS");
- } else if(subtype == MEDIASUBTYPE_PCM_NONE || subtype == MEDIASUBTYPE_PCM_RAW ||
- subtype == MEDIASUBTYPE_PCM_TWOS || subtype == MEDIASUBTYPE_PCM_SOWT ||
- subtype == MEDIASUBTYPE_PCM_IN24 || subtype == MEDIASUBTYPE_PCM_IN32 ||
- subtype == MEDIASUBTYPE_PCM_IN24_le || subtype == MEDIASUBTYPE_PCM_IN32_le ||
- subtype == MEDIASUBTYPE_PCM_FL32 || subtype == MEDIASUBTYPE_PCM_FL32_le ||
- subtype == MEDIASUBTYPE_PCM_FL64 || subtype == MEDIASUBTYPE_PCM_FL64_le) {
+ } else if (subtype == MEDIASUBTYPE_PCM_NONE || subtype == MEDIASUBTYPE_PCM_RAW ||
+ subtype == MEDIASUBTYPE_PCM_TWOS || subtype == MEDIASUBTYPE_PCM_SOWT ||
+ subtype == MEDIASUBTYPE_PCM_IN24 || subtype == MEDIASUBTYPE_PCM_IN32 ||
+ subtype == MEDIASUBTYPE_PCM_IN24_le || subtype == MEDIASUBTYPE_PCM_IN32_le ||
+ subtype == MEDIASUBTYPE_PCM_FL32 || subtype == MEDIASUBTYPE_PCM_FL32_le ||
+ subtype == MEDIASUBTYPE_PCM_FL64 || subtype == MEDIASUBTYPE_PCM_FL64_le) {
str += _T("PCM");
}
// else if(subtype == ) str = _T("");
@@ -358,10 +358,10 @@ CString CMediaTypeEx::GetAudioCodecName(const GUID& subtype, WORD wFormatTag) }
}
- if(wFormatTag == WAVE_FORMAT_PCM) {
- if(subtype == MEDIASUBTYPE_DOLBY_AC3) {
+ if (wFormatTag == WAVE_FORMAT_PCM) {
+ if (subtype == MEDIASUBTYPE_DOLBY_AC3) {
str += _T(" (AC3)");
- } else if(subtype == MEDIASUBTYPE_DTS) {
+ } else if (subtype == MEDIASUBTYPE_DTS) {
str += _T(" (DTS)");
}
}
@@ -375,7 +375,7 @@ CString CMediaTypeEx::GetSubtitleCodecName(const GUID& subtype) static CAtlMap<GUID, CString> names;
- if(names.IsEmpty()) {
+ if (names.IsEmpty()) {
names[MEDIASUBTYPE_UTF8] = _T("UTF-8");
names[MEDIASUBTYPE_SSA] = _T("SubStation Alpha");
names[MEDIASUBTYPE_ASS] = _T("Advanced SubStation Alpha");
@@ -386,7 +386,7 @@ CString CMediaTypeEx::GetSubtitleCodecName(const GUID& subtype) // names[''] = _T("");
}
- if(names.Lookup(subtype, str)) {
+ if (names.Lookup(subtype, str)) {
}
@@ -425,7 +425,7 @@ void CMediaTypeEx::Dump(CAtlList<CString>& sl) sl.AddTail(_T(""));
- if(formattype == FORMAT_VideoInfo || formattype == FORMAT_VideoInfo2
+ if (formattype == FORMAT_VideoInfo || formattype == FORMAT_VideoInfo2
|| formattype == FORMAT_MPEGVideo || formattype == FORMAT_MPEG2_VIDEO) {
fmtsize =
formattype == FORMAT_VideoInfo ? sizeof(VIDEOINFOHEADER) :
@@ -451,7 +451,7 @@ void CMediaTypeEx::Dump(CAtlList<CString>& sl) sl.AddTail(_T(""));
- if(formattype == FORMAT_VideoInfo2 || formattype == FORMAT_MPEG2_VIDEO) {
+ if (formattype == FORMAT_VideoInfo2 || formattype == FORMAT_MPEG2_VIDEO) {
VIDEOINFOHEADER2& vih = *(VIDEOINFOHEADER2*)pbFormat;
bih = &vih.bmiHeader;
@@ -472,7 +472,7 @@ void CMediaTypeEx::Dump(CAtlList<CString>& sl) sl.AddTail(_T(""));
}
- if(formattype == FORMAT_MPEGVideo) {
+ if (formattype == FORMAT_MPEGVideo) {
MPEG1VIDEOINFO& mvih = *(MPEG1VIDEOINFO*)pbFormat;
sl.AddTail(_T("MPEG1VIDEOINFO:"));
@@ -482,7 +482,7 @@ void CMediaTypeEx::Dump(CAtlList<CString>& sl) sl.AddTail(str);
sl.AddTail(_T(""));
- } else if(formattype == FORMAT_MPEG2_VIDEO) {
+ } else if (formattype == FORMAT_MPEG2_VIDEO) {
MPEG2VIDEOINFO& mvih = *(MPEG2VIDEOINFO*)pbFormat;
sl.AddTail(_T("MPEG2VIDEOINFO:"));
@@ -511,7 +511,7 @@ void CMediaTypeEx::Dump(CAtlList<CString>& sl) sl.AddTail(str);
str.Format(_T("biBitCount: %d"), bih->biBitCount);
sl.AddTail(str);
- if(bih->biCompression < 256) {
+ if (bih->biCompression < 256) {
str.Format(_T("biCompression: %d"), bih->biCompression);
} else {
str.Format(_T("biCompression: %4.4hs"), &bih->biCompression);
@@ -529,7 +529,7 @@ void CMediaTypeEx::Dump(CAtlList<CString>& sl) sl.AddTail(str);
sl.AddTail(_T(""));
- } else if(formattype == FORMAT_WaveFormatEx || formattype == FORMAT_WaveFormatExFFMPEG) {
+ } else if (formattype == FORMAT_WaveFormatEx || formattype == FORMAT_WaveFormatExFFMPEG) {
WAVEFORMATEX *pWfe = NULL;
if (formattype == FORMAT_WaveFormatExFFMPEG) {
fmtsize = sizeof(WAVEFORMATEXFFMPEG);
@@ -566,14 +566,14 @@ void CMediaTypeEx::Dump(CAtlList<CString>& sl) sl.AddTail(_T(""));
- if(wfe.wFormatTag != WAVE_FORMAT_PCM && wfe.cbSize > 0 && formattype == FORMAT_WaveFormatEx) {
- if(wfe.wFormatTag == WAVE_FORMAT_EXTENSIBLE && wfe.cbSize == sizeof(WAVEFORMATEXTENSIBLE)-sizeof(WAVEFORMATEX)) {
+ if (wfe.wFormatTag != WAVE_FORMAT_PCM && wfe.cbSize > 0 && formattype == FORMAT_WaveFormatEx) {
+ if (wfe.wFormatTag == WAVE_FORMAT_EXTENSIBLE && wfe.cbSize == sizeof(WAVEFORMATEXTENSIBLE)-sizeof(WAVEFORMATEX)) {
fmtsize = sizeof(WAVEFORMATEXTENSIBLE);
WAVEFORMATEXTENSIBLE& wfe = *(WAVEFORMATEXTENSIBLE*)pbFormat;
sl.AddTail(_T("WAVEFORMATEXTENSIBLE:"));
- if(wfe.Format.wBitsPerSample != 0) {
+ if (wfe.Format.wBitsPerSample != 0) {
str.Format(_T("wValidBitsPerSample: %d"), wfe.Samples.wValidBitsPerSample);
} else {
str.Format(_T("wSamplesPerBlock: %d"), wfe.Samples.wSamplesPerBlock);
@@ -585,7 +585,7 @@ void CMediaTypeEx::Dump(CAtlList<CString>& sl) sl.AddTail(str);
sl.AddTail(_T(""));
- } else if(wfe.wFormatTag == WAVE_FORMAT_DOLBY_AC3 && wfe.cbSize == sizeof(DOLBYAC3WAVEFORMAT)-sizeof(WAVEFORMATEX)) {
+ } else if (wfe.wFormatTag == WAVE_FORMAT_DOLBY_AC3 && wfe.cbSize == sizeof(DOLBYAC3WAVEFORMAT)-sizeof(WAVEFORMATEX)) {
fmtsize = sizeof(DOLBYAC3WAVEFORMAT);
DOLBYAC3WAVEFORMAT& wfe = *(DOLBYAC3WAVEFORMAT*)pbFormat;
@@ -605,7 +605,7 @@ void CMediaTypeEx::Dump(CAtlList<CString>& sl) sl.AddTail(_T(""));
}
}
- } else if(formattype == FORMAT_VorbisFormat) {
+ } else if (formattype == FORMAT_VorbisFormat) {
fmtsize = sizeof(VORBISFORMAT);
VORBISFORMAT& vf = *(VORBISFORMAT*)pbFormat;
@@ -625,7 +625,7 @@ void CMediaTypeEx::Dump(CAtlList<CString>& sl) sl.AddTail(str);
sl.AddTail(_T(""));
- } else if(formattype == FORMAT_VorbisFormat2) {
+ } else if (formattype == FORMAT_VorbisFormat2) {
fmtsize = sizeof(VORBISFORMAT2);
VORBISFORMAT2& vf = *(VORBISFORMAT2*)pbFormat;
@@ -641,7 +641,7 @@ void CMediaTypeEx::Dump(CAtlList<CString>& sl) sl.AddTail(str);
sl.AddTail(_T(""));
- } else if(formattype == FORMAT_SubtitleInfo) {
+ } else if (formattype == FORMAT_SubtitleInfo) {
fmtsize = sizeof(SUBTITLEINFO);
SUBTITLEINFO& si = *(SUBTITLEINFO*)pbFormat;
@@ -657,25 +657,25 @@ void CMediaTypeEx::Dump(CAtlList<CString>& sl) sl.AddTail(_T(""));
}
- if(cbFormat > 0) {
+ if (cbFormat > 0) {
sl.AddTail(_T("pbFormat:"));
- for(ptrdiff_t i = 0, j = (cbFormat + 15) & ~15; i < j; i += 16) {
+ for (ptrdiff_t i = 0, j = (cbFormat + 15) & ~15; i < j; i += 16) {
str.Format(_T("%04x:"), i);
- for(ptrdiff_t k = i, l = min(i + 16, (int)cbFormat); k < l; k++) {
+ for (ptrdiff_t k = i, l = min(i + 16, (int)cbFormat); k < l; k++) {
CString byte;
byte.Format(_T("%c%02x"), fmtsize > 0 && fmtsize == k ? '|' : ' ', pbFormat[k]);
str += byte;
}
- for(ptrdiff_t k = min(i + 16, (int)cbFormat), l = i + 16; k < l; k++) {
+ for (ptrdiff_t k = min(i + 16, (int)cbFormat), l = i + 16; k < l; k++) {
str += _T(" ");
}
str += ' ';
- for(ptrdiff_t k = i, l = min(i + 16, (int)cbFormat); k < l; k++) {
+ for (ptrdiff_t k = i, l = min(i + 16, (int)cbFormat); k < l; k++) {
unsigned char c = (unsigned char)pbFormat[k];
CStringA ch;
ch.Format("%c", c >= 0x20 ? c : '.');
diff --git a/src/DSUtil/MediaTypes.cpp b/src/DSUtil/MediaTypes.cpp index 48cebc636..4b97556c0 100644 --- a/src/DSUtil/MediaTypes.cpp +++ b/src/DSUtil/MediaTypes.cpp @@ -324,13 +324,13 @@ UINT VIHSIZE = countof(vihs); CString VIH2String(int i)
{
CString ret = CString(GuidNames[*vihs[i].subtype]);
- if(!ret.Left(13).CompareNoCase(_T("MEDIASUBTYPE_"))) {
+ if (!ret.Left(13).CompareNoCase(_T("MEDIASUBTYPE_"))) {
ret = ret.Mid(13);
}
- if(vihs[i].vih.bmiHeader.biCompression == 3) {
+ if (vihs[i].vih.bmiHeader.biCompression == 3) {
ret += _T(" BITF");
}
- if(*vihs[i].subtype == MEDIASUBTYPE_I420) {
+ if (*vihs[i].subtype == MEDIASUBTYPE_I420) {
ret = _T("I420"); // FIXME
}
return(ret);
@@ -339,10 +339,10 @@ CString VIH2String(int i) CString Subtype2String(const GUID& subtype)
{
CString ret = CString(GuidNames[subtype]);
- if(!ret.Left(13).CompareNoCase(_T("MEDIASUBTYPE_"))) {
+ if (!ret.Left(13).CompareNoCase(_T("MEDIASUBTYPE_"))) {
ret = ret.Mid(13);
}
- if(subtype == MEDIASUBTYPE_I420) {
+ if (subtype == MEDIASUBTYPE_I420) {
ret = _T("I420"); // FIXME
}
return(ret);
@@ -350,17 +350,17 @@ CString Subtype2String(const GUID& subtype) void CorrectMediaType(AM_MEDIA_TYPE* pmt)
{
- if(!pmt) {
+ if (!pmt) {
return;
}
CMediaType mt(*pmt);
- if(mt.formattype == FORMAT_VideoInfo) {
+ if (mt.formattype == FORMAT_VideoInfo) {
VIDEOINFOHEADER* vih = (VIDEOINFOHEADER*)mt.pbFormat;
- for(UINT i = 0; i < VIHSIZE; i++) {
- if(mt.subtype == *vihs[i].subtype
+ for (UINT i = 0; i < VIHSIZE; i++) {
+ if (mt.subtype == *vihs[i].subtype
&& vih->bmiHeader.biCompression == vihs[i].vih.bmiHeader.biCompression) {
mt.AllocFormatBuffer(vihs[i].size);
memcpy(mt.pbFormat, &vihs[i], vihs[i].size);
@@ -368,11 +368,11 @@ void CorrectMediaType(AM_MEDIA_TYPE* pmt) break;
}
}
- } else if(mt.formattype == FORMAT_VideoInfo2) {
+ } else if (mt.formattype == FORMAT_VideoInfo2) {
VIDEOINFOHEADER2* vih2 = (VIDEOINFOHEADER2*)mt.pbFormat;
- for(UINT i = 0; i < VIHSIZE; i++) {
- if(mt.subtype == *vih2s[i].subtype
+ for (UINT i = 0; i < VIHSIZE; i++) {
+ if (mt.subtype == *vih2s[i].subtype
&& vih2->bmiHeader.biCompression == vih2s[i].vih.bmiHeader.biCompression) {
mt.AllocFormatBuffer(vih2s[i].size);
memcpy(mt.pbFormat, &vih2s[i], vih2s[i].size);
diff --git a/src/DSUtil/NullRenderers.cpp b/src/DSUtil/NullRenderers.cpp index 94a5b42b3..5a7b811fe 100644 --- a/src/DSUtil/NullRenderers.cpp +++ b/src/DSUtil/NullRenderers.cpp @@ -49,7 +49,8 @@ class CNullVideoRendererInputPin : public CRendererInputPin, public :
CNullVideoRendererInputPin(CBaseRenderer *pRenderer, HRESULT *phr, LPCWSTR Name);
~CNullVideoRendererInputPin() {
- if (m_hDXVA2Lib) FreeLibrary(m_hDXVA2Lib);}
+ if (m_hDXVA2Lib) FreeLibrary(m_hDXVA2Lib);
+ }
DECLARE_IUNKNOWN
STDMETHODIMP NonDelegatingQueryInterface(REFIID riid, void** ppv);
@@ -165,7 +166,7 @@ void CNullVideoRendererInputPin::CreateSurface() {
HRESULT hr;
m_pD3D.Attach(Direct3DCreate9(D3D_SDK_VERSION));
- if(!m_pD3D) {
+ if (!m_pD3D) {
m_pD3D.Attach(Direct3DCreate9(D3D9b_SDK_VERSION));
}
diff --git a/src/DSUtil/text.cpp b/src/DSUtil/text.cpp index 623609e9c..bc32ddf17 100644 --- a/src/DSUtil/text.cpp +++ b/src/DSUtil/text.cpp @@ -70,10 +70,10 @@ CString Implode(CAtlList<CString>& sl, TCHAR sep) DWORD CharSetToCodePage(DWORD dwCharSet)
{
- if(dwCharSet == CP_UTF8) {
+ if (dwCharSet == CP_UTF8) {
return CP_UTF8;
}
- if(dwCharSet == CP_UTF7) {
+ if (dwCharSet == CP_UTF7) {
return CP_UTF7;
}
CHARSETINFO cs= {0};
@@ -112,13 +112,13 @@ CStringA UrlEncode(CStringA str, bool fRaw) {
CStringA urlstr;
- for(int i = 0; i < str.GetLength(); i++) {
+ for (int i = 0; i < str.GetLength(); i++) {
CHAR c = str[i];
- if(fRaw && c == '+') {
+ if (fRaw && c == '+') {
urlstr += "%2B";
- } else if(c > 0x20 && c < 0x7f && c != '&') {
+ } else if (c > 0x20 && c < 0x7f && c != '&') {
urlstr += c;
- } else if(c == 0x20) {
+ } else if (c == 0x20) {
urlstr += fRaw ? ' ' : '+';
} else {
CStringA tmp;
@@ -138,25 +138,25 @@ CStringA UrlDecode(CStringA str, bool fRaw) CHAR* e = s + str.GetLength();
CHAR* s1 = s;
CHAR* s2 = s;
- while(s1 < e) {
+ while (s1 < e) {
CHAR s11 = (s1 < e-1) ? (__isascii(s1[1]) && isupper(s1[1]) ? tolower(s1[1]) : s1[1]) : 0;
CHAR s12 = (s1 < e-2) ? (__isascii(s1[2]) && isupper(s1[2]) ? tolower(s1[2]) : s1[2]) : 0;
- if(*s1 == '%' && s1 < e-2
+ if (*s1 == '%' && s1 < e-2
&& (s1[1] >= '0' && s1[1] <= '9' || s11 >= 'a' && s11 <= 'f')
&& (s1[2] >= '0' && s1[2] <= '9' || s12 >= 'a' && s12 <= 'f')) {
s1[1] = s11;
s1[2] = s12;
*s2 = 0;
- if(s1[1] >= '0' && s1[1] <= '9') {
+ if (s1[1] >= '0' && s1[1] <= '9') {
*s2 |= s1[1]-'0';
- } else if(s1[1] >= 'a' && s1[1] <= 'f') {
+ } else if (s1[1] >= 'a' && s1[1] <= 'f') {
*s2 |= s1[1]-'a'+10;
}
*s2 <<= 4;
- if(s1[2] >= '0' && s1[2] <= '9') {
+ if (s1[2] >= '0' && s1[2] <= '9') {
*s2 |= s1[2]-'0';
- } else if(s1[2] >= 'a' && s1[2] <= 'f') {
+ } else if (s1[2] >= 'a' && s1[2] <= 'f') {
*s2 |= s1[2]-'a'+10;
}
s1 += 2;
@@ -182,30 +182,30 @@ CString ExtractTag(CString tag, CMapStringToString& attribs, bool& fClosing) tag.TrimLeft('/');
int i = tag.Find(' ');
- if(i < 0) {
+ if (i < 0) {
i = tag.GetLength();
}
CString type = tag.Left(i).MakeLower();
tag = tag.Mid(i).Trim();
- while((i = tag.Find('=')) > 0) {
+ while ((i = tag.Find('=')) > 0) {
CString attrib = tag.Left(i).Trim().MakeLower();
tag = tag.Mid(i+1);
- for(i = 0; i < tag.GetLength() && _istspace(tag[i]); i++) {
+ for (i = 0; i < tag.GetLength() && _istspace(tag[i]); i++) {
;
}
tag = i < tag.GetLength() ? tag.Mid(i) : _T("");
- if(!tag.IsEmpty() && tag[0] == '\"') {
+ if (!tag.IsEmpty() && tag[0] == '\"') {
tag = tag.Mid(1);
i = tag.Find('\"');
} else {
i = tag.Find(' ');
}
- if(i < 0) {
+ if (i < 0) {
i = tag.GetLength();
}
CString param = tag.Left(i).Trim();
- if(!param.IsEmpty()) {
+ if (!param.IsEmpty()) {
attribs[attrib] = param;
}
tag = i+1 < tag.GetLength() ? tag.Mid(i+1) : _T("");
@@ -217,7 +217,7 @@ CString ExtractTag(CString tag, CMapStringToString& attribs, bool& fClosing) CAtlList<CString>& MakeLower(CAtlList<CString>& sl)
{
POSITION pos = sl.GetHeadPosition();
- while(pos) {
+ while (pos) {
sl.GetNext(pos).MakeLower();
}
return sl;
@@ -226,7 +226,7 @@ CAtlList<CString>& MakeLower(CAtlList<CString>& sl) CAtlList<CString>& MakeUpper(CAtlList<CString>& sl)
{
POSITION pos = sl.GetHeadPosition();
- while(pos) {
+ while (pos) {
sl.GetNext(pos).MakeUpper();
}
return sl;
@@ -235,11 +235,11 @@ CAtlList<CString>& MakeUpper(CAtlList<CString>& sl) CAtlList<CString>& RemoveStrings(CAtlList<CString>& sl, int minlen, int maxlen)
{
POSITION pos = sl.GetHeadPosition();
- while(pos) {
+ while (pos) {
POSITION tmp = pos;
CString& str = sl.GetNext(pos);
int len = str.GetLength();
- if(len < minlen || len > maxlen) {
+ if (len < minlen || len > maxlen) {
sl.RemoveAt(tmp);
}
}
diff --git a/src/DSUtil/text.h b/src/DSUtil/text.h index ccec847f9..7310bb1c6 100644 --- a/src/DSUtil/text.h +++ b/src/DSUtil/text.h @@ -11,10 +11,10 @@ T Explode(T str, CAtlList<T>& sl, SEP sep, size_t limit = 0) {
sl.RemoveAll();
- for(ptrdiff_t i = 0, j = 0; ; i = j+1) {
+ for (ptrdiff_t i = 0, j = 0; ; i = j+1) {
j = str.Find(sep, i);
- if(j < 0 || sl.GetCount() == limit-1) {
+ if (j < 0 || sl.GetCount() == limit-1) {
sl.AddTail(str.Mid(i).Trim());
break;
} else {
@@ -30,13 +30,13 @@ T ExplodeMin(T str, CAtlList<T>& sl, SEP sep, size_t limit = 0) {
Explode(str, sl, sep, limit);
POSITION pos = sl.GetHeadPosition();
- while(pos) {
+ while (pos) {
POSITION tmp = pos;
- if(sl.GetNext(pos).IsEmpty()) {
+ if (sl.GetNext(pos).IsEmpty()) {
sl.RemoveAt(tmp);
}
}
- if(sl.IsEmpty()) {
+ if (sl.IsEmpty()) {
sl.AddTail(T()); // eh
}
@@ -48,9 +48,9 @@ T Implode(CAtlList<T>& sl, SEP sep) {
T ret;
POSITION pos = sl.GetHeadPosition();
- while(pos) {
+ while (pos) {
ret += sl.GetNext(pos);
- if(pos) {
+ if (pos) {
ret += sep;
}
}
diff --git a/src/SubPic/CoordGeom.cpp b/src/SubPic/CoordGeom.cpp index c507e59a7..79c54bc4a 100644 --- a/src/SubPic/CoordGeom.cpp +++ b/src/SubPic/CoordGeom.cpp @@ -75,7 +75,7 @@ Vector Vector::Pow(float exp) Vector Vector::Unit()
{
float l = Length();
- if(!l || l == 1) {
+ if (!l || l == 1) {
return(*this);
}
return(*this * (1 / l));
@@ -108,11 +108,11 @@ void Vector::Angle(float& u, float& v) u = asin(n.y);
- if(IsZero(n.z)) {
+ if (IsZero(n.z)) {
v = PI/2 * Sgn(n.x);
- } else if(n.z > 0) {
+ } else if (n.z > 0) {
v = atan(n.x / n.z);
- } else if(n.z < 0) {
+ } else if (n.z < 0) {
v = IsZero(n.x) ? PI : (PI * Sgn(n.x) + atan(n.x / n.z));
}
}
@@ -163,19 +163,19 @@ Vector Vector::Refract(Vector& N, float nFront, float nBack, float* nOut) float len_sin_T = sin_T | sin_T;
- if(len_sin_T > 1) {
- if(nOut) {
+ if (len_sin_T > 1) {
+ if (nOut) {
*nOut = N_dot_D >= 0 ? nFront : nBack;
}
return((*this).Reflect(N));
}
float N_dot_T = sqrt(1.0 - len_sin_T);
- if(N_dot_D < 0) {
+ if (N_dot_D < 0) {
N_dot_T = -N_dot_T;
}
- if(nOut) {
+ if (nOut) {
*nOut = N_dot_D >= 0 ? nBack : nFront;
}
@@ -194,19 +194,19 @@ Vector Vector::Refract2(Vector& N, float nFrom, float nTo, float* nOut) float len_sin_T = sin_T | sin_T;
- if(len_sin_T > 1) {
- if(nOut) {
+ if (len_sin_T > 1) {
+ if (nOut) {
*nOut = nFrom;
}
return((*this).Reflect(N));
}
float N_dot_T = sqrt(1.0 - len_sin_T);
- if(N_dot_D < 0) {
+ if (N_dot_D < 0) {
N_dot_T = -N_dot_T;
}
- if(nOut) {
+ if (nOut) {
*nOut = nTo;
}
@@ -235,7 +235,7 @@ Vector Vector::operator - () bool Vector::operator == (const Vector& v) const
{
- if(IsZero(x - v.x) && IsZero(y - v.y) && IsZero(z - v.z)) {
+ if (IsZero(x - v.x) && IsZero(y - v.y) && IsZero(z - v.z)) {
return true;
}
return false;
@@ -369,7 +369,7 @@ void Ray::Set(Vector& p, Vector& d) float Ray::GetDistanceFrom(Ray& r)
{
float t = (d | r.d);
- if(IsZero(t)) {
+ if (IsZero(t)) {
return(-BIGNUMBER); // plane is paralell to the ray, return -infinite
}
return(((r.p - p) | r.d) / t);
@@ -405,7 +405,7 @@ void XForm::Initalize(Ray& r, Vector& s, bool isWorldToLocal) Initalize();
m_isWorldToLocal = isWorldToLocal;
- if(isWorldToLocal) {
+ if (isWorldToLocal) {
*this -= r.p;
*this >>= r.d;
*this /= s;
@@ -552,14 +552,14 @@ XForm::Matrix XForm::Matrix::operator * (Matrix& m) {
Matrix ret;
- for(ptrdiff_t i = 0; i < 4; i++) {
- for(ptrdiff_t j = 0; j < 4; j++) {
+ for (ptrdiff_t i = 0; i < 4; i++) {
+ for (ptrdiff_t j = 0; j < 4; j++) {
ret.mat[i][j] = mat[i][0] * m.mat[0][j] +
mat[i][1] * m.mat[1][j] +
mat[i][2] * m.mat[2][j] +
mat[i][3] * m.mat[3][j];
- if(IsZero(ret.mat[i][j])) {
+ if (IsZero(ret.mat[i][j])) {
ret.mat[i][j] = 0;
}
}
diff --git a/src/SubPic/DX7SubPic.cpp b/src/SubPic/DX7SubPic.cpp index 2112e67d1..07a4bcf30 100644 --- a/src/SubPic/DX7SubPic.cpp +++ b/src/SubPic/DX7SubPic.cpp @@ -36,7 +36,7 @@ CDX7SubPic::CDX7SubPic(IDirect3DDevice7* pD3DDev, IDirectDrawSurface7* pSurface) {
DDSURFACEDESC2 ddsd;
INITDDSTRUCT(ddsd);
- if(SUCCEEDED(m_pSurface->GetSurfaceDesc(&ddsd))) {
+ if (SUCCEEDED(m_pSurface->GetSurfaceDesc(&ddsd))) {
m_maxsize.SetSize(ddsd.dwWidth, ddsd.dwHeight);
m_rcDirty.SetRect(0, 0, ddsd.dwWidth, ddsd.dwHeight);
}
@@ -53,7 +53,7 @@ STDMETHODIMP CDX7SubPic::GetDesc(SubPicDesc& spd) {
DDSURFACEDESC2 ddsd;
INITDDSTRUCT(ddsd);
- if(FAILED(m_pSurface->GetSurfaceDesc(&ddsd))) {
+ if (FAILED(m_pSurface->GetSurfaceDesc(&ddsd))) {
return E_FAIL;
}
@@ -71,7 +71,7 @@ STDMETHODIMP CDX7SubPic::GetDesc(SubPicDesc& spd) STDMETHODIMP CDX7SubPic::CopyTo(ISubPic* pSubPic)
{
HRESULT hr;
- if(FAILED(hr = __super::CopyTo(pSubPic))) {
+ if (FAILED(hr = __super::CopyTo(pSubPic))) {
return hr;
}
@@ -83,7 +83,7 @@ STDMETHODIMP CDX7SubPic::CopyTo(ISubPic* pSubPic) STDMETHODIMP CDX7SubPic::ClearDirtyRect(DWORD color)
{
- if(m_rcDirty.IsRectEmpty()) {
+ if (m_rcDirty.IsRectEmpty()) {
return S_FALSE;
}
@@ -101,7 +101,7 @@ STDMETHODIMP CDX7SubPic::Lock(SubPicDesc& spd) {
DDSURFACEDESC2 ddsd;
INITDDSTRUCT(ddsd);
- if(FAILED(m_pSurface->Lock(NULL, &ddsd, DDLOCK_SURFACEMEMORYPTR|DDLOCK_WAIT, NULL))) {
+ if (FAILED(m_pSurface->Lock(NULL, &ddsd, DDLOCK_SURFACEMEMORYPTR|DDLOCK_WAIT, NULL))) {
return E_FAIL;
}
@@ -120,7 +120,7 @@ STDMETHODIMP CDX7SubPic::Unlock(RECT* pDirtyRect) {
m_pSurface->Unlock(NULL);
- if(pDirtyRect) {
+ if (pDirtyRect) {
m_rcDirty = *pDirtyRect;
m_rcDirty.InflateRect(1, 1);
m_rcDirty &= CRect(CPoint(0, 0), m_size);
@@ -135,7 +135,7 @@ STDMETHODIMP CDX7SubPic::AlphaBlt(RECT* pSrc, RECT* pDst, SubPicDesc* pTarget) {
ASSERT(pTarget == NULL);
- if(!m_pD3DDev || !m_pSurface || !pSrc || !pDst) {
+ if (!m_pD3DDev || !m_pSurface || !pSrc || !pDst) {
return E_POINTER;
}
@@ -146,7 +146,7 @@ STDMETHODIMP CDX7SubPic::AlphaBlt(RECT* pSrc, RECT* pDst, SubPicDesc* pTarget) do {
DDSURFACEDESC2 ddsd;
INITDDSTRUCT(ddsd);
- if(FAILED(hr = m_pSurface->GetSurfaceDesc(&ddsd))) {
+ if (FAILED(hr = m_pSurface->GetSurfaceDesc(&ddsd))) {
break;
}
@@ -201,7 +201,7 @@ STDMETHODIMP CDX7SubPic::AlphaBlt(RECT* pSrc, RECT* pDst, SubPicDesc* pTarget) *///
- if(FAILED(hr = m_pD3DDev->BeginScene())) {
+ if (FAILED(hr = m_pD3DDev->BeginScene())) {
break;
}
@@ -215,7 +215,7 @@ STDMETHODIMP CDX7SubPic::AlphaBlt(RECT* pSrc, RECT* pDst, SubPicDesc* pTarget) m_pD3DDev->SetTexture(0, NULL);
return S_OK;
- } while(0);
+ } while (0);
return E_FAIL;
}
@@ -236,7 +236,7 @@ CDX7SubPicAllocator::CDX7SubPicAllocator(IDirect3DDevice7* pD3DDev, SIZE maxsize STDMETHODIMP CDX7SubPicAllocator::ChangeDevice(IUnknown* pDev)
{
CComQIPtr<IDirect3DDevice7, &IID_IDirect3DDevice7> pD3DDev = pDev;
- if(!pD3DDev) {
+ if (!pD3DDev) {
return E_NOINTERFACE;
}
@@ -250,7 +250,7 @@ STDMETHODIMP CDX7SubPicAllocator::ChangeDevice(IUnknown* pDev) bool CDX7SubPicAllocator::Alloc(bool fStatic, ISubPic** ppSubPic)
{
- if(!ppSubPic) {
+ if (!ppSubPic) {
return false;
}
@@ -271,12 +271,12 @@ bool CDX7SubPicAllocator::Alloc(bool fStatic, ISubPic** ppSubPic) ddsd.ddpfPixelFormat.dwGBitMask = 0x0000FF00;
ddsd.ddpfPixelFormat.dwBBitMask = 0x000000FF;
- if(m_fPow2Textures) {
+ if (m_fPow2Textures) {
ddsd.dwWidth = ddsd.dwHeight = 1;
- while(ddsd.dwWidth < (DWORD)m_maxsize.cx) {
+ while (ddsd.dwWidth < (DWORD)m_maxsize.cx) {
ddsd.dwWidth <<= 1;
}
- while(ddsd.dwHeight < (DWORD)m_maxsize.cy) {
+ while (ddsd.dwHeight < (DWORD)m_maxsize.cy) {
ddsd.dwHeight <<= 1;
}
}
@@ -284,17 +284,17 @@ bool CDX7SubPicAllocator::Alloc(bool fStatic, ISubPic** ppSubPic) CComPtr<IDirect3D7> pD3D;
CComQIPtr<IDirectDraw7, &IID_IDirectDraw7> pDD;
- if(FAILED(m_pD3DDev->GetDirect3D(&pD3D)) || !pD3D || !(pDD = pD3D)) {
+ if (FAILED(m_pD3DDev->GetDirect3D(&pD3D)) || !pD3D || !(pDD = pD3D)) {
return false;
}
CComPtr<IDirectDrawSurface7> pSurface;
- if(FAILED(pDD->CreateSurface(&ddsd, &pSurface, NULL))) {
+ if (FAILED(pDD->CreateSurface(&ddsd, &pSurface, NULL))) {
return false;
}
*ppSubPic = DNew CDX7SubPic(m_pD3DDev, pSurface);
- if(!(*ppSubPic)) {
+ if (!(*ppSubPic)) {
return false;
}
diff --git a/src/SubPic/DX9SubPic.cpp b/src/SubPic/DX9SubPic.cpp index 16b4263a5..f530b249d 100644 --- a/src/SubPic/DX9SubPic.cpp +++ b/src/SubPic/DX9SubPic.cpp @@ -35,7 +35,7 @@ CDX9SubPic::CDX9SubPic(IDirect3DSurface9* pSurface, CDX9SubPicAllocator *pAlloca {
D3DSURFACE_DESC d3dsd;
ZeroMemory(&d3dsd, sizeof(d3dsd));
- if(SUCCEEDED(m_pSurface->GetDesc(&d3dsd))) {
+ if (SUCCEEDED(m_pSurface->GetDesc(&d3dsd))) {
m_maxsize.SetSize(d3dsd.Width, d3dsd.Height);
m_rcDirty.SetRect(0, 0, d3dsd.Width, d3dsd.Height);
}
@@ -66,7 +66,7 @@ CDX9SubPic::~CDX9SubPic() STDMETHODIMP_(void*) CDX9SubPic::GetObject()
{
CComPtr<IDirect3DTexture9> pTexture;
- if(SUCCEEDED(m_pSurface->GetContainer(IID_IDirect3DTexture9, (void**)&pTexture))) {
+ if (SUCCEEDED(m_pSurface->GetContainer(IID_IDirect3DTexture9, (void**)&pTexture))) {
return (void*)(IDirect3DTexture9*)pTexture;
}
@@ -77,7 +77,7 @@ STDMETHODIMP CDX9SubPic::GetDesc(SubPicDesc& spd) {
D3DSURFACE_DESC d3dsd;
ZeroMemory(&d3dsd, sizeof(d3dsd));
- if(FAILED(m_pSurface->GetDesc(&d3dsd))) {
+ if (FAILED(m_pSurface->GetDesc(&d3dsd))) {
return E_FAIL;
}
@@ -97,16 +97,16 @@ STDMETHODIMP CDX9SubPic::GetDesc(SubPicDesc& spd) STDMETHODIMP CDX9SubPic::CopyTo(ISubPic* pSubPic)
{
HRESULT hr;
- if(FAILED(hr = __super::CopyTo(pSubPic))) {
+ if (FAILED(hr = __super::CopyTo(pSubPic))) {
return hr;
}
- if(m_rcDirty.IsRectEmpty()) {
+ if (m_rcDirty.IsRectEmpty()) {
return S_FALSE;
}
CComPtr<IDirect3DDevice9> pD3DDev;
- if(!m_pSurface || FAILED(m_pSurface->GetDevice(&pD3DDev)) || !pD3DDev) {
+ if (!m_pSurface || FAILED(m_pSurface->GetDevice(&pD3DDev)) || !pD3DDev) {
return E_FAIL;
}
@@ -133,28 +133,28 @@ STDMETHODIMP CDX9SubPic::CopyTo(ISubPic* pSubPic) STDMETHODIMP CDX9SubPic::ClearDirtyRect(DWORD color)
{
- if(m_rcDirty.IsRectEmpty()) {
+ if (m_rcDirty.IsRectEmpty()) {
return S_FALSE;
}
CComPtr<IDirect3DDevice9> pD3DDev;
- if(!m_pSurface || FAILED(m_pSurface->GetDevice(&pD3DDev)) || !pD3DDev) {
+ if (!m_pSurface || FAILED(m_pSurface->GetDevice(&pD3DDev)) || !pD3DDev) {
return E_FAIL;
}
SubPicDesc spd;
- if(SUCCEEDED(Lock(spd))) {
+ if (SUCCEEDED(Lock(spd))) {
int h = m_rcDirty.Height();
BYTE* ptr = (BYTE*)spd.bits + spd.pitch*m_rcDirty.top + (m_rcDirty.left*spd.bpp>>3);
- if(spd.bpp == 16) {
- while(h-- > 0) {
+ if (spd.bpp == 16) {
+ while (h-- > 0) {
memsetw(ptr, color, 2 * m_rcDirty.Width());
ptr += spd.pitch;
}
- } else if(spd.bpp == 32) {
- while(h-- > 0) {
+ } else if (spd.bpp == 32) {
+ while (h-- > 0) {
memsetd(ptr, color, 4 * m_rcDirty.Width());
ptr += spd.pitch;
}
@@ -178,13 +178,13 @@ STDMETHODIMP CDX9SubPic::Lock(SubPicDesc& spd) {
D3DSURFACE_DESC d3dsd;
ZeroMemory(&d3dsd, sizeof(d3dsd));
- if(FAILED(m_pSurface->GetDesc(&d3dsd))) {
+ if (FAILED(m_pSurface->GetDesc(&d3dsd))) {
return E_FAIL;
}
D3DLOCKED_RECT LockedRect;
ZeroMemory(&LockedRect, sizeof(LockedRect));
- if(FAILED(m_pSurface->LockRect(&LockedRect, NULL, D3DLOCK_NO_DIRTY_UPDATE|D3DLOCK_NOSYSLOCK))) {
+ if (FAILED(m_pSurface->LockRect(&LockedRect, NULL, D3DLOCK_NO_DIRTY_UPDATE|D3DLOCK_NOSYSLOCK))) {
return E_FAIL;
}
@@ -205,7 +205,7 @@ STDMETHODIMP CDX9SubPic::Unlock(RECT* pDirtyRect) {
HRESULT hr = m_pSurface->UnlockRect();
- if(pDirtyRect) {
+ if (pDirtyRect) {
m_rcDirty = *pDirtyRect;
if (!((CRect*)pDirtyRect)->IsRectEmpty()) {
m_rcDirty.InflateRect(1, 1);
@@ -231,7 +231,7 @@ STDMETHODIMP CDX9SubPic::AlphaBlt(RECT* pSrc, RECT* pDst, SubPicDesc* pTarget) {
ASSERT(pTarget == NULL);
- if(!pSrc || !pDst) {
+ if (!pSrc || !pDst) {
return E_POINTER;
}
@@ -239,7 +239,7 @@ STDMETHODIMP CDX9SubPic::AlphaBlt(RECT* pSrc, RECT* pDst, SubPicDesc* pTarget) CComPtr<IDirect3DDevice9> pD3DDev;
CComPtr<IDirect3DTexture9> pTexture = (IDirect3DTexture9*)GetObject();
- if(!pTexture || FAILED(pTexture->GetDevice(&pD3DDev)) || !pD3DDev) {
+ if (!pTexture || FAILED(pTexture->GetDevice(&pD3DDev)) || !pD3DDev) {
return E_NOINTERFACE;
}
@@ -248,7 +248,7 @@ STDMETHODIMP CDX9SubPic::AlphaBlt(RECT* pSrc, RECT* pDst, SubPicDesc* pTarget) do {
D3DSURFACE_DESC d3dsd;
ZeroMemory(&d3dsd, sizeof(d3dsd));
- if(FAILED(pTexture->GetLevelDesc(0, &d3dsd)) /*|| d3dsd.Type != D3DRTYPE_TEXTURE*/) {
+ if (FAILED(pTexture->GetLevelDesc(0, &d3dsd)) /*|| d3dsd.Type != D3DRTYPE_TEXTURE*/) {
break;
}
@@ -266,7 +266,7 @@ STDMETHODIMP CDX9SubPic::AlphaBlt(RECT* pSrc, RECT* pDst, SubPicDesc* pTarget) {(float)dst.right, (float)dst.bottom, 0.5f, 2.0f, (float)src.right / w, (float)src.bottom / h},
};
- for(ptrdiff_t i = 0; i < countof(pVertices); i++) {
+ for (ptrdiff_t i = 0; i < countof(pVertices); i++) {
pVertices[i].x -= 0.5;
pVertices[i].y -= 0.5;
}
@@ -294,12 +294,14 @@ STDMETHODIMP CDX9SubPic::AlphaBlt(RECT* pSrc, RECT* pDst, SubPicDesc* pTarget) hr = pD3DDev->SetTextureStageState(0, D3DTSS_COLORARG1, D3DTA_TEXTURE);
hr = pD3DDev->SetTextureStageState(0, D3DTSS_ALPHAARG1, D3DTA_TEXTURE);
- if(pSrc == pDst) {
+ if (pSrc == pDst) {
hr = pD3DDev->SetSamplerState(0, D3DSAMP_MAGFILTER, D3DTEXF_POINT);
- hr = pD3DDev->SetSamplerState(0, D3DSAMP_MINFILTER, D3DTEXF_POINT);}
+ hr = pD3DDev->SetSamplerState(0, D3DSAMP_MINFILTER, D3DTEXF_POINT);
+ }
else {
hr = pD3DDev->SetSamplerState(0, D3DSAMP_MAGFILTER, D3DTEXF_LINEAR);
- hr = pD3DDev->SetSamplerState(0, D3DSAMP_MINFILTER, D3DTEXF_LINEAR);}
+ hr = pD3DDev->SetSamplerState(0, D3DSAMP_MINFILTER, D3DTEXF_LINEAR);
+ }
hr = pD3DDev->SetSamplerState(0, D3DSAMP_MIPFILTER, D3DTEXF_NONE);
hr = pD3DDev->SetSamplerState(0, D3DSAMP_ADDRESSU, D3DTADDRESS_BORDER);
@@ -321,13 +323,13 @@ STDMETHODIMP CDX9SubPic::AlphaBlt(RECT* pSrc, RECT* pDst, SubPicDesc* pTarget) hr = pD3DDev->SetPixelShader(NULL);
- if((m_bExternalRenderer) && (FAILED(hr = pD3DDev->BeginScene())))
+ if ((m_bExternalRenderer) && (FAILED(hr = pD3DDev->BeginScene())))
break;
hr = pD3DDev->SetFVF(D3DFVF_XYZRHW | D3DFVF_TEX1);
hr = pD3DDev->DrawPrimitiveUP(D3DPT_TRIANGLESTRIP, 2, pVertices, sizeof(pVertices[0]));
- if(m_bExternalRenderer)
+ if (m_bExternalRenderer)
hr = pD3DDev->EndScene();
//
@@ -339,7 +341,7 @@ STDMETHODIMP CDX9SubPic::AlphaBlt(RECT* pSrc, RECT* pDst, SubPicDesc* pTarget) pD3DDev->SetRenderState(D3DRS_DESTBLEND, db);
return S_OK;
- } while(0);
+ } while (0);
return E_FAIL;
}
@@ -390,7 +392,7 @@ STDMETHODIMP CDX9SubPicAllocator::ChangeDevice(IUnknown* pDev) {
ClearCache();
CComQIPtr<IDirect3DDevice9> pD3DDev = pDev;
- if(!pD3DDev) {
+ if (!pD3DDev) {
return E_NOINTERFACE;
}
@@ -412,7 +414,7 @@ STDMETHODIMP CDX9SubPicAllocator::SetMaxTextureSize(SIZE MaxTextureSize) bool CDX9SubPicAllocator::Alloc(bool fStatic, ISubPic** ppSubPic)
{
- if(!ppSubPic) {
+ if (!ppSubPic) {
return false;
}
@@ -425,12 +427,12 @@ bool CDX9SubPicAllocator::Alloc(bool fStatic, ISubPic** ppSubPic) int Width = m_maxsize.cx;
int Height = m_maxsize.cy;
- if(m_fPow2Textures) {
+ if (m_fPow2Textures) {
Width = Height = 1;
- while(Width < m_maxsize.cx) {
+ while (Width < m_maxsize.cx) {
Width <<= 1;
}
- while(Height < m_maxsize.cy) {
+ while (Height < m_maxsize.cy) {
Height <<= 1;
}
}
@@ -445,17 +447,17 @@ bool CDX9SubPicAllocator::Alloc(bool fStatic, ISubPic** ppSubPic) if (!pSurface) {
CComPtr<IDirect3DTexture9> pTexture;
- if(FAILED(m_pD3DDev->CreateTexture(Width, Height, 1, 0, D3DFMT_A8R8G8B8, fStatic?D3DPOOL_SYSTEMMEM:D3DPOOL_DEFAULT, &pTexture, NULL))) {
+ if (FAILED(m_pD3DDev->CreateTexture(Width, Height, 1, 0, D3DFMT_A8R8G8B8, fStatic?D3DPOOL_SYSTEMMEM:D3DPOOL_DEFAULT, &pTexture, NULL))) {
return false;
}
- if(FAILED(pTexture->GetSurfaceLevel(0, &pSurface))) {
+ if (FAILED(pTexture->GetSurfaceLevel(0, &pSurface))) {
return false;
}
}
*ppSubPic = DNew CDX9SubPic(pSurface, fStatic ? 0 : this, m_bExternalRenderer);
- if(!(*ppSubPic)) {
+ if (!(*ppSubPic)) {
return false;
}
diff --git a/src/SubPic/MemSubPic.cpp b/src/SubPic/MemSubPic.cpp index 8dded33db..e5a7f44fb 100644 --- a/src/SubPic/MemSubPic.cpp +++ b/src/SubPic/MemSubPic.cpp @@ -59,19 +59,19 @@ bool fColorConvInitOK = false; void ColorConvInit()
{
- if(fColorConvInitOK) {
+ if (fColorConvInitOK) {
return;
}
int i;
- for(i = 0; i < 256; i++) {
+ for (i = 0; i < 256; i++) {
Clip_base[i] = 0;
Clip_base[i+256] = i;
Clip_base[i+512] = 255;
}
- for(i = 0; i < 256; i++) {
+ for (i = 0; i < 256; i++) {
c2y_yb[i] = c2y_cyb*i;
c2y_yg[i] = c2y_cyg*i;
c2y_yr[i] = c2y_cyr*i;
@@ -135,12 +135,12 @@ STDMETHODIMP CMemSubPic::GetDesc(SubPicDesc& spd) STDMETHODIMP CMemSubPic::CopyTo(ISubPic* pSubPic)
{
HRESULT hr;
- if(FAILED(hr = __super::CopyTo(pSubPic))) {
+ if (FAILED(hr = __super::CopyTo(pSubPic))) {
return hr;
}
SubPicDesc src, dst;
- if(FAILED(GetDesc(src)) || FAILED(pSubPic->GetDesc(dst))) {
+ if (FAILED(GetDesc(src)) || FAILED(pSubPic->GetDesc(dst))) {
return E_FAIL;
}
@@ -149,7 +149,7 @@ STDMETHODIMP CMemSubPic::CopyTo(ISubPic* pSubPic) BYTE* s = (BYTE*)src.bits + src.pitch*m_rcDirty.top + m_rcDirty.left*4;
BYTE* d = (BYTE*)dst.bits + dst.pitch*m_rcDirty.top + m_rcDirty.left*4;
- for(ptrdiff_t j = 0; j < h; j++, s += src.pitch, d += dst.pitch) {
+ for (ptrdiff_t j = 0; j < h; j++, s += src.pitch, d += dst.pitch) {
memcpy(d, s, w*4);
}
@@ -158,12 +158,12 @@ STDMETHODIMP CMemSubPic::CopyTo(ISubPic* pSubPic) STDMETHODIMP CMemSubPic::ClearDirtyRect(DWORD color)
{
- if(m_rcDirty.IsRectEmpty()) {
+ if (m_rcDirty.IsRectEmpty()) {
return S_FALSE;
}
BYTE* p = (BYTE*)m_spd.bits + m_spd.pitch*m_rcDirty.top + m_rcDirty.left*(m_spd.bpp>>3);
- for(ptrdiff_t j = 0, h = m_rcDirty.Height(); j < h; j++, p += m_spd.pitch) {
+ for (ptrdiff_t j = 0, h = m_rcDirty.Height(); j < h; j++, p += m_spd.pitch) {
int w = m_rcDirty.Width();
#ifdef _WIN64
memsetd(p, color, w*4); // nya
@@ -192,18 +192,18 @@ STDMETHODIMP CMemSubPic::Unlock(RECT* pDirtyRect) {
m_rcDirty = pDirtyRect ? *pDirtyRect : CRect(0,0,m_spd.w,m_spd.h);
- if(m_rcDirty.IsRectEmpty()) {
+ if (m_rcDirty.IsRectEmpty()) {
return S_OK;
}
- if(m_spd.type == MSP_YUY2 || m_spd.type == MSP_YV12 || m_spd.type == MSP_IYUV || m_spd.type == MSP_AYUV) {
+ if (m_spd.type == MSP_YUY2 || m_spd.type == MSP_YV12 || m_spd.type == MSP_IYUV || m_spd.type == MSP_AYUV) {
ColorConvInit();
- if(m_spd.type == MSP_YUY2 || m_spd.type == MSP_YV12 || m_spd.type == MSP_IYUV) {
+ if (m_spd.type == MSP_YUY2 || m_spd.type == MSP_YV12 || m_spd.type == MSP_IYUV) {
m_rcDirty.left &= ~1;
m_rcDirty.right = (m_rcDirty.right+1)&~1;
- if(m_spd.type == MSP_YV12 || m_spd.type == MSP_IYUV) {
+ if (m_spd.type == MSP_YV12 || m_spd.type == MSP_IYUV) {
m_rcDirty.top &= ~1;
m_rcDirty.bottom = (m_rcDirty.bottom+1)&~1;
}
@@ -215,30 +215,30 @@ STDMETHODIMP CMemSubPic::Unlock(RECT* pDirtyRect) BYTE* top = (BYTE*)m_spd.bits + m_spd.pitch*m_rcDirty.top + m_rcDirty.left*4;
BYTE* bottom = top + m_spd.pitch*h;
- if(m_spd.type == MSP_RGB16) {
- for(; top < bottom ; top += m_spd.pitch) {
+ if (m_spd.type == MSP_RGB16) {
+ for (; top < bottom ; top += m_spd.pitch) {
DWORD* s = (DWORD*)top;
DWORD* e = s + w;
- for(; s < e; s++) {
+ for (; s < e; s++) {
*s = ((*s>>3)&0x1f000000)|((*s>>8)&0xf800)|((*s>>5)&0x07e0)|((*s>>3)&0x001f);
// *s = (*s&0xff000000)|((*s>>8)&0xf800)|((*s>>5)&0x07e0)|((*s>>3)&0x001f);
}
}
- } else if(m_spd.type == MSP_RGB15) {
- for(; top < bottom; top += m_spd.pitch) {
+ } else if (m_spd.type == MSP_RGB15) {
+ for (; top < bottom; top += m_spd.pitch) {
DWORD* s = (DWORD*)top;
DWORD* e = s + w;
- for(; s < e; s++) {
+ for (; s < e; s++) {
*s = ((*s>>3)&0x1f000000)|((*s>>9)&0x7c00)|((*s>>6)&0x03e0)|((*s>>3)&0x001f);
// *s = (*s&0xff000000)|((*s>>9)&0x7c00)|((*s>>6)&0x03e0)|((*s>>3)&0x001f);
}
}
- } else if(m_spd.type == MSP_YUY2 || m_spd.type == MSP_YV12 || m_spd.type == MSP_IYUV) {
- for(; top < bottom ; top += m_spd.pitch) {
+ } else if (m_spd.type == MSP_YUY2 || m_spd.type == MSP_YV12 || m_spd.type == MSP_IYUV) {
+ for (; top < bottom ; top += m_spd.pitch) {
BYTE* s = top;
BYTE* e = s + w*4;
- for(; s < e; s+=8) { // ARGB ARGB -> AxYU AxYV
- if((s[3]+s[7]) < 0x1fe) {
+ for (; s < e; s+=8) { // ARGB ARGB -> AxYU AxYV
+ if ((s[3]+s[7]) < 0x1fe) {
s[1] = (c2y_yb[s[0]] + c2y_yg[s[1]] + c2y_yr[s[2]] + 0x108000) >> 16;
s[5] = (c2y_yb[s[4]] + c2y_yg[s[5]] + c2y_yr[s[6]] + 0x108000) >> 16;
@@ -252,12 +252,12 @@ STDMETHODIMP CMemSubPic::Unlock(RECT* pDirtyRect) }
}
}
- } else if(m_spd.type == MSP_AYUV) {
- for(; top < bottom ; top += m_spd.pitch) {
+ } else if (m_spd.type == MSP_AYUV) {
+ for (; top < bottom ; top += m_spd.pitch) {
BYTE* s = top;
BYTE* e = s + w*4;
- for(; s < e; s+=4) { // ARGB -> AYUV
- if(s[3] < 0xff) {
+ for (; s < e; s+=4) { // ARGB -> AYUV
+ if (s[3] < 0xff) {
int y = (c2y_yb[s[0]] + c2y_yg[s[1]] + c2y_yr[s[2]] + 0x108000) >> 16;
int scaled_y = (y-32) * cy_cy;
s[1] = Clip[((((s[0]<<16) - scaled_y) >> 10) * c2y_cu + 0x800000 + 0x8000) >> 16];
@@ -284,10 +284,10 @@ void AlphaBlt_YUY2_SSE2(int w, int h, BYTE* d, int dstpitch, BYTE* s, int srcpit BYTE* s2end = s2 + w*4;
static const __int64 _8181 = 0x0080001000800010i64;
- for(ptrdiff_t j = 0; j < h; j++, s += srcpitch, d += dstpitch) {
- for(; s2 < s2end; s2 += 8, d2++) {
+ for (ptrdiff_t j = 0; j < h; j++, s += srcpitch, d += dstpitch) {
+ for (; s2 < s2end; s2 += 8, d2++) {
ia = (s2[3]+s2[7])>>1;
- if(ia < 0xff) {
+ if (ia < 0xff) {
unsigned int c = (s2[4]<<24)|(s2[5]<<16)|(s2[0]<<8)|s2[1]; // (v<<24)|(y2<<16)|(u<<8)|y1;
ia = (ia<<24)|(s2[7]<<16)|(ia<<8)|s2[3];
@@ -324,10 +324,10 @@ void AlphaBlt_YUY2_MMX(int w, int h, BYTE* d, int dstpitch, BYTE* s, int srcpitc static const __int64 _8181 = 0x0080001000800010i64;
- for(ptrdiff_t j = 0; j < h; j++, s += srcpitch, d += dstpitch) {
- for(; s2 < s2end; s2 += 8, d2++) {
+ for (ptrdiff_t j = 0; j < h; j++, s += srcpitch, d += dstpitch) {
+ for (; s2 < s2end; s2 += 8, d2++) {
ia = (s2[3]+s2[7])>>1;
- if(ia < 0xff) {
+ if (ia < 0xff) {
unsigned int c = (s2[4]<<24)|(s2[5]<<16)|(s2[0]<<8)|s2[1]; // (v<<24)|(y2<<16)|(u<<8)|y1;
ia = (ia<<24)|(s2[7]<<16)|(ia<<8)|s2[3];
__asm {
@@ -364,10 +364,10 @@ void AlphaBlt_YUY2_C(int w, int h, BYTE* d, int dstpitch, BYTE* s, int srcpitch) BYTE* s2end = s2 + w*4;
static const __int64 _8181 = 0x0080001000800010i64;
- for(ptrdiff_t j = 0; j < h; j++, s += srcpitch, d += dstpitch) {
- for(; s2 < s2end; s2 += 8, d2++) {
+ for (ptrdiff_t j = 0; j < h; j++, s += srcpitch, d += dstpitch) {
+ for (; s2 < s2end; s2 += 8, d2++) {
ia = (s2[3]+s2[7])>>1;
- if(ia < 0xff) {
+ if (ia < 0xff) {
//unsigned int c = (s2[4]<<24)|(s2[5]<<16)|(s2[0]<<8)|s2[1]; // (v<<24)|(y2<<16)|(u<<8)|y1;
// YUY2 colorspace fix. rewritten from sse2 asm
@@ -385,26 +385,26 @@ STDMETHODIMP CMemSubPic::AlphaBlt(RECT* pSrc, RECT* pDst, SubPicDesc* pTarget) {
ASSERT(pTarget);
- if(!pSrc || !pDst || !pTarget) {
+ if (!pSrc || !pDst || !pTarget) {
return E_POINTER;
}
const SubPicDesc& src = m_spd;
SubPicDesc dst = *pTarget; // copy, because we might modify it
- if(src.type != dst.type) {
+ if (src.type != dst.type) {
return E_INVALIDARG;
}
CRect rs(*pSrc), rd(*pDst);
- if(dst.h < 0) {
+ if (dst.h < 0) {
dst.h = -dst.h;
rd.bottom = dst.h - rd.bottom;
rd.top = dst.h - rd.top;
}
- if(rs.Width() != rd.Width() || rs.Height() != abs(rd.Height())) {
+ if (rs.Width() != rd.Width() || rs.Height() != abs(rd.Height())) {
return E_INVALIDARG;
}
@@ -413,12 +413,12 @@ STDMETHODIMP CMemSubPic::AlphaBlt(RECT* pSrc, RECT* pDst, SubPicDesc* pTarget) BYTE* s = (BYTE*)src.bits + src.pitch*rs.top + rs.left*4;
BYTE* d = (BYTE*)dst.bits + dst.pitch*rd.top + ((rd.left*dst.bpp)>>3);
- if(rd.top > rd.bottom) {
- if(dst.type == MSP_RGB32 || dst.type == MSP_RGB24
+ if (rd.top > rd.bottom) {
+ if (dst.type == MSP_RGB32 || dst.type == MSP_RGB24
|| dst.type == MSP_RGB16 || dst.type == MSP_RGB15
|| dst.type == MSP_YUY2 || dst.type == MSP_AYUV) {
d = (BYTE*)dst.bits + dst.pitch*(rd.top-1) + (rd.left*dst.bpp>>3);
- } else if(dst.type == MSP_YV12 || dst.type == MSP_IYUV) {
+ } else if (dst.type == MSP_YV12 || dst.type == MSP_IYUV) {
d = (BYTE*)dst.bits + dst.pitch*(rd.top-1) + (rd.left*8>>3);
} else {
return E_NOTIMPL;
@@ -427,14 +427,14 @@ STDMETHODIMP CMemSubPic::AlphaBlt(RECT* pSrc, RECT* pDst, SubPicDesc* pTarget) dst.pitch = -dst.pitch;
}
- switch(dst.type) {
+ switch (dst.type) {
case MSP_RGBA:
- for(ptrdiff_t j = 0; j < h; j++, s += src.pitch, d += dst.pitch) {
+ for (ptrdiff_t j = 0; j < h; j++, s += src.pitch, d += dst.pitch) {
BYTE* s2 = s;
BYTE* s2end = s2 + w*4;
DWORD* d2 = (DWORD*)d;
- for(; s2 < s2end; s2 += 4, d2++) {
- if(s2[3] < 0xff) {
+ for (; s2 < s2end; s2 += 4, d2++) {
+ if (s2[3] < 0xff) {
DWORD bd =0x00000100 -( (DWORD) s2[3]);
DWORD B = ((*((DWORD*)s2)&0x000000ff)<<8)/bd;
DWORD V = ((*((DWORD*)s2)&0x0000ff00)/bd)<<8;
@@ -447,20 +447,20 @@ STDMETHODIMP CMemSubPic::AlphaBlt(RECT* pSrc, RECT* pDst, SubPicDesc* pTarget) break;
case MSP_RGB32:
case MSP_AYUV:
- for(ptrdiff_t j = 0; j < h; j++, s += src.pitch, d += dst.pitch) {
+ for (ptrdiff_t j = 0; j < h; j++, s += src.pitch, d += dst.pitch) {
BYTE* s2 = s;
BYTE* s2end = s2 + w*4;
DWORD* d2 = (DWORD*)d;
- for(; s2 < s2end; s2 += 4, d2++) {
+ for (; s2 < s2end; s2 += 4, d2++) {
#ifdef _WIN64
DWORD ia = 256-s2[3];
- if(s2[3] < 0xff) {
+ if (s2[3] < 0xff) {
*d2 = ((((*d2&0x00ff00ff)*s2[3])>>8) + (((*((DWORD*)s2)&0x00ff00ff)*ia)>>8)&0x00ff00ff)
| ((((*d2&0x0000ff00)*s2[3])>>8) + (((*((DWORD*)s2)&0x0000ff00)*ia)>>8)&0x0000ff00);
}
#else
- if(s2[3] < 0xff) {
+ if (s2[3] < 0xff) {
*d2 = ((((*d2&0x00ff00ff)*s2[3])>>8) + (*((DWORD*)s2)&0x00ff00ff)&0x00ff00ff)
| ((((*d2&0x0000ff00)*s2[3])>>8) + (*((DWORD*)s2)&0x0000ff00)&0x0000ff00);
}
@@ -469,12 +469,12 @@ STDMETHODIMP CMemSubPic::AlphaBlt(RECT* pSrc, RECT* pDst, SubPicDesc* pTarget) }
break;
case MSP_RGB24:
- for(ptrdiff_t j = 0; j < h; j++, s += src.pitch, d += dst.pitch) {
+ for (ptrdiff_t j = 0; j < h; j++, s += src.pitch, d += dst.pitch) {
BYTE* s2 = s;
BYTE* s2end = s2 + w*4;
BYTE* d2 = d;
- for(; s2 < s2end; s2 += 4, d2 += 3) {
- if(s2[3] < 0xff) {
+ for (; s2 < s2end; s2 += 4, d2 += 3) {
+ if (s2[3] < 0xff) {
d2[0] = ((d2[0]*s2[3])>>8) + s2[0];
d2[1] = ((d2[1]*s2[3])>>8) + s2[1];
d2[2] = ((d2[2]*s2[3])>>8) + s2[2];
@@ -483,12 +483,12 @@ STDMETHODIMP CMemSubPic::AlphaBlt(RECT* pSrc, RECT* pDst, SubPicDesc* pTarget) }
break;
case MSP_RGB16:
- for(ptrdiff_t j = 0; j < h; j++, s += src.pitch, d += dst.pitch) {
+ for (ptrdiff_t j = 0; j < h; j++, s += src.pitch, d += dst.pitch) {
BYTE* s2 = s;
BYTE* s2end = s2 + w*4;
WORD* d2 = (WORD*)d;
- for(; s2 < s2end; s2 += 4, d2++) {
- if(s2[3] < 0x1f) {
+ for (; s2 < s2end; s2 += 4, d2++) {
+ if (s2[3] < 0x1f) {
*d2 = (WORD)((((((*d2&0xf81f)*s2[3])>>5) + (*(DWORD*)s2&0xf81f))&0xf81f)
| (((((*d2&0x07e0)*s2[3])>>5) + (*(DWORD*)s2&0x07e0))&0x07e0));
@@ -497,12 +497,12 @@ STDMETHODIMP CMemSubPic::AlphaBlt(RECT* pSrc, RECT* pDst, SubPicDesc* pTarget) }
break;
case MSP_RGB15:
- for(ptrdiff_t j = 0; j < h; j++, s += src.pitch, d += dst.pitch) {
+ for (ptrdiff_t j = 0; j < h; j++, s += src.pitch, d += dst.pitch) {
BYTE* s2 = s;
BYTE* s2end = s2 + w*4;
WORD* d2 = (WORD*)d;
- for(; s2 < s2end; s2 += 4, d2++) {
- if(s2[3] < 0x1f) {
+ for (; s2 < s2end; s2 += 4, d2++) {
+ if (s2[3] < 0x1f) {
*d2 = (WORD)((((((*d2&0x7c1f)*s2[3])>>5) + (*(DWORD*)s2&0x7c1f))&0x7c1f)
| (((((*d2&0x03e0)*s2[3])>>5) + (*(DWORD*)s2&0x03e0))&0x03e0));
}
@@ -523,12 +523,12 @@ STDMETHODIMP CMemSubPic::AlphaBlt(RECT* pSrc, RECT* pDst, SubPicDesc* pTarget) break;
case MSP_YV12:
case MSP_IYUV:
- for(ptrdiff_t j = 0; j < h; j++, s += src.pitch, d += dst.pitch) {
+ for (ptrdiff_t j = 0; j < h; j++, s += src.pitch, d += dst.pitch) {
BYTE* s2 = s;
BYTE* s2end = s2 + w*4;
BYTE* d2 = d;
- for(; s2 < s2end; s2 += 4, d2++) {
- if(s2[3] < 0xff) {
+ for (; s2 < s2end; s2 += 4, d2++) {
+ if (s2[3] < 0xff) {
d2[0] = (((d2[0]-0x10)*s2[3])>>8) + s2[1];
}
}
@@ -540,10 +540,10 @@ STDMETHODIMP CMemSubPic::AlphaBlt(RECT* pSrc, RECT* pDst, SubPicDesc* pTarget) dst.pitch = abs(dst.pitch);
- if(dst.type == MSP_YV12 || dst.type == MSP_IYUV) {
+ if (dst.type == MSP_YV12 || dst.type == MSP_IYUV) {
int h2 = h/2;
- if(!dst.pitchUV) {
+ if (!dst.pitchUV) {
dst.pitchUV = dst.pitch/2;
}
@@ -551,11 +551,11 @@ STDMETHODIMP CMemSubPic::AlphaBlt(RECT* pSrc, RECT* pDst, SubPicDesc* pTarget) ss[0] = (BYTE*)src.bits + src.pitch*rs.top + rs.left*4;
ss[1] = ss[0] + 4;
- if(!dst.bitsU || !dst.bitsV) {
+ if (!dst.bitsU || !dst.bitsV) {
dst.bitsU = (BYTE*)dst.bits + dst.pitch*dst.h;
dst.bitsV = dst.bitsU + dst.pitchUV*dst.h/2;
- if(dst.type == MSP_YV12) {
+ if (dst.type == MSP_YV12) {
BYTE* p = dst.bitsU;
dst.bitsU = dst.bitsV;
dst.bitsV = p;
@@ -566,24 +566,24 @@ STDMETHODIMP CMemSubPic::AlphaBlt(RECT* pSrc, RECT* pDst, SubPicDesc* pTarget) dd[0] = dst.bitsU + dst.pitchUV*rd.top/2 + rd.left/2;
dd[1] = dst.bitsV + dst.pitchUV*rd.top/2 + rd.left/2;
- if(rd.top > rd.bottom) {
+ if (rd.top > rd.bottom) {
dd[0] = dst.bitsU + dst.pitchUV*(rd.top/2-1) + rd.left/2;
dd[1] = dst.bitsV + dst.pitchUV*(rd.top/2-1) + rd.left/2;
dst.pitchUV = -dst.pitchUV;
}
- for(ptrdiff_t i = 0; i < 2; i++) {
+ for (ptrdiff_t i = 0; i < 2; i++) {
s = ss[i];
d = dd[i];
BYTE* is = ss[1-i];
- for(ptrdiff_t j = 0; j < h2; j++, s += src.pitch*2, d += dst.pitchUV, is += src.pitch*2) {
+ for (ptrdiff_t j = 0; j < h2; j++, s += src.pitch*2, d += dst.pitchUV, is += src.pitch*2) {
BYTE* s2 = s;
BYTE* s2end = s2 + w*4;
BYTE* d2 = d;
BYTE* is2 = is;
- for(; s2 < s2end; s2 += 8, d2++, is2 += 8) {
+ for (; s2 < s2end; s2 += 8, d2++, is2 += 8) {
unsigned int ia = (s2[3]+s2[3+src.pitch]+is2[3]+is2[3+src.pitch])>>2;
- if(ia < 0xff) {
+ if (ia < 0xff) {
*d2 = (((*d2-0x80)*ia)>>8) + ((s2[0]+s2[src.pitch])>>1);
}
}
@@ -614,7 +614,7 @@ CMemSubPicAllocator::CMemSubPicAllocator(int type, SIZE maxsize) bool CMemSubPicAllocator::Alloc(bool fStatic, ISubPic** ppSubPic)
{
- if(!ppSubPic) {
+ if (!ppSubPic) {
return false;
}
@@ -625,12 +625,12 @@ bool CMemSubPicAllocator::Alloc(bool fStatic, ISubPic** ppSubPic) spd.pitch = (spd.w*spd.bpp)>>3;
spd.type = m_type;
spd.bits = DNew BYTE[spd.pitch*spd.h];
- if(!spd.bits) {
+ if (!spd.bits) {
return false;
}
*ppSubPic = DNew CMemSubPic(spd);
- if(!(*ppSubPic)) {
+ if (!(*ppSubPic)) {
return false;
}
diff --git a/src/SubPic/SubPicAllocatorPresenterImpl.cpp b/src/SubPic/SubPicAllocatorPresenterImpl.cpp index 2d90c85fd..9a2d6c506 100644 --- a/src/SubPic/SubPicAllocatorPresenterImpl.cpp +++ b/src/SubPic/SubPicAllocatorPresenterImpl.cpp @@ -35,7 +35,7 @@ CSubPicAllocatorPresenterImpl::CSubPicAllocatorPresenterImpl(HWND hWnd, HRESULT& , m_bDeviceResetRequested(false)
, m_bPendingResetDevice(false)
{
- if(!IsWindow(m_hWnd)) {
+ if (!IsWindow(m_hWnd)) {
hr = E_INVALIDARG;
if (_pError) {
*_pError += "Invalid window handle in ISubPicAllocatorPresenterImpl\n";
@@ -63,7 +63,7 @@ STDMETHODIMP CSubPicAllocatorPresenterImpl::NonDelegatingQueryInterface(REFIID r void CSubPicAllocatorPresenterImpl::AlphaBltSubPic(CSize size, SubPicDesc* pTarget)
{
CComPtr<ISubPic> pSubPic;
- if(m_pSubPicQueue->LookupSubPic(m_rtNow, pSubPic)) {
+ if (m_pSubPicQueue->LookupSubPic(m_rtNow, pSubPic)) {
CRect rcSource, rcDest;
if (SUCCEEDED (pSubPic->GetSourceAndDest(&size, rcSource, rcDest))) {
pSubPic->AlphaBlt(rcSource, rcDest, pTarget);
@@ -97,7 +97,7 @@ STDMETHODIMP_(SIZE) CSubPicAllocatorPresenterImpl::GetVideoSize(bool fCorrectAR) {
CSize VideoSize(GetVisibleVideoSize());
- if(fCorrectAR && m_AspectRatio.cx > 0 && m_AspectRatio.cy > 0) {
+ if (fCorrectAR && m_AspectRatio.cx > 0 && m_AspectRatio.cy > 0) {
VideoSize.cx = (LONGLONG(VideoSize.cy)*LONGLONG(m_AspectRatio.cx))/LONGLONG(m_AspectRatio.cy);
}
@@ -115,18 +115,18 @@ STDMETHODIMP_(void) CSubPicAllocatorPresenterImpl::SetPosition(RECT w, RECT v) m_VideoRect = v;
- if(fWindowSizeChanged || fVideoRectChanged) {
- if(m_pAllocator) {
+ if (fWindowSizeChanged || fVideoRectChanged) {
+ if (m_pAllocator) {
m_pAllocator->SetCurSize(m_WindowRect.Size());
m_pAllocator->SetCurVidRect(m_VideoRect);
}
- if(m_pSubPicQueue) {
+ if (m_pSubPicQueue) {
m_pSubPicQueue->Invalidate();
}
}
- if(fWindowPosChanged || fVideoRectChanged) {
+ if (fWindowPosChanged || fVideoRectChanged) {
Paint(fWindowSizeChanged || fVideoRectChanged);
}
}
@@ -139,7 +139,7 @@ STDMETHODIMP_(void) CSubPicAllocatorPresenterImpl::SetTime(REFERENCE_TIME rtNow) */
m_rtNow = rtNow - m_rtSubtitleDelay;
- if(m_pSubPicQueue) {
+ if (m_pSubPicQueue) {
m_pSubPicQueue->SetTime(m_rtNow);
}
}
@@ -163,14 +163,14 @@ STDMETHODIMP_(void) CSubPicAllocatorPresenterImpl::SetSubPicProvider(ISubPicProv {
m_SubPicProvider = pSubPicProvider;
- if(m_pSubPicQueue) {
+ if (m_pSubPicQueue) {
m_pSubPicQueue->SetSubPicProvider(pSubPicProvider);
}
}
STDMETHODIMP_(void) CSubPicAllocatorPresenterImpl::Invalidate(REFERENCE_TIME rtInvalidate)
{
- if(m_pSubPicQueue) {
+ if (m_pSubPicQueue) {
m_pSubPicQueue->Invalidate(rtInvalidate);
}
}
@@ -187,7 +187,7 @@ void CSubPicAllocatorPresenterImpl::Transform(CRect r, Vector v[4]) Vector center(r.CenterPoint().x, r.CenterPoint().y, 0);
int l = (int)(Vector(r.Size().cx, r.Size().cy, 0).Length()*1.5f)+1;
- for(ptrdiff_t i = 0; i < 4; i++) {
+ for (ptrdiff_t i = 0; i < 4; i++) {
v[i] = m_xform << (v[i] - center);
v[i].z = v[i].z / l + 0.5f;
v[i].x /= v[i].z*2;
@@ -199,7 +199,7 @@ void CSubPicAllocatorPresenterImpl::Transform(CRect r, Vector v[4]) STDMETHODIMP CSubPicAllocatorPresenterImpl::SetVideoAngle(Vector v, bool fRepaint)
{
m_xform = XForm(Ray(Vector(0, 0, 0), v), Vector(1, 1, 1), false);
- if(fRepaint) {
+ if (fRepaint) {
Paint(true);
}
return S_OK;
diff --git a/src/SubPic/SubPicImpl.cpp b/src/SubPic/SubPicImpl.cpp index 66b85b03f..8d96132f5 100644 --- a/src/SubPic/SubPicImpl.cpp +++ b/src/SubPic/SubPicImpl.cpp @@ -97,7 +97,7 @@ STDMETHODIMP_(void) CSubPicImpl::SetStop(REFERENCE_TIME rtStop) STDMETHODIMP CSubPicImpl::CopyTo(ISubPic* pSubPic)
{
- if(!pSubPic) {
+ if (!pSubPic) {
return E_POINTER;
}
@@ -122,7 +122,7 @@ STDMETHODIMP CSubPicImpl::GetSourceAndDest(SIZE* pSize, RECT* pRcSource, RECT* p CheckPointer (pRcSource, E_POINTER);
CheckPointer (pRcDest, E_POINTER);
- if(m_size.cx > 0 && m_size.cy > 0) {
+ if (m_size.cx > 0 && m_size.cy > 0) {
CRect rcTemp = m_rcDirty;
// FIXME
@@ -157,17 +157,17 @@ STDMETHODIMP CSubPicImpl::SetSize(SIZE size, RECT vidrect) m_size = size;
m_vidrect = vidrect;
- if(m_size.cx > m_maxsize.cx) {
+ if (m_size.cx > m_maxsize.cx) {
m_size.cy = MulDiv(m_size.cy, m_maxsize.cx, m_size.cx);
m_size.cx = m_maxsize.cx;
}
- if(m_size.cy > m_maxsize.cy) {
+ if (m_size.cy > m_maxsize.cy) {
m_size.cx = MulDiv(m_size.cx, m_maxsize.cy, m_size.cy);
m_size.cy = m_maxsize.cy;
}
- if(m_size.cx != size.cx || m_size.cy != size.cy) {
+ if (m_size.cx != size.cx || m_size.cy != size.cy) {
m_vidrect.top = MulDiv(m_vidrect.top, m_size.cx, size.cx);
m_vidrect.bottom = MulDiv(m_vidrect.bottom, m_size.cx, size.cx);
m_vidrect.left = MulDiv(m_vidrect.left, m_size.cy, size.cy);
@@ -222,12 +222,12 @@ STDMETHODIMP CSubPicAllocatorImpl::SetCurVidRect(RECT curvidrect) STDMETHODIMP CSubPicAllocatorImpl::GetStatic(ISubPic** ppSubPic)
{
- if(!ppSubPic) {
+ if (!ppSubPic) {
return E_POINTER;
}
- if(!m_pStatic) {
- if(!Alloc(true, &m_pStatic) || !m_pStatic) {
+ if (!m_pStatic) {
+ if (!Alloc(true, &m_pStatic) || !m_pStatic) {
return E_OUTOFMEMORY;
}
}
@@ -241,11 +241,11 @@ STDMETHODIMP CSubPicAllocatorImpl::GetStatic(ISubPic** ppSubPic) STDMETHODIMP CSubPicAllocatorImpl::AllocDynamic(ISubPic** ppSubPic)
{
- if(!ppSubPic) {
+ if (!ppSubPic) {
return E_POINTER;
}
- if(!Alloc(false, ppSubPic) || !*ppSubPic) {
+ if (!Alloc(false, ppSubPic) || !*ppSubPic) {
return E_OUTOFMEMORY;
}
diff --git a/src/SubPic/SubPicQueueImpl.cpp b/src/SubPic/SubPicQueueImpl.cpp index 15cea2d48..eaad3ccd9 100644 --- a/src/SubPic/SubPicQueueImpl.cpp +++ b/src/SubPic/SubPicQueueImpl.cpp @@ -36,12 +36,12 @@ CSubPicQueueImpl::CSubPicQueueImpl(ISubPicAllocator* pAllocator, HRESULT* phr) , m_rtNowLast(0)
, m_fps(25.0)
{
- if(phr) {
+ if (phr) {
*phr = S_OK;
}
- if(!m_pAllocator) {
- if(phr) {
+ if (!m_pAllocator) {
+ if (phr) {
*phr = E_FAIL;
}
return;
@@ -77,13 +77,13 @@ STDMETHODIMP CSubPicQueueImpl::SetSubPicProvider(ISubPicProvider* pSubPicProvide STDMETHODIMP CSubPicQueueImpl::GetSubPicProvider(ISubPicProvider** pSubPicProvider)
{
- if(!pSubPicProvider) {
+ if (!pSubPicProvider) {
return E_POINTER;
}
CAutoLock cAutoLock(&m_csSubPicProvider);
- if(m_pSubPicProvider) {
+ if (m_pSubPicProvider) {
*pSubPicProvider = m_pSubPicProvider;
(*pSubPicProvider)->AddRef();
}
@@ -111,12 +111,12 @@ HRESULT CSubPicQueueImpl::RenderTo(ISubPic* pSubPic, REFERENCE_TIME rtStart, REF {
HRESULT hr = E_FAIL;
- if(!pSubPic) {
+ if (!pSubPic) {
return hr;
}
CComPtr<ISubPicProvider> pSubPicProvider;
- if(FAILED(GetSubPicProvider(&pSubPicProvider)) || !pSubPicProvider) {
+ if (FAILED(GetSubPicProvider(&pSubPicProvider)) || !pSubPicProvider) {
return hr;
}
@@ -149,19 +149,19 @@ CSubPicQueue::CSubPicQueue(int nMaxSubPic, BOOL bDisableAnim, ISubPicAllocator* ,m_rtQueueMin(0)
,m_rtQueueMax(0)
{
- if(phr && FAILED(*phr)) {
+ if (phr && FAILED(*phr)) {
return;
}
- if(m_nMaxSubPic < 1) {
- if(phr) {
+ if (m_nMaxSubPic < 1) {
+ if (phr) {
*phr = E_INVALIDARG;
}
return;
}
m_fBreakBuffering = false;
- for(ptrdiff_t i = 0; i < EVENT_COUNT; i++) {
+ for (ptrdiff_t i = 0; i < EVENT_COUNT; i++) {
m_ThreadEvents[i] = CreateEvent(NULL, FALSE, FALSE, NULL);
}
CAMThread::Create();
@@ -172,7 +172,7 @@ CSubPicQueue::~CSubPicQueue() m_fBreakBuffering = true;
SetEvent(m_ThreadEvents[EVENT_EXIT]);
CAMThread::Close();
- for(ptrdiff_t i = 0; i < EVENT_COUNT; i++) {
+ for (ptrdiff_t i = 0; i < EVENT_COUNT; i++) {
CloseHandle(m_ThreadEvents[i]);
}
}
@@ -182,7 +182,7 @@ CSubPicQueue::~CSubPicQueue() STDMETHODIMP CSubPicQueue::SetFPS(double fps)
{
HRESULT hr = __super::SetFPS(fps);
- if(FAILED(hr)) {
+ if (FAILED(hr)) {
return hr;
}
@@ -194,7 +194,7 @@ STDMETHODIMP CSubPicQueue::SetFPS(double fps) STDMETHODIMP CSubPicQueue::SetTime(REFERENCE_TIME rtNow)
{
HRESULT hr = __super::SetTime(rtNow);
- if(FAILED(hr)) {
+ if (FAILED(hr)) {
return hr;
}
@@ -231,12 +231,12 @@ STDMETHODIMP_(bool) CSubPicQueue::LookupSubPic(REFERENCE_TIME rtNow, CComPtr<ISu #if DSubPicTraceLevel > 2
TRACE("Find: ");
#endif
- while(pos) {
+ while (pos) {
CComPtr<ISubPic> pSubPic = m_Queue.GetNext(pos);
REFERENCE_TIME rtStart = pSubPic->GetStart();
REFERENCE_TIME rtStop = pSubPic->GetStop();
REFERENCE_TIME rtSegmentStop = pSubPic->GetSegmentStop();
- if(rtNow >= rtStart && rtNow < rtSegmentStop) {
+ if (rtNow >= rtStart && rtNow < rtSegmentStop) {
REFERENCE_TIME Diff = rtNow - rtStop;
if (Diff < rtBestStop) {
rtBestStop = Diff;
@@ -300,8 +300,8 @@ STDMETHODIMP CSubPicQueue::GetStats(int nSubPic, REFERENCE_TIME& rtStart, REFERE rtStart = rtStop = -1;
- if(nSubPic >= 0 && nSubPic < (int)m_Queue.GetCount()) {
- if(POSITION pos = m_Queue.FindIndex(nSubPic)) {
+ if (nSubPic >= 0 && nSubPic < (int)m_Queue.GetCount()) {
+ if (POSITION pos = m_Queue.FindIndex(nSubPic)) {
rtStart = m_Queue.GetAt(pos)->GetStart();
rtStop = m_Queue.GetAt(pos)->GetStop();
}
@@ -334,13 +334,13 @@ REFERENCE_TIME CSubPicQueue::UpdateQueue() {
POSITION Iter = m_Queue.GetHeadPosition();
REFERENCE_TIME rtBestStop = 0x7fffffffffffffffi64;
- while(Iter) {
+ while (Iter) {
POSITION ThisPos = Iter;
ISubPic *pSubPic = m_Queue.GetNext(Iter);
REFERENCE_TIME rtStart = pSubPic->GetStart();
REFERENCE_TIME rtStop = pSubPic->GetStop();
REFERENCE_TIME rtSegmentStop = pSubPic->GetSegmentStop();
- if(rtNow >= rtStart && rtNow < rtSegmentStop) {
+ if (rtNow >= rtStart && rtNow < rtSegmentStop) {
REFERENCE_TIME Diff = rtNow - rtStop;
if (Diff < rtBestStop) {
rtBestStop = Diff;
@@ -360,7 +360,7 @@ REFERENCE_TIME CSubPicQueue::UpdateQueue() #endif
{
POSITION Iter = m_Queue.GetHeadPosition();
- while(Iter) {
+ while (Iter) {
POSITION ThisPos = Iter;
ISubPic *pSubPic = m_Queue.GetNext(Iter);
@@ -408,7 +408,7 @@ DWORD CSubPicQueue::ThreadProc() SetThreadPriority(m_hThread, bDisableAnim ? THREAD_PRIORITY_LOWEST : THREAD_PRIORITY_ABOVE_NORMAL/*THREAD_PRIORITY_BELOW_NORMAL*/);
bool bAgain = true;
- while(1) {
+ while (1) {
DWORD Ret = WaitForMultipleObjects(EVENT_COUNT, m_ThreadEvents, FALSE, bAgain ? 0 : INFINITE);
bAgain = false;
@@ -424,26 +424,26 @@ DWORD CSubPicQueue::ThreadProc() int nMaxSubPic = m_nMaxSubPic;
CComPtr<ISubPicProvider> pSubPicProvider;
- if(SUCCEEDED(GetSubPicProvider(&pSubPicProvider)) && pSubPicProvider
+ if (SUCCEEDED(GetSubPicProvider(&pSubPicProvider)) && pSubPicProvider
&& SUCCEEDED(pSubPicProvider->Lock())) {
- for(POSITION pos = pSubPicProvider->GetStartPosition(rtNow, fps);
+ for (POSITION pos = pSubPicProvider->GetStartPosition(rtNow, fps);
pos && !m_fBreakBuffering && GetQueueCount() < nMaxSubPic;
pos = pSubPicProvider->GetNext(pos)) {
REFERENCE_TIME rtStart = pSubPicProvider->GetStart(pos, fps);
REFERENCE_TIME rtStop = pSubPicProvider->GetStop(pos, fps);
- if(m_rtNow >= rtStart) {
+ if (m_rtNow >= rtStart) {
// m_fBufferUnderrun = true;
- if(m_rtNow >= rtStop) {
+ if (m_rtNow >= rtStop) {
continue;
}
}
- if(rtStart >= m_rtNow + 60*10000000i64) { // we are already one minute ahead, this should be enough
+ if (rtStart >= m_rtNow + 60*10000000i64) { // we are already one minute ahead, this should be enough
break;
}
- if(rtNow < rtStop) {
+ if (rtNow < rtStop) {
REFERENCE_TIME rtCurrent = max(rtNow, rtStart);
bool bIsAnimated = pSubPicProvider->IsAnimated(pos) && !bDisableAnim;
while (rtCurrent < rtStop) {
@@ -456,7 +456,7 @@ DWORD CSubPicQueue::ThreadProc() }
CComPtr<ISubPic> pStatic;
- if(FAILED(m_pAllocator->GetStatic(&pStatic))) {
+ if (FAILED(m_pAllocator->GetStatic(&pStatic))) {
break;
}
@@ -488,16 +488,16 @@ DWORD CSubPicQueue::ThreadProc() }
#endif
- if(FAILED(hr)) {
+ if (FAILED(hr)) {
break;
}
- if(S_OK != hr) { // subpic was probably empty
+ if (S_OK != hr) { // subpic was probably empty
continue;
}
CComPtr<ISubPic> pDynamic;
- if(FAILED(m_pAllocator->AllocDynamic(&pDynamic))
+ if (FAILED(m_pAllocator->AllocDynamic(&pDynamic))
|| FAILED(pStatic->CopyTo(pDynamic))) {
break;
}
@@ -519,14 +519,14 @@ DWORD CSubPicQueue::ThreadProc() pSubPicProvider->Unlock();
}
- if(m_fBreakBuffering) {
+ if (m_fBreakBuffering) {
bAgain = true;
CAutoLock cQueueLock(&m_csQueueLock);
REFERENCE_TIME rtInvalidate = m_rtInvalidate;
POSITION Iter = m_Queue.GetHeadPosition();
- while(Iter) {
+ while (Iter) {
POSITION ThisPos = Iter;
ISubPic *pSubPic = m_Queue.GetNext(Iter);
@@ -591,8 +591,8 @@ STDMETHODIMP_(bool) CSubPicQueueNoThread::LookupSubPic(REFERENCE_TIME rtNow, CCo {
CAutoLock cAutoLock(&m_csLock);
- if(!m_pSubPic) {
- if(FAILED(m_pAllocator->AllocDynamic(&m_pSubPic))) {
+ if (!m_pSubPic) {
+ if (FAILED(m_pAllocator->AllocDynamic(&m_pSubPic))) {
return false;
}
}
@@ -600,7 +600,7 @@ STDMETHODIMP_(bool) CSubPicQueueNoThread::LookupSubPic(REFERENCE_TIME rtNow, CCo pSubPic = m_pSubPic;
}
- if(pSubPic->GetStart() <= rtNow && rtNow < pSubPic->GetStop()) {
+ if (pSubPic->GetStart() <= rtNow && rtNow < pSubPic->GetStop()) {
ppSubPic = pSubPic;
} else {
CComPtr<ISubPicProvider> pSubPicProvider;
@@ -609,16 +609,16 @@ STDMETHODIMP_(bool) CSubPicQueueNoThread::LookupSubPic(REFERENCE_TIME rtNow, CCo double fps = m_fps;
POSITION pos = pSubPicProvider->GetStartPosition(rtNow, fps);
- if(pos != 0) {
+ if (pos != 0) {
REFERENCE_TIME rtStart = pSubPicProvider->GetStart(pos, fps);
REFERENCE_TIME rtStop = pSubPicProvider->GetStop(pos, fps);
- if(pSubPicProvider->IsAnimated(pos)) {
+ if (pSubPicProvider->IsAnimated(pos)) {
rtStart = rtNow;
rtStop = rtNow+1;
}
- if(rtStart <= rtNow && rtNow < rtStop) {
+ if (rtStart <= rtNow && rtNow < rtStop) {
SIZE MaxTextureSize, VirtualSize;
POINT VirtualTopLeft;
HRESULT hr2;
@@ -626,20 +626,20 @@ STDMETHODIMP_(bool) CSubPicQueueNoThread::LookupSubPic(REFERENCE_TIME rtNow, CCo m_pAllocator->SetMaxTextureSize(MaxTextureSize);
}
- if(m_pAllocator->IsDynamicWriteOnly()) {
+ if (m_pAllocator->IsDynamicWriteOnly()) {
CComPtr<ISubPic> pStatic;
HRESULT hr = m_pAllocator->GetStatic(&pStatic);
- if(SUCCEEDED(hr)) {
+ if (SUCCEEDED(hr)) {
hr = RenderTo(pStatic, rtStart, rtStop, fps, false);
}
- if(SUCCEEDED(hr)) {
+ if (SUCCEEDED(hr)) {
hr = pStatic->CopyTo(pSubPic);
}
- if(SUCCEEDED(hr)) {
+ if (SUCCEEDED(hr)) {
ppSubPic = pSubPic;
}
} else {
- if(SUCCEEDED(RenderTo(m_pSubPic, rtStart, rtStop, fps, false))) {
+ if (SUCCEEDED(RenderTo(m_pSubPic, rtStart, rtStop, fps, false))) {
ppSubPic = pSubPic;
}
}
@@ -649,7 +649,7 @@ STDMETHODIMP_(bool) CSubPicQueueNoThread::LookupSubPic(REFERENCE_TIME rtNow, CCo }
}
- if(ppSubPic) {
+ if (ppSubPic) {
CAutoLock cAutoLock(&m_csLock);
m_pSubPic = ppSubPic;
@@ -668,7 +668,7 @@ STDMETHODIMP CSubPicQueueNoThread::GetStats(int& nSubPics, REFERENCE_TIME& rtNow rtNow = m_rtNow;
rtStart = rtStop = 0;
- if(m_pSubPic) {
+ if (m_pSubPic) {
nSubPics = 1;
rtStart = m_pSubPic->GetStart();
rtStop = m_pSubPic->GetStop();
@@ -681,7 +681,7 @@ STDMETHODIMP CSubPicQueueNoThread::GetStats(int nSubPic, REFERENCE_TIME& rtStart {
CAutoLock cAutoLock(&m_csLock);
- if(!m_pSubPic || nSubPic != 0) {
+ if (!m_pSubPic || nSubPic != 0) {
return E_INVALIDARG;
}
diff --git a/src/Subtitles/CCDecoder.cpp b/src/Subtitles/CCDecoder.cpp index 60b4d2fd1..dc917801a 100644 --- a/src/Subtitles/CCDecoder.cpp +++ b/src/Subtitles/CCDecoder.cpp @@ -34,14 +34,14 @@ CCDecoder::CCDecoder(CString fn, CString rawfn) : m_fn(fn), m_rawfn(rawfn) memset(m_disp, 0, sizeof(m_disp));
m_cursor = CPoint(0, 0);
- if(!m_rawfn.IsEmpty()) {
+ if (!m_rawfn.IsEmpty()) {
_tremove(m_rawfn);
}
}
CCDecoder::~CCDecoder()
{
- if(!m_sts.IsEmpty() && !m_fn.IsEmpty()) {
+ if (!m_sts.IsEmpty() && !m_fn.IsEmpty()) {
m_sts.Sort();
m_sts.SaveAs(m_fn, EXTSRT, -1, CTextFile::ASCII);
m_sts.SaveAs(m_fn.Left(m_fn.ReverseFind('.')+1) + _T("utf8.srt"), EXTSRT, -1, CTextFile::UTF8);
@@ -53,16 +53,16 @@ CCDecoder::~CCDecoder() void CCDecoder::MoveCursor(int x, int y)
{
m_cursor = CPoint(x, y);
- if(m_cursor.x < 0) {
+ if (m_cursor.x < 0) {
m_cursor.x = 0;
}
- if(m_cursor.y < 0) {
+ if (m_cursor.y < 0) {
m_cursor.y = 0;
}
- if(m_cursor.x >= 32) {
+ if (m_cursor.x >= 32) {
m_cursor.x = 0, m_cursor.y++;
}
- if(m_cursor.y >= 16) {
+ if (m_cursor.y >= 16) {
m_cursor.y = 0;
}
}
@@ -82,13 +82,13 @@ void CCDecoder::SaveDisp(__int64 time) {
CStringW str;
- for(ptrdiff_t row = 0; row < 16; row++) {
+ for (ptrdiff_t row = 0; row < 16; row++) {
bool fNonEmptyRow = false;
- for(ptrdiff_t col = 0; col < 32; col++) {
- if(m_disp[row][col]) {
+ for (ptrdiff_t col = 0; col < 32; col++) {
+ if (m_disp[row][col]) {
CStringW str2(&m_disp[row][col]);
- if(fNonEmptyRow) {
+ if (fNonEmptyRow) {
str += ' ';
}
str += str2;
@@ -97,12 +97,12 @@ void CCDecoder::SaveDisp(__int64 time) }
}
- if(fNonEmptyRow) {
+ if (fNonEmptyRow) {
str += '\n';
}
}
- if(str.IsEmpty()) {
+ if (str.IsEmpty()) {
return;
}
@@ -111,33 +111,33 @@ void CCDecoder::SaveDisp(__int64 time) void CCDecoder::DecodeCC(BYTE* buff, int len, __int64 time)
{
- if(!m_rawfn.IsEmpty()) {
- if(FILE* f = _tfopen(m_rawfn, _T("at"))) {
+ if (!m_rawfn.IsEmpty()) {
+ if (FILE* f = _tfopen(m_rawfn, _T("at"))) {
_ftprintf(f, _T("%02d:%02d:%02d.%03d\n"),
(int)(time/1000/60/60),
(int)((time/1000/60)%60),
(int)((time/1000)%60),
(int)(time%1000));
- for(ptrdiff_t i = 0; i < len; i++) {
+ for (ptrdiff_t i = 0; i < len; i++) {
_ftprintf(f, _T("%02x"), buff[i]);
- if(i < len-1) {
+ if (i < len-1) {
_ftprintf(f, _T(" "));
}
- if(i > 0 && (i&15)==15) {
+ if (i > 0 && (i&15)==15) {
_ftprintf(f, _T("\n"));
}
}
- if(len > 0) {
+ if (len > 0) {
_ftprintf(f, _T("\n\n"));
}
fclose(f);
}
}
- for(ptrdiff_t i = 0; i < len; i++) {
+ for (ptrdiff_t i = 0; i < len; i++) {
BYTE c = buff[i]&0x7f;
- if(c >= 0x20) {
+ if (c >= 0x20) {
static WCHAR charmap[0x60] = {
' ','!','"','#','$','%','&','\'','(',')',0xE1,'+',',','-','.','/',
'0','1','2','3','4','5','6','7','8','9',':',';','<','=','>',0x3F,
@@ -148,18 +148,18 @@ void CCDecoder::DecodeCC(BYTE* buff, int len, __int64 time) };
PutChar(charmap[c - 0x20]);
- } else if(buff[i] != 0x80 && i < len-1) {
+ } else if (buff[i] != 0x80 && i < len-1) {
// codes and special characters are supposed to be doubled
- if(i < len-3 && buff[i] == buff[i+2] && buff[i+1] == buff[i+3]) {
+ if (i < len-3 && buff[i] == buff[i+2] && buff[i+1] == buff[i+3]) {
i += 2;
}
c = buff[i+1]&0x7f;
- if(buff[i] == 0x91 && c >= 0x20 && c < 0x30) { // formating
+ if (buff[i] == 0x91 && c >= 0x20 && c < 0x30) { // formating
// TODO
- } else if(buff[i] == 0x91 && c == 0x39) { // transparent space
+ } else if (buff[i] == 0x91 && c == 0x39) { // transparent space
OffsetCursor(1, 0);
- } else if(buff[i] == 0x91 && c >= 0x30 && c < 0x40) { // special characters
+ } else if (buff[i] == 0x91 && c >= 0x30 && c < 0x40) { // special characters
static WCHAR charmap[0x10] = {
0x00ae, // (r)egistered
0x00b0, // degree
@@ -180,7 +180,7 @@ void CCDecoder::DecodeCC(BYTE* buff, int len, __int64 time) };
PutChar(charmap[c - 0x30]);
- } else if(buff[i] == 0x92 && c >= 0x20 && c < 0x40) { // extended characters
+ } else if (buff[i] == 0x92 && c >= 0x20 && c < 0x40) { // extended characters
static WCHAR charmap[0x20] = {
0x00c0, // A'
0x00c9, // E'
@@ -218,7 +218,7 @@ void CCDecoder::DecodeCC(BYTE* buff, int len, __int64 time) };
PutChar(charmap[c - 0x20]);
- } else if(buff[i] == 0x13 && c >= 0x20 && c < 0x40) { // more extended characters
+ } else if (buff[i] == 0x13 && c >= 0x20 && c < 0x40) { // more extended characters
static WCHAR charmap[0x20] = {
0x00c3, // A~
0x00e3, // a~
@@ -256,13 +256,13 @@ void CCDecoder::DecodeCC(BYTE* buff, int len, __int64 time) };
PutChar(charmap[c - 0x20]);
- } else if(buff[i] == 0x94 && buff[i+1] == 0xae) { // Erase Non-displayed [buffer] Memory
+ } else if (buff[i] == 0x94 && buff[i+1] == 0xae) { // Erase Non-displayed [buffer] Memory
memset(m_buff, 0, sizeof(m_buff));
- } else if(buff[i] == 0x94 && buff[i+1] == 0x20) { // Resume Caption Loading
+ } else if (buff[i] == 0x94 && buff[i+1] == 0x20) { // Resume Caption Loading
memset(m_buff, 0, sizeof(m_buff));
- } else if(buff[i] == 0x94 && buff[i+1] == 0x2f) { // End Of Caption
- if(memcmp(m_disp, m_buff, sizeof(m_disp)) != 0) {
- if(m_fEndOfCaption) {
+ } else if (buff[i] == 0x94 && buff[i+1] == 0x2f) { // End Of Caption
+ if (memcmp(m_disp, m_buff, sizeof(m_disp)) != 0) {
+ if (m_fEndOfCaption) {
SaveDisp(time + (i/2)*1000/30);
}
@@ -270,19 +270,19 @@ void CCDecoder::DecodeCC(BYTE* buff, int len, __int64 time) memcpy(m_disp, m_buff, sizeof(m_disp));
m_time = time + (i/2)*1000/30;
}
- } else if(buff[i] == 0x94 && buff[i+1] == 0x2c) { // Erase Displayed Memory
- if(m_fEndOfCaption) {
+ } else if (buff[i] == 0x94 && buff[i+1] == 0x2c) { // Erase Displayed Memory
+ if (m_fEndOfCaption) {
m_fEndOfCaption = false;
SaveDisp(time + (i/2)*1000/30);
}
memset(m_disp, 0, sizeof(m_disp));
- } else if(buff[i] == 0x97 && (buff[i+1] == 0xa1 || buff[i+1] == 0xa2 || buff[i+1] == 0x23)) { // Tab Over
+ } else if (buff[i] == 0x97 && (buff[i+1] == 0xa1 || buff[i+1] == 0xa2 || buff[i+1] == 0x23)) { // Tab Over
OffsetCursor(buff[i+1]&3, 0);
- } else if(buff[i] == 0x91 || buff[i] == 0x92 || buff[i] == 0x15 || buff[i] == 0x16
- || buff[i] == 0x97 || buff[i] == 0x10 || buff[i] == 0x13 || buff[i] == 0x94) { // curpos, color, underline
+ } else if (buff[i] == 0x91 || buff[i] == 0x92 || buff[i] == 0x15 || buff[i] == 0x16
+ || buff[i] == 0x97 || buff[i] == 0x10 || buff[i] == 0x13 || buff[i] == 0x94) { // curpos, color, underline
int row = 0;
- switch(buff[i]) {
+ switch (buff[i]) {
default:
case 0x91:
row = 0;
@@ -309,12 +309,12 @@ void CCDecoder::DecodeCC(BYTE* buff, int len, __int64 time) row = 14;
break;
}
- if(buff[i+1]&0x20) {
+ if (buff[i+1]&0x20) {
row++;
}
int col = buff[i+1]&0xe;
- if(col == 0 || (col > 0 && !(buff[i+1]&0x10))) {
+ if (col == 0 || (col > 0 && !(buff[i+1]&0x10))) {
col = 0;
} else {
col <<= 1;
@@ -330,21 +330,21 @@ void CCDecoder::DecodeCC(BYTE* buff, int len, __int64 time) void CCDecoder::ExtractCC(BYTE* buff, int len, __int64 time)
{
- for(ptrdiff_t i = 0; i < len-9; i++) {
- if(*(DWORD*)&buff[i] == 0xb2010000 && *(DWORD*)&buff[i+4] == 0xf8014343) {
+ for (ptrdiff_t i = 0; i < len-9; i++) {
+ if (*(DWORD*)&buff[i] == 0xb2010000 && *(DWORD*)&buff[i+4] == 0xf8014343) {
i += 8;
int nBytes = buff[i++]&0x3f;
- if(nBytes > 0) {
+ if (nBytes > 0) {
nBytes = (nBytes+1)&~1;
BYTE* pData1 = new BYTE[nBytes];
BYTE* pData2 = new BYTE[nBytes];
- if(pData1 && pData2) {
+ if (pData1 && pData2) {
int nBytes1 = 0, nBytes2 = 0;
- for(ptrdiff_t j = 0; j < nBytes && i < 0x800;) {
- if(buff[i++] == 0xff) {
+ for (ptrdiff_t j = 0; j < nBytes && i < 0x800;) {
+ if (buff[i++] == 0xff) {
pData1[nBytes1++] = buff[i++];
pData1[nBytes1++] = buff[i++];
} else {
@@ -353,11 +353,11 @@ void CCDecoder::ExtractCC(BYTE* buff, int len, __int64 time) j++;
- if(j >= nBytes) {
+ if (j >= nBytes) {
break;
}
- if(buff[i++] == 0xff) {
+ if (buff[i++] == 0xff) {
pData2[nBytes2++] = buff[i++];
pData2[nBytes2++] = buff[i++];
} else {
@@ -367,19 +367,19 @@ void CCDecoder::ExtractCC(BYTE* buff, int len, __int64 time) j++;
}
- if(nBytes1 > 0) {
+ if (nBytes1 > 0) {
DecodeCC(pData1, nBytes1, time);
}
- if(nBytes2 > 0) {
+ if (nBytes2 > 0) {
DecodeCC(pData2, nBytes2, time);
}
}
- if(pData1) {
+ if (pData1) {
delete [] pData1;
}
- if(pData2) {
+ if (pData2) {
delete [] pData2;
}
}
diff --git a/src/Subtitles/DVBSub.cpp b/src/Subtitles/DVBSub.cpp index e772bc417..d67467c2d 100644 --- a/src/Subtitles/DVBSub.cpp +++ b/src/Subtitles/DVBSub.cpp @@ -26,9 +26,9 @@ #include "../DSUtil/GolombBuffer.h"
#if (0) // Set to 1 to activate DVB subtitles traces
- #define TRACE_DVB TRACE
+#define TRACE_DVB TRACE
#else
- #define TRACE_DVB
+#define TRACE_DVB
#endif
#define BUFFER_CHUNK_GROW 0x1000
@@ -153,7 +153,7 @@ HRESULT CDVBSub::ParseSample (IMediaSample* pSample) DVB_SEGMENT_TYPE nCurSegment;
hr = pSample->GetPointer(&pData);
- if(FAILED(hr) || pData == NULL) {
+ if (FAILED(hr) || pData == NULL) {
return hr;
}
nSize = pSample->GetActualDataLength();
@@ -184,9 +184,9 @@ HRESULT CDVBSub::ParseSample (IMediaSample* pSample) gb.BitRead(1); // extension
gb.BitRead(8); // hdrlen
- if(fpts) {
+ if (fpts) {
BYTE b = (BYTE)gb.BitRead(4);
- if(!(fdts && b == 3 || !fdts && b == 2)) {
+ if (!(fdts && b == 3 || !fdts && b == 2)) {
ASSERT(0);
return(E_FAIL);
}
diff --git a/src/Subtitles/GFN.cpp b/src/Subtitles/GFN.cpp index 4b3e8408b..e66cc6732 100644 --- a/src/Subtitles/GFN.cpp +++ b/src/Subtitles/GFN.cpp @@ -70,7 +70,7 @@ void GetSubFileNames(CString fn, CAtlArray<CString>& paths, CAtlArray<SubFile>& {
// int i = fn.Find(_T("://"));
int i = fn.Find(_T("http://"));
- if(i > 0) {
+ if (i > 0) {
fn = _T("http") + fn.Mid(i);
fWeb = true;
}
@@ -79,7 +79,7 @@ void GetSubFileNames(CString fn, CAtlArray<CString>& paths, CAtlArray<SubFile>& int l = fn.GetLength(), l2 = l;
l2 = fn.ReverseFind('.');
l = fn.ReverseFind('/') + 1;
- if(l2 < l) {
+ if (l2 < l) {
l2 = l;
}
@@ -87,23 +87,23 @@ void GetSubFileNames(CString fn, CAtlArray<CString>& paths, CAtlArray<SubFile>& CString title = fn.Mid(l, l2-l);
CString filename = title + _T(".nooneexpectsthespanishinquisition");
- if(!fWeb) {
+ if (!fWeb) {
// struct _tfinddata_t file, file2;
// long hFile, hFile2 = 0;
WIN32_FIND_DATA wfd, wfd2;
HANDLE hFile, hFile2;
- for(size_t k = 0; k < paths.GetCount(); k++) {
+ for (size_t k = 0; k < paths.GetCount(); k++) {
CString path = paths[k];
path.Replace('\\', '/');
l = path.GetLength();
- if(l > 0 && path[l-1] != '/') {
+ if (l > 0 && path[l-1] != '/') {
path += '/';
}
- if(path.Find(':') == -1 && path.Find(_T("\\\\")) != 0) {
+ if (path.Find(':') == -1 && path.Find(_T("\\\\")) != 0) {
path = orgpath + path;
}
@@ -114,51 +114,51 @@ void GetSubFileNames(CString fn, CAtlArray<CString>& paths, CAtlArray<SubFile>& bool fEmpty = true;
- if((hFile = FindFirstFile(path + title + _T("*"), &wfd)) != INVALID_HANDLE_VALUE) {
+ if ((hFile = FindFirstFile(path + title + _T("*"), &wfd)) != INVALID_HANDLE_VALUE) {
do {
- if(filename.CompareNoCase(wfd.cFileName) != 0) {
+ if (filename.CompareNoCase(wfd.cFileName) != 0) {
fEmpty = false;
// sl.AddTail(path + file.name);
}
- } while(FindNextFile(hFile, &wfd));
+ } while (FindNextFile(hFile, &wfd));
FindClose(hFile);
}
// TODO: use 'sl' in the next step to find files (already a nice speedup as it is now...)
- if(fEmpty) {
+ if (fEmpty) {
continue;
}
- for(ptrdiff_t j = 0; j < extlistnum; j++) {
- for(ptrdiff_t i = 0; i < extsubnum; i++) {
- if((hFile = FindFirstFile(path + title + ext[j][i], &wfd)) != INVALID_HANDLE_VALUE) {
+ for (ptrdiff_t j = 0; j < extlistnum; j++) {
+ for (ptrdiff_t i = 0; i < extsubnum; i++) {
+ if ((hFile = FindFirstFile(path + title + ext[j][i], &wfd)) != INVALID_HANDLE_VALUE) {
do {
CString fn = path + wfd.cFileName;
hFile2 = INVALID_HANDLE_VALUE;
- if(j == 0 || (hFile2 = FindFirstFile(fn.Left(fn.ReverseFind('.')) + _T(".avi"), &wfd2)) == INVALID_HANDLE_VALUE) {
+ if (j == 0 || (hFile2 = FindFirstFile(fn.Left(fn.ReverseFind('.')) + _T(".avi"), &wfd2)) == INVALID_HANDLE_VALUE) {
SubFile f;
f.fn = fn;
ret.Add(f);
}
- if(hFile2 != INVALID_HANDLE_VALUE) {
+ if (hFile2 != INVALID_HANDLE_VALUE) {
FindClose(hFile2);
}
- } while(FindNextFile(hFile, &wfd));
+ } while (FindNextFile(hFile, &wfd));
FindClose(hFile);
}
}
}
}
- } else if(l > 7) {
+ } else if (l > 7) {
CWebTextFile wtf; // :)
- if(wtf.Open(orgpath + title + WEBSUBEXT)) {
+ if (wtf.Open(orgpath + title + WEBSUBEXT)) {
CString fn;
- while(wtf.ReadString(fn) && fn.Find(_T("://")) >= 0) {
+ while (wtf.ReadString(fn) && fn.Find(_T("://")) >= 0) {
SubFile f;
f.fn = fn;
ret.Add(f);
diff --git a/src/Subtitles/HdmvSub.cpp b/src/Subtitles/HdmvSub.cpp index 0c7e3591a..a74de6a5b 100644 --- a/src/Subtitles/HdmvSub.cpp +++ b/src/Subtitles/HdmvSub.cpp @@ -25,9 +25,9 @@ #include "../DSUtil/GolombBuffer.h"
#if (0) // Set to 1 to activate HDMV subtitles traces
- #define TRACE_HDMVSUB TRACE
+#define TRACE_HDMVSUB TRACE
#else
- #define TRACE_HDMVSUB
+#define TRACE_HDMVSUB
#endif
@@ -98,7 +98,7 @@ HRESULT CHdmvSub::ParseSample(IMediaSample* pSample) int lSampleLen;
hr = pSample->GetPointer(&pData);
- if(FAILED(hr) || pData == NULL) {
+ if (FAILED(hr) || pData == NULL) {
return hr;
}
lSampleLen = pSample->GetActualDataLength();
@@ -158,7 +158,7 @@ HRESULT CHdmvSub::ParseSample(IMediaSample* pSample) if (m_pCurrentObject) {
TRACE_HDMVSUB ("CHdmvSub:PRESENTATION_SEG %d\n", m_pCurrentObject->m_nObjectNumber);
- if(m_pCurrentObject->m_nObjectNumber > 1) {
+ if (m_pCurrentObject->m_nObjectNumber > 1) {
m_pCurrentObject->m_nObjectNumber--;
break;
}
@@ -211,7 +211,7 @@ int CHdmvSub::ParsePresentationSegment(CGolombBuffer* pGBuffer) delete m_pCurrentObject;
m_pCurrentObject = DNew CompositionObject();
m_pCurrentObject->m_nObjectNumber = nObjectNumber;
- for(int i=0; i<nObjectNumber; i++) {
+ for (int i=0; i<nObjectNumber; i++) {
ParseCompositionObject (pGBuffer, m_pCurrentObject);
}
}
@@ -308,8 +308,8 @@ void CHdmvSub::Render(SubPicDesc& spd, REFERENCE_TIME rt, RECT& bbox) ASSERT (pObject!=NULL && spd.w >= (pObject->m_horizontal_position + pObject->m_width) && spd.h >= (pObject->m_vertical_position + pObject->m_height));
- if (pObject && pObject->GetRLEDataSize() && pObject->m_width > 0 && pObject->m_height > 0 &&
- spd.w >= (pObject->m_horizontal_position + pObject->m_width) &&
+ if (pObject && pObject->GetRLEDataSize() && pObject->m_width > 0 && pObject->m_height > 0 &&
+ spd.w >= (pObject->m_horizontal_position + pObject->m_width) &&
spd.h >= (pObject->m_vertical_position + pObject->m_height)) {
if (!pObject->HavePalette()) {
pObject->SetPalette (m_nDefaultPaletteNbEntry, m_pDefaultPalette, m_VideoDescriptor.nVideoWidth>720);
diff --git a/src/Subtitles/RTS.cpp b/src/Subtitles/RTS.cpp index fe5483fb4..9d81c53af 100644 --- a/src/Subtitles/RTS.cpp +++ b/src/Subtitles/RTS.cpp @@ -54,7 +54,7 @@ CMyFont::CMyFont(STSStyle& style) lf.lfOrientation = (LONG)style.mod_fontOrient;
#endif
- if(!CreateFontIndirect(&lf)) {
+ if (!CreateFontIndirect(&lf)) {
_tcscpy(lf.lfFaceName, _T("Arial"));
CreateFontIndirect(&lf);
}
@@ -77,7 +77,7 @@ CWord::CWord(STSStyle& style, CStringW str, int ktype, int kstart, int kend) , m_fLineBreak(false), m_fWhiteSpaceChar(false)
, m_pOpaqueBox(NULL)
{
- if(str.IsEmpty()) {
+ if (str.IsEmpty()) {
m_fWhiteSpaceChar = m_fLineBreak = true;
}
@@ -89,14 +89,14 @@ CWord::CWord(STSStyle& style, CStringW str, int ktype, int kstart, int kend) CWord::~CWord()
{
- if(m_pOpaqueBox) {
+ if (m_pOpaqueBox) {
delete m_pOpaqueBox;
}
}
bool CWord::Append(CWord* w)
{
- if(!(m_style == w->m_style)
+ if (!(m_style == w->m_style)
|| m_fLineBreak || w->m_fLineBreak
|| w->m_kstart != w->m_kend || m_ktype != w->m_ktype) {
return false;
@@ -114,45 +114,45 @@ bool CWord::Append(CWord* w) void CWord::Paint(CPoint p, CPoint org)
{
- if(!m_str) {
+ if (!m_str) {
return;
}
- if(!m_fDrawn) {
- if(!CreatePath()) {
+ if (!m_fDrawn) {
+ if (!CreatePath()) {
return;
}
Transform(CPoint((org.x-p.x)*8, (org.y-p.y)*8));
- __try{
- if(!ScanConvert()) return;
- }__except (EXCEPTION_EXECUTE_HANDLER) {
- return;
+ __try {
+ if (!ScanConvert()) return;
+ } __except (EXCEPTION_EXECUTE_HANDLER) {
+ return;
}
- if(m_style.borderStyle == 0 && (m_style.outlineWidthX+m_style.outlineWidthY > 0)) {
- if(!CreateWidenedRegion((int)(m_style.outlineWidthX+0.5), (int)(m_style.outlineWidthY+0.5))) {
+ if (m_style.borderStyle == 0 && (m_style.outlineWidthX+m_style.outlineWidthY > 0)) {
+ if (!CreateWidenedRegion((int)(m_style.outlineWidthX+0.5), (int)(m_style.outlineWidthY+0.5))) {
return;
}
- } else if(m_style.borderStyle == 1) {
- if(!CreateOpaqueBox()) {
+ } else if (m_style.borderStyle == 1) {
+ if (!CreateOpaqueBox()) {
return;
}
}
m_fDrawn = true;
- if(!Rasterize(p.x&7, p.y&7, m_style.fBlur, m_style.fGaussianBlur)) {
+ if (!Rasterize(p.x&7, p.y&7, m_style.fBlur, m_style.fGaussianBlur)) {
return;
}
- } else if((m_p.x&7) != (p.x&7) || (m_p.y&7) != (p.y&7)) {
+ } else if ((m_p.x&7) != (p.x&7) || (m_p.y&7) != (p.y&7)) {
Rasterize(p.x&7, p.y&7, m_style.fBlur, m_style.fGaussianBlur);
}
m_p = p;
- if(m_pOpaqueBox) {
+ if (m_pOpaqueBox) {
m_pOpaqueBox->Paint(p, org);
}
}
@@ -163,7 +163,7 @@ void CWord::Transform(CPoint org) // CPUID from VDub
bool fSSE2 = !!(g_cpuid.m_flags & CCpuID::sse2);
- if(fSSE2) { // SSE code
+ if (fSSE2) { // SSE code
Transform_SSE2(org);
} else // C-code
#endif
@@ -172,7 +172,7 @@ void CWord::Transform(CPoint org) bool CWord::CreateOpaqueBox()
{
- if(m_pOpaqueBox) {
+ if (m_pOpaqueBox) {
return true;
}
@@ -224,17 +224,17 @@ void CWord::Transform_C( CPoint &org ) bool is_dist = m_style.mod_distort.enabled;
if (is_dist) {
- for(int i = 0; i < mPathPoints; i++) {
- if(minx > mpPathPoints[i].x) {
+ for (int i = 0; i < mPathPoints; i++) {
+ if (minx > mpPathPoints[i].x) {
minx = mpPathPoints[i].x;
}
- if(miny > mpPathPoints[i].y) {
+ if (miny > mpPathPoints[i].y) {
miny = mpPathPoints[i].y;
}
- if(maxx < mpPathPoints[i].x) {
+ if (maxx < mpPathPoints[i].x) {
maxx = mpPathPoints[i].x;
}
- if(maxy < mpPathPoints[i].y) {
+ if (maxy < mpPathPoints[i].y) {
maxy = mpPathPoints[i].y;
}
}
@@ -348,8 +348,8 @@ void CWord::Transform_SSE2( CPoint &org ) __m128 __max = _mm_set_ps(-INT_MAX, -INT_MAX, 1, 1);
bool is_dist = m_style.mod_distort.enabled;
- if(is_dist) {
- for(int i = 0; i < mPathPoints; i++) {
+ if (is_dist) {
+ for (int i = 0; i < mPathPoints; i++) {
__m128 __point = _mm_set_ps(mpPathPoints[i].x, mpPathPoints[i].y, 0, 0);
__minx = _mm_min_ps(__minx, __point);
__max = _mm_max_ps(__max, __point);
@@ -390,14 +390,14 @@ void CWord::Transform_SSE2( CPoint &org ) int mPathPointsD4 = mPathPoints / 4;
int mPathPointsM4 = mPathPoints % 4;
- for(ptrdiff_t i = 0; i < mPathPointsD4 + 1; i++) {
+ for (ptrdiff_t i = 0; i < mPathPointsD4 + 1; i++) {
__m128 __pointx, __pointy;
// we can't use load .-.
- if(i != mPathPointsD4) {
+ if (i != mPathPointsD4) {
__pointx = _mm_set_ps(mpPathPoints[4 * i + 0].x, mpPathPoints[4 * i + 1].x, mpPathPoints[4 * i + 2].x, mpPathPoints[4 * i + 3].x);
__pointy = _mm_set_ps(mpPathPoints[4 * i + 0].y, mpPathPoints[4 * i + 1].y, mpPathPoints[4 * i + 2].y, mpPathPoints[4 * i + 3].y);
} else { // last cycle
- switch(mPathPointsM4) {
+ switch (mPathPointsM4) {
default:
case 0:
continue;
@@ -420,7 +420,7 @@ void CWord::Transform_SSE2( CPoint &org ) __m128 __pointz = _mm_set_ps1(m_style.mod_z);
// distort
- if(is_dist) {
+ if (is_dist) {
//P = P0 + (P1 - P0)u + (P3 - P0)v + (P0 + P2 - P1 - P3)uv
__m128 __u = _mm_sub_ps(__pointx, __minx);
__m128 __v = _mm_sub_ps(__pointy, __miny);
@@ -455,28 +455,28 @@ void CWord::Transform_SSE2( CPoint &org ) }
// randomize
- if(xrnd!=0 || yrnd!=0 || zrnd!=0) {
+ if (xrnd!=0 || yrnd!=0 || zrnd!=0) {
__declspec(align(16)) float rx[4], ry[4], rz[4];
- for(int k=0; k<4; k++) {
+ for (int k=0; k<4; k++) {
rx[k] = xrnd > 0 ? (xrnd - rand() % (int)(xrnd * 2 + 1)) : 0;
ry[k] = yrnd > 0 ? (yrnd - rand() % (int)(yrnd * 2 + 1)) : 0;
rz[k] = zrnd > 0 ? (zrnd - rand() % (int)(zrnd * 2 + 1)) : 0;
}
__m128 __001 = _mm_set_ps1(0.01f);
- if(xrnd!=0) {
+ if (xrnd!=0) {
__m128 __rx = _mm_load_ps(rx);
__rx = _mm_mul_ps(__rx, __001);
__pointx = _mm_add_ps(__pointx, __rx);
}
- if(yrnd!=0) {
+ if (yrnd!=0) {
__m128 __ry = _mm_load_ps(ry);
__ry = _mm_mul_ps(__ry, __001);
__pointy = _mm_add_ps(__pointy, __ry);
}
- if(zrnd!=0) {
+ if (zrnd!=0) {
__m128 __rz = _mm_load_ps(rz);
__rz = _mm_mul_ps(__rz, __001);
__pointz = _mm_add_ps(__pointz, __rz);
@@ -488,7 +488,7 @@ void CWord::Transform_SSE2( CPoint &org ) // scale and shift
__m128 __tmpx;
- if(m_style.fontShiftX!=0) {
+ if (m_style.fontShiftX!=0) {
__tmpx = _mm_mul_ps(__xshift, __pointy);
__tmpx = _mm_add_ps(__tmpx, __pointx);
} else {
@@ -498,7 +498,7 @@ void CWord::Transform_SSE2( CPoint &org ) __tmpx = _mm_sub_ps(__tmpx, __xorg);
__m128 __tmpy;
- if(m_style.fontShiftY!=0) {
+ if (m_style.fontShiftY!=0) {
__tmpy = _mm_mul_ps(__yshift, __pointx);
__tmpy = _mm_add_ps(__tmpy, __pointy);
} else {
@@ -550,13 +550,13 @@ void CWord::Transform_SSE2( CPoint &org ) __pointx = _mm_add_ps(__pointx, __05);
__pointy = _mm_add_ps(__pointy, __05);
- if(i == mPathPointsD4) { // last cycle
- for(int k=0; k<mPathPointsM4; k++) {
+ if (i == mPathPointsD4) { // last cycle
+ for (int k=0; k<mPathPointsM4; k++) {
mpPathPoints[i*4+k].x = static_cast<LONG>(__pointx.m128_f32[3-k]);
mpPathPoints[i*4+k].y = static_cast<LONG>(__pointy.m128_f32[3-k]);
}
} else {
- for(int k=0; k<4; k++) {
+ for (int k=0; k<4; k++) {
mpPathPoints[i*4+k].x = static_cast<LONG>(__pointx.m128_f32[3-k]);
mpPathPoints[i*4+k].y = static_cast<LONG>(__pointy.m128_f32[3-k]);
}
@@ -570,7 +570,7 @@ void CWord::Transform_SSE2( CPoint &org ) CText::CText(STSStyle& style, CStringW str, int ktype, int kstart, int kend)
: CWord(style, str, ktype, kstart, kend)
{
- if(m_str == L" ") {
+ if (m_str == L" ") {
m_fWhiteSpaceChar = true;
}
@@ -581,10 +581,10 @@ CText::CText(STSStyle& style, CStringW str, int ktype, int kstart, int kend) #ifdef _VSMOD // patch m007. symbol rotating
double t = (double)m_style.mod_fontOrient * 3.1415926 / 1800;
#endif
- if(m_style.fontSpacing || (long)GetVersion() < 0) {
- for(LPCWSTR s = m_str; *s; s++) {
+ if (m_style.fontSpacing || (long)GetVersion() < 0) {
+ for (LPCWSTR s = m_str; *s; s++) {
CSize extent;
- if(!GetTextExtentPoint32W(g_hDC, s, 1, &extent)) {
+ if (!GetTextExtentPoint32W(g_hDC, s, 1, &extent)) {
SelectFont(g_hDC, hOldFont);
ASSERT(0);
return;
@@ -598,7 +598,7 @@ CText::CText(STSStyle& style, CStringW str, int ktype, int kstart, int kend) // m_width -= (int)m_style.fontSpacing; // TODO: subtract only at the end of the line
} else {
CSize extent;
- if(!GetTextExtentPoint32W(g_hDC, m_str, wcslen(str), &extent)) {
+ if (!GetTextExtentPoint32W(g_hDC, m_str, wcslen(str), &extent)) {
SelectFont(g_hDC, hOldFont);
ASSERT(0);
return;
@@ -631,13 +631,13 @@ bool CText::CreatePath() HFONT hOldFont = SelectFont(g_hDC, font);
- if(m_style.fontSpacing || (long)GetVersion() < 0) {
+ if (m_style.fontSpacing || (long)GetVersion() < 0) {
int width = 0;
bool bFirstPath = true;
- for(LPCWSTR s = m_str; *s; s++) {
+ for (LPCWSTR s = m_str; *s; s++) {
CSize extent;
- if(!GetTextExtentPoint32W(g_hDC, s, 1, &extent)) {
+ if (!GetTextExtentPoint32W(g_hDC, s, 1, &extent)) {
SelectFont(g_hDC, hOldFont);
ASSERT(0);
return false;
@@ -652,7 +652,7 @@ bool CText::CreatePath() }
} else {
CSize extent;
- if(!GetTextExtentPoint32W(g_hDC, m_str, m_str.GetLength(), &extent)) {
+ if (!GetTextExtentPoint32W(g_hDC, m_str, m_str.GetLength(), &extent)) {
SelectFont(g_hDC, hOldFont);
ASSERT(0);
return false;
@@ -683,8 +683,8 @@ CPolygon::CPolygon(CPolygon& src) : CWord(src.m_style, src.m_str, src.m_ktype, s m_scaley = src.m_scaley;
m_baseline = src.m_baseline;
m_width = src.m_width;
- m_ascent = src.m_ascent;
- m_descent = src.m_descent;
+ m_ascent = src.m_ascent;
+ m_descent = src.m_descent;
m_pathTypesOrg.Copy(src.m_pathTypesOrg);
m_pathPointsOrg.Copy(src.m_pathPointsOrg);
@@ -702,7 +702,7 @@ CWord* CPolygon::Copy() bool CPolygon::Append(CWord* w)
{
CPolygon* p = dynamic_cast<CPolygon*>(w);
- if(!p) {
+ if (!p) {
return false;
}
@@ -716,7 +716,7 @@ bool CPolygon::GetLONG(CStringW& str, LONG& ret) {
LPWSTR s = (LPWSTR)(LPCWSTR)str, e = s;
ret = wcstol(str, &e, 10);
- str.Delete(0,e-s);
+ str.Delete(0,e-s);
return(e > s);
}
@@ -727,7 +727,7 @@ bool CPolygon::GetPOINT(CStringW& str, POINT& ret) bool CPolygon::ParseStr()
{
- if(m_pathTypesOrg.GetCount() > 0) {
+ if (m_pathTypesOrg.GetCount() > 0) {
return true;
}
@@ -745,22 +745,22 @@ bool CPolygon::ParseStr() str.Replace(L"c", L"*c");
int k = 0;
- for(CStringW s = str.Tokenize(L"*", k); !s.IsEmpty(); s = str.Tokenize(L"*", k)) {
+ for (CStringW s = str.Tokenize(L"*", k); !s.IsEmpty(); s = str.Tokenize(L"*", k)) {
WCHAR c = s[0];
s.TrimLeft(L"mnlbspc ");
- switch(c) {
+ switch (c) {
case 'm':
lastmoveto = m_pathTypesOrg.GetCount();
- if(firstmoveto == -1) {
+ if (firstmoveto == -1) {
firstmoveto = lastmoveto;
}
- while(GetPOINT(s, p)) {
+ while (GetPOINT(s, p)) {
m_pathTypesOrg.Add(PT_MOVETO);
m_pathPointsOrg.Add(p);
}
break;
case 'n':
- while(GetPOINT(s, p)) {
+ while (GetPOINT(s, p)) {
m_pathTypesOrg.Add(PT_MOVETONC);
m_pathPointsOrg.Add(p);
}
@@ -769,7 +769,7 @@ bool CPolygon::ParseStr() if (m_pathPointsOrg.GetCount() < 1) {
break;
}
- while(GetPOINT(s, p)) {
+ while (GetPOINT(s, p)) {
m_pathTypesOrg.Add(PT_LINETO);
m_pathPointsOrg.Add(p);
}
@@ -779,7 +779,7 @@ bool CPolygon::ParseStr() if (j < 1) {
break;
}
- while(GetPOINT(s, p)) {
+ while (GetPOINT(s, p)) {
m_pathTypesOrg.Add(PT_BEZIERTO);
m_pathPointsOrg.Add(p);
j++;
@@ -794,12 +794,12 @@ bool CPolygon::ParseStr() }
j = lastsplinestart = m_pathTypesOrg.GetCount();
i = 3;
- while(i-- && GetPOINT(s, p)) {
+ while (i-- && GetPOINT(s, p)) {
m_pathTypesOrg.Add(PT_BSPLINETO);
m_pathPointsOrg.Add(p);
j++;
}
- if(m_pathTypesOrg.GetCount() - lastsplinestart < 3) {
+ if (m_pathTypesOrg.GetCount() - lastsplinestart < 3) {
m_pathTypesOrg.SetCount(lastsplinestart);
m_pathPointsOrg.SetCount(lastsplinestart);
lastsplinestart = -1;
@@ -809,13 +809,13 @@ bool CPolygon::ParseStr() if (m_pathPointsOrg.GetCount() < 3) {
break;
}
- while(GetPOINT(s, p)) {
+ while (GetPOINT(s, p)) {
m_pathTypesOrg.Add(PT_BSPLINEPATCHTO);
m_pathPointsOrg.Add(p);
}
break;
case 'c':
- if(lastsplinestart > 0) {
+ if (lastsplinestart > 0) {
m_pathTypesOrg.Add(PT_BSPLINEPATCHTO);
m_pathTypesOrg.Add(PT_BSPLINEPATCHTO);
m_pathTypesOrg.Add(PT_BSPLINEPATCHTO);
@@ -833,7 +833,7 @@ bool CPolygon::ParseStr() }
}
- if(lastmoveto == -1 || firstmoveto > 0) {
+ if (lastmoveto == -1 || firstmoveto > 0) {
m_pathTypesOrg.RemoveAll();
m_pathPointsOrg.RemoveAll();
return false;
@@ -875,14 +875,14 @@ bool CPolygon::ParseStr() bool CPolygon::CreatePath()
{
size_t len = m_pathTypesOrg.GetCount();
- if(len == 0) {
+ if (len == 0) {
return false;
}
- if(mPathPoints != len) {
+ if (mPathPoints != len) {
mpPathTypes = (BYTE*)realloc(mpPathTypes, len*sizeof(BYTE));
mpPathPoints = (POINT*)realloc(mpPathPoints, len*sizeof(POINT));
- if(!mpPathTypes || !mpPathPoints) {
+ if (!mpPathTypes || !mpPathPoints) {
return false;
}
mPathPoints = len;
@@ -902,7 +902,7 @@ CClipper::CClipper(CStringW str, CSize size, double scalex, double scaley, bool m_size.cx = m_size.cy = 0;
m_pAlphaMask = NULL;
- if(size.cx < 0 || size.cy < 0) {
+ if (size.cx < 0 || size.cy < 0) {
return;
}
@@ -924,32 +924,32 @@ CClipper::CClipper(CStringW str, CSize size, double scalex, double scaley, bool int x = (mOffsetX+cpOffset.x+4)>>3, y = (mOffsetY+cpOffset.y+4)>>3;
int xo = 0, yo = 0;
- if(x < 0) {
+ if (x < 0) {
xo = -x;
w -= -x;
x = 0;
}
- if(y < 0) {
+ if (y < 0) {
yo = -y;
h -= -y;
y = 0;
}
- if(x+w > m_size.cx) {
+ if (x+w > m_size.cx) {
w = m_size.cx-x;
}
- if(y+h > m_size.cy) {
+ if (y+h > m_size.cy) {
h = m_size.cy-y;
}
- if(w <= 0 || h <= 0) {
+ if (w <= 0 || h <= 0) {
return;
}
const BYTE* src = mpOverlayBuffer + 2*(mOverlayWidth * yo + xo);
BYTE* dst = m_pAlphaMask + m_size.cx * y + x;
- while(h--) {
- for(ptrdiff_t wt=0; wt<w; ++wt) {
+ while (h--) {
+ for (ptrdiff_t wt=0; wt<w; ++wt) {
dst[wt] = src[wt*2];
}
@@ -957,9 +957,9 @@ CClipper::CClipper(CStringW str, CSize size, double scalex, double scaley, bool dst += m_size.cx;
}
- if(inverse) {
+ if (inverse) {
BYTE* dst = m_pAlphaMask;
- for(ptrdiff_t i = size.cx*size.cy; i>0; --i, ++dst) {
+ for (ptrdiff_t i = size.cx*size.cy; i>0; --i, ++dst) {
*dst = 0x40 - *dst; // mask is 6 bit
}
}
@@ -967,7 +967,7 @@ CClipper::CClipper(CStringW str, CSize size, double scalex, double scaley, bool CClipper::~CClipper()
{
- if(m_pAlphaMask) {
+ if (m_pAlphaMask) {
delete [] m_pAlphaMask;
}
m_pAlphaMask = NULL;
@@ -988,7 +988,7 @@ bool CClipper::Append(CWord* w) CLine::~CLine()
{
POSITION pos = GetHeadPosition();
- while(pos) {
+ while (pos) {
delete GetNext(pos);
}
}
@@ -996,9 +996,9 @@ CLine::~CLine() void CLine::Compact()
{
POSITION pos = GetHeadPosition();
- while(pos) {
+ while (pos) {
CWord* w = GetNext(pos);
- if(!w->m_fWhiteSpaceChar) {
+ if (!w->m_fWhiteSpaceChar) {
break;
}
@@ -1008,9 +1008,9 @@ void CLine::Compact() }
pos = GetTailPosition();
- while(pos) {
+ while (pos) {
CWord* w = GetPrev(pos);
- if(!w->m_fWhiteSpaceChar) {
+ if (!w->m_fWhiteSpaceChar) {
break;
}
@@ -1019,7 +1019,7 @@ void CLine::Compact() RemoveTail();
}
- if(IsEmpty()) {
+ if (IsEmpty()) {
return;
}
@@ -1030,10 +1030,10 @@ void CLine::Compact() CWord* last = NULL;
pos = l.GetHeadPosition();
- while(pos) {
+ while (pos) {
CWord* w = l.GetNext(pos);
- if(!last || !last->Append(w)) {
+ if (!last || !last->Append(w)) {
AddTail(last = w->Copy());
}
}
@@ -1041,19 +1041,19 @@ void CLine::Compact() m_ascent = m_descent = m_borderX = m_borderY = 0;
pos = GetHeadPosition();
- while(pos) {
+ while (pos) {
CWord* w = GetNext(pos);
- if(m_ascent < w->m_ascent) {
+ if (m_ascent < w->m_ascent) {
m_ascent = w->m_ascent;
}
- if(m_descent < w->m_descent) {
+ if (m_descent < w->m_descent) {
m_descent = w->m_descent;
}
- if(m_borderX < w->m_style.outlineWidthX) {
+ if (m_borderX < w->m_style.outlineWidthX) {
m_borderX = (int)(w->m_style.outlineWidthX+0.5);
}
- if(m_borderY < w->m_style.outlineWidthY) {
+ if (m_borderY < w->m_style.outlineWidthY) {
m_borderY = (int)(w->m_style.outlineWidthY+0.5);
}
}
@@ -1068,14 +1068,14 @@ CRect CLine::PaintShadow(SubPicDesc& spd, CRect& clipRect, BYTE* pAlphaMask, CPo CRect bbox(0, 0, 0, 0);
POSITION pos = GetHeadPosition();
- while(pos) {
+ while (pos) {
CWord* w = GetNext(pos);
- if(w->m_fLineBreak) {
+ if (w->m_fLineBreak) {
return(bbox); // should not happen since this class is just a line of text without any breaks
}
- if(w->m_style.shadowDepthX != 0 || w->m_style.shadowDepthY != 0) {
+ if (w->m_style.shadowDepthX != 0 || w->m_style.shadowDepthY != 0) {
int x = p.x + (int)(w->m_style.shadowDepthX+0.5);
#ifdef _VSMOD // patch m001. Vertical fontspacing
int y = p.y - w->m_style.mod_verticalSpace + m_ascent - w->m_ascent + (int)(w->m_style.shadowDepthY+0.5);
@@ -1083,8 +1083,9 @@ CRect CLine::PaintShadow(SubPicDesc& spd, CRect& clipRect, BYTE* pAlphaMask, CPo int y = p.y + m_ascent - w->m_ascent + (int)(w->m_style.shadowDepthY+0.5);
#endif
DWORD a = 0xff - w->m_style.alpha[3];
- if(alpha > 0) {
- a = a*(0xff-static_cast<DWORD>(alpha))/0xff;}
+ if (alpha > 0) {
+ a = a*(0xff-static_cast<DWORD>(alpha))/0xff;
+ }
COLORREF shadow = revcolor(w->m_style.colors[3]) | (a<<24);
DWORD sw[6] = {shadow, 0xffffffff};
@@ -1100,7 +1101,7 @@ CRect CLine::PaintShadow(SubPicDesc& spd, CRect& clipRect, BYTE* pAlphaMask, CPo #endif
w->Paint(CPoint(x, y), org);
- if(w->m_style.borderStyle == 0) {
+ if (w->m_style.borderStyle == 0) {
#ifdef _VSMOD // patch m004. gradient colors
bbox |= w->Draw(spd, clipRect, pAlphaMask, x, y, sw,
w->m_ktype > 0 || w->m_style.alpha[0] < 0xff,
@@ -1110,7 +1111,7 @@ CRect CLine::PaintShadow(SubPicDesc& spd, CRect& clipRect, BYTE* pAlphaMask, CPo w->m_ktype > 0 || w->m_style.alpha[0] < 0xff,
(w->m_style.outlineWidthX+w->m_style.outlineWidthY > 0) && !(w->m_ktype == 2 && time < w->m_kstart));
#endif
- } else if(w->m_style.borderStyle == 1 && w->m_pOpaqueBox) {
+ } else if (w->m_style.borderStyle == 1 && w->m_pOpaqueBox) {
#ifdef _VSMOD // patch m004. gradient colors
bbox |= w->m_pOpaqueBox->Draw(spd, clipRect, pAlphaMask, x, y, sw, true, false,3,w->m_style.mod_grad, mod_vc);
#else
@@ -1134,14 +1135,14 @@ CRect CLine::PaintOutline(SubPicDesc& spd, CRect& clipRect, BYTE* pAlphaMask, CP CRect bbox(0, 0, 0, 0);
POSITION pos = GetHeadPosition();
- while(pos) {
+ while (pos) {
CWord* w = GetNext(pos);
- if(w->m_fLineBreak) {
+ if (w->m_fLineBreak) {
return(bbox); // should not happen since this class is just a line of text without any breaks
}
- if(w->m_style.outlineWidthX+w->m_style.outlineWidthY > 0 && !(w->m_ktype == 2 && time < w->m_kstart)) {
+ if (w->m_style.outlineWidthX+w->m_style.outlineWidthY > 0 && !(w->m_ktype == 2 && time < w->m_kstart)) {
int x = p.x;
#ifdef _VSMOD // patch m001. Vertical fontspacing
int y = p.y - w->m_style.mod_verticalSpace + m_ascent - w->m_ascent;
@@ -1149,7 +1150,7 @@ CRect CLine::PaintOutline(SubPicDesc& spd, CRect& clipRect, BYTE* pAlphaMask, CP int y = p.y + m_ascent - w->m_ascent;
#endif
DWORD aoutline = w->m_style.alpha[2];
- if(alpha > 0) {
+ if (alpha > 0) {
aoutline += alpha*(0xff-w->m_style.alpha[2])/0xff;
}
COLORREF outline = revcolor(w->m_style.colors[2]) | ((0xff-aoutline)<<24);
@@ -1168,13 +1169,13 @@ CRect CLine::PaintOutline(SubPicDesc& spd, CRect& clipRect, BYTE* pAlphaMask, CP w->Paint(CPoint(x, y), org);
- if(w->m_style.borderStyle == 0) {
+ if (w->m_style.borderStyle == 0) {
#ifdef _VSMOD // patch m004. gradient colors
bbox |= w->Draw(spd, clipRect, pAlphaMask, x, y, sw, !w->m_style.alpha[0] && !w->m_style.alpha[1] && !alpha, true,2,w->m_style.mod_grad, mod_vc);
#else
bbox |= w->Draw(spd, clipRect, pAlphaMask, x, y, sw, !w->m_style.alpha[0] && !w->m_style.alpha[1] && !alpha, true);
#endif
- } else if(w->m_style.borderStyle == 1 && w->m_pOpaqueBox) {
+ } else if (w->m_style.borderStyle == 1 && w->m_pOpaqueBox) {
#ifdef _VSMOD // patch m004. gradient colors
bbox |= w->m_pOpaqueBox->Draw(spd, clipRect, pAlphaMask, x, y, sw, true, false,2,w->m_style.mod_grad, mod_vc);
#else
@@ -1198,10 +1199,10 @@ CRect CLine::PaintBody(SubPicDesc& spd, CRect& clipRect, BYTE* pAlphaMask, CPoin CRect bbox(0, 0, 0, 0);
POSITION pos = GetHeadPosition();
- while(pos) {
+ while (pos) {
CWord* w = GetNext(pos);
- if(w->m_fLineBreak) {
+ if (w->m_fLineBreak) {
return(bbox); // should not happen since this class is just a line of text without any breaks
}
@@ -1215,7 +1216,7 @@ CRect CLine::PaintBody(SubPicDesc& spd, CRect& clipRect, BYTE* pAlphaMask, CPoin DWORD aprimary = w->m_style.alpha[0];
DWORD asecondary = w->m_style.alpha[1];
- if(alpha > 0) {
+ if (alpha > 0) {
aprimary += alpha*(0xff-w->m_style.alpha[0])/0xff;
asecondary += alpha*(0xff-w->m_style.alpha[1])/0xff;
}
@@ -1228,16 +1229,16 @@ CRect CLine::PaintBody(SubPicDesc& spd, CRect& clipRect, BYTE* pAlphaMask, CPoin double t;
- if(w->m_ktype == 0 || w->m_ktype == 2) {
+ if (w->m_ktype == 0 || w->m_ktype == 2) {
t = time < w->m_kstart ? 0 : 1;
- } else if(w->m_ktype == 1) {
- if(time < w->m_kstart) {
+ } else if (w->m_ktype == 1) {
+ if (time < w->m_kstart) {
t = 0;
- } else if(time < w->m_kend) {
+ } else if (time < w->m_kend) {
t = 1.0 * (time - w->m_kstart) / (w->m_kend - w->m_kstart);
double angle = fmod(w->m_style.fontAngleZ, 360.0);
- if(angle > 90 && angle < 270) {
+ if (angle > 90 && angle < 270) {
t = 1-t;
COLORREF tmp = sw[0];
sw[0] = sw[2];
@@ -1248,7 +1249,7 @@ CRect CLine::PaintBody(SubPicDesc& spd, CRect& clipRect, BYTE* pAlphaMask, CPoin }
}
- if(t >= 1) {
+ if (t >= 1) {
sw[1] = 0xFFFFFFF;
}
@@ -1310,18 +1311,18 @@ CSubtitle::~CSubtitle() void CSubtitle::Empty()
{
POSITION pos = GetHeadPosition();
- while(pos) {
+ while (pos) {
delete GetNext(pos);
}
pos = m_words.GetHeadPosition();
- while(pos) {
+ while (pos) {
delete m_words.GetNext(pos);
}
EmptyEffects();
- if(m_pClipper) {
+ if (m_pClipper) {
delete m_pClipper;
}
m_pClipper = NULL;
@@ -1329,8 +1330,8 @@ void CSubtitle::Empty() void CSubtitle::EmptyEffects()
{
- for(ptrdiff_t i = 0; i < EF_NUMBEROFEFFECTS; i++) {
- if(m_effects[i]) {
+ for (ptrdiff_t i = 0; i < EF_NUMBEROFEFFECTS; i++) {
+ if (m_effects[i]) {
delete m_effects[i];
}
}
@@ -1342,7 +1343,7 @@ int CSubtitle::GetFullWidth() int width = 0;
POSITION pos = m_words.GetHeadPosition();
- while(pos) {
+ while (pos) {
width += m_words.GetNext(pos)->m_width;
}
@@ -1353,9 +1354,9 @@ int CSubtitle::GetFullLineWidth(POSITION pos) {
int width = 0;
- while(pos) {
+ while (pos) {
CWord* w = m_words.GetNext(pos);
- if(w->m_fLineBreak) {
+ if (w->m_fLineBreak) {
break;
}
width += w->m_width;
@@ -1366,8 +1367,8 @@ int CSubtitle::GetFullLineWidth(POSITION pos) int CSubtitle::GetWrapWidth(POSITION pos, int maxwidth)
{
- if(m_wrapStyle == 0 || m_wrapStyle == 3) {
- if(maxwidth > 0) {
+ if (m_wrapStyle == 0 || m_wrapStyle == 3) {
+ if (maxwidth > 0) {
// int fullwidth = GetFullWidth();
int fullwidth = GetFullLineWidth(pos);
@@ -1375,23 +1376,23 @@ int CSubtitle::GetWrapWidth(POSITION pos, int maxwidth) int width = 0, wordwidth = 0;
- while(pos && width < minwidth) {
+ while (pos && width < minwidth) {
CWord* w = m_words.GetNext(pos);
wordwidth = w->m_width;
- if(abs(width + wordwidth) < abs(maxwidth)) {
+ if (abs(width + wordwidth) < abs(maxwidth)) {
width += wordwidth;
}
}
maxwidth = width;
- if(m_wrapStyle == 3 && pos) {
+ if (m_wrapStyle == 3 && pos) {
maxwidth -= wordwidth;
}
}
- } else if(m_wrapStyle == 1) {
+ } else if (m_wrapStyle == 1) {
// maxwidth = maxwidth;
- } else if(m_wrapStyle == 2) {
+ } else if (m_wrapStyle == 2) {
maxwidth = INT_MAX;
}
@@ -1400,12 +1401,12 @@ int CSubtitle::GetWrapWidth(POSITION pos, int maxwidth) CLine* CSubtitle::GetNextLine(POSITION& pos, int maxwidth)
{
- if(pos == NULL) {
+ if (pos == NULL) {
return(NULL);
}
CLine* ret = DNew CLine();
- if(!ret) {
+ if (!ret) {
return(NULL);
}
@@ -1415,24 +1416,24 @@ CLine* CSubtitle::GetNextLine(POSITION& pos, int maxwidth) bool fEmptyLine = true;
- while(pos) {
+ while (pos) {
CWord* w = m_words.GetNext(pos);
- if(ret->m_ascent < w->m_ascent) {
+ if (ret->m_ascent < w->m_ascent) {
ret->m_ascent = w->m_ascent;
}
- if(ret->m_descent < w->m_descent) {
+ if (ret->m_descent < w->m_descent) {
ret->m_descent = w->m_descent;
}
- if(ret->m_borderX < w->m_style.outlineWidthX) {
+ if (ret->m_borderX < w->m_style.outlineWidthX) {
ret->m_borderX = (int)(w->m_style.outlineWidthX+0.5);
}
- if(ret->m_borderY < w->m_style.outlineWidthY) {
+ if (ret->m_borderY < w->m_style.outlineWidthY) {
ret->m_borderY = (int)(w->m_style.outlineWidthY+0.5);
}
- if(w->m_fLineBreak) {
- if(fEmptyLine) {
+ if (w->m_fLineBreak) {
+ if (fEmptyLine) {
ret->m_ascent /= 2;
ret->m_descent /= 2;
ret->m_borderX = ret->m_borderY = 0;
@@ -1449,8 +1450,8 @@ CLine* CSubtitle::GetNextLine(POSITION& pos, int maxwidth) int width = w->m_width;
POSITION pos2 = pos;
- while(pos2) {
- if(m_words.GetAt(pos2)->m_fWhiteSpaceChar != fWSC
+ while (pos2) {
+ if (m_words.GetAt(pos2)->m_fWhiteSpaceChar != fWSC
|| m_words.GetAt(pos2)->m_fLineBreak) {
break;
}
@@ -1459,16 +1460,16 @@ CLine* CSubtitle::GetNextLine(POSITION& pos, int maxwidth) width += w2->m_width;
}
- if((ret->m_width += width) <= maxwidth || ret->IsEmpty()) {
+ if ((ret->m_width += width) <= maxwidth || ret->IsEmpty()) {
ret->AddTail(w->Copy());
- while(pos != pos2) {
+ while (pos != pos2) {
ret->AddTail(m_words.GetNext(pos)->Copy());
}
pos = pos2;
} else {
- if(pos) {
+ if (pos) {
m_words.GetPrev(pos);
} else {
pos = m_words.GetTailPosition();
@@ -1490,16 +1491,16 @@ void CSubtitle::CreateClippers(CSize size) size.cx >>= 3;
size.cy >>= 3;
- if(m_effects[EF_BANNER] && m_effects[EF_BANNER]->param[2]) {
+ if (m_effects[EF_BANNER] && m_effects[EF_BANNER]->param[2]) {
int width = m_effects[EF_BANNER]->param[2];
int w = size.cx, h = size.cy;
- if(!m_pClipper) {
+ if (!m_pClipper) {
CStringW str;
str.Format(L"m %d %d l %d %d %d %d %d %d", 0, 0, w, 0, w, h, 0, h);
m_pClipper = DNew CClipper(str, size, 1, 1, false, CPoint(0,0));
- if(!m_pClipper) {
+ if (!m_pClipper) {
return;
}
}
@@ -1507,36 +1508,36 @@ void CSubtitle::CreateClippers(CSize size) int da = (64<<8)/width;
BYTE* am = m_pClipper->m_pAlphaMask;
- for(ptrdiff_t j = 0; j < h; j++, am += w) {
+ for (ptrdiff_t j = 0; j < h; j++, am += w) {
int a = 0;
int k = min(width, w);
- for(ptrdiff_t i = 0; i < k; i++, a += da) {
+ for (ptrdiff_t i = 0; i < k; i++, a += da) {
am[i] = (am[i]*a)>>14;
}
a = 0x40<<8;
k = w-width;
- if(k < 0) {
+ if (k < 0) {
a -= -k*da;
k = 0;
}
- for(ptrdiff_t i = k; i < w; i++, a -= da) {
+ for (ptrdiff_t i = k; i < w; i++, a -= da) {
am[i] = (am[i]*a)>>14;
}
}
- } else if(m_effects[EF_SCROLL] && m_effects[EF_SCROLL]->param[4]) {
+ } else if (m_effects[EF_SCROLL] && m_effects[EF_SCROLL]->param[4]) {
int height = m_effects[EF_SCROLL]->param[4];
int w = size.cx, h = size.cy;
- if(!m_pClipper) {
+ if (!m_pClipper) {
CStringW str;
str.Format(L"m %d %d l %d %d %d %d %d %d", 0, 0, w, 0, w, h, 0, h);
m_pClipper = DNew CClipper(str, size, 1, 1, false, CPoint(0,0));
- if(!m_pClipper) {
+ if (!m_pClipper) {
return;
}
}
@@ -1545,21 +1546,21 @@ void CSubtitle::CreateClippers(CSize size) int a = 0;
int k = m_effects[EF_SCROLL]->param[0]>>3;
int l = k+height;
- if(k < 0) {
+ if (k < 0) {
a += -k*da;
k = 0;
}
- if(l > h) {
+ if (l > h) {
l = h;
}
- if(k < h) {
+ if (k < h) {
BYTE* am = &m_pClipper->m_pAlphaMask[k*w];
memset(m_pClipper->m_pAlphaMask, 0, am - m_pClipper->m_pAlphaMask);
- for(ptrdiff_t j = k; j < l; j++, a += da) {
- for(ptrdiff_t i = 0; i < w; i++, am++) {
+ for (ptrdiff_t j = k; j < l; j++, a += da) {
+ for (ptrdiff_t i = 0; i < w; i++, am++) {
*am = ((*am)*a)>>14;
}
}
@@ -1569,20 +1570,20 @@ void CSubtitle::CreateClippers(CSize size) a = 0x40<<8;
l = m_effects[EF_SCROLL]->param[1]>>3;
k = l-height;
- if(k < 0) {
+ if (k < 0) {
a += -k*da;
k = 0;
}
- if(l > h) {
+ if (l > h) {
l = h;
}
- if(k < h) {
+ if (k < h) {
BYTE* am = &m_pClipper->m_pAlphaMask[k*w];
int j = k;
- for(; j < l; j++, a += da) {
- for(ptrdiff_t i = 0; i < w; i++, am++) {
+ for (; j < l; j++, a += da) {
+ for (ptrdiff_t i = 0; i < w; i++, am++) {
*am = ((*am)*a)>>14;
}
}
@@ -1603,13 +1604,13 @@ void CSubtitle::MakeLines(CSize size, CRect marginRect) CLine* l = NULL;
POSITION pos = m_words.GetHeadPosition();
- while(pos) {
+ while (pos) {
l = GetNextLine(pos, size.cx - marginRect.left - marginRect.right);
- if(!l) {
+ if (!l) {
break;
}
- if(fFirstLine) {
+ if (fFirstLine) {
m_topborder = l->m_borderY;
fFirstLine = false;
}
@@ -1620,7 +1621,7 @@ void CSubtitle::MakeLines(CSize size, CRect marginRect) AddTail(l);
}
- if(l) {
+ if (l) {
m_bottomborder = l->m_borderY;
}
@@ -1671,9 +1672,9 @@ CRect CScreenLayoutAllocator::AllocRect(CSubtitle* s, int segment, int entry, in // TODO: handle collisions == 1 (reversed collisions)
POSITION pos = m_subrects.GetHeadPosition();
- while(pos) {
+ while (pos) {
SubRect& sr = m_subrects.GetNext(pos);
- if(sr.segment == segment && sr.entry == entry) {
+ if (sr.segment == segment && sr.entry == entry) {
return(sr.r + CRect(0, -s->m_topborder, 0, -s->m_bottomborder));
}
}
@@ -1688,11 +1689,11 @@ CRect CScreenLayoutAllocator::AllocRect(CSubtitle* s, int segment, int entry, in fOK = true;
pos = m_subrects.GetHeadPosition();
- while(pos) {
+ while (pos) {
SubRect& sr = m_subrects.GetNext(pos);
- if(layer == sr.layer && !(r & sr.r).IsRectEmpty()) {
- if(fSearchDown) {
+ if (layer == sr.layer && !(r & sr.r).IsRectEmpty()) {
+ if (fSearchDown) {
r.bottom = sr.r.bottom + r.Height();
r.top = sr.r.bottom;
} else {
@@ -1703,7 +1704,7 @@ CRect CScreenLayoutAllocator::AllocRect(CSubtitle* s, int segment, int entry, in fOK = false;
}
}
- } while(!fOK);
+ } while (!fOK);
SubRect sr;
sr.r = r;
@@ -1722,7 +1723,7 @@ CRenderedTextSubtitle::CRenderedTextSubtitle(CCritSec* pLock, STSStyle *styleOve {
m_size = CSize(0, 0);
- if(g_hDC_refcnt == 0) {
+ if (g_hDC_refcnt == 0) {
g_hDC = CreateCompatibleDC(NULL);
#ifdef _VSMOD // patch m007. symbol rotating
SetGraphicsMode(g_hDC, GM_ADVANCED); // patch for lfOrientation
@@ -1740,7 +1741,7 @@ CRenderedTextSubtitle::~CRenderedTextSubtitle() Deinit();
g_hDC_refcnt--;
- if(g_hDC_refcnt == 0) {
+ if (g_hDC_refcnt == 0) {
DeleteDC(g_hDC);
}
}
@@ -1751,7 +1752,7 @@ void CRenderedTextSubtitle::Copy(CSimpleTextSubtitle& sts) m_size = CSize(0, 0);
- if(CRenderedTextSubtitle* pRTS = dynamic_cast<CRenderedTextSubtitle*>(&sts)) {
+ if (CRenderedTextSubtitle* pRTS = dynamic_cast<CRenderedTextSubtitle*>(&sts)) {
m_size = pRTS->m_size;
}
}
@@ -1768,7 +1769,7 @@ void CRenderedTextSubtitle::OnChanged() __super::OnChanged();
POSITION pos = m_subtitleCache.GetStartPosition();
- while(pos) {
+ while (pos) {
int i;
CSubtitle* s;
m_subtitleCache.GetNextAssoc(pos, i, s);
@@ -1795,7 +1796,7 @@ bool CRenderedTextSubtitle::Init(CSize size, CRect vidrect) void CRenderedTextSubtitle::Deinit()
{
POSITION pos = m_subtitleCache.GetStartPosition();
- while(pos) {
+ while (pos) {
int i;
CSubtitle* s;
m_subtitleCache.GetNextAssoc(pos, i, s);
@@ -1813,26 +1814,26 @@ void CRenderedTextSubtitle::Deinit() void CRenderedTextSubtitle::ParseEffect(CSubtitle* sub, CString str)
{
str.Trim();
- if(!sub || str.IsEmpty()) {
+ if (!sub || str.IsEmpty()) {
return;
}
const TCHAR* s = _tcschr(str, ';');
- if(!s) {
+ if (!s) {
s = (LPTSTR)(LPCTSTR)str;
s += str.GetLength() - 1;
}
s++;
CString effect = str.Left(s - str);
- if(!effect.CompareNoCase(_T("Banner;"))) {
+ if (!effect.CompareNoCase(_T("Banner;"))) {
int delay, lefttoright = 0, fadeawaywidth = 0;
- if(_stscanf(s, _T("%d;%d;%d"), &delay, &lefttoright, &fadeawaywidth) < 1) {
+ if (_stscanf(s, _T("%d;%d;%d"), &delay, &lefttoright, &fadeawaywidth) < 1) {
return;
}
Effect* e = DNew Effect;
- if(!e) {
+ if (!e) {
return;
}
@@ -1842,20 +1843,20 @@ void CRenderedTextSubtitle::ParseEffect(CSubtitle* sub, CString str) e->param[2] = (int)(sub->m_scalex*fadeawaywidth);
sub->m_wrapStyle = 2;
- } else if(!effect.CompareNoCase(_T("Scroll up;")) || !effect.CompareNoCase(_T("Scroll down;"))) {
+ } else if (!effect.CompareNoCase(_T("Scroll up;")) || !effect.CompareNoCase(_T("Scroll down;"))) {
int top, bottom, delay, fadeawayheight = 0;
- if(_stscanf(s, _T("%d;%d;%d;%d"), &top, &bottom, &delay, &fadeawayheight) < 3) {
+ if (_stscanf(s, _T("%d;%d;%d;%d"), &top, &bottom, &delay, &fadeawayheight) < 3) {
return;
}
- if(top > bottom) {
+ if (top > bottom) {
int tmp = top;
top = bottom;
bottom = tmp;
}
Effect* e = DNew Effect;
- if(!e) {
+ if (!e) {
return;
}
@@ -1870,7 +1871,7 @@ void CRenderedTextSubtitle::ParseEffect(CSubtitle* sub, CString str) void CRenderedTextSubtitle::ParseString(CSubtitle* sub, CStringW str, STSStyle& style)
{
- if(!sub) {
+ if (!sub) {
return;
}
@@ -1878,27 +1879,27 @@ void CRenderedTextSubtitle::ParseString(CSubtitle* sub, CStringW str, STSStyle& str.Replace(L"\\n", (sub->m_wrapStyle < 2 || sub->m_wrapStyle == 3) ? L" " : L"\n");
str.Replace(L"\\h", L"\x00A0");
- for(size_t i = 0, j = 0, len = str.GetLength(); j <= len; j++) {
+ for (size_t i = 0, j = 0, len = str.GetLength(); j <= len; j++) {
WCHAR c = str[j];
- if(c != '\n' && c != ' ' && c != '\x00A0' && c != 0) {
+ if (c != '\n' && c != ' ' && c != '\x00A0' && c != 0) {
continue;
}
- if(i < j) {
- if(CWord* w = DNew CText(style, str.Mid(i, j-i), m_ktype, m_kstart, m_kend)) {
+ if (i < j) {
+ if (CWord* w = DNew CText(style, str.Mid(i, j-i), m_ktype, m_kstart, m_kend)) {
sub->m_words.AddTail(w);
m_kstart = m_kend;
}
}
- if(c == '\n') {
- if(CWord* w = DNew CText(style, CStringW(), m_ktype, m_kstart, m_kend)) {
+ if (c == '\n') {
+ if (CWord* w = DNew CText(style, CStringW(), m_ktype, m_kstart, m_kend)) {
sub->m_words.AddTail(w);
m_kstart = m_kend;
}
- } else if(c == ' ' || c == '\x00A0') {
- if(CWord* w = DNew CText(style, CStringW(c), m_ktype, m_kstart, m_kend)) {
+ } else if (c == ' ' || c == '\x00A0') {
+ if (CWord* w = DNew CText(style, CStringW(c), m_ktype, m_kstart, m_kend)) {
sub->m_words.AddTail(w);
m_kstart = m_kend;
}
@@ -1912,11 +1913,11 @@ void CRenderedTextSubtitle::ParseString(CSubtitle* sub, CStringW str, STSStyle& void CRenderedTextSubtitle::ParsePolygon(CSubtitle* sub, CStringW str, STSStyle& style)
{
- if(!sub || !str.GetLength() || !m_nPolygon) {
+ if (!sub || !str.GetLength() || !m_nPolygon) {
return;
}
- if(CWord* w = DNew CPolygon(style, str, m_ktype, m_kstart, m_kend, sub->m_scalex/(1<<(m_nPolygon-1)), sub->m_scaley/(1<<(m_nPolygon-1)), m_polygonBaselineOffset)) {
+ if (CWord* w = DNew CPolygon(style, str, m_ktype, m_kstart, m_kend, sub->m_scalex/(1<<(m_nPolygon-1)), sub->m_scaley/(1<<(m_nPolygon-1)), m_polygonBaselineOffset)) {
sub->m_words.AddTail(w);
m_kstart = m_kend;
}
@@ -1924,29 +1925,29 @@ void CRenderedTextSubtitle::ParsePolygon(CSubtitle* sub, CStringW str, STSStyle& bool CRenderedTextSubtitle::ParseSSATag(CSubtitle* sub, CStringW str, STSStyle& style, STSStyle& org, bool fAnimate)
{
- if(!sub) {
+ if (!sub) {
return false;
}
int nTags = 0, nUnrecognizedTags = 0;
- for(int i = 0, j; (j = str.Find('\\', i)) >= 0; i = j) {
+ for (int i = 0, j; (j = str.Find('\\', i)) >= 0; i = j) {
CStringW cmd;
- for(WCHAR c = str[++j]; c && c != '(' && c != '\\'; cmd += c, c = str[++j]) {
+ for (WCHAR c = str[++j]; c && c != '(' && c != '\\'; cmd += c, c = str[++j]) {
;
}
cmd.Trim();
- if(cmd.IsEmpty()) {
+ if (cmd.IsEmpty()) {
continue;
}
CAtlArray<CStringW> params;
- if(str[j] == '(') {
+ if (str[j] == '(') {
CStringW param;
// complex tags search
int br = 1; // 1 bracket
- for(WCHAR c = str[++j]; c && br>0; param += c, c = str[++j]) {
+ for (WCHAR c = str[++j]; c && br>0; param += c, c = str[++j]) {
if (c=='(') {
br++;
}
@@ -1959,18 +1960,18 @@ bool CRenderedTextSubtitle::ParseSSATag(CSubtitle* sub, CStringW str, STSStyle& }
param.Trim();
- while(!param.IsEmpty()) {
+ while (!param.IsEmpty()) {
int i = param.Find(','), j = param.Find('\\');
- if(i >= 0 && (j < 0 || i < j)) {
+ if (i >= 0 && (j < 0 || i < j)) {
CStringW s = param.Left(i).Trim();
- if(!s.IsEmpty()) {
+ if (!s.IsEmpty()) {
params.Add(s);
}
param = i+1 < param.GetLength() ? param.Mid(i+1) : L"";
} else {
param.Trim();
- if(!param.IsEmpty()) {
+ if (!param.IsEmpty()) {
params.Add(param);
}
param.Empty();
@@ -1978,149 +1979,149 @@ bool CRenderedTextSubtitle::ParseSSATag(CSubtitle* sub, CStringW str, STSStyle& }
}
- if(!cmd.Find(L"1c") || !cmd.Find(L"2c") || !cmd.Find(L"3c") || !cmd.Find(L"4c")) {
+ if (!cmd.Find(L"1c") || !cmd.Find(L"2c") || !cmd.Find(L"3c") || !cmd.Find(L"4c")) {
params.Add(cmd.Mid(2).Trim(L"&H")), cmd = cmd.Left(2);
- } else if(!cmd.Find(L"1a") || !cmd.Find(L"2a") || !cmd.Find(L"3a") || !cmd.Find(L"4a")) {
+ } else if (!cmd.Find(L"1a") || !cmd.Find(L"2a") || !cmd.Find(L"3a") || !cmd.Find(L"4a")) {
params.Add(cmd.Mid(2).Trim(L"&H")), cmd = cmd.Left(2);
}
#ifdef _VSMOD // patch m010. png background
- else if(!cmd.Find(L"1img") || !cmd.Find(L"2img") || !cmd.Find(L"3img") || !cmd.Find(L"4img")) {
+ else if (!cmd.Find(L"1img") || !cmd.Find(L"2img") || !cmd.Find(L"3img") || !cmd.Find(L"4img")) {
; //params.Add(cmd.Mid(4)), cmd = cmd.Left(4);
}
#endif
#ifdef _VSMOD // patch m004. gradient colors
- else if(!cmd.Find(L"1vc") || !cmd.Find(L"2vc") || !cmd.Find(L"3vc") || !cmd.Find(L"4vc")) {
+ else if (!cmd.Find(L"1vc") || !cmd.Find(L"2vc") || !cmd.Find(L"3vc") || !cmd.Find(L"4vc")) {
; //params.Add(cmd.Mid(3)), cmd = cmd.Left(3);
- } else if(!cmd.Find(L"1va") || !cmd.Find(L"2va") || !cmd.Find(L"3va") || !cmd.Find(L"4va")) {
+ } else if (!cmd.Find(L"1va") || !cmd.Find(L"2va") || !cmd.Find(L"3va") || !cmd.Find(L"4va")) {
; //params.Add(cmd.Mid(3)), cmd = cmd.Left(3);
}
#endif
- else if(!cmd.Find(L"alpha")) {
+ else if (!cmd.Find(L"alpha")) {
params.Add(cmd.Mid(5).Trim(L"&H")), cmd = cmd.Left(5);
- } else if(!cmd.Find(L"an")) {
+ } else if (!cmd.Find(L"an")) {
params.Add(cmd.Mid(2)), cmd = cmd.Left(2);
- } else if(!cmd.Find(L"a")) {
+ } else if (!cmd.Find(L"a")) {
params.Add(cmd.Mid(1)), cmd = cmd.Left(1);
- } else if(!cmd.Find(L"blur")) {
+ } else if (!cmd.Find(L"blur")) {
params.Add(cmd.Mid(4)), cmd = cmd.Left(4);
- } else if(!cmd.Find(L"bord")) {
+ } else if (!cmd.Find(L"bord")) {
params.Add(cmd.Mid(4)), cmd = cmd.Left(4);
- } else if(!cmd.Find(L"be")) {
+ } else if (!cmd.Find(L"be")) {
params.Add(cmd.Mid(2)), cmd = cmd.Left(2);
- } else if(!cmd.Find(L"b")) {
+ } else if (!cmd.Find(L"b")) {
params.Add(cmd.Mid(1)), cmd = cmd.Left(1);
- } else if(!cmd.Find(L"clip")) {
+ } else if (!cmd.Find(L"clip")) {
;
- } else if(!cmd.Find(L"c")) {
+ } else if (!cmd.Find(L"c")) {
params.Add(cmd.Mid(1).Trim(L"&H")), cmd = cmd.Left(1);
}
#ifdef _VSMOD // patch m008. distort
- else if(!cmd.Find(L"distort")) {
+ else if (!cmd.Find(L"distort")) {
;
}
#endif
- else if(!cmd.Find(L"fade")) {
+ else if (!cmd.Find(L"fade")) {
;
- } else if(!cmd.Find(L"fe")) {
+ } else if (!cmd.Find(L"fe")) {
params.Add(cmd.Mid(2)), cmd = cmd.Left(2);
- } else if(!cmd.Find(L"fn")) {
+ } else if (!cmd.Find(L"fn")) {
params.Add(cmd.Mid(2)), cmd = cmd.Left(2);
- } else if(!cmd.Find(L"frx") || !cmd.Find(L"fry") || !cmd.Find(L"frz")) {
+ } else if (!cmd.Find(L"frx") || !cmd.Find(L"fry") || !cmd.Find(L"frz")) {
params.Add(cmd.Mid(3)), cmd = cmd.Left(3);
}
#ifdef _VSMOD // patch m007. symbol rotating
- else if(!cmd.Find(L"frs")) {
+ else if (!cmd.Find(L"frs")) {
params.Add(cmd.Mid(3)), cmd = cmd.Left(3);
}
#endif
- else if(!cmd.Find(L"fax") || !cmd.Find(L"fay")) {
+ else if (!cmd.Find(L"fax") || !cmd.Find(L"fay")) {
params.Add(cmd.Mid(3)), cmd = cmd.Left(3);
- } else if(!cmd.Find(L"fr")) {
+ } else if (!cmd.Find(L"fr")) {
params.Add(cmd.Mid(2)), cmd = cmd.Left(2);
- } else if(!cmd.Find(L"fscx") || !cmd.Find(L"fscy")) {
+ } else if (!cmd.Find(L"fscx") || !cmd.Find(L"fscy")) {
params.Add(cmd.Mid(4)), cmd = cmd.Left(4);
- } else if(!cmd.Find(L"fsc")) {
+ } else if (!cmd.Find(L"fsc")) {
params.Add(cmd.Mid(3)), cmd = cmd.Left(3);
- } else if(!cmd.Find(L"fsp")) {
+ } else if (!cmd.Find(L"fsp")) {
params.Add(cmd.Mid(3)), cmd = cmd.Left(3);
}
#ifdef _VSMOD// patch m001. Vertical fontspacing
- else if(!cmd.Find(L"fsvp")) {
+ else if (!cmd.Find(L"fsvp")) {
params.Add(cmd.Mid(4)), cmd = cmd.Left(4);
}
#endif
- else if(!cmd.Find(L"fs")) {
+ else if (!cmd.Find(L"fs")) {
params.Add(cmd.Mid(2)), cmd = cmd.Left(2);
- } else if(!cmd.Find(L"iclip")) {
+ } else if (!cmd.Find(L"iclip")) {
;
- } else if(!cmd.Find(L"i")) {
+ } else if (!cmd.Find(L"i")) {
params.Add(cmd.Mid(1)), cmd = cmd.Left(1);
}
#ifdef _VSMOD // patch m011. jitter
- else if(!cmd.Find(L"jitter")) {
+ else if (!cmd.Find(L"jitter")) {
;
}
#endif
- else if(!cmd.Find(L"kt") || !cmd.Find(L"kf") || !cmd.Find(L"ko")) {
+ else if (!cmd.Find(L"kt") || !cmd.Find(L"kf") || !cmd.Find(L"ko")) {
params.Add(cmd.Mid(2)), cmd = cmd.Left(2);
- } else if(!cmd.Find(L"k") || !cmd.Find(L"K")) {
+ } else if (!cmd.Find(L"k") || !cmd.Find(L"K")) {
params.Add(cmd.Mid(1)), cmd = cmd.Left(1);
}
#ifdef _VSMOD // patch m005. add some move types
- else if(!cmd.Find(L"mover")) { // radial move
+ else if (!cmd.Find(L"mover")) { // radial move
;
- } else if(!cmd.Find(L"moves3")) { // square spline
+ } else if (!cmd.Find(L"moves3")) { // square spline
;
- } else if(!cmd.Find(L"moves4")) { // cubic spline
+ } else if (!cmd.Find(L"moves4")) { // cubic spline
;
}
#endif
#ifdef _VSMOD // patch m006. moveable vector clip
- else if(!cmd.Find(L"movevc")) {
+ else if (!cmd.Find(L"movevc")) {
;
}
#endif
- else if(!cmd.Find(L"move")) {
+ else if (!cmd.Find(L"move")) {
;
- } else if(!cmd.Find(L"org")) {
+ } else if (!cmd.Find(L"org")) {
;
- } else if(!cmd.Find(L"pbo")) {
+ } else if (!cmd.Find(L"pbo")) {
params.Add(cmd.Mid(3)), cmd = cmd.Left(3);
- } else if(!cmd.Find(L"pos")) {
+ } else if (!cmd.Find(L"pos")) {
;
- } else if(!cmd.Find(L"p")) {
+ } else if (!cmd.Find(L"p")) {
params.Add(cmd.Mid(1)), cmd = cmd.Left(1);
- } else if(!cmd.Find(L"q")) {
+ } else if (!cmd.Find(L"q")) {
params.Add(cmd.Mid(1)), cmd = cmd.Left(1);
}
#ifdef _VSMOD // patch m003. random text points
- else if(!cmd.Find(L"rndx") || !cmd.Find(L"rndy") || !cmd.Find(L"rndz") || !cmd.Find(L"rnds")) {
+ else if (!cmd.Find(L"rndx") || !cmd.Find(L"rndy") || !cmd.Find(L"rndz") || !cmd.Find(L"rnds")) {
params.Add(cmd.Mid(4)), cmd = cmd.Left(4);
- } else if(!cmd.Find(L"rnd")) {
+ } else if (!cmd.Find(L"rnd")) {
params.Add(cmd.Mid(3)), cmd = cmd.Left(3);
}
#endif
- else if(!cmd.Find(L"r")) {
+ else if (!cmd.Find(L"r")) {
params.Add(cmd.Mid(1)), cmd = cmd.Left(1);
- } else if(!cmd.Find(L"shad")) {
+ } else if (!cmd.Find(L"shad")) {
params.Add(cmd.Mid(4)), cmd = cmd.Left(4);
- } else if(!cmd.Find(L"s")) {
+ } else if (!cmd.Find(L"s")) {
params.Add(cmd.Mid(1)), cmd = cmd.Left(1);
- } else if(!cmd.Find(L"t")) {
+ } else if (!cmd.Find(L"t")) {
;
- } else if(!cmd.Find(L"u")) {
+ } else if (!cmd.Find(L"u")) {
params.Add(cmd.Mid(1)), cmd = cmd.Left(1);
- } else if(!cmd.Find(L"xbord")) {
+ } else if (!cmd.Find(L"xbord")) {
params.Add(cmd.Mid(5)), cmd = cmd.Left(5);
- } else if(!cmd.Find(L"xshad")) {
+ } else if (!cmd.Find(L"xshad")) {
params.Add(cmd.Mid(5)), cmd = cmd.Left(5);
- } else if(!cmd.Find(L"ybord")) {
+ } else if (!cmd.Find(L"ybord")) {
params.Add(cmd.Mid(5)), cmd = cmd.Left(5);
- } else if(!cmd.Find(L"yshad")) {
+ } else if (!cmd.Find(L"yshad")) {
params.Add(cmd.Mid(5)), cmd = cmd.Left(5);
}
#ifdef _VSMOD // patch m002. Z-coord
- else if(!cmd.Find(L"z")) {
+ else if (!cmd.Find(L"z")) {
params.Add(cmd.Mid(1)), cmd = cmd.Left(1);
}
#endif
@@ -2134,7 +2135,7 @@ bool CRenderedTextSubtitle::ParseSSATag(CSubtitle* sub, CStringW str, STSStyle& CStringW p = params.GetCount() > 0 ? params[0] : L"";
- if(cmd == "1c" || cmd == L"2c" || cmd == L"3c" || cmd == L"4c") {
+ if (cmd == "1c" || cmd == L"2c" || cmd == L"3c" || cmd == L"4c") {
int i = cmd[0] - '1';
DWORD c = wcstol(p, NULL, 16);
@@ -2154,7 +2155,7 @@ bool CRenderedTextSubtitle::ParseSSATag(CSubtitle* sub, CStringW str, STSStyle& |(int)c&0xff0000)
: org.mod_grad.color[i][j];
}
- } else if(style.mod_grad.mode[i] != 0) {
+ } else if (style.mod_grad.mode[i] != 0) {
for (int j=0; j<4; j++) {
style.mod_grad.color[i][j] = !p.IsEmpty()
? (((int)CalcAnimation(c&0xff, style.mod_grad.color[i][j]&0xff, fAnimate))&0xff
@@ -2164,7 +2165,7 @@ bool CRenderedTextSubtitle::ParseSSATag(CSubtitle* sub, CStringW str, STSStyle& }
}
#endif
- } else if(cmd == L"1a" || cmd == L"2a" || cmd == L"3a" || cmd == L"4a") {
+ } else if (cmd == L"1a" || cmd == L"2a" || cmd == L"3a" || cmd == L"4a") {
DWORD al = wcstol(p, NULL, 16)&0xff;
int i = cmd[0] - '1';
@@ -2191,45 +2192,45 @@ bool CRenderedTextSubtitle::ParseSSATag(CSubtitle* sub, CStringW str, STSStyle& #endif
}
#ifdef _VSMOD // patch m010. png background
- else if(cmd == L"1img" || cmd == L"2img" || cmd == L"3img" || cmd == L"4img") {
+ else if (cmd == L"1img" || cmd == L"2img" || cmd == L"3img" || cmd == L"4img") {
int i = cmd[0] - '1';
- if(params.GetCount() >= 1) { // file[,xoffset,yoffset[,angle]]
+ if (params.GetCount() >= 1) { // file[,xoffset,yoffset[,angle]]
if (!fAnimate) {
CString fpath = m_path.Left(m_path.ReverseFind('\\')+1);
bool t_init = false;
// buffer
- for(ptrdiff_t k = 0, j = mod_images.GetCount(); k < j; k++) {
+ for (ptrdiff_t k = 0, j = mod_images.GetCount(); k < j; k++) {
MOD_PNGIMAGE t_temp = mod_images[k];
- if(t_temp.filename==params[0]) { // found buffered image
+ if (t_temp.filename==params[0]) { // found buffered image
style.mod_grad.b_images[i] = t_temp;
t_init = true;
break;
}
- if(t_temp.filename==fpath+params[0]) { // found buffered image
+ if (t_temp.filename==fpath+params[0]) { // found buffered image
style.mod_grad.b_images[i] = t_temp;
t_init = true;
break;
}
}
- if(t_init) {
+ if (t_init) {
style.mod_grad.mode[i] = 2;
} else {
// not found
MOD_PNGIMAGE t_temp;
- if(t_temp.initImage(params[0])) { // absolute path or default directory
+ if (t_temp.initImage(params[0])) { // absolute path or default directory
style.mod_grad.mode[i] = 2;
style.mod_grad.b_images[i] = t_temp;
mod_images.Add(t_temp);
- } else if(t_temp.initImage(fpath+params[0])) { // path + relative path
+ } else if (t_temp.initImage(fpath+params[0])) { // path + relative path
style.mod_grad.mode[i] = 2;
style.mod_grad.b_images[i] = t_temp;
mod_images.Add(t_temp);
}
}
}
- if(params.GetCount() >= 3) {
+ if (params.GetCount() >= 3) {
style.mod_grad.b_images[i].xoffset = !p.IsEmpty()
? CalcAnimation(wcstol(params[1], NULL, 10), style.mod_grad.b_images[i].xoffset, fAnimate)
: org.mod_grad.b_images[i].xoffset;
@@ -2241,10 +2242,10 @@ bool CRenderedTextSubtitle::ParseSSATag(CSubtitle* sub, CStringW str, STSStyle& }
#endif
#ifdef _VSMOD // patch m004. gradient colors
- else if(cmd == L"1vc" || cmd == L"2vc" || cmd == L"3vc" || cmd == L"4vc") {
+ else if (cmd == L"1vc" || cmd == L"2vc" || cmd == L"3vc" || cmd == L"4vc") {
int i = cmd[0] - '1';
- if(params.GetCount() >= 4) {
+ if (params.GetCount() >= 4) {
DWORD c;
for (int j=0; j<4; j++) {
c = wcstol(params[j].Trim(L"&H"), NULL, 16);
@@ -2262,10 +2263,10 @@ bool CRenderedTextSubtitle::ParseSSATag(CSubtitle* sub, CStringW str, STSStyle& //if (!fAnimate)
style.mod_grad.mode[i] = 1;
}
- } else if(cmd == L"1va" || cmd == L"2va" || cmd == L"3va" || cmd == L"4va") {
+ } else if (cmd == L"1va" || cmd == L"2va" || cmd == L"3va" || cmd == L"4va") {
int i = cmd[0] - '1';
- if(params.GetCount() >= 4) {
+ if (params.GetCount() >= 4) {
int a;
for (int j=0; j<4; j++) {
a = wcstol(params[j].Trim(L"&H"), NULL, 16);
@@ -2282,8 +2283,8 @@ bool CRenderedTextSubtitle::ParseSSATag(CSubtitle* sub, CStringW str, STSStyle& }
}
#endif
- else if(cmd == L"alpha") {
- for(ptrdiff_t i = 0; i < 4; i++) {
+ else if (cmd == L"alpha") {
+ for (ptrdiff_t i = 0; i < 4; i++) {
DWORD al = wcstol(p, NULL, 16)&0xff;
style.alpha[i] = !p.IsEmpty()
? (BYTE)CalcAnimation(al, style.alpha[i], fAnimate)
@@ -2298,7 +2299,7 @@ bool CRenderedTextSubtitle::ParseSSATag(CSubtitle* sub, CStringW str, STSStyle& : org.mod_grad.alpha[i][j];
style.mod_grad.b_images[i].alpha = 255-al;
}
- } else if(style.mod_grad.mode[i] != 0) {
+ } else if (style.mod_grad.mode[i] != 0) {
for (int j=0; j<4; j++) {
style.mod_grad.alpha[i][j] = !p.IsEmpty()
? (((int)CalcAnimation(al, style.mod_grad.alpha[i][j], fAnimate)))
@@ -2308,22 +2309,22 @@ bool CRenderedTextSubtitle::ParseSSATag(CSubtitle* sub, CStringW str, STSStyle& }
#endif
}
- } else if(cmd == L"an") {
+ } else if (cmd == L"an") {
int n = wcstol(p, NULL, 10);
- if(sub->m_scrAlignment < 0) {
+ if (sub->m_scrAlignment < 0) {
sub->m_scrAlignment = (n > 0 && n < 10) ? n : org.scrAlignment;
}
- } else if(cmd == L"a") {
+ } else if (cmd == L"a") {
int n = wcstol(p, NULL, 10);
- if(sub->m_scrAlignment < 0) {
+ if (sub->m_scrAlignment < 0) {
sub->m_scrAlignment = (n > 0 && n < 12) ? ((((n-1)&3)+1)+((n&4)?6:0)+((n&8)?3:0)) : org.scrAlignment;
}
- } else if(cmd == L"blur") {
+ } else if (cmd == L"blur") {
double n = CalcAnimation(wcstod(p, NULL), style.fGaussianBlur, fAnimate);
style.fGaussianBlur = !p.IsEmpty()
? (n < 0 ? 0 : n)
: org.fGaussianBlur;
- } else if(cmd == L"bord") {
+ } else if (cmd == L"bord") {
double dst = wcstod(p, NULL);
double nx = CalcAnimation(dst, style.outlineWidthX, fAnimate);
style.outlineWidthX = !p.IsEmpty()
@@ -2333,26 +2334,26 @@ bool CRenderedTextSubtitle::ParseSSATag(CSubtitle* sub, CStringW str, STSStyle& style.outlineWidthY = !p.IsEmpty()
? (ny < 0 ? 0 : ny)
: org.outlineWidthY;
- } else if(cmd == L"be") {
+ } else if (cmd == L"be") {
int n = (int)(CalcAnimation(wcstol(p, NULL, 10), style.fBlur, fAnimate)+0.5);
style.fBlur = !p.IsEmpty()
? n
: org.fBlur;
- } else if(cmd == L"b") {
+ } else if (cmd == L"b") {
int n = wcstol(p, NULL, 10);
style.fontWeight = !p.IsEmpty()
? (n == 0 ? FW_NORMAL : n == 1 ? FW_BOLD : n >= 100 ? n : org.fontWeight)
: org.fontWeight;
- } else if(cmd == L"clip" || cmd == L"iclip") {
+ } else if (cmd == L"clip" || cmd == L"iclip") {
bool invert = (cmd == L"iclip");
- if(params.GetCount() == 1 && !sub->m_pClipper) {
+ if (params.GetCount() == 1 && !sub->m_pClipper) {
sub->m_pClipper = DNew CClipper(params[0], CSize(m_size.cx>>3, m_size.cy>>3), sub->m_scalex, sub->m_scaley, invert, (sub->m_relativeTo == 1)? CPoint(m_vidrect.left, m_vidrect.top) : CPoint(0, 0));
- } else if(params.GetCount() == 2 && !sub->m_pClipper) {
+ } else if (params.GetCount() == 2 && !sub->m_pClipper) {
long scale = wcstol(p, NULL, 10);
- if(scale < 1) scale = 1;
+ if (scale < 1) scale = 1;
sub->m_pClipper = DNew CClipper(params[1], CSize(m_size.cx>>3, m_size.cy>>3), sub->m_scalex/(1<<(scale-1)), sub->m_scaley/(1<<(scale-1)), invert, (sub->m_relativeTo == 1)? CPoint(m_vidrect.left, m_vidrect.top) : CPoint(0, 0));
- } else if(params.GetCount() == 4) {
+ } else if (params.GetCount() == 4) {
CRect r;
sub->m_clipInverse = invert;
@@ -2364,13 +2365,14 @@ bool CRenderedTextSubtitle::ParseSSATag(CSubtitle* sub, CStringW str, STSStyle& wcstol(params[3], NULL, 10));
double dLeft = sub->m_scalex*static_cast<double>(r.left), dTop = sub->m_scaley*static_cast<double>(r.top), dRight = sub->m_scalex*static_cast<double>(r.right), dBottom = sub->m_scaley*static_cast<double>(r.bottom);
- if(sub->m_relativeTo == 1) {
+ if (sub->m_relativeTo == 1) {
double dOffsetX = static_cast<double>(m_vidrect.left)*0.125;
double dOffsetY = static_cast<double>(m_vidrect.top)*0.125;
dLeft += dOffsetX;
dTop += dOffsetY;
dRight += dOffsetX;
- dBottom += dOffsetY;}
+ dBottom += dOffsetY;
+ }
sub->m_clip.SetRect(
static_cast<int>(CalcAnimation(dLeft, sub->m_clip.left, fAnimate)),
@@ -2378,7 +2380,7 @@ bool CRenderedTextSubtitle::ParseSSATag(CSubtitle* sub, CStringW str, STSStyle& static_cast<int>(CalcAnimation(dRight, sub->m_clip.right, fAnimate)),
static_cast<int>(CalcAnimation(dBottom, sub->m_clip.bottom, fAnimate)));
}
- } else if(cmd == L"c") {
+ } else if (cmd == L"c") {
DWORD c = wcstol(p, NULL, 16);
style.colors[0] = !p.IsEmpty()
? (((int)CalcAnimation(c&0xff, style.colors[0]&0xff, fAnimate))&0xff
@@ -2408,8 +2410,8 @@ bool CRenderedTextSubtitle::ParseSSATag(CSubtitle* sub, CStringW str, STSStyle& #endif
}
#ifdef _VSMOD // patch m008. distort
- else if(cmd == L"distort") {
- if(params.GetCount() >= 6) {
+ else if (cmd == L"distort") {
+ if (params.GetCount() >= 6) {
DWORD c;
for (int j=0; j<3; j++) {
style.mod_distort.pointsx[j] = !p.IsEmpty()
@@ -2423,13 +2425,13 @@ bool CRenderedTextSubtitle::ParseSSATag(CSubtitle* sub, CStringW str, STSStyle& }
}
#endif
- else if(cmd == L"fade" || cmd == L"fad") {
- if(params.GetCount() == 7 && !sub->m_effects[EF_FADE]) { // {\fade(a1=param[0], a2=param[1], a3=param[2], t1=t[0], t2=t[1], t3=t[2], t4=t[3])
- if(Effect* e = DNew Effect) {
- for(ptrdiff_t i = 0; i < 3; i++) {
+ else if (cmd == L"fade" || cmd == L"fad") {
+ if (params.GetCount() == 7 && !sub->m_effects[EF_FADE]) { // {\fade(a1=param[0], a2=param[1], a3=param[2], t1=t[0], t2=t[1], t3=t[2], t4=t[3])
+ if (Effect* e = DNew Effect) {
+ for (ptrdiff_t i = 0; i < 3; i++) {
e->param[i] = wcstol(params[i], NULL, 10);
}
- for(ptrdiff_t i = 0; i < 4; i++) {
+ for (ptrdiff_t i = 0; i < 4; i++) {
e->t[i] = wcstol(params[3+i], NULL, 10);
}
@@ -2438,11 +2440,11 @@ bool CRenderedTextSubtitle::ParseSSATag(CSubtitle* sub, CStringW str, STSStyle& #ifdef _VSMOD // patch f005. don't cache animated
sub->m_fAnimated = true;
#endif
- } else if(params.GetCount() == 2 && !sub->m_effects[EF_FADE]) { // {\fad(t1=t[1], t2=t[2])
- if(Effect* e = DNew Effect) {
+ } else if (params.GetCount() == 2 && !sub->m_effects[EF_FADE]) { // {\fad(t1=t[1], t2=t[2])
+ if (Effect* e = DNew Effect) {
e->param[0] = e->param[2] = 0xff;
e->param[1] = 0x00;
- for(ptrdiff_t i = 1; i < 3; i++) {
+ for (ptrdiff_t i = 1; i < 3; i++) {
e->t[i] = wcstol(params[i-1], NULL, 10);
}
e->t[0] = e->t[3] = -1; // will be substituted with "start" and "end"
@@ -2453,26 +2455,26 @@ bool CRenderedTextSubtitle::ParseSSATag(CSubtitle* sub, CStringW str, STSStyle& sub->m_fAnimated = true;
#endif
}
- } else if(cmd == L"fax") {
+ } else if (cmd == L"fax") {
style.fontShiftX = !p.IsEmpty()
? CalcAnimation(wcstod(p, NULL), style.fontShiftX, fAnimate)
: org.fontShiftX;
- } else if(cmd == L"fay") {
+ } else if (cmd == L"fay") {
style.fontShiftY = !p.IsEmpty()
? CalcAnimation(wcstod(p, NULL), style.fontShiftY, fAnimate)
: org.fontShiftY;
- } else if(cmd == L"fe") {
+ } else if (cmd == L"fe") {
int n = wcstol(p, NULL, 10);
style.charSet = !p.IsEmpty()
? n
: org.charSet;
- } else if(cmd == L"fn") {
+ } else if (cmd == L"fn") {
style.fontName = (!p.IsEmpty() && p != '0')
? CString(p).Trim()
: org.fontName;
}
#ifdef _VSMOD // patch m007. symbol rotating
- else if(cmd == L"frs") {
+ else if (cmd == L"frs") {
double dst = wcstod(p, NULL)*10;
style.mod_fontOrient = !p.IsEmpty()
@@ -2480,29 +2482,29 @@ bool CRenderedTextSubtitle::ParseSSATag(CSubtitle* sub, CStringW str, STSStyle& : org.mod_fontOrient;
}
#endif
- else if(cmd == L"frx") {
+ else if (cmd == L"frx") {
style.fontAngleX = !p.IsEmpty()
? CalcAnimation(wcstod(p, NULL), style.fontAngleX, fAnimate)
: org.fontAngleX;
- } else if(cmd == L"fry") {
+ } else if (cmd == L"fry") {
style.fontAngleY = !p.IsEmpty()
? CalcAnimation(wcstod(p, NULL), style.fontAngleY, fAnimate)
: org.fontAngleY;
- } else if(cmd == L"frz" || cmd == L"fr") {
+ } else if (cmd == L"frz" || cmd == L"fr") {
style.fontAngleZ = !p.IsEmpty()
? CalcAnimation(wcstod(p, NULL), style.fontAngleZ, fAnimate)
: org.fontAngleZ;
- } else if(cmd == L"fscx") {
+ } else if (cmd == L"fscx") {
double n = CalcAnimation(wcstol(p, NULL, 10), style.fontScaleX, fAnimate);
style.fontScaleX = !p.IsEmpty()
? ((n < 0) ? 0 : n)
: org.fontScaleX;
- } else if(cmd == L"fscy") {
+ } else if (cmd == L"fscy") {
double n = CalcAnimation(wcstol(p, NULL, 10), style.fontScaleY, fAnimate);
style.fontScaleY = !p.IsEmpty()
? ((n < 0) ? 0 : n)
: org.fontScaleY;
- } else if(cmd == L"fsc") {
+ } else if (cmd == L"fsc") {
#ifdef _VSMOD // patch f004. \fsc(%f) is working
double dst = wcstod(p, NULL);
double nx = CalcAnimation(dst, style.fontScaleX, fAnimate);
@@ -2517,21 +2519,21 @@ bool CRenderedTextSubtitle::ParseSSATag(CSubtitle* sub, CStringW str, STSStyle& style.fontScaleX = org.fontScaleX;
style.fontScaleY = org.fontScaleY;
#endif
- } else if(cmd == L"fsp") {
+ } else if (cmd == L"fsp") {
style.fontSpacing = !p.IsEmpty()
? CalcAnimation(wcstod(p, NULL), style.fontSpacing, fAnimate)
: org.fontSpacing;
}
#ifdef _VSMOD // patch m001. Vertical fontspacing
- else if(cmd == L"fsvp") {
+ else if (cmd == L"fsvp") {
double dst = wcstod(p, NULL)*8;
double nx = CalcAnimation(dst, style.mod_verticalSpace, fAnimate);
style.mod_verticalSpace = !p.IsEmpty() ? nx : org.mod_verticalSpace;
}
#endif
- else if(cmd == L"fs") {
- if(!p.IsEmpty()) {
- if(p[0] == '-' || p[0] == '+') {
+ else if (cmd == L"fs") {
+ if (!p.IsEmpty()) {
+ if (p[0] == '-' || p[0] == '+') {
double n = CalcAnimation(style.fontSize + style.fontSize*wcstol(p, NULL, 10)/10, style.fontSize, fAnimate);
style.fontSize = (n > 0) ? n : org.fontSize;
} else {
@@ -2541,15 +2543,15 @@ bool CRenderedTextSubtitle::ParseSSATag(CSubtitle* sub, CStringW str, STSStyle& } else {
style.fontSize = org.fontSize;
}
- } else if(cmd == L"i") {
+ } else if (cmd == L"i") {
int n = wcstol(p, NULL, 10);
style.fItalic = !p.IsEmpty()
? (n == 0 ? false : n == 1 ? true : org.fItalic)
: org.fItalic;
}
#ifdef _VSMOD // patch m011. jitter
- else if(cmd == L"jitter") { // {\jitter(left,right,up,down,period,[seed])}
- if((params.GetCount() >= 4)) {
+ else if (cmd == L"jitter") { // {\jitter(left,right,up,down,period,[seed])}
+ if ((params.GetCount() >= 4)) {
int left = (int)abs(wcstol(params[0], NULL,10))*8;
int right = (int)abs(wcstol(params[1], NULL,10))*8;
int up = (int)abs(wcstol(params[2], NULL,10))*8;
@@ -2560,10 +2562,10 @@ bool CRenderedTextSubtitle::ParseSSATag(CSubtitle* sub, CStringW str, STSStyle& style.mod_jitter.offset.right = CalcAnimation(right, style.mod_jitter.offset.right, fAnimate);
style.mod_jitter.enabled = true;
- if(params.GetCount() >= 5) {
+ if (params.GetCount() >= 5) {
int period = wcstol(params[4], NULL, 10) * 10000;
style.mod_jitter.period = CalcAnimation(period, style.mod_jitter.period, fAnimate);
- if(params.GetCount() >= 6) {
+ if (params.GetCount() >= 6) {
style.mod_jitter.seed = wcstol(params[5], NULL, 10);
}
}
@@ -2572,12 +2574,12 @@ bool CRenderedTextSubtitle::ParseSSATag(CSubtitle* sub, CStringW str, STSStyle& }
}
#endif
- else if(cmd == L"kt") {
+ else if (cmd == L"kt") {
m_kstart = !p.IsEmpty()
? wcstol(p, NULL, 10)*10
: 0;
m_kend = m_kstart;
- } else if(cmd == L"kf" || cmd == L"K") {
+ } else if (cmd == L"kf" || cmd == L"K") {
m_ktype = 1;
m_kstart = m_kend;
m_kend += !p.IsEmpty()
@@ -2586,7 +2588,7 @@ bool CRenderedTextSubtitle::ParseSSATag(CSubtitle* sub, CStringW str, STSStyle& #ifdef _VSMOD // patch f005. don't cache animated
sub->m_fAnimated = true;
#endif
- } else if(cmd == L"ko") {
+ } else if (cmd == L"ko") {
m_ktype = 2;
m_kstart = m_kend;
m_kend += !p.IsEmpty()
@@ -2595,7 +2597,7 @@ bool CRenderedTextSubtitle::ParseSSATag(CSubtitle* sub, CStringW str, STSStyle& #ifdef _VSMOD // patch f005. don't cache animated
sub->m_fAnimated = true;
#endif
- } else if(cmd == L"k") {
+ } else if (cmd == L"k") {
m_ktype = 0;
m_kstart = m_kend;
m_kend += !p.IsEmpty()
@@ -2603,9 +2605,9 @@ bool CRenderedTextSubtitle::ParseSSATag(CSubtitle* sub, CStringW str, STSStyle& : 1000;
}
#ifdef _VSMOD // patch m005. add some move types
- else if(cmd == L"mover") { // {\mover(x1,x2,x2,y2,alp1,alp2,r1,r2,t1,t2)}
- if((params.GetCount() == 8 || params.GetCount() == 10) && !sub->m_effects[EF_MOVE]) {
- if(Effect* e = new Effect) {
+ else if (cmd == L"mover") { // {\mover(x1,x2,x2,y2,alp1,alp2,r1,r2,t1,t2)}
+ if ((params.GetCount() == 8 || params.GetCount() == 10) && !sub->m_effects[EF_MOVE]) {
+ if (Effect* e = new Effect) {
e->param[0] = 1;
e->param[1] = (int)(sub->m_scalex*wcstod(params[0], NULL)*8); // x1
e->param[2] = (int)(sub->m_scaley*wcstod(params[1], NULL)*8); // y1
@@ -2618,8 +2620,8 @@ bool CRenderedTextSubtitle::ParseSSATag(CSubtitle* sub, CStringW str, STSStyle& e->t[0] = e->t[1] = -1;
- if(params.GetCount() == 10) {
- for(int i = 0; i < 2; i++) {
+ if (params.GetCount() == 10) {
+ for (int i = 0; i < 2; i++) {
e->t[i] = wcstol(params[8+i], NULL, 10);
}
}
@@ -2628,9 +2630,9 @@ bool CRenderedTextSubtitle::ParseSSATag(CSubtitle* sub, CStringW str, STSStyle& // patch f005. don't cache animated
// sub->m_fAnimated = true;
}
- } else if(cmd == L"moves3") { // {\moves3(x1,x2,x2,y2,x3,y3[,t1,t2])}
- if((params.GetCount() == 6 || params.GetCount() == 8) && !sub->m_effects[EF_MOVE]) {
- if(Effect* e = new Effect) {
+ } else if (cmd == L"moves3") { // {\moves3(x1,x2,x2,y2,x3,y3[,t1,t2])}
+ if ((params.GetCount() == 6 || params.GetCount() == 8) && !sub->m_effects[EF_MOVE]) {
+ if (Effect* e = new Effect) {
e->param[0] = 2; // square spline
e->param[1] = (int)(sub->m_scalex*wcstod(params[0], NULL)*8); // x1
e->param[2] = (int)(sub->m_scaley*wcstod(params[1], NULL)*8); // y1
@@ -2640,8 +2642,8 @@ bool CRenderedTextSubtitle::ParseSSATag(CSubtitle* sub, CStringW str, STSStyle& e->param[6] = (int)(sub->m_scaley*wcstod(params[5], NULL)*8); // y3
e->t[0] = e->t[1] = -1;
- if(params.GetCount() == 8) {
- for(int i = 0; i < 2; i++) {
+ if (params.GetCount() == 8) {
+ for (int i = 0; i < 2; i++) {
e->t[i] = wcstol(params[6+i], NULL, 10);
}
}
@@ -2650,9 +2652,9 @@ bool CRenderedTextSubtitle::ParseSSATag(CSubtitle* sub, CStringW str, STSStyle& // patch f005. don't cache animated
// sub->m_fAnimated = true;
}
- } else if(cmd == L"moves4") { // {\moves4(x1,x2,x2,y2,x3,y3,x4,y4[,t1,t2])}
- if((params.GetCount() == 8 || params.GetCount() == 10) && !sub->m_effects[EF_MOVE]) {
- if(Effect* e = new Effect) {
+ } else if (cmd == L"moves4") { // {\moves4(x1,x2,x2,y2,x3,y3,x4,y4[,t1,t2])}
+ if ((params.GetCount() == 8 || params.GetCount() == 10) && !sub->m_effects[EF_MOVE]) {
+ if (Effect* e = new Effect) {
e->param[0] = 3; // cubic spline
e->param[1] = (int)(sub->m_scalex*wcstod(params[0], NULL)*8); // x1
e->param[2] = (int)(sub->m_scaley*wcstod(params[1], NULL)*8); // y1
@@ -2664,8 +2666,8 @@ bool CRenderedTextSubtitle::ParseSSATag(CSubtitle* sub, CStringW str, STSStyle& e->param[8] = (int)(sub->m_scaley*wcstod(params[7], NULL)*8); // y4
e->t[0] = e->t[1] = -1;
- if(params.GetCount() == 10) {
- for(int i = 0; i < 2; i++) {
+ if (params.GetCount() == 10) {
+ for (int i = 0; i < 2; i++) {
e->t[i] = wcstol(params[8+i], NULL, 10);
}
}
@@ -2677,18 +2679,18 @@ bool CRenderedTextSubtitle::ParseSSATag(CSubtitle* sub, CStringW str, STSStyle& }
#endif
#ifdef _VSMOD // patch m006. moveable vector clip
- else if(cmd == L"movevc") {
- if((params.GetCount() == 2 || params.GetCount() == 4 || params.GetCount() == 6) && !sub->m_effects[EF_VECTCLP]) {
- if(Effect* e = new Effect) {
+ else if (cmd == L"movevc") {
+ if ((params.GetCount() == 2 || params.GetCount() == 4 || params.GetCount() == 6) && !sub->m_effects[EF_VECTCLP]) {
+ if (Effect* e = new Effect) {
e->param[0] = e->param[2] = (int)(sub->m_scalex*wcstod(params[0], NULL));
e->param[1] = e->param[3] = (int)(sub->m_scaley*wcstod(params[1], NULL));
e->t[0] = e->t[1] = -1;
- if(params.GetCount() >= 4) {
+ if (params.GetCount() >= 4) {
e->param[2] = (int)(sub->m_scalex*wcstod(params[2], NULL));
e->param[3] = (int)(sub->m_scaley*wcstod(params[3], NULL));
}
- if(params.GetCount() == 6) {
+ if (params.GetCount() == 6) {
e->t[0] = (int)(sub->m_scalex*wcstod(params[4], NULL));
e->t[1] = (int)(sub->m_scaley*wcstod(params[5], NULL));
}
@@ -2699,9 +2701,9 @@ bool CRenderedTextSubtitle::ParseSSATag(CSubtitle* sub, CStringW str, STSStyle& }
}
#endif
- else if(cmd == L"move") { // {\move(x1=param[0], y1=param[1], x2=param[2], y2=param[3][, t1=t[0], t2=t[1]])}
- if((params.GetCount() == 4 || params.GetCount() == 6) && !sub->m_effects[EF_MOVE]) {
- if(Effect* e = DNew Effect) {
+ else if (cmd == L"move") { // {\move(x1=param[0], y1=param[1], x2=param[2], y2=param[3][, t1=t[0], t2=t[1]])}
+ if ((params.GetCount() == 4 || params.GetCount() == 6) && !sub->m_effects[EF_MOVE]) {
+ if (Effect* e = DNew Effect) {
#ifdef _VSMOD // patch m005. add some move types
e->param[0] = 0;
e->param[1] = (int)(sub->m_scalex*wcstod(params[0], NULL)*8);
@@ -2716,8 +2718,8 @@ bool CRenderedTextSubtitle::ParseSSATag(CSubtitle* sub, CStringW str, STSStyle& #endif
e->t[0] = e->t[1] = -1;
- if(params.GetCount() == 6) {
- for(ptrdiff_t i = 0; i < 2; i++) {
+ if (params.GetCount() == 6) {
+ for (ptrdiff_t i = 0; i < 2; i++) {
e->t[i] = wcstol(params[4+i], NULL, 10);
}
}
@@ -2728,57 +2730,63 @@ bool CRenderedTextSubtitle::ParseSSATag(CSubtitle* sub, CStringW str, STSStyle& // sub->m_fAnimated = true;
#endif
}
- } else if(cmd == L"org") { // {\org(x=param[0], y=param[1])}
+ } else if (cmd == L"org") { // {\org(x=param[0], y=param[1])}
size_t uNumParams = params.GetCount();
#ifdef _VSMOD // patch f003. moving \org for some karaoke effects. part 1
- if((uNumParams == 2 || uNumParams == 4 || uNumParams == 6) && !sub->m_effects[EF_ORG]) {
- if(Effect* e = DNew Effect) {
+ if ((uNumParams == 2 || uNumParams == 4 || uNumParams == 6) && !sub->m_effects[EF_ORG]) {
+ if (Effect* e = DNew Effect) {
e->param[0] = (int)(sub->m_scalex*wcstod(params[0], NULL)*8.0);
e->param[1] = (int)(sub->m_scaley*wcstod(params[1], NULL)*8.0);
- if(uNumParams >= 4) {
+ if (uNumParams >= 4) {
e->param[2] = (int)(sub->m_scalex*wcstod(params[2], NULL)*8.0);
- e->param[3] = (int)(sub->m_scaley*wcstod(params[3], NULL)*8.0);}
+ e->param[3] = (int)(sub->m_scaley*wcstod(params[3], NULL)*8.0);
+ }
else {
e->param[2] = e->param[0];
- e->param[3] = e->param[1];}
+ e->param[3] = e->param[1];
+ }
- if(uNumParams == 6) {
+ if (uNumParams == 6) {
e->t[0] = (int)(sub->m_scalex*wcstod(params[4], NULL)*8.0);
- e->t[1] = (int)(sub->m_scaley*wcstod(params[5], NULL)*8.0);}
+ e->t[1] = (int)(sub->m_scaley*wcstod(params[5], NULL)*8.0);
+ }
else e->t[0] = e->t[1] = -1;
- if(sub->m_relativeTo == 1) {
+ if (sub->m_relativeTo == 1) {
e->param[0] += m_vidrect.left;
e->param[1] += m_vidrect.top;
e->param[2] += m_vidrect.left;
e->param[3] += m_vidrect.top;
- if(uNumParams == 6) {
+ if (uNumParams == 6) {
e->t[0] += m_vidrect.left;
- e->t[1] += m_vidrect.top;}}
+ e->t[1] += m_vidrect.top;
+ }
+ }
sub->m_effects[EF_ORG] = e;
}
}
#else
- if(uNumParams == 2 && !sub->m_effects[EF_ORG]) {
- if(Effect* e = DNew Effect) {
+ if (uNumParams == 2 && !sub->m_effects[EF_ORG]) {
+ if (Effect* e = DNew Effect) {
e->param[0] = (int)(sub->m_scalex*wcstod(params[0], NULL)*8.0);
e->param[1] = (int)(sub->m_scaley*wcstod(params[1], NULL)*8.0);
- if(sub->m_relativeTo == 1) {
+ if (sub->m_relativeTo == 1) {
e->param[0] += m_vidrect.left;
- e->param[1] += m_vidrect.top;}
+ e->param[1] += m_vidrect.top;
+ }
sub->m_effects[EF_ORG] = e;
}
}
#endif
- } else if(cmd == L"pbo") {
+ } else if (cmd == L"pbo") {
m_polygonBaselineOffset = wcstol(p, NULL, 10);
- } else if(cmd == L"pos") {
- if(params.GetCount() == 2 && !sub->m_effects[EF_MOVE]) {
- if(Effect* e = DNew Effect) {
+ } else if (cmd == L"pos") {
+ if (params.GetCount() == 2 && !sub->m_effects[EF_MOVE]) {
+ if (Effect* e = DNew Effect) {
#ifdef _VSMOD // patch m005. add some move types
e->param[0] = 0; // usual move
e->param[1] = e->param[3] = (int)(sub->m_scalex*wcstod(params[0], NULL)*8);
@@ -2793,8 +2801,8 @@ bool CRenderedTextSubtitle::ParseSSATag(CSubtitle* sub, CStringW str, STSStyle& }
}
#ifdef _VSMOD // patch m002. Z-coord
- else if(params.GetCount() == 3 && !sub->m_effects[EF_MOVE]) {
- if(Effect* e = DNew Effect) {
+ else if (params.GetCount() == 3 && !sub->m_effects[EF_MOVE]) {
+ if (Effect* e = DNew Effect) {
e->param[0] = e->param[2] = (int)(sub->m_scalex*wcstod(params[0], NULL)*8);
e->param[1] = e->param[3] = (int)(sub->m_scaley*wcstod(params[1], NULL)*8);
e->t[0] = e->t[1] = 0;
@@ -2804,43 +2812,43 @@ bool CRenderedTextSubtitle::ParseSSATag(CSubtitle* sub, CStringW str, STSStyle& }
}
#endif
- } else if(cmd == L"p") {
+ } else if (cmd == L"p") {
int n = wcstol(p, NULL, 10);
m_nPolygon = (n <= 0 ? 0 : n);
- } else if(cmd == L"q") {
+ } else if (cmd == L"q") {
int n = wcstol(p, NULL, 10);
sub->m_wrapStyle = !p.IsEmpty() && (0 <= n && n <= 3)
? n
: m_defaultWrapStyle;
}
#ifdef _VSMOD // patch m003. random text points
- else if(cmd == L"rnds") {
+ else if (cmd == L"rnds") {
double dst = wcstol(p, NULL, 16);
double nx = CalcAnimation(dst, style.mod_rand.Seed, fAnimate);
style.mod_rand.Seed = !p.IsEmpty() ? nx : org.mod_rand.Seed;
- } else if(cmd == L"rndx") {
+ } else if (cmd == L"rndx") {
double dst = wcstod(p, NULL)*8;
double nx = CalcAnimation(dst, style.mod_rand.X, fAnimate);
style.mod_rand.X = !p.IsEmpty() ? nx : org.mod_rand.X;
- } else if(cmd == L"rndy") {
+ } else if (cmd == L"rndy") {
double dst = wcstod(p, NULL)*8;
double nx = CalcAnimation(dst, style.mod_rand.Y, fAnimate);
style.mod_rand.Y = !p.IsEmpty() ? nx : org.mod_rand.Y;
- } else if(cmd == L"rndz") {
+ } else if (cmd == L"rndz") {
double dst = wcstod(p, NULL)*8;
double nx = CalcAnimation(dst, style.mod_rand.Z, fAnimate);
style.mod_rand.Z = !p.IsEmpty() ? nx : org.mod_rand.Z;
- } else if(cmd == L"rnd") {
+ } else if (cmd == L"rnd") {
double dst = wcstod(p, NULL)*8;
style.mod_rand.X = !p.IsEmpty() ? CalcAnimation(dst, style.mod_rand.X, fAnimate) : org.mod_rand.X;
style.mod_rand.Y = !p.IsEmpty() ? CalcAnimation(dst, style.mod_rand.Y, fAnimate) : org.mod_rand.Y;
style.mod_rand.Z = !p.IsEmpty() ? CalcAnimation(dst, style.mod_rand.Z, fAnimate) : org.mod_rand.Z;
}
#endif
- else if(cmd == L"r") {
+ else if (cmd == L"r") {
STSStyle* val;
style = (!p.IsEmpty() && m_styles.Lookup(CString(p), val) && val) ? *val : org;
- } else if(cmd == L"shad") {
+ } else if (cmd == L"shad") {
double dst = wcstod(p, NULL);
double nx = CalcAnimation(dst, style.shadowDepthX, fAnimate);
style.shadowDepthX = !p.IsEmpty()
@@ -2850,27 +2858,27 @@ bool CRenderedTextSubtitle::ParseSSATag(CSubtitle* sub, CStringW str, STSStyle& style.shadowDepthY = !p.IsEmpty()
? (ny < 0 ? 0 : ny)
: org.shadowDepthY;
- } else if(cmd == L"s") {
+ } else if (cmd == L"s") {
int n = wcstol(p, NULL, 10);
style.fStrikeOut = !p.IsEmpty()
? (n == 0 ? false : n == 1 ? true : org.fStrikeOut)
: org.fStrikeOut;
- } else if(cmd == L"t") { // \t([<t1>,<t2>,][<accel>,]<style modifiers>)
+ } else if (cmd == L"t") { // \t([<t1>,<t2>,][<accel>,]<style modifiers>)
p.Empty();
m_animStart = m_animEnd = 0;
m_animAccel = 1;
- if(params.GetCount() == 1) {
+ if (params.GetCount() == 1) {
p = params[0];
- } else if(params.GetCount() == 2) {
+ } else if (params.GetCount() == 2) {
m_animAccel = wcstod(params[0], NULL);
p = params[1];
- } else if(params.GetCount() == 3) {
+ } else if (params.GetCount() == 3) {
m_animStart = (int)wcstod(params[0], NULL);
m_animEnd = (int)wcstod(params[1], NULL);
p = params[2];
- } else if(params.GetCount() == 4) {
+ } else if (params.GetCount() == 4) {
m_animStart = wcstol(params[0], NULL, 10);
m_animEnd = wcstol(params[1], NULL, 10);
m_animAccel = wcstod(params[2], NULL);
@@ -2880,30 +2888,30 @@ bool CRenderedTextSubtitle::ParseSSATag(CSubtitle* sub, CStringW str, STSStyle& ParseSSATag(sub, p, style, org, true);
sub->m_fAnimated = true;
- } else if(cmd == L"u") {
+ } else if (cmd == L"u") {
int n = wcstol(p, NULL, 10);
style.fUnderline = !p.IsEmpty()
? (n == 0 ? false : n == 1 ? true : org.fUnderline)
: org.fUnderline;
- } else if(cmd == L"xbord") {
+ } else if (cmd == L"xbord") {
double dst = wcstod(p, NULL);
double nx = CalcAnimation(dst, style.outlineWidthX, fAnimate);
style.outlineWidthX = !p.IsEmpty()
? (nx < 0 ? 0 : nx)
: org.outlineWidthX;
- } else if(cmd == L"xshad") {
+ } else if (cmd == L"xshad") {
double dst = wcstod(p, NULL);
double nx = CalcAnimation(dst, style.shadowDepthX, fAnimate);
style.shadowDepthX = !p.IsEmpty()
? nx
: org.shadowDepthX;
- } else if(cmd == L"ybord") {
+ } else if (cmd == L"ybord") {
double dst = wcstod(p, NULL);
double ny = CalcAnimation(dst, style.outlineWidthY, fAnimate);
style.outlineWidthY = !p.IsEmpty()
? (ny < 0 ? 0 : ny)
: org.outlineWidthY;
- } else if(cmd == L"yshad") {
+ } else if (cmd == L"yshad") {
double dst = wcstod(p, NULL);
double ny = CalcAnimation(dst, style.shadowDepthY, fAnimate);
style.shadowDepthY = !p.IsEmpty()
@@ -2911,7 +2919,7 @@ bool CRenderedTextSubtitle::ParseSSATag(CSubtitle* sub, CStringW str, STSStyle& : org.shadowDepthY;
}
#ifdef _VSMOD // patch m002. Z-coord
- else if(cmd == L"z") {
+ else if (cmd == L"z") {
double dst = wcstod(p, NULL)*80;
double nx = CalcAnimation(dst, style.mod_z, fAnimate);
style.mod_z = !p.IsEmpty() ? nx : org.mod_z;
@@ -2925,7 +2933,7 @@ bool CRenderedTextSubtitle::ParseSSATag(CSubtitle* sub, CStringW str, STSStyle& bool CRenderedTextSubtitle::ParseHtmlTag(CSubtitle* sub, CStringW str, STSStyle& style, STSStyle& org)
{
- if(str.Find(L"!--") == 0) {
+ if (str.Find(L"!--") == 0) {
return true;
}
@@ -2933,7 +2941,7 @@ bool CRenderedTextSubtitle::ParseHtmlTag(CSubtitle* sub, CStringW str, STSStyle& str.Trim(L" /");
int i = str.Find(' ');
- if(i < 0) {
+ if (i < 0) {
i = str.GetLength();
}
@@ -2941,73 +2949,73 @@ bool CRenderedTextSubtitle::ParseHtmlTag(CSubtitle* sub, CStringW str, STSStyle& str = str.Mid(i).Trim();
CAtlArray<CStringW> attribs, params;
- while((i = str.Find('=')) > 0) {
+ while ((i = str.Find('=')) > 0) {
attribs.Add(str.Left(i).Trim().MakeLower());
str = str.Mid(i+1);
- for(i = 0; _istspace(str[i]); i++) {
+ for (i = 0; _istspace(str[i]); i++) {
;
}
str = str.Mid(i);
- if(str[0] == '\"') {
+ if (str[0] == '\"') {
str = str.Mid(1);
i = str.Find('\"');
} else {
i = str.Find(' ');
}
- if(i < 0) {
+ if (i < 0) {
i = str.GetLength();
}
params.Add(str.Left(i).Trim().MakeLower());
str = str.Mid(i+1);
}
- if(tag == L"text") {
+ if (tag == L"text") {
;
- } else if(tag == L"b" || tag == L"strong") {
+ } else if (tag == L"b" || tag == L"strong") {
style.fontWeight = !fClosing ? FW_BOLD : org.fontWeight;
- } else if(tag == L"i" || tag == L"em") {
+ } else if (tag == L"i" || tag == L"em") {
style.fItalic = !fClosing ? true : org.fItalic;
- } else if(tag == L"u") {
+ } else if (tag == L"u") {
style.fUnderline = !fClosing ? true : org.fUnderline;
- } else if(tag == L"s" || tag == L"strike" || tag == L"del") {
+ } else if (tag == L"s" || tag == L"strike" || tag == L"del") {
style.fStrikeOut = !fClosing ? true : org.fStrikeOut;
- } else if(tag == L"font") {
- if(!fClosing) {
- for(size_t i = 0; i < attribs.GetCount(); i++) {
- if(params[i].IsEmpty()) {
+ } else if (tag == L"font") {
+ if (!fClosing) {
+ for (size_t i = 0; i < attribs.GetCount(); i++) {
+ if (params[i].IsEmpty()) {
continue;
}
int nColor = -1;
- if(attribs[i] == L"face") {
+ if (attribs[i] == L"face") {
style.fontName = params[i];
- } else if(attribs[i] == L"size") {
- if(params[i][0] == '+') {
+ } else if (attribs[i] == L"size") {
+ if (params[i][0] == '+') {
style.fontSize += wcstol(params[i], NULL, 10);
- } else if(params[i][0] == '-') {
+ } else if (params[i][0] == '-') {
style.fontSize -= wcstol(params[i], NULL, 10);
} else {
style.fontSize = wcstol(params[i], NULL, 10);
}
- } else if(attribs[i] == L"color") {
+ } else if (attribs[i] == L"color") {
nColor = 0;
- } else if(attribs[i] == L"outline-color") {
+ } else if (attribs[i] == L"outline-color") {
nColor = 2;
- } else if(attribs[i] == L"outline-level") {
+ } else if (attribs[i] == L"outline-level") {
style.outlineWidthX = style.outlineWidthY = wcstol(params[i], NULL, 10);
- } else if(attribs[i] == L"shadow-color") {
+ } else if (attribs[i] == L"shadow-color") {
nColor = 3;
- } else if(attribs[i] == L"shadow-level") {
+ } else if (attribs[i] == L"shadow-level") {
style.shadowDepthX = style.shadowDepthY = wcstol(params[i], NULL, 10);
}
- if(nColor >= 0 && nColor < 4) {
+ if (nColor >= 0 && nColor < 4) {
CString key = WToT(params[i]).TrimLeft('#');
DWORD val;
- if(g_colors.Lookup(key, val)) {
+ if (g_colors.Lookup(key, val)) {
style.colors[nColor] = val;
- } else if((style.colors[nColor] = _tcstol(key, NULL, 16)) == 0) {
+ } else if ((style.colors[nColor] = _tcstol(key, NULL, 16)) == 0) {
style.colors[nColor] = 0x00ffffff; // default is white
}
style.colors[nColor] = ((style.colors[nColor]>>16)&0xff)|((style.colors[nColor]&0xff)<<16)|(style.colors[nColor]&0x00ff00);
@@ -3018,7 +3026,7 @@ bool CRenderedTextSubtitle::ParseHtmlTag(CSubtitle* sub, CStringW str, STSStyle& style.fontSize = org.fontSize;
memcpy(style.colors, org.colors, sizeof(style.colors));
}
- } else if(tag == L"k" && attribs.GetCount() == 1 && attribs[0] == L"t") {
+ } else if (tag == L"k" && attribs.GetCount() == 1 && attribs[0] == L"t") {
m_ktype = 1;
m_kstart = m_kend;
m_kend += wcstol(params[0], NULL, 10);
@@ -3034,10 +3042,10 @@ double CRenderedTextSubtitle::CalcAnimation(double dst, double src, bool fAnimat int s = m_animStart ? m_animStart : 0;
int e = m_animEnd ? m_animEnd : m_delay;
- if(fabs(dst-src) >= 0.0001 && fAnimate) {
- if(m_time < s) {
+ if (fabs(dst-src) >= 0.0001 && fAnimate) {
+ if (m_time < s) {
dst = src;
- } else if(s <= m_time && m_time < e) {
+ } else if (s <= m_time && m_time < e) {
double t = pow(1.0 * (m_time - s) / (e - s), m_animAccel);
dst = (1 - t) * src + t * dst;
}
@@ -3050,8 +3058,8 @@ double CRenderedTextSubtitle::CalcAnimation(double dst, double src, bool fAnimat CSubtitle* CRenderedTextSubtitle::GetSubtitle(int entry)
{
CSubtitle* sub;
- if(m_subtitleCache.Lookup(entry, sub)) {
- if(sub->m_fAnimated) {
+ if (m_subtitleCache.Lookup(entry, sub)) {
+ if (sub->m_fAnimated) {
delete sub;
sub = NULL;
} else {
@@ -3060,14 +3068,14 @@ CSubtitle* CRenderedTextSubtitle::GetSubtitle(int entry) }
sub = DNew CSubtitle();
- if(!sub) {
+ if (!sub) {
return(NULL);
}
CStringW str = GetStrW(entry, true);
STSStyle stss, orgstss;
- if(m_doOverrideStyle && m_pStyleOverride != NULL) {
+ if (m_doOverrideStyle && m_pStyleOverride != NULL) {
// this RTS has been signaled to ignore embedded styles, use the built-in one
stss = *m_pStyleOverride;
} else {
@@ -3107,7 +3115,7 @@ CSubtitle* CRenderedTextSubtitle::GetSubtitle(int entry) // in CSimpleTextSubtitle::Open, we have m_dstScreenSize = CSize(384, 288)
// now, files containing embedded subtitles (and with styles) set m_dstScreenSize to a correct value
// but where no style is given, those defaults are taken - 384, 288
- if(m_doOverrideStyle && m_pStyleOverride) {
+ if (m_doOverrideStyle && m_pStyleOverride) {
// so mind the default values, stated here to increase comprehension
sub->m_scalex = m_size.cx / (384 * 8);
sub->m_scaley = m_size.cy / (288 * 8);
@@ -3131,34 +3139,34 @@ CSubtitle* CRenderedTextSubtitle::GetSubtitle(int entry) #endif
ParseEffect(sub, GetAt(entry).effect);
- while(!str.IsEmpty()) {
+ while (!str.IsEmpty()) {
bool fParsed = false;
int i;
- if(str[0] == '{' && (i = str.Find(L'}')) > 0) {
+ if (str[0] == '{' && (i = str.Find(L'}')) > 0) {
fParsed = ParseSSATag(sub, str.Mid(1, i-1), stss, orgstss);
- if(fParsed) {
+ if (fParsed) {
str = str.Mid(i+1);
}
- } else if(str[0] == '<' && (i = str.Find(L'>')) > 0) {
+ } else if (str[0] == '<' && (i = str.Find(L'>')) > 0) {
fParsed = ParseHtmlTag(sub, str.Mid(1, i-1), stss, orgstss);
- if(fParsed) {
+ if (fParsed) {
str = str.Mid(i+1);
}
}
- if(fParsed) {
+ if (fParsed) {
i = str.FindOneOf(L"{<");
- if(i < 0) {
+ if (i < 0) {
i = str.GetLength();
}
- if(i == 0) {
+ if (i == 0) {
continue;
}
} else {
i = str.Mid(1).FindOneOf(L"{<");
- if(i < 0) {
+ if (i < 0) {
i = str.GetLength()-1;
}
i++;
@@ -3175,7 +3183,7 @@ CSubtitle* CRenderedTextSubtitle::GetSubtitle(int entry) tmp.shadowDepthX *= (m_fScaledBAS ? sub->m_scalex : 1) * 8;
tmp.shadowDepthY *= (m_fScaledBAS ? sub->m_scaley : 1) * 8;
- if(m_nPolygon) {
+ if (m_nPolygon) {
ParsePolygon(sub, str.Left(i), tmp);
} else {
ParseString(sub, str.Left(i), tmp);
@@ -3184,12 +3192,12 @@ CSubtitle* CRenderedTextSubtitle::GetSubtitle(int entry) str = str.Mid(i);
}
- if(m_doOverrideStyle && m_pStyleOverride != NULL) {
+ if (m_doOverrideStyle && m_pStyleOverride != NULL) {
sub->EmptyEffects();
}
// just a "work-around" solution... in most cases nobody will want to use \org together with moving but without rotating the subs
- if(sub->m_effects[EF_ORG] && (sub->m_effects[EF_MOVE] || sub->m_effects[EF_BANNER] || sub->m_effects[EF_SCROLL])) {
+ if (sub->m_effects[EF_ORG] && (sub->m_effects[EF_MOVE] || sub->m_effects[EF_BANNER] || sub->m_effects[EF_SCROLL])) {
sub->m_fAnimated = true;
}
@@ -3197,16 +3205,16 @@ CSubtitle* CRenderedTextSubtitle::GetSubtitle(int entry) STSEntry stse = GetAt(entry);
CRect marginRect = stse.marginRect;
- if(marginRect.left == 0) {
+ if (marginRect.left == 0) {
marginRect.left = orgstss.marginRect.left;
}
- if(marginRect.top == 0) {
+ if (marginRect.top == 0) {
marginRect.top = orgstss.marginRect.top;
}
- if(marginRect.right == 0) {
+ if (marginRect.right == 0) {
marginRect.right = orgstss.marginRect.right;
}
- if(marginRect.bottom == 0) {
+ if (marginRect.bottom == 0) {
marginRect.bottom = orgstss.marginRect.bottom;
}
marginRect.left = (int)(sub->m_scalex*marginRect.left*8);
@@ -3214,10 +3222,10 @@ CSubtitle* CRenderedTextSubtitle::GetSubtitle(int entry) marginRect.right = (int)(sub->m_scalex*marginRect.right*8);
marginRect.bottom = (int)(sub->m_scaley*marginRect.bottom*8);
- if(stss.relativeTo == 1) {
- marginRect.left += m_vidrect.left;
- marginRect.top += m_vidrect.top;
- marginRect.right += m_size.cx - m_vidrect.right;
+ if (stss.relativeTo == 1) {
+ marginRect.left += m_vidrect.left;
+ marginRect.top += m_vidrect.top;
+ marginRect.right += m_size.cx - m_vidrect.right;
marginRect.bottom += m_size.cy - m_vidrect.bottom;
}
@@ -3251,7 +3259,7 @@ STDMETHODIMP_(POSITION) CRenderedTextSubtitle::GetStartPosition(REFERENCE_TIME r int iSegment = -1;
SearchSubs((int)(rt/10000), fps, &iSegment, NULL);
- if(iSegment < 0) {
+ if (iSegment < 0) {
iSegment = 0;
}
@@ -3263,7 +3271,7 @@ STDMETHODIMP_(POSITION) CRenderedTextSubtitle::GetNext(POSITION pos) int iSegment = (int)pos;
const STSSegment* stss = GetSegment(iSegment);
- while(stss && stss->subs.GetCount() == 0) {
+ while (stss && stss->subs.GetCount() == 0) {
iSegment++;
stss = GetSegment(iSegment);
}
@@ -3293,7 +3301,7 @@ struct LSub { static int lscomp(const void* ls1, const void* ls2)
{
int ret = ((LSub*)ls1)->layer - ((LSub*)ls2)->layer;
- if(!ret) {
+ if (!ret) {
ret = ((LSub*)ls1)->readorder - ((LSub*)ls2)->readorder;
}
return(ret);
@@ -3303,7 +3311,7 @@ STDMETHODIMP CRenderedTextSubtitle::Render(SubPicDesc& spd, REFERENCE_TIME rt, d {
CRect bbox2(0,0,0,0);
- if(m_size != CSize(spd.w*8, spd.h*8) || m_vidrect != CRect(spd.vidrect.left*8, spd.vidrect.top*8, spd.vidrect.right*8, spd.vidrect.bottom*8)) {
+ if (m_size != CSize(spd.w*8, spd.h*8) || m_vidrect != CRect(spd.vidrect.left*8, spd.vidrect.top*8, spd.vidrect.right*8, spd.vidrect.bottom*8)) {
Init(CSize(spd.w, spd.h), spd.vidrect);
}
@@ -3311,20 +3319,20 @@ STDMETHODIMP CRenderedTextSubtitle::Render(SubPicDesc& spd, REFERENCE_TIME rt, d int segment;
const STSSegment* stss = SearchSubs(t, fps, &segment);
- if(!stss) {
+ if (!stss) {
return S_FALSE;
}
// clear any cached subs not in the range of +/-30secs measured from the segment's bounds
{
POSITION pos = m_subtitleCache.GetStartPosition();
- while(pos) {
+ while (pos) {
int key;
CSubtitle* value;
m_subtitleCache.GetNextAssoc(pos, key, value);
STSEntry& stse = GetAt(key);
- if(stse.end <= (t-30000) || stse.start > (t+30000)) {
+ if (stse.end <= (t-30000) || stse.start > (t+30000)) {
delete value;
m_subtitleCache.RemoveKey(key);
pos = m_subtitleCache.GetStartPosition();
@@ -3336,7 +3344,7 @@ STDMETHODIMP CRenderedTextSubtitle::Render(SubPicDesc& spd, REFERENCE_TIME rt, d CAtlArray<LSub> subs;
- for(ptrdiff_t i = 0, j = stss->subs.GetCount(); i < j; i++) {
+ for (ptrdiff_t i = 0, j = stss->subs.GetCount(); i < j; i++) {
LSub ls;
ls.idx = stss->subs[i];
ls.layer = GetAt(stss->subs[i]).layer;
@@ -3346,7 +3354,7 @@ STDMETHODIMP CRenderedTextSubtitle::Render(SubPicDesc& spd, REFERENCE_TIME rt, d qsort(subs.GetData(), subs.GetCount(), sizeof(LSub), lscomp);
- for(ptrdiff_t i = 0, j = subs.GetCount(); i < j; i++) {
+ for (ptrdiff_t i = 0, j = subs.GetCount(); i < j; i++) {
int entry = subs[i].idx;
STSEntry stse = GetAt(entry);
@@ -3358,7 +3366,7 @@ STDMETHODIMP CRenderedTextSubtitle::Render(SubPicDesc& spd, REFERENCE_TIME rt, d }
CSubtitle* s = GetSubtitle(entry);
- if(!s) {
+ if (!s) {
continue;
}
@@ -3383,12 +3391,12 @@ STDMETHODIMP CRenderedTextSubtitle::Render(SubPicDesc& spd, REFERENCE_TIME rt, d mod_vc.size = s->m_pClipper?s->m_pClipper->m_size : CSize(0,0);
#endif
- for(int k = 0; k < EF_NUMBEROFEFFECTS; k++) {
- if(!s->m_effects[k]) {
+ for (int k = 0; k < EF_NUMBEROFEFFECTS; k++) {
+ if (!s->m_effects[k]) {
continue;
}
- switch(k) {
+ switch (k) {
case EF_MOVE: { // {\move(x1=param[0], y1=param[1], x2=param[2], y2=param[3], t1=t[0], t2=t[1])}
CPoint p;
#ifdef _VSMOD // patch m005. add some move types
@@ -3402,22 +3410,22 @@ STDMETHODIMP CRenderedTextSubtitle::Render(SubPicDesc& spd, REFERENCE_TIME rt, d int t1 = s->m_effects[k]->t[0];
int t2 = s->m_effects[k]->t[1];
- if(t2 < t1) {
+ if (t2 < t1) {
int t = t1;
t1 = t2;
t2 = t;
}
- if(t1 <= 0 && t2 <= 0) {
+ if (t1 <= 0 && t2 <= 0) {
t1 = 0;
t2 = m_delay;
}
- if(m_time <= t1) {
+ if (m_time <= t1) {
p = p1;
} else if (p1 == p2) {
p = p1;
- } else if(t1 < m_time && m_time < t2) {
+ } else if (t1 < m_time && m_time < t2) {
double t = 1.0*(m_time-t1)/(t2-t1);
p.x = (int)((1-t)*p1.x + t*p2.x);
p.y = (int)((1-t)*p1.y + t*p2.y);
@@ -3437,22 +3445,22 @@ STDMETHODIMP CRenderedTextSubtitle::Render(SubPicDesc& spd, REFERENCE_TIME rt, d CPoint pr1 = (p1.x + cos(alp1)*r0.x, p1.y + sin(alp1)*r0.x);
CPoint pr2 = (p2.x + cos(alp2)*r0.y, p2.y + sin(alp2)*r0.y);
- if(t2 < t1) {
+ if (t2 < t1) {
int t = t1;
t1 = t2;
t2 = t;
}
- if(t1 <= 0 && t2 <= 0) {
+ if (t1 <= 0 && t2 <= 0) {
t1 = 0;
t2 = m_delay;
}
- if(m_time <= t1) {
+ if (m_time <= t1) {
p = pr1;
}
//else if (p1 == p2) p = pr1; // jfs: avoid rounding error problems sometimes causing subtitles with \pos to jump around a bit
- else if((t1 < m_time) && (m_time < t2)) {
+ else if ((t1 < m_time) && (m_time < t2)) {
double t = (double)(m_time-t1)/(t2-t1);
double alp = ((1-t)*alp1 + t*alp2);
double rt = ((1-t)*r0.x + t*r0.y);
@@ -3472,22 +3480,22 @@ STDMETHODIMP CRenderedTextSubtitle::Render(SubPicDesc& spd, REFERENCE_TIME rt, d int t1 = s->m_effects[k]->t[0];
int t2 = s->m_effects[k]->t[1];
- if(t2 < t1) {
+ if (t2 < t1) {
int t = t1;
t1 = t2;
t2 = t;
}
- if(t1 <= 0 && t2 <= 0) {
+ if (t1 <= 0 && t2 <= 0) {
t1 = 0;
t2 = m_delay;
}
- if(m_time <= t1) {
+ if (m_time <= t1) {
p = p1;
} else if (p1 == p2) {
p = p1; // jfs: avoid rounding error problems sometimes causing subtitles with \pos to jump around a bit
- } else if(t1 < m_time && m_time < t2) {
+ } else if (t1 < m_time && m_time < t2) {
double t = (double)(m_time-t1)/(t2-t1);
p.x = (int)((1-t)*(1-t)*p1.x + 2*t*(1-t)*p2.x + t*t*p3.x);
p.y = (int)((1-t)*(1-t)*p1.y + 2*t*(1-t)*p2.y + t*t*p3.y);
@@ -3503,22 +3511,22 @@ STDMETHODIMP CRenderedTextSubtitle::Render(SubPicDesc& spd, REFERENCE_TIME rt, d int t1 = s->m_effects[k]->t[0];
int t2 = s->m_effects[k]->t[1];
- if(t2 < t1) {
+ if (t2 < t1) {
int t = t1;
t1 = t2;
t2 = t;
}
- if(t1 <= 0 && t2 <= 0) {
+ if (t1 <= 0 && t2 <= 0) {
t1 = 0;
t2 = m_delay;
}
- if(m_time <= t1) {
+ if (m_time <= t1) {
p = p1;
} else if (p1 == p2) {
p = p1; // jfs: avoid rounding error problems sometimes causing subtitles with \pos to jump around a bit
- } else if(t1 < m_time && m_time < t2) {
+ } else if (t1 < m_time && m_time < t2) {
double t = (double)(m_time-t1)/(t2-t1);
p.x = (int)((1-t)*(1-t)*(1-t)*p1.x + 3*t*(1-t)*(1-t)*p2.x + 3*t*t*(1-t)*p3.x + t*t*t*p4.x);
p.y = (int)((1-t)*(1-t)*(1-t)*p1.y + 3*t*(1-t)*(1-t)*p2.y + 3*t*t*(1-t)*p3.y + t*t*t*p4.y);
@@ -3532,7 +3540,7 @@ STDMETHODIMP CRenderedTextSubtitle::Render(SubPicDesc& spd, REFERENCE_TIME rt, d s->m_scrAlignment <= 3 ? p.y - spaceNeeded.cy : s->m_scrAlignment <= 6 ? p.y - (spaceNeeded.cy+1)/2 : p.y),
spaceNeeded);
- if(s->m_relativeTo == 1) {
+ if (s->m_relativeTo == 1) {
r.OffsetRect(m_vidrect.TopLeft());
}
fPosOverride = true;
@@ -3545,22 +3553,22 @@ STDMETHODIMP CRenderedTextSubtitle::Render(SubPicDesc& spd, REFERENCE_TIME rt, d int to1 = s->m_effects[k]->t[0];
int to2 = s->m_effects[k]->t[1];
- if(to2 < to1) {
+ if (to2 < to1) {
int to = to1;
to1 = to2;
to2 = to;
}
- if(to1 <= 0 && to2 <= 0) {
+ if (to1 <= 0 && to2 <= 0) {
to1 = 0;
to2 = m_delay;
}
- if(m_time <= to1) {
+ if (m_time <= to1) {
org2 = orgA;
} else if (to1 == to2) {
org2 = orgA; // jfs: avoid rounding error problems sometimes causing subtitles with \pos to jump around a bit
- } else if(to1 < m_time && m_time < to2) {
+ } else if (to1 < m_time && m_time < to2) {
double t = 1.0*(m_time-to1)/(to2-to1);
org2.x = (int)((1-t)*orgA.x + t*orgB.x);
org2.y = (int)((1-t)*orgA.y + t*orgB.y);
@@ -3579,23 +3587,23 @@ STDMETHODIMP CRenderedTextSubtitle::Render(SubPicDesc& spd, REFERENCE_TIME rt, d int t3 = s->m_effects[k]->t[2];
int t4 = s->m_effects[k]->t[3];
- if(t1 == -1 && t4 == -1) {
+ if (t1 == -1 && t4 == -1) {
t1 = 0;
t3 = m_delay - t3;
t4 = m_delay;
}
- if(m_time < t1) {
+ if (m_time < t1) {
alpha = s->m_effects[k]->param[0];
- } else if(m_time >= t1 && m_time < t2) {
+ } else if (m_time >= t1 && m_time < t2) {
double t = 1.0 * (m_time - t1) / (t2 - t1);
alpha = (int)(s->m_effects[k]->param[0]*(1-t) + s->m_effects[k]->param[1]*t);
- } else if(m_time >= t2 && m_time < t3) {
+ } else if (m_time >= t2 && m_time < t3) {
alpha = s->m_effects[k]->param[1];
- } else if(m_time >= t3 && m_time < t4) {
+ } else if (m_time >= t3 && m_time < t4) {
double t = 1.0 * (m_time - t3) / (t4 - t3);
alpha = (int)(s->m_effects[k]->param[1]*(1-t) + s->m_effects[k]->param[2]*t);
- } else if(m_time >= t4) {
+ } else if (m_time >= t4) {
alpha = s->m_effects[k]->param[2];
}
}
@@ -3624,7 +3632,7 @@ STDMETHODIMP CRenderedTextSubtitle::Render(SubPicDesc& spd, REFERENCE_TIME rt, d CRect cr(0, (s->m_effects[k]->param[0] + 4) >> 3, spd.w, (s->m_effects[k]->param[1] + 4) >> 3);
- if(s->m_relativeTo == 1)
+ if (s->m_relativeTo == 1)
r.top += m_vidrect.top,
r.bottom += m_vidrect.top,
cr.top += m_vidrect.top>>3,
@@ -3641,22 +3649,22 @@ STDMETHODIMP CRenderedTextSubtitle::Render(SubPicDesc& spd, REFERENCE_TIME rt, d int to1 = s->m_effects[k]->t[0];
int to2 = s->m_effects[k]->t[1];
- if(to2 < to1) {
+ if (to2 < to1) {
int to = to1;
to1 = to2;
to2 = to;
}
- if(to1 <= 0 && to2 <= 0) {
+ if (to1 <= 0 && to2 <= 0) {
to1 = 0;
to2 = m_delay;
}
- if(m_time <= to1) {
+ if (m_time <= to1) {
mod_vc.pos = vcpos1;
} else if (to1 == to2) {
mod_vc.pos = vcpos1; // jfs: avoid rounding error problems sometimes causing subtitles with \pos to jump around a bit
- } else if(to1 < m_time && m_time < to2) {
+ } else if (to1 < m_time && m_time < to2) {
double t = 1.0*(m_time-to1)/(to2-to1);
mod_vc.pos.x = (int)((1-t)*vcpos1.x + t*vcpos2.x);
mod_vc.pos.y = (int)((1-t)*vcpos1.y + t*vcpos2.y);
@@ -3672,7 +3680,7 @@ STDMETHODIMP CRenderedTextSubtitle::Render(SubPicDesc& spd, REFERENCE_TIME rt, d }
}
- if(!fPosOverride && !fOrgOverride && !s->m_fAnimated) {
+ if (!fPosOverride && !fOrgOverride && !s->m_fAnimated) {
r = m_sla.AllocRect(s, segment, entry, stse.layer, m_collisions);
}
@@ -3680,7 +3688,7 @@ STDMETHODIMP CRenderedTextSubtitle::Render(SubPicDesc& spd, REFERENCE_TIME rt, d org.x = (s->m_scrAlignment%3) == 1 ? r.left : (s->m_scrAlignment%3) == 2 ? r.CenterPoint().x : r.right;
org.y = s->m_scrAlignment <= 3 ? r.bottom : s->m_scrAlignment <= 6 ? r.CenterPoint().y : r.top;
- if(!fOrgOverride) {
+ if (!fOrgOverride) {
org2 = org;
}
@@ -3698,7 +3706,7 @@ STDMETHODIMP CRenderedTextSubtitle::Render(SubPicDesc& spd, REFERENCE_TIME rt, d iclipRect[3] = CRect(0, clipRect.bottom, spd.w, spd.h);
pos = s->GetHeadPosition();
- while(pos) {
+ while (pos) {
CLine* l = s->GetNext(pos);
p.x = (s->m_scrAlignment%3) == 1 ? org.x
@@ -3730,7 +3738,7 @@ STDMETHODIMP CRenderedTextSubtitle::Render(SubPicDesc& spd, REFERENCE_TIME rt, d p = p2;
pos = s->GetHeadPosition();
- while(pos) {
+ while (pos) {
CLine* l = s->GetNext(pos);
p.x = (s->m_scrAlignment%3) == 1 ? org.x
@@ -3762,7 +3770,7 @@ STDMETHODIMP CRenderedTextSubtitle::Render(SubPicDesc& spd, REFERENCE_TIME rt, d p = p2;
pos = s->GetHeadPosition();
- while(pos) {
+ while (pos) {
CLine* l = s->GetNext(pos);
p.x = (s->m_scrAlignment%3) == 1 ? org.x
@@ -3814,19 +3822,19 @@ STDMETHODIMP_(int) CRenderedTextSubtitle::GetStreamCount() STDMETHODIMP CRenderedTextSubtitle::GetStreamInfo(int iStream, WCHAR** ppName, LCID* pLCID)
{
USES_CONVERSION;
- if(iStream != 0) {
+ if (iStream != 0) {
return E_INVALIDARG;
}
- if(ppName) {
+ if (ppName) {
*ppName = (WCHAR*)CoTaskMemAlloc((m_name.GetLength()+1)*sizeof(WCHAR));
- if(!(*ppName)) {
+ if (!(*ppName)) {
return E_OUTOFMEMORY;
}
wcscpy(*ppName, CStringW(m_name));
- if(pLCID) {
+ if (pLCID) {
*pLCID = ISO6391ToLcid (W2A(*ppName));
if (*pLCID == 0) {
*pLCID = ISO6392ToLcid (W2A(*ppName));
@@ -3850,7 +3858,7 @@ STDMETHODIMP CRenderedTextSubtitle::SetStream(int iStream) STDMETHODIMP CRenderedTextSubtitle::Reload()
{
CFileStatus s;
- if(!CFile::GetStatus(m_path, s)) {
+ if (!CFile::GetStatus(m_path, s)) {
return E_FAIL;
}
return !m_path.IsEmpty() && Open(m_path, DEFAULT_CHARSET) ? S_OK : E_FAIL;
diff --git a/src/Subtitles/RTS.h b/src/Subtitles/RTS.h index ca179712c..9a135dadf 100644 --- a/src/Subtitles/RTS.h +++ b/src/Subtitles/RTS.h @@ -266,7 +266,7 @@ public: // call to signal this RTS to ignore any of the styles and apply the given override style
void SetOverride(bool doOverride = true, STSStyle *styleOverride = NULL) {
m_doOverrideStyle = doOverride;
- if(styleOverride != NULL) {
+ if (styleOverride != NULL) {
m_pStyleOverride = styleOverride;
}
}
diff --git a/src/Subtitles/Rasterizer.cpp b/src/Subtitles/Rasterizer.cpp index b651eae2a..366187836 100644 --- a/src/Subtitles/Rasterizer.cpp +++ b/src/Subtitles/Rasterizer.cpp @@ -108,7 +108,7 @@ void Rasterizer::_EvaluateBezier(int ptbase, bool fBSpline) double cx3, cx2, cx1, cx0, cy3, cy2, cy1, cy0;
- if(fBSpline) {
+ if (fBSpline) {
// 1 [-1 +3 -3 +1]
// - * [+3 -6 +3 0]
// 6 [-3 0 +3 0]
@@ -164,18 +164,18 @@ void Rasterizer::_EvaluateBezier(int ptbase, bool fBSpline) double maxaccel = maxaccel1 > maxaccel2 ? maxaccel1 : maxaccel2;
double h = 1.0;
- if(maxaccel > 8.0) {
+ if (maxaccel > 8.0) {
h = sqrt(8.0 / maxaccel);
}
- if(!fFirstSet) {
+ if (!fFirstSet) {
firstp.x = (LONG)cx0;
firstp.y = (LONG)cy0;
lastp = firstp;
fFirstSet = true;
}
- for(double t = 0; t < 1.0; t += h) {
+ for (double t = 0; t < 1.0; t += h) {
double x = cx0 + t*(cx1 + t*(cx2 + t*cx3));
double y = cy0 + t*(cy1 + t*(cy2 + t*cy3));
_EvaluateLine(lastp.x, lastp.y, (int)x, (int)y);
@@ -196,11 +196,11 @@ void Rasterizer::_EvaluateLine(int pt1idx, int pt2idx) void Rasterizer::_EvaluateLine(int x0, int y0, int x1, int y1)
{
- if(lastp.x != x0 || lastp.y != y0) {
+ if (lastp.x != x0 || lastp.y != y0) {
_EvaluateLine(lastp.x, lastp.y, x0, y0);
}
- if(!fFirstSet) {
+ if (!fFirstSet) {
firstp.x = x0;
firstp.y = y0;
fFirstSet = true;
@@ -208,7 +208,7 @@ void Rasterizer::_EvaluateLine(int x0, int y0, int x1, int y1) lastp.x = x1;
lastp.y = y1;
- if(y1 > y0) { // down
+ if (y1 > y0) { // down
__int64 xacc = (__int64)x0 << 13;
// prestep y0 down
@@ -219,16 +219,16 @@ void Rasterizer::_EvaluateLine(int x0, int y0, int x1, int y1) y1 = (y1 - 5) >> 3;
- if(iy <= y1) {
+ if (iy <= y1) {
__int64 invslope = (__int64(x1 - x0) << 16) / dy;
- while(mEdgeNext + y1 + 1 - iy > mEdgeHeapSize) {
+ while (mEdgeNext + y1 + 1 - iy > mEdgeHeapSize) {
_ReallocEdgeBuffer(mEdgeHeapSize*2);
}
xacc += (invslope * (y - y0)) >> 3;
- while(iy <= y1) {
+ while (iy <= y1) {
int ix = (int)((xacc + 32768) >> 16);
mpEdgeBuffer[mEdgeNext].next = mpScanBuffer[iy];
@@ -240,7 +240,7 @@ void Rasterizer::_EvaluateLine(int x0, int y0, int x1, int y1) xacc += invslope;
}
}
- } else if(y1 < y0) { // up
+ } else if (y1 < y0) { // up
__int64 xacc = (__int64)x1 << 13;
// prestep y1 down
@@ -251,16 +251,16 @@ void Rasterizer::_EvaluateLine(int x0, int y0, int x1, int y1) y0 = (y0 - 5) >> 3;
- if(iy <= y0) {
+ if (iy <= y0) {
__int64 invslope = (__int64(x0 - x1) << 16) / dy;
- while(mEdgeNext + y0 + 1 - iy > mEdgeHeapSize) {
+ while (mEdgeNext + y0 + 1 - iy > mEdgeHeapSize) {
_ReallocEdgeBuffer(mEdgeHeapSize*2);
}
xacc += (invslope * (y - y1)) >> 3;
- while(iy <= y0) {
+ while (iy <= y0) {
int ix = (int)((xacc + 32768) >> 16);
mpEdgeBuffer[mEdgeNext].next = mpScanBuffer[iy];
@@ -286,17 +286,17 @@ bool Rasterizer::EndPath(HDC hdc) {
::CloseFigure(hdc);
- if(::EndPath(hdc)) {
+ if (::EndPath(hdc)) {
mPathPoints = GetPath(hdc, NULL, NULL, 0);
- if(!mPathPoints) {
+ if (!mPathPoints) {
return true;
}
mpPathTypes = (BYTE*)malloc(sizeof(BYTE) * mPathPoints);
mpPathPoints = (POINT*)malloc(sizeof(POINT) * mPathPoints);
- if(mPathPoints == (size_t)GetPath(hdc, mpPathPoints, mpPathTypes, mPathPoints)) {
+ if (mPathPoints == (size_t)GetPath(hdc, mpPathPoints, mpPathTypes, mPathPoints)) {
return true;
}
}
@@ -308,7 +308,7 @@ bool Rasterizer::EndPath(HDC hdc) bool Rasterizer::PartialBeginPath(HDC hdc, bool bClearPath)
{
- if(bClearPath) {
+ if (bClearPath) {
_TrashPath();
}
@@ -319,33 +319,33 @@ bool Rasterizer::PartialEndPath(HDC hdc, long dx, long dy) {
::CloseFigure(hdc);
- if(::EndPath(hdc)) {
+ if (::EndPath(hdc)) {
int nPoints;
BYTE* pNewTypes;
POINT* pNewPoints;
nPoints = GetPath(hdc, NULL, NULL, 0);
- if(!nPoints) {
+ if (!nPoints) {
return true;
}
pNewTypes = (BYTE*)realloc(mpPathTypes, (mPathPoints + nPoints) * sizeof(BYTE));
pNewPoints = (POINT*)realloc(mpPathPoints, (mPathPoints + nPoints) * sizeof(POINT));
- if(pNewTypes) {
+ if (pNewTypes) {
mpPathTypes = pNewTypes;
}
- if(pNewPoints) {
+ if (pNewPoints) {
mpPathPoints = pNewPoints;
}
BYTE* pTypes = DNew BYTE[nPoints];
POINT* pPoints = DNew POINT[nPoints];
- if(pNewTypes && pNewPoints && nPoints == GetPath(hdc, pPoints, pTypes, nPoints)) {
- for(ptrdiff_t i = 0; i < nPoints; ++i) {
+ if (pNewTypes && pNewPoints && nPoints == GetPath(hdc, pPoints, pTypes, nPoints)) {
+ for (ptrdiff_t i = 0; i < nPoints; ++i) {
mpPathPoints[mPathPoints + i].x = pPoints[i].x + dx;
mpPathPoints[mPathPoints + i].y = pPoints[i].y + dy;
mpPathTypes[mPathPoints + i] = pTypes[i];
@@ -382,7 +382,7 @@ bool Rasterizer::ScanConvert() // Determine bounding box
- if(!mPathPoints) {
+ if (!mPathPoints) {
mPathOffsetX = mPathOffsetY = 0;
mWidth = mHeight = 0;
return 0;
@@ -393,20 +393,20 @@ bool Rasterizer::ScanConvert() ptrdiff_t maxx = INT_MIN;
ptrdiff_t maxy = INT_MIN;
- for(i=0; i<mPathPoints; ++i) {
+ for (i=0; i<mPathPoints; ++i) {
ptrdiff_t ix = mpPathPoints[i].x;
ptrdiff_t iy = mpPathPoints[i].y;
- if(ix < minx) {
+ if (ix < minx) {
minx = ix;
}
- if(ix > maxx) {
+ if (ix > maxx) {
maxx = ix;
}
- if(iy < miny) {
+ if (iy < miny) {
miny = iy;
}
- if(iy > maxy) {
+ if (iy > maxy) {
maxy = iy;
}
}
@@ -416,12 +416,12 @@ bool Rasterizer::ScanConvert() maxx = (maxx + 7) >> 3;
maxy = (maxy + 7) >> 3;
- for(i=0; i<mPathPoints; ++i) {
+ for (i=0; i<mPathPoints; ++i) {
mpPathPoints[i].x -= minx*8;
mpPathPoints[i].y -= miny*8;
}
- if(minx > maxx || miny > maxy) {
+ if (minx > maxx || miny > maxy) {
mWidth = mHeight = 0;
mPathOffsetX = mPathOffsetY = 0;
_TrashPath();
@@ -455,12 +455,12 @@ bool Rasterizer::ScanConvert() firstp.x = firstp.y = 0;
lastp.x = lastp.y = 0;
- for(i=0; i<mPathPoints; ++i) {
+ for (i=0; i<mPathPoints; ++i) {
BYTE t = mpPathTypes[i] & ~PT_CLOSEFIGURE;
- switch(t) {
+ switch (t) {
case PT_MOVETO:
- if(lastmoveto >= 0 && firstp != lastp) {
+ if (lastmoveto >= 0 && firstp != lastp) {
_EvaluateLine(lastp.x, lastp.y, firstp.x, firstp.y);
}
lastmoveto = i;
@@ -470,31 +470,31 @@ bool Rasterizer::ScanConvert() case PT_MOVETONC:
break;
case PT_LINETO:
- if(mPathPoints - (i-1) >= 2) {
+ if (mPathPoints - (i-1) >= 2) {
_EvaluateLine(i-1, i);
}
break;
case PT_BEZIERTO:
- if(mPathPoints - (i-1) >= 4) {
+ if (mPathPoints - (i-1) >= 4) {
_EvaluateBezier(i-1, false);
}
i += 2;
break;
case PT_BSPLINETO:
- if(mPathPoints - (i-1) >= 4) {
+ if (mPathPoints - (i-1) >= 4) {
_EvaluateBezier(i-1, true);
}
i += 2;
break;
case PT_BSPLINEPATCHTO:
- if(mPathPoints - (i-3) >= 4) {
+ if (mPathPoints - (i-3) >= 4) {
_EvaluateBezier(i-3, true);
}
break;
}
}
- if(lastmoveto >= 0 && firstp != lastp) {
+ if (lastmoveto >= 0 && firstp != lastp) {
_EvaluateLine(lastp.x, lastp.y, firstp.x, firstp.y);
}
@@ -514,12 +514,12 @@ bool Rasterizer::ScanConvert() __int64 y = 0;
- for(y=0; y<mHeight; ++y) {
+ for (y=0; y<mHeight; ++y) {
int count = 0;
// Detangle scanline into edge heap.
- for(size_t ptr = (mpScanBuffer[y]&size_t(-1)); ptr; ptr = mpEdgeBuffer[ptr].next) {
+ for (size_t ptr = (mpScanBuffer[y]&size_t(-1)); ptr; ptr = mpEdgeBuffer[ptr].next) {
heap.push_back(mpEdgeBuffer[ptr].posandflag);
}
@@ -538,23 +538,23 @@ bool Rasterizer::ScanConvert() size_t x1 = 0;
size_t x2;
- for(; itX1 != itX2; ++itX1) {
+ for (; itX1 != itX2; ++itX1) {
size_t x = *itX1;
- if(!count) {
+ if (!count) {
x1 = (x>>1);
}
- if(x&1) {
+ if (x&1) {
++count;
} else {
--count;
}
- if(!count) {
+ if (!count) {
x2 = (x>>1);
- if(x2>x1) {
+ if (x2>x1) {
mOutline.push_back(std::pair<__int64,__int64>((y<<32)+x1+0x4000000040000000i64, (y<<32)+x2+0x4000000040000000i64)); // G: damn Avery, this is evil! :)
}
}
@@ -593,8 +593,8 @@ void Rasterizer::_OverlapRegion(tSpanBuffer& dst, tSpanBuffer& src, int dx, int unsigned __int64 offset1 = (((__int64)dy)<<32) - dx;
unsigned __int64 offset2 = (((__int64)dy)<<32) + dx;
- while(itA != itAE && itB != itBE) {
- if((*itB).first + offset1 < (*itA).first) {
+ while (itA != itAE && itB != itBE) {
+ if ((*itB).first + offset1 < (*itA).first) {
// B span is earlier. Use it.
unsigned __int64 x1 = (*itB).first + offset1;
@@ -604,30 +604,30 @@ void Rasterizer::_OverlapRegion(tSpanBuffer& dst, tSpanBuffer& src, int dx, int // B spans don't overlap, so begin merge loop with A first.
- for(;;) {
+ for (;;) {
// If we run out of A spans or the A span doesn't overlap,
// then the next B span can't either (because B spans don't
// overlap) and we exit.
- if(itA == itAE || (*itA).first > x2) {
+ if (itA == itAE || (*itA).first > x2) {
break;
}
do {
x2 = _MAX(x2, (*itA++).second);
- } while(itA != itAE && (*itA).first <= x2);
+ } while (itA != itAE && (*itA).first <= x2);
// If we run out of B spans or the B span doesn't overlap,
// then the next A span can't either (because A spans don't
// overlap) and we exit.
- if(itB == itBE || (*itB).first + offset1 > x2) {
+ if (itB == itBE || (*itB).first + offset1 > x2) {
break;
}
do {
x2 = _MAX(x2, (*itB++).second + offset2);
- } while(itB != itBE && (*itB).first + offset1 <= x2);
+ } while (itB != itBE && (*itB).first + offset1 <= x2);
}
// Flush span.
@@ -643,30 +643,30 @@ void Rasterizer::_OverlapRegion(tSpanBuffer& dst, tSpanBuffer& src, int dx, int // A spans don't overlap, so begin merge loop with B first.
- for(;;) {
+ for (;;) {
// If we run out of B spans or the B span doesn't overlap,
// then the next A span can't either (because A spans don't
// overlap) and we exit.
- if(itB == itBE || (*itB).first + offset1 > x2) {
+ if (itB == itBE || (*itB).first + offset1 > x2) {
break;
}
do {
x2 = _MAX(x2, (*itB++).second + offset2);
- } while(itB != itBE && (*itB).first + offset1 <= x2);
+ } while (itB != itBE && (*itB).first + offset1 <= x2);
// If we run out of A spans or the A span doesn't overlap,
// then the next B span can't either (because B spans don't
// overlap) and we exit.
- if(itA == itAE || (*itA).first > x2) {
+ if (itA == itAE || (*itA).first > x2) {
break;
}
do {
x2 = _MAX(x2, (*itA++).second);
- } while(itA != itAE && (*itA).first <= x2);
+ } while (itA != itAE && (*itA).first <= x2);
}
// Flush span.
@@ -677,11 +677,11 @@ void Rasterizer::_OverlapRegion(tSpanBuffer& dst, tSpanBuffer& src, int dx, int // Copy over leftover spans.
- while(itA != itAE) {
+ while (itA != itAE) {
dst.push_back(*itA++);
}
- while(itB != itBE) {
+ while (itB != itBE) {
dst.push_back(tSpan((*itB).first + offset1, (*itB).second + offset2));
++itB;
}
@@ -689,10 +689,10 @@ void Rasterizer::_OverlapRegion(tSpanBuffer& dst, tSpanBuffer& src, int dx, int bool Rasterizer::CreateWidenedRegion(int rx, int ry)
{
- if(rx < 0) {
+ if (rx < 0) {
rx = 0;
}
- if(ry < 0) {
+ if (ry < 0) {
ry = 0;
}
@@ -701,7 +701,7 @@ bool Rasterizer::CreateWidenedRegion(int rx, int ry) if (ry > 0) {
// Do a half circle.
// _OverlapRegion mirrors this so both halves are done.
- for(ptrdiff_t y = -ry; y <= ry; ++y) {
+ for (ptrdiff_t y = -ry; y <= ry; ++y) {
int x = (int)(0.5 + sqrt(float(ry*ry - y*y)) * float(rx)/float(ry));
_OverlapRegion(mWideOutline, mOutline, x, y);
@@ -725,7 +725,7 @@ bool Rasterizer::Rasterize(int xsub, int ysub, int fBlur, double fGaussianBlur) {
_TrashOverlay();
- if(!mWidth || !mHeight) {
+ if (!mWidth || !mHeight) {
mOverlayWidth = mOverlayHeight = 0;
return true;
}
@@ -741,7 +741,7 @@ bool Rasterizer::Rasterize(int xsub, int ysub, int fBlur, double fGaussianBlur) mWideBorder = (mWideBorder+7)&~7;
- if(!mWideOutline.empty() || fBlur || fGaussianBlur > 0) {
+ if (!mWideOutline.empty() || fBlur || fGaussianBlur > 0) {
int bluradjust = 0;
if (fGaussianBlur > 0) {
bluradjust += (int)(fGaussianBlur*3*8 + 0.5) | 1;
@@ -768,7 +768,7 @@ bool Rasterizer::Rasterize(int xsub, int ysub, int fBlur, double fGaussianBlur) mOverlayHeight=((height+14)>>3) + 1;
mpOverlayBuffer = (byte*)_aligned_malloc(2 * mOverlayWidth * mOverlayHeight, 16);
- if(!mpOverlayBuffer) {
+ if (!mpOverlayBuffer) {
return false;
}
@@ -778,11 +778,11 @@ bool Rasterizer::Rasterize(int xsub, int ysub, int fBlur, double fGaussianBlur) tSpanBuffer* pOutline[2] = {&mOutline, &mWideOutline};
- for(ptrdiff_t i = countof(pOutline)-1; i >= 0; i--) {
+ for (ptrdiff_t i = countof(pOutline)-1; i >= 0; i--) {
tSpanBuffer::iterator it = pOutline[i]->begin();
tSpanBuffer::iterator itEnd = pOutline[i]->end();
- for(; it!=itEnd; ++it) {
+ for (; it!=itEnd; ++it) {
unsigned __int64 f = (*it).first;
size_t y = (f >> 32) - 0x40000000 + ysub;
size_t x1 = (f & 0xffffffff) - 0x40000000 + xsub;
@@ -790,18 +790,18 @@ bool Rasterizer::Rasterize(int xsub, int ysub, int fBlur, double fGaussianBlur) unsigned __int64 s = (*it).second;
size_t x2 = (s & 0xffffffff) - 0x40000000 + xsub;
- if(x2 > x1) {
+ if (x2 > x1) {
size_t first = x1>>3;
size_t last = (x2-1)>>3;
byte* dst = mpOverlayBuffer + 2*(mOverlayWidth*(y>>3) + first) + i;
- if(first == last) {
+ if (first == last) {
*dst += x2-x1;
} else {
*dst += ((first+1)<<3) - x1;
dst += 2;
- while(++first < last) {
+ while (++first < last) {
*dst += 0x08;
dst += 2;
}
@@ -819,7 +819,7 @@ bool Rasterizer::Rasterize(int xsub, int ysub, int fBlur, double fGaussianBlur) size_t pitch = mOverlayWidth*2;
byte *tmp = DNew byte[pitch*mOverlayHeight];
- if(!tmp) {
+ if (!tmp) {
return false;
}
@@ -837,11 +837,11 @@ bool Rasterizer::Rasterize(int xsub, int ysub, int fBlur, double fGaussianBlur) // If we're blurring, do a 3x3 box blur
// Can't do it on subpictures smaller than 3x3 pixels
for (int pass = 0; pass < fBlur; pass++) {
- if(mOverlayWidth >= 3 && mOverlayHeight >= 3) {
+ if (mOverlayWidth >= 3 && mOverlayHeight >= 3) {
int pitch = mOverlayWidth*2;
byte* tmp = DNew byte[pitch*mOverlayHeight];
- if(!tmp) {
+ if (!tmp) {
return false;
}
@@ -850,11 +850,11 @@ bool Rasterizer::Rasterize(int xsub, int ysub, int fBlur, double fGaussianBlur) int border = !mWideOutline.empty() ? 1 : 0;
// This could be done in a separated way and win some speed
- for(ptrdiff_t j = 1; j < mOverlayHeight-1; j++) {
+ for (ptrdiff_t j = 1; j < mOverlayHeight-1; j++) {
byte* src = tmp + pitch*j + 2 + border;
byte* dst = mpOverlayBuffer + pitch*j + 2 + border;
- for(ptrdiff_t i = 1; i < mOverlayWidth-1; i++, src+=2, dst+=2) {
+ for (ptrdiff_t i = 1; i < mOverlayWidth-1; i++, src+=2, dst+=2) {
*dst = (src[-2-pitch] + (src[-pitch]<<1) + src[+2-pitch]
+ (src[-2]<<1) + (src[0]<<2) + (src[+2]<<1)
+ src[-2+pitch] + (src[+pitch]<<1) + src[+2+pitch]) >> 4;
@@ -911,7 +911,7 @@ static __forceinline void alpha_blend_sse2(DWORD* dst, DWORD original_color, BYT alpha_mask = _mm_and_si128(alpha_mask, low_mask);
alpha_mask = _mm_mullo_epi16(alpha_mask, src_alpha);
-
+
alpha_mask = _mm_srli_epi16(alpha_mask, 6);
alpha_mask = _mm_and_si128(alpha_mask, low_mask);
@@ -1072,8 +1072,8 @@ void Rasterizer::Draw_noAlpha_spFF_Body_0(RasterizerNfo& rnfo) // The <<6 is due to pixmix expecting the alpha parameter to be
// the multiplication of two 6-bit unsigned numbers but we
// only have one here. (No alpha mask.)
- while(h--) {
- for(int wt=0; wt<rnfo.w; ++wt) {
+ while (h--) {
+ for (int wt=0; wt<rnfo.w; ++wt) {
pixmix(&dst[wt], color, s[wt*2]);
}
s += 2*rnfo.overlayp;
@@ -1096,8 +1096,8 @@ void Rasterizer::Draw_noAlpha_spFF_noBody_0(RasterizerNfo& rnfo) // subtraction must be saturating since the widened region
// pixel value can be smaller than the fill value.
// This happens when blur edges is used.
- while(h--) {
- for(int wt=0; wt<rnfo.w; ++wt) {
+ while (h--) {
+ for (int wt=0; wt<rnfo.w; ++wt) {
pixmix(&dst[wt], color, safe_subtract(src[wt*2+1], src[wt*2]));
}
src += 2*rnfo.overlayp;
@@ -1119,11 +1119,11 @@ void Rasterizer::Draw_noAlpha_sp_Body_0(RasterizerNfo& rnfo) // (So switchpts stores both colours *and* coordinates?)
int gran = min(rnfo.sw[3]+1-rnfo.xo,rnfo.w);
int color2 = rnfo.sw[2];
- while(h--) {
- for(int wt=0; wt<gran; ++wt) {
+ while (h--) {
+ for (int wt=0; wt<gran; ++wt) {
pixmix(&dst[wt], color, s[wt*2]);
}
- for(int wt=gran; wt<rnfo.w; ++wt) {
+ for (int wt=gran; wt<rnfo.w; ++wt) {
pixmix(&dst[wt], color2, s[wt*2]);
}
s += 2*rnfo.overlayp;
@@ -1141,11 +1141,11 @@ void Rasterizer::Draw_noAlpha_sp_noBody_0(RasterizerNfo& rnfo) int gran = min(rnfo.sw[3]+1-rnfo.xo,rnfo.w);
int color2 = rnfo.sw[2];
- while(h--) {
- for(int wt=0; wt<gran; ++wt) {
+ while (h--) {
+ for (int wt=0; wt<gran; ++wt) {
pixmix(&dst[wt], color, safe_subtract(src[wt*2+1], src[wt*2]));
}
- for(int wt=gran; wt<rnfo.w; ++wt) {
+ for (int wt=gran; wt<rnfo.w; ++wt) {
pixmix(&dst[wt], color2, safe_subtract(src[wt*2+1], src[wt*2]));
}
src += 2*rnfo.overlayp;
@@ -1170,8 +1170,8 @@ void Rasterizer::Draw_Alpha_spFF_Body_0(RasterizerNfo& rnfo) // clipping mask.
// Multiplying them together yields a 12-bit number.
// I think some imprecision is introduced here??
- while(h--) {
- for(int wt=0; wt<rnfo.w; ++wt)
+ while (h--) {
+ for (int wt=0; wt<rnfo.w; ++wt)
#ifdef _VSMOD // patch m006. moveable vector clip
pixmix2(&dst[wt], color, s[wt*2], mod_vc.GetAlphaValue(wt,h));
#else
@@ -1198,19 +1198,19 @@ void Rasterizer::Draw_Alpha_spFF_noBody_0(RasterizerNfo& rnfo) int gran = min(rnfo.sw[3]+1-rnfo.xo,rnfo.w);
int color2 = rnfo.sw[2];
- while(h--) {
+ while (h--) {
#ifdef _VSMOD // patch m006. moveable vector clip
- for(int wt=0; wt<gran; ++wt) {
+ for (int wt=0; wt<gran; ++wt) {
pixmix2(&dst[wt], color, safe_subtract(src[wt*2+1], src[wt*2]), mod_vc.GetAlphaValue(wt,h));
}
- for(int wt=gran; wt<rnfo.w; ++wt) {
+ for (int wt=gran; wt<rnfo.w; ++wt) {
pixmix2(&dst[wt], color2, safe_subtract(src[wt*2+1], src[wt*2]), mod_vc.GetAlphaValue(wt,h));
}
#else
- for(int wt=0; wt<gran; ++wt) {
+ for (int wt=0; wt<gran; ++wt) {
pixmix2(&dst[wt], color, safe_subtract(src[wt*2+1], src[wt*2]), am[wt]);
}
- for(int wt=gran; wt<rnfo.w; ++wt) {
+ for (int wt=gran; wt<rnfo.w; ++wt) {
pixmix2(&dst[wt], color2, safe_subtract(src[wt*2+1], src[wt*2]), am[wt]);
}
am += rnfo.spdw;
@@ -1233,8 +1233,8 @@ void Rasterizer::Draw_Alpha_sp_Body_0(RasterizerNfo& rnfo) byte* s = rnfo.s;
DWORD* dst = rnfo.dst;
- while(h--) {
- for(int wt=0; wt<rnfo.w; ++wt) {
+ while (h--) {
+ for (int wt=0; wt<rnfo.w; ++wt) {
#ifdef _VSMOD // patch m006. moveable vector clip
pixmix2(&dst[wt], color, s[wt*2], mod_vc.GetAlphaValue(wt,h));
}
@@ -1263,19 +1263,19 @@ void Rasterizer::Draw_Alpha_sp_noBody_0(RasterizerNfo& rnfo) DWORD* dst = rnfo.dst;
int gran = min(rnfo.sw[3]+1-rnfo.xo,rnfo.w);
int color2 = rnfo.sw[2];
- while(h--) {
+ while (h--) {
#ifdef _VSMOD // patch m006. moveable vector clip
- for(int wt=0; wt<gran; ++wt) {
+ for (int wt=0; wt<gran; ++wt) {
pixmix2(&dst[wt], color, safe_subtract(src[wt*2+1], src[wt*2]), mod_vc.GetAlphaValue(wt,h));
}
- for(int wt=gran; wt<rnfo.w; ++wt) {
+ for (int wt=gran; wt<rnfo.w; ++wt) {
pixmix2(&dst[wt], color2, safe_subtract(src[wt*2+1], src[wt*2]), mod_vc.GetAlphaValue(wt,h));
}
#else
- for(int wt=0; wt<gran; ++wt) {
+ for (int wt=0; wt<gran; ++wt) {
pixmix2(&dst[wt], color, safe_subtract(src[wt*2+1], src[wt*2]), am[wt]);
}
- for(int wt=gran; wt<rnfo.w; ++wt) {
+ for (int wt=gran; wt<rnfo.w; ++wt) {
pixmix2(&dst[wt], color2, safe_subtract(src[wt*2+1], src[wt*2]), am[wt]);
}
am += rnfo.spdw;
@@ -1298,12 +1298,12 @@ void Rasterizer::Draw_noAlpha_spFF_Body_sse2(RasterizerNfo& rnfo) // only have one here. (No alpha mask.)
int w = rnfo.w;
int end_w = ((w-1)/8)*8;
- while(h--) {
- for(int wt = 0; wt < end_w; wt+=8)
+ while (h--) {
+ for (int wt = 0; wt < end_w; wt+=8)
{
alpha_blend_sse2(dst, color, s, wt);
}
- for(int wt=end_w; wt<w; ++wt) {
+ for (int wt=end_w; wt<w; ++wt) {
pixmix_sse2(&dst[wt], color, s[wt*2]);
}
s += 2*rnfo.overlayp;
@@ -1326,8 +1326,8 @@ void Rasterizer::Draw_noAlpha_spFF_noBody_sse2(RasterizerNfo& rnfo) // subtraction must be saturating since the widened region
// pixel value can be smaller than the fill value.
// This happens when blur edges is used.
- while(h--) {
- for(int wt=0; wt<rnfo.w; ++wt) {
+ while (h--) {
+ for (int wt=0; wt<rnfo.w; ++wt) {
pixmix_sse2(&dst[wt], color, safe_subtract_sse2(src[wt*2+1], src[wt*2]));
}
src += 2*rnfo.overlayp;
@@ -1351,19 +1351,19 @@ void Rasterizer::Draw_noAlpha_sp_Body_sse2(RasterizerNfo& rnfo) int end_gran = ((gran-1)/8)*8;
int end_w = gran+((rnfo.w-gran-1)/8)*8;
int color2 = rnfo.sw[2];
- while(h--) {
- for(int wt=0; wt < end_gran; wt+=8)
+ while (h--) {
+ for (int wt=0; wt < end_gran; wt+=8)
{
alpha_blend_sse2(dst, color, s, wt);
}
- for(int wt=end_gran; wt<gran; ++wt) {
+ for (int wt=end_gran; wt<gran; ++wt) {
pixmix_sse2(&dst[wt], color, s[wt*2]);
}
- for(int wt=gran; wt<end_w; wt+=8)
+ for (int wt=gran; wt<end_w; wt+=8)
{
alpha_blend_sse2(dst, color2, s, wt);
}
- for(int wt=end_w; wt<rnfo.w; wt++)
+ for (int wt=end_w; wt<rnfo.w; wt++)
{
pixmix_sse2(&dst[wt], color2, s[wt*2]);
}
@@ -1382,11 +1382,11 @@ void Rasterizer::Draw_noAlpha_sp_noBody_sse2(RasterizerNfo& rnfo) DWORD* dst = rnfo.dst;
int gran = min(rnfo.sw[3]+1-rnfo.xo,rnfo.w);
int color2 = rnfo.sw[2];
- while(h--) {
- for(int wt=0; wt<gran; ++wt) {
+ while (h--) {
+ for (int wt=0; wt<gran; ++wt) {
pixmix_sse2(&dst[wt], color, safe_subtract_sse2(src[wt*2+1], src[wt*2]));
}
- for(int wt=gran; wt<rnfo.w; ++wt) {
+ for (int wt=gran; wt<rnfo.w; ++wt) {
pixmix_sse2(&dst[wt], color2, safe_subtract_sse2(src[wt*2+1], src[wt*2]));
}
src += 2*rnfo.overlayp;
@@ -1411,8 +1411,8 @@ void Rasterizer::Draw_Alpha_spFF_Body_sse2(RasterizerNfo& rnfo) // clipping mask.
// Multiplying them together yields a 12-bit number.
// I think some imprecision is introduced here??
- while(h--) {
- for(int wt=0; wt<rnfo.w; ++wt)
+ while (h--) {
+ for (int wt=0; wt<rnfo.w; ++wt)
#ifdef _VSMOD // patch m006. moveable vector clip
pixmix2_sse2(&dst[wt], color, s[wt*2], mod_vc.GetAlphaValue(wt,h));
#else
@@ -1437,8 +1437,8 @@ void Rasterizer::Draw_Alpha_spFF_noBody_sse2(RasterizerNfo& rnfo) byte* src = rnfo.src;
DWORD* dst = rnfo.dst;
- while(h--) {
- for(int wt=0; wt<rnfo.w; ++wt)
+ while (h--) {
+ for (int wt=0; wt<rnfo.w; ++wt)
#ifdef _VSMOD // patch m006. moveable vector clip
pixmix2_sse2(&dst[wt], color, safe_subtract_sse2(src[wt*2+1], src[wt*2]), mod_vc.GetAlphaValue(wt,h));
#else
@@ -1466,19 +1466,19 @@ void Rasterizer::Draw_Alpha_sp_Body_sse2(RasterizerNfo& rnfo) int gran = min(rnfo.sw[3]+1-rnfo.xo,rnfo.w);
int color2 = rnfo.sw[2];
- while(h--) {
+ while (h--) {
#ifdef _VSMOD // patch m006. moveable vector clip
- for(int wt=0; wt<gran; ++wt) {
+ for (int wt=0; wt<gran; ++wt) {
pixmix2_sse2(&dst[wt], color, s[wt*2], mod_vc.GetAlphaValue(wt,h));
}
- for(int wt=gran; wt<rnfo.w; ++wt) {
+ for (int wt=gran; wt<rnfo.w; ++wt) {
pixmix2_sse2(&dst[wt], color2, s[wt*2], mod_vc.GetAlphaValue(wt,h));
}
#else
- for(int wt=0; wt<gran; ++wt) {
+ for (int wt=0; wt<gran; ++wt) {
pixmix2_sse2(&dst[wt], color, s[wt*2], am[wt]);
}
- for(int wt=gran; wt<rnfo.w; ++wt) {
+ for (int wt=gran; wt<rnfo.w; ++wt) {
pixmix2_sse2(&dst[wt], color2, s[wt*2], am[wt]);
}
am += rnfo.spdw;
@@ -1506,19 +1506,19 @@ void Rasterizer::Draw_Alpha_sp_noBody_sse2(RasterizerNfo& rnfo) int color2 = rnfo.sw[2];
UNUSED_ALWAYS(color2);
- while(h--) {
+ while (h--) {
#ifdef _VSMOD // patch m006. moveable vector clip
- for(int wt=0; wt<gran; ++wt) {
+ for (int wt=0; wt<gran; ++wt) {
pixmix2_sse2(&dst[wt], color, safe_subtract_sse2(src[wt*2+1], src[wt*2]), mod_vc.GetAlphaValue(wt,h));
}
- for(int wt=gran; wt<rnfo.w; ++wt) {
+ for (int wt=gran; wt<rnfo.w; ++wt) {
pixmix2_sse2(&dst[wt], color, safe_subtract_sse2(src[wt*2+1], src[wt*2]), mod_vc.GetAlphaValue(wt,h));
}
#else
- for(int wt=0; wt<gran; ++wt) {
+ for (int wt=0; wt<gran; ++wt) {
pixmix2_sse2(&dst[wt], color, safe_subtract_sse2(src[wt*2+1], src[wt*2]), am[wt]);
}
- for(int wt=gran; wt<rnfo.w; ++wt) {
+ for (int wt=gran; wt<rnfo.w; ++wt) {
pixmix2_sse2(&dst[wt], color, safe_subtract_sse2(src[wt*2+1], src[wt*2]), am[wt]);
}
am += rnfo.spdw;
@@ -1539,8 +1539,8 @@ void Rasterizer::Draw_Grad_noAlpha_spFF_Body_0(RasterizerNfo& rnfo) int typ = rnfo.typ;
int h = rnfo.h;
int w = rnfo.w;
- while(h--) {
- for(int wt=0; wt<w; ++wt) {
+ while (h--) {
+ for (int wt=0; wt<w; ++wt) {
pixmix(&dst[wt], mod_grad.getmixcolor(wt,h,typ), s[wt*2]);
}
s += 2*rnfo.overlayp;
@@ -1558,8 +1558,8 @@ void Rasterizer::Draw_Grad_noAlpha_spFF_noBody_0(RasterizerNfo& rnfo) int typ = rnfo.typ;
int h = rnfo.h;
int w = rnfo.w;
- while(h--) {
- for(int wt=0; wt<w; ++wt) {
+ while (h--) {
+ for (int wt=0; wt<w; ++wt) {
pixmix(&dst[wt], mod_grad.getmixcolor(wt,h,typ), safe_subtract(src[wt*2+1], src[wt*2]));
}
src += 2*rnfo.overlayp;
@@ -1579,11 +1579,11 @@ void Rasterizer::Draw_Grad_noAlpha_sp_Body_0(RasterizerNfo& rnfo) int w = rnfo.w;
int gran = max(rnfo.sw[3]+1-rnfo.xo,0);
- while(h--) {
- for(int wt=0; wt<gran; ++wt) {
+ while (h--) {
+ for (int wt=0; wt<gran; ++wt) {
pixmix(&dst[wt], mod_grad.getmixcolor(wt,h,0), s[wt*2]);
}
- for(int wt=gran; wt<w; ++wt) {
+ for (int wt=gran; wt<w; ++wt) {
pixmix(&dst[wt], mod_grad.getmixcolor(wt,h,1), s[wt*2]);
}
s += 2*rnfo.overlayp;
@@ -1602,11 +1602,11 @@ void Rasterizer::Draw_Grad_noAlpha_sp_noBody_0(RasterizerNfo& rnfo) int w = rnfo.w;
int gran = min(rnfo.sw[3]+1-rnfo.xo,rnfo.w);
- while(h--) {
- for(int wt=0; wt<gran; ++wt) {
+ while (h--) {
+ for (int wt=0; wt<gran; ++wt) {
pixmix(&dst[wt], mod_grad.getmixcolor(wt,h,0), safe_subtract(src[wt*2+1], src[wt*2]));
}
- for(int wt=gran; wt<w; ++wt) {
+ for (int wt=gran; wt<w; ++wt) {
pixmix(&dst[wt], mod_grad.getmixcolor(wt,h,1), safe_subtract(src[wt*2+1], src[wt*2]));
}
src += 2*rnfo.overlayp;
@@ -1624,8 +1624,8 @@ void Rasterizer::Draw_Grad_Alpha_spFF_Body_0(RasterizerNfo& rnfo) int typ = rnfo.typ;
int h = rnfo.h;
int w = rnfo.w;
- while(h--) {
- for(int wt=0; wt<w; ++wt) {
+ while (h--) {
+ for (int wt=0; wt<w; ++wt) {
pixmix2(&dst[wt], mod_grad.getmixcolor(wt,h,typ), s[wt*2], mod_vc.GetAlphaValue(wt,h));
}
s += 2*rnfo.overlayp;
@@ -1643,8 +1643,8 @@ void Rasterizer::Draw_Grad_Alpha_spFF_noBody_0(RasterizerNfo& rnfo) int typ = rnfo.typ;
int h = rnfo.h;
int w = rnfo.w;
- while(h--) {
- for(int wt=0; wt<w; ++wt) {
+ while (h--) {
+ for (int wt=0; wt<w; ++wt) {
pixmix2(&dst[wt], mod_grad.getmixcolor(wt,h,typ), safe_subtract(src[wt*2+1], src[wt*2]), mod_vc.GetAlphaValue(wt,h));
}
src += 2*rnfo.overlayp;
@@ -1664,11 +1664,11 @@ void Rasterizer::Draw_Grad_Alpha_sp_Body_0(RasterizerNfo& rnfo) int h = rnfo.h;
int w = rnfo.w;
- while(h--) {
- for(int wt=0; wt<gran; ++wt) {
+ while (h--) {
+ for (int wt=0; wt<gran; ++wt) {
pixmix2(&dst[wt], mod_grad.getmixcolor(wt,h,0), s[wt*2], mod_vc.GetAlphaValue(wt,h));
}
- for(int wt=gran; wt<w; ++wt) {
+ for (int wt=gran; wt<w; ++wt) {
pixmix2(&dst[wt], mod_grad.getmixcolor(wt,h,1), s[wt*2], mod_vc.GetAlphaValue(wt,h));
}
s += 2*rnfo.overlayp;
@@ -1688,11 +1688,11 @@ void Rasterizer::Draw_Grad_Alpha_sp_noBody_0(RasterizerNfo& rnfo) int h = rnfo.h;
int w = rnfo.w;
- while(h--) {
- for(int wt=0; wt<gran; ++wt) {
+ while (h--) {
+ for (int wt=0; wt<gran; ++wt) {
pixmix2(&dst[wt], mod_grad.getmixcolor(wt,h,0), safe_subtract(src[wt*2+1], src[wt*2]), mod_vc.GetAlphaValue(wt,h));
}
- for(int wt=gran; wt<w; ++wt) {
+ for (int wt=gran; wt<w; ++wt) {
pixmix2(&dst[wt], mod_grad.getmixcolor(wt,h,1), safe_subtract(src[wt*2+1], src[wt*2]), mod_vc.GetAlphaValue(wt,h));
}
src += 2*rnfo.overlayp;
@@ -1711,8 +1711,8 @@ void Rasterizer::Draw_Grad_noAlpha_spFF_Body_sse2(RasterizerNfo& rnfo) int h = rnfo.h;
int w = rnfo.w;
- while(h--) {
- for(int wt=0; wt<w; ++wt) {
+ while (h--) {
+ for (int wt=0; wt<w; ++wt) {
pixmix_sse2(&dst[wt], mod_grad.getmixcolor(wt,h,typ), s[wt*2]);
}
s += 2*rnfo.overlayp;
@@ -1730,8 +1730,8 @@ void Rasterizer::Draw_Grad_noAlpha_spFF_noBody_sse2(RasterizerNfo& rnfo) int h = rnfo.h;
int w = rnfo.w;
- while(h--) {
- for(int wt=0; wt<w; ++wt) {
+ while (h--) {
+ for (int wt=0; wt<w; ++wt) {
pixmix_sse2(&dst[wt], mod_grad.getmixcolor(wt,h,typ), safe_subtract_sse2(src[wt*2+1], src[wt*2]));
}
src += 2*rnfo.overlayp;
@@ -1750,11 +1750,11 @@ void Rasterizer::Draw_Grad_noAlpha_sp_Body_sse2(RasterizerNfo& rnfo) int h = rnfo.h;
int w = rnfo.w;
int gran = min(rnfo.sw[3]+1-rnfo.xo,rnfo.w);
- while(h--) {
- for(int wt=0; wt<gran; ++wt) {
+ while (h--) {
+ for (int wt=0; wt<gran; ++wt) {
pixmix_sse2(&dst[wt], mod_grad.getmixcolor(wt,h,0), s[wt*2]);
}
- for(int wt=gran; wt<w; ++wt) {
+ for (int wt=gran; wt<w; ++wt) {
pixmix_sse2(&dst[wt], mod_grad.getmixcolor(wt,h,1), s[wt*2]);
}
s += 2*rnfo.overlayp;
@@ -1772,11 +1772,11 @@ void Rasterizer::Draw_Grad_noAlpha_sp_noBody_sse2(RasterizerNfo& rnfo) int h = rnfo.h;
int w = rnfo.w;
int gran = min(rnfo.sw[3]+1-rnfo.xo,rnfo.w);
- while(h--) {
- for(int wt=0; wt<gran; ++wt) {
+ while (h--) {
+ for (int wt=0; wt<gran; ++wt) {
pixmix_sse2(&dst[wt], mod_grad.getmixcolor(wt,h,0), safe_subtract_sse2(src[wt*2+1], src[wt*2]));
}
- for(int wt=gran; wt<w; ++wt) {
+ for (int wt=gran; wt<w; ++wt) {
pixmix_sse2(&dst[wt], mod_grad.getmixcolor(wt,h,1), safe_subtract_sse2(src[wt*2+1], src[wt*2]));
}
src += 2*rnfo.overlayp;
@@ -1795,8 +1795,8 @@ void Rasterizer::Draw_Grad_Alpha_spFF_Body_sse2(RasterizerNfo& rnfo) int typ = rnfo.typ;
int h = rnfo.h;
int w = rnfo.w;
- while(h--) {
- for(int wt=0; wt<w; ++wt) {
+ while (h--) {
+ for (int wt=0; wt<w; ++wt) {
pixmix2_sse2(&dst[wt], mod_grad.getmixcolor(wt,h,typ), s[wt*2], mod_vc.GetAlphaValue(wt,h));
}
s += 2*rnfo.overlayp;
@@ -1815,8 +1815,8 @@ void Rasterizer::Draw_Grad_Alpha_spFF_noBody_sse2(RasterizerNfo& rnfo) int typ = rnfo.typ;
int h = rnfo.h;
int w = rnfo.w;
- while(h--) {
- for(int wt=0; wt<w; ++wt) {
+ while (h--) {
+ for (int wt=0; wt<w; ++wt) {
pixmix2_sse2(&dst[wt], mod_grad.getmixcolor(wt,h,typ), safe_subtract_sse2(src[wt*2+1], src[wt*2]), mod_vc.GetAlphaValue(wt,h));
}
src += 2*rnfo.overlayp;
@@ -1835,11 +1835,11 @@ void Rasterizer::Draw_Grad_Alpha_sp_Body_sse2(RasterizerNfo& rnfo) int h = rnfo.h;
int w = rnfo.w;
int gran = min(rnfo.sw[3]+1-rnfo.xo,rnfo.w);
- while(h--) {
- for(int wt=0; wt<gran; ++wt) {
+ while (h--) {
+ for (int wt=0; wt<gran; ++wt) {
pixmix2_sse2(&dst[wt], mod_grad.getmixcolor(wt,h,0), s[wt*2], mod_vc.GetAlphaValue(wt,h));
}
- for(int wt=gran; wt<w; ++wt) {
+ for (int wt=gran; wt<w; ++wt) {
pixmix2_sse2(&dst[wt], mod_grad.getmixcolor(wt,h,1), s[wt*2], mod_vc.GetAlphaValue(wt,h));
}
s += 2*rnfo.overlayp;
@@ -1858,11 +1858,11 @@ void Rasterizer::Draw_Grad_Alpha_sp_noBody_sse2(RasterizerNfo& rnfo) int h = rnfo.h;
int w = rnfo.w;
int gran = min(rnfo.sw[3]+1-rnfo.xo,rnfo.w);
- while(h--) {
- for(int wt=0; wt<gran; ++wt) {
+ while (h--) {
+ for (int wt=0; wt<gran; ++wt) {
pixmix2_sse2(&dst[wt], mod_grad.getmixcolor(wt,h,0), safe_subtract_sse2(src[wt*2+1], src[wt*2]), mod_vc.GetAlphaValue(wt,h));
}
- for(int wt=gran; wt<w; ++wt) {
+ for (int wt=gran; wt<w; ++wt) {
pixmix2_sse2(&dst[wt], mod_grad.getmixcolor(wt,h,1), safe_subtract_sse2(src[wt*2+1], src[wt*2]), mod_vc.GetAlphaValue(wt,h));
}
src += 2*rnfo.overlayp;
@@ -1889,7 +1889,7 @@ CRect Rasterizer::Draw(SubPicDesc& spd, CRect& clipRect, byte* pAlphaMask, int x {
CRect bbox(0, 0, 0, 0);
- if(!switchpts || !fBody && !fBorder) {
+ if (!switchpts || !fBody && !fBorder) {
return(bbox);
}
@@ -1907,25 +1907,25 @@ CRect Rasterizer::Draw(SubPicDesc& spd, CRect& clipRect, byte* pAlphaMask, int x int xo = 0, yo = 0;
// Again, limiting?
- if(x < r.left) {
+ if (x < r.left) {
xo = r.left-x;
w -= r.left-x;
x = r.left;
}
- if(y < r.top) {
+ if (y < r.top) {
yo = r.top-y;
h -= r.top-y;
y = r.top;
}
- if(x+w > r.right) {
+ if (x+w > r.right) {
w = r.right-x;
}
- if(y+h > r.bottom) {
+ if (y+h > r.bottom) {
h = r.bottom-y;
}
// Check if there's actually anything to render
- if(w <= 0 || h <= 0) {
+ if (w <= 0 || h <= 0) {
return(bbox);
}
@@ -1977,17 +1977,17 @@ CRect Rasterizer::Draw(SubPicDesc& spd, CRect& clipRect, byte* pAlphaMask, int x // Every remaining line in the bitmap to be rendered...
// Basic case of no complex clipping mask
#ifdef _VSMOD // patch m004. gradient colors
- if(((typ==0)&&((mod_grad.mode[0]==0)&&(mod_grad.mode[1]==0)))||(mod_grad.mode[typ]==0))
+ if (((typ==0)&&((mod_grad.mode[0]==0)&&(mod_grad.mode[1]==0)))||(mod_grad.mode[typ]==0))
// No gradient
#endif
- if(!pAlphaMask) {
+ if (!pAlphaMask) {
// If the first colour switching coordinate is at "infinite" we're
// never switching and can use some simpler code.
// ??? Is this optimisation really worth the extra readability issues it adds?
- if(switchpts[1] == 0xFFFFFFFF) {
+ if (switchpts[1] == 0xFFFFFFFF) {
// fBody is true if we're rendering a fill or a shadow.
- if(fBody) {
- if(fSSE2) {
+ if (fBody) {
+ if (fSSE2) {
Draw_noAlpha_spFF_Body_sse2(rnfo);
} else {
Draw_noAlpha_spFF_Body_0(rnfo);
@@ -1995,7 +1995,7 @@ CRect Rasterizer::Draw(SubPicDesc& spd, CRect& clipRect, byte* pAlphaMask, int x }
// Not painting body, ie. painting border without fill in it
else {
- if(fSSE2) {
+ if (fSSE2) {
Draw_noAlpha_spFF_noBody_sse2(rnfo);
} else {
Draw_noAlpha_spFF_noBody_0(rnfo);
@@ -2007,8 +2007,8 @@ CRect Rasterizer::Draw(SubPicDesc& spd, CRect& clipRect, byte* pAlphaMask, int x // switchpts plays an important rule here
//const long *sw = switchpts;
- if(fBody) {
- if(fSSE2) {
+ if (fBody) {
+ if (fSSE2) {
Draw_noAlpha_sp_Body_sse2(rnfo);
} else {
Draw_noAlpha_sp_Body_0(rnfo);
@@ -2016,7 +2016,7 @@ CRect Rasterizer::Draw(SubPicDesc& spd, CRect& clipRect, byte* pAlphaMask, int x }
// Not body
else {
- if(fSSE2) {
+ if (fSSE2) {
Draw_noAlpha_sp_noBody_sse2(rnfo);
} else {
Draw_noAlpha_sp_noBody_0(rnfo);
@@ -2026,15 +2026,15 @@ CRect Rasterizer::Draw(SubPicDesc& spd, CRect& clipRect, byte* pAlphaMask, int x }
// Here we *do* have an alpha mask
else {
- if(switchpts[1] == 0xFFFFFFFF) {
- if(fBody) {
- if(fSSE2) {
+ if (switchpts[1] == 0xFFFFFFFF) {
+ if (fBody) {
+ if (fSSE2) {
Draw_Alpha_spFF_Body_sse2(rnfo);
} else {
Draw_Alpha_spFF_Body_0(rnfo);
}
} else {
- if(fSSE2) {
+ if (fSSE2) {
Draw_Alpha_spFF_noBody_sse2(rnfo);
} else {
Draw_Alpha_spFF_noBody_0(rnfo);
@@ -2043,14 +2043,14 @@ CRect Rasterizer::Draw(SubPicDesc& spd, CRect& clipRect, byte* pAlphaMask, int x } else {
//const long *sw = switchpts;
- if(fBody) {
- if(fSSE2) {
+ if (fBody) {
+ if (fSSE2) {
Draw_Alpha_sp_Body_sse2(rnfo);
} else {
Draw_Alpha_sp_Body_0(rnfo);
}
} else {
- if(fSSE2) {
+ if (fSSE2) {
Draw_Alpha_sp_noBody_sse2(rnfo);
} else {
Draw_Alpha_sp_noBody_0(rnfo);
@@ -2060,14 +2060,14 @@ CRect Rasterizer::Draw(SubPicDesc& spd, CRect& clipRect, byte* pAlphaMask, int x }
#ifdef _VSMOD // patch m004. gradient colors
else {
- if(!pAlphaMask) {
+ if (!pAlphaMask) {
// If the first colour switching coordinate is at "infinite" we're
// never switching and can use some simpler code.
// ??? Is this optimisation really worth the extra readability issues it adds?
- if(switchpts[1] == 0xFFFFFFFF) {
+ if (switchpts[1] == 0xFFFFFFFF) {
// fBody is true if we're rendering a fill or a shadow.
- if(fBody) {
- if(fSSE2) {
+ if (fBody) {
+ if (fSSE2) {
Draw_Grad_noAlpha_spFF_Body_sse2(rnfo);
} else {
Draw_Grad_noAlpha_spFF_Body_0(rnfo);
@@ -2075,7 +2075,7 @@ CRect Rasterizer::Draw(SubPicDesc& spd, CRect& clipRect, byte* pAlphaMask, int x }
// Not painting body, ie. painting border without fill in it
else {
- if(fSSE2) {
+ if (fSSE2) {
Draw_Grad_noAlpha_spFF_noBody_sse2(rnfo);
} else {
Draw_Grad_noAlpha_spFF_noBody_0(rnfo);
@@ -2087,8 +2087,8 @@ CRect Rasterizer::Draw(SubPicDesc& spd, CRect& clipRect, byte* pAlphaMask, int x // switchpts plays an important rule here
//const long *sw = switchpts;
- if(fBody) {
- if(fSSE2) {
+ if (fBody) {
+ if (fSSE2) {
Draw_Grad_noAlpha_sp_Body_sse2(rnfo);
} else {
Draw_Grad_noAlpha_sp_Body_0(rnfo);
@@ -2096,7 +2096,7 @@ CRect Rasterizer::Draw(SubPicDesc& spd, CRect& clipRect, byte* pAlphaMask, int x }
// Not body
else {
- if(fSSE2) {
+ if (fSSE2) {
Draw_Grad_noAlpha_sp_noBody_sse2(rnfo);
} else {
Draw_Grad_noAlpha_sp_noBody_0(rnfo);
@@ -2106,15 +2106,15 @@ CRect Rasterizer::Draw(SubPicDesc& spd, CRect& clipRect, byte* pAlphaMask, int x }
// Here we *do* have an alpha mask
else {
- if(switchpts[1] == 0xFFFFFFFF) {
- if(fBody) {
- if(fSSE2) {
+ if (switchpts[1] == 0xFFFFFFFF) {
+ if (fBody) {
+ if (fSSE2) {
Draw_Grad_Alpha_spFF_Body_sse2(rnfo);
} else {
Draw_Grad_Alpha_spFF_Body_0(rnfo);
}
} else {
- if(fSSE2) {
+ if (fSSE2) {
Draw_Grad_Alpha_spFF_noBody_sse2(rnfo);
} else {
Draw_Grad_Alpha_spFF_noBody_0(rnfo);
@@ -2123,14 +2123,14 @@ CRect Rasterizer::Draw(SubPicDesc& spd, CRect& clipRect, byte* pAlphaMask, int x } else {
//const long *sw = switchpts;
- if(fBody) {
- if(fSSE2) {
+ if (fBody) {
+ if (fSSE2) {
Draw_Grad_Alpha_sp_Body_sse2(rnfo);
} else {
Draw_Grad_Alpha_sp_Body_0(rnfo);
}
} else {
- if(fSSE2) {
+ if (fSSE2) {
Draw_Grad_Alpha_sp_noBody_sse2(rnfo);
} else {
Draw_Grad_Alpha_sp_noBody_0(rnfo);
@@ -2169,17 +2169,17 @@ void Rasterizer::FillSolidRect(SubPicDesc& spd, int x, int y, int nWidth, int nH {
bool fSSE2 = !!(g_cpuid.m_flags & CCpuID::sse2);
- if(fSSE2) {
+ if (fSSE2) {
for (int wy=y; wy<y+nHeight; wy++) {
DWORD* dst = (DWORD*)((BYTE*)spd.bits + spd.pitch * wy) + x;
- for(int wt=0; wt<nWidth; ++wt) {
+ for (int wt=0; wt<nWidth; ++wt) {
pixmix_sse2(&dst[wt], lColor, 0x40); // 0x40 because >> 6 in pixmix (to preserve tranparency)
}
}
} else {
for (int wy=y; wy<y+nHeight; wy++) {
DWORD* dst = (DWORD*)((BYTE*)spd.bits + spd.pitch * wy) + x;
- for(int wt=0; wt<nWidth; ++wt) {
+ for (int wt=0; wt<nWidth; ++wt) {
pixmix(&dst[wt], lColor, 0x40);
}
}
@@ -2208,7 +2208,7 @@ void MOD_MOVEVC::clear() byte MOD_MOVEVC::GetAlphaValue(int wx,int wy)
{
byte alpham;
- if(!enable) {
+ if (!enable) {
// return 0xFF;
return alphamask[wx+((hfull-wy)*spd.cx)];
}
diff --git a/src/Subtitles/RealTextParser.cpp b/src/Subtitles/RealTextParser.cpp index 779cb02ae..bcaba7419 100644 --- a/src/Subtitles/RealTextParser.cpp +++ b/src/Subtitles/RealTextParser.cpp @@ -429,7 +429,7 @@ wstring CRealTextParser::FormatTimecode(int iTimecode, wstring CRealTextParser::StringToLower(const wstring& p_crszString)
{
wstring szLowercaseString;
- for(unsigned int i=0; i < p_crszString.length(); ++i) {
+ for (unsigned int i=0; i < p_crszString.length(); ++i) {
szLowercaseString += towlower(p_crszString.at(i));
}
return szLowercaseString;
diff --git a/src/Subtitles/RenderedHdmvSubtitle.cpp b/src/Subtitles/RenderedHdmvSubtitle.cpp index 441a61499..0a86a79cd 100644 --- a/src/Subtitles/RenderedHdmvSubtitle.cpp +++ b/src/Subtitles/RenderedHdmvSubtitle.cpp @@ -125,20 +125,20 @@ STDMETHODIMP_(int) CRenderedHdmvSubtitle::GetStreamCount() STDMETHODIMP CRenderedHdmvSubtitle::GetStreamInfo(int iStream, WCHAR** ppName, LCID* pLCID)
{
- if(iStream != 0) {
+ if (iStream != 0) {
return E_INVALIDARG;
}
- if(ppName) {
+ if (ppName) {
*ppName = (WCHAR*)CoTaskMemAlloc((m_name.GetLength()+1)*sizeof(WCHAR));
- if(!(*ppName)) {
+ if (!(*ppName)) {
return E_OUTOFMEMORY;
}
wcscpy_s (*ppName, m_name.GetLength()+1, CStringW(m_name));
}
- if(pLCID) {
+ if (pLCID) {
*pLCID = m_lcid;
}
diff --git a/src/Subtitles/SSF.cpp b/src/Subtitles/SSF.cpp index 0dda7749b..13b3ec3de 100644 --- a/src/Subtitles/SSF.cpp +++ b/src/Subtitles/SSF.cpp @@ -49,7 +49,7 @@ namespace ssf m_file.Free();
m_renderer.Free();
- if(name.IsEmpty()) {
+ if (name.IsEmpty()) {
CString str = fn;
str.Replace('\\', '/');
name = str.Left(str.ReverseFind('.'));
@@ -58,11 +58,11 @@ namespace ssf }
try {
- if(Open(FileInputStream(fn), name)) {
+ if (Open(FileInputStream(fn), name)) {
m_fn = fn;
return true;
}
- } catch(Exception& e) {
+ } catch (Exception& e) {
UNREFERENCED_PARAMETER(e);
TRACE(_T("%s\n"), e.ToString());
}
@@ -83,7 +83,7 @@ namespace ssf m_renderer.Attach(DNew Renderer());
m_name = name;
return true;
- } catch(Exception& e) {
+ } catch (Exception& e) {
UNREFERENCED_PARAMETER(e);
TRACE(_T("%s\n"), e.ToString());
}
@@ -93,13 +93,13 @@ namespace ssf void CRenderer::Append(REFERENCE_TIME rtStart, REFERENCE_TIME rtStop, LPCWSTR str)
{
- if(!m_file) {
+ if (!m_file) {
return;
}
try {
m_file->Append(ssf::WCharInputStream(str), (float)rtStart / 10000000, (float)rtStop / 10000000);
- } catch(Exception& e) {
+ } catch (Exception& e) {
UNREFERENCED_PARAMETER(e);
TRACE(_T("%s\n"), e.ToString());
}
@@ -157,7 +157,7 @@ namespace ssf CheckPointer(m_file, E_UNEXPECTED);
CheckPointer(m_renderer, E_UNEXPECTED);
- if(spd.type != MSP_RGB32) {
+ if (spd.type != MSP_RGB32) {
return E_INVALIDARG;
}
@@ -172,10 +172,10 @@ namespace ssf m_renderer->NextSegment(subs);
POSITION pos = subs.GetHeadPosition();
- while(pos) {
+ while (pos) {
const Subtitle* s = subs.GetNext(pos);
const RenderedSubtitle* rs = m_renderer->Lookup(s, CSize(spd.w, spd.h), spd.vidrect);
- if(rs) {
+ if (rs) {
bbox2 |= rs->Draw(spd);
}
}
@@ -201,20 +201,20 @@ namespace ssf STDMETHODIMP CRenderer::GetStreamInfo(int iStream, WCHAR** ppName, LCID* pLCID)
{
- if(iStream != 0) {
+ if (iStream != 0) {
return E_INVALIDARG;
}
- if(ppName) {
+ if (ppName) {
*ppName = (WCHAR*)CoTaskMemAlloc((m_name.GetLength()+1)*sizeof(WCHAR));
- if(!(*ppName)) {
+ if (!(*ppName)) {
return E_OUTOFMEMORY;
}
wcscpy(*ppName, CStringW(m_name));
}
- if(pLCID) {
+ if (pLCID) {
*pLCID = 0; // TODO
}
diff --git a/src/Subtitles/STS.cpp b/src/Subtitles/STS.cpp index 99dd959e0..5da7343a3 100644 --- a/src/Subtitles/STS.cpp +++ b/src/Subtitles/STS.cpp @@ -183,7 +183,7 @@ struct htmlcolor { CHtmlColorMap::CHtmlColorMap()
{
- for(ptrdiff_t i = 0; i < countof(hmtlcolors); i++) {
+ for (ptrdiff_t i = 0; i < countof(hmtlcolors); i++) {
SetAt(hmtlcolors[i].name, hmtlcolors[i].color);
}
}
@@ -251,7 +251,7 @@ static DWORD CharSetToCodePage(DWORD dwCharSet) int FindChar(CStringW str, WCHAR c, int pos, bool fUnicode, int CharSet)
{
- if(fUnicode) {
+ if (fUnicode) {
return(str.Find(c, pos));
}
@@ -260,28 +260,28 @@ int FindChar(CStringW str, WCHAR c, int pos, bool fUnicode, int CharSet) DWORD cp = CharSetToCodePage(CharSet);
int OrgCharSet = CharSet;
- for(int i = 0, j = str.GetLength(), k; i < j; i++) {
+ for (int i = 0, j = str.GetLength(), k; i < j; i++) {
WCHAR c2 = str[i];
- if(IsDBCSLeadByteEx(cp, (BYTE)c2)) {
+ if (IsDBCSLeadByteEx(cp, (BYTE)c2)) {
i++;
- } else if(i >= pos) {
- if(c2 == c) {
+ } else if (i >= pos) {
+ if (c2 == c) {
return(i);
}
}
- if(c2 == '{') {
+ if (c2 == '{') {
fStyleMod++;
- } else if(fStyleMod > 0) {
- if(c2 == '}') {
+ } else if (fStyleMod > 0) {
+ if (c2 == '}') {
fStyleMod--;
- } else if(c2 == 'e' && i >= 3 && i < j-1 && str.Mid(i-2, 3) == L"\\fe") {
+ } else if (c2 == 'e' && i >= 3 && i < j-1 && str.Mid(i-2, 3) == L"\\fe") {
CharSet = 0;
- for(k = i+1; _istdigit(str[k]); k++) {
+ for (k = i+1; _istdigit(str[k]); k++) {
CharSet = CharSet*10 + (str[k] - '0');
}
- if(k == i+1) {
+ if (k == i+1) {
CharSet = OrgCharSet;
}
@@ -306,13 +306,13 @@ static CStringW ToMBCS(CStringW str, DWORD CharSet) DWORD cp = CharSetToCodePage(CharSet);
- for(ptrdiff_t i = 0, j = str.GetLength(); i < j; i++) {
+ for (ptrdiff_t i = 0, j = str.GetLength(); i < j; i++) {
WCHAR wc = str.GetAt(i);
char c[8];
int len;
- if((len = WideCharToMultiByte(cp, 0, &wc, 1, c, 8, NULL, NULL)) > 0) {
- for(ptrdiff_t k = 0; k < len; k++) {
+ if ((len = WideCharToMultiByte(cp, 0, &wc, 1, c, 8, NULL, NULL)) > 0) {
+ for (ptrdiff_t k = 0; k < len; k++) {
ret += (WCHAR)(BYTE)c[k];
}
} else {
@@ -329,25 +329,25 @@ static CStringW UnicodeSSAToMBCS(CStringW str, DWORD CharSet) int OrgCharSet = CharSet;
- for(ptrdiff_t j = 0; j < str.GetLength(); ) {
+ for (ptrdiff_t j = 0; j < str.GetLength(); ) {
j = str.Find('{', j);
- if(j >= 0) {
+ if (j >= 0) {
ret += ToMBCS(str.Left(j), CharSet);
str = str.Mid(j);
j = str.Find('}');
- if(j < 0) {
+ if (j < 0) {
ret += ToMBCS(str, CharSet);
break;
} else {
int k = str.Find(L"\\fe");
- if(k >= 0 && k < j) {
+ if (k >= 0 && k < j) {
CharSet = 0;
int l = k+3;
- for(; _istdigit(str[l]); l++) {
+ for (; _istdigit(str[l]); l++) {
CharSet = CharSet*10 + (str[l] - '0');
}
- if(l == k+3) {
+ if (l == k+3) {
CharSet = OrgCharSet;
}
}
@@ -373,14 +373,14 @@ static CStringW ToUnicode(CStringW str, DWORD CharSet) DWORD cp = CharSetToCodePage(CharSet);
- for(ptrdiff_t i = 0, j = str.GetLength(); i < j; i++) {
+ for (ptrdiff_t i = 0, j = str.GetLength(); i < j; i++) {
WCHAR wc = str.GetAt(i);
char c = wc&0xff;
- if(IsDBCSLeadByteEx(cp, (BYTE)wc)) {
+ if (IsDBCSLeadByteEx(cp, (BYTE)wc)) {
i++;
- if(i < j) {
+ if (i < j) {
char cc[2];
cc[0] = c;
cc[1] = (char)str.GetAt(i);
@@ -403,27 +403,27 @@ static CStringW MBCSSSAToUnicode(CStringW str, int CharSet) int OrgCharSet = CharSet;
- for(ptrdiff_t j = 0; j < str.GetLength(); ) {
+ for (ptrdiff_t j = 0; j < str.GetLength(); ) {
j = FindChar(str, '{', 0, false, CharSet);
- if(j >= 0) {
+ if (j >= 0) {
ret += ToUnicode(str.Left(j), CharSet);
str = str.Mid(j);
j = FindChar(str, '}', 0, false, CharSet);
- if(j < 0) {
+ if (j < 0) {
ret += ToUnicode(str, CharSet);
break;
} else {
int k = str.Find(L"\\fe");
- if(k >= 0 && k < j) {
+ if (k >= 0 && k < j) {
CharSet = 0;
int l = k+3;
- for(; _istdigit(str[l]); l++) {
+ for (; _istdigit(str[l]); l++) {
CharSet = CharSet*10 + (str[l] - '0');
}
- if(l == k+3) {
+ if (l == k+3) {
CharSet = OrgCharSet;
}
}
@@ -448,11 +448,11 @@ CStringW RemoveSSATags(CStringW str, bool fUnicode, int CharSet) str.Replace (L"{\\i1}", L"<i>");
str.Replace (L"{\\i}", L"</i>");
- for(ptrdiff_t i = 0, j; i < str.GetLength(); ) {
- if((i = FindChar(str, '{', i, fUnicode, CharSet)) < 0) {
+ for (ptrdiff_t i = 0, j; i < str.GetLength(); ) {
+ if ((i = FindChar(str, '{', i, fUnicode, CharSet)) < 0) {
break;
}
- if((j = FindChar(str, '}', i, fUnicode, CharSet)) < 0) {
+ if ((j = FindChar(str, '}', i, fUnicode, CharSet)) < 0) {
break;
}
str.Delete(i, j-i+1);
@@ -482,9 +482,9 @@ static CStringW SubRipper2SSA(CStringW str, int CharSet) static bool OpenSubRipper(CTextFile* file, CSimpleTextSubtitle& ret, int CharSet)
{
CStringW buff;
- while(file->ReadString(buff)) {
+ while (file->ReadString(buff)) {
buff.Trim();
- if(buff.IsEmpty()) {
+ if (buff.IsEmpty()) {
continue;
}
@@ -495,22 +495,22 @@ static bool OpenSubRipper(CTextFile* file, CSimpleTextSubtitle& ret, int CharSet &hh1, &sep, &mm1, &sep, &ss1, &sep, &ms1,
&hh2, &sep, &mm2, &sep, &ss2, &sep, &ms2);
- if(c == 1) { // numbering
+ if (c == 1) { // numbering
num = hh1;
- } else if(c == 14) { // time info
+ } else if (c == 14) { // time info
CStringW str, tmp;
bool fFoundEmpty = false;
- while(file->ReadString(tmp)) {
+ while (file->ReadString(tmp)) {
tmp.Trim();
- if(tmp.IsEmpty()) {
+ if (tmp.IsEmpty()) {
fFoundEmpty = true;
}
int num2;
WCHAR c;
- if(swscanf(tmp, L"%d%c", &num2, &c) == 1 && fFoundEmpty) {
+ if (swscanf(tmp, L"%d%c", &num2, &c) == 1 && fFoundEmpty) {
num = num2;
break;
}
@@ -523,7 +523,7 @@ static bool OpenSubRipper(CTextFile* file, CSimpleTextSubtitle& ret, int CharSet file->IsUnicode(),
(((hh1*60 + mm1)*60) + ss1)*1000 + ms1,
(((hh2*60 + mm2)*60) + ss2)*1000 + ms2);
- } else if(c != EOF) { // might be another format
+ } else if (c != EOF) { // might be another format
return false;
}
}
@@ -534,14 +534,14 @@ static bool OpenSubRipper(CTextFile* file, CSimpleTextSubtitle& ret, int CharSet static bool OpenOldSubRipper(CTextFile* file, CSimpleTextSubtitle& ret, int CharSet)
{
CStringW buff;
- while(file->ReadString(buff)) {
+ while (file->ReadString(buff)) {
buff.Trim();
- if(buff.IsEmpty()) {
+ if (buff.IsEmpty()) {
continue;
}
- for(ptrdiff_t i = 0; i < buff.GetLength(); i++) {
- if((i = FindChar(buff, '|', i, file->IsUnicode(), CharSet)) < 0) {
+ for (ptrdiff_t i = 0; i < buff.GetLength(); i++) {
+ if ((i = FindChar(buff, '|', i, file->IsUnicode(), CharSet)) < 0) {
break;
}
buff.SetAt(i, '\n');
@@ -550,13 +550,13 @@ static bool OpenOldSubRipper(CTextFile* file, CSimpleTextSubtitle& ret, int Char int hh1, mm1, ss1, hh2, mm2, ss2;
int c = swscanf(buff, L"{%d:%d:%d}{%d:%d:%d}", &hh1, &mm1, &ss1, &hh2, &mm2, &ss2);
- if(c == 6) {
+ if (c == 6) {
ret.Add(
buff.Mid(buff.Find('}', buff.Find('}')+1)+1),
file->IsUnicode(),
(((hh1*60 + mm1)*60) + ss1)*1000,
(((hh2*60 + mm2)*60) + ss2)*1000);
- } else if(c != EOF) { // might be another format
+ } else if (c != EOF) { // might be another format
return false;
}
}
@@ -574,16 +574,16 @@ static bool OpenSubViewer(CTextFile* file, CSimpleTextSubtitle& ret, int CharSet bool fUnderline = false;
CStringW buff;
- while(file->ReadString(buff)) {
+ while (file->ReadString(buff)) {
buff.Trim();
- if(buff.IsEmpty()) {
+ if (buff.IsEmpty()) {
continue;
}
- if(buff[0] == '[') {
- for(int i = 0; i < buff.GetLength() && buff[i]== '['; ) {
+ if (buff[0] == '[') {
+ for (int i = 0; i < buff.GetLength() && buff[i]== '['; ) {
int j = buff.Find(']', ++i);
- if(j < i) {
+ if (j < i) {
break;
}
@@ -594,7 +594,7 @@ static bool OpenSubViewer(CTextFile* file, CSimpleTextSubtitle& ret, int CharSet i += j-i;
j = buff.Find('[', ++i);
- if(j < 0) {
+ if (j < 0) {
j = buff.GetLength();
}
@@ -603,14 +603,14 @@ static bool OpenSubViewer(CTextFile* file, CSimpleTextSubtitle& ret, int CharSet i = j;
- if(tag == L"font") {
+ if (tag == L"font") {
font = def.fontName.CompareNoCase(WToT(param)) ? param : L"";
- } else if(tag == L"colf") {
+ } else if (tag == L"colf") {
color = def.colors[0] != (DWORD)wcstol(((LPCWSTR)param)+2, 0, 16) ? param : L"";
- } else if(tag == L"size") {
+ } else if (tag == L"size") {
size = def.fontSize != (double)wcstol(param, 0, 10) ? param : L"";
- } else if(tag == L"style") {
- if(param.Find(L"no") >= 0) {
+ } else if (tag == L"style") {
+ if (param.Find(L"no") >= 0) {
fBold = fItalic = fStriked = fUnderline = false;
} else {
fBold = def.fontWeight < FW_BOLD && param.Find(L"bd") >= 0;
@@ -629,35 +629,35 @@ static bool OpenSubViewer(CTextFile* file, CSimpleTextSubtitle& ret, int CharSet int c = swscanf(buff, L"%d:%d:%d%c%d,%d:%d:%d%c%d\n",
&hh1, &mm1, &ss1, &sep, &hs1, &hh2, &mm2, &ss2, &sep, &hs2);
- if(c == 10) {
+ if (c == 10) {
CStringW str;
file->ReadString(str);
str.Replace(L"[br]", L"\\N");
CStringW prefix;
- if(!font.IsEmpty()) {
+ if (!font.IsEmpty()) {
prefix += L"\\fn" + font;
}
- if(!color.IsEmpty()) {
+ if (!color.IsEmpty()) {
prefix += L"\\c" + color;
}
- if(!size.IsEmpty()) {
+ if (!size.IsEmpty()) {
prefix += L"\\fs" + size;
}
- if(fBold) {
+ if (fBold) {
prefix += L"\\b1";
}
- if(fItalic) {
+ if (fItalic) {
prefix += L"\\i1";
}
- if(fStriked) {
+ if (fStriked) {
prefix += L"\\s1";
}
- if(fUnderline) {
+ if (fUnderline) {
prefix += L"\\u1";
}
- if(!prefix.IsEmpty()) {
+ if (!prefix.IsEmpty()) {
str = L"{" + prefix + L"}" + str;
}
@@ -665,7 +665,7 @@ static bool OpenSubViewer(CTextFile* file, CSimpleTextSubtitle& ret, int CharSet file->IsUnicode(),
(((hh1*60 + mm1)*60) + ss1)*1000 + hs1*10,
(((hh2*60 + mm2)*60) + ss2)*1000 + hs2*10);
- } else if(c != EOF) { // might be another format
+ } else if (c != EOF) { // might be another format
return false;
}
}
@@ -676,56 +676,56 @@ static bool OpenSubViewer(CTextFile* file, CSimpleTextSubtitle& ret, int CharSet static STSStyle* GetMicroDVDStyle(CString str, int CharSet)
{
STSStyle* ret = DNew STSStyle();
- if(!ret) {
+ if (!ret) {
return(NULL);
}
- for(ptrdiff_t i = 0, len = str.GetLength(); i < len; i++) {
+ for (ptrdiff_t i = 0, len = str.GetLength(); i < len; i++) {
int j = str.Find('{', i);
- if(j < 0) {
+ if (j < 0) {
j = len;
}
- if(j >= len) {
+ if (j >= len) {
break;
}
int k = str.Find('}', j);
- if(k < 0) {
+ if (k < 0) {
k = len;
}
CString code = str.Mid(j, k-j);
- if(code.GetLength() > 2) {
+ if (code.GetLength() > 2) {
code.SetAt(1, (TCHAR)towlower(code[1]));
}
- if(!_tcsnicmp(code, _T("{c:$"), 4)) {
+ if (!_tcsnicmp(code, _T("{c:$"), 4)) {
_stscanf(code, _T("{c:$%x"), &ret->colors[0]);
- } else if(!_tcsnicmp(code, _T("{f:"), 3)) {
+ } else if (!_tcsnicmp(code, _T("{f:"), 3)) {
ret->fontName = code.Mid(3);
- } else if(!_tcsnicmp(code, _T("{s:"), 3)) {
+ } else if (!_tcsnicmp(code, _T("{s:"), 3)) {
double f;
- if(1 == _stscanf(code, _T("{s:%f"), &f)) {
+ if (1 == _stscanf(code, _T("{s:%f"), &f)) {
ret->fontSize = f;
}
- } else if(!_tcsnicmp(code, _T("{h:"), 3)) {
+ } else if (!_tcsnicmp(code, _T("{h:"), 3)) {
_stscanf(code, _T("{h:%d"), &ret->charSet);
- } else if(!_tcsnicmp(code, _T("{y:"), 3)) {
+ } else if (!_tcsnicmp(code, _T("{y:"), 3)) {
code.MakeLower();
- if(code.Find('b') >= 0) {
+ if (code.Find('b') >= 0) {
ret->fontWeight = FW_BOLD;
}
- if(code.Find('i') >= 0) {
+ if (code.Find('i') >= 0) {
ret->fItalic = true;
}
- if(code.Find('u') >= 0) {
+ if (code.Find('u') >= 0) {
ret->fUnderline = true;
}
- if(code.Find('s') >= 0) {
+ if (code.Find('s') >= 0) {
ret->fStrikeOut = true;
}
- } else if(!_tcsnicmp(code, _T("{p:"), 3)) {
+ } else if (!_tcsnicmp(code, _T("{p:"), 3)) {
int p;
_stscanf(code, _T("{p:%d"), &p);
ret->scrAlignment = (p == 0) ? 8 : 2;
@@ -746,8 +746,8 @@ static CStringW MicroDVD2SSA(CStringW str, bool fUnicode, int CharSet) int fRestoreLen = 8;
memset(fRestore, 0, sizeof(bool)*fRestoreLen);
- for(ptrdiff_t pos = 0, eol; pos < str.GetLength(); pos++) {
- if((eol = FindChar(str, '|', pos, fUnicode, CharSet)) < 0) {
+ for (ptrdiff_t pos = 0, eol; pos < str.GetLength(); pos++) {
+ if ((eol = FindChar(str, '|', pos, fUnicode, CharSet)) < 0) {
eol = str.GetLength();
}
@@ -755,25 +755,25 @@ static CStringW MicroDVD2SSA(CStringW str, bool fUnicode, int CharSet) pos = eol;
- for(ptrdiff_t i = 0, j, k, len = line.GetLength(); i < len; i++) {
- if((j = FindChar(line, '{', i, fUnicode, CharSet)) < 0) {
+ for (ptrdiff_t i = 0, j, k, len = line.GetLength(); i < len; i++) {
+ if ((j = FindChar(line, '{', i, fUnicode, CharSet)) < 0) {
j = str.GetLength();
}
ret += line.Mid(i, j-i);
- if(j >= len) {
+ if (j >= len) {
break;
}
- if((k = FindChar(line, '}', j, fUnicode, CharSet)) < 0) {
+ if ((k = FindChar(line, '}', j, fUnicode, CharSet)) < 0) {
k = len;
}
{
CStringW code = line.Mid(j, k-j);
- if(!_wcsnicmp(code, L"{c:$", 4)) {
+ if (!_wcsnicmp(code, L"{c:$", 4)) {
fRestore[COLOR] = (iswupper(code[1]) == 0);
code.MakeLower();
@@ -781,12 +781,12 @@ static CStringW MicroDVD2SSA(CStringW str, bool fUnicode, int CharSet) swscanf(code, L"{c:$%x", &color);
code.Format(L"{\\c&H%x&}", color);
ret += code;
- } else if(!_wcsnicmp(code, L"{f:", 3)) {
+ } else if (!_wcsnicmp(code, L"{f:", 3)) {
fRestore[FONTNAME] = (iswupper(code[1]) == 0);
code.Format(L"{\\fn%s}", code.Mid(3));
ret += code;
- } else if(!_wcsnicmp(code, L"{s:", 3)) {
+ } else if (!_wcsnicmp(code, L"{s:", 3)) {
fRestore[FONTSIZE] = (iswupper(code[1]) == 0);
code.MakeLower();
@@ -794,7 +794,7 @@ static CStringW MicroDVD2SSA(CStringW str, bool fUnicode, int CharSet) swscanf(code, L"{s:%f", &size);
code.Format(L"{\\fs%f}", size);
ret += code;
- } else if(!_wcsnicmp(code, L"{h:", 3)) {
+ } else if (!_wcsnicmp(code, L"{h:", 3)) {
fRestore[COLOR] = (_istupper(code[1]) == 0);
code.MakeLower();
@@ -802,30 +802,30 @@ static CStringW MicroDVD2SSA(CStringW str, bool fUnicode, int CharSet) swscanf(code, L"{h:%d", &CharSet);
code.Format(L"{\\fe%d}", CharSet);
ret += code;
- } else if(!_wcsnicmp(code, L"{y:", 3)) {
+ } else if (!_wcsnicmp(code, L"{y:", 3)) {
bool f = (_istupper(code[1]) == 0);
code.MakeLower();
ret += '{';
- if(code.Find('b') >= 0) {
+ if (code.Find('b') >= 0) {
ret += L"\\b1";
fRestore[BOLD] = f;
}
- if(code.Find('i') >= 0) {
+ if (code.Find('i') >= 0) {
ret += L"\\i1";
fRestore[ITALIC] = f;
}
- if(code.Find('u') >= 0) {
+ if (code.Find('u') >= 0) {
ret += L"\\u1";
fRestore[UNDERLINE] = f;
}
- if(code.Find('s') >= 0) {
+ if (code.Find('s') >= 0) {
ret += L"\\s1";
fRestore[STRIKEOUT] = f;
}
ret += '}';
- } else if(!_wcsnicmp(code, L"{o:", 3)) {
+ } else if (!_wcsnicmp(code, L"{o:", 3)) {
code.MakeLower();
int x, y;
@@ -841,13 +841,13 @@ static CStringW MicroDVD2SSA(CStringW str, bool fUnicode, int CharSet) i = k;
}
- if(pos >= str.GetLength()) {
+ if (pos >= str.GetLength()) {
break;
}
- for(ptrdiff_t i = 0; i < fRestoreLen; i++) {
- if(fRestore[i]) {
- switch(i) {
+ for (ptrdiff_t i = 0; i < fRestoreLen; i++) {
+ if (fRestore[i]) {
+ switch (i) {
case COLOR:
ret += L"{\\c}";
break;
@@ -893,28 +893,28 @@ static bool OpenMicroDVD(CTextFile* file, CSimpleTextSubtitle& ret, int CharSet) CString style(_T("Default"));
CStringW buff;
- while(file->ReadString(buff)) {
+ while (file->ReadString(buff)) {
buff.Trim();
- if(buff.IsEmpty()) {
+ if (buff.IsEmpty()) {
continue;
}
int start, end;
int c = swscanf(buff, L"{%d}{%d}", &start, &end);
- if(c != 2) {
+ if (c != 2) {
c = swscanf(buff, L"{%d}{}", &start) + 1;
end = start + 60;
fCheck = true;
}
- if(c != 2) {
+ if (c != 2) {
int i;
- if(buff.Find('{') == 0 && (i = buff.Find('}')) > 1 && i < buff.GetLength()) {
- if(STSStyle* s = GetMicroDVDStyle(WToT(buff.Mid(i+1)), CharSet)) {
+ if (buff.Find('{') == 0 && (i = buff.Find('}')) > 1 && i < buff.GetLength()) {
+ if (STSStyle* s = GetMicroDVDStyle(WToT(buff.Mid(i+1)), CharSet)) {
style = buff.Mid(1, i-1);
style.MakeUpper();
- if(style.GetLength()) {
+ if (style.GetLength()) {
CString str = style.Mid(1);
str.MakeLower();
style = style.Left(1) + str;
@@ -926,8 +926,8 @@ static bool OpenMicroDVD(CTextFile* file, CSimpleTextSubtitle& ret, int CharSet) }
}
- if(c == 2) {
- if(fCheck2 && ret.GetCount()) {
+ if (c == 2) {
+ if (fCheck2 && ret.GetCount()) {
STSEntry& stse = ret[ret.GetCount()-1];
stse.end = min(stse.end, start);
fCheck2 = false;
@@ -939,11 +939,11 @@ static bool OpenMicroDVD(CTextFile* file, CSimpleTextSubtitle& ret, int CharSet) start, end,
style);
- if(fCheck) {
+ if (fCheck) {
fCheck = false;
fCheck2 = true;
}
- } else if(c != EOF) { // might be another format
+ } else if (c != EOF) { // might be another format
return false;
}
}
@@ -958,8 +958,8 @@ static void ReplaceNoCase(CStringW& str, CStringW from, CStringW to) int i, j, k;
- for(i = 0, j = str.GetLength(); i < j; ) {
- if((k = lstr.Find(from, i)) >= 0) {
+ for (i = 0, j = str.GetLength(); i < j; ) {
+ if ((k = lstr.Find(from, i)) >= 0) {
str.Delete(k, from.GetLength());
lstr.Delete(k, from.GetLength());
str.Insert(k, to);
@@ -987,16 +987,16 @@ static CStringW SMI2SSA(CStringW str, int CharSet) // maven@maven.de
// now parse line
- for(ptrdiff_t i = 0, j = str.GetLength(); i < j; ) {
+ for (ptrdiff_t i = 0, j = str.GetLength(); i < j; ) {
int k;
- if((k = lstr.Find('<', i)) < 0) {
+ if ((k = lstr.Find('<', i)) < 0) {
break;
}
int chars_inserted = 0;
int l = 1;
- for(; k+l < j && lstr[k+l] != '>'; l++) {
+ for (; k+l < j && lstr[k+l] != '>'; l++) {
;
}
l++;
@@ -1016,7 +1016,7 @@ static CStringW SMI2SSA(CStringW str, int CharSet) arg = args.SpanExcluding(L" \t>");
args = args.Mid(arg.GetLength());
- if(arg.IsEmpty()) {
+ if (arg.IsEmpty()) {
break;
}
if (arg.Find(L"color=") == 0 ) {
@@ -1028,9 +1028,9 @@ static CStringW SMI2SSA(CStringW str, int CharSet) }
DWORD val;
- if(g_colors.Lookup(CString(arg), val)) {
+ if (g_colors.Lookup(CString(arg), val)) {
color = (DWORD)val;
- } else if((color = wcstol(arg, NULL, 16) ) == 0) {
+ } else if ((color = wcstol(arg, NULL, 16) ) == 0) {
color = 0x00ffffff; // default is white
}
@@ -1109,13 +1109,13 @@ static bool OpenSami(CTextFile* file, CSimpleTextSubtitle& ret, int CharSet) bool fSAMI = false;
- while(file->ReadString(buff) && !fSAMI) {
- if(buff.MakeUpper().Find(L"<SAMI>") >= 0) {
+ while (file->ReadString(buff) && !fSAMI) {
+ if (buff.MakeUpper().Find(L"<SAMI>") >= 0) {
fSAMI = true;
}
}
- if(!fSAMI) {
+ if (!fSAMI) {
return false;
}
@@ -1125,28 +1125,28 @@ static bool OpenSami(CTextFile* file, CSimpleTextSubtitle& ret, int CharSet) int start_time = 0;
- while(file->ReadString(buff)) {
+ while (file->ReadString(buff)) {
buff.Trim();
- if(buff.IsEmpty()) {
+ if (buff.IsEmpty()) {
continue;
}
CStringW ubuff = buff;
ubuff.MakeUpper();
- if(ubuff.Find(L"<!--") >= 0 || ubuff.Find(L"<TITLE>") >= 0) {
+ if (ubuff.Find(L"<!--") >= 0 || ubuff.Find(L"<TITLE>") >= 0) {
fComment = true;
}
- if(!fComment) {
+ if (!fComment) {
int i;
- if((i = ubuff.Find(L"<SYNC START=")) >= 0) {
+ if ((i = ubuff.Find(L"<SYNC START=")) >= 0) {
int time = 0;
- for(i = 12; i < ubuff.GetLength(); i++) {
- if(ubuff[i] != '>' && ubuff[i] != 'M') {
- if(iswdigit(ubuff[i])) {
+ for (i = 12; i < ubuff.GetLength(); i++) {
+ if (ubuff[i] != '>' && ubuff[i] != 'M') {
+ if (iswdigit(ubuff[i])) {
time *= 10;
time += ubuff[i] - 0x30;
}
@@ -1167,7 +1167,7 @@ static bool OpenSami(CTextFile* file, CSimpleTextSubtitle& ret, int CharSet) caption += buff;
}
- if(ubuff.Find(L"-->") >= 0 || ubuff.Find(L"</TITLE>") >= 0) {
+ if (ubuff.Find(L"-->") >= 0 || ubuff.Find(L"</TITLE>") >= 0) {
fComment = false;
}
}
@@ -1183,14 +1183,14 @@ static bool OpenSami(CTextFile* file, CSimpleTextSubtitle& ret, int CharSet) static bool OpenVPlayer(CTextFile* file, CSimpleTextSubtitle& ret, int CharSet)
{
CStringW buff;
- while(file->ReadString(buff)) {
+ while (file->ReadString(buff)) {
buff.Trim();
- if(buff.IsEmpty()) {
+ if (buff.IsEmpty()) {
continue;
}
- for(ptrdiff_t i = 0; i < buff.GetLength(); i++) {
- if((i = FindChar(buff, '|', i, file->IsUnicode(), CharSet)) < 0) {
+ for (ptrdiff_t i = 0; i < buff.GetLength(); i++) {
+ if ((i = FindChar(buff, '|', i, file->IsUnicode(), CharSet)) < 0) {
break;
}
buff.SetAt(i, '\n');
@@ -1199,13 +1199,13 @@ static bool OpenVPlayer(CTextFile* file, CSimpleTextSubtitle& ret, int CharSet) int hh, mm, ss;
int c = swscanf(buff, L"%d:%d:%d:", &hh, &mm, &ss);
- if(c == 3) {
+ if (c == 3) {
CStringW str = buff.Mid(buff.Find(':', buff.Find(':', buff.Find(':')+1)+1)+1);
ret.Add(str,
file->IsUnicode(),
(((hh*60 + mm)*60) + ss)*1000,
(((hh*60 + mm)*60) + ss)*1000 + 1000 + 50*str.GetLength());
- } else if(c != EOF) { // might be another format
+ } else if (c != EOF) { // might be another format
return false;
}
}
@@ -1218,15 +1218,15 @@ CStringW GetStr(CStringW& buff, char sep = ',') //throw(...) buff.TrimLeft();
int pos = buff.Find(sep);
- if(pos < 0) {
+ if (pos < 0) {
pos = buff.GetLength();
- if(pos < 1) {
+ if (pos < 1) {
throw 1;
}
}
CStringW ret = buff.Left(pos);
- if(pos < buff.GetLength()) {
+ if (pos < buff.GetLength()) {
buff = buff.Mid(pos+1);
}
@@ -1245,7 +1245,7 @@ int GetInt(CStringW& buff, char sep = ',') //throw(...) : L"%d";
int ret;
- if(swscanf(str, fmtstr, &ret) != 1) {
+ if (swscanf(str, fmtstr, &ret) != 1) {
throw 1;
}
@@ -1260,7 +1260,7 @@ double GetFloat(CStringW& buff, char sep = ',') //throw(...) str.MakeLower();
double ret;
- if(swscanf(str, L"%lf", &ret) != 1) {
+ if (swscanf(str, L"%lf", &ret) != 1) {
throw 1;
}
@@ -1272,17 +1272,17 @@ static bool LoadFont(CString& font) int len = font.GetLength();
CAutoVectorPtr<BYTE> pData;
- if(len == 0 || (len&3) == 1 || !pData.Allocate(len)) {
+ if (len == 0 || (len&3) == 1 || !pData.Allocate(len)) {
return false;
}
const TCHAR* s = font;
const TCHAR* e = s + len;
- for(BYTE* p = pData; s < e; s++, p++) {
+ for (BYTE* p = pData; s < e; s++, p++) {
*p = *s - 33;
}
- for(ptrdiff_t i = 0, j = 0, k = len&~3; i < k; i+=4, j+=3) {
+ for (ptrdiff_t i = 0, j = 0, k = len&~3; i < k; i+=4, j+=3) {
pData[j+0] = ((pData[i+0]&63)<<2)|((pData[i+1]>>4)& 3);
pData[j+1] = ((pData[i+1]&15)<<4)|((pData[i+2]>>2)&15);
pData[j+2] = ((pData[i+2]& 3)<<6)|((pData[i+3]>>0)&63);
@@ -1290,18 +1290,18 @@ static bool LoadFont(CString& font) int datalen = (len&~3)*3/4;
- if((len&3) == 2) {
+ if ((len&3) == 2) {
pData[datalen++] = ((pData[(len&~3)+0]&63)<<2)|((pData[(len&~3)+1]>>4)&3);
- } else if((len&3) == 3) {
+ } else if ((len&3) == 3) {
pData[datalen++] = ((pData[(len&~3)+0]&63)<<2)|((pData[(len&~3)+1]>>4)& 3);
pData[datalen++] = ((pData[(len&~3)+1]&15)<<4)|((pData[(len&~3)+2]>>2)&15);
}
HANDLE hFont = INVALID_HANDLE_VALUE;
- if(HMODULE hModule = LoadLibrary(_T("GDI32.DLL"))) {
+ if (HMODULE hModule = LoadLibrary(_T("GDI32.DLL"))) {
typedef HANDLE (WINAPI *PAddFontMemResourceEx)( IN PVOID, IN DWORD, IN PVOID , IN DWORD*);
- if(PAddFontMemResourceEx f = (PAddFontMemResourceEx)GetProcAddress(hModule, "AddFontMemResourceEx")) {
+ if (PAddFontMemResourceEx f = (PAddFontMemResourceEx)GetProcAddress(hModule, "AddFontMemResourceEx")) {
DWORD cFonts;
hFont = f(pData, datalen, NULL, &cFonts);
}
@@ -1309,12 +1309,12 @@ static bool LoadFont(CString& font) FreeLibrary(hModule);
}
- if(hFont == INVALID_HANDLE_VALUE) {
+ if (hFont == INVALID_HANDLE_VALUE) {
TCHAR path[_MAX_PATH];
GetTempPath(_MAX_PATH, path);
DWORD chksum = 0;
- for(ptrdiff_t i = 0, j = datalen>>2; i < j; i++) {
+ for (ptrdiff_t i = 0, j = datalen>>2; i < j; i++) {
chksum += ((DWORD*)(BYTE*)pData)[i];
}
@@ -1322,9 +1322,9 @@ static bool LoadFont(CString& font) fn.Format(_T("%sfont%08x.ttf"), path, chksum);
CFileStatus fs;
- if(!CFileGetStatus(fn, fs)) {
+ if (!CFileGetStatus(fn, fs)) {
CFile f;
- if(f.Open(fn, CFile::modeCreate|CFile::modeWrite|CFile::typeBinary|CFile::shareDenyNone)) {
+ if (f.Open(fn, CFile::modeCreate|CFile::modeWrite|CFile::typeBinary|CFile::shareDenyNone)) {
f.Write(pData, datalen);
f.Close();
}
@@ -1339,32 +1339,32 @@ static bool LoadFont(CString& font) static bool LoadUUEFont(CTextFile* file)
{
CString s, font;
- while(file->ReadString(s)) {
+ while (file->ReadString(s)) {
s.Trim();
- if(s.IsEmpty()) {
+ if (s.IsEmpty()) {
break;
}
- if(s[0] == '[') { // check for some standatr blocks
- if(s.Find(_T("[Script Info]")) == 0) {
+ if (s[0] == '[') { // check for some standatr blocks
+ if (s.Find(_T("[Script Info]")) == 0) {
break;
}
- if(s.Find(_T("[V4+ Styles]")) == 0) {
+ if (s.Find(_T("[V4+ Styles]")) == 0) {
break;
}
- if(s.Find(_T("[V4 Styles]")) == 0) {
+ if (s.Find(_T("[V4 Styles]")) == 0) {
break;
}
- if(s.Find(_T("[Events]")) == 0) {
+ if (s.Find(_T("[Events]")) == 0) {
break;
}
- if(s.Find(_T("[Fonts]")) == 0) {
+ if (s.Find(_T("[Fonts]")) == 0) {
break;
}
- if(s.Find(_T("[Graphics]")) == 0) {
+ if (s.Find(_T("[Graphics]")) == 0) {
break;
}
}
- if(s.Find(_T("fontname:")) == 0) {
+ if (s.Find(_T("fontname:")) == 0) {
LoadFont(font);
font.Empty();
continue;
@@ -1373,7 +1373,7 @@ static bool LoadUUEFont(CTextFile* file) font += s;
}
- if(!font.IsEmpty()) {
+ if (!font.IsEmpty()) {
LoadFont(font);
}
@@ -1386,17 +1386,17 @@ bool CSimpleTextSubtitle::LoadEfile(CString& img, CString m_fn) int len = img.GetLength();
CAutoVectorPtr<BYTE> pData;
- if(len == 0 || (len&3) == 1 || !pData.Allocate(len)) {
+ if (len == 0 || (len&3) == 1 || !pData.Allocate(len)) {
return false;
}
const TCHAR* s = img;
const TCHAR* e = s + len;
- for(BYTE* p = pData; s < e; s++, p++) {
+ for (BYTE* p = pData; s < e; s++, p++) {
*p = *s - 33;
}
- for(ptrdiff_t i = 0, j = 0, k = len&~3; i < k; i+=4, j+=3) {
+ for (ptrdiff_t i = 0, j = 0, k = len&~3; i < k; i+=4, j+=3) {
pData[j+0] = ((pData[i+0]&63)<<2)|((pData[i+1]>>4)& 3);
pData[j+1] = ((pData[i+1]&15)<<4)|((pData[i+2]>>2)&15);
pData[j+2] = ((pData[i+2]& 3)<<6)|((pData[i+3]>>0)&63);
@@ -1404,16 +1404,16 @@ bool CSimpleTextSubtitle::LoadEfile(CString& img, CString m_fn) int datalen = (len&~3)*3/4;
- if((len&3) == 2) {
+ if ((len&3) == 2) {
pData[datalen++] = ((pData[(len&~3)+0]&63)<<2)|((pData[(len&~3)+1]>>4)&3);
- } else if((len&3) == 3) {
+ } else if ((len&3) == 3) {
pData[datalen++] = ((pData[(len&~3)+0]&63)<<2)|((pData[(len&~3)+1]>>4)& 3);
pData[datalen++] = ((pData[(len&~3)+1]&15)<<4)|((pData[(len&~3)+2]>>2)&15);
}
// load png image
MOD_PNGIMAGE t_temp;
- if(t_temp.initImage(pData.m_p,m_fn)) { // save path
+ if (t_temp.initImage(pData.m_p,m_fn)) { // save path
mod_images.Add(t_temp);
}
return true;
@@ -1423,33 +1423,33 @@ bool CSimpleTextSubtitle::LoadEfile(CString& img, CString m_fn) bool CSimpleTextSubtitle::LoadUUEFile(CTextFile* file, CString m_fn)
{
CString s, img;
- while(file->ReadString(s)) {
+ while (file->ReadString(s)) {
s.Trim();
- if(s.IsEmpty()) {
+ if (s.IsEmpty()) {
break;
}
- if(s[0] == '[') { // check for some standatr blocks
- if(s.Find(_T("[Script Info]")) == 0) {
+ if (s[0] == '[') { // check for some standatr blocks
+ if (s.Find(_T("[Script Info]")) == 0) {
break;
}
- if(s.Find(_T("[V4+ Styles]")) == 0) {
+ if (s.Find(_T("[V4+ Styles]")) == 0) {
break;
}
- if(s.Find(_T("[V4 Styles]")) == 0) {
+ if (s.Find(_T("[V4 Styles]")) == 0) {
break;
}
- if(s.Find(_T("[Events]")) == 0) {
+ if (s.Find(_T("[Events]")) == 0) {
break;
}
- if(s.Find(_T("[Fonts]")) == 0) {
+ if (s.Find(_T("[Fonts]")) == 0) {
break;
}
- if(s.Find(_T("[Graphics]")) == 0) {
+ if (s.Find(_T("[Graphics]")) == 0) {
break;
}
}
// next file
- if(s.Find(_T("filename:")) == 0) {
+ if (s.Find(_T("filename:")) == 0) {
LoadEfile(img, m_fn);
m_fn = s.Mid(10);
img.Empty();
@@ -1459,7 +1459,7 @@ bool CSimpleTextSubtitle::LoadUUEFile(CTextFile* file, CString m_fn) img += s;
}
- if(!img.IsEmpty()) {
+ if (!img.IsEmpty()) {
LoadEfile(img, m_fn);
}
@@ -1474,9 +1474,9 @@ static bool OpenSubStationAlpha(CTextFile* file, CSimpleTextSubtitle& ret, int C int version = 3, sver = 3;
CStringW buff;
- while(file->ReadString(buff)) {
+ while (file->ReadString(buff)) {
buff.Trim();
- if(buff.IsEmpty() || buff.GetAt(0) == ';') {
+ if (buff.IsEmpty() || buff.GetAt(0) == ';') {
continue;
}
@@ -1489,69 +1489,69 @@ static bool OpenSubStationAlpha(CTextFile* file, CSimpleTextSubtitle& ret, int C entry.MakeLower();
- if(entry == L"[script info]") {
+ if (entry == L"[script info]") {
fRet = true;
- } else if(entry == L"playresx") {
+ } else if (entry == L"playresx") {
try {
ret.m_dstScreenSize.cx = GetInt(buff);
- } catch(...) {
+ } catch (...) {
ret.m_dstScreenSize = CSize(0, 0);
return false;
}
- if(ret.m_dstScreenSize.cy <= 0) {
+ if (ret.m_dstScreenSize.cy <= 0) {
ret.m_dstScreenSize.cy = (ret.m_dstScreenSize.cx == 1280)
? 1024
: ret.m_dstScreenSize.cx * 3 / 4;
}
- } else if(entry == L"playresy") {
+ } else if (entry == L"playresy") {
try {
ret.m_dstScreenSize.cy = GetInt(buff);
- } catch(...) {
+ } catch (...) {
ret.m_dstScreenSize = CSize(0, 0);
return false;
}
- if(ret.m_dstScreenSize.cx <= 0) {
+ if (ret.m_dstScreenSize.cx <= 0) {
ret.m_dstScreenSize.cx = (ret.m_dstScreenSize.cy == 1024)
? 1280
: ret.m_dstScreenSize.cy * 4 / 3;
}
- } else if(entry == L"wrapstyle") {
+ } else if (entry == L"wrapstyle") {
try {
ret.m_defaultWrapStyle = GetInt(buff);
- } catch(...) {
+ } catch (...) {
ret.m_defaultWrapStyle = 1;
return false;
}
- } else if(entry == L"scripttype") {
- if(buff.GetLength() >= 4 && !buff.Right(4).CompareNoCase(L"4.00")) {
+ } else if (entry == L"scripttype") {
+ if (buff.GetLength() >= 4 && !buff.Right(4).CompareNoCase(L"4.00")) {
version = sver = 4;
- } else if(buff.GetLength() >= 5 && !buff.Right(5).CompareNoCase(L"4.00+")) {
+ } else if (buff.GetLength() >= 5 && !buff.Right(5).CompareNoCase(L"4.00+")) {
version = sver = 5;
- } else if(buff.GetLength() >= 6 && !buff.Right(6).CompareNoCase(L"4.00++")) {
+ } else if (buff.GetLength() >= 6 && !buff.Right(6).CompareNoCase(L"4.00++")) {
version = sver = 6;
}
- } else if(entry == L"collisions") {
+ } else if (entry == L"collisions") {
buff = GetStr(buff);
buff.MakeLower();
ret.m_collisions = buff.Find(L"reverse") >= 0 ? 1 : 0;
- } else if(entry == L"scaledborderandshadow") {
+ } else if (entry == L"scaledborderandshadow") {
buff = GetStr(buff);
buff.MakeLower();
ret.m_fScaledBAS = buff.Find(L"yes") >= 0;
- } else if(entry == L"[v4 styles]") {
+ } else if (entry == L"[v4 styles]") {
fRet = true;
sver = 4;
- } else if(entry == L"[v4+ styles]") {
+ } else if (entry == L"[v4+ styles]") {
fRet = true;
sver = 5;
- } else if(entry == L"[v4++ styles]") {
+ } else if (entry == L"[v4++ styles]") {
fRet = true;
sver = 6;
- } else if(entry == L"style") {
+ } else if (entry == L"style") {
STSStyle* style = DNew STSStyle;
- if(!style) {
+ if (!style) {
return false;
}
@@ -1562,30 +1562,30 @@ static bool OpenSubStationAlpha(CTextFile* file, CSimpleTextSubtitle& ret, int C StyleName = WToT(GetStr(buff));
style->fontName = WToT(GetStr(buff));
style->fontSize = GetFloat(buff);
- for(ptrdiff_t i = 0; i < 4; i++) {
+ for (ptrdiff_t i = 0; i < 4; i++) {
style->colors[i] = (COLORREF)GetInt(buff);
}
style->fontWeight = GetInt(buff) ? FW_BOLD : FW_NORMAL;
style->fItalic = GetInt(buff);
- if(sver >= 5) {
+ if (sver >= 5) {
style->fUnderline = GetInt(buff);
}
- if(sver >= 5) {
+ if (sver >= 5) {
style->fStrikeOut = GetInt(buff);
}
- if(sver >= 5) {
+ if (sver >= 5) {
style->fontScaleX = GetFloat(buff);
}
- if(sver >= 5) {
+ if (sver >= 5) {
style->fontScaleY = GetFloat(buff);
}
- if(sver >= 5) {
+ if (sver >= 5) {
style->fontSpacing = GetFloat(buff);
}
- if(sver >= 5) {
+ if (sver >= 5) {
style->fontAngleZ = GetFloat(buff);
}
- if(sver >= 4) {
+ if (sver >= 4) {
style->borderStyle = GetInt(buff);
}
style->outlineWidthX = style->outlineWidthY = GetFloat(buff);
@@ -1594,41 +1594,41 @@ static bool OpenSubStationAlpha(CTextFile* file, CSimpleTextSubtitle& ret, int C style->marginRect.left = GetInt(buff);
style->marginRect.right = GetInt(buff);
style->marginRect.top = style->marginRect.bottom = GetInt(buff);
- if(sver >= 6) {
+ if (sver >= 6) {
style->marginRect.bottom = GetInt(buff);
}
- if(sver <= 4) {
+ if (sver <= 4) {
alpha = GetInt(buff);
}
style->charSet = GetInt(buff);
- if(sver >= 6) {
+ if (sver >= 6) {
style->relativeTo = GetInt(buff);
}
- if(sver <= 4) {
+ if (sver <= 4) {
style->colors[2] = style->colors[3]; // style->colors[2] is used for drawing the outline
}
- if(sver <= 4) {
+ if (sver <= 4) {
alpha = max(min(alpha, 0xff), 0);
}
- if(sver <= 4) {
- for(ptrdiff_t i = 0; i < 3; i++) {
+ if (sver <= 4) {
+ for (ptrdiff_t i = 0; i < 3; i++) {
style->alpha[i] = alpha;
}
style->alpha[3] = 0x80;
}
- if(sver >= 5) for(ptrdiff_t i = 0; i < 4; i++) {
+ if (sver >= 5) for (ptrdiff_t i = 0; i < 4; i++) {
style->alpha[i] = (BYTE)(style->colors[i] >> 24);
style->colors[i] &= 0xffffff;
}
- if(sver >= 5) {
+ if (sver >= 5) {
style->fontScaleX = max(style->fontScaleX, 0);
}
- if(sver >= 5) {
+ if (sver >= 5) {
style->fontScaleY = max(style->fontScaleY, 0);
}
#ifndef _VSMOD // patch f002. negative fontspacing at style
- if(sver >= 5) {
+ if (sver >= 5) {
style->fontSpacing = max(style->fontSpacing, 0);
}
#endif
@@ -1638,30 +1638,30 @@ static bool OpenSubStationAlpha(CTextFile* file, CSimpleTextSubtitle& ret, int C style->outlineWidthY = max(style->outlineWidthY, 0);
style->shadowDepthX = max(style->shadowDepthX, 0);
style->shadowDepthY = max(style->shadowDepthY, 0);
- if(sver <= 4) style->scrAlignment = (style->scrAlignment & 4) ? ((style->scrAlignment & 3) + 6) // top
+ if (sver <= 4) style->scrAlignment = (style->scrAlignment & 4) ? ((style->scrAlignment & 3) + 6) // top
: (style->scrAlignment & 8) ? ((style->scrAlignment & 3) + 3) // mid
: (style->scrAlignment & 3); // bottom
StyleName.TrimLeft('*');
ret.AddStyle(StyleName, style);
- } catch(...) {
+ } catch (...) {
delete style;
return false;
}
- } else if(entry == L"[events]") {
+ } else if (entry == L"[events]") {
fRet = true;
- } else if(entry == _T("dialogue")) {
+ } else if (entry == _T("dialogue")) {
try {
int hh1, mm1, ss1, ms1_div10, hh2, mm2, ss2, ms2_div10, layer = 0;
CString Style, Actor, Effect;
CRect marginRect;
- if(version <= 4) {
+ if (version <= 4) {
GetStr(buff, '='); /* Marked = */
GetInt(buff);
}
- if(version >= 5) {
+ if (version >= 5) {
layer = GetInt(buff);
}
hh1 = GetInt(buff, ':');
@@ -1677,18 +1677,18 @@ static bool OpenSubStationAlpha(CTextFile* file, CSimpleTextSubtitle& ret, int C marginRect.left = GetInt(buff);
marginRect.right = GetInt(buff);
marginRect.top = marginRect.bottom = GetInt(buff);
- if(version >= 6) {
+ if (version >= 6) {
marginRect.bottom = GetInt(buff);
}
Effect = WToT(GetStr(buff));
int len = min(Effect.GetLength(), buff.GetLength());
- if(Effect.Left(len) == WToT(buff.Left(len))) {
+ if (Effect.Left(len) == WToT(buff.Left(len))) {
Effect.Empty();
}
Style.TrimLeft('*');
- if(!Style.CompareNoCase(_T("Default"))) {
+ if (!Style.CompareNoCase(_T("Default"))) {
Style = _T("Default");
}
@@ -1699,14 +1699,14 @@ static bool OpenSubStationAlpha(CTextFile* file, CSimpleTextSubtitle& ret, int C Style, Actor, Effect,
marginRect,
layer);
- } catch(...) {
+ } catch (...) {
return false;
}
- } else if(entry == L"fontname") {
+ } else if (entry == L"fontname") {
LoadUUEFont(file);
}
#ifdef _VSMOD // load png graphic from text resources
- else if(entry == L"filename") {
+ else if (entry == L"filename") {
ret.LoadUUEFile(file,GetStr(buff));
}
#endif
@@ -1720,10 +1720,10 @@ static bool OpenXombieSub(CTextFile* file, CSimpleTextSubtitle& ret, int CharSet // CMapStringToPtr stylemap;
CStringW buff;
- while(file->ReadString(buff)) {
+ while (file->ReadString(buff)) {
buff.Trim();
- if(buff.IsEmpty() || buff.GetAt(0) == ';') {
+ if (buff.IsEmpty() || buff.GetAt(0) == ';') {
continue;
}
@@ -1738,35 +1738,35 @@ static bool OpenXombieSub(CTextFile* file, CSimpleTextSubtitle& ret, int CharSet /*if(entry == L"version") {
double version = GetFloat(buff);
- } else*/ if(entry == L"screenhorizontal") {
+ } else*/ if (entry == L"screenhorizontal") {
try {
ret.m_dstScreenSize.cx = GetInt(buff);
- } catch(...) {
+ } catch (...) {
ret.m_dstScreenSize = CSize(0, 0);
return false;
}
- if(ret.m_dstScreenSize.cy <= 0) {
+ if (ret.m_dstScreenSize.cy <= 0) {
ret.m_dstScreenSize.cy = (ret.m_dstScreenSize.cx == 1280)
? 1024
: ret.m_dstScreenSize.cx * 3 / 4;
}
- } else if(entry == L"screenvertical") {
+ } else if (entry == L"screenvertical") {
try {
ret.m_dstScreenSize.cy = GetInt(buff);
- } catch(...) {
+ } catch (...) {
ret.m_dstScreenSize = CSize(0, 0);
return false;
}
- if(ret.m_dstScreenSize.cx <= 0) {
+ if (ret.m_dstScreenSize.cx <= 0) {
ret.m_dstScreenSize.cx = (ret.m_dstScreenSize.cy == 1024)
? 1280
: ret.m_dstScreenSize.cy * 4 / 3;
}
- } else if(entry == L"style") {
+ } else if (entry == L"style") {
STSStyle* style = DNew STSStyle;
- if(!style) {
+ if (!style) {
return false;
}
@@ -1776,10 +1776,10 @@ static bool OpenXombieSub(CTextFile* file, CSimpleTextSubtitle& ret, int CharSet StyleName = WToT(GetStr(buff)) + _T("_") + WToT(GetStr(buff));
style->fontName = WToT(GetStr(buff));
style->fontSize = GetFloat(buff);
- for(ptrdiff_t i = 0; i < 4; i++) {
+ for (ptrdiff_t i = 0; i < 4; i++) {
style->colors[i] = (COLORREF)GetInt(buff);
}
- for(ptrdiff_t i = 0; i < 4; i++) {
+ for (ptrdiff_t i = 0; i < 4; i++) {
style->alpha[i] = GetInt(buff);
}
style->fontWeight = GetInt(buff) ? FW_BOLD : FW_NORMAL;
@@ -1812,18 +1812,18 @@ static bool OpenXombieSub(CTextFile* file, CSimpleTextSubtitle& ret, int CharSet style->shadowDepthY = max(style->shadowDepthY, 0);
ret.AddStyle(StyleName, style);
- } catch(...) {
+ } catch (...) {
delete style;
return false;
}
- } else if(entry == L"line") {
+ } else if (entry == L"line") {
try {
CString id;
int hh1, mm1, ss1, ms1, hh2, mm2, ss2, ms2, layer = 0;
CString Style, Actor;
CRect marginRect;
- if(GetStr(buff) != L"D") {
+ if (GetStr(buff) != L"D") {
continue;
}
id = GetStr(buff);
@@ -1843,7 +1843,7 @@ static bool OpenXombieSub(CTextFile* file, CSimpleTextSubtitle& ret, int CharSet marginRect.top = marginRect.bottom = GetInt(buff);
Style.TrimLeft('*');
- if(!Style.CompareNoCase(_T("Default"))) {
+ if (!Style.CompareNoCase(_T("Default"))) {
Style = _T("Default");
}
@@ -1854,14 +1854,14 @@ static bool OpenXombieSub(CTextFile* file, CSimpleTextSubtitle& ret, int CharSet Style, Actor, _T(""),
marginRect,
layer);
- } catch(...) {
+ } catch (...) {
return false;
}
- } else if(entry == L"fontname") {
+ } else if (entry == L"fontname") {
LoadUUEFont(file);
}
#ifdef _VSMOD // load png graphic from text resources
- else if(entry == L"filename") {
+ else if (entry == L"filename") {
ret.LoadUUEFile(file,GetStr(buff));
}
#endif
@@ -1875,10 +1875,10 @@ static bool OpenXombieSub(CTextFile* file, CSimpleTextSubtitle& ret, int CharSet static bool OpenUSF(CTextFile* file, CSimpleTextSubtitle& ret, int CharSet)
{
CString str;
- while(file->ReadString(str)) {
- if(str.Find(_T("USFSubtitles")) >= 0) {
+ while (file->ReadString(str)) {
+ if (str.Find(_T("USFSubtitles")) >= 0) {
CUSFSubtitles usf;
- if(usf.Read(file->GetFilePath()) && usf.ConvertToSTS(ret)) {
+ if (usf.Read(file->GetFilePath()) && usf.ConvertToSTS(ret)) {
return true;
}
@@ -1894,9 +1894,9 @@ static CStringW MPL22SSA(CStringW str) CAtlList<CStringW> sl;
Explode(str, sl, '|');
POSITION pos = sl.GetHeadPosition();
- while(pos) {
+ while (pos) {
CStringW& s = sl.GetNext(pos);
- if(s[0] == '/') {
+ if (s[0] == '/') {
s = L"{\\i1}" + s.Mid(1) + L"{\\i0}";
}
}
@@ -1908,21 +1908,21 @@ static CStringW MPL22SSA(CStringW str) static bool OpenMPL2(CTextFile* file, CSimpleTextSubtitle& ret, int CharSet)
{
CStringW buff;
- while(file->ReadString(buff)) {
+ while (file->ReadString(buff)) {
buff.Trim();
- if(buff.IsEmpty()) {
+ if (buff.IsEmpty()) {
continue;
}
int start, end;
int c = swscanf(buff, L"[%d][%d]", &start, &end);
- if(c == 2) {
+ if (c == 2) {
ret.Add(
MPL22SSA(buff.Mid(buff.Find(']', buff.Find(']')+1)+1)),
file->IsUnicode(),
start*100, end*100);
- } else if(c != EOF) { // might be another format
+ } else if (c != EOF) { // might be another format
return false;
}
}
@@ -1995,7 +1995,7 @@ CSimpleTextSubtitle& CSimpleTextSubtitle::operator = (CSimpleTextSubtitle& sts) void CSimpleTextSubtitle::Copy(CSimpleTextSubtitle& sts)
{
- if(this != &sts) {
+ if (this != &sts) {
Empty();
m_name = sts.m_name;
@@ -2016,12 +2016,12 @@ void CSimpleTextSubtitle::Copy(CSimpleTextSubtitle& sts) void CSimpleTextSubtitle::Append(CSimpleTextSubtitle& sts, int timeoff)
{
- if(timeoff < 0) {
+ if (timeoff < 0) {
timeoff = GetCount() > 0 ? GetAt(GetCount()-1).end : 0;
}
- for(ptrdiff_t i = 0, j = GetCount(); i < j; i++) {
- if(GetAt(i).start > timeoff) {
+ for (ptrdiff_t i = 0, j = GetCount(); i < j; i++) {
+ if (GetAt(i).start > timeoff) {
RemoveAt(i, j - i);
break;
}
@@ -2029,7 +2029,7 @@ void CSimpleTextSubtitle::Append(CSimpleTextSubtitle& sts, int timeoff) CopyStyles(sts.m_styles, true);
- for(ptrdiff_t i = 0, j = sts.GetCount(); i < j; i++) {
+ for (ptrdiff_t i = 0, j = sts.GetCount(); i < j; i++) {
STSEntry stse = sts.GetAt(i);
stse.start += timeoff;
stse.end += timeoff;
@@ -2043,7 +2043,7 @@ void CSimpleTextSubtitle::Append(CSimpleTextSubtitle& sts, int timeoff) void CSTSStyleMap::Free()
{
POSITION pos = GetStartPosition();
- while(pos) {
+ while (pos) {
CString key;
STSStyle* val;
GetNextAssoc(pos, key, val);
@@ -2055,18 +2055,18 @@ void CSTSStyleMap::Free() bool CSimpleTextSubtitle::CopyStyles(const CSTSStyleMap& styles, bool fAppend)
{
- if(!fAppend) {
+ if (!fAppend) {
m_styles.Free();
}
POSITION pos = styles.GetStartPosition();
- while(pos) {
+ while (pos) {
CString key;
STSStyle* val;
styles.GetNextAssoc(pos, key, val);
STSStyle* s = DNew STSStyle;
- if(!s) {
+ if (!s) {
return false;
}
@@ -2086,7 +2086,7 @@ void CSimpleTextSubtitle::Empty() RemoveAll();
#ifdef _VSMOD // indexing
- if(ind_size>0) {
+ if (ind_size>0) {
delete ind_time;
delete ind_pos;
}
@@ -2095,13 +2095,13 @@ void CSimpleTextSubtitle::Empty() void CSimpleTextSubtitle::Add(CStringW str, bool fUnicode, int start, int end, CString style, CString actor, CString effect, CRect marginRect, int layer, int readorder)
{
- if(str.Trim().IsEmpty() || start > end) {
+ if (str.Trim().IsEmpty() || start > end) {
return;
}
str.Remove('\r');
str.Replace(L"\n", L"\\N");
- if(style.IsEmpty()) {
+ if (style.IsEmpty()) {
style = _T("Default");
}
style.TrimLeft('*');
@@ -2123,38 +2123,38 @@ void CSimpleTextSubtitle::Add(CStringW str, bool fUnicode, int start, int end, C #ifndef _VSMOD
int len = m_segments.GetCount();
- if(len == 0) {
+ if (len == 0) {
STSSegment stss(start, end);
stss.subs.Add(n);
m_segments.Add(stss);
- } else if(end <= m_segments[0].start) {
+ } else if (end <= m_segments[0].start) {
STSSegment stss(start, end);
stss.subs.Add(n);
m_segments.InsertAt(0, stss);
- } else if(start >= m_segments[len-1].end) {
+ } else if (start >= m_segments[len-1].end) {
STSSegment stss(start, end);
stss.subs.Add(n);
m_segments.Add(stss);
} else {
- if(start < m_segments[0].start) {
+ if (start < m_segments[0].start) {
STSSegment stss(start, m_segments[0].start);
stss.subs.Add(n);
start = m_segments[0].start;
m_segments.InsertAt(0, stss);
}
- for(size_t i = 0; i < m_segments.GetCount(); i++) {
+ for (size_t i = 0; i < m_segments.GetCount(); i++) {
STSSegment& s = m_segments[i];
- if(start >= s.end) {
+ if (start >= s.end) {
continue;
}
- if(end <= s.start) {
+ if (end <= s.start) {
break;
}
- if(s.start < start && start < s.end) {
+ if (s.start < start && start < s.end) {
STSSegment stss(s.start, start);
stss.subs.Copy(s.subs);
s.start = start;
@@ -2162,20 +2162,20 @@ void CSimpleTextSubtitle::Add(CStringW str, bool fUnicode, int start, int end, C continue;
}
- if(start <= s.start && s.end <= end) {
- for(ptrdiff_t j = 0, k = s.subs.GetCount(); j <= k; j++) {
- if(j == k || sub.readorder < GetAt(s.subs[j]).readorder) {
+ if (start <= s.start && s.end <= end) {
+ for (ptrdiff_t j = 0, k = s.subs.GetCount(); j <= k; j++) {
+ if (j == k || sub.readorder < GetAt(s.subs[j]).readorder) {
s.subs.InsertAt(j, n);
}
}
// s.subs.Add(n);
}
- if(s.start < end && end < s.end) {
+ if (s.start < end && end < s.end) {
STSSegment stss(s.start, end);
stss.subs.Copy(s.subs);
- for(ptrdiff_t j = 0, k = s.subs.GetCount(); j <= k; j++) {
- if(j == k || sub.readorder < GetAt(stss.subs[j]).readorder) {
+ for (ptrdiff_t j = 0, k = s.subs.GetCount(); j <= k; j++) {
+ if (j == k || sub.readorder < GetAt(stss.subs[j]).readorder) {
stss.subs.InsertAt(j, n);
}
}
@@ -2185,7 +2185,7 @@ void CSimpleTextSubtitle::Add(CStringW str, bool fUnicode, int start, int end, C }
}
- if(end > m_segments[m_segments.GetCount()-1].end) {
+ if (end > m_segments[m_segments.GetCount()-1].end) {
STSSegment stss(m_segments[m_segments.GetCount()-1].end, end);
stss.subs.Add(n);
m_segments.Add(stss);
@@ -2202,7 +2202,7 @@ void CSimpleTextSubtitle::MakeIndex(int SizeOfSegment) if (SizeOfSegment==0) { // autosize
// 100000 lines == 1300 segments
// TODO: make gooood =D
- if(cnt<100) {
+ if (cnt<100) {
SizeOfSegment = (cnt==0) ? 1 : cnt;
} else if (cnt<1000) {
SizeOfSegment = cnt / 50;
@@ -2216,7 +2216,7 @@ void CSimpleTextSubtitle::MakeIndex(int SizeOfSegment) ind_time = new DWORD[ind_size];
ind_pos = new DWORD[ind_size];
- for(int i = 0; i<ind_size; i++) {
+ for (int i = 0; i<ind_size; i++) {
int pos = i * SizeOfSegment;
ind_time[i] = m_segments[pos].start;
ind_pos[i] = pos;
@@ -2230,7 +2230,7 @@ STSStyle* CSimpleTextSubtitle::CreateDefaultStyle(int CharSet) STSStyle* ret = NULL;
- if(!m_styles.Lookup(def, ret)) {
+ if (!m_styles.Lookup(def, ret)) {
STSStyle* style = DNew STSStyle();
style->charSet = CharSet;
AddStyle(def, style);
@@ -2249,16 +2249,16 @@ void CSimpleTextSubtitle::ChangeUnknownStylesToDefault() CAtlMap<CString, STSStyle*, CStringElementTraits<CString> > unknown;
bool fReport = true;
- for(size_t i = 0; i < GetCount(); i++) {
+ for (size_t i = 0; i < GetCount(); i++) {
STSEntry& stse = GetAt(i);
STSStyle* val;
- if(!m_styles.Lookup(stse.style, val)) {
- if(!unknown.Lookup(stse.style, val)) {
- if(fReport) {
+ if (!m_styles.Lookup(stse.style, val)) {
+ if (!unknown.Lookup(stse.style, val)) {
+ if (fReport) {
CString msg;
msg.Format(_T("Unknown style found: \"%s\", changed to \"Default\"!\n\nPress Cancel to ignore further warnings."), stse.style);
- if(MessageBox(NULL, msg, _T("Warning"), MB_OKCANCEL|MB_ICONWARNING) != IDOK) {
+ if (MessageBox(NULL, msg, _T("Warning"), MB_OKCANCEL|MB_ICONWARNING) != IDOK) {
fReport = false;
}
}
@@ -2273,13 +2273,13 @@ void CSimpleTextSubtitle::ChangeUnknownStylesToDefault() void CSimpleTextSubtitle::AddStyle(CString name, STSStyle* style)
{
- if(name.IsEmpty()) {
+ if (name.IsEmpty()) {
name = _T("Default");
}
STSStyle* val;
- if(m_styles.Lookup(name, val)) {
- if(*val == *style) {
+ if (m_styles.Lookup(name, val)) {
+ if (*val == *style) {
delete style;
return;
}
@@ -2287,7 +2287,7 @@ void CSimpleTextSubtitle::AddStyle(CString name, STSStyle* style) int i, j;
int len = name.GetLength();
- for(i = len; i > 0 && _istdigit(name[i-1]); i--) {
+ for (i = len; i > 0 && _istdigit(name[i-1]); i--) {
;
}
@@ -2295,7 +2295,7 @@ void CSimpleTextSubtitle::AddStyle(CString name, STSStyle* style) CString name2 = name;
- if(i < len && _stscanf(name.Right(len-i), _T("%d"), &idx) == 1) {
+ if (i < len && _stscanf(name.Right(len-i), _T("%d"), &idx) == 1) {
name2 = name.Left(i);
}
@@ -2305,14 +2305,14 @@ void CSimpleTextSubtitle::AddStyle(CString name, STSStyle* style) do {
name3.Format(_T("%s%d"), name2, idx);
idx++;
- } while(m_styles.Lookup(name3));
+ } while (m_styles.Lookup(name3));
m_styles.RemoveKey(name);
m_styles[name3] = val;
- for(i = 0, j = GetCount(); i < j; i++) {
+ for (i = 0, j = GetCount(); i < j; i++) {
STSEntry& stse = GetAt(i);
- if(stse.style == name) {
+ if (stse.style == name) {
stse.style = name3;
}
}
@@ -2324,7 +2324,7 @@ void CSimpleTextSubtitle::AddStyle(CString name, STSStyle* style) bool CSimpleTextSubtitle::SetDefaultStyle(STSStyle& s)
{
STSStyle* val;
- if(!m_styles.Lookup(_T("Default"), val)) {
+ if (!m_styles.Lookup(_T("Default"), val)) {
return false;
}
*val = s;
@@ -2335,7 +2335,7 @@ bool CSimpleTextSubtitle::SetDefaultStyle(STSStyle& s) bool CSimpleTextSubtitle::GetDefaultStyle(STSStyle& s)
{
STSStyle* val;
- if(!m_styles.Lookup(_T("Default"), val)) {
+ if (!m_styles.Lookup(_T("Default"), val)) {
return false;
}
s = *val;
@@ -2344,11 +2344,11 @@ bool CSimpleTextSubtitle::GetDefaultStyle(STSStyle& s) void CSimpleTextSubtitle::ConvertToTimeBased(double fps)
{
- if(m_mode == TIME) {
+ if (m_mode == TIME) {
return;
}
- for(ptrdiff_t i = 0, j = GetCount(); i < j; i++) {
+ for (ptrdiff_t i = 0, j = GetCount(); i < j; i++) {
STSEntry& stse = (*this)[i];
stse.start = 1.0 * stse.start * 1000 / fps + 0.5;
stse.end = 1.0 * stse.end * 1000 / fps + 0.5;
@@ -2361,11 +2361,11 @@ void CSimpleTextSubtitle::ConvertToTimeBased(double fps) void CSimpleTextSubtitle::ConvertToFrameBased(double fps)
{
- if(m_mode == FRAME) {
+ if (m_mode == FRAME) {
return;
}
- for(ptrdiff_t i = 0, j = GetCount(); i < j; i++) {
+ for (ptrdiff_t i = 0, j = GetCount(); i < j; i++) {
STSEntry& stse = (*this)[i];
stse.start = 1.0 * stse.start * fps / 1000 + 0.5;
stse.end = 1.0 * stse.end * fps / 1000 + 0.5;
@@ -2380,30 +2380,30 @@ int CSimpleTextSubtitle::SearchSub(int t, double fps) {
int i = 0, j = GetCount() - 1, ret = -1;
- if(j >= 0 && t >= TranslateStart(j, fps)) {
+ if (j >= 0 && t >= TranslateStart(j, fps)) {
return(j);
}
- while(i < j) {
+ while (i < j) {
int mid = (i + j) >> 1;
int midt = TranslateStart(mid, fps);
- if(t == midt) {
- while(mid > 0 && t == TranslateStart(mid-1, fps)) {
+ if (t == midt) {
+ while (mid > 0 && t == TranslateStart(mid-1, fps)) {
--mid;
}
ret = mid;
break;
- } else if(t < midt) {
+ } else if (t < midt) {
ret = -1;
- if(j == mid) {
+ if (j == mid) {
mid--;
}
j = mid;
- } else if(t > midt) {
+ } else if (t > midt) {
ret = mid;
- if(i == mid) {
+ if (i == mid) {
++mid;
}
i = mid;
@@ -2417,29 +2417,29 @@ const STSSegment* CSimpleTextSubtitle::SearchSubs(int t, double fps, /*[out]*/ i {
int i = 0, j = m_segments.GetCount() - 1, ret = -1;
- if(nSegments) {
+ if (nSegments) {
*nSegments = j+1;
}
// last segment
- if(j >= 0 && t >= TranslateSegmentStart(j, fps) && t < TranslateSegmentEnd(j, fps)) {
- if(iSegment) {
+ if (j >= 0 && t >= TranslateSegmentStart(j, fps) && t < TranslateSegmentEnd(j, fps)) {
+ if (iSegment) {
*iSegment = j;
}
return(&m_segments[j]);
}
// after last segment
- if(j >= 0 && t >= TranslateSegmentEnd(j, fps)) {
- if(iSegment) {
+ if (j >= 0 && t >= TranslateSegmentEnd(j, fps)) {
+ if (iSegment) {
*iSegment = j+1;
}
return(NULL);
}
// before first segment
- if(j > 0 && t < TranslateSegmentStart(i, fps)) {
- if(iSegment) {
+ if (j > 0 && t < TranslateSegmentStart(i, fps)) {
+ if (iSegment) {
*iSegment = -1;
}
return(NULL);
@@ -2448,9 +2448,9 @@ const STSSegment* CSimpleTextSubtitle::SearchSubs(int t, double fps, /*[out]*/ i #ifdef _VSMOD
// find bounds
// is this nya?
- for(size_t k = 0; k < ind_size; ++k) {
- if(ind_time[k]>t) {
- if(k==0) {
+ for (size_t k = 0; k < ind_size; ++k) {
+ if (ind_time[k]>t) {
+ if (k==0) {
break;
}
i = ind_pos[k-1];
@@ -2460,36 +2460,36 @@ const STSSegment* CSimpleTextSubtitle::SearchSubs(int t, double fps, /*[out]*/ i }
#endif
- while(i < j) {
+ while (i < j) {
int mid = (i + j) >> 1;
int midt = TranslateSegmentStart(mid, fps);
- if(t == midt) {
+ if (t == midt) {
ret = mid;
break;
- } else if(t < midt) {
+ } else if (t < midt) {
ret = -1;
- if(j == mid) {
+ if (j == mid) {
mid--;
}
j = mid;
- } else if(t > midt) {
+ } else if (t > midt) {
ret = mid;
- if(i == mid) {
+ if (i == mid) {
mid++;
}
i = mid;
}
}
- if(0 <= ret && (size_t)ret < m_segments.GetCount()) {
- if(iSegment) {
+ if (0 <= ret && (size_t)ret < m_segments.GetCount()) {
+ if (iSegment) {
*iSegment = ret;
}
}
- if(0 <= ret && (size_t)ret < m_segments.GetCount()
+ if (0 <= ret && (size_t)ret < m_segments.GetCount()
&& m_segments[ret].subs.GetCount() > 0
&& TranslateSegmentStart(ret, fps) <= t && t < TranslateSegmentEnd(ret, fps)) {
return(&m_segments[ret]);
@@ -2540,7 +2540,7 @@ STSStyle* CSimpleTextSubtitle::GetStyle(int i) STSStyle* defstyle = NULL;
m_styles.Lookup(def, defstyle);
- if(!style) {
+ if (!style) {
style = defstyle;
}
@@ -2559,21 +2559,21 @@ bool CSimpleTextSubtitle::GetStyle(int i, STSStyle& stss) STSStyle* defstyle = NULL;
m_styles.Lookup(def, defstyle);
- if(!style) {
- if(!defstyle) {
+ if (!style) {
+ if (!defstyle) {
defstyle = CreateDefaultStyle(DEFAULT_CHARSET);
}
style = defstyle;
}
- if(!style) {
+ if (!style) {
ASSERT(0);
return false;
}
stss = *style;
- if(stss.relativeTo == 2 && defstyle) {
+ if (stss.relativeTo == 2 && defstyle) {
stss.relativeTo = defstyle->relativeTo;
}
@@ -2596,7 +2596,7 @@ void CSimpleTextSubtitle::ConvertUnicode(int i, bool fUnicode) {
STSEntry& stse = GetAt(i);
- if(stse.fUnicode ^ fUnicode) {
+ if (stse.fUnicode ^ fUnicode) {
int CharSet = GetCharSet(i);
stse.str = fUnicode
@@ -2619,11 +2619,11 @@ CStringW CSimpleTextSubtitle::GetStrW(int i, bool fSSA) CStringW str = GetAt(i).str;
- if(!fUnicode) {
+ if (!fUnicode) {
str = MBCSSSAToUnicode(str, CharSet);
}
- if(!fSSA) {
+ if (!fSSA) {
str = RemoveSSATags(str, fUnicode, CharSet);
}
@@ -2637,11 +2637,11 @@ CStringW CSimpleTextSubtitle::GetStrWA(int i, bool fSSA) CStringW str = GetAt(i).str;
- if(fUnicode) {
+ if (fUnicode) {
str = UnicodeSSAToMBCS(str, CharSet);
}
- if(!fSSA) {
+ if (!fSSA) {
str = RemoveSSATags(str, fUnicode, CharSet);
}
@@ -2659,9 +2659,9 @@ void CSimpleTextSubtitle::SetStr(int i, CStringW str, bool fUnicode) str.Replace(L"\n", L"\\N");
- if(stse.fUnicode && !fUnicode) {
+ if (stse.fUnicode && !fUnicode) {
stse.str = MBCSSSAToUnicode(str, GetCharSet(i));
- } else if(!stse.fUnicode && fUnicode) {
+ } else if (!stse.fUnicode && fUnicode) {
stse.str = UnicodeSSAToMBCS(str, GetCharSet(i));
} else {
stse.str = str;
@@ -2671,10 +2671,10 @@ void CSimpleTextSubtitle::SetStr(int i, CStringW str, bool fUnicode) static int comp1(const void* a, const void* b)
{
int ret = ((STSEntry*)a)->start - ((STSEntry*)b)->start;
- if(ret == 0) {
+ if (ret == 0) {
ret = ((STSEntry*)a)->layer - ((STSEntry*)b)->layer;
}
- if(ret == 0) {
+ if (ret == 0) {
ret = ((STSEntry*)a)->readorder - ((STSEntry*)b)->readorder;
}
return(ret);
@@ -2704,7 +2704,7 @@ void CSimpleTextSubtitle::CreateSegments() CAtlArray<int> breakpoints;
- for(i = 0; i < GetCount(); i++) {
+ for (i = 0; i < GetCount(); i++) {
STSEntry& stse = GetAt(i);
breakpoints.Add(stse.start);
breakpoints.Add(stse.end);
@@ -2714,19 +2714,19 @@ void CSimpleTextSubtitle::CreateSegments() int* ptr = breakpoints.GetData(), prev = ptr ? *ptr : NULL;
- for(i = breakpoints.GetCount(); i > 0; i--, ptr++) {
- if(*ptr != prev) {
+ for (i = breakpoints.GetCount(); i > 0; i--, ptr++) {
+ if (*ptr != prev) {
m_segments.Add(STSSegment(prev, *ptr));
prev = *ptr;
}
}
- for(i = 0; i < GetCount(); i++) {
+ for (i = 0; i < GetCount(); i++) {
STSEntry& stse = GetAt(i);
- for(j = 0; j < m_segments.GetCount() && m_segments[j].start < stse.start; j++) {
+ for (j = 0; j < m_segments.GetCount() && m_segments[j].start < stse.start; j++) {
;
}
- for(; j < m_segments.GetCount() && m_segments[j].end <= stse.end; j++) {
+ for (; j < m_segments.GetCount() && m_segments[j].end <= stse.end; j++) {
m_segments[j].subs.Add(i);
}
}
@@ -2754,14 +2754,14 @@ bool CSimpleTextSubtitle::Open(CString videoFn, CString subFn, int charSet, CStr Empty();
CWebTextFile f;
- if(!f.Open(subFn)) {
+ if (!f.Open(subFn)) {
return false;
}
videoFn.Replace('\\', '/');
subFn.Replace('\\', '/');
- if(name.IsEmpty()) {
-
+ if (name.IsEmpty()) {
+
// The filname of the video file
CString videoName = videoFn.Left(videoFn.ReverseFind('.')).Mid(videoFn.ReverseFind('/') + 1);
@@ -2771,7 +2771,7 @@ bool CSimpleTextSubtitle::Open(CString videoFn, CString subFn, int charSet, CStr if (subName.Find(videoName) != -1 && videoName.CompareNoCase(subName) != 0)
{
name = CString(subName);
- if(name.Replace(videoName, _T("")) == 1)
+ if (name.Replace(videoName, _T("")) == 1)
{
name = name.TrimLeft('.');
}
@@ -2794,12 +2794,12 @@ bool CSimpleTextSubtitle::Open(CString fn, int CharSet, CString name) Empty();
CWebTextFile f;
- if(!f.Open(fn)) {
+ if (!f.Open(fn)) {
return false;
}
fn.Replace('\\', '/');
- if(name.IsEmpty()) {
+ if (name.IsEmpty()) {
name = fn.Left(fn.ReverseFind('.'));
name = name.Mid(name.ReverseFind('/')+1);
int len = name.GetLength();
@@ -2817,7 +2817,7 @@ static int CountLines(CTextFile* f, ULONGLONG from, ULONGLONG to) int n = 0;
CString s;
f->Seek(from, 0);
- while(f->ReadString(s) && f->GetPosition() < to) {
+ while (f->ReadString(s) && f->GetPosition() < to) {
n++;
}
return(n);
@@ -2829,9 +2829,9 @@ bool CSimpleTextSubtitle::Open(CTextFile* f, int CharSet, CString name) ULONGLONG pos = f->GetPosition();
- for(ptrdiff_t i = 0; i < nOpenFuncts; i++) {
- if(!OpenFuncts[i].open(f, *this, CharSet) /*|| !GetCount()*/) {
- if(GetCount() > 0) {
+ for (ptrdiff_t i = 0; i < nOpenFuncts; i++) {
+ if (!OpenFuncts[i].open(f, *this, CharSet) /*|| !GetCount()*/) {
+ if (GetCount() > 0) {
int n = CountLines(f, pos, f->GetPosition());
CString s;
s.Format(_T("Syntax error at line %d!\t"), n+1);
@@ -2857,7 +2857,7 @@ bool CSimpleTextSubtitle::Open(CTextFile* f, int CharSet, CString name) MakeIndex(0);
#endif
CWebTextFile f2;
- if(f2.Open(f->GetFilePath() + _T(".style"))) {
+ if (f2.Open(f->GetFilePath() + _T(".style"))) {
OpenSubStationAlpha(&f2, *this, CharSet);
}
@@ -2865,7 +2865,7 @@ bool CSimpleTextSubtitle::Open(CTextFile* f, int CharSet, CString name) ChangeUnknownStylesToDefault();
- if(m_dstScreenSize == CSize(0, 0)) {
+ if (m_dstScreenSize == CSize(0, 0)) {
m_dstScreenSize = CSize(384, 288);
}
@@ -2878,25 +2878,25 @@ bool CSimpleTextSubtitle::Open(CTextFile* f, int CharSet, CString name) bool CSimpleTextSubtitle::Open(BYTE* data, int len, int CharSet, CString name)
{
TCHAR path[_MAX_PATH];
- if(!GetTempPath(_MAX_PATH, path)) {
+ if (!GetTempPath(_MAX_PATH, path)) {
return false;
}
TCHAR fn[_MAX_PATH];
- if(!GetTempFileName(path, _T("vs"), 0, fn)) {
+ if (!GetTempFileName(path, _T("vs"), 0, fn)) {
return false;
}
FILE* tmp = _tfopen(fn, _T("wb"));
- if(!tmp) {
+ if (!tmp) {
return false;
}
int i = 0;
- for(; i <= (len-1024); i += 1024) {
+ for (; i <= (len-1024); i += 1024) {
fwrite(&data[i], 1024, 1, tmp);
}
- if(len > i) {
+ if (len > i) {
fwrite(&data[i], len - i, 1, tmp);
}
@@ -2911,19 +2911,19 @@ bool CSimpleTextSubtitle::Open(BYTE* data, int len, int CharSet, CString name) bool CSimpleTextSubtitle::SaveAs(CString fn, exttype et, double fps, CTextFile::enc e)
{
- if(fn.Mid(fn.ReverseFind('.')+1).CompareNoCase(exttypestr[et])) {
- if(fn[fn.GetLength()-1] != '.') {
+ if (fn.Mid(fn.ReverseFind('.')+1).CompareNoCase(exttypestr[et])) {
+ if (fn[fn.GetLength()-1] != '.') {
fn += _T(".");
}
fn += exttypestr[et];
}
CTextFile f;
- if(!f.Save(fn, e)) {
+ if (!f.Save(fn, e)) {
return false;
}
- if(et == EXTSMI) {
+ if (et == EXTSMI) {
CString str;
str += _T("<SAMI>\n<HEAD>\n");
@@ -2939,7 +2939,7 @@ bool CSimpleTextSubtitle::SaveAs(CString fn, exttype et, double fps, CTextFile:: str += _T("<BODY>\n");
f.WriteString(str);
- } else if(et == EXTSSA || et == EXTASS) {
+ } else if (et == EXTSSA || et == EXTASS) {
CString str;
str = _T("[Script Info]\n");
@@ -2948,7 +2948,7 @@ bool CSimpleTextSubtitle::SaveAs(CString fn, exttype et, double fps, CTextFile:: str += _T("; go to http://www.eswat.demon.co.uk/\n");
str += _T("; or email kotus@eswat.demon.co.uk\n");
str += _T("; \n");
- if(et == EXTASS) {
+ if (et == EXTASS) {
str += _T("; Advanced Sub Station Alpha script format developed by #Anime-Fansubs@EfNET\n");
str += _T("; http://www.anime-fansubs.org\n");
str += _T("; \n");
@@ -2960,7 +2960,7 @@ bool CSimpleTextSubtitle::SaveAs(CString fn, exttype et, double fps, CTextFile:: str += _T("; \n");
str += (et == EXTSSA) ? _T("ScriptType: v4.00\n") : _T("ScriptType: v4.00+\n");
str += (m_collisions == 0) ? _T("Collisions: Normal\n") : _T("Collisions: Reverse\n");
- if(et == EXTASS && m_fScaledBAS) {
+ if (et == EXTASS && m_fScaledBAS) {
str += _T("ScaledBorderAndShadow: Yes\n");
}
str += _T("PlayResX: %d\n");
@@ -2980,12 +2980,12 @@ bool CSimpleTextSubtitle::SaveAs(CString fn, exttype et, double fps, CTextFile:: : _T("Style: %s,%s,%d,&H%08x,&H%08x,&H%08x,&H%08x,%d,%d,%d,%d,%d,%d,%d,%.2f,%d,%d,%d,%d,%d,%d,%d,%d\n");
POSITION pos = m_styles.GetStartPosition();
- while(pos) {
+ while (pos) {
CString key;
STSStyle* s;
m_styles.GetNextAssoc(pos, key, s);
- if(et == EXTSSA) {
+ if (et == EXTSSA) {
CString str2;
str2.Format(str, key,
s->fontName, s->fontSize,
@@ -3022,7 +3022,7 @@ bool CSimpleTextSubtitle::SaveAs(CString fn, exttype et, double fps, CTextFile:: }
}
- if(GetCount() > 0) {
+ if (GetCount() > 0) {
str = _T("\n");
str += _T("[Events]\n");
str += (et == EXTSSA)
@@ -3042,11 +3042,11 @@ bool CSimpleTextSubtitle::SaveAs(CString fn, exttype et, double fps, CTextFile:: L"";
// Sort(true);
- for(ptrdiff_t i = 0, j = GetCount(), k = 0; i < j; i++) {
+ for (ptrdiff_t i = 0, j = GetCount(), k = 0; i < j; i++) {
STSEntry& stse = GetAt(i);
int t1 = TranslateStart(i, fps);
- if(t1 < 0) {
+ if (t1 < 0) {
k++;
continue;
}
@@ -3068,18 +3068,18 @@ bool CSimpleTextSubtitle::SaveAs(CString fn, exttype et, double fps, CTextFile:: CStringW str2;
- if(et == EXTSRT) {
+ if (et == EXTSRT) {
str2.Format(fmt, i-k+1, hh1, mm1, ss1, ms1, hh2, mm2, ss2, ms2, str);
- } else if(et == EXTSUB) {
+ } else if (et == EXTSUB) {
str.Replace('\n', '|');
str2.Format(fmt, t1*fps/1000, t2*fps/1000, str);
- } else if(et == EXTSMI) {
+ } else if (et == EXTSMI) {
str.Replace(L"\n", L"<br>");
str2.Format(fmt, t1, str, t2);
- } else if(et == EXTPSB) {
+ } else if (et == EXTPSB) {
str.Replace('\n', '|');
str2.Format(fmt, hh1, mm1, ss1, hh2, mm2, ss2, str);
- } else if(et == EXTSSA) {
+ } else if (et == EXTSSA) {
str.Replace(L"\n", L"\\N");
str2.Format(fmt,
hh1, mm1, ss1, ms1/10,
@@ -3087,7 +3087,7 @@ bool CSimpleTextSubtitle::SaveAs(CString fn, exttype et, double fps, CTextFile:: TToW(stse.style), TToW(stse.actor),
stse.marginRect.left, stse.marginRect.right, (stse.marginRect.top + stse.marginRect.bottom) / 2,
TToW(stse.effect), str);
- } else if(et == EXTASS) {
+ } else if (et == EXTASS) {
str.Replace(L"\n", L"\\N");
str2.Format(fmt,
stse.layer,
@@ -3103,14 +3103,14 @@ bool CSimpleTextSubtitle::SaveAs(CString fn, exttype et, double fps, CTextFile:: // Sort();
- if(et == EXTSMI) {
+ if (et == EXTSMI) {
f.WriteString(_T("</BODY>\n</SAMI>\n"));
}
STSStyle* s;
- if(!m_fUsingAutoGeneratedDefaultStyle && m_styles.Lookup(_T("Default"), s) && et != EXTSSA && et != EXTASS) {
+ if (!m_fUsingAutoGeneratedDefaultStyle && m_styles.Lookup(_T("Default"), s) && et != EXTSSA && et != EXTASS) {
CTextFile f;
- if(!f.Save(fn + _T(".style"), e)) {
+ if (!f.Save(fn + _T(".style"), e)) {
return false;
}
@@ -3320,7 +3320,7 @@ void STSStyle::mod_CopyStyleFrom(STSStyle& s) STSStyle STSStyle::operator = (const STSStyle& s)
{
- if(this != &s) {
+ if (this != &s) {
mod_CopyStyleFrom(s);
}
return *this;
@@ -3395,7 +3395,7 @@ STSStyle& operator <<= (STSStyle& s, CString& style) try {
CStringW str = TToW(style);
- if(str.Find(';')>=0) {
+ if (str.Find(';')>=0) {
s.marginRect.left = GetInt(str, ';');
s.marginRect.right = GetInt(str, ';');
s.marginRect.top = GetInt(str, ';');
@@ -3406,10 +3406,10 @@ STSStyle& operator <<= (STSStyle& s, CString& style) s.outlineWidthY = GetFloat(str, ';');
s.shadowDepthX = GetFloat(str, ';');
s.shadowDepthY = GetFloat(str, ';');
- for(ptrdiff_t i = 0; i < 4; i++) {
+ for (ptrdiff_t i = 0; i < 4; i++) {
s.colors[i] = (COLORREF)GetInt(str, ';');
}
- for(ptrdiff_t i = 0; i < 4; i++) {
+ for (ptrdiff_t i = 0; i < 4; i++) {
s.alpha[i] = GetInt(str, ';');
}
s.charSet = GetInt(str, ';');
@@ -3429,7 +3429,7 @@ STSStyle& operator <<= (STSStyle& s, CString& style) s.fontAngleY = GetFloat(str, ';');
s.relativeTo = GetInt(str, ';');
}
- } catch(...) {
+ } catch (...) {
s.SetDefault();
}
@@ -3441,9 +3441,9 @@ static bool OpenRealText(CTextFile* file, CSimpleTextSubtitle& ret, int CharSet) wstring szFile;
CStringW buff;
- while(file->ReadString(buff)) {
+ while (file->ReadString(buff)) {
buff.Trim();
- if(buff.IsEmpty()) {
+ if (buff.IsEmpty()) {
continue;
}
@@ -3586,7 +3586,7 @@ bool MOD_PNGIMAGE::processData(png_structp png_ptr) png_set_gray_to_rgb(png_ptr);
}
- png_set_interlace_handling(png_ptr); //int number_of_passes =
+ png_set_interlace_handling(png_ptr); //int number_of_passes =
png_read_update_info(png_ptr, info_ptr);
/* read file */
@@ -3606,7 +3606,7 @@ bool MOD_PNGIMAGE::processData(png_structp png_ptr) bool MOD_PNGIMAGE::initImage(CString m_fn)
{
- if((m_fn==filename)&&(pointer!=NULL)) {
+ if ((m_fn==filename)&&(pointer!=NULL)) {
return true; // already loaded
}
@@ -3644,10 +3644,10 @@ bool MOD_PNGIMAGE::initImage(CString m_fn) bool MOD_PNGIMAGE::initImage(BYTE* data, CString m_fn)
{
- if((m_fn==filename)&&(pointer!=NULL)) {
+ if ((m_fn==filename)&&(pointer!=NULL)) {
return true; // already loaded
}
- if(data == NULL) {
+ if (data == NULL) {
return false; // not loaded
}
@@ -3673,7 +3673,7 @@ bool MOD_PNGIMAGE::initImage(BYTE* data, CString m_fn) void MOD_PNGIMAGE::freeImage()
{
- if(pointer!=NULL) {
+ if (pointer!=NULL) {
delete [] pointer;
}
}
@@ -3752,10 +3752,10 @@ DWORD MOD_GRADIENT::getmixcolor(int tx, int ty, int i) // too slow T.T DWORD colorb = 0;
tx += xoffset;
// gradient
- if(mode[i]==1) {
+ if (mode[i]==1) {
double x = (double)tx/(double)width;
double y = (double)ty/(double)height;
- for(int j=0; j<3; j++) {
+ for (int j=0; j<3; j++) {
colorb |= ((DWORD)(((color[i][0]>>(8*j))&0xff)*(1-x)*y +
((color[i][1]>>(8*j))&0xff)*x*y+
((color[i][2]>>(8*j))&0xff)*(1-y)*(1-x)+
@@ -3769,20 +3769,20 @@ DWORD MOD_GRADIENT::getmixcolor(int tx, int ty, int i) // too slow T.T return colorb;
}
// png background
- if(mode[i]==2) {
+ if (mode[i]==2) {
// unwarp
tx += b_images[i].xoffset;
ty += b_images[i].yoffset;
- while(tx>b_images[i].width-1) {
+ while (tx>b_images[i].width-1) {
tx-=b_images[i].width;
}
- while(ty>b_images[i].height-1) {
+ while (ty>b_images[i].height-1) {
ty-=b_images[i].height;
}
- while(tx<0) {
+ while (tx<0) {
tx+=b_images[i].width;
}
- while(ty<0) {
+ while (ty<0) {
ty+=b_images[i].height;
}
// now tx and ty are valid array indexes
@@ -3798,17 +3798,17 @@ DWORD MOD_GRADIENT::getmixcolor(int tx, int ty, int i) // too slow T.T BYTE b = dst11[2];
BYTE a = (b_images[i].bpp==4) ? dst11[3] : 0xFF;
// subpixel positioning
- if(nlastpixx&&!nlastpixy) { // last row
+ if (nlastpixx&&!nlastpixy) { // last row
r = (r*(8-subpixx)+dst12[0]*subpixx)>>3;
g = (g*(8-subpixx)+dst12[1]*subpixx)>>3;
b = (b*(8-subpixx)+dst12[2]*subpixx)>>3;
a = (b_images[i].bpp==4) ? (a*(8-subpixx)+dst12[3]*subpixx)>>3 : 0xFF;
- } else if(nlastpixy&&!nlastpixx) { // last col
+ } else if (nlastpixy&&!nlastpixx) { // last col
r = (r*(subpixy)+dst21[0]*(8-subpixy))>>3;
g = (g*(subpixy)+dst21[1]*(8-subpixy))>>3;
b = (b*(subpixy)+dst21[2]*(8-subpixy))>>3;
a = (b_images[i].bpp==4) ? (a*(subpixy)+dst21[3]*(8-subpixy))>>3 : 0xFF;
- } else if(nlastpixy&&nlastpixx) {
+ } else if (nlastpixy&&nlastpixx) {
// T.T
r = (((dst21[0]*(8-subpixx)+dst22[0]*subpixx)>>3)*(subpixy)+((r*(8-subpixx)+dst12[0]*subpixx)>>3)*(8-subpixy))>>3;
g = (((dst21[1]*(8-subpixx)+dst22[1]*subpixx)>>3)*(subpixy)+((g*(8-subpixx)+dst12[1]*subpixx)>>3)*(8-subpixy))>>3;
@@ -3872,7 +3872,7 @@ CPoint MOD_JITTER::getOffset(REFERENCE_TIME rt) if (!enabled) {
return CPoint(0,0);
}
- if(period==0) {
+ if (period==0) {
period = 1;
}
int rseed = (seed + rt / period)*100;
diff --git a/src/Subtitles/STS.h b/src/Subtitles/STS.h index ec62dfa40..9ba713aa6 100644 --- a/src/Subtitles/STS.h +++ b/src/Subtitles/STS.h @@ -244,7 +244,7 @@ public: *this = stss;
}
STSSegment& operator = (const STSSegment& stss) {
- if(this != &stss) {
+ if (this != &stss) {
start = stss.start;
end = stss.end;
subs.Copy(stss.subs);
diff --git a/src/Subtitles/SeparableFilter.h b/src/Subtitles/SeparableFilter.h index 49327c7a5..9b0e1cd21 100644 --- a/src/Subtitles/SeparableFilter.h +++ b/src/Subtitles/SeparableFilter.h @@ -1,141 +1,141 @@ -/* - Copyright 2007 Niels Martin Hansen - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License along - with this program; if not, write to the Free Software Foundation, Inc., - 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - - Contact: - E-mail: <jiifurusu@gmail.com> - IRC: jfs in #aegisub on irc.rizon.net - - */ - -#pragma once - -#ifdef _OPENMP -#include <omp.h> -#endif -#include <math.h> - - -// Filter an image in horizontal direction with a one-dimensional filter -// PixelWidth is the distance in bytes between pixels -template<ptrdiff_t PixelDist> -void SeparableFilterX(unsigned char *src, unsigned char *dst, int width, int height, ptrdiff_t stride, int *kernel, int kernel_size, int divisor) -{ - #pragma omp parallel for - for (int y = 0; y < height; y++) { - unsigned char *in = src + y*stride; - unsigned char *out = dst + y*stride; - for (int x = 0; x < width; x++) { - int accum = 0; - for (int k = 0; k < kernel_size; k++) { - int xofs = k - kernel_size/2; - if (x+xofs < 0) { - xofs += width; - } - if (x+xofs >= width) { - xofs -= width; - } - accum += (int)(in[xofs*PixelDist] * kernel[k]); - } - accum /= divisor; - if (accum > 255) { - accum = 255; - } - if (accum < 0) { - accum = 0; - } - *out = (unsigned char)accum; - in+=PixelDist; - out+=PixelDist; - } - } -} - - -// Filter an image in vertical direction with a one-dimensional filter -// This one templated with PixelWidth since the channel interlacing is horizontal only, -// filtering once vertically will automatically catch all channels. -// (Width must be multiplied by pixel width for that to happen though.) -template<ptrdiff_t PixelDist> -void SeparableFilterY(unsigned char *src, unsigned char *dst, int width, int height, ptrdiff_t stride, int *kernel, int kernel_size, int divisor) -{ - width *= PixelDist; - #pragma omp parallel for - for (int x = 0; x < width; x+=PixelDist) { - unsigned char *in = src + x; - unsigned char *out = dst + x; - for (int y = 0; y < height; y++) { - int accum = 0; - for (int k = 0; k < kernel_size; k++) { - int yofs = k - kernel_size/2; - if (y+yofs < 0) { - yofs += height; - } - if (y+yofs >= height) { - yofs -= height; - } - accum += (int)(in[yofs*stride] * kernel[k]); - } - accum /= divisor; - if (accum > 255) { - accum = 255; - } - if (accum < 0) { - accum = 0; - } - *out = (unsigned char)accum; - in += stride; - out += stride; - } - } -} - - -static inline double NormalDist(double sigma, double x) -{ - if (sigma <= 0 && x == 0) { - return 1; - } else if (sigma <= 0) { - return 0; - } else { - return exp(-(x*x)/(2*sigma*sigma)) / (sigma * sqrt(2*3.1415926535)); - } -} - - -struct GaussianKernel { - int *kernel; - int width; - int divisor; - inline GaussianKernel(double sigma) { - width = (int)(sigma*3 + 0.5) | 1; // binary-or with 1 to make sure the number is odd - if (width < 3) { - width = 3; - } - kernel = DNew int[width]; - kernel[width/2] = (int)(NormalDist(sigma, 0) * 255); - divisor = kernel[width/2]; - for (int x = width/2-1; x >= 0; x--) { - int val = (int)(NormalDist(sigma, width/2-x) * 255 + 0.5); - divisor += val*2; - kernel[x] = val; - kernel[width - x - 1] = val; - } - } - inline ~GaussianKernel() { - delete[] kernel; - } -}; +/*
+ Copyright 2007 Niels Martin Hansen
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License along
+ with this program; if not, write to the Free Software Foundation, Inc.,
+ 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+
+ Contact:
+ E-mail: <jiifurusu@gmail.com>
+ IRC: jfs in #aegisub on irc.rizon.net
+
+ */
+
+#pragma once
+
+#ifdef _OPENMP
+#include <omp.h>
+#endif
+#include <math.h>
+
+
+// Filter an image in horizontal direction with a one-dimensional filter
+// PixelWidth is the distance in bytes between pixels
+template<ptrdiff_t PixelDist>
+void SeparableFilterX(unsigned char *src, unsigned char *dst, int width, int height, ptrdiff_t stride, int *kernel, int kernel_size, int divisor)
+{
+ #pragma omp parallel for
+ for (int y = 0; y < height; y++) {
+ unsigned char *in = src + y*stride;
+ unsigned char *out = dst + y*stride;
+ for (int x = 0; x < width; x++) {
+ int accum = 0;
+ for (int k = 0; k < kernel_size; k++) {
+ int xofs = k - kernel_size/2;
+ if (x+xofs < 0) {
+ xofs += width;
+ }
+ if (x+xofs >= width) {
+ xofs -= width;
+ }
+ accum += (int)(in[xofs*PixelDist] * kernel[k]);
+ }
+ accum /= divisor;
+ if (accum > 255) {
+ accum = 255;
+ }
+ if (accum < 0) {
+ accum = 0;
+ }
+ *out = (unsigned char)accum;
+ in+=PixelDist;
+ out+=PixelDist;
+ }
+ }
+}
+
+
+// Filter an image in vertical direction with a one-dimensional filter
+// This one templated with PixelWidth since the channel interlacing is horizontal only,
+// filtering once vertically will automatically catch all channels.
+// (Width must be multiplied by pixel width for that to happen though.)
+template<ptrdiff_t PixelDist>
+void SeparableFilterY(unsigned char *src, unsigned char *dst, int width, int height, ptrdiff_t stride, int *kernel, int kernel_size, int divisor)
+{
+ width *= PixelDist;
+ #pragma omp parallel for
+ for (int x = 0; x < width; x+=PixelDist) {
+ unsigned char *in = src + x;
+ unsigned char *out = dst + x;
+ for (int y = 0; y < height; y++) {
+ int accum = 0;
+ for (int k = 0; k < kernel_size; k++) {
+ int yofs = k - kernel_size/2;
+ if (y+yofs < 0) {
+ yofs += height;
+ }
+ if (y+yofs >= height) {
+ yofs -= height;
+ }
+ accum += (int)(in[yofs*stride] * kernel[k]);
+ }
+ accum /= divisor;
+ if (accum > 255) {
+ accum = 255;
+ }
+ if (accum < 0) {
+ accum = 0;
+ }
+ *out = (unsigned char)accum;
+ in += stride;
+ out += stride;
+ }
+ }
+}
+
+
+static inline double NormalDist(double sigma, double x)
+{
+ if (sigma <= 0 && x == 0) {
+ return 1;
+ } else if (sigma <= 0) {
+ return 0;
+ } else {
+ return exp(-(x*x)/(2*sigma*sigma)) / (sigma * sqrt(2*3.1415926535));
+ }
+}
+
+
+struct GaussianKernel {
+ int *kernel;
+ int width;
+ int divisor;
+ inline GaussianKernel(double sigma) {
+ width = (int)(sigma*3 + 0.5) | 1; // binary-or with 1 to make sure the number is odd
+ if (width < 3) {
+ width = 3;
+ }
+ kernel = DNew int[width];
+ kernel[width/2] = (int)(NormalDist(sigma, 0) * 255);
+ divisor = kernel[width/2];
+ for (int x = width/2-1; x >= 0; x--) {
+ int val = (int)(NormalDist(sigma, width/2-x) * 255 + 0.5);
+ divisor += val*2;
+ kernel[x] = val;
+ kernel[width - x - 1] = val;
+ }
+ }
+ inline ~GaussianKernel() {
+ delete[] kernel;
+ }
+};
diff --git a/src/Subtitles/SubtitleInputPin.cpp b/src/Subtitles/SubtitleInputPin.cpp index 6f764aad2..b45d8819d 100644 --- a/src/Subtitles/SubtitleInputPin.cpp +++ b/src/Subtitles/SubtitleInputPin.cpp @@ -73,15 +73,15 @@ HRESULT CSubtitleInputPin::CheckMediaType(const CMediaType* pmt) HRESULT CSubtitleInputPin::CompleteConnect(IPin* pReceivePin)
{
- if(m_mt.majortype == MEDIATYPE_Text) {
- if(!(m_pSubStream = DNew CRenderedTextSubtitle(m_pSubLock))) {
+ if (m_mt.majortype == MEDIATYPE_Text) {
+ if (!(m_pSubStream = DNew CRenderedTextSubtitle(m_pSubLock))) {
return E_FAIL;
}
CRenderedTextSubtitle* pRTS = (CRenderedTextSubtitle*)(ISubStream*)m_pSubStream;
pRTS->m_name = CString(GetPinName(pReceivePin)) + _T(" (embeded)");
pRTS->m_dstScreenSize = CSize(384, 288);
pRTS->CreateDefaultStyle(DEFAULT_CHARSET);
- } else if(m_mt.majortype == MEDIATYPE_Subtitle) {
+ } else if (m_mt.majortype == MEDIATYPE_Subtitle) {
SUBTITLEINFO* psi = (SUBTITLEINFO*)m_mt.pbFormat;
DWORD dwOffset = 0;
CString name;
@@ -93,10 +93,10 @@ HRESULT CSubtitleInputPin::CompleteConnect(IPin* pReceivePin) name = ISO6392ToLanguage(psi->IsoLang);
lcid = ISO6392ToLcid(psi->IsoLang);
- if(wcslen(psi->TrackName) > 0) {
+ if (wcslen(psi->TrackName) > 0) {
name += (!name.IsEmpty() ? _T(", ") : _T("")) + CString(psi->TrackName);
}
- if(name.IsEmpty()) {
+ if (name.IsEmpty()) {
name = _T("Unknown");
}
}
@@ -104,12 +104,12 @@ HRESULT CSubtitleInputPin::CompleteConnect(IPin* pReceivePin) name.Replace(_T(""), _T(""));
name.Replace(_T(""), _T(""));
- if(m_mt.subtype == MEDIASUBTYPE_UTF8
+ if (m_mt.subtype == MEDIASUBTYPE_UTF8
/*|| m_mt.subtype == MEDIASUBTYPE_USF*/
|| m_mt.subtype == MEDIASUBTYPE_SSA
|| m_mt.subtype == MEDIASUBTYPE_ASS
|| m_mt.subtype == MEDIASUBTYPE_ASS2) {
- if(!(m_pSubStream = DNew CRenderedTextSubtitle(m_pSubLock))) {
+ if (!(m_pSubStream = DNew CRenderedTextSubtitle(m_pSubLock))) {
return E_FAIL;
}
CRenderedTextSubtitle* pRTS = (CRenderedTextSubtitle*)(ISubStream*)m_pSubStream;
@@ -118,9 +118,9 @@ HRESULT CSubtitleInputPin::CompleteConnect(IPin* pReceivePin) pRTS->m_dstScreenSize = CSize(384, 288);
pRTS->CreateDefaultStyle(DEFAULT_CHARSET);
- if(dwOffset > 0 && m_mt.cbFormat - dwOffset > 0) {
+ if (dwOffset > 0 && m_mt.cbFormat - dwOffset > 0) {
CMediaType mt = m_mt;
- if(mt.pbFormat[dwOffset+0] != 0xef
+ if (mt.pbFormat[dwOffset+0] != 0xef
&& mt.pbFormat[dwOffset+1] != 0xbb
&& mt.pbFormat[dwOffset+2] != 0xfb) {
dwOffset -= 3;
@@ -132,20 +132,20 @@ HRESULT CSubtitleInputPin::CompleteConnect(IPin* pReceivePin) pRTS->Open(mt.pbFormat + dwOffset, mt.cbFormat - dwOffset, DEFAULT_CHARSET, pRTS->m_name);
}
- } else if(m_mt.subtype == MEDIASUBTYPE_SSF) {
- if(!(m_pSubStream = DNew ssf::CRenderer(m_pSubLock))) {
+ } else if (m_mt.subtype == MEDIASUBTYPE_SSF) {
+ if (!(m_pSubStream = DNew ssf::CRenderer(m_pSubLock))) {
return E_FAIL;
}
ssf::CRenderer* pSSF = (ssf::CRenderer*)(ISubStream*)m_pSubStream;
pSSF->Open(ssf::MemoryInputStream(m_mt.pbFormat + dwOffset, m_mt.cbFormat - dwOffset, false, false), name);
- } else if(m_mt.subtype == MEDIASUBTYPE_VOBSUB) {
- if(!(m_pSubStream = DNew CVobSubStream(m_pSubLock))) {
+ } else if (m_mt.subtype == MEDIASUBTYPE_VOBSUB) {
+ if (!(m_pSubStream = DNew CVobSubStream(m_pSubLock))) {
return E_FAIL;
}
CVobSubStream* pVSS = (CVobSubStream*)(ISubStream*)m_pSubStream;
pVSS->Open(name, m_mt.pbFormat + dwOffset, m_mt.cbFormat - dwOffset);
} else if (IsHdmvSub(&m_mt)) {
- if(!(m_pSubStream = DNew CRenderedHdmvSubtitle(m_pSubLock, (m_mt.subtype == MEDIASUBTYPE_DVB_SUBTITLES) ? ST_DVB : ST_HDMV, name, lcid))) {
+ if (!(m_pSubStream = DNew CRenderedHdmvSubtitle(m_pSubLock, (m_mt.subtype == MEDIASUBTYPE_DVB_SUBTITLES) ? ST_DVB : ST_HDMV, name, lcid))) {
return E_FAIL;
}
}
@@ -168,7 +168,7 @@ HRESULT CSubtitleInputPin::BreakConnect() STDMETHODIMP CSubtitleInputPin::ReceiveConnection(IPin* pConnector, const AM_MEDIA_TYPE* pmt)
{
- if(m_Connected) {
+ if (m_Connected) {
RemoveSubStream(m_pSubStream);
m_pSubStream = NULL;
@@ -183,7 +183,7 @@ STDMETHODIMP CSubtitleInputPin::NewSegment(REFERENCE_TIME tStart, REFERENCE_TIME {
CAutoLock cAutoLock(&m_csReceive);
- if(m_mt.majortype == MEDIATYPE_Text
+ if (m_mt.majortype == MEDIATYPE_Text
|| m_mt.majortype == MEDIATYPE_Subtitle
&& (m_mt.subtype == MEDIASUBTYPE_UTF8
/*|| m_mt.subtype == MEDIASUBTYPE_USF*/
@@ -194,14 +194,14 @@ STDMETHODIMP CSubtitleInputPin::NewSegment(REFERENCE_TIME tStart, REFERENCE_TIME CRenderedTextSubtitle* pRTS = (CRenderedTextSubtitle*)(ISubStream*)m_pSubStream;
pRTS->RemoveAll();
pRTS->CreateSegments();
- } else if(m_mt.majortype == MEDIATYPE_Subtitle && m_mt.subtype == MEDIASUBTYPE_SSF) {
+ } else if (m_mt.majortype == MEDIATYPE_Subtitle && m_mt.subtype == MEDIASUBTYPE_SSF) {
CAutoLock cAutoLock(m_pSubLock);
ssf::CRenderer* pSSF = (ssf::CRenderer*)(ISubStream*)m_pSubStream;
// LAME, implement RemoveSubtitles
DWORD dwOffset = ((SUBTITLEINFO*)m_mt.pbFormat)->dwOffset;
pSSF->Open(ssf::MemoryInputStream(m_mt.pbFormat + dwOffset, m_mt.cbFormat - dwOffset, false, false), _T(""));
// pSSF->RemoveSubtitles();
- } else if(m_mt.majortype == MEDIATYPE_Subtitle && (m_mt.subtype == MEDIASUBTYPE_VOBSUB)) {
+ } else if (m_mt.majortype == MEDIATYPE_Subtitle && (m_mt.subtype == MEDIASUBTYPE_VOBSUB)) {
CAutoLock cAutoLock(m_pSubLock);
CVobSubStream* pVSS = (CVobSubStream*)(ISubStream*)m_pSubStream;
pVSS->RemoveAll();
@@ -226,7 +226,7 @@ STDMETHODIMP CSubtitleInputPin::Receive(IMediaSample* pSample) HRESULT hr;
hr = __super::Receive(pSample);
- if(FAILED(hr)) {
+ if (FAILED(hr)) {
return hr;
}
@@ -239,7 +239,7 @@ STDMETHODIMP CSubtitleInputPin::Receive(IMediaSample* pSample) BYTE* pData = NULL;
hr = pSample->GetPointer(&pData);
- if(FAILED(hr) || pData == NULL) {
+ if (FAILED(hr) || pData == NULL) {
return hr;
}
@@ -247,87 +247,87 @@ STDMETHODIMP CSubtitleInputPin::Receive(IMediaSample* pSample) bool fInvalidate = false;
- if(m_mt.majortype == MEDIATYPE_Text) {
+ if (m_mt.majortype == MEDIATYPE_Text) {
CAutoLock cAutoLock(m_pSubLock);
CRenderedTextSubtitle* pRTS = (CRenderedTextSubtitle*)(ISubStream*)m_pSubStream;
- if(!strncmp((char*)pData, __GAB1__, strlen(__GAB1__))) {
+ if (!strncmp((char*)pData, __GAB1__, strlen(__GAB1__))) {
char* ptr = (char*)&pData[strlen(__GAB1__)+1];
char* end = (char*)&pData[len];
- while(ptr < end) {
+ while (ptr < end) {
WORD tag = *((WORD*)(ptr));
ptr += 2;
WORD size = *((WORD*)(ptr));
ptr += 2;
- if(tag == __GAB1_LANGUAGE__) {
+ if (tag == __GAB1_LANGUAGE__) {
pRTS->m_name = CString(ptr);
- } else if(tag == __GAB1_ENTRY__) {
+ } else if (tag == __GAB1_ENTRY__) {
pRTS->Add(AToW(&ptr[8]), false, *(int*)ptr, *(int*)(ptr+4));
fInvalidate = true;
- } else if(tag == __GAB1_LANGUAGE_UNICODE__) {
+ } else if (tag == __GAB1_LANGUAGE_UNICODE__) {
pRTS->m_name = (WCHAR*)ptr;
- } else if(tag == __GAB1_ENTRY_UNICODE__) {
+ } else if (tag == __GAB1_ENTRY_UNICODE__) {
pRTS->Add((WCHAR*)(ptr+8), true, *(int*)ptr, *(int*)(ptr+4));
fInvalidate = true;
}
ptr += size;
}
- } else if(!strncmp((char*)pData, __GAB2__, strlen(__GAB2__))) {
+ } else if (!strncmp((char*)pData, __GAB2__, strlen(__GAB2__))) {
char* ptr = (char*)&pData[strlen(__GAB2__)+1];
char* end = (char*)&pData[len];
- while(ptr < end) {
+ while (ptr < end) {
WORD tag = *((WORD*)(ptr));
ptr += 2;
DWORD size = *((DWORD*)(ptr));
ptr += 4;
- if(tag == __GAB1_LANGUAGE_UNICODE__) {
+ if (tag == __GAB1_LANGUAGE_UNICODE__) {
pRTS->m_name = (WCHAR*)ptr;
- } else if(tag == __GAB1_RAWTEXTSUBTITLE__) {
+ } else if (tag == __GAB1_RAWTEXTSUBTITLE__) {
pRTS->Open((BYTE*)ptr, size, DEFAULT_CHARSET, pRTS->m_name);
fInvalidate = true;
}
ptr += size;
}
- } else if(pData != 0 && len > 1 && *pData != 0) {
+ } else if (pData != 0 && len > 1 && *pData != 0) {
CStringA str((char*)pData, len);
str.Replace("\r\n", "\n");
str.Trim();
- if(!str.IsEmpty()) {
+ if (!str.IsEmpty()) {
pRTS->Add(AToW(str), false, (int)(tStart / 10000), (int)(tStop / 10000));
fInvalidate = true;
}
}
- } else if(m_mt.majortype == MEDIATYPE_Subtitle) {
+ } else if (m_mt.majortype == MEDIATYPE_Subtitle) {
CAutoLock cAutoLock(m_pSubLock);
- if(m_mt.subtype == MEDIASUBTYPE_UTF8) {
+ if (m_mt.subtype == MEDIASUBTYPE_UTF8) {
CRenderedTextSubtitle* pRTS = (CRenderedTextSubtitle*)(ISubStream*)m_pSubStream;
CStringW str = UTF8To16(CStringA((LPCSTR)pData, len)).Trim();
- if(!str.IsEmpty()) {
+ if (!str.IsEmpty()) {
pRTS->Add(str, true, (int)(tStart / 10000), (int)(tStop / 10000));
fInvalidate = true;
}
- } else if(m_mt.subtype == MEDIASUBTYPE_SSA || m_mt.subtype == MEDIASUBTYPE_ASS || m_mt.subtype == MEDIASUBTYPE_ASS2) {
+ } else if (m_mt.subtype == MEDIASUBTYPE_SSA || m_mt.subtype == MEDIASUBTYPE_ASS || m_mt.subtype == MEDIASUBTYPE_ASS2) {
CRenderedTextSubtitle* pRTS = (CRenderedTextSubtitle*)(ISubStream*)m_pSubStream;
CStringW str = UTF8To16(CStringA((LPCSTR)pData, len)).Trim();
- if(!str.IsEmpty()) {
+ if (!str.IsEmpty()) {
STSEntry stse;
int fields = m_mt.subtype == MEDIASUBTYPE_ASS2 ? 10 : 9;
CAtlList<CStringW> sl;
Explode(str, sl, ',', fields);
- if(sl.GetCount() == (size_t)fields) {
+ if (sl.GetCount() == (size_t)fields) {
stse.readorder = wcstol(sl.RemoveHead(), NULL, 10);
stse.layer = wcstol(sl.RemoveHead(), NULL, 10);
stse.style = sl.RemoveHead();
@@ -335,28 +335,28 @@ STDMETHODIMP CSubtitleInputPin::Receive(IMediaSample* pSample) stse.marginRect.left = wcstol(sl.RemoveHead(), NULL, 10);
stse.marginRect.right = wcstol(sl.RemoveHead(), NULL, 10);
stse.marginRect.top = stse.marginRect.bottom = wcstol(sl.RemoveHead(), NULL, 10);
- if(fields == 10) {
+ if (fields == 10) {
stse.marginRect.bottom = wcstol(sl.RemoveHead(), NULL, 10);
}
stse.effect = sl.RemoveHead();
stse.str = sl.RemoveHead();
}
- if(!stse.str.IsEmpty()) {
+ if (!stse.str.IsEmpty()) {
pRTS->Add(stse.str, true, (int)(tStart / 10000), (int)(tStop / 10000),
stse.style, stse.actor, stse.effect, stse.marginRect, stse.layer, stse.readorder);
fInvalidate = true;
}
}
- } else if(m_mt.subtype == MEDIASUBTYPE_SSF) {
+ } else if (m_mt.subtype == MEDIASUBTYPE_SSF) {
ssf::CRenderer* pSSF = (ssf::CRenderer*)(ISubStream*)m_pSubStream;
CStringW str = UTF8To16(CStringA((LPCSTR)pData, len)).Trim();
- if(!str.IsEmpty()) {
+ if (!str.IsEmpty()) {
pSSF->Append(tStart, tStop, str);
fInvalidate = true;
}
- } else if(m_mt.subtype == MEDIASUBTYPE_VOBSUB) {
+ } else if (m_mt.subtype == MEDIASUBTYPE_VOBSUB) {
CVobSubStream* pVSS = (CVobSubStream*)(ISubStream*)m_pSubStream;
pVSS->Add(tStart, tStop, pData, len);
} else if (IsHdmvSub(&m_mt)) {
@@ -366,7 +366,7 @@ STDMETHODIMP CSubtitleInputPin::Receive(IMediaSample* pSample) }
}
- if(fInvalidate) {
+ if (fInvalidate) {
TRACE(_T("InvalidateSubtitle(%I64d, ..)\n"), tStart);
// IMPORTANT: m_pSubLock must not be locked when calling this
InvalidateSubtitle(tStart, m_pSubStream);
diff --git a/src/Subtitles/TextFile.cpp b/src/Subtitles/TextFile.cpp index 864e1e8d8..629b2791c 100644 --- a/src/Subtitles/TextFile.cpp +++ b/src/Subtitles/TextFile.cpp @@ -34,41 +34,41 @@ CTextFile::CTextFile(enc e) bool CTextFile::Open(LPCTSTR lpszFileName)
{
- if(!__super::Open(lpszFileName, modeRead|typeBinary|shareDenyNone)) {
+ if (!__super::Open(lpszFileName, modeRead|typeBinary|shareDenyNone)) {
return false;
}
m_encoding = m_defaultencoding;
m_offset = 0;
- if(__super::GetLength() >= 2) {
+ if (__super::GetLength() >= 2) {
WORD w;
- if(sizeof(w) != Read(&w, sizeof(w))) {
+ if (sizeof(w) != Read(&w, sizeof(w))) {
return Close(), false;
}
- if(w == 0xfeff) {
+ if (w == 0xfeff) {
m_encoding = LE16;
m_offset = 2;
- } else if(w == 0xfffe) {
+ } else if (w == 0xfffe) {
m_encoding = BE16;
m_offset = 2;
- } else if(w == 0xbbef && __super::GetLength() >= 3) {
+ } else if (w == 0xbbef && __super::GetLength() >= 3) {
BYTE b;
- if(sizeof(b) != Read(&b, sizeof(b))) {
+ if (sizeof(b) != Read(&b, sizeof(b))) {
return Close(), false;
}
- if(b == 0xbf) {
+ if (b == 0xbf) {
m_encoding = UTF8;
m_offset = 3;
}
}
}
- if(m_encoding == m_defaultencoding) {
+ if (m_encoding == m_defaultencoding) {
__super::Close(); // CWebTextFile::Close() would delete the temp file if we called it...
- if(!__super::Open(lpszFileName, modeRead|typeText|shareDenyNone)) {
+ if (!__super::Open(lpszFileName, modeRead|typeText|shareDenyNone)) {
return false;
}
}
@@ -78,17 +78,17 @@ bool CTextFile::Open(LPCTSTR lpszFileName) bool CTextFile::Save(LPCTSTR lpszFileName, enc e)
{
- if(!__super::Open(lpszFileName, modeCreate|modeWrite|shareDenyWrite|(e==ASCII?typeText:typeBinary))) {
+ if (!__super::Open(lpszFileName, modeCreate|modeWrite|shareDenyWrite|(e==ASCII?typeText:typeBinary))) {
return false;
}
- if(e == UTF8) {
+ if (e == UTF8) {
BYTE b[3] = {0xef,0xbb,0xbf};
Write(b, sizeof(b));
- } else if(e == LE16) {
+ } else if (e == LE16) {
BYTE b[2] = {0xff,0xfe};
Write(b, sizeof(b));
- } else if(e == BE16) {
+ } else if (e == BE16) {
BYTE b[2] = {0xfe,0xff};
Write(b, sizeof(b));
}
@@ -138,7 +138,7 @@ ULONGLONG CTextFile::Seek(LONGLONG lOff, UINT nFrom) ULONGLONG pos = GetPosition();
ULONGLONG len = GetLength();
- switch(nFrom) {
+ switch (nFrom) {
default:
case begin:
break;
@@ -161,16 +161,16 @@ void CTextFile::WriteString(LPCSTR lpsz/*CStringA str*/) {
CStringA str(lpsz);
- if(m_encoding == ASCII) {
+ if (m_encoding == ASCII) {
__super::WriteString(AToT(str));
- } else if(m_encoding == ANSI) {
+ } else if (m_encoding == ANSI) {
str.Replace("\n", "\r\n");
Write((LPCSTR)str, str.GetLength());
- } else if(m_encoding == UTF8) {
+ } else if (m_encoding == UTF8) {
WriteString(AToW(str));
- } else if(m_encoding == LE16) {
+ } else if (m_encoding == LE16) {
WriteString(AToW(str));
- } else if(m_encoding == BE16) {
+ } else if (m_encoding == BE16) {
WriteString(AToW(str));
}
}
@@ -179,24 +179,24 @@ void CTextFile::WriteString(LPCWSTR lpsz/*CStringW str*/) {
CStringW str(lpsz);
- if(m_encoding == ASCII) {
+ if (m_encoding == ASCII) {
__super::WriteString(WToT(str));
- } else if(m_encoding == ANSI) {
+ } else if (m_encoding == ANSI) {
str.Replace(L"\n", L"\r\n");
CStringA stra = CStringA(CString(str)); // TODO: codepage
Write((LPCSTR)stra, stra.GetLength());
- } else if(m_encoding == UTF8) {
+ } else if (m_encoding == UTF8) {
str.Replace(L"\n", L"\r\n");
- for(int i = 0; i < str.GetLength(); i++) {
+ for (int i = 0; i < str.GetLength(); i++) {
DWORD c = (WORD)str[i];
- if(0 <= c && c < 0x80) { // 0xxxxxxx
+ if (0 <= c && c < 0x80) { // 0xxxxxxx
Write(&c, 1);
- } else if(0x80 <= c && c < 0x800) { // 110xxxxx 10xxxxxx
+ } else if (0x80 <= c && c < 0x800) { // 110xxxxx 10xxxxxx
c = 0xc080|((c<<2)&0x1f00)|(c&0x003f);
Write((BYTE*)&c+1, 1);
Write(&c, 1);
- } else if(0x800 <= c && c < 0xFFFF) { // 1110xxxx 10xxxxxx 10xxxxxx
+ } else if (0x800 <= c && c < 0xFFFF) { // 1110xxxx 10xxxxxx 10xxxxxx
c = 0xe08080|((c<<4)&0x0f0000)|((c<<2)&0x3f00)|(c&0x003f);
Write((BYTE*)&c+2, 1);
Write((BYTE*)&c+1, 1);
@@ -206,12 +206,12 @@ void CTextFile::WriteString(LPCWSTR lpsz/*CStringW str*/) Write(&c, 1);
}
}
- } else if(m_encoding == LE16) {
+ } else if (m_encoding == LE16) {
str.Replace(L"\n", L"\r\n");
Write((LPCWSTR)str, str.GetLength()*2);
- } else if(m_encoding == BE16) {
+ } else if (m_encoding == BE16) {
str.Replace(L"\n", L"\r\n");
- for(int i = 0; i < str.GetLength(); i++) {
+ for (int i = 0; i < str.GetLength(); i++) {
str.SetAt(i, ((str[i]>>8)&0x00ff)|((str[i]<<8)&0xff00));
}
Write((LPCWSTR)str, str.GetLength()*2);
@@ -224,77 +224,77 @@ BOOL CTextFile::ReadString(CStringA& str) str.Empty();
- if(m_encoding == ASCII) {
+ if (m_encoding == ASCII) {
CString s;
fEOF = !__super::ReadString(s);
str = TToA(s);
- } else if(m_encoding == ANSI) {
+ } else if (m_encoding == ANSI) {
char c;
- while(Read(&c, sizeof(c)) == sizeof(c)) {
+ while (Read(&c, sizeof(c)) == sizeof(c)) {
fEOF = false;
- if(c == '\r') {
+ if (c == '\r') {
continue;
}
- if(c == '\n') {
+ if (c == '\n') {
break;
}
str += c;
}
- } else if(m_encoding == UTF8) {
+ } else if (m_encoding == UTF8) {
BYTE b;
- while(Read(&b, sizeof(b)) == sizeof(b)) {
+ while (Read(&b, sizeof(b)) == sizeof(b)) {
fEOF = false;
char c = '?';
- if(!(b&0x80)) { // 0xxxxxxx
+ if (!(b&0x80)) { // 0xxxxxxx
c = b&0x7f;
- } else if((b&0xe0) == 0xc0) { // 110xxxxx 10xxxxxx
- if(Read(&b, sizeof(b)) != sizeof(b)) {
+ } else if ((b&0xe0) == 0xc0) { // 110xxxxx 10xxxxxx
+ if (Read(&b, sizeof(b)) != sizeof(b)) {
break;
}
- } else if((b&0xf0) == 0xe0) { // 1110xxxx 10xxxxxx 10xxxxxx
- if(Read(&b, sizeof(b)) != sizeof(b)) {
+ } else if ((b&0xf0) == 0xe0) { // 1110xxxx 10xxxxxx 10xxxxxx
+ if (Read(&b, sizeof(b)) != sizeof(b)) {
break;
}
- if(Read(&b, sizeof(b)) != sizeof(b)) {
+ if (Read(&b, sizeof(b)) != sizeof(b)) {
break;
}
}
- if(c == '\r') {
+ if (c == '\r') {
continue;
}
- if(c == '\n') {
+ if (c == '\n') {
break;
}
str += c;
}
- } else if(m_encoding == LE16) {
+ } else if (m_encoding == LE16) {
WORD w;
- while(Read(&w, sizeof(w)) == sizeof(w)) {
+ while (Read(&w, sizeof(w)) == sizeof(w)) {
fEOF = false;
char c = '?';
- if(!(w&0xff00)) {
+ if (!(w&0xff00)) {
c = w&0xff;
}
- if(c == '\r') {
+ if (c == '\r') {
continue;
}
- if(c == '\n') {
+ if (c == '\n') {
break;
}
str += c;
}
- } else if(m_encoding == BE16) {
+ } else if (m_encoding == BE16) {
WORD w;
- while(Read(&w, sizeof(w)) == sizeof(w)) {
+ while (Read(&w, sizeof(w)) == sizeof(w)) {
fEOF = false;
char c = '?';
- if(!(w&0xff)) {
+ if (!(w&0xff)) {
c = w>>8;
}
- if(c == '\r') {
+ if (c == '\r') {
continue;
}
- if(c == '\n') {
+ if (c == '\n') {
break;
}
str += c;
@@ -310,77 +310,77 @@ BOOL CTextFile::ReadString(CStringW& str) str.Empty();
- if(m_encoding == ASCII) {
+ if (m_encoding == ASCII) {
CString s;
fEOF = !__super::ReadString(s);
str = TToW(s);
- } else if(m_encoding == ANSI) {
+ } else if (m_encoding == ANSI) {
CStringA stra;
char c;
- while(Read(&c, sizeof(c)) == sizeof(c)) {
+ while (Read(&c, sizeof(c)) == sizeof(c)) {
fEOF = false;
- if(c == '\r') {
+ if (c == '\r') {
continue;
}
- if(c == '\n') {
+ if (c == '\n') {
break;
}
stra += c;
}
str = CStringW(CString(stra)); // TODO: codepage
- } else if(m_encoding == UTF8) {
+ } else if (m_encoding == UTF8) {
BYTE b;
- while(Read(&b, sizeof(b)) == sizeof(b)) {
+ while (Read(&b, sizeof(b)) == sizeof(b)) {
fEOF = false;
WCHAR c = '?';
- if(!(b&0x80)) { // 0xxxxxxx
+ if (!(b&0x80)) { // 0xxxxxxx
c = b&0x7f;
- } else if((b&0xe0) == 0xc0) { // 110xxxxx 10xxxxxx
+ } else if ((b&0xe0) == 0xc0) { // 110xxxxx 10xxxxxx
c = (b&0x1f)<<6;
- if(Read(&b, sizeof(b)) != sizeof(b)) {
+ if (Read(&b, sizeof(b)) != sizeof(b)) {
break;
}
c |= (b&0x3f);
- } else if((b&0xf0) == 0xe0) { // 1110xxxx 10xxxxxx 10xxxxxx
+ } else if ((b&0xf0) == 0xe0) { // 1110xxxx 10xxxxxx 10xxxxxx
c = (b&0x0f)<<12;
- if(Read(&b, sizeof(b)) != sizeof(b)) {
+ if (Read(&b, sizeof(b)) != sizeof(b)) {
break;
}
c |= (b&0x3f)<<6;
- if(Read(&b, sizeof(b)) != sizeof(b)) {
+ if (Read(&b, sizeof(b)) != sizeof(b)) {
break;
}
c |= (b&0x3f);
}
- if(c == '\r') {
+ if (c == '\r') {
continue;
}
- if(c == '\n') {
+ if (c == '\n') {
break;
}
str += c;
}
- } else if(m_encoding == LE16) {
+ } else if (m_encoding == LE16) {
WCHAR wc;
- while(Read(&wc, sizeof(wc)) == sizeof(wc)) {
+ while (Read(&wc, sizeof(wc)) == sizeof(wc)) {
fEOF = false;
- if(wc == '\r') {
+ if (wc == '\r') {
continue;
}
- if(wc == '\n') {
+ if (wc == '\n') {
break;
}
str += wc;
}
- } else if(m_encoding == BE16) {
+ } else if (m_encoding == BE16) {
WCHAR wc;
- while(Read(&wc, sizeof(wc)) == sizeof(wc)) {
+ while (Read(&wc, sizeof(wc)) == sizeof(wc)) {
fEOF = false;
wc = ((wc>>8)&0x00ff)|((wc<<8)&0xff00);
- if(wc == '\r') {
+ if (wc == '\r') {
continue;
}
- if(wc == '\n') {
+ if (wc == '\n') {
break;
}
str += wc;
@@ -403,7 +403,7 @@ bool CWebTextFile::Open(LPCTSTR lpszFileName) {
CString fn(lpszFileName);
- if(fn.Find(_T("http://")) != 0) {
+ if (fn.Find(_T("http://")) != 0) {
return __super::Open(lpszFileName);
}
@@ -411,7 +411,7 @@ bool CWebTextFile::Open(LPCTSTR lpszFileName) CInternetSession is;
CAutoPtr<CStdioFile> f(is.OpenURL(fn, 1, INTERNET_FLAG_TRANSFER_BINARY|INTERNET_FLAG_EXISTING_CONNECT));
- if(!f) {
+ if (!f) {
return false;
}
@@ -420,28 +420,28 @@ bool CWebTextFile::Open(LPCTSTR lpszFileName) fn = path + fn.Mid(fn.ReverseFind('/')+1);
int i = fn.Find(_T("?"));
- if(i > 0) {
+ if (i > 0) {
fn = fn.Left(i);
}
CFile temp;
- if(!temp.Open(fn, modeCreate|modeWrite|typeBinary|shareDenyWrite)) {
+ if (!temp.Open(fn, modeCreate|modeWrite|typeBinary|shareDenyWrite)) {
f->Close();
return false;
}
BYTE buff[1024];
int len, total = 0;
- while((len = f->Read(buff, 1024)) == 1024 && (m_llMaxSize < 0 || (total+=1024) < m_llMaxSize)) {
+ while ((len = f->Read(buff, 1024)) == 1024 && (m_llMaxSize < 0 || (total+=1024) < m_llMaxSize)) {
temp.Write(buff, len);
}
- if(len > 0) {
+ if (len > 0) {
temp.Write(buff, len);
}
m_tempfn = fn;
f->Close(); // must close it because the desctructor doesn't seem to do it and we will get an exception when "is" is destroying
- } catch(CInternetException* ie) {
+ } catch (CInternetException* ie) {
ie->Delete();
return false;
}
@@ -460,7 +460,7 @@ void CWebTextFile::Close() {
__super::Close();
- if(!m_tempfn.IsEmpty()) {
+ if (!m_tempfn.IsEmpty()) {
_tremove(m_tempfn);
m_tempfn.Empty();
}
@@ -471,7 +471,7 @@ void CWebTextFile::Close() CStringW AToW(CStringA str)
{
CStringW ret;
- for(size_t i = 0, j = str.GetLength(); i < j; i++) {
+ for (size_t i = 0, j = str.GetLength(); i < j; i++) {
ret += (WCHAR)(BYTE)str[i];
}
return(ret);
@@ -480,7 +480,7 @@ CStringW AToW(CStringA str) CStringA WToA(CStringW str)
{
CStringA ret;
- for(size_t i = 0, j = str.GetLength(); i < j; i++) {
+ for (size_t i = 0, j = str.GetLength(); i < j; i++) {
ret += (CHAR)(WORD)str[i];
}
return(ret);
@@ -489,7 +489,7 @@ CStringA WToA(CStringW str) CString AToT(CStringA str)
{
CString ret;
- for(size_t i = 0, j = str.GetLength(); i < j; i++) {
+ for (size_t i = 0, j = str.GetLength(); i < j; i++) {
ret += (TCHAR)(BYTE)str[i];
}
return(ret);
@@ -498,7 +498,7 @@ CString AToT(CStringA str) CString WToT(CStringW str)
{
CString ret;
- for(size_t i = 0, j = str.GetLength(); i < j; i++) {
+ for (size_t i = 0, j = str.GetLength(); i < j; i++) {
ret += (TCHAR)(WORD)str[i];
}
return(ret);
@@ -508,7 +508,7 @@ CStringA TToA(CString str) {
CStringA ret;
#ifdef UNICODE
- for(size_t i = 0, j = str.GetLength(); i < j; i++) {
+ for (size_t i = 0, j = str.GetLength(); i < j; i++) {
ret += (CHAR)(BYTE)str[i];
}
#else
@@ -523,7 +523,7 @@ CStringW TToW(CString str) #ifdef UNICODE
ret = str;
#else
- for(size_t i = 0, j = str.GetLength(); i < j; i++) {
+ for (size_t i = 0, j = str.GetLength(); i < j; i++) {
ret += (WCHAR)(BYTE)str[i];
}
#endif
diff --git a/src/Subtitles/USFSubtitles.cpp b/src/Subtitles/USFSubtitles.cpp index b778aceae..cf5a1bc0a 100644 --- a/src/Subtitles/USFSubtitles.cpp +++ b/src/Subtitles/USFSubtitles.cpp @@ -64,8 +64,8 @@ static CStringW GetXML(CComPtr<IXMLDOMNode> pNode) CStringW str(bstr);
str.Remove('\r');
str.Replace('\n', ' ');
- for(int i = 0; (i = str.Find(L" ", i)) >= 0; ) {
- for(++i; i < str.GetLength() && (str[i] == ' ');) {
+ for (int i = 0; (i = str.Find(L" ", i)) >= 0; ) {
+ for (++i; i < str.GetLength() && (str[i] == ' ');) {
str.Delete(i);
}
}
@@ -79,7 +79,7 @@ static CStringW GetAttrib(CStringW attrib, CComPtr<IXMLDOMNode> pNode) BeginEnumAttribs(pNode, pChild) {
DeclareNameAndValue(pChild, name, val);
- if(CStringW(name) == attrib && val.vt == VT_BSTR) { // TODO: prepare for other types
+ if (CStringW(name) == attrib && val.vt == VT_BSTR) { // TODO: prepare for other types
ret = val.bstrVal;
break;
}
@@ -93,11 +93,11 @@ static int TimeToInt(CStringW str) {
CAtlList<CStringW> sl;
int i = 0;
- for(CStringW token = str.Tokenize(L":.,", i); !token.IsEmpty(); token = str.Tokenize(L":.,", i)) {
+ for (CStringW token = str.Tokenize(L":.,", i); !token.IsEmpty(); token = str.Tokenize(L":.,", i)) {
sl.AddHead(token);
}
- if(sl.GetCount() > 4) {
+ if (sl.GetCount() > 4) {
return(-1);
}
@@ -105,11 +105,11 @@ static int TimeToInt(CStringW str) int mul[4] = {1,1000,60*1000,60*60*1000};
POSITION pos = sl.GetHeadPosition();
- for(i = 0; pos; i++) {
+ for (i = 0; pos; i++) {
const WCHAR* s = sl.GetNext(pos);
WCHAR* tmp = NULL;
int t = wcstol(s, &tmp, 10);
- if(s >= tmp) {
+ if (s >= tmp) {
return(-1);
}
time += t * mul[i];
@@ -120,10 +120,10 @@ static int TimeToInt(CStringW str) static DWORD StringToDWORD(CStringW str)
{
- if(str.IsEmpty()) {
+ if (str.IsEmpty()) {
return(0);
}
- if(str[0] == '#') {
+ if (str[0] == '#') {
return((DWORD)wcstol(str, NULL, 16));
} else {
return((DWORD)wcstol(str, NULL, 10));
@@ -132,13 +132,13 @@ static DWORD StringToDWORD(CStringW str) static DWORD ColorToDWORD(CStringW str)
{
- if(str.IsEmpty()) {
+ if (str.IsEmpty()) {
return(0);
}
DWORD ret = 0;
- if(str[0] == '#') {
+ if (str[0] == '#') {
ret = (DWORD)wcstol(str.TrimLeft('#'), NULL, 16);
} else {
g_colors.Lookup(CString(str), ret);
@@ -168,9 +168,9 @@ static int TranslateMargin(CStringW margin, int wndsize) {
int ret = 0;
- if(!margin.IsEmpty()) {
+ if (!margin.IsEmpty()) {
ret = wcstol(margin, NULL, 10);
- if(margin.Find('%') >= 0) {
+ if (margin.Find('%') >= 0) {
ret = wndsize * ret / 100;
}
}
@@ -192,7 +192,7 @@ bool CUSFSubtitles::Read(LPCTSTR fn) {
VARIANT_BOOL vb;
CComPtr<IXMLDOMDocument> pDoc;
- if(FAILED(pDoc.CoCreateInstance(CLSID_DOMDocument))
+ if (FAILED(pDoc.CoCreateInstance(CLSID_DOMDocument))
|| FAILED(pDoc->put_async(VARIANT_FALSE))
|| FAILED(pDoc->load(CComVariant(fn), &vb)) || vb != VARIANT_TRUE) {
return false;
@@ -202,84 +202,84 @@ bool CUSFSubtitles::Read(LPCTSTR fn) effects.RemoveAll();
texts.RemoveAll();
- if(!ParseUSFSubtitles(CComQIPtr<IXMLDOMNode>(pDoc))) {
+ if (!ParseUSFSubtitles(CComQIPtr<IXMLDOMNode>(pDoc))) {
return false;
}
POSITION pos = styles.GetHeadPosition();
- while(pos) {
+ while (pos) {
style_t* def = styles.GetNext(pos);
- if(def->name.CompareNoCase(L"Default")) {
+ if (def->name.CompareNoCase(L"Default")) {
continue;
}
POSITION pos2 = styles.GetHeadPosition();
- while(pos2) {
+ while (pos2) {
style_t* s = styles.GetNext(pos2);
- if(!s->name.CompareNoCase(L"Default")) {
+ if (!s->name.CompareNoCase(L"Default")) {
continue;
}
- if(s->fontstyle.face.IsEmpty()) {
+ if (s->fontstyle.face.IsEmpty()) {
s->fontstyle.face = def->fontstyle.face;
}
- if(s->fontstyle.size.IsEmpty()) {
+ if (s->fontstyle.size.IsEmpty()) {
s->fontstyle.size = def->fontstyle.size;
}
- if(s->fontstyle.color[0].IsEmpty()) {
+ if (s->fontstyle.color[0].IsEmpty()) {
s->fontstyle.color[0] = def->fontstyle.color[0];
}
- if(s->fontstyle.color[1].IsEmpty()) {
+ if (s->fontstyle.color[1].IsEmpty()) {
s->fontstyle.color[1] = def->fontstyle.color[1];
}
- if(s->fontstyle.color[2].IsEmpty()) {
+ if (s->fontstyle.color[2].IsEmpty()) {
s->fontstyle.color[2] = def->fontstyle.color[2];
}
- if(s->fontstyle.color[3].IsEmpty()) {
+ if (s->fontstyle.color[3].IsEmpty()) {
s->fontstyle.color[3] = def->fontstyle.color[3];
}
- if(s->fontstyle.italic.IsEmpty()) {
+ if (s->fontstyle.italic.IsEmpty()) {
s->fontstyle.italic = def->fontstyle.italic;
}
- if(s->fontstyle.weight.IsEmpty()) {
+ if (s->fontstyle.weight.IsEmpty()) {
s->fontstyle.weight = def->fontstyle.weight;
}
- if(s->fontstyle.underline.IsEmpty()) {
+ if (s->fontstyle.underline.IsEmpty()) {
s->fontstyle.underline = def->fontstyle.underline;
}
- if(s->fontstyle.alpha.IsEmpty()) {
+ if (s->fontstyle.alpha.IsEmpty()) {
s->fontstyle.alpha = def->fontstyle.alpha;
}
- if(s->fontstyle.outline.IsEmpty()) {
+ if (s->fontstyle.outline.IsEmpty()) {
s->fontstyle.outline = def->fontstyle.outline;
}
- if(s->fontstyle.shadow.IsEmpty()) {
+ if (s->fontstyle.shadow.IsEmpty()) {
s->fontstyle.shadow = def->fontstyle.shadow;
}
- if(s->fontstyle.wrap.IsEmpty()) {
+ if (s->fontstyle.wrap.IsEmpty()) {
s->fontstyle.wrap = def->fontstyle.wrap;
}
- if(s->pal.alignment.IsEmpty()) {
+ if (s->pal.alignment.IsEmpty()) {
s->pal.alignment = def->pal.alignment;
}
- if(s->pal.relativeto.IsEmpty()) {
+ if (s->pal.relativeto.IsEmpty()) {
s->pal.relativeto = def->pal.relativeto;
}
- if(s->pal.horizontal_margin.IsEmpty()) {
+ if (s->pal.horizontal_margin.IsEmpty()) {
s->pal.horizontal_margin = def->pal.horizontal_margin;
}
- if(s->pal.vertical_margin.IsEmpty()) {
+ if (s->pal.vertical_margin.IsEmpty()) {
s->pal.vertical_margin = def->pal.vertical_margin;
}
- if(s->pal.rotate[0].IsEmpty()) {
+ if (s->pal.rotate[0].IsEmpty()) {
s->pal.rotate[0] = def->pal.rotate[0];
}
- if(s->pal.rotate[1].IsEmpty()) {
+ if (s->pal.rotate[1].IsEmpty()) {
s->pal.rotate[1] = def->pal.rotate[1];
}
- if(s->pal.rotate[2].IsEmpty()) {
+ if (s->pal.rotate[2].IsEmpty()) {
s->pal.rotate[2] = def->pal.rotate[2];
}
}
@@ -288,9 +288,9 @@ bool CUSFSubtitles::Read(LPCTSTR fn) }
pos = texts.GetHeadPosition();
- while(pos) {
+ while (pos) {
text_t* t = texts.GetNext(pos);
- if(t->style.IsEmpty()) {
+ if (t->style.IsEmpty()) {
t->style = L"Default";
}
}
@@ -310,10 +310,10 @@ bool CUSFSubtitles::ConvertToSTS(CSimpleTextSubtitle& sts) int charSet = DEFAULT_CHARSET;
POSITION pos = styles.GetHeadPosition();
- while(pos) {
+ while (pos) {
style_t* s = styles.GetNext(pos);
- if(!s->name.CompareNoCase(L"Default") && !s->fontstyle.wrap.IsEmpty()) {
+ if (!s->name.CompareNoCase(L"Default") && !s->fontstyle.wrap.IsEmpty()) {
sts.m_defaultWrapStyle =
!s->fontstyle.wrap.CompareNoCase(L"no") ? 2 :
!s->fontstyle.wrap.CompareNoCase(L"auto") ? 1 :
@@ -321,33 +321,33 @@ bool CUSFSubtitles::ConvertToSTS(CSimpleTextSubtitle& sts) }
STSStyle* stss = DNew STSStyle;
- if(!stss) {
+ if (!stss) {
continue;
}
- if(!s->pal.horizontal_margin.IsEmpty()) {
+ if (!s->pal.horizontal_margin.IsEmpty()) {
stss->marginRect.left = stss->marginRect.right = TranslateMargin(s->pal.horizontal_margin, sts.m_dstScreenSize.cx);
}
- if(!s->pal.vertical_margin.IsEmpty()) {
+ if (!s->pal.vertical_margin.IsEmpty()) {
stss->marginRect.top = stss->marginRect.bottom = TranslateMargin(s->pal.vertical_margin, sts.m_dstScreenSize.cy);
}
stss->scrAlignment = TranslateAlignment(s->pal.alignment);
- if(!s->pal.relativeto.IsEmpty()) stss->relativeTo =
+ if (!s->pal.relativeto.IsEmpty()) stss->relativeTo =
!s->pal.relativeto.CompareNoCase(L"window") ? 0 :
!s->pal.relativeto.CompareNoCase(L"video") ? 1 :
0;
stss->borderStyle = 0;
- if(!s->fontstyle.outline.IsEmpty()) {
+ if (!s->fontstyle.outline.IsEmpty()) {
stss->outlineWidthX = stss->outlineWidthY = wcstol(s->fontstyle.outline, NULL, 10);
}
- if(!s->fontstyle.shadow.IsEmpty()) {
+ if (!s->fontstyle.shadow.IsEmpty()) {
stss->shadowDepthX = stss->shadowDepthY = wcstol(s->fontstyle.shadow, NULL, 10);
}
- for(ptrdiff_t i = 0; i < 4; i++) {
+ for (ptrdiff_t i = 0; i < 4; i++) {
DWORD color = ColorToDWORD(s->fontstyle.color[i]);
int alpha = (BYTE)wcstol(s->fontstyle.alpha, NULL, 10);
@@ -357,34 +357,34 @@ bool CUSFSubtitles::ConvertToSTS(CSimpleTextSubtitle& sts) stss->alpha[i] = stss->alpha[i] + (255 - stss->alpha[i]) * min(max(alpha, 0), 100) / 100;
}
- if(!s->fontstyle.face.IsEmpty()) {
+ if (!s->fontstyle.face.IsEmpty()) {
stss->fontName = s->fontstyle.face;
}
- if(!s->fontstyle.size.IsEmpty()) {
+ if (!s->fontstyle.size.IsEmpty()) {
stss->fontSize = wcstol(s->fontstyle.size, NULL, 10);
}
- if(!s->fontstyle.weight.IsEmpty()) stss->fontWeight =
+ if (!s->fontstyle.weight.IsEmpty()) stss->fontWeight =
!s->fontstyle.weight.CompareNoCase(L"normal") ? FW_NORMAL :
!s->fontstyle.weight.CompareNoCase(L"bold") ? FW_BOLD :
!s->fontstyle.weight.CompareNoCase(L"lighter") ? FW_LIGHT :
!s->fontstyle.weight.CompareNoCase(L"bolder") ? FW_SEMIBOLD :
wcstol(s->fontstyle.weight, NULL, 10);
- if(stss->fontWeight == 0) {
+ if (stss->fontWeight == 0) {
stss->fontWeight = FW_NORMAL;
}
- if(!s->fontstyle.italic.IsEmpty()) {
+ if (!s->fontstyle.italic.IsEmpty()) {
stss->fItalic = s->fontstyle.italic.CompareNoCase(L"yes") == 0;
}
- if(!s->fontstyle.underline.IsEmpty()) {
+ if (!s->fontstyle.underline.IsEmpty()) {
stss->fUnderline = s->fontstyle.underline.CompareNoCase(L"yes") == 0;
}
- if(!s->pal.rotate[0].IsEmpty()) {
+ if (!s->pal.rotate[0].IsEmpty()) {
stss->fontAngleZ = wcstol(s->pal.rotate[0], NULL, 10);
}
- if(!s->pal.rotate[1].IsEmpty()) {
+ if (!s->pal.rotate[1].IsEmpty()) {
stss->fontAngleX = wcstol(s->pal.rotate[1], NULL, 10);
}
- if(!s->pal.rotate[2].IsEmpty()) {
+ if (!s->pal.rotate[2].IsEmpty()) {
stss->fontAngleY = wcstol(s->pal.rotate[2], NULL, 10);
}
@@ -394,10 +394,10 @@ bool CUSFSubtitles::ConvertToSTS(CSimpleTextSubtitle& sts) }
pos = texts.GetHeadPosition();
- while(pos) {
+ while (pos) {
text_t* t = texts.GetNext(pos);
- if(!t->pal.alignment.IsEmpty()) {
+ if (!t->pal.alignment.IsEmpty()) {
CStringW s;
s.Format(L"{\\an%d}", TranslateAlignment(t->pal.alignment));
t->str = s + t->str;
@@ -406,33 +406,33 @@ bool CUSFSubtitles::ConvertToSTS(CSimpleTextSubtitle& sts) CRect marginRect;
marginRect.SetRectEmpty();
- if(!t->pal.horizontal_margin.IsEmpty()) {
+ if (!t->pal.horizontal_margin.IsEmpty()) {
marginRect.left = marginRect.right = TranslateMargin(t->pal.horizontal_margin, sts.m_dstScreenSize.cx);
}
- if(!t->pal.vertical_margin.IsEmpty()) {
+ if (!t->pal.vertical_margin.IsEmpty()) {
marginRect.top = marginRect.bottom = TranslateMargin(t->pal.vertical_margin, sts.m_dstScreenSize.cy);
}
WCHAR rtags[3][8] = {L"{\\rz%d}", L"{\\rx%d}", L"{\\ry%d}"};
- for(ptrdiff_t i = 0; i < 3; i++) {
- if(int angle = wcstol(t->pal.rotate[i], NULL, 10)) {
+ for (ptrdiff_t i = 0; i < 3; i++) {
+ if (int angle = wcstol(t->pal.rotate[i], NULL, 10)) {
CStringW str;
str.Format(rtags[i], angle);
t->str = str + t->str;
}
}
- if(t->style.CompareNoCase(L"Default") != 0) {
+ if (t->style.CompareNoCase(L"Default") != 0) {
POSITION pos = styles.GetHeadPosition();
- while(pos) {
+ while (pos) {
style_t* s = styles.GetNext(pos);
- if(s->name == t->style && !s->fontstyle.wrap.IsEmpty()) {
+ if (s->name == t->style && !s->fontstyle.wrap.IsEmpty()) {
int WrapStyle =
!s->fontstyle.wrap.CompareNoCase(L"no") ? 2 :
!s->fontstyle.wrap.CompareNoCase(L"auto") ? 1 :
1;
- if(WrapStyle != sts.m_defaultWrapStyle) {
+ if (WrapStyle != sts.m_defaultWrapStyle) {
CStringW str;
str.Format(L"{\\q%d}", WrapStyle);
t->str = str + t->str;
@@ -455,13 +455,13 @@ bool CUSFSubtitles::ParseUSFSubtitles(CComPtr<IXMLDOMNode> pNode) {
DeclareNameAndValue(pNode, name, val);
- if(name == L"usfsubtitles") {
+ if (name == L"usfsubtitles") {
// metadata
BeginEnumChildren(pNode, pChild) {
DeclareNameAndValue(pChild, name, val);
- if(name == L"metadata") {
+ if (name == L"metadata") {
ParseMetadata(pChild, metadata);
}
}
@@ -472,13 +472,13 @@ bool CUSFSubtitles::ParseUSFSubtitles(CComPtr<IXMLDOMNode> pNode) BeginEnumChildren(pNode, pChild) {
DeclareNameAndValue(pChild, name, val);
- if(name == L"styles") {
+ if (name == L"styles") {
BeginEnumChildren(pChild, pGrandChild) { // :)
DeclareNameAndValue(pGrandChild, name, val);
- if(name == L"style") {
+ if (name == L"style") {
CAutoPtr<style_t> s(DNew style_t);
- if(s) {
+ if (s) {
ParseStyle(pGrandChild, s);
styles.AddTail(s);
}
@@ -494,13 +494,13 @@ bool CUSFSubtitles::ParseUSFSubtitles(CComPtr<IXMLDOMNode> pNode) BeginEnumChildren(pNode, pChild) {
DeclareNameAndValue(pChild, name, val);
- if(name == L"effects") {
+ if (name == L"effects") {
BeginEnumChildren(pChild, pGrandChild) { // :)
DeclareNameAndValue(pGrandChild, name, val);
- if(name == L"effect") {
+ if (name == L"effect") {
CAutoPtr<effect_t> e(DNew effect_t);
- if(e) {
+ if (e) {
ParseEffect(pGrandChild, e);
effects.AddTail(e);
}
@@ -516,15 +516,15 @@ bool CUSFSubtitles::ParseUSFSubtitles(CComPtr<IXMLDOMNode> pNode) BeginEnumChildren(pNode, pChild) {
DeclareNameAndValue(pChild, name, val);
- if(name == L"subtitles") {
+ if (name == L"subtitles") {
BeginEnumChildren(pChild, pGrandChild) { // :)
DeclareNameAndValue(pGrandChild, name, val);
- if(name == L"subtitle") {
+ if (name == L"subtitle") {
CStringW sstart = GetAttrib(L"start", pGrandChild);
CStringW sstop = GetAttrib(L"stop", pGrandChild);
CStringW sduration = GetAttrib(L"duration", pGrandChild);
- if(sstart.IsEmpty() || (sstop.IsEmpty() && sduration.IsEmpty())) {
+ if (sstart.IsEmpty() || (sstop.IsEmpty() && sduration.IsEmpty())) {
continue;
}
@@ -543,7 +543,7 @@ bool CUSFSubtitles::ParseUSFSubtitles(CComPtr<IXMLDOMNode> pNode) }
BeginEnumChildren(pNode, pChild) {
- if(ParseUSFSubtitles(pChild)) {
+ if (ParseUSFSubtitles(pChild)) {
return true;
}
}
@@ -556,31 +556,31 @@ void CUSFSubtitles::ParseMetadata(CComPtr<IXMLDOMNode> pNode, metadata_t& m) {
DeclareNameAndValue(pNode, name, val);
- if(name == L"title") {
+ if (name == L"title") {
m.title = GetText(pNode);
- } else if(name == L"date") {
+ } else if (name == L"date") {
m.date = GetText(pNode);
- } else if(name == L"comment") {
+ } else if (name == L"comment") {
m.comment = GetText(pNode);
- } else if(name == L"author") {
+ } else if (name == L"author") {
BeginEnumChildren(pNode, pChild) {
DeclareNameAndValue(pChild, name, val);
- if(name == L"name") {
+ if (name == L"name") {
m.author.name = GetText(pChild);
- } else if(name == L"email") {
+ } else if (name == L"email") {
m.author.email = GetText(pChild);
- } else if(name == L"url") {
+ } else if (name == L"url") {
m.author.url = GetText(pChild);
}
}
EndEnumChildren
return;
- } else if(name == L"language") {
+ } else if (name == L"language") {
m.language.text = GetText(pNode);
m.language.code = GetAttrib(L"code", pNode);
- } else if(name == L"languageext") {
+ } else if (name == L"languageext") {
m.languageext.text = GetText(pNode);
m.languageext.code = GetAttrib(L"code", pNode);
}
@@ -595,12 +595,12 @@ void CUSFSubtitles::ParseStyle(CComPtr<IXMLDOMNode> pNode, style_t* s) {
DeclareNameAndValue(pNode, name, val);
- if(name == L"style") {
+ if (name == L"style") {
s->name = GetAttrib(L"name", pNode);
- } else if(name == L"fontstyle") {
+ } else if (name == L"fontstyle") {
ParseFontstyle(pNode, s->fontstyle);
return;
- } else if(name == L"position") {
+ } else if (name == L"position") {
ParsePal(pNode, s->pal);
return;
}
@@ -643,15 +643,15 @@ void CUSFSubtitles::ParseEffect(CComPtr<IXMLDOMNode> pNode, effect_t* e) {
DeclareNameAndValue(pNode, name, val);
- if(name == L"effect") {
+ if (name == L"effect") {
e->name = GetAttrib(L"name", pNode);
- } else if(name == L"keyframes") {
+ } else if (name == L"keyframes") {
BeginEnumChildren(pNode, pChild) {
DeclareNameAndValue(pChild, name, val);
- if(name == L"keyframe") {
+ if (name == L"keyframe") {
CAutoPtr<keyframe_t> k(DNew keyframe_t);
- if(k) {
+ if (k) {
ParseKeyframe(pChild, k);
e->keyframes.AddTail(k);
}
@@ -672,12 +672,12 @@ void CUSFSubtitles::ParseKeyframe(CComPtr<IXMLDOMNode> pNode, keyframe_t* k) {
DeclareNameAndValue(pNode, name, val);
- if(name == L"keyframe") {
+ if (name == L"keyframe") {
k->position = GetAttrib(L"position", pNode);
- } else if(name == L"fontstyle") {
+ } else if (name == L"fontstyle") {
ParseFontstyle(pNode, k->fontstyle);
return;
- } else if(name == L"position") {
+ } else if (name == L"position") {
ParsePal(pNode, k->pal);
return;
}
@@ -687,9 +687,9 @@ void CUSFSubtitles::ParseSubtitle(CComPtr<IXMLDOMNode> pNode, int start, int sto {
DeclareNameAndValue(pNode, name, val);
- if(name == L"text" || name == L"karaoke") {
+ if (name == L"text" || name == L"karaoke") {
CAutoPtr<text_t> t(DNew text_t);
- if(t) {
+ if (t) {
t->start = start;
t->stop = stop;
t->style = GetAttrib(L"style", pNode);
@@ -715,38 +715,38 @@ void CUSFSubtitles::ParseText(CComPtr<IXMLDOMNode> pNode, CStringW& str) CStringW prefix, postfix;
- if(name == L"b") {
+ if (name == L"b") {
prefix = L"{\\b1}";
postfix = L"{\\b}";
- } else if(name == L"i") {
+ } else if (name == L"i") {
prefix = L"{\\i1}";
postfix = L"{\\i}";
- } else if(name == L"u") {
+ } else if (name == L"u") {
prefix = L"{\\u1}";
postfix = L"{\\u}";
- } else if(name == L"font") {
+ } else if (name == L"font") {
fontstyle_t fs;
ParseFontstyle(pNode, fs);
- if(!fs.face.IsEmpty()) {
+ if (!fs.face.IsEmpty()) {
prefix += L"{\\fn" + fs.face + L"}";
postfix += L"{\\fn}";
}
- if(!fs.size.IsEmpty()) {
+ if (!fs.size.IsEmpty()) {
prefix += L"{\\fs" + fs.size + L"}";
postfix += L"{\\fs}";
}
- if(!fs.outline.IsEmpty()) {
+ if (!fs.outline.IsEmpty()) {
prefix += L"{\\bord" + fs.outline + L"}";
postfix += L"{\\bord}";
}
- if(!fs.shadow.IsEmpty()) {
+ if (!fs.shadow.IsEmpty()) {
prefix += L"{\\shad" + fs.shadow + L"}";
postfix += L"{\\shad}";
}
- for(ptrdiff_t i = 0; i < 4; i++) {
- if(!fs.color[i].IsEmpty()) {
+ for (ptrdiff_t i = 0; i < 4; i++) {
+ if (!fs.color[i].IsEmpty()) {
CStringW s;
s.Format(L"{\\%dc&H%06x&}", i+1, ColorToDWORD(fs.color[i]));
prefix += s;
@@ -754,16 +754,16 @@ void CUSFSubtitles::ParseText(CComPtr<IXMLDOMNode> pNode, CStringW& str) postfix += s;
}
}
- } else if(name == L"k") {
+ } else if (name == L"k") {
int t = wcstol(GetAttrib(L"t", pNode), NULL, 10);
CStringW s;
s.Format(L"{\\kf%d}", t / 10);
str += s;
return;
- } else if(name == L"br") {
+ } else if (name == L"br") {
str += L"\\N";
return;
- } else if(name == L"#text") {
+ } else if (name == L"#text") {
str += GetXML(pNode);
return;
}
diff --git a/src/Subtitles/VobSubFile.cpp b/src/Subtitles/VobSubFile.cpp index 0d4c297b1..778b46dbd 100644 --- a/src/Subtitles/VobSubFile.cpp +++ b/src/Subtitles/VobSubFile.cpp @@ -183,11 +183,11 @@ int find_lang(unsigned short id) {
int mid, lo = 0, hi = countof(lang_tbl) - 1;
- while(lo < hi) {
+ while (lo < hi) {
mid = (lo + hi) >> 1;
- if(id < lang_tbl[mid].id) {
+ if (id < lang_tbl[mid].id) {
hi = mid;
- } else if(id > lang_tbl[mid].id) {
+ } else if (id > lang_tbl[mid].id) {
lo = mid + 1;
} else {
return(mid);
@@ -229,7 +229,7 @@ bool CVobSubFile::Copy(CVobSubFile& vsf) m_sub.SetLength(vsf.m_sub.GetLength());
m_sub.SeekToBegin();
- for(ptrdiff_t i = 0; i < 32; i++) {
+ for (ptrdiff_t i = 0; i < 32; i++) {
SubLang& src = vsf.m_langs[i];
SubLang& dst = m_langs[i];
@@ -237,13 +237,13 @@ bool CVobSubFile::Copy(CVobSubFile& vsf) dst.name = src.name;
dst.alt = src.alt;
- for(size_t j = 0; j < src.subpos.GetCount(); j++) {
+ for (size_t j = 0; j < src.subpos.GetCount(); j++) {
SubPos& sp = src.subpos[j];
- if(!sp.fValid) {
+ if (!sp.fValid) {
continue;
}
- if(sp.filepos != (__int64)vsf.m_sub.Seek(sp.filepos, CFile::begin)) {
+ if (sp.filepos != (__int64)vsf.m_sub.Seek(sp.filepos, CFile::begin)) {
continue;
}
@@ -255,15 +255,15 @@ bool CVobSubFile::Copy(CVobSubFile& vsf) WORD packetsize = (buff[buff[0x16]+0x18]<<8) | buff[buff[0x16]+0x19];
- for(ptrdiff_t k = 0, size, sizeleft = packetsize - 4;
+ for (ptrdiff_t k = 0, size, sizeleft = packetsize - 4;
k < packetsize - 4;
k += size, sizeleft -= size) {
int hsize = buff[0x16]+0x18 + ((buff[0x15]&0x80) ? 4 : 0);
size = min(sizeleft, 2048 - hsize);
- if(size != sizeleft) {
- while(vsf.m_sub.Read(buff, 2048)) {
- if(!(buff[0x15]&0x80) && buff[buff[0x16]+0x17] == (i|0x20)) {
+ if (size != sizeleft) {
+ while (vsf.m_sub.Read(buff, 2048)) {
+ if (!(buff[0x15]&0x80) && buff[buff[0x16]+0x17] == (i|0x20)) {
break;
}
}
@@ -286,9 +286,9 @@ bool CVobSubFile::Copy(CVobSubFile& vsf) void CVobSubFile::TrimExtension(CString& fn)
{
int i = fn.ReverseFind('.');
- if(i > 0) {
+ if (i > 0) {
CString ext = fn.Mid(i).MakeLower();
- if(ext == _T(".ifo") || ext == _T(".idx") || ext == _T(".sub")
+ if (ext == _T(".ifo") || ext == _T(".idx") || ext == _T(".sub")
|| ext == _T(".sst") || ext == _T(".son") || ext == _T(".rar")) {
fn = fn.Left(i);
}
@@ -303,43 +303,43 @@ bool CVobSubFile::Open(CString fn) Close();
int ver;
- if(!ReadIdx(fn + _T(".idx"), ver)) {
+ if (!ReadIdx(fn + _T(".idx"), ver)) {
break;
}
- if(ver < 6 && !ReadIfo(fn + _T(".ifo"))) {
+ if (ver < 6 && !ReadIfo(fn + _T(".ifo"))) {
break;
}
- if(!ReadSub(fn + _T(".sub")) && !ReadRar(fn + _T(".rar"))) {
+ if (!ReadSub(fn + _T(".sub")) && !ReadRar(fn + _T(".rar"))) {
break;
}
m_title = fn;
- for(ptrdiff_t i = 0; i < 32; i++) {
+ for (ptrdiff_t i = 0; i < 32; i++) {
CAtlArray<SubPos>& sp = m_langs[i].subpos;
- for(size_t j = 0; j < sp.GetCount(); j++) {
+ for (size_t j = 0; j < sp.GetCount(); j++) {
sp[j].stop = sp[j].start;
sp[j].fForced = false;
int packetsize = 0, datasize = 0;
BYTE* buff = GetPacket(j, packetsize, datasize, i);
- if(!buff) {
+ if (!buff) {
continue;
}
m_img.delay = j < (sp.GetCount()-1) ? sp[j+1].start - sp[j].start : 3000;
m_img.GetPacketInfo(buff, packetsize, datasize);
- if(j < (sp.GetCount()-1)) {
+ if (j < (sp.GetCount()-1)) {
m_img.delay = min(m_img.delay, sp[j+1].start - sp[j].start);
}
sp[j].stop = sp[j].start + m_img.delay;
sp[j].fForced = m_img.fForced;
- if(j > 0 && sp[j-1].stop > sp[j].start) {
+ if (j > 0 && sp[j-1].stop > sp[j].start) {
sp[j-1].stop = sp[j].start;
}
@@ -348,7 +348,7 @@ bool CVobSubFile::Open(CString fn) }
return true;
- } while(false);
+ } while (false);
Close();
@@ -360,11 +360,11 @@ bool CVobSubFile::Save(CString fn, SubFormat sf) TrimExtension(fn);
CVobSubFile vsf(NULL);
- if(!vsf.Copy(*this)) {
+ if (!vsf.Copy(*this)) {
return false;
}
- switch(sf) {
+ switch (sf) {
case VobSub:
return vsf.SaveVobSub(fn);
break;
@@ -391,7 +391,7 @@ void CVobSubFile::Close() m_sub.SetLength(0);
m_img.Invalidate();
m_iLang = -1;
- for(ptrdiff_t i = 0; i < 32; i++) {
+ for (ptrdiff_t i = 0; i < 32; i++) {
m_langs[i].id = 0;
m_langs[i].name.Empty();
m_langs[i].alt.Empty();
@@ -404,7 +404,7 @@ void CVobSubFile::Close() bool CVobSubFile::ReadIdx(CString fn, int& ver)
{
CWebTextFile f;
- if(!f.Open(fn)) {
+ if (!f.Open(fn)) {
return false;
}
@@ -414,30 +414,30 @@ bool CVobSubFile::ReadIdx(CString fn, int& ver) __int64 celltimestamp = 0;
CString str;
- for(ptrdiff_t line = 0; !fError && f.ReadString(str); line++) {
+ for (ptrdiff_t line = 0; !fError && f.ReadString(str); line++) {
str.Trim();
- if(line == 0) {
+ if (line == 0) {
TCHAR buff[] = _T("VobSub index file, v");
const TCHAR* s = str;
int i = str.Find(buff);
- if(i < 0 || _stscanf(&s[i+_tcslen(buff)], _T("%d"), &ver) != 1
+ if (i < 0 || _stscanf(&s[i+_tcslen(buff)], _T("%d"), &ver) != 1
|| ver > VOBSUBIDXVER) {
AfxMessageBox(_T("Wrong file version!"));
fError = true;
continue;
}
- } else if(!str.GetLength()) {
+ } else if (!str.GetLength()) {
continue;
- } else if(str[0] == _T('#')) {
+ } else if (str[0] == _T('#')) {
TCHAR buff[] = _T("Vob/Cell ID:");
const TCHAR* s = str;
int i = str.Find(buff);
- if(i >= 0) {
+ if (i >= 0) {
_stscanf(&s[i+_tcslen(buff)], _T("%d, %d (PTS: %d)"), &vobid, &cellid, &celltimestamp);
}
@@ -445,7 +445,7 @@ bool CVobSubFile::ReadIdx(CString fn, int& ver) }
int i = str.Find(':');
- if(i <= 0) {
+ if (i <= 0) {
continue;
}
@@ -453,100 +453,100 @@ bool CVobSubFile::ReadIdx(CString fn, int& ver) str = str.Mid(i+1);
str.Trim();
- if(str.IsEmpty()) {
+ if (str.IsEmpty()) {
continue;
}
- if(entry == _T("size")) {
+ if (entry == _T("size")) {
int x, y;
- if(_stscanf(str, _T("%dx%d"), &x, &y) != 2) {
+ if (_stscanf(str, _T("%dx%d"), &x, &y) != 2) {
fError = true;
}
m_size.cx = x;
m_size.cy = y;
- } else if(entry == _T("org")) {
- if(_stscanf(str, _T("%d,%d"), &m_x, &m_y) != 2) {
+ } else if (entry == _T("org")) {
+ if (_stscanf(str, _T("%d,%d"), &m_x, &m_y) != 2) {
fError = true;
} else {
m_org = CPoint(m_x, m_y);
}
- } else if(entry == _T("scale")) {
- if(ver < 5) {
+ } else if (entry == _T("scale")) {
+ if (ver < 5) {
int scale = 100;
- if(_stscanf(str, _T("%d%%"), &scale) != 1) {
+ if (_stscanf(str, _T("%d%%"), &scale) != 1) {
fError = true;
}
m_scale_x = m_scale_y = scale;
} else {
- if(_stscanf(str, _T("%d%%,%d%%"), &m_scale_x, &m_scale_y) != 2) {
+ if (_stscanf(str, _T("%d%%,%d%%"), &m_scale_x, &m_scale_y) != 2) {
fError = true;
}
}
- } else if(entry == _T("alpha")) {
- if(_stscanf(str, _T("%d"), &m_alpha) != 1) {
+ } else if (entry == _T("alpha")) {
+ if (_stscanf(str, _T("%d"), &m_alpha) != 1) {
fError = true;
}
- } else if(entry == _T("smooth")) {
+ } else if (entry == _T("smooth")) {
str.MakeLower();
- if(str.Find(_T("old")) >= 0 || str.Find(_T("2")) >= 0) {
+ if (str.Find(_T("old")) >= 0 || str.Find(_T("2")) >= 0) {
m_fSmooth = 2;
- } else if(str.Find(_T("on")) >= 0 || str.Find(_T("1")) >= 0) {
+ } else if (str.Find(_T("on")) >= 0 || str.Find(_T("1")) >= 0) {
m_fSmooth = 1;
- } else if(str.Find(_T("off")) >= 0 || str.Find(_T("0")) >= 0) {
+ } else if (str.Find(_T("off")) >= 0 || str.Find(_T("0")) >= 0) {
m_fSmooth = 0;
} else {
fError = true;
}
- } else if(entry == _T("fadein/out")) {
- if(_stscanf(str, _T("%d,%d"), &m_fadein, &m_fadeout) != 2) {
+ } else if (entry == _T("fadein/out")) {
+ if (_stscanf(str, _T("%d,%d"), &m_fadein, &m_fadeout) != 2) {
fError = true;
}
- } else if(entry == _T("align")) {
+ } else if (entry == _T("align")) {
str.MakeLower();
int i = 0, j = 0;
- for(CString token = str.Tokenize(_T(" "), i);
+ for (CString token = str.Tokenize(_T(" "), i);
j < 3 && !fError && !token.IsEmpty();
token = str.Tokenize(_T(" "), i), j++) {
- if(j == 0) {
- if(token == _T("on") || token == _T("1")) {
+ if (j == 0) {
+ if (token == _T("on") || token == _T("1")) {
m_fAlign = true;
- } else if(token == _T("off") || token == _T("0")) {
+ } else if (token == _T("off") || token == _T("0")) {
m_fAlign = false;
} else {
fError = true;
}
- } else if(j == 1) {
- if(token == _T("at")) {
+ } else if (j == 1) {
+ if (token == _T("at")) {
j--;
continue;
}
- if(token == _T("left")) {
+ if (token == _T("left")) {
m_alignhor = 0;
- } else if(token == _T("center")) {
+ } else if (token == _T("center")) {
m_alignhor = 1;
- } else if(token == _T("right")) {
+ } else if (token == _T("right")) {
m_alignhor = 2;
} else {
fError = true;
}
- } else if(j == 2) {
- if(token == _T("top")) {
+ } else if (j == 2) {
+ if (token == _T("top")) {
m_alignver = 0;
- } else if(token == _T("center")) {
+ } else if (token == _T("center")) {
m_alignver = 1;
- } else if(token == _T("bottom")) {
+ } else if (token == _T("bottom")) {
m_alignver = 2;
} else {
fError = true;
}
}
}
- } else if(entry == _T("time offset")) {
+ } else if (entry == _T("time offset")) {
bool fNegative = false;
- if(str[0] == '-') {
+ if (str[0] == '-') {
fNegative = true;
}
str.TrimLeft(_T("+-"));
@@ -560,85 +560,85 @@ bool CVobSubFile::ReadIdx(CString fn, int& ver) : n == 4+3
? (hh*60*60*1000 + mm*60*1000 + ss*1000 + ms) * (fNegative ? -1 : 1)
: fError = true, 0;
- } else if(entry == _T("forced subs")) {
+ } else if (entry == _T("forced subs")) {
str.MakeLower();
- if(str.Find(_T("on")) >= 0 || str.Find(_T("1")) >= 0) {
+ if (str.Find(_T("on")) >= 0 || str.Find(_T("1")) >= 0) {
m_fOnlyShowForcedSubs = true;
- } else if(str.Find(_T("off")) >= 0 || str.Find(_T("0")) >= 0) {
+ } else if (str.Find(_T("off")) >= 0 || str.Find(_T("0")) >= 0) {
m_fOnlyShowForcedSubs = false;
} else {
fError = true;
}
- } else if(entry == _T("langidx")) {
- if(_stscanf(str, _T("%d"), &m_iLang) != 1) {
+ } else if (entry == _T("langidx")) {
+ if (_stscanf(str, _T("%d"), &m_iLang) != 1) {
fError = true;
}
- } else if(entry == _T("palette")) {
- if(_stscanf(str, _T("%x,%x,%x,%x,%x,%x,%x,%x,%x,%x,%x,%x,%x,%x,%x,%x"),
- &m_orgpal[0], &m_orgpal[1], &m_orgpal[2], &m_orgpal[3],
- &m_orgpal[4], &m_orgpal[5], &m_orgpal[6], &m_orgpal[7],
- &m_orgpal[8], &m_orgpal[9], &m_orgpal[10], &m_orgpal[11],
- &m_orgpal[12], &m_orgpal[13], &m_orgpal[14], &m_orgpal[15]
- ) != 16) {
+ } else if (entry == _T("palette")) {
+ if (_stscanf(str, _T("%x,%x,%x,%x,%x,%x,%x,%x,%x,%x,%x,%x,%x,%x,%x,%x"),
+ &m_orgpal[0], &m_orgpal[1], &m_orgpal[2], &m_orgpal[3],
+ &m_orgpal[4], &m_orgpal[5], &m_orgpal[6], &m_orgpal[7],
+ &m_orgpal[8], &m_orgpal[9], &m_orgpal[10], &m_orgpal[11],
+ &m_orgpal[12], &m_orgpal[13], &m_orgpal[14], &m_orgpal[15]
+ ) != 16) {
fError = true;
}
- } else if(entry == _T("custom colors")) {
+ } else if (entry == _T("custom colors")) {
str.MakeLower();
- if(str.Find(_T("on")) == 0 || str.Find(_T("1")) == 0) {
+ if (str.Find(_T("on")) == 0 || str.Find(_T("1")) == 0) {
m_fCustomPal = true;
- } else if(str.Find(_T("off")) == 0 || str.Find(_T("0")) == 0) {
+ } else if (str.Find(_T("off")) == 0 || str.Find(_T("0")) == 0) {
m_fCustomPal = false;
} else {
fError = true;
}
i = str.Find(_T("tridx:"));
- if(i < 0) {
+ if (i < 0) {
fError = true;
continue;
}
str = str.Mid(i + (int)_tcslen(_T("tridx:")));
int tridx;
- if(_stscanf(str, _T("%x"), &tridx) != 1) {
+ if (_stscanf(str, _T("%x"), &tridx) != 1) {
fError = true;
continue;
}
tridx = ((tridx&0x1000)>>12) | ((tridx&0x100)>>7) | ((tridx&0x10)>>2) | ((tridx&1)<<3);
i = str.Find(_T("colors:"));
- if(i < 0) {
+ if (i < 0) {
fError = true;
continue;
}
str = str.Mid(i + (int)_tcslen(_T("colors:")));
RGBQUAD pal[4];
- if(_stscanf(str, _T("%x,%x,%x,%x"), &pal[0], &pal[1], &pal[2], &pal[3]) != 4) {
+ if (_stscanf(str, _T("%x,%x,%x,%x"), &pal[0], &pal[1], &pal[2], &pal[3]) != 4) {
fError = true;
continue;
}
SetCustomPal(pal, tridx);
- } else if(entry == _T("id")) {
+ } else if (entry == _T("id")) {
str.MakeLower();
int langid = ((str[0]&0xff)<<8)|(str[1]&0xff);
i = str.Find(_T("index:"));
- if(i < 0) {
+ if (i < 0) {
fError = true;
continue;
}
str = str.Mid(i + (int)_tcslen(_T("index:")));
- if(_stscanf(str, _T("%d"), &id) != 1 || id < 0 || id >= 32) {
+ if (_stscanf(str, _T("%d"), &id) != 1 || id < 0 || id >= 32) {
fError = true;
continue;
}
- if(m_iLang < 0) {
+ if (m_iLang < 0) {
m_iLang = id;
}
@@ -647,24 +647,24 @@ bool CVobSubFile::ReadIdx(CString fn, int& ver) m_langs[id].alt = lang_tbl[find_lang(langid)].lang_long;
delay = 0;
- } else if(id >= 0 && entry == _T("alt")) {
+ } else if (id >= 0 && entry == _T("alt")) {
m_langs[id].alt = str;
- } else if(id >= 0 && entry == _T("delay")) {
+ } else if (id >= 0 && entry == _T("delay")) {
bool fNegative = false;
- if(str[0] == '-') {
+ if (str[0] == '-') {
fNegative = true;
}
str.TrimLeft(_T("+-"));
TCHAR c;
int hh, mm, ss, ms;
- if(_stscanf(str, _T("%d%c%d%c%d%c%d"), &hh, &c, &mm, &c, &ss, &c, &ms) != 4+3) {
+ if (_stscanf(str, _T("%d%c%d%c%d%c%d"), &hh, &c, &mm, &c, &ss, &c, &ms) != 4+3) {
fError = true;
continue;
}
delay += (hh*60*60*1000 + mm*60*1000 + ss*1000 + ms) * (fNegative ? -1 : 1);
- } else if(id >= 0 && entry == _T("timestamp")) {
+ } else if (id >= 0 && entry == _T("timestamp")) {
SubPos sb;
sb.vobid = vobid;
@@ -673,14 +673,14 @@ bool CVobSubFile::ReadIdx(CString fn, int& ver) sb.fValid = true;
bool fNegative = false;
- if(str[0] == '-') {
+ if (str[0] == '-') {
fNegative = true;
}
str.TrimLeft(_T("+-"));
TCHAR c;
int hh, mm, ss, ms;
- if(_stscanf(str, _T("%d%c%d%c%d%c%d"), &hh, &c, &mm, &c, &ss, &c, &ms) != 4+3) {
+ if (_stscanf(str, _T("%d%c%d%c%d%c%d"), &hh, &c, &mm, &c, &ss, &c, &ms) != 4+3) {
fError = true;
continue;
}
@@ -688,21 +688,21 @@ bool CVobSubFile::ReadIdx(CString fn, int& ver) sb.start = (hh*60*60*1000 + mm*60*1000 + ss*1000 + ms) * (fNegative ? -1 : 1) + delay;
i = str.Find(_T("filepos:"));
- if(i < 0) {
+ if (i < 0) {
fError = true;
continue;
}
str = str.Mid(i + (int)_tcslen(_T("filepos:")));
- if(_stscanf(str, _T("%I64x"), &sb.filepos) != 1) {
+ if (_stscanf(str, _T("%I64x"), &sb.filepos) != 1) {
fError = true;
continue;
}
- if(delay < 0 && m_langs[id].subpos.GetCount() > 0) {
+ if (delay < 0 && m_langs[id].subpos.GetCount() > 0) {
__int64 ts = m_langs[id].subpos[m_langs[id].subpos.GetCount()-1].start;
- if(sb.start < ts) {
+ if (sb.start < ts) {
delay += (int)(ts - sb.start);
sb.start = ts;
}
@@ -720,7 +720,7 @@ bool CVobSubFile::ReadIdx(CString fn, int& ver) bool CVobSubFile::ReadSub(CString fn)
{
CFile f;
- if(!f.Open(fn, CFile::modeRead|CFile::typeBinary|CFile::shareDenyNone)) {
+ if (!f.Open(fn, CFile::modeRead|CFile::typeBinary|CFile::shareDenyNone)) {
return false;
}
@@ -729,7 +729,7 @@ bool CVobSubFile::ReadSub(CString fn) int len;
BYTE buff[2048];
- while((len = f.Read(buff, sizeof(buff))) > 0 && *(DWORD*)buff == 0xba010000) {
+ while ((len = f.Read(buff, sizeof(buff))) > 0 && *(DWORD*)buff == 0xba010000) {
m_sub.Write(buff, len);
}
@@ -756,7 +756,7 @@ bool CVobSubFile::ReadRar(CString fn) #else
HMODULE h = LoadLibrary(_T("unrar.dll"));
#endif
- if(!h) {
+ if (!h) {
return false;
}
@@ -768,7 +768,7 @@ bool CVobSubFile::ReadRar(CString fn) RARSetProcessDataProc SetProcessDataProc = (RARSetProcessDataProc)GetProcAddress(h, "RARSetProcessDataProc");
RARSetPassword SetPassword = (RARSetPassword)GetProcAddress(h, "RARSetPassword");
- if(!(OpenArchiveEx && CloseArchive && ReadHeaderEx && ProcessFile
+ if (!(OpenArchiveEx && CloseArchive && ReadHeaderEx && ProcessFile
&& SetChangeVolProc && SetProcessDataProc && SetPassword)) {
FreeLibrary(h);
return false;
@@ -779,7 +779,7 @@ bool CVobSubFile::ReadRar(CString fn) #ifdef UNICODE
ArchiveDataEx.ArcNameW = (LPTSTR)(LPCTSTR)fn;
char fnA[_MAX_PATH];
- if(wcstombs(fnA, fn, fn.GetLength()+1) == -1) {
+ if (wcstombs(fnA, fn, fn.GetLength()+1) == -1) {
fnA[0] = 0;
}
ArchiveDataEx.ArcName = fnA;
@@ -789,7 +789,7 @@ bool CVobSubFile::ReadRar(CString fn) ArchiveDataEx.OpenMode = RAR_OM_EXTRACT;
ArchiveDataEx.CmtBuf = 0;
HANDLE hrar = OpenArchiveEx(&ArchiveDataEx);
- if(!hrar) {
+ if (!hrar) {
FreeLibrary(h);
return false;
}
@@ -799,16 +799,16 @@ bool CVobSubFile::ReadRar(CString fn) struct RARHeaderDataEx HeaderDataEx;
HeaderDataEx.CmtBuf = NULL;
- while(ReadHeaderEx(hrar, &HeaderDataEx) == 0) {
+ while (ReadHeaderEx(hrar, &HeaderDataEx) == 0) {
#ifdef UNICODE
CString subfn(HeaderDataEx.FileNameW);
#else
CString subfn(HeaderDataEx.FileName);
#endif
- if(!subfn.Right(4).CompareNoCase(_T(".sub"))) {
+ if (!subfn.Right(4).CompareNoCase(_T(".sub"))) {
CAutoVectorPtr<BYTE> buff;
- if(!buff.Allocate(HeaderDataEx.UnpSize)) {
+ if (!buff.Allocate(HeaderDataEx.UnpSize)) {
CloseArchive(hrar);
FreeLibrary(h);
return false;
@@ -817,7 +817,7 @@ bool CVobSubFile::ReadRar(CString fn) RARbuff = buff;
RARpos = 0;
- if(ProcessFile(hrar, RAR_TEST, NULL, NULL)) {
+ if (ProcessFile(hrar, RAR_TEST, NULL, NULL)) {
CloseArchive(hrar);
FreeLibrary(h);
@@ -853,7 +853,7 @@ bool CVobSubFile::ReadRar(CString fn) bool CVobSubFile::ReadIfo(CString fn)
{
CFile f;
- if(!f.Open(fn, CFile::modeRead|CFile::typeBinary|CFile::shareDenyNone)) {
+ if (!f.Open(fn, CFile::modeRead|CFile::typeBinary|CFile::shareDenyNone)) {
return false;
}
@@ -873,7 +873,7 @@ bool CVobSubFile::ReadIfo(CString fn) f.Seek(pos*0x800 + offset + 0xa4, CFile::begin);
- for(ptrdiff_t i = 0; i < 16; i++) {
+ for (ptrdiff_t i = 0; i < 16; i++) {
BYTE y, u, v, tmp;
f.Read(&tmp, 1);
@@ -894,7 +894,7 @@ bool CVobSubFile::ReadIfo(CString fn) bool CVobSubFile::WriteIdx(CString fn)
{
CTextFile f;
- if(!f.Save(fn, CTextFile::ASCII)) {
+ if (!f.Save(fn, CTextFile::ASCII)) {
return false;
}
@@ -1003,11 +1003,11 @@ bool CVobSubFile::WriteIdx(CString fn) // Subs
- for(ptrdiff_t i = 0; i < 32; i++) {
+ for (ptrdiff_t i = 0; i < 32; i++) {
SubLang& sl = m_langs[i];
CAtlArray<SubPos>& sp = sl.subpos;
- if(sp.IsEmpty() && !sl.id) {
+ if (sp.IsEmpty() && !sl.id) {
continue;
}
@@ -1015,7 +1015,7 @@ bool CVobSubFile::WriteIdx(CString fn) f.WriteString(str);
ASSERT(sl.id);
- if(!sl.id) {
+ if (!sl.id) {
sl.id = '--';
}
str.Format(_T("id: %c%c, index: %d\n"), sl.id>>8, sl.id&0xff, i);
@@ -1024,19 +1024,19 @@ bool CVobSubFile::WriteIdx(CString fn) str.Format(_T("# Decomment next line to activate alternative name in DirectVobSub / Windows Media Player 6.x\n"));
f.WriteString(str);
str.Format(_T("alt: %s\n"), sl.alt);
- if(sl.name == sl.alt) {
+ if (sl.name == sl.alt) {
str = _T("# ") + str;
}
f.WriteString(str);
char vobid = -1, cellid = -1;
- for(size_t j = 0; j < sp.GetCount(); j++) {
- if(!sp[j].fValid) {
+ for (size_t j = 0; j < sp.GetCount(); j++) {
+ if (!sp[j].fValid) {
continue;
}
- if(sp[j].vobid != vobid || sp[j].cellid != cellid) {
+ if (sp[j].vobid != vobid || sp[j].cellid != cellid) {
str.Format(_T("# Vob/Cell ID: %d, %d (PTS: %d)\n"), sp[j].vobid, sp[j].cellid, sp[j].celltimestamp);
f.WriteString(str);
vobid = sp[j].vobid;
@@ -1062,11 +1062,11 @@ bool CVobSubFile::WriteIdx(CString fn) bool CVobSubFile::WriteSub(CString fn)
{
CFile f;
- if(!f.Open(fn, CFile::modeCreate|CFile::modeWrite|CFile::typeBinary|CFile::shareDenyWrite)) {
+ if (!f.Open(fn, CFile::modeCreate|CFile::modeWrite|CFile::typeBinary|CFile::shareDenyWrite)) {
return false;
}
- if(m_sub.GetLength() == 0) {
+ if (m_sub.GetLength() == 0) {
return true; // nothing to do...
}
@@ -1074,7 +1074,7 @@ bool CVobSubFile::WriteSub(CString fn) int len;
BYTE buff[2048];
- while((len = m_sub.Read(buff, sizeof(buff))) > 0 && *(DWORD*)buff == 0xba010000) {
+ while ((len = m_sub.Read(buff, sizeof(buff))) > 0 && *(DWORD*)buff == 0xba010000) {
f.Write(buff, len);
}
@@ -1087,27 +1087,27 @@ BYTE* CVobSubFile::GetPacket(int idx, int& packetsize, int& datasize, int iLang) {
BYTE* ret = NULL;
- if(iLang < 0 || iLang >= 32) {
+ if (iLang < 0 || iLang >= 32) {
iLang = m_iLang;
}
CAtlArray<SubPos>& sp = m_langs[iLang].subpos;
do {
- if(idx < 0 || (size_t)idx >= sp.GetCount()) {
+ if (idx < 0 || (size_t)idx >= sp.GetCount()) {
break;
}
- if((__int64)m_sub.Seek(sp[idx].filepos, CFile::begin) != sp[idx].filepos) {
+ if ((__int64)m_sub.Seek(sp[idx].filepos, CFile::begin) != sp[idx].filepos) {
break;
}
BYTE buff[0x800];
- if(sizeof(buff) != m_sub.Read(buff, sizeof(buff))) {
+ if (sizeof(buff) != m_sub.Read(buff, sizeof(buff))) {
break;
}
// let's check a few things to make sure...
- if(*(DWORD*)&buff[0x00] != 0xba010000
+ if (*(DWORD*)&buff[0x00] != 0xba010000
|| *(DWORD*)&buff[0x0e] != 0xbd010000
|| !(buff[0x15] & 0x80)
|| (buff[0x17] & 0xf0) != 0x20
@@ -1120,51 +1120,51 @@ BYTE* CVobSubFile::GetPacket(int idx, int& packetsize, int& datasize, int iLang) datasize = (buff[buff[0x16] + 0x1a] << 8) + buff[buff[0x16] + 0x1b];
ret = DNew BYTE[packetsize];
- if(!ret) {
+ if (!ret) {
break;
}
int i = 0, sizeleft = packetsize;
- for(ptrdiff_t size;
+ for (ptrdiff_t size;
i < packetsize;
i += size, sizeleft -= size) {
int hsize = 0x18 + buff[0x16];
size = min(sizeleft, 0x800 - hsize);
memcpy(&ret[i], &buff[hsize], size);
- if(size != sizeleft) {
- while(m_sub.Read(buff, sizeof(buff))) {
- if(/*!(buff[0x15] & 0x80) &&*/ buff[buff[0x16] + 0x17] == (iLang|0x20)) {
+ if (size != sizeleft) {
+ while (m_sub.Read(buff, sizeof(buff))) {
+ if (/*!(buff[0x15] & 0x80) &&*/ buff[buff[0x16] + 0x17] == (iLang|0x20)) {
break;
}
}
}
}
- if(i != packetsize || sizeleft > 0) {
+ if (i != packetsize || sizeleft > 0) {
delete [] ret, ret = NULL;
}
- } while(false);
+ } while (false);
return(ret);
}
bool CVobSubFile::GetFrame(int idx, int iLang)
{
- if(iLang < 0 || iLang >= 32) {
+ if (iLang < 0 || iLang >= 32) {
iLang = m_iLang;
}
CAtlArray<SubPos>& sp = m_langs[iLang].subpos;
- if(idx < 0 || (size_t)idx >= sp.GetCount()) {
+ if (idx < 0 || (size_t)idx >= sp.GetCount()) {
return false;
}
- if(m_img.iLang != iLang || m_img.iIdx != idx) {
+ if (m_img.iLang != iLang || m_img.iIdx != idx) {
int packetsize = 0, datasize = 0;
CAutoVectorPtr<BYTE> buff;
buff.Attach(GetPacket(idx, packetsize, datasize, iLang));
- if(!buff || packetsize <= 0 || datasize <= 0) {
+ if (!buff || packetsize <= 0 || datasize <= 0) {
return false;
}
@@ -1175,11 +1175,11 @@ bool CVobSubFile::GetFrame(int idx, int iLang) bool ret = m_img.Decode(buff, packetsize, datasize, m_fCustomPal, m_tridx, m_orgpal, m_cuspal, true);
- if((size_t)idx < (sp.GetCount()-1)) {
+ if ((size_t)idx < (sp.GetCount()-1)) {
m_img.delay = min(m_img.delay, sp[idx+1].start - m_img.start);
}
- if(!ret) {
+ if (!ret) {
return false;
}
@@ -1197,7 +1197,7 @@ bool CVobSubFile::GetFrameByTimeStamp(__int64 time) int CVobSubFile::GetFrameIdxByTimeStamp(__int64 time)
{
- if(m_iLang < 0 || m_iLang >= 32) {
+ if (m_iLang < 0 || m_iLang >= 32) {
return(-1);
}
@@ -1205,26 +1205,26 @@ int CVobSubFile::GetFrameIdxByTimeStamp(__int64 time) int i = 0, j = (int)sp.GetCount() - 1, ret = -1;
- if(j >= 0 && time >= sp[j].start) {
+ if (j >= 0 && time >= sp[j].start) {
return(j);
}
- while(i < j) {
+ while (i < j) {
int mid = (i + j) >> 1;
int midstart = (int)sp[mid].start;
- if(time == midstart) {
+ if (time == midstart) {
ret = mid;
break;
- } else if(time < midstart) {
+ } else if (time < midstart) {
ret = -1;
- if(j == mid) {
+ if (j == mid) {
mid--;
}
j = mid;
- } else if(time > midstart) {
+ } else if (time > midstart) {
ret = mid;
- if(i == mid) {
+ if (i == mid) {
mid++;
}
i = mid;
@@ -1258,12 +1258,12 @@ STDMETHODIMP_(POSITION) CVobSubFile::GetStartPosition(REFERENCE_TIME rt, double int i = GetFrameIdxByTimeStamp(rt);
- if(!GetFrame(i)) {
+ if (!GetFrame(i)) {
return(NULL);
}
- if(rt >= (m_img.start + m_img.delay)) {
- if(!GetFrame(++i)) {
+ if (rt >= (m_img.start + m_img.delay)) {
+ if (!GetFrame(++i)) {
return(NULL);
}
}
@@ -1296,17 +1296,17 @@ STDMETHODIMP_(bool) CVobSubFile::IsAnimated(POSITION pos) STDMETHODIMP CVobSubFile::Render(SubPicDesc& spd, REFERENCE_TIME rt, double fps, RECT& bbox)
{
- if(spd.bpp != 32) {
+ if (spd.bpp != 32) {
return E_INVALIDARG;
}
rt /= 10000;
- if(!GetFrame(GetFrameIdxByTimeStamp(rt))) {
+ if (!GetFrame(GetFrameIdxByTimeStamp(rt))) {
return E_FAIL;
}
- if(rt >= (m_img.start + m_img.delay)) {
+ if (rt >= (m_img.start + m_img.delay)) {
return E_FAIL;
}
@@ -1325,8 +1325,8 @@ STDMETHODIMP CVobSubFile::GetClassID(CLSID* pClassID) STDMETHODIMP_(int) CVobSubFile::GetStreamCount()
{
int iStreamCount = 0;
- for(ptrdiff_t i = 0; i < 32; i++)
- if(m_langs[i].subpos.GetCount()) {
+ for (ptrdiff_t i = 0; i < 32; i++)
+ if (m_langs[i].subpos.GetCount()) {
iStreamCount++;
}
return(iStreamCount);
@@ -1334,23 +1334,23 @@ STDMETHODIMP_(int) CVobSubFile::GetStreamCount() STDMETHODIMP CVobSubFile::GetStreamInfo(int iStream, WCHAR** ppName, LCID* pLCID)
{
- for(ptrdiff_t i = 0; i < 32; i++) {
+ for (ptrdiff_t i = 0; i < 32; i++) {
SubLang& sl = m_langs[i];
- if(sl.subpos.IsEmpty() || iStream-- > 0) {
+ if (sl.subpos.IsEmpty() || iStream-- > 0) {
continue;
}
- if(ppName) {
+ if (ppName) {
*ppName = (WCHAR*)CoTaskMemAlloc((sl.alt.GetLength() + 1) * sizeof(WCHAR));
- if(!(*ppName)) {
+ if (!(*ppName)) {
return E_OUTOFMEMORY;
}
wcscpy(*ppName, CStringW(sl.alt));
}
- if(pLCID) {
+ if (pLCID) {
*pLCID = 0; // TODO: make lcid out of "sl.id"
}
@@ -1364,8 +1364,8 @@ STDMETHODIMP_(int) CVobSubFile::GetStream() {
int iStream = 0;
- for(ptrdiff_t i = 0; i < m_iLang; i++)
- if(!m_langs[i].subpos.IsEmpty()) {
+ for (ptrdiff_t i = 0; i < m_iLang; i++)
+ if (!m_langs[i].subpos.IsEmpty()) {
iStream++;
}
@@ -1374,10 +1374,10 @@ STDMETHODIMP_(int) CVobSubFile::GetStream() STDMETHODIMP CVobSubFile::SetStream(int iStream)
{
- for(ptrdiff_t i = 0; i < 32; i++) {
+ for (ptrdiff_t i = 0; i < 32; i++) {
CAtlArray<SubPos>& sp = m_langs[i].subpos;
- if(sp.IsEmpty() || iStream-- > 0) {
+ if (sp.IsEmpty() || iStream-- > 0) {
continue;
}
@@ -1394,7 +1394,7 @@ STDMETHODIMP CVobSubFile::SetStream(int iStream) STDMETHODIMP CVobSubFile::Reload()
{
CFileStatus s;
- if(!CFile::GetStatus(m_title + _T(".idx"), s)) {
+ if (!CFile::GetStatus(m_title + _T(".idx"), s)) {
return E_FAIL;
}
return !m_title.IsEmpty() && Open(m_title) ? S_OK : E_FAIL;
@@ -1437,11 +1437,11 @@ static void PixelAtBiLinear(RGBQUAD& c, int x, int y, CVobSubImage& src) static void StretchBlt(SubPicDesc& spd, CRect dstrect, CVobSubImage& src)
{
- if(dstrect.IsRectEmpty()) {
+ if (dstrect.IsRectEmpty()) {
return;
}
- if((dstrect & CRect(0, 0, spd.w, spd.h)).IsRectEmpty()) {
+ if ((dstrect & CRect(0, 0, spd.w, spd.h)).IsRectEmpty()) {
return;
}
@@ -1455,33 +1455,33 @@ static void StretchBlt(SubPicDesc& spd, CRect dstrect, CVobSubImage& src) srcdx = (sw << 16) / dw >> 1,
srcdy = (sh << 16) / dh >> 1;
- if(dstrect.left < 0) {
+ if (dstrect.left < 0) {
srcx = -dstrect.left * (srcdx << 1);
dstrect.left = 0;
}
- if(dstrect.top < 0) {
+ if (dstrect.top < 0) {
srcy = -dstrect.top * (srcdy << 1);
dstrect.top = 0;
}
- if(dstrect.right > spd.w) {
+ if (dstrect.right > spd.w) {
dstrect.right = spd.w;
}
- if(dstrect.bottom > spd.h) {
+ if (dstrect.bottom > spd.h) {
dstrect.bottom = spd.h;
}
- if((dstrect & CRect(0, 0, spd.w, spd.h)).IsRectEmpty()) {
+ if ((dstrect & CRect(0, 0, spd.w, spd.h)).IsRectEmpty()) {
return;
}
dw = dstrect.Width();
dh = dstrect.Height();
- for(ptrdiff_t y = dstrect.top; y < dstrect.bottom; y++, srcy += (srcdy<<1)) {
+ for (ptrdiff_t y = dstrect.top; y < dstrect.bottom; y++, srcy += (srcdy<<1)) {
RGBQUAD* ptr = (RGBQUAD*)&((BYTE*)spd.bits)[y*spd.pitch] + dstrect.left;
RGBQUAD* endptr = ptr + dw;
- for(ptrdiff_t sx = srcx; ptr < endptr; sx += (srcdx<<1), ptr++) {
+ for (ptrdiff_t sx = srcx; ptr < endptr; sx += (srcdx<<1), ptr++) {
// PixelAtBiLinear(*ptr, sx, srcy, src);
////
RGBQUAD cc[4];
@@ -1537,7 +1537,7 @@ void CVobSubSettings::SetCustomPal(RGBQUAD* cuspal, int tridx) {
memcpy(m_cuspal, cuspal, sizeof(RGBQUAD)*4);
m_tridx = tridx & 0xf;
- for(ptrdiff_t i = 0; i < 4; i++) {
+ for (ptrdiff_t i = 0; i < 4; i++) {
m_cuspal[i].rgbReserved = (tridx&(1<<i)) ? 0 : 0xff;
}
m_img.Invalidate();
@@ -1548,13 +1548,13 @@ void CVobSubSettings::GetDestrect(CRect& r) int w = MulDiv(m_img.rect.Width(), m_scale_x, 100);
int h = MulDiv(m_img.rect.Height(), m_scale_y, 100);
- if(!m_fAlign) {
+ if (!m_fAlign) {
r.left = MulDiv(m_img.rect.left, m_scale_x, 100);
r.right = MulDiv(m_img.rect.right, m_scale_x, 100);
r.top = MulDiv(m_img.rect.top, m_scale_y, 100);
r.bottom = MulDiv(m_img.rect.bottom, m_scale_y, 100);
} else {
- switch(m_alignhor) {
+ switch (m_alignhor) {
case 0:
r.left = 0;
r.right = w;
@@ -1573,7 +1573,7 @@ void CVobSubSettings::GetDestrect(CRect& r) break;
}
- switch(m_alignver) {
+ switch (m_alignver) {
case 0:
r.top = 0;
r.bottom = h;
@@ -1609,7 +1609,7 @@ void CVobSubSettings::GetDestrect(CRect& r, int w, int h) void CVobSubSettings::SetAlignment(bool fAlign, int x, int y, int hor, int ver)
{
m_fAlign = fAlign;
- if(fAlign) {
+ if (fAlign) {
m_org.x = MulDiv(m_size.cx, x, 100);
m_org.y = MulDiv(m_size.cy, y, 100);
m_alignhor = min(max(hor, 0), 2);
@@ -1646,14 +1646,14 @@ HRESULT CVobSubSettings::Render(SubPicDesc& spd, RECT& bbox) static bool CompressFile(CString fn)
{
- if(GetVersion() < 0) {
+ if (GetVersion() < 0) {
return false;
}
BOOL b = FALSE;
HANDLE h = CreateFile(fn, GENERIC_WRITE|GENERIC_READ, FILE_SHARE_READ, 0, OPEN_EXISTING, FILE_FLAG_SEQUENTIAL_SCAN, 0);
- if(h != INVALID_HANDLE_VALUE) {
+ if (h != INVALID_HANDLE_VALUE) {
USHORT us = COMPRESSION_FORMAT_DEFAULT;
DWORD nBytesReturned;
b = DeviceIoControl(h, FSCTL_SET_COMPRESSION, (LPVOID)&us, 2, NULL, 0, (LPDWORD)&nBytesReturned, NULL);
@@ -1673,27 +1673,27 @@ bool CVobSubFile::SaveWinSubMux(CString fn) TrimExtension(fn);
CStdioFile f;
- if(!f.Open(fn + _T(".sub"), CFile::modeCreate|CFile::modeWrite|CFile::typeText|CFile::shareDenyWrite)) {
+ if (!f.Open(fn + _T(".sub"), CFile::modeCreate|CFile::modeWrite|CFile::typeText|CFile::shareDenyWrite)) {
return false;
}
m_img.Invalidate();
CAutoVectorPtr<BYTE> p4bpp;
- if(!p4bpp.Allocate(720*576/2)) {
+ if (!p4bpp.Allocate(720*576/2)) {
return false;
}
CAtlArray<SubPos>& sp = m_langs[m_iLang].subpos;
- for(size_t i = 0; i < sp.GetCount(); i++) {
- if(!GetFrame(i)) {
+ for (size_t i = 0; i < sp.GetCount(); i++) {
+ if (!GetFrame(i)) {
continue;
}
int pal[4] = {0, 1, 2, 3};
- for(ptrdiff_t j = 0; j < 5; j++) {
- if(j == 4 || !m_img.pal[j].tr) {
+ for (ptrdiff_t j = 0; j < 5; j++) {
+ if (j == 4 || !m_img.pal[j].tr) {
j &= 3;
memset(p4bpp, (j<<4)|j, 720*576/2);
pal[j] ^= pal[0], pal[0] ^= pal[j], pal[j] ^= pal[0];
@@ -1705,7 +1705,7 @@ bool CVobSubFile::SaveWinSubMux(CString fn) DWORD uipal[4+12];
- if(!m_fCustomPal) {
+ if (!m_fCustomPal) {
uipal[0] = *((DWORD*)&m_img.orgpal[m_img.pal[pal[0]].pal]);
uipal[1] = *((DWORD*)&m_img.orgpal[m_img.pal[pal[1]].pal]);
uipal[2] = *((DWORD*)&m_img.orgpal[m_img.pal[pal[2]].pal]);
@@ -1729,13 +1729,13 @@ bool CVobSubFile::SaveWinSubMux(CString fn) int h = m_img.rect.Height()-2;
int pitch = (((w+1)>>1) + 3) & ~3;
- for(ptrdiff_t y = 0; y < h; y++) {
+ for (ptrdiff_t y = 0; y < h; y++) {
DWORD* p = (DWORD*)&m_img.lpPixels[(y+1)*(w+2)+1];
- for(ptrdiff_t x = 0; x < w; x++, p++) {
+ for (ptrdiff_t x = 0; x < w; x++, p++) {
BYTE c = 0;
- if(*p & 0xff000000) {
+ if (*p & 0xff000000) {
DWORD uic = *p & 0xffffff;
palmap.Lookup(uic, c);
}
@@ -1749,10 +1749,10 @@ bool CVobSubFile::SaveWinSubMux(CString fn) ASSERT(t2>t1);
- if(t2 <= 0) {
+ if (t2 <= 0) {
continue;
}
- if(t1 < 0) {
+ if (t1 < 0) {
t1 = 0;
}
@@ -1784,7 +1784,7 @@ bool CVobSubFile::SaveWinSubMux(CString fn) };
CFile bmp;
- if(bmp.Open(bmpfn, CFile::modeCreate|CFile::modeWrite|CFile::typeBinary|CFile::shareDenyWrite)) {
+ if (bmp.Open(bmpfn, CFile::modeCreate|CFile::modeWrite|CFile::typeBinary|CFile::shareDenyWrite)) {
bmp.Write(&fhdr, sizeof(fhdr));
bmp.Write(&ihdr, sizeof(ihdr));
bmp.Write(uipal, sizeof(RGBQUAD)*16);
@@ -1803,7 +1803,7 @@ bool CVobSubFile::SaveScenarist(CString fn) TrimExtension(fn);
CStdioFile f;
- if(!f.Open(fn + _T(".sst"), CFile::modeCreate|CFile::modeWrite|CFile::typeText|CFile::shareDenyWrite)) {
+ if (!f.Open(fn + _T(".sst"), CFile::modeCreate|CFile::modeWrite|CFile::typeText|CFile::shareDenyWrite)) {
return false;
}
@@ -1813,13 +1813,13 @@ bool CVobSubFile::SaveScenarist(CString fn) CString title = fn.Mid(fn.ReverseFind('/')+1);
TCHAR buff[_MAX_PATH], * pFilePart = buff;
- if(GetFullPathName(fn, MAX_PATH, buff, &pFilePart) == 0) {
+ if (GetFullPathName(fn, MAX_PATH, buff, &pFilePart) == 0) {
return false;
}
CString fullpath = CString(buff).Left(pFilePart - buff);
fullpath.TrimRight(_T("\\/"));
- if(fullpath.IsEmpty()) {
+ if (fullpath.IsEmpty()) {
return false;
}
@@ -1893,22 +1893,22 @@ bool CVobSubFile::SaveScenarist(CString fn) memcpy(m_cuspal, newCusPal, sizeof(m_cuspal));
CAutoVectorPtr<BYTE> p4bpp;
- if(!p4bpp.Allocate((m_size.cy-2)*360)) {
+ if (!p4bpp.Allocate((m_size.cy-2)*360)) {
return false;
}
BYTE colormap[16];
- for(ptrdiff_t i = 0; i < 16; i++) {
+ for (ptrdiff_t i = 0; i < 16; i++) {
int idx = 0, maxdif = 255*255*3+1;
- for(ptrdiff_t j = 0; j < 16 && maxdif; j++) {
+ for (ptrdiff_t j = 0; j < 16 && maxdif; j++) {
int rdif = pal[j].rgbRed - m_orgpal[i].rgbRed;
int gdif = pal[j].rgbGreen - m_orgpal[i].rgbGreen;
int bdif = pal[j].rgbBlue - m_orgpal[i].rgbBlue;
int dif = rdif*rdif + gdif*gdif + bdif*bdif;
- if(dif < maxdif) {
+ if (dif < maxdif) {
maxdif = dif;
idx = j;
}
@@ -1920,28 +1920,28 @@ bool CVobSubFile::SaveScenarist(CString fn) int pc[4] = {1, 1, 1, 1}, pa[4] = {15, 15, 15, 0};
CAtlArray<SubPos>& sp = m_langs[m_iLang].subpos;
- for(size_t i = 0, k = 0; i < sp.GetCount(); i++) {
- if(!GetFrame(i)) {
+ for (size_t i = 0, k = 0; i < sp.GetCount(); i++) {
+ if (!GetFrame(i)) {
continue;
}
- for(ptrdiff_t j = 0; j < 5; j++) {
- if(j == 4 || !m_img.pal[j].tr) {
+ for (ptrdiff_t j = 0; j < 5; j++) {
+ if (j == 4 || !m_img.pal[j].tr) {
j &= 3;
memset(p4bpp, (j<<4)|j, (m_size.cy-2)*360);
break;
}
}
- for(ptrdiff_t y = max(m_img.rect.top+1, 2); y < m_img.rect.bottom-1; y++) {
+ for (ptrdiff_t y = max(m_img.rect.top+1, 2); y < m_img.rect.bottom-1; y++) {
ASSERT(m_size.cy-y-1 >= 0);
- if(m_size.cy-y-1 < 0) {
+ if (m_size.cy-y-1 < 0) {
break;
}
DWORD* p = (DWORD*)&m_img.lpPixels[(y-m_img.rect.top)*m_img.rect.Width()+1];
- for(ptrdiff_t x = m_img.rect.left+1; x < m_img.rect.right-1; x++, p++) {
+ for (ptrdiff_t x = m_img.rect.left+1; x < m_img.rect.right-1; x++, p++) {
DWORD rgb = *p&0xffffff;
BYTE c = rgb == 0x0000ff ? 0 : rgb == 0xff0000 ? 1 : rgb == 0x000000 ? 2 : 3;
BYTE& c4bpp = p4bpp[(m_size.cy-y-1)*360+(x>>1)];
@@ -1957,7 +1957,7 @@ bool CVobSubFile::SaveScenarist(CString fn) int c[4] = {colormap[m_img.pal[1].pal], colormap[m_img.pal[2].pal], colormap[m_img.pal[0].pal], colormap[m_img.pal[3].pal]};
c[0]^=c[1], c[1]^=c[0], c[0]^=c[1];
- if(memcmp(pc, c, sizeof(c))) {
+ if (memcmp(pc, c, sizeof(c))) {
memcpy(pc, c, sizeof(c));
str.Format(_T("Color\t (%d %d %d %d)\n"), c[0], c[1], c[2], c[3]);
f.WriteString(str);
@@ -1967,7 +1967,7 @@ bool CVobSubFile::SaveScenarist(CString fn) int a[4] = {m_img.pal[1].tr, m_img.pal[2].tr, m_img.pal[0].tr, m_img.pal[3].tr};
a[0]^=a[1], a[1]^=a[0], a[0]^=a[1];
- if(memcmp(pa, a, sizeof(a))) {
+ if (memcmp(pa, a, sizeof(a))) {
memcpy(pa, a, sizeof(a));
str.Format(_T("Contrast (%d %d %d %d)\n"), a[0], a[1], a[2], a[3]);
f.WriteString(str);
@@ -1981,22 +1981,22 @@ bool CVobSubFile::SaveScenarist(CString fn) int h2 = t2/1000/60/60, m2 = (t2/1000/60)%60, s2 = (t2/1000)%60;
int f2 = (int)((m_size.cy==480?29.97:25)*(t2%1000)/1000);
- if(t2 <= 0) {
+ if (t2 <= 0) {
continue;
}
- if(t1 < 0) {
+ if (t1 < 0) {
t1 = 0;
}
- if(h1 == h2 && m1 == m2 && s1 == s2 && f1 == f2) {
+ if (h1 == h2 && m1 == m2 && s1 == s2 && f1 == f2) {
f2++;
- if(f2 == (m_size.cy == 480 ? 30 : 25)) {
+ if (f2 == (m_size.cy == 480 ? 30 : 25)) {
f2 = 0;
s2++;
- if(s2 == 60) {
+ if (s2 == 60) {
s2 = 0;
m2++;
- if(m2 == 60) {
+ if (m2 == 60) {
m2 = 0;
h2++;
}
@@ -2004,22 +2004,22 @@ bool CVobSubFile::SaveScenarist(CString fn) }
}
- if(i < sp.GetCount()-1) {
+ if (i < sp.GetCount()-1) {
int t3 = sp[i+1].start;
int h3 = t3/1000/60/60, m3 = (t3/1000/60)%60, s3 = (t3/1000)%60;
int f3 = (int)((m_size.cy==480?29.97:25)*(t3%1000)/1000);
- if(h3 == h2 && m3 == m2 && s3 == s2 && f3 == f2) {
+ if (h3 == h2 && m3 == m2 && s3 == s2 && f3 == f2) {
f2--;
- if(f2 == -1) {
+ if (f2 == -1) {
f2 = (m_size.cy == 480 ? 29 : 24);
s2--;
- if(s2 == -1) {
+ if (s2 == -1) {
s2 = 59;
m2--;
- if(m2 == -1) {
+ if (m2 == -1) {
m2 = 59;
- if(h2 > 0) {
+ if (h2 > 0) {
h2--;
}
}
@@ -2028,7 +2028,7 @@ bool CVobSubFile::SaveScenarist(CString fn) }
}
- if(h1 == h2 && m1 == m2 && s1 == s2 && f1 == f2) {
+ if (h1 == h2 && m1 == m2 && s1 == s2 && f1 == f2) {
continue;
}
@@ -2040,7 +2040,7 @@ bool CVobSubFile::SaveScenarist(CString fn) f.WriteString(str);
CFile bmp;
- if(bmp.Open(bmpfn, CFile::modeCreate|CFile::modeWrite|CFile::modeRead|CFile::typeBinary)) {
+ if (bmp.Open(bmpfn, CFile::modeCreate|CFile::modeWrite|CFile::modeRead|CFile::typeBinary)) {
bmp.Write(&fhdr, sizeof(fhdr));
bmp.Write(&ihdr, sizeof(ihdr));
bmp.Write(newCusPal, sizeof(RGBQUAD)*16);
@@ -2062,7 +2062,7 @@ bool CVobSubFile::SaveMaestro(CString fn) TrimExtension(fn);
CStdioFile f;
- if(!f.Open(fn + _T(".son"), CFile::modeCreate|CFile::modeWrite|CFile::typeText|CFile::shareDenyWrite)) {
+ if (!f.Open(fn + _T(".son"), CFile::modeCreate|CFile::modeWrite|CFile::typeText|CFile::shareDenyWrite)) {
return false;
}
@@ -2072,13 +2072,13 @@ bool CVobSubFile::SaveMaestro(CString fn) CString title = fn.Mid(fn.ReverseFind('/')+1);
TCHAR buff[_MAX_PATH], * pFilePart = buff;
- if(GetFullPathName(fn, MAX_PATH, buff, &pFilePart) == 0) {
+ if (GetFullPathName(fn, MAX_PATH, buff, &pFilePart) == 0) {
return false;
}
CString fullpath = CString(buff).Left(pFilePart - buff);
fullpath.TrimRight(_T("\\/"));
- if(fullpath.IsEmpty()) {
+ if (fullpath.IsEmpty()) {
return false;
}
@@ -2128,18 +2128,18 @@ bool CVobSubFile::SaveMaestro(CString fn) memcpy(m_cuspal, newCusPal, sizeof(m_cuspal));
CAutoVectorPtr<BYTE> p4bpp;
- if(!p4bpp.Allocate((m_size.cy-2)*360)) {
+ if (!p4bpp.Allocate((m_size.cy-2)*360)) {
return false;
}
BYTE colormap[16];
- for(ptrdiff_t i = 0; i < 16; i++) {
+ for (ptrdiff_t i = 0; i < 16; i++) {
colormap[i] = i;
}
CFile spf;
- if(spf.Open(fn + _T(".spf"), CFile::modeCreate|CFile::modeWrite|CFile::typeBinary)) {
- for(ptrdiff_t i = 0; i < 16; i++) {
+ if (spf.Open(fn + _T(".spf"), CFile::modeCreate|CFile::modeWrite|CFile::typeBinary)) {
+ for (ptrdiff_t i = 0; i < 16; i++) {
COLORREF c = (m_orgpal[i].rgbBlue<<16) | (m_orgpal[i].rgbGreen<<8) | m_orgpal[i].rgbRed;
spf.Write(&c, sizeof(COLORREF));
}
@@ -2150,28 +2150,28 @@ bool CVobSubFile::SaveMaestro(CString fn) int pc[4] = {1,1,1,1}, pa[4] = {15,15,15,0};
CAtlArray<SubPos>& sp = m_langs[m_iLang].subpos;
- for(size_t i = 0, k = 0; i < sp.GetCount(); i++) {
- if(!GetFrame(i)) {
+ for (size_t i = 0, k = 0; i < sp.GetCount(); i++) {
+ if (!GetFrame(i)) {
continue;
}
- for(ptrdiff_t j = 0; j < 5; j++) {
- if(j == 4 || !m_img.pal[j].tr) {
+ for (ptrdiff_t j = 0; j < 5; j++) {
+ if (j == 4 || !m_img.pal[j].tr) {
j &= 3;
memset(p4bpp, (j<<4)|j, (m_size.cy-2)*360);
break;
}
}
- for(ptrdiff_t y = max(m_img.rect.top+1, 2); y < m_img.rect.bottom-1; y++) {
+ for (ptrdiff_t y = max(m_img.rect.top+1, 2); y < m_img.rect.bottom-1; y++) {
ASSERT(m_size.cy-y-1 >= 0);
- if(m_size.cy-y-1 < 0) {
+ if (m_size.cy-y-1 < 0) {
break;
}
DWORD* p = (DWORD*)&m_img.lpPixels[(y-m_img.rect.top)*m_img.rect.Width()+1];
- for(ptrdiff_t x = m_img.rect.left+1; x < m_img.rect.right-1; x++, p++) {
+ for (ptrdiff_t x = m_img.rect.left+1; x < m_img.rect.right-1; x++, p++) {
DWORD rgb = *p&0xffffff;
BYTE c = rgb == 0x0000ff ? 0 : rgb == 0xff0000 ? 1 : rgb == 0x000000 ? 2 : 3;
BYTE& c4bpp = p4bpp[(m_size.cy-y-1)*360+(x>>1)];
@@ -2186,7 +2186,7 @@ bool CVobSubFile::SaveMaestro(CString fn) // E1, E2, P, Bg
int c[4] = {colormap[m_img.pal[1].pal], colormap[m_img.pal[2].pal], colormap[m_img.pal[0].pal], colormap[m_img.pal[3].pal]};
- if(memcmp(pc, c, sizeof(c))) {
+ if (memcmp(pc, c, sizeof(c))) {
memcpy(pc, c, sizeof(c));
str.Format(_T("Color\t (%d %d %d %d)\n"), c[0], c[1], c[2], c[3]);
f.WriteString(str);
@@ -2195,7 +2195,7 @@ bool CVobSubFile::SaveMaestro(CString fn) // E1, E2, P, Bg
int a[4] = {m_img.pal[1].tr, m_img.pal[2].tr, m_img.pal[0].tr, m_img.pal[3].tr};
- if(memcmp(pa, a, sizeof(a))) {
+ if (memcmp(pa, a, sizeof(a))) {
memcpy(pa, a, sizeof(a));
str.Format(_T("Contrast (%d %d %d %d)\n"), a[0], a[1], a[2], a[3]);
f.WriteString(str);
@@ -2209,22 +2209,22 @@ bool CVobSubFile::SaveMaestro(CString fn) int h2 = t2/1000/60/60, m2 = (t2/1000/60)%60, s2 = (t2/1000)%60;
int f2 = (int)((m_size.cy==480?29.97:25)*(t2%1000)/1000);
- if(t2 <= 0) {
+ if (t2 <= 0) {
continue;
}
- if(t1 < 0) {
+ if (t1 < 0) {
t1 = 0;
}
- if(h1 == h2 && m1 == m2 && s1 == s2 && f1 == f2) {
+ if (h1 == h2 && m1 == m2 && s1 == s2 && f1 == f2) {
f2++;
- if(f2 == (m_size.cy == 480 ? 30 : 25)) {
+ if (f2 == (m_size.cy == 480 ? 30 : 25)) {
f2 = 0;
s2++;
- if(s2 == 60) {
+ if (s2 == 60) {
s2 = 0;
m2++;
- if(m2 == 60) {
+ if (m2 == 60) {
m2 = 0;
h2++;
}
@@ -2232,22 +2232,22 @@ bool CVobSubFile::SaveMaestro(CString fn) }
}
- if(i < sp.GetCount()-1) {
+ if (i < sp.GetCount()-1) {
int t3 = sp[i+1].start;
int h3 = t3/1000/60/60, m3 = (t3/1000/60)%60, s3 = (t3/1000)%60;
int f3 = (int)((m_size.cy==480?29.97:25)*(t3%1000)/1000);
- if(h3 == h2 && m3 == m2 && s3 == s2 && f3 == f2) {
+ if (h3 == h2 && m3 == m2 && s3 == s2 && f3 == f2) {
f2--;
- if(f2 == -1) {
+ if (f2 == -1) {
f2 = (m_size.cy == 480 ? 29 : 24);
s2--;
- if(s2 == -1) {
+ if (s2 == -1) {
s2 = 59;
m2--;
- if(m2 == -1) {
+ if (m2 == -1) {
m2 = 59;
- if(h2 > 0) {
+ if (h2 > 0) {
h2--;
}
}
@@ -2256,7 +2256,7 @@ bool CVobSubFile::SaveMaestro(CString fn) }
}
- if(h1 == h2 && m1 == m2 && s1 == s2 && f1 == f2) {
+ if (h1 == h2 && m1 == m2 && s1 == s2 && f1 == f2) {
continue;
}
@@ -2268,7 +2268,7 @@ bool CVobSubFile::SaveMaestro(CString fn) f.WriteString(str);
CFile bmp;
- if(bmp.Open(bmpfn, CFile::modeCreate|CFile::modeWrite|CFile::typeBinary)) {
+ if (bmp.Open(bmpfn, CFile::modeCreate|CFile::modeWrite|CFile::typeBinary)) {
bmp.Write(&fhdr, sizeof(fhdr));
bmp.Write(&ihdr, sizeof(ihdr));
bmp.Write(newCusPal, sizeof(RGBQUAD)*16);
@@ -2306,67 +2306,67 @@ void CVobSubStream::Open(CString name, BYTE* pData, int len) CAtlList<CString> lines;
Explode(CString(CStringA((CHAR*)pData, len)), lines, '\n');
- while(lines.GetCount()) {
+ while (lines.GetCount()) {
CAtlList<CString> sl;
Explode(lines.RemoveHead(), sl, ':', 2);
- if(sl.GetCount() != 2) {
+ if (sl.GetCount() != 2) {
continue;
}
CString key = sl.GetHead();
CString value = sl.GetTail();
- if(key == _T("size")) {
+ if (key == _T("size")) {
_stscanf(value, _T("%dx %d"), &m_size.cx, &m_size.cy);
- } else if(key == _T("org")) {
+ } else if (key == _T("org")) {
_stscanf(value, _T("%d, %d"), &m_org.x, &m_org.y);
- } else if(key == _T("scale")) {
+ } else if (key == _T("scale")) {
_stscanf(value, _T("%d%%, %d%%"), &m_scale_x, &m_scale_y);
- } else if(key == _T("alpha")) {
+ } else if (key == _T("alpha")) {
_stscanf(value, _T("%d%%"), &m_alpha);
- } else if(key == _T("smooth"))
+ } else if (key == _T("smooth"))
m_fSmooth =
value == _T("0") || value == _T("OFF") ? 0 :
value == _T("1") || value == _T("ON") ? 1 :
value == _T("2") || value == _T("OLD") ? 2 :
0;
- else if(key == _T("align")) {
+ else if (key == _T("align")) {
Explode(value, sl, ' ');
- if(sl.GetCount() == 4) {
+ if (sl.GetCount() == 4) {
sl.RemoveAt(sl.FindIndex(1));
}
- if(sl.GetCount() == 3) {
+ if (sl.GetCount() == 3) {
m_fAlign = sl.RemoveHead() == _T("ON");
CString hor = sl.GetHead(), ver = sl.GetTail();
m_alignhor = hor == _T("LEFT") ? 0 : hor == _T("CENTER") ? 1 : hor == _T("RIGHT") ? 2 : 1;
m_alignver = ver == _T("TOP") ? 0 : ver == _T("CENTER") ? 1 : ver == _T("BOTTOM") ? 2 : 2;
}
- } else if(key == _T("fade in/out")) {
+ } else if (key == _T("fade in/out")) {
_stscanf(value, _T("%d%, %d%"), &m_fadein, &m_fadeout);
- } else if(key == _T("time offset")) {
+ } else if (key == _T("time offset")) {
m_toff = _tcstol(value, NULL, 10);
- } else if(key == _T("forced subs")) {
+ } else if (key == _T("forced subs")) {
m_fOnlyShowForcedSubs = value == _T("1") || value == _T("ON");
- } else if(key == _T("palette")) {
+ } else if (key == _T("palette")) {
Explode(value, sl, ',', 16);
- for(ptrdiff_t i = 0; i < 16 && sl.GetCount(); i++) {
+ for (ptrdiff_t i = 0; i < 16 && sl.GetCount(); i++) {
*(DWORD*)&m_orgpal[i] = _tcstol(sl.RemoveHead(), NULL, 16);
}
- } else if(key == _T("custom colors")) {
+ } else if (key == _T("custom colors")) {
m_fCustomPal = Explode(value, sl, ',', 3) == _T("ON");
- if(sl.GetCount() == 3) {
+ if (sl.GetCount() == 3) {
sl.RemoveHead();
CAtlList<CString> tridx, colors;
Explode(sl.RemoveHead(), tridx, ':', 2);
- if(tridx.RemoveHead() == _T("tridx")) {
+ if (tridx.RemoveHead() == _T("tridx")) {
TCHAR tr[4];
_stscanf(tridx.RemoveHead(), _T("%c%c%c%c"), &tr[0], &tr[1], &tr[2], &tr[3]);
- for(ptrdiff_t i = 0; i < 4; i++) {
+ for (ptrdiff_t i = 0; i < 4; i++) {
m_tridx |= ((tr[i]=='1')?1:0)<<i;
}
}
Explode(sl.RemoveHead(), colors, ':', 2);
- if(colors.RemoveHead() == _T("colors")) {
+ if (colors.RemoveHead() == _T("colors")) {
Explode(colors.RemoveHead(), colors, ',', 4);
- for(ptrdiff_t i = 0; i < 4 && colors.GetCount(); i++) {
+ for (ptrdiff_t i = 0; i < 4 && colors.GetCount(); i++) {
*(DWORD*)&m_cuspal[i] = _tcstol(colors.RemoveHead(), NULL, 16);
}
}
@@ -2377,7 +2377,7 @@ void CVobSubStream::Open(CString name, BYTE* pData, int len) void CVobSubStream::Add(REFERENCE_TIME tStart, REFERENCE_TIME tStop, BYTE* pData, int len)
{
- if(len <= 4 || ((pData[0]<<8)|pData[1]) != len) {
+ if (len <= 4 || ((pData[0]<<8)|pData[1]) != len) {
return;
}
@@ -2391,7 +2391,7 @@ void CVobSubStream::Add(REFERENCE_TIME tStart, REFERENCE_TIME tStop, BYTE* pData memcpy(p->pData.GetData(), pData, p->pData.GetCount());
CAutoLock cAutoLock(&m_csSubPics);
- while(m_subpics.GetCount() && m_subpics.GetTail()->tStart >= tStart) {
+ while (m_subpics.GetCount() && m_subpics.GetTail()->tStart >= tStart) {
m_subpics.RemoveTail();
m_img.iIdx = -1;
}
@@ -2423,10 +2423,10 @@ STDMETHODIMP_(POSITION) CVobSubStream::GetStartPosition(REFERENCE_TIME rt, doubl {
CAutoLock cAutoLock(&m_csSubPics);
POSITION pos = m_subpics.GetTailPosition();
- for(; pos; m_subpics.GetPrev(pos)) {
+ for (; pos; m_subpics.GetPrev(pos)) {
SubPic* sp = m_subpics.GetAt(pos);
- if(sp->tStart <= rt) {
- if(sp->tStop <= rt) {
+ if (sp->tStart <= rt) {
+ if (sp->tStop <= rt) {
m_subpics.GetNext(pos);
}
break;
@@ -2461,15 +2461,15 @@ STDMETHODIMP_(bool) CVobSubStream::IsAnimated(POSITION pos) STDMETHODIMP CVobSubStream::Render(SubPicDesc& spd, REFERENCE_TIME rt, double fps, RECT& bbox)
{
- if(spd.bpp != 32) {
+ if (spd.bpp != 32) {
return E_INVALIDARG;
}
POSITION pos = m_subpics.GetTailPosition();
- for(; pos; m_subpics.GetPrev(pos)) {
+ for (; pos; m_subpics.GetPrev(pos)) {
SubPic* sp = m_subpics.GetAt(pos);
- if(sp->tStart <= rt && rt < sp->tStop) {
- if(m_img.iIdx != (int)pos) {
+ if (sp->tStart <= rt && rt < sp->tStop) {
+ if (m_img.iIdx != (int)pos) {
BYTE* pData = sp->pData.GetData();
m_img.Decode(
pData, (pData[0]<<8)|pData[1], (pData[2]<<8)|pData[3],
@@ -2502,15 +2502,15 @@ STDMETHODIMP CVobSubStream::GetStreamInfo(int i, WCHAR** ppName, LCID* pLCID) {
CAutoLock cAutoLock(&m_csSubPics);
- if(ppName) {
+ if (ppName) {
*ppName = (WCHAR*)CoTaskMemAlloc((m_name.GetLength() + 1) * sizeof(WCHAR));
- if(!(*ppName)) {
+ if (!(*ppName)) {
return E_OUTOFMEMORY;
}
wcscpy(*ppName, CStringW(m_name));
}
- if(pLCID) {
+ if (pLCID) {
*pLCID = 0; // TODO
}
diff --git a/src/Subtitles/VobSubFileRipper.cpp b/src/Subtitles/VobSubFileRipper.cpp index 926777235..0efee751f 100644 --- a/src/Subtitles/VobSubFileRipper.cpp +++ b/src/Subtitles/VobSubFileRipper.cpp @@ -56,7 +56,7 @@ STDMETHODIMP CVobSubFileRipper::NonDelegatingQueryInterface(REFIID riid, void** void CVobSubFileRipper::Log(log_t type, LPCTSTR lpszFormat, ...)
{
CAutoLock cAutoLock(&m_csCallback);
- if(!m_pCallback) {
+ if (!m_pCallback) {
return;
}
@@ -68,7 +68,7 @@ void CVobSubFileRipper::Log(log_t type, LPCTSTR lpszFormat, ...) va_end(args);
CString msg;
- switch(type) {
+ switch (type) {
default:
case LOG_INFO:
msg = _T("");
@@ -89,7 +89,7 @@ void CVobSubFileRipper::Log(log_t type, LPCTSTR lpszFormat, ...) void CVobSubFileRipper::Progress(double progress)
{
CAutoLock cAutoLock(&m_csCallback);
- if(!m_pCallback) {
+ if (!m_pCallback) {
return;
}
@@ -99,7 +99,7 @@ void CVobSubFileRipper::Progress(double progress) void CVobSubFileRipper::Finished(bool fSucceeded)
{
CAutoLock cAutoLock(&m_csCallback);
- if(!m_pCallback) {
+ if (!m_pCallback) {
return;
}
@@ -124,13 +124,13 @@ bool CVobSubFileRipper::LoadIfo(CString fn) CString str;
CFileStatus status;
- if(!CFileGetStatus(fn, status) || !status.m_size) {
+ if (!CFileGetStatus(fn, status) || !status.m_size) {
Log(LOG_ERROR, _T("Invalid ifo"));
return false;
}
CFile f;
- if(!f.Open(fn, CFile::modeRead|CFile::typeBinary|CFile::shareDenyNone)) {
+ if (!f.Open(fn, CFile::modeRead|CFile::typeBinary|CFile::shareDenyNone)) {
Log(LOG_ERROR, _T("Cannot open ifo"));
return false;
}
@@ -140,7 +140,7 @@ bool CVobSubFileRipper::LoadIfo(CString fn) char hdr[13];
f.Read(hdr, 12);
hdr[12] = 0;
- if(strcmp(hdr, "DVDVIDEO-VTS")) {
+ if (strcmp(hdr, "DVDVIDEO-VTS")) {
Log(LOG_ERROR, _T("Not a Video Title Set IFO file!"));
return false;
}
@@ -155,10 +155,10 @@ bool CVobSubFileRipper::LoadIfo(CString fn) int len = 0;
ReadBEw(len);
- for(ptrdiff_t i = 0; i < len; i++) {
+ for (ptrdiff_t i = 0; i < len; i++) {
f.Seek(2, CFile::current); // 01 00 ?
ReadBEw(ids[i]);
- if(ids[i] == 0) {
+ if (ids[i] == 0) {
ids[i] = '--';
}
f.Seek(2, CFile::current); // 00 00 ?
@@ -197,7 +197,7 @@ bool CVobSubFileRipper::LoadIfo(CString fn) m_rd.pgcs.RemoveAll();
m_rd.pgcs.SetCount(nPGC);
- for(ptrdiff_t i = 0; i < nPGC; i++) {
+ for (ptrdiff_t i = 0; i < nPGC; i++) {
PGC& pgc = m_rd.pgcs[i];
f.Seek(pgcpos + 8 + i*8 + 4, CFile::begin);
@@ -221,13 +221,13 @@ bool CVobSubFileRipper::LoadIfo(CString fn) f.Seek(offset + 0x1c, CFile::begin);
f.Read(splinfo, 32*4);
- for(ptrdiff_t j = 0; j < 32; j++) {
- if(splinfo[j].id1 || splinfo[i].id2) {
+ for (ptrdiff_t j = 0; j < 32; j++) {
+ if (splinfo[j].id1 || splinfo[i].id2) {
WORD tmpids[32];
memset(tmpids, 0, sizeof(tmpids));
- for(j = 0; j < 32; j++) {
- if(!(splinfo[j].res1 & 0x80)) {
+ for (j = 0; j < 32; j++) {
+ if (!(splinfo[j].res1 & 0x80)) {
break;
}
@@ -243,7 +243,7 @@ bool CVobSubFileRipper::LoadIfo(CString fn) f.Seek(offset + 0xa4, CFile::begin);
- for(ptrdiff_t j = 0; j < 16; j++) {
+ for (ptrdiff_t j = 0; j < 16; j++) {
BYTE y, u, v, tmp;
f.Read(&tmp, 1);
@@ -283,7 +283,7 @@ bool CVobSubFileRipper::LoadIfo(CString fn) //
f.Seek(offset + vobcelloff, CFile::begin);
- for(ptrdiff_t j = 0; j < nCells; j++) {
+ for (ptrdiff_t j = 0; j < nCells; j++) {
ReadBEw(pgc.angles[0][j].vob);
ReadBEw(pgc.angles[0][j].cell);
}
@@ -297,10 +297,10 @@ bool CVobSubFileRipper::LoadIfo(CString fn) pgc.nAngles = 0;
f.Seek(offset + celladdroff, CFile::begin);
- for(ptrdiff_t j = 0; j < nCells; j++) {
+ for (ptrdiff_t j = 0; j < nCells; j++) {
BYTE b;
ReadBEb(b);
- switch(b>>6) {
+ switch (b>>6) {
case 0:
iAngle = 0;
break; // normal
@@ -324,7 +324,7 @@ bool CVobSubFileRipper::LoadIfo(CString fn) ReadBEdw(pgc.angles[0][j].end);
float fps;
- switch((pgc.angles[0][j].tTime>>6)&0x3) {
+ switch ((pgc.angles[0][j].tTime>>6)&0x3) {
default:
case 3:
fps = 30;
@@ -342,7 +342,7 @@ bool CVobSubFileRipper::LoadIfo(CString fn) pgc.angles[0][j].tTime = (DWORD)((((hh*60+mm)*60+ss)*1000+ms)*rate);
// time discontinuity
- if(b&0x02) {
+ if (b&0x02) {
tOffset = tTotal;
}
pgc.angles[0][j].fDiscontinuity = !!(b&0x02);
@@ -353,18 +353,18 @@ bool CVobSubFileRipper::LoadIfo(CString fn) tTotal += pgc.angles[0][j].tTime;
}
- for(iAngle = 1; iAngle <= 9; iAngle++) {
+ for (iAngle = 1; iAngle <= 9; iAngle++) {
tOffset = tTotal = 0;
- for(ptrdiff_t j = 0, k = 0; j < nCells; j++) {
- if(pgc.angles[0][j].iAngle != 0
+ for (ptrdiff_t j = 0, k = 0; j < nCells; j++) {
+ if (pgc.angles[0][j].iAngle != 0
&& pgc.angles[0][j].iAngle != iAngle) {
continue;
}
pgc.angles[iAngle].Add(pgc.angles[0][j]);
- if(pgc.angles[iAngle][k].fDiscontinuity) {
+ if (pgc.angles[iAngle][k].fDiscontinuity) {
tOffset = tTotal;
}
@@ -432,33 +432,33 @@ bool CVobSubFileRipper::LoadVob(CString fn) }
*/
CAtlList<CString> vobs;
- if(!m_vob.Open(fn, vobs/*m_vobs*/)) {
+ if (!m_vob.Open(fn, vobs/*m_vobs*/)) {
Log(LOG_ERROR, _T("Cannot open vob sequence"));
return false;
}
- if(vobs.GetCount() <= 0) {
+ if (vobs.GetCount() <= 0) {
Log(LOG_ERROR, _T("Nothing found! (%s*.vob)"), fn);
return false;
}
POSITION pos = vobs.GetHeadPosition();
- while(pos) {
+ while (pos) {
Log(LOG_INFO, _T("Found ") + vobs.GetNext(pos));
}
- if(m_vob.IsDVD()) {
+ if (m_vob.IsDVD()) {
Log(LOG_INFO, _T("DVD detected..."));
BYTE key[5];
- if(m_vob.HasDiscKey(key)) {
+ if (m_vob.HasDiscKey(key)) {
Log(LOG_INFO, _T("Disc key: %02x%02x%02x%02x%02x"), key[0], key[1], key[2], key[3], key[4]);
} else {
Log(LOG_WARNING, _T("Couldn't get the disc key"));
}
- if(m_vob.HasTitleKey(key)) {
+ if (m_vob.HasTitleKey(key)) {
Log(LOG_INFO, _T("Title key: %02x%02x%02x%02x%02x"), key[0], key[1], key[2], key[3], key[4]);
} else {
Log(LOG_WARNING, _T("Couldn't get the title key"));
@@ -467,7 +467,7 @@ bool CVobSubFileRipper::LoadVob(CString fn) BYTE buff[2048];
m_vob.Seek(0);
- if(!m_vob.Read(buff)) {
+ if (!m_vob.Read(buff)) {
Log(LOG_ERROR, _T("Can't read vob, please unlock it with a software player!"));
return false;
}
@@ -481,12 +481,12 @@ DWORD CVobSubFileRipper::ThreadProc() {
SetThreadPriority(m_hThread, THREAD_PRIORITY_BELOW_NORMAL);
- while(1) {
+ while (1) {
DWORD cmd = GetRequest();
m_fThreadActive = true;
- switch(cmd) {
+ switch (cmd) {
case CMD_EXIT:
Reply(S_OK);
return 0;
@@ -522,26 +522,26 @@ bool CVobSubFileRipper::Create() {
CAutoLock cAutoLock(&m_csAccessLock);
- if(m_rd.iSelPGC < 0 || (size_t)m_rd.iSelPGC >= m_rd.pgcs.GetCount()) {
+ if (m_rd.iSelPGC < 0 || (size_t)m_rd.iSelPGC >= m_rd.pgcs.GetCount()) {
Log(LOG_ERROR, _T("Invalid program chain number (%d)!"), m_rd.iSelPGC);
return false;
}
PGC& pgc = m_rd.pgcs[m_rd.iSelPGC];
- if(pgc.iSelAngle < 0 || pgc.iSelAngle > 9 || pgc.angles[pgc.iSelAngle].GetCount() == 0) {
+ if (pgc.iSelAngle < 0 || pgc.iSelAngle > 9 || pgc.angles[pgc.iSelAngle].GetCount() == 0) {
Log(LOG_ERROR, _T("Invalid angle number (%d)!"), pgc.iSelAngle);
return false;
}
CAtlArray<vc_t>& angle = pgc.angles[pgc.iSelAngle];
- if(m_rd.selids.GetCount() == 0 && !m_rd.fClosedCaption) {
+ if (m_rd.selids.GetCount() == 0 && !m_rd.fClosedCaption) {
Log(LOG_ERROR, _T("No valid stream set to be extacted!"));
return false;
}
- if(m_rd.selvcs.GetCount() == 0) {
+ if (m_rd.selvcs.GetCount() == 0) {
Log(LOG_ERROR, _T("No valid vob/cell id set to be extacted!"));
return false;
}
@@ -567,8 +567,8 @@ bool CVobSubFileRipper::Create() int PTSframeoffset = 0, minPTSframeoffset = 0;
- if(m_rd.fResetTime) {
- for(size_t i = 0; i < angle.GetCount() && (UINT)((angle[i].vob<<16)|angle[i].cell) != m_rd.selvcs[0]; i++) {
+ if (m_rd.fResetTime) {
+ for (size_t i = 0; i < angle.GetCount() && (UINT)((angle[i].vob<<16)|angle[i].cell) != m_rd.selvcs[0]; i++) {
tStart += angle[i].tTime;
}
@@ -578,18 +578,18 @@ bool CVobSubFileRipper::Create() CAtlMap<DWORD, int> selvcmap;
selvcmap.RemoveAll();
- for(size_t i = 0; i < m_rd.selvcs.GetCount(); i++) {
+ for (size_t i = 0; i < m_rd.selvcs.GetCount(); i++) {
selvcmap[m_rd.selvcs[i]] = 90000;
}
CAtlArray<vcchunk> chunks, foundchunks, loadedchunks;
- if(m_vob.IsDVD()) {
+ if (m_vob.IsDVD()) {
Log(LOG_INFO, _T("Indexing mode: DVD"));
- for(size_t i = 0; i < angle.GetCount(); i++) {
+ for (size_t i = 0; i < angle.GetCount(); i++) {
DWORD vc = (angle[i].vob<<16)|angle[i].cell;
- if(!selvcmap.Lookup(vc)) {
+ if (!selvcmap.Lookup(vc)) {
continue;
}
@@ -599,12 +599,12 @@ bool CVobSubFileRipper::Create() Log(LOG_INFO, _T("Adding: 0x%x - 0x%x (lba) for vob %d cell %d"),
angle[i].start, angle[i].end, angle[i].vob, angle[i].cell);
}
- } else if(LoadChunks(loadedchunks)) {
+ } else if (LoadChunks(loadedchunks)) {
Log(LOG_INFO, _T("Indexing mode: File"));
- for(size_t i = 0; i < loadedchunks.GetCount(); i++) {
+ for (size_t i = 0; i < loadedchunks.GetCount(); i++) {
DWORD vcid = loadedchunks[i].vc;
- if(!selvcmap.Lookup(vcid)) {
+ if (!selvcmap.Lookup(vcid)) {
continue;
}
@@ -621,52 +621,52 @@ bool CVobSubFileRipper::Create() }
__int64 sizedone = 0, sizetotal = 0;
- for(size_t i = 0; i < chunks.GetCount(); i++) {
+ for (size_t i = 0; i < chunks.GetCount(); i++) {
sizetotal += chunks[i].end - chunks[i].start;
}
- for(size_t i = 0; !m_fBreakThread && i < chunks.GetCount(); i++) {
+ for (size_t i = 0; !m_fBreakThread && i < chunks.GetCount(); i++) {
__int64 curpos = chunks[i].start, endpos = chunks[i].end;
vcchunk curchunk = {curpos, curpos, chunks[i].vc};
- for(m_vob.Seek((int)(curpos/2048)); !m_fBreakThread && curpos < endpos; curpos += 2048, sizedone += 2048) {
- if(!(curpos&0x7ffff)) {
+ for (m_vob.Seek((int)(curpos/2048)); !m_fBreakThread && curpos < endpos; curpos += 2048, sizedone += 2048) {
+ if (!(curpos&0x7ffff)) {
Progress(1.0 * sizedone / sizetotal);
}
static BYTE buff[2048];
- if(!m_vob.Read(buff)) {
+ if (!m_vob.Read(buff)) {
Log(LOG_ERROR, _T("Cannot read, either locked dvd or truncated/missing files!"));
return false;
}
curchunk.end = curpos;
- if(buff[0x14] & 0x30) {
- if(!vd.m_fFoundKey) {
+ if (buff[0x14] & 0x30) {
+ if (!vd.m_fFoundKey) {
Log(LOG_INFO, _T("Encrypted sector found, searching key..."));
__int64 savepos = curpos;
m_vob.Seek(0);
- for(__int64 pos = 0; !m_fBreakThread && pos < endpos; pos += 2048) {
- if(!m_vob.Read(buff)) {
+ for (__int64 pos = 0; !m_fBreakThread && pos < endpos; pos += 2048) {
+ if (!m_vob.Read(buff)) {
Log(LOG_ERROR, _T("Cannot read, either locked dvd or truncated/missing files!"));
return false;
}
- if(vd.FindKey(buff)) {
+ if (vd.FindKey(buff)) {
break;
}
}
- if(m_fBreakThread) {
+ if (m_fBreakThread) {
break;
}
- if(!vd.m_fFoundKey) {
+ if (!vd.m_fFoundKey) {
Log(LOG_ERROR, _T("Key not found, can't decrypt!"));
return false;
}
@@ -680,10 +680,10 @@ bool CVobSubFileRipper::Create() vd.Decrypt(buff);
}
- if(*((DWORD*)&buff[0]) != 0xba010000) {
+ if (*((DWORD*)&buff[0]) != 0xba010000) {
Log(LOG_WARNING, _T("Bad sector header at block %08d!"), (int)(curpos/2048));
- if(AfxMessageBox(_T("Bad packet header found, do you want to continue?"), MB_YESNO) == IDNO) {
+ if (AfxMessageBox(_T("Bad packet header found, do you want to continue?"), MB_YESNO) == IDNO) {
Log(LOG_ERROR, _T("Terminated!"));
return false;
}
@@ -699,7 +699,7 @@ bool CVobSubFileRipper::Create() bool hasPTS = false;
- if((*(DWORD*)&buff[0x0e] == 0xe0010000 || *(DWORD*)&buff[0x0e] == 0xbd010000)
+ if ((*(DWORD*)&buff[0x0e] == 0xe0010000 || *(DWORD*)&buff[0x0e] == 0xbd010000)
&& buff[0x15] & 0x80) {
PTS = (__int64)(buff[0x17] & 0x0e) << 29 // 32-30 (+marker)
| ((__int64)(buff[0x18]) << 22) // 29-22
@@ -710,10 +710,10 @@ bool CVobSubFileRipper::Create() hasPTS = true;
}
- if(*((DWORD*)&buff[0x0e]) == 0xbb010000) {
+ if (*((DWORD*)&buff[0x0e]) == 0xbb010000) {
fNavpackFound = true;
- if(vob == buff[0x420] && cell == buff[0x422]) {
+ if (vob == buff[0x420] && cell == buff[0x422]) {
continue;
}
@@ -722,8 +722,8 @@ bool CVobSubFileRipper::Create() tOffset = tTotal = 0;
- for(size_t i = 0; i < angle.GetCount(); i++) {
- if(angle[i].vob == vob && angle[i].cell == cell) {
+ for (size_t i = 0; i < angle.GetCount(); i++) {
+ if (angle[i].vob == vob && angle[i].cell == cell) {
tPrevOffset = tOffset;
tOffset = (__int64)angle[i].tOffset;
tTotal = (__int64)angle[i].tTotal;
@@ -733,8 +733,8 @@ bool CVobSubFileRipper::Create() }
}
- if(curchunk.vc != (DWORD)((vob<<16)|cell)) {
- if(curchunk.vc != 0) {
+ if (curchunk.vc != (DWORD)((vob<<16)|cell)) {
+ if (curchunk.vc != 0) {
foundchunks.Add(curchunk);
}
curchunk.start = curchunk.end = curpos;
@@ -744,7 +744,7 @@ bool CVobSubFileRipper::Create() CString str, str2;
str.Format(_T("v%02d c%02d lba%08d"), vob, cell, (int)(curpos/2048));
UINT vcid = (vob<<16)|cell;
- if(!selvcmap.Lookup(vcid, minPTSframeoffset)) {
+ if (!selvcmap.Lookup(vcid, minPTSframeoffset)) {
str2 = _T(", skipping");
} else str2.Format(_T(", total=%I64dms, off=%I64dms, corr=%I64dms, discont.:%d"),
tTotal, tOffset, -tStart, (int)fDiscontinuity);
@@ -752,13 +752,13 @@ bool CVobSubFileRipper::Create() }
DWORD vcid = (vob<<16)|cell;
- if(!selvcmap.Lookup(vcid, minPTSframeoffset)) {
+ if (!selvcmap.Lookup(vcid, minPTSframeoffset)) {
continue;
}
- if(hasPTS && fDiscontinuity && !fDiscontinuityFixApplied) {
+ if (hasPTS && fDiscontinuity && !fDiscontinuityFixApplied) {
__int64 tDiff = tOffset - tPrevOffset;
- if(tDiff > 0 && tDiff < (PTS/90+1000)) {
+ if (tDiff > 0 && tDiff < (PTS/90+1000)) {
CString str;
str.Format(_T("False discontinuity detected, correcting time by %I64dms"), -tDiff);
Log(LOG_INFO, str);
@@ -768,23 +768,23 @@ bool CVobSubFileRipper::Create() fDiscontinuityFixApplied = true;
}
- if(*(DWORD*)&buff[0x0e] == 0xe0010000) {
- if(fDiscontinuity) {
- if(PTS < minPTSframeoffset) {
+ if (*(DWORD*)&buff[0x0e] == 0xe0010000) {
+ if (fDiscontinuity) {
+ if (PTS < minPTSframeoffset) {
selvcmap[vcid] = PTSframeoffset = PTS;
}
fDiscontinuity = false;
}
- if(m_rd.fClosedCaption) {
+ if (m_rd.fClosedCaption) {
ccdec.ExtractCC(buff, 2048, tOffset + ((PTS - PTSframeoffset) / 90) - tStart);
}
- } else if(*(DWORD*)&buff[0x0e] == 0xbd010000) {
+ } else if (*(DWORD*)&buff[0x0e] == 0xbd010000) {
BYTE id = buff[0x17 + buff[0x16]], iLang = id&0x1f;
- if((id & 0xe0) == 0x20 && m_rd.selids.Lookup(iLang)) {
- if(hasPTS) {
+ if ((id & 0xe0) == 0x20 && m_rd.selids.Lookup(iLang)) {
+ if (hasPTS) {
SubPos sb;
sb.filepos = m_sub.GetPosition();
sb.start = tOffset + ((PTS - PTSframeoffset) / 90) - tStart;
@@ -800,8 +800,8 @@ bool CVobSubFileRipper::Create() }
}
- if(curchunk.vc != (DWORD)((vob<<16)|cell)) {
- if(curchunk.vc != 0) {
+ if (curchunk.vc != (DWORD)((vob<<16)|cell)) {
+ if (curchunk.vc != 0) {
foundchunks.Add(curchunk);
}
curchunk.start = curchunk.end = curpos;
@@ -809,15 +809,15 @@ bool CVobSubFileRipper::Create() }
}
- if(sizedone < sizetotal) {
+ if (sizedone < sizetotal) {
Log(LOG_ERROR, _T("Indexing terminated before reaching the end!"));
Progress(0);
return false;
}
- if(!fNavpackFound) {
+ if (!fNavpackFound) {
Log(LOG_ERROR, _T("Could not find any system header start code! (0x000001bb)"));
- if(!m_vob.IsDVD()) {
+ if (!m_vob.IsDVD()) {
Log(LOG_ERROR, _T("Make sure the ripper doesn't strip these packets."));
}
Progress(0);
@@ -827,8 +827,8 @@ bool CVobSubFileRipper::Create() Log(LOG_INFO, _T("Indexing finished"));
Progress(1);
- for(ptrdiff_t i = 0; i < 32; i++) {
- if(m_iLang == -1 && m_langs[i].subpos.GetCount() > 0) {
+ for (ptrdiff_t i = 0; i < 32; i++) {
+ if (m_iLang == -1 && m_langs[i].subpos.GetCount() > 0) {
m_iLang = i;
}
m_langs[i].id = pgc.ids[i];
@@ -837,16 +837,16 @@ bool CVobSubFileRipper::Create() CAtlArray<SubPos>& sp = m_langs[i].subpos;
qsort(sp.GetData(), sp.GetCount(), sizeof(SubPos), SubPosSortProc);
- if(m_rd.fForcedOnly) {
+ if (m_rd.fForcedOnly) {
Log(LOG_INFO, _T("Searching for forced subs..."));
Progress(0);
- for(ptrdiff_t j = 0, len = sp.GetCount(); j < len; j++) {
+ for (ptrdiff_t j = 0, len = sp.GetCount(); j < len; j++) {
Progress(1.0 * j / len);
sp[j].fValid = false;
int packetsize = 0, datasize = 0;
- if(BYTE* buff = GetPacket(j, packetsize, datasize, i)) {
+ if (BYTE* buff = GetPacket(j, packetsize, datasize, i)) {
m_img.GetPacketInfo(buff, packetsize, datasize);
sp[j].fValid = m_img.fForced;
delete [] buff;
@@ -859,8 +859,8 @@ bool CVobSubFileRipper::Create() Log(LOG_INFO, _T("Saving files..."));
- if(m_iLang != -1) {
- if(!Save(m_title)) {
+ if (m_iLang != -1) {
+ if (!Save(m_title)) {
Log(LOG_ERROR, _T("Could not save output files!"));
return false;
}
@@ -868,8 +868,8 @@ bool CVobSubFileRipper::Create() Log(LOG_INFO, _T("Subtitles saved"));
- if(!m_vob.IsDVD() && loadedchunks.GetCount() == 0) {
- if(SaveChunks(foundchunks)) {
+ if (!m_vob.IsDVD() && loadedchunks.GetCount() == 0) {
+ if (SaveChunks(foundchunks)) {
Log(LOG_INFO, _T(".chunk file saved"));
}
}
@@ -892,11 +892,11 @@ bool CVobSubFileRipper::LoadChunks(CAtlArray<vcchunk>& chunks) DWORD chksum = 0, chunklen, version;
__int64 voblen = 0;
- if(!f.Open(fn, CFile::modeRead|CFile::typeBinary|CFile::shareDenyNone)) {
+ if (!f.Open(fn, CFile::modeRead|CFile::typeBinary|CFile::shareDenyNone)) {
return false;
}
f.Read(&version, sizeof(version));
- if(version == 1) {
+ if (version == 1) {
f.Read(&chksum, sizeof(chksum));
f.Read(&voblen, sizeof(voblen));
f.Read(&chunklen, sizeof(chunklen));
@@ -905,21 +905,21 @@ bool CVobSubFileRipper::LoadChunks(CAtlArray<vcchunk>& chunks) }
f.Close();
- if(voblen != m_vob.GetLength()) {
+ if (voblen != m_vob.GetLength()) {
chunks.RemoveAll();
return false;
}
- if(!f.Open(m_infn, CFile::modeRead|CFile::typeBinary|CFile::shareDenyNone)) {
+ if (!f.Open(m_infn, CFile::modeRead|CFile::typeBinary|CFile::shareDenyNone)) {
return false;
}
DWORD dw, chksum2 = 0;
- while(f.Read(&dw, sizeof(dw)) == sizeof(dw)) {
+ while (f.Read(&dw, sizeof(dw)) == sizeof(dw)) {
chksum2 += dw;
}
f.Close();
- if(chksum != chksum2) {
+ if (chksum != chksum2) {
chunks.RemoveAll();
return false;
}
@@ -938,16 +938,16 @@ bool CVobSubFileRipper::SaveChunks(CAtlArray<vcchunk>& chunks) DWORD chksum = 0, chunklen = chunks.GetCount();
__int64 voblen = m_vob.GetLength();
- if(!f.Open(m_infn, CFile::modeRead|CFile::typeBinary|CFile::shareDenyNone)) {
+ if (!f.Open(m_infn, CFile::modeRead|CFile::typeBinary|CFile::shareDenyNone)) {
return false;
}
DWORD dw;
- while(f.Read(&dw, sizeof(dw)) == sizeof(dw)) {
+ while (f.Read(&dw, sizeof(dw)) == sizeof(dw)) {
chksum += dw;
}
f.Close();
- if(!f.Open(fn, CFile::modeCreate|CFile::modeWrite|CFile::typeBinary|CFile::shareDenyWrite)) {
+ if (!f.Open(fn, CFile::modeCreate|CFile::modeWrite|CFile::typeBinary|CFile::shareDenyWrite)) {
return false;
}
f.Write(&s_version, sizeof(s_version));
@@ -976,7 +976,7 @@ STDMETHODIMP CVobSubFileRipper::LoadParamFile(CString fn) m_rd.Reset();
CStdioFile f;
- if(!f.Open(fn, CFile::modeRead|CFile::typeText)) {
+ if (!f.Open(fn, CFile::modeRead|CFile::typeText)) {
return E_FAIL;
}
@@ -986,50 +986,50 @@ STDMETHODIMP CVobSubFileRipper::LoadParamFile(CString fn) int phase = P_INPUT;
CString line;
- while(f.ReadString(line)) {
- if(line.Trim().IsEmpty() || line[0] == '#') {
+ while (f.ReadString(line)) {
+ if (line.Trim().IsEmpty() || line[0] == '#') {
continue;
}
- if(phase == P_INPUT) {
- if(S_OK != SetInput(line)) {
+ if (phase == P_INPUT) {
+ if (S_OK != SetInput(line)) {
break;
}
phase = P_OUTPUT;
- } else if(phase == P_OUTPUT) {
- if(S_OK != SetOutput(line)) {
+ } else if (phase == P_OUTPUT) {
+ if (S_OK != SetOutput(line)) {
break;
}
phase = P_PGC;
- } else if(phase == P_PGC) {
+ } else if (phase == P_PGC) {
m_rd.iSelPGC = _tcstol(line, NULL, 10)-1;
- if(m_rd.iSelPGC < 0 || (size_t)m_rd.iSelPGC >= m_rd.pgcs.GetCount()) {
+ if (m_rd.iSelPGC < 0 || (size_t)m_rd.iSelPGC >= m_rd.pgcs.GetCount()) {
break;
}
phase = P_ANGLE;
- } else if(phase == 3) {
+ } else if (phase == 3) {
PGC& pgc = m_rd.pgcs[m_rd.iSelPGC];
pgc.iSelAngle = _tcstol(line, NULL, 10);
- if(pgc.iSelAngle < 0 || pgc.iSelAngle > max(1, pgc.nAngles) || pgc.iSelAngle > 9) {
+ if (pgc.iSelAngle < 0 || pgc.iSelAngle > max(1, pgc.nAngles) || pgc.iSelAngle > 9) {
break;
}
CAtlArray<vc_t>& angle = pgc.angles[pgc.iSelAngle];
- if(line.Find('v') >= 0) {
+ if (line.Find('v') >= 0) {
int vob = 0, cell = 0;
line += ' ';
TCHAR* s = (LPTSTR)(LPCTSTR)line;
TCHAR* e = s + line.GetLength();
- while(s < e) {
- if(*s == 'v' || s == e-1) {
+ while (s < e) {
+ if (*s == 'v' || s == e-1) {
s++;
- if(vob != 0 && cell == 0) {
- for(size_t i = 0; i < angle.GetCount(); i++) {
- if(angle[i].vob == vob) {
+ if (vob != 0 && cell == 0) {
+ for (size_t i = 0; i < angle.GetCount(); i++) {
+ if (angle[i].vob == vob) {
m_rd.selvcs.Add((angle[i].vob<<16)|angle[i].cell);
}
}
@@ -1037,12 +1037,12 @@ STDMETHODIMP CVobSubFileRipper::LoadParamFile(CString fn) vob = _tcstol(s, &s, 10);
cell = 0;
- } else if(*s == 'c' && vob > 0) {
+ } else if (*s == 'c' && vob > 0) {
s++;
cell = _tcstol(s, &s, 10);
- for(size_t i = 0; i < angle.GetCount(); i++) {
- if(angle[i].vob == vob && angle[i].cell == cell) {
+ for (size_t i = 0; i < angle.GetCount(); i++) {
+ if (angle[i].vob == vob && angle[i].cell == cell) {
m_rd.selvcs.Add((vob<<16)|cell);
break;
}
@@ -1052,15 +1052,15 @@ STDMETHODIMP CVobSubFileRipper::LoadParamFile(CString fn) }
}
} else {
- for(size_t i = 0; i < angle.GetCount(); i++) {
+ for (size_t i = 0; i < angle.GetCount(); i++) {
m_rd.selvcs.Add((angle[i].vob<<16)|angle[i].cell);
}
}
phase = P_LANGS;
- } else if(phase == 4) {
- if(!line.CompareNoCase(_T("ALL"))) {
- for(ptrdiff_t i = 0; i < 32; i++) {
+ } else if (phase == 4) {
+ if (!line.CompareNoCase(_T("ALL"))) {
+ for (ptrdiff_t i = 0; i < 32; i++) {
m_rd.selids[i] = true;
}
m_rd.fClosedCaption = true;
@@ -1068,7 +1068,7 @@ STDMETHODIMP CVobSubFileRipper::LoadParamFile(CString fn) } else {
line += ' ';
- while(line.GetLength() > 0) {
+ while (line.GetLength() > 0) {
int n = line.Find(_T(" "));
CString lang = line.Left(n);
@@ -1080,22 +1080,22 @@ STDMETHODIMP CVobSubFileRipper::LoadParamFile(CString fn) int langnum;
- if(_istdigit(lang[0])) {
+ if (_istdigit(lang[0])) {
n = _stscanf(lang, _T("%d"), &langnum);
- if(n != 1) {
+ if (n != 1) {
break;
}
m_rd.selids[langnum] = true;
- } else if(_istalpha(lang[0])) {
+ } else if (_istalpha(lang[0])) {
n = _stscanf(lang, _T("%s"), langid);
- if(n != 1) {
+ if (n != 1) {
break;
}
int id = (langid[0] << 8) + langid[1];
- if(id == 'cc') {
+ if (id == 'cc') {
m_rd.fClosedCaption = true;
} else {
m_rd.selids[id] = true;
@@ -1104,24 +1104,24 @@ STDMETHODIMP CVobSubFileRipper::LoadParamFile(CString fn) break;
}
- if(n != 1) {
+ if (n != 1) {
break;
}
}
- if((m_rd.selids.GetCount() > 0 || m_rd.fClosedCaption) && line.IsEmpty()) {
+ if ((m_rd.selids.GetCount() > 0 || m_rd.fClosedCaption) && line.IsEmpty()) {
phase = P_OPTIONS;
}
}
- } else if(phase == 5 && !line.CompareNoCase(_T("CLOSE"))) {
+ } else if (phase == 5 && !line.CompareNoCase(_T("CLOSE"))) {
m_rd.fClose = true;
- } else if(phase == 5 && !line.CompareNoCase(_T("BEEP"))) {
+ } else if (phase == 5 && !line.CompareNoCase(_T("BEEP"))) {
m_rd.fBeep = true;
- } else if(phase == 5 && !line.CompareNoCase(_T("RESETTIME"))) {
+ } else if (phase == 5 && !line.CompareNoCase(_T("RESETTIME"))) {
m_rd.fResetTime = true;
- } else if(phase == 5 && !line.CompareNoCase(_T("FORCEDONLY"))) {
+ } else if (phase == 5 && !line.CompareNoCase(_T("FORCEDONLY"))) {
m_rd.fForcedOnly = true;
- } else if(phase == 5 && !line.CompareNoCase(_T("CLOSEIGNOREERRORS"))) {
+ } else if (phase == 5 && !line.CompareNoCase(_T("CLOSEIGNOREERRORS"))) {
m_rd.fCloseIgnoreError = true;
}
@@ -1138,7 +1138,7 @@ STDMETHODIMP CVobSubFileRipper::SetInput(CString infn) m_rd.Reset();
- if(!LoadIfo(infn) || !LoadVob(infn)) {
+ if (!LoadIfo(infn) || !LoadVob(infn)) {
return E_INVALIDARG;
}
@@ -1170,7 +1170,7 @@ STDMETHODIMP CVobSubFileRipper::UpdateRipperData(VSFRipperData& rd) STDMETHODIMP CVobSubFileRipper::Index()
{
- if(m_fIndexing) {
+ if (m_fIndexing) {
return E_FAIL;
}
CAMThread::CallWorker(CMD_INDEX);
@@ -1212,13 +1212,13 @@ void VSFRipperData::Copy(VSFRipperData& rd) vidsize = rd.vidsize;
vidinfo = rd.vidinfo;
- if(int len = rd.pgcs.GetCount()) {
+ if (int len = rd.pgcs.GetCount()) {
pgcs.SetCount(len);
- for(ptrdiff_t i = 0; i < len; i++) {
+ for (ptrdiff_t i = 0; i < len; i++) {
PGC& src = rd.pgcs[i];
PGC& dst = pgcs[i];
dst.nAngles = src.nAngles;
- for(ptrdiff_t i = 0; i < countof(dst.angles); i++) {
+ for (ptrdiff_t i = 0; i < countof(dst.angles); i++) {
dst.angles[i].Copy(src.angles[i]);
}
dst.iSelAngle = src.iSelAngle;
@@ -1236,7 +1236,7 @@ void VSFRipperData::Copy(VSFRipperData& rd) fCloseIgnoreError = rd.fCloseIgnoreError;
selvcs.Copy(rd.selvcs);
POSITION pos = rd.selids.GetStartPosition();
- while(pos) {
+ while (pos) {
BYTE key;
bool val;
rd.selids.GetNextAssoc(pos, key, val);
diff --git a/src/Subtitles/VobSubImage.cpp b/src/Subtitles/VobSubImage.cpp index 8af7abe1c..0d979b2dd 100644 --- a/src/Subtitles/VobSubImage.cpp +++ b/src/Subtitles/VobSubImage.cpp @@ -45,16 +45,16 @@ bool CVobSubImage::Alloc(int w, int h) // wide border around the text, that's why we need a bit more memory
// to be allocated.
- if(lpTemp1 == NULL || w*h > org.cx*org.cy || (w+2)*(h+2) > (org.cx+2)*(org.cy+2)) {
+ if (lpTemp1 == NULL || w*h > org.cx*org.cy || (w+2)*(h+2) > (org.cx+2)*(org.cy+2)) {
Free();
lpTemp1 = DNew RGBQUAD[w*h];
- if(!lpTemp1) {
+ if (!lpTemp1) {
return false;
}
lpTemp2 = DNew RGBQUAD[(w+2)*(h+2)];
- if(!lpTemp2) {
+ if (!lpTemp2) {
delete [] lpTemp1;
lpTemp1 = NULL;
return false;
@@ -71,12 +71,12 @@ bool CVobSubImage::Alloc(int w, int h) void CVobSubImage::Free()
{
- if(lpTemp1) {
+ if (lpTemp1) {
delete [] lpTemp1;
}
lpTemp1 = NULL;
- if(lpTemp2) {
+ if (lpTemp2) {
delete [] lpTemp2;
}
lpTemp2 = NULL;
@@ -92,7 +92,7 @@ bool CVobSubImage::Decode(BYTE* lpData, int packetsize, int datasize, {
GetPacketInfo(lpData, packetsize, datasize);
- if(!Alloc(rect.Width(), rect.Height())) {
+ if (!Alloc(rect.Width(), rect.Height())) {
return false;
}
@@ -111,22 +111,22 @@ bool CVobSubImage::Decode(BYTE* lpData, int packetsize, int datasize, int end0 = nOffset[1];
int end1 = datasize;
- while((nPlane == 0 && nOffset[0] < end0) || (nPlane == 1 && nOffset[1] < end1)) {
+ while ((nPlane == 0 && nOffset[0] < end0) || (nPlane == 1 && nOffset[1] < end1)) {
DWORD code;
- if((code = GetNibble(lpData)) >= 0x4
+ if ((code = GetNibble(lpData)) >= 0x4
|| (code = (code << 4) | GetNibble(lpData)) >= 0x10
|| (code = (code << 4) | GetNibble(lpData)) >= 0x40
|| (code = (code << 4) | GetNibble(lpData)) >= 0x100) {
DrawPixels(p, code >> 2, code & 3);
- if((p.x += code >> 2) < rect.right) {
+ if ((p.x += code >> 2) < rect.right) {
continue;
}
}
DrawPixels(p, rect.right - p.x, code & 3);
- if(!fAligned) {
+ if (!fAligned) {
GetNibble(lpData); // align to byte
}
@@ -137,7 +137,7 @@ bool CVobSubImage::Decode(BYTE* lpData, int packetsize, int datasize, rect.bottom = min(p.y, rect.bottom);
- if(fTrim) {
+ if (fTrim) {
TrimSubImage();
}
@@ -159,17 +159,17 @@ void CVobSubImage::GetPacketInfo(BYTE* lpData, int packetsize, int datasize) nextctrlblk = (lpData[i] << 8) | lpData[i+1];
i += 2;
- if(nextctrlblk > packetsize || nextctrlblk < datasize) {
+ if (nextctrlblk > packetsize || nextctrlblk < datasize) {
ASSERT(0);
return;
}
bool fBreak = false;
- while(!fBreak) {
+ while (!fBreak) {
int len = 0;
- switch(lpData[i]) {
+ switch (lpData[i]) {
case 0x00:
len = 0;
break;
@@ -196,12 +196,12 @@ void CVobSubImage::GetPacketInfo(BYTE* lpData, int packetsize, int datasize) break;
}
- if(i+len >= packetsize) {
+ if (i+len >= packetsize) {
TRACE(_T("Warning: Wrong subpicture parameter block ending\n"));
break;
}
- switch(lpData[i++]) {
+ switch (lpData[i++]) {
case 0x00: // forced start displaying
fForced = true;
break;
@@ -241,9 +241,9 @@ void CVobSubImage::GetPacketInfo(BYTE* lpData, int packetsize, int datasize) break;
}
}
- } while(i <= nextctrlblk && i < packetsize);
+ } while (i <= nextctrlblk && i < packetsize);
- for(i = 0; i < 4; i++) {
+ for (i = 0; i < 4; i++) {
this->pal[i].pal = (pal >> (i << 2)) & 0xf;
this->pal[i].tr = (tr >> (i << 2)) & 0xf;
}
@@ -260,7 +260,7 @@ BYTE CVobSubImage::GetNibble(BYTE* lpData) void CVobSubImage::DrawPixels(CPoint p, int length, int colorid)
{
- if(length <= 0
+ if (length <= 0
|| p.x + length < rect.left
|| p.x >= rect.right
|| p.y < rect.top
@@ -268,10 +268,10 @@ void CVobSubImage::DrawPixels(CPoint p, int length, int colorid) return;
}
- if(p.x < rect.left) {
+ if (p.x < rect.left) {
p.x = rect.left;
}
- if(p.x + length >= rect.right) {
+ if (p.x + length >= rect.right) {
length = rect.right - p.x;
}
@@ -279,14 +279,14 @@ void CVobSubImage::DrawPixels(CPoint p, int length, int colorid) RGBQUAD c;
- if(!fCustomPal) {
+ if (!fCustomPal) {
c = orgpal[pal[colorid].pal];
c.rgbReserved = (pal[colorid].tr<<4)|pal[colorid].tr;
} else {
c = cuspal[colorid];
}
- while(length-- > 0) {
+ while (length-- > 0) {
*ptr++ = c;
}
}
@@ -301,26 +301,26 @@ void CVobSubImage::TrimSubImage() RGBQUAD* ptr = lpTemp1;
- for(ptrdiff_t j = 0, y = rect.Height(); j < y; j++) {
- for(ptrdiff_t i = 0, x = rect.Width(); i < x; i++, ptr++) {
- if(ptr->rgbReserved) {
- if(r.top > j) {
+ for (ptrdiff_t j = 0, y = rect.Height(); j < y; j++) {
+ for (ptrdiff_t i = 0, x = rect.Width(); i < x; i++, ptr++) {
+ if (ptr->rgbReserved) {
+ if (r.top > j) {
r.top = j;
}
- if(r.bottom < j) {
+ if (r.bottom < j) {
r.bottom = j;
}
- if(r.left > i) {
+ if (r.left > i) {
r.left = i;
}
- if(r.right < i) {
+ if (r.right < i) {
r.right = i;
}
}
}
}
- if(r.left > r.right || r.top > r.bottom) {
+ if (r.left > r.right || r.top > r.bottom) {
return;
}
@@ -339,7 +339,7 @@ void CVobSubImage::TrimSubImage() memset(lpTemp2, 0, (1 + w + 1)*sizeof(RGBQUAD));
- for(ptrdiff_t height = h; height; height--, src += rect.Width()) {
+ for (ptrdiff_t height = h; height; height--, src += rect.Width()) {
*dst++ = 0;
memcpy(dst, src, w*sizeof(RGBQUAD));
dst += w;
@@ -363,24 +363,24 @@ void CVobSubImage::TrimSubImage() CAutoPtrList<COutline>* CVobSubImage::GetOutlineList(CPoint& topleft)
{
int w = rect.Width(), h = rect.Height(), len = w*h;
- if(len <= 0) {
+ if (len <= 0) {
return NULL;
}
CAutoVectorPtr<BYTE> p;
- if(!p.Allocate(len)) {
+ if (!p.Allocate(len)) {
return NULL;
}
CAutoPtrList<COutline>* ol = DNew CAutoPtrList<COutline>();
- if(!ol) {
+ if (!ol) {
return NULL;
}
BYTE* cp = p;
RGBQUAD* rgbp = (RGBQUAD*)lpPixels;
- for(ptrdiff_t i = 0; i < len; i++, cp++, rgbp++) {
+ for (ptrdiff_t i = 0; i < len; i++, cp++, rgbp++) {
*cp = !!rgbp->rgbReserved;
}
@@ -388,27 +388,27 @@ CAutoPtrList<COutline>* CVobSubImage::GetOutlineList(CPoint& topleft) topleft.x = topleft.y = INT_MAX;
- while(1) {
+ while (1) {
cp = p;
int x = 0;
int y = 0;
- for(y = 0; y < h; y++) {
- for(x = 0; x < w-1; x++, cp++) {
- if(cp[0] == 0 && cp[1] == 1) {
+ for (y = 0; y < h; y++) {
+ for (x = 0; x < w-1; x++, cp++) {
+ if (cp[0] == 0 && cp[1] == 1) {
break;
}
}
- if(x < w-1) {
+ if (x < w-1) {
break;
}
cp++;
}
- if(y == h) {
+ if (y == h) {
break;
}
@@ -417,7 +417,7 @@ CAutoPtrList<COutline>* CVobSubImage::GetOutlineList(CPoint& topleft) int ox = x, oy = y, odir = dir;
CAutoPtr<COutline> o(DNew COutline);
- if(!o) {
+ if (!o) {
break;
}
@@ -429,7 +429,7 @@ CAutoPtrList<COutline>* CVobSubImage::GetOutlineList(CPoint& topleft) prevdir = dir;
- switch(prevdir) {
+ switch (prevdir) {
case UP:
pp = CPoint(x+1, y);
fl = GP(x, y-1);
@@ -465,51 +465,51 @@ CAutoPtrList<COutline>* CVobSubImage::GetOutlineList(CPoint& topleft) //
// o set, x empty, . can be anything
- if(fl==1) {
+ if (fl==1) {
dir = (dir-1+4)&3;
- } else if(fl!=1 && fr!=1 && br==1) {
+ } else if (fl!=1 && fr!=1 && br==1) {
dir = (dir+1)&3;
- } else if(p[y*w+x]&16) {
+ } else if (p[y*w+x]&16) {
ASSERT(0); // we are going around in one place (this must not happen if the starting conditions were correct)
break;
}
p[y*w+x] = (p[y*w+x]<<1) | 2; // increase turn count (== log2(highordbit(*p)))
- switch(dir) {
+ switch (dir) {
case UP:
- if(prevdir == LEFT) {
+ if (prevdir == LEFT) {
x--;
y--;
}
- if(prevdir == UP) {
+ if (prevdir == UP) {
y--;
}
break;
case RIGHT:
- if(prevdir == UP) {
+ if (prevdir == UP) {
x++;
y--;
}
- if(prevdir == RIGHT) {
+ if (prevdir == RIGHT) {
x++;
}
break;
case DOWN:
- if(prevdir == RIGHT) {
+ if (prevdir == RIGHT) {
x++;
y++;
}
- if(prevdir == DOWN) {
+ if (prevdir == DOWN) {
y++;
}
break;
case LEFT:
- if(prevdir == DOWN) {
+ if (prevdir == DOWN) {
x--;
y++;
}
- if(prevdir == LEFT) {
+ if (prevdir == LEFT) {
x--;
}
break;
@@ -518,15 +518,15 @@ CAutoPtrList<COutline>* CVobSubImage::GetOutlineList(CPoint& topleft) int d = dir - prevdir;
o->Add(pp, d == 3 ? -1 : d == -3 ? 1 : d);
- if(topleft.x > pp.x) {
+ if (topleft.x > pp.x) {
topleft.x = pp.x;
}
- if(topleft.y > pp.y) {
+ if (topleft.y > pp.y) {
topleft.y = pp.y;
}
- } while(!(x == ox && y == oy && dir == odir));
+ } while (!(x == ox && y == oy && dir == odir));
- if(o->pa.GetCount() > 0 && (x == ox && y == oy && dir == odir)) {
+ if (o->pa.GetCount() > 0 && (x == ox && y == oy && dir == odir)) {
ol->AddTail(o);
} else {
ASSERT(0);
@@ -539,18 +539,18 @@ CAutoPtrList<COutline>* CVobSubImage::GetOutlineList(CPoint& topleft) static bool FitLine(COutline& o, int& start, int& end)
{
int len = int(o.pa.GetCount());
- if(len < 7) {
+ if (len < 7) {
return false; // small segments should be handled with beziers...
}
- for(start = 0; start < len && !o.da[start]; start++) {
+ for (start = 0; start < len && !o.da[start]; start++) {
;
}
- for(end = len-1; end > start && !o.da[end]; end--) {
+ for (end = len-1; end > start && !o.da[end]; end--) {
;
}
- if(end-start < 8 || end-start < (len-end)+(start-0)) {
+ if (end-start < 8 || end-start < (len-end)+(start-0)) {
return false;
}
@@ -558,14 +558,14 @@ static bool FitLine(COutline& o, int& start, int& end) int i, j, k;
- for(i = start+1, j = end, k = start; i <= j; i++) {
- if(!o.da[i]) {
+ for (i = start+1, j = end, k = start; i <= j; i++) {
+ if (!o.da[i]) {
continue;
}
- if(o.da[i] == o.da[k]) {
+ if (o.da[i] == o.da[k]) {
return false;
}
- if(o.da[i] == -1) {
+ if (o.da[i] == -1) {
la.Add(i-k);
} else {
ra.Add(i-k);
@@ -577,27 +577,27 @@ static bool FitLine(COutline& o, int& start, int& end) // these tests are completly heuristic and might be redundant a bit...
- for(i = 0, j = la.GetSize(); i < j && fl; i++) {
- if(la[i] != 1) {
+ for (i = 0, j = la.GetSize(); i < j && fl; i++) {
+ if (la[i] != 1) {
fl = false;
}
}
- for(i = 0, j = ra.GetSize(); i < j && fr; i++) {
- if(ra[i] != 1) {
+ for (i = 0, j = ra.GetSize(); i < j && fr; i++) {
+ if (ra[i] != 1) {
fr = false;
}
}
- if(!fl && !fr) {
+ if (!fl && !fr) {
return false; // can't be a line if there are bigger steps than one in both directions (lines are usually drawn by stepping one either horizontally or vertically)
}
- if(fl && fr && 1.0*(end-start)/((len-end)*2+(start-0)*2) > 0.4) {
+ if (fl && fr && 1.0*(end-start)/((len-end)*2+(start-0)*2) > 0.4) {
return false; // if this section is relatively too small it may only be a rounded corner
}
- if(!fl && la.GetSize() > 0 && la.GetSize() <= 4 && (la[0] == 1 && la[la.GetSize()-1] == 1)) {
+ if (!fl && la.GetSize() > 0 && la.GetSize() <= 4 && (la[0] == 1 && la[la.GetSize()-1] == 1)) {
return false; // one step at both ends, doesn't sound good for a line (may be it was skewed, so only eliminate smaller sections where beziers going to look just as good)
}
- if(!fr && ra.GetSize() > 0 && ra.GetSize() <= 4 && (ra[0] == 1 && ra[ra.GetSize()-1] == 1)) {
+ if (!fr && ra.GetSize() > 0 && ra.GetSize() <= 4 && (ra[0] == 1 && ra[ra.GetSize()-1] == 1)) {
return false; // -''-
}
@@ -607,25 +607,25 @@ static bool FitLine(COutline& o, int& start, int& end) int sum = 0;
- for(i = 0, j = INT_MAX, k = 0; i < len; i++) {
- if(j > a[i]) {
+ for (i = 0, j = INT_MAX, k = 0; i < len; i++) {
+ if (j > a[i]) {
j = a[i];
}
- if(k < a[i]) {
+ if (k < a[i]) {
k = a[i];
}
sum += a[i];
}
- if(k - j > 2 && 1.0*sum/len < 2) {
+ if (k - j > 2 && 1.0*sum/len < 2) {
return false;
}
- if(k - j > 2 && 1.0*sum/len >= 2 && len < 4) {
+ if (k - j > 2 && 1.0*sum/len >= 2 && len < 4) {
return false;
}
- if((la.GetSize()/2+ra.GetSize()/2)/2 <= 2) {
- if((k+j)/2 < 2 && k*j!=1) {
+ if ((la.GetSize()/2+ra.GetSize()/2)/2 <= 2) {
+ if ((k+j)/2 < 2 && k*j!=1) {
return false;
}
}
@@ -640,18 +640,18 @@ static bool FitLine(COutline& o, int& start, int& end) vx /= l;
vy /= l;
- for(i = start+1, j = end-1; i <= j; i++) {
+ for (i = start+1, j = end-1; i <= j; i++) {
CPoint p = o.pa[i], dp = p - sp;
double t = vx*dp.x+vy*dp.y, dx = vx*t + sp.x - p.x, dy = vy*t + sp.y - p.y;
t = dx*dx+dy*dy;
err += t;
t = sqrt(t);
- if(vy*dx-dy*vx < 0) {
- if(minerr > -t) {
+ if (vy*dx-dy*vx < 0) {
+ if (minerr > -t) {
minerr = -t;
}
} else {
- if(maxerr < t) {
+ if (maxerr < t) {
maxerr = t;
}
}
@@ -666,8 +666,8 @@ static int CalcPossibleCurveDegree(COutline& o) CUIntArray la;
- for(ptrdiff_t i = 0, j = 0; j < len2; j++) {
- if(j == len2-1 || o.da[j]) {
+ for (ptrdiff_t i = 0, j = 0; j < len2; j++) {
+ if (j == len2-1 || o.da[j]) {
la.Add(j-i);
i = j;
}
@@ -683,22 +683,22 @@ static int CalcPossibleCurveDegree(COutline& o) int penalty = 0;
int ma[2] = {0, 0};
- for(ptrdiff_t i = 0; i < len; i++) {
+ for (ptrdiff_t i = 0; i < len; i++) {
ma[i&1] += la[i];
}
int ca[2] = {ma[0], ma[1]};
- for(ptrdiff_t i = 0; i < len; i++) {
+ for (ptrdiff_t i = 0; i < len; i++) {
ca[i&1] -= la[i];
double c1 = 1.0*ca[0]/ma[0], c2 = 1.0*ca[1]/ma[1], c3 = 1.0*la[i]/ma[i&1];
- if(len2 > 16 && (fabs(c1-c2) > 0.7 || (c3 > 0.6 && la[i] > 5))) {
+ if (len2 > 16 && (fabs(c1-c2) > 0.7 || (c3 > 0.6 && la[i] > 5))) {
penalty = 2;
break;
}
- if(fabs(c1-c2) > 0.6 || (c3 > 0.4 && la[i] > 5)) {
+ if (fabs(c1-c2) > 0.6 || (c3 > 0.4 && la[i] > 5)) {
penalty = 1;
}
}
@@ -709,8 +709,8 @@ static int CalcPossibleCurveDegree(COutline& o) la[0] <<= 1;
la[len-1] <<= 1;
- for(ptrdiff_t i = 0; i < len; i+=2) {
- if(la[i] > 1) {
+ for (ptrdiff_t i = 0; i < len; i+=2) {
+ if (la[i] > 1) {
ret++; // prependicular to the last chosen section and bigger then 1 -> add a degree and continue with the other dir
i--;
}
@@ -734,7 +734,7 @@ static bool MinMaxCosfi(COutline& o, double& mincf, double& maxcf) // not really CAtlArray<CPoint>& pa = o.pa;
int len = (int)pa.GetCount();
- if(len < 6) {
+ if (len < 6) {
return false;
}
@@ -745,7 +745,7 @@ static bool MinMaxCosfi(COutline& o, double& mincf, double& maxcf) // not really double l = vectlen(p);
UNUSED_ALWAYS(l);
- for(ptrdiff_t i = 2; i < len-2; i++) { // skip the endpoints, they aren't accurate
+ for (ptrdiff_t i = 2; i < len-2; i++) { // skip the endpoints, they aren't accurate
CPoint p1 = pa[0] - pa[i], p2 = pa[len-1] - pa[i];
double l1 = vectlen(p1), l2 = vectlen(p2);
int sign = p1.x*p.y-p1.y*p.x >= 0 ? 1 : -1;
@@ -753,10 +753,10 @@ static bool MinMaxCosfi(COutline& o, double& mincf, double& maxcf) // not really double c = (1.0*len/2 - fabs(i - 1.0*len/2)) / len * 2; // c: 0 -> 1 -> 0
double cosfi = (1+(p1.x*p2.x+p1.y*p2.y)/(l1*l2)) * sign * c;
- if(mincf > cosfi) {
+ if (mincf > cosfi) {
mincf = cosfi;
}
- if(maxcf < cosfi) {
+ if (maxcf < cosfi) {
maxcf = cosfi;
}
}
@@ -772,9 +772,9 @@ static bool FitBezierVH(COutline& o, CPoint& p1, CPoint& p2) int len = (int)pa.GetCount();
- if(len <= 1) {
+ if (len <= 1) {
return false;
- } else if(len == 2) {
+ } else if (len == 2) {
CPoint mid = pa[0]+pa[1];
mid.x >>= 1;
mid.y >>= 1;
@@ -783,17 +783,17 @@ static bool FitBezierVH(COutline& o, CPoint& p1, CPoint& p2) }
CPoint dir1 = pa[1] - pa[0], dir2 = pa[len-2] - pa[len-1];
- if((dir1.x&&dir1.y)||(dir2.x&&dir2.y)) {
+ if ((dir1.x&&dir1.y)||(dir2.x&&dir2.y)) {
return false; // we are only fitting beziers with hor./ver. endings
}
- if(CalcPossibleCurveDegree(o) > 3) {
+ if (CalcPossibleCurveDegree(o) > 3) {
return false;
}
double mincf, maxcf;
- if(MinMaxCosfi(o, mincf, maxcf)) {
- if(maxcf-mincf > 0.8
+ if (MinMaxCosfi(o, mincf, maxcf)) {
+ if (maxcf-mincf > 0.8
|| maxcf-mincf > 0.6 && (maxcf >= 0.4 || mincf <= -0.4)) {
return false;
}
@@ -809,12 +809,12 @@ static bool FitBezierVH(COutline& o, CPoint& p1, CPoint& p2) double c20 = 0, c21 = 0, c22 = 0, c23 = 0, c2x = 0, c2y = 0;
double length = 0;
- for(pl[0] = 0, i = 1; i < len; i++) {
+ for (pl[0] = 0, i = 1; i < len; i++) {
CPoint diff = (pa[i] - pa[i-1]);
pl[i] = (length += sqrt((double)(diff.x*diff.x+diff.y*diff.y)));
}
- for(i = 0; i < len; i++) {
+ for (i = 0; i < len; i++) {
double t1 = pl[i] / length;
double t2 = t1*t1;
double t3 = t2*t1;
@@ -840,18 +840,18 @@ static bool FitBezierVH(COutline& o, CPoint& p1, CPoint& p2) c2y += pa[i].y*dc2;
}
- if(dir1.y == 0 && dir2.x == 0) {
+ if (dir1.y == 0 && dir2.x == 0) {
p1.x = (int)((c1x - c10*p0.x - c12*p3.x - c13*p3.x) / c11 + 0.5);
p2.y = (int)((c2y - c20*p0.y - c21*p0.y - c23*p3.y) / c22 + 0.5);
- } else if(dir1.x == 0 && dir2.y == 0) {
+ } else if (dir1.x == 0 && dir2.y == 0) {
p2.x = (int)((c2x - c20*p0.x - c21*p0.x - c23*p3.x) / c22 + 0.5);
p1.y = (int)((c1y - c10*p0.y - c12*p3.y - c13*p3.y) / c11 + 0.5);
- } else if(dir1.y == 0 && dir2.y == 0) {
+ } else if (dir1.y == 0 && dir2.y == 0) {
// cramer's rule
double D = c11*c22 - c12*c21;
p1.x = (int)(((c1x-c10*p0.x-c13*p3.x)*c22 - c12*(c2x-c20*p0.x-c23*p3.x)) / D + 0.5);
p2.x = (int)((c11*(c2x-c20*p0.x-c23*p3.x) - (c1x-c10*p0.x-c13*p3.x)*c21) / D + 0.5);
- } else if(dir1.x == 0 && dir2.x == 0) {
+ } else if (dir1.x == 0 && dir2.x == 0) {
// cramer's rule
double D = c11*c22 - c12*c21;
p1.y = (int)(((c1y-c10*p0.y-c13*p3.y)*c22 - c12*(c2y-c20*p0.y-c23*p3.y)) / D + 0.5);
@@ -863,7 +863,7 @@ static bool FitBezierVH(COutline& o, CPoint& p1, CPoint& p2) // check for "inside-out" beziers
CPoint dir3 = p1 - p0, dir4 = p2 - p3;
- if((dir1.x*dir3.x+dir1.y*dir3.y) <= 0 || (dir2.x*dir4.x+dir2.y*dir4.y) <= 0) {
+ if ((dir1.x*dir3.x+dir1.y*dir3.y) <= 0 || (dir2.x*dir4.x+dir2.y*dir4.y) <= 0) {
return false;
}
@@ -879,18 +879,18 @@ int CVobSubImage::GrabSegment(int start, COutline& o, COutline& ret) int cur = (start)%len, first = -1, last = -1;
int lastDir = 0;
- for(ptrdiff_t i = 0; i < len; i++) {
+ for (ptrdiff_t i = 0; i < len; i++) {
cur = (cur+1)%len;
- if(o.da[cur] == 0) {
+ if (o.da[cur] == 0) {
continue;
}
- if(first == -1) {
+ if (first == -1) {
first = cur;
}
- if(lastDir == o.da[cur]) {
+ if (lastDir == o.da[cur]) {
CPoint startp = o.pa[first]+o.pa[start];
startp.x >>= 1;
startp.y >>= 1;
@@ -898,28 +898,28 @@ int CVobSubImage::GrabSegment(int start, COutline& o, COutline& ret) endp.x >>= 1;
endp.y >>= 1;
- if(first < start) {
+ if (first < start) {
first += len;
}
start = ((start+first)>>1)+1;
- if(start >= len) {
+ if (start >= len) {
start -= len;
}
- if(cur < last) {
+ if (cur < last) {
cur += len;
}
cur = ((last+cur+1)>>1);
- if(cur >= len) {
+ if (cur >= len) {
cur -= len;
}
ret.Add(startp, 0);
- while(start != cur) {
+ while (start != cur) {
ret.Add(o.pa[start], o.da[start]);
start++;
- if(start >= len) {
+ if (start >= len) {
start -= len;
}
}
@@ -941,7 +941,7 @@ int CVobSubImage::GrabSegment(int start, COutline& o, COutline& ret) void CVobSubImage::SplitOutline(COutline& o, COutline& o1, COutline& o2)
{
int len = int(o.pa.GetCount());
- if(len < 4) {
+ if (len < 4) {
return;
}
@@ -949,8 +949,8 @@ void CVobSubImage::SplitOutline(COutline& o, COutline& o1, COutline& o2) int i, j, k;
- for(i = 0, j = 0; j < len; j++) {
- if(j == len-1 || o.da[j]) {
+ for (i = 0, j = 0; j < len; j++) {
+ if (j == len-1 || o.da[j]) {
la.Add(j-i);
sa.Add(i);
ea.Add(j);
@@ -961,19 +961,19 @@ void CVobSubImage::SplitOutline(COutline& o, COutline& o1, COutline& o2) int maxlen = 0, maxidx = -1;
int maxlen2 = 0, maxidx2 = -1;
- for(i = 0; i < la.GetCount(); i++) {
- if(maxlen < la[i]) {
+ for (i = 0; i < la.GetCount(); i++) {
+ if (maxlen < la[i]) {
maxlen = la[i];
maxidx = i;
}
- if(maxlen2 < la[i] && i > 0 && i < la.GetCount()-1) {
+ if (maxlen2 < la[i] && i > 0 && i < la.GetCount()-1) {
maxlen2 = la[i];
maxidx2 = i;
}
}
- if(maxlen == maxlen2) {
+ if (maxlen == maxlen2) {
maxidx = maxidx2; // if equal choose the inner section
}
@@ -982,11 +982,11 @@ void CVobSubImage::SplitOutline(COutline& o, COutline& o1, COutline& o2) o1.RemoveAll();
o2.RemoveAll();
- for(i = 0; i <= j; i++) {
+ for (i = 0; i <= j; i++) {
o1.Add(o.pa[i], o.da[i]);
}
- if(j != k) {
+ if (j != k) {
CPoint mid = o.pa[j]+o.pa[k];
mid.x >>= 1;
mid.y >>= 1;
@@ -994,7 +994,7 @@ void CVobSubImage::SplitOutline(COutline& o, COutline& o1, COutline& o2) o2.Add(mid, 0);
}
- for(i = k; i < len; i++) {
+ for (i = k; i < len; i++) {
o2.Add(o.pa[i], o.da[i]);
}
}
@@ -1002,37 +1002,37 @@ void CVobSubImage::SplitOutline(COutline& o, COutline& o1, COutline& o2) void CVobSubImage::AddSegment(COutline& o, CAtlArray<BYTE>& pathTypes, CAtlArray<CPoint>& pathPoints)
{
int i, len = int(o.pa.GetCount());
- if(len < 3) {
+ if (len < 3) {
return;
}
int nLeftTurns = 0, nRightTurns = 0;
- for(i = 0; i < len; i++) {
- if(o.da[i] == -1) {
+ for (i = 0; i < len; i++) {
+ if (o.da[i] == -1) {
nLeftTurns++;
- } else if(o.da[i] == 1) {
+ } else if (o.da[i] == 1) {
nRightTurns++;
}
}
- if(nLeftTurns == 0 && nRightTurns == 0) { // line
+ if (nLeftTurns == 0 && nRightTurns == 0) { // line
pathTypes.Add(PT_LINETO);
pathPoints.Add(o.pa[len-1]);
return;
}
- if(nLeftTurns == 0 || nRightTurns == 0) { // b-spline
+ if (nLeftTurns == 0 || nRightTurns == 0) { // b-spline
pathTypes.Add(PT_MOVETONC);
pathPoints.Add(o.pa[0]+(o.pa[0]-o.pa[1]));
- for(i = 0; i < 3; i++) {
+ for (i = 0; i < 3; i++) {
pathTypes.Add(PT_BSPLINETO);
pathPoints.Add(o.pa[i]);
}
- for(; i < len; i++) {
+ for (; i < len; i++) {
pathTypes.Add(PT_BSPLINEPATCHTO);
pathPoints.Add(o.pa[i]);
}
@@ -1047,7 +1047,7 @@ void CVobSubImage::AddSegment(COutline& o, CAtlArray<BYTE>& pathTypes, CAtlArray }
int start, end;
- if(FitLine(o, start, end)) { // b-spline, line, b-spline
+ if (FitLine(o, start, end)) { // b-spline, line, b-spline
pathTypes.Add(PT_MOVETONC);
pathPoints.Add(o.pa[0]+(o.pa[0]-o.pa[1]));
@@ -1069,14 +1069,14 @@ void CVobSubImage::AddSegment(COutline& o, CAtlArray<BYTE>& pathTypes, CAtlArray p[2] = CPoint((int)(1.0 * o.pa[end].x - dx*l2*2 + 0.5), (int)(1.0 * o.pa[end].y - dy*l2*2 + 0.5));
p[3] = CPoint((int)(1.0 * o.pa[end].x - dx*l2 + 0.5), (int)(1.0 * o.pa[end].y - dy*l2 + 0.5));
- if(start == 1) {
+ if (start == 1) {
pathTypes.Add(PT_BSPLINETO);
pathPoints.Add(p[0]);
} else {
pathTypes.Add(PT_BSPLINETO);
pathPoints.Add(o.pa[2]);
- for(ptrdiff_t i = 3; i <= start; i++) {
+ for (ptrdiff_t i = 3; i <= start; i++) {
pathTypes.Add(PT_BSPLINEPATCHTO);
pathPoints.Add(o.pa[i]);
}
@@ -1100,7 +1100,7 @@ void CVobSubImage::AddSegment(COutline& o, CAtlArray<BYTE>& pathTypes, CAtlArray pathTypes.Add(PT_BSPLINEPATCHTO);
pathPoints.Add(p[3]);
- for(i = end; i < len; i++) {
+ for (i = end; i < len; i++) {
pathTypes.Add(PT_BSPLINEPATCHTO);
pathPoints.Add(o.pa[i]);
}
@@ -1115,7 +1115,7 @@ void CVobSubImage::AddSegment(COutline& o, CAtlArray<BYTE>& pathTypes, CAtlArray }
CPoint p1, p2;
- if(FitBezierVH(o, p1, p2)) { // bezier
+ if (FitBezierVH(o, p1, p2)) { // bezier
pathTypes.Add(PT_BEZIERTO);
pathPoints.Add(p1);
pathTypes.Add(PT_BEZIERTO);
@@ -1136,36 +1136,36 @@ bool CVobSubImage::Polygonize(CAtlArray<BYTE>& pathTypes, CAtlArray<CPoint>& pat {
CPoint topleft;
CAutoPtr<CAutoPtrList<COutline> > ol(GetOutlineList(topleft));
- if(!ol) {
+ if (!ol) {
return false;
}
POSITION pos;
pos = ol->GetHeadPosition();
- while(pos) {
+ while (pos) {
CAtlArray<CPoint>& pa = ol->GetNext(pos)->pa;
- for(size_t i = 0; i < pa.GetCount(); i++) {
+ for (size_t i = 0; i < pa.GetCount(); i++) {
pa[i].x = (pa[i].x-topleft.x)<<scale;
pa[i].y = (pa[i].y-topleft.y)<<scale;
}
}
pos = ol->GetHeadPosition();
- while(pos) {
+ while (pos) {
COutline& o = *ol->GetNext(pos), o2;
- if(fSmooth) {
+ if (fSmooth) {
int i = 0, iFirst = -1;
- while(1) {
+ while (1) {
i = GrabSegment(i, o, o2);
- if(i == iFirst) {
+ if (i == iFirst) {
break;
}
- if(iFirst < 0) {
+ if (iFirst < 0) {
iFirst = i;
pathTypes.Add(PT_MOVETO);
pathPoints.Add(o2.pa[0]);
@@ -1196,7 +1196,7 @@ bool CVobSubImage::Polygonize(CAtlArray<BYTE>& pathTypes, CAtlArray<CPoint>& pat pathTypes.Add(PT_MOVETO);
pathPoints.Add(o.pa[0]);
- for(ptrdiff_t i = 1, len = int(o.pa.GetCount()); i < len; i++) {
+ for (ptrdiff_t i = 1, len = int(o.pa.GetCount()); i < len; i++) {
pathTypes.Add(PT_LINETO);
pathPoints.Add(o.pa[i]);
}
@@ -1211,7 +1211,7 @@ bool CVobSubImage::Polygonize(CStringW& assstr, bool fSmooth, int scale) CAtlArray<BYTE> pathTypes;
CAtlArray<CPoint> pathPoints;
- if(!Polygonize(pathTypes, pathPoints, fSmooth, scale)) {
+ if (!Polygonize(pathTypes, pathPoints, fSmooth, scale)) {
return false;
}
@@ -1222,31 +1222,31 @@ bool CVobSubImage::Polygonize(CStringW& assstr, bool fSmooth, int scale) int nPoints = int(pathTypes.GetCount());
- for(ptrdiff_t i = 0; i < nPoints; i++) {
+ for (ptrdiff_t i = 0; i < nPoints; i++) {
CStringW s;
- switch(pathTypes[i]) {
+ switch (pathTypes[i]) {
case PT_MOVETO:
- if(lastType != PT_MOVETO) {
+ if (lastType != PT_MOVETO) {
assstr += L"m ";
}
s.Format(L"%d %d ", pathPoints[i].x, pathPoints[i].y);
break;
case PT_MOVETONC:
- if(lastType != PT_MOVETONC) {
+ if (lastType != PT_MOVETONC) {
assstr += L"n ";
}
s.Format(L"%d %d ", pathPoints[i].x, pathPoints[i].y);
break;
case PT_LINETO:
- if(lastType != PT_LINETO) {
+ if (lastType != PT_LINETO) {
assstr += L"l ";
}
s.Format(L"%d %d ", pathPoints[i].x, pathPoints[i].y);
break;
case PT_BEZIERTO:
- if(i < nPoints-2) {
- if(lastType != PT_BEZIERTO) {
+ if (i < nPoints-2) {
+ if (lastType != PT_BEZIERTO) {
assstr += L"b ";
}
s.Format(L"%d %d %d %d %d %d ", pathPoints[i].x, pathPoints[i].y, pathPoints[i+1].x, pathPoints[i+1].y, pathPoints[i+2].x, pathPoints[i+2].y);
@@ -1254,8 +1254,8 @@ bool CVobSubImage::Polygonize(CStringW& assstr, bool fSmooth, int scale) }
break;
case PT_BSPLINETO:
- if(i < nPoints-2) {
- if(lastType != PT_BSPLINETO) {
+ if (i < nPoints-2) {
+ if (lastType != PT_BSPLINETO) {
assstr += L"s ";
}
s.Format(L"%d %d %d %d %d %d ", pathPoints[i].x, pathPoints[i].y, pathPoints[i+1].x, pathPoints[i+1].y, pathPoints[i+2].x, pathPoints[i+2].y);
@@ -1263,7 +1263,7 @@ bool CVobSubImage::Polygonize(CStringW& assstr, bool fSmooth, int scale) }
break;
case PT_BSPLINEPATCHTO:
- if(lastType != PT_BSPLINEPATCHTO) {
+ if (lastType != PT_BSPLINEPATCHTO) {
assstr += L"p ";
}
s.Format(L"%d %d ", pathPoints[i].x, pathPoints[i].y);
@@ -1287,8 +1287,8 @@ void CVobSubImage::Scale2x() DWORD* src = (DWORD*)lpPixels;
DWORD* dst = DNew DWORD[w*h];
- for(ptrdiff_t y = 0; y < h; y++) {
- for(ptrdiff_t x = 0; x < w; x++, src++, dst++) {
+ for (ptrdiff_t y = 0; y < h; y++) {
+ for (ptrdiff_t x = 0; x < w; x++, src++, dst++) {
DWORD E = *src;
DWORD A = x > 0 && y > 0 ? src[-w-1] : E;
diff --git a/src/Subtitles/libssf/Arabic.cpp b/src/Subtitles/libssf/Arabic.cpp index d918d82cc..e6dbfeff4 100644 --- a/src/Subtitles/libssf/Arabic.cpp +++ b/src/Subtitles/libssf/Arabic.cpp @@ -298,13 +298,13 @@ namespace ssf bool Arabic::Replace(WCHAR& c, pres_form_t pf)
{
- if(!IsArabic(c)) {
+ if (!IsArabic(c)) {
return false;
}
const arabicforms& af = ArabicForms[c - 0x600];
- switch(pf) {
+ switch (pf) {
case isol:
c = af.isolated;
break;
@@ -324,7 +324,7 @@ namespace ssf bool Arabic::Replace(WCHAR& c, WCHAR prev, WCHAR next)
{
- if(!IsArabic(c)) {
+ if (!IsArabic(c)) {
return false;
}
diff --git a/src/Subtitles/libssf/Array.h b/src/Subtitles/libssf/Array.h index 7e9ac50fd..5aa557ce9 100644 --- a/src/Subtitles/libssf/Array.h +++ b/src/Subtitles/libssf/Array.h @@ -41,17 +41,17 @@ namespace ssf m_nGrowBy = 4096;
}
virtual ~Array() {
- if(m_pData) {
+ if (m_pData) {
_aligned_free(m_pData);
}
}
void SetCount(size_t nSize, size_t nGrowBy = 0) {
- if(nGrowBy > 0) {
+ if (nGrowBy > 0) {
m_nGrowBy = nGrowBy;
}
- if(nSize > m_nMaxSize) {
+ if (nSize > m_nMaxSize) {
m_nMaxSize = nSize + max(m_nGrowBy, m_nSize);
size_t nBytes = m_nMaxSize * sizeof(T);
m_pData = m_pData ? (T*)_aligned_realloc(m_pData, nBytes, 16) : (T*)_aligned_malloc(nBytes, 16);
@@ -86,7 +86,7 @@ namespace ssf }
void Append(const T* ptr, size_t nSize, size_t nGrowBy = 0) {
- if(!nSize) {
+ if (!nSize) {
return;
}
size_t nOldSize = m_nSize;
diff --git a/src/Subtitles/libssf/Exception.cpp b/src/Subtitles/libssf/Exception.cpp index 2253e9926..061ddd0dc 100644 --- a/src/Subtitles/libssf/Exception.cpp +++ b/src/Subtitles/libssf/Exception.cpp @@ -29,7 +29,7 @@ namespace ssf va_list args;
va_start(args, fmt);
int len = _vsctprintf(fmt, args) + 1;
- if(len > 0) {
+ if (len > 0) {
_vstprintf_s(m_msg.GetBufferSetLength(len), len, fmt, args);
}
va_end(args);
diff --git a/src/Subtitles/libssf/File.cpp b/src/Subtitles/libssf/File.cpp index 176ec16d6..f4dae3428 100644 --- a/src/Subtitles/libssf/File.cpp +++ b/src/Subtitles/libssf/File.cpp @@ -46,7 +46,7 @@ namespace ssf try {
ParseDefs(WCharInputStream(predef), pRef);
- } catch(Exception& e) {
+ } catch (Exception& e) {
ASSERT(0);
TRACE(_T("%s\n"), e.ToString());
}
@@ -57,37 +57,37 @@ namespace ssf Commit();
- if(s.PeekChar() != Stream::EOS) {
+ if (s.PeekChar() != Stream::EOS) {
TRACE(_T("Warning: parsing ended before EOF!\n"));
}
}
void File::ParseDefs(InputStream& s, Reference* pParentRef)
{
- while(s.SkipWhiteSpace(L";") != '}' && s.PeekChar() != Stream::EOS) {
+ while (s.SkipWhiteSpace(L";") != '}' && s.PeekChar() != Stream::EOS) {
NodePriority priority = PNormal;
CAtlList<CStringW> types;
CStringW name;
int c = s.SkipWhiteSpace();
- if(c == '*') {
+ if (c == '*') {
s.GetChar();
priority = PLow;
- } else if(c == '!') {
+ } else if (c == '!') {
s.GetChar();
priority = PHigh;
}
ParseTypes(s, types);
- if(s.SkipWhiteSpace() == '#') {
+ if (s.SkipWhiteSpace() == '#') {
s.GetChar();
ParseName(s, name);
}
- if(types.IsEmpty()) {
- if(name.IsEmpty()) {
+ if (types.IsEmpty()) {
+ if (name.IsEmpty()) {
s.ThrowError(_T("syntax error"));
}
types.AddTail(L"?");
@@ -95,23 +95,23 @@ namespace ssf Reference* pRef = pParentRef;
- while(types.GetCount() > 1) {
+ while (types.GetCount() > 1) {
pRef = CreateRef(CreateDef(pRef, types.RemoveHead()));
}
Definition* pDef = NULL;
- if(!types.IsEmpty()) {
+ if (!types.IsEmpty()) {
pDef = CreateDef(pRef, types.RemoveHead(), name, priority);
}
c = s.SkipWhiteSpace(L":=");
- if(c == '"' || c == '\'') {
+ if (c == '"' || c == '\'') {
ParseQuotedString(s, pDef);
- } else if(iswdigit(c) || c == '+' || c == '-') {
+ } else if (iswdigit(c) || c == '+' || c == '-') {
ParseNumber(s, pDef);
- } else if(pDef->IsType(L"@")) {
+ } else if (pDef->IsType(L"@")) {
ParseBlock(s, pDef);
} else {
ParseRefs(s, pDef);
@@ -127,24 +127,24 @@ namespace ssf CStringW str;
- for(int c = s.SkipWhiteSpace(); iswcsym(c) || c == '.' || c == '@'; c = s.PeekChar()) {
+ for (int c = s.SkipWhiteSpace(); iswcsym(c) || c == '.' || c == '@'; c = s.PeekChar()) {
c = s.GetChar();
- if(c == '.') {
- if(str.IsEmpty()) {
+ if (c == '.') {
+ if (str.IsEmpty()) {
s.ThrowError(_T("'type' cannot be an empty string"));
}
- if(!iswcsym(s.PeekChar())) {
+ if (!iswcsym(s.PeekChar())) {
s.ThrowError(_T("unexpected dot after type '%s'"), CString(str));
}
types.AddTail(str);
str.Empty();
} else {
- if(str.IsEmpty() && iswdigit(c)) {
+ if (str.IsEmpty() && iswdigit(c)) {
s.ThrowError(_T("'type' cannot start with a number"));
}
- if((!str.IsEmpty() || !types.IsEmpty()) && c == '@') {
+ if ((!str.IsEmpty() || !types.IsEmpty()) && c == '@') {
s.ThrowError(_T("unexpected @ in 'type'"));
}
@@ -152,7 +152,7 @@ namespace ssf }
}
- if(!str.IsEmpty()) {
+ if (!str.IsEmpty()) {
types.AddTail(str);
}
}
@@ -161,8 +161,8 @@ namespace ssf {
name.Empty();
- for(int c = s.SkipWhiteSpace(); iswcsym(c); c = s.PeekChar()) {
- if(name.IsEmpty() && iswdigit(c)) {
+ for (int c = s.SkipWhiteSpace(); iswcsym(c); c = s.PeekChar()) {
+ if (name.IsEmpty() && iswdigit(c)) {
s.ThrowError(_T("'name' cannot start with a number"));
}
name += (WCHAR)s.GetChar();
@@ -174,24 +174,24 @@ namespace ssf CStringW v;
int quote = s.SkipWhiteSpace();
- if(quote != '"' && quote != '\'') {
+ if (quote != '"' && quote != '\'') {
s.ThrowError(_T("expected qouted string"));
}
s.GetChar();
- for(int c = s.PeekChar(); c != Stream::EOS; c = s.PeekChar()) {
+ for (int c = s.PeekChar(); c != Stream::EOS; c = s.PeekChar()) {
c = s.GetChar();
- if(c == quote) {
+ if (c == quote) {
pDef->SetAsValue(Definition::string, v);
return;
}
- if(c == '\n') {
+ if (c == '\n') {
s.ThrowError(_T("qouted string terminated unexpectedly by a new-line character"));
}
- if(c == '\\') {
+ if (c == '\\') {
c = s.GetChar();
}
- if(c == Stream::EOS) {
+ if (c == Stream::EOS) {
s.ThrowError(_T("qouted string terminated unexpectedly by EOS"));
}
v += (WCHAR)c;
@@ -204,8 +204,8 @@ namespace ssf {
CStringW v, u;
- for(int c = s.SkipWhiteSpace(); iswxdigit(c) || wcschr(L"+-.x:", c); c = s.PeekChar()) {
- if((c == '+' || c == '-') && !v.IsEmpty()
+ for (int c = s.SkipWhiteSpace(); iswxdigit(c) || wcschr(L"+-.x:", c); c = s.PeekChar()) {
+ if ((c == '+' || c == '-') && !v.IsEmpty()
|| (c == '.' && (v.IsEmpty() || v.Find('.') >= 0 || v.Find('x') >= 0))
|| (c == 'x' && v != '0')
|| (c >= 'a' && c <= 'f' || c >= 'A' && c <= 'F') && v.Find(L"0x") != 0
@@ -216,11 +216,11 @@ namespace ssf v += (WCHAR)s.GetChar();
}
- if(v.IsEmpty()) {
+ if (v.IsEmpty()) {
s.ThrowError(_T("invalid number"));
}
- for(int c = s.SkipWhiteSpace(); iswcsym(c); c = s.PeekChar()) {
+ for (int c = s.SkipWhiteSpace(); iswcsym(c); c = s.PeekChar()) {
u += (WCHAR)s.GetChar();
}
@@ -232,28 +232,28 @@ namespace ssf CStringW v;
int c = s.SkipWhiteSpace(L":=");
- if(c != '{') {
+ if (c != '{') {
s.ThrowError(_T("expected '{'"));
}
s.GetChar();
int depth = 0;
- for(int c = s.PeekChar(); c != Stream::EOS; c = s.PeekChar()) {
+ for (int c = s.PeekChar(); c != Stream::EOS; c = s.PeekChar()) {
c = s.GetChar();
- if(c == '}' && depth == 0) {
+ if (c == '}' && depth == 0) {
pDef->SetAsValue(Definition::block, v);
return;
}
- if(c == '\\') {
+ if (c == '\\') {
v += (WCHAR)c;
c = s.GetChar();
- } else if(c == '{') {
+ } else if (c == '{') {
depth++;
- } else if(c == '}') {
+ } else if (c == '}') {
depth--;
}
- if(c == Stream::EOS) {
+ if (c == Stream::EOS) {
s.ThrowError(_T("block terminated unexpectedly by EOS"));
}
v += (WCHAR)c;
@@ -267,34 +267,34 @@ namespace ssf int c = s.SkipWhiteSpace();
do {
- if(pParentDef->IsValue()) {
+ if (pParentDef->IsValue()) {
s.ThrowError(_T("cannot mix references with other values"));
}
- if(c == '{') {
+ if (c == '{') {
s.GetChar();
ParseDefs(s, CreateRef(pParentDef));
- } else if(iswcsym(c)) {
+ } else if (iswcsym(c)) {
CStringW str;
ParseName(s, str);
// TODO: allow spec references: parent.<type>, self.<type>, child.<type>
Definition* pDef = GetDefByName(str);
- if(!pDef) {
+ if (!pDef) {
s.ThrowError(_T("cannot find definition of '%s'"), CString(str));
}
- if(!pParentDef->IsVisible(pDef)) {
+ if (!pParentDef->IsVisible(pDef)) {
s.ThrowError(_T("cannot access '%s' from here"), CString(str));
}
pParentDef->AddTail(pDef);
- } else if(!wcschr(term, c) && c != Stream::EOS) {
+ } else if (!wcschr(term, c) && c != Stream::EOS) {
s.ThrowError(_T("unexpected character '%c'"), (TCHAR)c);
}
c = s.SkipWhiteSpace();
- } while(!wcschr(term, c) && c != Stream::EOS);
+ } while (!wcschr(term, c) && c != Stream::EOS);
}
}
diff --git a/src/Subtitles/libssf/FontWrapper.cpp b/src/Subtitles/libssf/FontWrapper.cpp index 40fd717a7..e1878172d 100644 --- a/src/Subtitles/libssf/FontWrapper.cpp +++ b/src/Subtitles/libssf/FontWrapper.cpp @@ -32,10 +32,10 @@ namespace ssf GetTextMetrics(hDC, &m_tm);
- if(DWORD nNumPairs = GetKerningPairs(hDC, 0, NULL)) {
+ if (DWORD nNumPairs = GetKerningPairs(hDC, 0, NULL)) {
KERNINGPAIR* kp = DNew KERNINGPAIR[nNumPairs];
GetKerningPairs(hDC, nNumPairs, kp);
- for(DWORD i = 0; i < nNumPairs; i++) {
+ for (DWORD i = 0; i < nNumPairs; i++) {
m_kerning[(kp[i].wFirst<<16)|kp[i].wSecond] = kp[i].iKernAmount;
}
delete [] kp;
diff --git a/src/Subtitles/libssf/Glyph.cpp b/src/Subtitles/libssf/Glyph.cpp index 5fd5b4324..4db3fa498 100644 --- a/src/Subtitles/libssf/Glyph.cpp +++ b/src/Subtitles/libssf/Glyph.cpp @@ -67,10 +67,10 @@ namespace ssf {
path_bkg.RemoveAll();
- if(style.background.type == L"enlarge" && style.background.size > 0) {
+ if (style.background.type == L"enlarge" && style.background.size > 0) {
path_bkg.Enlarge(path, GetBackgroundSize());
- } else if(style.background.type == L"box" && style.background.size >= 0) {
- if(c != ssf::Text::LSEP) {
+ } else if (style.background.type == L"box" && style.background.size >= 0) {
+ if (c != ssf::Text::LSEP) {
int s = (int)(GetBackgroundSize() + 0.5);
int x0 = (!vertical ? -spacing/2 : ascent - row_ascent);
int y0 = (!vertical ? ascent - row_ascent : -spacing/2);
@@ -94,7 +94,7 @@ namespace ssf {
spline.RemoveAll();
- if(style.placement.path.IsEmpty()) {
+ if (style.placement.path.IsEmpty()) {
return;
}
@@ -105,14 +105,14 @@ namespace ssf Point p;
- while(i < j) {
+ while (i < j) {
p.x = style.placement.path[i].x * scale.cx + spdrc.left * 64;
p.y = style.placement.path[i].y * scale.cy + spdrc.top * 64;
pts[++i] = p;
}
- if(pts.GetCount() >= 4) {
- if(pts[1].x == pts[j].x && pts[1].y == pts[j].y) {
+ if (pts.GetCount() >= 4) {
+ if (pts[1].x == pts[j].x && pts[1].y == pts[j].y) {
pts.SetAt(0, pts[j-1]);
pts.SetAt(j+1, pts[2]);
} else {
@@ -127,7 +127,7 @@ namespace ssf spline.SetCount(pts.GetCount()-3);
- for(size_t i = 0, j = pts.GetCount()-4; i <= j; i++) {
+ for (size_t i = 0, j = pts.GetCount()-4; i <= j; i++) {
static const float _1div6 = 1.0f / 6;
SplineCoeffs sc;
@@ -165,17 +165,17 @@ namespace ssf float cay = cos(deg2rad(style.placement.angle.y));
float say = sin(deg2rad(style.placement.angle.y));
- for(size_t i = 0, j = path.types.GetCount(); i < j; i++) {
+ for (size_t i = 0, j = path.types.GetCount(); i < j; i++) {
CPoint p = path.points[i];
- if(bscale) {
+ if (bscale) {
float x, y, z;
x = sx * (p.x - org.x);
y = sy * (p.y - org.y);
z = 0;
- if(bspline) {
+ if (bspline) {
float pos = vertical ? y + org.y + tl.y - subrect.top : x + org.x + tl.x - subrect.left;
float size = vertical ? subrect.Size().cy : subrect.Size().cx;
float dist = vertical ? x : y;
@@ -183,7 +183,7 @@ namespace ssf const SplineCoeffs* sc;
float t;
- if(pos >= size) {
+ if (pos >= size) {
sc = &spline[spline.GetCount() - 1];
t = 1;
} else {
@@ -203,7 +203,7 @@ namespace ssf y = sc->cy[0] + t*(sc->cy[1] + t*(sc->cy[2] + t*sc->cy[3])) + nx * dist - org.y - tl.y;
}
- if(brotate) {
+ if (brotate) {
float xx = x*caz + y*saz;
float yy = -(x*saz - y*caz);
float zz = z;
@@ -228,16 +228,16 @@ namespace ssf path.points[i] = p;
}
- if(p.x < bbox.left) {
+ if (p.x < bbox.left) {
bbox.left = p.x;
}
- if(p.x > bbox.right) {
+ if (p.x > bbox.right) {
bbox.right = p.x;
}
- if(p.y < bbox.top) {
+ if (p.y < bbox.top) {
bbox.top = p.y;
}
- if(p.y > bbox.bottom) {
+ if (p.y > bbox.bottom) {
bbox.bottom = p.y;
}
}
@@ -245,10 +245,10 @@ namespace ssf void Glyph::Transform(CPoint org, const CRect& subrect)
{
- if(!style.placement.org.auto_x) {
+ if (!style.placement.org.auto_x) {
org.x = style.placement.org.x * scale.cx;
}
- if(!style.placement.org.auto_y) {
+ if (!style.placement.org.auto_y) {
org.y = style.placement.org.y * scale.cy;
}
@@ -264,14 +264,14 @@ namespace ssf void Glyph::Rasterize()
{
- if(!path_bkg.IsEmpty()) {
+ if (!path_bkg.IsEmpty()) {
ras_bkg.ScanConvert(path_bkg, bbox);
ras_bkg.Rasterize(tl.x, tl.y);
}
ras.ScanConvert(path, bbox);
- if(style.background.type == L"outline" && style.background.size > 0) {
+ if (style.background.type == L"outline" && style.background.size > 0) {
ras.CreateWidenedRegion((int)(GetBackgroundSize() + 0.5));
}
@@ -283,7 +283,7 @@ namespace ssf ras.Rasterize(tl.x, tl.y);
r->Blur(style.background.blur, plane);
- if(style.shadow.depth > 0) {
+ if (style.shadow.depth > 0) {
ras_shadow.Reuse(*r);
float depth = GetShadowDepth();
diff --git a/src/Subtitles/libssf/GlyphPath.cpp b/src/Subtitles/libssf/GlyphPath.cpp index 1c08945de..7ae264815 100644 --- a/src/Subtitles/libssf/GlyphPath.cpp +++ b/src/Subtitles/libssf/GlyphPath.cpp @@ -31,7 +31,7 @@ namespace ssf GlyphPath& GlyphPath::operator = (const GlyphPath& path)
{
- if(this != &path) {
+ if (this != &path) {
types.Copy(path.types);
points.Copy(path.points);
}
@@ -56,15 +56,15 @@ namespace ssf unsigned int i = 0;
- if(!!(g_cpuid.m_flags & CCpuID::sse2) && !((DWORD_PTR)p & 7)) {
- for( ; i < n && ((DWORD_PTR)&p[i] & 15); i++) {
+ if (!!(g_cpuid.m_flags & CCpuID::sse2) && !((DWORD_PTR)p & 7)) {
+ for ( ; i < n && ((DWORD_PTR)&p[i] & 15); i++) {
p[i].x += o.x;
p[i].y += o.y;
}
__m128i oo = _mm_set_epi32(o.y, o.x, o.y, o.x);
- for(unsigned int j = i + ((n - i) & ~7); i < j; i += 8) {
+ for (unsigned int j = i + ((n - i) & ~7); i < j; i += 8) {
__m128i r0 = _mm_load_si128((__m128i*)&p[i+0]);
__m128i r1 = _mm_load_si128((__m128i*)&p[i+2]);
__m128i r2 = _mm_load_si128((__m128i*)&p[i+4]);
@@ -76,7 +76,7 @@ namespace ssf }
}
- for(; i < n; i++) {
+ for (; i < n; i++) {
p[i].x += o.x;
p[i].y += o.y;
}
@@ -91,8 +91,8 @@ namespace ssf size_t start = 0, end = 0;
- for(size_t i = 0, j = src.types.GetCount(); i <= j; i++) {
- if(i > 0 && (i == j || (src.types[i] & ~PT_CLOSEFIGURE) == PT_MOVETO)) {
+ for (size_t i = 0, j = src.types.GetCount(); i <= j; i++) {
+ if (i > 0 && (i == j || (src.types[i] & ~PT_CLOSEFIGURE) == PT_MOVETO)) {
end = i-1;
bool cw = true; // TODO: determine orientation (ttf is always cw and we are sill before Transform)
@@ -101,18 +101,18 @@ namespace ssf CPoint prev = src.points[end];
CPoint cur = src.points[start];
- for(size_t k = start; k <= end; k++) {
+ for (size_t k = start; k <= end; k++) {
CPoint next = k < end ? src.points[k+1] : src.points[start];
- for(int l = int(k-1); prev == cur; l--) {
- if(l < (int)start) {
+ for (int l = int(k-1); prev == cur; l--) {
+ if (l < (int)start) {
l = int(end);
}
prev = src.points[l];
}
- for(int l = int(k+1); next == cur; l++) {
- if(l > (int)end) {
+ for (int l = int(k+1); next == cur; l++) {
+ if (l > (int)end) {
l = int(start);
}
next = src.points[l];
@@ -124,39 +124,39 @@ namespace ssf float angle_in = atan2((float)in.y, (float)in.x);
float angle_out = atan2((float)out.y, (float)out.x);
float angle_diff = angle_out - angle_in;
- if(angle_diff < 0) {
+ if (angle_diff < 0) {
angle_diff += (float)M_PI*2;
}
- if(angle_diff > M_PI) {
+ if (angle_diff > M_PI) {
angle_diff -= (float)M_PI*2;
}
float scale = cos(angle_diff / 2);
CPoint p;
- if(angle_diff < 0) {
- if(angle_diff > -M_PI/8) {
- if(scale < 1) {
+ if (angle_diff < 0) {
+ if (angle_diff > -M_PI/8) {
+ if (scale < 1) {
scale = 1;
}
} else {
- if(scale < 0.50) {
+ if (scale < 0.50) {
scale = 0.50;
}
}
} else {
- if(angle_diff < M_PI/8) {
- if(scale < 0.75) {
+ if (angle_diff < M_PI/8) {
+ if (scale < 0.75) {
scale = 0.75;
}
} else {
- if(scale < 0.25) {
+ if (scale < 0.25) {
scale = 0.25;
}
}
}
- if(scale < 0.1) {
+ if (scale < 0.1) {
scale = 0.1f;
}
diff --git a/src/Subtitles/libssf/Node.cpp b/src/Subtitles/libssf/Node.cpp index 93b111616..70bc6bb08 100644 --- a/src/Subtitles/libssf/Node.cpp +++ b/src/Subtitles/libssf/Node.cpp @@ -42,7 +42,7 @@ namespace ssf void Node::AddTail(Node* pNode)
{
- if(POSITION pos = m_nodes.Find(pNode)) { // TODO: slow
+ if (POSITION pos = m_nodes.Find(pNode)) { // TODO: slow
m_nodes.MoveToTail(pos);
return;
}
@@ -70,20 +70,20 @@ namespace ssf {
CAtlList<Definition*> rdl[3];
- if(fFirst) {
- if(Definition* pDef = m_pnf->GetDefByName(m_type)) {
+ if (fFirst) {
+ if (Definition* pDef = m_pnf->GetDefByName(m_type)) {
pDef->GetChildDefs(rdl[pDef->m_priority], type, false);
}
}
POSITION pos = m_nodes.GetHeadPosition();
- while(pos) {
- if(Node* pNode = m_nodes.GetNext(pos)) {
+ while (pos) {
+ if (Node* pNode = m_nodes.GetNext(pos)) {
pNode->GetChildDefs(rdl[pNode->m_priority], type, false);
}
}
- for(int i = 0; i < sizeof(rdl)/sizeof(rdl[0]); i++) {
+ for (int i = 0; i < sizeof(rdl)/sizeof(rdl[0]); i++) {
l.AddTailList(&rdl[i]);
}
}
@@ -104,22 +104,22 @@ namespace ssf CAtlList<Definition*> rdl[3];
POSITION pos = m_nodes.GetHeadPosition();
- while(pos) {
- if(Definition* pDef = dynamic_cast<Definition*>(m_nodes.GetNext(pos))) {
- if(!type || pDef->m_type == type) { // TODO: faster lookup
+ while (pos) {
+ if (Definition* pDef = dynamic_cast<Definition*>(m_nodes.GetNext(pos))) {
+ if (!type || pDef->m_type == type) { // TODO: faster lookup
rdl[pDef->m_priority].AddTail(pDef);
}
}
}
- for(int i = 0; i < sizeof(rdl)/sizeof(rdl[0]); i++) {
+ for (int i = 0; i < sizeof(rdl)/sizeof(rdl[0]); i++) {
l.AddTailList(&rdl[i]);
}
}
void Reference::Dump(OutputStream& s, int level, bool fLast)
{
- if(m_predefined) {
+ if (m_predefined) {
return;
}
@@ -129,10 +129,10 @@ namespace ssf s.PutString(L" {\n");
POSITION pos = m_nodes.GetHeadPosition();
- while(pos) {
+ while (pos) {
Node* pNode = m_nodes.GetNext(pos);
- if(Definition* pDef = dynamic_cast<Definition*>(pNode)) {
+ if (Definition* pDef = dynamic_cast<Definition*>(pNode)) {
pDef->Dump(s, level + 1, pos == NULL);
}
}
@@ -158,8 +158,8 @@ namespace ssf {
Node* pNode = m_parent;
- while(pNode) {
- if(pNode->m_name2node.Lookup(pDef->m_name)) {
+ while (pNode) {
+ if (pNode->m_name2node.Lookup(pDef->m_name)) {
return true;
}
@@ -177,7 +177,7 @@ namespace ssf m_status = node;
- if(IsTypeUnknown() && !pNode->IsTypeUnknown()) {
+ if (IsTypeUnknown() && !pNode->IsTypeUnknown()) {
m_type = pNode->m_type;
m_autotype = true;
}
@@ -191,7 +191,7 @@ namespace ssf Definition& Definition::operator[] (LPCWSTR type)
{
Definition* pRetDef = NULL;
- if(m_type2def.Lookup(type, pRetDef)) {
+ if (m_type2def.Lookup(type, pRetDef)) {
return *pRetDef;
}
@@ -203,13 +203,13 @@ namespace ssf CAtlList<Definition*> l;
GetChildDefs(l, type);
- while(!l.IsEmpty()) {
+ while (!l.IsEmpty()) {
Definition* pDef = l.RemoveHead();
pRetDef->m_priority = pDef->m_priority;
pRetDef->m_parent = pDef->m_parent;
- if(pDef->IsValue()) {
+ if (pDef->IsValue()) {
pRetDef->SetAsValue(pDef->m_status, pDef->m_value, pDef->m_unit);
} else {
pRetDef->m_status = node;
@@ -222,12 +222,12 @@ namespace ssf void Definition::RemoveFromCache(LPCWSTR type)
{
- if(!type) {
+ if (!type) {
POSITION pos = m_type2def.GetStartPosition();
- while(pos) {
+ while (pos) {
delete m_type2def.GetNextValue(pos);
}
- } else if(StringMapW<Definition*>::CPair* p = m_type2def.Lookup(type)) {
+ } else if (StringMapW<Definition*>::CPair* p = m_type2def.Lookup(type)) {
delete p->m_value;
m_type2def.RemoveKey(type);
}
@@ -269,26 +269,26 @@ namespace ssf n.unit = m_unit;
n.sign = 0;
- if(n2n) {
- if(m_status == node) {
+ if (n2n) {
+ if (m_status == node) {
throw Exception(_T("expected value type"));
}
- if(StringMapW<T>::CPair* p = n2n->Lookup(str)) {
+ if (StringMapW<T>::CPair* p = n2n->Lookup(str)) {
n.value = p->m_value;
return;
}
}
- if(m_status != number) {
+ if (m_status != number) {
throw Exception(_T("expected number"));
}
n.sign = str.Find('+') == 0 ? 1 : str.Find('-') == 0 ? -1 : 0;
str.TrimLeft(L"+-");
- if(str.Find(L"0x") == 0) {
- if(n.sign) {
+ if (str.Find(L"0x") == 0) {
+ if (n.sign) {
throw Exception(_T("hex values must be unsigned"));
}
@@ -296,30 +296,30 @@ namespace ssf } else {
CStringW num_string = m_value + m_unit;
- if(m_num_string != num_string) {
+ if (m_num_string != num_string) {
Split sa(':', str);
Split sa2('.', sa ? sa[sa-1] : L"");
- if(sa == 0 || sa2 == 0 || sa2 > 2) {
+ if (sa == 0 || sa2 == 0 || sa2 > 2) {
throw Exception(_T("invalid number"));
}
float f = 0;
- for(size_t i = 0; i < sa; i++) {
+ for (size_t i = 0; i < sa; i++) {
f *= 60;
f += wcstoul(sa[i], NULL, 10);
}
- if(sa2 > 1) {
+ if (sa2 > 1) {
f += (float)wcstoul(sa2[1], NULL, 10) / pow((float)10, sa2[1].GetLength());
}
- if(n.unit == L"ms") {
+ if (n.unit == L"ms") {
f /= 1000;
n.unit = L"s";
- } else if(n.unit == L"m") {
+ } else if (n.unit == L"m") {
f *= 60;
n.unit = L"s";
- } else if(n.unit == L"h") {
+ } else if (n.unit == L"h") {
f *= 3600;
n.unit = L"s";
}
@@ -334,7 +334,7 @@ namespace ssf n.unit = m_num.unit;
}
- if(n.sign) {
+ if (n.sign) {
n.value *= n.sign;
}
}
@@ -342,7 +342,7 @@ namespace ssf void Definition::GetAsString(CStringW& str)
{
- if(m_status == node) {
+ if (m_status == node) {
throw Exception(_T("expected value type"));
}
@@ -366,7 +366,7 @@ namespace ssf {
static StringMapW<bool> s2b;
- if(s2b.IsEmpty()) {
+ if (s2b.IsEmpty()) {
s2b[L"true"] = true;
s2b[L"on"] = true;
s2b[L"yes"] = true;
@@ -377,7 +377,7 @@ namespace ssf s2b[L"0"] = false;
}
- if(!s2b.Lookup(m_value, b)) { // m_status != boolean && m_status != number ||
+ if (!s2b.Lookup(m_value, b)) { // m_status != boolean && m_status != number ||
throw Exception(_T("expected boolean"));
}
}
@@ -387,7 +387,7 @@ namespace ssf Definition& time = (*this)[L"time"];
CStringW id;
- if(time[L"id"].IsValue()) {
+ if (time[L"id"].IsValue()) {
id = time[L"id"];
} else {
id.Format(L"%d", default_id);
@@ -395,24 +395,24 @@ namespace ssf float scale = time[L"scale"].IsValue() ? time[L"scale"] : 1.0f;
- if(time[L"start"].IsValue() && time[L"stop"].IsValue()) {
+ if (time[L"start"].IsValue() && time[L"stop"].IsValue()) {
time[L"start"].GetAsNumber(t.start, n2n);
time[L"stop"].GetAsNumber(t.stop, n2n);
- if(t.start.unit.IsEmpty()) {
+ if (t.start.unit.IsEmpty()) {
t.start.value *= scale;
}
- if(t.stop.unit.IsEmpty()) {
+ if (t.stop.unit.IsEmpty()) {
t.stop.value *= scale;
}
float o = 0;
offset.Lookup(id, o);
- if(t.start.sign != 0) {
+ if (t.start.sign != 0) {
t.start.value = o + t.start.value;
}
- if(t.stop.sign != 0) {
+ if (t.stop.sign != 0) {
t.stop.value = t.start.value + t.stop.value;
}
@@ -451,33 +451,33 @@ namespace ssf Split split('.', path);
- for(size_t i = 0, j = split-1; i <= j; i++) {
+ for (size_t i = 0, j = split-1; i <= j; i++) {
CStringW type = split[i];
- if(pDef->m_nodes.IsEmpty() || !dynamic_cast<Reference*>(pDef->m_nodes.GetTail())) {
+ if (pDef->m_nodes.IsEmpty() || !dynamic_cast<Reference*>(pDef->m_nodes.GetTail())) {
EXECUTE_ASSERT(m_pnf->CreateRef(pDef) != NULL);
}
- if(Reference* pRef = dynamic_cast<Reference*>(pDef->m_nodes.GetTail())) {
+ if (Reference* pRef = dynamic_cast<Reference*>(pDef->m_nodes.GetTail())) {
pDef = NULL;
POSITION pos = pRef->m_nodes.GetTailPosition();
- while(pos) {
+ while (pos) {
Definition* pChildDef = dynamic_cast<Definition*>(pRef->m_nodes.GetPrev(pos));
- if(pChildDef->IsType(type)) {
- if(pChildDef->IsNameUnknown()) {
+ if (pChildDef->IsType(type)) {
+ if (pChildDef->IsNameUnknown()) {
pDef = pChildDef;
}
break;
}
}
- if(!pDef) {
+ if (!pDef) {
pDef = m_pnf->CreateDef(pRef, type);
}
- if(i == j) {
+ if (i == j) {
pDef->SetAsValue(s, v, u);
return pDef;
}
@@ -499,36 +499,36 @@ namespace ssf void Definition::Dump(OutputStream& s, int level, bool fLast)
{
- if(m_predefined) {
+ if (m_predefined) {
return;
}
CStringW tabs(' ', level*4);
CStringW str = tabs;
- if(m_predefined) {
+ if (m_predefined) {
str += '?';
}
- if(m_priority == PLow) {
+ if (m_priority == PLow) {
str += '*';
- } else if(m_priority == PHigh) {
+ } else if (m_priority == PHigh) {
str += '!';
}
- if(!IsTypeUnknown() && !m_autotype) {
+ if (!IsTypeUnknown() && !m_autotype) {
str += m_type;
}
- if(!IsNameUnknown()) {
+ if (!IsNameUnknown()) {
str += '#' + m_name;
}
str += ':';
s.PutString(L"%s", str);
- if(!m_nodes.IsEmpty()) {
+ if (!m_nodes.IsEmpty()) {
POSITION pos = m_nodes.GetHeadPosition();
- while(pos) {
+ while (pos) {
Node* pNode = m_nodes.GetNext(pos);
- if(Reference* pRef = dynamic_cast<Reference*>(pNode)) {
+ if (Reference* pRef = dynamic_cast<Reference*>(pNode)) {
pRef->Dump(s, level, fLast);
} else {
ASSERT(!pNode->IsNameUnknown());
@@ -538,22 +538,22 @@ namespace ssf s.PutString(L";\n");
- if(!fLast && (!m_nodes.IsEmpty() || level == 0)) {
+ if (!fLast && (!m_nodes.IsEmpty() || level == 0)) {
s.PutString(L"\n");
}
- } else if(m_status == string) {
+ } else if (m_status == string) {
CStringW str = m_value;
str.Replace(L"\"", L"\\\"");
s.PutString(L" \"%s\";\n", str);
- } else if(m_status == number) {
+ } else if (m_status == number) {
CStringW str = m_value;
- if(!m_unit.IsEmpty()) {
+ if (!m_unit.IsEmpty()) {
str += m_unit;
}
s.PutString(L" %s;\n", str);
- } else if(m_status == boolean) {
+ } else if (m_status == boolean) {
s.PutString(L" %s;\n", m_value);
- } else if(m_status == block) {
+ } else if (m_status == block) {
s.PutString(L" {%s};\n", m_value);
} else {
s.PutString(L" null;\n");
diff --git a/src/Subtitles/libssf/NodeFactory.cpp b/src/Subtitles/libssf/NodeFactory.cpp index d9a73eaaa..f91de1e19 100644 --- a/src/Subtitles/libssf/NodeFactory.cpp +++ b/src/Subtitles/libssf/NodeFactory.cpp @@ -49,7 +49,7 @@ namespace ssf m_root = NULL;
POSITION pos = m_nodes.GetStartPosition();
- while(pos) {
+ while (pos) {
delete m_nodes.GetNextValue(pos);
}
m_nodes.RemoveAll();
@@ -65,8 +65,8 @@ namespace ssf void NodeFactory::Rollback()
{
POSITION pos = m_newnodes.GetTailPosition();
- while(pos) {
- if(StringMap<Node*, CStringW>::CPair* p = m_nodes.Lookup(m_newnodes.GetPrev(pos))) {
+ while (pos) {
+ if (StringMap<Node*, CStringW>::CPair* p = m_nodes.Lookup(m_newnodes.GetPrev(pos))) {
delete p->m_value; // TODO: remove it from "parent"->m_nodes too
m_nodes.RemoveKey(p->m_key);
}
@@ -95,7 +95,7 @@ namespace ssf m_nodes.SetAt(name, pRef);
m_newnodes.AddTail(name);
- if(pParentDef) {
+ if (pParentDef) {
pParentDef->AddTail(pRef);
pRef->m_parent = pParentDef;
}
@@ -107,29 +107,29 @@ namespace ssf {
Definition* pDef = NULL;
- if(name.IsEmpty()) {
+ if (name.IsEmpty()) {
name = GenName();
} else {
pDef = GetDefByName(name);
- if(pDef) {
- if(!pDef->m_predefined) {
+ if (pDef) {
+ if (!pDef->m_predefined) {
throw Exception(_T("redefinition of '%s' is not allowed"), CString(name));
}
- if(!pDef->IsTypeUnknown() && !pDef->IsType(type)) {
+ if (!pDef->IsTypeUnknown() && !pDef->IsType(type)) {
throw Exception(_T("cannot redefine type of %s to %s"), CString(name), CString(type));
}
}
}
- if(!pDef) {
+ if (!pDef) {
pDef = DNew Definition(this, name);
m_nodes.SetAt(name, pDef);
m_newnodes.AddTail(name);
- if(pParentRef) {
+ if (pParentRef) {
pParentRef->AddTail(pDef);
pDef->m_parent = pParentRef;
}
@@ -154,8 +154,8 @@ namespace ssf defs.RemoveAll();
POSITION pos = m_newnodes.GetHeadPosition();
- while(pos) {
- if(Definition* pDef = GetDefByName(m_newnodes.GetNext(pos))) {
+ while (pos) {
+ if (Definition* pDef = GetDefByName(m_newnodes.GetNext(pos))) {
defs.AddTail(pDef);
}
}
@@ -163,12 +163,12 @@ namespace ssf void NodeFactory::Dump(OutputStream& s) const
{
- if(!m_root) {
+ if (!m_root) {
return;
}
POSITION pos = m_root->m_nodes.GetHeadPosition();
- while(pos) {
+ while (pos) {
m_root->m_nodes.GetNext(pos)->Dump(s);
}
}
diff --git a/src/Subtitles/libssf/Rasterizer.cpp b/src/Subtitles/libssf/Rasterizer.cpp index c7c9c3382..02ad744ee 100644 --- a/src/Subtitles/libssf/Rasterizer.cpp +++ b/src/Subtitles/libssf/Rasterizer.cpp @@ -58,7 +58,7 @@ namespace ssf void Rasterizer::_TrashOverlay()
{
- if(mpOverlayBuffer) {
+ if (mpOverlayBuffer) {
delete [] mpOverlayBuffer;
}
mpOverlayBuffer = NULL;
@@ -72,7 +72,7 @@ namespace ssf void Rasterizer::_EvaluateBezier(const CPoint& p0, const CPoint& p1, const CPoint& p2, const CPoint& p3)
{
- if(abs(p0.x + p2.x - p1.x*2) +
+ if (abs(p0.x + p2.x - p1.x*2) +
abs(p0.y + p2.y - p1.y*2) +
abs(p1.x + p3.x - p2.x*2) +
abs(p1.y + p3.y - p2.y*2) <= max(2, 1<<FONT_AA)) {
@@ -100,11 +100,11 @@ namespace ssf void Rasterizer::_EvaluateLine(CPoint p0, CPoint p1)
{
- if(lastp != p0) {
+ if (lastp != p0) {
_EvaluateLine(lastp, p0);
}
- if(!fFirstSet) {
+ if (!fFirstSet) {
firstp = p0;
fFirstSet = true;
}
@@ -113,7 +113,7 @@ namespace ssf // TODO: ((1<<FONT_SCALE)/2+-1)
- if(p1.y > p0.y) { // down
+ if (p1.y > p0.y) { // down
int xacc = p0.x << (8 - FONT_SCALE);
// prestep p0.y down
@@ -124,16 +124,16 @@ namespace ssf p1.y = (p1.y - ((1<<FONT_SCALE)/2+1)) >> FONT_SCALE;
- if(iy <= p1.y) {
+ if (iy <= p1.y) {
int invslope = ((p1.x - p0.x) << 8) / dy;
- while(mEdgeNext + p1.y + 1 - iy > mEdgeHeapSize) {
+ while (mEdgeNext + p1.y + 1 - iy > mEdgeHeapSize) {
_ReallocEdgeBuffer(mEdgeHeapSize*2);
}
xacc += (invslope * (y - p0.y)) >> FONT_SCALE;
- while(iy <= p1.y) {
+ while (iy <= p1.y) {
int ix = (xacc + 128) >> 8;
mpEdgeBuffer[mEdgeNext].next = mpScanBuffer[iy];
@@ -145,7 +145,7 @@ namespace ssf xacc += invslope;
}
}
- } else if(p1.y < p0.y) { // up
+ } else if (p1.y < p0.y) { // up
int xacc = p1.x << (8 - FONT_SCALE);
// prestep p1.y down
@@ -156,16 +156,16 @@ namespace ssf p0.y = (p0.y - ((1<<FONT_SCALE)/2+1)) >> FONT_SCALE;
- if(iy <= p0.y) {
+ if (iy <= p0.y) {
int invslope = ((p0.x - p1.x) << 8) / dy;
- while(mEdgeNext + p0.y + 1 - iy > mEdgeHeapSize) {
+ while (mEdgeNext + p0.y + 1 - iy > mEdgeHeapSize) {
_ReallocEdgeBuffer(mEdgeHeapSize*2);
}
xacc += (invslope * (y - p1.y)) >> FONT_SCALE;
- while(iy <= p0.y) {
+ while (iy <= p0.y) {
int ix = (xacc + 128) >> 8;
mpEdgeBuffer[mEdgeNext].next = mpScanBuffer[iy];
@@ -187,7 +187,7 @@ namespace ssf mOutline.RemoveAll();
mWideOutline.RemoveAll();
- if(path.types.IsEmpty() || path.points.IsEmpty() || bbox.IsRectEmpty()) {
+ if (path.types.IsEmpty() || path.points.IsEmpty() || bbox.IsRectEmpty()) {
mPathOffsetX = mPathOffsetY = 0;
mWidth = mHeight = 0;
return 0;
@@ -200,7 +200,7 @@ namespace ssf path.MovePoints(CPoint(-minx*(1<<FONT_SCALE), -miny*(1<<FONT_SCALE)));
- if(minx > maxx || miny > maxy) {
+ if (minx > maxx || miny > maxy) {
mWidth = mHeight = 0;
mPathOffsetX = mPathOffsetY = 0;
return true;
@@ -238,10 +238,10 @@ namespace ssf BYTE* type = path.types.GetData();
POINT* pt = path.points.GetData();
- for(size_t i = 0, j = path.types.GetCount(); i < j; i++) {
- switch(type[i] & ~PT_CLOSEFIGURE) {
+ for (size_t i = 0, j = path.types.GetCount(); i < j; i++) {
+ switch (type[i] & ~PT_CLOSEFIGURE) {
case PT_MOVETO:
- if(lastmoveto >= 0 && firstp != lastp) {
+ if (lastmoveto >= 0 && firstp != lastp) {
_EvaluateLine(lastp, firstp);
}
lastmoveto = int(i);
@@ -249,12 +249,12 @@ namespace ssf lastp = pt[i];
break;
case PT_LINETO:
- if(j - (i-1) >= 2) {
+ if (j - (i-1) >= 2) {
_EvaluateLine(pt[i-1], pt[i]);
}
break;
case PT_BEZIERTO:
- if(j - (i-1) >= 4) {
+ if (j - (i-1) >= 4) {
_EvaluateBezier(pt[i-1], pt[i], pt[i+1], pt[i+2]);
}
i += 2;
@@ -262,7 +262,7 @@ namespace ssf }
}
- if(lastmoveto >= 0 && firstp != lastp) {
+ if (lastmoveto >= 0 && firstp != lastp) {
_EvaluateLine(lastp, firstp);
}
@@ -276,12 +276,12 @@ namespace ssf mOutline.SetCount(0, mEdgeNext / 2);
- for(int y = 0; y < mHeight; y++) {
+ for (int y = 0; y < mHeight; y++) {
int count = 0;
// Detangle scanline into edge heap.
- for(unsigned int ptr = mpScanBuffer[y]; ptr; ptr = mpEdgeBuffer[ptr].next) {
+ for (unsigned int ptr = mpScanBuffer[y]; ptr; ptr = mpEdgeBuffer[ptr].next) {
heap.push_back(mpEdgeBuffer[ptr].posandflag);
}
@@ -299,23 +299,23 @@ namespace ssf int x1 = 0;
- for(; itX1 != itX2; ++itX1) {
+ for (; itX1 != itX2; ++itX1) {
int x = *itX1;
- if(!count) {
+ if (!count) {
x1 = x >> 1;
}
- if(x&1) {
+ if (x&1) {
++count;
} else {
--count;
}
- if(!count) {
+ if (!count) {
int x2 = x >> 1;
- if(x2 > x1) {
+ if (x2 > x1) {
Span s(x1, y, x2, y);
s.first += 0x4000000040000000i64;
s.second += 0x4000000040000000i64;
@@ -350,10 +350,10 @@ namespace ssf o.first -= dx;
o.second += dx;
- while(a != ae && b != be) {
+ while (a != ae && b != be) {
Span x;
- if(b->first + o.first < a->first) {
+ if (b->first + o.first < a->first) {
// B span is earlier. Use it.
x.first = b->first + o.first;
@@ -363,30 +363,30 @@ namespace ssf // B spans don't overlap, so begin merge loop with A first.
- for(;;) {
+ for (;;) {
// If we run out of A spans or the A span doesn't overlap,
// then the next B span can't either (because B spans don't
// overlap) and we exit.
- if(a == ae || a->first > x.second) {
+ if (a == ae || a->first > x.second) {
break;
}
do {
x.second = mymax(x.second, a->second);
- } while(++a != ae && a->first <= x.second);
+ } while (++a != ae && a->first <= x.second);
// If we run out of B spans or the B span doesn't overlap,
// then the next A span can't either (because A spans don't
// overlap) and we exit.
- if(b == be || b->first + o.first > x.second) {
+ if (b == be || b->first + o.first > x.second) {
break;
}
do {
x.second = mymax(x.second, b->second + o.second);
- } while(++b != be && b->first + o.first <= x.second);
+ } while (++b != be && b->first + o.first <= x.second);
}
} else {
// A span is earlier. Use it.
@@ -397,30 +397,30 @@ namespace ssf // A spans don't overlap, so begin merge loop with B first.
- for(;;) {
+ for (;;) {
// If we run out of B spans or the B span doesn't overlap,
// then the next A span can't either (because A spans don't
// overlap) and we exit.
- if(b == be || b->first + o.first > x.second) {
+ if (b == be || b->first + o.first > x.second) {
break;
}
do {
x.second = mymax(x.second, b->second + o.second);
- } while(++b != be && b->first + o.first <= x.second);
+ } while (++b != be && b->first + o.first <= x.second);
// If we run out of A spans or the A span doesn't overlap,
// then the next B span can't either (because B spans don't
// overlap) and we exit.
- if(a == ae || a->first > x.second) {
+ if (a == ae || a->first > x.second) {
break;
}
do {
x.second = mymax(x.second, a->second);
- } while(++a != ae && a->first <= x.second);
+ } while (++a != ae && a->first <= x.second);
}
}
@@ -433,20 +433,20 @@ namespace ssf dst.Append(a, ae - a);
- for(; b != be; b++) {
+ for (; b != be; b++) {
dst.Add(Span(b->first + o.first, b->second + o.second));
}
}
bool Rasterizer::CreateWidenedRegion(int r)
{
- if(r < 0) {
+ if (r < 0) {
r = 0;
}
r >>= FONT_SCALE;
- for(int y = -r; y <= r; ++y) {
+ for (int y = -r; y <= r; ++y) {
int x = (int)(0.5f + sqrt(float(r*r - y*y)));
_OverlapRegion(mWideOutline, mOutline, x, y);
@@ -461,7 +461,7 @@ namespace ssf {
_TrashOverlay();
- if(!mWidth || !mHeight) {
+ if (!mWidth || !mHeight) {
mOverlayWidth = mOverlayHeight = 0;
return true;
}
@@ -480,7 +480,7 @@ namespace ssf int border = ((mWideBorder + ((1<<FONT_AA)-1)) & ~((1<<FONT_AA)-1)) + (1<<FONT_AA)*4;
- if(!mWideOutline.IsEmpty()) {
+ if (!mWideOutline.IsEmpty()) {
width += 2*border;
height += 2*border;
@@ -499,27 +499,27 @@ namespace ssf Array<Span>* pOutline[2] = {&mOutline, &mWideOutline};
- for(int i = 0; i < countof(pOutline); i++) {
+ for (int i = 0; i < countof(pOutline); i++) {
const Span* s = pOutline[i]->GetData();
- for(size_t j = 0, k = pOutline[i]->GetCount(); j < k; j++) {
+ for (size_t j = 0, k = pOutline[i]->GetCount(); j < k; j++) {
int y = s[j].y1 - 0x40000000 + ysub;
int x1 = s[j].x1 - 0x40000000 + xsub;
int x2 = s[j].x2 - 0x40000000 + xsub;
- if(x2 > x1) {
+ if (x2 > x1) {
int first = x1 >> FONT_AA;
int last = (x2-1) >> FONT_AA;
BYTE* dst = mpOverlayBuffer + 4*(mOverlayWidth * (y >> FONT_AA) + first) + i;
- if(first == last) {
+ if (first == last) {
*dst += x2 - x1;
} else {
*dst += (((first+1) << FONT_AA) - x1) << (6 - FONT_AA*2);
dst += 4;
- while(++first < last) {
+ while (++first < last) {
*dst += (1 << FONT_AA) << (6 - FONT_AA*2);
dst += 4;
}
@@ -530,11 +530,11 @@ namespace ssf }
}
- if(!mWideOutline.IsEmpty()) {
+ if (!mWideOutline.IsEmpty()) {
BYTE* p = mpOverlayBuffer;
- for(int j = 0; j < mOverlayHeight; j++, p += mOverlayWidth*4) {
- for(int i = 0; i < mOverlayWidth; i++) {
+ for (int j = 0; j < mOverlayHeight; j++, p += mOverlayWidth*4) {
+ for (int i = 0; i < mOverlayWidth; i++) {
p[i*4+2] = min(p[i*4+1], (1<<6) - p[i*4]); // TODO: sse2
}
}
@@ -545,7 +545,7 @@ namespace ssf void Rasterizer::Blur(float n, int plane)
{
- if(n <= 0 || !mOverlayWidth || !mOverlayHeight || !mpOverlayBuffer) {
+ if (n <= 0 || !mOverlayWidth || !mOverlayHeight || !mpOverlayBuffer) {
return;
}
@@ -554,14 +554,14 @@ namespace ssf int pitch = w*4;
BYTE* q0 = DNew BYTE[w*h];
- for(int pass = 0; pass < n; pass++) {
+ for (int pass = 0; pass < n; pass++) {
BYTE* p = mpOverlayBuffer + plane;
BYTE* q = q0;
- for(int y = 0; y < h; y++, p += pitch, q += w) {
+ for (int y = 0; y < h; y++, p += pitch, q += w) {
q[0] = (2*p[0] + p[4]) >> 2;
int x = 0;
- for(x = 1; x < w-1; x++) {
+ for (x = 1; x < w-1; x++) {
q[x] = (p[(x-1)*4] + 2*p[x*4] + p[(x+1)*4]) >> 2;
}
q[x] = (p[(x-1)*4] + 2*p[x*4]) >> 2;
@@ -570,10 +570,10 @@ namespace ssf p = mpOverlayBuffer + plane;
q = q0;
- for(int x = 0; x < w; x++, p += 4, q++) {
+ for (int x = 0; x < w; x++, p += 4, q++) {
p[0] = (2*q[0] + q[w]) >> 2;
int y = 0, yp, yq;
- for(y = 1, yp = y*pitch, yq = y*w; y < h-1; y++, yp += pitch, yq += w) {
+ for (y = 1, yp = y*pitch, yq = y*w; y < h-1; y++, yp += pitch, yq += w) {
p[yp] = (q[yq-w] + 2*q[yq] + q[yq+w]) >> 2;
}
p[yp] = (q[yq-w] + 2*q[yq]) >> 2;
@@ -628,7 +628,7 @@ namespace ssf {
CRect bbox(0, 0, 0, 0);
- if(!switchpts) {
+ if (!switchpts) {
return bbox;
}
@@ -646,24 +646,24 @@ namespace ssf int h = mOverlayHeight;
unsigned int xo = 0, yo = 0;
- if(x < r.left) {
+ if (x < r.left) {
xo = r.left - x;
w -= r.left - x;
x = r.left;
}
- if(y < r.top) {
+ if (y < r.top) {
yo = r.top - y;
h -= r.top - y;
y = r.top;
}
- if(x+w > r.right) {
+ if (x+w > r.right) {
w = r.right - x;
}
- if(y+h > r.bottom) {
+ if (y+h > r.bottom) {
h = r.bottom - y;
}
- if(w <= 0 || h <= 0) {
+ if (w <= 0 || h <= 0) {
return bbox;
}
@@ -679,21 +679,21 @@ namespace ssf bool fSSE2 = !!(g_cpuid.m_flags & CCpuID::sse2);
- while(h--) {
- if(switchpts[1] == 0xffffffff) {
- if(fSSE2) for(int wt=0; wt<w; ++wt) {
+ while (h--) {
+ if (switchpts[1] == 0xffffffff) {
+ if (fSSE2) for (int wt=0; wt<w; ++wt) {
pixmix_sse2(&dst[wt], color, src[wt*4]);
}
- else for(int wt=0; wt<w; ++wt) {
+ else for (int wt=0; wt<w; ++wt) {
pixmix_c(&dst[wt], color, src[wt*4]);
}
} else {
const DWORD* sw = switchpts;
- if(fSSE2)
- for(unsigned int wt=0; wt<(unsigned int)w; ++wt) {
- if(wt+xo >= sw[1]) {
- while(wt+xo >= sw[1]) {
+ if (fSSE2)
+ for (unsigned int wt=0; wt<(unsigned int)w; ++wt) {
+ if (wt+xo >= sw[1]) {
+ while (wt+xo >= sw[1]) {
sw += 2;
}
color = sw[-2];
@@ -701,9 +701,9 @@ namespace ssf pixmix_sse2(&dst[wt], color, src[wt*4]);
}
else
- for(unsigned int wt=0; wt<(unsigned int)w; ++wt) {
- if(wt+xo >= sw[1]) {
- while(wt+xo >= sw[1]) {
+ for (unsigned int wt=0; wt<(unsigned int)w; ++wt) {
+ if (wt+xo >= sw[1]) {
+ while (wt+xo >= sw[1]) {
sw += 2;
}
color = sw[-2];
diff --git a/src/Subtitles/libssf/Renderer.cpp b/src/Subtitles/libssf/Renderer.cpp index 619b74b25..4a82b9ba5 100644 --- a/src/Subtitles/libssf/Renderer.cpp +++ b/src/Subtitles/libssf/Renderer.cpp @@ -31,7 +31,7 @@ namespace ssf void ReverseList(T& l)
{
POSITION pos = l.GetHeadPosition();
- while(pos) {
+ while (pos) {
POSITION cur = pos;
l.GetNext(pos);
l.AddHead(l.GetAt(cur));
@@ -81,15 +81,15 @@ namespace ssf {
StringMapW<bool> names;
POSITION pos = subs.GetHeadPosition();
- while(pos) {
+ while (pos) {
names[subs.GetNext(pos)->m_name] = true;
}
pos = m_sra.GetStartPosition();
- while(pos) {
+ while (pos) {
POSITION cur = pos;
const CStringW& name = m_sra.GetNextKey(pos);
- if(!names.Lookup(name)) {
+ if (!names.Lookup(name)) {
m_sra.RemoveAtPos(cur);
}
}
@@ -99,20 +99,20 @@ namespace ssf {
m_sra.UpdateTarget(vs, vr);
- if(s->m_text.IsEmpty()) {
+ if (s->m_text.IsEmpty()) {
return NULL;
}
CRect spdrc = s->m_frame.reference == _T("video") ? vr : CRect(CPoint(0, 0), vs);
- if(spdrc.IsRectEmpty()) {
+ if (spdrc.IsRectEmpty()) {
return NULL;
}
RenderedSubtitle* rs = NULL;
- if(m_rsc.Lookup(s->m_name, rs)) {
- if(!s->m_animated && rs->m_spdrc == spdrc) {
+ if (m_rsc.Lookup(s->m_name, rs)) {
+ if (!s->m_animated && rs->m_spdrc == spdrc) {
return rs;
}
@@ -135,22 +135,22 @@ namespace ssf CRect clip;
- if(style.placement.clip.l == -1) {
+ if (style.placement.clip.l == -1) {
clip.left = 0;
} else {
clip.left = (int)(spdrc.left + style.placement.clip.l * scale.cx);
}
- if(style.placement.clip.t == -1) {
+ if (style.placement.clip.t == -1) {
clip.top = 0;
} else {
clip.top = (int)(spdrc.top + style.placement.clip.t * scale.cy);
}
- if(style.placement.clip.r == -1) {
+ if (style.placement.clip.r == -1) {
clip.right = vs.cx;
} else {
clip.right = (int)(spdrc.left + style.placement.clip.r * scale.cx);
}
- if(style.placement.clip.b == -1) {
+ if (style.placement.clip.b == -1) {
clip.bottom = vs.cy;
} else {
clip.bottom = (int)(spdrc.top + style.placement.clip.b * scale.cy);
@@ -173,7 +173,7 @@ namespace ssf CAutoPtrList<Glyph> glyphs;
POSITION pos = s->m_text.GetHeadPosition();
- while(pos) {
+ while (pos) {
const Text& t = s->m_text.GetNext(pos);
LOGFONT lf;
@@ -192,11 +192,11 @@ namespace ssf FontWrapper* font = m_fc.Create(m_hDC, lf);
- if(!font) {
+ if (!font) {
_tcscpy_s(lf.lfFaceName, _T("Arial"));
font = m_fc.Create(m_hDC, lf);
- if(!font) {
+ if (!font) {
ASSERT(0);
continue;
}
@@ -206,7 +206,7 @@ namespace ssf const TEXTMETRIC& tm = font->GetTextMetric();
- for(LPCWSTR c = t.str; *c; c++) {
+ for (LPCWSTR c = t.str; *c; c++) {
CAutoPtr<Glyph> g(DNew Glyph());
g->c = *c;
@@ -223,14 +223,14 @@ namespace ssf GetTextExtentPoint32W(m_hDC, &g->c, 1, &extent);
ASSERT(extent.cx >= 0 && extent.cy >= 0);
- if(vertical) {
+ if (vertical) {
g->spacing = (int)(t.style.font.spacing * scale.cy + 0.5);
g->ascent = extent.cx / 2;
g->descent = extent.cx - g->ascent;
g->width = extent.cy;
// TESTME
- if(g->c == Text::SP) {
+ if (g->c == Text::SP) {
g->width /= 2;
}
} else {
@@ -240,14 +240,14 @@ namespace ssf g->width = extent.cx;
}
- if(g->c == Text::LSEP) {
+ if (g->c == Text::LSEP) {
g->spacing = 0;
g->width = 0;
g->ascent /= 2;
g->descent /= 2;
} else {
GlyphPath* path = m_gpc.Create(m_hDC, font, g->c);
- if(!path) {
+ if (!path) {
ASSERT(0);
continue;
}
@@ -266,37 +266,37 @@ namespace ssf CAutoPtr<Row> row;
pos = glyphs.GetHeadPosition();
- while(pos) {
+ while (pos) {
CAutoPtr<Glyph> g = glyphs.GetNext(pos);
- if(!row) {
+ if (!row) {
row.Attach(DNew Row());
}
WCHAR c = g->c;
row->AddTail(g);
- if(c == Text::LSEP || !pos) {
+ if (c == Text::LSEP || !pos) {
rows.AddTail(row);
}
}
// kerning
- if(s->m_direction.primary == _T("right")) { // || s->m_direction.primary == _T("left")
- for(POSITION rpos = rows.GetHeadPosition(); rpos; rows.GetNext(rpos)) {
+ if (s->m_direction.primary == _T("right")) { // || s->m_direction.primary == _T("left")
+ for (POSITION rpos = rows.GetHeadPosition(); rpos; rows.GetNext(rpos)) {
Row* r = rows.GetAt(rpos);
POSITION gpos = r->GetHeadPosition();
- while(gpos) {
+ while (gpos) {
Glyph* g1 = r->GetNext(gpos);
- if(!gpos) {
+ if (!gpos) {
break;
}
Glyph* g2 = r->GetAt(gpos);
- if(g1->font != g2->font || !g1->style.font.kerning || !g2->style.font.kerning) {
+ if (g1->font != g2->font || !g1->style.font.kerning || !g2->style.font.kerning) {
continue;
}
- if(int size = g1->font->GetKernAmount(g1->c, g2->c)) {
+ if (int size = g1->font->GetKernAmount(g1->c, g2->c)) {
g2->path.MovePoints(CPoint(size, 0));
g2->width += size;
}
@@ -306,19 +306,19 @@ namespace ssf // wrap rows
- if(s->m_wrap == _T("normal") || s->m_wrap == _T("even")) {
+ if (s->m_wrap == _T("normal") || s->m_wrap == _T("even")) {
int maxwidth = abs((int)(vertical ? frame.Height() : frame.Width()));
int minwidth = 0;
- for(POSITION rpos = rows.GetHeadPosition(); rpos; rows.GetNext(rpos)) {
+ for (POSITION rpos = rows.GetHeadPosition(); rpos; rows.GetNext(rpos)) {
Row* r = rows.GetAt(rpos);
POSITION brpos = NULL;
- if(s->m_wrap == _T("even")) {
+ if (s->m_wrap == _T("even")) {
int fullwidth = 0;
- for(POSITION gpos = r->GetHeadPosition(); gpos; r->GetNext(gpos)) {
+ for (POSITION gpos = r->GetHeadPosition(); gpos; r->GetNext(gpos)) {
const Glyph* g = r->GetAt(gpos);
fullwidth += g->width + g->spacing;
@@ -326,7 +326,7 @@ namespace ssf fullwidth = abs(fullwidth);
- if(fullwidth > maxwidth) {
+ if (fullwidth > maxwidth) {
maxwidth = fullwidth / ((fullwidth / maxwidth) + 1);
minwidth = maxwidth;
}
@@ -334,28 +334,28 @@ namespace ssf int width = 0;
- for(POSITION gpos = r->GetHeadPosition(); gpos; r->GetNext(gpos)) {
+ for (POSITION gpos = r->GetHeadPosition(); gpos; r->GetNext(gpos)) {
const Glyph* g = r->GetAt(gpos);
width += g->width + g->spacing;
- if(brpos && abs(width) > maxwidth && g->c != Text::SP) {
+ if (brpos && abs(width) > maxwidth && g->c != Text::SP) {
row.Attach(DNew Row());
POSITION next = brpos;
r->GetNext(next);
do {
row->AddHead(r->GetPrev(brpos));
- } while(brpos);
+ } while (brpos);
rows.InsertBefore(rpos, row);
- while(!r->IsEmpty() && r->GetHeadPosition() != next) {
+ while (!r->IsEmpty() && r->GetHeadPosition() != next) {
r->RemoveHeadNoReturn();
}
g = r->GetAt(gpos = next);
width = g->width + g->spacing;
}
- if(abs(width) >= minwidth) {
- if(g->style.linebreak == _T("char")
+ if (abs(width) >= minwidth) {
+ if (g->style.linebreak == _T("char")
|| g->style.linebreak == _T("word") && g->c == Text::SP) {
brpos = gpos;
}
@@ -366,14 +366,14 @@ namespace ssf // trim rows
- for(POSITION pos = rows.GetHeadPosition(); pos; rows.GetNext(pos)) {
+ for (POSITION pos = rows.GetHeadPosition(); pos; rows.GetNext(pos)) {
Row* r = rows.GetAt(pos);
- while(!r->IsEmpty() && r->GetHead()->c == Text::SP) {
+ while (!r->IsEmpty() && r->GetHead()->c == Text::SP) {
r->RemoveHead();
}
- while(!r->IsEmpty() && r->GetTail()->c == Text::SP) {
+ while (!r->IsEmpty() && r->GetTail()->c == Text::SP) {
r->RemoveTail();
}
}
@@ -384,17 +384,17 @@ namespace ssf int fill_id = 0;
int fill_width = 0;
- for(POSITION pos = rows.GetHeadPosition(); pos; rows.GetNext(pos)) {
+ for (POSITION pos = rows.GetHeadPosition(); pos; rows.GetNext(pos)) {
Row* r = rows.GetAt(pos);
POSITION gpos = r->GetHeadPosition();
- while(gpos) {
+ while (gpos) {
Glyph* g = r->GetNext(gpos);
- if(!glypsh2fill.IsEmpty() && fill_id && (g->style.fill.id != fill_id || !pos && !gpos)) {
+ if (!glypsh2fill.IsEmpty() && fill_id && (g->style.fill.id != fill_id || !pos && !gpos)) {
int w = (int)(g->style.fill.width * fill_width + 0.5);
- while(!glypsh2fill.IsEmpty()) {
+ while (!glypsh2fill.IsEmpty()) {
Glyph* g = glypsh2fill.RemoveTail();
fill_width -= g->width;
g->fill = w - fill_width;
@@ -409,7 +409,7 @@ namespace ssf fill_id = g->style.fill.id;
- if(g->style.fill.id) {
+ if (g->style.fill.id) {
glypsh2fill.AddTail(g);
fill_width += g->width;
}
@@ -420,14 +420,14 @@ namespace ssf CSize size(0, 0);
- if(s->m_direction.secondary == _T("left") || s->m_direction.secondary == _T("up")) {
+ if (s->m_direction.secondary == _T("left") || s->m_direction.secondary == _T("up")) {
ReverseList(rows);
}
- for(POSITION pos = rows.GetHeadPosition(); pos; rows.GetNext(pos)) {
+ for (POSITION pos = rows.GetHeadPosition(); pos; rows.GetNext(pos)) {
Row* r = rows.GetAt(pos);
- if(s->m_direction.primary == _T("left") || s->m_direction.primary == _T("up")) {
+ if (s->m_direction.primary == _T("left") || s->m_direction.primary == _T("up")) {
ReverseList(*r);
}
@@ -435,17 +435,17 @@ namespace ssf r->width = 0;
- for(POSITION gpos = r->GetHeadPosition(); gpos; r->GetNext(gpos)) {
+ for (POSITION gpos = r->GetHeadPosition(); gpos; r->GetNext(gpos)) {
const Glyph* g = r->GetAt(gpos);
w += g->width;
- if(gpos) {
+ if (gpos) {
w += g->spacing;
}
h = max(h, g->ascent + g->descent);
r->width += g->width;
- if(gpos) {
+ if (gpos) {
r->width += g->spacing;
}
r->ascent = max(r->ascent, g->ascent);
@@ -453,13 +453,13 @@ namespace ssf r->border = max(r->border, g->GetBackgroundSize());
}
- for(POSITION gpos = r->GetHeadPosition(); gpos; r->GetNext(gpos)) {
+ for (POSITION gpos = r->GetHeadPosition(); gpos; r->GetNext(gpos)) {
Glyph* g = r->GetAt(gpos);
g->row_ascent = r->ascent;
g->row_descent = r->descent;
}
- if(vertical) {
+ if (vertical) {
size.cx += h;
size.cy = max(size.cy, w);
} else {
@@ -477,7 +477,7 @@ namespace ssf // collision detection
- if(!s->m_animated) {
+ if (!s->m_animated) {
int tlb = !rows.IsEmpty() ? rows.GetHead()->border : 0;
int brb = !rows.IsEmpty() ? rows.GetTail()->border : 0;
@@ -491,16 +491,16 @@ namespace ssf // continue positioning
- for(POSITION pos = rows.GetHeadPosition(); pos; rows.GetNext(pos)) {
+ for (POSITION pos = rows.GetHeadPosition(); pos; rows.GetNext(pos)) {
Row* r = rows.GetAt(pos);
CSize rsize;
rsize.cx = rsize.cy = r->width;
- if(vertical) {
+ if (vertical) {
p.y = GetAlignPoint(style.placement, scale, frame, rsize).y;
- for(POSITION gpos = r->GetHeadPosition(); gpos; r->GetNext(gpos)) {
+ for (POSITION gpos = r->GetHeadPosition(); gpos; r->GetNext(gpos)) {
CAutoPtr<Glyph> g = r->GetAt(gpos);
g->tl.x = p.x + (int)(g->style.placement.offset.x * scale.cx + 0.5) + r->ascent - g->ascent;
g->tl.y = p.y + (int)(g->style.placement.offset.y * scale.cy + 0.5);
@@ -512,7 +512,7 @@ namespace ssf } else {
p.x = GetAlignPoint(style.placement, scale, frame, rsize).x;
- for(POSITION gpos = r->GetHeadPosition(); gpos; r->GetNext(gpos)) {
+ for (POSITION gpos = r->GetHeadPosition(); gpos; r->GetNext(gpos)) {
CAutoPtr<Glyph> g = r->GetAt(gpos);
g->tl.x = p.x + (int)(g->style.placement.offset.x * scale.cx + 0.5);
g->tl.y = p.y + (int)(g->style.placement.offset.y * scale.cy + 0.5) + r->ascent - g->ascent;
@@ -527,7 +527,7 @@ namespace ssf // bkg, precalc style.placement.path, transform
pos = rs->m_glyphs.GetHeadPosition();
- while(pos) {
+ while (pos) {
Glyph* g = rs->m_glyphs.GetNext(pos);
g->CreateBkg();
g->CreateSplineCoeffs(spdrc);
@@ -539,7 +539,7 @@ namespace ssf Glyph* g0 = NULL;
pos = rs->m_glyphs.GetHeadPosition();
- while(pos) {
+ while (pos) {
POSITION cur = pos;
Glyph* g = rs->m_glyphs.GetNext(pos);
@@ -557,9 +557,9 @@ namespace ssf r.right = (r.right + 32) >> 6;
r.bottom = (r.bottom + 32) >> 6;
- if((r & clip).IsRectEmpty()) { // clip
+ if ((r & clip).IsRectEmpty()) { // clip
rs->m_glyphs.RemoveAt(cur);
- } else if(g0 && g0->style.IsSimilar(g->style)) { // append
+ } else if (g0 && g0->style.IsSimilar(g->style)) { // append
CPoint o = g->tl - g0->tl;
g->path.MovePoints(o);
@@ -583,7 +583,7 @@ namespace ssf // rasterize
pos = rs->m_glyphs.GetHeadPosition();
- while(pos) {
+ while (pos) {
rs->m_glyphs.GetNext(pos)->Rasterize();
}
@@ -606,10 +606,10 @@ namespace ssf // shadow
POSITION pos = m_glyphs.GetHeadPosition();
- while(pos) {
+ while (pos) {
Glyph* g = m_glyphs.GetNext(pos);
- if(g->style.shadow.depth <= 0) {
+ if (g->style.shadow.depth <= 0) {
continue;
}
@@ -624,16 +624,16 @@ namespace ssf // background
pos = m_glyphs.GetHeadPosition();
- while(pos) {
+ while (pos) {
Glyph* g = m_glyphs.GetNext(pos);
DWORD c = g->style.background.color;
DWORD sw[6] = {c, (DWORD)-1};
- if(g->style.background.type == L"outline" && g->style.background.size > 0) {
+ if (g->style.background.type == L"outline" && g->style.background.size > 0) {
bbox |= g->ras.Draw(spd, m_clip, g->tl.x, g->tl.y, sw, g->style.font.color.a < 255 ? 2 : 1);
- } else if(g->style.background.type == L"enlarge" && g->style.background.size > 0
- || g->style.background.type == L"box" && g->style.background.size >= 0) {
+ } else if (g->style.background.type == L"enlarge" && g->style.background.size > 0
+ || g->style.background.type == L"box" && g->style.background.size >= 0) {
bbox |= g->ras_bkg.Draw(spd, m_clip, g->tl.x, g->tl.y, sw, 0);
}
}
@@ -641,7 +641,7 @@ namespace ssf // body
pos = m_glyphs.GetHeadPosition();
- while(pos) {
+ while (pos) {
Glyph* g = m_glyphs.GetNext(pos);
DWORD c = g->style.font.color;
@@ -657,7 +657,7 @@ namespace ssf void SubRectAllocator::UpdateTarget(const CSize& s, const CRect& r)
{
- if(vs != s || vr != r) {
+ if (vs != s || vr != r) {
RemoveAll();
}
vs = s;
@@ -671,26 +671,26 @@ namespace ssf StringMapW<SubRect>::CPair* pPair = Lookup(s->m_name);
- if(pPair && pPair->m_value.rect != sr.rect) {
+ if (pPair && pPair->m_value.rect != sr.rect) {
RemoveKey(s->m_name);
pPair = NULL;
}
- if(!pPair) {
+ if (!pPair) {
bool vertical = s->m_direction.primary == _T("down") || s->m_direction.primary == _T("up");
bool fOK = false;
- while(!fOK) {
+ while (!fOK) {
fOK = true;
POSITION pos = GetStartPosition();
- while(pos) {
+ while (pos) {
const SubRect& sr2 = GetNextValue(pos);
- if(sr.layer == sr2.layer && !(sr.rect & sr2.rect).IsRectEmpty()) {
- if(vertical) {
- if(align.h < 0.5) {
+ if (sr.layer == sr2.layer && !(sr.rect & sr2.rect).IsRectEmpty()) {
+ if (vertical) {
+ if (align.h < 0.5) {
sr.rect.right = sr2.rect.right + sr.rect.Width();
sr.rect.left = sr2.rect.right;
} else {
@@ -698,7 +698,7 @@ namespace ssf sr.rect.right = sr2.rect.left;
}
} else {
- if(align.v < 0.5) {
+ if (align.v < 0.5) {
sr.rect.bottom = sr2.rect.bottom + sr.rect.Height();
sr.rect.top = sr2.rect.bottom;
} else {
@@ -731,13 +731,13 @@ namespace ssf FontWrapper* pFW = NULL;
- if(m_key2obj.Lookup(key, pFW)) {
+ if (m_key2obj.Lookup(key, pFW)) {
return pFW;
}
HFONT hFont = CreateFontIndirect(&lf);
- if(!hFont) {
+ if (!hFont) {
ASSERT(0);
return NULL;
}
@@ -757,14 +757,14 @@ namespace ssf GlyphPath* path = NULL;
- if(m_key2obj.Lookup(key, path)) {
+ if (m_key2obj.Lookup(key, path)) {
return path;
}
BeginPath(hDC);
TextOutW(hDC, 0, 0, &c, 1);
CloseFigure(hDC);
- if(!EndPath(hDC)) {
+ if (!EndPath(hDC)) {
AbortPath(hDC);
ASSERT(0);
return NULL;
@@ -774,11 +774,11 @@ namespace ssf int count = GetPath(hDC, NULL, NULL, 0);
- if(count > 0) {
+ if (count > 0) {
path->points.SetCount(count);
path->types.SetCount(count);
- if(count != GetPath(hDC, path->points.GetData(), path->types.GetData(), count)) {
+ if (count != GetPath(hDC, path->points.GetData(), path->types.GetData(), count)) {
ASSERT(0);
delete path;
return NULL;
diff --git a/src/Subtitles/libssf/Renderer.h b/src/Subtitles/libssf/Renderer.h index bf2bd1826..8a2d8e773 100644 --- a/src/Subtitles/libssf/Renderer.h +++ b/src/Subtitles/libssf/Renderer.h @@ -44,7 +44,7 @@ namespace ssf void RemoveAll() {
POSITION pos = m_key2obj.GetStartPosition();
- while(pos) {
+ while (pos) {
delete m_key2obj.GetNextValue(pos);
}
m_key2obj.RemoveAll();
@@ -52,7 +52,7 @@ namespace ssf }
void Add(const CStringW& key, T& obj, bool fFlush = true) {
- if(StringMapW<T>::CPair* p = m_key2obj.Lookup(key)) {
+ if (StringMapW<T>::CPair* p = m_key2obj.Lookup(key)) {
delete p->m_value;
} else {
m_objs.AddTail(key);
@@ -60,13 +60,13 @@ namespace ssf m_key2obj[key] = obj;
- if(fFlush) {
+ if (fFlush) {
Flush();
}
}
void Flush() {
- while(m_objs.GetCount() > m_limit) {
+ while (m_objs.GetCount() > m_limit) {
CStringW key = m_objs.RemoveHead();
ASSERT(m_key2obj.Lookup(key));
delete m_key2obj[key];
@@ -80,7 +80,7 @@ namespace ssf void Invalidate(const CStringW& key) {
T val;
- if(m_key2obj.Lookup(key, val)) {
+ if (m_key2obj.Lookup(key, val)) {
delete val;
m_key2obj[key] = NULL;
}
diff --git a/src/Subtitles/libssf/Split.cpp b/src/Subtitles/libssf/Split.cpp index 6c620703c..aef0bdb59 100644 --- a/src/Subtitles/libssf/Split.cpp +++ b/src/Subtitles/libssf/Split.cpp @@ -39,22 +39,22 @@ namespace ssf {
RemoveAll();
- if(size_t seplen = wcslen(sep)) {
- for(int i = 0, j = 0, len = str.GetLength();
+ if (size_t seplen = wcslen(sep)) {
+ for (int i = 0, j = 0, len = str.GetLength();
i <= len && (limit == 0 || GetCount() < limit);
i = j + (int)seplen) {
j = str.Find(sep, i);
- if(j < 0) {
+ if (j < 0) {
j = len;
}
CStringW s = i < j ? str.Mid(i, j - i) : L"";
- switch(type) {
+ switch (type) {
case Min:
s.Trim(); // fall through
case Def:
- if(s.IsEmpty()) {
+ if (s.IsEmpty()) {
break; // else fall through
}
case Max:
@@ -67,7 +67,7 @@ namespace ssf int Split::GetAtInt(size_t i)
{
- if(i >= GetCount()) {
+ if (i >= GetCount()) {
throw Exception(_T("Index out of bounds"));
}
return _wtoi(GetAt(i));
@@ -75,7 +75,7 @@ namespace ssf float Split::GetAtFloat(size_t i)
{
- if(i >= GetCount()) {
+ if (i >= GetCount()) {
throw Exception(_T("Index out of bounds"));
}
return (float)_wtof(GetAt(i));
diff --git a/src/Subtitles/libssf/Stream.cpp b/src/Subtitles/libssf/Stream.cpp index fd4c3e400..e246f476d 100644 --- a/src/Subtitles/libssf/Stream.cpp +++ b/src/Subtitles/libssf/Stream.cpp @@ -43,7 +43,7 @@ namespace ssf va_start(args, fmt);
int len = _vsctprintf(fmt, args) + 1;
CString str;
- if(len > 0) {
+ if (len > 0) {
_vstprintf_s(str.GetBufferSetLength(len), len, fmt, args);
}
va_end(args);
@@ -69,29 +69,29 @@ namespace ssf int InputStream::NextChar()
{
- if(m_encoding == none) {
+ if (m_encoding == none) {
m_encoding = unknown;
- switch(NextByte()) {
+ switch (NextByte()) {
case 0xef:
- if(NextByte() == 0xbb && NextByte() == 0xbf) {
+ if (NextByte() == 0xbb && NextByte() == 0xbf) {
m_encoding = utf8;
}
break;
case 0xff:
- if(NextByte() == 0xfe) {
+ if (NextByte() == 0xfe) {
m_encoding = utf16le;
}
break;
case 0xfe:
- if(NextByte() == 0xff) {
+ if (NextByte() == 0xff) {
m_encoding = utf16be;
}
break;
}
}
- if(m_encoding == unknown) {
+ if (m_encoding == unknown) {
throw Exception(_T("unknown character encoding, missing BOM"));
}
@@ -99,15 +99,15 @@ namespace ssf int cur = NextByte();
- switch(m_encoding) {
+ switch (m_encoding) {
case utf8:
- for(i = 7; i >= 0 && (cur & (1 << i)); i--) {
+ for (i = 7; i >= 0 && (cur & (1 << i)); i--) {
;
}
cur &= (1 << i) - 1;
- while(++i < 7) {
+ while (++i < 7) {
c = NextByte();
- if(c == EOS) {
+ if (c == EOS) {
cur = EOS;
break;
}
@@ -116,7 +116,7 @@ namespace ssf break;
case utf16le:
c = NextByte();
- if(c == EOS) {
+ if (c == EOS) {
cur = EOS;
break;
}
@@ -124,7 +124,7 @@ namespace ssf break;
case utf16be:
c = NextByte();
- if(c == EOS) {
+ if (c == EOS) {
cur = EOS;
break;
}
@@ -146,14 +146,14 @@ namespace ssf int InputStream::PopChar()
{
- if(m_queue.IsEmpty()) {
+ if (m_queue.IsEmpty()) {
ThrowError(_T("fatal stream error"));
}
int c = m_queue.RemoveHead();
- if(c != EOS) {
- if(c == '\n') {
+ if (c != EOS) {
+ if (c == '\n') {
m_line++;
m_col = -1;
}
@@ -165,24 +165,24 @@ namespace ssf int InputStream::PeekChar()
{
- while(m_queue.GetCount() < 2) {
+ while (m_queue.GetCount() < 2) {
PushChar();
}
ASSERT(m_queue.GetCount() == 2);
- if(m_queue.GetHead() == '/' && m_queue.GetTail() == '/') {
- while(!m_queue.IsEmpty()) {
+ if (m_queue.GetHead() == '/' && m_queue.GetTail() == '/') {
+ while (!m_queue.IsEmpty()) {
PopChar();
}
int c;
do {
PushChar();
c = PopChar();
- } while(!(c == '\n' || c == EOS));
+ } while (!(c == '\n' || c == EOS));
return PeekChar();
- } else if(m_queue.GetHead() == '/' && m_queue.GetTail() == '*') {
- while(!m_queue.IsEmpty()) {
+ } else if (m_queue.GetHead() == '/' && m_queue.GetTail() == '*') {
+ while (!m_queue.IsEmpty()) {
PopChar();
}
int c1, c2;
@@ -190,7 +190,7 @@ namespace ssf do {
c2 = PushChar();
c1 = PopChar();
- } while(!((c1 == '*' && c2 == '/') || c1 == EOS));
+ } while (!((c1 == '*' && c2 == '/') || c1 == EOS));
PopChar();
return PeekChar();
}
@@ -200,7 +200,7 @@ namespace ssf int InputStream::GetChar()
{
- if(m_queue.GetCount() < 2) {
+ if (m_queue.GetCount() < 2) {
PeekChar();
}
return PopChar();
@@ -209,7 +209,7 @@ namespace ssf int InputStream::SkipWhiteSpace(LPCWSTR morechars)
{
int c = PeekChar();
- for(; IsWhiteSpace(c, morechars); c = PeekChar()) {
+ for (; IsWhiteSpace(c, morechars); c = PeekChar()) {
GetChar();
}
return c;
@@ -220,14 +220,14 @@ namespace ssf FileInputStream::FileInputStream(const TCHAR* fn)
: m_file(NULL)
{
- if(_tfopen_s(&m_file, fn, _T("r")) != 0) {
+ if (_tfopen_s(&m_file, fn, _T("r")) != 0) {
ThrowError(_T("cannot open file '%s'"), fn);
}
}
FileInputStream::~FileInputStream()
{
- if(m_file) {
+ if (m_file) {
fclose(m_file);
m_file = NULL;
}
@@ -235,7 +235,7 @@ namespace ssf int FileInputStream::NextByte()
{
- if(!m_file) {
+ if (!m_file) {
ThrowError(_T("file pointer is NULL"));
}
return fgetc(m_file);
@@ -248,9 +248,9 @@ namespace ssf , m_pos(0)
, m_len(len)
{
- if(fCopy) {
+ if (fCopy) {
m_pBytes = DNew BYTE[len];
- if(m_pBytes) {
+ if (m_pBytes) {
memcpy(m_pBytes, pBytes, len);
}
m_fFree = true;
@@ -259,14 +259,14 @@ namespace ssf m_fFree = fFree;
}
- if(!m_pBytes) {
+ if (!m_pBytes) {
ThrowError(_T("memory stream pointer is NULL"));
}
}
MemoryInputStream::~MemoryInputStream()
{
- if(m_fFree) {
+ if (m_fFree) {
delete [] m_pBytes;
}
m_pBytes = NULL;
@@ -274,10 +274,10 @@ namespace ssf int MemoryInputStream::NextByte()
{
- if(!m_pBytes) {
+ if (!m_pBytes) {
ThrowError(_T("memory stream pointer is NULL"));
}
- if(m_pos >= m_len) {
+ if (m_pos >= m_len) {
return Stream::EOS;
}
return (int)m_pBytes[m_pos++];
@@ -294,7 +294,7 @@ namespace ssf int WCharInputStream::NextByte()
{
- if(m_pos >= m_str.GetLength()) {
+ if (m_pos >= m_str.GetLength()) {
return Stream::EOS;
}
return m_str[m_pos++];
@@ -314,10 +314,10 @@ namespace ssf void OutputStream::PutChar(WCHAR c)
{
- if(m_bof) {
+ if (m_bof) {
m_bof = false;
- switch(m_encoding) {
+ switch (m_encoding) {
case utf8:
case utf16le:
case utf16be:
@@ -326,14 +326,14 @@ namespace ssf }
}
- switch(m_encoding) {
+ switch (m_encoding) {
case utf8:
- if(0 <= c && c < 0x80) { // 0xxxxxxx
+ if (0 <= c && c < 0x80) { // 0xxxxxxx
NextByte(c);
- } else if(0x80 <= c && c < 0x800) { // 110xxxxx 10xxxxxx
+ } else if (0x80 <= c && c < 0x800) { // 110xxxxx 10xxxxxx
NextByte(0xc0 | ((c<<2)&0x1f));
NextByte(0x80 | ((c<<0)&0x3f));
- } else if(0x800 <= c && c < 0xFFFF) { // 1110xxxx 10xxxxxx 10xxxxxx
+ } else if (0x800 <= c && c < 0xFFFF) { // 1110xxxx 10xxxxxx 10xxxxxx
NextByte(0xe0 | ((c<<4)&0x0f));
NextByte(0x80 | ((c<<2)&0x3f));
NextByte(0x80 | ((c<<0)&0x3f));
@@ -362,13 +362,13 @@ namespace ssf va_list args;
va_start(args, fmt);
int len = _vscwprintf(fmt, args) + 1;
- if(len > 0) {
+ if (len > 0) {
vswprintf_s(str.GetBufferSetLength(len), len, fmt, args);
}
va_end(args);
LPCWSTR s = str;
- while(*s) {
+ while (*s) {
PutChar(*s++);
}
}
@@ -399,10 +399,10 @@ namespace ssf void DebugOutputStream::NextByte(int b)
{
- if(b == '\n') {
+ if (b == '\n') {
TRACE(_T("%s\n"), m_str);
m_str.Empty();
- } else if(b != '\r') {
+ } else if (b != '\r') {
m_str += (WCHAR)b;
}
}
diff --git a/src/Subtitles/libssf/StringMap.h b/src/Subtitles/libssf/StringMap.h index 30f528b4d..1b88ad649 100644 --- a/src/Subtitles/libssf/StringMap.h +++ b/src/Subtitles/libssf/StringMap.h @@ -34,7 +34,7 @@ namespace ssf StringMap& operator = (const StringMap& s2t) {
RemoveAll();
POSITION pos = s2t.GetStartPosition();
- while(pos) {
+ while (pos) {
const StringMap::CPair* p = s2t.GetNext(pos);
SetAt(p->m_key, p->m_value);
}
diff --git a/src/Subtitles/libssf/Subtitle.cpp b/src/Subtitles/libssf/Subtitle.cpp index 288d6b0a9..3153642db 100644 --- a/src/Subtitles/libssf/Subtitle.cpp +++ b/src/Subtitles/libssf/Subtitle.cpp @@ -32,27 +32,27 @@ namespace ssf : m_pFile(pFile)
, m_animated(false)
{
- if(m_n2n.align[0].IsEmpty()) {
+ if (m_n2n.align[0].IsEmpty()) {
m_n2n.align[0][L"left"] = 0;
m_n2n.align[0][L"center"] = 0.5;
m_n2n.align[0][L"middle"] = 0.5;
m_n2n.align[0][L"right"] = 1;
}
- if(m_n2n.align[1].IsEmpty()) {
+ if (m_n2n.align[1].IsEmpty()) {
m_n2n.align[1][L"top"] = 0;
m_n2n.align[1][L"middle"] = 0.5;
m_n2n.align[1][L"center"] = 0.5;
m_n2n.align[1][L"bottom"] = 1;
}
- if(m_n2n.weight.IsEmpty()) {
+ if (m_n2n.weight.IsEmpty()) {
m_n2n.weight[L"thin"] = FW_THIN;
m_n2n.weight[L"normal"] = FW_NORMAL;
m_n2n.weight[L"bold"] = FW_BOLD;
}
- if(m_n2n.transition.IsEmpty()) {
+ if (m_n2n.transition.IsEmpty()) {
m_n2n.transition[L"start"] = 0;
m_n2n.transition[L"stop"] = 1e10;
m_n2n.transition[L"linear"] = 1;
@@ -105,20 +105,20 @@ namespace ssf // TODO: trimming should be done by the renderer later, after breaking the words into lines
- while(!m_text.IsEmpty() && (m_text.GetHead().str == Text::SP || m_text.GetHead().str == Text::LSEP)) {
+ while (!m_text.IsEmpty() && (m_text.GetHead().str == Text::SP || m_text.GetHead().str == Text::LSEP)) {
m_text.RemoveHead();
}
- while(!m_text.IsEmpty() && (m_text.GetTail().str == Text::SP || m_text.GetTail().str == Text::LSEP)) {
+ while (!m_text.IsEmpty() && (m_text.GetTail().str == Text::SP || m_text.GetTail().str == Text::LSEP)) {
m_text.RemoveTail();
}
- for(POSITION pos = m_text.GetHeadPosition(); pos; m_text.GetNext(pos)) {
- if(m_text.GetAt(pos).str == Text::LSEP) {
+ for (POSITION pos = m_text.GetHeadPosition(); pos; m_text.GetNext(pos)) {
+ if (m_text.GetAt(pos).str == Text::LSEP) {
POSITION prev = pos;
m_text.GetPrev(prev);
- while(prev && m_text.GetAt(prev).str == Text::SP) {
+ while (prev && m_text.GetAt(prev).str == Text::SP) {
POSITION tmp = prev;
m_text.GetPrev(prev);
m_text.RemoveAt(tmp);
@@ -127,14 +127,14 @@ namespace ssf POSITION next = pos;
m_text.GetNext(next);
- while(next && m_text.GetAt(next).str == Text::SP) {
+ while (next && m_text.GetAt(next).str == Text::SP) {
POSITION tmp = next;
m_text.GetNext(next);
m_text.RemoveAt(tmp);
}
}
}
- } catch(Exception& e) {
+ } catch (Exception& e) {
UNREFERENCED_PARAMETER(e);
TRACE(_T("%s"), e.ToString());
return false;
@@ -172,24 +172,24 @@ namespace ssf Definition& clip = placement[L"clip"];
- if(clip.IsValue(Definition::string)) {
+ if (clip.IsValue(Definition::string)) {
CStringW str = clip;
- if(str == L"frame") {
+ if (str == L"frame") {
style.placement.clip = frame;
}
// else ?
} else {
- if(clip[L"t"].IsValue()) {
+ if (clip[L"t"].IsValue()) {
style.placement.clip.t = clip[L"t"];
}
- if(clip[L"r"].IsValue()) {
+ if (clip[L"r"].IsValue()) {
style.placement.clip.r = clip[L"r"];
}
- if(clip[L"b"].IsValue()) {
+ if (clip[L"b"].IsValue()) {
style.placement.clip.b = clip[L"b"];
}
- if(clip[L"l"].IsValue()) {
+ if (clip[L"l"].IsValue()) {
style.placement.clip.l = clip[L"l"];
}
}
@@ -213,11 +213,11 @@ namespace ssf placement[L"align"][L"h"].GetAsNumber(style.placement.align.h, &m_n2n.align[0]);
placement[L"align"][L"v"].GetAsNumber(style.placement.align.v, &m_n2n.align[1]);
- if(placement[L"pos"][L"x"].IsValue()) {
+ if (placement[L"pos"][L"x"].IsValue()) {
style.placement.pos.x = placement[L"pos"][L"x"];
style.placement.pos.auto_x = false;
}
- if(placement[L"pos"][L"y"].IsValue()) {
+ if (placement[L"pos"][L"y"].IsValue()) {
style.placement.pos.y = placement[L"pos"][L"y"];
style.placement.pos.auto_y = false;
}
@@ -229,11 +229,11 @@ namespace ssf style.placement.angle.y = placement[L"angle"][L"y"];
style.placement.angle.z = placement[L"angle"][L"z"];
- if(placement[L"org"][L"x"].IsValue()) {
+ if (placement[L"org"][L"x"].IsValue()) {
style.placement.org.x = placement[L"org"][L"x"];
style.placement.org.auto_x = false;
}
- if(placement[L"org"][L"y"].IsValue()) {
+ if (placement[L"org"][L"y"].IsValue()) {
style.placement.org.y = placement[L"org"][L"y"];
style.placement.org.auto_y = false;
}
@@ -297,30 +297,30 @@ namespace ssf n2n[L"stop"] = m_time.stop - m_time.start;
Definition::Time time;
- if(pDef->GetAsTime(time, offset, &n2n, default_id) && time.start.value < time.stop.value) {
+ if (pDef->GetAsTime(time, offset, &n2n, default_id) && time.start.value < time.stop.value) {
t = (at - time.start.value) / (time.stop.value - time.start.value);
float u = t;
- if(t < 0) {
+ if (t < 0) {
t = 0;
- } else if(t >= 1) {
+ } else if (t >= 1) {
t = 0.99999f; // doh
}
- if((*pDef)[L"loop"].IsValue()) {
+ if ((*pDef)[L"loop"].IsValue()) {
t *= (float)(*pDef)[L"loop"];
}
CStringW direction = (*pDef)[L"direction"].IsValue() ? (*pDef)[L"direction"] : L"fw";
- if(direction == L"fwbw" || direction == L"bwfw") {
+ if (direction == L"fwbw" || direction == L"bwfw") {
t *= 2;
}
float n;
t = modf(t, &n);
- if(direction == L"bw"
+ if (direction == L"bw"
|| direction == L"fwbw" && ((int)n & 1)
|| direction == L"bwfw" && !((int)n & 1)) {
t = 1 - t;
@@ -328,26 +328,26 @@ namespace ssf float accel = 1;
- if((*pDef)[L"transition"].IsValue()) {
+ if ((*pDef)[L"transition"].IsValue()) {
Definition::Number<float> n;
(*pDef)[L"transition"].GetAsNumber(n, &m_n2n.transition);
- if(n.value >= 0) {
+ if (n.value >= 0) {
accel = n.value;
}
}
- if(t == 0.99999f) {
+ if (t == 0.99999f) {
t = 1;
}
- if(u >= 0 && u < 1) {
+ if (u >= 0 && u < 1) {
t = accel == 0 ? 1 :
accel == 1 ? t :
accel >= 1e10 ? 0 :
pow(t, accel);
}
}
- } catch(Exception&) {
+ } catch (Exception&) {
}
return t;
@@ -370,13 +370,13 @@ namespace ssf template<class T>
bool Subtitle::MixValue(Definition& def, T& value, float t, StringMapW<T>* n2n)
{
- if(!def.IsValue()) {
+ if (!def.IsValue()) {
return false;
}
- if(t >= 0.5) {
- if(n2n && def.IsValue(Definition::string)) {
- if(StringMapW<T>::CPair* p = n2n->Lookup(def)) {
+ if (t >= 0.5) {
+ if (n2n && def.IsValue(Definition::string)) {
+ if (StringMapW<T>::CPair* p = n2n->Lookup(def)) {
value = p->m_value;
return true;
}
@@ -391,13 +391,13 @@ namespace ssf template<>
bool Subtitle::MixValue(Definition& def, float& value, float t, StringMapW<float>* n2n)
{
- if(!def.IsValue()) {
+ if (!def.IsValue()) {
return false;
}
- if(t > 0) {
- if(n2n && def.IsValue(Definition::string)) {
- if(StringMap<float, CStringW>::CPair* p = n2n->Lookup(def)) {
+ if (t > 0) {
+ if (n2n && def.IsValue(Definition::string)) {
+ if (StringMap<float, CStringW>::CPair* p = n2n->Lookup(def)) {
value += (p->m_value - value) * t;
return true;
}
@@ -412,17 +412,17 @@ namespace ssf template<>
bool Subtitle::MixValue(Definition& def, Path& src, float t)
{
- if(!def.IsValue(Definition::string)) {
+ if (!def.IsValue(Definition::string)) {
return false;
}
- if(t >= 1) {
+ if (t >= 1) {
src = (LPCWSTR)def;
- } else if(t > 0) {
+ } else if (t > 0) {
Path dst = (LPCWSTR)def;
- if(src.GetCount() == dst.GetCount()) {
- for(size_t i = 0, j = src.GetCount(); i < j; i++) {
+ if (src.GetCount() == dst.GetCount()) {
+ for (size_t i = 0, j = src.GetCount(); i < j; i++) {
Point& s = src[i];
const Point& d = dst[i];
s.x += (d.x - s.x) * t;
@@ -438,9 +438,9 @@ namespace ssf {
const Style src = dst;
- if(t <= 0) {
+ if (t <= 0) {
return;
- } else if(t > 1) {
+ } else if (t > 1) {
t = 1;
}
@@ -510,8 +510,8 @@ namespace ssf MixValue(fill[L"color"][L"b"], dst.fill.color.b, t);
MixValue(fill[L"width"], dst.fill.width, t);
- if(fill.m_priority >= PNormal) { // this assumes there is no way to set low priority inline overrides
- if(dst.fill.id > 0) {
+ if (fill.m_priority >= PNormal) { // this assumes there is no way to set low priority inline overrides
+ if (dst.fill.id > 0) {
throw Exception(_T("cannot apply fill more than once on the same text"));
}
dst.fill.id = ++Fill::gen_id;
@@ -523,10 +523,10 @@ namespace ssf Text text;
text.style = style;
- for(int c = s.PeekChar(); c != Stream::EOS; c = s.PeekChar()) {
+ for (int c = s.PeekChar(); c != Stream::EOS; c = s.PeekChar()) {
s.GetChar();
- if(c == '[') {
+ if (c == '[') {
AddText(text);
style = text.style;
@@ -542,55 +542,55 @@ namespace ssf ASSERT(pDef->IsType(L"style") || pDef->IsTypeUnknown());
- if((*pDef)[L"time"][L"start"].IsValue() && (*pDef)[L"time"][L"stop"].IsValue()) {
+ if ((*pDef)[L"time"][L"start"].IsValue() && (*pDef)[L"time"][L"stop"].IsValue()) {
m_animated = true;
}
float t = GetMixWeight(pDef, at, offset, ++default_id);
MixStyle(pDef, style, t);
- if((*pDef)[L"@"].IsValue()) {
+ if ((*pDef)[L"@"].IsValue()) {
Parse(WCharInputStream((LPCWSTR)(*pDef)[L"@"]), style, at, offset, pParentRef);
}
s.SkipWhiteSpace();
c = s.GetChar();
- } while(c == ',' || c == ';');
+ } while (c == ',' || c == ';');
- if(c != ']') {
+ if (c != ']') {
s.ThrowError(_T("unterminated override"));
}
bool fWhiteSpaceNext = s.IsWhiteSpace(s.PeekChar());
c = s.SkipWhiteSpace();
- if(c == '{') {
+ if (c == '{') {
s.GetChar();
Parse(s, style, at, inneroffset, pParentRef);
} else {
- if(fWhiteSpaceNext) {
+ if (fWhiteSpaceNext) {
text.str += (WCHAR)Text::SP;
}
text.style = style;
}
- } else if(c == ']') {
+ } else if (c == ']') {
s.ThrowError(_T("unexpected ] found"));
- } else if(c == '{') {
+ } else if (c == '{') {
AddText(text);
Parse(s, text.style, at, offset, pParentRef);
- } else if(c == '}') {
+ } else if (c == '}') {
break;
} else {
- if(c == '\\') {
+ if (c == '\\') {
c = s.GetChar();
- if(c == Stream::EOS) {
+ if (c == Stream::EOS) {
break;
- } else if(c == 'n') {
+ } else if (c == 'n') {
AddText(text);
text.str = (WCHAR)Text::LSEP;
AddText(text);
continue;
- } else if(c == 'h') {
+ } else if (c == 'h') {
c = Text::NBSP;
}
}
@@ -606,31 +606,31 @@ namespace ssf {
bool f1 = !t.str.IsEmpty() && Stream::IsWhiteSpace(t.str[t.str.GetLength()-1]);
bool f2 = Stream::IsWhiteSpace(c);
- if(f2) {
+ if (f2) {
c = Text::SP;
}
- if(!f1 || !f2) {
+ if (!f1 || !f2) {
t.str += (WCHAR)c;
}
}
void Subtitle::AddText(Text& t)
{
- if(t.str.IsEmpty()) {
+ if (t.str.IsEmpty()) {
return;
}
Split sa(' ', t.str, 0, Split::Max);
- for(size_t i = 0, n = sa; i < n; i++) {
+ for (size_t i = 0, n = sa; i < n; i++) {
CStringW str = sa[i];
- if(!str.IsEmpty()) {
+ if (!str.IsEmpty()) {
t.str = str;
m_text.AddTail(t);
}
- if(i < n-1 && (m_text.IsEmpty() || m_text.GetTail().str != Text::SP)) {
+ if (i < n-1 && (m_text.IsEmpty() || m_text.GetTail().str != Text::SP)) {
t.str = (WCHAR)Text::SP;
m_text.AddTail(t);
}
@@ -660,7 +660,7 @@ namespace ssf SetCount(s/2);
- for(size_t i = 0, j = GetCount(); i < j; i++) {
+ for (size_t i = 0, j = GetCount(); i < j; i++) {
Point p;
p.x = s.GetAtFloat(i*2+0);
p.y = s.GetAtFloat(i*2+1);
@@ -674,7 +674,7 @@ namespace ssf {
CStringW ret;
- for(size_t i = 0, j = GetCount(); i < j; i++) {
+ for (size_t i = 0, j = GetCount(); i < j; i++) {
const Point& p = GetAt(i);
CStringW str;
diff --git a/src/Subtitles/libssf/SubtitleFile.cpp b/src/Subtitles/libssf/SubtitleFile.cpp index 35c5e3ed6..c12fc09d4 100644 --- a/src/Subtitles/libssf/SubtitleFile.cpp +++ b/src/Subtitles/libssf/SubtitleFile.cpp @@ -46,16 +46,16 @@ namespace ssf StringMapW<float> offset;
POSITION pos = defs.GetHeadPosition();
- while(pos) {
+ while (pos) {
Definition* pDef = defs.GetNext(pos);
try {
Definition::Time time;
- if(pDef->GetAsTime(time, offset) && (*pDef)[L"@"].IsValue()) {
+ if (pDef->GetAsTime(time, offset) && (*pDef)[L"@"].IsValue()) {
m_segments.Insert(time.start.value, time.stop.value, pDef);
}
- } catch(Exception&) {
+ } catch (Exception&) {
}
}
}
@@ -70,21 +70,21 @@ namespace ssf GetNewDefs(defs);
POSITION pos = defs.GetHeadPosition();
- while(pos) {
+ while (pos) {
Definition* pDef = defs.GetNext(pos);
- if(pDef->m_parent == pRootRef && pDef->m_type == L"subtitle" && (*pDef)[L"@"].IsValue()) {
+ if (pDef->m_parent == pRootRef && pDef->m_type == L"subtitle" && (*pDef)[L"@"].IsValue()) {
m_segments.Insert(start, stop, pDef);
- if(fSetTime) {
+ if (fSetTime) {
try {
Definition::Time time;
StringMapW<float> offset;
pDef->GetAsTime(time, offset);
- if(time.start.value == start && time.stop.value == stop) {
+ if (time.start.value == start && time.stop.value == stop) {
continue;
}
- } catch(Exception&) {
+ } catch (Exception&) {
}
CStringW str;
@@ -101,7 +101,7 @@ namespace ssf bool SubtitleFile::Lookup(float at, CAutoPtrList<Subtitle>& subs)
{
- if(!subs.IsEmpty()) {
+ if (!subs.IsEmpty()) {
ASSERT(0);
return false;
}
@@ -110,20 +110,20 @@ namespace ssf m_segments.Lookup(at, sis);
POSITION pos = sis.GetHeadPosition();
- while(pos) {
+ while (pos) {
SegmentItem& si = sis.GetNext(pos);
CAutoPtr<Subtitle> s(DNew Subtitle(this));
- if(s->Parse(si.pDef, si.start, si.stop, at)) {
- for(POSITION pos = subs.GetHeadPosition(); pos; subs.GetNext(pos)) {
- if(s->m_layer < subs.GetAt(pos)->m_layer) {
+ if (s->Parse(si.pDef, si.start, si.stop, at)) {
+ for (POSITION pos = subs.GetHeadPosition(); pos; subs.GetNext(pos)) {
+ if (s->m_layer < subs.GetAt(pos)->m_layer) {
subs.InsertBefore(pos, s);
break;
}
}
- if(s) {
+ if (s) {
subs.AddTail(s);
}
}
@@ -138,7 +138,7 @@ namespace ssf {
m_start = start;
m_stop = stop;
- if(si) {
+ if (si) {
AddTail(*si);
}
}
@@ -150,7 +150,7 @@ namespace ssf SubtitleFile::Segment& SubtitleFile::Segment::operator = (const Segment& s)
{
- if(this != &s) {
+ if (this != &s) {
m_start = s.m_start;
m_stop = s.m_stop;
RemoveAll();
@@ -169,7 +169,7 @@ namespace ssf void SubtitleFile::SegmentList::Insert(float start, float stop, Definition* pDef)
{
- if(start >= stop) {
+ if (start >= stop) {
ASSERT(0);
return;
}
@@ -178,7 +178,7 @@ namespace ssf SegmentItem si = {pDef, start, stop};
- if(IsEmpty()) {
+ if (IsEmpty()) {
AddTail(Segment(start, stop, &si));
return;
}
@@ -186,46 +186,46 @@ namespace ssf Segment& head = GetHead();
Segment& tail = GetTail();
- if(start >= tail.m_stop && stop > tail.m_stop) {
- if(start > tail.m_stop) {
+ if (start >= tail.m_stop && stop > tail.m_stop) {
+ if (start > tail.m_stop) {
AddTail(Segment(tail.m_stop, start));
}
AddTail(Segment(start, stop, &si));
- } else if(start < head.m_start && stop <= head.m_start) {
- if(stop < head.m_start) {
+ } else if (start < head.m_start && stop <= head.m_start) {
+ if (stop < head.m_start) {
AddHead(Segment(stop, head.m_start));
}
AddHead(Segment(start, stop, &si));
} else {
- if(start < head.m_start) {
+ if (start < head.m_start) {
AddHead(Segment(start, head.m_start, &si));
start = head.m_start;
}
- if(stop > tail.m_stop) {
+ if (stop > tail.m_stop) {
AddTail(Segment(tail.m_stop, stop, &si));
stop = tail.m_stop;
}
- for(POSITION pos = GetHeadPosition(); pos; GetNext(pos)) {
+ for (POSITION pos = GetHeadPosition(); pos; GetNext(pos)) {
Segment& s = GetAt(pos);
- if(start >= s.m_stop) {
+ if (start >= s.m_stop) {
continue;
}
- if(stop <= s.m_start) {
+ if (stop <= s.m_start) {
break;
}
- if(s.m_start < start && start < s.m_stop) {
+ if (s.m_start < start && start < s.m_stop) {
Segment s2 = s;
s2.m_start = start;
InsertAfter(pos, s2);
s.m_stop = start;
- } else if(s.m_start == start) {
- if(stop > s.m_stop) {
+ } else if (s.m_start == start) {
+ if (stop > s.m_stop) {
start = s.m_stop;
- } else if(stop < s.m_stop) {
+ } else if (stop < s.m_stop) {
Segment s2 = s;
s2.m_start = stop;
InsertAfter(pos, s2);
@@ -240,10 +240,10 @@ namespace ssf size_t SubtitleFile::SegmentList::Index(bool fForce)
{
- if(m_index.IsEmpty() || fForce) {
+ if (m_index.IsEmpty() || fForce) {
m_index.RemoveAll();
POSITION pos = GetHeadPosition();
- while(pos) {
+ while (pos) {
m_index.Add(&GetNext(pos));
}
}
@@ -256,36 +256,36 @@ namespace ssf sis.RemoveAll();
size_t k;
- if(Lookup(at, k)) {
+ if (Lookup(at, k)) {
sis.AddTailList(GetSegment(k));
}
}
bool SubtitleFile::SegmentList::Lookup(float at, size_t& k)
{
- if(!Index()) {
+ if (!Index()) {
return false;
}
size_t i = 0, j = m_index.GetCount()-1;
- if(m_index[i]->m_start <= at && at < m_index[j]->m_stop)
+ if (m_index[i]->m_start <= at && at < m_index[j]->m_stop)
do {
k = (i+j)/2;
- if(m_index[k]->m_start <= at && at < m_index[k]->m_stop) {
+ if (m_index[k]->m_start <= at && at < m_index[k]->m_stop) {
return true;
- } else if(at < m_index[k]->m_start) {
- if(j == k) {
+ } else if (at < m_index[k]->m_start) {
+ if (j == k) {
k--;
}
j = k;
- } else if(at >= m_index[k]->m_stop) {
- if(i == k) {
+ } else if (at >= m_index[k]->m_stop) {
+ if (i == k) {
k++;
}
i = k;
}
- } while(i <= j);
+ } while (i <= j);
return false;
}
diff --git a/src/apps/mplayerc/EditWithButton.cpp b/src/apps/mplayerc/EditWithButton.cpp index 54da1e00f..4cef234d9 100644 --- a/src/apps/mplayerc/EditWithButton.cpp +++ b/src/apps/mplayerc/EditWithButton.cpp @@ -35,8 +35,8 @@ CRect CEditWithButton_Base::GetButtonRect(const CRect& rectWindow) const rectButton.right -= m_RightBorder;
rectButton.left = rectButton.right - m_ButtonWidth;
- // take into account any scrollbars in the edit control
- if(rectButton.right > rectButton.left)
+ // take into account any scrollbars in the edit control
+ if (rectButton.right > rectButton.left)
rectButton.OffsetRect(m_RightBorder - m_LeftBorder, 0);
return rectButton;
@@ -44,11 +44,11 @@ CRect CEditWithButton_Base::GetButtonRect(const CRect& rectWindow) const int CEditWithButton_Base::GetButtonThemeState() const
{
- if(GetStyle() & (ES_READONLY | WS_DISABLED))
+ if (GetStyle() & (ES_READONLY | WS_DISABLED))
return PBS_DISABLED;
- else if(m_IsButtonPressed)
+ else if (m_IsButtonPressed)
return PBS_PRESSED;
- else if(m_IsButtonHot)
+ else if (m_IsButtonHot)
return PBS_HOT;
else
return PBS_NORMAL;
@@ -60,12 +60,12 @@ void CEditWithButton_Base::DrawButton(CRect rectButton) #ifdef UNICODE
HTHEME hButtonTheme = OpenThemeData(m_hWnd, _T("Button"));
- if(hButtonTheme)
+ if (hButtonTheme)
{
int ButtonState = GetButtonThemeState();
// If necessary, first fill with the edit control's background color.
- if(IsThemeBackgroundPartiallyTransparent(hButtonTheme, BP_PUSHBUTTON, ButtonState))
+ if (IsThemeBackgroundPartiallyTransparent(hButtonTheme, BP_PUSHBUTTON, ButtonState))
{
HTHEME hEditTheme = OpenThemeDataEx(m_hWnd, _T("Edit"), OTD_NONCLIENT);
@@ -86,14 +86,14 @@ void CEditWithButton_Base::DrawButton(CRect rectButton) #endif //UNICODE
{
UINT uState = DFCS_BUTTONPUSH;
- if(GetStyle() & (ES_READONLY | WS_DISABLED))
+ if (GetStyle() & (ES_READONLY | WS_DISABLED))
uState |= DFCS_INACTIVE;
- else if(m_IsButtonPressed)
+ else if (m_IsButtonPressed)
uState |= DFCS_PUSHED;
dc.DrawFrameControl(rectButton, DFC_BUTTON, uState);
// If the button is in a pressed state, then contents should move slightly as part of the "push" effect.
- if(m_IsButtonPressed)
+ if (m_IsButtonPressed)
rectButton.OffsetRect(1, 1);
DrawButtonContent(dc, rectButton, NULL);
@@ -136,13 +136,13 @@ void CEditWithButton_Base::OnNcPaint() void CEditWithButton_Base::OnNcLButtonDown(UINT nHitTest, CPoint point)
{
- if(!(GetStyle() & (ES_READONLY | WS_DISABLED)))
+ if (!(GetStyle() & (ES_READONLY | WS_DISABLED)))
{
CRect rectWindow;
GetWindowRect(rectWindow);
CRect rectButton = GetButtonRect(rectWindow);
- if(rectButton.PtInRect(point))
+ if (rectButton.PtInRect(point))
{
SetCapture();
@@ -159,7 +159,7 @@ void CEditWithButton_Base::OnNcLButtonDown(UINT nHitTest, CPoint point) void CEditWithButton_Base::OnMouseMove(UINT nFlags, CPoint point)
{
- if(m_IsMouseActive)
+ if (m_IsMouseActive)
{
ClientToScreen(&point);
@@ -172,7 +172,7 @@ void CEditWithButton_Base::OnMouseMove(UINT nFlags, CPoint point) m_IsButtonPressed = rectButton.PtInRect(point) != FALSE;
// If the button state has changed, redraw it to reflect the change
- if(OldState != m_IsButtonPressed)
+ if (OldState != m_IsButtonPressed)
SetWindowPos(NULL, 0, 0, 0, 0, SWP_DRAWFRAME | SWP_NOMOVE | SWP_NOSIZE | SWP_NOACTIVATE | SWP_NOZORDER);
}
@@ -188,12 +188,12 @@ void CEditWithButton_Base::OnNcMouseMove(UINT nHitTest, CPoint point) bool OldState = m_IsButtonHot;
m_IsButtonHot = rectButton.PtInRect(point) != FALSE;
// If the button state has changed, redraw it to reflect the change
- if(OldState != m_IsButtonHot)
+ if (OldState != m_IsButtonHot)
{
SetWindowPos(NULL, 0, 0, 0, 0, SWP_DRAWFRAME | SWP_NOMOVE | SWP_NOSIZE | SWP_NOACTIVATE | SWP_NOZORDER);
// If the state has changed to hot, register to get the WM_NCMOUSELEAVE notification.
- if(m_IsButtonHot)
+ if (m_IsButtonHot)
{
TRACKMOUSEEVENT tme;
tme.cbSize = sizeof(tme);
@@ -216,11 +216,11 @@ void CEditWithButton_Base::OnNcMouseLeave() GetWindowRect(rectWindow);
CRect rectButton = GetButtonRect(rectWindow);
- // We may get this message either when the mouse actually leaves the client area
- // or when the user clicks the mouse on the button. So we must check whether or
- // not the cursor has actually left the button area. If so, then update the hot
+ // We may get this message either when the mouse actually leaves the client area
+ // or when the user clicks the mouse on the button. So we must check whether or
+ // not the cursor has actually left the button area. If so, then update the hot
// state and prompt a redraw of the button.
- if(!rectButton.PtInRect(point))
+ if (!rectButton.PtInRect(point))
{
m_IsButtonHot = false;
SetWindowPos(NULL, 0, 0, 0, 0, SWP_DRAWFRAME | SWP_NOMOVE | SWP_NOSIZE | SWP_NOACTIVATE | SWP_NOZORDER);
@@ -231,7 +231,7 @@ void CEditWithButton_Base::OnNcMouseLeave() void CEditWithButton_Base::OnLButtonUp(UINT nFlags, CPoint point)
{
- if(m_IsMouseActive)
+ if (m_IsMouseActive)
{
ReleaseCapture();
@@ -250,7 +250,7 @@ void CEditWithButton_Base::OnLButtonUp(UINT nFlags, CPoint point) SetWindowPos(NULL, 0, 0, 0, 0, SWP_DRAWFRAME | SWP_NOMOVE | SWP_NOSIZE | SWP_NOACTIVATE | SWP_NOZORDER);
// Run the on-click logic if appropriate.
- if(rectButton.PtInRect(point))
+ if (rectButton.PtInRect(point))
OnLeftClick();
}
@@ -263,7 +263,7 @@ LRESULT CEditWithButton_Base::OnNcHitTest(CPoint point) GetWindowRect(rectWindow);
CRect rectButton = GetButtonRect(rectWindow);
- if(rectButton.PtInRect(point))
+ if (rectButton.PtInRect(point))
return HTBORDER;
return CEdit::OnNcHitTest(point);
@@ -329,7 +329,7 @@ void CEditWithButton::SetButtonText(LPCTSTR buttonText) m_ButtonText = buttonText;
// If this is a live window, then prompt the button area to redraw.
- if(IsWindow(m_hWnd))
+ if (IsWindow(m_hWnd))
SetWindowPos(NULL, 0, 0, 0, 0, SWP_DRAWFRAME | SWP_NOMOVE | SWP_NOSIZE | SWP_NOACTIVATE | SWP_NOZORDER);
}
@@ -338,21 +338,21 @@ void CEditWithButton::DrawButtonContent(CDC& dc, CRect rectButton, HTHEME hButto CFont* pOldFont = dc.SelectObject(GetFont());
#ifdef UNICODE
- if(hButtonTheme)
+ if (hButtonTheme)
{
- DrawThemeText(hButtonTheme, dc.m_hDC, BP_PUSHBUTTON, GetButtonThemeState(),
- m_ButtonText, m_ButtonText.GetLength(),
- DT_CENTER | DT_VCENTER | DT_SINGLELINE, 0, rectButton);
+ DrawThemeText(hButtonTheme, dc.m_hDC, BP_PUSHBUTTON, GetButtonThemeState(),
+ m_ButtonText, m_ButtonText.GetLength(),
+ DT_CENTER | DT_VCENTER | DT_SINGLELINE, 0, rectButton);
}
else
#endif UNICODE
{
- if(GetStyle() & (ES_READONLY | WS_DISABLED))
+ if (GetStyle() & (ES_READONLY | WS_DISABLED))
dc.SetTextColor(GetSysColor(COLOR_GRAYTEXT));
dc.SetBkMode(TRANSPARENT);
- dc.DrawText(m_ButtonText, m_ButtonText.GetLength(),
- rectButton, DT_CENTER | DT_VCENTER | DT_SINGLELINE);
+ dc.DrawText(m_ButtonText, m_ButtonText.GetLength(),
+ rectButton, DT_CENTER | DT_VCENTER | DT_SINGLELINE);
}
dc.SelectObject(pOldFont);
diff --git a/src/apps/mplayerc/EditWithButton.h b/src/apps/mplayerc/EditWithButton.h index ec3c66305..046db6fac 100644 --- a/src/apps/mplayerc/EditWithButton.h +++ b/src/apps/mplayerc/EditWithButton.h @@ -1,16 +1,16 @@ /*
Edit With Button
- This class acts mostly like a normal Edit Box except that it provides a button to the right
- side of the control. Clicking the button invokes the virutal OnLeftClick method. If that
- has not been overridden in a derived classes then it sends the EDIT_BUTTON_LEFTCLICKED
+ This class acts mostly like a normal Edit Box except that it provides a button to the right
+ side of the control. Clicking the button invokes the virutal OnLeftClick method. If that
+ has not been overridden in a derived classes then it sends the EDIT_BUTTON_LEFTCLICKED
message to the parent window.
- CEditWithButton_Base contains most of the code to make this work but cannot be instantiated
- itself. A derived class must override DrawButtonContent and CalculateButtonWidth to determine
+ CEditWithButton_Base contains most of the code to make this work but cannot be instantiated
+ itself. A derived class must override DrawButtonContent and CalculateButtonWidth to determine
what is actually drawn for the button.
- CEditWithButton is a derived class that handles the simplest form of a button where a plain
+ CEditWithButton is a derived class that handles the simplest form of a button where a plain
text string is displayed on the button.
Other classes could be derived to draw other kinds of buttons.
@@ -34,8 +34,8 @@ public: CEditWithButton_Base();
// Called when a left click is detected. The default implementation will send a
- // EDIT_BUTTON_LEFTCLICKED message to the parent window. Derived classes
- // could override this to handle the event themselves, and so are not required
+ // EDIT_BUTTON_LEFTCLICKED message to the parent window. Derived classes
+ // could override this to handle the event themselves, and so are not required
// to call this base implementation.
virtual void OnLeftClick();
@@ -61,12 +61,12 @@ protected: int GetButtonThemeState() const;
// Called when the button needs to be drawn.
- // The default implementation draws the button frame, adjusts the rect if
- // the button is pressed, and then calls DrawButtonContent to render the
+ // The default implementation draws the button frame, adjusts the rect if
+ // the button is pressed, and then calls DrawButtonContent to render the
// contents of the button.
virtual void DrawButton(CRect rectButton);
- // Called when the button contents (anything inside the button's border) needs to
+ // Called when the button contents (anything inside the button's border) needs to
// be drawn. The rect will have already been adjusted if the button is pressed.
// The content must be drawn using the given device context within the given rect.
virtual void DrawButtonContent(CDC& dc, CRect rectButton, HTHEME hButtonTheme) = 0;
diff --git a/src/apps/mplayerc/GoToDlg.cpp b/src/apps/mplayerc/GoToDlg.cpp index b8f73c774..2f22d2fc9 100644 --- a/src/apps/mplayerc/GoToDlg.cpp +++ b/src/apps/mplayerc/GoToDlg.cpp @@ -118,7 +118,7 @@ void CGoToDlg::OnBnClickedOk1() swscanf_s(m_timestr, L"%u%c%f%1s", &mm, &c2, 1, &ss, &c3, 2) == 3 && ss < 60 || // mmm:ss[.ms]
swscanf_s(m_timestr, L"%u%c%u%c%f%1s", &hh, &c1, 1, &mm, &c2, 1, &ss, &c3, 2) == 5 && mm < 60 && ss < 60) && // hhh:mm:ss[.ms]
c1 == L':' && c2 == L':' && ss >=0) {
-
+
m_time = (int)(1000*((hh*60+mm)*60+ss)+0.5);
OnOK();
} else {
diff --git a/src/apps/mplayerc/MainFrm.cpp b/src/apps/mplayerc/MainFrm.cpp index 5dc5303a5..2723d17cf 100644 --- a/src/apps/mplayerc/MainFrm.cpp +++ b/src/apps/mplayerc/MainFrm.cpp @@ -4160,8 +4160,8 @@ void CMainFrame::OnFileOpenQuick() ShowWindow(SW_SHOW);
SetForegroundWindow();
- if(fns.GetCount() == 1) {
- if(OpenBD(fns.GetHead())) {
+ if (fns.GetCount() == 1) {
+ if (OpenBD(fns.GetHead())) {
return;
}
}
@@ -4193,8 +4193,8 @@ void CMainFrame::OnFileOpenmedia() ShowWindow(SW_SHOW);
SetForegroundWindow();
- if(!dlg.m_fMultipleFiles) {
- if(OpenBD(dlg.m_fns.GetHead())) {
+ if (!dlg.m_fMultipleFiles) {
+ if (OpenBD(dlg.m_fns.GetHead())) {
return;
}
}
@@ -4349,7 +4349,7 @@ BOOL CMainFrame::OnCopyData(CWnd* pWnd, COPYDATASTRUCT* pCDS) sl.AddTailList(&s.slDubs);
}
- if(OpenBD(s.slFiles.GetHead())) {
+ if (OpenBD(s.slFiles.GetHead())) {
if (fSetForegroundWindow && !(s.nCLSwitches&CLSW_NOFOCUS)) {
SetForegroundWindow();
}
@@ -4459,7 +4459,7 @@ void CMainFrame::OnFileOpendvd() if (iil) {
SHGetPathFromIDList(iil, path);
s.strDVDPath = path;
- if(!OpenBD(path)) {
+ if (!OpenBD(path)) {
CAutoPtr<OpenDVDData> p(DNew OpenDVDData());
p->path = path;
p->path.Replace('/', '\\');
@@ -4533,7 +4533,7 @@ void CMainFrame::OnFileOpenCD(UINT nID) void CMainFrame::OnFileReopen()
{
- if(!m_LastOpenBDPath.IsEmpty() && OpenBD(m_LastOpenBDPath)) {
+ if (!m_LastOpenBDPath.IsEmpty() && OpenBD(m_LastOpenBDPath)) {
return;
}
OpenCurPlaylistItem();
@@ -4552,10 +4552,10 @@ void CMainFrame::OnDropFiles(HDROP hDropInfo) UINT nFiles = ::DragQueryFile(hDropInfo, (UINT)-1, NULL, 0);
- if(nFiles == 1) {
+ if (nFiles == 1) {
CString path;
path.ReleaseBuffer(::DragQueryFile(hDropInfo, 0, path.GetBuffer(_MAX_PATH), _MAX_PATH));
- if(OpenBD(path)) {
+ if (OpenBD(path)) {
return;
}
}
@@ -7143,7 +7143,7 @@ void CMainFrame::OnPlayPlay() CString m_strOSD = _T("");
if (GetPlaybackMode() == PM_FILE) {
m_strOSD = m_wndPlaylistBar.GetCurFileName();
- if(!m_LastOpenBDPath.IsEmpty()) {
+ if (!m_LastOpenBDPath.IsEmpty()) {
m_strOSD = ResStr(ID_PLAY_PLAY);
int i = m_strOSD.Find(_T("\n"));
if (i > 0) {
@@ -8580,9 +8580,9 @@ void CMainFrame::OnNavigateChapters(UINT nID) if ((int)nID >= 0 && (nID < m_MPLSPlaylist.GetCount() && m_MPLSPlaylist.GetCount() > 1)) {
POSITION pos = m_MPLSPlaylist.GetHeadPosition();
int idx = 0;
- while(pos) {
- CHdmvClipInfo::PlaylistItem Item = m_MPLSPlaylist.GetNext(pos);
- if(idx == nID) {
+ while (pos) {
+ CHdmvClipInfo::PlaylistItem Item = m_MPLSPlaylist.GetNext(pos);
+ if (idx == nID) {
m_bIsBDPlay = true;
m_wndPlaylistBar.Empty();
CAtlList<CString> sl;
@@ -8595,7 +8595,7 @@ void CMainFrame::OnNavigateChapters(UINT nID) }
}
- if(m_MPLSPlaylist.GetCount() > 1) {
+ if (m_MPLSPlaylist.GetCount() > 1) {
nID -= m_MPLSPlaylist.GetCount();
}
@@ -8614,8 +8614,8 @@ void CMainFrame::OnNavigateChapters(UINT nID) }
return;
}
-
- if(m_pCB->ChapGetCount() > 1) {
+
+ if (m_pCB->ChapGetCount() > 1) {
nID -= m_pCB->ChapGetCount();
}
@@ -9817,9 +9817,9 @@ void CMainFrame::AutoChangeMonitorMode() for (int rs = 1; rs < 100 ; rs++) {
if (s.AutoChangeFullscrRes.dmFullscreenRes[rs].fIsData == true
- && s.AutoChangeFullscrRes.dmFullscreenRes[rs].fChecked == 1
- && MediaFPS >= s.AutoChangeFullscrRes.dmFullscreenRes[rs].vfr_from
- && MediaFPS <= s.AutoChangeFullscrRes.dmFullscreenRes[rs].vfr_to) {
+ && s.AutoChangeFullscrRes.dmFullscreenRes[rs].fChecked == 1
+ && MediaFPS >= s.AutoChangeFullscrRes.dmFullscreenRes[rs].vfr_from
+ && MediaFPS <= s.AutoChangeFullscrRes.dmFullscreenRes[rs].vfr_to) {
SetDispMode(s.AutoChangeFullscrRes.dmFullscreenRes[rs].dmFSRes, mf_hmonitor);
return;
@@ -11515,7 +11515,7 @@ bool CMainFrame::OpenMediaPrivate(CAutoPtr<OpenMediaData> pOMD) return false;
}
- // Clear DXVA state ...
+ // Clear DXVA state ...
ClearDXVAState();
#ifdef _DEBUG
@@ -11587,7 +11587,7 @@ bool CMainFrame::OpenMediaPrivate(CAutoPtr<OpenMediaData> pOMD) path.RemoveFileSpec();
mi_fn = path + _T("\\VTS_01_1.VOB");
}
- } else {
+ } else {
CPath path(mi_fn);
CString ext = path.GetExtension();
// BD
@@ -11616,14 +11616,14 @@ bool CMainFrame::OpenMediaPrivate(CAutoPtr<OpenMediaData> pOMD) CString strFPS = MI.Get(Stream_Video, 0, _T("FrameRate"), Info_Text, Info_Name).c_str();
// 3:2 pulldown ???
- CString strST = MI.Get(Stream_Video, 0, _T("ScanType"), Info_Text, Info_Name).c_str();
- CString strSO = MI.Get(Stream_Video, 0, _T("ScanOrder"), Info_Text, Info_Name).c_str();
+ CString strST = MI.Get(Stream_Video, 0, _T("ScanType"), Info_Text, Info_Name).c_str();
+ CString strSO = MI.Get(Stream_Video, 0, _T("ScanOrder"), Info_Text, Info_Name).c_str();
if (strFPS == _T("29.970") && (strSO == _T("2:3 Pulldown") || strST == _T("Progressive") && (strSO == _T("TFF") || strSO == _T("BFF") || strSO == _T("2:3 Pulldown"))) ) {
strFPS = _T("23.976");
}
- miFPS = wcstod(strFPS, NULL);
+ miFPS = wcstod(strFPS, NULL);
AutoChangeMonitorMode();
}
@@ -11917,7 +11917,7 @@ bool CMainFrame::OpenMediaPrivate(CAutoPtr<OpenMediaData> pOMD) PostMessage(WM_KICKIDLE); // calls main thread to update things
- if(!m_bIsBDPlay) {
+ if (!m_bIsBDPlay) {
m_MPLSPlaylist.RemoveAll();
m_LastOpenBDPath = _T("");
}
@@ -12478,8 +12478,8 @@ void CMainFrame::SetupLanguageMenu() if (!IsMenu(pSub->m_hMenu)) {
pSub->CreatePopupMenu();
} else while (pSub->RemoveMenu(0, MF_BYPOSITION)) {
- ;
- }
+ ;
+ }
for (int i=1; i<ID_LANGUAGE_LAST-ID_LANGUAGE_ENGLISH; i++) {
UINT nID = AfxGetMyApp()->GetLanguageAlph(i);
if (nID == 1) {
@@ -12489,15 +12489,15 @@ void CMainFrame::SetupLanguageMenu() if (strSatellite) {
HMODULE lib = NULL;
if ((lib = LoadLibrary(strSatellite)) != NULL) {
- FreeLibrary(lib);
+ FreeLibrary(lib);
pSub->AppendMenu(MF_BYCOMMAND|MF_STRING|MF_ENABLED, nID+ID_LANGUAGE_ENGLISH, AfxGetMyApp()->GetLanguageName(nID));
iCount++;
}
}
}
- if(!iCount) {
- pSub->RemoveMenu(0, MF_BYPOSITION);
+ if (!iCount) {
+ pSub->RemoveMenu(0, MF_BYPOSITION);
}
}
@@ -12868,7 +12868,7 @@ void CMainFrame::SetupNavChaptersSubMenu() UINT id = ID_NAVIGATE_CHAP_SUBITEM_START;
if (GetPlaybackMode() == PM_FILE) {
- if(m_MPLSPlaylist.GetCount() > 1) {
+ if (m_MPLSPlaylist.GetCount() > 1) {
DWORD idx = 1;
POSITION pos = m_MPLSPlaylist.GetHeadPosition();
while (pos) {
@@ -12887,7 +12887,7 @@ void CMainFrame::SetupNavChaptersSubMenu() CString time = _T("[") + ReftimeToString2(Item.Duration()) + _T("]");
CString name = StripPath(Item.m_strFileName);
- if(name == m_wndPlaylistBar.m_pl.GetHead().GetLabel()) {
+ if (name == m_wndPlaylistBar.m_pl.GetHead().GetLabel()) {
flags |= MF_CHECKED;
}
@@ -12900,7 +12900,7 @@ void CMainFrame::SetupNavChaptersSubMenu() REFERENCE_TIME rt = GetPos();
DWORD j = m_pCB->ChapLookup(&rt, NULL);
- if(m_pCB->ChapGetCount() > 1) {
+ if (m_pCB->ChapGetCount() > 1) {
for (DWORD i = 0, idx = 0; i < m_pCB->ChapGetCount(); i++, id++, idx++) {
rt = 0;
CComBSTR bstr;
@@ -12926,14 +12926,14 @@ void CMainFrame::SetupNavChaptersSubMenu() if (id != ID_NAVIGATE_CHAP_SUBITEM_START && i == 0) {
//pSub->AppendMenu(MF_SEPARATOR);
- if(m_MPLSPlaylist.GetCount() > 1) {
+ if (m_MPLSPlaylist.GetCount() > 1) {
flags |= MF_MENUBARBREAK;
}
}
pSub->AppendMenu(flags, id, name + '\t' + time);
}
}
-
+
if (m_wndPlaylistBar.GetCount() > 1) {
POSITION pos = m_wndPlaylistBar.m_pl.GetHeadPosition();
while (pos) {
@@ -12950,7 +12950,7 @@ void CMainFrame::SetupNavChaptersSubMenu() pSub->AppendMenu(flags, id++, name);
}
}
-
+
} else if (GetPlaybackMode() == PM_DVD) {
ULONG ulNumOfVolumes, ulVolume;
DVD_DISC_SIDE Side;
@@ -15858,13 +15858,13 @@ bool CMainFrame::OpenBD(CString Path) CString ext = CPath(Path).GetExtension();
ext.MakeLower();
- if((CPath(Path).IsDirectory() && Path.Find(_T("\\BDMV"))) || CPath(Path + _T("\\BDMV")).IsDirectory() || (!ext.IsEmpty() && ext == _T(".bdmv"))){
- if(!ext.IsEmpty() && ext == _T(".bdmv")) {
+ if ((CPath(Path).IsDirectory() && Path.Find(_T("\\BDMV"))) || CPath(Path + _T("\\BDMV")).IsDirectory() || (!ext.IsEmpty() && ext == _T(".bdmv"))) {
+ if (!ext.IsEmpty() && ext == _T(".bdmv")) {
Path.Replace(_T("\\BDMV\\"), _T("\\"));
CPath _Path(Path);
_Path.RemoveFileSpec();
Path = CString(_Path);
- } else if(Path.Find(_T("\\BDMV"))) {
+ } else if (Path.Find(_T("\\BDMV"))) {
Path.Replace(_T("\\BDMV"), _T("\\"));
}
if (SUCCEEDED (ClipInfo.FindMainMovie (Path, strPlaylistFile, MainPlaylist, m_MPLSPlaylist))) {
diff --git a/src/apps/mplayerc/PPageFullscreen.cpp b/src/apps/mplayerc/PPageFullscreen.cpp index 3e50e1ff9..21019f954 100644 --- a/src/apps/mplayerc/PPageFullscreen.cpp +++ b/src/apps/mplayerc/PPageFullscreen.cpp @@ -445,8 +445,8 @@ void CPPageFullscreen::ModesUpdate() dm = m_dms[i];
j = i - 1;
while (j != -1 && m_dms[j].size.cx >= dm.size.cx &&
- m_dms[j].size.cy >= dm.size.cy &&
- m_dms[j].freq > dm.freq) {
+ m_dms[j].size.cy >= dm.size.cy &&
+ m_dms[j].freq > dm.freq) {
m_dms[j+1] = m_dms[j];
j--;
}
diff --git a/src/apps/mplayerc/PPageFullscreen.h b/src/apps/mplayerc/PPageFullscreen.h index 0b121bd78..34c3b0b25 100644 --- a/src/apps/mplayerc/PPageFullscreen.h +++ b/src/apps/mplayerc/PPageFullscreen.h @@ -92,7 +92,7 @@ public: afx_msg void OnMoveDown();
afx_msg void OnUpdateUp(CCmdUI* pCmdUI);
afx_msg void OnUpdateDown(CCmdUI* pCmdUI);
-
+
void ReindexList();
void ReindexListSubItem();
void GetCurDispModeString(CString& strMode);
diff --git a/src/apps/mplayerc/RealMediaGraph.cpp b/src/apps/mplayerc/RealMediaGraph.cpp index 80bb6b928..526f43a05 100644 --- a/src/apps/mplayerc/RealMediaGraph.cpp +++ b/src/apps/mplayerc/RealMediaGraph.cpp @@ -792,7 +792,7 @@ STDMETHODIMP CRealMediaGraph::get_Volume(long* plVolume) *plVolume = min((long)(4000*log10(*plVolume/100.0f)), 0);
} else {
*plVolume = -10000;
- }
+ }
return S_OK;
}
diff --git a/src/apps/mplayerc/ShaderCombineDlg.cpp b/src/apps/mplayerc/ShaderCombineDlg.cpp index 758a27019..890dfaece 100644 --- a/src/apps/mplayerc/ShaderCombineDlg.cpp +++ b/src/apps/mplayerc/ShaderCombineDlg.cpp @@ -46,7 +46,7 @@ void CShaderCombineDlg::DoDataExchange(CDataExchange* pDX) __super::DoDataExchange(pDX);
DDX_Check(pDX, IDC_CHECK1, m_fcheck1);
DDX_Control(pDX, IDC_LIST1, m_list1);
-
+
DDX_Check(pDX, IDC_CHECK2, m_fcheck2);
DDX_Control(pDX, IDC_LIST2, m_list2);
@@ -72,8 +72,8 @@ BOOL CShaderCombineDlg::OnInitDialog() {
__super::OnInitDialog();
-// AddAnchor(IDOK, TOP_RIGHT);
-// AddAnchor(IDCANCEL, TOP_RIGHT);
+ //AddAnchor(IDOK, TOP_RIGHT);
+ //AddAnchor(IDCANCEL, TOP_RIGHT);
AppSettings& s = AfxGetAppSettings();
@@ -177,7 +177,7 @@ void CShaderCombineDlg::OnBnClickedAdd() UpdateShaders(SHAIDER1);
return;
}
-
+
i = m_list2.GetCurSel();
if (i >= 0) {
m_list2.InsertString(i, label);
diff --git a/src/apps/mplayerc/ShaderCombineDlg.h b/src/apps/mplayerc/ShaderCombineDlg.h index afef73f22..a6248352c 100644 --- a/src/apps/mplayerc/ShaderCombineDlg.h +++ b/src/apps/mplayerc/ShaderCombineDlg.h @@ -60,7 +60,7 @@ protected: virtual BOOL OnInitDialog();
DECLARE_MESSAGE_MAP()
-
+
protected:
virtual void OnOK();
virtual void OnCancel();
diff --git a/src/apps/mplayerc/WebClientSocket.cpp b/src/apps/mplayerc/WebClientSocket.cpp index 3d3400dba..1d6dfe4ea 100644 --- a/src/apps/mplayerc/WebClientSocket.cpp +++ b/src/apps/mplayerc/WebClientSocket.cpp @@ -405,7 +405,7 @@ bool CWebClientSocket::OnInfo(CStringA& hdr, CStringA& body, CStringA& mime) WIN32_FIND_DATA wfd;
HANDLE hFind = FindFirstFile(m_pMainFrame->m_wndPlaylistBar.GetCurFileName(), &wfd);
- if(hFind != INVALID_HANDLE_VALUE) {
+ if (hFind != INVALID_HANDLE_VALUE) {
FindClose(hFind);
__int64 size = (__int64(wfd.nFileSizeHigh)<<32)|wfd.nFileSizeLow;
const int MAX_FILE_SIZE_BUFFER = 65;
diff --git a/src/apps/mplayerc/mplayerc.cpp b/src/apps/mplayerc/mplayerc.cpp index 73a165cda..c15adb313 100644 --- a/src/apps/mplayerc/mplayerc.cpp +++ b/src/apps/mplayerc/mplayerc.cpp @@ -1108,8 +1108,8 @@ BOOL CMPlayerCApp::InitInstance() CString str = mf[i].GetExtsWithPeriod();
for (CString ext = str.Tokenize(_T(" "), j); !ext.IsEmpty(); ext = str.Tokenize(_T(" "), j)) {
if (((m_s.nCLSwitches & CLSW_REGEXTVID) && !bAudioOnly) ||
- ((m_s.nCLSwitches & CLSW_REGEXTAUD) && bAudioOnly) ||
- ((m_s.nCLSwitches & CLSW_REGEXTPL) && bPlaylist)) {
+ ((m_s.nCLSwitches & CLSW_REGEXTAUD) && bAudioOnly) ||
+ ((m_s.nCLSwitches & CLSW_REGEXTPL) && bPlaylist)) {
CPPageFormats::RegisterExt(ext, mf[i].GetDescription(), true);
}
}
@@ -1156,7 +1156,7 @@ BOOL CMPlayerCApp::InitInstance() m_mutexOneInstance.Create(NULL, TRUE, MPC_WND_CLASS_NAME);
if ( GetLastError() == ERROR_ALREADY_EXISTS &&
- (!(m_s.GetAllowMultiInst() || m_s.nCLSwitches&CLSW_NEW || m_cmdln.IsEmpty()) || m_s.nCLSwitches&CLSW_ADD) ) {
+ (!(m_s.GetAllowMultiInst() || m_s.nCLSwitches&CLSW_NEW || m_cmdln.IsEmpty()) || m_s.nCLSwitches&CLSW_ADD) ) {
DWORD res = WaitForSingleObject(m_mutexOneInstance.m_h, 5000);
if (res==WAIT_OBJECT_0 || res==WAIT_ABANDONED) {
@@ -2126,7 +2126,7 @@ void CMPlayerCApp::UpdateColorControlRange(bool isEVR) m_ColorControl[0].StepSize = max(1,(int)(m_VMR9ColorControl[0].StepSize+0.5));
// Contrast
//if(m_VMR9ColorControl[1].MinValue == 0.0999908447265625) m_VMR9ColorControl[1].MinValue = 0.11; //fix nvidia bug
- if(*(int*)&m_VMR9ColorControl[1].MinValue == 1036830720) m_VMR9ColorControl[1].MinValue = 0.11f; //fix nvidia bug
+ if (*(int*)&m_VMR9ColorControl[1].MinValue == 1036830720) m_VMR9ColorControl[1].MinValue = 0.11f; //fix nvidia bug
m_ColorControl[1].MinValue = (int)floor(m_VMR9ColorControl[1].MinValue*100+0.5);
m_ColorControl[1].MaxValue = (int)floor(m_VMR9ColorControl[1].MaxValue*100+0.5);
m_ColorControl[1].DefaultValue = (int)floor(m_VMR9ColorControl[1].DefaultValue*100+0.5);
diff --git a/src/filters/FilterApp.cpp b/src/filters/FilterApp.cpp index 059fcda74..bba89e1c0 100644 --- a/src/filters/FilterApp.cpp +++ b/src/filters/FilterApp.cpp @@ -32,7 +32,7 @@ CFilterApp::CFilterApp() BOOL CFilterApp::InitInstance()
{
- if(!__super::InitInstance()) {
+ if (!__super::InitInstance()) {
return FALSE;
}
diff --git a/src/filters/InternalPropertyPage.cpp b/src/filters/InternalPropertyPage.cpp index 9694d1b4c..fa9dc0ba3 100644 --- a/src/filters/InternalPropertyPage.cpp +++ b/src/filters/InternalPropertyPage.cpp @@ -37,17 +37,17 @@ CInternalPropertyPageWnd::CInternalPropertyPageWnd() BOOL CInternalPropertyPageWnd::Create(IPropertyPageSite* pPageSite, LPCRECT pRect, CWnd* pParentWnd)
{
- if(!pPageSite || !pRect) {
+ if (!pPageSite || !pRect) {
return FALSE;
}
m_pPageSite = pPageSite;
- if(!m_font.m_hObject) {
+ if (!m_font.m_hObject) {
CString face;
WORD height;
extern BOOL AFXAPI AfxGetPropSheetFont(CString& strFace, WORD& wSize, BOOL bWizard); // yay
- if(!AfxGetPropSheetFont(face, height, FALSE)) {
+ if (!AfxGetPropSheetFont(face, height, FALSE)) {
return FALSE;
}
@@ -59,15 +59,15 @@ BOOL CInternalPropertyPageWnd::Create(IPropertyPageSite* pPageSite, LPCRECT pRec ::ReleaseDC(0, hDC);
lf.lfWeight = FW_NORMAL;
lf.lfCharSet = DEFAULT_CHARSET;
- if(!m_font.CreateFontIndirect(&lf)) {
+ if (!m_font.CreateFontIndirect(&lf)) {
return FALSE;
}
lf.lfHeight -= -1;
_tcscpy(lf.lfFaceName, _T("Lucida Console"));
- if(!m_monospacefont.CreateFontIndirect(&lf)) {
+ if (!m_monospacefont.CreateFontIndirect(&lf)) {
_tcscpy(lf.lfFaceName, _T("Courier New"));
- if(!m_monospacefont.CreateFontIndirect(&lf)) {
+ if (!m_monospacefont.CreateFontIndirect(&lf)) {
return FALSE;
}
}
@@ -83,7 +83,7 @@ BOOL CInternalPropertyPageWnd::Create(IPropertyPageSite* pPageSite, LPCRECT pRec }
LPCTSTR wc = AfxRegisterWndClass(CS_VREDRAW|CS_HREDRAW|CS_DBLCLKS, 0, (HBRUSH)(COLOR_BTNFACE + 1));
- if(!CreateEx(0, wc, _T("CInternalPropertyPageWnd"), WS_CHILDWINDOW, *pRect, pParentWnd, 0)) {
+ if (!CreateEx(0, wc, _T("CInternalPropertyPageWnd"), WS_CHILDWINDOW, *pRect, pParentWnd, 0)) {
return FALSE;
}
@@ -94,7 +94,7 @@ BOOL CInternalPropertyPageWnd::Create(IPropertyPageSite* pPageSite, LPCRECT pRec BOOL CInternalPropertyPageWnd::OnWndMsg(UINT message, WPARAM wParam, LPARAM lParam, LRESULT* pResult)
{
- if(message == WM_COMMAND || message == WM_HSCROLL || message == WM_VSCROLL) {
+ if (message == WM_COMMAND || message == WM_HSCROLL || message == WM_VSCROLL) {
SetDirty(true);
}
@@ -112,15 +112,15 @@ CInternalPropertyPage::CInternalPropertyPage(LPUNKNOWN lpunk, HRESULT* phr) : CUnknown(_T("CInternalPropertyPage"), lpunk)
, m_pWnd(NULL)
{
- if(phr) {
+ if (phr) {
*phr = S_OK;
}
}
CInternalPropertyPage::~CInternalPropertyPage()
{
- if(m_pWnd) {
- if(m_pWnd->m_hWnd) {
+ if (m_pWnd) {
+ if (m_pWnd->m_hWnd) {
ASSERT(0);
m_pWnd->DestroyWindow();
}
@@ -142,7 +142,7 @@ STDMETHODIMP CInternalPropertyPage::SetPageSite(IPropertyPageSite* pPageSite) {
CAutoLock cAutoLock(this);
- if(pPageSite && m_pPageSite || !pPageSite && !m_pPageSite) {
+ if (pPageSite && m_pPageSite || !pPageSite && !m_pPageSite) {
return E_UNEXPECTED;
}
@@ -159,15 +159,15 @@ STDMETHODIMP CInternalPropertyPage::Activate(HWND hwndParent, LPCRECT pRect, BOO CheckPointer(pRect, E_POINTER);
- if(!m_pWnd || m_pWnd->m_hWnd || m_pUnks.IsEmpty()) {
+ if (!m_pWnd || m_pWnd->m_hWnd || m_pUnks.IsEmpty()) {
return E_UNEXPECTED;
}
- if(!m_pWnd->Create(m_pPageSite, pRect, CWnd::FromHandle(hwndParent))) {
+ if (!m_pWnd->Create(m_pPageSite, pRect, CWnd::FromHandle(hwndParent))) {
return E_OUTOFMEMORY;
}
- if(!m_pWnd->OnActivate()) {
+ if (!m_pWnd->OnActivate()) {
m_pWnd->DestroyWindow();
return E_FAIL;
}
@@ -184,7 +184,7 @@ STDMETHODIMP CInternalPropertyPage::Deactivate() CAutoLock cAutoLock(this);
- if(!m_pWnd || !m_pWnd->m_hWnd) {
+ if (!m_pWnd || !m_pWnd->m_hWnd) {
return E_UNEXPECTED;
}
@@ -204,7 +204,7 @@ STDMETHODIMP CInternalPropertyPage::GetPageInfo(PROPPAGEINFO* pPageInfo) LPOLESTR pszTitle;
HRESULT hr = AMGetWideString(CStringW(GetWindowTitle()), &pszTitle);
- if(FAILED(hr)) {
+ if (FAILED(hr)) {
return hr;
}
@@ -222,25 +222,25 @@ STDMETHODIMP CInternalPropertyPage::SetObjects(ULONG cObjects, LPUNKNOWN* ppUnk) {
CAutoLock cAutoLock(this);
- if(cObjects && m_pWnd || !cObjects && !m_pWnd) {
+ if (cObjects && m_pWnd || !cObjects && !m_pWnd) {
return E_UNEXPECTED;
}
m_pUnks.RemoveAll();
- if(cObjects > 0) {
+ if (cObjects > 0) {
CheckPointer(ppUnk, E_POINTER);
- for(ULONG i = 0; i < cObjects; i++) {
+ for (ULONG i = 0; i < cObjects; i++) {
m_pUnks.AddTail(ppUnk[i]);
}
m_pWnd = GetWindow();
- if(!m_pWnd) {
+ if (!m_pWnd) {
return E_OUTOFMEMORY;
}
- if(!m_pWnd->OnConnect(m_pUnks)) {
+ if (!m_pWnd->OnConnect(m_pUnks)) {
delete m_pWnd;
m_pWnd = NULL;
@@ -263,11 +263,11 @@ STDMETHODIMP CInternalPropertyPage::Show(UINT nCmdShow) CAutoLock cAutoLock(this);
- if(!m_pWnd) {
+ if (!m_pWnd) {
return E_UNEXPECTED;
}
- if((nCmdShow != SW_SHOW) && (nCmdShow != SW_SHOWNORMAL) && (nCmdShow != SW_HIDE)) {
+ if ((nCmdShow != SW_SHOW) && (nCmdShow != SW_SHOWNORMAL) && (nCmdShow != SW_HIDE)) {
return E_INVALIDARG;
}
@@ -285,7 +285,7 @@ STDMETHODIMP CInternalPropertyPage::Move(LPCRECT pRect) CheckPointer(pRect, E_POINTER);
- if(!m_pWnd) {
+ if (!m_pWnd) {
return E_UNEXPECTED;
}
@@ -307,11 +307,11 @@ STDMETHODIMP CInternalPropertyPage::Apply() CAutoLock cAutoLock(this);
- if(!m_pWnd || m_pUnks.IsEmpty() || !m_pPageSite) {
+ if (!m_pWnd || m_pUnks.IsEmpty() || !m_pPageSite) {
return E_UNEXPECTED;
}
- if(m_pWnd->GetDirty() && m_pWnd->OnApply()) {
+ if (m_pWnd->GetDirty() && m_pWnd->OnApply()) {
m_pWnd->SetDirty(false);
}
diff --git a/src/filters/InternalPropertyPage.h b/src/filters/InternalPropertyPage.h index 39e012012..be0c3723c 100644 --- a/src/filters/InternalPropertyPage.h +++ b/src/filters/InternalPropertyPage.h @@ -47,8 +47,8 @@ public: void SetDirty(bool fDirty = true) {
m_fDirty = fDirty;
- if(m_pPageSite) {
- if(fDirty) {
+ if (m_pPageSite) {
+ if (fDirty) {
m_pPageSite->OnStatusChange(PROPPAGESTATUS_DIRTY);
} else {
m_pPageSite->OnStatusChange(PROPPAGESTATUS_CLEAN);
diff --git a/src/filters/PinInfoWnd.cpp b/src/filters/PinInfoWnd.cpp index a9b192f44..a96589912 100644 --- a/src/filters/PinInfoWnd.cpp +++ b/src/filters/PinInfoWnd.cpp @@ -40,11 +40,11 @@ bool CPinInfoWnd::OnConnect(const CInterfaceList<IUnknown, &IID_IUnknown>& pUnks m_pBF.Release();
POSITION pos = pUnks.GetHeadPosition();
- while(pos && !(m_pBF = pUnks.GetNext(pos))) {
+ while (pos && !(m_pBF = pUnks.GetNext(pos))) {
;
}
- if(!m_pBF) {
+ if (!m_pBF) {
return false;
}
@@ -59,7 +59,7 @@ void CPinInfoWnd::OnDisconnect() static WNDPROC OldControlProc;
static LRESULT CALLBACK ControlProc(HWND control, UINT message, WPARAM wParam, LPARAM lParam)
{
- if(message == WM_KEYDOWN) {
+ if (message == WM_KEYDOWN) {
if (LOWORD(wParam)==VK_ESCAPE) {
return 0; // just ignore ESCAPE in edit control
}
@@ -84,17 +84,17 @@ bool CPinInfoWnd::OnActivate() m_pin_combo.Create(dwStyle|CBS_DROPDOWNLIST, CRect(p + CPoint(30, 0), CSize(450, 200)), this, IDC_PP_COMBO1);
BeginEnumPins(m_pBF, pEP, pPin) {
CPinInfo pi;
- if(FAILED(pPin->QueryPinInfo(&pi))) {
+ if (FAILED(pPin->QueryPinInfo(&pi))) {
continue;
}
CString str = CString(pi.achName);
- if(!str.Find(_T("Apple"))) {
+ if (!str.Find(_T("Apple"))) {
str.Delete(0,1);
}
CString dir = _T("[?] ");
- if(pi.dir == PINDIR_INPUT) {
+ if (pi.dir == PINDIR_INPUT) {
dir = _T("[IN] ");
- } else if(pi.dir == PINDIR_OUTPUT) {
+ } else if (pi.dir == PINDIR_OUTPUT) {
dir = _T("[OUT] ");
}
m_pin_combo.SetItemDataPtr(m_pin_combo.AddString(dir + str), pPin);
@@ -109,7 +109,7 @@ bool CPinInfoWnd::OnActivate() OnCbnSelchangeCombo1();
- for(CWnd* pWnd = GetWindow(GW_CHILD); pWnd; pWnd = pWnd->GetNextWindow()) {
+ for (CWnd* pWnd = GetWindow(GW_CHILD); pWnd; pWnd = pWnd->GetNextWindow()) {
pWnd->SetFont(&m_font, FALSE);
}
@@ -129,7 +129,7 @@ bool CPinInfoWnd::OnApply() {
OnDeactivate();
- if(m_pBF) {
+ if (m_pBF) {
}
return true;
@@ -158,12 +158,12 @@ void CPinInfoWnd::OnCbnSelchangeCombo1() m_info_edit.SetWindowText(_T(""));
int i = m_pin_combo.GetCurSel();
- if(i < 0) {
+ if (i < 0) {
return;
}
CComPtr<IPin> pPin = (IPin*)m_pin_combo.GetItemDataPtr(i);
- if(!pPin) {
+ if (!pPin) {
return;
}
@@ -197,7 +197,7 @@ void CPinInfoWnd::OnCbnSelchangeCombo1() CMediaTypeEx cmt;
CComPtr<IPin> pPinTo;
- if(SUCCEEDED(pPin->ConnectedTo(&pPinTo)) && pPinTo) {
+ if (SUCCEEDED(pPin->ConnectedTo(&pPinTo)) && pPinTo) {
str.Format(_T("- Connected to:\n\nCLSID: %s\nFilter: %s\nPin: %s\n\n"),
CString(CStringFromGUID(GetCLSID(pPinTo))),
CString(GetFilterName(GetFilterFromPin(pPinTo))),
@@ -207,11 +207,11 @@ void CPinInfoWnd::OnCbnSelchangeCombo1() AddLine(_T("- Connection media type:\n\n"));
- if(SUCCEEDED(pPin->ConnectionMediaType(&cmt))) {
+ if (SUCCEEDED(pPin->ConnectionMediaType(&cmt))) {
CAtlList<CString> sl;
cmt.Dump(sl);
POSITION pos = sl.GetHeadPosition();
- while(pos) {
+ while (pos) {
AddLine(sl.GetNext(pos) + '\n');
}
}
@@ -227,13 +227,13 @@ void CPinInfoWnd::OnCbnSelchangeCombo1() str.Format(_T("- Enumerated media type %d:\n\n"), iMT++);
AddLine(str);
- if(cmt.majortype != GUID_NULL && mt == cmt) {
+ if (cmt.majortype != GUID_NULL && mt == cmt) {
AddLine(_T("Set as the current media type\n\n"));
} else {
CAtlList<CString> sl;
mt.Dump(sl);
POSITION pos = sl.GetHeadPosition();
- while(pos) {
+ while (pos) {
AddLine(sl.GetNext(pos) + '\n');
}
}
diff --git a/src/filters/muxer/BaseMuxer/BaseMuxer.cpp b/src/filters/muxer/BaseMuxer/BaseMuxer.cpp index c5ff73bf0..810c6936a 100644 --- a/src/filters/muxer/BaseMuxer/BaseMuxer.cpp +++ b/src/filters/muxer/BaseMuxer/BaseMuxer.cpp @@ -30,7 +30,7 @@ CBaseMuxerFilter::CBaseMuxerFilter(LPUNKNOWN pUnk, HRESULT* phr, const CLSID& cl : CBaseFilter(NAME("CBaseMuxerFilter"), pUnk, this, clsid)
, m_rtCurrent(0)
{
- if(phr) {
+ if (phr) {
*phr = S_OK;
}
m_pOutput.Attach(DNew CBaseMuxerOutputPin(L"Output", this, this, phr));
@@ -62,9 +62,9 @@ STDMETHODIMP CBaseMuxerFilter::NonDelegatingQueryInterface(REFIID riid, void** p void CBaseMuxerFilter::AddInput()
{
POSITION pos = m_pInputs.GetHeadPosition();
- while(pos) {
+ while (pos) {
CBasePin* pPin = m_pInputs.GetNext(pos);
- if(!pPin->IsConnected()) {
+ if (!pPin->IsConnected()) {
return;
}
}
@@ -74,7 +74,7 @@ void CBaseMuxerFilter::AddInput() name.Format(L"Input %d", m_pInputs.GetCount()+1);
CBaseMuxerInputPin* pInputPin = NULL;
- if(FAILED(CreateInput(name, &pInputPin)) || !pInputPin) {
+ if (FAILED(CreateInput(name, &pInputPin)) || !pInputPin) {
ASSERT(0);
return;
}
@@ -83,7 +83,7 @@ void CBaseMuxerFilter::AddInput() name.Format(L"~Output %d", m_pRawOutputs.GetCount()+1);
CBaseMuxerRawOutputPin* pRawOutputPin = NULL;
- if(FAILED(CreateRawOutput(name, &pRawOutputPin)) || !pRawOutputPin) {
+ if (FAILED(CreateRawOutput(name, &pRawOutputPin)) || !pRawOutputPin) {
ASSERT(0);
return;
}
@@ -120,10 +120,10 @@ DWORD CBaseMuxerFilter::ThreadProc() POSITION pos;
- while(1) {
+ while (1) {
DWORD cmd = GetRequest();
- switch(cmd) {
+ switch (cmd) {
default:
case CMD_EXIT:
CAMThread::m_hThread = NULL;
@@ -135,9 +135,9 @@ DWORD CBaseMuxerFilter::ThreadProc() m_pPins.RemoveAll();
pos = m_pInputs.GetHeadPosition();
- while(pos) {
+ while (pos) {
CBaseMuxerInputPin* pPin = m_pInputs.GetNext(pos);
- if(pPin->IsConnected()) {
+ if (pPin->IsConnected()) {
m_pActivePins.AddTail(pPin);
m_pPins.AddTail(pPin);
}
@@ -152,23 +152,23 @@ DWORD CBaseMuxerFilter::ThreadProc() try {
MuxHeaderInternal();
- while(!CheckRequest(NULL) && m_pActivePins.GetCount()) {
- if(m_State == State_Paused) {
+ while (!CheckRequest(NULL) && m_pActivePins.GetCount()) {
+ if (m_State == State_Paused) {
Sleep(10);
continue;
}
CAutoPtr<MuxerPacket> pPacket = GetPacket();
- if(!pPacket) {
+ if (!pPacket) {
Sleep(1);
continue;
}
- if(pPacket->IsTimeValid()) {
+ if (pPacket->IsTimeValid()) {
m_rtCurrent = pPacket->rtStart;
}
- if(pPacket->IsEOS()) {
+ if (pPacket->IsEOS()) {
m_pActivePins.RemoveAt(m_pActivePins.Find(pPacket->pPin));
}
@@ -176,14 +176,14 @@ DWORD CBaseMuxerFilter::ThreadProc() }
MuxFooterInternal();
- } catch(HRESULT hr) {
+ } catch (HRESULT hr) {
CComQIPtr<IMediaEventSink>(m_pGraph)->Notify(EC_ERRORABORT, hr, 0);
}
m_pOutput->DeliverEndOfStream();
pos = m_pRawOutputs.GetHeadPosition();
- while(pos) {
+ while (pos) {
m_pRawOutputs.GetNext(pos)->DeliverEndOfStream();
}
@@ -204,7 +204,7 @@ void CBaseMuxerFilter::MuxHeaderInternal() {
TRACE(_T("MuxHeader\n"));
- if(CComQIPtr<IBitStream> pBitStream = m_pOutput->GetBitStream()) {
+ if (CComQIPtr<IBitStream> pBitStream = m_pOutput->GetBitStream()) {
MuxHeader(pBitStream);
}
@@ -213,9 +213,9 @@ void CBaseMuxerFilter::MuxHeaderInternal() //
POSITION pos = m_pPins.GetHeadPosition();
- while(pos) {
- if(CBaseMuxerInputPin* pInput = m_pPins.GetNext(pos))
- if(CBaseMuxerRawOutputPin* pOutput = dynamic_cast<CBaseMuxerRawOutputPin*>(pInput->GetRelatedPin())) {
+ while (pos) {
+ if (CBaseMuxerInputPin* pInput = m_pPins.GetNext(pos))
+ if (CBaseMuxerRawOutputPin* pOutput = dynamic_cast<CBaseMuxerRawOutputPin*>(pInput->GetRelatedPin())) {
pOutput->MuxHeader(pInput->CurrentMediaType());
}
}
@@ -231,14 +231,14 @@ void CBaseMuxerFilter::MuxPacketInternal(const MuxerPacket* pPacket) !!(pPacket->flags & MuxerPacket::bogus),
pPacket->rtStart/10000, pPacket->rtStop/10000);
- if(CComQIPtr<IBitStream> pBitStream = m_pOutput->GetBitStream()) {
+ if (CComQIPtr<IBitStream> pBitStream = m_pOutput->GetBitStream()) {
MuxPacket(pBitStream, pPacket);
}
MuxPacket(pPacket);
- if(CBaseMuxerInputPin* pInput = pPacket->pPin)
- if(CBaseMuxerRawOutputPin* pOutput = dynamic_cast<CBaseMuxerRawOutputPin*>(pInput->GetRelatedPin())) {
+ if (CBaseMuxerInputPin* pInput = pPacket->pPin)
+ if (CBaseMuxerRawOutputPin* pOutput = dynamic_cast<CBaseMuxerRawOutputPin*>(pInput->GetRelatedPin())) {
pOutput->MuxPacket(pInput->CurrentMediaType(), pPacket);
}
}
@@ -247,7 +247,7 @@ void CBaseMuxerFilter::MuxFooterInternal() {
TRACE(_T("MuxFooter\n"));
- if(CComQIPtr<IBitStream> pBitStream = m_pOutput->GetBitStream()) {
+ if (CComQIPtr<IBitStream> pBitStream = m_pOutput->GetBitStream()) {
MuxFooter(pBitStream);
}
@@ -256,9 +256,9 @@ void CBaseMuxerFilter::MuxFooterInternal() //
POSITION pos = m_pPins.GetHeadPosition();
- while(pos) {
- if(CBaseMuxerInputPin* pInput = m_pPins.GetNext(pos))
- if(CBaseMuxerRawOutputPin* pOutput = dynamic_cast<CBaseMuxerRawOutputPin*>(pInput->GetRelatedPin())) {
+ while (pos) {
+ if (CBaseMuxerInputPin* pInput = m_pPins.GetNext(pos))
+ if (CBaseMuxerRawOutputPin* pOutput = dynamic_cast<CBaseMuxerRawOutputPin*>(pInput->GetRelatedPin())) {
pOutput->MuxFooter(pInput->CurrentMediaType());
}
}
@@ -271,23 +271,23 @@ CAutoPtr<MuxerPacket> CBaseMuxerFilter::GetPacket() int i = int(m_pActivePins.GetCount());
POSITION pos = m_pActivePins.GetHeadPosition();
- while(pos) {
+ while (pos) {
CBaseMuxerInputPin* pPin = m_pActivePins.GetNext(pos);
CAutoLock cAutoLock(&pPin->m_csQueue);
- if(!pPin->m_queue.GetCount()) {
+ if (!pPin->m_queue.GetCount()) {
continue;
}
MuxerPacket* p = pPin->m_queue.GetHead();
- if(p->IsBogus() || !p->IsTimeValid() || p->IsEOS()) {
+ if (p->IsBogus() || !p->IsTimeValid() || p->IsEOS()) {
pPinMin = pPin;
i = 0;
break;
}
- if(p->rtStart < rtMin) {
+ if (p->rtStart < rtMin) {
rtMin = p->rtStart;
pPinMin = pPin;
}
@@ -297,11 +297,11 @@ CAutoPtr<MuxerPacket> CBaseMuxerFilter::GetPacket() CAutoPtr<MuxerPacket> pPacket;
- if(pPinMin && i == 0) {
+ if (pPinMin && i == 0) {
pPacket = pPinMin->PopPacket();
} else {
pos = m_pActivePins.GetHeadPosition();
- while(pos) {
+ while (pos) {
m_pActivePins.GetNext(pos)->m_evAcceptPacket.Set();
}
}
@@ -320,22 +320,22 @@ CBasePin* CBaseMuxerFilter::GetPin(int n) {
CAutoLock cAutoLock(this);
- if(n >= 0 && n < (int)m_pInputs.GetCount()) {
- if(POSITION pos = m_pInputs.FindIndex(n)) {
+ if (n >= 0 && n < (int)m_pInputs.GetCount()) {
+ if (POSITION pos = m_pInputs.FindIndex(n)) {
return m_pInputs.GetAt(pos);
}
}
n -= int(m_pInputs.GetCount());
- if(n == 0 && m_pOutput) {
+ if (n == 0 && m_pOutput) {
return m_pOutput;
}
n--;
- if(n >= 0 && n < (int)m_pRawOutputs.GetCount()) {
- if(POSITION pos = m_pRawOutputs.FindIndex(n)) {
+ if (n >= 0 && n < (int)m_pRawOutputs.GetCount()) {
+ if (POSITION pos = m_pRawOutputs.FindIndex(n)) {
return m_pRawOutputs.GetAt(pos);
}
}
@@ -350,7 +350,7 @@ STDMETHODIMP CBaseMuxerFilter::Stop() CAutoLock cAutoLock(this);
HRESULT hr = __super::Stop();
- if(FAILED(hr)) {
+ if (FAILED(hr)) {
return hr;
}
@@ -366,11 +366,11 @@ STDMETHODIMP CBaseMuxerFilter::Pause() FILTER_STATE fs = m_State;
HRESULT hr = __super::Pause();
- if(FAILED(hr)) {
+ if (FAILED(hr)) {
return hr;
}
- if(fs == State_Stopped && m_pOutput) {
+ if (fs == State_Stopped && m_pOutput) {
CAMThread::Create();
CallWorker(CMD_RUN);
}
@@ -383,7 +383,7 @@ STDMETHODIMP CBaseMuxerFilter::Run(REFERENCE_TIME tStart) CAutoLock cAutoLock(this);
HRESULT hr = __super::Run(tStart);
- if(FAILED(hr)) {
+ if (FAILED(hr)) {
return hr;
}
@@ -400,7 +400,7 @@ STDMETHODIMP CBaseMuxerFilter::GetCapabilities(DWORD* pCapabilities) STDMETHODIMP CBaseMuxerFilter::CheckCapabilities(DWORD* pCapabilities)
{
CheckPointer(pCapabilities, E_POINTER);
- if(*pCapabilities == 0) {
+ if (*pCapabilities == 0) {
return S_OK;
}
DWORD caps;
@@ -439,9 +439,9 @@ STDMETHODIMP CBaseMuxerFilter::GetDuration(LONGLONG* pDuration) CheckPointer(pDuration, E_POINTER);
*pDuration = 0;
POSITION pos = m_pInputs.GetHeadPosition();
- while(pos) {
+ while (pos) {
REFERENCE_TIME rt = m_pInputs.GetNext(pos)->GetDuration();
- if(rt > *pDuration) {
+ if (rt > *pDuration) {
*pDuration = rt;
}
}
@@ -469,15 +469,15 @@ STDMETHODIMP CBaseMuxerFilter::SetPositions(LONGLONG* pCurrent, DWORD dwCurrentF {
FILTER_STATE fs;
- if(SUCCEEDED(GetState(0, &fs)) && fs == State_Stopped) {
+ if (SUCCEEDED(GetState(0, &fs)) && fs == State_Stopped) {
POSITION pos = m_pInputs.GetHeadPosition();
- while(pos) {
+ while (pos) {
CBasePin* pPin = m_pInputs.GetNext(pos);
CComQIPtr<IMediaSeeking> pMS = pPin->GetConnected();
- if(!pMS) {
+ if (!pMS) {
pMS = GetFilterFromPin(pPin->GetConnected());
}
- if(pMS) {
+ if (pMS) {
pMS->SetPositions(pCurrent, dwCurrentFlags, pStop, dwStopFlags);
}
}
diff --git a/src/filters/muxer/BaseMuxer/BaseMuxerInputPin.cpp b/src/filters/muxer/BaseMuxer/BaseMuxerInputPin.cpp index 8c34c6743..a95fc592e 100644 --- a/src/filters/muxer/BaseMuxer/BaseMuxerInputPin.cpp +++ b/src/filters/muxer/BaseMuxer/BaseMuxerInputPin.cpp @@ -65,14 +65,14 @@ bool CBaseMuxerInputPin::IsSubtitleStream() void CBaseMuxerInputPin::PushPacket(CAutoPtr<MuxerPacket> pPacket)
{
- for(int i = 0; m_pFilter->IsActive() && !m_bFlushing
+ for (int i = 0; m_pFilter->IsActive() && !m_bFlushing
&& !m_evAcceptPacket.Wait(1)
&& i < 1000;
i++) {
;
}
- if(!m_pFilter->IsActive() || m_bFlushing) {
+ if (!m_pFilter->IsActive() || m_bFlushing) {
return;
}
@@ -80,7 +80,7 @@ void CBaseMuxerInputPin::PushPacket(CAutoPtr<MuxerPacket> pPacket) m_queue.AddTail(pPacket);
- if(m_queue.GetCount() >= MAXQUEUESIZE) {
+ if (m_queue.GetCount() >= MAXQUEUESIZE) {
m_evAcceptPacket.Reset();
}
}
@@ -91,11 +91,11 @@ CAutoPtr<MuxerPacket> CBaseMuxerInputPin::PopPacket() CAutoLock cAutoLock(&m_csQueue);
- if(m_queue.GetCount()) {
+ if (m_queue.GetCount()) {
pPacket = m_queue.RemoveHead();
}
- if(m_queue.GetCount() < MAXQUEUESIZE) {
+ if (m_queue.GetCount() < MAXQUEUESIZE) {
m_evAcceptPacket.Set();
}
@@ -104,9 +104,9 @@ CAutoPtr<MuxerPacket> CBaseMuxerInputPin::PopPacket() HRESULT CBaseMuxerInputPin::CheckMediaType(const CMediaType* pmt)
{
- if(pmt->formattype == FORMAT_WaveFormatEx) {
+ if (pmt->formattype == FORMAT_WaveFormatEx) {
WORD wFormatTag = ((WAVEFORMATEX*)pmt->pbFormat)->wFormatTag;
- if((wFormatTag == WAVE_FORMAT_PCM
+ if ((wFormatTag == WAVE_FORMAT_PCM
|| wFormatTag == WAVE_FORMAT_EXTENSIBLE
|| wFormatTag == WAVE_FORMAT_IEEE_FLOAT)
&& pmt->subtype != FOURCCMap(wFormatTag)
@@ -130,7 +130,7 @@ HRESULT CBaseMuxerInputPin::CheckMediaType(const CMediaType* pmt) HRESULT CBaseMuxerInputPin::BreakConnect()
{
HRESULT hr = __super::BreakConnect();
- if(FAILED(hr)) {
+ if (FAILED(hr)) {
return hr;
}
@@ -144,7 +144,7 @@ HRESULT CBaseMuxerInputPin::BreakConnect() HRESULT CBaseMuxerInputPin::CompleteConnect(IPin* pReceivePin)
{
HRESULT hr = __super::CompleteConnect(pReceivePin);
- if(FAILED(hr)) {
+ if (FAILED(hr)) {
return hr;
}
@@ -152,27 +152,27 @@ HRESULT CBaseMuxerInputPin::CompleteConnect(IPin* pReceivePin) m_rtDuration = 0;
CComQIPtr<IMediaSeeking> pMS;
- if((pMS = GetFilterFromPin(pReceivePin)) || (pMS = pReceivePin)) {
+ if ((pMS = GetFilterFromPin(pReceivePin)) || (pMS = pReceivePin)) {
pMS->GetDuration(&m_rtDuration);
}
// properties
- for(CComPtr<IPin> pPin = pReceivePin; pPin; pPin = GetUpStreamPin(GetFilterFromPin(pPin))) {
- if(CComQIPtr<IDSMPropertyBag> pPB = pPin) {
+ for (CComPtr<IPin> pPin = pReceivePin; pPin; pPin = GetUpStreamPin(GetFilterFromPin(pPin))) {
+ if (CComQIPtr<IDSMPropertyBag> pPB = pPin) {
ULONG cProperties = 0;
- if(SUCCEEDED(pPB->CountProperties(&cProperties)) && cProperties > 0) {
- for(ULONG iProperty = 0; iProperty < cProperties; iProperty++) {
+ if (SUCCEEDED(pPB->CountProperties(&cProperties)) && cProperties > 0) {
+ for (ULONG iProperty = 0; iProperty < cProperties; iProperty++) {
PROPBAG2 PropBag;
memset(&PropBag, 0, sizeof(PropBag));
ULONG cPropertiesReturned = 0;
- if(FAILED(pPB->GetPropertyInfo(iProperty, 1, &PropBag, &cPropertiesReturned))) {
+ if (FAILED(pPB->GetPropertyInfo(iProperty, 1, &PropBag, &cPropertiesReturned))) {
continue;
}
HRESULT hr;
CComVariant var;
- if(SUCCEEDED(pPB->Read(1, &PropBag, NULL, &var, &hr)) && SUCCEEDED(hr)) {
+ if (SUCCEEDED(pPB->Read(1, &PropBag, NULL, &var, &hr)) && SUCCEEDED(hr)) {
SetProperty(PropBag.pstrName, &var);
}
@@ -215,7 +215,7 @@ STDMETHODIMP CBaseMuxerInputPin::Receive(IMediaSample* pSample) CAutoLock cAutoLock(&m_csReceive);
HRESULT hr = __super::Receive(pSample);
- if(FAILED(hr)) {
+ if (FAILED(hr)) {
return hr;
}
@@ -224,35 +224,35 @@ STDMETHODIMP CBaseMuxerInputPin::Receive(IMediaSample* pSample) long len = pSample->GetActualDataLength();
BYTE* pData = NULL;
- if(FAILED(pSample->GetPointer(&pData)) || !pData) {
+ if (FAILED(pSample->GetPointer(&pData)) || !pData) {
return S_OK;
}
pPacket->pData.SetCount(len);
memcpy(pPacket->pData.GetData(), pData, len);
- if(S_OK == pSample->IsSyncPoint() || m_mt.majortype == MEDIATYPE_Audio && !m_mt.bTemporalCompression) {
+ if (S_OK == pSample->IsSyncPoint() || m_mt.majortype == MEDIATYPE_Audio && !m_mt.bTemporalCompression) {
pPacket->flags |= MuxerPacket::syncpoint;
}
- if(S_OK == pSample->GetTime(&pPacket->rtStart, &pPacket->rtStop)) {
+ if (S_OK == pSample->GetTime(&pPacket->rtStart, &pPacket->rtStop)) {
pPacket->flags |= MuxerPacket::timevalid;
pPacket->rtStart += m_tStart;
pPacket->rtStop += m_tStart;
- if((pPacket->flags & MuxerPacket::syncpoint) && pPacket->rtStart < m_rtMaxStart) {
+ if ((pPacket->flags & MuxerPacket::syncpoint) && pPacket->rtStart < m_rtMaxStart) {
pPacket->flags &= ~MuxerPacket::syncpoint;
pPacket->flags |= MuxerPacket::bogus;
}
m_rtMaxStart = max(m_rtMaxStart, pPacket->rtStart);
- } else if(pPacket->flags & MuxerPacket::syncpoint) {
+ } else if (pPacket->flags & MuxerPacket::syncpoint) {
pPacket->flags &= ~MuxerPacket::syncpoint;
pPacket->flags |= MuxerPacket::bogus;
}
- if(S_OK == pSample->IsDiscontinuity()) {
+ if (S_OK == pSample->IsDiscontinuity()) {
pPacket->flags |= MuxerPacket::discontinuity;
}
@@ -268,7 +268,7 @@ STDMETHODIMP CBaseMuxerInputPin::EndOfStream() CAutoLock cAutoLock(&m_csReceive);
HRESULT hr = __super::EndOfStream();
- if(FAILED(hr)) {
+ if (FAILED(hr)) {
return hr;
}
diff --git a/src/filters/muxer/BaseMuxer/BaseMuxerOutputPin.cpp b/src/filters/muxer/BaseMuxer/BaseMuxerOutputPin.cpp index cccf16a47..6a020c826 100644 --- a/src/filters/muxer/BaseMuxer/BaseMuxerOutputPin.cpp +++ b/src/filters/muxer/BaseMuxer/BaseMuxerOutputPin.cpp @@ -40,8 +40,8 @@ CBaseMuxerOutputPin::CBaseMuxerOutputPin(LPCWSTR pName, CBaseFilter* pFilter, CC IBitStream* CBaseMuxerOutputPin::GetBitStream()
{
- if(!m_pBitStream) {
- if(CComQIPtr<IStream> pStream = GetConnected()) {
+ if (!m_pBitStream) {
+ if (CComQIPtr<IStream> pStream = GetConnected()) {
m_pBitStream = DNew CBitStream(pStream, true);
}
}
@@ -67,11 +67,11 @@ HRESULT CBaseMuxerOutputPin::DecideBufferSize(IMemAllocator* pAlloc, ALLOCATOR_P pProperties->cbBuffer = 1;
ALLOCATOR_PROPERTIES Actual;
- if(FAILED(hr = pAlloc->SetProperties(pProperties, &Actual))) {
+ if (FAILED(hr = pAlloc->SetProperties(pProperties, &Actual))) {
return hr;
}
- if(Actual.cbBuffer < pProperties->cbBuffer) {
+ if (Actual.cbBuffer < pProperties->cbBuffer) {
return E_FAIL;
}
ASSERT(Actual.cBuffers == pProperties->cBuffers);
@@ -90,10 +90,10 @@ HRESULT CBaseMuxerOutputPin::GetMediaType(int iPosition, CMediaType* pmt) {
CAutoLock cAutoLock(m_pLock);
- if(iPosition < 0) {
+ if (iPosition < 0) {
return E_INVALIDARG;
}
- if(iPosition > 0) {
+ if (iPosition > 0) {
return VFW_S_NO_MORE_ITEMS;
}
@@ -139,50 +139,50 @@ STDMETHODIMP CBaseMuxerRawOutputPin::NonDelegatingQueryInterface(REFIID riid, vo void CBaseMuxerRawOutputPin::MuxHeader(const CMediaType& mt)
{
CComQIPtr<IBitStream> pBitStream = GetBitStream();
- if(!pBitStream) {
+ if (!pBitStream) {
return;
}
const BYTE utf8bom[3] = {0xef, 0xbb, 0xbf};
- if((mt.subtype == FOURCCMap('1CVA') || mt.subtype == FOURCCMap('1cva')) && mt.formattype == FORMAT_MPEG2_VIDEO) {
+ if ((mt.subtype == FOURCCMap('1CVA') || mt.subtype == FOURCCMap('1cva')) && mt.formattype == FORMAT_MPEG2_VIDEO) {
MPEG2VIDEOINFO* vih = (MPEG2VIDEOINFO*)mt.Format();
- for(DWORD i = 0; i < vih->cbSequenceHeader-2; i += 2) {
+ for (DWORD i = 0; i < vih->cbSequenceHeader-2; i += 2) {
pBitStream->BitWrite(0x00000001, 32);
WORD size = (((BYTE*)vih->dwSequenceHeader)[i+0]<<8) | ((BYTE*)vih->dwSequenceHeader)[i+1];
pBitStream->ByteWrite(&((BYTE*)vih->dwSequenceHeader)[i+2], size);
i += size;
}
- } else if(mt.subtype == MEDIASUBTYPE_UTF8) {
+ } else if (mt.subtype == MEDIASUBTYPE_UTF8) {
pBitStream->ByteWrite(utf8bom, sizeof(utf8bom));
- } else if(mt.subtype == MEDIASUBTYPE_SSA || mt.subtype == MEDIASUBTYPE_ASS || mt.subtype == MEDIASUBTYPE_ASS2) {
+ } else if (mt.subtype == MEDIASUBTYPE_SSA || mt.subtype == MEDIASUBTYPE_ASS || mt.subtype == MEDIASUBTYPE_ASS2) {
SUBTITLEINFO* si = (SUBTITLEINFO*)mt.Format();
BYTE* p = (BYTE*)si + si->dwOffset;
- if(memcmp(utf8bom, p, 3) != 0) {
+ if (memcmp(utf8bom, p, 3) != 0) {
pBitStream->ByteWrite(utf8bom, sizeof(utf8bom));
}
CStringA str((char*)p, mt.FormatLength() - (p - mt.Format()));
pBitStream->StrWrite(str + '\n', true);
- if(str.Find("[Events]") < 0) {
+ if (str.Find("[Events]") < 0) {
pBitStream->StrWrite("\n\n[Events]\n", true);
}
- } else if(mt.subtype == MEDIASUBTYPE_SSF) {
+ } else if (mt.subtype == MEDIASUBTYPE_SSF) {
DWORD dwOffset = ((SUBTITLEINFO*)mt.pbFormat)->dwOffset;
try {
m_ssf.Parse(ssf::MemoryInputStream(mt.pbFormat + dwOffset, mt.cbFormat - dwOffset, false, false));
- } catch(ssf::Exception&) {}
- } else if(mt.subtype == MEDIASUBTYPE_VOBSUB) {
+ } catch (ssf::Exception&) {}
+ } else if (mt.subtype == MEDIASUBTYPE_VOBSUB) {
m_idx.RemoveAll();
- } else if(mt.majortype == MEDIATYPE_Audio
- && (mt.subtype == MEDIASUBTYPE_PCM
- || mt.subtype == MEDIASUBTYPE_DVD_LPCM_AUDIO
- || mt.subtype == FOURCCMap(WAVE_FORMAT_EXTENSIBLE)
- || mt.subtype == FOURCCMap(WAVE_FORMAT_IEEE_FLOAT))
- && mt.formattype == FORMAT_WaveFormatEx) {
+ } else if (mt.majortype == MEDIATYPE_Audio
+ && (mt.subtype == MEDIASUBTYPE_PCM
+ || mt.subtype == MEDIASUBTYPE_DVD_LPCM_AUDIO
+ || mt.subtype == FOURCCMap(WAVE_FORMAT_EXTENSIBLE)
+ || mt.subtype == FOURCCMap(WAVE_FORMAT_IEEE_FLOAT))
+ && mt.formattype == FORMAT_WaveFormatEx) {
pBitStream->BitWrite('RIFF', 32);
pBitStream->BitWrite(0, 32); // file length - 8, set later
pBitStream->BitWrite('WAVE', 32);
@@ -199,46 +199,46 @@ void CBaseMuxerRawOutputPin::MuxHeader(const CMediaType& mt) void CBaseMuxerRawOutputPin::MuxPacket(const CMediaType& mt, const MuxerPacket* pPacket)
{
CComQIPtr<IBitStream> pBitStream = GetBitStream();
- if(!pBitStream) {
+ if (!pBitStream) {
return;
}
const BYTE* pData = pPacket->pData.GetData();
const int DataSize = int(pPacket->pData.GetCount());
- if(mt.subtype == MEDIASUBTYPE_AAC && mt.formattype == FORMAT_WaveFormatEx) {
+ if (mt.subtype == MEDIASUBTYPE_AAC && mt.formattype == FORMAT_WaveFormatEx) {
WAVEFORMATEX* wfe = (WAVEFORMATEX*)mt.Format();
int profile = 0;
int srate_idx = 11;
- if(92017 <= wfe->nSamplesPerSec) {
+ if (92017 <= wfe->nSamplesPerSec) {
srate_idx = 0;
- } else if(75132 <= wfe->nSamplesPerSec) {
+ } else if (75132 <= wfe->nSamplesPerSec) {
srate_idx = 1;
- } else if(55426 <= wfe->nSamplesPerSec) {
+ } else if (55426 <= wfe->nSamplesPerSec) {
srate_idx = 2;
- } else if(46009 <= wfe->nSamplesPerSec) {
+ } else if (46009 <= wfe->nSamplesPerSec) {
srate_idx = 3;
- } else if(37566 <= wfe->nSamplesPerSec) {
+ } else if (37566 <= wfe->nSamplesPerSec) {
srate_idx = 4;
- } else if(27713 <= wfe->nSamplesPerSec) {
+ } else if (27713 <= wfe->nSamplesPerSec) {
srate_idx = 5;
- } else if(23004 <= wfe->nSamplesPerSec) {
+ } else if (23004 <= wfe->nSamplesPerSec) {
srate_idx = 6;
- } else if(18783 <= wfe->nSamplesPerSec) {
+ } else if (18783 <= wfe->nSamplesPerSec) {
srate_idx = 7;
- } else if(13856 <= wfe->nSamplesPerSec) {
+ } else if (13856 <= wfe->nSamplesPerSec) {
srate_idx = 8;
- } else if(11502 <= wfe->nSamplesPerSec) {
+ } else if (11502 <= wfe->nSamplesPerSec) {
srate_idx = 9;
- } else if(9391 <= wfe->nSamplesPerSec) {
+ } else if (9391 <= wfe->nSamplesPerSec) {
srate_idx = 10;
}
int channels = wfe->nChannels;
- if(wfe->cbSize >= 2) {
+ if (wfe->cbSize >= 2) {
BYTE* p = (BYTE*)(wfe+1);
profile = (p[0]>>3)-1;
srate_idx = ((p[0]&7)<<1)|((p[1]&0x80)>>7);
@@ -255,22 +255,22 @@ void CBaseMuxerRawOutputPin::MuxPacket(const CMediaType& mt, const MuxerPacket* hdr[6] = 0xfc;
pBitStream->ByteWrite(hdr, sizeof(hdr));
- } else if((mt.subtype == FOURCCMap('1CVA') || mt.subtype == FOURCCMap('1cva')) && mt.formattype == FORMAT_MPEG2_VIDEO) {
+ } else if ((mt.subtype == FOURCCMap('1CVA') || mt.subtype == FOURCCMap('1cva')) && mt.formattype == FORMAT_MPEG2_VIDEO) {
const BYTE* p = pData;
int i = DataSize;
- while(i >= 4) {
+ while (i >= 4) {
DWORD len = (p[0]<<24)|(p[1]<<16)|(p[2]<<8)|p[3];
i -= len + 4;
p += len + 4;
}
- if(i == 0) {
+ if (i == 0) {
p = pData;
i = DataSize;
- while(i >= 4) {
+ while (i >= 4) {
DWORD len = (p[0]<<24)|(p[1]<<16)|(p[2]<<8)|p[3];
pBitStream->BitWrite(0x00000001, 32);
@@ -278,7 +278,7 @@ void CBaseMuxerRawOutputPin::MuxPacket(const CMediaType& mt, const MuxerPacket* p += 4;
i -= 4;
- if(len > i || len == 1) {
+ if (len > i || len == 1) {
len = i;
ASSERT(0);
}
@@ -291,10 +291,10 @@ void CBaseMuxerRawOutputPin::MuxPacket(const CMediaType& mt, const MuxerPacket* return;
}
- } else if(mt.subtype == MEDIASUBTYPE_UTF8 || mt.majortype == MEDIATYPE_Text) {
+ } else if (mt.subtype == MEDIASUBTYPE_UTF8 || mt.majortype == MEDIATYPE_Text) {
CStringA str((char*)pData, DataSize);
str.Trim();
- if(str.IsEmpty()) {
+ if (str.IsEmpty()) {
return;
}
@@ -310,10 +310,10 @@ void CBaseMuxerRawOutputPin::MuxPacket(const CMediaType& mt, const MuxerPacket* pBitStream->StrWrite(str, true);
return;
- } else if(mt.subtype == MEDIASUBTYPE_SSA || mt.subtype == MEDIASUBTYPE_ASS || mt.subtype == MEDIASUBTYPE_ASS2) {
+ } else if (mt.subtype == MEDIASUBTYPE_SSA || mt.subtype == MEDIASUBTYPE_ASS || mt.subtype == MEDIASUBTYPE_ASS2) {
CStringA str((char*)pData, DataSize);
str.Trim();
- if(str.IsEmpty()) {
+ if (str.IsEmpty()) {
return;
}
@@ -324,7 +324,7 @@ void CBaseMuxerRawOutputPin::MuxPacket(const CMediaType& mt, const MuxerPacket* CAtlList<CStringA> sl;
Explode(str, sl, ',', fields);
- if(sl.GetCount() < fields) {
+ if (sl.GetCount() < fields) {
return;
}
@@ -335,13 +335,13 @@ void CBaseMuxerRawOutputPin::MuxPacket(const CMediaType& mt, const MuxerPacket* CStringA left = sl.RemoveHead();
CStringA right = sl.RemoveHead();
CStringA top = sl.RemoveHead();
- if(fields == 10) {
+ if (fields == 10) {
top += ',' + sl.RemoveHead(); // bottom
}
CStringA effect = sl.RemoveHead();
str = sl.RemoveHead();
- if(mt.subtype == MEDIASUBTYPE_SSA) {
+ if (mt.subtype == MEDIASUBTYPE_SSA) {
layer = "Marked=0";
}
@@ -355,15 +355,15 @@ void CBaseMuxerRawOutputPin::MuxPacket(const CMediaType& mt, const MuxerPacket* pBitStream->StrWrite(str, true);
return;
- } else if(mt.subtype == MEDIASUBTYPE_SSF) {
+ } else if (mt.subtype == MEDIASUBTYPE_SSF) {
float start = (float)pPacket->rtStart / 10000000;
float stop = (float)pPacket->rtStop / 10000000;
m_ssf.Append(ssf::WCharInputStream(UTF8To16(CStringA((char*)pData, DataSize))), start, stop, true);
return;
- } else if(mt.subtype == MEDIASUBTYPE_VOBSUB) {
+ } else if (mt.subtype == MEDIASUBTYPE_VOBSUB) {
bool fTimeValid = pPacket->IsTimeValid();
- if(fTimeValid) {
+ if (fTimeValid) {
idx_t i;
i.rt = pPacket->rtStart;
i.fp = pBitStream->GetPos();
@@ -372,7 +372,7 @@ void CBaseMuxerRawOutputPin::MuxPacket(const CMediaType& mt, const MuxerPacket* int DataSizeLeft = DataSize;
- while(DataSizeLeft > 0) {
+ while (DataSizeLeft > 0) {
int BytesAvail = 0x7ec - (fTimeValid ? 9 : 4);
int Size = min(BytesAvail, DataSizeLeft);
int Padding = 0x800 - Size - 20 - (fTimeValid ? 9 : 4);
@@ -382,7 +382,7 @@ void CBaseMuxerRawOutputPin::MuxPacket(const CMediaType& mt, const MuxerPacket* pBitStream->BitWrite(0x000003f8, 32);
pBitStream->BitWrite(0x000001bd, 32);
- if(fTimeValid) {
+ if (fTimeValid) {
pBitStream->BitWrite(Size+9, 16);
pBitStream->BitWrite(0x8180052100010001ui64, 64);
} else {
@@ -397,12 +397,12 @@ void CBaseMuxerRawOutputPin::MuxPacket(const CMediaType& mt, const MuxerPacket* pData += Size;
DataSizeLeft -= Size;
- if(Padding > 0) {
+ if (Padding > 0) {
Padding -= 6;
ASSERT(Padding >= 0);
pBitStream->BitWrite(0x000001be, 32);
pBitStream->BitWrite(Padding, 16);
- while(Padding-- > 0) {
+ while (Padding-- > 0) {
pBitStream->BitWrite(0xff, 8);
}
}
@@ -411,12 +411,12 @@ void CBaseMuxerRawOutputPin::MuxPacket(const CMediaType& mt, const MuxerPacket* }
return;
- } else if(mt.subtype == MEDIASUBTYPE_DVD_LPCM_AUDIO) {
+ } else if (mt.subtype == MEDIASUBTYPE_DVD_LPCM_AUDIO) {
WAVEFORMATEX* wfe = (WAVEFORMATEX*)mt.Format();
// This code is probably totally broken for anything but 16 bits
- for(int i = 0, bps = wfe->wBitsPerSample/8; i < DataSize; i += bps)
- for(int j = bps-1; j >= 0; j--) {
+ for (int i = 0, bps = wfe->wBitsPerSample/8; i < DataSize; i += bps)
+ for (int j = bps-1; j >= 0; j--) {
pBitStream->BitWrite(pData[i+j], 8);
}
@@ -430,11 +430,11 @@ void CBaseMuxerRawOutputPin::MuxPacket(const CMediaType& mt, const MuxerPacket* void CBaseMuxerRawOutputPin::MuxFooter(const CMediaType& mt)
{
CComQIPtr<IBitStream> pBitStream = GetBitStream();
- if(!pBitStream) {
+ if (!pBitStream) {
return;
}
- if(mt.majortype == MEDIATYPE_Audio
+ if (mt.majortype == MEDIATYPE_Audio
&& (mt.subtype == MEDIASUBTYPE_PCM
|| mt.subtype == MEDIASUBTYPE_DVD_LPCM_AUDIO
|| mt.subtype == FOURCCMap(WAVE_FORMAT_EXTENSIBLE)
@@ -452,22 +452,22 @@ void CBaseMuxerRawOutputPin::MuxFooter(const CMediaType& mt) size -= sizeof(RIFFLIST) + sizeof(RIFFCHUNK) + mt.FormatLength();
pBitStream->Seek(sizeof(RIFFLIST) + sizeof(RIFFCHUNK) + mt.FormatLength() + 4);
pBitStream->ByteWrite(&size, 4);
- } else if(mt.subtype == MEDIASUBTYPE_SSF) {
+ } else if (mt.subtype == MEDIASUBTYPE_SSF) {
ssf::WCharOutputStream s;
try {
m_ssf.Dump(s);
- } catch(ssf::Exception&) {}
+ } catch (ssf::Exception&) {}
CStringA str = UTF16To8(s.GetString());
pBitStream->StrWrite(str, true);
- } else if(mt.subtype == MEDIASUBTYPE_VOBSUB) {
- if(CComQIPtr<IFileSinkFilter> pFSF = GetFilterFromPin(GetConnected())) {
+ } else if (mt.subtype == MEDIASUBTYPE_VOBSUB) {
+ if (CComQIPtr<IFileSinkFilter> pFSF = GetFilterFromPin(GetConnected())) {
WCHAR* fn = NULL;
- if(SUCCEEDED(pFSF->GetCurFile(&fn, NULL))) {
+ if (SUCCEEDED(pFSF->GetCurFile(&fn, NULL))) {
CPathW p(fn);
p.RenameExtension(L".idx");
CoTaskMemFree(fn);
- if(FILE* f = _tfopen(CString((LPCWSTR)p), _T("w"))) {
+ if (FILE* f = _tfopen(CString((LPCWSTR)p), _T("w"))) {
SUBTITLEINFO* si = (SUBTITLEINFO*)mt.Format();
_ftprintf(f, _T("%s\n"), _T("# VobSub index file, v7 (do not modify this line!)"));
@@ -475,18 +475,18 @@ void CBaseMuxerRawOutputPin::MuxFooter(const CMediaType& mt) fwrite(mt.Format() + si->dwOffset, mt.FormatLength() - si->dwOffset, 1, f);
CString iso6391 = ISO6392To6391(si->IsoLang);
- if(iso6391.IsEmpty()) {
+ if (iso6391.IsEmpty()) {
iso6391 = _T("--");
}
_ftprintf(f, _T("\nlangidx: 0\n\nid: %s, index: 0\n"), iso6391);
CString alt = CString(CStringW(si->TrackName));
- if(!alt.IsEmpty()) {
+ if (!alt.IsEmpty()) {
_ftprintf(f, _T("alt: %s\n"), alt);
}
POSITION pos = m_idx.GetHeadPosition();
- while(pos) {
+ while (pos) {
const idx_t& i = m_idx.GetNext(pos);
DVD_HMSF_TIMECODE start = RT2HMSF(i.rt, 25);
_ftprintf(f, _T("timestamp: %02d:%02d:%02d:%03d, filepos: %09I64x\n"),
diff --git a/src/filters/muxer/BaseMuxer/BitStream.cpp b/src/filters/muxer/BaseMuxer/BitStream.cpp index 355cc19ff..902e32c17 100644 --- a/src/filters/muxer/BaseMuxer/BitStream.cpp +++ b/src/filters/muxer/BaseMuxer/BitStream.cpp @@ -87,12 +87,12 @@ STDMETHODIMP CBitStream::ByteWrite(const void* pData, int len) BitFlush();
- if(len > 0) {
+ if (len > 0) {
ULONG cbWritten = 0;
hr = m_pStream->Write(pData, len, &cbWritten);
ASSERT(SUCCEEDED(hr));
- if(m_fThrowError && FAILED(hr)) {
+ if (m_fThrowError && FAILED(hr)) {
throw hr;
}
}
@@ -106,7 +106,7 @@ STDMETHODIMP CBitStream::BitWrite(UINT64 data, int len) ASSERT(len >= 0 && len <= 64);
- if(len > 56) {
+ if (len > 56) {
BitWrite(data >> 56, len - 56);
len = 56;
}
@@ -115,13 +115,13 @@ STDMETHODIMP CBitStream::BitWrite(UINT64 data, int len) m_bitbuff |= data & ((1ui64 << len) - 1);
m_bitlen += len;
- while(m_bitlen >= 8) {
+ while (m_bitlen >= 8) {
BYTE b = (BYTE)(m_bitbuff >> (m_bitlen - 8));
hr = m_pStream->Write(&b, 1, NULL);
m_bitlen -= 8;
ASSERT(SUCCEEDED(hr));
- if(m_fThrowError && FAILED(hr)) {
+ if (m_fThrowError && FAILED(hr)) {
throw E_FAIL;
}
}
@@ -133,14 +133,14 @@ STDMETHODIMP CBitStream::BitFlush() {
HRESULT hr = S_OK;
- if(m_bitlen > 0) {
+ if (m_bitlen > 0) {
ASSERT(m_bitlen < 8);
BYTE b = (BYTE)(m_bitbuff << (8 - m_bitlen));
hr = m_pStream->Write(&b, 1, NULL);
m_bitlen = 0;
ASSERT(SUCCEEDED(hr));
- if(m_fThrowError && FAILED(hr)) {
+ if (m_fThrowError && FAILED(hr)) {
throw E_FAIL;
}
}
@@ -152,7 +152,7 @@ STDMETHODIMP CBitStream::StrWrite(LPCSTR pData, BOOL bFixNewLine) {
CStringA str = pData;
- if(bFixNewLine) {
+ if (bFixNewLine) {
str.Replace("\r", "");
str.Replace("\n", "\r\n");
}
diff --git a/src/filters/muxer/DSMMuxer/DSMMuxer.cpp b/src/filters/muxer/DSMMuxer/DSMMuxer.cpp index ecf02d6bb..1e9a8c6c8 100644 --- a/src/filters/muxer/DSMMuxer/DSMMuxer.cpp +++ b/src/filters/muxer/DSMMuxer/DSMMuxer.cpp @@ -73,7 +73,7 @@ template<typename T> static T myabs(T n) static int GetByteLength(UINT64 data, int min = 0)
{
int i = 7;
- while(i >= min && ((BYTE*)&data)[i] == 0) {
+ while (i >= min && ((BYTE*)&data)[i] == 0) {
i--;
}
return ++i;
@@ -88,7 +88,7 @@ CDSMMuxerFilter::CDSMMuxerFilter(LPUNKNOWN pUnk, HRESULT* phr, bool fAutoChap, b , m_fAutoChap(fAutoChap)
, m_fAutoRes(fAutoRes)
{
- if(phr) {
+ if (phr) {
*phr = S_OK;
}
}
@@ -124,9 +124,9 @@ void CDSMMuxerFilter::MuxFileInfo(IBitStream* pBS) int len = 1;
CSimpleMap<CStringA, CStringA> si;
- for(int i = 0; i < GetSize(); i++) {
+ for (int i = 0; i < GetSize(); i++) {
CStringA key = CStringA(CString(GetKeyAt(i))), value = UTF16To8(GetValueAt(i));
- if(key.GetLength() != 4) {
+ if (key.GetLength() != 4) {
continue;
}
si.Add(key, value);
@@ -135,7 +135,7 @@ void CDSMMuxerFilter::MuxFileInfo(IBitStream* pBS) MuxPacketHeader(pBS, DSMP_FILEINFO, len);
pBS->BitWrite(DSMF_VERSION, 8);
- for(int i = 0; i < si.GetSize(); i++) {
+ for (int i = 0; i < si.GetSize(); i++) {
CStringA key = si.GetKeyAt(i), value = si.GetValueAt(i);
pBS->ByteWrite((LPCSTR)key, 4);
pBS->ByteWrite((LPCSTR)value, value.GetLength()+1);
@@ -148,19 +148,19 @@ void CDSMMuxerFilter::MuxStreamInfo(IBitStream* pBS, CBaseMuxerInputPin* pPin) int len = 1;
CSimpleMap<CStringA, CStringA> si;
- for(int i = 0; i < pPin->GetSize(); i++) {
+ for (int i = 0; i < pPin->GetSize(); i++) {
CStringA key = CStringA(CString(pPin->GetKeyAt(i))), value = UTF16To8(pPin->GetValueAt(i));
- if(key.GetLength() != 4) {
+ if (key.GetLength() != 4) {
continue;
}
si.Add(key, value);
len += 4 + value.GetLength() + 1;
}
- if(len > 1) {
+ if (len > 1) {
MuxPacketHeader(pBS, DSMP_STREAMINFO, len);
pBS->BitWrite(pPin->GetID(), 8);
- for(int i = 0; i < si.GetSize(); i++) {
+ for (int i = 0; i < si.GetSize(); i++) {
CStringA key = si.GetKeyAt(i), value = si.GetValueAt(i);
pBS->ByteWrite((LPCSTR)key, 4);
pBS->ByteWrite((LPCSTR)value, value.GetLength()+1);
@@ -186,7 +186,7 @@ void CDSMMuxerFilter::MuxHeader(IBitStream* pBS) MuxFileInfo(pBS);
POSITION pos = m_pPins.GetHeadPosition();
- while(pos) {
+ while (pos) {
CBaseMuxerInputPin* pPin = m_pPins.GetNext(pos);
const CMediaType& mt = pPin->CurrentMediaType();
@@ -213,17 +213,17 @@ void CDSMMuxerFilter::MuxHeader(IBitStream* pBS) CComQIPtr<IDSMChapterBag> pCB = (IUnknown*)(INonDelegatingUnknown*)this;
pos = m_pPins.GetHeadPosition();
- while(pos) {
- for(CComPtr<IPin> pPin = m_pPins.GetNext(pos)->GetConnected(); pPin; pPin = GetUpStreamPin(GetFilterFromPin(pPin))) {
- if(m_fAutoRes) {
+ while (pos) {
+ for (CComPtr<IPin> pPin = m_pPins.GetNext(pos)->GetConnected(); pPin; pPin = GetUpStreamPin(GetFilterFromPin(pPin))) {
+ if (m_fAutoRes) {
CComQIPtr<IDSMResourceBag> pPB = GetFilterFromPin(pPin);
- if(pPB && !pRBs.Find(pPB)) {
+ if (pPB && !pRBs.Find(pPB)) {
pRBs.AddTail(pPB);
}
}
- if(m_fAutoChap) {
- if(!pCB || pCB->ChapGetCount() == 0) {
+ if (m_fAutoChap) {
+ if (!pCB || pCB->ChapGetCount() == 0) {
pCB = GetFilterFromPin(pPin);
}
}
@@ -233,14 +233,14 @@ void CDSMMuxerFilter::MuxHeader(IBitStream* pBS) // resources
pos = pRBs.GetHeadPosition();
- while(pos) {
+ while (pos) {
IDSMResourceBag* pRB = pRBs.GetNext(pos);
- for(DWORD i = 0, j = pRB->ResGetCount(); i < j; i++) {
+ for (DWORD i = 0, j = pRB->ResGetCount(); i < j; i++) {
CComBSTR name, desc, mime;
BYTE* pData = NULL;
DWORD len = 0;
- if(SUCCEEDED(pRB->ResGet(i, &name, &desc, &mime, &pData, &len, NULL))) {
+ if (SUCCEEDED(pRB->ResGet(i, &name, &desc, &mime, &pData, &len, NULL))) {
CStringA utf8_name = UTF16To8(name);
CStringA utf8_desc = UTF16To8(desc);
CStringA utf8_mime = UTF16To8(mime);
@@ -266,17 +266,17 @@ void CDSMMuxerFilter::MuxHeader(IBitStream* pBS) // chapters
- if(pCB) {
+ if (pCB) {
CAtlList<CDSMChapter> chapters;
REFERENCE_TIME rtPrev = 0;
int len = 0;
pCB->ChapSort();
- for(DWORD i = 0; i < pCB->ChapGetCount(); i++) {
+ for (DWORD i = 0; i < pCB->ChapGetCount(); i++) {
CDSMChapter c;
CComBSTR name;
- if(SUCCEEDED(pCB->ChapGet(i, &c.rt, &name))) {
+ if (SUCCEEDED(pCB->ChapGet(i, &c.rt, &name))) {
REFERENCE_TIME rtDiff = c.rt - rtPrev;
rtPrev = c.rt;
c.rt = rtDiff;
@@ -286,11 +286,11 @@ void CDSMMuxerFilter::MuxHeader(IBitStream* pBS) }
}
- if(chapters.GetCount()) {
+ if (chapters.GetCount()) {
MuxPacketHeader(pBS, DSMP_CHAPTERS, len);
pos = chapters.GetHeadPosition();
- while(pos) {
+ while (pos) {
CDSMChapter& c = chapters.GetNext(pos);
CStringA name = UTF16To8(c.name);
int irt = GetByteLength(myabs(c.rt));
@@ -306,17 +306,17 @@ void CDSMMuxerFilter::MuxHeader(IBitStream* pBS) void CDSMMuxerFilter::MuxPacket(IBitStream* pBS, const MuxerPacket* pPacket)
{
- if(pPacket->IsEOS()) {
+ if (pPacket->IsEOS()) {
return;
}
- if(pPacket->pPin->CurrentMediaType().majortype == MEDIATYPE_Text) {
+ if (pPacket->pPin->CurrentMediaType().majortype == MEDIATYPE_Text) {
CStringA str((char*)pPacket->pData.GetData(), pPacket->pData.GetCount());
str.Replace("\xff", " ");
str.Replace(" ", " ");
str.Replace(" ", " ");
str.Trim();
- if(str.IsEmpty()) {
+ if (str.IsEmpty()) {
return;
}
}
@@ -326,7 +326,7 @@ void CDSMMuxerFilter::MuxPacket(IBitStream* pBS, const MuxerPacket* pPacket) REFERENCE_TIME rtTimeStamp = _I64_MIN, rtDuration = 0;
int iTimeStamp = 0, iDuration = 0;
- if(pPacket->IsTimeValid()) {
+ if (pPacket->IsTimeValid()) {
rtTimeStamp = pPacket->rtStart;
rtDuration = max(pPacket->rtStop - pPacket->rtStart, 0);
@@ -362,7 +362,7 @@ void CDSMMuxerFilter::MuxFooter(IBitStream* pBS) UINT64 fpPrev = 0, fp;
POSITION pos = m_isps.GetHeadPosition();
- while(pos) {
+ while (pos) {
IndexedSyncPoint& isp = m_isps.GetNext(pos);
TRACE(_T("sp[%d]: %I64d %I64x\n"), isp.id, isp.rt, isp.fp);
@@ -382,7 +382,7 @@ void CDSMMuxerFilter::MuxFooter(IBitStream* pBS) MuxPacketHeader(pBS, DSMP_SYNCPOINTS, len);
pos = isps.GetHeadPosition();
- while(pos) {
+ while (pos) {
IndexedSyncPoint& isp = isps.GetNext(pos);
int irt = GetByteLength(myabs(isp.rt));
@@ -405,7 +405,7 @@ void CDSMMuxerFilter::IndexSyncPoint(const MuxerPacket* p, __int64 fp) // FIXME: the very last syncpoints won't get moved to m_isps because there are no more syncpoints to trigger it!
- if(fp < 0 || !p || !p->IsTimeValid() || !p->IsSyncPoint()) {
+ if (fp < 0 || !p || !p->IsTimeValid() || !p->IsSyncPoint()) {
return;
}
@@ -423,7 +423,7 @@ void CDSMMuxerFilter::IndexSyncPoint(const MuxerPacket* p, __int64 fp) SyncPoint& tail = !m_sps.IsEmpty() ? m_sps.GetTail() : sp;
REFERENCE_TIME rtfp = !m_isps.IsEmpty() ? m_isps.GetTail().rtfp : _I64_MIN;
- if(head.rtStart > rtfp + 1000000) { // 100ms limit, just in case every stream had only keyframes, then sycnpoints would be too frequent
+ if (head.rtStart > rtfp + 1000000) { // 100ms limit, just in case every stream had only keyframes, then sycnpoints would be too frequent
IndexedSyncPoint isp;
isp.id = head.id;
isp.rt = tail.rtStart;
@@ -434,10 +434,10 @@ void CDSMMuxerFilter::IndexSyncPoint(const MuxerPacket* p, __int64 fp) }
POSITION pos = m_sps.GetHeadPosition();
- while(pos) {
+ while (pos) {
POSITION cur = pos;
SyncPoint& sp2 = m_sps.GetNext(pos);
- if(sp2.id == sp.id && sp2.rtStop <= sp.rtStop || sp2.rtStop <= sp.rtStart) {
+ if (sp2.id == sp.id && sp2.rtStop <= sp.rtStop || sp2.rtStop <= sp.rtStart) {
m_sps.RemoveAt(cur);
}
}
diff --git a/src/filters/muxer/MatroskaMuxer/MatroskaFile.cpp b/src/filters/muxer/MatroskaMuxer/MatroskaFile.cpp index 14660e5b9..3eabda81f 100644 --- a/src/filters/muxer/MatroskaMuxer/MatroskaFile.cpp +++ b/src/filters/muxer/MatroskaMuxer/MatroskaFile.cpp @@ -27,7 +27,7 @@ using namespace MatroskaWriter; static void bswap(BYTE* s, int len)
{
- for(BYTE* d = s + len-1; s < d; s++, d--) {
+ for (BYTE* d = s + len-1; s < d; s++, d--) {
*s ^= *d, *d ^= *s, *s ^= *d;
}
}
@@ -66,13 +66,13 @@ HRESULT CID::HeaderWrite(IStream* pStream) MatroskaWriter::QWORD CBinary::Size(bool fWithHeader)
{
- if(GetCount() == 0) {
+ if (GetCount() == 0) {
return 0;
}
MatroskaWriter::QWORD len = 0;
len += GetCount();
- if(fWithHeader) {
+ if (fWithHeader) {
len += HeaderSize(len);
}
return len;
@@ -80,7 +80,7 @@ MatroskaWriter::QWORD CBinary::Size(bool fWithHeader) HRESULT CBinary::Write(IStream* pStream)
{
- if(GetCount() == 0) {
+ if (GetCount() == 0) {
return S_OK;
}
@@ -90,13 +90,13 @@ HRESULT CBinary::Write(IStream* pStream) MatroskaWriter::QWORD CANSI::Size(bool fWithHeader)
{
- if(GetLength() == 0) {
+ if (GetLength() == 0) {
return 0;
}
MatroskaWriter::QWORD len = 0;
len += GetLength();
- if(fWithHeader) {
+ if (fWithHeader) {
len += HeaderSize(len);
}
return len;
@@ -104,7 +104,7 @@ MatroskaWriter::QWORD CANSI::Size(bool fWithHeader) HRESULT CANSI::Write(IStream* pStream)
{
- if(GetLength() == 0) {
+ if (GetLength() == 0) {
return S_OK;
}
@@ -114,13 +114,13 @@ HRESULT CANSI::Write(IStream* pStream) MatroskaWriter::QWORD CUTF8::Size(bool fWithHeader)
{
- if(GetLength() == 0) {
+ if (GetLength() == 0) {
return 0;
}
MatroskaWriter::QWORD len = 0;
len += UTF16To8(*this).GetLength();
- if(fWithHeader) {
+ if (fWithHeader) {
len += HeaderSize(len);
}
return len;
@@ -128,7 +128,7 @@ MatroskaWriter::QWORD CUTF8::Size(bool fWithHeader) HRESULT CUTF8::Write(IStream* pStream)
{
- if(GetLength() == 0) {
+ if (GetLength() == 0) {
return S_OK;
}
@@ -140,13 +140,13 @@ HRESULT CUTF8::Write(IStream* pStream) template<class T, class BASE>
MatroskaWriter::QWORD CSimpleVar<T, BASE>::Size(bool fWithHeader)
{
- if(!m_fSet) {
+ if (!m_fSet) {
return 0;
}
MatroskaWriter::QWORD len = 0;
len += sizeof(T);
- if(fWithHeader) {
+ if (fWithHeader) {
len += HeaderSize(len);
}
return len;
@@ -155,7 +155,7 @@ MatroskaWriter::QWORD CSimpleVar<T, BASE>::Size(bool fWithHeader) template<class T, class BASE>
HRESULT CSimpleVar<T, BASE>::Write(IStream* pStream)
{
- if(!m_fSet) {
+ if (!m_fSet) {
return S_OK;
}
@@ -167,23 +167,23 @@ HRESULT CSimpleVar<T, BASE>::Write(IStream* pStream) MatroskaWriter::QWORD CUInt::Size(bool fWithHeader)
{
- if(!m_fSet) {
+ if (!m_fSet) {
return 0;
}
MatroskaWriter::QWORD len = 0;
- if(m_val == 0) {
+ if (m_val == 0) {
len++;
} else {
- for(int i = 8; i > 0; i--) {
- if(((0xffi64<<((i-1)*8))&m_val)) {
+ for (int i = 8; i > 0; i--) {
+ if (((0xffi64<<((i-1)*8))&m_val)) {
len += i;
break;
}
}
}
- if(fWithHeader) {
+ if (fWithHeader) {
len += HeaderSize(len);
}
return len;
@@ -191,7 +191,7 @@ MatroskaWriter::QWORD CUInt::Size(bool fWithHeader) HRESULT CUInt::Write(IStream* pStream)
{
- if(!m_fSet) {
+ if (!m_fSet) {
return S_OK;
}
@@ -205,27 +205,27 @@ HRESULT CUInt::Write(IStream* pStream) MatroskaWriter::QWORD CInt::Size(bool fWithHeader)
{
- if(!m_fSet) {
+ if (!m_fSet) {
return 0;
}
MatroskaWriter::QWORD len = 0;
- if(m_val == 0) {
+ if (m_val == 0) {
len++;
} else {
UINT64 val = m_val >= 0 ? m_val : -m_val;
- for(int i = 8; i > 0; i--) {
- if(((0xffi64<<((i-1)*8))&val)) {
+ for (int i = 8; i > 0; i--) {
+ if (((0xffi64<<((i-1)*8))&val)) {
len += i;
- if(m_val < 0 && !(m_val&(0x80<<(i-1)))) {
+ if (m_val < 0 && !(m_val&(0x80<<(i-1)))) {
len++;
}
break;
}
}
}
- if(fWithHeader) {
+ if (fWithHeader) {
len += HeaderSize(len);
}
return len;
@@ -233,7 +233,7 @@ MatroskaWriter::QWORD CInt::Size(bool fWithHeader) HRESULT CInt::Write(IStream* pStream)
{
- if(!m_fSet) {
+ if (!m_fSet) {
return S_OK;
}
@@ -247,13 +247,13 @@ HRESULT CInt::Write(IStream* pStream) MatroskaWriter::QWORD CLength::Size(bool fWithHeader)
{
- if(m_len == 0x00FFFFFFFFFFFFFFi64) {
+ if (m_len == 0x00FFFFFFFFFFFFFFi64) {
return 8;
}
MatroskaWriter::QWORD len = 0;
- for(int i = 1; i <= 8; i++) {
- if(!(m_len&(~((1i64<<(7*i))-1))) && (m_len&((1i64<<(7*i))-1)) != ((1i64<<(7*i))-1)) {
+ for (int i = 1; i <= 8; i++) {
+ if (!(m_len&(~((1i64<<(7*i))-1))) && (m_len&((1i64<<(7*i))-1)) != ((1i64<<(7*i))-1)) {
len += i;
break;
}
@@ -294,7 +294,7 @@ MatroskaWriter::QWORD EBML::Size(bool fWithHeader) len += DocType.Size();
len += DocTypeVersion.Size();
len += DocTypeReadVersion.Size();
- if(fWithHeader) {
+ if (fWithHeader) {
len += HeaderSize(len);
}
return len;
@@ -345,7 +345,7 @@ MatroskaWriter::QWORD Info::Size(bool fWithHeader) len += Title.Size();
len += MuxingApp.Size();
len += WritingApp.Size();
- if(fWithHeader) {
+ if (fWithHeader) {
len += HeaderSize(len);
}
return len;
@@ -399,7 +399,7 @@ MatroskaWriter::QWORD Track::Size(bool fWithHeader) {
MatroskaWriter::QWORD len = 0;
len += TrackEntries.Size();
- if(fWithHeader) {
+ if (fWithHeader) {
len += HeaderSize(len);
}
return len;
@@ -461,13 +461,13 @@ MatroskaWriter::QWORD TrackEntry::Size(bool fWithHeader) len += CodecDecodeAll.Size();
len += TrackOverlay.Size();
len += DefaultDuration.Size();
- if(DescType == TypeVideo) {
+ if (DescType == TypeVideo) {
len += v.Size();
}
- if(DescType == TypeAudio) {
+ if (DescType == TypeAudio) {
len += a.Size();
}
- if(fWithHeader) {
+ if (fWithHeader) {
len += HeaderSize(len);
}
return len;
@@ -495,10 +495,10 @@ HRESULT TrackEntry::Write(IStream* pStream) CodecDecodeAll.Write(pStream);
TrackOverlay.Write(pStream);
DefaultDuration.Write(pStream);
- if(DescType == TypeVideo) {
+ if (DescType == TypeVideo) {
v.Write(pStream);
}
- if(DescType == TypeAudio) {
+ if (DescType == TypeAudio) {
a.Write(pStream);
}
return S_OK;
@@ -534,7 +534,7 @@ MatroskaWriter::QWORD Video::Size(bool fWithHeader) len += ColourSpace.Size();
len += GammaValue.Size();
len += FramePerSec.Size();
- if(fWithHeader) {
+ if (fWithHeader) {
len += HeaderSize(len);
}
return len;
@@ -575,7 +575,7 @@ MatroskaWriter::QWORD Audio::Size(bool fWithHeader) len += Channels.Size();
len += ChannelPositions.Size();
len += BitDepth.Size();
- if(fWithHeader) {
+ if (fWithHeader) {
len += HeaderSize(len);
}
return len;
@@ -607,7 +607,7 @@ MatroskaWriter::QWORD Cluster::Size(bool fWithHeader) len += Position.Size();
len += PrevSize.Size();
len += BlockGroups.Size();
- if(fWithHeader) {
+ if (fWithHeader) {
len += HeaderSize(len);
}
return len;
@@ -642,7 +642,7 @@ MatroskaWriter::QWORD BlockGroup::Size(bool fWithHeader) len += ReferenceVirtual.Size();
len += CodecState.Size();
len += Block.Size();
- if(fWithHeader) {
+ if (fWithHeader) {
len += HeaderSize(len);
}
return len;
@@ -670,22 +670,22 @@ MatroskaWriter::QWORD CBlock::Size(bool fWithHeader) {
MatroskaWriter::QWORD len = 0;
len += TrackNumber.Size() + 2 + 1; // TrackNumber + TimeCode + Lacing
- if(BlockData.GetCount() > 1) {
+ if (BlockData.GetCount() > 1) {
len += 1; // nBlockData
POSITION pos = BlockData.GetHeadPosition();
- while(pos) {
+ while (pos) {
CBinary* b = BlockData.GetNext(pos);
- if(pos) {
+ if (pos) {
len += b->GetCount()/255 + 1;
}
}
}
POSITION pos = BlockData.GetHeadPosition();
- while(pos) {
+ while (pos) {
CBinary* b = BlockData.GetNext(pos);
len += b->GetCount();
}
- if(fWithHeader) {
+ if (fWithHeader) {
len += HeaderSize(len);
}
return len;
@@ -700,18 +700,18 @@ HRESULT CBlock::Write(IStream* pStream) pStream->Write(&t, 2, NULL);
BYTE Lacing = 0;
BYTE n = BlockData.GetCount();
- if(n > 1) {
+ if (n > 1) {
Lacing |= 2;
}
pStream->Write(&Lacing, 1, NULL);
- if(n > 1) {
+ if (n > 1) {
pStream->Write(&n, 1, NULL);
POSITION pos = BlockData.GetHeadPosition();
- while(pos) {
+ while (pos) {
CBinary* b = BlockData.GetNext(pos);
- if(pos) {
+ if (pos) {
int len = b->GetCount();
- while(len >= 0) {
+ while (len >= 0) {
n = min(len, 255);
pStream->Write(&n, 1, NULL);
len -= 255;
@@ -720,7 +720,7 @@ HRESULT CBlock::Write(IStream* pStream) }
}
POSITION pos = BlockData.GetHeadPosition();
- while(pos) {
+ while (pos) {
CBinary* b = BlockData.GetNext(pos);
pStream->Write(b->GetData(), b->GetCount(), NULL);
}
@@ -736,7 +736,7 @@ MatroskaWriter::QWORD Cue::Size(bool fWithHeader) {
MatroskaWriter::QWORD len = 0;
len += CuePoints.Size();
- if(fWithHeader) {
+ if (fWithHeader) {
len += HeaderSize(len);
}
return len;
@@ -760,7 +760,7 @@ MatroskaWriter::QWORD CuePoint::Size(bool fWithHeader) MatroskaWriter::QWORD len = 0;
len += CueTime.Size();
len += CueTrackPositions.Size();
- if(fWithHeader) {
+ if (fWithHeader) {
len += HeaderSize(len);
}
return len;
@@ -791,7 +791,7 @@ MatroskaWriter::QWORD CueTrackPosition::Size(bool fWithHeader) len += CueBlockNumber.Size();
len += CueCodecState.Size();
// len += CueReferences.Size();
- if(fWithHeader) {
+ if (fWithHeader) {
len += HeaderSize(len);
}
return len;
@@ -817,7 +817,7 @@ MatroskaWriter::QWORD Seek::Size(bool fWithHeader) {
MatroskaWriter::QWORD len = 0;
len += SeekHeads.Size();
- if(fWithHeader) {
+ if (fWithHeader) {
len += HeaderSize(len);
}
return len;
@@ -840,7 +840,7 @@ MatroskaWriter::QWORD SeekID::Size(bool fWithHeader) {
MatroskaWriter::QWORD len = 0;
len += m_id.Size();
- if(fWithHeader) {
+ if (fWithHeader) {
len += HeaderSize(len);
}
return len;
@@ -864,7 +864,7 @@ MatroskaWriter::QWORD SeekHead::Size(bool fWithHeader) MatroskaWriter::QWORD len = 0;
len += ID.Size();
len += Position.Size();
- if(fWithHeader) {
+ if (fWithHeader) {
len += HeaderSize(len);
}
return len;
@@ -887,7 +887,7 @@ MatroskaWriter::QWORD Tags::Size(bool fWithHeader) {
MatroskaWriter::QWORD len = 0;
// len += .Size();
- if(fWithHeader) {
+ if (fWithHeader) {
len += HeaderSize(len);
}
return len;
@@ -910,7 +910,7 @@ MatroskaWriter::QWORD Void::Size(bool fWithHeader) {
MatroskaWriter::QWORD len = 0;
len += m_len;
- if(fWithHeader) {
+ if (fWithHeader) {
len += HeaderSize(len);
}
return len;
@@ -921,7 +921,7 @@ HRESULT Void::Write(IStream* pStream) HeaderWrite(pStream);
BYTE buff[64];
memset(buff, 0x80, sizeof(buff));
- for(int len = (int)m_len; len > 0; len -= sizeof(buff)) {
+ for (int len = (int)m_len; len > 0; len -= sizeof(buff)) {
pStream->Write(buff, (ULONG)min(sizeof(buff), len), NULL);
}
return S_OK;
diff --git a/src/filters/muxer/MatroskaMuxer/MatroskaFile.h b/src/filters/muxer/MatroskaMuxer/MatroskaFile.h index 477d9c990..d34bc7d0b 100644 --- a/src/filters/muxer/MatroskaMuxer/MatroskaFile.h +++ b/src/filters/muxer/MatroskaMuxer/MatroskaFile.h @@ -167,7 +167,7 @@ namespace MatroskaWriter QWORD Size(bool fWithHeader = true) {
QWORD len = 0;
POSITION pos = GetHeadPosition();
- while(pos) {
+ while (pos) {
len += GetNext(pos)->Size(fWithHeader);
}
return len;
@@ -175,7 +175,7 @@ namespace MatroskaWriter HRESULT Write(IStream* pStream) {
HRESULT hr;
POSITION pos = GetHeadPosition();
- while(pos) if(FAILED(hr = GetNext(pos)->Write(pStream))) {
+ while (pos) if (FAILED(hr = GetNext(pos)->Write(pStream))) {
return hr;
}
return S_OK;
diff --git a/src/filters/muxer/MatroskaMuxer/MatroskaMuxer.cpp b/src/filters/muxer/MatroskaMuxer/MatroskaMuxer.cpp index cc1fe52ab..8b8c04f9d 100644 --- a/src/filters/muxer/MatroskaMuxer/MatroskaMuxer.cpp +++ b/src/filters/muxer/MatroskaMuxer/MatroskaMuxer.cpp @@ -75,7 +75,7 @@ CMatroskaMuxerFilter::CMatroskaMuxerFilter(LPUNKNOWN pUnk, HRESULT* phr) , m_rtCurrent(0)
, m_fNegative(true), m_fPositive(false)
{
- if(phr) {
+ if (phr) {
*phr = S_OK;
}
@@ -109,9 +109,9 @@ UINT CMatroskaMuxerFilter::GetTrackNumber(CBasePin* pPin) UINT nTrackNumber = 0;
POSITION pos = m_pInputs.GetHeadPosition();
- while(pos) {
+ while (pos) {
nTrackNumber++;
- if(m_pInputs.GetNext(pos) == pPin) {
+ if (m_pInputs.GetNext(pos) == pPin) {
return nTrackNumber;
}
}
@@ -122,9 +122,9 @@ UINT CMatroskaMuxerFilter::GetTrackNumber(CBasePin* pPin) void CMatroskaMuxerFilter::AddInput()
{
POSITION pos = m_pInputs.GetHeadPosition();
- while(pos) {
+ while (pos) {
CBasePin* pPin = m_pInputs.GetNext(pos);
- if(!pPin->IsConnected()) {
+ if (!pPin->IsConnected()) {
return;
}
}
@@ -146,13 +146,13 @@ CBasePin* CMatroskaMuxerFilter::GetPin(int n) {
CAutoLock cAutoLock(this);
- if(n >= 0 && n < (int)m_pInputs.GetCount()) {
- if(POSITION pos = m_pInputs.FindIndex(n)) {
+ if (n >= 0 && n < (int)m_pInputs.GetCount()) {
+ if (POSITION pos = m_pInputs.FindIndex(n)) {
return m_pInputs.GetAt(pos);
}
}
- if(n == m_pInputs.GetCount() && m_pOutput) {
+ if (n == m_pInputs.GetCount() && m_pOutput) {
return m_pOutput;
}
@@ -165,7 +165,7 @@ STDMETHODIMP CMatroskaMuxerFilter::Stop() HRESULT hr;
- if(FAILED(hr = __super::Stop())) {
+ if (FAILED(hr = __super::Stop())) {
return hr;
}
@@ -182,11 +182,11 @@ STDMETHODIMP CMatroskaMuxerFilter::Pause() HRESULT hr;
- if(FAILED(hr = __super::Pause())) {
+ if (FAILED(hr = __super::Pause())) {
return hr;
}
- if(fs == State_Stopped && m_pOutput) {
+ if (fs == State_Stopped && m_pOutput) {
CAMThread::Create();
CallWorker(CMD_RUN);
}
@@ -200,7 +200,7 @@ STDMETHODIMP CMatroskaMuxerFilter::Run(REFERENCE_TIME tStart) HRESULT hr;
- if(FAILED(hr = __super::Run(tStart))) {
+ if (FAILED(hr = __super::Run(tStart))) {
return hr;
}
@@ -226,7 +226,7 @@ STDMETHODIMP CMatroskaMuxerFilter::GetCapabilities(DWORD* pCapabilities) STDMETHODIMP CMatroskaMuxerFilter::CheckCapabilities(DWORD* pCapabilities)
{
CheckPointer(pCapabilities, E_POINTER);
- if(*pCapabilities == 0) {
+ if (*pCapabilities == 0) {
return S_OK;
}
DWORD caps;
@@ -265,9 +265,9 @@ STDMETHODIMP CMatroskaMuxerFilter::GetDuration(LONGLONG* pDuration) CheckPointer(pDuration, E_POINTER);
*pDuration = 0;
POSITION pos = m_pInputs.GetHeadPosition();
- while(pos) {
+ while (pos) {
REFERENCE_TIME rt = m_pInputs.GetNext(pos)->m_rtDur;
- if(rt > *pDuration) {
+ if (rt > *pDuration) {
*pDuration = rt;
}
}
@@ -353,14 +353,14 @@ DWORD CMatroskaMuxerFilter::ThreadProc() {
CComQIPtr<IStream> pStream;
- if(!m_pOutput || !(pStream = m_pOutput->GetConnected())) {
- while(1) {
+ if (!m_pOutput || !(pStream = m_pOutput->GetConnected())) {
+ while (1) {
DWORD cmd = GetRequest();
- if(cmd == CMD_EXIT) {
+ if (cmd == CMD_EXIT) {
CAMThread::m_hThread = NULL;
}
Reply(S_OK);
- if(cmd == CMD_EXIT) {
+ if (cmd == CMD_EXIT) {
return 0;
}
}
@@ -385,7 +385,7 @@ DWORD CMatroskaMuxerFilter::ThreadProc() // TODO
MatroskaWriter::QWORD voidlen = 100;
- if(rtDur > 0) {
+ if (rtDur > 0) {
voidlen += int(1.0 * rtDur / MAXCLUSTERTIME / 10000 + 0.5) * 20;
} else {
voidlen += int(1.0 * 1000*60*60*24 / MAXCLUSTERTIME + 0.5) * 20; // when no duration is known, allocate for 24 hours (~340k)
@@ -459,17 +459,17 @@ DWORD CMatroskaMuxerFilter::ThreadProc() CAtlList<CMatroskaMuxerInputPin*> pActivePins;
POSITION pos = m_pInputs.GetHeadPosition();
- while(pos) {
+ while (pos) {
CMatroskaMuxerInputPin* pPin = m_pInputs.GetNext(pos);
- if(pPin->IsConnected()) {
+ if (pPin->IsConnected()) {
pActivePins.AddTail(pPin);
}
}
- while(1) {
+ while (1) {
DWORD cmd = GetRequest();
- switch(cmd) {
+ switch (cmd) {
default:
case CMD_EXIT:
CAMThread::m_hThread = NULL;
@@ -484,8 +484,8 @@ DWORD CMatroskaMuxerFilter::ThreadProc() INT64 lastcuetimecode = (INT64)-1;
UINT64 nBlocksInCueTrack = 0;
- while(!CheckRequest(NULL)) {
- if(m_State == State_Paused) {
+ while (!CheckRequest(NULL)) {
+ if (m_State == State_Paused) {
Sleep(10);
continue;
}
@@ -495,28 +495,28 @@ DWORD CMatroskaMuxerFilter::ThreadProc() REFERENCE_TIME rtMin = _I64_MAX;
pos = pActivePins.GetHeadPosition();
- while(pos) {
+ while (pos) {
CMatroskaMuxerInputPin* pTmp = pActivePins.GetNext(pos);
CAutoLock cAutoLock(&pTmp->m_csQueue);
- if(pTmp->m_blocks.GetCount() == 0 && pTmp->m_fEndOfStreamReceived) {
+ if (pTmp->m_blocks.GetCount() == 0 && pTmp->m_fEndOfStreamReceived) {
pActivePins.RemoveAt(pActivePins.Find(pTmp));
continue;
}
- if(pTmp->GetTrackEntry()->TrackType != TrackEntry::TypeSubtitle) {
+ if (pTmp->GetTrackEntry()->TrackType != TrackEntry::TypeSubtitle) {
nPinsNeeded++;
}
- if(pTmp->m_blocks.GetCount() > 0) {
- if(pTmp->GetTrackEntry()->TrackType != TrackEntry::TypeSubtitle) {
+ if (pTmp->m_blocks.GetCount() > 0) {
+ if (pTmp->GetTrackEntry()->TrackType != TrackEntry::TypeSubtitle) {
nPinsGotSomething++;
}
- if(pTmp->m_blocks.GetCount() > 0) {
+ if (pTmp->m_blocks.GetCount() > 0) {
REFERENCE_TIME rt = pTmp->m_blocks.GetHead()->Block.TimeCode;
- if(rt < rtMin) {
+ if (rt < rtMin) {
rtMin = rt;
pPin = pTmp;
}
@@ -524,25 +524,25 @@ DWORD CMatroskaMuxerFilter::ThreadProc() }
}
- if(pActivePins.GetCount() == 0) {
+ if (pActivePins.GetCount() == 0) {
break;
}
- if(!pPin || nPinsNeeded > nPinsGotSomething || !pPin && nPinsGotSomething == 0) {
+ if (!pPin || nPinsNeeded > nPinsGotSomething || !pPin && nPinsGotSomething == 0) {
Sleep(1);
continue;
}
- if(!fTracksWritten) {
+ if (!fTracksWritten) {
CNode<Track> Tracks;
CAutoPtr<Track> pT(DNew Track());
POSITION pos = pActivePins.GetHeadPosition();
- for(int i = 1; pos; i++) {
+ for (int i = 1; pos; i++) {
CMatroskaMuxerInputPin* pPin = pActivePins.GetNext(pos);
CAutoPtr<TrackEntry> pTE(DNew TrackEntry());
*pTE = *pPin->GetTrackEntry();
- if(TrackNumber == 0 && pTE->TrackType == TrackEntry::TypeVideo) {
+ if (TrackNumber == 0 && pTE->TrackType == TrackEntry::TypeVideo) {
TrackNumber = pTE->TrackNumber;
}
pT->TrackEntries.AddTail(pTE);
@@ -550,7 +550,7 @@ DWORD CMatroskaMuxerFilter::ThreadProc() Tracks.AddTail(pT);
Tracks.Write(pStream);
- if(TrackNumber == 0) {
+ if (TrackNumber == 0) {
TrackNumber = 1;
}
@@ -566,9 +566,9 @@ DWORD CMatroskaMuxerFilter::ThreadProc() b = pPin->m_blocks.RemoveHead();
}
- if(b) {
- if(fFirstBlock) {
- if(b->Block.TimeCode < 0 && m_fNegative || b->Block.TimeCode > 0 && m_fPositive) {
+ if (b) {
+ if (fFirstBlock) {
+ if (b->Block.TimeCode < 0 && m_fNegative || b->Block.TimeCode > 0 && m_fPositive) {
firstTimeCode = b->Block.TimeCode;
}
fFirstBlock = false;
@@ -584,13 +584,13 @@ DWORD CMatroskaMuxerFilter::ThreadProc() (int)((b->Block.TimeCode)/MAXCLUSTERTIME), (int)(b->Block.TimeCode%MAXCLUSTERTIME),
b->Block.BlockData.GetCount(), (int)b->ReferenceBlock);
*/
- if(b->Block.TimeCode < SHRT_MIN /*0*/) {
+ if (b->Block.TimeCode < SHRT_MIN /*0*/) {
ASSERT(0);
continue;
}
- while((INT64)(c.TimeCode + MAXCLUSTERTIME) < b->Block.TimeCode) {
- if(!c.BlockGroups.IsEmpty()) {
+ while ((INT64)(c.TimeCode + MAXCLUSTERTIME) < b->Block.TimeCode) {
+ if (!c.BlockGroups.IsEmpty()) {
sh.Attach(DNew SeekHead());
sh->ID.Set(c.GetID()/*0x1F43B675*/);
sh->Position.Set(GetStreamPosition(pStream) - segpos);
@@ -604,17 +604,17 @@ DWORD CMatroskaMuxerFilter::ThreadProc() nBlocksInCueTrack = 0;
}
- if(b->Block.TrackNumber == TrackNumber) {
+ if (b->Block.TrackNumber == TrackNumber) {
nBlocksInCueTrack++;
}
- if(b->ReferenceBlock == 0 && b->Block.TrackNumber == TrackNumber) {
+ if (b->ReferenceBlock == 0 && b->Block.TrackNumber == TrackNumber) {
ULONGLONG clusterpos = GetStreamPosition(pStream) - segpos;
- if(lastcueclusterpos != clusterpos || lastcuetimecode + 1000 < b->Block.TimeCode) {
+ if (lastcueclusterpos != clusterpos || lastcuetimecode + 1000 < b->Block.TimeCode) {
CAutoPtr<CueTrackPosition> ctp(DNew CueTrackPosition());
ctp->CueTrack.Set(b->Block.TrackNumber);
ctp->CueClusterPosition.Set(clusterpos);
- if(c.BlockGroups.GetCount() > 0) {
+ if (c.BlockGroups.GetCount() > 0) {
ctp->CueBlockNumber.Set(nBlocksInCueTrack);
}
CAutoPtr<CuePoint> cp(DNew CuePoint());
@@ -635,7 +635,7 @@ DWORD CMatroskaMuxerFilter::ThreadProc() }
}
- if(!c.BlockGroups.IsEmpty()) {
+ if (!c.BlockGroups.IsEmpty()) {
sh.Attach(DNew SeekHead());
sh->ID.Set(c.GetID()/*0x1F43B675*/);
sh->Position.Set(GetStreamPosition(pStream) - segpos);
@@ -644,7 +644,7 @@ DWORD CMatroskaMuxerFilter::ThreadProc() c.Write(pStream);
}
- if(!cue.CuePoints.IsEmpty()) {
+ if (!cue.CuePoints.IsEmpty()) {
sh.Attach(DNew SeekHead());
sh->ID.Set(cue.GetID()/*0x1C53BB6B*/);
sh->Position.Set(GetStreamPosition(pStream) - segpos);
@@ -669,18 +669,18 @@ DWORD CMatroskaMuxerFilter::ThreadProc() ASSERT(len >= 0 && len != 1);
seek.Write(pStream);
- if(len == 0) {
+ if (len == 0) {
// nothing to do
- } else if(len >= 2) {
- for(int i = 0; i < 8; i++) {
- if(len >= (1<<i*7)-2 && len <= (1<<(i+1)*7)-2) {
+ } else if (len >= 2) {
+ for (int i = 0; i < 8; i++) {
+ if (len >= (1<<i*7)-2 && len <= (1<<(i+1)*7)-2) {
Void(len-2-i).Write(pStream);
break;
}
}
}
- if(abs(m_rtCurrent - (REFERENCE_TIME)info.Duration*10000) > 10000000i64) {
+ if (abs(m_rtCurrent - (REFERENCE_TIME)info.Duration*10000) > 10000000i64) {
info.Duration.Set(m_rtCurrent / 10000 + 1);
}
@@ -751,7 +751,7 @@ HRESULT CMatroskaMuxerInputPin::BreakConnect() {
HRESULT hr;
- if(FAILED(hr = __super::BreakConnect())) {
+ if (FAILED(hr = __super::BreakConnect())) {
return hr;
}
@@ -764,13 +764,13 @@ HRESULT CMatroskaMuxerInputPin::CompleteConnect(IPin* pPin) {
HRESULT hr;
- if(FAILED(hr = __super::CompleteConnect(pPin))) {
+ if (FAILED(hr = __super::CompleteConnect(pPin))) {
return hr;
}
m_rtDur = 0;
CComQIPtr<IMediaSeeking> pMS;
- if((pMS = GetFilterFromPin(pPin)) || (pMS = pPin)) {
+ if ((pMS = GetFilterFromPin(pPin)) || (pMS = pPin)) {
pMS->GetDuration(&m_rtDur);
}
@@ -784,18 +784,18 @@ HRESULT CMatroskaMuxerInputPin::CompleteConnect(IPin* pPin) hr = E_FAIL;
- if(m_mt.majortype == MEDIATYPE_Video) {
+ if (m_mt.majortype == MEDIATYPE_Video) {
m_pTE->TrackType.Set(TrackEntry::TypeVideo);
- if(m_mt.formattype == FORMAT_VideoInfo
+ if (m_mt.formattype == FORMAT_VideoInfo
&& m_mt.subtype == MEDIASUBTYPE_RV10 || m_mt.subtype == MEDIASUBTYPE_RV20
|| m_mt.subtype == MEDIASUBTYPE_RV30 || m_mt.subtype == MEDIASUBTYPE_RV40) {
m_pTE->CodecID.Set("V_REAL/RV00");
m_pTE->CodecID.SetAt(9, (BYTE)(m_mt.subtype.Data1>>16));
- if(m_mt.formattype == FORMAT_VideoInfo) {
+ if (m_mt.formattype == FORMAT_VideoInfo) {
VIDEOINFOHEADER* vih = (VIDEOINFOHEADER*)m_mt.pbFormat;
- if(m_mt.cbFormat > sizeof(VIDEOINFOHEADER)) {
+ if (m_mt.cbFormat > sizeof(VIDEOINFOHEADER)) {
m_pTE->CodecPrivate.SetCount(m_mt.cbFormat - sizeof(VIDEOINFOHEADER));
memcpy(m_pTE->CodecPrivate, m_mt.pbFormat + sizeof(VIDEOINFOHEADER), m_pTE->CodecPrivate.GetCount());
}
@@ -803,12 +803,12 @@ HRESULT CMatroskaMuxerInputPin::CompleteConnect(IPin* pPin) m_pTE->DescType = TrackEntry::DescVideo;
m_pTE->v.PixelWidth.Set(vih->bmiHeader.biWidth);
m_pTE->v.PixelHeight.Set(abs(vih->bmiHeader.biHeight));
- if(vih->AvgTimePerFrame > 0) {
+ if (vih->AvgTimePerFrame > 0) {
m_pTE->v.FramePerSec.Set((float)(10000000.0 / vih->AvgTimePerFrame));
}
- } else if(m_mt.formattype == FORMAT_VideoInfo2) {
+ } else if (m_mt.formattype == FORMAT_VideoInfo2) {
VIDEOINFOHEADER2* vih = (VIDEOINFOHEADER2*)m_mt.pbFormat;
- if(m_mt.cbFormat > sizeof(VIDEOINFOHEADER2)) {
+ if (m_mt.cbFormat > sizeof(VIDEOINFOHEADER2)) {
m_pTE->CodecPrivate.SetCount(m_mt.cbFormat - sizeof(VIDEOINFOHEADER2));
memcpy(m_pTE->CodecPrivate, m_mt.pbFormat + sizeof(VIDEOINFOHEADER2), m_pTE->CodecPrivate.GetCount());
}
@@ -816,7 +816,7 @@ HRESULT CMatroskaMuxerInputPin::CompleteConnect(IPin* pPin) m_pTE->DescType = TrackEntry::DescVideo;
m_pTE->v.PixelWidth.Set(vih->bmiHeader.biWidth);
m_pTE->v.PixelHeight.Set(abs(vih->bmiHeader.biHeight));
- if(vih->AvgTimePerFrame > 0) {
+ if (vih->AvgTimePerFrame > 0) {
m_pTE->v.FramePerSec.Set((float)(10000000.0 / vih->AvgTimePerFrame));
}
m_pTE->v.DisplayWidth.Set(vih->dwPictAspectRatioX);
@@ -827,7 +827,7 @@ HRESULT CMatroskaMuxerInputPin::CompleteConnect(IPin* pPin) }
hr = S_OK;
- } else if(m_mt.formattype == FORMAT_VideoInfo) {
+ } else if (m_mt.formattype == FORMAT_VideoInfo) {
m_pTE->CodecID.Set("V_MS/VFW/FOURCC");
VIDEOINFOHEADER* vih = (VIDEOINFOHEADER*)m_mt.pbFormat;
@@ -837,12 +837,12 @@ HRESULT CMatroskaMuxerInputPin::CompleteConnect(IPin* pPin) m_pTE->DescType = TrackEntry::DescVideo;
m_pTE->v.PixelWidth.Set(vih->bmiHeader.biWidth);
m_pTE->v.PixelHeight.Set(abs(vih->bmiHeader.biHeight));
- if(vih->AvgTimePerFrame > 0) {
+ if (vih->AvgTimePerFrame > 0) {
m_pTE->v.FramePerSec.Set((float)(10000000.0 / vih->AvgTimePerFrame));
}
hr = S_OK;
- } else if(m_mt.formattype == FORMAT_VideoInfo2) {
+ } else if (m_mt.formattype == FORMAT_VideoInfo2) {
m_pTE->CodecID.Set("V_MS/VFW/FOURCC");
VIDEOINFOHEADER2* vih = (VIDEOINFOHEADER2*)m_mt.pbFormat;
@@ -854,12 +854,12 @@ HRESULT CMatroskaMuxerInputPin::CompleteConnect(IPin* pPin) m_pTE->v.PixelHeight.Set(abs(vih->bmiHeader.biHeight));
m_pTE->v.DisplayWidth.Set(vih->dwPictAspectRatioX);
m_pTE->v.DisplayHeight.Set(vih->dwPictAspectRatioY);
- if(vih->AvgTimePerFrame > 0) {
+ if (vih->AvgTimePerFrame > 0) {
m_pTE->v.FramePerSec.Set((float)(10000000.0 / vih->AvgTimePerFrame));
}
hr = S_OK;
- } else if(m_mt.formattype == FORMAT_DiracVideoInfo) {
+ } else if (m_mt.formattype == FORMAT_DiracVideoInfo) {
m_pTE->CodecID.Set("V_DIRAC");
DIRACINFOHEADER* vih = (DIRACINFOHEADER*)m_mt.pbFormat;
@@ -871,7 +871,7 @@ HRESULT CMatroskaMuxerInputPin::CompleteConnect(IPin* pPin) m_pTE->v.PixelHeight.Set(abs(vih->hdr.bmiHeader.biHeight));
// m_pTE->v.DisplayWidth.Set(vih->dwPictAspectRatioX);
// m_pTE->v.DisplayHeight.Set(vih->dwPictAspectRatioY);
- if(vih->hdr.AvgTimePerFrame > 0) {
+ if (vih->hdr.AvgTimePerFrame > 0) {
m_pTE->v.FramePerSec.Set((float)(10000000.0 / vih->hdr.AvgTimePerFrame));
}
@@ -911,10 +911,10 @@ HRESULT CMatroskaMuxerInputPin::CompleteConnect(IPin* pPin) hr = S_OK;
}
*/
- } else if(m_mt.majortype == MEDIATYPE_Audio) {
+ } else if (m_mt.majortype == MEDIATYPE_Audio) {
m_pTE->TrackType.Set(TrackEntry::TypeAudio);
- if(m_mt.formattype == FORMAT_WaveFormatEx
+ if (m_mt.formattype == FORMAT_WaveFormatEx
&& ((WAVEFORMATEX*)m_mt.pbFormat)->wFormatTag == WAVE_FORMAT_AAC
&& m_mt.cbFormat >= sizeof(WAVEFORMATEX)+2) {
WAVEFORMATEX* wfe = (WAVEFORMATEX*)m_mt.pbFormat;
@@ -928,7 +928,7 @@ HRESULT CMatroskaMuxerInputPin::CompleteConnect(IPin* pPin) int exttype = 0;
int rate2 = rate1;
- if(wfe->cbSize >= 5) {
+ if (wfe->cbSize >= 5) {
profile = 4;
exttype = (p[2]<<3)|(p[3]>>5);
@@ -937,13 +937,13 @@ HRESULT CMatroskaMuxerInputPin::CompleteConnect(IPin* pPin) ASSERT((p[4]>>7) == 1);
rate2 = ((p[4]>>3)&15);
- if(rate2 < rate1) {
+ if (rate2 < rate1) {
m_pTE->a.OutputSamplingFrequency.Set((float)nSamplesPerSec);
nSamplesPerSec /= 2;
}
}
- switch(profile) {
+ switch (profile) {
default:
case 0:
m_pTE->CodecID.Set("A_AAC/MPEG2/MAIN");
@@ -970,8 +970,8 @@ HRESULT CMatroskaMuxerInputPin::CompleteConnect(IPin* pPin) m_pTE->a.BitDepth.Set(wfe->wBitsPerSample);
hr = S_OK;
- } else if(m_mt.formattype == FORMAT_WaveFormatEx
- && ((WAVEFORMATEX*)m_mt.pbFormat)->wFormatTag == WAVE_FORMAT_DOLBY_AC3) {
+ } else if (m_mt.formattype == FORMAT_WaveFormatEx
+ && ((WAVEFORMATEX*)m_mt.pbFormat)->wFormatTag == WAVE_FORMAT_DOLBY_AC3) {
m_pTE->CodecID.Set("A_AC3");
WAVEFORMATEX* wfe = (WAVEFORMATEX*)m_mt.pbFormat;
@@ -981,8 +981,8 @@ HRESULT CMatroskaMuxerInputPin::CompleteConnect(IPin* pPin) m_pTE->a.BitDepth.Set(wfe->wBitsPerSample);
hr = S_OK;
- } else if(m_mt.formattype == FORMAT_WaveFormatEx
- && ((WAVEFORMATEX*)m_mt.pbFormat)->wFormatTag == WAVE_FORMAT_DVD_DTS) {
+ } else if (m_mt.formattype == FORMAT_WaveFormatEx
+ && ((WAVEFORMATEX*)m_mt.pbFormat)->wFormatTag == WAVE_FORMAT_DVD_DTS) {
m_pTE->CodecID.Set("A_DTS");
WAVEFORMATEX* wfe = (WAVEFORMATEX*)m_mt.pbFormat;
@@ -992,8 +992,8 @@ HRESULT CMatroskaMuxerInputPin::CompleteConnect(IPin* pPin) m_pTE->a.BitDepth.Set(wfe->wBitsPerSample);
hr = S_OK;
- } else if(m_mt.formattype == FORMAT_WaveFormatEx
- && ((WAVEFORMATEX*)m_mt.pbFormat)->wFormatTag == WAVE_FORMAT_FLAC) {
+ } else if (m_mt.formattype == FORMAT_WaveFormatEx
+ && ((WAVEFORMATEX*)m_mt.pbFormat)->wFormatTag == WAVE_FORMAT_FLAC) {
m_pTE->CodecID.Set("A_FLAC");
WAVEFORMATEX* wfe = (WAVEFORMATEX*)m_mt.pbFormat;
@@ -1002,19 +1002,19 @@ HRESULT CMatroskaMuxerInputPin::CompleteConnect(IPin* pPin) m_pTE->a.Channels.Set(wfe->nChannels);
m_pTE->a.BitDepth.Set(wfe->wBitsPerSample);
- if(wfe->cbSize) {
+ if (wfe->cbSize) {
m_pTE->CodecPrivate.SetCount(wfe->cbSize);
memcpy(m_pTE->CodecPrivate, m_mt.pbFormat + sizeof(WAVEFORMATEX), wfe->cbSize);
}
hr = S_OK;
- } else if(m_mt.formattype == FORMAT_WaveFormatEx
- && (m_mt.subtype == MEDIASUBTYPE_14_4
- || m_mt.subtype == MEDIASUBTYPE_28_8
- || m_mt.subtype == MEDIASUBTYPE_ATRC
- || m_mt.subtype == MEDIASUBTYPE_COOK
- || m_mt.subtype == MEDIASUBTYPE_DNET
- || m_mt.subtype == MEDIASUBTYPE_SIPR)) {
+ } else if (m_mt.formattype == FORMAT_WaveFormatEx
+ && (m_mt.subtype == MEDIASUBTYPE_14_4
+ || m_mt.subtype == MEDIASUBTYPE_28_8
+ || m_mt.subtype == MEDIASUBTYPE_ATRC
+ || m_mt.subtype == MEDIASUBTYPE_COOK
+ || m_mt.subtype == MEDIASUBTYPE_DNET
+ || m_mt.subtype == MEDIASUBTYPE_SIPR)) {
CStringA id;
id.Format("A_REAL/%c%c%c%c",
(char)((m_mt.subtype.Data1>>0)&0xff),
@@ -1026,7 +1026,7 @@ HRESULT CMatroskaMuxerInputPin::CompleteConnect(IPin* pPin) WAVEFORMATEX* wfe = (WAVEFORMATEX*)m_mt.pbFormat;
DWORD cbSize = sizeof(WAVEFORMATEX) + wfe->cbSize;
- if(m_mt.cbFormat > cbSize) {
+ if (m_mt.cbFormat > cbSize) {
m_pTE->CodecPrivate.SetCount(m_mt.cbFormat - cbSize);
memcpy(m_pTE->CodecPrivate, m_mt.pbFormat + cbSize, m_pTE->CodecPrivate.GetCount());
}
@@ -1036,8 +1036,8 @@ HRESULT CMatroskaMuxerInputPin::CompleteConnect(IPin* pPin) m_pTE->a.BitDepth.Set(wfe->wBitsPerSample);
hr = S_OK;
- } else if(m_mt.formattype == FORMAT_WaveFormatEx
- && ((WAVEFORMATEX*)m_mt.pbFormat)->wFormatTag == WAVE_FORMAT_PCM) {
+ } else if (m_mt.formattype == FORMAT_WaveFormatEx
+ && ((WAVEFORMATEX*)m_mt.pbFormat)->wFormatTag == WAVE_FORMAT_PCM) {
m_pTE->CodecID.Set("A_PCM/INT/LIT");
WAVEFORMATEX* wfe = (WAVEFORMATEX*)m_mt.pbFormat;
@@ -1047,7 +1047,7 @@ HRESULT CMatroskaMuxerInputPin::CompleteConnect(IPin* pPin) m_pTE->a.BitDepth.Set(wfe->wBitsPerSample);
hr = S_OK;
- } else if(m_mt.formattype == FORMAT_WaveFormatEx) {
+ } else if (m_mt.formattype == FORMAT_WaveFormatEx) {
m_pTE->CodecID.Set("A_MS/ACM");
WAVEFORMATEX* wfe = (WAVEFORMATEX*)m_mt.pbFormat;
@@ -1059,7 +1059,7 @@ HRESULT CMatroskaMuxerInputPin::CompleteConnect(IPin* pPin) m_pTE->a.BitDepth.Set(wfe->wBitsPerSample);
hr = S_OK;
- } else if(m_mt.formattype == FORMAT_VorbisFormat) {
+ } else if (m_mt.formattype == FORMAT_VorbisFormat) {
m_pTE->CodecID.Set("A_VORBIS");
VORBISFORMAT* pvf = (VORBISFORMAT*)m_mt.pbFormat;
@@ -1070,7 +1070,7 @@ HRESULT CMatroskaMuxerInputPin::CompleteConnect(IPin* pPin) // m_pTE->CodecPrivate will be filled later
hr = S_OK;
- } else if(m_mt.formattype == FORMAT_VorbisFormat2) {
+ } else if (m_mt.formattype == FORMAT_VorbisFormat2) {
m_pTE->CodecID.Set("A_VORBIS");
VORBISFORMAT2* pvf2 = (VORBISFORMAT2*)m_mt.pbFormat;
@@ -1080,10 +1080,10 @@ HRESULT CMatroskaMuxerInputPin::CompleteConnect(IPin* pPin) m_pTE->a.BitDepth.Set(pvf2->BitsPerSample);
int len = 1;
- for(int i = 0; i < 2; i++) {
+ for (int i = 0; i < 2; i++) {
len += pvf2->HeaderSize[i]/255 + 1;
}
- for(int i = 0; i < 3; i++) {
+ for (int i = 0; i < 3; i++) {
len += pvf2->HeaderSize[i];
}
m_pTE->CodecPrivate.SetCount(len);
@@ -1092,8 +1092,8 @@ HRESULT CMatroskaMuxerInputPin::CompleteConnect(IPin* pPin) BYTE* dst = m_pTE->CodecPrivate.GetData();
*dst++ = 2;
- for(int i = 0; i < 2; i++)
- for(int len = pvf2->HeaderSize[i]; len >= 0; len -= 255) {
+ for (int i = 0; i < 2; i++)
+ for (int len = pvf2->HeaderSize[i]; len >= 0; len -= 255) {
*dst++ = min(len, 255);
}
@@ -1112,14 +1112,14 @@ HRESULT CMatroskaMuxerInputPin::CompleteConnect(IPin* pPin) hr = S_OK;
}
- } else if(m_mt.majortype == MEDIATYPE_Text) {
+ } else if (m_mt.majortype == MEDIATYPE_Text) {
m_pTE->TrackType.Set(TrackEntry::TypeSubtitle);
- if(m_mt.formattype == FORMAT_None) {
+ if (m_mt.formattype == FORMAT_None) {
m_pTE->CodecID.Set("S_TEXT/ASCII");
hr = S_OK;
}
- } else if(m_mt.majortype == MEDIATYPE_Subtitle) {
+ } else if (m_mt.majortype == MEDIATYPE_Subtitle) {
m_pTE->TrackType.Set(TrackEntry::TypeSubtitle);
m_pTE->CodecID.Set(
@@ -1130,18 +1130,18 @@ HRESULT CMatroskaMuxerInputPin::CompleteConnect(IPin* pPin) m_mt.subtype == MEDIASUBTYPE_VOBSUB ? "S_VOBSUB" :
"");
- if(!m_pTE->CodecID.IsEmpty()) {
+ if (!m_pTE->CodecID.IsEmpty()) {
hr = S_OK;
SUBTITLEINFO* psi = (SUBTITLEINFO*)m_mt.pbFormat;
- if(psi->dwOffset) {
+ if (psi->dwOffset) {
m_pTE->CodecPrivate.SetCount(m_mt.cbFormat - psi->dwOffset);
memcpy(m_pTE->CodecPrivate, m_mt.pbFormat + psi->dwOffset, m_pTE->CodecPrivate.GetCount());
}
}
}
- if(S_OK == hr) {
+ if (S_OK == hr) {
(static_cast<CMatroskaMuxerFilter*>(m_pFilter))->AddInput();
}
@@ -1183,17 +1183,17 @@ STDMETHODIMP CMatroskaMuxerInputPin::EndFlush() STDMETHODIMP CMatroskaMuxerInputPin::Receive(IMediaSample* pSample)
{
- if(m_fEndOfStreamReceived) {
+ if (m_fEndOfStreamReceived) {
/*ASSERT(0);*/
return S_FALSE;
}
CAutoLock cAutoLock(&m_csReceive);
- while(m_fActive) {
+ while (m_fActive) {
{
CAutoLock cAutoLock2(&m_csQueue);
- if(m_blocks.GetCount() < MAXBLOCKS) {
+ if (m_blocks.GetCount() < MAXBLOCKS) {
break;
}
}
@@ -1201,13 +1201,13 @@ STDMETHODIMP CMatroskaMuxerInputPin::Receive(IMediaSample* pSample) Sleep(1);
}
- if(!m_fActive) {
+ if (!m_fActive) {
return S_FALSE;
}
HRESULT hr;
- if(FAILED(hr = __super::Receive(pSample))) {
+ if (FAILED(hr = __super::Receive(pSample))) {
return hr;
}
@@ -1219,7 +1219,7 @@ STDMETHODIMP CMatroskaMuxerInputPin::Receive(IMediaSample* pSample) REFERENCE_TIME rtStart = -1, rtStop = -1;
hr = pSample->GetTime(&rtStart, &rtStop);
- if(FAILED(hr) || rtStart == -1 || rtStop == -1) {
+ if (FAILED(hr) || rtStart == -1 || rtStop == -1) {
TRACE(_T("No timestamp was set on the sample!!!"));
m_pFilter->NotifyEvent(EC_ERRORABORT, VFW_E_SAMPLE_TIME_NOT_SET, 0);
return VFW_E_SAMPLE_TIME_NOT_SET;
@@ -1237,18 +1237,18 @@ STDMETHODIMP CMatroskaMuxerInputPin::Receive(IMediaSample* pSample) pSample->IsPreroll() == S_OK ? 1 : 0,
pSample->IsSyncPoint() == S_OK ? 1 : 0);
- if(m_mt.subtype == MEDIASUBTYPE_Vorbis && m_pVorbisHdrs.GetCount() < 3) {
+ if (m_mt.subtype == MEDIASUBTYPE_Vorbis && m_pVorbisHdrs.GetCount() < 3) {
CAutoPtr<CBinary> data(DNew CBinary(0));
data->SetCount(len);
memcpy(data->GetData(), pData, len);
m_pVorbisHdrs.Add(data);
- if(m_pVorbisHdrs.GetCount() == 3) {
+ if (m_pVorbisHdrs.GetCount() == 3) {
int len = 1;
- for(int i = 0; i < 2; i++) {
+ for (int i = 0; i < 2; i++) {
len += m_pVorbisHdrs[i]->GetCount()/255 + 1;
}
- for(int i = 0; i < 3; i++) {
+ for (int i = 0; i < 3; i++) {
len += m_pVorbisHdrs[i]->GetCount();
}
m_pTE->CodecPrivate.SetCount(len);
@@ -1256,12 +1256,12 @@ STDMETHODIMP CMatroskaMuxerInputPin::Receive(IMediaSample* pSample) BYTE* dst = m_pTE->CodecPrivate.GetData();
*dst++ = 2;
- for(int i = 0; i < 2; i++)
- for(int len = m_pVorbisHdrs[i]->GetCount(); len >= 0; len -= 255) {
+ for (int i = 0; i < 2; i++)
+ for (int len = m_pVorbisHdrs[i]->GetCount(); len >= 0; len -= 255) {
*dst++ = min(len, 255);
}
- for(int i = 0; i < 3; i++) {
+ for (int i = 0; i < 3; i++) {
memcpy(dst, m_pVorbisHdrs[i]->GetData(), m_pVorbisHdrs[i]->GetCount());
dst += m_pVorbisHdrs[i]->GetCount();
}
@@ -1270,7 +1270,7 @@ STDMETHODIMP CMatroskaMuxerInputPin::Receive(IMediaSample* pSample) return S_OK;
}
- if(m_mt.formattype == FORMAT_WaveFormatEx
+ if (m_mt.formattype == FORMAT_WaveFormatEx
&& (((WAVEFORMATEX*)m_mt.pbFormat)->wFormatTag == WAVE_FORMAT_PCM
|| ((WAVEFORMATEX*)m_mt.pbFormat)->wFormatTag == WAVE_FORMAT_MPEGLAYER3)) {
pSample->SetSyncPoint(TRUE); // HACK: some capture filters don't set this
@@ -1285,7 +1285,7 @@ STDMETHODIMP CMatroskaMuxerInputPin::Receive(IMediaSample* pSample) return S_OK;
}
*/
- if((S_OK != pSample->IsSyncPoint() || m_rtLastStart == rtStart) && m_rtLastStart >= 0 /*&& m_rtLastStart < rtStart*/) {
+ if ((S_OK != pSample->IsSyncPoint() || m_rtLastStart == rtStart) && m_rtLastStart >= 0 /*&& m_rtLastStart < rtStart*/) {
ASSERT(m_rtLastStart - rtStart <= 0);
REFERENCE_TIME rtDiff = m_rtLastStart - rtStart;
b->ReferenceBlock.Set((rtDiff + (rtDiff >= 0 ? 5000 : -5000)) / 10000);
@@ -1296,7 +1296,7 @@ STDMETHODIMP CMatroskaMuxerInputPin::Receive(IMediaSample* pSample) b->Block.TimeCode = (rtStart + 5000) / 10000;
b->Block.TimeCodeStop = (rtStop + 5000) / 10000;
- if(m_pTE->TrackType == TrackEntry::TypeSubtitle) {
+ if (m_pTE->TrackType == TrackEntry::TypeSubtitle) {
b->BlockDuration.Set((rtStop - rtStart + 5000) / 10000);
}
@@ -1318,7 +1318,7 @@ STDMETHODIMP CMatroskaMuxerInputPin::EndOfStream() {
HRESULT hr;
- if(FAILED(hr = __super::EndOfStream())) {
+ if (FAILED(hr = __super::EndOfStream())) {
return hr;
}
@@ -1361,11 +1361,11 @@ HRESULT CMatroskaMuxerOutputPin::DecideBufferSize(IMemAllocator* pAlloc, ALLOCAT pProperties->cbBuffer = 1;
ALLOCATOR_PROPERTIES Actual;
- if(FAILED(hr = pAlloc->SetProperties(pProperties, &Actual))) {
+ if (FAILED(hr = pAlloc->SetProperties(pProperties, &Actual))) {
return hr;
}
- if(Actual.cbBuffer < pProperties->cbBuffer) {
+ if (Actual.cbBuffer < pProperties->cbBuffer) {
return E_FAIL;
}
ASSERT(Actual.cBuffers == pProperties->cBuffers);
@@ -1384,10 +1384,10 @@ HRESULT CMatroskaMuxerOutputPin::GetMediaType(int iPosition, CMediaType* pmt) {
CAutoLock cAutoLock(m_pLock);
- if(iPosition < 0) {
+ if (iPosition < 0) {
return E_INVALIDARG;
}
- if(iPosition > 0) {
+ if (iPosition > 0) {
return VFW_S_NO_MORE_ITEMS;
}
diff --git a/src/filters/muxer/WavDest/WavDest.cpp b/src/filters/muxer/WavDest/WavDest.cpp index 05d68a2a5..ca876cf74 100644 --- a/src/filters/muxer/WavDest/WavDest.cpp +++ b/src/filters/muxer/WavDest/WavDest.cpp @@ -73,9 +73,9 @@ CFilterApp theApp; CWavDestFilter::CWavDestFilter(LPUNKNOWN pUnk, HRESULT* phr)
: CTransformFilter(NAME("WavDest filter"), pUnk, __uuidof(this))
{
- if(SUCCEEDED(*phr)) {
- if(CWavDestOutputPin* pOut = DNew CWavDestOutputPin(this, phr)) {
- if(SUCCEEDED(*phr)) {
+ if (SUCCEEDED(*phr)) {
+ if (CWavDestOutputPin* pOut = DNew CWavDestOutputPin(this, phr)) {
+ if (SUCCEEDED(*phr)) {
m_pOutput = pOut;
} else {
delete pOut;
@@ -85,8 +85,8 @@ CWavDestFilter::CWavDestFilter(LPUNKNOWN pUnk, HRESULT* phr) return;
}
- if(CTransformInputPin* pIn = DNew CTransformInputPin(NAME("Transform input pin"), this, phr, L"In")) {
- if(SUCCEEDED(*phr)) {
+ if (CTransformInputPin* pIn = DNew CTransformInputPin(NAME("Transform input pin"), this, phr, L"In")) {
+ if (SUCCEEDED(*phr)) {
m_pInput = pIn;
} else {
delete pIn;
@@ -113,7 +113,7 @@ HRESULT CWavDestFilter::Receive(IMediaSample* pSample) HRESULT hr = CTransformFilter::Receive(pSample);
// don't update the count if Deliver() downstream fails.
- if(hr != S_OK) {
+ if (hr != S_OK) {
m_cbWavData = cbOld;
}
@@ -125,14 +125,14 @@ HRESULT CWavDestFilter::Transform(IMediaSample* pIn, IMediaSample* pOut) REFERENCE_TIME rtStart, rtEnd;
HRESULT hr = Copy(pIn, pOut);
- if(FAILED(hr)) {
+ if (FAILED(hr)) {
return hr;
}
// Prepare it for writing
LONG lActual = pOut->GetActualDataLength();
- if(m_cbWavData + m_cbHeader + lActual < m_cbWavData + m_cbHeader ) { // overflow
+ if (m_cbWavData + m_cbHeader + lActual < m_cbWavData + m_cbHeader ) { // overflow
return E_FAIL;
}
@@ -163,12 +163,12 @@ HRESULT CWavDestFilter::Copy(IMediaSample* pSource, IMediaSample* pDest) const // Copy the sample times
REFERENCE_TIME TimeStart, TimeEnd;
- if(NOERROR == pSource->GetTime(&TimeStart, &TimeEnd)) {
+ if (NOERROR == pSource->GetTime(&TimeStart, &TimeEnd)) {
pDest->SetTime(&TimeStart, &TimeEnd);
}
LONGLONG MediaStart, MediaEnd;
- if(pSource->GetMediaTime(&MediaStart, &MediaEnd) == NOERROR) {
+ if (pSource->GetMediaTime(&MediaStart, &MediaEnd) == NOERROR) {
pDest->SetMediaTime(&MediaStart, &MediaEnd);
}
@@ -194,7 +194,7 @@ HRESULT CWavDestFilter::GetMediaType(int iPosition, CMediaType* pMediaType) {
ASSERT(iPosition == 0 || iPosition == 1);
- if(iPosition == 0) {
+ if (iPosition == 0) {
pMediaType->SetType(&MEDIATYPE_Stream);
pMediaType->SetSubtype(&MEDIASUBTYPE_WAVE);
return S_OK;
@@ -205,7 +205,7 @@ HRESULT CWavDestFilter::GetMediaType(int iPosition, CMediaType* pMediaType) HRESULT CWavDestFilter::DecideBufferSize(IMemAllocator* pAlloc, ALLOCATOR_PROPERTIES* pProperties)
{
- if(m_pInput->IsConnected() == FALSE) {
+ if (m_pInput->IsConnected() == FALSE) {
return E_UNEXPECTED;
}
@@ -219,7 +219,7 @@ HRESULT CWavDestFilter::DecideBufferSize(IMemAllocator* pAlloc, ALLOCATOR_PROPER CComPtr<IMemAllocator> pInAlloc;
ALLOCATOR_PROPERTIES InProps;
- if(SUCCEEDED(hr = m_pInput->GetAllocator(&pInAlloc))
+ if (SUCCEEDED(hr = m_pInput->GetAllocator(&pInAlloc))
&& SUCCEEDED(hr = pInAlloc->GetProperties(&InProps))) {
pProperties->cbBuffer = InProps.cbBuffer;
} else {
@@ -229,13 +229,13 @@ HRESULT CWavDestFilter::DecideBufferSize(IMemAllocator* pAlloc, ALLOCATOR_PROPER ASSERT(pProperties->cbBuffer);
ALLOCATOR_PROPERTIES Actual;
- if(FAILED(hr = pAlloc->SetProperties(pProperties,&Actual))) {
+ if (FAILED(hr = pAlloc->SetProperties(pProperties,&Actual))) {
return hr;
}
ASSERT(Actual.cBuffers == 1);
- if(pProperties->cBuffers > Actual.cBuffers
+ if (pProperties->cBuffers > Actual.cBuffers
|| pProperties->cbBuffer > Actual.cbBuffer) {
return E_FAIL;
}
@@ -278,7 +278,7 @@ HRESULT CWavDestFilter::StopStreaming() }
HRESULT hr = ((IMemInputPin *) pDwnstrmInputPin)->QueryInterface(IID_IStream, (void **)&pStream);
- if(SUCCEEDED(hr)) {
+ if (SUCCEEDED(hr)) {
BYTE *pb = (BYTE *)_alloca(m_cbHeader);
RIFFLIST *pRiffWave = (RIFFLIST *)pb;
@@ -300,7 +300,7 @@ HRESULT CWavDestFilter::StopStreaming() ZeroMemory(&li, sizeof(li));
hr = pStream->Seek(li, STREAM_SEEK_SET, 0);
- if(SUCCEEDED(hr)) {
+ if (SUCCEEDED(hr)) {
hr = pStream->Write(pb, m_cbHeader, 0);
}
pStream->Release();
@@ -321,7 +321,7 @@ STDMETHODIMP CWavDestOutputPin::EnumMediaTypes(IEnumMediaTypes** ppEnum) HRESULT CWavDestOutputPin::CheckMediaType(const CMediaType* pmt)
{
- if(pmt->majortype == MEDIATYPE_Stream && pmt->subtype == MEDIASUBTYPE_WAVE) {
+ if (pmt->majortype == MEDIATYPE_Stream && pmt->subtype == MEDIASUBTYPE_WAVE) {
return S_OK;
} else {
return S_FALSE;
diff --git a/src/filters/parser/AviSplitter/AviFile.cpp b/src/filters/parser/AviSplitter/AviFile.cpp index 20583dc7e..27957bc18 100644 --- a/src/filters/parser/AviSplitter/AviFile.cpp +++ b/src/filters/parser/AviSplitter/AviFile.cpp @@ -30,7 +30,7 @@ CAviFile::CAviFile(IAsyncReader* pAsyncReader, HRESULT& hr)
: CBaseSplitterFile(pAsyncReader, hr)
{
- if(FAILED(hr)) {
+ if (FAILED(hr)) {
return;
}
m_isamv = false;
@@ -41,7 +41,7 @@ HRESULT CAviFile::Init() {
Seek(0);
DWORD dw[3];
- if(S_OK != Read(dw) || dw[0] != FCC('RIFF') || (dw[2] != FCC('AVI ') && dw[2] != FCC('AVIX') && dw[2] != FCC('AMV '))) {
+ if (S_OK != Read(dw) || dw[0] != FCC('RIFF') || (dw[2] != FCC('AVI ') && dw[2] != FCC('AVIX') && dw[2] != FCC('AMV '))) {
return E_FAIL;
}
@@ -49,25 +49,25 @@ HRESULT CAviFile::Init() Seek(0);
HRESULT hr = Parse(0, GetLength());
UNUSED_ALWAYS(hr);
- if(m_movis.GetCount() == 0) { // FAILED(hr) is allowed as long as there was a movi chunk found
+ if (m_movis.GetCount() == 0) { // FAILED(hr) is allowed as long as there was a movi chunk found
return E_FAIL;
}
- if(m_avih.dwStreams == 0 && m_strms.GetCount() > 0) {
+ if (m_avih.dwStreams == 0 && m_strms.GetCount() > 0) {
m_avih.dwStreams = m_strms.GetCount();
}
- if(m_avih.dwStreams != m_strms.GetCount()) {
+ if (m_avih.dwStreams != m_strms.GetCount()) {
return E_FAIL;
}
- for(DWORD i = 0; i < m_avih.dwStreams; ++i) {
+ for (DWORD i = 0; i < m_avih.dwStreams; ++i) {
strm_t* s = m_strms[i];
- if(s->strh.fccType != FCC('auds')) {
+ if (s->strh.fccType != FCC('auds')) {
continue;
}
WAVEFORMATEX* wfe = (WAVEFORMATEX*)s->strf.GetData();
- if(wfe->wFormatTag == 0x55 && wfe->nBlockAlign == 1152
+ if (wfe->wFormatTag == 0x55 && wfe->nBlockAlign == 1152
&& s->strh.dwScale == 1 && s->strh.dwRate != wfe->nSamplesPerSec) {
// correcting encoder bugs...
s->strh.dwScale = 1152;
@@ -89,7 +89,7 @@ HRESULT CAviFile::BuildAMVIndex() DWORD ulSize;
memset (&NewChunk, 0, sizeof(strm_t::chunk));
- while((Read(ulType) == S_OK) && (Read(ulSize) == S_OK)) {
+ while ((Read(ulType) == S_OK) && (Read(ulSize) == S_OK)) {
switch (ulType) {
case FCC('00dc'): // 01bw : JPeg
NewChunk.size = ulSize;
@@ -119,16 +119,16 @@ HRESULT CAviFile::Parse(DWORD parentid, __int64 end) CAutoPtr<strm_t> strm;
- while(S_OK == hr && GetPos() < end) {
+ while (S_OK == hr && GetPos() < end) {
UINT64 pos = GetPos();
DWORD id = 0, size;
- if(S_OK != Read(id) || id == 0) {
+ if (S_OK != Read(id) || id == 0) {
return E_FAIL;
}
- if(id == FCC('RIFF') || id == FCC('LIST')) {
- if(S_OK != Read(size) || S_OK != Read(id)) {
+ if (id == FCC('RIFF') || id == FCC('LIST')) {
+ if (S_OK != Read(size) || S_OK != Read(id)) {
return E_FAIL;
}
@@ -143,7 +143,7 @@ HRESULT CAviFile::Parse(DWORD parentid, __int64 end) TCHAR((id>>16)&0xff),
TCHAR((id>>24)&0xff));
- if(id == FCC('movi')) {
+ if (id == FCC('movi')) {
m_movis.AddTail(pos);
if (m_isamv) {
BuildAMVIndex();
@@ -152,7 +152,7 @@ HRESULT CAviFile::Parse(DWORD parentid, __int64 end) hr = Parse(id, pos + size);
}
} else {
- if(S_OK != Read(size)) {
+ if (S_OK != Read(size)) {
return E_FAIL;
}
@@ -162,8 +162,8 @@ HRESULT CAviFile::Parse(DWORD parentid, __int64 end) TCHAR((id>>16)&0xff),
TCHAR((id>>24)&0xff));
- if(parentid == FCC('INFO') && size > 0) {
- switch(id) {
+ if (parentid == FCC('INFO') && size > 0) {
+ switch (id) {
case FCC('IARL'): // Archival Location. Indicates where the subject of the file is archived.
case FCC('IART'): // Artist. Lists the artist of the original subject of the file; for example, “Michaelangelo.”
case FCC('ICMS'): // Commissioned. Lists the name of the person or organization that commissioned the subject of the file; for example, “Pope Julian II.”
@@ -188,7 +188,7 @@ HRESULT CAviFile::Parse(DWORD parentid, __int64 end) case FCC('ISRF'): // Source Form. Identifies the original form of the material that was digitized, such as “slide,” “paper,” “map,” and so on. This is not necessarily the same as IMED.
case FCC('ITCH'): { // Technician. Identifies the technician who digitized the subject file; for example, “Smith, John.”
CStringA str;
- if(S_OK != ByteRead((BYTE*)str.GetBufferSetLength(size), size)) {
+ if (S_OK != ByteRead((BYTE*)str.GetBufferSetLength(size), size)) {
return E_FAIL;
}
m_info[id] = str;
@@ -197,22 +197,22 @@ HRESULT CAviFile::Parse(DWORD parentid, __int64 end) }
}
- switch(id) {
+ switch (id) {
case FCC('amvh'):
case FCC('avih'):
m_avih.fcc = id;
m_avih.cb = size;
- if(S_OK != Read(m_avih, 8)) {
+ if (S_OK != Read(m_avih, 8)) {
return E_FAIL;
}
break;
case FCC('strh'):
- if(!strm) {
+ if (!strm) {
strm.Attach(DNew strm_t());
}
strm->strh.fcc = FCC('strh');
strm->strh.cb = size;
- if(S_OK != Read(strm->strh, 8)) {
+ if (S_OK != Read(strm->strh, 8)) {
return E_FAIL;
}
if (m_isamv) {
@@ -223,16 +223,16 @@ HRESULT CAviFile::Parse(DWORD parentid, __int64 end) }
break;
case FCC('strn'):
- if(S_OK != ByteRead((BYTE*)strm->strn.GetBufferSetLength(size), size)) {
+ if (S_OK != ByteRead((BYTE*)strm->strn.GetBufferSetLength(size), size)) {
return E_FAIL;
}
break;
case FCC('strf'):
- if(!strm) {
+ if (!strm) {
strm.Attach(DNew strm_t());
}
strm->strf.SetCount(size);
- if(S_OK != ByteRead(strm->strf.GetData(), size)) {
+ if (S_OK != ByteRead(strm->strf.GetData(), size)) {
return E_FAIL;
}
if (m_isamv) {
@@ -252,7 +252,7 @@ HRESULT CAviFile::Parse(DWORD parentid, __int64 end) break;
case FCC('indx'):
- if(!strm) {
+ if (!strm) {
strm.Attach(DNew strm_t());
}
ASSERT(strm->indx == NULL);
@@ -270,7 +270,7 @@ HRESULT CAviFile::Parse(DWORD parentid, __int64 end) strm->indx.Attach(pSuperIndex);
strm->indx->fcc = FCC('indx');
strm->indx->cb = size;
- if(S_OK != ByteRead((BYTE*)(AVISUPERINDEX*)strm->indx + 8, size)) {
+ if (S_OK != ByteRead((BYTE*)(AVISUPERINDEX*)strm->indx + 8, size)) {
return E_FAIL;
}
ASSERT(strm->indx->wLongsPerEntry == 4 && strm->indx->bIndexType == AVI_INDEX_OF_INDEXES);
@@ -278,7 +278,7 @@ HRESULT CAviFile::Parse(DWORD parentid, __int64 end) }
break;
case FCC('dmlh'):
- if(S_OK != Read(m_dmlh)) {
+ if (S_OK != Read(m_dmlh)) {
return E_FAIL;
}
break;
@@ -290,7 +290,7 @@ HRESULT CAviFile::Parse(DWORD parentid, __int64 end) m_idx1.Attach((AVIOLDINDEX*)DNew BYTE[size + 8]);
m_idx1->fcc = FCC('idx1');
m_idx1->cb = size;
- if(S_OK != ByteRead((BYTE*)(AVIOLDINDEX*)m_idx1 + 8, size)) {
+ if (S_OK != ByteRead((BYTE*)(AVIOLDINDEX*)m_idx1 + 8, size)) {
return E_FAIL;
}
break;
@@ -309,7 +309,7 @@ HRESULT CAviFile::Parse(DWORD parentid, __int64 end) Seek(pos + size);
}
- if(strm) {
+ if (strm) {
m_strms.Add(strm);
}
@@ -320,13 +320,13 @@ REFERENCE_TIME CAviFile::GetTotalTime() {
REFERENCE_TIME t = 0/*10i64*m_avih.dwMicroSecPerFrame*m_avih.dwTotalFrames*/;
- for(DWORD i = 0; i < m_avih.dwStreams; ++i) {
+ for (DWORD i = 0; i < m_avih.dwStreams; ++i) {
strm_t* s = m_strms[i];
REFERENCE_TIME t2 = s->GetRefTime(s->cs.GetCount(), s->totalsize);
t = max(t, t2);
}
- if(t == 0) {
+ if (t == 0) {
t = 10i64*m_avih.dwMicroSecPerFrame*m_avih.dwTotalFrames;
}
@@ -339,26 +339,26 @@ HRESULT CAviFile::BuildIndex() DWORD nSuperIndexes = 0;
- for(DWORD i = 0; i < m_avih.dwStreams; ++i) {
+ for (DWORD i = 0; i < m_avih.dwStreams; ++i) {
strm_t* s = m_strms[i];
- if(s->indx && s->indx->nEntriesInUse > 0) {
+ if (s->indx && s->indx->nEntriesInUse > 0) {
++nSuperIndexes;
}
}
- if(nSuperIndexes == m_avih.dwStreams) {
- for(DWORD i = 0; i < m_avih.dwStreams; ++i) {
+ if (nSuperIndexes == m_avih.dwStreams) {
+ for (DWORD i = 0; i < m_avih.dwStreams; ++i) {
strm_t* s = m_strms[i];
AVISUPERINDEX* idx = (AVISUPERINDEX*)s->indx;
DWORD nEntriesInUse = 0;
- for(DWORD j = 0; j < idx->nEntriesInUse; ++j) {
+ for (DWORD j = 0; j < idx->nEntriesInUse; ++j) {
Seek(idx->aIndex[j].qwOffset);
AVISTDINDEX stdidx;
- if(S_OK != ByteRead((BYTE*)&stdidx, FIELD_OFFSET(AVISTDINDEX, aIndex))) {
+ if (S_OK != ByteRead((BYTE*)&stdidx, FIELD_OFFSET(AVISTDINDEX, aIndex))) {
EmptyIndex();
return E_FAIL;
}
@@ -371,16 +371,16 @@ HRESULT CAviFile::BuildIndex() DWORD frame = 0;
UINT64 size = 0;
- for(DWORD j = 0; j < idx->nEntriesInUse; ++j) {
+ for (DWORD j = 0; j < idx->nEntriesInUse; ++j) {
Seek(idx->aIndex[j].qwOffset);
CAutoPtr<AVISTDINDEX> p((AVISTDINDEX*)DNew BYTE[idx->aIndex[j].dwSize]);
- if(!p || S_OK != ByteRead((BYTE*)(AVISTDINDEX*)p, idx->aIndex[j].dwSize) || p->qwBaseOffset >= GetLength()) {
+ if (!p || S_OK != ByteRead((BYTE*)(AVISTDINDEX*)p, idx->aIndex[j].dwSize) || p->qwBaseOffset >= GetLength()) {
EmptyIndex();
return E_FAIL;
}
- for(DWORD k = 0; k < p->nEntriesInUse; ++k) {
+ for (DWORD k = 0; k < p->nEntriesInUse; ++k) {
s->cs[frame].size = size;
s->cs[frame].filepos = p->qwBaseOffset + p->aIndex[k].dwOffset;
s->cs[frame].fKeyFrame = !(p->aIndex[k].dwSize&AVISTDINDEX_DELTAFRAME)
@@ -388,7 +388,7 @@ HRESULT CAviFile::BuildIndex() s->cs[frame].fChunkHdr = false;
s->cs[frame].orgsize = p->aIndex[k].dwSize&AVISTDINDEX_SIZEMASK;
- if(m_idx1) {
+ if (m_idx1) {
s->cs[frame].filepos -= 8;
s->cs[frame].fChunkHdr = true;
}
@@ -400,29 +400,29 @@ HRESULT CAviFile::BuildIndex() s->totalsize = size;
}
- } else if(AVIOLDINDEX* idx = m_idx1) {
+ } else if (AVIOLDINDEX* idx = m_idx1) {
DWORD len = idx->cb / sizeof(idx->aIndex[0]);
UINT64 offset = m_movis.GetHead() + 8;
//detect absolute chunk addressing (TODO: read AVI specification and make it better)
- if(idx->aIndex[0].dwOffset > offset) {
+ if (idx->aIndex[0].dwOffset > offset) {
DWORD id;
Seek(offset + idx->aIndex[0].dwOffset);
Read(id);
- if(id != idx->aIndex[0].dwChunkId) {
+ if (id != idx->aIndex[0].dwChunkId) {
TRACE(_T("WARNING: CAviFile::Init() detected absolute chunk addressing in \'idx1\'"));
offset = 0;
}
}
- for(DWORD i = 0; i < m_avih.dwStreams; ++i) {
+ for (DWORD i = 0; i < m_avih.dwStreams; ++i) {
strm_t* s = m_strms[i];
// calculate the number of frames and set index size before using it
DWORD nFrames = 0;
- for(DWORD j = 0; j < len; ++j) {
- if(TRACKNUM(idx->aIndex[j].dwChunkId) == i) {
+ for (DWORD j = 0; j < len; ++j) {
+ if (TRACKNUM(idx->aIndex[j].dwChunkId) == i) {
++nFrames;
}
}
@@ -431,10 +431,10 @@ HRESULT CAviFile::BuildIndex() //read index
DWORD frame = 0;
UINT64 size = 0;
- for(DWORD j = 0; j < len; ++j) {
+ for (DWORD j = 0; j < len; ++j) {
DWORD TrackNumber = TRACKNUM(idx->aIndex[j].dwChunkId);
- if(TrackNumber == i) {
+ if (TrackNumber == i) {
s->cs[frame].size = size;
s->cs[frame].filepos = offset + idx->aIndex[j].dwOffset;
s->cs[frame].fKeyFrame = !!(idx->aIndex[j].dwFlags&AVIIF_KEYFRAME)
@@ -453,7 +453,7 @@ HRESULT CAviFile::BuildIndex() }
m_idx1.Free();
- for(DWORD i = 0; i < m_avih.dwStreams; ++i) {
+ for (DWORD i = 0; i < m_avih.dwStreams; ++i) {
m_strms[i]->indx.Free();
}
@@ -462,7 +462,7 @@ HRESULT CAviFile::BuildIndex() void CAviFile::EmptyIndex()
{
- for(DWORD i = 0; i < m_avih.dwStreams; ++i) {
+ for (DWORD i = 0; i < m_avih.dwStreams; ++i) {
strm_t* s = m_strms[i];
s->cs.RemoveAll();
s->totalsize = 0;
@@ -471,14 +471,14 @@ void CAviFile::EmptyIndex() bool CAviFile::IsInterleaved(bool fKeepInfo)
{
- if(m_strms.GetCount() < 2) {
+ if (m_strms.GetCount() < 2) {
return true;
}
/*
if(m_avih.dwFlags&AVIF_ISINTERLEAVED) // not reliable, nandub can write f*cked up files and still sets it
return true;
*/
- for(DWORD i = 0; i < m_avih.dwStreams; ++i) {
+ for (DWORD i = 0; i < m_avih.dwStreams; ++i) {
m_strms[i]->cs2.SetCount(m_strms[i]->cs.GetCount());
}
@@ -490,23 +490,23 @@ bool CAviFile::IsInterleaved(bool fKeepInfo) int end = 0;
- while(1) {
+ while (1) {
UINT64 fpmin = _I64_MAX;
DWORD n = (DWORD)-1;
- for(DWORD i = 0; i < m_avih.dwStreams; ++i) {
+ for (DWORD i = 0; i < m_avih.dwStreams; ++i) {
DWORD curchunk = curchunks[i];
CAtlArray<strm_t::chunk>& cs = m_strms[i]->cs;
- if(curchunk >= cs.GetCount()) {
+ if (curchunk >= cs.GetCount()) {
continue;
}
UINT64 fp = cs[curchunk].filepos;
- if(fp < fpmin) {
+ if (fp < fpmin) {
fpmin = fp;
n = i;
}
}
- if(n == -1) {
+ if (n == -1) {
break;
}
@@ -514,7 +514,7 @@ bool CAviFile::IsInterleaved(bool fKeepInfo) DWORD& curchunk = curchunks[n];
UINT64& cursize = cursizes[n];
- if(!s->IsRawSubtitleStream()) {
+ if (!s->IsRawSubtitleStream()) {
strm_t::chunk2& cs2 = s->cs2[curchunk];
cs2.t = (DWORD)(s->GetRefTime(curchunk, cursize)>>13); // for comparing later it is just as good as /10000 to get a near [ms] accuracy
//cs2.t = (DWORD)(s->GetRefTime(curchunk, cursize)/10000);
@@ -531,28 +531,28 @@ bool CAviFile::IsInterleaved(bool fKeepInfo) bool fInterleaved = true;
- while(fInterleaved) {
+ while (fInterleaved) {
strm_t::chunk2 cs2min = {LONG_MAX, LONG_MAX};
DWORD n = (DWORD)-1;
- for(DWORD i = 0; i < m_avih.dwStreams; ++i) {
+ for (DWORD i = 0; i < m_avih.dwStreams; ++i) {
DWORD curchunk = curchunks[i];
- if(curchunk >= m_strms[i]->cs2.GetCount()) {
+ if (curchunk >= m_strms[i]->cs2.GetCount()) {
continue;
}
strm_t::chunk2& cs2 = m_strms[i]->cs2[curchunk];
- if(cs2.t < cs2min.t) {
+ if (cs2.t < cs2min.t) {
cs2min = cs2;
n = i;
}
}
- if(n == -1) {
+ if (n == -1) {
break;
}
++curchunks[n];
- if(cs2last.t != (DWORD)-1 && abs((int)cs2min.n - (int)cs2last.n) >= 1000) {
+ if (cs2last.t != (DWORD)-1 && abs((int)cs2min.n - (int)cs2last.n) >= 1000) {
fInterleaved = false;
}
@@ -562,9 +562,9 @@ bool CAviFile::IsInterleaved(bool fKeepInfo) delete [] curchunks;
delete [] cursizes;
- if(fInterleaved && !fKeepInfo) {
+ if (fInterleaved && !fKeepInfo) {
// this is not needed anymore, let's save a little memory then
- for(DWORD i = 0; i < m_avih.dwStreams; ++i) {
+ for (DWORD i = 0; i < m_avih.dwStreams; ++i) {
m_strms[i]->cs2.RemoveAll();
}
}
@@ -577,7 +577,7 @@ REFERENCE_TIME CAviFile::strm_t::GetRefTime(DWORD frame, UINT64 size) if (frame == 0 || strh.dwRate == 0) {
return 0;
}
- if(strh.fccType == FCC('auds')) {
+ if (strh.fccType == FCC('auds')) {
WAVEFORMATEX* wfe = (WAVEFORMATEX*)strf.GetData();
if (wfe->nBlockAlign == 0) {
return 0;
@@ -589,22 +589,22 @@ REFERENCE_TIME CAviFile::strm_t::GetRefTime(DWORD frame, UINT64 size) return (REFERENCE_TIME)ceil(10000000.0 * frame * strh.dwScale / strh.dwRate);
// need calculate in double, because the (10000000ui64 * frame * strh.dwScale) can give overflow (verified in practice)
// "ceil" is necessary to compensate for framenumber->reftime->framenumber conversion
-}
+}
DWORD CAviFile::strm_t::GetFrame(REFERENCE_TIME rt)
{
DWORD frame;
if (strh.dwScale == 0 || rt <= 0 || cs.GetCount() == 0) {
- frame = 0;
- } else if (strh.fccType == FCC('auds')) {
+ frame = 0;
+ } else if (strh.fccType == FCC('auds')) {
WAVEFORMATEX* wfe = (WAVEFORMATEX*)strf.GetData();
UINT64 size = (UINT64)(double(rt) * wfe->nBlockAlign * strh.dwRate / (strh.dwScale * 10000000.0));
// need calculate in double, because the (rt * wfe->nBlockAlign * strh.dwRate) can give overflow
frame = 1;
- for(; frame < cs.GetCount(); ++frame) {
- if(cs[frame].size > size) {
+ for (; frame < cs.GetCount(); ++frame) {
+ if (cs[frame].size > size) {
break;
}
}
@@ -623,8 +623,8 @@ DWORD CAviFile::strm_t::GetFrame(REFERENCE_TIME rt) DWORD CAviFile::strm_t::GetKeyFrame(REFERENCE_TIME rt)
{
DWORD i = GetFrame(rt);
- for(; i > 0; i--) {
- if(cs[i].fKeyFrame) {
+ for (; i > 0; i--) {
+ if (cs[i].fKeyFrame) {
break;
}
}
@@ -633,7 +633,7 @@ DWORD CAviFile::strm_t::GetKeyFrame(REFERENCE_TIME rt) DWORD CAviFile::strm_t::GetChunkSize(DWORD size)
{
- if(strh.fccType == FCC('auds')) {
+ if (strh.fccType == FCC('auds')) {
WORD nBlockAlign = ((WAVEFORMATEX*)strf.GetData())->nBlockAlign;
size = nBlockAlign ? (size + (nBlockAlign-1)) / nBlockAlign * nBlockAlign : 0; // round up for nando's vbr hack
}
diff --git a/src/filters/parser/AviSplitter/AviReportWnd.cpp b/src/filters/parser/AviSplitter/AviReportWnd.cpp index d7d8a3a16..9802ff28e 100644 --- a/src/filters/parser/AviSplitter/AviReportWnd.cpp +++ b/src/filters/parser/AviSplitter/AviReportWnd.cpp @@ -15,9 +15,9 @@ bool CAviReportWnd::DoModal(CAviFile* pAF, bool fHideChecked, bool fShowWarningT m_nChunks = 0;
m_rtDur = 0;
- for(DWORD i = 0; i < pAF->m_avih.dwStreams; ++i) {
+ for (DWORD i = 0; i < pAF->m_avih.dwStreams; ++i) {
unsigned int cnt = pAF->m_strms[i]->cs2.GetCount();
- if(cnt == 0) {
+ if (cnt == 0) {
continue;
}
CAviFile::strm_t::chunk2& c2 = pAF->m_strms[i]->cs2[cnt-1];
@@ -77,7 +77,7 @@ bool CAviReportWnd::DoModal(CAviFile* pAF, bool fHideChecked, bool fShowWarningT //
- if(!fShowWarningText) {
+ if (!fShowWarningText) {
m_message.ShowWindow(SW_HIDE);
m_checkbox.ShowWindow(SW_HIDE);
r = cr;
@@ -122,7 +122,7 @@ void CAviReportWnd::OnMouseMove(UINT nFlags, CPoint p) r.bottom -= GRAPHFOOTER;
r2.top = r.bottom;
- if(r.PtInRect(p)) {
+ if (r.PtInRect(p)) {
SetCapture();
int x = p.x - r.left;
@@ -143,18 +143,18 @@ void CAviReportWnd::OnMouseMove(UINT nFlags, CPoint p) CString str;
str.Format(_T("%s (%d - %d:%02d:%02d.%03d)"), TITLE, chunk, h, m, s, ms);
SetWindowText(str);
- } else if(r2.PtInRect(p)) {
+ } else if (r2.PtInRect(p)) {
SetCapture();
int dist = m_graph.GetChunkDist(p.x - r2.left);
CString str;
str.Format(_T("%s (chunk distance: %d"), TITLE, dist);
- if(dist >= 1000) {
+ if (dist >= 1000) {
str += _T(" - over the limit!");
}
str += ")";
SetWindowText(str);
- } else if(GetCapture() == this) {
+ } else if (GetCapture() == this) {
SetWindowText(TITLE);
ReleaseCapture();
@@ -171,7 +171,7 @@ CAviPlotterWnd::CAviPlotterWnd() bool CAviPlotterWnd::Create(CAviFile* pAF, CRect r, CWnd* pParentWnd)
{
- if(!CreateEx(WS_EX_CLIENTEDGE, _T("STATIC"), _T(""), WS_CHILD|WS_VISIBLE, r, pParentWnd, 0)) {
+ if (!CreateEx(WS_EX_CLIENTEDGE, _T("STATIC"), _T(""), WS_CHILD|WS_VISIBLE, r, pParentWnd, 0)) {
return false;
}
@@ -191,15 +191,15 @@ bool CAviPlotterWnd::Create(CAviFile* pAF, CRect r, CWnd* pParentWnd) {
CPen pen(PS_DOT, 1, 0x008000);
CPen* pOldPen = m_dc.SelectObject(&pen);
- for(int y = 0, dy = max(h/10,1); y < h; y += dy) {
- if(y == 0) {
+ for (int y = 0, dy = max(h/10,1); y < h; y += dy) {
+ if (y == 0) {
continue;
}
m_dc.MoveTo(0, y);
m_dc.LineTo(w, y);
}
- for(int x = 0, dx = max(w/10,1); x < w; x += dx) {
- if(x == 0) {
+ for (int x = 0, dx = max(w/10,1); x < w; x += dx) {
+ if (x == 0) {
continue;
}
m_dc.MoveTo(x, 0);
@@ -232,7 +232,7 @@ bool CAviPlotterWnd::Create(CAviFile* pAF, CRect r, CWnd* pParentWnd) COLORREF clr[] = {0x0000ff,0xff0000,0x40ffff,0xff40ff,0xffff40,0xffffff};
- for(DWORD i = 0, y = 40, dy = m_dc.GetTextExtent(_T("Stream N")).cy + 1; i < pAF->m_avih.dwStreams; ++i, y += dy) {
+ for (DWORD i = 0, y = 40, dy = m_dc.GetTextExtent(_T("Stream N")).cy + 1; i < pAF->m_avih.dwStreams; ++i, y += dy) {
m_dc.SetTextColor(clr[i % pAF->m_avih.dwStreams]);
m_dc.SetBkMode(TRANSPARENT);
CString str;
@@ -242,9 +242,9 @@ bool CAviPlotterWnd::Create(CAviFile* pAF, CRect r, CWnd* pParentWnd) DWORD nmax = 0, tmax = 0;
- for(DWORD i = 0; i < pAF->m_avih.dwStreams; ++i) {
+ for (DWORD i = 0; i < pAF->m_avih.dwStreams; ++i) {
unsigned int cnt = pAF->m_strms[i]->cs2.GetCount();
- if(cnt == 0) {
+ if (cnt == 0) {
continue;
}
CAviFile::strm_t::chunk2& c2 = pAF->m_strms[i]->cs2[cnt-1];
@@ -252,16 +252,16 @@ bool CAviPlotterWnd::Create(CAviFile* pAF, CRect r, CWnd* pParentWnd) tmax = max(tmax, c2.t);
}
- if(nmax > 0 && tmax > 0) {
+ if (nmax > 0 && tmax > 0) {
CAtlArray<CPen> pen;
pen.SetCount(pAF->m_avih.dwStreams);
- for(size_t i = 0; i < pen.GetCount(); ++i) {
+ for (size_t i = 0; i < pen.GetCount(); ++i) {
pen[i].CreatePen(PS_SOLID, 2, clr[i]);
}
CAtlArray<CPoint> pp;
pp.SetCount(pAF->m_avih.dwStreams);
- for(size_t i = 0; i < pen.GetCount(); ++i) {
+ for (size_t i = 0; i < pen.GetCount(); ++i) {
pp[i].SetPoint(-1, -1);
}
@@ -273,22 +273,22 @@ bool CAviPlotterWnd::Create(CAviFile* pAF, CRect r, CWnd* pParentWnd) CAviFile::strm_t::chunk2 cs2last = {(DWORD)-1, 0};
- while(1) {
+ while (1) {
CAviFile::strm_t::chunk2 cs2min = {LONG_MAX, LONG_MAX};
DWORD n = (DWORD)-1;
- for(DWORD i = 0; i < pAF->m_avih.dwStreams; ++i) {
+ for (DWORD i = 0; i < pAF->m_avih.dwStreams; ++i) {
DWORD curchunk = curchunks[i];
- if(curchunk >= pAF->m_strms[i]->cs2.GetCount()) {
+ if (curchunk >= pAF->m_strms[i]->cs2.GetCount()) {
continue;
}
CAviFile::strm_t::chunk2& cs2 = pAF->m_strms[i]->cs2[curchunk];
- if(cs2.t < cs2min.t) {
+ if (cs2.t < cs2min.t) {
cs2min = cs2;
n = i;
}
}
- if(n == -1) {
+ if (n == -1) {
break;
}
@@ -296,9 +296,9 @@ bool CAviPlotterWnd::Create(CAviFile* pAF, CRect r, CWnd* pParentWnd) CPoint p;
p.x = (int)(1.0 * w * cs2min.t / tmax);
p.y = (int)(h - 1.0 * h * cs2min.n / nmax);
- if(pp[n] != p) {
+ if (pp[n] != p) {
CPen* pOldPen = m_dc.SelectObject(&pen[n]);
- if(pp[n] == CPoint(-1, -1)) {
+ if (pp[n] == CPoint(-1, -1)) {
m_dc.MoveTo(p);
} else {
m_dc.MoveTo(pp[n]);
@@ -310,8 +310,8 @@ bool CAviPlotterWnd::Create(CAviFile* pAF, CRect r, CWnd* pParentWnd) int dist = abs((int)cs2min.n - (int)cs2last.n);
- if(cs2last.t != (DWORD)-1 /*&& dist >= 1000*/) {
- if(p.x >= 0 && p.x < w) {
+ if (cs2last.t != (DWORD)-1 /*&& dist >= 1000*/) {
+ if (p.x >= 0 && p.x < w) {
m_chunkdist[p.x] = max(m_chunkdist[p.x], dist);
}
}
@@ -323,7 +323,7 @@ bool CAviPlotterWnd::Create(CAviFile* pAF, CRect r, CWnd* pParentWnd) CPen red(PS_SOLID, 1, 0x0000ff);
CPen green(PS_SOLID, 1, 0x00ff00);
- for(int x = 0; x < w; ++x) {
+ for (int x = 0; x < w; ++x) {
CPen* pOldPen = m_dc.SelectObject(m_chunkdist[x] >= 1000 ? &red : &green);
m_dc.MoveTo(x, h);
m_dc.LineTo(x, h + GRAPHFOOTER);
diff --git a/src/filters/parser/AviSplitter/AviSplitter.cpp b/src/filters/parser/AviSplitter/AviSplitter.cpp index 7022434cd..517a02e5d 100644 --- a/src/filters/parser/AviSplitter/AviSplitter.cpp +++ b/src/filters/parser/AviSplitter/AviSplitter.cpp @@ -80,7 +80,7 @@ public: CAviSplitterApp() {}
BOOL InitInstance() {
- if(!__super::InitInstance()) {
+ if (!__super::InitInstance()) {
return FALSE;
}
DllEntryPoint(m_hInstance, DLL_PROCESS_ATTACH, 0);
@@ -137,7 +137,7 @@ STDMETHODIMP CAviSplitterFilter::QueryFilterInfo(FILTER_INFO* pInfo) wcscpy(pInfo->achName, AviSourceName);
}
pInfo->pGraph = m_pGraph;
- if(m_pGraph) {
+ if (m_pGraph) {
m_pGraph->AddRef();
}
@@ -154,20 +154,20 @@ HRESULT CAviSplitterFilter::CreateOutputs(IAsyncReader* pAsyncReader) m_tFrame.Free();
m_pFile.Attach(DNew CAviFile(pAsyncReader, hr));
- if(!m_pFile) {
+ if (!m_pFile) {
return E_OUTOFMEMORY;
}
bool fShiftDown = !!(::GetKeyState(VK_SHIFT)&0x8000);
bool fShowWarningText = !m_pFile->IsInterleaved(fShiftDown);
- if(SUCCEEDED(hr) && (fShowWarningText || fShiftDown)) {
+ if (SUCCEEDED(hr) && (fShowWarningText || fShiftDown)) {
#ifdef REGISTER_FILTER
AFX_MANAGE_STATE(AfxGetStaticModuleState());
#endif
bool fHideWarning = !!AfxGetApp()->GetProfileInt(_T("Settings"), _T("HideAviSplitterWarning"), 0);
- if(!fHideWarning && !dynamic_cast<CAviSourceFilter*>(this) || fShiftDown) {
+ if (!fHideWarning && !dynamic_cast<CAviSourceFilter*>(this) || fShiftDown) {
CAviReportWnd wnd;
fHideWarning = wnd.DoModal(m_pFile, fHideWarning, fShowWarningText);
AfxGetApp()->WriteProfileInt(_T("Settings"), _T("HideAviSplitterWarning"), fHideWarning);
@@ -179,7 +179,7 @@ HRESULT CAviSplitterFilter::CreateOutputs(IAsyncReader* pAsyncReader) */
}
- if(FAILED(hr)) {
+ if (FAILED(hr)) {
m_pFile.Free();
return hr;
}
@@ -189,15 +189,15 @@ HRESULT CAviSplitterFilter::CreateOutputs(IAsyncReader* pAsyncReader) bool fHasIndex = false;
- for(unsigned int i = 0; !fHasIndex && i < m_pFile->m_strms.GetCount(); ++i)
- if(m_pFile->m_strms[i]->cs.GetCount() > 0) {
+ for (unsigned int i = 0; !fHasIndex && i < m_pFile->m_strms.GetCount(); ++i)
+ if (m_pFile->m_strms[i]->cs.GetCount() > 0) {
fHasIndex = true;
}
- for(unsigned int i = 0; i < m_pFile->m_strms.GetCount(); ++i) {
+ for (unsigned int i = 0; i < m_pFile->m_strms.GetCount(); ++i) {
CAviFile::strm_t* s = m_pFile->m_strms[i];
- if(fHasIndex && s->cs.GetCount() == 0) {
+ if (fHasIndex && s->cs.GetCount() == 0) {
continue;
}
@@ -206,7 +206,7 @@ HRESULT CAviSplitterFilter::CreateOutputs(IAsyncReader* pAsyncReader) CStringW name, label;
- if(s->strh.fccType == FCC('vids')) {
+ if (s->strh.fccType == FCC('vids')) {
label = L"Video";
ASSERT(s->strf.GetCount() >= sizeof(BITMAPINFOHEADER));
@@ -214,7 +214,7 @@ HRESULT CAviSplitterFilter::CreateOutputs(IAsyncReader* pAsyncReader) BITMAPINFOHEADER* pbmi = &((BITMAPINFO*)s->strf.GetData())->bmiHeader;
mt.majortype = MEDIATYPE_Video;
- switch(pbmi->biCompression) {
+ switch (pbmi->biCompression) {
case BI_RGB:
case BI_BITFIELDS:
mt.subtype =
@@ -239,13 +239,13 @@ HRESULT CAviSplitterFilter::CreateOutputs(IAsyncReader* pAsyncReader) VIDEOINFOHEADER* pvih = (VIDEOINFOHEADER*)mt.AllocFormatBuffer(sizeof(VIDEOINFOHEADER) + s->strf.GetCount() - sizeof(BITMAPINFOHEADER));
memset(mt.Format(), 0, mt.FormatLength());
memcpy(&pvih->bmiHeader, s->strf.GetData(), s->strf.GetCount());
- if(s->strh.dwRate > 0) {
+ if (s->strh.dwRate > 0) {
pvih->AvgTimePerFrame = 10000000ui64 * s->strh.dwScale / s->strh.dwRate;
}
- if(s->cs.GetCount() && pvih->AvgTimePerFrame > 0) {
+ if (s->cs.GetCount() && pvih->AvgTimePerFrame > 0) {
UINT64 size = 0;
- for(unsigned int i = 0; i < s->cs.GetCount(); ++i) {
+ for (unsigned int i = 0; i < s->cs.GetCount(); ++i) {
size += s->cs[i].orgsize;
}
pvih->dwBitRate = (DWORD)(10000000.0 * size * 8 / (s->cs.GetCount() * pvih->AvgTimePerFrame) + 0.5);
@@ -256,7 +256,7 @@ HRESULT CAviSplitterFilter::CreateOutputs(IAsyncReader* pAsyncReader) ? s->strh.dwSuggestedBufferSize*3/2
: (pvih->bmiHeader.biWidth*pvih->bmiHeader.biHeight*4));
mts.Add(mt);
- } else if(s->strh.fccType == FCC('auds') || s->strh.fccType == FCC('amva')) {
+ } else if (s->strh.fccType == FCC('auds') || s->strh.fccType == FCC('amva')) {
label = L"Audio";
ASSERT(s->strf.GetCount() >= sizeof(WAVEFORMATEX)
@@ -264,7 +264,7 @@ HRESULT CAviSplitterFilter::CreateOutputs(IAsyncReader* pAsyncReader) WAVEFORMATEX* pwfe = (WAVEFORMATEX*)s->strf.GetData();
- if(pwfe->nBlockAlign == 0) {
+ if (pwfe->nBlockAlign == 0) {
continue;
}
@@ -277,20 +277,20 @@ HRESULT CAviSplitterFilter::CreateOutputs(IAsyncReader* pAsyncReader) mt.formattype = FORMAT_WaveFormatEx;
mt.SetFormat(s->strf.GetData(), max(s->strf.GetCount(), sizeof(WAVEFORMATEX)));
pwfe = (WAVEFORMATEX*)mt.Format();
- if(s->strf.GetCount() == sizeof(PCMWAVEFORMAT)) {
+ if (s->strf.GetCount() == sizeof(PCMWAVEFORMAT)) {
pwfe->cbSize = 0;
}
- if(pwfe->wFormatTag == WAVE_FORMAT_PCM) {
+ if (pwfe->wFormatTag == WAVE_FORMAT_PCM) {
pwfe->nBlockAlign = pwfe->nChannels*pwfe->wBitsPerSample>>3;
}
- if(pwfe->wFormatTag == WAVE_FORMAT_EXTENSIBLE) {
+ if (pwfe->wFormatTag == WAVE_FORMAT_EXTENSIBLE) {
mt.subtype = FOURCCMap(WAVE_FORMAT_PCM); // audio renderer doesn't accept fffe in the subtype
}
mt.SetSampleSize(s->strh.dwSuggestedBufferSize > 0
? s->strh.dwSuggestedBufferSize*3/2
: (pwfe->nChannels*pwfe->nSamplesPerSec*32>>3));
mts.Add(mt);
- } else if(s->strh.fccType == FCC('mids')) {
+ } else if (s->strh.fccType == FCC('mids')) {
label = L"Midi";
mt.majortype = MEDIATYPE_Midi;
@@ -300,7 +300,7 @@ HRESULT CAviSplitterFilter::CreateOutputs(IAsyncReader* pAsyncReader) ? s->strh.dwSuggestedBufferSize*3/2
: (1024*1024));
mts.Add(mt);
- } else if(s->strh.fccType == FCC('txts')) {
+ } else if (s->strh.fccType == FCC('txts')) {
label = L"Text";
mt.majortype = MEDIATYPE_Text;
@@ -310,7 +310,7 @@ HRESULT CAviSplitterFilter::CreateOutputs(IAsyncReader* pAsyncReader) ? s->strh.dwSuggestedBufferSize*3/2
: (1024*1024));
mts.Add(mt);
- } else if(s->strh.fccType == FCC('iavs')) {
+ } else if (s->strh.fccType == FCC('iavs')) {
label = L"Interleaved";
ASSERT(s->strh.fccHandler == FCC('dvsd'));
@@ -325,7 +325,7 @@ HRESULT CAviSplitterFilter::CreateOutputs(IAsyncReader* pAsyncReader) mts.Add(mt);
}
- if(mts.IsEmpty()) {
+ if (mts.IsEmpty()) {
TRACE(_T("CAviSourceFilter: Unsupported stream (%d)\n"), i);
continue;
}
@@ -333,7 +333,7 @@ HRESULT CAviSplitterFilter::CreateOutputs(IAsyncReader* pAsyncReader) //Put filename at front sometime(eg. ~temp.avi) will cause filter graph
//stop check this pin. Not sure the reason exactly. but it happens.
//If you know why, please emailto: tomasen@gmail.com
- if(s->strn.IsEmpty()) {
+ if (s->strn.IsEmpty()) {
name.Format(L"%s %u", label, i);
} else {
name.Format(L"%s (%s %u)", CStringW(s->strn), label, i);
@@ -346,12 +346,12 @@ HRESULT CAviSplitterFilter::CreateOutputs(IAsyncReader* pAsyncReader) }
POSITION pos = m_pFile->m_info.GetStartPosition();
- while(pos) {
+ while (pos) {
DWORD fcc;
CStringA value;
m_pFile->m_info.GetNextAssoc(pos, fcc, value);
- switch(fcc) {
+ switch (fcc) {
case FCC('INAM'):
SetProperty(L"TITL", CStringW(value));
break;
@@ -376,7 +376,7 @@ bool CAviSplitterFilter::DemuxInit() {
SetThreadName((DWORD)-1, "CAviSplitterFilter");
- if(!m_pFile) {
+ if (!m_pFile) {
return false;
}
@@ -384,13 +384,13 @@ bool CAviSplitterFilter::DemuxInit() bool fReIndex = false;
- for(DWORD i = 0; i < m_pFile->m_avih.dwStreams && !fReIndex; ++i) {
- if(m_pFile->m_strms[i]->cs.GetCount() == 0 && GetOutputPin(i)) {
+ for (DWORD i = 0; i < m_pFile->m_avih.dwStreams && !fReIndex; ++i) {
+ if (m_pFile->m_strms[i]->cs.GetCount() == 0 && GetOutputPin(i)) {
fReIndex = true;
}
}
- if(fReIndex) {
+ if (fReIndex) {
m_pFile->EmptyIndex();
m_fAbort = false;
@@ -404,7 +404,7 @@ bool CAviSplitterFilter::DemuxInit() m_pFile->Seek(0);
ReIndex(m_pFile->GetLength(), pSize);
- if(m_fAbort) {
+ if (m_fAbort) {
m_pFile->EmptyIndex();
}
@@ -419,37 +419,37 @@ HRESULT CAviSplitterFilter::ReIndex(__int64 end, UINT64* pSize) {
HRESULT hr = S_OK;
- while(S_OK == hr && m_pFile->GetPos() < end && SUCCEEDED(hr) && !m_fAbort) {
+ while (S_OK == hr && m_pFile->GetPos() < end && SUCCEEDED(hr) && !m_fAbort) {
__int64 pos = m_pFile->GetPos();
DWORD id = 0, size;
- if(S_OK != m_pFile->Read(id) || id == 0) {
+ if (S_OK != m_pFile->Read(id) || id == 0) {
return E_FAIL;
}
- if(id == FCC('RIFF') || id == FCC('LIST')) {
- if(S_OK != m_pFile->Read(size) || S_OK != m_pFile->Read(id)) {
+ if (id == FCC('RIFF') || id == FCC('LIST')) {
+ if (S_OK != m_pFile->Read(size) || S_OK != m_pFile->Read(id)) {
return E_FAIL;
}
size += (size&1) + 8;
- if(id == FCC('AVI ') || id == FCC('AVIX') || id == FCC('movi') || id == FCC('rec ')) {
+ if (id == FCC('AVI ') || id == FCC('AVIX') || id == FCC('movi') || id == FCC('rec ')) {
hr = ReIndex(pos + size, pSize);
}
} else {
- if(S_OK != m_pFile->Read(size)) {
+ if (S_OK != m_pFile->Read(size)) {
return E_FAIL;
}
DWORD TrackNumber = TRACKNUM(id);
- if(TrackNumber < m_pFile->m_strms.GetCount()) {
+ if (TrackNumber < m_pFile->m_strms.GetCount()) {
CAviFile::strm_t* s = m_pFile->m_strms[TrackNumber];
WORD type = TRACKTYPE(id);
- if(type == 'db' || type == 'dc' || /*type == 'pc' ||*/ type == 'wb'
+ if (type == 'db' || type == 'dc' || /*type == 'pc' ||*/ type == 'wb'
|| type == 'iv' || type == '__' || type == 'xx') {
CAviFile::strm_t::chunk c;
c.filepos = pos;
@@ -474,8 +474,8 @@ HRESULT CAviSplitterFilter::ReIndex(__int64 end, UINT64* pSize) m_nOpenProgress = m_pFile->GetPos()*100/m_pFile->GetLength();
DWORD cmd;
- if(CheckRequest(&cmd)) {
- if(cmd == CMD_EXIT) {
+ if (CheckRequest(&cmd)) {
+ if (cmd == CMD_EXIT) {
m_fAbort = true;
} else {
Reply(S_OK);
@@ -493,26 +493,26 @@ void CAviSplitterFilter::DemuxSeek(REFERENCE_TIME rt) DbgLog((LOG_TRACE, 0, _T("Seek: %I64d"), rt/10000));
- if(rt > 0) {
+ if (rt > 0) {
UINT64 minfp = _I64_MAX;
- for(unsigned int j = 0; j < m_pFile->m_strms.GetCount(); ++j) {
+ for (unsigned int j = 0; j < m_pFile->m_strms.GetCount(); ++j) {
CAviFile::strm_t* s = m_pFile->m_strms[j];
DWORD f = s->GetKeyFrame(rt);
UINT64 fp = s->cs[f].filepos;
- if(!s->IsRawSubtitleStream()) {
+ if (!s->IsRawSubtitleStream()) {
minfp = min(minfp, fp);
}
}
- for(unsigned int j = 0; j < m_pFile->m_strms.GetCount(); ++j) {
+ for (unsigned int j = 0; j < m_pFile->m_strms.GetCount(); ++j) {
CAviFile::strm_t* s = m_pFile->m_strms[j];
- for(unsigned int i = 0; i < s->cs.GetCount(); ++i) {
+ for (unsigned int i = 0; i < s->cs.GetCount(); ++i) {
CAviFile::strm_t::chunk& c = s->cs[i];
- if(c.filepos >= minfp) {
+ if (c.filepos >= minfp) {
m_tFrame[j] = i;
break;
}
@@ -532,31 +532,31 @@ bool CAviSplitterFilter::DemuxLoop() fDiscontinuity.SetCount(nTracks);
memset(fDiscontinuity.GetData(), 0, nTracks*sizeof(bool));
- while(SUCCEEDED(hr) && !CheckRequest(NULL)) {
+ while (SUCCEEDED(hr) && !CheckRequest(NULL)) {
unsigned int minTrack = nTracks;
UINT64 minFilePos = _I64_MAX;
- for(unsigned int i = 0; i < nTracks; ++i) {
+ for (unsigned int i = 0; i < nTracks; ++i) {
CAviFile::strm_t* s = m_pFile->m_strms[i];
DWORD f = m_tFrame[i];
- if(f >= (DWORD)s->cs.GetCount()) {
+ if (f >= (DWORD)s->cs.GetCount()) {
continue;
}
bool fUrgent = s->IsRawSubtitleStream();
- if(fUrgent || s->cs[f].filepos < minFilePos) {
+ if (fUrgent || s->cs[f].filepos < minFilePos) {
minTrack = i;
minFilePos = s->cs[f].filepos;
}
- if(fUrgent) {
+ if (fUrgent) {
break;
}
}
- if(minTrack == nTracks) {
+ if (minTrack == nTracks) {
break;
}
@@ -569,9 +569,9 @@ bool CAviSplitterFilter::DemuxLoop() DWORD size = 0;
- if(s->cs[f].fChunkHdr) {
+ if (s->cs[f].fChunkHdr) {
DWORD id = 0;
- if(S_OK != m_pFile->Read(id) || id == 0 || minTrack != TRACKNUM(id)
+ if (S_OK != m_pFile->Read(id) || id == 0 || minTrack != TRACKNUM(id)
|| S_OK != m_pFile->Read(size)) {
fDiscontinuity[minTrack] = true;
break;
@@ -582,7 +582,7 @@ bool CAviSplitterFilter::DemuxLoop() ? s->cs[f+1].size - s->cs[f].size
: s->totalsize - s->cs[f].size;
- if(expectedsize != s->GetChunkSize(size)) {
+ if (expectedsize != s->GetChunkSize(size)) {
fDiscontinuity[minTrack] = true;
//ASSERT(0);
break;
@@ -600,7 +600,7 @@ bool CAviSplitterFilter::DemuxLoop() p->rtStop = s->GetRefTime(f+1, f+1 < (DWORD)s->cs.GetCount() ? s->cs[f+1].size : s->totalsize);
p->SetCount(size);
- if(S_OK != (hr = m_pFile->ByteRead(p->GetData(), p->GetCount()))) {
+ if (S_OK != (hr = m_pFile->ByteRead(p->GetData(), p->GetCount()))) {
return true; // break;
}
/*
@@ -613,7 +613,7 @@ bool CAviSplitterFilter::DemuxLoop() hr = DeliverPacket(p);
fDiscontinuity[minTrack] = false;
- } while(0);
+ } while (0);
++f;
}
@@ -628,10 +628,10 @@ STDMETHODIMP CAviSplitterFilter::GetDuration(LONGLONG* pDuration) CheckPointer(pDuration, E_POINTER);
CheckPointer(m_pFile, VFW_E_NOT_CONNECTED);
- if(m_timeformat == TIME_FORMAT_FRAME) {
- for(unsigned int i = 0; i < m_pFile->m_strms.GetCount(); ++i) {
+ if (m_timeformat == TIME_FORMAT_FRAME) {
+ for (unsigned int i = 0; i < m_pFile->m_strms.GetCount(); ++i) {
CAviFile::strm_t* s = m_pFile->m_strms[i];
- if(s->strh.fccType == FCC('vids')) {
+ if (s->strh.fccType == FCC('vids')) {
*pDuration = s->cs.GetCount();
return S_OK;
}
@@ -649,7 +649,7 @@ STDMETHODIMP CAviSplitterFilter::IsFormatSupported(const GUID* pFormat) {
CheckPointer(pFormat, E_POINTER);
HRESULT hr = __super::IsFormatSupported(pFormat);
- if(S_OK == hr) {
+ if (S_OK == hr) {
return hr;
}
return *pFormat == TIME_FORMAT_FRAME ? S_OK : S_FALSE;
@@ -671,7 +671,7 @@ STDMETHODIMP CAviSplitterFilter::IsUsingTimeFormat(const GUID* pFormat) STDMETHODIMP CAviSplitterFilter::SetTimeFormat(const GUID* pFormat)
{
CheckPointer(pFormat, E_POINTER);
- if(S_OK != IsFormatSupported(pFormat)) {
+ if (S_OK != IsFormatSupported(pFormat)) {
return E_FAIL;
}
m_timeformat = *pFormat;
@@ -681,14 +681,14 @@ STDMETHODIMP CAviSplitterFilter::SetTimeFormat(const GUID* pFormat) STDMETHODIMP CAviSplitterFilter::GetStopPosition(LONGLONG* pStop)
{
CheckPointer(pStop, E_POINTER);
- if(FAILED(__super::GetStopPosition(pStop))) {
+ if (FAILED(__super::GetStopPosition(pStop))) {
return E_FAIL;
}
- if(m_timeformat == TIME_FORMAT_MEDIA_TIME) {
+ if (m_timeformat == TIME_FORMAT_MEDIA_TIME) {
return S_OK;
}
LONGLONG rt = *pStop;
- if(FAILED(ConvertTimeFormat(pStop, &TIME_FORMAT_FRAME, rt, &TIME_FORMAT_MEDIA_TIME))) {
+ if (FAILED(ConvertTimeFormat(pStop, &TIME_FORMAT_FRAME, rt, &TIME_FORMAT_MEDIA_TIME))) {
return E_FAIL;
}
return S_OK;
@@ -701,22 +701,22 @@ STDMETHODIMP CAviSplitterFilter::ConvertTimeFormat(LONGLONG* pTarget, const GUID const GUID& SourceFormat = pSourceFormat ? *pSourceFormat : m_timeformat;
const GUID& TargetFormat = pTargetFormat ? *pTargetFormat : m_timeformat;
- if(TargetFormat == SourceFormat) {
+ if (TargetFormat == SourceFormat) {
*pTarget = Source;
return S_OK;
- } else if(TargetFormat == TIME_FORMAT_FRAME && SourceFormat == TIME_FORMAT_MEDIA_TIME) {
- for(unsigned int i = 0; i < m_pFile->m_strms.GetCount(); ++i) {
+ } else if (TargetFormat == TIME_FORMAT_FRAME && SourceFormat == TIME_FORMAT_MEDIA_TIME) {
+ for (unsigned int i = 0; i < m_pFile->m_strms.GetCount(); ++i) {
CAviFile::strm_t* s = m_pFile->m_strms[i];
- if(s->strh.fccType == FCC('vids')) {
+ if (s->strh.fccType == FCC('vids')) {
*pTarget = s->GetFrame(Source);
return S_OK;
}
}
- } else if(TargetFormat == TIME_FORMAT_MEDIA_TIME && SourceFormat == TIME_FORMAT_FRAME) {
- for(unsigned int i = 0; i < m_pFile->m_strms.GetCount(); ++i) {
+ } else if (TargetFormat == TIME_FORMAT_MEDIA_TIME && SourceFormat == TIME_FORMAT_FRAME) {
+ for (unsigned int i = 0; i < m_pFile->m_strms.GetCount(); ++i) {
CAviFile::strm_t* s = m_pFile->m_strms[i];
- if(s->strh.fccType == FCC('vids')) {
- if(Source < 0 || Source >= s->cs.GetCount()) {
+ if (s->strh.fccType == FCC('vids')) {
+ if (Source < 0 || Source >= s->cs.GetCount()) {
return E_FAIL;
}
CAviFile::strm_t::chunk& c = s->cs[(size_t)Source];
@@ -732,16 +732,16 @@ STDMETHODIMP CAviSplitterFilter::ConvertTimeFormat(LONGLONG* pTarget, const GUID STDMETHODIMP CAviSplitterFilter::GetPositions(LONGLONG* pCurrent, LONGLONG* pStop)
{
HRESULT hr;
- if(FAILED(hr = __super::GetPositions(pCurrent, pStop)) || m_timeformat != TIME_FORMAT_FRAME) {
+ if (FAILED(hr = __super::GetPositions(pCurrent, pStop)) || m_timeformat != TIME_FORMAT_FRAME) {
return hr;
}
- if(pCurrent)
- if(FAILED(ConvertTimeFormat(pCurrent, &TIME_FORMAT_FRAME, *pCurrent, &TIME_FORMAT_MEDIA_TIME))) {
+ if (pCurrent)
+ if (FAILED(ConvertTimeFormat(pCurrent, &TIME_FORMAT_FRAME, *pCurrent, &TIME_FORMAT_MEDIA_TIME))) {
return E_FAIL;
}
- if(pStop)
- if(FAILED(ConvertTimeFormat(pStop, &TIME_FORMAT_FRAME, *pStop, &TIME_FORMAT_MEDIA_TIME))) {
+ if (pStop)
+ if (FAILED(ConvertTimeFormat(pStop, &TIME_FORMAT_FRAME, *pStop, &TIME_FORMAT_MEDIA_TIME))) {
return E_FAIL;
}
@@ -750,11 +750,11 @@ STDMETHODIMP CAviSplitterFilter::GetPositions(LONGLONG* pCurrent, LONGLONG* pSto HRESULT CAviSplitterFilter::SetPositionsInternal(void* id, LONGLONG* pCurrent, DWORD dwCurrentFlags, LONGLONG* pStop, DWORD dwStopFlags)
{
- if(m_timeformat != TIME_FORMAT_FRAME) {
+ if (m_timeformat != TIME_FORMAT_FRAME) {
return __super::SetPositionsInternal(id, pCurrent, dwCurrentFlags, pStop, dwStopFlags);
}
- if(!pCurrent && !pStop
+ if (!pCurrent && !pStop
|| (dwCurrentFlags&AM_SEEKING_PositioningBitsMask) == AM_SEEKING_NoPositioning
&& (dwStopFlags&AM_SEEKING_PositioningBitsMask) == AM_SEEKING_NoPositioning) {
return S_OK;
@@ -764,17 +764,17 @@ HRESULT CAviSplitterFilter::SetPositionsInternal(void* id, LONGLONG* pCurrent, D rtCurrent = m_rtCurrent,
rtStop = m_rtStop;
- if((dwCurrentFlags&AM_SEEKING_PositioningBitsMask)
+ if ((dwCurrentFlags&AM_SEEKING_PositioningBitsMask)
&& FAILED(ConvertTimeFormat(&rtCurrent, &TIME_FORMAT_FRAME, rtCurrent, &TIME_FORMAT_MEDIA_TIME))) {
return E_FAIL;
}
- if((dwStopFlags&AM_SEEKING_PositioningBitsMask)
+ if ((dwStopFlags&AM_SEEKING_PositioningBitsMask)
&& FAILED(ConvertTimeFormat(&rtStop, &TIME_FORMAT_FRAME, rtStop, &TIME_FORMAT_MEDIA_TIME))) {
return E_FAIL;
}
- if(pCurrent)
- switch(dwCurrentFlags&AM_SEEKING_PositioningBitsMask) {
+ if (pCurrent)
+ switch (dwCurrentFlags&AM_SEEKING_PositioningBitsMask) {
case AM_SEEKING_NoPositioning:
break;
case AM_SEEKING_AbsolutePositioning:
@@ -788,8 +788,8 @@ HRESULT CAviSplitterFilter::SetPositionsInternal(void* id, LONGLONG* pCurrent, D break;
}
- if(pStop)
- switch(dwStopFlags&AM_SEEKING_PositioningBitsMask) {
+ if (pStop)
+ switch (dwStopFlags&AM_SEEKING_PositioningBitsMask) {
case AM_SEEKING_NoPositioning:
break;
case AM_SEEKING_AbsolutePositioning:
@@ -803,14 +803,14 @@ HRESULT CAviSplitterFilter::SetPositionsInternal(void* id, LONGLONG* pCurrent, D break;
}
- if((dwCurrentFlags&AM_SEEKING_PositioningBitsMask)
+ if ((dwCurrentFlags&AM_SEEKING_PositioningBitsMask)
&& pCurrent)
- if(FAILED(ConvertTimeFormat(pCurrent, &TIME_FORMAT_MEDIA_TIME, rtCurrent, &TIME_FORMAT_FRAME))) {
+ if (FAILED(ConvertTimeFormat(pCurrent, &TIME_FORMAT_MEDIA_TIME, rtCurrent, &TIME_FORMAT_FRAME))) {
return E_FAIL;
}
- if((dwStopFlags&AM_SEEKING_PositioningBitsMask)
+ if ((dwStopFlags&AM_SEEKING_PositioningBitsMask)
&& pStop)
- if(FAILED(ConvertTimeFormat(pStop, &TIME_FORMAT_MEDIA_TIME, rtStop, &TIME_FORMAT_FRAME))) {
+ if (FAILED(ConvertTimeFormat(pStop, &TIME_FORMAT_MEDIA_TIME, rtStop, &TIME_FORMAT_FRAME))) {
return E_FAIL;
}
@@ -821,7 +821,7 @@ HRESULT CAviSplitterFilter::SetPositionsInternal(void* id, LONGLONG* pCurrent, D STDMETHODIMP CAviSplitterFilter::GetKeyFrameCount(UINT& nKFs)
{
- if(!m_pFile) {
+ if (!m_pFile) {
return E_UNEXPECTED;
}
@@ -829,20 +829,20 @@ STDMETHODIMP CAviSplitterFilter::GetKeyFrameCount(UINT& nKFs) nKFs = 0;
- for(unsigned int i = 0; i < m_pFile->m_strms.GetCount(); ++i) {
+ for (unsigned int i = 0; i < m_pFile->m_strms.GetCount(); ++i) {
CAviFile::strm_t* s = m_pFile->m_strms[i];
- if(s->strh.fccType != FCC('vids')) {
+ if (s->strh.fccType != FCC('vids')) {
continue;
}
- for(unsigned int j = 0; j < s->cs.GetCount(); ++j) {
+ for (unsigned int j = 0; j < s->cs.GetCount(); ++j) {
CAviFile::strm_t::chunk& c = s->cs[j];
- if(c.fKeyFrame) {
+ if (c.fKeyFrame) {
++nKFs;
}
}
- if(nKFs == s->cs.GetCount()) {
+ if (nKFs == s->cs.GetCount()) {
hr = S_FALSE;
}
@@ -857,25 +857,25 @@ STDMETHODIMP CAviSplitterFilter::GetKeyFrames(const GUID* pFormat, REFERENCE_TIM CheckPointer(pFormat, E_POINTER);
CheckPointer(pKFs, E_POINTER);
- if(!m_pFile) {
+ if (!m_pFile) {
return E_UNEXPECTED;
}
- if(*pFormat != TIME_FORMAT_MEDIA_TIME && *pFormat != TIME_FORMAT_FRAME) {
+ if (*pFormat != TIME_FORMAT_MEDIA_TIME && *pFormat != TIME_FORMAT_FRAME) {
return E_INVALIDARG;
}
UINT nKFsTmp = 0;
- for(unsigned int i = 0; i < m_pFile->m_strms.GetCount(); ++i) {
+ for (unsigned int i = 0; i < m_pFile->m_strms.GetCount(); ++i) {
CAviFile::strm_t* s = m_pFile->m_strms[i];
- if(s->strh.fccType != FCC('vids')) {
+ if (s->strh.fccType != FCC('vids')) {
continue;
}
bool fConvertToRefTime = !!(*pFormat == TIME_FORMAT_MEDIA_TIME);
- for(unsigned int j = 0; j < s->cs.GetCount() && nKFsTmp < nKFs; ++j) {
- if(s->cs[j].fKeyFrame) {
+ for (unsigned int j = 0; j < s->cs.GetCount() && nKFsTmp < nKFs; ++j) {
+ if (s->cs[j].fKeyFrame) {
pKFs[nKFsTmp++] = fConvertToRefTime ? s->GetRefTime(j, s->cs[j].size) : j;
}
}
@@ -912,13 +912,13 @@ HRESULT CAviSplitterOutputPin::CheckConnect(IPin* pPin) {
int iPosition = 0;
CMediaType mt;
- while(S_OK == GetMediaType(iPosition++, &mt)) {
- if(mt.majortype == MEDIATYPE_Video
+ while (S_OK == GetMediaType(iPosition++, &mt)) {
+ if (mt.majortype == MEDIATYPE_Video
&& (mt.subtype == FOURCCMap(FCC('IV32'))
|| mt.subtype == FOURCCMap(FCC('IV31'))
|| mt.subtype == FOURCCMap(FCC('IF09')))) {
CLSID clsid = GetCLSID(GetFilterFromPin(pPin));
- if(clsid == CLSID_VideoMixingRenderer || clsid == CLSID_OverlayMixer) {
+ if (clsid == CLSID_VideoMixingRenderer || clsid == CLSID_OverlayMixer) {
return E_FAIL;
}
}
diff --git a/src/filters/parser/BaseSplitter/AsyncReader.cpp b/src/filters/parser/BaseSplitter/AsyncReader.cpp index c0217ae4d..42be1f26c 100644 --- a/src/filters/parser/BaseSplitter/AsyncReader.cpp +++ b/src/filters/parser/BaseSplitter/AsyncReader.cpp @@ -37,7 +37,7 @@ CAsyncFileReader::CAsyncFileReader(CString fn, HRESULT& hr) , m_lOsError(0)
{
hr = Open(fn, modeRead|shareDenyNone|typeBinary|osSequentialScan) ? S_OK : E_FAIL;
- if(SUCCEEDED(hr)) {
+ if (SUCCEEDED(hr)) {
m_len = GetLength();
}
}
@@ -49,7 +49,7 @@ CAsyncFileReader::CAsyncFileReader(CAtlList<CHdmvClipInfo::PlaylistItem>& Items, , m_lOsError(0)
{
hr = OpenFiles(Items, modeRead|shareDenyNone|typeBinary|osSequentialScan) ? S_OK : E_FAIL;
- if(SUCCEEDED(hr)) {
+ if (SUCCEEDED(hr)) {
m_len = GetLength();
}
}
@@ -71,44 +71,44 @@ STDMETHODIMP CAsyncFileReader::SyncRead(LONGLONG llPosition, LONG lLength, BYTE* {
do {
try {
- if((ULONGLONG)llPosition+lLength > GetLength()) {
+ if ((ULONGLONG)llPosition+lLength > GetLength()) {
return E_FAIL; // strange, but the Seek below can return llPosition even if the file is not that big (?)
}
- if((ULONGLONG)llPosition != Seek(llPosition, begin)) {
+ if ((ULONGLONG)llPosition != Seek(llPosition, begin)) {
return E_FAIL;
}
- if((UINT)lLength < Read(pBuffer, lLength)) {
+ if ((UINT)lLength < Read(pBuffer, lLength)) {
return E_FAIL;
}
#if 0 // def DEBUG
static __int64 s_total = 0, s_laststoppos = 0;
s_total += lLength;
- if(s_laststoppos > llPosition) {
+ if (s_laststoppos > llPosition) {
TRACE(_T("[%I64d - %I64d] %d (%I64d)\n"), llPosition, llPosition + lLength, lLength, s_total);
}
s_laststoppos = llPosition + lLength;
#endif
return S_OK;
- } catch(CFileException* e) {
+ } catch (CFileException* e) {
m_lOsError = e->m_lOsError;
e->Delete();
Sleep(1);
CString fn = m_strFileName;
try {
Close();
- } catch(CFileException* e) {
+ } catch (CFileException* e) {
e->Delete();
}
try {
Open(fn, modeRead|shareDenyNone|typeBinary|osSequentialScan);
- } catch(CFileException* e) {
+ } catch (CFileException* e) {
e->Delete();
}
m_strFileName = fn;
}
- } while(m_hBreakEvent && WaitForSingleObject(m_hBreakEvent, 0) == WAIT_TIMEOUT);
+ } while (m_hBreakEvent && WaitForSingleObject(m_hBreakEvent, 0) == WAIT_TIMEOUT);
return E_FAIL;
}
@@ -116,10 +116,10 @@ STDMETHODIMP CAsyncFileReader::SyncRead(LONGLONG llPosition, LONG lLength, BYTE* STDMETHODIMP CAsyncFileReader::Length(LONGLONG* pTotal, LONGLONG* pAvailable)
{
LONGLONG len = m_len >= 0 ? m_len : GetLength();
- if(pTotal) {
+ if (pTotal) {
*pTotal = len;
}
- if(pAvailable) {
+ if (pAvailable) {
*pAvailable = len;
}
return S_OK;
@@ -144,13 +144,13 @@ STDMETHODIMP_(LPCTSTR) CAsyncFileReader::GetFileName() CAsyncUrlReader::CAsyncUrlReader(CString url, HRESULT& hr)
: CAsyncFileReader(url, hr)
{
- if(SUCCEEDED(hr)) {
+ if (SUCCEEDED(hr)) {
return;
}
m_url = url;
- if(CAMThread::Create()) {
+ if (CAMThread::Create()) {
CallWorker(CMD_INIT);
}
@@ -160,11 +160,11 @@ CAsyncUrlReader::CAsyncUrlReader(CString url, HRESULT& hr) CAsyncUrlReader::~CAsyncUrlReader()
{
- if(ThreadExists()) {
+ if (ThreadExists()) {
CallWorker(CMD_EXIT);
}
- if(!m_fn.IsEmpty()) {
+ if (!m_fn.IsEmpty()) {
CMultiFiles::Close();
DeleteFile(m_fn);
}
@@ -174,7 +174,7 @@ CAsyncUrlReader::~CAsyncUrlReader() STDMETHODIMP CAsyncUrlReader::Length(LONGLONG* pTotal, LONGLONG* pAvailable)
{
- if(pTotal) {
+ if (pTotal) {
*pTotal = 0;
}
return __super::Length(NULL, pAvailable);
@@ -187,7 +187,7 @@ DWORD CAsyncUrlReader::ThreadProc() AfxSocketInit(NULL);
DWORD cmd = GetRequest();
- if(cmd != CMD_INIT) {
+ if (cmd != CMD_INIT) {
Reply((DWORD)E_FAIL);
return (DWORD)-1;
}
@@ -198,21 +198,21 @@ DWORD CAsyncUrlReader::ThreadProc() TCHAR path[_MAX_PATH], fn[_MAX_PATH];
CFile fout;
- if(GetTempPath(MAX_PATH, path) && GetTempFileName(path, _T("mpc_http"), 0, fn)
+ if (GetTempPath(MAX_PATH, path) && GetTempFileName(path, _T("mpc_http"), 0, fn)
&& fout.Open(fn, modeCreate|modeWrite|shareDenyWrite|typeBinary)) {
m_fn = fn;
char buff[1024];
int len = fin->Read(buff, sizeof(buff));
- if(len > 0) {
+ if (len > 0) {
fout.Write(buff, len);
}
Reply(S_OK);
- while(!CheckRequest(&cmd)) {
+ while (!CheckRequest(&cmd)) {
int len = fin->Read(buff, sizeof(buff));
- if(len > 0) {
+ if (len > 0) {
fout.Write(buff, len);
}
}
@@ -221,7 +221,7 @@ DWORD CAsyncUrlReader::ThreadProc() }
fin->Close(); // must close it because the destructor doesn't seem to do it and we will get an exception when "is" is destroying
- } catch(CInternetException* ie) {
+ } catch (CInternetException* ie) {
ie->Delete();
Reply((DWORD)E_FAIL);
}
diff --git a/src/filters/parser/BaseSplitter/BaseSplitter.cpp b/src/filters/parser/BaseSplitter/BaseSplitter.cpp index 589dd2d2f..6c621ff2d 100644 --- a/src/filters/parser/BaseSplitter/BaseSplitter.cpp +++ b/src/filters/parser/BaseSplitter/BaseSplitter.cpp @@ -44,10 +44,10 @@ void CPacketQueue::Add(CAutoPtr<Packet> p) {
CAutoLock cAutoLock(this);
- if(p) {
+ if (p) {
m_size += p->GetDataSize();
- if(p->bAppendable && !p->bDiscontinuity && !p->pmt
+ if (p->bAppendable && !p->bDiscontinuity && !p->pmt
&& p->rtStart == Packet::INVALID_TIME
&& !IsEmpty() && GetTail()->rtStart != Packet::INVALID_TIME) {
Packet* tail = GetTail();
@@ -70,7 +70,7 @@ CAutoPtr<Packet> CPacketQueue::Remove() CAutoLock cAutoLock(this);
ASSERT(__super::GetCount() > 0);
CAutoPtr<Packet> p = RemoveHead();
- if(p) {
+ if (p) {
m_size -= p->GetDataSize();
}
return p;
@@ -138,7 +138,7 @@ HRESULT CBaseSplitterInputPin::CheckMediaType(const CMediaType* pmt) HRESULT CBaseSplitterInputPin::CheckConnect(IPin* pPin)
{
HRESULT hr;
- if(FAILED(hr = __super::CheckConnect(pPin))) {
+ if (FAILED(hr = __super::CheckConnect(pPin))) {
return hr;
}
@@ -149,11 +149,11 @@ HRESULT CBaseSplitterInputPin::BreakConnect() {
HRESULT hr;
- if(FAILED(hr = __super::BreakConnect())) {
+ if (FAILED(hr = __super::BreakConnect())) {
return hr;
}
- if(FAILED(hr = (static_cast<CBaseSplitterFilter*>(m_pFilter))->BreakConnect(PINDIR_INPUT, this))) {
+ if (FAILED(hr = (static_cast<CBaseSplitterFilter*>(m_pFilter))->BreakConnect(PINDIR_INPUT, this))) {
return hr;
}
@@ -166,7 +166,7 @@ HRESULT CBaseSplitterInputPin::CompleteConnect(IPin* pPin) {
HRESULT hr;
- if(FAILED(hr = __super::CompleteConnect(pPin))) {
+ if (FAILED(hr = __super::CompleteConnect(pPin))) {
return hr;
}
@@ -174,7 +174,7 @@ HRESULT CBaseSplitterInputPin::CompleteConnect(IPin* pPin) m_pAsyncReader = pPin;
CheckPointer(m_pAsyncReader, E_NOINTERFACE);
- if(FAILED(hr = (static_cast<CBaseSplitterFilter*>(m_pFilter))->CompleteConnect(PINDIR_INPUT, this))) {
+ if (FAILED(hr = (static_cast<CBaseSplitterFilter*>(m_pFilter))->CompleteConnect(PINDIR_INPUT, this))) {
return hr;
}
@@ -239,7 +239,7 @@ STDMETHODIMP CBaseSplitterOutputPin::NonDelegatingQueryInterface(REFIID riid, vo HRESULT CBaseSplitterOutputPin::SetName(LPCWSTR pName)
{
CheckPointer(pName, E_POINTER);
- if(m_pName) {
+ if (m_pName) {
delete [] m_pName;
}
m_pName = DNew WCHAR[wcslen(pName)+1];
@@ -259,17 +259,17 @@ HRESULT CBaseSplitterOutputPin::DecideBufferSize(IMemAllocator* pAlloc, ALLOCATO pProperties->cbBuffer = max(m_mt.lSampleSize, 1);
// TODO: is this still needed ?
- if(m_mt.subtype == MEDIASUBTYPE_Vorbis && m_mt.formattype == FORMAT_VorbisFormat) {
+ if (m_mt.subtype == MEDIASUBTYPE_Vorbis && m_mt.formattype == FORMAT_VorbisFormat) {
// oh great, the oggds vorbis decoder assumes there will be two at least, stupid thing...
pProperties->cBuffers = max(pProperties->cBuffers, 2);
}
ALLOCATOR_PROPERTIES Actual;
- if(FAILED(hr = pAlloc->SetProperties(pProperties, &Actual))) {
+ if (FAILED(hr = pAlloc->SetProperties(pProperties, &Actual))) {
return hr;
}
- if(Actual.cbBuffer < pProperties->cbBuffer) {
+ if (Actual.cbBuffer < pProperties->cbBuffer) {
return E_FAIL;
}
ASSERT(Actual.cBuffers == pProperties->cBuffers);
@@ -279,8 +279,8 @@ HRESULT CBaseSplitterOutputPin::DecideBufferSize(IMemAllocator* pAlloc, ALLOCATO HRESULT CBaseSplitterOutputPin::CheckMediaType(const CMediaType* pmt)
{
- for(size_t i = 0; i < m_mts.GetCount(); i++) {
- if(*pmt == m_mts[i]) {
+ for (size_t i = 0; i < m_mts.GetCount(); i++) {
+ if (*pmt == m_mts[i]) {
return S_OK;
}
}
@@ -292,10 +292,10 @@ HRESULT CBaseSplitterOutputPin::GetMediaType(int iPosition, CMediaType* pmt) {
CAutoLock cAutoLock(m_pLock);
- if(iPosition < 0) {
+ if (iPosition < 0) {
return E_INVALIDARG;
}
- if((size_t)iPosition >= m_mts.GetCount()) {
+ if ((size_t)iPosition >= m_mts.GetCount()) {
return VFW_S_NO_MORE_ITEMS;
}
@@ -315,7 +315,7 @@ HRESULT CBaseSplitterOutputPin::Active() {
CAutoLock cAutoLock(m_pLock);
- if(m_Connected) {
+ if (m_Connected) {
Create();
}
@@ -326,7 +326,7 @@ HRESULT CBaseSplitterOutputPin::Inactive() {
CAutoLock cAutoLock(m_pLock);
- if(ThreadExists()) {
+ if (ThreadExists()) {
CallWorker(CMD_EXIT);
}
@@ -341,7 +341,7 @@ HRESULT CBaseSplitterOutputPin::DeliverBeginFlush() m_hrDeliver = S_FALSE;
m_queue.RemoveAll();
HRESULT hr = IsConnected() ? GetConnected()->BeginFlush() : S_OK;
- if(S_OK != hr) {
+ if (S_OK != hr) {
m_eEndFlush.Set();
}
return(hr);
@@ -349,7 +349,7 @@ HRESULT CBaseSplitterOutputPin::DeliverBeginFlush() HRESULT CBaseSplitterOutputPin::DeliverEndFlush()
{
- if(!ThreadExists()) {
+ if (!ThreadExists()) {
return S_FALSE;
}
HRESULT hr = IsConnected() ? GetConnected()->EndFlush() : S_OK;
@@ -363,15 +363,15 @@ HRESULT CBaseSplitterOutputPin::DeliverEndFlush() HRESULT CBaseSplitterOutputPin::DeliverNewSegment(REFERENCE_TIME tStart, REFERENCE_TIME tStop, double dRate)
{
m_brs.rtLastDeliverTime = Packet::INVALID_TIME;
- if(m_fFlushing) {
+ if (m_fFlushing) {
return S_FALSE;
}
m_rtStart = tStart;
- if(!ThreadExists()) {
+ if (!ThreadExists()) {
return S_FALSE;
}
HRESULT hr = __super::DeliverNewSegment(tStart, tStop, dRate);
- if(S_OK != hr) {
+ if (S_OK != hr) {
return hr;
}
MakeISCRHappy();
@@ -395,17 +395,17 @@ HRESULT CBaseSplitterOutputPin::QueueEndOfStream() HRESULT CBaseSplitterOutputPin::QueuePacket(CAutoPtr<Packet> p)
{
- if(!ThreadExists()) {
+ if (!ThreadExists()) {
return S_FALSE;
}
- while(S_OK == m_hrDeliver
+ while (S_OK == m_hrDeliver
&& (!(static_cast<CBaseSplitterFilter*>(m_pFilter))->IsAnyPinDrying()
|| m_queue.GetSize() > MAXPACKETSIZE*100)) {
Sleep(1);
}
- if(S_OK != m_hrDeliver) {
+ if (S_OK != m_hrDeliver) {
return m_hrDeliver;
}
@@ -430,11 +430,11 @@ bool CBaseSplitterOutputPin::IsActive() do {
CComPtr<IPin> pPinTo;
CComQIPtr<IStreamSwitcherInputPin> pSSIP;
- if(S_OK == pPin->ConnectedTo(&pPinTo) && (pSSIP = pPinTo) && !pSSIP->IsActive()) {
+ if (S_OK == pPin->ConnectedTo(&pPinTo) && (pSSIP = pPinTo) && !pSSIP->IsActive()) {
return false;
}
pPin = GetFirstPin(GetFilterFromPin(pPinTo), PINDIR_OUTPUT);
- } while(pPin);
+ } while (pPin);
return true;
}
@@ -449,25 +449,25 @@ DWORD CBaseSplitterOutputPin::ThreadProc() // fix for Microsoft DTV-DVD Video Decoder - video freeze after STOP/PLAY
bool iHaaliRenderConnect = false;
CComPtr<IPin> pPinTo = this, pTmp;
- while(pPinTo && SUCCEEDED(pPinTo->ConnectedTo(&pTmp)) && (pPinTo = pTmp)) {
+ while (pPinTo && SUCCEEDED(pPinTo->ConnectedTo(&pTmp)) && (pPinTo = pTmp)) {
pTmp = NULL;
CComPtr<IBaseFilter> pBF = GetFilterFromPin(pPinTo);
- if(GetCLSID(pBF) == CLSID_DXR) { // Haali Renderer
+ if (GetCLSID(pBF) == CLSID_DXR) { // Haali Renderer
iHaaliRenderConnect = true;
break;
}
pPinTo = GetFirstPin(pBF, PINDIR_OUTPUT);
}
- if(IsConnected() && !iHaaliRenderConnect) {
+ if (IsConnected() && !iHaaliRenderConnect) {
GetConnected()->BeginFlush();
GetConnected()->EndFlush();
}
- while(1) {
+ while (1) {
Sleep(1);
DWORD cmd;
- if(CheckRequest(&cmd)) {
+ if (CheckRequest(&cmd)) {
m_hThread = NULL;
cmd = GetRequest();
Reply(S_OK);
@@ -481,12 +481,12 @@ DWORD CBaseSplitterOutputPin::ThreadProc() {
CAutoLock cAutoLock(&m_queue);
- if((cnt = m_queue.GetCount()) > 0) {
+ if ((cnt = m_queue.GetCount()) > 0) {
p = m_queue.Remove();
}
}
- if(S_OK == m_hrDeliver && cnt > 0) {
+ if (S_OK == m_hrDeliver && cnt > 0) {
ASSERT(!m_fFlushing);
m_fFlushed = false;
@@ -499,13 +499,13 @@ DWORD CBaseSplitterOutputPin::ThreadProc() m_eEndFlush.Wait(); // .. so we have to wait until it is done
- if(hr != S_OK && !m_fFlushed) { // and only report the error in m_hrDeliver if we didn't flush the stream
+ if (hr != S_OK && !m_fFlushed) { // and only report the error in m_hrDeliver if we didn't flush the stream
// CAutoLock cAutoLock(&m_csQueueLock);
m_hrDeliver = hr;
break;
}
}
- } while(--cnt > 0);
+ } while (--cnt > 0);
}
}
@@ -515,19 +515,19 @@ HRESULT CBaseSplitterOutputPin::DeliverPacket(CAutoPtr<Packet> p) INT_PTR nBytes = p->GetCount();
- if(nBytes == 0) {
+ if (nBytes == 0) {
return S_OK;
}
m_brs.nBytesSinceLastDeliverTime += nBytes;
- if(p->rtStart != Packet::INVALID_TIME) {
- if(m_brs.rtLastDeliverTime == Packet::INVALID_TIME) {
+ if (p->rtStart != Packet::INVALID_TIME) {
+ if (m_brs.rtLastDeliverTime == Packet::INVALID_TIME) {
m_brs.rtLastDeliverTime = p->rtStart;
m_brs.nBytesSinceLastDeliverTime = 0;
}
- if(m_brs.rtLastDeliverTime + 10000000 < p->rtStart) {
+ if (m_brs.rtLastDeliverTime + 10000000 < p->rtStart) {
REFERENCE_TIME rtDiff = p->rtStart - m_brs.rtLastDeliverTime;
double secs, bits;
@@ -554,7 +554,7 @@ HRESULT CBaseSplitterOutputPin::DeliverPacket(CAutoPtr<Packet> p) }
double dRate = 1.0;
- if(SUCCEEDED((static_cast<CBaseSplitterFilter*>(m_pFilter))->GetRate(&dRate))) {
+ if (SUCCEEDED((static_cast<CBaseSplitterFilter*>(m_pFilter))->GetRate(&dRate))) {
p->rtStart = (REFERENCE_TIME)((double)p->rtStart / dRate);
p->rtStop = (REFERENCE_TIME)((double)p->rtStop / dRate);
}
@@ -562,43 +562,43 @@ HRESULT CBaseSplitterOutputPin::DeliverPacket(CAutoPtr<Packet> p) do {
CComPtr<IMediaSample> pSample;
- if(S_OK != (hr = GetDeliveryBuffer(&pSample, NULL, NULL, 0))) {
+ if (S_OK != (hr = GetDeliveryBuffer(&pSample, NULL, NULL, 0))) {
break;
}
- if(nBytes > pSample->GetSize()) {
+ if (nBytes > pSample->GetSize()) {
pSample.Release();
ALLOCATOR_PROPERTIES props, actual;
- if(S_OK != (hr = m_pAllocator->GetProperties(&props))) {
+ if (S_OK != (hr = m_pAllocator->GetProperties(&props))) {
break;
}
props.cbBuffer = nBytes*3/2;
- if(props.cBuffers > 1) {
- if(S_OK != (hr = __super::DeliverBeginFlush())) {
+ if (props.cBuffers > 1) {
+ if (S_OK != (hr = __super::DeliverBeginFlush())) {
break;
}
- if(S_OK != (hr = __super::DeliverEndFlush())) {
+ if (S_OK != (hr = __super::DeliverEndFlush())) {
break;
}
}
- if(S_OK != (hr = m_pAllocator->Decommit())) {
+ if (S_OK != (hr = m_pAllocator->Decommit())) {
break;
}
- if(S_OK != (hr = m_pAllocator->SetProperties(&props, &actual))) {
+ if (S_OK != (hr = m_pAllocator->SetProperties(&props, &actual))) {
break;
}
- if(S_OK != (hr = m_pAllocator->Commit())) {
+ if (S_OK != (hr = m_pAllocator->Commit())) {
break;
}
- if(S_OK != (hr = GetDeliveryBuffer(&pSample, NULL, NULL, 0))) {
+ if (S_OK != (hr = GetDeliveryBuffer(&pSample, NULL, NULL, 0))) {
break;
}
}
- if(p->pmt) {
+ if (p->pmt) {
pSample->SetMediaType(p->pmt);
p->bDiscontinuity = true;
@@ -619,32 +619,32 @@ HRESULT CBaseSplitterOutputPin::DeliverPacket(CAutoPtr<Packet> p) ASSERT(!p->bSyncPoint || fTimeValid);
BYTE* pData = NULL;
- if(S_OK != (hr = pSample->GetPointer(&pData)) || !pData) {
+ if (S_OK != (hr = pSample->GetPointer(&pData)) || !pData) {
break;
}
memcpy(pData, p->GetData(), nBytes);
- if(S_OK != (hr = pSample->SetActualDataLength(nBytes))) {
+ if (S_OK != (hr = pSample->SetActualDataLength(nBytes))) {
break;
}
- if(S_OK != (hr = pSample->SetTime(fTimeValid ? &p->rtStart : NULL, fTimeValid ? &p->rtStop : NULL))) {
+ if (S_OK != (hr = pSample->SetTime(fTimeValid ? &p->rtStart : NULL, fTimeValid ? &p->rtStop : NULL))) {
break;
}
- if(S_OK != (hr = pSample->SetMediaTime(NULL, NULL))) {
+ if (S_OK != (hr = pSample->SetMediaTime(NULL, NULL))) {
break;
}
- if(S_OK != (hr = pSample->SetDiscontinuity(p->bDiscontinuity))) {
+ if (S_OK != (hr = pSample->SetDiscontinuity(p->bDiscontinuity))) {
break;
}
- if(S_OK != (hr = pSample->SetSyncPoint(p->bSyncPoint))) {
+ if (S_OK != (hr = pSample->SetSyncPoint(p->bSyncPoint))) {
break;
}
- if(S_OK != (hr = pSample->SetPreroll(fTimeValid && p->rtStart < 0))) {
+ if (S_OK != (hr = pSample->SetPreroll(fTimeValid && p->rtStart < 0))) {
break;
}
- if(S_OK != (hr = Deliver(pSample))) {
+ if (S_OK != (hr = Deliver(pSample))) {
break;
}
- } while(false);
+ } while (false);
return hr;
}
@@ -652,12 +652,12 @@ HRESULT CBaseSplitterOutputPin::DeliverPacket(CAutoPtr<Packet> p) void CBaseSplitterOutputPin::MakeISCRHappy()
{
CComPtr<IPin> pPinTo = this, pTmp;
- while(pPinTo && SUCCEEDED(pPinTo->ConnectedTo(&pTmp)) && (pPinTo = pTmp)) {
+ while (pPinTo && SUCCEEDED(pPinTo->ConnectedTo(&pTmp)) && (pPinTo = pTmp)) {
pTmp = NULL;
CComPtr<IBaseFilter> pBF = GetFilterFromPin(pPinTo);
- if(GetCLSID(pBF) == GUIDFromCString(_T("{48025243-2D39-11CE-875D-00608CB78066}"))) { // ISCR
+ if (GetCLSID(pBF) == GUIDFromCString(_T("{48025243-2D39-11CE-875D-00608CB78066}"))) { // ISCR
CAutoPtr<Packet> p(DNew Packet());
p->TrackNumber = (DWORD)-1;
p->rtStart = -1;
@@ -783,7 +783,7 @@ CBaseSplitterFilter::CBaseSplitterFilter(LPCTSTR pName, LPUNKNOWN pUnk, HRESULT* , m_rtLastStop(_I64_MIN)
, m_priority(THREAD_PRIORITY_NORMAL)
{
- if(phr) {
+ if (phr) {
*phr = S_OK;
}
@@ -804,7 +804,7 @@ STDMETHODIMP CBaseSplitterFilter::NonDelegatingQueryInterface(REFIID riid, void* *ppv = NULL;
- if(m_pInput && riid == __uuidof(IFileSourceFilter)) {
+ if (m_pInput && riid == __uuidof(IFileSourceFilter)) {
return E_NOINTERFACE;
}
@@ -838,11 +838,11 @@ DWORD CBaseSplitterFilter::GetOutputTrackNum(CBaseSplitterOutputPin* pPin) CAutoLock cAutoLock(&m_csPinMap);
POSITION pos = m_pPinMap.GetStartPosition();
- while(pos) {
+ while (pos) {
DWORD TrackNum;
CBaseSplitterOutputPin* pPinTmp;
m_pPinMap.GetNextAssoc(pos, TrackNum, pPinTmp);
- if(pPinTmp == pPin) {
+ if (pPinTmp == pPin) {
return TrackNum;
}
}
@@ -855,9 +855,9 @@ HRESULT CBaseSplitterFilter::RenameOutputPin(DWORD TrackNumSrc, DWORD TrackNumDs CAutoLock cAutoLock(&m_csPinMap);
CBaseSplitterOutputPin* pPin;
- if(m_pPinMap.Lookup(TrackNumSrc, pPin)) {
- if(CComQIPtr<IPin> pPinTo = pPin->GetConnected()) {
- if(pmt && S_OK != pPinTo->QueryAccept(pmt)) {
+ if (m_pPinMap.Lookup(TrackNumSrc, pPin)) {
+ if (CComQIPtr<IPin> pPinTo = pPin->GetConnected()) {
+ if (pmt && S_OK != pPinTo->QueryAccept(pmt)) {
return VFW_E_TYPE_NOT_ACCEPTED;
}
}
@@ -865,7 +865,7 @@ HRESULT CBaseSplitterFilter::RenameOutputPin(DWORD TrackNumSrc, DWORD TrackNumDs m_pPinMap.RemoveKey(TrackNumSrc);
m_pPinMap[TrackNumDst] = pPin;
- if(pmt) {
+ if (pmt) {
CAutoLock cAutoLock(&m_csmtnew);
m_mtnew[TrackNumDst] = *pmt;
}
@@ -880,7 +880,7 @@ HRESULT CBaseSplitterFilter::AddOutputPin(DWORD TrackNum, CAutoPtr<CBaseSplitter {
CAutoLock cAutoLock(&m_csPinMap);
- if(!pPin) {
+ if (!pPin) {
return E_INVALIDARG;
}
m_pPinMap[TrackNum] = pPin;
@@ -895,13 +895,13 @@ HRESULT CBaseSplitterFilter::DeleteOutputs() m_pRetiredOutputs.RemoveAll();
CAutoLock cAutoLockF(this);
- if(m_State != State_Stopped) {
+ if (m_State != State_Stopped) {
return VFW_E_NOT_STOPPED;
}
- while(m_pOutputs.GetCount()) {
+ while (m_pOutputs.GetCount()) {
CAutoPtr<CBaseSplitterOutputPin> pPin = m_pOutputs.RemoveHead();
- if(IPin* pPinTo = pPin->GetConnected()) {
+ if (IPin* pPinTo = pPin->GetConnected()) {
pPinTo->Disconnect();
}
pPin->Disconnect();
@@ -930,7 +930,7 @@ void CBaseSplitterFilter::DeliverBeginFlush() {
m_fFlushing = true;
POSITION pos = m_pOutputs.GetHeadPosition();
- while(pos) {
+ while (pos) {
m_pOutputs.GetNext(pos)->DeliverBeginFlush();
}
}
@@ -938,7 +938,7 @@ void CBaseSplitterFilter::DeliverBeginFlush() void CBaseSplitterFilter::DeliverEndFlush()
{
POSITION pos = m_pOutputs.GetHeadPosition();
- while(pos) {
+ while (pos) {
m_pOutputs.GetNext(pos)->DeliverEndFlush();
}
m_fFlushing = false;
@@ -947,18 +947,18 @@ void CBaseSplitterFilter::DeliverEndFlush() DWORD CBaseSplitterFilter::ThreadProc()
{
- if(m_pSyncReader) {
+ if (m_pSyncReader) {
m_pSyncReader->SetBreakEvent(GetRequestHandle());
}
- if(!DemuxInit()) {
- while(1) {
+ if (!DemuxInit()) {
+ while (1) {
DWORD cmd = GetRequest();
- if(cmd == CMD_EXIT) {
+ if (cmd == CMD_EXIT) {
CAMThread::m_hThread = NULL;
}
Reply(S_OK);
- if(cmd == CMD_EXIT) {
+ if (cmd == CMD_EXIT) {
return 0;
}
}
@@ -967,8 +967,8 @@ DWORD CBaseSplitterFilter::ThreadProc() m_eEndFlush.Set();
m_fFlushing = false;
- for(DWORD cmd = (DWORD)-1; ; cmd = GetRequest()) {
- if(cmd == CMD_EXIT) {
+ for (DWORD cmd = (DWORD)-1; ; cmd = GetRequest()) {
+ if (cmd == CMD_EXIT) {
m_hThread = NULL;
Reply(S_OK);
return 0;
@@ -981,7 +981,7 @@ DWORD CBaseSplitterFilter::ThreadProc() DemuxSeek(m_rtStart);
- if(cmd != (DWORD)-1) {
+ if (cmd != (DWORD)-1) {
Reply(S_OK);
}
@@ -990,9 +990,9 @@ DWORD CBaseSplitterFilter::ThreadProc() m_pActivePins.RemoveAll();
POSITION pos = m_pOutputs.GetHeadPosition();
- while(pos && !m_fFlushing) {
+ while (pos && !m_fFlushing) {
CBaseSplitterOutputPin* pPin = m_pOutputs.GetNext(pos);
- if(pPin->IsConnected() && pPin->IsActive()) {
+ if (pPin->IsConnected() && pPin->IsActive()) {
m_pActivePins.AddTail(pPin);
pPin->DeliverNewSegment(m_rtStart, m_rtStop, m_dRate);
}
@@ -1000,10 +1000,10 @@ DWORD CBaseSplitterFilter::ThreadProc() do {
m_bDiscontinuitySent.RemoveAll();
- } while(!DemuxLoop());
+ } while (!DemuxLoop());
pos = m_pActivePins.GetHeadPosition();
- while(pos && !CheckRequest(&cmd)) {
+ while (pos && !CheckRequest(&cmd)) {
m_pActivePins.GetNext(pos)->QueueEndOfStream();
}
}
@@ -1019,11 +1019,11 @@ HRESULT CBaseSplitterFilter::DeliverPacket(CAutoPtr<Packet> p) HRESULT hr = S_FALSE;
CBaseSplitterOutputPin* pPin = GetOutputPin(p->TrackNumber);
- if(!pPin || !pPin->IsConnected() || !m_pActivePins.Find(pPin)) {
+ if (!pPin || !pPin->IsConnected() || !m_pActivePins.Find(pPin)) {
return S_FALSE;
}
- if(p->rtStart != Packet::INVALID_TIME) {
+ if (p->rtStart != Packet::INVALID_TIME) {
m_rtCurrent = p->rtStart;
p->rtStart -= m_rtStart;
@@ -1036,13 +1036,13 @@ HRESULT CBaseSplitterFilter::DeliverPacket(CAutoPtr<Packet> p) CAutoLock cAutoLock(&m_csmtnew);
CMediaType mt;
- if(m_mtnew.Lookup(p->TrackNumber, mt)) {
+ if (m_mtnew.Lookup(p->TrackNumber, mt)) {
p->pmt = CreateMediaType(&mt);
m_mtnew.RemoveKey(p->TrackNumber);
}
}
- if(!m_bDiscontinuitySent.Find(p->TrackNumber)) {
+ if (!m_bDiscontinuitySent.Find(p->TrackNumber)) {
p->bDiscontinuity = TRUE;
}
@@ -1059,19 +1059,19 @@ HRESULT CBaseSplitterFilter::DeliverPacket(CAutoPtr<Packet> p) hr = pPin->QueuePacket(p);
- if(S_OK != hr) {
- if(POSITION pos = m_pActivePins.Find(pPin)) {
+ if (S_OK != hr) {
+ if (POSITION pos = m_pActivePins.Find(pPin)) {
m_pActivePins.RemoveAt(pos);
}
- if(!m_pActivePins.IsEmpty()) { // only die when all pins are down
+ if (!m_pActivePins.IsEmpty()) { // only die when all pins are down
hr = S_OK;
}
return hr;
}
- if(bDiscontinuity) {
+ if (bDiscontinuity) {
m_bDiscontinuitySent.AddTail(TrackNumber);
}
@@ -1083,16 +1083,16 @@ bool CBaseSplitterFilter::IsAnyPinDrying() int totalcount = 0, totalsize = 0;
POSITION pos = m_pActivePins.GetHeadPosition();
- while(pos) {
+ while (pos) {
CBaseSplitterOutputPin* pPin = m_pActivePins.GetNext(pos);
int count = pPin->QueueCount();
int size = pPin->QueueSize();
- if(!pPin->IsDiscontinuous() && (count < MINPACKETS || size < MINPACKETSIZE)) {
+ if (!pPin->IsDiscontinuous() && (count < MINPACKETS || size < MINPACKETSIZE)) {
// if(m_priority != THREAD_PRIORITY_ABOVE_NORMAL && (count < MINPACKETS/3 || size < MINPACKETSIZE/3))
- if(m_priority != THREAD_PRIORITY_BELOW_NORMAL && (count < MINPACKETS/3 || size < MINPACKETSIZE/3)) {
+ if (m_priority != THREAD_PRIORITY_BELOW_NORMAL && (count < MINPACKETS/3 || size < MINPACKETSIZE/3)) {
// SetThreadPriority(m_hThread, m_priority = THREAD_PRIORITY_ABOVE_NORMAL);
POSITION pos = m_pOutputs.GetHeadPosition();
- while(pos) {
+ while (pos) {
m_pOutputs.GetNext(pos)->SetThreadPriority(THREAD_PRIORITY_BELOW_NORMAL);
}
m_priority = THREAD_PRIORITY_BELOW_NORMAL;
@@ -1103,16 +1103,16 @@ bool CBaseSplitterFilter::IsAnyPinDrying() totalsize += size;
}
- if(m_priority != THREAD_PRIORITY_NORMAL && (totalcount > MAXPACKETS*2/3 || totalsize > MAXPACKETSIZE*2/3)) {
+ if (m_priority != THREAD_PRIORITY_NORMAL && (totalcount > MAXPACKETS*2/3 || totalsize > MAXPACKETSIZE*2/3)) {
// SetThreadPriority(m_hThread, m_priority = THREAD_PRIORITY_NORMAL);
POSITION pos = m_pOutputs.GetHeadPosition();
- while(pos) {
+ while (pos) {
m_pOutputs.GetNext(pos)->SetThreadPriority(THREAD_PRIORITY_NORMAL);
}
m_priority = THREAD_PRIORITY_NORMAL;
}
- if(totalcount < MAXPACKETS && totalsize < MAXPACKETSIZE) {
+ if (totalcount < MAXPACKETS && totalsize < MAXPACKETSIZE) {
return true;
}
@@ -1123,9 +1123,9 @@ HRESULT CBaseSplitterFilter::BreakConnect(PIN_DIRECTION dir, CBasePin* pPin) {
CheckPointer(pPin, E_POINTER);
- if(dir == PINDIR_INPUT) {
+ if (dir == PINDIR_INPUT) {
DeleteOutputs();
- } else if(dir == PINDIR_OUTPUT) {
+ } else if (dir == PINDIR_OUTPUT) {
} else {
return E_UNEXPECTED;
}
@@ -1137,13 +1137,13 @@ HRESULT CBaseSplitterFilter::CompleteConnect(PIN_DIRECTION dir, CBasePin* pPin) {
CheckPointer(pPin, E_POINTER);
- if(dir == PINDIR_INPUT) {
+ if (dir == PINDIR_INPUT) {
CBaseSplitterInputPin* pIn = static_cast<CBaseSplitterInputPin*>(pPin);
HRESULT hr;
CComPtr<IAsyncReader> pAsyncReader;
- if(FAILED(hr = pIn->GetAsyncReader(&pAsyncReader))
+ if (FAILED(hr = pIn->GetAsyncReader(&pAsyncReader))
|| FAILED(hr = DeleteOutputs())
|| FAILED(hr = CreateOutputs(pAsyncReader))) {
return hr;
@@ -1152,7 +1152,7 @@ HRESULT CBaseSplitterFilter::CompleteConnect(PIN_DIRECTION dir, CBasePin* pPin) ChapSort();
m_pSyncReader = pAsyncReader;
- } else if(dir == PINDIR_OUTPUT) {
+ } else if (dir == PINDIR_OUTPUT) {
m_pRetiredOutputs.RemoveAll();
} else {
return E_UNEXPECTED;
@@ -1170,13 +1170,13 @@ CBasePin* CBaseSplitterFilter::GetPin(int n) {
CAutoLock cAutoLock(this);
- if(n >= 0 && n < (int)m_pOutputs.GetCount()) {
- if(POSITION pos = m_pOutputs.FindIndex(n)) {
+ if (n >= 0 && n < (int)m_pOutputs.GetCount()) {
+ if (POSITION pos = m_pOutputs.FindIndex(n)) {
return m_pOutputs.GetAt(pos);
}
}
- if(n == (int)m_pOutputs.GetCount() && m_pInput) {
+ if (n == (int)m_pOutputs.GetCount() && m_pInput) {
return m_pInput;
}
@@ -1192,7 +1192,7 @@ STDMETHODIMP CBaseSplitterFilter::Stop() DeliverEndFlush();
HRESULT hr;
- if(FAILED(hr = __super::Stop())) {
+ if (FAILED(hr = __super::Stop())) {
return hr;
}
@@ -1206,11 +1206,11 @@ STDMETHODIMP CBaseSplitterFilter::Pause() FILTER_STATE fs = m_State;
HRESULT hr;
- if(FAILED(hr = __super::Pause())) {
+ if (FAILED(hr = __super::Pause())) {
return hr;
}
- if(fs == State_Stopped) {
+ if (fs == State_Stopped) {
Create();
}
@@ -1222,7 +1222,7 @@ STDMETHODIMP CBaseSplitterFilter::Run(REFERENCE_TIME tStart) CAutoLock cAutoLock(this);
HRESULT hr;
- if(FAILED(hr = __super::Run(tStart))) {
+ if (FAILED(hr = __super::Run(tStart))) {
return hr;
}
@@ -1243,10 +1243,10 @@ STDMETHODIMP CBaseSplitterFilter::Load(LPCOLESTR pszFileName, const AM_MEDIA_TYP if (BuildPlaylist (pszFileName, Items))
pAsyncReader = (IAsyncReader*)DNew CAsyncFileReader(Items, hr);
- else
+ else
pAsyncReader = (IAsyncReader*)DNew CAsyncFileReader(CString(pszFileName), hr);
- if(FAILED(hr)
+ if (FAILED(hr)
|| FAILED(hr = DeleteOutputs())
|| FAILED(hr = CreateOutputs(pAsyncReader)))
{
@@ -1258,7 +1258,7 @@ STDMETHODIMP CBaseSplitterFilter::Load(LPCOLESTR pszFileName, const AM_MEDIA_TYP {
POSITION pos = Chapters.GetHeadPosition();
int i = 1;
- while(pos)
+ while (pos)
{
CString str;
CHdmvClipInfo::PlaylistChapter& chap = Chapters.GetNext(pos);
@@ -1282,7 +1282,7 @@ STDMETHODIMP CBaseSplitterFilter::GetCurFile(LPOLESTR* ppszFileName, AM_MEDIA_TY {
CheckPointer(ppszFileName, E_POINTER);
*ppszFileName = (LPOLESTR)CoTaskMemAlloc((m_fn.GetLength()+1)*sizeof(WCHAR));
- if(!(*ppszFileName)) {
+ if (!(*ppszFileName)) {
return E_OUTOFMEMORY;
}
wcscpy(*ppszFileName, m_fn);
@@ -1310,15 +1310,15 @@ STDMETHODIMP CBaseSplitterFilter::GetCapabilities(DWORD* pCapabilities) STDMETHODIMP CBaseSplitterFilter::CheckCapabilities(DWORD* pCapabilities)
{
CheckPointer(pCapabilities, E_POINTER);
- if(*pCapabilities == 0) {
+ if (*pCapabilities == 0) {
return S_OK;
}
DWORD caps;
GetCapabilities(&caps);
- if((caps&*pCapabilities) == 0) {
+ if ((caps&*pCapabilities) == 0) {
return E_FAIL;
}
- if(caps == *pCapabilities) {
+ if (caps == *pCapabilities) {
return S_OK;
}
return S_FALSE;
@@ -1378,10 +1378,10 @@ STDMETHODIMP CBaseSplitterFilter::SetPositions(LONGLONG* pCurrent, DWORD dwCurre STDMETHODIMP CBaseSplitterFilter::GetPositions(LONGLONG* pCurrent, LONGLONG* pStop)
{
- if(pCurrent) {
+ if (pCurrent) {
*pCurrent = m_rtCurrent;
}
- if(pStop) {
+ if (pStop) {
*pStop = m_rtStop;
}
return S_OK;
@@ -1389,7 +1389,7 @@ STDMETHODIMP CBaseSplitterFilter::GetPositions(LONGLONG* pCurrent, LONGLONG* pSt STDMETHODIMP CBaseSplitterFilter::GetAvailable(LONGLONG* pEarliest, LONGLONG* pLatest)
{
- if(pEarliest) {
+ if (pEarliest) {
*pEarliest = 0;
}
return GetDuration(pLatest);
@@ -1414,7 +1414,7 @@ HRESULT CBaseSplitterFilter::SetPositionsInternal(void* id, LONGLONG* pCurrent, {
CAutoLock cAutoLock(this);
- if(!pCurrent && !pStop
+ if (!pCurrent && !pStop
|| (dwCurrentFlags&AM_SEEKING_PositioningBitsMask) == AM_SEEKING_NoPositioning
&& (dwStopFlags&AM_SEEKING_PositioningBitsMask) == AM_SEEKING_NoPositioning) {
return S_OK;
@@ -1424,8 +1424,8 @@ HRESULT CBaseSplitterFilter::SetPositionsInternal(void* id, LONGLONG* pCurrent, rtCurrent = m_rtCurrent,
rtStop = m_rtStop;
- if(pCurrent)
- switch(dwCurrentFlags&AM_SEEKING_PositioningBitsMask) {
+ if (pCurrent)
+ switch (dwCurrentFlags&AM_SEEKING_PositioningBitsMask) {
case AM_SEEKING_NoPositioning:
break;
case AM_SEEKING_AbsolutePositioning:
@@ -1439,8 +1439,8 @@ HRESULT CBaseSplitterFilter::SetPositionsInternal(void* id, LONGLONG* pCurrent, break;
}
- if(pStop)
- switch(dwStopFlags&AM_SEEKING_PositioningBitsMask) {
+ if (pStop)
+ switch (dwStopFlags&AM_SEEKING_PositioningBitsMask) {
case AM_SEEKING_NoPositioning:
break;
case AM_SEEKING_AbsolutePositioning:
@@ -1454,11 +1454,11 @@ HRESULT CBaseSplitterFilter::SetPositionsInternal(void* id, LONGLONG* pCurrent, break;
}
- if(m_rtCurrent == rtCurrent && m_rtStop == rtStop) {
+ if (m_rtCurrent == rtCurrent && m_rtStop == rtStop) {
return S_OK;
}
- if(m_rtLastStart == rtCurrent && m_rtLastStop == rtStop && !m_LastSeekers.Find(id)) {
+ if (m_rtLastStart == rtCurrent && m_rtLastStop == rtStop && !m_LastSeekers.Find(id)) {
m_LastSeekers.AddTail(id);
return S_OK;
}
@@ -1473,7 +1473,7 @@ HRESULT CBaseSplitterFilter::SetPositionsInternal(void* id, LONGLONG* pCurrent, m_rtNewStart = m_rtCurrent = rtCurrent;
m_rtNewStop = rtStop;
- if(ThreadExists()) {
+ if (ThreadExists()) {
DeliverBeginFlush();
CallWorker(CMD_SEEK);
DeliverEndFlush();
@@ -1536,7 +1536,7 @@ STDMETHODIMP CBaseSplitterFilter::get_ExSeekCapabilities(long* pExCapabilities) {
CheckPointer(pExCapabilities, E_POINTER);
*pExCapabilities = AM_EXSEEK_CANSEEK;
- if(ChapGetCount()) {
+ if (ChapGetCount()) {
*pExCapabilities |= AM_EXSEEK_MARKERSEEK;
}
return S_OK;
@@ -1554,7 +1554,7 @@ STDMETHODIMP CBaseSplitterFilter::get_CurrentMarker(long* pCurrentMarker) CheckPointer(pCurrentMarker, E_POINTER);
REFERENCE_TIME rt = m_rtCurrent;
long i = ChapLookup(&rt);
- if(i < 0) {
+ if (i < 0) {
return E_FAIL;
}
*pCurrentMarker = i+1;
@@ -1565,7 +1565,7 @@ STDMETHODIMP CBaseSplitterFilter::GetMarkerTime(long MarkerNum, double* pMarkerT {
CheckPointer(pMarkerTime, E_POINTER);
REFERENCE_TIME rt;
- if(FAILED(ChapGet((int)MarkerNum-1, &rt))) {
+ if (FAILED(ChapGet((int)MarkerNum-1, &rt))) {
return E_FAIL;
}
*pMarkerTime = (double)rt / 10000000;
@@ -1602,7 +1602,7 @@ STDMETHODIMP CBaseSplitterFilter::GetStatus(int i, int& samples, int& size) {
CAutoLock cAutoLock(m_pLock);
- if(POSITION pos = m_pOutputs.FindIndex(i)) {
+ if (POSITION pos = m_pOutputs.FindIndex(i)) {
CBaseSplitterOutputPin* pPin = m_pOutputs.GetAt(pos);
samples = pPin->QueueCount();
size = pPin->QueueSize();
diff --git a/src/filters/parser/BaseSplitter/BaseSplitter.h b/src/filters/parser/BaseSplitter/BaseSplitter.h index 6916cb760..b35e16f91 100644 --- a/src/filters/parser/BaseSplitter/BaseSplitter.h +++ b/src/filters/parser/BaseSplitter/BaseSplitter.h @@ -33,66 +33,66 @@ #include "../../../DSUtil/FontInstaller.h"
enum {
- /* various PCM "codecs" */
- FF_CODEC_ID_FIRST_AUDIO = 0x10000, ///< A dummy id pointing at the start of audio codecs
- FF_CODEC_ID_PCM_S16LE= 0x10000,
- FF_CODEC_ID_PCM_S16BE,
- FF_CODEC_ID_PCM_U16LE,
- FF_CODEC_ID_PCM_U16BE,
- FF_CODEC_ID_PCM_S8,
- FF_CODEC_ID_PCM_U8,
- FF_CODEC_ID_PCM_MULAW,
- FF_CODEC_ID_PCM_ALAW,
- FF_CODEC_ID_PCM_S32LE,
- FF_CODEC_ID_PCM_S32BE,
- FF_CODEC_ID_PCM_U32LE,
- FF_CODEC_ID_PCM_U32BE,
- FF_CODEC_ID_PCM_S24LE,
- FF_CODEC_ID_PCM_S24BE,
- FF_CODEC_ID_PCM_U24LE,
- FF_CODEC_ID_PCM_U24BE,
- FF_CODEC_ID_PCM_S24DAUD,
- FF_CODEC_ID_PCM_ZORK,
- FF_CODEC_ID_PCM_S16LE_PLANAR,
- FF_CODEC_ID_PCM_DVD,
- FF_CODEC_ID_PCM_F32BE,
- FF_CODEC_ID_PCM_F32LE,
- FF_CODEC_ID_PCM_F64BE,
- FF_CODEC_ID_PCM_F64LE,
- FF_CODEC_ID_PCM_BLURAY,
- FF_CODEC_ID_PCM_LXF,
- FF_CODEC_ID_S302M,
-
- /* various ADPCM codecs */
- FF_CODEC_ID_ADPCM_IMA_QT= 0x11000,
- FF_CODEC_ID_ADPCM_IMA_WAV,
- FF_CODEC_ID_ADPCM_IMA_DK3,
- FF_CODEC_ID_ADPCM_IMA_DK4,
- FF_CODEC_ID_ADPCM_IMA_WS,
- FF_CODEC_ID_ADPCM_IMA_SMJPEG,
- FF_CODEC_ID_ADPCM_MS,
- FF_CODEC_ID_ADPCM_4XM,
- FF_CODEC_ID_ADPCM_XA,
- FF_CODEC_ID_ADPCM_ADX,
- FF_CODEC_ID_ADPCM_EA,
- FF_CODEC_ID_ADPCM_G726,
- FF_CODEC_ID_ADPCM_CT,
- FF_CODEC_ID_ADPCM_SWF,
- FF_CODEC_ID_ADPCM_YAMAHA,
- FF_CODEC_ID_ADPCM_SBPRO_4,
- FF_CODEC_ID_ADPCM_SBPRO_3,
- FF_CODEC_ID_ADPCM_SBPRO_2,
- FF_CODEC_ID_ADPCM_THP,
- FF_CODEC_ID_ADPCM_IMA_AMV,
- FF_CODEC_ID_ADPCM_EA_R1,
- FF_CODEC_ID_ADPCM_EA_R3,
- FF_CODEC_ID_ADPCM_EA_R2,
- FF_CODEC_ID_ADPCM_IMA_EA_SEAD,
- FF_CODEC_ID_ADPCM_IMA_EA_EACS,
- FF_CODEC_ID_ADPCM_EA_XAS,
- FF_CODEC_ID_ADPCM_EA_MAXIS_XA,
- FF_CODEC_ID_ADPCM_IMA_ISS,
- FF_CODEC_ID_ADPCM_G722,
+ /* various PCM "codecs" */
+ FF_CODEC_ID_FIRST_AUDIO = 0x10000, ///< A dummy id pointing at the start of audio codecs
+ FF_CODEC_ID_PCM_S16LE= 0x10000,
+ FF_CODEC_ID_PCM_S16BE,
+ FF_CODEC_ID_PCM_U16LE,
+ FF_CODEC_ID_PCM_U16BE,
+ FF_CODEC_ID_PCM_S8,
+ FF_CODEC_ID_PCM_U8,
+ FF_CODEC_ID_PCM_MULAW,
+ FF_CODEC_ID_PCM_ALAW,
+ FF_CODEC_ID_PCM_S32LE,
+ FF_CODEC_ID_PCM_S32BE,
+ FF_CODEC_ID_PCM_U32LE,
+ FF_CODEC_ID_PCM_U32BE,
+ FF_CODEC_ID_PCM_S24LE,
+ FF_CODEC_ID_PCM_S24BE,
+ FF_CODEC_ID_PCM_U24LE,
+ FF_CODEC_ID_PCM_U24BE,
+ FF_CODEC_ID_PCM_S24DAUD,
+ FF_CODEC_ID_PCM_ZORK,
+ FF_CODEC_ID_PCM_S16LE_PLANAR,
+ FF_CODEC_ID_PCM_DVD,
+ FF_CODEC_ID_PCM_F32BE,
+ FF_CODEC_ID_PCM_F32LE,
+ FF_CODEC_ID_PCM_F64BE,
+ FF_CODEC_ID_PCM_F64LE,
+ FF_CODEC_ID_PCM_BLURAY,
+ FF_CODEC_ID_PCM_LXF,
+ FF_CODEC_ID_S302M,
+
+ /* various ADPCM codecs */
+ FF_CODEC_ID_ADPCM_IMA_QT= 0x11000,
+ FF_CODEC_ID_ADPCM_IMA_WAV,
+ FF_CODEC_ID_ADPCM_IMA_DK3,
+ FF_CODEC_ID_ADPCM_IMA_DK4,
+ FF_CODEC_ID_ADPCM_IMA_WS,
+ FF_CODEC_ID_ADPCM_IMA_SMJPEG,
+ FF_CODEC_ID_ADPCM_MS,
+ FF_CODEC_ID_ADPCM_4XM,
+ FF_CODEC_ID_ADPCM_XA,
+ FF_CODEC_ID_ADPCM_ADX,
+ FF_CODEC_ID_ADPCM_EA,
+ FF_CODEC_ID_ADPCM_G726,
+ FF_CODEC_ID_ADPCM_CT,
+ FF_CODEC_ID_ADPCM_SWF,
+ FF_CODEC_ID_ADPCM_YAMAHA,
+ FF_CODEC_ID_ADPCM_SBPRO_4,
+ FF_CODEC_ID_ADPCM_SBPRO_3,
+ FF_CODEC_ID_ADPCM_SBPRO_2,
+ FF_CODEC_ID_ADPCM_THP,
+ FF_CODEC_ID_ADPCM_IMA_AMV,
+ FF_CODEC_ID_ADPCM_EA_R1,
+ FF_CODEC_ID_ADPCM_EA_R3,
+ FF_CODEC_ID_ADPCM_EA_R2,
+ FF_CODEC_ID_ADPCM_IMA_EA_SEAD,
+ FF_CODEC_ID_ADPCM_IMA_EA_EACS,
+ FF_CODEC_ID_ADPCM_EA_XAS,
+ FF_CODEC_ID_ADPCM_EA_MAXIS_XA,
+ FF_CODEC_ID_ADPCM_IMA_ISS,
+ FF_CODEC_ID_ADPCM_G722,
};
class Packet : public CAtlArray<BYTE>
@@ -108,7 +108,7 @@ public: bDiscontinuity = bAppendable = FALSE;
}
virtual ~Packet() {
- if(pmt) {
+ if (pmt) {
DeleteMediaType(pmt);
}
}
@@ -254,7 +254,7 @@ public: return m_hThread;
}
void SetThreadPriority(int nPriority) {
- if(m_hThread) {
+ if (m_hThread) {
::SetThreadPriority(m_hThread, nPriority);
}
}
diff --git a/src/filters/parser/BaseSplitter/BaseSplitterFile.cpp b/src/filters/parser/BaseSplitter/BaseSplitterFile.cpp index 4e8f55d5a..568952518 100644 --- a/src/filters/parser/BaseSplitter/BaseSplitterFile.cpp +++ b/src/filters/parser/BaseSplitter/BaseSplitterFile.cpp @@ -35,7 +35,7 @@ CBaseSplitterFile::CBaseSplitterFile(IAsyncReader* pAsyncReader, HRESULT& hr, in , m_bitbuff(0), m_bitlen(0)
, m_cachepos(0), m_cachelen(0)
{
- if(!m_pAsyncReader) {
+ if (!m_pAsyncReader) {
hr = E_UNEXPECTED;
return;
}
@@ -47,12 +47,12 @@ CBaseSplitterFile::CBaseSplitterFile(IAsyncReader* pAsyncReader, HRESULT& hr, in m_fRandomAccess = total > 0 && total == available;
m_len = total;
- if(FAILED(hr) || fRandomAccess && !m_fRandomAccess || !fStreaming && m_fStreaming || m_len < 0) {
+ if (FAILED(hr) || fRandomAccess && !m_fRandomAccess || !fStreaming && m_fStreaming || m_len < 0) {
hr = E_FAIL;
return;
}
- if(!SetCacheSize(cachelen)) {
+ if (!SetCacheSize(cachelen)) {
hr = E_OUTOFMEMORY;
return;
}
@@ -65,7 +65,7 @@ bool CBaseSplitterFile::SetCacheSize(int cachelen) m_pCache.Free();
m_cachetotal = 0;
m_pCache.Allocate((size_t)cachelen);
- if(!m_pCache) {
+ if (!m_pCache) {
return false;
}
m_cachetotal = cachelen;
@@ -87,9 +87,9 @@ __int64 CBaseSplitterFile::GetAvailable() __int64 CBaseSplitterFile::GetLength(bool fUpdate)
{
- if(m_fStreaming) {
+ if (m_fStreaming) {
m_len = GetAvailable();
- } else if(fUpdate) {
+ } else if (fUpdate) {
LONGLONG total = 0, available;
m_pAsyncReader->Length(&total, &available);
m_len = total;
@@ -111,16 +111,16 @@ HRESULT CBaseSplitterFile::Read(BYTE* pData, __int64 len) HRESULT hr = S_OK;
- if(!m_fRandomAccess) {
+ if (!m_fRandomAccess) {
LONGLONG total = 0, available = -1;
m_pAsyncReader->Length(&total, &available);
- if(total == available) {
+ if (total == available) {
m_fRandomAccess = true;
OnComplete();
}
}
- if(m_cachetotal == 0 || !m_pCache) {
+ if (m_cachetotal == 0 || !m_pCache) {
hr = m_pAsyncReader->SyncRead(m_pos, (long)len, pData);
m_pos += len;
return hr;
@@ -128,7 +128,7 @@ HRESULT CBaseSplitterFile::Read(BYTE* pData, __int64 len) BYTE* pCache = m_pCache;
- if(m_cachepos <= m_pos && m_pos < m_cachepos + m_cachelen) {
+ if (m_cachepos <= m_pos && m_pos < m_cachepos + m_cachelen) {
__int64 minlen = min(len, m_cachelen - (m_pos - m_cachepos));
memcpy(pData, &pCache[m_pos - m_cachepos], (size_t)minlen);
@@ -138,9 +138,9 @@ HRESULT CBaseSplitterFile::Read(BYTE* pData, __int64 len) pData += minlen;
}
- while(len > m_cachetotal) {
+ while (len > m_cachetotal) {
hr = m_pAsyncReader->SyncRead(m_pos, (long)m_cachetotal, pData);
- if(S_OK != hr) {
+ if (S_OK != hr) {
return hr;
}
@@ -149,16 +149,16 @@ HRESULT CBaseSplitterFile::Read(BYTE* pData, __int64 len) pData += m_cachetotal;
}
- while(len > 0) {
+ while (len > 0) {
__int64 tmplen = GetLength();
__int64 maxlen = min(tmplen - m_pos, m_cachetotal);
__int64 minlen = min(len, maxlen);
- if(minlen <= 0) {
+ if (minlen <= 0) {
return S_FALSE;
}
hr = m_pAsyncReader->SyncRead(m_pos, (long)maxlen, pCache);
- if(S_OK != hr) {
+ if (S_OK != hr) {
return hr;
}
@@ -179,9 +179,9 @@ UINT64 CBaseSplitterFile::BitRead(int nBits, bool fPeek) {
ASSERT(nBits >= 0 && nBits <= 64);
- while(m_bitlen < nBits) {
+ while (m_bitlen < nBits) {
m_bitbuff <<= 8;
- if(S_OK != Read((BYTE*)&m_bitbuff, 1)) {
+ if (S_OK != Read((BYTE*)&m_bitbuff, 1)) {
return 0; // EOF? // ASSERT(0);
}
m_bitlen += 8;
@@ -191,7 +191,7 @@ UINT64 CBaseSplitterFile::BitRead(int nBits, bool fPeek) UINT64 ret = (m_bitbuff >> bitlen) & ((1ui64 << nBits) - 1);
- if(!fPeek) {
+ if (!fPeek) {
m_bitbuff &= ((1ui64 << bitlen) - 1);
m_bitlen = bitlen;
}
@@ -218,7 +218,7 @@ HRESULT CBaseSplitterFile::ByteRead(BYTE* pData, __int64 len) UINT64 CBaseSplitterFile::UExpGolombRead()
{
int n = -1;
- for(BYTE b = 0; !b; n++) {
+ for (BYTE b = 0; !b; n++) {
b = BitRead(1);
}
return (1ui64 << n) - 1 + BitRead(n);
@@ -234,12 +234,12 @@ HRESULT CBaseSplitterFile::HasMoreData(__int64 len, DWORD ms) {
__int64 available = GetLength() - GetPos();
- if(!m_fStreaming) {
+ if (!m_fStreaming) {
return available < 1 ? E_FAIL : S_OK;
}
- if(available < len) {
- if(ms > 0) {
+ if (available < len) {
+ if (ms > 0) {
Sleep(ms);
}
return S_FALSE;
diff --git a/src/filters/parser/BaseSplitter/BaseSplitterFileEx.cpp b/src/filters/parser/BaseSplitter/BaseSplitterFileEx.cpp index 7a318a9fb..b6ea8fb10 100644 --- a/src/filters/parser/BaseSplitter/BaseSplitterFileEx.cpp +++ b/src/filters/parser/BaseSplitter/BaseSplitterFileEx.cpp @@ -50,11 +50,11 @@ bool CBaseSplitterFileEx::NextMpegStartCode(BYTE& code, __int64 len) BitByteAlign();
DWORD dw = (DWORD)-1;
do {
- if(len-- == 0 || !GetRemaining()) {
+ if (len-- == 0 || !GetRemaining()) {
return false;
}
dw = (dw << 8) | (BYTE)BitRead(8);
- } while((dw&0xffffff00) != 0x00000100);
+ } while ((dw&0xffffff00) != 0x00000100);
code = (BYTE)(dw&0xff);
return true;
}
@@ -69,7 +69,7 @@ bool CBaseSplitterFileEx::Read(pshdr& h) BYTE b = (BYTE)BitRead(8, true);
- if((b&0xf1) == 0x21) {
+ if ((b&0xf1) == 0x21) {
h.type = mpeg1;
EXECUTE_ASSERT(BitRead(4) == 2);
@@ -84,7 +84,7 @@ bool CBaseSplitterFileEx::Read(pshdr& h) MARKER; // 14..0
h.bitrate = BitRead(22);
MARKER;
- } else if((b&0xc4) == 0x44) {
+ } else if ((b&0xc4) == 0x44) {
h.type = mpeg2;
EXECUTE_ASSERT(BitRead(2) == 1);
@@ -103,7 +103,7 @@ bool CBaseSplitterFileEx::Read(pshdr& h) MARKER;
BitRead(5); // reserved
UINT64 stuffing = BitRead(3);
- while(stuffing-- > 0) {
+ while (stuffing-- > 0) {
EXECUTE_ASSERT(BitRead(8) == 0xff);
}
} else {
@@ -133,7 +133,7 @@ bool CBaseSplitterFileEx::Read(pssyshdr& h) EXECUTE_ASSERT((BitRead(8)&0x7f) == 0x7f); // reserved (should be 0xff, but not in reality)
- for(len -= 6; len > 3; len -= 3) { // TODO: also store these, somewhere, if needed
+ for (len -= 6; len > 3; len -= 3) { // TODO: also store these, somewhere, if needed
UINT64 stream_id = BitRead(8);
UNUSED_ALWAYS(stream_id);
EXECUTE_ASSERT(BitRead(2) == 3);
@@ -148,42 +148,42 @@ bool CBaseSplitterFileEx::Read(peshdr& h, BYTE code) {
memset(&h, 0, sizeof(h));
- if(!(code >= 0xbd && code < 0xf0 || code == 0xfd)) { // 0xfd => blu-ray (.m2ts)
+ if (!(code >= 0xbd && code < 0xf0 || code == 0xfd)) { // 0xfd => blu-ray (.m2ts)
return false;
}
h.len = (WORD)BitRead(16);
- if(code == 0xbe || code == 0xbf) {
+ if (code == 0xbe || code == 0xbf) {
return true;
}
// mpeg1 stuffing (ff ff .. , max 16x)
- for(int i = 0; i < 16 && BitRead(8, true) == 0xff; i++) {
+ for (int i = 0; i < 16 && BitRead(8, true) == 0xff; i++) {
BitRead(8);
- if(h.len) {
+ if (h.len) {
h.len--;
}
}
h.type = (BYTE)BitRead(2, true) == mpeg2 ? mpeg2 : mpeg1;
- if(h.type == mpeg1) {
+ if (h.type == mpeg1) {
BYTE b = (BYTE)BitRead(2);
- if(b == 1) {
+ if (b == 1) {
h.std_buff_size = (BitRead(1)?1024:128)*BitRead(13);
- if(h.len) {
+ if (h.len) {
h.len -= 2;
}
b = (BYTE)BitRead(2);
}
- if(b == 0) {
+ if (b == 0) {
h.fpts = (BYTE)BitRead(1);
h.fdts = (BYTE)BitRead(1);
}
- } else if(h.type == mpeg2) {
+ } else if (h.type == mpeg2) {
EXECUTE_ASSERT(BitRead(2) == mpeg2);
h.scrambling = (BYTE)BitRead(2);
h.priority = (BYTE)BitRead(1);
@@ -200,16 +200,16 @@ bool CBaseSplitterFileEx::Read(peshdr& h, BYTE code) h.extension = (BYTE)BitRead(1);
h.hdrlen = (BYTE)BitRead(8);
} else {
- if(h.len) while(h.len-- > 0) {
+ if (h.len) while (h.len-- > 0) {
BitRead(8);
}
return false;
}
- if(h.fpts) {
- if(h.type == mpeg2) {
+ if (h.fpts) {
+ if (h.type == mpeg2) {
BYTE b = (BYTE)BitRead(4);
- if(!(h.fdts && b == 3 || !h.fdts && b == 2)) {/*ASSERT(0); */return false;}
+ if (!(h.fdts && b == 3 || !h.fdts && b == 2)) {/*ASSERT(0); */return false;}
}
h.pts = 0;
@@ -222,8 +222,8 @@ bool CBaseSplitterFileEx::Read(peshdr& h, BYTE code) h.pts = 10000*h.pts/90 + m_rtPTSOffset;
}
- if(h.fdts) {
- if((BYTE)BitRead(4) != 1) {/*ASSERT(0); */return false;}
+ if (h.fdts) {
+ if ((BYTE)BitRead(4) != 1) {/*ASSERT(0); */return false;}
h.dts = 0;
h.dts |= BitRead(3) << 30;
@@ -237,35 +237,35 @@ bool CBaseSplitterFileEx::Read(peshdr& h, BYTE code) // skip to the end of header
- if(h.type == mpeg1) {
- if(!h.fpts && !h.fdts && BitRead(4) != 0xf) {
+ if (h.type == mpeg1) {
+ if (!h.fpts && !h.fdts && BitRead(4) != 0xf) {
/*ASSERT(0);*/ return false;
}
- if(h.len) {
+ if (h.len) {
h.len--;
- if(h.pts) {
+ if (h.pts) {
h.len -= 4;
}
- if(h.dts) {
+ if (h.dts) {
h.len -= 5;
}
}
}
- if(h.type == mpeg2) {
- if(h.len) {
+ if (h.type == mpeg2) {
+ if (h.len) {
h.len -= 3+h.hdrlen;
}
int left = h.hdrlen;
- if(h.fpts) {
+ if (h.fpts) {
left -= 5;
}
- if(h.fdts) {
+ if (h.fdts) {
left -= 5;
}
- while(left-- > 0) {
+ while (left-- > 0) {
BitRead(8);
}
/*
@@ -289,13 +289,13 @@ bool CBaseSplitterFileEx::Read(seqhdr& h, int len, CMediaType* pmt) BYTE id = 0;
- while(GetPos() < endpos && id != 0xb3) {
- if(!NextMpegStartCode(id, len)) {
+ while (GetPos() < endpos && id != 0xb3) {
+ if (!NextMpegStartCode(id, len)) {
return false;
}
}
- if(id != 0xb3) {
+ if (id != 0xb3) {
return false;
}
@@ -312,14 +312,14 @@ bool CBaseSplitterFileEx::Read(seqhdr& h, int len, CMediaType* pmt) h.constrained = BitRead(1);
h.fiqm = BitRead(1);
- if(h.fiqm)
- for(int i = 0; i < countof(h.iqm); i++) {
+ if (h.fiqm)
+ for (int i = 0; i < countof(h.iqm); i++) {
h.iqm[i] = (BYTE)BitRead(8);
}
h.fniqm = BitRead(1);
- if(h.fniqm)
- for(int i = 0; i < countof(h.niqm); i++) {
+ if (h.fniqm)
+ for (int i = 0; i < countof(h.niqm); i++) {
h.niqm[i] = (BYTE)BitRead(8);
}
@@ -337,7 +337,7 @@ bool CBaseSplitterFileEx::Read(seqhdr& h, int len, CMediaType* pmt) __int64 shextpos = 0, shextlen = 0;
- if(NextMpegStartCode(id, 8) && id == 0xb5) { // sequence header ext
+ if (NextMpegStartCode(id, 8) && id == 0xb5) { // sequence header ext
shextpos = GetPos() - 4;
h.startcodeid = BitRead(4);
@@ -370,22 +370,22 @@ bool CBaseSplitterFileEx::Read(seqhdr& h, int len, CMediaType* pmt) h.bitrate = h.bitrate == (1<<30)-1 ? 0 : h.bitrate * 400;
DWORD a = h.arx, b = h.ary;
- while(a) {
+ while (a) {
DWORD tmp = a;
a = b % tmp;
b = tmp;
}
- if(b) {
+ if (b) {
h.arx /= b, h.ary /= b;
}
- if(!pmt) {
+ if (!pmt) {
return true;
}
pmt->majortype = MEDIATYPE_Video;
- if(type == mpeg1) {
+ if (type == mpeg1) {
pmt->subtype = MEDIASUBTYPE_MPEG1Payload;
pmt->formattype = FORMAT_MPEGVideo;
int len = FIELD_OFFSET(MPEG1VIDEOINFO, bSequenceHeader) + shlen + shextlen;
@@ -401,13 +401,13 @@ bool CBaseSplitterFileEx::Read(seqhdr& h, int len, CMediaType* pmt) vi->cbSequenceHeader = shlen + shextlen;
Seek(shpos);
ByteRead((BYTE*)&vi->bSequenceHeader[0], shlen);
- if(shextpos && shextlen) {
+ if (shextpos && shextlen) {
Seek(shextpos);
}
ByteRead((BYTE*)&vi->bSequenceHeader[0] + shlen, shextlen);
pmt->SetFormat((BYTE*)vi, len);
delete [] vi;
- } else if(type == mpeg2) {
+ } else if (type == mpeg2) {
pmt->subtype = MEDIASUBTYPE_MPEG2_VIDEO;
pmt->formattype = FORMAT_MPEG2_VIDEO;
int len = FIELD_OFFSET(MPEG2VIDEOINFO, dwSequenceHeader) + shlen + shextlen;
@@ -425,7 +425,7 @@ bool CBaseSplitterFileEx::Read(seqhdr& h, int len, CMediaType* pmt) vi->cbSequenceHeader = shlen + shextlen;
Seek(shpos);
ByteRead((BYTE*)&vi->dwSequenceHeader[0], shlen);
- if(shextpos && shextlen) {
+ if (shextpos && shextlen) {
Seek(shextpos);
}
ByteRead((BYTE*)&vi->dwSequenceHeader[0] + shlen, shextlen);
@@ -444,11 +444,11 @@ bool CBaseSplitterFileEx::Read(mpahdr& h, int len, bool fAllowV25, CMediaType* p int syncbits = fAllowV25 ? 11 : 12;
- for(; len >= 4 && BitRead(syncbits, true) != (1<<syncbits) - 1; len--) {
+ for (; len >= 4 && BitRead(syncbits, true) != (1<<syncbits) - 1; len--) {
BitRead(8);
}
- if(len < 4) {
+ if (len < 4) {
return false;
}
@@ -466,12 +466,12 @@ bool CBaseSplitterFileEx::Read(mpahdr& h, int len, bool fAllowV25, CMediaType* p h.original = BitRead(1);
h.emphasis = BitRead(2);
- if(h.version == 1 || h.layer == 0 || h.freq == 3 || h.bitrate == 15 || h.emphasis == 2) {
+ if (h.version == 1 || h.layer == 0 || h.freq == 3 || h.bitrate == 15 || h.emphasis == 2) {
return false;
}
- if(h.version == 3 && h.layer == 2) {
- if((h.bitrate == 1 || h.bitrate == 2 || h.bitrate == 3 || h.bitrate == 5) && h.channels != 3
+ if (h.version == 3 && h.layer == 2) {
+ if ((h.bitrate == 1 || h.bitrate == 2 || h.bitrate == 3 || h.bitrate == 5) && h.channels != 3
&& (h.bitrate >= 11 && h.bitrate <= 14) && h.channels == 3) {
return false;
}
@@ -502,7 +502,7 @@ bool CBaseSplitterFileEx::Read(mpahdr& h, int len, bool fAllowV25, CMediaType* p static int brtblcol[][4] = {{0,3,4,4},{0,0,1,2}};
int bitrate = 1000*brtbl[h.bitrate][brtblcol[h.version&1][h.layer]];
- if(bitrate == 0) {
+ if (bitrate == 0) {
return false;
}
@@ -517,7 +517,7 @@ bool CBaseSplitterFileEx::Read(mpahdr& h, int len, bool fAllowV25, CMediaType* p h.rtDuration = 10000000i64 * (h.layer == 1 ? 384 : l3ext ? 576 : 1152) / h.nSamplesPerSec;// / (h.channels == 3 ? 1 : 2);
h.nBytesPerSec = bitrate / 8;
- if(!pmt) {
+ if (!pmt) {
return true;
}
@@ -528,7 +528,7 @@ bool CBaseSplitterFileEx::Read(mpahdr& h, int len, bool fAllowV25, CMediaType* p memset(wfe, 0, len);
wfe->cbSize = len - sizeof(WAVEFORMATEX);
- if(h.layer == 3) {
+ if (h.layer == 3) {
wfe->wFormatTag = WAVE_FORMAT_MP3;
/* MPEGLAYER3WAVEFORMAT* f = (MPEGLAYER3WAVEFORMAT*)wfe;
@@ -542,19 +542,19 @@ bool CBaseSplitterFileEx::Read(mpahdr& h, int len, bool fAllowV25, CMediaType* p f->fwHeadMode = 1 << h.channels;
f->fwHeadModeExt = 1 << h.modeext;
f->wHeadEmphasis = h.emphasis+1;
- if(h.privatebit) {
+ if (h.privatebit) {
f->fwHeadFlags |= ACM_MPEG_PRIVATEBIT;
}
- if(h.copyright) {
+ if (h.copyright) {
f->fwHeadFlags |= ACM_MPEG_COPYRIGHT;
}
- if(h.original) {
+ if (h.original) {
f->fwHeadFlags |= ACM_MPEG_ORIGINALHOME;
}
- if(h.crc == 0) {
+ if (h.crc == 0) {
f->fwHeadFlags |= ACM_MPEG_PROTECTIONBIT;
}
- if(h.version == 3) {
+ if (h.version == 3) {
f->fwHeadFlags |= ACM_MPEG_ID_MPEG1;
}
f->fwHeadLayer = 1 << (h.layer-1);
@@ -580,11 +580,11 @@ bool CBaseSplitterFileEx::Read(latm_aachdr& h, int len, CMediaType* pmt) {
memset(&h, 0, sizeof(h));
- for(; len >= 3 && BitRead(11, true) != 0x2b7; len--) {
+ for (; len >= 3 && BitRead(11, true) != 0x2b7; len--) {
BitRead(8);
}
-
- if(len < 3) {
+
+ if (len < 3) {
return false;
}
@@ -597,14 +597,14 @@ bool CBaseSplitterFileEx::Read(aachdr& h, int len, CMediaType* pmt) memset(&h, 0, sizeof(h));
__int64 pos = 0;
- int found_fake_sync = 0;
+ int found_fake_sync = 0;
- for(;;) {
- for(; len >= 7 && BitRead(12, true) != 0xfff; len--) {
+ for (;;) {
+ for (; len >= 7 && BitRead(12, true) != 0xfff; len--) {
BitRead(8);
}
- if(len < 7) {
+ if (len < 7) {
return false;
}
@@ -627,12 +627,12 @@ bool CBaseSplitterFileEx::Read(aachdr& h, int len, CMediaType* pmt) h.adts_buffer_fullness = BitRead(11);
h.no_raw_data_blocks_in_frame = BitRead(2);
- if(h.fcrc == 0) {
+ if (h.fcrc == 0) {
h.crc = BitRead(16);
}
- if(h.layer != 0 || h.freq >= 12 || h.aac_frame_length <= (h.fcrc == 0 ? 9 : 7)) {
- if(found_fake_sync) // skip only one "fake" sync. TODO - find better way to detect and skip "fake" sync
+ if (h.layer != 0 || h.freq >= 12 || h.aac_frame_length <= (h.fcrc == 0 ? 9 : 7)) {
+ if (found_fake_sync) // skip only one "fake" sync. TODO - find better way to detect and skip "fake" sync
return false;
found_fake_sync++;
Seek(pos + 1);
@@ -645,7 +645,7 @@ bool CBaseSplitterFileEx::Read(aachdr& h, int len, CMediaType* pmt) h.nBytesPerSec = h.aac_frame_length * freq[h.freq] / 1024; // ok?
h.rtDuration = 10000000i64 * 1024 / freq[h.freq]; // ok?
- if(!pmt) {
+ if (!pmt) {
return true;
}
@@ -676,11 +676,11 @@ bool CBaseSplitterFileEx::Read(ac3hdr& h, int len, CMediaType* pmt, bool find_sy bool e_ac3 = false;
__int64 startpos = GetPos();
-
+
memset(&h, 0, sizeof(h));
// Parse TrueHD header
- if(!AC3CoreOnly) {
+ if (!AC3CoreOnly) {
BYTE buf[20];
int m_channels;
int m_samplerate;
@@ -688,11 +688,11 @@ bool CBaseSplitterFileEx::Read(ac3hdr& h, int len, CMediaType* pmt, bool find_sy int fsize = 0;
ByteRead(buf, 20);
-
+
fsize = ParseTrueHDHeader(buf, &m_samplerate, &m_channels, &m_framelength);
- if(fsize) {
+ if (fsize) {
- if(!pmt) {
+ if (!pmt) {
return true;
}
@@ -701,7 +701,7 @@ bool CBaseSplitterFileEx::Read(ac3hdr& h, int len, CMediaType* pmt, bool find_sy pmt->majortype = MEDIATYPE_Audio;
pmt->subtype = MEDIASUBTYPE_DOLBY_TRUEHD;
pmt->formattype = FORMAT_WaveFormatEx;
-
+
WAVEFORMATEX* wfe = (WAVEFORMATEX*)pmt->AllocFormatBuffer(sizeof(WAVEFORMATEX));
wfe->wFormatTag = WAVE_FORMAT_UNKNOWN;
wfe->nChannels = m_channels;
@@ -718,18 +718,18 @@ bool CBaseSplitterFileEx::Read(ac3hdr& h, int len, CMediaType* pmt, bool find_sy Seek(startpos);
- if(find_sync) {
- for(; len >= 7 && BitRead(16, true) != 0x0b77; len--) {
+ if (find_sync) {
+ for (; len >= 7 && BitRead(16, true) != 0x0b77; len--) {
BitRead(8);
}
}
- if(len < 7) {
+ if (len < 7) {
return false;
}
h.sync = (WORD)BitRead(16);
- if(h.sync != 0x0B77) {
+ if (h.sync != 0x0B77) {
return false;
}
@@ -738,26 +738,26 @@ bool CBaseSplitterFileEx::Read(ac3hdr& h, int len, CMediaType* pmt, bool find_sy h.fscod = BitRead(2);
h.frmsizecod = BitRead(6);
h.bsid = BitRead(5);
- if(h.bsid > 16) {
+ if (h.bsid > 16) {
return false;
}
- if(h.bsid <= 10) {
+ if (h.bsid <= 10) {
/* Normal AC-3 */
- if(h.fscod == 3) {
+ if (h.fscod == 3) {
return false;
}
- if(h.frmsizecod > 37) {
+ if (h.frmsizecod > 37) {
return false;
}
h.bsmod = BitRead(3);
h.acmod = BitRead(3);
- if(h.acmod == 2) {
+ if (h.acmod == 2) {
h.dsurmod = BitRead(2);
}
- if((h.acmod & 1) && h.acmod != 1) {
+ if ((h.acmod & 1) && h.acmod != 1) {
h.cmixlev = BitRead(2);
}
- if(h.acmod & 4) {
+ if (h.acmod & 4) {
h.surmixlev = BitRead(2);
}
h.lfeon = BitRead(1);
@@ -768,17 +768,17 @@ bool CBaseSplitterFileEx::Read(ac3hdr& h, int len, CMediaType* pmt, bool find_sy Seek(pos);
h.frame_type = BitRead(2);
h.substreamid = BitRead(3);
- if(h.frame_type || h.substreamid) {
+ if (h.frame_type || h.substreamid) {
return false;
}
h.frame_size = (BitRead(11) + 1) << 1;
- if(h.frame_size < 7) {
+ if (h.frame_size < 7) {
return false;
}
h.sr_code = BitRead(2);
- if(h.sr_code == 3) {
+ if (h.sr_code == 3) {
int sr_code2 = BitRead(2);
- if(sr_code2 == 3) {
+ if (sr_code2 == 3) {
return false;
}
h.sample_rate = freq[sr_code2] / 2;
@@ -793,7 +793,7 @@ bool CBaseSplitterFileEx::Read(ac3hdr& h, int len, CMediaType* pmt, bool find_sy h.lfeon = BitRead(1);
}
- if(!pmt) {
+ if (!pmt) {
return true;
}
@@ -804,7 +804,7 @@ bool CBaseSplitterFileEx::Read(ac3hdr& h, int len, CMediaType* pmt, bool find_sy static int channels[] = {2, 1, 2, 3, 3, 4, 4, 5};
wfe.nChannels = channels[h.acmod] + h.lfeon;
- if(!e_ac3) {
+ if (!e_ac3) {
wfe.nSamplesPerSec = freq[h.fscod] >> h.sr_shift;
static int rate[] = {32, 40, 48, 56, 64, 80, 96, 112, 128, 160, 192, 224, 256, 320, 384, 448, 512, 576, 640, 768, 896, 1024, 1152, 1280};
wfe.nAvgBytesPerSec = ((rate[h.frmsizecod>>1] * 1000) >> h.sr_shift) / 8;
@@ -816,7 +816,7 @@ bool CBaseSplitterFileEx::Read(ac3hdr& h, int len, CMediaType* pmt, bool find_sy wfe.nBlockAlign = (WORD)(1536 * wfe.nAvgBytesPerSec / wfe.nSamplesPerSec);
pmt->majortype = MEDIATYPE_Audio;
- if(e_ac3) {
+ if (e_ac3) {
pmt->subtype = MEDIASUBTYPE_DOLBY_DDPLUS;
} else {
pmt->subtype = MEDIASUBTYPE_DOLBY_AC3;
@@ -831,18 +831,18 @@ bool CBaseSplitterFileEx::Read(dtshdr& h, int len, CMediaType* pmt, bool find_sy {
memset(&h, 0, sizeof(h));
- if(find_sync) {
- for(; len >= 10 && BitRead(32, true) != 0x7ffe8001; len--) {
+ if (find_sync) {
+ for (; len >= 10 && BitRead(32, true) != 0x7ffe8001; len--) {
BitRead(8);
}
}
- if(len < 10) {
+ if (len < 10) {
return false;
}
h.sync = (DWORD)BitRead(32);
- if(h.sync != 0x7ffe8001) {
+ if (h.sync != 0x7ffe8001) {
return false;
}
@@ -867,7 +867,7 @@ bool CBaseSplitterFileEx::Read(dtshdr& h, int len, CMediaType* pmt, bool find_sy h.predictor_history = BitRead(1);
- if(!pmt) {
+ if (!pmt) {
return true;
}
@@ -877,7 +877,7 @@ bool CBaseSplitterFileEx::Read(dtshdr& h, int len, CMediaType* pmt, bool find_sy static int channels[] = {1, 2, 2, 2, 2, 3, 3, 4, 4, 5, 6, 6, 6, 7, 8, 8};
- if(h.amode < countof(channels)) {
+ if (h.amode < countof(channels)) {
wfe.nChannels = channels[h.amode];
if (h.lfe > 0) {
++wfe.nChannels;
@@ -927,7 +927,7 @@ bool CBaseSplitterFileEx::Read(hdmvlpcmhdr& h, CMediaType* pmt) return false;
}
- if(!pmt) {
+ if (!pmt) {
return true;
}
@@ -969,11 +969,11 @@ bool CBaseSplitterFileEx::Read(lpcmhdr& h, CMediaType* pmt) h.channels = BitRead(3);
h.drc = (BYTE)BitRead(8);
- if(h.quantwordlen == 3 || h.reserved1 || h.reserved2) {
+ if (h.quantwordlen == 3 || h.reserved1 || h.reserved2) {
return false;
}
- if(!pmt) {
+ if (!pmt) {
return true;
}
@@ -1011,7 +1011,7 @@ bool CBaseSplitterFileEx::Read(dvdspuhdr& h, CMediaType* pmt) {
memset(&h, 0, sizeof(h));
- if(!pmt) {
+ if (!pmt) {
return true;
}
@@ -1026,7 +1026,7 @@ bool CBaseSplitterFileEx::Read(hdmvsubhdr& h, CMediaType* pmt, const char* langu {
memset(&h, 0, sizeof(h));
- if(!pmt) {
+ if (!pmt) {
return true;
}
@@ -1047,7 +1047,7 @@ bool CBaseSplitterFileEx::Read(svcdspuhdr& h, CMediaType* pmt) {
memset(&h, 0, sizeof(h));
- if(!pmt) {
+ if (!pmt) {
return true;
}
@@ -1062,7 +1062,7 @@ bool CBaseSplitterFileEx::Read(cvdspuhdr& h, CMediaType* pmt) {
memset(&h, 0, sizeof(h));
- if(!pmt) {
+ if (!pmt) {
return true;
}
@@ -1077,23 +1077,23 @@ bool CBaseSplitterFileEx::Read(ps2audhdr& h, CMediaType* pmt) {
memset(&h, 0, sizeof(h));
- if(BitRead(16, true) != 'SS') {
+ if (BitRead(16, true) != 'SS') {
return false;
}
__int64 pos = GetPos();
- while(BitRead(16, true) == 'SS') {
+ while (BitRead(16, true) == 'SS') {
DWORD tag = (DWORD)BitRead(32, true);
DWORD size = 0;
- if(tag == 'SShd') {
+ if (tag == 'SShd') {
BitRead(32);
ByteRead((BYTE*)&size, sizeof(size));
ASSERT(size == 0x18);
Seek(GetPos());
ByteRead((BYTE*)&h, sizeof(h));
- } else if(tag == 'SSbd') {
+ } else if (tag == 'SSbd') {
BitRead(32);
ByteRead((BYTE*)&size, sizeof(size));
break;
@@ -1102,7 +1102,7 @@ bool CBaseSplitterFileEx::Read(ps2audhdr& h, CMediaType* pmt) Seek(pos);
- if(!pmt) {
+ if (!pmt) {
return true;
}
@@ -1130,7 +1130,7 @@ bool CBaseSplitterFileEx::Read(ps2subhdr& h, CMediaType* pmt) {
memset(&h, 0, sizeof(h));
- if(!pmt) {
+ if (!pmt) {
return true;
}
@@ -1147,19 +1147,19 @@ bool CBaseSplitterFileEx::Read(trhdr& h, bool fSync) BitByteAlign();
- if(m_tslen == 0) {
+ if (m_tslen == 0) {
__int64 pos = GetPos();
- for(int i = 0; i < 192; i++) {
- if(BitRead(8, true) == 0x47) {
+ for (int i = 0; i < 192; i++) {
+ if (BitRead(8, true) == 0x47) {
__int64 pos = GetPos();
Seek(pos + 188);
- if(BitRead(8, true) == 0x47) {
+ if (BitRead(8, true) == 0x47) {
m_tslen = 188; // TS stream
break;
}
Seek(pos + 192);
- if(BitRead(8, true) == 0x47) {
+ if (BitRead(8, true) == 0x47) {
m_tslen = 192; // M2TS stream
break;
}
@@ -1170,19 +1170,19 @@ bool CBaseSplitterFileEx::Read(trhdr& h, bool fSync) Seek(pos);
- if(m_tslen == 0) {
+ if (m_tslen == 0) {
return false;
}
}
- if(fSync) {
- for(int i = 0; i < m_tslen; i++) {
- if(BitRead(8, true) == 0x47) {
- if(i == 0) {
+ if (fSync) {
+ for (int i = 0; i < m_tslen; i++) {
+ if (BitRead(8, true) == 0x47) {
+ if (i == 0) {
break;
}
Seek(GetPos()+m_tslen);
- if(BitRead(8, true) == 0x47) {
+ if (BitRead(8, true) == 0x47) {
Seek(GetPos()-m_tslen);
break;
}
@@ -1190,13 +1190,13 @@ bool CBaseSplitterFileEx::Read(trhdr& h, bool fSync) BitRead(8);
- if(i == m_tslen-1) {
+ if (i == m_tslen-1) {
return false;
}
}
}
- if(BitRead(8, true) != 0x47) {
+ if (BitRead(8, true) != 0x47) {
return false;
}
@@ -1214,10 +1214,10 @@ bool CBaseSplitterFileEx::Read(trhdr& h, bool fSync) h.bytes = 188 - 4;
- if(h.adapfield) {
+ if (h.adapfield) {
h.length = (BYTE)BitRead(8);
- if(h.length > 0) {
+ if (h.length > 0) {
h.discontinuity = BitRead(1);
h.randomaccess = BitRead(1);
h.priority = BitRead(1);
@@ -1229,7 +1229,7 @@ bool CBaseSplitterFileEx::Read(trhdr& h, bool fSync) int i = 1;
- if(h.fPCR) {
+ if (h.fPCR) {
h.PCR = BitRead(33);
BitRead(6);
UINT64 PCRExt = BitRead(9);
@@ -1239,14 +1239,14 @@ bool CBaseSplitterFileEx::Read(trhdr& h, bool fSync) ASSERT(i <= h.length);
- for(; i < h.length; i++) {
+ for (; i < h.length; i++) {
BitRead(8);
}
}
h.bytes -= h.length+1;
- if(h.bytes < 0) {
+ if (h.bytes < 0) {
ASSERT(0);
return false;
}
@@ -1259,7 +1259,7 @@ bool CBaseSplitterFileEx::Read(trsechdr& h) memset(&h, 0, sizeof(h));
BYTE pointer_field = BitRead(8);
- while(pointer_field-- > 0) {
+ while (pointer_field-- > 0) {
BitRead(8);
}
h.table_id = BitRead(8);
@@ -1282,16 +1282,16 @@ bool CBaseSplitterFileEx::Read(pvahdr& h, bool fSync) BitByteAlign();
- if(fSync) {
- for(int i = 0; i < 65536; i++) {
- if((BitRead(64, true)&0xfffffc00ffe00000i64) == 0x4156000055000000i64) {
+ if (fSync) {
+ for (int i = 0; i < 65536; i++) {
+ if ((BitRead(64, true)&0xfffffc00ffe00000i64) == 0x4156000055000000i64) {
break;
}
BitRead(8);
}
}
- if((BitRead(64, true)&0xfffffc00ffe00000i64) != 0x4156000055000000i64) {
+ if ((BitRead(64, true)&0xfffffc00ffe00000i64) != 0x4156000055000000i64) {
return false;
}
@@ -1305,26 +1305,26 @@ bool CBaseSplitterFileEx::Read(pvahdr& h, bool fSync) h.prebytes = BitRead(2);
h.length = (WORD)BitRead(16);
- if(h.length > 6136) {
+ if (h.length > 6136) {
return false;
}
__int64 pos = GetPos();
- if(h.streamid == 1 && h.fpts) {
+ if (h.streamid == 1 && h.fpts) {
h.pts = 10000*BitRead(32)/90 + m_rtPTSOffset;
- } else if(h.streamid == 2 && (h.fpts || (BitRead(32, true)&0xffffffe0) == 0x000001c0)) {
+ } else if (h.streamid == 2 && (h.fpts || (BitRead(32, true)&0xffffffe0) == 0x000001c0)) {
BYTE b;
- if(!NextMpegStartCode(b, 4)) {
+ if (!NextMpegStartCode(b, 4)) {
return false;
}
peshdr h2;
- if(!Read(h2, b)) {
+ if (!Read(h2, b)) {
return false;
}
// Maybe bug, code before: if(h.fpts = h2.fpts) h.pts = h2.pts;
h.fpts = h2.fpts;
- if(h.fpts) {
+ if (h.fpts) {
h.pts = h2.pts;
}
}
@@ -1339,12 +1339,12 @@ bool CBaseSplitterFileEx::Read(pvahdr& h, bool fSync) int CBaseSplitterFileEx::HrdParameters(CGolombBuffer& gb)
{
unsigned int cnt = gb.UExpGolombRead(); // cpb_cnt_minus1
- if(cnt > 32U)
+ if (cnt > 32U)
return -1;
gb.BitRead(4); // bit_rate_scale
gb.BitRead(4); // cpb_size_scale
- for(unsigned int i = 0; i <= cnt; i++ ) {
+ for (unsigned int i = 0; i <= cnt; i++ ) {
gb.UExpGolombRead(); // bit_rate_value_minus1
gb.UExpGolombRead(); // cpb_size_value_minus1
gb.BitRead(1); // cbr_flag
@@ -1354,7 +1354,7 @@ int CBaseSplitterFileEx::HrdParameters(CGolombBuffer& gb) gb.BitRead(5); // cpb_removal_delay_length_minus1
gb.BitRead(5); // dpb_output_delay_length_minus1
gb.BitRead(5); // time_offset_length
-
+
return 0;
}
@@ -1362,13 +1362,13 @@ void CBaseSplitterFileEx::RemoveMpegEscapeCode(BYTE* dst, BYTE* src, int length) {
int si=0;
int di=0;
- while(si+2<length) {
+ while (si+2<length) {
//remove escapes (very rare 1:2^22)
- if(src[si+2]>3) {
+ if (src[si+2]>3) {
dst[di++]= src[si++];
dst[di++]= src[si++];
- } else if(src[si]==0 && src[si+1]==0) {
- if(src[si+2]==3) { //escape
+ } else if (src[si]==0 && src[si+1]==0) {
+ if (src[si+2]==3) { //escape
dst[di++]= 0;
dst[di++]= 0;
si+=3;
@@ -1391,23 +1391,23 @@ bool CBaseSplitterFileEx::Read(avchdr& h, int len, CMediaType* pmt) // First try search for the start code
DWORD _dwStartCode = BitRead(32, true);
- while(GetPos() < endpos+4 &&
+ while (GetPos() < endpos+4 &&
(_dwStartCode & 0xFFFFFF1F) != 0x101 && // Coded slide of a non-IDR
(_dwStartCode & 0xFFFFFF1F) != 0x105 && // Coded slide of an IDR
(_dwStartCode & 0xFFFFFF1F) != 0x107 && // Sequence Parameter Set
(_dwStartCode & 0xFFFFFF1F) != 0x108 && // Picture Parameter Set
(_dwStartCode & 0xFFFFFF1F) != 0x109 && // Access Unit Delimiter
(_dwStartCode & 0xFFFFFF1F) != 0x10f // Subset Sequence Parameter Set (MVC)
- ) {
+ ) {
BitRead(8);
_dwStartCode = BitRead(32, true);
}
- if(GetPos() >= endpos+4) {
+ if (GetPos() >= endpos+4) {
return false;
}
// At least a SPS (normal or subset) and a PPS is required
- while(GetPos() < endpos+4 && (!(h.spspps[index_sps].complete || h.spspps[index_subsetsps].complete) || !h.spspps[index_pps1].complete || repeat))
+ while (GetPos() < endpos+4 && (!(h.spspps[index_sps].complete || h.spspps[index_subsetsps].complete) || !h.spspps[index_pps1].complete || repeat))
{
BYTE id = h.lastid;
repeat = false;
@@ -1415,19 +1415,19 @@ bool CBaseSplitterFileEx::Read(avchdr& h, int len, CMediaType* pmt) // Get array index from NAL unit type
spsppsindex index = index_unknown;
- if((id&0x60) != 0) {
- if((id&0x9f) == 0x07) {
+ if ((id&0x60) != 0) {
+ if ((id&0x9f) == 0x07) {
index = index_sps;
- } else if((id&0x9f) == 0x0F) {
+ } else if ((id&0x9f) == 0x0F) {
index = index_subsetsps;
- } else if((id&0x9f) == 0x08) {
+ } else if ((id&0x9f) == 0x08) {
index = h.spspps[index_pps1].complete ? index_pps2 : index_pps1;
}
}
// Search for next start code
DWORD dwStartCode = BitRead(32, true);
- while(GetPos() < endpos+4 && (dwStartCode != 0x00000001) && (dwStartCode & 0xFFFFFF00) != 0x00000100) {
+ while (GetPos() < endpos+4 && (dwStartCode != 0x00000001) && (dwStartCode & 0xFFFFFF00) != 0x00000100) {
BitRead(8);
dwStartCode = BitRead(32, true);
}
@@ -1436,7 +1436,7 @@ bool CBaseSplitterFileEx::Read(avchdr& h, int len, CMediaType* pmt) // Skip start code
__int64 pos;
- if(GetPos() < endpos+4) {
+ if (GetPos() < endpos+4) {
if (dwStartCode == 0x00000001)
BitRead(32);
else
@@ -1449,11 +1449,11 @@ bool CBaseSplitterFileEx::Read(avchdr& h, int len, CMediaType* pmt) }
// The SPS or PPS might be fragmented, copy data into buffer until NAL is complete
- if(index >= 0) {
- if(h.spspps[index].complete) {
+ if (index >= 0) {
+ if (h.spspps[index].complete) {
// Don't handle SPS/PPS twice
continue;
- } else if(pos > nalstartpos) {
+ } else if (pos > nalstartpos) {
// Copy into buffer
Seek(nalstartpos);
unsigned int bufsize = countof(h.spspps[index].buffer);
@@ -1464,7 +1464,7 @@ bool CBaseSplitterFileEx::Read(avchdr& h, int len, CMediaType* pmt) //ASSERT(h.spspps[index].size < bufsize); // disable for better debug ...
- if(h.spspps[index].size >= bufsize || dwStartCode == 0x00000001 || (dwStartCode & 0xFFFFFF00) == 0x00000100) {
+ if (h.spspps[index].size >= bufsize || dwStartCode == 0x00000001 || (dwStartCode & 0xFFFFFF00) == 0x00000100) {
if (Read(h, index)) {
h.spspps[index].complete = true;
h.spspps[index].size -= 4;
@@ -1481,20 +1481,20 @@ bool CBaseSplitterFileEx::Read(avchdr& h, int len, CMediaType* pmt) }
// Exit and wait for next packet if there is no SPS and PPS yet
- if((!h.spspps[index_sps].complete && !h.spspps[index_subsetsps].complete) || !h.spspps[index_pps1].complete || repeat) {
+ if ((!h.spspps[index_sps].complete && !h.spspps[index_subsetsps].complete) || !h.spspps[index_pps1].complete || repeat) {
return false;
}
- if(!pmt) {
+ if (!pmt) {
return true;
}
{
// Calculate size of extra data
int extra = 0;
- for(int i = 0; i < 4; i++) {
- if(h.spspps[i].complete)
+ for (int i = 0; i < 4; i++) {
+ if (h.spspps[i].complete)
extra += 2+(h.spspps[i].size);
}
@@ -1513,15 +1513,15 @@ bool CBaseSplitterFileEx::Read(avchdr& h, int len, CMediaType* pmt) memset(vi, 0, len);
// vi->hdr.dwBitRate = ;
vi->hdr.AvgTimePerFrame = h.AvgTimePerFrame;
- if(!h.sar.num) h.sar.num = 1;
- if(!h.sar.den) h.sar.den = 1;
+ if (!h.sar.num) h.sar.num = 1;
+ if (!h.sar.den) h.sar.den = 1;
CSize aspect(h.width * h.sar.num, h.height * h.sar.den);
int lnko = LNKO(aspect.cx, aspect.cy);
- if(lnko > 1) {
+ if (lnko > 1) {
aspect.cx /= lnko, aspect.cy /= lnko;
}
- if(aspect.cx * 2 < aspect.cy) {
+ if (aspect.cx * 2 < aspect.cy) {
delete[] vi;
return false;
}
@@ -1545,8 +1545,8 @@ bool CBaseSplitterFileEx::Read(avchdr& h, int len, CMediaType* pmt) // Copy extra data
BYTE* p = (BYTE*)&vi->dwSequenceHeader[0];
- for(int i = 0; i < 4; i++) {
- if(h.spspps[i].complete) {
+ for (int i = 0; i < 4; i++) {
+ if (h.spspps[i].complete) {
*p++ = (h.spspps[i].size) >> 8;
*p++ = (h.spspps[i].size) & 0xff;
memcpy(p, h.spspps[i].buffer, h.spspps[i].size);
@@ -1567,7 +1567,7 @@ bool CBaseSplitterFileEx::Read(avchdr& h, spsppsindex index) static BYTE levels[] = {10, 11, 12, 13, 20, 21, 22, 30, 31, 32, 40, 41, 42, 50, 51};
// Only care about SPS and subset SPS
- if(index != index_sps && index != index_subsetsps)
+ if (index != index_sps && index != index_subsetsps)
return true;
// Manage escape codes
@@ -1578,35 +1578,35 @@ bool CBaseSplitterFileEx::Read(avchdr& h, spsppsindex index) gb.BitRead(8); // nal_unit_type
h.profile = (BYTE)gb.BitRead(8);
bool b_ident = false;
- for(int i = 0; i<sizeof(profiles); i++) {
- if(h.profile == profiles[i]) {
+ for (int i = 0; i<sizeof(profiles); i++) {
+ if (h.profile == profiles[i]) {
b_ident = true;
break;
}
}
- if(!b_ident)
+ if (!b_ident)
return false;
gb.BitRead(8);
h.level = (BYTE)gb.BitRead(8);
b_ident = false;
- for(int i = 0; i<sizeof(levels); i++) {
- if(h.level == levels[i]) {
+ for (int i = 0; i<sizeof(levels); i++) {
+ if (h.level == levels[i]) {
b_ident = true;
break;
}
}
- if(!b_ident)
+ if (!b_ident)
return false;
unsigned int sps_id = gb.UExpGolombRead(); // seq_parameter_set_id
- if(sps_id >= 32)
+ if (sps_id >= 32)
return false;
UINT64 chroma_format_idc = 0;
- if(h.profile >= 100) { // high profile
+ if (h.profile >= 100) { // high profile
chroma_format_idc = gb.UExpGolombRead();
- if(chroma_format_idc == 3) { // chroma_format_idc
+ if (chroma_format_idc == 3) { // chroma_format_idc
gb.BitRead(1); // residue_transform_flag
}
@@ -1615,10 +1615,10 @@ bool CBaseSplitterFileEx::Read(avchdr& h, spsppsindex index) gb.BitRead(1); // qpprime_y_zero_transform_bypass_flag
- if(gb.BitRead(1)) { // seq_scaling_matrix_present_flag
- for(int i = 0; i < 8; i++) {
- if(gb.BitRead(1)) { // seq_scaling_list_present_flag
- for(int j = 0, size = i < 6 ? 16 : 64, next = 8; j < size && next != 0; ++j) {
+ if (gb.BitRead(1)) { // seq_scaling_matrix_present_flag
+ for (int i = 0; i < 8; i++) {
+ if (gb.BitRead(1)) { // seq_scaling_list_present_flag
+ for (int j = 0, size = i < 6 ? 16 : 64, next = 8; j < size && next != 0; ++j) {
next = (next + gb.SExpGolombRead() + 256) & 255;
}
}
@@ -1630,24 +1630,24 @@ bool CBaseSplitterFileEx::Read(avchdr& h, spsppsindex index) UINT64 pic_order_cnt_type = gb.UExpGolombRead();
- if(pic_order_cnt_type == 0) {
+ if (pic_order_cnt_type == 0) {
gb.UExpGolombRead(); // log2_max_pic_order_cnt_lsb_minus4
- } else if(pic_order_cnt_type == 1) {
+ } else if (pic_order_cnt_type == 1) {
gb.BitRead(1); // delta_pic_order_always_zero_flag
gb.SExpGolombRead(); // offset_for_non_ref_pic
gb.SExpGolombRead(); // offset_for_top_to_bottom_field
UINT64 num_ref_frames_in_pic_order_cnt_cycle = gb.UExpGolombRead();
- if(num_ref_frames_in_pic_order_cnt_cycle >= 256)
+ if (num_ref_frames_in_pic_order_cnt_cycle >= 256)
return false;
- for(int i = 0; i < num_ref_frames_in_pic_order_cnt_cycle; i++) {
+ for (int i = 0; i < num_ref_frames_in_pic_order_cnt_cycle; i++) {
gb.SExpGolombRead(); // offset_for_ref_frame[i]
}
- } else if(pic_order_cnt_type != 2) {
+ } else if (pic_order_cnt_type != 2) {
return false;
}
UINT64 ref_frame_count = gb.UExpGolombRead(); // num_ref_frames
- if (ref_frame_count > 30)
+ if (ref_frame_count > 30)
return false;
gb.BitRead(1); // gaps_in_frame_num_value_allowed_flag
@@ -1655,29 +1655,29 @@ bool CBaseSplitterFileEx::Read(avchdr& h, spsppsindex index) UINT64 pic_height_in_map_units_minus1 = gb.UExpGolombRead();
BYTE frame_mbs_only_flag = (BYTE)gb.BitRead(1);
- if(!frame_mbs_only_flag) {
+ if (!frame_mbs_only_flag) {
gb.BitRead(1); // mb_adaptive_frame_field_flag
}
BYTE direct_8x8_inference_flag = (BYTE)gb.BitRead(1); // direct_8x8_inference_flag
- if(!frame_mbs_only_flag && !direct_8x8_inference_flag) {
+ if (!frame_mbs_only_flag && !direct_8x8_inference_flag) {
return false;
}
- if(gb.BitRead(1)) { // frame_cropping_flag
+ if (gb.BitRead(1)) { // frame_cropping_flag
h.crop_left = gb.UExpGolombRead(); // frame_cropping_rect_left_offset
h.crop_right = gb.UExpGolombRead(); // frame_cropping_rect_right_offset
h.crop_top = gb.UExpGolombRead(); // frame_cropping_rect_top_offset
h.crop_bottom = gb.UExpGolombRead(); // frame_cropping_rect_bottom_offset
}
- if(gb.BitRead(1)) { // vui_parameters_present_flag
- if(gb.BitRead(1)) { // aspect_ratio_info_present_flag
+ if (gb.BitRead(1)) { // vui_parameters_present_flag
+ if (gb.BitRead(1)) { // aspect_ratio_info_present_flag
BYTE aspect_ratio_idc = gb.BitRead(8); // aspect_ratio_idc
- if(255==(BYTE)aspect_ratio_idc) {
+ if (255==(BYTE)aspect_ratio_idc) {
h.sar.num = gb.BitRead(16); // sar_width
h.sar.den = gb.BitRead(16); // sar_height
- } else if(aspect_ratio_idc < 17) {
+ } else if (aspect_ratio_idc < 17) {
h.sar.num = pixel_aspect[aspect_ratio_idc][0];
h.sar.den = pixel_aspect[aspect_ratio_idc][1];
} else {
@@ -1688,24 +1688,24 @@ bool CBaseSplitterFileEx::Read(avchdr& h, spsppsindex index) h.sar.den = 1;
}
- if(gb.BitRead(1)) { // overscan_info_present_flag
+ if (gb.BitRead(1)) { // overscan_info_present_flag
gb.BitRead(1); // overscan_appropriate_flag
}
- if(gb.BitRead(1)) { // video_signal_type_present_flag
+ if (gb.BitRead(1)) { // video_signal_type_present_flag
gb.BitRead(3); // video_format
gb.BitRead(1); // video_full_range_flag
- if(gb.BitRead(1)) { // colour_description_present_flag
+ if (gb.BitRead(1)) { // colour_description_present_flag
gb.BitRead(8); // colour_primaries
gb.BitRead(8); // transfer_characteristics
gb.BitRead(8); // matrix_coefficients
}
}
- if(gb.BitRead(1)) { // chroma_location_info_present_flag
+ if (gb.BitRead(1)) { // chroma_location_info_present_flag
gb.UExpGolombRead(); // chroma_sample_loc_type_top_field
gb.UExpGolombRead(); // chroma_sample_loc_type_bottom_field
}
- if(gb.BitRead(1)) { // timing_info_present_flag
+ if (gb.BitRead(1)) { // timing_info_present_flag
__int64 num_units_in_tick = gb.BitRead(32);
__int64 time_scale = gb.BitRead(32);
/*long fixed_frame_rate_flag = */gb.BitRead(1);
@@ -1728,21 +1728,21 @@ bool CBaseSplitterFileEx::Read(avchdr& h, spsppsindex index) }
bool nalflag = !!gb.BitRead(1); // nal_hrd_parameters_present_flag
- if(nalflag) {
- if(HrdParameters(gb)<0)
+ if (nalflag) {
+ if (HrdParameters(gb)<0)
return false;
}
bool vlcflag = !!gb.BitRead(1); // vlc_hrd_parameters_present_flag
- if(vlcflag) {
- if(HrdParameters(gb)<0)
+ if (vlcflag) {
+ if (HrdParameters(gb)<0)
return false;
}
- if(nalflag || vlcflag) {
- gb.BitRead(1); // low_delay_hrd_flag
+ if (nalflag || vlcflag) {
+ gb.BitRead(1); // low_delay_hrd_flag
}
gb.BitRead(1); // pic_struct_present_flag
- if(gb.BitRead(1)) { // bitstream_restriction_flag
+ if (gb.BitRead(1)) { // bitstream_restriction_flag
gb.BitRead(1); // motion_vectors_over_pic_boundaries_flag
gb.UExpGolombRead(); // max_bytes_per_pic_denom
gb.UExpGolombRead(); // max_bits_per_mb_denom
@@ -1751,19 +1751,19 @@ bool CBaseSplitterFileEx::Read(avchdr& h, spsppsindex index) UINT64 num_reorder_frames = gb.UExpGolombRead(); // num_reorder_frames
gb.UExpGolombRead(); // max_dec_frame_buffering
- if(gb.GetSize() < gb.GetPos()){
+ if (gb.GetSize() < gb.GetPos()) {
num_reorder_frames = 0;
}
- if(num_reorder_frames > 16U)
+ if (num_reorder_frames > 16U)
return false;
}
}
- if(index == index_subsetsps) {
- if(h.profile == 83 || h.profile == 86) {
+ if (index == index_subsetsps) {
+ if (h.profile == 83 || h.profile == 86) {
// TODO: SVC extensions
return false;
- } else if(h.profile == 118 || h.profile == 128) {
+ } else if (h.profile == 118 || h.profile == 128) {
gb.BitRead(1); // bit_equal_to_one
// seq_parameter_set_mvc_extension
@@ -1838,18 +1838,18 @@ bool CBaseSplitterFileEx::Read(avchdr& h, spsppsindex index) BYTE CHROMA444 = (chroma_format_idc == 3);
h.width = 16 * mb_Width - (2>>CHROMA444) * min(h.crop_right, (8<<CHROMA444)-1);
- if(frame_mbs_only_flag) {
+ if (frame_mbs_only_flag) {
h.height = 16 * mb_Height - (2>>CHROMA444) * min(h.crop_bottom, (8<<CHROMA444)-1);
} else {
h.height = 16 * mb_Height - (4>>CHROMA444) * min(h.crop_bottom, (8<<CHROMA444)-1);
}
- if(h.height<100 || h.width<100) {
+ if (h.height<100 || h.width<100) {
return false;
}
- if(h.height == 1088) {
- h.height = 1080; // Prevent blur lines
+ if (h.height == 1088) {
+ h.height = 1080; // Prevent blur lines
}
return true;
@@ -1893,17 +1893,17 @@ bool CBaseSplitterFileEx::Read(vc1hdr& h, int len, CMediaType* pmt, int guid_fla h.finterpflag = BitRead (1);
BitRead (1); // reserved
h.psf = BitRead (1);
- if(BitRead (1)) {
+ if (BitRead (1)) {
int ar = 0;
BitRead (14);
BitRead (14);
- if(BitRead (1)) {
+ if (BitRead (1)) {
ar = BitRead (4);
}
- if(ar && ar < 14) {
+ if (ar && ar < 14) {
h.sar.num = pixel_aspect[ar][0];
h.sar.den = pixel_aspect[ar][1];
- } else if(ar == 15) {
+ } else if (ar == 15) {
h.sar.num = BitRead (8);
h.sar.den = BitRead (8);
}
@@ -1912,15 +1912,15 @@ bool CBaseSplitterFileEx::Read(vc1hdr& h, int len, CMediaType* pmt, int guid_fla const int ff_vc1_fps_nr[5] = { 24, 25, 30, 50, 60 },
ff_vc1_fps_dr[2] = { 1000, 1001 };
- if(BitRead (1)) {
- if(BitRead (1)) {
+ if (BitRead (1)) {
+ if (BitRead (1)) {
nFrameRateNum = 32;
nFrameRateDen = BitRead (16) + 1;
} else {
int nr, dr;
nr = BitRead (8);
dr = BitRead (4);
- if(nr && nr < 8 && dr && dr < 3) {
+ if (nr && nr < 8 && dr && dr < 3) {
nFrameRateNum = ff_vc1_fps_dr[dr - 1];
nFrameRateDen = ff_vc1_fps_nr[nr - 1] * 1000;
}
@@ -1939,11 +1939,11 @@ bool CBaseSplitterFileEx::Read(vc1hdr& h, int len, CMediaType* pmt, int guid_fla }
}
- if(!extrapos || !extralen) {
+ if (!extrapos || !extralen) {
return false;
}
- if(!pmt) {
+ if (!pmt) {
return true;
}
@@ -1963,14 +1963,14 @@ bool CBaseSplitterFileEx::Read(vc1hdr& h, int len, CMediaType* pmt, int guid_fla memset(vi, 0, len);
vi->AvgTimePerFrame = (10000000I64*nFrameRateNum)/nFrameRateDen;
- if(!h.sar.num) h.sar.num = 1;
- if(!h.sar.den) h.sar.den = 1;
+ if (!h.sar.num) h.sar.num = 1;
+ if (!h.sar.den) h.sar.den = 1;
CSize aspect = CSize(h.width * h.sar.num, h.height * h.sar.den);
- if(h.width == h.sar.num && h.height == h.sar.den) {
+ if (h.width == h.sar.num && h.height == h.sar.den) {
aspect = CSize(h.width, h.height);
}
int lnko = LNKO(aspect.cx, aspect.cy);
- if(lnko > 1) {
+ if (lnko > 1) {
aspect.cx /= lnko, aspect.cy /= lnko;
}
diff --git a/src/filters/parser/BaseSplitter/BaseSplitterFileEx.h b/src/filters/parser/BaseSplitter/BaseSplitterFileEx.h index 9866c1891..52b1bab04 100644 --- a/src/filters/parser/BaseSplitter/BaseSplitterFileEx.h +++ b/src/filters/parser/BaseSplitter/BaseSplitterFileEx.h @@ -26,7 +26,7 @@ #define MAX_SPSPPS 256 // Max size for a SPS/PPS packet
class CGolombBuffer;
-static const byte pixel_aspect[17][2]={
+static const byte pixel_aspect[17][2]= {
{0, 1},
{1, 1},
{12, 11},
@@ -369,10 +369,10 @@ public: UINT64 crop_left, crop_right, crop_top, crop_bottom;
__int64 AvgTimePerFrame;
- struct sar{
+ struct sar {
BYTE num;
BYTE den;
- }sar;
+ } sar;
spsppsdata spspps[4];
BYTE lastid;
@@ -399,10 +399,10 @@ public: BYTE finterpflag;
BYTE psf;
unsigned int width, height;
- struct sar{
+ struct sar {
BYTE num;
BYTE den;
- }sar;
+ } sar;
};
struct dvbsub {
diff --git a/src/filters/parser/BaseSplitter/MultiFiles.cpp b/src/filters/parser/BaseSplitter/MultiFiles.cpp index cd08aec72..ca0a5c8cd 100644 --- a/src/filters/parser/BaseSplitter/MultiFiles.cpp +++ b/src/filters/parser/BaseSplitter/MultiFiles.cpp @@ -59,7 +59,7 @@ BOOL CMultiFiles::OpenFiles(CAtlList<CHdmvClipInfo::PlaylistItem>& files, UINT n REFERENCE_TIME rtDur = 0;
Reset();
- while(pos) {
+ while (pos) {
CHdmvClipInfo::PlaylistItem& s = files.GetNext(pos);
m_strFiles.Add(s.m_strFileName);
if (!OpenPart(nPos)) {
diff --git a/src/filters/parser/DSMSplitter/DSMSplitter.cpp b/src/filters/parser/DSMSplitter/DSMSplitter.cpp index 8ec453c3f..3ed71b3b3 100644 --- a/src/filters/parser/DSMSplitter/DSMSplitter.cpp +++ b/src/filters/parser/DSMSplitter/DSMSplitter.cpp @@ -101,7 +101,7 @@ STDMETHODIMP CDSMSplitterFilter::QueryFilterInfo(FILTER_INFO* pInfo) wcscpy(pInfo->achName, DSMSourceName);
}
pInfo->pGraph = m_pGraph;
- if(m_pGraph) {
+ if (m_pGraph) {
m_pGraph->AddRef();
}
@@ -121,10 +121,10 @@ HRESULT CDSMSplitterFilter::CreateOutputs(IAsyncReader* pAsyncReader) m_pFile.Free();
m_pFile.Attach(DNew CDSMSplitterFile(pAsyncReader, hr, *this, *this));
- if(!m_pFile) {
+ if (!m_pFile) {
return E_OUTOFMEMORY;
}
- if(FAILED(hr)) {
+ if (FAILED(hr)) {
m_pFile.Free();
return hr;
}
@@ -135,7 +135,7 @@ HRESULT CDSMSplitterFilter::CreateOutputs(IAsyncReader* pAsyncReader) CAtlArray<BYTE> ids;
POSITION pos = m_pFile->m_mts.GetStartPosition();
- while(pos) {
+ while (pos) {
BYTE id;
CMediaType mt;
m_pFile->m_mts.GetNextAssoc(pos, id, mt);
@@ -144,7 +144,7 @@ HRESULT CDSMSplitterFilter::CreateOutputs(IAsyncReader* pAsyncReader) qsort(ids.GetData(), ids.GetCount(), sizeof(BYTE), compare_id);
- for(size_t i = 0; i < ids.GetCount(); i++) {
+ for (size_t i = 0; i < ids.GetCount(); i++) {
BYTE id = ids[i];
CMediaType& mt = m_pFile->m_mts[id];
@@ -159,26 +159,26 @@ HRESULT CDSMSplitterFilter::CreateOutputs(IAsyncReader* pAsyncReader) name.Empty();
pos = m_pFile->m_sim[id].GetStartPosition();
- while(pos) {
+ while (pos) {
CStringA key;
CStringW value;
m_pFile->m_sim[id].GetNextAssoc(pos, key, value);
pPinOut->SetProperty(CStringW(key), value);
- if(key == "NAME") {
+ if (key == "NAME") {
name = value;
}
- if(key == "LANG") if((lang = ISO6392ToLanguage(CStringA(CString(value)))).IsEmpty()) {
+ if (key == "LANG") if ((lang = ISO6392ToLanguage(CStringA(CString(value)))).IsEmpty()) {
lang = value;
}
}
- if(!name.IsEmpty() || !lang.IsEmpty()) {
- if(!name.IsEmpty()) {
- if(!lang.IsEmpty()) {
+ if (!name.IsEmpty() || !lang.IsEmpty()) {
+ if (!name.IsEmpty()) {
+ if (!lang.IsEmpty()) {
name += L" (" + lang + L")";
}
- } else if(!lang.IsEmpty()) {
+ } else if (!lang.IsEmpty()) {
name = lang;
}
pPinOut->SetName(name);
@@ -188,18 +188,18 @@ HRESULT CDSMSplitterFilter::CreateOutputs(IAsyncReader* pAsyncReader) }
pos = m_pFile->m_fim.GetStartPosition();
- while(pos) {
+ while (pos) {
CStringA key;
CStringW value;
m_pFile->m_fim.GetNextAssoc(pos, key, value);
SetProperty(CStringW(key), value);
}
- for(size_t i = 0; i < m_resources.GetCount(); i++) {
+ for (size_t i = 0; i < m_resources.GetCount(); i++) {
const CDSMResource& r = m_resources[i];
- if(r.mime == "application/x-truetype-font" ||
- r.mime == "application/x-font-ttf" ||
- r.mime == "application/vnd.ms-opentype") {
+ if (r.mime == "application/x-truetype-font" ||
+ r.mime == "application/x-font-ttf" ||
+ r.mime == "application/vnd.ms-opentype") {
//m_fontinst.InstallFont(r.data);
m_fontinst.InstallFontMemory(r.data.GetData(), r.data.GetCount());
}
@@ -223,20 +223,20 @@ bool CDSMSplitterFilter::DemuxLoop() {
HRESULT hr = S_OK;
- while(SUCCEEDED(hr) && !CheckRequest(NULL) && m_pFile->GetRemaining()) {
+ while (SUCCEEDED(hr) && !CheckRequest(NULL) && m_pFile->GetRemaining()) {
dsmp_t type;
UINT64 len;
- if(!m_pFile->Sync(type, len)) {
+ if (!m_pFile->Sync(type, len)) {
continue;
}
__int64 pos = m_pFile->GetPos();
- if(type == DSMP_SAMPLE) {
+ if (type == DSMP_SAMPLE) {
CAutoPtr<Packet> p(DNew Packet());
- if(m_pFile->Read(len, p)) {
- if(p->rtStart != Packet::INVALID_TIME) {
+ if (m_pFile->Read(len, p)) {
+ if (p->rtStart != Packet::INVALID_TIME) {
p->rtStart -= m_pFile->m_rtFirst;
p->rtStop -= m_pFile->m_rtFirst;
}
@@ -266,12 +266,12 @@ STDMETHODIMP CDSMSplitterFilter::GetKeyFrames(const GUID* pFormat, REFERENCE_TIM CheckPointer(pKFs, E_POINTER);
CheckPointer(m_pFile, E_UNEXPECTED);
- if(*pFormat != TIME_FORMAT_MEDIA_TIME) {
+ if (*pFormat != TIME_FORMAT_MEDIA_TIME) {
return E_INVALIDARG;
}
// these aren't really the keyframes, but quicky accessable points in the stream
- for(nKFs = 0; nKFs < m_pFile->m_sps.GetCount(); nKFs++) {
+ for (nKFs = 0; nKFs < m_pFile->m_sps.GetCount(); nKFs++) {
pKFs[nKFs] = m_pFile->m_sps[nKFs].rt;
}
diff --git a/src/filters/parser/DSMSplitter/DSMSplitterFile.cpp b/src/filters/parser/DSMSplitter/DSMSplitterFile.cpp index 2219844c0..715864b87 100644 --- a/src/filters/parser/DSMSplitter/DSMSplitterFile.cpp +++ b/src/filters/parser/DSMSplitter/DSMSplitterFile.cpp @@ -8,7 +8,7 @@ CDSMSplitterFile::CDSMSplitterFile(IAsyncReader* pReader, HRESULT& hr, IDSMResou , m_rtFirst(0)
, m_rtDuration(0)
{
- if(FAILED(hr)) {
+ if (FAILED(hr)) {
return;
}
@@ -19,7 +19,7 @@ HRESULT CDSMSplitterFile::Init(IDSMResourceBagImpl& res, IDSMChapterBagImpl& cha {
Seek(0);
- if(BitRead(DSMSW_SIZE<<3) != DSMSW || BitRead(5) != DSMP_FILEINFO) {
+ if (BitRead(DSMSW_SIZE<<3) != DSMSW || BitRead(5) != DSMP_FILEINFO) {
return E_FAIL;
}
@@ -38,64 +38,64 @@ HRESULT CDSMSplitterFile::Init(IDSMResourceBagImpl& res, IDSMChapterBagImpl& cha // examine the beginning of the file ...
- while(Sync(type, len, 0)) {
+ while (Sync(type, len, 0)) {
__int64 pos = GetPos();
- if(type == DSMP_MEDIATYPE) {
+ if (type == DSMP_MEDIATYPE) {
BYTE id;
CMediaType mt;
- if(Read(len, id, mt)) {
+ if (Read(len, id, mt)) {
m_mts[id] = mt;
}
- } else if(type == DSMP_SAMPLE) {
+ } else if (type == DSMP_SAMPLE) {
Packet p;
- if(Read(len, &p, false) && p.rtStart != Packet::INVALID_TIME) {
+ if (Read(len, &p, false) && p.rtStart != Packet::INVALID_TIME) {
m_rtFirst = p.rtStart;
break;
}
- } else if(type == DSMP_FILEINFO) {
- if((BYTE)BitRead(8) > DSMF_VERSION) {
+ } else if (type == DSMP_FILEINFO) {
+ if ((BYTE)BitRead(8) > DSMF_VERSION) {
return E_FAIL;
}
Read(len-1, m_fim);
- } else if(type == DSMP_STREAMINFO) {
+ } else if (type == DSMP_STREAMINFO) {
Read(len-1, m_sim[(BYTE)BitRead(8)]);
- } else if(type == DSMP_SYNCPOINTS) {
+ } else if (type == DSMP_SYNCPOINTS) {
Read(len, m_sps);
- } else if(type == DSMP_RESOURCE) {
+ } else if (type == DSMP_RESOURCE) {
Read(len, res);
- } else if(type == DSMP_CHAPTERS) {
+ } else if (type == DSMP_CHAPTERS) {
Read(len, chap);
}
Seek(pos + len);
}
- if(type != DSMP_SAMPLE) {
+ if (type != DSMP_SAMPLE) {
return E_FAIL;
}
// ... and the end
- if(IsRandomAccess())
- for(int i = 1, j = (int)((GetLength()+limit/2)/limit); i <= j; i++) {
+ if (IsRandomAccess())
+ for (int i = 1, j = (int)((GetLength()+limit/2)/limit); i <= j; i++) {
__int64 seekpos = max(0, (__int64)GetLength()-i*limit);
Seek(seekpos);
- while(Sync(type, len, limit) && GetPos() < seekpos+limit) {
+ while (Sync(type, len, limit) && GetPos() < seekpos+limit) {
__int64 pos = GetPos();
- if(type == DSMP_SAMPLE) {
+ if (type == DSMP_SAMPLE) {
Packet p;
- if(Read(len, &p, false) && p.rtStart != Packet::INVALID_TIME) {
+ if (Read(len, &p, false) && p.rtStart != Packet::INVALID_TIME) {
m_rtDuration = max(m_rtDuration, p.rtStop - m_rtFirst); // max isn't really needed, only for safety
i = j;
}
- } else if(type == DSMP_SYNCPOINTS) {
+ } else if (type == DSMP_SYNCPOINTS) {
Read(len, m_sps);
- } else if(type == DSMP_RESOURCE) {
+ } else if (type == DSMP_RESOURCE) {
Read(len, res);
- } else if(type == DSMP_CHAPTERS) {
+ } else if (type == DSMP_CHAPTERS) {
Read(len, chap);
}
@@ -103,7 +103,7 @@ HRESULT CDSMSplitterFile::Init(IDSMResourceBagImpl& res, IDSMChapterBagImpl& cha }
}
- if(m_rtFirst < 0) {
+ if (m_rtFirst < 0) {
m_rtDuration += m_rtFirst;
m_rtFirst = 0;
}
@@ -123,8 +123,8 @@ bool CDSMSplitterFile::Sync(UINT64& syncpos, dsmp_t& type, UINT64& len, __int64 limit += DSMSW_SIZE;
- for(UINT64 id = 0; (id&((1ui64<<(DSMSW_SIZE<<3))-1)) != DSMSW; id = (id << 8) | (BYTE)BitRead(8)) {
- if(limit-- <= 0 || GetRemaining() <= 2) {
+ for (UINT64 id = 0; (id&((1ui64<<(DSMSW_SIZE<<3))-1)) != DSMSW; id = (id << 8) | (BYTE)BitRead(8)) {
+ if (limit-- <= 0 || GetRemaining() <= 2) {
return false;
}
}
@@ -147,7 +147,7 @@ bool CDSMSplitterFile::Read(__int64 len, BYTE& id, CMediaType& mt) ByteRead((BYTE*)&mt.formattype, sizeof(mt.formattype));
len -= 5 + sizeof(GUID)*3;
ASSERT(len >= 0);
- if(len > 0) {
+ if (len > 0) {
mt.AllocFormatBuffer((LONG)len);
ByteRead(mt.Format(), mt.FormatLength());
} else {
@@ -158,7 +158,7 @@ bool CDSMSplitterFile::Read(__int64 len, BYTE& id, CMediaType& mt) bool CDSMSplitterFile::Read(__int64 len, Packet* p, bool fData)
{
- if(!p) {
+ if (!p) {
return false;
}
@@ -168,7 +168,7 @@ bool CDSMSplitterFile::Read(__int64 len, Packet* p, bool fData) int iTimeStamp = (int)BitRead(3);
int iDuration = (int)BitRead(3);
- if(fSign && !iTimeStamp) {
+ if (fSign && !iTimeStamp) {
ASSERT(!iDuration);
p->rtStart = Packet::INVALID_TIME;
p->rtStop = Packet::INVALID_TIME + 1;
@@ -177,7 +177,7 @@ bool CDSMSplitterFile::Read(__int64 len, Packet* p, bool fData) p->rtStop = p->rtStart + BitRead(iDuration<<3);
}
- if(fData) {
+ if (fData) {
p->SetCount((INT_PTR)len - (2 + iTimeStamp + iDuration));
ByteRead(p->GetData(), p->GetCount());
}
@@ -190,7 +190,7 @@ bool CDSMSplitterFile::Read(__int64 len, CAtlArray<SyncPoint>& sps) SyncPoint sp = {0, 0};
sps.RemoveAll();
- while(len > 0) {
+ while (len > 0) {
bool fSign = !!BitRead(1);
int iTimeStamp = (int)BitRead(3);
int iFilePos = (int)BitRead(3);
@@ -203,7 +203,7 @@ bool CDSMSplitterFile::Read(__int64 len, CAtlArray<SyncPoint>& sps) len -= 1 + iTimeStamp + iFilePos;
}
- if(len != 0) {
+ if (len != 0) {
sps.RemoveAll();
return false;
}
@@ -215,7 +215,7 @@ bool CDSMSplitterFile::Read(__int64 len, CAtlArray<SyncPoint>& sps) bool CDSMSplitterFile::Read(__int64 len, CStreamInfoMap& im)
{
- while(len >= 5) {
+ while (len >= 5) {
CStringA key;
ByteRead((BYTE*)key.GetBufferSetLength(4), 4);
len -= 4;
@@ -237,7 +237,7 @@ bool CDSMSplitterFile::Read(__int64 len, IDSMResourceBagImpl& res) len -= Read(len, r.desc);
len -= Read(len, r.mime);
- if(compression != 0) {
+ if (compression != 0) {
return false; // TODO
}
@@ -253,7 +253,7 @@ bool CDSMSplitterFile::Read(__int64 len, IDSMChapterBagImpl& chap) {
CDSMChapter c(0, L"");
- while(len > 0) {
+ while (len > 0) {
bool fSign = !!BitRead(1);
int iTimeStamp = (int)BitRead(3);
BitRead(4); // reserved
@@ -276,7 +276,7 @@ __int64 CDSMSplitterFile::Read(__int64 len, CStringW& str) char c;
CStringA s;
__int64 i = 0;
- while(i++ < len && (c = (char)BitRead(8)) != 0) {
+ while (i++ < len && (c = (char)BitRead(8)) != 0) {
s += c;
}
str = UTF8To16(s);
@@ -285,12 +285,12 @@ __int64 CDSMSplitterFile::Read(__int64 len, CStringW& str) __int64 CDSMSplitterFile::FindSyncPoint(REFERENCE_TIME rt)
{
- if(/*!m_sps.IsEmpty()*/ m_sps.GetCount() > 1) {
+ if (/*!m_sps.IsEmpty()*/ m_sps.GetCount() > 1) {
int i = range_bsearch(m_sps, m_rtFirst + rt);
return i >= 0 ? m_sps[i].fp : 0;
}
- if(m_rtDuration <= 0 || rt <= m_rtFirst) {
+ if (m_rtDuration <= 0 || rt <= m_rtFirst) {
return 0;
}
@@ -303,21 +303,21 @@ __int64 CDSMSplitterFile::FindSyncPoint(REFERENCE_TIME rt) __int64 minpos = 0, maxpos = GetLength();
- for(int i = 0; i < 10 && (maxpos - minpos) >= 1024*1024; i++) {
+ for (int i = 0; i < 10 && (maxpos - minpos) >= 1024*1024; i++) {
Seek((minpos + maxpos) / 2);
- while(GetPos() < maxpos) {
- if(!Sync(syncpos, type, len)) {
+ while (GetPos() < maxpos) {
+ if (!Sync(syncpos, type, len)) {
continue;
}
__int64 pos = GetPos();
- if(type == DSMP_SAMPLE) {
+ if (type == DSMP_SAMPLE) {
Packet p;
- if(Read(len, &p, false) && p.rtStart != Packet::INVALID_TIME) {
+ if (Read(len, &p, false) && p.rtStart != Packet::INVALID_TIME) {
REFERENCE_TIME dt = (p.rtStart -= m_rtFirst) - rt;
- if(dt >= 0) {
+ if (dt >= 0) {
maxpos = max((__int64)syncpos - 65536, minpos);
} else {
minpos = syncpos;
@@ -334,18 +334,18 @@ __int64 CDSMSplitterFile::FindSyncPoint(REFERENCE_TIME rt) Seek(minpos);
- while(GetRemaining()) {
- if(!Sync(syncpos, type, len)) {
+ while (GetRemaining()) {
+ if (!Sync(syncpos, type, len)) {
continue;
}
__int64 pos = GetPos();
- if(type == DSMP_SAMPLE) {
+ if (type == DSMP_SAMPLE) {
Packet p;
- if(Read(len, &p, false) && p.rtStart != Packet::INVALID_TIME) {
+ if (Read(len, &p, false) && p.rtStart != Packet::INVALID_TIME) {
REFERENCE_TIME dt = (p.rtStart -= m_rtFirst) - rt;
- if(dt >= 0) {
+ if (dt >= 0) {
maxpos = (__int64)syncpos;
break;
}
@@ -361,11 +361,11 @@ __int64 CDSMSplitterFile::FindSyncPoint(REFERENCE_TIME rt) {
POSITION pos = m_mts.GetStartPosition();
- while(pos) {
+ while (pos) {
BYTE id;
CMediaType mt;
m_mts.GetNextAssoc(pos, id, mt);
- if(mt.majortype != MEDIATYPE_Text && mt.majortype != MEDIATYPE_Subtitle) {
+ if (mt.majortype != MEDIATYPE_Text && mt.majortype != MEDIATYPE_Subtitle) {
ids[id] = 0;
}
}
@@ -373,19 +373,19 @@ __int64 CDSMSplitterFile::FindSyncPoint(REFERENCE_TIME rt) __int64 ret = maxpos;
- while(maxpos > 0 && !ids.IsEmpty()) {
+ while (maxpos > 0 && !ids.IsEmpty()) {
minpos = max(0, maxpos - 65536);
Seek(minpos);
- while(Sync(syncpos, type, len) && GetPos() < maxpos) {
+ while (Sync(syncpos, type, len) && GetPos() < maxpos) {
UINT64 pos = GetPos();
- if(type == DSMP_SAMPLE) {
+ if (type == DSMP_SAMPLE) {
Packet p;
- if(Read(len, &p, false) && p.rtStart != Packet::INVALID_TIME && p.bSyncPoint) {
+ if (Read(len, &p, false) && p.rtStart != Packet::INVALID_TIME && p.bSyncPoint) {
BYTE id = (BYTE)p.TrackNumber, tmp;
- if(ids.Lookup(id, tmp)) {
+ if (ids.Lookup(id, tmp)) {
ids.RemoveKey((BYTE)p.TrackNumber);
ret = min(ret, (__int64)syncpos);
}
diff --git a/src/filters/parser/FLVSplitter/FLVSplitter.cpp b/src/filters/parser/FLVSplitter/FLVSplitter.cpp index ccc0ee1b9..d56aade66 100644 --- a/src/filters/parser/FLVSplitter/FLVSplitter.cpp +++ b/src/filters/parser/FLVSplitter/FLVSplitter.cpp @@ -27,12 +27,12 @@ #include <moreuuids.h>
enum {
- FLV_CODECID_H263 = 2,
- FLV_CODECID_SCREEN = 3,
- FLV_CODECID_VP6 = 4,
- FLV_CODECID_VP6A = 5,
- FLV_CODECID_SCREEN2 = 6,
- FLV_CODECID_H264 = 7,
+ FLV_CODECID_H263 = 2,
+ FLV_CODECID_SCREEN = 3,
+ FLV_CODECID_VP6 = 4,
+ FLV_CODECID_VP6A = 5,
+ FLV_CODECID_SCREEN2 = 6,
+ FLV_CODECID_H264 = 7,
};
#ifdef REGISTER_FILTER
@@ -105,7 +105,7 @@ STDMETHODIMP CFLVSplitterFilter::QueryFilterInfo(FILTER_INFO* pInfo) wcscpy(pInfo->achName, FlvSourceName);
}
pInfo->pGraph = m_pGraph;
- if(m_pGraph) {
+ if (m_pGraph) {
m_pGraph->AddRef();
}
@@ -114,7 +114,7 @@ STDMETHODIMP CFLVSplitterFilter::QueryFilterInfo(FILTER_INFO* pInfo) bool CFLVSplitterFilter::ReadTag(Tag& t)
{
- if(m_pFile->GetRemaining() < 15) {
+ if (m_pFile->GetRemaining() < 15) {
return false;
}
@@ -130,7 +130,7 @@ bool CFLVSplitterFilter::ReadTag(Tag& t) bool CFLVSplitterFilter::ReadTag(AudioTag& at)
{
- if(!m_pFile->GetRemaining()) {
+ if (!m_pFile->GetRemaining()) {
return false;
}
@@ -144,7 +144,7 @@ bool CFLVSplitterFilter::ReadTag(AudioTag& at) bool CFLVSplitterFilter::ReadTag(VideoTag& vt)
{
- if(!m_pFile->GetRemaining()) {
+ if (!m_pFile->GetRemaining()) {
return false;
}
@@ -157,7 +157,7 @@ bool CFLVSplitterFilter::ReadTag(VideoTag& vt) #ifndef NOVIDEOTWEAK
bool CFLVSplitterFilter::ReadTag(VideoTweak& vt)
{
- if(!m_pFile->GetRemaining()) {
+ if (!m_pFile->GetRemaining()) {
return false;
}
@@ -172,7 +172,7 @@ bool CFLVSplitterFilter::Sync(__int64& pos) {
m_pFile->Seek(pos);
- while(m_pFile->GetRemaining() >= 15) {
+ while (m_pFile->GetRemaining() >= 15) {
__int64 limit = m_pFile->GetRemaining();
while (true) {
BYTE b = m_pFile->BitRead(8);
@@ -190,7 +190,7 @@ bool CFLVSplitterFilter::Sync(__int64& pos) Tag ct;
if (ReadTag(ct)) {
__int64 next = m_pFile->GetPos() + ct.DataSize;
- if(next == m_pFile->GetLength() - 4) {
+ if (next == m_pFile->GetLength() - 4) {
m_pFile->Seek(pos);
return true;
} else if (next <= m_pFile->GetLength() - 19) {
@@ -222,10 +222,10 @@ HRESULT CFLVSplitterFilter::CreateOutputs(IAsyncReader* pAsyncReader) m_pFile.Free();
m_pFile.Attach(DNew CBaseSplitterFileEx(pAsyncReader, hr, DEFAULT_CACHE_LENGTH, false));
- if(!m_pFile) {
+ if (!m_pFile) {
return E_OUTOFMEMORY;
}
- if(FAILED(hr)) {
+ if (FAILED(hr)) {
m_pFile.Free();
return hr;
}
@@ -233,7 +233,7 @@ HRESULT CFLVSplitterFilter::CreateOutputs(IAsyncReader* pAsyncReader) m_rtNewStart = m_rtCurrent = 0;
m_rtNewStop = m_rtStop = m_rtDuration = 0;
- if(m_pFile->BitRead(24) != 'FLV' || m_pFile->BitRead(8) != 1) {
+ if (m_pFile->BitRead(24) != 'FLV' || m_pFile->BitRead(8) != 1) {
return E_FAIL;
}
@@ -255,8 +255,8 @@ HRESULT CFLVSplitterFilter::CreateOutputs(IAsyncReader* pAsyncReader) m_pFile->Seek(m_DataOffset);
- for(int i = 0; ReadTag(t) && (fTypeFlagsVideo || fTypeFlagsAudio); i++) {
- if(!t.DataSize) continue; // skip empty Tag
+ for (int i = 0; ReadTag(t) && (fTypeFlagsVideo || fTypeFlagsAudio); i++) {
+ if (!t.DataSize) continue; // skip empty Tag
UINT64 next = m_pFile->GetPos() + t.DataSize;
@@ -272,12 +272,12 @@ HRESULT CFLVSplitterFilter::CreateOutputs(IAsyncReader* pAsyncReader) }
prevTagSize = t.DataSize + 11;
- if(t.TagType == 8 && t.DataSize != 0 && fTypeFlagsAudio) {
+ if (t.TagType == 8 && t.DataSize != 0 && fTypeFlagsAudio) {
UNREFERENCED_PARAMETER(at);
AudioTag at;
name = L"Audio";
- if(ReadTag(at)) {
+ if (ReadTag(at)) {
int dataSize = t.DataSize - 1;
fTypeFlagsAudio = false;
@@ -290,7 +290,7 @@ HRESULT CFLVSplitterFilter::CreateOutputs(IAsyncReader* pAsyncReader) wfe->wBitsPerSample = 8*(at.SoundSize+1);
wfe->nChannels = at.SoundType+1;
- switch(at.SoundFormat) {
+ switch (at.SoundFormat) {
case 0: // FLV_CODECID_PCM_BE
mt.subtype = FOURCCMap(wfe->wFormatTag = WAVE_FORMAT_PCM);
name += L" PCM";
@@ -316,11 +316,11 @@ HRESULT CFLVSplitterFilter::CreateOutputs(IAsyncReader* pAsyncReader) case 2: // FLV_CODECID_MP3
mt.subtype = FOURCCMap(wfe->wFormatTag = WAVE_FORMAT_MP3);
name += L" MP3";
-
+
{
CBaseSplitterFileEx::mpahdr h;
CMediaType mt2;
- if(m_pFile->Read(h, 4, false, &mt2)) {
+ if (m_pFile->Read(h, 4, false, &mt2)) {
mt = mt2;
}
}
@@ -386,10 +386,10 @@ HRESULT CFLVSplitterFilter::CreateOutputs(IAsyncReader* pAsyncReader) }
}
- } else if(t.TagType == 9 && t.DataSize != 0 && fTypeFlagsVideo) {
+ } else if (t.TagType == 9 && t.DataSize != 0 && fTypeFlagsVideo) {
UNREFERENCED_PARAMETER(vt);
VideoTag vt;
- if(ReadTag(vt) && vt.FrameType == 1) {
+ if (ReadTag(vt) && vt.FrameType == 1) {
int dataSize = t.DataSize - 1;
fTypeFlagsVideo = false;
@@ -404,15 +404,15 @@ HRESULT CFLVSplitterFilter::CreateOutputs(IAsyncReader* pAsyncReader) int w, h, arx, ary;
- switch(vt.CodecID) {
+ switch (vt.CodecID) {
case FLV_CODECID_H263: // H.263
- if(m_pFile->BitRead(17) != 1) {
+ if (m_pFile->BitRead(17) != 1) {
break;
}
m_pFile->BitRead(13); // Version (5), TemporalReference (8)
- switch(BYTE PictureSize = (BYTE)m_pFile->BitRead(3)) { // w00t
+ switch (BYTE PictureSize = (BYTE)m_pFile->BitRead(3)) { // w00t
case 0:
case 1:
vih->bmiHeader.biWidth = (WORD)m_pFile->BitRead(8*(PictureSize+1));
@@ -432,7 +432,7 @@ HRESULT CFLVSplitterFilter::CreateOutputs(IAsyncReader* pAsyncReader) break;
}
- if(!vih->bmiHeader.biWidth || !vih->bmiHeader.biHeight) {
+ if (!vih->bmiHeader.biWidth || !vih->bmiHeader.biHeight) {
break;
}
@@ -446,7 +446,7 @@ HRESULT CFLVSplitterFilter::CreateOutputs(IAsyncReader* pAsyncReader) m_pFile->BitRead(4);
vih->bmiHeader.biHeight = m_pFile->BitRead(12);
- if(!vih->bmiHeader.biWidth || !vih->bmiHeader.biHeight) {
+ if (!vih->bmiHeader.biWidth || !vih->bmiHeader.biHeight) {
break;
}
@@ -490,7 +490,7 @@ HRESULT CFLVSplitterFilter::CreateOutputs(IAsyncReader* pAsyncReader) ary = m_pFile->BitRead(8) * 16;
arx = m_pFile->BitRead(8) * 16;
- if(arx && arx != w || ary && ary != h) {
+ if (arx && arx != w || ary && ary != h) {
VIDEOINFOHEADER2* vih2 = (VIDEOINFOHEADER2*)mt.AllocFormatBuffer(sizeof(VIDEOINFOHEADER2));
memset(vih2, 0, sizeof(VIDEOINFOHEADER2));
vih2->dwPictAspectRatioX = arx;
@@ -540,31 +540,31 @@ HRESULT CFLVSplitterFilter::CreateOutputs(IAsyncReader* pAsyncReader) vih->dwLevel = (BYTE)m_pFile->BitRead(8);
m_pFile->UExpGolombRead(); // seq_parameter_set_id
UINT64 chroma_format_idc = 0;
- if(vih->dwProfile >= 100) { // high profile
+ if (vih->dwProfile >= 100) { // high profile
chroma_format_idc = m_pFile->UExpGolombRead();
- if(chroma_format_idc == 3) { // chroma_format_idc
+ if (chroma_format_idc == 3) { // chroma_format_idc
m_pFile->BitRead(1); // residue_transform_flag
}
m_pFile->UExpGolombRead(); // bit_depth_luma_minus8
m_pFile->UExpGolombRead(); // bit_depth_chroma_minus8
m_pFile->BitRead(1); // qpprime_y_zero_transform_bypass_flag
- if(m_pFile->BitRead(1)) // seq_scaling_matrix_present_flag
- for(int i = 0; i < 8; i++)
- if(m_pFile->BitRead(1)) // seq_scaling_list_present_flag
- for(int j = 0, size = i < 6 ? 16 : 64, next = 8; j < size && next != 0; ++j) {
+ if (m_pFile->BitRead(1)) // seq_scaling_matrix_present_flag
+ for (int i = 0; i < 8; i++)
+ if (m_pFile->BitRead(1)) // seq_scaling_list_present_flag
+ for (int j = 0, size = i < 6 ? 16 : 64, next = 8; j < size && next != 0; ++j) {
next = (next + m_pFile->SExpGolombRead() + 256) & 255;
}
}
m_pFile->UExpGolombRead(); // log2_max_frame_num_minus4
UINT64 pic_order_cnt_type = m_pFile->UExpGolombRead();
- if(pic_order_cnt_type == 0) {
+ if (pic_order_cnt_type == 0) {
m_pFile->UExpGolombRead(); // log2_max_pic_order_cnt_lsb_minus4
- } else if(pic_order_cnt_type == 1) {
+ } else if (pic_order_cnt_type == 1) {
m_pFile->BitRead(1); // delta_pic_order_always_zero_flag
m_pFile->SExpGolombRead(); // offset_for_non_ref_pic
m_pFile->SExpGolombRead(); // offset_for_top_to_bottom_field
UINT64 num_ref_frames_in_pic_order_cnt_cycle = m_pFile->UExpGolombRead();
- for(int i = 0; i < num_ref_frames_in_pic_order_cnt_cycle; i++) {
+ for (int i = 0; i < num_ref_frames_in_pic_order_cnt_cycle; i++) {
m_pFile->SExpGolombRead(); // offset_for_ref_frame[i]
}
}
@@ -573,7 +573,7 @@ HRESULT CFLVSplitterFilter::CreateOutputs(IAsyncReader* pAsyncReader) UINT64 pic_width_in_mbs_minus1 = m_pFile->UExpGolombRead();
UINT64 pic_height_in_map_units_minus1 = m_pFile->UExpGolombRead();
BYTE frame_mbs_only_flag = (BYTE)m_pFile->BitRead(1);
- if(!frame_mbs_only_flag) {
+ if (!frame_mbs_only_flag) {
m_pFile->BitRead(1); // mb_adaptive_frame_field_flag
}
m_pFile->BitRead(1); // direct_8x8_inference_flag
@@ -583,24 +583,24 @@ HRESULT CFLVSplitterFilter::CreateOutputs(IAsyncReader* pAsyncReader) UINT64 crop_top = 0;
UINT64 crop_bottom = 0;
- if(crop) {
+ if (crop) {
crop_left = m_pFile->UExpGolombRead(); // frame_cropping_rect_left_offset
crop_right = m_pFile->UExpGolombRead(); // frame_cropping_rect_right_offset
crop_top = m_pFile->UExpGolombRead(); // frame_cropping_rect_top_offset
crop_bottom = m_pFile->UExpGolombRead(); // frame_cropping_rect_bottom_offset
}
- struct sar{
+ struct sar {
BYTE num;
BYTE den;
- }sar;
+ } sar;
- if(m_pFile->BitRead(1)) { // vui_parameters_present_flag
- if(m_pFile->BitRead(1)) { // aspect_ratio_info_present_flag
+ if (m_pFile->BitRead(1)) { // vui_parameters_present_flag
+ if (m_pFile->BitRead(1)) { // aspect_ratio_info_present_flag
BYTE aspect_ratio_idc = m_pFile->BitRead(8); // aspect_ratio_idc
- if(255==(BYTE)aspect_ratio_idc) {
+ if (255==(BYTE)aspect_ratio_idc) {
sar.num = m_pFile->BitRead(16); // sar_width
sar.den = m_pFile->BitRead(16); // sar_height
- } else if(aspect_ratio_idc < 17) {
+ } else if (aspect_ratio_idc < 17) {
sar.num = pixel_aspect[aspect_ratio_idc][0];
sar.den = pixel_aspect[aspect_ratio_idc][1];
} else {
@@ -617,16 +617,16 @@ HRESULT CFLVSplitterFilter::CreateOutputs(IAsyncReader* pAsyncReader) UINT64 Width, Height;
Width = 16 * mb_Width - (2>>CHROMA444) * min(crop_right, (8<<CHROMA444)-1);
- if(frame_mbs_only_flag) {
+ if (frame_mbs_only_flag) {
Height = 16 * mb_Height - (2>>CHROMA444) * min(crop_bottom, (8<<CHROMA444)-1);
} else {
Height = 16 * mb_Height - (4>>CHROMA444) * min(crop_bottom, (8<<CHROMA444)-1);
}
- if(!sar.num) sar.num = 1;
- if(!sar.den) sar.den = 1;
+ if (!sar.num) sar.num = 1;
+ if (!sar.den) sar.den = 1;
CSize aspect(Width * sar.num, Height * sar.den);
int lnko = LNKO(aspect.cx, aspect.cy);
- if(lnko > 1) {
+ if (lnko > 1) {
aspect.cx /= lnko, aspect.cy /= lnko;
}
@@ -659,7 +659,7 @@ HRESULT CFLVSplitterFilter::CreateOutputs(IAsyncReader* pAsyncReader) }
int len = ((src[0] << 8) | src[1]) + 2;
- if(src + len > src_end || dst + len > dst_end) {
+ if (src + len > src_end || dst + len > dst_end) {
ASSERT(0);
break;
}
@@ -682,9 +682,9 @@ HRESULT CFLVSplitterFilter::CreateOutputs(IAsyncReader* pAsyncReader) }
}
- if(mt.subtype != GUID_NULL) {
+ if (mt.subtype != GUID_NULL) {
CAtlArray<CMediaType> mts;
- if(mt.subtype == FOURCCMap(MAKEFOURCC('A','S','W','F'))) {
+ if (mt.subtype == FOURCCMap(MAKEFOURCC('A','S','W','F'))) {
mts.InsertAt(0, ff_mtype);
}
mts.Add(mt);
@@ -695,18 +695,18 @@ HRESULT CFLVSplitterFilter::CreateOutputs(IAsyncReader* pAsyncReader) m_pFile->Seek(next);
}
- if(m_pFile->IsRandomAccess()) {
+ if (m_pFile->IsRandomAccess()) {
__int64 pos = max(m_DataOffset, m_pFile->GetLength() - 256 * 1024);
- if(Sync(pos)) {
+ if (Sync(pos)) {
Tag t;
AudioTag at;
VideoTag vt;
- while(ReadTag(t)) {
+ while (ReadTag(t)) {
UINT64 next = m_pFile->GetPos() + t.DataSize;
- if(t.TagType == 8 && ReadTag(at) || t.TagType == 9 && ReadTag(vt)) {
+ if (t.TagType == 8 && ReadTag(at) || t.TagType == 9 && ReadTag(vt)) {
m_rtDuration = max(m_rtDuration, 10000i64 * t.TimeStamp);
}
@@ -728,7 +728,7 @@ bool CFLVSplitterFilter::DemuxInit() void CFLVSplitterFilter::DemuxSeek(REFERENCE_TIME rt)
{
- if(!m_rtDuration || rt <= 0) {
+ if (!m_rtDuration || rt <= 0) {
m_pFile->Seek(m_DataOffset);
} else if (!m_IgnorePrevSizes) {
NormalSeek(rt);
@@ -744,7 +744,7 @@ void CFLVSplitterFilter::NormalSeek(REFERENCE_TIME rt) __int64 pos = m_DataOffset + 1.0 * rt / m_rtDuration * (m_pFile->GetLength() - m_DataOffset);
- if(!Sync(pos)) {
+ if (!Sync(pos)) {
ASSERT(0);
m_pFile->Seek(m_DataOffset);
return;
@@ -754,8 +754,8 @@ void CFLVSplitterFilter::NormalSeek(REFERENCE_TIME rt) AudioTag at;
VideoTag vt;
- while(ReadTag(t)) {
- if(10000i64 * t.TimeStamp >= rt) {
+ while (ReadTag(t)) {
+ if (10000i64 * t.TimeStamp >= rt) {
m_pFile->Seek(m_pFile->GetPos() - 15);
break;
}
@@ -763,13 +763,13 @@ void CFLVSplitterFilter::NormalSeek(REFERENCE_TIME rt) m_pFile->Seek(m_pFile->GetPos() + t.DataSize);
}
- while(m_pFile->GetPos() >= m_DataOffset && (fAudio || fVideo) && ReadTag(t)) {
+ while (m_pFile->GetPos() >= m_DataOffset && (fAudio || fVideo) && ReadTag(t)) {
UINT64 prev = m_pFile->GetPos() - 15 - t.PreviousTagSize - 4;
- if(10000i64 * t.TimeStamp <= rt) {
- if(t.TagType == 8 && ReadTag(at)) {
+ if (10000i64 * t.TimeStamp <= rt) {
+ if (t.TagType == 8 && ReadTag(at)) {
fAudio = false;
- } else if(t.TagType == 9 && ReadTag(vt) && vt.FrameType == 1) {
+ } else if (t.TagType == 9 && ReadTag(vt) && vt.FrameType == 1) {
fVideo = false;
}
}
@@ -777,7 +777,7 @@ void CFLVSplitterFilter::NormalSeek(REFERENCE_TIME rt) m_pFile->Seek(prev);
}
- if(fAudio || fVideo) {
+ if (fAudio || fVideo) {
ASSERT(0);
m_pFile->Seek(m_DataOffset);
}
@@ -844,24 +844,24 @@ bool CFLVSplitterFilter::DemuxLoop() AudioTag at = {};
VideoTag vt = {};
- while(SUCCEEDED(hr) && !CheckRequest(NULL) && m_pFile->GetRemaining()) {
- if(!ReadTag(t)) {
+ while (SUCCEEDED(hr) && !CheckRequest(NULL) && m_pFile->GetRemaining()) {
+ if (!ReadTag(t)) {
break;
}
__int64 next = m_pFile->GetPos() + t.DataSize;
- if((t.DataSize > 0) && (t.TagType == 8 && ReadTag(at) || t.TagType == 9 && ReadTag(vt))) {
+ if ((t.DataSize > 0) && (t.TagType == 8 && ReadTag(at) || t.TagType == 9 && ReadTag(vt))) {
UINT32 tsOffset = 0;
- if(t.TagType == 9) {
- if(vt.FrameType == 5) {
+ if (t.TagType == 9) {
+ if (vt.FrameType == 5) {
goto NextTag; // video info/command frame
}
- if(vt.CodecID == 4) {
+ if (vt.CodecID == 4) {
m_pFile->BitRead(8);
- } else if(vt.CodecID == 5) {
+ } else if (vt.CodecID == 5) {
m_pFile->BitRead(32);
- } else if(vt.CodecID == 7) {
+ } else if (vt.CodecID == 7) {
if (m_pFile->BitRead(8) != 1) {
goto NextTag;
}
@@ -870,7 +870,7 @@ bool CFLVSplitterFilter::DemuxLoop() tsOffset = (tsOffset + 0xff800000) ^ 0xff800000; // sign extension
}
}
- if(t.TagType == 8 && at.SoundFormat == 10) {
+ if (t.TagType == 8 && at.SoundFormat == 10) {
if (m_pFile->BitRead(8) != 1) {
goto NextTag;
}
diff --git a/src/filters/parser/MP4Splitter/Ap4AsyncReaderStream.cpp b/src/filters/parser/MP4Splitter/Ap4AsyncReaderStream.cpp index 4e42bf718..2824094a2 100644 --- a/src/filters/parser/MP4Splitter/Ap4AsyncReaderStream.cpp +++ b/src/filters/parser/MP4Splitter/Ap4AsyncReaderStream.cpp @@ -22,7 +22,7 @@ void AP4_AsyncReaderStream::AddReference() void AP4_AsyncReaderStream::Release()
{
ASSERT(m_refs > 0);
- if(--m_refs == 0) {
+ if (--m_refs == 0) {
delete this;
}
}
@@ -31,25 +31,25 @@ AP4_Result AP4_AsyncReaderStream::Read(void* buffer, AP4_Size bytesToRead, AP4_S {
__int64 bytesAvail = m_pFile->GetRemaining();
- if(bytesAvail < (long long)bytesToRead) {
- if(bytesRead) {
+ if (bytesAvail < (long long)bytesToRead) {
+ if (bytesRead) {
*bytesRead = bytesAvail;
}
bytesToRead = bytesAvail;
}
- if(bytesAvail == 0) {
+ if (bytesAvail == 0) {
return AP4_ERROR_EOS;
}
- if(FAILED(m_pFile->ByteRead((BYTE*)buffer, bytesToRead))) {
- if(bytesRead) {
+ if (FAILED(m_pFile->ByteRead((BYTE*)buffer, bytesToRead))) {
+ if (bytesRead) {
*bytesRead = 0;
}
return AP4_ERROR_READ_FAILED;
}
- if(bytesRead) {
+ if (bytesRead) {
*bytesRead = bytesToRead;
}
diff --git a/src/filters/parser/MP4Splitter/MP4Splitter.cpp b/src/filters/parser/MP4Splitter/MP4Splitter.cpp index f88de531b..62d46bd18 100644 --- a/src/filters/parser/MP4Splitter/MP4Splitter.cpp +++ b/src/filters/parser/MP4Splitter/MP4Splitter.cpp @@ -150,7 +150,7 @@ STDMETHODIMP CMP4SplitterFilter::QueryFilterInfo(FILTER_INFO* pInfo) wcscpy(pInfo->achName, MP4SourceName);
}
pInfo->pGraph = m_pGraph;
- if(m_pGraph) {
+ if (m_pGraph) {
m_pGraph->AddRef();
}
@@ -159,7 +159,7 @@ STDMETHODIMP CMP4SplitterFilter::QueryFilterInfo(FILTER_INFO* pInfo) void SetTrackName(CString *TrackName, CString Suffix)
{
- if(TrackName->IsEmpty()) {
+ if (TrackName->IsEmpty()) {
*TrackName = Suffix;
} else {
*TrackName += _T(" - ");
@@ -179,10 +179,10 @@ HRESULT CMP4SplitterFilter::CreateOutputs(IAsyncReader* pAsyncReader) m_pFile.Free();
m_pFile.Attach(DNew CMP4SplitterFile(pAsyncReader, hr));
- if(!m_pFile) {
+ if (!m_pFile) {
return E_OUTOFMEMORY;
}
- if(FAILED(hr)) {
+ if (FAILED(hr)) {
m_pFile.Free();
return hr;
}
@@ -192,26 +192,26 @@ HRESULT CMP4SplitterFilter::CreateOutputs(IAsyncReader* pAsyncReader) m_framesize.SetSize(640, 480);
- if(AP4_Movie* movie = (AP4_Movie*)m_pFile->GetMovie()) {
- for(AP4_List<AP4_Track>::Item* item = movie->GetTracks().FirstItem();
+ if (AP4_Movie* movie = (AP4_Movie*)m_pFile->GetMovie()) {
+ for (AP4_List<AP4_Track>::Item* item = movie->GetTracks().FirstItem();
item;
item = item->GetNext()) {
AP4_Track* track = item->GetData();
- if(track->GetType() != AP4_Track::TYPE_VIDEO
+ if (track->GetType() != AP4_Track::TYPE_VIDEO
&& track->GetType() != AP4_Track::TYPE_AUDIO
&& track->GetType() != AP4_Track::TYPE_TEXT
&& track->GetType() != AP4_Track::TYPE_SUBP) {
continue;
}
- if(b_HasVideo && track->GetType() == AP4_Track::TYPE_VIDEO) {
+ if (b_HasVideo && track->GetType() == AP4_Track::TYPE_VIDEO) {
continue;
}
AP4_Sample sample;
- if(!AP4_SUCCEEDED(track->GetSample(0, sample)) || sample.GetDescriptionIndex() == 0xFFFFFFFF) {
+ if (!AP4_SUCCEEDED(track->GetSample(0, sample)) || sample.GetDescriptionIndex() == 0xFFFFFFFF) {
continue;
}
@@ -231,41 +231,41 @@ HRESULT CMP4SplitterFilter::CreateOutputs(IAsyncReader* pAsyncReader) AP4_DataBuffer empty;
- if(AP4_SampleDescription* desc = track->GetSampleDescription(sample.GetDescriptionIndex())) {
+ if (AP4_SampleDescription* desc = track->GetSampleDescription(sample.GetDescriptionIndex())) {
AP4_MpegSampleDescription* mpeg_desc = NULL;
- if(desc->GetType() == AP4_SampleDescription::TYPE_MPEG) {
+ if (desc->GetType() == AP4_SampleDescription::TYPE_MPEG) {
mpeg_desc = dynamic_cast<AP4_MpegSampleDescription*>(desc);
- } else if(desc->GetType() == AP4_SampleDescription::TYPE_ISMACRYP) {
+ } else if (desc->GetType() == AP4_SampleDescription::TYPE_ISMACRYP) {
AP4_IsmaCrypSampleDescription* isma_desc = dynamic_cast<AP4_IsmaCrypSampleDescription*>(desc);
mpeg_desc = isma_desc->GetOriginalSampleDescription();
}
- if(mpeg_desc) {
+ if (mpeg_desc) {
CStringW TypeString = CStringW(mpeg_desc->GetObjectTypeString(mpeg_desc->GetObjectTypeId()));
- if((TypeString.Find(_T("UNKNOWN")) == -1) && (TypeString.Find(_T("INVALID")) == -1)) {
+ if ((TypeString.Find(_T("UNKNOWN")) == -1) && (TypeString.Find(_T("INVALID")) == -1)) {
SetTrackName(&TrackName, TypeString);
}
}
- if(AP4_MpegVideoSampleDescription* video_desc =
+ if (AP4_MpegVideoSampleDescription* video_desc =
dynamic_cast<AP4_MpegVideoSampleDescription*>(mpeg_desc)) {
const AP4_DataBuffer* di = video_desc->GetDecoderInfo();
- if(!di) {
+ if (!di) {
di = ∅
}
LONG biWidth = (LONG)video_desc->GetWidth();
LONG biHeight = (LONG)video_desc->GetHeight();
- if(!biWidth || !biHeight) {
- if(AP4_TkhdAtom* tkhd = dynamic_cast<AP4_TkhdAtom*>(track->GetTrakAtom()->GetChild(AP4_ATOM_TYPE_TKHD))) {
+ if (!biWidth || !biHeight) {
+ if (AP4_TkhdAtom* tkhd = dynamic_cast<AP4_TkhdAtom*>(track->GetTrakAtom()->GetChild(AP4_ATOM_TYPE_TKHD))) {
biWidth = tkhd->GetWidth()>>16;
biHeight = tkhd->GetHeight()>>16;
}
}
- if(!biWidth || !biHeight) {
+ if (!biWidth || !biHeight) {
continue;
}
@@ -279,7 +279,7 @@ HRESULT CMP4SplitterFilter::CreateOutputs(IAsyncReader* pAsyncReader) vih->bmiHeader.biHeight = biHeight;
memcpy(vih + 1, di->GetData(), di->GetDataSize());
- switch(video_desc->GetObjectTypeId()) {
+ switch (video_desc->GetObjectTypeId()) {
case AP4_MPEG4_VISUAL_OTI:
mt.subtype = FOURCCMap('v4pm');
mt.formattype = FORMAT_MPEG2Video;
@@ -333,7 +333,7 @@ HRESULT CMP4SplitterFilter::CreateOutputs(IAsyncReader* pAsyncReader) m_pFile->Seek(sample.GetOffset());
CBaseSplitterFileEx::seqhdr h;
CMediaType mt2;
- if(m_pFile->Read(h, sample.GetSize(), &mt2)) {
+ if (m_pFile->Read(h, sample.GetSize(), &mt2)) {
mt = mt2;
}
}
@@ -345,7 +345,7 @@ HRESULT CMP4SplitterFilter::CreateOutputs(IAsyncReader* pAsyncReader) m_pFile->Seek(sample.GetOffset());
CBaseSplitterFileEx::seqhdr h;
CMediaType mt2;
- if(m_pFile->Read(h, sample.GetSize(), &mt2)) {
+ if (m_pFile->Read(h, sample.GetSize(), &mt2)) {
mt = mt2;
}
}
@@ -353,13 +353,13 @@ HRESULT CMP4SplitterFilter::CreateOutputs(IAsyncReader* pAsyncReader) break;
}
- if(mt.subtype == GUID_NULL) {
+ if (mt.subtype == GUID_NULL) {
TRACE(_T("Unknown video OBI: %02x\n"), video_desc->GetObjectTypeId());
}
- } else if(AP4_MpegAudioSampleDescription* audio_desc =
- dynamic_cast<AP4_MpegAudioSampleDescription*>(mpeg_desc)) {
+ } else if (AP4_MpegAudioSampleDescription* audio_desc =
+ dynamic_cast<AP4_MpegAudioSampleDescription*>(mpeg_desc)) {
const AP4_DataBuffer* di = audio_desc->GetDecoderInfo();
- if(!di) {
+ if (!di) {
di = ∅
}
@@ -377,13 +377,13 @@ HRESULT CMP4SplitterFilter::CreateOutputs(IAsyncReader* pAsyncReader) memcpy(wfe + 1, di->GetData(), di->GetDataSize());
- switch(audio_desc->GetObjectTypeId()) {
+ switch (audio_desc->GetObjectTypeId()) {
case AP4_MPEG4_AUDIO_OTI:
case AP4_MPEG2_AAC_AUDIO_MAIN_OTI: // ???
case AP4_MPEG2_AAC_AUDIO_LC_OTI: // ???
case AP4_MPEG2_AAC_AUDIO_SSRP_OTI: // ???
mt.subtype = FOURCCMap(wfe->wFormatTag = WAVE_FORMAT_AAC);
- if(wfe->cbSize >= 2 && wfe->nChannels < 8) {
+ if (wfe->cbSize >= 2 && wfe->nChannels < 8) {
wfe->nChannels = (((BYTE*)(wfe+1))[1]>>3) & 0xf;
wfe->nBlockAlign = (WORD)((wfe->nChannels * wfe->wBitsPerSample) / 8);
}
@@ -396,7 +396,7 @@ HRESULT CMP4SplitterFilter::CreateOutputs(IAsyncReader* pAsyncReader) m_pFile->Seek(sample.GetOffset());
CBaseSplitterFileEx::mpahdr h;
CMediaType mt2;
- if(m_pFile->Read(h, sample.GetSize(), false, &mt2)) {
+ if (m_pFile->Read(h, sample.GetSize(), false, &mt2)) {
mt = mt2;
}
}
@@ -410,7 +410,7 @@ HRESULT CMP4SplitterFilter::CreateOutputs(IAsyncReader* pAsyncReader) m_pFile->Seek(sample.GetOffset());
CBaseSplitterFileEx::dtshdr h;
CMediaType mt2;
- if(m_pFile->Read(h, sample.GetSize(), &mt2)) {
+ if (m_pFile->Read(h, sample.GetSize(), &mt2)) {
mt = mt2;
}
}
@@ -418,28 +418,28 @@ HRESULT CMP4SplitterFilter::CreateOutputs(IAsyncReader* pAsyncReader) break;
}
- if(mt.subtype == GUID_NULL) {
+ if (mt.subtype == GUID_NULL) {
TRACE(_T("Unknown audio OBI: %02x\n"), audio_desc->GetObjectTypeId());
}
- } else if(AP4_MpegSystemSampleDescription* system_desc =
- dynamic_cast<AP4_MpegSystemSampleDescription*>(desc)) {
+ } else if (AP4_MpegSystemSampleDescription* system_desc =
+ dynamic_cast<AP4_MpegSystemSampleDescription*>(desc)) {
const AP4_DataBuffer* di = system_desc->GetDecoderInfo();
- if(!di) {
+ if (!di) {
di = ∅
}
- switch(system_desc->GetObjectTypeId()) {
+ switch (system_desc->GetObjectTypeId()) {
case AP4_NERO_VOBSUB:
- if(di->GetDataSize() >= 16*4) {
+ if (di->GetDataSize() >= 16*4) {
CSize size(720, 576);
- if(AP4_TkhdAtom* tkhd = dynamic_cast<AP4_TkhdAtom*>(track->GetTrakAtom()->GetChild(AP4_ATOM_TYPE_TKHD))) {
+ if (AP4_TkhdAtom* tkhd = dynamic_cast<AP4_TkhdAtom*>(track->GetTrakAtom()->GetChild(AP4_ATOM_TYPE_TKHD))) {
size.cx = tkhd->GetWidth()>>16;
size.cy = tkhd->GetHeight()>>16;
}
const AP4_Byte* pal = di->GetData();
CAtlList<CStringA> sl;
- for(int i = 0; i < 16*4; i += 4) {
+ for (int i = 0; i < 16*4; i += 4) {
BYTE y = (pal[i+1]-16)*255/219;
BYTE u = pal[i+2];
BYTE v = pal[i+3];
@@ -473,14 +473,14 @@ HRESULT CMP4SplitterFilter::CreateOutputs(IAsyncReader* pAsyncReader) break;
}
- if(mt.subtype == GUID_NULL) {
+ if (mt.subtype == GUID_NULL) {
TRACE(_T("Unknown audio OBI: %02x\n"), system_desc->GetObjectTypeId());
}
- } else if(AP4_UnknownSampleDescription* unknown_desc =
- dynamic_cast<AP4_UnknownSampleDescription*>(desc)) { // TEMP
+ } else if (AP4_UnknownSampleDescription* unknown_desc =
+ dynamic_cast<AP4_UnknownSampleDescription*>(desc)) { // TEMP
AP4_SampleEntry* sample_entry = unknown_desc->GetSampleEntry();
- if(dynamic_cast<AP4_TextSampleEntry*>(sample_entry)
+ if (dynamic_cast<AP4_TextSampleEntry*>(sample_entry)
|| dynamic_cast<AP4_Tx3gSampleEntry*>(sample_entry)) {
mt.majortype = MEDIATYPE_Subtitle;
mt.subtype = MEDIASUBTYPE_ASS2;
@@ -506,22 +506,22 @@ HRESULT CMP4SplitterFilter::CreateOutputs(IAsyncReader* pAsyncReader) mts.Add(mt);
}
}
- } else if(AP4_Avc1SampleEntry* avc1 = dynamic_cast<AP4_Avc1SampleEntry*>(
+ } else if (AP4_Avc1SampleEntry* avc1 = dynamic_cast<AP4_Avc1SampleEntry*>(
track->GetTrakAtom()->FindChild("mdia/minf/stbl/stsd/avc1"))) {
- if(AP4_AvcCAtom* avcC = dynamic_cast<AP4_AvcCAtom*>(avc1->GetChild(AP4_ATOM_TYPE_AVCC))) {
+ if (AP4_AvcCAtom* avcC = dynamic_cast<AP4_AvcCAtom*>(avc1->GetChild(AP4_ATOM_TYPE_AVCC))) {
SetTrackName(&TrackName, _T("MPEG4 Video (H264)"));
const AP4_DataBuffer* di = avcC->GetDecoderInfo();
- if(!di) {
+ if (!di) {
di = ∅
}
int num = 1;
int den = 1;
- if(AP4_PaspAtom* pasp = dynamic_cast<AP4_PaspAtom*>(avc1->GetChild(AP4_ATOM_TYPE_PASP))) {
+ if (AP4_PaspAtom* pasp = dynamic_cast<AP4_PaspAtom*>(avc1->GetChild(AP4_ATOM_TYPE_PASP))) {
num = pasp->GetNum();
den = pasp->GetDen();
}
- if(num <= 0 || den <= 0) { // if bad AR
+ if (num <= 0 || den <= 0) { // if bad AR
num = den = 1; // then reset AR
}
@@ -543,7 +543,7 @@ HRESULT CMP4SplitterFilter::CreateOutputs(IAsyncReader* pAsyncReader) CSize aspect(vih->hdr.bmiHeader.biWidth * num, vih->hdr.bmiHeader.biHeight * den);
int lnko = LNKO(aspect.cx, aspect.cy);
- if(lnko > 1) {
+ if (lnko > 1) {
aspect.cx /= lnko, aspect.cy /= lnko;
}
vih->hdr.dwPictAspectRatioX = aspect.cx;
@@ -563,10 +563,10 @@ HRESULT CMP4SplitterFilter::CreateOutputs(IAsyncReader* pAsyncReader) BYTE* src_end = (BYTE*)data + size;
BYTE* dst_end = (BYTE*)vih->dwSequenceHeader + size;
- for(int i = 0; i < 2; i++) {
- for(int n = *src++ & 0x1f; n > 0; n--) {
+ for (int i = 0; i < 2; i++) {
+ for (int n = *src++ & 0x1f; n > 0; n--) {
int len = ((src[0] << 8) | src[1]) + 2;
- if(src + len > src_end || dst + len > dst_end) {
+ if (src + len > src_end || dst + len > dst_end) {
ASSERT(0);
break;
}
@@ -583,11 +583,11 @@ HRESULT CMP4SplitterFilter::CreateOutputs(IAsyncReader* pAsyncReader) mts.Add(mt);
b_HasVideo = true;
}
- } else if(AP4_StsdAtom* stsd = dynamic_cast<AP4_StsdAtom*>(
- track->GetTrakAtom()->FindChild("mdia/minf/stbl/stsd"))) {
+ } else if (AP4_StsdAtom* stsd = dynamic_cast<AP4_StsdAtom*>(
+ track->GetTrakAtom()->FindChild("mdia/minf/stbl/stsd"))) {
const AP4_DataBuffer& db = stsd->GetDataBuffer();
- for(AP4_List<AP4_Atom>::Item* item = stsd->GetChildren().FirstItem();
+ for (AP4_List<AP4_Atom>::Item* item = stsd->GetChildren().FirstItem();
item;
item = item->GetNext()) {
AP4_Atom* atom = item->GetData();
@@ -595,22 +595,22 @@ HRESULT CMP4SplitterFilter::CreateOutputs(IAsyncReader* pAsyncReader) AP4_Atom::Type type = atom->GetType();
DWORD fourcc;
- if((type & 0xffff0000) == AP4_ATOM_TYPE('m', 's', 0, 0)) {
+ if ((type & 0xffff0000) == AP4_ATOM_TYPE('m', 's', 0, 0)) {
fourcc = type & 0xffff;
- } else if(type == AP4_ATOM_TYPE__MP3) {
+ } else if (type == AP4_ATOM_TYPE__MP3) {
SetTrackName(&TrackName, _T("MPEG Audio (MP3)"));
fourcc = 0x0055;
- } else if((type == AP4_ATOM_TYPE__AC3) || (type == AP4_ATOM_TYPE_SAC3) || (type == AP4_ATOM_TYPE_EAC3)) {
- if(type == AP4_ATOM_TYPE_EAC3) {
+ } else if ((type == AP4_ATOM_TYPE__AC3) || (type == AP4_ATOM_TYPE_SAC3) || (type == AP4_ATOM_TYPE_EAC3)) {
+ if (type == AP4_ATOM_TYPE_EAC3) {
SetTrackName(&TrackName, _T("AC-3 Audio"));
} else {
SetTrackName(&TrackName, _T("Enhanced AC-3 audio"));
}
fourcc = 0x2000;
- } else if(type == AP4_ATOM_TYPE_MP4A) {
+ } else if (type == AP4_ATOM_TYPE_MP4A) {
SetTrackName(&TrackName, _T("MPEG-2 Audio AAC"));
fourcc = WAVE_FORMAT_AAC;
- } else if(type == AP4_ATOM_TYPE_NMOS) {
+ } else if (type == AP4_ATOM_TYPE_NMOS) {
SetTrackName(&TrackName, _T("NellyMoser Audio"));
fourcc = MAKEFOURCC('N','E','L','L');
} else {
@@ -621,7 +621,7 @@ HRESULT CMP4SplitterFilter::CreateOutputs(IAsyncReader* pAsyncReader) ((type << 24) & 0xff000000);
}
- if(AP4_VisualSampleEntry* vse = dynamic_cast<AP4_VisualSampleEntry*>(atom)) {
+ if (AP4_VisualSampleEntry* vse = dynamic_cast<AP4_VisualSampleEntry*>(atom)) {
mt.majortype = MEDIATYPE_Video;
mt.subtype = FOURCCMap(fourcc);
mt.formattype = FORMAT_VideoInfo;
@@ -642,7 +642,7 @@ HRESULT CMP4SplitterFilter::CreateOutputs(IAsyncReader* pAsyncReader) _strlwr((char*)&buff);
AP4_Atom::Type typelwr = *(AP4_Atom::Type*)buff;
- if(typelwr != fourcc) {
+ if (typelwr != fourcc) {
mt.subtype = FOURCCMap(vih->bmiHeader.biCompression = typelwr);
mts.Add(mt);
b_HasVideo = true;
@@ -651,48 +651,48 @@ HRESULT CMP4SplitterFilter::CreateOutputs(IAsyncReader* pAsyncReader) _strupr((char*)&buff);
AP4_Atom::Type typeupr = *(AP4_Atom::Type*)buff;
- if(typeupr != fourcc) {
+ if (typeupr != fourcc) {
mt.subtype = FOURCCMap(vih->bmiHeader.biCompression = typeupr);
mts.Add(mt);
b_HasVideo = true;
}
break;
- } else if(AP4_AudioSampleEntry* ase = dynamic_cast<AP4_AudioSampleEntry*>(atom)) {
+ } else if (AP4_AudioSampleEntry* ase = dynamic_cast<AP4_AudioSampleEntry*>(atom)) {
if (ase->GetEndian()==1) {
if (type==AP4_ATOM_TYPE_IN24 || type==AP4_ATOM_TYPE_IN32 ||
type==AP4_ATOM_TYPE_FL32 || type==AP4_ATOM_TYPE_FL64) {
fourcc = type; //reverse fourcc
}
}
-
+
DWORD nSampleRate = ase->GetSampleRate();
WORD nChannels = ase->GetChannelCount();
DWORD nAvgBytesPerSec = 0;
- if(type == AP4_ATOM_TYPE_EAC3) {
+ if (type == AP4_ATOM_TYPE_EAC3) {
AP4_Sample sample;
AP4_DataBuffer sample_data;
AP4_Cardinal SampleCount = track->GetSampleCount();
- if(SampleCount) {
+ if (SampleCount) {
track->ReadSample(1, sample, sample_data);
const AP4_Byte* data = sample_data.GetData();
AP4_Size size = sample_data.GetDataSize();
CGolombBuffer gb((BYTE *)data, size);
- for(; size >= 7 && gb.BitRead(16, true) != 0x0b77; size--) {
+ for (; size >= 7 && gb.BitRead(16, true) != 0x0b77; size--) {
gb.BitRead(8);
}
WORD sync = (WORD)gb.BitRead(16);
- if((size >= 7) && (sync == 0x0b77)) {
+ if ((size >= 7) && (sync == 0x0b77)) {
static int freq[] = {48000, 44100, 32000, 0};
BYTE num_blocks;
gb.BitRead(2);
gb.BitRead(3);
WORD frame_size = (gb.BitRead(11) + 1) << 1;
BYTE sr_code = gb.BitRead(2);
- if(sr_code == 3) {
+ if (sr_code == 3) {
BYTE sr_code2 = gb.BitRead(2);
nSampleRate = freq[sr_code2] / 2;
} else {
@@ -713,7 +713,7 @@ HRESULT CMP4SplitterFilter::CreateOutputs(IAsyncReader* pAsyncReader) mt.formattype = FORMAT_WaveFormatEx;
wfe = (WAVEFORMATEX*)mt.AllocFormatBuffer(sizeof(WAVEFORMATEX) + (type == AP4_ATOM_TYPE_MP4A ? 0 : db.GetDataSize()));
memset(wfe, 0, mt.FormatLength());
- if(!(fourcc & 0xffff0000)) {
+ if (!(fourcc & 0xffff0000)) {
wfe->wFormatTag = (WORD)fourcc;
}
wfe->nSamplesPerSec = nSampleRate;
@@ -727,7 +727,7 @@ HRESULT CMP4SplitterFilter::CreateOutputs(IAsyncReader* pAsyncReader) } else {
mt.subtype = FOURCCMap(fourcc);
}
- if(type != AP4_ATOM_TYPE_MP4A) {
+ if (type != AP4_ATOM_TYPE_MP4A) {
wfe->cbSize = db.GetDataSize();
memcpy(wfe+1, db.GetData(), db.GetDataSize());
}
@@ -740,12 +740,12 @@ HRESULT CMP4SplitterFilter::CreateOutputs(IAsyncReader* pAsyncReader) }
}
- if(mts.IsEmpty()) {
+ if (mts.IsEmpty()) {
continue;
}
REFERENCE_TIME rtDuration = 10000i64 * track->GetDurationMs();
- if(m_rtDuration < rtDuration) {
+ if (m_rtDuration < rtDuration) {
m_rtDuration = rtDuration;
}
@@ -754,19 +754,19 @@ HRESULT CMP4SplitterFilter::CreateOutputs(IAsyncReader* pAsyncReader) CStringW name, lang;
name.Format(L"Output %d", id);
- if(!TrackName.IsEmpty()) {
+ if (!TrackName.IsEmpty()) {
name = TrackName;
}
- if(!TrackLanguage.IsEmpty()) {
- if(TrackLanguage != L"und") {
+ if (!TrackLanguage.IsEmpty()) {
+ if (TrackLanguage != L"und") {
name += " (" + TrackLanguage + ")";
}
}
- for(int i = 0, j = mts.GetCount(); i < j; i++) {
+ for (int i = 0, j = mts.GetCount(); i < j; i++) {
BITMAPINFOHEADER bih;
- if(ExtractBIH(&mts[i], &bih)) {
+ if (ExtractBIH(&mts[i], &bih)) {
m_framesize.cx = bih.biWidth;
m_framesize.cy = abs(bih.biHeight);
}
@@ -774,10 +774,10 @@ HRESULT CMP4SplitterFilter::CreateOutputs(IAsyncReader* pAsyncReader) CAutoPtr<CBaseSplitterOutputPin> pPinOut(DNew CBaseSplitterOutputPin(mts, name, this, this, &hr));
- if(!TrackName.IsEmpty()) {
+ if (!TrackName.IsEmpty()) {
pPinOut->SetProperty(L"NAME", TrackName);
}
- if(!TrackLanguage.IsEmpty()) {
+ if (!TrackLanguage.IsEmpty()) {
pPinOut->SetProperty(L"LANG", CStringW(TrackLanguage));
}
@@ -785,7 +785,7 @@ HRESULT CMP4SplitterFilter::CreateOutputs(IAsyncReader* pAsyncReader) m_trackpos[id] = trackpos();
- if(mts.GetCount() == 1 && mts[0].subtype == MEDIASUBTYPE_ASS2) {
+ if (mts.GetCount() == 1 && mts[0].subtype == MEDIASUBTYPE_ASS2) {
LPCWSTR postfix = L" (plain text)";
mts[0].subtype = MEDIASUBTYPE_UTF8;
@@ -797,10 +797,10 @@ HRESULT CMP4SplitterFilter::CreateOutputs(IAsyncReader* pAsyncReader) CAutoPtr<CBaseSplitterOutputPin> pPinOut(DNew CBaseSplitterOutputPin(mts, name + postfix, this, this, &hr));
- if(!TrackName.IsEmpty()) {
+ if (!TrackName.IsEmpty()) {
pPinOut->SetProperty(L"NAME", TrackName + postfix);
}
- if(!TrackLanguage.IsEmpty()) {
+ if (!TrackLanguage.IsEmpty()) {
pPinOut->SetProperty(L"LANG", CStringW(TrackLanguage));
}
@@ -808,10 +808,10 @@ HRESULT CMP4SplitterFilter::CreateOutputs(IAsyncReader* pAsyncReader) }
}
- if(AP4_ChplAtom* chpl = dynamic_cast<AP4_ChplAtom*>(movie->GetMoovAtom()->FindChild("udta/chpl"))) {
+ if (AP4_ChplAtom* chpl = dynamic_cast<AP4_ChplAtom*>(movie->GetMoovAtom()->FindChild("udta/chpl"))) {
AP4_Array<AP4_ChplAtom::AP4_Chapter>& chapters = chpl->GetChapters();
- for(AP4_Cardinal i = 0; i < chapters.ItemCount(); i++) {
+ for (AP4_Cardinal i = 0; i < chapters.ItemCount(); i++) {
AP4_ChplAtom::AP4_Chapter& chapter = chapters[i];
ChapAppend(chapter.Time, UTF8To16(ConvertMBCS(chapter.Name.c_str(), ANSI_CHARSET, CP_UTF8))); // this is b0rked, thx to nero :P
}
@@ -819,29 +819,29 @@ HRESULT CMP4SplitterFilter::CreateOutputs(IAsyncReader* pAsyncReader) ChapSort();
}
- if(AP4_ContainerAtom* ilst = dynamic_cast<AP4_ContainerAtom*>(movie->GetMoovAtom()->FindChild("udta/meta/ilst"))) {
+ if (AP4_ContainerAtom* ilst = dynamic_cast<AP4_ContainerAtom*>(movie->GetMoovAtom()->FindChild("udta/meta/ilst"))) {
CStringW title, artist, writer, album, year, appl, desc, gen, track;
- for(AP4_List<AP4_Atom>::Item* item = ilst->GetChildren().FirstItem();
+ for (AP4_List<AP4_Atom>::Item* item = ilst->GetChildren().FirstItem();
item;
item = item->GetNext()) {
- if(AP4_ContainerAtom* atom = dynamic_cast<AP4_ContainerAtom*>(item->GetData())) {
- if(AP4_DataAtom* data = dynamic_cast<AP4_DataAtom*>(atom->GetChild(AP4_ATOM_TYPE_DATA))) {
+ if (AP4_ContainerAtom* atom = dynamic_cast<AP4_ContainerAtom*>(item->GetData())) {
+ if (AP4_DataAtom* data = dynamic_cast<AP4_DataAtom*>(atom->GetChild(AP4_ATOM_TYPE_DATA))) {
const AP4_DataBuffer* db = data->GetData();
- if(atom->GetType() == AP4_ATOM_TYPE_TRKN) {
- if(db->GetDataSize() >= 4) {
+ if (atom->GetType() == AP4_ATOM_TYPE_TRKN) {
+ if (db->GetDataSize() >= 4) {
unsigned short n = (db->GetData()[2] << 8) | db->GetData()[3];
- if(n > 0 && n < 100) {
+ if (n > 0 && n < 100) {
track.Format(L"%02d", n);
- } else if(n >= 100) {
+ } else if (n >= 100) {
track.Format(L"%d", n);
}
}
} else {
CStringW str = UTF8To16(CStringA((LPCSTR)db->GetData(), db->GetDataSize()));
- switch(atom->GetType()) {
+ switch (atom->GetType()) {
case AP4_ATOM_TYPE_NAM:
title = str;
break;
@@ -872,33 +872,33 @@ HRESULT CMP4SplitterFilter::CreateOutputs(IAsyncReader* pAsyncReader) }
}
- if(!title.IsEmpty()) {
- if(!track.IsEmpty()) {
+ if (!title.IsEmpty()) {
+ if (!track.IsEmpty()) {
title = track + L" - " + title;
}
- if(!album.IsEmpty()) {
+ if (!album.IsEmpty()) {
title = album + L" - " + title;
}
- if(!year.IsEmpty()) {
+ if (!year.IsEmpty()) {
title += L" - " + year;
}
- if(!gen.IsEmpty()) {
+ if (!gen.IsEmpty()) {
title += L" - " + gen;
}
SetProperty(L"TITL", title);
}
- if(!artist.IsEmpty()) {
+ if (!artist.IsEmpty()) {
SetProperty(L"AUTH", artist);
- } else if(!writer.IsEmpty()) {
+ } else if (!writer.IsEmpty()) {
SetProperty(L"AUTH", writer);
}
- if(!appl.IsEmpty()) {
+ if (!appl.IsEmpty()) {
SetProperty(L"APPL", appl);
}
- if(!desc.IsEmpty()) {
+ if (!desc.IsEmpty()) {
SetProperty(L"DESC", desc);
}
}
@@ -916,7 +916,7 @@ bool CMP4SplitterFilter::DemuxInit() AP4_Movie* movie = (AP4_Movie*)m_pFile->GetMovie();
POSITION pos = m_trackpos.GetStartPosition();
- while(pos) {
+ while (pos) {
CAtlMap<DWORD, trackpos>::CPair* pPair = m_trackpos.GetNext(pos);
pPair->m_value.index = 0;
@@ -925,7 +925,7 @@ bool CMP4SplitterFilter::DemuxInit() AP4_Track* track = movie->GetTrack(pPair->m_key);
AP4_Sample sample;
- if(AP4_SUCCEEDED(track->GetSample(0, sample))) {
+ if (AP4_SUCCEEDED(track->GetSample(0, sample))) {
pPair->m_value.ts = sample.GetCts();
}
}
@@ -940,29 +940,29 @@ void CMP4SplitterFilter::DemuxSeek(REFERENCE_TIME rt) AP4_Movie* movie = (AP4_Movie*)m_pFile->GetMovie();
POSITION pos = m_trackpos.GetStartPosition();
- while(pos) {
+ while (pos) {
CAtlMap<DWORD, trackpos>::CPair* pPair = m_trackpos.GetNext(pos);
AP4_Track* track = movie->GetTrack(pPair->m_key);
- if(AP4_FAILED(track->GetSampleIndexForTimeStampMs(ts, pPair->m_value.index))) {
+ if (AP4_FAILED(track->GetSampleIndexForTimeStampMs(ts, pPair->m_value.index))) {
pPair->m_value.index = 0;
}
AP4_Sample sample;
- if(AP4_SUCCEEDED(track->GetSample(pPair->m_value.index, sample))) {
+ if (AP4_SUCCEEDED(track->GetSample(pPair->m_value.index, sample))) {
pPair->m_value.ts = sample.GetCts();
}
// FIXME: slow search & stss->m_Entries is private
- if(AP4_StssAtom* stss = dynamic_cast<AP4_StssAtom*>(track->GetTrakAtom()->FindChild("mdia/minf/stbl/stss"))) {
- if(stss->m_Entries.ItemCount() > 0) {
+ if (AP4_StssAtom* stss = dynamic_cast<AP4_StssAtom*>(track->GetTrakAtom()->FindChild("mdia/minf/stbl/stss"))) {
+ if (stss->m_Entries.ItemCount() > 0) {
AP4_Cardinal i = -1;
- while(++i < stss->m_Entries.ItemCount() && stss->m_Entries[i]-1 <= pPair->m_value.index) {
+ while (++i < stss->m_Entries.ItemCount() && stss->m_Entries[i]-1 <= pPair->m_value.index) {
;
}
- if(i > 0) {
+ if (i > 0) {
i--;
}
pPair->m_value.index = stss->m_Entries[i]-1;
@@ -990,7 +990,7 @@ static CStringW ConvertTX3GToSSA( int str_len = str.GetLength();
SSACharacter* chars = DNew SSACharacter[str_len];
- for(int i = 0; i < str_len; i++) {
+ for (int i = 0; i < str_len; i++) {
chars[i].c = str[i];
}
str.Empty();
@@ -1002,32 +1002,32 @@ static CStringW ConvertTX3GToSSA( int align = 2;
signed char h = (signed char)desc.HorizontalJustification;
signed char v = (signed char)desc.VerticalJustification;
- if(h == 0 && v < 0) {
+ if (h == 0 && v < 0) {
align = 1;
- } else if(h > 0 && v < 0) {
+ } else if (h > 0 && v < 0) {
align = 2;
- } else if(h < 0 && v < 0) {
+ } else if (h < 0 && v < 0) {
align = 3;
- } else if(h == 0 && v > 0) {
+ } else if (h == 0 && v > 0) {
align = 4;
- } else if(h > 0 && v > 0) {
+ } else if (h > 0 && v > 0) {
align = 5;
- } else if(h < 0 && v > 0) {
+ } else if (h < 0 && v > 0) {
align = 6;
- } else if(h == 0 && v == 0) {
+ } else if (h == 0 && v == 0) {
align = 7;
- } else if(h > 0 && v == 0) {
+ } else if (h > 0 && v == 0) {
align = 8;
- } else if(h < 0 && v == 0) {
+ } else if (h < 0 && v == 0) {
align = 9;
}
str.Format(L"{\\an%d}%s", align, CStringW(str));
- if(!font.CompareNoCase(L"serif")) {
+ if (!font.CompareNoCase(L"serif")) {
font = L"Times New Roman";
- } else if(!font.CompareNoCase(L"sans-serif")) {
+ } else if (!font.CompareNoCase(L"sans-serif")) {
font = L"Arial";
- } else if(!font.CompareNoCase(L"monospace")) {
+ } else if (!font.CompareNoCase(L"monospace")) {
font = L"Courier New";
}
str.Format(L"{\\fn%s}%s", font, CStringW(str));
@@ -1055,7 +1055,7 @@ static CStringW ConvertTX3GToSSA( const AP4_Byte* hclr = (const AP4_Byte*)&desc.BackgroundColor;
- while(size > 8) {
+ while (size > 8) {
DWORD tag_size = (mods[0]<<24)|(mods[1]<<16)|(mods[2]<<8)|(mods[3]);
mods += 4;
DWORD tag = (mods[0]<<24)|(mods[1]<<16)|(mods[2]<<8)|(mods[3]);
@@ -1065,11 +1065,11 @@ static CStringW ConvertTX3GToSSA( tag_size -= 8;
const AP4_Byte* next = mods + tag_size;
- if(tag == 'styl') {
+ if (tag == 'styl') {
WORD styl_count = (mods[0]<<8)|(mods[1]);
mods += 2;
- while(styl_count-- > 0) {
+ while (styl_count-- > 0) {
WORD start = (mods[0]<<8)|(mods[1]);
mods += 2;
WORD end = (mods[0]<<8)|(mods[1]);
@@ -1083,11 +1083,11 @@ static CStringW ConvertTX3GToSSA( const AP4_Byte* color = mods;
mods += 4;
- if(end > str_len) {
+ if (end > str_len) {
end = str_len;
}
- if(start < end) {
+ if (start < end) {
CStringW s;
s.Format(L"{\\1c%02x%02x%02x\\1a%02x}", color[2], color[1], color[0], 255 - color[3]);
@@ -1103,19 +1103,19 @@ static CStringW ConvertTX3GToSSA( chars[end-1].post += font_flags;
}
}
- } else if(tag == 'hclr') {
+ } else if (tag == 'hclr') {
hclr = mods;
- } else if(tag == 'hlit') {
+ } else if (tag == 'hlit') {
WORD start = (mods[0]<<8)|(mods[1]);
mods += 2;
WORD end = (mods[0]<<8)|(mods[1]);
mods += 2;
- if(end > str_len) {
+ if (end > str_len) {
end = str_len;
}
- if(start < end) {
+ if (start < end) {
CStringW s;
s.Format(L"{\\3c%02x%02x%02x\\3a%02x}", hclr[2], hclr[1], hclr[0], 255 - hclr[3]);
@@ -1125,20 +1125,20 @@ static CStringW ConvertTX3GToSSA( chars[start].pre += L"{\\bord0.1}";
chars[end-1].post += L"{\\bord}";
}
- } else if(tag == 'blnk') {
+ } else if (tag == 'blnk') {
WORD start = (mods[0]<<8)|(mods[1]);
mods += 2;
WORD end = (mods[0]<<8)|(mods[1]);
mods += 2;
- if(end > str_len) {
+ if (end > str_len) {
end = str_len;
}
- if(start < end) {
+ if (start < end) {
// cheap...
- for(int i = 0, alpha = 255; i < durationms; i += 750, alpha = 255 - alpha) {
+ for (int i = 0, alpha = 255; i < durationms; i += 750, alpha = 255 - alpha) {
CStringW s;
s.Format(L"{\\t(%d, %d, \\alpha&H%02x&)}", i, i + 750, alpha);
chars[start].pre += s;
@@ -1146,7 +1146,7 @@ static CStringW ConvertTX3GToSSA( chars[end-1].post += L"{\\alpha}";
}
- } else if(tag == 'tbox') {
+ } else if (tag == 'tbox') {
rbox.top = (mods[0]<<8)|(mods[1]);
mods += 2;
rbox.left = (mods[0]<<8)|(mods[1]);
@@ -1155,13 +1155,13 @@ static CStringW ConvertTX3GToSSA( mods += 2;
rbox.right = (mods[0]<<8)|(mods[1]);
mods += 2;
- } else if(tag == 'krok' && !(desc.DisplayFlags & 0x800)) {
+ } else if (tag == 'krok' && !(desc.DisplayFlags & 0x800)) {
DWORD start_time = (mods[0]<<24)|(mods[1]<<16)|(mods[2]<<8)|(mods[3]);
mods += 4;
WORD krok_count = (mods[0]<<8)|(mods[1]);
mods += 2;
- while(krok_count-- > 0) {
+ while (krok_count-- > 0) {
DWORD end_time = (mods[0]<<24)|(mods[1]<<16)|(mods[2]<<8)|(mods[3]);
mods += 4;
WORD start = (mods[0]<<8)|(mods[1]);
@@ -1169,11 +1169,11 @@ static CStringW ConvertTX3GToSSA( WORD end = (mods[0]<<8)|(mods[1]);
mods += 2;
- if(end > str_len) {
+ if (end > str_len) {
end = str_len;
}
- if(start < end) {
+ if (start < end) {
CStringW s;
s.Format(L"{\\kt%d\\kf%d}", start_time/10, (end_time - start_time)/10);
@@ -1192,7 +1192,7 @@ static CStringW ConvertTX3GToSSA( // continous karaoke
- if(desc.DisplayFlags & 0x800) {
+ if (desc.DisplayFlags & 0x800) {
CStringW s;
s.Format(L"{\\1c%02x%02x%02x\\1a%02x}", hclr[2], hclr[1], hclr[0], 255 - hclr[3]);
@@ -1200,17 +1200,17 @@ static CStringW ConvertTX3GToSSA( int breaks = 0;
- for(int i = 0, j = 0; i <= str_len; i++) {
- if(chars[i].c == '\n' /*|| chars[i].c == ' '*/) {
+ for (int i = 0, j = 0; i <= str_len; i++) {
+ if (chars[i].c == '\n' /*|| chars[i].c == ' '*/) {
breaks++;
}
}
- if(str_len > breaks) {
+ if (str_len > breaks) {
float dur = (float)max(durationms - 500, 0) / 10;
- for(int i = 0, j = 0; i <= str_len; i++) {
- if(i == str_len || chars[i].c == '\n' /*|| chars[i].c == ' '*/) {
+ for (int i = 0, j = 0; i <= str_len; i++) {
+ if (i == str_len || chars[i].c == '\n' /*|| chars[i].c == ' '*/) {
s.Format(L"{\\kf%d}", (int)(dur * (i - j) / (str_len - breaks)));
chars[j].pre += s;
j = i+1;
@@ -1221,10 +1221,10 @@ static CStringW ConvertTX3GToSSA( //
- for(int i = 0; i < str_len; i++) {
+ for (int i = 0; i < str_len; i++) {
str += chars[i].pre;
str += chars[i].c;
- if(desc.DisplayFlags & 0x20000) {
+ if (desc.DisplayFlags & 0x20000) {
str += L"\\N";
}
str += chars[i].post;
@@ -1234,7 +1234,7 @@ static CStringW ConvertTX3GToSSA( //
- if(rbox.IsRectEmpty()) {
+ if (rbox.IsRectEmpty()) {
rbox.SetRect(0, 0, framesize.cx, framesize.cy);
}
rbox.OffsetRect(translation);
@@ -1243,11 +1243,11 @@ static CStringW ConvertTX3GToSSA( rbox2.DeflateRect(2, 2);
CRect r(0,0,0,0);
- if(rbox2.Height() > 0) {
+ if (rbox2.Height() > 0) {
r.top = rbox2.top;
r.bottom = framesize.cy - rbox2.bottom;
}
- if(rbox2.Width() > 0) {
+ if (rbox2.Width() > 0) {
r.left = rbox2.left;
r.right = framesize.cx - rbox2.right;
}
@@ -1268,30 +1268,30 @@ bool CMP4SplitterFilter::DemuxLoop() AP4_Movie* movie = (AP4_Movie*)m_pFile->GetMovie();
- while(SUCCEEDED(hr) && !CheckRequest(NULL)) {
+ while (SUCCEEDED(hr) && !CheckRequest(NULL)) {
CAtlMap<DWORD, trackpos>::CPair* pPairNext = NULL;
REFERENCE_TIME rtNext = 0;
POSITION pos = m_trackpos.GetStartPosition();
- while(pos) {
+ while (pos) {
CAtlMap<DWORD, trackpos>::CPair* pPair = m_trackpos.GetNext(pos);
AP4_Track* track = movie->GetTrack(pPair->m_key);
CBaseSplitterOutputPin* pPin = GetOutputPin((DWORD)track->GetId());
- if(!pPin->IsConnected()) {
+ if (!pPin->IsConnected()) {
continue;
}
REFERENCE_TIME rt = (REFERENCE_TIME)(10000000.0 / track->GetMediaTimeScale() * pPair->m_value.ts);
- if(pPair->m_value.index < track->GetSampleCount() && (!pPairNext || rt < rtNext)) {
+ if (pPair->m_value.index < track->GetSampleCount() && (!pPairNext || rt < rtNext)) {
pPairNext = pPair;
rtNext = rt;
}
}
- if(!pPairNext) {
+ if (!pPairNext) {
break;
}
@@ -1302,7 +1302,7 @@ bool CMP4SplitterFilter::DemuxLoop() AP4_Sample sample;
AP4_DataBuffer data;
- if(pPin && pPin->IsConnected() && AP4_SUCCEEDED(track->ReadSample(pPairNext->m_value.index, sample, data))) {
+ if (pPin && pPin->IsConnected() && AP4_SUCCEEDED(track->ReadSample(pPairNext->m_value.index, sample, data))) {
const CMediaType& mt = pPin->CurrentMediaType();
CAutoPtr<Packet> p(DNew Packet());
@@ -1312,25 +1312,25 @@ bool CMP4SplitterFilter::DemuxLoop() p->bSyncPoint = TRUE;
// FIXME: slow search & stss->m_Entries is private
- if(AP4_StssAtom* stss = dynamic_cast<AP4_StssAtom*>(track->GetTrakAtom()->FindChild("mdia/minf/stbl/stss"))) {
- if(stss->m_Entries.ItemCount() > 0) {
+ if (AP4_StssAtom* stss = dynamic_cast<AP4_StssAtom*>(track->GetTrakAtom()->FindChild("mdia/minf/stbl/stss"))) {
+ if (stss->m_Entries.ItemCount() > 0) {
p->bSyncPoint = FALSE;
AP4_Cardinal i = -1;
- while(++i < stss->m_Entries.ItemCount())
- if(stss->m_Entries[i]-1 == pPairNext->m_value.index) {
+ while (++i < stss->m_Entries.ItemCount())
+ if (stss->m_Entries[i]-1 == pPairNext->m_value.index) {
p->bSyncPoint = TRUE;
}
}
}
//
- if(track->GetType() == AP4_Track::TYPE_AUDIO && data.GetDataSize() == 1) {
+ if (track->GetType() == AP4_Track::TYPE_AUDIO && data.GetDataSize() == 1) {
WAVEFORMATEX* wfe = (WAVEFORMATEX*)mt.Format();
int nBlockAlign = 1200;
- if(wfe->nBlockAlign > 1) {
+ if (wfe->nBlockAlign > 1) {
nBlockAlign = wfe->nBlockAlign;
pPairNext->m_value.index -= pPairNext->m_value.index % wfe->nBlockAlign;
}
@@ -1339,40 +1339,40 @@ bool CMP4SplitterFilter::DemuxLoop() TRACE(_T("track->GetSampleCount() %d %d "), track->GetSampleCount(),pPairNext->m_value.index);
int fFirst = true;
- while(AP4_SUCCEEDED(track->ReadSample(pPairNext->m_value.index, sample, data))) {
+ while (AP4_SUCCEEDED(track->ReadSample(pPairNext->m_value.index, sample, data))) {
AP4_Size size = data.GetDataSize();
const AP4_Byte* ptr = data.GetData();
- for(int i = 0; i < size; i++) {
+ for (int i = 0; i < size; i++) {
p->Add(ptr[i]);
}
- if(fFirst) {
+ if (fFirst) {
p->rtStart = p->rtStop = (REFERENCE_TIME)(10000000.0 / track->GetMediaTimeScale() * sample.GetCts());
fFirst = false;
}
p->rtStop += (REFERENCE_TIME)(10000000.0 / track->GetMediaTimeScale() * sample.GetDuration());
- if(pPairNext->m_value.index+1 >= track->GetSampleCount() || (int)p->GetCount() >= nBlockAlign) {
+ if (pPairNext->m_value.index+1 >= track->GetSampleCount() || (int)p->GetCount() >= nBlockAlign) {
break;
}
pPairNext->m_value.index++;
}
- } else if(track->GetType() == AP4_Track::TYPE_TEXT) {
+ } else if (track->GetType() == AP4_Track::TYPE_TEXT) {
CStringA dlgln_bkg, dlgln_plaintext;
const AP4_Byte* ptr = data.GetData();
AP4_Size avail = data.GetDataSize();
- if(avail > 2) {
+ if (avail > 2) {
AP4_UI16 size = (ptr[0] << 8) | ptr[1];
- if(size <= avail-2) {
+ if (size <= avail-2) {
CStringA str;
- if(size >= 2 && ptr[2] == 0xfe && ptr[3] == 0xff) {
+ if (size >= 2 && ptr[2] == 0xfe && ptr[3] == 0xff) {
CStringW wstr = CStringW((LPCWSTR)&ptr[2], size/2);
- for(int i = 0; i < wstr.GetLength(); i++) {
+ for (int i = 0; i < wstr.GetLength(); i++) {
wstr.SetAt(i, ((WORD)wstr[i] >> 8) | ((WORD)wstr[i] << 8));
}
str = UTF16To8(wstr);
@@ -1382,34 +1382,34 @@ bool CMP4SplitterFilter::DemuxLoop() CStringA dlgln = str;
- if(mt.subtype == MEDIASUBTYPE_ASS2) {
+ if (mt.subtype == MEDIASUBTYPE_ASS2) {
AP4_SampleDescription* desc = track->GetSampleDescription(sample.GetDescriptionIndex());
dlgln = "0,0,Text,,0000,0000,0000,0000,," + str;
dlgln_plaintext = str;
CPoint translation(0, 0);
- if(AP4_TkhdAtom* tkhd = dynamic_cast<AP4_TkhdAtom*>(track->GetTrakAtom()->GetChild(AP4_ATOM_TYPE_TKHD))) {
+ if (AP4_TkhdAtom* tkhd = dynamic_cast<AP4_TkhdAtom*>(track->GetTrakAtom()->GetChild(AP4_ATOM_TYPE_TKHD))) {
AP4_Float x, y;
tkhd->GetTranslation(x, y);
translation.SetPoint((int)x, (int)y);
}
- if(AP4_UnknownSampleDescription* unknown_desc = dynamic_cast<AP4_UnknownSampleDescription*>(desc)) { // TEMP
+ if (AP4_UnknownSampleDescription* unknown_desc = dynamic_cast<AP4_UnknownSampleDescription*>(desc)) { // TEMP
AP4_SampleEntry* sample_entry = unknown_desc->GetSampleEntry();
- if(AP4_TextSampleEntry* text = dynamic_cast<AP4_TextSampleEntry*>(sample_entry)) {
+ if (AP4_TextSampleEntry* text = dynamic_cast<AP4_TextSampleEntry*>(sample_entry)) {
const AP4_TextSampleEntry::AP4_TextDescription& d = text->GetDescription();
// TODO
- } else if(AP4_Tx3gSampleEntry* tx3g = dynamic_cast<AP4_Tx3gSampleEntry*>(sample_entry)) {
+ } else if (AP4_Tx3gSampleEntry* tx3g = dynamic_cast<AP4_Tx3gSampleEntry*>(sample_entry)) {
const AP4_Tx3gSampleEntry::AP4_Tx3gDescription& desc = tx3g->GetDescription();
CStringW font = L"Arial";
- if(AP4_FtabAtom* ftab = dynamic_cast<AP4_FtabAtom*>(tx3g->GetChild(AP4_ATOM_TYPE_FTAB))) {
+ if (AP4_FtabAtom* ftab = dynamic_cast<AP4_FtabAtom*>(tx3g->GetChild(AP4_ATOM_TYPE_FTAB))) {
AP4_String Name;
- if(AP4_SUCCEEDED(ftab->LookupFont(desc.Style.Font.Id, Name))) {
+ if (AP4_SUCCEEDED(ftab->LookupFont(desc.Style.Font.Id, Name))) {
font = Name.c_str();
}
}
@@ -1425,7 +1425,7 @@ bool CMP4SplitterFilter::DemuxLoop() const AP4_Byte* bclr = (const AP4_Byte*)&desc.BackgroundColor;
- if(bclr[3]) {
+ if (bclr[3]) {
CPoint tl = rbox.TopLeft();
rbox.OffsetRect(-tl.x, -tl.y);
@@ -1450,7 +1450,7 @@ bool CMP4SplitterFilter::DemuxLoop() }
}
- if(!dlgln_bkg.IsEmpty()) {
+ if (!dlgln_bkg.IsEmpty()) {
CAutoPtr<Packet> p2(DNew Packet());
p2->TrackNumber = p->TrackNumber;
p2->rtStart = p->rtStart;
@@ -1460,7 +1460,7 @@ bool CMP4SplitterFilter::DemuxLoop() hr = DeliverPacket(p2);
}
- if(!dlgln_plaintext.IsEmpty()) {
+ if (!dlgln_plaintext.IsEmpty()) {
CAutoPtr<Packet> p2(DNew Packet());
p2->TrackNumber = p->TrackNumber ^ 0x80402010;
p2->rtStart = p->rtStart;
@@ -1477,7 +1477,7 @@ bool CMP4SplitterFilter::DemuxLoop() {
AP4_Sample sample;
- if(AP4_SUCCEEDED(track->GetSample(++pPairNext->m_value.index, sample))) {
+ if (AP4_SUCCEEDED(track->GetSample(++pPairNext->m_value.index, sample))) {
pPairNext->m_value.ts = sample.GetCts();
}
}
@@ -1493,23 +1493,23 @@ STDMETHODIMP CMP4SplitterFilter::GetKeyFrameCount(UINT& nKFs) {
CheckPointer(m_pFile, E_UNEXPECTED);
- if(!m_pFile) {
+ if (!m_pFile) {
return E_UNEXPECTED;
}
AP4_Movie* movie = (AP4_Movie*)m_pFile->GetMovie();
POSITION pos = m_trackpos.GetStartPosition();
- while(pos) {
+ while (pos) {
CAtlMap<DWORD, trackpos>::CPair* pPair = m_trackpos.GetNext(pos);
AP4_Track* track = movie->GetTrack(pPair->m_key);
- if(track->GetType() != AP4_Track::TYPE_VIDEO) {
+ if (track->GetType() != AP4_Track::TYPE_VIDEO) {
continue;
}
- if(AP4_StssAtom* stss = dynamic_cast<AP4_StssAtom*>(track->GetTrakAtom()->FindChild("mdia/minf/stbl/stss"))) {
+ if (AP4_StssAtom* stss = dynamic_cast<AP4_StssAtom*>(track->GetTrakAtom()->FindChild("mdia/minf/stbl/stss"))) {
nKFs = stss->m_Entries.ItemCount();
return S_OK;
}
@@ -1524,32 +1524,32 @@ STDMETHODIMP CMP4SplitterFilter::GetKeyFrames(const GUID* pFormat, REFERENCE_TIM CheckPointer(pKFs, E_POINTER);
CheckPointer(m_pFile, E_UNEXPECTED);
- if(*pFormat != TIME_FORMAT_MEDIA_TIME) {
+ if (*pFormat != TIME_FORMAT_MEDIA_TIME) {
return E_INVALIDARG;
}
- if(!m_pFile) {
+ if (!m_pFile) {
return E_UNEXPECTED;
}
AP4_Movie* movie = (AP4_Movie*)m_pFile->GetMovie();
POSITION pos = m_trackpos.GetStartPosition();
- while(pos) {
+ while (pos) {
CAtlMap<DWORD, trackpos>::CPair* pPair = m_trackpos.GetNext(pos);
AP4_Track* track = movie->GetTrack(pPair->m_key);
- if(track->GetType() != AP4_Track::TYPE_VIDEO) {
+ if (track->GetType() != AP4_Track::TYPE_VIDEO) {
continue;
}
- if(AP4_StssAtom* stss = dynamic_cast<AP4_StssAtom*>(track->GetTrakAtom()->FindChild("mdia/minf/stbl/stss"))) {
+ if (AP4_StssAtom* stss = dynamic_cast<AP4_StssAtom*>(track->GetTrakAtom()->FindChild("mdia/minf/stbl/stss"))) {
nKFs = 0;
- for(AP4_Cardinal i = 0; i < stss->m_Entries.ItemCount(); i++) {
+ for (AP4_Cardinal i = 0; i < stss->m_Entries.ItemCount(); i++) {
AP4_Sample sample;
- if(AP4_SUCCEEDED(track->GetSample(stss->m_Entries[i]-1, sample))) {
+ if (AP4_SUCCEEDED(track->GetSample(stss->m_Entries[i]-1, sample))) {
pKFs[nKFs++] = 10000000i64 * sample.GetCts() / track->GetMediaTimeScale();
}
}
@@ -1584,8 +1584,8 @@ CMPEG4VideoSplitterFilter::CMPEG4VideoSplitterFilter(LPUNKNOWN pUnk, HRESULT* ph void CMPEG4VideoSplitterFilter::SkipUserData()
{
m_pFile->BitByteAlign();
- while(m_pFile->BitRead(32, true) == 0x000001b2)
- while(m_pFile->BitRead(24, true) != 0x000001) {
+ while (m_pFile->BitRead(32, true) == 0x000001b2)
+ while (m_pFile->BitRead(24, true) != 0x000001) {
m_pFile->BitRead(8);
}
}
@@ -1598,10 +1598,10 @@ HRESULT CMPEG4VideoSplitterFilter::CreateOutputs(IAsyncReader* pAsyncReader) m_pFile.Free();
m_pFile.Attach(DNew CBaseSplitterFileEx(pAsyncReader, hr));
- if(!m_pFile) {
+ if (!m_pFile) {
return E_OUTOFMEMORY;
}
- if(FAILED(hr)) {
+ if (FAILED(hr)) {
m_pFile.Free();
return hr;
}
@@ -1617,31 +1617,31 @@ HRESULT CMPEG4VideoSplitterFilter::CreateOutputs(IAsyncReader* pAsyncReader) BYTE pary = 1;
REFERENCE_TIME atpf = 400000;
- if(m_pFile->BitRead(24, true) != 0x000001) {
+ if (m_pFile->BitRead(24, true) != 0x000001) {
return E_FAIL;
}
BYTE id;
- while(m_pFile->NextMpegStartCode(id, 1024 - m_pFile->GetPos())) {
- if(id == 0xb5) {
+ while (m_pFile->NextMpegStartCode(id, 1024 - m_pFile->GetPos())) {
+ if (id == 0xb5) {
BYTE is_visual_object_identifier = (BYTE)m_pFile->BitRead(1);
- if(is_visual_object_identifier) {
+ if (is_visual_object_identifier) {
BYTE visual_object_verid = (BYTE)m_pFile->BitRead(4);
BYTE visual_object_priority = (BYTE)m_pFile->BitRead(3);
}
BYTE visual_object_type = (BYTE)m_pFile->BitRead(4);
- if(visual_object_type == 1 || visual_object_type == 2) {
+ if (visual_object_type == 1 || visual_object_type == 2) {
BYTE video_signal_type = (BYTE)m_pFile->BitRead(1);
- if(video_signal_type) {
+ if (video_signal_type) {
BYTE video_format = (BYTE)m_pFile->BitRead(3);
BYTE video_range = (BYTE)m_pFile->BitRead(1);
BYTE colour_description = (BYTE)m_pFile->BitRead(1);
- if(colour_description) {
+ if (colour_description) {
BYTE colour_primaries = (BYTE)m_pFile->BitRead(8);
BYTE transfer_characteristics = (BYTE)m_pFile->BitRead(8);
BYTE matrix_coefficients = (BYTE)m_pFile->BitRead(8);
@@ -1651,29 +1651,29 @@ HRESULT CMPEG4VideoSplitterFilter::CreateOutputs(IAsyncReader* pAsyncReader) SkipUserData();
- if(visual_object_type == 1) {
- if(m_pFile->BitRead(24) != 0x000001) {
+ if (visual_object_type == 1) {
+ if (m_pFile->BitRead(24) != 0x000001) {
break;
}
BYTE video_object_start_code = (BYTE)m_pFile->BitRead(8);
- if(video_object_start_code < 0x00 || video_object_start_code > 0x1f) {
+ if (video_object_start_code < 0x00 || video_object_start_code > 0x1f) {
break;
}
- if(m_pFile->BitRead(24) != 0x000001) {
+ if (m_pFile->BitRead(24) != 0x000001) {
break;
}
BYTE video_object_layer_start_code = (DWORD)m_pFile->BitRead(8);
- if(video_object_layer_start_code < 0x20 || video_object_layer_start_code > 0x2f) {
+ if (video_object_layer_start_code < 0x20 || video_object_layer_start_code > 0x2f) {
break;
}
BYTE random_accessible_vol = (BYTE)m_pFile->BitRead(1);
BYTE video_object_type_indication = (BYTE)m_pFile->BitRead(8);
- if(video_object_type_indication == 0x12) { // Fine Granularity Scalable
+ if (video_object_type_indication == 0x12) { // Fine Granularity Scalable
break; // huh
}
@@ -1681,14 +1681,14 @@ HRESULT CMPEG4VideoSplitterFilter::CreateOutputs(IAsyncReader* pAsyncReader) BYTE video_object_layer_verid = 0;
- if(is_object_layer_identifier) {
+ if (is_object_layer_identifier) {
video_object_layer_verid = (BYTE)m_pFile->BitRead(4);
BYTE video_object_layer_priority = (BYTE)m_pFile->BitRead(3);
}
BYTE aspect_ratio_info = (BYTE)m_pFile->BitRead(4);
- switch(aspect_ratio_info) {
+ switch (aspect_ratio_info) {
default:
ASSERT(0);
break;
@@ -1720,32 +1720,32 @@ HRESULT CMPEG4VideoSplitterFilter::CreateOutputs(IAsyncReader* pAsyncReader) BYTE vol_control_parameters = (BYTE)m_pFile->BitRead(1);
- if(vol_control_parameters) {
+ if (vol_control_parameters) {
BYTE chroma_format = (BYTE)m_pFile->BitRead(2);
BYTE low_delay = (BYTE)m_pFile->BitRead(1);
BYTE vbv_parameters = (BYTE)m_pFile->BitRead(1);
- if(vbv_parameters) {
+ if (vbv_parameters) {
WORD first_half_bit_rate = (WORD)m_pFile->BitRead(15);
- if(!m_pFile->BitRead(1)) {
+ if (!m_pFile->BitRead(1)) {
break;
}
WORD latter_half_bit_rate = (WORD)m_pFile->BitRead(15);
- if(!m_pFile->BitRead(1)) {
+ if (!m_pFile->BitRead(1)) {
break;
}
WORD first_half_vbv_buffer_size = (WORD)m_pFile->BitRead(15);
- if(!m_pFile->BitRead(1)) {
+ if (!m_pFile->BitRead(1)) {
break;
}
BYTE latter_half_vbv_buffer_size = (BYTE)m_pFile->BitRead(3);
WORD first_half_vbv_occupancy = (WORD)m_pFile->BitRead(11);
- if(!m_pFile->BitRead(1)) {
+ if (!m_pFile->BitRead(1)) {
break;
}
WORD latter_half_vbv_occupancy = (WORD)m_pFile->BitRead(15);
- if(!m_pFile->BitRead(1)) {
+ if (!m_pFile->BitRead(1)) {
break;
}
}
@@ -1753,43 +1753,43 @@ HRESULT CMPEG4VideoSplitterFilter::CreateOutputs(IAsyncReader* pAsyncReader) BYTE video_object_layer_shape = (BYTE)m_pFile->BitRead(2);
- if(video_object_layer_shape == 3 && video_object_layer_verid != 1) {
+ if (video_object_layer_shape == 3 && video_object_layer_verid != 1) {
BYTE video_object_layer_shape_extension = (BYTE)m_pFile->BitRead(4);
}
- if(!m_pFile->BitRead(1)) {
+ if (!m_pFile->BitRead(1)) {
break;
}
WORD vop_time_increment_resolution = (WORD)m_pFile->BitRead(16);
- if(!m_pFile->BitRead(1)) {
+ if (!m_pFile->BitRead(1)) {
break;
}
BYTE fixed_vop_rate = (BYTE)m_pFile->BitRead(1);
- if(fixed_vop_rate) {
+ if (fixed_vop_rate) {
int bits = 0;
- for(WORD i = vop_time_increment_resolution; i; i /= 2) {
+ for (WORD i = vop_time_increment_resolution; i; i /= 2) {
bits++;
}
WORD fixed_vop_time_increment = m_pFile->BitRead(bits);
- if(fixed_vop_time_increment) {
+ if (fixed_vop_time_increment) {
atpf = 10000000i64 * fixed_vop_time_increment / vop_time_increment_resolution;
}
}
- if(video_object_layer_shape != 2) {
- if(video_object_layer_shape == 0) {
- if(!m_pFile->BitRead(1)) {
+ if (video_object_layer_shape != 2) {
+ if (video_object_layer_shape == 0) {
+ if (!m_pFile->BitRead(1)) {
break;
}
width = (WORD)m_pFile->BitRead(13);
- if(!m_pFile->BitRead(1)) {
+ if (!m_pFile->BitRead(1)) {
break;
}
height = (WORD)m_pFile->BitRead(13);
- if(!m_pFile->BitRead(1)) {
+ if (!m_pFile->BitRead(1)) {
break;
}
}
@@ -1800,12 +1800,12 @@ HRESULT CMPEG4VideoSplitterFilter::CreateOutputs(IAsyncReader* pAsyncReader) // ...
}
}
- } else if(id == 0xb6) {
+ } else if (id == 0xb6) {
m_seqhdrsize = m_pFile->GetPos() - 4;
}
}
- if(!width || !height) {
+ if (!width || !height) {
return E_FAIL;
}
@@ -1866,19 +1866,19 @@ bool CMPEG4VideoSplitterFilter::DemuxLoop() DWORD sync = ~0;
- while(SUCCEEDED(hr) && !CheckRequest(NULL) && m_pFile->GetRemaining()) {
- for(int i = 0; i < 65536; i++) { // don't call CheckRequest so often
+ while (SUCCEEDED(hr) && !CheckRequest(NULL) && m_pFile->GetRemaining()) {
+ for (int i = 0; i < 65536; i++) { // don't call CheckRequest so often
bool eof = !m_pFile->GetRemaining();
- if(p && !p->IsEmpty() && (m_pFile->BitRead(32, true) == 0x000001b6 || eof)) {
+ if (p && !p->IsEmpty() && (m_pFile->BitRead(32, true) == 0x000001b6 || eof)) {
hr = DeliverPacket(p);
}
- if(eof) {
+ if (eof) {
break;
}
- if(!p) {
+ if (!p) {
p.Attach(DNew Packet());
p->SetCount(0, 1024);
p->TrackNumber = 0;
diff --git a/src/filters/parser/MP4Splitter/MP4SplitterFile.cpp b/src/filters/parser/MP4Splitter/MP4SplitterFile.cpp index 88ce5ebfa..b7331bba4 100644 --- a/src/filters/parser/MP4Splitter/MP4SplitterFile.cpp +++ b/src/filters/parser/MP4Splitter/MP4SplitterFile.cpp @@ -6,7 +6,7 @@ CMP4SplitterFile::CMP4SplitterFile(IAsyncReader* pReader, HRESULT& hr) : CBaseSplitterFileEx(pReader, hr, DEFAULT_CACHE_LENGTH, false)
, m_pAp4File(NULL)
{
- if(FAILED(hr)) {
+ if (FAILED(hr)) {
return;
}
diff --git a/src/filters/parser/MatroskaSplitter/MatroskaFile.cpp b/src/filters/parser/MatroskaSplitter/MatroskaFile.cpp index 027b97b41..092e19334 100644 --- a/src/filters/parser/MatroskaSplitter/MatroskaFile.cpp +++ b/src/filters/parser/MatroskaSplitter/MatroskaFile.cpp @@ -32,7 +32,7 @@ static void LOG(LPCTSTR fmt, ...) {
va_list args;
va_start(args, fmt);
- if(FILE* f = _tfopen(_T("c:\\matroskasplitterlog.txt"), _T("at"))) {
+ if (FILE* f = _tfopen(_T("c:\\matroskasplitterlog.txt"), _T("at"))) {
fseek(f, 0, 2);
_vftprintf(f, fmt, args);
fclose(f);
@@ -62,7 +62,7 @@ using namespace MatroskaReader; static void bswap(BYTE* s, int len)
{
- for(BYTE* d = s + len-1; s < d; s++, d--) {
+ for (BYTE* d = s + len-1; s < d; s++, d--) {
*s ^= *d, *d ^= *s, *s ^= *d;
}
}
@@ -75,7 +75,7 @@ CMatroskaFile::CMatroskaFile(IAsyncReader* pAsyncReader, HRESULT& hr) : CBaseSplitterFile(pAsyncReader, hr, DEFAULT_CACHE_LENGTH, false)
, m_rtOffset(0)
{
- if(FAILED(hr)) {
+ if (FAILED(hr)) {
return;
}
hr = Init();
@@ -84,17 +84,17 @@ CMatroskaFile::CMatroskaFile(IAsyncReader* pAsyncReader, HRESULT& hr) HRESULT CMatroskaFile::Init()
{
DWORD dw;
- if(FAILED(Read(dw)) || dw != 0x1A45DFA3) {
+ if (FAILED(Read(dw)) || dw != 0x1A45DFA3) {
return E_FAIL;
}
CMatroskaNode Root(this);
- if(FAILED(Parse(&Root))) {
+ if (FAILED(Parse(&Root))) {
return E_FAIL;
}
CAutoPtr<CMatroskaNode> pSegment, pCluster;
- if((pSegment = Root.Child(0x18538067))
+ if ((pSegment = Root.Child(0x18538067))
&& (pCluster = pSegment->Child(0x1F43B675))) {
Cluster c0;
c0.ParseTimeCode(pCluster);
@@ -108,7 +108,7 @@ template <class T> HRESULT CMatroskaFile::Read(T& var)
{
HRESULT hr = ByteRead((BYTE*)&var, sizeof(var));
- if(S_OK == hr) {
+ if (S_OK == hr) {
bswap((BYTE*)&var, sizeof(var));
}
return hr;
@@ -119,12 +119,12 @@ HRESULT CMatroskaFile::Parse(CMatroskaNode* pMN0) BeginChunk
case 0x1A45DFA3:
m_ebml.Parse(pMN);
- if((m_ebml.DocType != DOCTYPE || m_ebml.DocTypeReadVersion > DOCTYPEVERSION) && m_ebml.DocType != DOCTYPE_WEBM) {
+ if ((m_ebml.DocType != DOCTYPE || m_ebml.DocTypeReadVersion > DOCTYPEVERSION) && m_ebml.DocType != DOCTYPE_WEBM) {
return E_FAIL;
}
break;
case 0x18538067:
- if(m_segment.SegmentInfo.SegmentUID.IsEmpty()) {
+ if (m_segment.SegmentInfo.SegmentUID.IsEmpty()) {
m_segment.ParseMinimal(pMN);
}
break;
@@ -198,14 +198,14 @@ HRESULT Segment::ParseMinimal(CMatroskaNode* pMN0) len = pMN0->m_len;
CAutoPtr<CMatroskaNode> pMN = pMN0->Child();
- if(!pMN) {
+ if (!pMN) {
return S_FALSE;
}
int n = 0;
do {
- switch(pMN->m_id) {
+ switch (pMN->m_id) {
case 0x1549A966:
SegmentInfo.Parse(pMN);
n++;
@@ -222,37 +222,37 @@ HRESULT Segment::ParseMinimal(CMatroskaNode* pMN0) Cues.Parse(pMN);
break;
}
- } while(n < 3 && pMN->Next());
+ } while (n < 3 && pMN->Next());
- if(!pMN->IsRandomAccess()) {
+ if (!pMN->IsRandomAccess()) {
return S_OK;
}
- while(MatroskaReader::QWORD pos = pMN->FindPos(0x114D9B74, pMN->GetPos())) {
+ while (MatroskaReader::QWORD pos = pMN->FindPos(0x114D9B74, pMN->GetPos())) {
pMN->SeekTo(pos);
pMN->Parse();
- if(pMN->m_id != 0x114D9B74) {
+ if (pMN->m_id != 0x114D9B74) {
ASSERT(0);
break;
}
MetaSeekInfo.Parse(pMN);
}
- if(n == 3) {
- if(Cues.IsEmpty() && (pMN = pMN0->Child(0x1C53BB6B, false))) {
+ if (n == 3) {
+ if (Cues.IsEmpty() && (pMN = pMN0->Child(0x1C53BB6B, false))) {
do {
Cues.Parse(pMN);
- } while(pMN->Next(true));
+ } while (pMN->Next(true));
}
- if(Chapters.IsEmpty() && (pMN = pMN0->Child(0x1043A770, false))) {
+ if (Chapters.IsEmpty() && (pMN = pMN0->Child(0x1043A770, false))) {
do {
Chapters.Parse(pMN); /*BIG UGLY HACK:*/
break;
- } while(pMN->Next(true));
+ } while (pMN->Next(true));
}
- if(Attachments.IsEmpty() && (pMN = pMN0->Child(0x1941A469, false))) {
+ if (Attachments.IsEmpty() && (pMN = pMN0->Child(0x1941A469, false))) {
do {
Attachments.Parse(pMN); /*BIG UGLY HACK:*/
break;
@@ -268,26 +268,26 @@ UINT64 Segment::GetMasterTrack() UINT64 TrackNumber = 0, AltTrackNumber = 0;
POSITION pos1 = Tracks.GetHeadPosition();
- while(pos1 && TrackNumber == 0) {
+ while (pos1 && TrackNumber == 0) {
Track* pT = Tracks.GetNext(pos1);
POSITION pos2 = pT->TrackEntries.GetHeadPosition();
- while(pos2 && TrackNumber == 0) {
+ while (pos2 && TrackNumber == 0) {
TrackEntry* pTE = pT->TrackEntries.GetNext(pos2);
- if(pTE->TrackType == TrackEntry::TypeVideo) {
+ if (pTE->TrackType == TrackEntry::TypeVideo) {
TrackNumber = pTE->TrackNumber;
break;
- } else if(pTE->TrackType == TrackEntry::TypeAudio && AltTrackNumber == 0) {
+ } else if (pTE->TrackType == TrackEntry::TypeAudio && AltTrackNumber == 0) {
AltTrackNumber = pTE->TrackNumber;
}
}
}
- if(TrackNumber == 0) {
+ if (TrackNumber == 0) {
TrackNumber = AltTrackNumber;
}
- if(TrackNumber == 0) {
+ if (TrackNumber == 0) {
TrackNumber = 1;
}
@@ -296,14 +296,14 @@ UINT64 Segment::GetMasterTrack() ChapterAtom* ChapterAtom::FindChapterAtom(UINT64 id)
{
- if(ChapterUID == id) {
+ if (ChapterUID == id) {
return(this);
}
POSITION pos = ChapterAtoms.GetHeadPosition();
- while(pos) {
+ while (pos) {
ChapterAtom* ca = ChapterAtoms.GetNext(pos)->FindChapterAtom(id);
- if(ca) {
+ if (ca) {
return ca;
}
}
@@ -314,14 +314,14 @@ ChapterAtom* ChapterAtom::FindChapterAtom(UINT64 id) ChapterAtom* Segment::FindChapterAtom(UINT64 id, int nEditionEntry)
{
POSITION pos1 = Chapters.GetHeadPosition();
- while(pos1) {
+ while (pos1) {
Chapter* c = Chapters.GetNext(pos1);
POSITION pos2 = c->EditionEntries.GetHeadPosition();
- while(pos2) {
+ while (pos2) {
EditionEntry* ee = c->EditionEntries.GetNext(pos2);
- if(nEditionEntry-- == 0) {
+ if (nEditionEntry-- == 0) {
return id == 0 ? ee : ee->FindChapterAtom(id);
}
}
@@ -470,12 +470,12 @@ case 0x23314F: TrackTimecodeScale.Parse(pMN);
break;
case 0xE0:
- if(S_OK == v.Parse(pMN)) {
+ if (S_OK == v.Parse(pMN)) {
DescType |= DescVideo;
}
break;
case 0xE1:
- if(S_OK == a.Parse(pMN)) {
+ if (S_OK == a.Parse(pMN)) {
DescType |= DescAudio;
}
break;
@@ -496,29 +496,29 @@ static int cesort(const void* a, const void* b) bool TrackEntry::Expand(CBinary& data, UINT64 Scope)
{
- if(ces.ce.GetCount() == 0) {
+ if (ces.ce.GetCount() == 0) {
return true;
}
CAtlArray<ContentEncoding*> cearray;
POSITION pos = ces.ce.GetHeadPosition();
- while(pos) {
+ while (pos) {
cearray.Add(ces.ce.GetNext(pos));
}
qsort(cearray.GetData(), cearray.GetCount(), sizeof(ContentEncoding*), cesort);
- for(int i = cearray.GetCount()-1; i >= 0; i--) {
+ for (int i = cearray.GetCount()-1; i >= 0; i--) {
ContentEncoding* ce = cearray[i];
- if(!(ce->ContentEncodingScope & Scope)) {
+ if (!(ce->ContentEncodingScope & Scope)) {
continue;
}
- if(ce->ContentEncodingType == ContentEncoding::Compression) {
- if(!data.Decompress(ce->cc)) {
+ if (ce->ContentEncodingType == ContentEncoding::Compression) {
+ if (!data.Decompress(ce->cc)) {
return false;
}
- } else if(ce->ContentEncodingType == ContentEncoding::Encryption) {
+ } else if (ce->ContentEncodingType == ContentEncoding::Encryption) {
// TODO
return false;
}
@@ -720,7 +720,7 @@ case 0xE8: TimeSlices.Parse(pMN);
break;
case 0x75A1:
- if(fFull) {
+ if (fFull) {
ba.Parse(pMN);
}
break;
@@ -737,7 +737,7 @@ HRESULT SimpleBlock::Parse(CMatroskaNode* pMN, bool fFull) TimeCode.Set(s);
Lacing.Parse(pMN);
- if(!fFull) {
+ if (!fFull) {
return S_OK;
}
@@ -746,7 +746,7 @@ HRESULT SimpleBlock::Parse(CMatroskaNode* pMN, bool fFull) MatroskaReader::QWORD FrameSize;
BYTE FramesInLaceLessOne;
- switch((Lacing & 0x06) >> 1) {
+ switch ((Lacing & 0x06) >> 1) {
case 0:
// No lacing
lens.AddTail((pMN->m_start+pMN->m_len) - (pMN->GetPos()+tlen));
@@ -755,13 +755,13 @@ HRESULT SimpleBlock::Parse(CMatroskaNode* pMN, bool fFull) // Xiph lacing
BYTE n;
pMN->Read(n);
- while(n-- > 0) {
+ while (n-- > 0) {
BYTE b;
MatroskaReader::QWORD len = 0;
do {
pMN->Read(b);
len += b;
- } while(b == 0xff);
+ } while (b == 0xff);
lens.AddTail(len);
tlen += len;
}
@@ -772,7 +772,7 @@ HRESULT SimpleBlock::Parse(CMatroskaNode* pMN, bool fFull) pMN->Read(FramesInLaceLessOne);
FramesInLaceLessOne++;
FrameSize = ((pMN->m_start+pMN->m_len) - (pMN->GetPos()+tlen)) / FramesInLaceLessOne;
- while(FramesInLaceLessOne-- > 0) {
+ while (FramesInLaceLessOne-- > 0) {
lens.AddTail(FrameSize);
}
break;
@@ -788,7 +788,7 @@ HRESULT SimpleBlock::Parse(CMatroskaNode* pMN, bool fFull) CSignedLength DiffSize;
FrameSize = FirstFrameSize;
- while(FramesInLaceLessOne--) {
+ while (FramesInLaceLessOne--) {
DiffSize.Parse(pMN);
FrameSize += DiffSize;
lens.AddTail(FrameSize);
@@ -799,7 +799,7 @@ HRESULT SimpleBlock::Parse(CMatroskaNode* pMN, bool fFull) }
POSITION pos = lens.GetHeadPosition();
- while(pos) {
+ while (pos) {
MatroskaReader::QWORD len = lens.GetNext(pos);
CAutoPtr<CBinary> p(DNew CBinary());
p->SetCount((INT_PTR)len);
@@ -1012,7 +1012,7 @@ HRESULT CBinary::Parse(CMatroskaNode* pMN) bool CBinary::Compress(ContentCompression& cc)
{
- if(cc.ContentCompAlgo == ContentCompression::ZLIB) {
+ if (cc.ContentCompAlgo == ContentCompression::ZLIB) {
int res;
z_stream c_stream;
@@ -1020,7 +1020,7 @@ bool CBinary::Compress(ContentCompression& cc) c_stream.zfree = (free_func)0;
c_stream.opaque = (voidpf)0;
- if(Z_OK != (res = deflateInit(&c_stream, 9))) {
+ if (Z_OK != (res = deflateInit(&c_stream, 9))) {
return false;
}
@@ -1033,11 +1033,11 @@ bool CBinary::Compress(ContentCompression& cc) dst = (BYTE*)realloc(dst, ++n*10);
c_stream.next_out = &dst[(n-1)*10];
c_stream.avail_out = 10;
- if(Z_OK != (res = deflate(&c_stream, Z_FINISH)) && Z_STREAM_END != res) {
+ if (Z_OK != (res = deflate(&c_stream, Z_FINISH)) && Z_STREAM_END != res) {
free(dst);
return false;
}
- } while(0 == c_stream.avail_out && Z_STREAM_END != res);
+ } while (0 == c_stream.avail_out && Z_STREAM_END != res);
deflateEnd(&c_stream);
@@ -1054,7 +1054,7 @@ bool CBinary::Compress(ContentCompression& cc) bool CBinary::Decompress(ContentCompression& cc)
{
- if(cc.ContentCompAlgo == ContentCompression::ZLIB) {
+ if (cc.ContentCompAlgo == ContentCompression::ZLIB) {
int res;
z_stream d_stream;
@@ -1062,7 +1062,7 @@ bool CBinary::Decompress(ContentCompression& cc) d_stream.zfree = (free_func)0;
d_stream.opaque = (voidpf)0;
- if(Z_OK != (res = inflateInit(&d_stream))) {
+ if (Z_OK != (res = inflateInit(&d_stream))) {
return false;
}
@@ -1075,11 +1075,11 @@ bool CBinary::Decompress(ContentCompression& cc) dst = (unsigned char *)realloc(dst, ++n*1000);
d_stream.next_out = &dst[(n-1)*1000];
d_stream.avail_out = 1000;
- if(Z_OK != (res = inflate(&d_stream, Z_NO_FLUSH)) && Z_STREAM_END != res) {
+ if (Z_OK != (res = inflate(&d_stream, Z_NO_FLUSH)) && Z_STREAM_END != res) {
free(dst);
return false;
}
- } while(0 == d_stream.avail_out && 0 != d_stream.avail_in && Z_STREAM_END != res);
+ } while (0 == d_stream.avail_out && 0 != d_stream.avail_in && Z_STREAM_END != res);
inflateEnd(&d_stream);
@@ -1089,7 +1089,7 @@ bool CBinary::Decompress(ContentCompression& cc) free(dst);
return true;
- } else if(cc.ContentCompAlgo == ContentCompression::HDRSTRIP) {
+ } else if (cc.ContentCompAlgo == ContentCompression::HDRSTRIP) {
InsertArrayAt(0, &cc.ContentCompSettings);
}
@@ -1102,7 +1102,7 @@ HRESULT CANSI::Parse(CMatroskaNode* pMN) MatroskaReader::QWORD len = pMN->m_len;
CHAR c;
- while(len-- > 0 && SUCCEEDED(pMN->Read(c))) {
+ while (len-- > 0 && SUCCEEDED(pMN->Read(c))) {
*this += c;
}
@@ -1113,7 +1113,7 @@ HRESULT CUTF8::Parse(CMatroskaNode* pMN) {
Empty();
CAutoVectorPtr<BYTE> buff;
- if(!buff.Allocate((UINT)pMN->m_len + 1) || S_OK != pMN->Read(buff, pMN->m_len)) {
+ if (!buff.Allocate((UINT)pMN->m_len + 1) || S_OK != pMN->Read(buff, pMN->m_len)) {
return E_FAIL;
}
buff[pMN->m_len] = 0;
@@ -1124,10 +1124,10 @@ HRESULT CUTF8::Parse(CMatroskaNode* pMN) HRESULT CUInt::Parse(CMatroskaNode* pMN)
{
m_val = 0;
- for(int i = 0; i < (int)pMN->m_len; i++) {
+ for (int i = 0; i < (int)pMN->m_len; i++) {
m_val <<= 8;
HRESULT hr = pMN->Read(*(BYTE*)&m_val);
- if(FAILED(hr)) {
+ if (FAILED(hr)) {
return hr;
}
}
@@ -1138,9 +1138,9 @@ HRESULT CUInt::Parse(CMatroskaNode* pMN) HRESULT CInt::Parse(CMatroskaNode* pMN)
{
m_val = 0;
- for(int i = 0; i < (int)pMN->m_len; i++) {
+ for (int i = 0; i < (int)pMN->m_len; i++) {
HRESULT hr = pMN->Read(*((BYTE*)&m_val+7-i));
- if(FAILED(hr)) {
+ if (FAILED(hr)) {
return hr;
}
}
@@ -1154,14 +1154,14 @@ HRESULT CFloat::Parse(CMatroskaNode* pMN) HRESULT hr = E_FAIL;
m_val = 0;
- if(pMN->m_len == 4) {
+ if (pMN->m_len == 4) {
float val = 0;
hr = pMN->Read(val);
m_val = val;
- } else if(pMN->m_len == 8) {
+ } else if (pMN->m_len == 8) {
hr = pMN->Read(m_val);
}
- if(SUCCEEDED(hr)) {
+ if (SUCCEEDED(hr)) {
m_fValid = true;
}
return hr;
@@ -1182,32 +1182,32 @@ HRESULT CID::Parse(CMatroskaNode* pMN) BYTE b = 0;
HRESULT hr = pMN->Read(b);
- if(FAILED(hr)) {
+ if (FAILED(hr)) {
return hr;
}
int nMoreBytes = 0;
- if((b&0x80) == 0x80) {
+ if ((b&0x80) == 0x80) {
m_val = b&0xff;
nMoreBytes = 0;
- } else if((b&0xc0) == 0x40) {
+ } else if ((b&0xc0) == 0x40) {
m_val = b&0x7f;
nMoreBytes = 1;
- } else if((b&0xe0) == 0x20) {
+ } else if ((b&0xe0) == 0x20) {
m_val = b&0x3f;
nMoreBytes = 2;
- } else if((b&0xf0) == 0x10) {
+ } else if ((b&0xf0) == 0x10) {
m_val = b&0x1f;
nMoreBytes = 3;
} else {
return E_FAIL;
}
- while(nMoreBytes-- > 0) {
+ while (nMoreBytes-- > 0) {
m_val <<= 8;
hr = pMN->Read(*(BYTE*)&m_val);
- if(FAILED(hr)) {
+ if (FAILED(hr)) {
return hr;
}
}
@@ -1223,34 +1223,34 @@ HRESULT CLength::Parse(CMatroskaNode* pMN) BYTE b = 0;
HRESULT hr = pMN->Read(b);
- if(FAILED(hr)) {
+ if (FAILED(hr)) {
return hr;
}
int nMoreBytes = 0;
- if((b&0x80) == 0x80) {
+ if ((b&0x80) == 0x80) {
m_val = b&0x7f;
nMoreBytes = 0;
- } else if((b&0xc0) == 0x40) {
+ } else if ((b&0xc0) == 0x40) {
m_val = b&0x3f;
nMoreBytes = 1;
- } else if((b&0xe0) == 0x20) {
+ } else if ((b&0xe0) == 0x20) {
m_val = b&0x1f;
nMoreBytes = 2;
- } else if((b&0xf0) == 0x10) {
+ } else if ((b&0xf0) == 0x10) {
m_val = b&0x0f;
nMoreBytes = 3;
- } else if((b&0xf8) == 0x08) {
+ } else if ((b&0xf8) == 0x08) {
m_val = b&0x07;
nMoreBytes = 4;
- } else if((b&0xfc) == 0x04) {
+ } else if ((b&0xfc) == 0x04) {
m_val = b&0x03;
nMoreBytes = 5;
- } else if((b&0xfe) == 0x02) {
+ } else if ((b&0xfe) == 0x02) {
m_val = b&0x01;
nMoreBytes = 6;
- } else if((b&0xff) == 0x01) {
+ } else if ((b&0xff) == 0x01) {
m_val = b&0x00;
nMoreBytes = 7;
} else {
@@ -1261,20 +1261,20 @@ HRESULT CLength::Parse(CMatroskaNode* pMN) MatroskaReader::QWORD UnknownSize = (1i64<<(7*(nMoreBytes+1)))-1;
- while(nMoreBytes-- > 0) {
+ while (nMoreBytes-- > 0) {
m_val <<= 8;
hr = pMN->Read(*(BYTE*)&m_val);
- if(FAILED(hr)) {
+ if (FAILED(hr)) {
return hr;
}
}
- if(m_val == UnknownSize) {
+ if (m_val == UnknownSize) {
m_val = pMN->GetLength() - pMN->GetPos();
TRACE(_T("CLength: Unspecified chunk size at %I64d (corrected to %I64d)\n"), pMN->GetPos(), m_val);
}
- if(m_fSigned) {
+ if (m_fSigned) {
m_val -= (UnknownSize >> 1);
}
@@ -1335,7 +1335,7 @@ HRESULT CNode<T>::Parse(CMatroskaNode* pMN) {
CAutoPtr<T> p(DNew T());
HRESULT hr = E_OUTOFMEMORY;
- if(!p || FAILED(hr = p->Parse(pMN))) {
+ if (!p || FAILED(hr = p->Parse(pMN))) {
return hr;
}
AddTail(p);
@@ -1346,7 +1346,7 @@ HRESULT CBlockGroupNode::Parse(CMatroskaNode* pMN, bool fFull) {
CAutoPtr<BlockGroup> p(DNew BlockGroup());
HRESULT hr = E_OUTOFMEMORY;
- if(!p || FAILED(hr = p->Parse(pMN, fFull))) {
+ if (!p || FAILED(hr = p->Parse(pMN, fFull))) {
return hr;
}
AddTail(p);
@@ -1357,7 +1357,7 @@ HRESULT CSimpleBlockNode::Parse(CMatroskaNode* pMN, bool fFull) {
CAutoPtr<SimpleBlock> p(DNew SimpleBlock());
HRESULT hr = E_OUTOFMEMORY;
- if(!p || FAILED(hr = p->Parse(pMN, fFull))) {
+ if (!p || FAILED(hr = p->Parse(pMN, fFull))) {
return hr;
}
AddTail(p);
@@ -1385,7 +1385,7 @@ CMatroskaNode::CMatroskaNode(CMatroskaNode* pParent) HRESULT CMatroskaNode::Parse()
{
m_filepos = GetPos();
- if(FAILED(m_id.Parse(this)) || FAILED(m_len.Parse(this))) {
+ if (FAILED(m_id.Parse(this)) || FAILED(m_len.Parse(this))) {
return E_FAIL;
}
m_start = GetPos();
@@ -1394,12 +1394,12 @@ HRESULT CMatroskaNode::Parse() CAutoPtr<CMatroskaNode> CMatroskaNode::Child(DWORD id, bool fSearch)
{
- if(m_len == 0) {
+ if (m_len == 0) {
return CAutoPtr<CMatroskaNode>();
}
SeekTo(m_start);
CAutoPtr<CMatroskaNode> pMN(DNew CMatroskaNode(this));
- if(id && !pMN->Find(id, fSearch)) {
+ if (id && !pMN->Find(id, fSearch)) {
pMN.Free();
}
return pMN;
@@ -1407,22 +1407,22 @@ CAutoPtr<CMatroskaNode> CMatroskaNode::Child(DWORD id, bool fSearch) bool CMatroskaNode::Next(bool fSame)
{
- if(!m_pParent) {
+ if (!m_pParent) {
return false;
}
CID id = m_id;
- while(m_start+m_len < m_pParent->m_start+m_pParent->m_len) {
+ while (m_start+m_len < m_pParent->m_start+m_pParent->m_len) {
SeekTo(m_start+m_len);
- if(FAILED(Parse())) {
- if(!Resync()) {
+ if (FAILED(Parse())) {
+ if (!Resync()) {
return false;
}
}
- if(!fSame || m_id == id) {
+ if (!fSame || m_id == id) {
return true;
}
}
@@ -1436,11 +1436,11 @@ bool CMatroskaNode::Find(DWORD id, bool fSearch) ? FindPos(id)
: 0;
- if(pos) {
+ if (pos) {
SeekTo(pos);
Parse();
- } else if(fSearch) {
- while(m_id != id && Next()) {
+ } else if (fSearch) {
+ while (m_id != id && Next()) {
;
}
}
@@ -1479,13 +1479,13 @@ MatroskaReader::QWORD CMatroskaNode::FindPos(DWORD id, MatroskaReader::QWORD sta Segment& sm = m_pMF->m_segment;
POSITION pos = sm.MetaSeekInfo.GetHeadPosition();
- while(pos) {
+ while (pos) {
Seek* s = sm.MetaSeekInfo.GetNext(pos);
POSITION pos2 = s->SeekHeads.GetHeadPosition();
- while(pos2) {
+ while (pos2) {
SeekHead* sh = s->SeekHeads.GetNext(pos2);
- if(sh->SeekID == id && sh->SeekPosition+sm.pos >= start) {
+ if (sh->SeekID == id && sh->SeekPosition+sm.pos >= start) {
return sh->SeekPosition+sm.pos;
}
}
@@ -1509,31 +1509,31 @@ CAutoPtr<CMatroskaNode> CMatroskaNode::GetFirstBlock() {
CAutoPtr<CMatroskaNode> pNode = Child();
do {
- if(pNode->m_id == 0xA0 || pNode->m_id == 0xA3) {
+ if (pNode->m_id == 0xA0 || pNode->m_id == 0xA3) {
return pNode;
}
- } while(pNode->Next());
+ } while (pNode->Next());
return CAutoPtr<CMatroskaNode>();
}
bool CMatroskaNode::NextBlock()
{
- if(!m_pParent) {
+ if (!m_pParent) {
return false;
}
CID id = m_id;
- while(m_start+m_len < m_pParent->m_start+m_pParent->m_len) {
+ while (m_start+m_len < m_pParent->m_start+m_pParent->m_len) {
SeekTo(m_start+m_len);
- if(FAILED(Parse())) {
- if(!Resync()) {
+ if (FAILED(Parse())) {
+ if (!Resync()) {
return false;
}
}
- if(m_id == 0xA0 || m_id == 0xA3) {
+ if (m_id == 0xA0 || m_id == 0xA3) {
return true;
}
}
@@ -1543,11 +1543,11 @@ bool CMatroskaNode::NextBlock() bool CMatroskaNode::Resync()
{
- if(m_pParent->m_id == 0x18538067) { /*segment?*/
+ if (m_pParent->m_id == 0x18538067) { /*segment?*/
SeekTo(m_filepos);
- for(BYTE b = 0; S_OK == Read(b); b = 0) {
- if((b&0xf0) != 0x10) {
+ for (BYTE b = 0; S_OK == Read(b); b = 0) {
+ if ((b&0xf0) != 0x10) {
continue;
}
@@ -1555,7 +1555,7 @@ bool CMatroskaNode::Resync() Read((BYTE*)&dw+1, 3);
bswap((BYTE*)&dw, 4);
- switch(dw) {
+ switch (dw) {
case 0x1549A966: // SegmentInfo
case 0x114D9B74: // MetaSeekInfo
case 0x1654AE6B: // Tracks
diff --git a/src/filters/parser/MatroskaSplitter/MatroskaSplitter.cpp b/src/filters/parser/MatroskaSplitter/MatroskaSplitter.cpp index ca36e6d76..5b41014d2 100644 --- a/src/filters/parser/MatroskaSplitter/MatroskaSplitter.cpp +++ b/src/filters/parser/MatroskaSplitter/MatroskaSplitter.cpp @@ -111,7 +111,7 @@ STDMETHODIMP CMatroskaSplitterFilter::QueryFilterInfo(FILTER_INFO* pInfo) wcscpy(pInfo->achName, MatroskaSourceName);
}
pInfo->pGraph = m_pGraph;
- if(m_pGraph) {
+ if (m_pGraph) {
m_pGraph->AddRef();
}
@@ -132,10 +132,10 @@ HRESULT CMatroskaSplitterFilter::CreateOutputs(IAsyncReader* pAsyncReader) CAtlArray<TrackEntry*> pinOutTE;
m_pFile.Attach(DNew CMatroskaFile(pAsyncReader, hr));
- if(!m_pFile) {
+ if (!m_pFile) {
return E_OUTOFMEMORY;
}
- if(FAILED(hr)) {
+ if (FAILED(hr)) {
m_pFile.Free();
return hr;
}
@@ -147,16 +147,16 @@ HRESULT CMatroskaSplitterFilter::CreateOutputs(IAsyncReader* pAsyncReader) bool bHasVideo = 0;
POSITION pos = m_pFile->m_segment.Tracks.GetHeadPosition();
- while(pos) {
+ while (pos) {
Track* pT = m_pFile->m_segment.Tracks.GetNext(pos);
POSITION pos2 = pT->TrackEntries.GetHeadPosition();
- while(pos2) {
+ while (pos2) {
TrackEntry* pTE = pT->TrackEntries.GetNext(pos2);
bool isSub = false;
- if(!pTE->Expand(pTE->CodecPrivate, ContentEncoding::TracksPrivateData)) {
+ if (!pTE->Expand(pTE->CodecPrivate, ContentEncoding::TracksPrivateData)) {
continue;
}
@@ -170,18 +170,18 @@ HRESULT CMatroskaSplitterFilter::CreateOutputs(IAsyncReader* pAsyncReader) mt.SetSampleSize(1);
- if(pTE->TrackType == TrackEntry::TypeVideo) {
+ if (pTE->TrackType == TrackEntry::TypeVideo) {
Name.Format(L"Video %d", iVideo++);
mt.majortype = MEDIATYPE_Video;
- if(CodecID == "V_MS/VFW/FOURCC") {
+ if (CodecID == "V_MS/VFW/FOURCC") {
mt.formattype = FORMAT_VideoInfo;
VIDEOINFOHEADER* pvih = (VIDEOINFOHEADER*)mt.AllocFormatBuffer(sizeof(VIDEOINFOHEADER) + pTE->CodecPrivate.GetCount() - sizeof(BITMAPINFOHEADER));
memset(mt.Format(), 0, mt.FormatLength());
memcpy(&pvih->bmiHeader, pTE->CodecPrivate.GetData(), pTE->CodecPrivate.GetCount());
mt.subtype = FOURCCMap(pvih->bmiHeader.biCompression);
- switch(pvih->bmiHeader.biCompression) {
+ switch (pvih->bmiHeader.biCompression) {
case BI_RGB:
case BI_BITFIELDS:
mt.subtype =
@@ -197,19 +197,19 @@ HRESULT CMatroskaSplitterFilter::CreateOutputs(IAsyncReader* pAsyncReader) // case BI_RLE4: mt.subtype = MEDIASUBTYPE_RGB4; break;
}
if (!bHasVideo) {
- mts.Add(mt);
+ mts.Add(mt);
if (mt.subtype == MEDIASUBTYPE_WVC1) {
mt.subtype = MEDIASUBTYPE_WVC1_CYBERLINK;
mts.Add(mt);
}
}
bHasVideo = true;
- } else if(CodecID == "V_UNCOMPRESSED") {
- } else if(CodecID.Find("V_MPEG4/ISO/AVC") == 0 && pTE->CodecPrivate.GetCount() >= 6) {
+ } else if (CodecID == "V_UNCOMPRESSED") {
+ } else if (CodecID.Find("V_MPEG4/ISO/AVC") == 0 && pTE->CodecPrivate.GetCount() >= 6) {
BYTE sps = pTE->CodecPrivate[5] & 0x1f;
std::vector<BYTE> avcC;
- for(int i = 0, j = pTE->CodecPrivate.GetCount(); i < j; i++) {
+ for (int i = 0, j = pTE->CodecPrivate.GetCount(); i < j; i++) {
avcC.push_back(pTE->CodecPrivate[i]);
}
@@ -277,9 +277,9 @@ avcsuccess: memcpy(pSequenceHeader, data.GetData(), data.GetCount());
pm2vi->cbSequenceHeader = data.GetCount();
if (!bHasVideo)
- mts.Add(mt);
+ mts.Add(mt);
bHasVideo = true;
- } else if(CodecID.Find("V_MPEG4/") == 0) {
+ } else if (CodecID.Find("V_MPEG4/") == 0) {
mt.subtype = FOURCCMap('V4PM');
mt.formattype = FORMAT_MPEG2Video;
MPEG2VIDEOINFO* pm2vi = (MPEG2VIDEOINFO*)mt.AllocFormatBuffer(FIELD_OFFSET(MPEG2VIDEOINFO, dwSequenceHeader) + pTE->CodecPrivate.GetCount());
@@ -294,9 +294,9 @@ avcsuccess: memcpy(pSequenceHeader, pTE->CodecPrivate.GetData(), pTE->CodecPrivate.GetCount());
pm2vi->cbSequenceHeader = pTE->CodecPrivate.GetCount();
if (!bHasVideo)
- mts.Add(mt);
+ mts.Add(mt);
bHasVideo = true;
- } else if(CodecID.Find("V_REAL/RV") == 0) {
+ } else if (CodecID.Find("V_REAL/RV") == 0) {
mt.subtype = FOURCCMap('00VR' + ((CodecID[9]-0x30)<<16));
mt.formattype = FORMAT_VideoInfo;
VIDEOINFOHEADER* pvih = (VIDEOINFOHEADER*)mt.AllocFormatBuffer(sizeof(VIDEOINFOHEADER) + pTE->CodecPrivate.GetCount());
@@ -307,9 +307,9 @@ avcsuccess: pvih->bmiHeader.biHeight = (LONG)pTE->v.PixelHeight;
pvih->bmiHeader.biCompression = mt.subtype.Data1;
if (!bHasVideo)
- mts.Add(mt);
+ mts.Add(mt);
bHasVideo = true;
- } else if(CodecID == "V_DIRAC") {
+ } else if (CodecID == "V_DIRAC") {
mt.subtype = MEDIASUBTYPE_DiracVideo;
mt.formattype = FORMAT_DiracVideoInfo;
DIRACINFOHEADER* dvih = (DIRACINFOHEADER*)mt.AllocFormatBuffer(FIELD_OFFSET(DIRACINFOHEADER, dwSequenceHeader) + pTE->CodecPrivate.GetCount());
@@ -325,20 +325,20 @@ avcsuccess: dvih->cbSequenceHeader = pTE->CodecPrivate.GetCount();
if (!bHasVideo)
- mts.Add(mt);
+ mts.Add(mt);
bHasVideo = true;
- } else if(CodecID == "V_MPEG2") {
+ } else if (CodecID == "V_MPEG2") {
BYTE* seqhdr = pTE->CodecPrivate.GetData();
DWORD len = pTE->CodecPrivate.GetCount();
int w = pTE->v.PixelWidth;
int h = pTE->v.PixelHeight;
- if(MakeMPEG2MediaType(mt, seqhdr, len, w, h)) {
+ if (MakeMPEG2MediaType(mt, seqhdr, len, w, h)) {
if (!bHasVideo)
mts.Add(mt);
bHasVideo = true;
}
- } else if(CodecID == "V_THEORA") {
+ } else if (CodecID == "V_THEORA") {
BYTE* thdr = pTE->CodecPrivate.GetData() + 3;
mt.majortype = MEDIATYPE_Video;
@@ -354,7 +354,7 @@ avcsuccess: vih->hdr.bmiHeader.biBitCount = 24;
int nFpsNum = (thdr[22]<<24)|(thdr[23]<<16)|(thdr[24]<<8)|thdr[25];
int nFpsDenum = (thdr[26]<<24)|(thdr[27]<<16)|(thdr[28]<<8)|thdr[29];
- if(nFpsNum) {
+ if (nFpsNum) {
vih->hdr.AvgTimePerFrame = (REFERENCE_TIME)(10000000.0 * nFpsDenum / nFpsNum);
}
vih->hdr.dwPictAspectRatioX = (thdr[14]<<16)|(thdr[15]<<8)|thdr[16];
@@ -365,9 +365,9 @@ avcsuccess: memcpy (&vih->dwSequenceHeader, pTE->CodecPrivate.GetData(), vih->cbSequenceHeader);
if (!bHasVideo)
- mts.Add(mt);
+ mts.Add(mt);
bHasVideo = true;
- } else if(CodecID.Find("V_VP8") == 0) {
+ } else if (CodecID.Find("V_VP8") == 0) {
mt.subtype = FOURCCMap('08PV');
mt.formattype = FORMAT_VideoInfo;
VIDEOINFOHEADER* pvih = (VIDEOINFOHEADER*)mt.AllocFormatBuffer(sizeof(VIDEOINFOHEADER) + pTE->CodecPrivate.GetCount());
@@ -378,7 +378,7 @@ avcsuccess: pvih->bmiHeader.biHeight = (LONG)pTE->v.PixelHeight;
pvih->bmiHeader.biCompression = mt.subtype.Data1;
if (!bHasVideo)
- mts.Add(mt);
+ mts.Add(mt);
bHasVideo = true;
}
/*
@@ -395,15 +395,15 @@ avcsuccess: */
REFERENCE_TIME AvgTimePerFrame = 0;
- if(pTE->v.FramePerSec > 0) {
+ if (pTE->v.FramePerSec > 0) {
AvgTimePerFrame = (REFERENCE_TIME)(10000000i64 / pTE->v.FramePerSec);
- } else if(pTE->DefaultDuration > 0) {
+ } else if (pTE->DefaultDuration > 0) {
AvgTimePerFrame = (REFERENCE_TIME)pTE->DefaultDuration / 100;
}
- if(AvgTimePerFrame) {
- for(size_t i = 0; i < mts.GetCount(); i++) {
- if(mts[i].formattype == FORMAT_VideoInfo
+ if (AvgTimePerFrame) {
+ for (size_t i = 0; i < mts.GetCount(); i++) {
+ if (mts[i].formattype == FORMAT_VideoInfo
|| mts[i].formattype == FORMAT_VideoInfo2
|| mts[i].formattype == FORMAT_MPEG2Video) {
((VIDEOINFOHEADER*)mts[i].Format())->AvgTimePerFrame = AvgTimePerFrame;
@@ -411,9 +411,9 @@ avcsuccess: }
}
- if(pTE->v.DisplayWidth != 0 && pTE->v.DisplayHeight != 0) {
- for(size_t i = 0; i < mts.GetCount(); i++) {
- if(mts[i].formattype == FORMAT_VideoInfo) {
+ if (pTE->v.DisplayWidth != 0 && pTE->v.DisplayHeight != 0) {
+ for (size_t i = 0; i < mts.GetCount(); i++) {
+ if (mts[i].formattype == FORMAT_VideoInfo) {
mt = mts[i];
DWORD vih1 = FIELD_OFFSET(VIDEOINFOHEADER, bmiHeader);
DWORD vih2 = FIELD_OFFSET(VIDEOINFOHEADER2, bmiHeader);
@@ -426,16 +426,16 @@ avcsuccess: CSize aspect(pTE->v.DisplayWidth, pTE->v.DisplayHeight);
int lnko = LNKO(aspect.cx, aspect.cy);
- if(lnko > 1) {
+ if (lnko > 1) {
aspect.cx /= lnko, aspect.cy /= lnko;
}
((VIDEOINFOHEADER2*)mt.Format())->dwPictAspectRatioX = aspect.cx;
((VIDEOINFOHEADER2*)mt.Format())->dwPictAspectRatioY = aspect.cy;
mts.InsertAt(i++, mt);
- } else if(mts[i].formattype == FORMAT_MPEG2Video) {
+ } else if (mts[i].formattype == FORMAT_MPEG2Video) {
CSize aspect(pTE->v.DisplayWidth, pTE->v.DisplayHeight);
int lnko = LNKO(aspect.cx, aspect.cy);
- if(lnko > 1) {
+ if (lnko > 1) {
aspect.cx /= lnko, aspect.cy /= lnko;
}
((MPEG2VIDEOINFO*)mts[i].Format())->hdr.dwPictAspectRatioX = aspect.cx;
@@ -443,7 +443,7 @@ avcsuccess: }
}
}
- } else if(pTE->TrackType == TrackEntry::TypeAudio) {
+ } else if (pTE->TrackType == TrackEntry::TypeAudio) {
Name.Format(L"Audio %d", iAudio++);
mt.majortype = MEDIATYPE_Audio;
@@ -459,7 +459,7 @@ avcsuccess: static CAtlMap<CStringA, int, CStringElementTraits<CStringA> > id2ft;
- if(id2ft.IsEmpty()) {
+ if (id2ft.IsEmpty()) {
id2ft["A_MPEG/L3"] = WAVE_FORMAT_MP3;
id2ft["A_MPEG/L2"] = WAVE_FORMAT_MPEG;
id2ft["A_MPEG/L1"] = WAVE_FORMAT_MPEG;
@@ -476,8 +476,8 @@ avcsuccess: }
int wFormatTag;
- if(id2ft.Lookup(CodecID, wFormatTag)) {
- if(wFormatTag < 0) {
+ if (id2ft.Lookup(CodecID, wFormatTag)) {
+ if (wFormatTag < 0) {
wFormatTag = -wFormatTag;
wfe->cbSize = pTE->CodecPrivate.GetCount();
wfe = (WAVEFORMATEX*)mt.ReallocFormatBuffer(sizeof(WAVEFORMATEX) + pTE->CodecPrivate.GetCount());
@@ -491,11 +491,11 @@ avcsuccess: }
mts.Add(mt);
- if(wFormatTag == WAVE_FORMAT_FLAC) {
+ if (wFormatTag == WAVE_FORMAT_FLAC) {
mt.subtype = MEDIASUBTYPE_FLAC_FRAMED;
mts.InsertAt(0, mt);
}
- } else if(CodecID == "A_PCM/INT/LIT") {
+ } else if (CodecID == "A_PCM/INT/LIT") {
mt.subtype = MEDIASUBTYPE_PCM;
if (pTE->a.Channels <= 2 && pTE->a.BitDepth <= 16) {
wfe->wFormatTag = WAVE_FORMAT_PCM;
@@ -516,7 +516,7 @@ avcsuccess: mt.SetSampleSize(wfex->Format.nBlockAlign);
}
mts.Add(mt);
- } else if(CodecID == "A_MS/ACM") {
+ } else if (CodecID == "A_MS/ACM") {
wfe = (WAVEFORMATEX*)mt.AllocFormatBuffer(pTE->CodecPrivate.GetCount());
memcpy(wfe, (WAVEFORMATEX*)pTE->CodecPrivate.GetData(), pTE->CodecPrivate.GetCount());
if (wfe->wFormatTag == WAVE_FORMAT_EXTENSIBLE && wfe->cbSize == 22) {
@@ -524,26 +524,26 @@ avcsuccess: }
else mt.subtype = FOURCCMap(wfe->wFormatTag);
mts.Add(mt);
- } else if(CodecID == "A_VORBIS") {
+ } else if (CodecID == "A_VORBIS") {
BYTE* p = pTE->CodecPrivate.GetData();
CAtlArray<int> sizes;
- for(BYTE n = *p++; n > 0; n--) {
+ for (BYTE n = *p++; n > 0; n--) {
int size = 0;
do {
size += *p;
- } while(*p++ == 0xff);
+ } while (*p++ == 0xff);
sizes.Add(size);
}
int totalsize = 0;
- for(size_t i = 0; i < sizes.GetCount(); i++) {
+ for (size_t i = 0; i < sizes.GetCount(); i++) {
totalsize += sizes[i];
}
sizes.Add(pTE->CodecPrivate.GetCount() - (p - pTE->CodecPrivate.GetData()) - totalsize);
totalsize += sizes[sizes.GetCount()-1];
- if(sizes.GetCount() == 3) {
+ if (sizes.GetCount() == 3) {
mt.subtype = MEDIASUBTYPE_Vorbis2;
mt.formattype = FORMAT_VorbisFormat2;
VORBISFORMAT2* pvf2 = (VORBISFORMAT2*)mt.AllocFormatBuffer(sizeof(VORBISFORMAT2) + totalsize);
@@ -552,7 +552,7 @@ avcsuccess: pvf2->SamplesPerSec = (DWORD)pTE->a.SamplingFrequency;
pvf2->BitsPerSample = (DWORD)pTE->a.BitDepth;
BYTE* p2 = mt.Format() + sizeof(VORBISFORMAT2);
- for(size_t i = 0; i < sizes.GetCount(); p += sizes[i], p2 += sizes[i], i++) {
+ for (size_t i = 0; i < sizes.GetCount(); p += sizes[i], p2 += sizes[i], i++) {
memcpy(p2, p, pvf2->HeaderSize[i] = sizes[i]);
}
@@ -567,22 +567,22 @@ avcsuccess: vf->nSamplesPerSec = (DWORD)pTE->a.SamplingFrequency;
vf->nMinBitsPerSec = vf->nMaxBitsPerSec = vf->nAvgBitsPerSec = (DWORD)-1;
mts.Add(mt);
- } else if(CodecID.Find("A_AAC/") == 0) {
+ } else if (CodecID.Find("A_AAC/") == 0) {
mt.subtype = FOURCCMap(wfe->wFormatTag = WAVE_FORMAT_AAC);
wfe = (WAVEFORMATEX*)mt.ReallocFormatBuffer(sizeof(WAVEFORMATEX) + 5);
wfe->cbSize = 2;
int profile;
- if(CodecID.Find("/MAIN") > 0) {
+ if (CodecID.Find("/MAIN") > 0) {
profile = 0;
- } else if(CodecID.Find("/SBR") > 0) {
+ } else if (CodecID.Find("/SBR") > 0) {
profile = -1;
- } else if(CodecID.Find("/LC") > 0) {
+ } else if (CodecID.Find("/LC") > 0) {
profile = 1;
- } else if(CodecID.Find("/SSR") > 0) {
+ } else if (CodecID.Find("/SSR") > 0) {
profile = 2;
- } else if(CodecID.Find("/LTP") > 0) {
+ } else if (CodecID.Find("/LTP") > 0) {
profile = 3;
} else {
continue;
@@ -592,14 +592,14 @@ avcsuccess: mts.Add(mt);
- if(profile < 0) {
+ if (profile < 0) {
wfe->cbSize = cbSize;
wfe->nSamplesPerSec *= 2;
wfe->nAvgBytesPerSec *= 2;
mts.InsertAt(0, mt);
}
- } else if(CodecID.Find("A_REAL/") == 0 && CodecID.GetLength() >= 11) {
+ } else if (CodecID.Find("A_REAL/") == 0 && CodecID.GetLength() >= 11) {
mt.subtype = FOURCCMap((DWORD)CodecID[7]|((DWORD)CodecID[8]<<8)|((DWORD)CodecID[9]<<16)|((DWORD)CodecID[10]<<24));
mt.bTemporalCompression = TRUE;
wfe->cbSize = pTE->CodecPrivate.GetCount();
@@ -608,8 +608,8 @@ avcsuccess: wfe->cbSize = 0; // IMPORTANT: this is screwed, but cbSize has to be 0 and the extra data from codec priv must be after WAVEFORMATEX
mts.Add(mt);
}
- } else if(pTE->TrackType == TrackEntry::TypeSubtitle) {
- if(iSubtitle == 1) {
+ } else if (pTE->TrackType == TrackEntry::TypeSubtitle) {
+ if (iSubtitle == 1) {
InstallFonts();
}
@@ -617,7 +617,7 @@ avcsuccess: mt.SetSampleSize(1);
- if(CodecID == "S_TEXT/ASCII") {
+ if (CodecID == "S_TEXT/ASCII") {
mt.majortype = MEDIATYPE_Text;
mt.subtype = MEDIASUBTYPE_NULL;
mt.formattype = FORMAT_None;
@@ -650,14 +650,14 @@ avcsuccess: CodecID == "S_VOBSUB" ? MEDIASUBTYPE_VOBSUB :
MEDIASUBTYPE_NULL;
- if(mt.subtype != MEDIASUBTYPE_NULL) {
+ if (mt.subtype != MEDIASUBTYPE_NULL) {
mts.Add(mt);
isSub = true;
}
}
}
- if(mts.IsEmpty()) {
+ if (mts.IsEmpty()) {
TRACE(_T("CMatroskaSourceFilter: Unsupported TrackType %s (%I64d)\n"), CString(CodecID), (UINT64)pTE->TrackType);
continue;
}
@@ -675,10 +675,10 @@ avcsuccess: HRESULT hr;
CAutoPtr<CBaseSplitterOutputPin> pPinOut(DNew CMatroskaSplitterOutputPin(pTE->MinCache, pTE->DefaultDuration / 100, mts, Name, this, this, &hr));
- if(!pTE->Name.IsEmpty()) {
+ if (!pTE->Name.IsEmpty()) {
pPinOut->SetProperty(L"NAME", pTE->Name);
}
- if(pTE->Language.GetLength() == 3) {
+ if (pTE->Language.GetLength() == 3) {
pPinOut->SetProperty(L"LANG", CStringW(CString(pTE->Language)));
}
@@ -693,7 +693,7 @@ avcsuccess: }
}
- for(size_t i = 0; i < pinOut.GetCount(); i++) {
+ for (size_t i = 0; i < pinOut.GetCount(); i++) {
CAutoPtr<CBaseSplitterOutputPin> pPinOut;
pPinOut.Attach(pinOut[i]);
@@ -709,7 +709,7 @@ avcsuccess: Info& info = m_pFile->m_segment.SegmentInfo;
- if(m_pFile->IsRandomAccess()) {
+ if (m_pFile->IsRandomAccess()) {
m_rtDuration = (REFERENCE_TIME)(info.Duration * info.TimeCodeScale / 100);
}
@@ -735,17 +735,17 @@ avcsuccess: {
POSITION pos = m_pFile->m_segment.Attachments.GetHeadPosition();
- while(pos) {
+ while (pos) {
Attachment* pA = m_pFile->m_segment.Attachments.GetNext(pos);
POSITION pos = pA->AttachedFiles.GetHeadPosition();
- while(pos) {
+ while (pos) {
AttachedFile* pF = pA->AttachedFiles.GetNext(pos);
CAtlArray<BYTE> pData;
pData.SetCount(pF->FileDataLen);
m_pFile->Seek(pF->FileDataPos);
- if(SUCCEEDED(m_pFile->ByteRead(pData.GetData(), pData.GetCount()))) {
+ if (SUCCEEDED(m_pFile->ByteRead(pData.GetData(), pData.GetCount()))) {
ResAppend(pF->FileName, pF->FileDescription, CStringW(pF->FileMimeType), pData.GetData(), pData.GetCount());
}
}
@@ -754,11 +754,11 @@ avcsuccess: // chapters
- if(ChapterAtom* caroot = m_pFile->m_segment.FindChapterAtom(0)) {
+ if (ChapterAtom* caroot = m_pFile->m_segment.FindChapterAtom(0)) {
CStringA str;
str.ReleaseBufferSetLength(GetLocaleInfoA(LOCALE_USER_DEFAULT, LOCALE_SISO639LANGNAME, str.GetBuffer(3), 3));
CStringA ChapLanguage = CStringA(ISO6391To6392(str));
- if(ChapLanguage.GetLength() < 3) {
+ if (ChapLanguage.GetLength() < 3) {
ChapLanguage = "eng";
}
@@ -772,26 +772,26 @@ void CMatroskaSplitterFilter::SetupChapters(LPCSTR lng, ChapterAtom* parent, int {
CStringW tabs('+', level);
- if(!tabs.IsEmpty()) {
+ if (!tabs.IsEmpty()) {
tabs += ' ';
}
POSITION pos = parent->ChapterAtoms.GetHeadPosition();
- while(pos) {
+ while (pos) {
// ChapUID zero not allow by Matroska specs
UINT64 ChapUID = parent->ChapterAtoms.GetNext(pos)->ChapterUID;
ChapterAtom* ca = (ChapUID == 0) ? NULL : m_pFile->m_segment.FindChapterAtom(ChapUID);
- if(ca) {
+ if (ca) {
CStringW name, first;
POSITION pos = ca->ChapterDisplays.GetHeadPosition();
- while(pos) {
+ while (pos) {
ChapterDisplay* cd = ca->ChapterDisplays.GetNext(pos);
- if(first.IsEmpty()) {
+ if (first.IsEmpty()) {
first = cd->ChapString;
}
- if(cd->ChapLanguage == lng) {
+ if (cd->ChapLanguage == lng) {
name = cd->ChapString;
}
}
@@ -800,7 +800,7 @@ void CMatroskaSplitterFilter::SetupChapters(LPCSTR lng, ChapterAtom* parent, int ChapAppend(ca->ChapterTimeStart / 100 - m_pFile->m_rtOffset, name);
- if(!ca->ChapterAtoms.IsEmpty()) {
+ if (!ca->ChapterAtoms.IsEmpty()) {
SetupChapters(lng, ca, level+1);
}
}
@@ -811,22 +811,22 @@ void CMatroskaSplitterFilter::SetupChapters(LPCSTR lng, ChapterAtom* parent, int void CMatroskaSplitterFilter::InstallFonts()
{
POSITION pos = m_pFile->m_segment.Attachments.GetHeadPosition();
- while(pos) {
+ while (pos) {
Attachment* pA = m_pFile->m_segment.Attachments.GetNext(pos);
POSITION p2 = pA->AttachedFiles.GetHeadPosition();
- while(p2) {
+ while (p2) {
AttachedFile* pF = pA->AttachedFiles.GetNext(p2);
- if(pF->FileMimeType == "application/x-truetype-font" ||
- pF->FileMimeType == "application/x-font-ttf" ||
- pF->FileMimeType == "application/vnd.ms-opentype") {
+ if (pF->FileMimeType == "application/x-truetype-font" ||
+ pF->FileMimeType == "application/x-font-ttf" ||
+ pF->FileMimeType == "application/vnd.ms-opentype") {
// assume this is a font resource
- if(BYTE* pData = DNew BYTE[(UINT)pF->FileDataLen]) {
+ if (BYTE* pData = DNew BYTE[(UINT)pF->FileDataLen]) {
m_pFile->Seek(pF->FileDataPos);
- if(SUCCEEDED(m_pFile->ByteRead(pData, pF->FileDataLen))) {
+ if (SUCCEEDED(m_pFile->ByteRead(pData, pF->FileDataLen))) {
//m_fontinst.InstallFont(pData, (UINT)pF->FileDataLen);
m_fontinst.InstallFontMemory(pData, (UINT)pF->FileDataLen);
}
@@ -843,28 +843,28 @@ void CMatroskaSplitterFilter::SendVorbisHeaderSample() HRESULT hr;
POSITION pos = m_pTrackEntryMap.GetStartPosition();
- while(pos) {
+ while (pos) {
DWORD TrackNumber = 0;
TrackEntry* pTE = NULL;
m_pTrackEntryMap.GetNextAssoc(pos, TrackNumber, pTE);
CBaseSplitterOutputPin* pPin = GetOutputPin(TrackNumber);
- if(!(pTE && pPin && pPin->IsConnected())) {
+ if (!(pTE && pPin && pPin->IsConnected())) {
continue;
}
- if(pTE->CodecID.ToString() == "A_VORBIS" && pPin->CurrentMediaType().subtype == MEDIASUBTYPE_Vorbis
+ if (pTE->CodecID.ToString() == "A_VORBIS" && pPin->CurrentMediaType().subtype == MEDIASUBTYPE_Vorbis
&& pTE->CodecPrivate.GetCount() > 0) {
BYTE* ptr = pTE->CodecPrivate.GetData();
CAtlList<int> sizes;
long last = 0;
- for(BYTE n = *ptr++; n > 0; n--) {
+ for (BYTE n = *ptr++; n > 0; n--) {
int size = 0;
do {
size += *ptr;
- } while(*ptr++ == 0xff);
+ } while (*ptr++ == 0xff);
sizes.AddTail(size);
last += size;
}
@@ -873,7 +873,7 @@ void CMatroskaSplitterFilter::SendVorbisHeaderSample() hr = S_OK;
POSITION pos = sizes.GetHeadPosition();
- while(pos && SUCCEEDED(hr)) {
+ while (pos && SUCCEEDED(hr)) {
long len = sizes.GetNext(pos);
CAutoPtr<Packet> p(DNew Packet());
@@ -888,7 +888,7 @@ void CMatroskaSplitterFilter::SendVorbisHeaderSample() hr = DeliverPacket(p);
}
- if(FAILED(hr)) {
+ if (FAILED(hr)) {
TRACE(_T("ERROR: Vorbis initialization failed for stream %I64d\n"), TrackNumber);
}
}
@@ -900,7 +900,7 @@ bool CMatroskaSplitterFilter::DemuxInit() SetThreadName((DWORD)-1, "CMatroskaSplitterFilter");
CMatroskaNode Root(m_pFile);
- if(!m_pFile
+ if (!m_pFile
|| !(m_pSegment = Root.Child(0x18538067))
|| !(m_pCluster = m_pSegment->Child(0x1F43B675))) {
return false;
@@ -908,7 +908,7 @@ bool CMatroskaSplitterFilter::DemuxInit() // reindex if needed
- if(m_pFile->IsRandomAccess() && m_pFile->m_segment.Cues.GetCount() == 0) {
+ if (m_pFile->IsRandomAccess() && m_pFile->m_segment.Cues.GetCount() == 0) {
m_nOpenProgress = 0;
m_pFile->m_segment.SegmentInfo.Duration.Set(0);
@@ -933,18 +933,18 @@ bool CMatroskaSplitterFilter::DemuxInit() m_nOpenProgress = m_pFile->GetPos()*100/m_pFile->GetLength();
DWORD cmd;
- if(CheckRequest(&cmd)) {
- if(cmd == CMD_EXIT) {
+ if (CheckRequest(&cmd)) {
+ if (cmd == CMD_EXIT) {
m_fAbort = true;
} else {
Reply(S_OK);
}
}
- } while(!m_fAbort && m_pCluster->Next(true));
+ } while (!m_fAbort && m_pCluster->Next(true));
m_nOpenProgress = 100;
- if(!m_fAbort) {
+ if (!m_fAbort) {
m_pFile->m_segment.Cues.AddTail(pCue);
}
@@ -962,7 +962,7 @@ void CMatroskaSplitterFilter::DemuxSeek(REFERENCE_TIME rt) m_pCluster = m_pSegment->Child(0x1F43B675);
m_pBlock.Free();
- if(rt > 0) {
+ if (rt > 0) {
rt += m_pFile->m_rtOffset;
MatroskaReader::QWORD lastCueClusterPosition = (MatroskaReader::QWORD)-1;
@@ -972,26 +972,26 @@ void CMatroskaSplitterFilter::DemuxSeek(REFERENCE_TIME rt) UINT64 TrackNumber = s.GetMasterTrack();
POSITION pos1 = s.Cues.GetHeadPosition();
- while(pos1) {
+ while (pos1) {
Cue* pCue = s.Cues.GetNext(pos1);
POSITION pos2 = pCue->CuePoints.GetTailPosition();
- while(pos2) {
+ while (pos2) {
CuePoint* pCuePoint = pCue->CuePoints.GetPrev(pos2);
- if(rt < s.GetRefTime(pCuePoint->CueTime)) {
+ if (rt < s.GetRefTime(pCuePoint->CueTime)) {
continue;
}
POSITION pos3 = pCuePoint->CueTrackPositions.GetHeadPosition();
- while(pos3) {
+ while (pos3) {
CueTrackPosition* pCueTrackPositions = pCuePoint->CueTrackPositions.GetNext(pos3);
- if(TrackNumber != pCueTrackPositions->CueTrack) {
+ if (TrackNumber != pCueTrackPositions->CueTrack) {
continue;
}
- if(lastCueClusterPosition == pCueTrackPositions->CueClusterPosition) {
+ if (lastCueClusterPosition == pCueTrackPositions->CueClusterPosition) {
continue;
}
@@ -1014,47 +1014,47 @@ void CMatroskaSplitterFilter::DemuxSeek(REFERENCE_TIME rt) Cluster c;
c.ParseTimeCode(m_pCluster);
- if(CAutoPtr<CMatroskaNode> pBlock = m_pCluster->GetFirstBlock()) {
+ if (CAutoPtr<CMatroskaNode> pBlock = m_pCluster->GetFirstBlock()) {
bool fPassedCueTime = false;
do {
CBlockGroupNode bgn;
- if(pBlock->m_id == 0xA0) {
+ if (pBlock->m_id == 0xA0) {
bgn.Parse(pBlock, true);
- } else if(pBlock->m_id == 0xA3) {
+ } else if (pBlock->m_id == 0xA3) {
CAutoPtr<BlockGroup> bg(DNew BlockGroup());
bg->Block.Parse(pBlock, true);
- if(!(bg->Block.Lacing & 0x80)) {
+ if (!(bg->Block.Lacing & 0x80)) {
bg->ReferenceBlock.Set(0); // not a kf
}
bgn.AddTail(bg);
}
POSITION pos4 = bgn.GetHeadPosition();
- while(!fPassedCueTime && pos4) {
+ while (!fPassedCueTime && pos4) {
BlockGroup* bg = bgn.GetNext(pos4);
- if(bg->Block.TrackNumber == pCueTrackPositions->CueTrack && rt < s.GetRefTime(c.TimeCode + bg->Block.TimeCode)
+ if (bg->Block.TrackNumber == pCueTrackPositions->CueTrack && rt < s.GetRefTime(c.TimeCode + bg->Block.TimeCode)
|| rt + 5000000i64 < s.GetRefTime(c.TimeCode + bg->Block.TimeCode)) { // allow 500ms difference between tracks, just in case intreleaving wasn't that much precise
fPassedCueTime = true;
- } else if(bg->Block.TrackNumber == pCueTrackPositions->CueTrack && !bg->ReferenceBlock.IsValid()) {
+ } else if (bg->Block.TrackNumber == pCueTrackPositions->CueTrack && !bg->ReferenceBlock.IsValid()) {
fFoundKeyFrame = true;
m_pBlock = pBlock->Copy();
}
}
- } while(!fPassedCueTime && pBlock->NextBlock());
+ } while (!fPassedCueTime && pBlock->NextBlock());
}
}
- if(fFoundKeyFrame) {
+ if (fFoundKeyFrame) {
pos1 = pos2 = pos3 = NULL;
}
}
}
}
- if(!m_pBlock) {
+ if (!m_pBlock) {
m_pCluster = m_pSegment->Child(0x1F43B675);
}
}
@@ -1070,28 +1070,28 @@ bool CMatroskaSplitterFilter::DemuxLoop() Cluster c;
c.ParseTimeCode(m_pCluster);
- if(!m_pBlock) {
+ if (!m_pBlock) {
m_pBlock = m_pCluster->GetFirstBlock();
}
- if(!m_pBlock) {
+ if (!m_pBlock) {
continue;
}
do {
CBlockGroupNode bgn;
- if(m_pBlock->m_id == 0xA0) {
+ if (m_pBlock->m_id == 0xA0) {
bgn.Parse(m_pBlock, true);
- } else if(m_pBlock->m_id == 0xA3) {
+ } else if (m_pBlock->m_id == 0xA3) {
CAutoPtr<BlockGroup> bg(DNew BlockGroup());
bg->Block.Parse(m_pBlock, true);
- if(!(bg->Block.Lacing & 0x80)) {
+ if (!(bg->Block.Lacing & 0x80)) {
bg->ReferenceBlock.Set(0); // not a kf
}
bgn.AddTail(bg);
}
- while(bgn.GetCount() && SUCCEEDED(hr)) {
+ while (bgn.GetCount() && SUCCEEDED(hr)) {
CAutoPtr<MatroskaPacket> p(DNew MatroskaPacket());
p->bg = bgn.RemoveHead();
@@ -1108,13 +1108,13 @@ bool CMatroskaSplitterFilter::DemuxLoop() p->rtStop = p->rtStart + (p->bg->BlockDuration.IsValid() ? m_pFile->m_segment.GetRefTime(p->bg->BlockDuration) : 1);
// Fix subtitle with duration = 0
- if(pTE->TrackType == TrackEntry::TypeSubtitle && !p->bg->BlockDuration.IsValid()) {
+ if (pTE->TrackType == TrackEntry::TypeSubtitle && !p->bg->BlockDuration.IsValid()) {
p->bg->BlockDuration.Set(1); // just setting it to be valid
p->rtStop = p->rtStart;
}
POSITION pos = p->bg->Block.BlockData.GetHeadPosition();
- while(pos) {
+ while (pos) {
CBinary* pb = p->bg->Block.BlockData.GetNext(pos);
pTE->Expand(*pb, ContentEncoding::AllFrameContents);
}
@@ -1125,11 +1125,11 @@ bool CMatroskaSplitterFilter::DemuxLoop() hr = DeliverPacket(p);
}
- } while(m_pBlock->NextBlock() && SUCCEEDED(hr) && !CheckRequest(NULL));
+ } while (m_pBlock->NextBlock() && SUCCEEDED(hr) && !CheckRequest(NULL));
m_pBlock.Free();
- } while(m_pFile->GetPos() < (__int64)(m_pFile->m_segment.pos + m_pFile->m_segment.len)
- && m_pCluster->Next(true) && SUCCEEDED(hr) && !CheckRequest(NULL));
+ } while (m_pFile->GetPos() < (__int64)(m_pFile->m_segment.pos + m_pFile->m_segment.len)
+ && m_pCluster->Next(true) && SUCCEEDED(hr) && !CheckRequest(NULL));
m_pCluster.Free();
@@ -1140,7 +1140,7 @@ bool CMatroskaSplitterFilter::DemuxLoop() STDMETHODIMP CMatroskaSplitterFilter::GetKeyFrameCount(UINT& nKFs)
{
- if(!m_pFile) {
+ if (!m_pFile) {
return E_UNEXPECTED;
}
@@ -1149,7 +1149,7 @@ STDMETHODIMP CMatroskaSplitterFilter::GetKeyFrameCount(UINT& nKFs) nKFs = 0;
POSITION pos = m_pFile->m_segment.Cues.GetHeadPosition();
- while(pos) {
+ while (pos) {
nKFs += m_pFile->m_segment.Cues.GetNext(pos)->CuePoints.GetCount();
}
@@ -1161,21 +1161,21 @@ STDMETHODIMP CMatroskaSplitterFilter::GetKeyFrames(const GUID* pFormat, REFERENC CheckPointer(pFormat, E_POINTER);
CheckPointer(pKFs, E_POINTER);
- if(!m_pFile) {
+ if (!m_pFile) {
return E_UNEXPECTED;
}
- if(*pFormat != TIME_FORMAT_MEDIA_TIME) {
+ if (*pFormat != TIME_FORMAT_MEDIA_TIME) {
return E_INVALIDARG;
}
UINT nKFsTmp = 0;
POSITION pos1 = m_pFile->m_segment.Cues.GetHeadPosition();
- while(pos1 && nKFsTmp < nKFs) {
+ while (pos1 && nKFsTmp < nKFs) {
Cue* pCue = m_pFile->m_segment.Cues.GetNext(pos1);
POSITION pos2 = pCue->CuePoints.GetHeadPosition();
- while(pos2 && nKFsTmp < nKFs) {
+ while (pos2 && nKFsTmp < nKFs) {
pKFs[nKFsTmp++] = m_pFile->m_segment.GetRefTime(pCue->CuePoints.GetNext(pos2)->CueTime);
}
}
@@ -1231,11 +1231,11 @@ HRESULT CMatroskaSplitterOutputPin::DeliverEndOfStream() // send out the last remaining packets from the queue
- while(m_rob.GetCount()) {
+ while (m_rob.GetCount()) {
MatroskaPacket* mp = m_rob.RemoveHead();
- if(m_rob.GetCount() && !mp->bg->BlockDuration.IsValid()) {
+ if (m_rob.GetCount() && !mp->bg->BlockDuration.IsValid()) {
mp->rtStop = m_rob.GetHead()->rtStart;
- } else if(m_rob.GetCount() == 0 && m_rtDefaultDuration > 0) {
+ } else if (m_rob.GetCount() == 0 && m_rtDefaultDuration > 0) {
mp->rtStop = mp->rtStart + m_rtDefaultDuration;
}
@@ -1243,9 +1243,9 @@ HRESULT CMatroskaSplitterOutputPin::DeliverEndOfStream() m_tos.AddTail(to);
}
- while(m_packets.GetCount()) {
+ while (m_packets.GetCount()) {
HRESULT hr = DeliverBlock(m_packets.RemoveHead());
- if(hr != S_OK) {
+ if (hr != S_OK) {
return hr;
}
}
@@ -1256,7 +1256,7 @@ HRESULT CMatroskaSplitterOutputPin::DeliverEndOfStream() HRESULT CMatroskaSplitterOutputPin::DeliverPacket(CAutoPtr<Packet> p)
{
MatroskaPacket* mp = dynamic_cast<MatroskaPacket*>(p.m_p);
- if(!mp) {
+ if (!mp) {
return __super::DeliverPacket(p);
}
@@ -1271,11 +1271,11 @@ HRESULT CMatroskaSplitterOutputPin::DeliverPacket(CAutoPtr<Packet> p) POSITION pos = m_rob.GetTailPosition();
_ASSERTE(m_nMinCache > 0);
- for(int i = m_nMinCache - 1; i > 0 && pos && mp->bg->ReferencePriority < m_rob.GetAt(pos)->bg->ReferencePriority; --i) {
+ for (int i = m_nMinCache - 1; i > 0 && pos && mp->bg->ReferencePriority < m_rob.GetAt(pos)->bg->ReferencePriority; --i) {
m_rob.GetPrev(pos);
}
- if(!pos) {
+ if (!pos) {
m_rob.AddHead(mp);
} else {
m_rob.InsertAfter(pos, mp);
@@ -1283,15 +1283,15 @@ HRESULT CMatroskaSplitterOutputPin::DeliverPacket(CAutoPtr<Packet> p) mp = NULL;
- if(m_rob.GetCount() == m_nMinCache + 1) {
+ if (m_rob.GetCount() == m_nMinCache + 1) {
ASSERT(m_nMinCache > 0);
pos = m_rob.GetHeadPosition();
MatroskaPacket* mp1 = m_rob.GetNext(pos);
MatroskaPacket* mp2 = m_rob.GetNext(pos);
- if(!mp1->bg->BlockDuration.IsValid()) {
+ if (!mp1->bg->BlockDuration.IsValid()) {
mp1->bg->BlockDuration.Set(1); // just to set it valid
- if(mp1->rtStart >= mp2->rtStart) {
+ if (mp1->rtStart >= mp2->rtStart) {
/* CString str;
str.Format(_T("mp1->rtStart (%I64d) >= mp2->rtStart (%I64d)!!!\n"), mp1->rtStart, mp2->rtStart);
AfxMessageBox(str);
@@ -1303,9 +1303,9 @@ HRESULT CMatroskaSplitterOutputPin::DeliverPacket(CAutoPtr<Packet> p) }
}
- while(m_packets.GetCount()) {
+ while (m_packets.GetCount()) {
mp = m_packets.GetHead();
- if(!mp->bg->BlockDuration.IsValid()) {
+ if (!mp->bg->BlockDuration.IsValid()) {
break;
}
@@ -1314,7 +1314,7 @@ HRESULT CMatroskaSplitterOutputPin::DeliverPacket(CAutoPtr<Packet> p) m_tos.AddTail(to);
HRESULT hr = DeliverBlock(m_packets.RemoveHead());
- if(hr != S_OK) {
+ if (hr != S_OK) {
return hr;
}
}
@@ -1326,7 +1326,7 @@ HRESULT CMatroskaSplitterOutputPin::DeliverBlock(MatroskaPacket* p) {
HRESULT hr = S_FALSE;
- if(m_tos.GetCount()) {
+ if (m_tos.GetCount()) {
timeoverride to = m_tos.RemoveHead();
// if(p->TrackNumber == 2)
TRACE(_T("(track=%d) %I64d, %I64d -> %I64d, %I64d (buffcnt=%d)\n"),
@@ -1343,7 +1343,7 @@ HRESULT CMatroskaSplitterOutputPin::DeliverBlock(MatroskaPacket* p) rtStop = p->rtStart + rtDelta;
POSITION pos = p->bg->Block.BlockData.GetHeadPosition();
- while(pos) {
+ while (pos) {
CAutoPtr<Packet> tmp(DNew Packet());
tmp->TrackNumber = p->TrackNumber;
tmp->bDiscontinuity = p->bDiscontinuity;
@@ -1351,7 +1351,7 @@ HRESULT CMatroskaSplitterOutputPin::DeliverBlock(MatroskaPacket* p) tmp->rtStart = rtStart;
tmp->rtStop = rtStop;
tmp->Copy(*p->bg->Block.BlockData.GetNext(pos));
- if(S_OK != (hr = DeliverPacket(tmp))) {
+ if (S_OK != (hr = DeliverPacket(tmp))) {
break;
}
@@ -1362,9 +1362,9 @@ HRESULT CMatroskaSplitterOutputPin::DeliverBlock(MatroskaPacket* p) p->bDiscontinuity = false;
}
- if(m_mt.subtype == FOURCCMap(WAVE_FORMAT_WAVPACK4)) {
+ if (m_mt.subtype == FOURCCMap(WAVE_FORMAT_WAVPACK4)) {
POSITION pos = p->bg->ba.bm.GetHeadPosition();
- while(pos) {
+ while (pos) {
const BlockMore* bm = p->bg->ba.bm.GetNext(pos);
CAutoPtr<Packet> tmp(DNew Packet());
tmp->TrackNumber = p->TrackNumber;
@@ -1373,7 +1373,7 @@ HRESULT CMatroskaSplitterOutputPin::DeliverBlock(MatroskaPacket* p) tmp->rtStart = p->rtStart;
tmp->rtStop = p->rtStop;
tmp->Copy(bm->BlockAdditional);
- if(S_OK != (hr = DeliverPacket(tmp))) {
+ if (S_OK != (hr = DeliverPacket(tmp))) {
break;
}
}
@@ -1386,7 +1386,7 @@ HRESULT CMatroskaSplitterOutputPin::DeliverBlock(MatroskaPacket* p) TrackEntry* CMatroskaSplitterFilter::GetTrackEntryAt(UINT aTrackIdx)
{
- if(aTrackIdx < 0 || aTrackIdx >= m_pOrderedTrackArray.GetCount()) {
+ if (aTrackIdx < 0 || aTrackIdx >= m_pOrderedTrackArray.GetCount()) {
return NULL;
}
return m_pOrderedTrackArray[aTrackIdx];
@@ -1400,7 +1400,7 @@ STDMETHODIMP_(UINT) CMatroskaSplitterFilter::GetTrackCount() STDMETHODIMP_(BOOL) CMatroskaSplitterFilter::GetTrackInfo(UINT aTrackIdx, struct TrackElement* pStructureToFill)
{
TrackEntry* pTE = GetTrackEntryAt(aTrackIdx);
- if(pTE == NULL) {
+ if (pTE == NULL) {
return FALSE;
}
@@ -1408,7 +1408,7 @@ STDMETHODIMP_(BOOL) CMatroskaSplitterFilter::GetTrackInfo(UINT aTrackIdx, struct pStructureToFill->FlagForced = !!pTE->FlagForced;
pStructureToFill->FlagLacing = !!pTE->FlagLacing;
strncpy(pStructureToFill->Language, pTE->Language, 3);
- if(pStructureToFill->Language[0] == '\0') {
+ if (pStructureToFill->Language[0] == '\0') {
strncpy(pStructureToFill->Language, "eng", 3);
}
pStructureToFill->Language[3] = '\0';
@@ -1421,11 +1421,11 @@ STDMETHODIMP_(BOOL) CMatroskaSplitterFilter::GetTrackInfo(UINT aTrackIdx, struct STDMETHODIMP_(BOOL) CMatroskaSplitterFilter::GetTrackExtendedInfo(UINT aTrackIdx, void* pStructureToFill)
{
TrackEntry* pTE = GetTrackEntryAt(aTrackIdx);
- if(pTE == NULL) {
+ if (pTE == NULL) {
return FALSE;
}
- if(pTE->TrackType == TrackEntry::TypeVideo) {
+ if (pTE->TrackType == TrackEntry::TypeVideo) {
TrackExtendedInfoVideo* pTEIV = (TrackExtendedInfoVideo*)pStructureToFill;
pTEIV->AspectRatioType = (BYTE)pTE->v.AspectRatioType;
pTEIV->DisplayUnit = (BYTE)pTE->v.DisplayUnit;
@@ -1434,7 +1434,7 @@ STDMETHODIMP_(BOOL) CMatroskaSplitterFilter::GetTrackExtendedInfo(UINT aTrackIdx pTEIV->Interlaced = !!pTE->v.FlagInterlaced;
pTEIV->PixelWidth = (UINT)pTE->v.PixelWidth;
pTEIV->PixelHeight = (UINT)pTE->v.PixelHeight;
- } else if(pTE->TrackType == TrackEntry::TypeAudio) {
+ } else if (pTE->TrackType == TrackEntry::TypeAudio) {
TrackExtendedInfoAudio* pTEIA = (TrackExtendedInfoAudio*)pStructureToFill;
pTEIA->BitDepth = (UINT)pTE->a.BitDepth;
pTEIA->Channels = (UINT)pTE->a.Channels;
@@ -1450,7 +1450,7 @@ STDMETHODIMP_(BOOL) CMatroskaSplitterFilter::GetTrackExtendedInfo(UINT aTrackIdx STDMETHODIMP_(BSTR) CMatroskaSplitterFilter::GetTrackName(UINT aTrackIdx)
{
TrackEntry* pTE = GetTrackEntryAt(aTrackIdx);
- if(pTE == NULL) {
+ if (pTE == NULL) {
return NULL;
}
return pTE->Name.AllocSysString();
@@ -1459,7 +1459,7 @@ STDMETHODIMP_(BSTR) CMatroskaSplitterFilter::GetTrackName(UINT aTrackIdx) STDMETHODIMP_(BSTR) CMatroskaSplitterFilter::GetTrackCodecID(UINT aTrackIdx)
{
TrackEntry* pTE = GetTrackEntryAt(aTrackIdx);
- if(pTE == NULL) {
+ if (pTE == NULL) {
return NULL;
}
return pTE->CodecID.ToString().AllocSysString();
@@ -1468,7 +1468,7 @@ STDMETHODIMP_(BSTR) CMatroskaSplitterFilter::GetTrackCodecID(UINT aTrackIdx) STDMETHODIMP_(BSTR) CMatroskaSplitterFilter::GetTrackCodecName(UINT aTrackIdx)
{
TrackEntry* pTE = GetTrackEntryAt(aTrackIdx);
- if(pTE == NULL) {
+ if (pTE == NULL) {
return NULL;
}
return pTE->CodecName.AllocSysString();
@@ -1477,7 +1477,7 @@ STDMETHODIMP_(BSTR) CMatroskaSplitterFilter::GetTrackCodecName(UINT aTrackIdx) STDMETHODIMP_(BSTR) CMatroskaSplitterFilter::GetTrackCodecInfoURL(UINT aTrackIdx)
{
TrackEntry* pTE = GetTrackEntryAt(aTrackIdx);
- if(pTE == NULL) {
+ if (pTE == NULL) {
return NULL;
}
return pTE->CodecInfoURL.AllocSysString();
@@ -1486,7 +1486,7 @@ STDMETHODIMP_(BSTR) CMatroskaSplitterFilter::GetTrackCodecInfoURL(UINT aTrackIdx STDMETHODIMP_(BSTR) CMatroskaSplitterFilter::GetTrackCodecDownloadURL(UINT aTrackIdx)
{
TrackEntry* pTE = GetTrackEntryAt(aTrackIdx);
- if(pTE == NULL) {
+ if (pTE == NULL) {
return NULL;
}
return pTE->CodecDownloadURL.AllocSysString();
diff --git a/src/filters/parser/MatroskaSplitter/MatroskaSplitter.h b/src/filters/parser/MatroskaSplitter/MatroskaSplitter.h index 9913040cd..9fb03dd10 100644 --- a/src/filters/parser/MatroskaSplitter/MatroskaSplitter.h +++ b/src/filters/parser/MatroskaSplitter/MatroskaSplitter.h @@ -36,7 +36,7 @@ protected: int GetDataSize() {
int size = 0;
POSITION pos = bg->Block.BlockData.GetHeadPosition();
- while(pos) {
+ while (pos) {
size += bg->Block.BlockData.GetNext(pos)->GetCount();
}
return size;
diff --git a/src/filters/parser/MpaSplitter/MpaSplitter.cpp b/src/filters/parser/MpaSplitter/MpaSplitter.cpp index d30ad5a5f..37aca92f8 100644 --- a/src/filters/parser/MpaSplitter/MpaSplitter.cpp +++ b/src/filters/parser/MpaSplitter/MpaSplitter.cpp @@ -98,7 +98,7 @@ STDMETHODIMP CMpaSplitterFilter::QueryFilterInfo(FILTER_INFO* pInfo) wcscpy(pInfo->achName, MpaSourceName);
}
pInfo->pGraph = m_pGraph;
- if(m_pGraph) {
+ if (m_pGraph) {
m_pGraph->AddRef();
}
@@ -114,10 +114,10 @@ HRESULT CMpaSplitterFilter::CreateOutputs(IAsyncReader* pAsyncReader) m_pFile.Free();
m_pFile.Attach(DNew CMpaSplitterFile(pAsyncReader, hr));
- if(!m_pFile) {
+ if (!m_pFile) {
return E_OUTOFMEMORY;
}
- if(FAILED(hr)) {
+ if (FAILED(hr)) {
m_pFile.Free();
return hr;
}
@@ -132,22 +132,22 @@ HRESULT CMpaSplitterFilter::CreateOutputs(IAsyncReader* pAsyncReader) m_rtNewStop = m_rtStop = m_rtDuration = m_pFile->GetDuration();
CStringW str, title;
- if(m_pFile->m_tags.Lookup('TIT2', str)) {
+ if (m_pFile->m_tags.Lookup('TIT2', str)) {
title = str;
}
- if(m_pFile->m_tags.Lookup('TYER', str) && !title.IsEmpty() && !str.IsEmpty()) {
+ if (m_pFile->m_tags.Lookup('TYER', str) && !title.IsEmpty() && !str.IsEmpty()) {
title += L" (" + str + L")";
}
- if(!title.IsEmpty()) {
+ if (!title.IsEmpty()) {
SetProperty(L"TITL", title);
}
- if(m_pFile->m_tags.Lookup('TPE1', str)) {
+ if (m_pFile->m_tags.Lookup('TPE1', str)) {
SetProperty(L"AUTH", str);
}
- if(m_pFile->m_tags.Lookup('TCOP', str)) {
+ if (m_pFile->m_tags.Lookup('TCOP', str)) {
SetProperty(L"CPYR", str);
}
- if(m_pFile->m_tags.Lookup('COMM', str)) {
+ if (m_pFile->m_tags.Lookup('COMM', str)) {
SetProperty(L"DESC", str);
}
@@ -167,7 +167,7 @@ STDMETHODIMP CMpaSplitterFilter::GetDuration(LONGLONG* pDuration) bool CMpaSplitterFilter::DemuxInit()
{
SetThreadName((DWORD)-1, "CMpaSplitterFilter");
- if(!m_pFile) {
+ if (!m_pFile) {
return false;
}
@@ -181,7 +181,7 @@ void CMpaSplitterFilter::DemuxSeek(REFERENCE_TIME rt) __int64 startpos = m_pFile->GetStartPos();
__int64 endpos = m_pFile->GetEndPos();
- if(rt <= 0 || m_pFile->GetDuration() <= 0) {
+ if (rt <= 0 || m_pFile->GetDuration() <= 0) {
m_pFile->Seek(startpos);
m_rtStart = 0;
} else {
@@ -198,8 +198,8 @@ bool CMpaSplitterFilter::DemuxLoop() int FrameSize;
REFERENCE_TIME rtDuration;
- while(SUCCEEDED(hr) && !CheckRequest(NULL) && m_pFile->GetPos() < m_pFile->GetEndPos() - 9) {
- if(!m_pFile->Sync(FrameSize, rtDuration)) {
+ while (SUCCEEDED(hr) && !CheckRequest(NULL) && m_pFile->GetPos() < m_pFile->GetEndPos() - 9) {
+ if (!m_pFile->Sync(FrameSize, rtDuration)) {
Sleep(1);
continue;
}
diff --git a/src/filters/parser/MpaSplitter/MpaSplitterFile.cpp b/src/filters/parser/MpaSplitter/MpaSplitterFile.cpp index fddbc1737..f14a79221 100644 --- a/src/filters/parser/MpaSplitter/MpaSplitterFile.cpp +++ b/src/filters/parser/MpaSplitter/MpaSplitterFile.cpp @@ -82,7 +82,7 @@ CMpaSplitterFile::CMpaSplitterFile(IAsyncReader* pAsyncReader, HRESULT& hr) , m_totalbps(0)
, m_bIsVBR(false)
{
- if(SUCCEEDED(hr)) {
+ if (SUCCEEDED(hr)) {
hr = Init();
}
}
@@ -94,14 +94,14 @@ HRESULT CMpaSplitterFile::Init() Seek(0);
- if(BitRead(24, true) == 0x000001) {
+ if (BitRead(24, true) == 0x000001) {
return E_FAIL;
}
- if(m_endpos > 128 && IsRandomAccess()) {
+ if (m_endpos > 128 && IsRandomAccess()) {
Seek(m_endpos - 128);
- if(BitRead(24) == 'TAG') {
+ if (BitRead(24) == 'TAG') {
m_endpos -= 128;
CStringA str;
@@ -128,13 +128,13 @@ HRESULT CMpaSplitterFile::Init() // track
LPCSTR s = str;
- if(s[28] == 0 && s[29] != 0) {
+ if (s[28] == 0 && s[29] != 0) {
m_tags['TRCK'].Format(L"%d", s[29]);
}
// genre
BYTE genre = (BYTE)BitRead(8);
- if(genre < countof(s_genre)) {
+ if (genre < countof(s_genre)) {
m_tags['TCON'] = CStringW(s_genre[genre]);
}
}
@@ -144,7 +144,7 @@ HRESULT CMpaSplitterFile::Init() bool MP3_find = false;
- while(BitRead(24, true) == 'ID3') {
+ while (BitRead(24, true) == 'ID3') {
MP3_find = true;
BitRead(24);
@@ -156,19 +156,19 @@ HRESULT CMpaSplitterFile::Init() BYTE flags = (BYTE)BitRead(8);
UNUSED_ALWAYS(flags);
DWORD size = 0;
- if(BitRead(1) != 0) {
+ if (BitRead(1) != 0) {
return E_FAIL;
}
size |= BitRead(7) << 21;
- if(BitRead(1) != 0) {
+ if (BitRead(1) != 0) {
return E_FAIL;
}
size |= BitRead(7) << 14;
- if(BitRead(1) != 0) {
+ if (BitRead(1) != 0) {
return E_FAIL;
}
size |= BitRead(7) << 7;
- if(BitRead(1) != 0) {
+ if (BitRead(1) != 0) {
return E_FAIL;
}
size |= BitRead(7);
@@ -177,10 +177,10 @@ HRESULT CMpaSplitterFile::Init() // TODO: read extended header
- if(major <= 4) {
+ if (major <= 4) {
__int64 pos = GetPos();
- while(pos < m_startpos) {
+ while (pos < m_startpos) {
Seek(pos);
DWORD tag = (DWORD)BitRead(32);
@@ -194,11 +194,11 @@ HRESULT CMpaSplitterFile::Init() pos += 4+4+2+size;
- if(!size || pos >= m_startpos) {
+ if (!size || pos >= m_startpos) {
break;
}
- if(tag == 'TIT2'
+ if (tag == 'TIT2'
|| tag == 'TPE1'
|| tag == 'TALB'
|| tag == 'TYER'
@@ -212,16 +212,16 @@ HRESULT CMpaSplitterFile::Init() CStringA str;
CStringW wstr;
- if(encoding > 0 && size >= 2 && bom == 0xfffe) {
+ if (encoding > 0 && size >= 2 && bom == 0xfffe) {
BitRead(16);
size = (size - 2) / 2;
ByteRead((BYTE*)wstr.GetBufferSetLength(size), size*2);
m_tags[tag] = wstr.Trim();
- } else if(encoding > 0 && size >= 2 && bom == 0xfeff) {
+ } else if (encoding > 0 && size >= 2 && bom == 0xfeff) {
BitRead(16);
size = (size - 2) / 2;
ByteRead((BYTE*)wstr.GetBufferSetLength(size), size*2);
- for(int i = 0, j = wstr.GetLength(); i < j; i++) {
+ for (int i = 0, j = wstr.GetLength(); i < j; i++) {
wstr.SetAt(i, (wstr[i]<<8)|(wstr[i]>>8));
}
m_tags[tag] = wstr.Trim();
@@ -235,7 +235,7 @@ HRESULT CMpaSplitterFile::Init() Seek(m_startpos);
- for(int i = 0; i < (1<<20) && m_startpos < m_endpos && BitRead(8, true) == 0; i++) {
+ for (int i = 0; i < (1<<20) && m_startpos < m_endpos && BitRead(8, true) == 0; i++) {
BitRead(8), m_startpos++;
}
}
@@ -244,16 +244,16 @@ HRESULT CMpaSplitterFile::Init() __int64 startpos;
__int64 syncpos;
-
- if(!MP3_find) { // if no 'ID3' tag at begin of file
+
+ if (!MP3_find) { // if no 'ID3' tag at begin of file
Seek(m_startpos);
searchlen = min(m_endpos - m_startpos, 4);
- if(Read(m_mpahdr, searchlen, true, &m_mt)) {
+ if (Read(m_mpahdr, searchlen, true, &m_mt)) {
MP3_find = true;
}
}
- if(MP3_find) {
+ if (MP3_find) {
__int64 startpos_mp3 = m_startpos;
while (m_mode == none) {
searchlen = min(m_endpos - startpos_mp3, 0x200);
@@ -263,7 +263,7 @@ HRESULT CMpaSplitterFile::Init() syncpos = startpos_mp3 + searchlen;
// Check for a valid MPA header
- if(Read(m_mpahdr, searchlen, true, &m_mt)) {
+ if (Read(m_mpahdr, searchlen, true, &m_mt)) {
m_mode = mpa;
syncpos = GetPos();
@@ -271,7 +271,7 @@ HRESULT CMpaSplitterFile::Init() // make sure the first frame is followed by another of the same kind (validates m_mpahdr basically)
Seek(startpos + m_mpahdr.FrameSize);
- if(!Sync(4)) {
+ if (!Sync(4)) {
m_mode = none;
} else {
break;
@@ -290,37 +290,37 @@ HRESULT CMpaSplitterFile::Init() searchlen = min(m_endpos - m_startpos, m_startpos > 0 ? 0x200 : 7);
Seek(m_startpos);
- if(m_mode == none && Read(m_aachdr, searchlen, &m_mt)) {
+ if (m_mode == none && Read(m_aachdr, searchlen, &m_mt)) {
m_mode = mp4a;
startpos = GetPos() - (m_aachdr.fcrc?7:9);
// make sure the first frame is followed by another of the same kind (validates m_aachdr basically)
Seek(startpos + m_aachdr.aac_frame_length);
- if(!Sync(9)) {
+ if (!Sync(9)) {
m_mode = none;
}
}
- if(m_mode == none) {
+ if (m_mode == none) {
return E_FAIL;
}
m_startpos = startpos;
- if(m_mode == mpa) {
+ if (m_mode == mpa) {
DWORD m_dwFrames = 0; // total number of frames
Seek(m_startpos + MPA_HEADER_SIZE + 32);
- if(BitRead(32, true) == 'Xing' || BitRead(32, true) == 'Info') {
+ if (BitRead(32, true) == 'Xing' || BitRead(32, true) == 'Info') {
TRACE(_T("CMpaSplitterFile - Xing VBR header found\n"));
BitRead(32); // Skip ID tag
DWORD dwFlags = BitRead(32);
// extract total number of frames in file
- if(dwFlags & FRAMES_FLAG)
+ if (dwFlags & FRAMES_FLAG)
m_dwFrames = BitRead(32);
- } else if(BitRead(32, true) == 'VBRI') {
+ } else if (BitRead(32, true) == 'VBRI') {
TRACE(_T("CMpaSplitterFile - VBRI header found\n"));
BitRead(32); // Skip ID tag
@@ -332,8 +332,8 @@ HRESULT CMpaSplitterFile::Init() m_dwFrames = BitRead(32); // extract total number of frames in file
}
- if(m_dwFrames) {
-
+ if (m_dwFrames) {
+
bool l3ext = m_mpahdr.layer == 3 && !(m_mpahdr.version&1);
DWORD m_dwSamplesPerFrame = m_mpahdr.layer == 1 ? 384 : l3ext ? 576 : 1152;
@@ -348,11 +348,11 @@ HRESULT CMpaSplitterFile::Init() REFERENCE_TIME rtFrameDur, rtPrevDur = -1;
clock_t start = clock();
int i = 0;
- while(Sync(FrameSize, rtFrameDur) && (clock() - start) < CLOCKS_PER_SEC) {
+ while (Sync(FrameSize, rtFrameDur) && (clock() - start) < CLOCKS_PER_SEC) {
TRACE(_T("%I64d\n"), m_rtDuration);
Seek(GetPos() + FrameSize);
i = rtPrevDur == m_rtDuration ? i+1 : 0;
- if(i == 10) {
+ if (i == 10) {
break;
}
rtPrevDur = m_rtDuration;
@@ -372,11 +372,11 @@ bool CMpaSplitterFile::Sync(int& FrameSize, REFERENCE_TIME& rtDuration, int limi {
__int64 endpos = min(m_endpos, GetPos() + limit);
- if(m_mode == mpa) {
- while(GetPos() <= endpos - 4) {
+ if (m_mode == mpa) {
+ while (GetPos() <= endpos - 4) {
mpahdr h;
- if(Read(h, endpos - GetPos(), true)) {
+ if (Read(h, endpos - GetPos(), true)) {
if (m_mpahdr.version == h.version
&& m_mpahdr.layer == h.layer
&& m_mpahdr.channels == h.channels) {
@@ -392,11 +392,11 @@ bool CMpaSplitterFile::Sync(int& FrameSize, REFERENCE_TIME& rtDuration, int limi break;
}
}
- } else if(m_mode == mp4a) {
- while(GetPos() <= endpos - 9) {
+ } else if (m_mode == mp4a) {
+ while (GetPos() <= endpos - 9) {
aachdr h;
- if(Read(h, endpos - GetPos())) {
+ if (Read(h, endpos - GetPos())) {
if (m_aachdr.version == h.version
&& m_aachdr.layer == h.layer
&& m_aachdr.channels == h.channels) {
@@ -422,11 +422,11 @@ void CMpaSplitterFile::AdjustDuration(int nBytesPerSec) {
ASSERT(nBytesPerSec);
- if(!m_bIsVBR) {
+ if (!m_bIsVBR) {
int rValue;
- if(!m_pos2bps.Lookup(GetPos(), rValue)) {
+ if (!m_pos2bps.Lookup(GetPos(), rValue)) {
m_totalbps += nBytesPerSec;
- if(!m_totalbps) {
+ if (!m_totalbps) {
return;
}
m_pos2bps.SetAt(GetPos(), nBytesPerSec);
diff --git a/src/filters/parser/MpegSplitter/MpegSplitter.cpp b/src/filters/parser/MpegSplitter/MpegSplitter.cpp index a7d6562cd..a3687b505 100644 --- a/src/filters/parser/MpegSplitter/MpegSplitter.cpp +++ b/src/filters/parser/MpegSplitter/MpegSplitter.cpp @@ -31,34 +31,34 @@ TCHAR* MPEG2_Profile[]=
{
- L"0",
- L"High Profile",
- L"Spatially Scalable Profile",
- L"SNR Scalable Profile",
- L"Main Profile",
- L"Simple Profile",
- L"6",
- L"7",
+ L"0",
+ L"High Profile",
+ L"Spatially Scalable Profile",
+ L"SNR Scalable Profile",
+ L"Main Profile",
+ L"Simple Profile",
+ L"6",
+ L"7",
};
TCHAR* MPEG2_Level[]=
{
- L"0",
- L"1",
- L"2",
- L"3",
- L"High Level",
- L"4",
- L"High1440 Level",
- L"5",
- L"Main Level",
- L"6",
- L"Low Level",
- L"7",
- L"8",
- L"9",
- L"10",
- L"11",
+ L"0",
+ L"1",
+ L"2",
+ L"3",
+ L"High Level",
+ L"4",
+ L"High1440 Level",
+ L"5",
+ L"Main Level",
+ L"6",
+ L"Low Level",
+ L"7",
+ L"8",
+ L"9",
+ L"10",
+ L"11",
};
#ifdef REGISTER_FILTER
@@ -229,10 +229,9 @@ CString GetMediaTypeDesc(const CMediaType *_pMediaType, const CHdmvClipInfo::Str Infos.AddTail(Temp);
}
- if(bIsMPEG2) {
+ if (bIsMPEG2) {
Infos.AddTail(MPEG2_Profile[pInfo->dwProfile]);
- } else
- if (pInfo->dwProfile) {
+ } else if (pInfo->dwProfile) {
if (bIsAVC) {
switch (pInfo->dwProfile) {
case 44:
@@ -274,10 +273,9 @@ CString GetMediaTypeDesc(const CMediaType *_pMediaType, const CHdmvClipInfo::Str }
}
- if(bIsMPEG2) {
+ if (bIsMPEG2) {
Infos.AddTail(MPEG2_Level[pInfo->dwLevel]);
- } else
- if (pInfo->dwLevel) {
+ } else if (pInfo->dwLevel) {
if (bIsAVC) {
Infos.AddTail(FormatString(L"Level %1.1f", double(pInfo->dwLevel)/10.0));
} else {
@@ -465,7 +463,7 @@ CString GetMediaTypeDesc(const CMediaType *_pMediaType, const CHdmvClipInfo::Str bool bFirst = true;
- for(POSITION pos = Infos.GetHeadPosition(); pos; Infos.GetNext(pos)) {
+ for (POSITION pos = Infos.GetHeadPosition(); pos; Infos.GetNext(pos)) {
CString& String = Infos.GetAt(pos);
if (bFirst) {
@@ -503,38 +501,38 @@ CMpegSplitterFilter::CMpegSplitterFilter(LPUNKNOWN pUnk, HRESULT* phr, const CLS TCHAR buff[256];
ULONG len;
- if(ERROR_SUCCESS == key.Open(HKEY_CURRENT_USER, _T("Software\\Gabest\\Filters\\MPEG Splitter"), KEY_READ)) {
+ if (ERROR_SUCCESS == key.Open(HKEY_CURRENT_USER, _T("Software\\Gabest\\Filters\\MPEG Splitter"), KEY_READ)) {
DWORD dw;
- if(ERROR_SUCCESS == key.QueryDWORDValue(_T("UseFastStreamChange"), dw)) {
+ if (ERROR_SUCCESS == key.QueryDWORDValue(_T("UseFastStreamChange"), dw)) {
m_useFastStreamChange = !!dw;
}
- if(ERROR_SUCCESS == key.QueryDWORDValue(_T("ForcedSub"), dw)) {
+ if (ERROR_SUCCESS == key.QueryDWORDValue(_T("ForcedSub"), dw)) {
m_ForcedSub = !!dw;
}
- if(ERROR_SUCCESS == key.QueryDWORDValue(_T("TrackPriority"), dw)) {
+ if (ERROR_SUCCESS == key.QueryDWORDValue(_T("TrackPriority"), dw)) {
m_TrackPriority = !!dw;
}
len = sizeof(buff)/sizeof(buff[0]);
memset(buff, 0, sizeof(buff));
- if(ERROR_SUCCESS == key.QueryStringValue(_T("AudioLanguageOrder"), buff, &len)) {
- m_csAudioLanguageOrder = CString(buff);
+ if (ERROR_SUCCESS == key.QueryStringValue(_T("AudioLanguageOrder"), buff, &len)) {
+ m_csAudioLanguageOrder = CString(buff);
}
len = sizeof(buff)/sizeof(buff[0]);
memset(buff, 0, sizeof(buff));
- if(ERROR_SUCCESS == key.QueryStringValue(_T("SubtitlesLanguageOrder"), buff, &len)) {
- m_csSubtitlesLanguageOrder = CString(buff);
+ if (ERROR_SUCCESS == key.QueryStringValue(_T("SubtitlesLanguageOrder"), buff, &len)) {
+ m_csSubtitlesLanguageOrder = CString(buff);
}
- if(ERROR_SUCCESS == key.QueryDWORDValue(_T("VC1_Decoder_Output"), dw)) {
+ if (ERROR_SUCCESS == key.QueryDWORDValue(_T("VC1_Decoder_Output"), dw)) {
m_nVC1_GuidFlag = dw;
}
- if(ERROR_SUCCESS == key.QueryDWORDValue(_T("AC3CoreOnly"), dw)) {
+ if (ERROR_SUCCESS == key.QueryDWORDValue(_T("AC3CoreOnly"), dw)) {
m_AC3CoreOnly = dw;
}
}
@@ -545,7 +543,7 @@ CMpegSplitterFilter::CMpegSplitterFilter(LPUNKNOWN pUnk, HRESULT* phr, const CLS m_csSubtitlesLanguageOrder = AfxGetApp()->GetProfileString(IDS_R_SETTINGS, IDS_RS_SUBTITLESLANGORDER, _T(""));
m_csAudioLanguageOrder = AfxGetApp()->GetProfileString(IDS_R_SETTINGS, IDS_RS_AUDIOSLANGORDER, _T(""));
m_nVC1_GuidFlag = AfxGetApp()->GetProfileInt(_T("Filters\\MPEG Splitter"), _T("VC1_Decoder_Output"), m_nVC1_GuidFlag);
- if(m_nVC1_GuidFlag<1 || m_nVC1_GuidFlag>3) m_nVC1_GuidFlag = 1;
+ if (m_nVC1_GuidFlag<1 || m_nVC1_GuidFlag>3) m_nVC1_GuidFlag = 1;
m_AC3CoreOnly = AfxGetApp()->GetProfileInt(_T("Filters\\MPEG Splitter"), _T("AC3CoreOnly"), m_AC3CoreOnly);
#endif
}
@@ -594,7 +592,7 @@ STDMETHODIMP CMpegSplitterFilter::QueryFilterInfo(FILTER_INFO* pInfo) wcscpy(pInfo->achName, MpegSourceName);
}
pInfo->pGraph = m_pGraph;
- if(m_pGraph) {
+ if (m_pGraph) {
m_pGraph->AddRef();
}
@@ -643,35 +641,35 @@ HRESULT CMpegSplitterFilter::DemuxNextPacket(REFERENCE_TIME rtStartOffset) HRESULT hr;
BYTE b;
- if(m_pFile->m_type == CMpegSplitterFile::ps || m_pFile->m_type == CMpegSplitterFile::es) {
- if(!m_pFile->NextMpegStartCode(b)) {
+ if (m_pFile->m_type == CMpegSplitterFile::ps || m_pFile->m_type == CMpegSplitterFile::es) {
+ if (!m_pFile->NextMpegStartCode(b)) {
return S_FALSE;
}
- if(b == 0xba) { // program stream header
+ if (b == 0xba) { // program stream header
CMpegSplitterFile::pshdr h;
- if(!m_pFile->Read(h)) {
+ if (!m_pFile->Read(h)) {
return S_FALSE;
}
- } else if(b == 0xbb) { // program stream system header
+ } else if (b == 0xbb) { // program stream system header
CMpegSplitterFile::pssyshdr h;
- if(!m_pFile->Read(h)) {
+ if (!m_pFile->Read(h)) {
return S_FALSE;
}
}
#if (EVO_SUPPORT == 0)
- else if(b >= 0xbd && b < 0xf0) // pes packet
+ else if (b >= 0xbd && b < 0xf0) // pes packet
#else
- else if((b >= 0xbd && b < 0xf0) || (b == 0xfd)) // pes packet
+ else if ((b >= 0xbd && b < 0xf0) || (b == 0xfd)) // pes packet
#endif
{
CMpegSplitterFile::peshdr h;
- if(!m_pFile->Read(h, b) || !h.len) {
+ if (!m_pFile->Read(h, b) || !h.len) {
return S_FALSE;
}
- if(h.type == CMpegSplitterFile::mpeg2 && h.scrambling) {
+ if (h.type == CMpegSplitterFile::mpeg2 && h.scrambling) {
ASSERT(0);
return E_FAIL;
}
@@ -680,7 +678,7 @@ HRESULT CMpegSplitterFilter::DemuxNextPacket(REFERENCE_TIME rtStartOffset) DWORD TrackNumber = m_pFile->AddStream(0, b, h.len);
- if(GetOutputPin(TrackNumber)) {
+ if (GetOutputPin(TrackNumber)) {
CAutoPtr<Packet> p(DNew Packet());
p->TrackNumber = TrackNumber;
@@ -696,10 +694,10 @@ HRESULT CMpegSplitterFilter::DemuxNextPacket(REFERENCE_TIME rtStartOffset) }
m_pFile->Seek(pos + h.len);
}
- } else if(m_pFile->m_type == CMpegSplitterFile::ts) {
+ } else if (m_pFile->m_type == CMpegSplitterFile::ts) {
CMpegSplitterFile::trhdr h;
- if(!m_pFile->Read(h)) {
+ if (!m_pFile->Read(h)) {
return S_FALSE;
}
@@ -708,20 +706,20 @@ HRESULT CMpegSplitterFilter::DemuxNextPacket(REFERENCE_TIME rtStartOffset) m_pFile->UpdatePrograms(h, false);
- if(h.payload && ISVALIDPID(h.pid)) {
+ if (h.payload && ISVALIDPID(h.pid)) {
DWORD TrackNumber = h.pid;
CMpegSplitterFile::peshdr h2;
- if(h.payloadstart && m_pFile->NextMpegStartCode(b, 4) && m_pFile->Read(h2, b)) { // pes packet
- if(h2.type == CMpegSplitterFile::mpeg2 && h2.scrambling) {
+ if (h.payloadstart && m_pFile->NextMpegStartCode(b, 4) && m_pFile->Read(h2, b)) { // pes packet
+ if (h2.type == CMpegSplitterFile::mpeg2 && h2.scrambling) {
ASSERT(0);
return E_FAIL;
}
TrackNumber = m_pFile->AddStream(h.pid, b, h.bytes - (DWORD)(m_pFile->GetPos() - pos));
}
- if(GetOutputPin(TrackNumber)) {
+ if (GetOutputPin(TrackNumber)) {
CAutoPtr<Packet> p(DNew Packet());
p->TrackNumber = TrackNumber;
@@ -746,9 +744,9 @@ HRESULT CMpegSplitterFilter::DemuxNextPacket(REFERENCE_TIME rtStartOffset) }
m_pFile->Seek(h.next);
- } else if(m_pFile->m_type == CMpegSplitterFile::pva) {
+ } else if (m_pFile->m_type == CMpegSplitterFile::pva) {
CMpegSplitterFile::pvahdr h;
- if(!m_pFile->Read(h)) {
+ if (!m_pFile->Read(h)) {
return S_FALSE;
}
@@ -756,7 +754,7 @@ HRESULT CMpegSplitterFilter::DemuxNextPacket(REFERENCE_TIME rtStartOffset) __int64 pos = m_pFile->GetPos();
- if(GetOutputPin(TrackNumber)) {
+ if (GetOutputPin(TrackNumber)) {
CAutoPtr<Packet> p(DNew Packet());
p->TrackNumber = TrackNumber;
@@ -789,17 +787,17 @@ HRESULT CMpegSplitterFilter::CreateOutputs(IAsyncReader* pAsyncReader) ReadClipInfo (GetPartFilename(pAsyncReader));
m_pFile.Attach(DNew CMpegSplitterFile(pAsyncReader, hr, m_ClipInfo.IsHdmv(), m_ClipInfo, m_nVC1_GuidFlag, m_ForcedSub, m_TrackPriority, m_AC3CoreOnly));
- if(!m_pFile) {
+ if (!m_pFile) {
return E_OUTOFMEMORY;
}
- if(FAILED(hr)) {
+ if (FAILED(hr)) {
m_pFile.Free();
return hr;
}
- if(m_pFile->m_type == CMpegSplitterFile::ps) {
- if(m_pInput && m_pInput->IsConnected() && (GetCLSID(m_pInput->GetConnected()) == GUIDFromCString(_T("{773EAEDE-D5EE-4fce-9C8F-C4F53D0A2F73}")))){ // MPC VTS Reader
+ if (m_pFile->m_type == CMpegSplitterFile::ps) {
+ if (m_pInput && m_pInput->IsConnected() && (GetCLSID(m_pInput->GetConnected()) == GUIDFromCString(_T("{773EAEDE-D5EE-4fce-9C8F-C4F53D0A2F73}")))) { // MPC VTS Reader
pTI = GetFilterFromPin(m_pInput->GetConnected());
}
}
@@ -823,29 +821,29 @@ HRESULT CMpegSplitterFilter::CreateOutputs(IAsyncReader* pAsyncReader) int Idx_audio = 99;
int Idx_subpic = 99;
- if(!m_csAudioLanguageOrder.IsEmpty()) {
+ if (!m_csAudioLanguageOrder.IsEmpty()) {
int tPos = 0;
lang = m_csAudioLanguageOrder.Tokenize(_T(",; "), tPos);
- while(tPos != -1) {
- if(!lang.IsEmpty()) lang_list_audio.AddTail(lang);
+ while (tPos != -1) {
+ if (!lang.IsEmpty()) lang_list_audio.AddTail(lang);
lang = m_csAudioLanguageOrder.Tokenize(_T(",; "), tPos);
}
- if(!lang.IsEmpty()) lang_list_audio.AddTail(lang);
+ if (!lang.IsEmpty()) lang_list_audio.AddTail(lang);
}
- if(!m_csSubtitlesLanguageOrder.IsEmpty()) {
+ if (!m_csSubtitlesLanguageOrder.IsEmpty()) {
int tPos = 0;
lang = m_csSubtitlesLanguageOrder.Tokenize(_T(",; "), tPos);
- while(tPos != -1) {
- if(!lang.IsEmpty()) lang_list_subpic.AddTail(lang);
+ while (tPos != -1) {
+ if (!lang.IsEmpty()) lang_list_subpic.AddTail(lang);
lang = m_csSubtitlesLanguageOrder.Tokenize(_T(",; "), tPos);
}
- if(!lang.IsEmpty()) lang_list_subpic.AddTail(lang);
+ if (!lang.IsEmpty()) lang_list_subpic.AddTail(lang);
}
- for(int i = 0; i < countof(m_pFile->m_streams); i++) {
+ for (int i = 0; i < countof(m_pFile->m_streams); i++) {
POSITION pos = m_pFile->m_streams[i].GetHeadPosition();
- while(pos) {
+ while (pos) {
CMpegSplitterFile::stream& s = m_pFile->m_streams[i].GetNext(pos);
CAtlArray<CMediaType> mts;
mts.Add(s.mt);
@@ -866,7 +864,7 @@ HRESULT CMpegSplitterFilter::CreateOutputs(IAsyncReader* pAsyncReader) CString lang_name = _T("");
m_pFile->m_pPMT_Lang.Lookup(s.pid, lang_name);
-
+
lang_name = pTI ? pTI->GetTrackName(s.ps1id) : lang_name;
CString FormatDesc = GetMediaTypeDesc(&s.mt, pClipInfo, StreamType, lang_name);
@@ -881,15 +879,15 @@ HRESULT CMpegSplitterFilter::CreateOutputs(IAsyncReader* pAsyncReader) }
CString str_tmp = str;
str_tmp.MakeLower();
- if(i == CMpegSplitterFile::audio) {
- if(lang_list_audio.GetCount()>0) {
+ if (i == CMpegSplitterFile::audio) {
+ if (lang_list_audio.GetCount()>0) {
int idx = 0;
POSITION pos = lang_list_audio.GetHeadPosition();
- while(pos) {
+ while (pos) {
lang = lang_list_audio.GetNext(pos).MakeLower();
- if(-1 != str_tmp.Find(lang)) {
- if(idx<Idx_audio) {
- cs_audioProgram = str;
+ if (-1 != str_tmp.Find(lang)) {
+ if (idx<Idx_audio) {
+ cs_audioProgram = str;
Idx_audio = idx;
break;
}
@@ -897,16 +895,16 @@ HRESULT CMpegSplitterFilter::CreateOutputs(IAsyncReader* pAsyncReader) idx++;
}
}
- if(!Idx_audio && !cs_audioProgram.IsEmpty()) break;
+ if (!Idx_audio && !cs_audioProgram.IsEmpty()) break;
}
- if(i == CMpegSplitterFile::subpic) {
- if(lang_list_subpic.GetCount()>0) {
+ if (i == CMpegSplitterFile::subpic) {
+ if (lang_list_subpic.GetCount()>0) {
int idx = 0;
POSITION pos = lang_list_subpic.GetHeadPosition();
- while(pos) {
+ while (pos) {
lang = lang_list_subpic.GetNext(pos).MakeLower();
- if(-1 != str_tmp.Find(lang)) {
- if(idx<Idx_subpic) {
+ if (-1 != str_tmp.Find(lang)) {
+ if (idx<Idx_subpic) {
cs_subpicProgram = str;
Idx_subpic = idx;
break;
@@ -915,7 +913,7 @@ HRESULT CMpegSplitterFilter::CreateOutputs(IAsyncReader* pAsyncReader) idx++;
}
}
- if(!Idx_subpic && !cs_subpicProgram.IsEmpty()) break;
+ if (!Idx_subpic && !cs_subpicProgram.IsEmpty()) break;
}
}
}
@@ -923,9 +921,9 @@ HRESULT CMpegSplitterFilter::CreateOutputs(IAsyncReader* pAsyncReader) m_rtNewStart = m_rtCurrent = 0;
m_rtNewStop = m_rtStop = m_rtDuration = 0;
- for(int i = 0; i < countof(m_pFile->m_streams); i++) {
+ for (int i = 0; i < countof(m_pFile->m_streams); i++) {
POSITION pos = m_pFile->m_streams[i].GetHeadPosition();
- while(pos) {
+ while (pos) {
CMpegSplitterFile::stream& s = m_pFile->m_streams[i].GetNext(pos);
CAtlArray<CMediaType> mts;
mts.Add(s.mt);
@@ -949,7 +947,7 @@ HRESULT CMpegSplitterFilter::CreateOutputs(IAsyncReader* pAsyncReader) lang_name = pTI ? pTI->GetTrackName(s.ps1id) : lang_name;
CString FormatDesc = GetMediaTypeDesc(&s.mt, pClipInfo, StreamType, lang_name);
-
+
if (!FormatDesc.IsEmpty()) {
str.Format(L"%s (%04x,%02x,%02x)", FormatDesc.GetString(), s.pid, s.pesid, s.ps1id); // TODO: make this nicer
} else if (pStreamName) {
@@ -964,41 +962,40 @@ HRESULT CMpegSplitterFilter::CreateOutputs(IAsyncReader* pAsyncReader) (static_cast<CMpegSplitterOutputPin*>(pPinOut.m_p))->SetMaxShift (_I64_MAX);
}
- if(i == CMpegSplitterFile::audio) {
- if(!cs_audioProgram.IsEmpty()) {
- if((!cs_audioProgram.Compare(str)) && (S_OK == AddOutputPin(s, pPinOut))) {
+ if (i == CMpegSplitterFile::audio) {
+ if (!cs_audioProgram.IsEmpty()) {
+ if ((!cs_audioProgram.Compare(str)) && (S_OK == AddOutputPin(s, pPinOut))) {
break;
}
} else {
- if(S_OK == AddOutputPin(s, pPinOut)) {
+ if (S_OK == AddOutputPin(s, pPinOut)) {
break;
}
}
}
- else
- if(i == CMpegSplitterFile::subpic) {
- if(!cs_subpicProgram.IsEmpty()) {
- if((!cs_subpicProgram.Compare(str)) && (S_OK == AddOutputPin(s, pPinOut))) {
+ else if (i == CMpegSplitterFile::subpic) {
+ if (!cs_subpicProgram.IsEmpty()) {
+ if ((!cs_subpicProgram.Compare(str)) && (S_OK == AddOutputPin(s, pPinOut))) {
break;
}
} else {
- if((m_pFile->m_streams[CMpegSplitterFile::subpic].GetCount() == 1) && (S_OK == AddOutputPin(s, pPinOut))) {
+ if ((m_pFile->m_streams[CMpegSplitterFile::subpic].GetCount() == 1) && (S_OK == AddOutputPin(s, pPinOut))) {
break;
- } else if((s.pid != NO_SUBTITLE_PID) && (S_OK == AddOutputPin(s, pPinOut))) {
+ } else if ((s.pid != NO_SUBTITLE_PID) && (S_OK == AddOutputPin(s, pPinOut))) {
break;
}
}
} else {
- if(S_OK == AddOutputPin(s, pPinOut)) {
+ if (S_OK == AddOutputPin(s, pPinOut)) {
break;
}
}
}
}
- if(m_rtPlaylistDuration) {
+ if (m_rtPlaylistDuration) {
m_rtNewStop = m_rtStop = m_rtDuration = m_rtPlaylistDuration;
- } else if(m_pFile->IsRandomAccess() && m_pFile->m_rate) {
+ } else if (m_pFile->IsRandomAccess() && m_pFile->m_rate) {
m_rtNewStop = m_rtStop = m_rtDuration = 10000000i64 * m_pFile->GetLength() / m_pFile->m_rate;
}
@@ -1008,7 +1005,7 @@ HRESULT CMpegSplitterFilter::CreateOutputs(IAsyncReader* pAsyncReader) bool CMpegSplitterFilter::DemuxInit()
{
SetThreadName((DWORD)-1, "CMpegSplitterFilter");
- if(!m_pFile) {
+ if (!m_pFile) {
return false;
}
@@ -1021,12 +1018,12 @@ void CMpegSplitterFilter::DemuxSeek(REFERENCE_TIME rt) {
CAtlList<CMpegSplitterFile::stream>* pMasterStream = m_pFile->GetMasterStream();
- if(!pMasterStream) {
+ if (!pMasterStream) {
ASSERT(0);
return;
}
- if(m_pFile->IsStreaming()) {
+ if (m_pFile->IsStreaming()) {
m_pFile->Seek(max(0, m_pFile->GetLength() - 100*1024));
m_rtStartOffset = m_pFile->m_rtMin + m_pFile->NextPTS(pMasterStream->GetHead());
return;
@@ -1034,7 +1031,7 @@ void CMpegSplitterFilter::DemuxSeek(REFERENCE_TIME rt) REFERENCE_TIME rtPreroll = 10000000;
- if(rt <= rtPreroll || m_rtDuration <= 0) {
+ if (rt <= rtPreroll || m_rtDuration <= 0) {
m_pFile->Seek(0);
} else {
__int64 len = m_pFile->GetLength();
@@ -1044,33 +1041,33 @@ void CMpegSplitterFilter::DemuxSeek(REFERENCE_TIME rt) REFERENCE_TIME rtmax = rt - rtPreroll;
REFERENCE_TIME rtmin = rtmax - 5000000;
- if(m_rtStartOffset == 0)
- for(int i = 0; i < countof(m_pFile->m_streams)-1; i++) {
+ if (m_rtStartOffset == 0)
+ for (int i = 0; i < countof(m_pFile->m_streams)-1; i++) {
POSITION pos = m_pFile->m_streams[i].GetHeadPosition();
- while(pos) {
+ while (pos) {
DWORD TrackNum = m_pFile->m_streams[i].GetNext(pos);
CBaseSplitterOutputPin* pPin = GetOutputPin(TrackNum);
- if(pPin && pPin->IsConnected()) {
+ if (pPin && pPin->IsConnected()) {
m_pFile->Seek(seekpos);
__int64 curpos = seekpos;
REFERENCE_TIME pdt = _I64_MIN;
- for(int j = 0; j < 10; j++) {
+ for (int j = 0; j < 10; j++) {
REFERENCE_TIME rt = m_pFile->NextPTS(TrackNum);
- if(rt < 0) {
+ if (rt < 0) {
break;
}
REFERENCE_TIME dt = rt - rtmax;
- if(dt > 0 && dt == pdt) {
+ if (dt > 0 && dt == pdt) {
dt = 10000000i64;
}
- if(rtmin <= rt && rt <= rtmax || pdt > 0 && dt < 0) {
+ if (rtmin <= rt && rt <= rtmax || pdt > 0 && dt < 0) {
minseekpos = min(minseekpos, curpos);
break;
}
@@ -1084,7 +1081,7 @@ void CMpegSplitterFilter::DemuxSeek(REFERENCE_TIME rt) }
}
- if(minseekpos != _I64_MAX) {
+ if (minseekpos != _I64_MAX) {
seekpos = minseekpos;
} else {
// this file is probably screwed up, try plan B, seek simply by bitrate
@@ -1104,9 +1101,9 @@ bool CMpegSplitterFilter::DemuxLoop() REFERENCE_TIME rtStartOffset = m_rtStartOffset ? m_rtStartOffset : m_pFile->m_rtMin;
HRESULT hr = S_OK;
- while(SUCCEEDED(hr) && !CheckRequest(NULL)) {
- if((hr = m_pFile->HasMoreData(1024*500)) == S_OK)
- if((hr = DemuxNextPacket(rtStartOffset)) == S_FALSE) {
+ while (SUCCEEDED(hr) && !CheckRequest(NULL)) {
+ if ((hr = m_pFile->HasMoreData(1024*500)) == S_OK)
+ if ((hr = DemuxNextPacket(rtStartOffset)) == S_FALSE) {
Sleep(1);
}
}
@@ -1133,7 +1130,7 @@ STDMETHODIMP CMpegSplitterFilter::Count(DWORD* pcStreams) *pcStreams = 0;
- for(int i = 0; i < countof(m_pFile->m_streams); i++) {
+ for (int i = 0; i < countof(m_pFile->m_streams); i++) {
(*pcStreams) += m_pFile->m_streams[i].GetCount();
}
@@ -1142,37 +1139,37 @@ STDMETHODIMP CMpegSplitterFilter::Count(DWORD* pcStreams) STDMETHODIMP CMpegSplitterFilter::Enable(long lIndex, DWORD dwFlags)
{
- if(!(dwFlags & AMSTREAMSELECTENABLE_ENABLE)) {
+ if (!(dwFlags & AMSTREAMSELECTENABLE_ENABLE)) {
return E_NOTIMPL;
}
- for(int i = 0, j = 0; i < countof(m_pFile->m_streams); i++) {
+ for (int i = 0, j = 0; i < countof(m_pFile->m_streams); i++) {
int cnt = m_pFile->m_streams[i].GetCount();
- if(lIndex >= j && lIndex < j+cnt) {
+ if (lIndex >= j && lIndex < j+cnt) {
lIndex -= j;
POSITION pos = m_pFile->m_streams[i].FindIndex(lIndex);
- if(!pos) {
+ if (!pos) {
return E_UNEXPECTED;
}
CMpegSplitterFile::stream& to = m_pFile->m_streams[i].GetAt(pos);
pos = m_pFile->m_streams[i].GetHeadPosition();
- while(pos) {
+ while (pos) {
CMpegSplitterFile::stream& from = m_pFile->m_streams[i].GetNext(pos);
- if(!GetOutputPin(from)) {
+ if (!GetOutputPin(from)) {
continue;
}
- if(m_useFastStreamChange) {
+ if (m_useFastStreamChange) {
PauseGraph;
ResumeGraph;
}
HRESULT hr;
- if(FAILED(hr = RenameOutputPin(from, to, &to.mt))) {
+ if (FAILED(hr = RenameOutputPin(from, to, &to.mt))) {
return hr;
}
@@ -1182,22 +1179,22 @@ STDMETHODIMP CMpegSplitterFilter::Enable(long lIndex, DWORD dwFlags) const CHdmvClipInfo::Stream *pClipInfo;
const CMpegSplitterFile::program* p = m_pFile->FindProgram(to.pid, iProgram, pClipInfo);
- if(p!=NULL && !m_ClipInfo.IsHdmv() && !m_pFile->IsHdmv()) {
- for(int k = 0; k < countof(m_pFile->m_streams); k++) {
- if(k == i) {
+ if (p!=NULL && !m_ClipInfo.IsHdmv() && !m_pFile->IsHdmv()) {
+ for (int k = 0; k < countof(m_pFile->m_streams); k++) {
+ if (k == i) {
continue;
}
pos = m_pFile->m_streams[k].GetHeadPosition();
- while(pos) {
+ while (pos) {
CMpegSplitterFile::stream& from = m_pFile->m_streams[k].GetNext(pos);
- if(!GetOutputPin(from)) {
+ if (!GetOutputPin(from)) {
continue;
}
- for(int l = 0; l < countof(p->streams); l++) {
- if(const CMpegSplitterFile::stream* s = m_pFile->m_streams[k].FindStream(p->streams[l].pid)) {
- if(from != *s) {
+ for (int l = 0; l < countof(p->streams); l++) {
+ if (const CMpegSplitterFile::stream* s = m_pFile->m_streams[k].FindStream(p->streams[l].pid)) {
+ if (from != *s) {
hr = RenameOutputPin(from, *s, &s->mt);
}
break;
@@ -1322,47 +1319,47 @@ bool CMpegSplitterFile::stream::operator < (const stream &_Other) const STDMETHODIMP CMpegSplitterFilter::Info(long lIndex, AM_MEDIA_TYPE** ppmt, DWORD* pdwFlags, LCID* plcid, DWORD* pdwGroup, WCHAR** ppszName, IUnknown** ppObject, IUnknown** ppUnk)
{
- for(int i = 0, j = 0; i < countof(m_pFile->m_streams); i++) {
+ for (int i = 0, j = 0; i < countof(m_pFile->m_streams); i++) {
int cnt = m_pFile->m_streams[i].GetCount();
- if(lIndex >= j && lIndex < j+cnt) {
+ if (lIndex >= j && lIndex < j+cnt) {
lIndex -= j;
POSITION pos = m_pFile->m_streams[i].FindIndex(lIndex);
- if(!pos) {
+ if (!pos) {
return E_UNEXPECTED;
}
CMpegSplitterFile::stream& s = m_pFile->m_streams[i].GetAt(pos);
CHdmvClipInfo::Stream* pStream = m_ClipInfo.FindStream (s.pid);
- if(ppmt) {
+ if (ppmt) {
*ppmt = CreateMediaType(&s.mt);
}
- if(pdwFlags) {
+ if (pdwFlags) {
*pdwFlags = GetOutputPin(s) ? (AMSTREAMSELECTINFO_ENABLED|AMSTREAMSELECTINFO_EXCLUSIVE) : 0;
}
- if(plcid) {
+ if (plcid) {
*plcid = pStream ? pStream->m_LCID : 0;
}
- if(pdwGroup) {
+ if (pdwGroup) {
*pdwGroup = i;
}
- if(ppObject) {
+ if (ppObject) {
*ppObject = NULL;
}
- if(ppUnk) {
+ if (ppUnk) {
*ppUnk = NULL;
}
- if(ppszName) {
+ if (ppszName) {
CStringW name = CMpegSplitterFile::CStreamList::ToString(i);
CStringW str;
if (i == CMpegSplitterFile::subpic && s.pid == NO_SUBTITLE_PID) {
str = NO_SUBTITLE_NAME;
- if(plcid) {
+ if (plcid) {
*plcid = (LCID)LCID_NOSUBTITLES;
}
} else {
@@ -1390,7 +1387,7 @@ STDMETHODIMP CMpegSplitterFilter::Info(long lIndex, AM_MEDIA_TYPE** ppmt, DWORD* }
*ppszName = (WCHAR*)CoTaskMemAlloc((str.GetLength()+1)*sizeof(WCHAR));
- if(*ppszName == NULL) {
+ if (*ppszName == NULL) {
return E_OUTOFMEMORY;
}
@@ -1421,13 +1418,13 @@ STDMETHODIMP CMpegSplitterFilter::CreatePage(const GUID& guid, IPropertyPage** p {
CheckPointer(ppPage, E_POINTER);
- if(*ppPage != NULL) {
+ if (*ppPage != NULL) {
return E_INVALIDARG;
}
HRESULT hr;
- if(guid == __uuidof(CMpegSplitterSettingsWnd)) {
+ if (guid == __uuidof(CMpegSplitterSettingsWnd)) {
(*ppPage = DNew CInternalPropertyPageTempl<CMpegSplitterSettingsWnd>(NULL, &hr))->AddRef();
}
@@ -1439,7 +1436,7 @@ STDMETHODIMP CMpegSplitterFilter::Apply() {
#ifdef REGISTER_FILTER
CRegKey key;
- if(ERROR_SUCCESS == key.Create(HKEY_CURRENT_USER, _T("Software\\Gabest\\Filters\\MPEG Splitter"))) {
+ if (ERROR_SUCCESS == key.Create(HKEY_CURRENT_USER, _T("Software\\Gabest\\Filters\\MPEG Splitter"))) {
key.SetDWORDValue(_T("UseFastStreamChange"), m_useFastStreamChange);
key.SetDWORDValue(_T("ForcedSub"), m_ForcedSub);
key.SetDWORDValue(_T("TrackPriority"), m_TrackPriority);
@@ -1607,12 +1604,12 @@ HRESULT CMpegSplitterOutputPin::DeliverPacket(CAutoPtr<Packet> p) {
CAutoLock cAutoLock(this);
- if(p->rtStart != Packet::INVALID_TIME) {
+ if (p->rtStart != Packet::INVALID_TIME) {
REFERENCE_TIME rt = p->rtStart + m_rtOffset;
// Filter invalid PTS (if too different from previous packet)
- if(m_rtPrev != Packet::INVALID_TIME)
- if(_abs64(rt - m_rtPrev) > m_rtMaxShift) {
+ if (m_rtPrev != Packet::INVALID_TIME)
+ if (_abs64(rt - m_rtPrev) > m_rtMaxShift) {
m_rtOffset += m_rtPrev - rt;
}
@@ -1630,22 +1627,22 @@ HRESULT CMpegSplitterOutputPin::DeliverPacket(CAutoPtr<Packet> p) }
- if(m_mt.subtype == MEDIASUBTYPE_AAC) { // special code for aac, the currently available decoders only like whole frame samples
- if(m_p && m_p->GetCount() == 1 && m_p->GetAt(0) == 0xff && !(!p->IsEmpty() && (p->GetAt(0) & 0xf6) == 0xf0)) {
+ if (m_mt.subtype == MEDIASUBTYPE_AAC) { // special code for aac, the currently available decoders only like whole frame samples
+ if (m_p && m_p->GetCount() == 1 && m_p->GetAt(0) == 0xff && !(!p->IsEmpty() && (p->GetAt(0) & 0xf6) == 0xf0)) {
m_p.Free();
}
- if(!m_p) {
+ if (!m_p) {
BYTE* base = p->GetData();
BYTE* s = base;
BYTE* e = s + p->GetCount();
- for(; s < e; s++) {
- if(*s != 0xff) {
+ for (; s < e; s++) {
+ if (*s != 0xff) {
continue;
}
- if(s == e-1 || (s[1]&0xf6) == 0xf0) {
+ if (s == e-1 || (s[1]&0xf6) == 0xf0) {
memmove(base, s, e - s);
p->SetCount(e - s);
m_p = p;
@@ -1656,7 +1653,7 @@ HRESULT CMpegSplitterOutputPin::DeliverPacket(CAutoPtr<Packet> p) m_p->Append(*p);
}
- while(m_p && m_p->GetCount() > 9) {
+ while (m_p && m_p->GetCount() > 9) {
BYTE* base = m_p->GetData();
BYTE* s = base;
BYTE* e = s + m_p->GetCount();
@@ -1664,15 +1661,15 @@ HRESULT CMpegSplitterOutputPin::DeliverPacket(CAutoPtr<Packet> p) bool crc = !(s[1]&1);
s += 7;
len -= 7;
- if(crc) {
+ if (crc) {
s += 2, len -= 2;
}
- if(e - s < len) {
+ if (e - s < len) {
break;
}
- if(len <= 0 || e - s >= len + 2 && (s[len] != 0xff || (s[len+1]&0xf6) != 0xf0)) {
+ if (len <= 0 || e - s >= len + 2 && (s[len] != 0xff || (s[len+1]&0xf6) != 0xf0)) {
m_p.Free();
break;
}
@@ -1698,22 +1695,22 @@ HRESULT CMpegSplitterOutputPin::DeliverPacket(CAutoPtr<Packet> p) m_p->SetCount(e - s);
HRESULT hr = __super::DeliverPacket(p2);
- if(hr != S_OK) {
+ if (hr != S_OK) {
return hr;
}
}
- if(m_p && p) {
- if(!m_p->bDiscontinuity) {
+ if (m_p && p) {
+ if (!m_p->bDiscontinuity) {
m_p->bDiscontinuity = p->bDiscontinuity;
}
- if(!m_p->bSyncPoint) {
+ if (!m_p->bSyncPoint) {
m_p->bSyncPoint = p->bSyncPoint;
}
- if(m_p->rtStart == Packet::INVALID_TIME) {
+ if (m_p->rtStart == Packet::INVALID_TIME) {
m_p->rtStart = p->rtStart, m_p->rtStop = p->rtStop;
}
- if(m_p->pmt) {
+ if (m_p->pmt) {
DeleteMediaType(m_p->pmt);
}
@@ -1722,8 +1719,8 @@ HRESULT CMpegSplitterOutputPin::DeliverPacket(CAutoPtr<Packet> p) }
return S_OK;
- } else if(m_mt.subtype == FOURCCMap('1CVA') || m_mt.subtype == FOURCCMap('1cva') || m_mt.subtype == FOURCCMap('CVMA') || m_mt.subtype == FOURCCMap('CVME')) {
- if(!m_p) {
+ } else if (m_mt.subtype == FOURCCMap('1CVA') || m_mt.subtype == FOURCCMap('1cva') || m_mt.subtype == FOURCCMap('CVMA') || m_mt.subtype == FOURCCMap('CVME')) {
+ if (!m_p) {
m_p.Attach(DNew Packet());
m_p->TrackNumber = p->TrackNumber;
m_p->bDiscontinuity = p->bDiscontinuity;
@@ -1746,12 +1743,12 @@ HRESULT CMpegSplitterOutputPin::DeliverPacket(CAutoPtr<Packet> p) MOVE_TO_H264_START_CODE(start, end);
- while(start <= end-4) {
+ while (start <= end-4) {
BYTE* next = start+1;
MOVE_TO_H264_START_CODE(next, end);
- if(next >= end-4) {
+ if (next >= end-4) {
break;
}
@@ -1799,20 +1796,20 @@ HRESULT CMpegSplitterOutputPin::DeliverPacket(CAutoPtr<Packet> p) m_pl.AddTail(p2);
- if(p->rtStart != Packet::INVALID_TIME) {
+ if (p->rtStart != Packet::INVALID_TIME) {
m_p->rtStart = p->rtStart;
m_p->rtStop = p->rtStop;
p->rtStart = Packet::INVALID_TIME;
}
- if(p->bDiscontinuity) {
+ if (p->bDiscontinuity) {
m_p->bDiscontinuity = p->bDiscontinuity;
p->bDiscontinuity = FALSE;
}
- if(p->bSyncPoint) {
+ if (p->bSyncPoint) {
m_p->bSyncPoint = p->bSyncPoint;
p->bSyncPoint = FALSE;
}
- if(m_p->pmt) {
+ if (m_p->pmt) {
DeleteMediaType(m_p->pmt);
}
@@ -1821,44 +1818,44 @@ HRESULT CMpegSplitterOutputPin::DeliverPacket(CAutoPtr<Packet> p) start = next;
}
- if(start > m_p->GetData()) {
+ if (start > m_p->GetData()) {
m_p->RemoveAt(0, start - m_p->GetData());
}
REFERENCE_TIME rtStart = Packet::INVALID_TIME, rtStop = Packet::INVALID_TIME;
- for(POSITION pos = m_pl.GetHeadPosition(); pos; m_pl.GetNext(pos)) {
- if(pos == m_pl.GetHeadPosition()) {
+ for (POSITION pos = m_pl.GetHeadPosition(); pos; m_pl.GetNext(pos)) {
+ if (pos == m_pl.GetHeadPosition()) {
continue;
}
Packet* pPacket = m_pl.GetAt(pos);
BYTE* pData = pPacket->GetData();
- if((pData[4]&0x1f) == 0x09) {
+ if ((pData[4]&0x1f) == 0x09) {
m_fHasAccessUnitDelimiters = true;
}
- if((pData[4]&0x1f) == 0x09 || (!m_fHasAccessUnitDelimiters && pPacket->rtStart != Packet::INVALID_TIME)) {
+ if ((pData[4]&0x1f) == 0x09 || (!m_fHasAccessUnitDelimiters && pPacket->rtStart != Packet::INVALID_TIME)) {
if (pPacket->rtStart == Packet::INVALID_TIME && rtStart != Packet::INVALID_TIME) {
pPacket->rtStart = rtStart;
pPacket->rtStop = rtStop;
}
-/*
- if(pPacket->rtStart == Packet::INVALID_TIME) {
- continue;
- }
-*/
+ /*
+ if(pPacket->rtStart == Packet::INVALID_TIME) {
+ continue;
+ }
+ */
p = m_pl.RemoveHead();
- while(pos != m_pl.GetHeadPosition()) {
+ while (pos != m_pl.GetHeadPosition()) {
CAutoPtr<Packet> p2 = m_pl.RemoveHead();
p->Append(*p2);
}
HRESULT hr = __super::DeliverPacket(p);
- if(hr != S_OK) {
+ if (hr != S_OK) {
return hr;
}
}
@@ -1869,8 +1866,8 @@ HRESULT CMpegSplitterOutputPin::DeliverPacket(CAutoPtr<Packet> p) }
return S_OK;
- } else if(m_mt.subtype == FOURCCMap('1CVW') || m_mt.subtype == FOURCCMap('1cvw') || m_mt.subtype == MEDIASUBTYPE_WVC1_CYBERLINK || m_mt.subtype == MEDIASUBTYPE_WVC1_ARCSOFT) { // just like aac, this has to be starting nalus, more can be packed together
- if(!m_p) {
+ } else if (m_mt.subtype == FOURCCMap('1CVW') || m_mt.subtype == FOURCCMap('1cvw') || m_mt.subtype == MEDIASUBTYPE_WVC1_CYBERLINK || m_mt.subtype == MEDIASUBTYPE_WVC1_ARCSOFT) { // just like aac, this has to be starting nalus, more can be packed together
+ if (!m_p) {
m_p.Attach(DNew Packet());
m_p->TrackNumber = p->TrackNumber;
m_p->bDiscontinuity = p->bDiscontinuity;
@@ -1892,7 +1889,7 @@ HRESULT CMpegSplitterOutputPin::DeliverPacket(CAutoPtr<Packet> p) BYTE* end = start + m_p->GetCount();
bool bSeqFound = false;
- while(start <= end-4) {
+ while (start <= end-4) {
if (*(DWORD*)start == 0x0D010000) {
bSeqFound = true;
break;
@@ -1902,10 +1899,10 @@ HRESULT CMpegSplitterOutputPin::DeliverPacket(CAutoPtr<Packet> p) start++;
}
- while(start <= end-4) {
+ while (start <= end-4) {
BYTE* next = start+1;
- while(next <= end-4) {
+ while (next <= end-4) {
if (*(DWORD*)next == 0x0D010000) {
if (bSeqFound) {
break;
@@ -1917,7 +1914,7 @@ HRESULT CMpegSplitterOutputPin::DeliverPacket(CAutoPtr<Packet> p) next++;
}
- if(next >= end-4) {
+ if (next >= end-4) {
break;
}
@@ -1944,24 +1941,24 @@ HRESULT CMpegSplitterOutputPin::DeliverPacket(CAutoPtr<Packet> p) p2->SetData(start, next - start);
HRESULT hr = __super::DeliverPacket(p2);
- if(hr != S_OK) {
+ if (hr != S_OK) {
return hr;
}
- if(p->rtStart != Packet::INVALID_TIME) {
+ if (p->rtStart != Packet::INVALID_TIME) {
m_p->rtStart = p->rtStop; //p->rtStart; //Sebastiii for enable VC1 decoding in FFDshow (no more shutter)
m_p->rtStop = p->rtStop;
p->rtStart = Packet::INVALID_TIME;
}
- if(p->bDiscontinuity) {
+ if (p->bDiscontinuity) {
m_p->bDiscontinuity = p->bDiscontinuity;
p->bDiscontinuity = FALSE;
}
- if(p->bSyncPoint) {
+ if (p->bSyncPoint) {
m_p->bSyncPoint = p->bSyncPoint;
p->bSyncPoint = FALSE;
}
- if(m_p->pmt) {
+ if (m_p->pmt) {
DeleteMediaType(m_p->pmt);
}
@@ -1972,7 +1969,7 @@ HRESULT CMpegSplitterOutputPin::DeliverPacket(CAutoPtr<Packet> p) bSeqFound = (*(DWORD*)start == 0x0D010000);
}
- if(start > m_p->GetData()) {
+ if (start > m_p->GetData()) {
m_p->RemoveAt(0, start - m_p->GetData());
}
@@ -2016,15 +2013,15 @@ HRESULT CMpegSplitterOutputPin::DeliverPacket(CAutoPtr<Packet> p) else if (!p->pmt) {
return S_OK;
}
- // HDMV LPCM
+ // HDMV LPCM
} else if (m_mt.subtype == MEDIASUBTYPE_HDMV_LPCM_AUDIO) {
BYTE* start = p->GetData();
p->SetData(start + 4, p->GetCount() - 4);
- // Dolby_AC3
- } else if ((m_type == CMpegSplitterFile::ts) &&
- (m_mt.subtype == MEDIASUBTYPE_DOLBY_AC3) &&
- (static_cast<CMpegSplitterFilter*>(m_pFilter))->StreamIsTrueHD(p->TrackNumber) &&
- (static_cast<CMpegSplitterFilter*>(m_pFilter))->GetTrueHD() != 2) {
+ // Dolby_AC3
+ } else if ((m_type == CMpegSplitterFile::ts) &&
+ (m_mt.subtype == MEDIASUBTYPE_DOLBY_AC3) &&
+ (static_cast<CMpegSplitterFilter*>(m_pFilter))->StreamIsTrueHD(p->TrackNumber) &&
+ (static_cast<CMpegSplitterFilter*>(m_pFilter))->GetTrueHD() != 2) {
if (p->GetCount() < 8) {
return S_OK; // Should be invalid packet
}
@@ -2032,7 +2029,7 @@ HRESULT CMpegSplitterOutputPin::DeliverPacket(CAutoPtr<Packet> p) if (*(WORD*)start != 0x770b) { // skip none AC3
return S_OK;
}
- // TrueHD
+ // TrueHD
} else if (m_mt.subtype == MEDIASUBTYPE_DOLBY_TRUEHD && (static_cast<CMpegSplitterFilter*>(m_pFilter))->GetTrueHD() != 2) {
if (p->GetCount() < 8) {
return S_OK; // Should be invalid packet
diff --git a/src/filters/parser/MpegSplitter/MpegSplitter.h b/src/filters/parser/MpegSplitter/MpegSplitter.h index 9a5872238..e58d84158 100644 --- a/src/filters/parser/MpegSplitter/MpegSplitter.h +++ b/src/filters/parser/MpegSplitter/MpegSplitter.h @@ -47,7 +47,7 @@ \
if(_fs == State_Running && _pMS) \
_pMC->Run(); \
-
+
class __declspec(uuid("DC257063-045F-4BE2-BD5B-E12279C464F0"))
CMpegSplitterFilter
: public CBaseSplitterFilter
diff --git a/src/filters/parser/MpegSplitter/MpegSplitterFile.cpp b/src/filters/parser/MpegSplitter/MpegSplitterFile.cpp index 93cecf54d..76df3392a 100644 --- a/src/filters/parser/MpegSplitter/MpegSplitterFile.cpp +++ b/src/filters/parser/MpegSplitter/MpegSplitterFile.cpp @@ -43,7 +43,7 @@ CMpegSplitterFile::CMpegSplitterFile(IAsyncReader* pAsyncReader, HRESULT& hr, bo , m_AC3CoreOnly(AC3CoreOnly)
, m_init(false)
{
- if(SUCCEEDED(hr)) {
+ if (SUCCEEDED(hr)) {
hr = Init(pAsyncReader);
}
}
@@ -58,64 +58,64 @@ HRESULT CMpegSplitterFile::Init(IAsyncReader* pAsyncReader) Seek(0);
- if(m_type == us) {
- if(BitRead(32, true) == 'TFrc') {
+ if (m_type == us) {
+ if (BitRead(32, true) == 'TFrc') {
Seek(0x67c);
}
int cnt = 0, limit = 4;
- for(trhdr h; cnt < limit && Read(h); cnt++) {
+ for (trhdr h; cnt < limit && Read(h); cnt++) {
Seek(h.next);
}
- if(cnt >= limit) {
+ if (cnt >= limit) {
m_type = ts;
}
}
Seek(0);
- if(m_type == us) {
- if(BitRead(32, true) == 'TFrc') {
+ if (m_type == us) {
+ if (BitRead(32, true) == 'TFrc') {
Seek(0xE80);
}
int cnt = 0, limit = 4;
- for(trhdr h; cnt < limit && Read(h); cnt++) {
+ for (trhdr h; cnt < limit && Read(h); cnt++) {
Seek(h.next);
}
- if(cnt >= limit) {
+ if (cnt >= limit) {
m_type = ts;
}
}
Seek(0);
- if(m_type == us) {
+ if (m_type == us) {
int cnt = 0, limit = 4;
- for(pvahdr h; cnt < limit && Read(h); cnt++) {
+ for (pvahdr h; cnt < limit && Read(h); cnt++) {
Seek(GetPos() + h.length);
}
- if(cnt >= limit) {
+ if (cnt >= limit) {
m_type = pva;
}
}
Seek(0);
- if(m_type == us) {
+ if (m_type == us) {
BYTE b;
- for(int i = 0; (i < 4 || GetPos() < 65536) && m_type == us && NextMpegStartCode(b); i++) {
- if(b == 0xba) {
+ for (int i = 0; (i < 4 || GetPos() < 65536) && m_type == us && NextMpegStartCode(b); i++) {
+ if (b == 0xba) {
pshdr h;
- if(Read(h)) {
+ if (Read(h)) {
m_type = ps;
m_rate = int(h.bitrate/8);
break;
}
- } else if((b&0xe0) == 0xc0 // audio, 110xxxxx, mpeg1/2/3
- || (b&0xf0) == 0xe0 // video, 1110xxxx, mpeg1/2
- // || (b&0xbd) == 0xbd) // private stream 1, 0xbd, ac3/dts/lpcm/subpic
- || b == 0xbd) { // private stream 1, 0xbd, ac3/dts/lpcm/subpic
+ } else if ((b&0xe0) == 0xc0 // audio, 110xxxxx, mpeg1/2/3
+ || (b&0xf0) == 0xe0 // video, 1110xxxx, mpeg1/2
+ // || (b&0xbd) == 0xbd) // private stream 1, 0xbd, ac3/dts/lpcm/subpic
+ || b == 0xbd) { // private stream 1, 0xbd, ac3/dts/lpcm/subpic
peshdr h;
- if(Read(h, b) && BitRead(24, true) == 0x000001) {
+ if (Read(h, b) && BitRead(24, true) == 0x000001) {
m_type = es;
}
}
@@ -124,75 +124,75 @@ HRESULT CMpegSplitterFile::Init(IAsyncReader* pAsyncReader) Seek(0);
- if(m_type == us) {
+ if (m_type == us) {
return E_FAIL;
}
// min/max pts & bitrate
m_rtMin = m_posMin = _I64_MAX;
m_rtMax = m_posMax = 0;
-
+
m_init = true;
- if(IsRandomAccess() || IsStreaming()) {
- if(IsStreaming()) {
- for(int i = 0; i < 20 || i < 50 && S_OK != HasMoreData(1024*100, 100); i++) {
+ if (IsRandomAccess() || IsStreaming()) {
+ if (IsStreaming()) {
+ for (int i = 0; i < 20 || i < 50 && S_OK != HasMoreData(1024*100, 100); i++) {
;
}
}
CAtlList<__int64> fps;
- for(int i = 0, j = 5; i <= j; i++) {
+ for (int i = 0, j = 5; i <= j; i++) {
fps.AddTail(i*GetLength()/j);
}
- for(__int64 pfp = 0; fps.GetCount(); ) {
+ for (__int64 pfp = 0; fps.GetCount(); ) {
__int64 fp = fps.RemoveHead();
fp = min(GetLength() - MEGABYTE/8, fp);
fp = max(pfp, fp);
__int64 nfp = fp + (pfp == 0 ? 10*MEGABYTE : MEGABYTE/8);
- if(FAILED(hr = SearchStreams(fp, nfp, pAsyncReader))) {
+ if (FAILED(hr = SearchStreams(fp, nfp, pAsyncReader))) {
return hr;
}
pfp = nfp;
}
} else {
- if(FAILED(hr = SearchStreams(0, MEGABYTE/8, pAsyncReader))) {
+ if (FAILED(hr = SearchStreams(0, MEGABYTE/8, pAsyncReader))) {
return hr;
}
}
- if(m_type == ts) {
- if(IsRandomAccess() || IsStreaming()) {
- if(IsStreaming()) {
- for(int i = 0; i < 20 || i < 50 && S_OK != HasMoreData(1024*100, 100); i++) {
+ if (m_type == ts) {
+ if (IsRandomAccess() || IsStreaming()) {
+ if (IsStreaming()) {
+ for (int i = 0; i < 20 || i < 50 && S_OK != HasMoreData(1024*100, 100); i++) {
;
}
}
CAtlList<__int64> fps;
- for(int i = 0, j = 5; i <= j; i++) {
+ for (int i = 0, j = 5; i <= j; i++) {
fps.AddTail(i*GetLength()/j);
}
- for(__int64 pfp = 0; fps.GetCount(); ) {
+ for (__int64 pfp = 0; fps.GetCount(); ) {
__int64 fp = fps.RemoveHead();
fp = min(GetLength() - MEGABYTE/8, fp);
fp = max(pfp, fp);
__int64 nfp = fp + (pfp == 0 ? 10*MEGABYTE : MEGABYTE/8);
- if(FAILED(hr = SearchStreams(fp, nfp, pAsyncReader, TRUE))) {
+ if (FAILED(hr = SearchStreams(fp, nfp, pAsyncReader, TRUE))) {
return hr;
}
pfp = nfp;
}
} else {
- if(FAILED(hr = SearchStreams(0, MEGABYTE/8, pAsyncReader, TRUE))) {
+ if (FAILED(hr = SearchStreams(0, MEGABYTE/8, pAsyncReader, TRUE))) {
return hr;
}
}
}
- if(m_posMax - m_posMin <= 0 || m_rtMax - m_rtMin <= 0) {
+ if (m_posMax - m_posMin <= 0 || m_rtMax - m_rtMin <= 0) {
return E_FAIL;
}
@@ -205,7 +205,7 @@ HRESULT CMpegSplitterFile::Init(IAsyncReader* pAsyncReader) #if (0)
// normally "detected" should always be less than "indicated", but sometimes it can be a few percent higher (+10% is allowed here)
// (update: also allowing +/-50k/s)
- if(indicated_rate == 0 || ((float)detected_rate / indicated_rate) < 1.1 || abs(detected_rate - indicated_rate) < 50*1024) {
+ if (indicated_rate == 0 || ((float)detected_rate / indicated_rate) < 1.1 || abs(detected_rate - indicated_rate) < 50*1024) {
m_rate = detected_rate;
} else {
; // TODO: in this case disable seeking, or try doing something less drastical...
@@ -213,8 +213,8 @@ HRESULT CMpegSplitterFile::Init(IAsyncReader* pAsyncReader) #endif
// Add fake Subtitle stream ...
- if(m_type == ts) {
- if(m_streams[video].GetCount()) {
+ if (m_type == ts) {
+ if (m_streams[video].GetCount()) {
if (!m_bIsHdmv && m_streams[subpic].GetCount()) {
stream s;
s.pid = NO_SUBTITLE_PID;
@@ -227,7 +227,7 @@ HRESULT CMpegSplitterFile::Init(IAsyncReader* pAsyncReader) }
}
} else {
- if(m_streams[video].GetCount() && m_streams[subpic].GetCount()) {
+ if (m_streams[video].GetCount() && m_streams[subpic].GetCount()) {
stream s;
s.pid = NO_SUBTITLE_PID;
s.mt.majortype = m_streams[subpic].GetHead().mt.majortype;
@@ -246,7 +246,7 @@ void CMpegSplitterFile::OnComplete(IAsyncReader* pAsyncReader) {
__int64 pos = GetPos();
- if(SUCCEEDED(SearchStreams(GetLength() - 500*1024, GetLength(), pAsyncReader, TRUE))) {
+ if (SUCCEEDED(SearchStreams(GetLength() - 500*1024, GetLength(), pAsyncReader, TRUE))) {
int indicated_rate = m_rate;
int detected_rate = int(m_rtMax > m_rtMin ? 10000000i64 * (m_posMax - m_posMin) / (m_rtMax - m_rtMin) : 0);
@@ -254,7 +254,7 @@ void CMpegSplitterFile::OnComplete(IAsyncReader* pAsyncReader) #if (0)
// normally "detected" should always be less than "indicated", but sometimes it can be a few percent higher (+10% is allowed here)
// (update: also allowing +/-50k/s)
- if(indicated_rate == 0 || ((float)detected_rate / indicated_rate) < 1.1 || abs(detected_rate - indicated_rate) < 50*1024) {
+ if (indicated_rate == 0 || ((float)detected_rate / indicated_rate) < 1.1 || abs(detected_rate - indicated_rate) < 50*1024) {
m_rate = detected_rate;
} else {
; // TODO: in this case disable seeking, or try doing something less drastical...
@@ -272,9 +272,9 @@ REFERENCE_TIME CMpegSplitterFile::NextPTS(DWORD TrackNum) BYTE b;
- while(GetRemaining()) {
- if(m_type == ps || m_type == es) {
- if(!NextMpegStartCode(b)) { // continue;
+ while (GetRemaining()) {
+ if (m_type == ps || m_type == es) {
+ if (!NextMpegStartCode(b)) { // continue;
ASSERT(0);
break;
}
@@ -282,19 +282,19 @@ REFERENCE_TIME CMpegSplitterFile::NextPTS(DWORD TrackNum) rtpos = GetPos()-4;
#if (EVO_SUPPORT == 0)
- if(b >= 0xbd && b < 0xf0)
+ if (b >= 0xbd && b < 0xf0)
#else
- if((b >= 0xbd && b < 0xf0) || (b == 0xfd))
+ if ((b >= 0xbd && b < 0xf0) || (b == 0xfd))
#endif
{
peshdr h;
- if(!Read(h, b) || !h.len) {
+ if (!Read(h, b) || !h.len) {
continue;
}
__int64 pos = GetPos();
- if(h.fpts && AddStream(0, b, h.len) == TrackNum) {
+ if (h.fpts && AddStream(0, b, h.len) == TrackNum) {
//ASSERT(h.pts >= m_rtMin && h.pts <= m_rtMax);
rt = h.pts;
break;
@@ -302,18 +302,18 @@ REFERENCE_TIME CMpegSplitterFile::NextPTS(DWORD TrackNum) Seek(pos + h.len);
}
- } else if(m_type == ts) {
+ } else if (m_type == ts) {
trhdr h;
- if(!Read(h)) {
+ if (!Read(h)) {
continue;
}
rtpos = GetPos()-4;
- if(h.payload && h.payloadstart && ISVALIDPID(h.pid)) {
+ if (h.payload && h.payloadstart && ISVALIDPID(h.pid)) {
peshdr h2;
- if(NextMpegStartCode(b, 4) && Read(h2, b)) { // pes packet
- if(h2.fpts && AddStream(h.pid, b, DWORD(h.bytes - (GetPos() - rtpos)) == TrackNum)) {
+ if (NextMpegStartCode(b, 4) && Read(h2, b)) { // pes packet
+ if (h2.fpts && AddStream(h.pid, b, DWORD(h.bytes - (GetPos() - rtpos)) == TrackNum)) {
//ASSERT(h2.pts >= m_rtMin && h2.pts <= m_rtMax);
rt = h2.pts;
break;
@@ -322,23 +322,23 @@ REFERENCE_TIME CMpegSplitterFile::NextPTS(DWORD TrackNum) }
Seek(h.next);
- } else if(m_type == pva) {
+ } else if (m_type == pva) {
pvahdr h;
- if(!Read(h)) {
+ if (!Read(h)) {
continue;
}
- if(h.fpts) {
+ if (h.fpts) {
rt = h.pts;
break;
}
}
}
- if(rtpos >= 0) {
+ if (rtpos >= 0) {
Seek(rtpos);
}
- if(rt >= 0) {
+ if (rt >= 0) {
rt -= m_rtMin;
}
@@ -350,49 +350,49 @@ HRESULT CMpegSplitterFile::SearchStreams(__int64 start, __int64 stop, IAsyncRead Seek(start);
stop = min(stop, GetLength());
- while(GetPos() < stop) {
+ while (GetPos() < stop) {
BYTE b;
- if(m_type == ps || m_type == es) {
- if(!NextMpegStartCode(b)) {
+ if (m_type == ps || m_type == es) {
+ if (!NextMpegStartCode(b)) {
continue;
}
- if(b == 0xba) { // program stream header
+ if (b == 0xba) { // program stream header
pshdr h;
- if(!Read(h)) {
+ if (!Read(h)) {
continue;
}
m_rate = int(h.bitrate/8);
- } else if(b == 0xbb) { // program stream system header
+ } else if (b == 0xbb) { // program stream system header
pssyshdr h;
- if(!Read(h)) {
+ if (!Read(h)) {
continue;
}
}
#if (EVO_SUPPORT == 0)
- else if(b >= 0xbd && b < 0xf0) // pes packet
+ else if (b >= 0xbd && b < 0xf0) // pes packet
#else
- else if((b >= 0xbd && b < 0xf0) || (b == 0xfd)) // pes packet
+ else if ((b >= 0xbd && b < 0xf0) || (b == 0xfd)) // pes packet
#endif
{
peshdr h;
- if(!Read(h, b)) {
+ if (!Read(h, b)) {
continue;
}
- if(h.type == mpeg2 && h.scrambling) {
+ if (h.type == mpeg2 && h.scrambling) {
ASSERT(0);
return E_FAIL;
}
- if(h.fpts) {
- if(m_rtMin == _I64_MAX) {
+ if (h.fpts) {
+ if (m_rtMin == _I64_MAX) {
m_rtMin = h.pts;
m_posMin = GetPos();
TRACE ("m_rtMin(SearchStreams)=%S\n", ReftimeToString(m_rtMin));
}
- if(m_rtMin < h.pts && m_rtMax < h.pts) {
+ if (m_rtMin < h.pts && m_rtMax < h.pts) {
m_rtMax = h.pts;
m_posMax = GetPos();
TRACE ("m_rtMax(SearchStreams)=%S\n", ReftimeToString(m_rtMax));
@@ -401,13 +401,13 @@ HRESULT CMpegSplitterFile::SearchStreams(__int64 start, __int64 stop, IAsyncRead __int64 pos = GetPos();
AddStream(0, b, h.len);
- if(h.len) {
+ if (h.len) {
Seek(pos + h.len);
}
}
- } else if(m_type == ts) {
+ } else if (m_type == ts) {
trhdr h;
- if(!Read(h)) {
+ if (!Read(h)) {
continue;
}
@@ -415,22 +415,22 @@ HRESULT CMpegSplitterFile::SearchStreams(__int64 start, __int64 stop, IAsyncRead UpdatePrograms(h);
- if(h.payload && ISVALIDPID(h.pid)) {
+ if (h.payload && ISVALIDPID(h.pid)) {
peshdr h2;
- if(h.payloadstart && NextMpegStartCode(b, 4) && Read(h2, b)) { // pes packet
- if(h2.type == mpeg2 && h2.scrambling) {
+ if (h.payloadstart && NextMpegStartCode(b, 4) && Read(h2, b)) { // pes packet
+ if (h2.type == mpeg2 && h2.scrambling) {
ASSERT(0);
return E_FAIL;
}
- if(h2.fpts && CalcDuration && GetMasterStream() && GetMasterStream()->GetHead() == h.pid) {
- if((m_rtMin == _I64_MAX) || (m_rtMin > h2.pts)) {
+ if (h2.fpts && CalcDuration && GetMasterStream() && GetMasterStream()->GetHead() == h.pid) {
+ if ((m_rtMin == _I64_MAX) || (m_rtMin > h2.pts)) {
m_rtMin = h2.pts;
m_posMin = GetPos();
TRACE ("m_rtMin(SearchStreams)=%S, PID=%d\n", ReftimeToString(m_rtMin), h.pid);
}
- if(m_rtMin < h2.pts && m_rtMax < h2.pts) {
+ if (m_rtMin < h2.pts && m_rtMax < h2.pts) {
m_rtMax = h2.pts;
m_posMax = GetPos();
TRACE ("m_rtMax(SearchStreams)=%S, PID=%d\n", ReftimeToString(m_rtMax), h.pid);
@@ -457,25 +457,25 @@ HRESULT CMpegSplitterFile::SearchStreams(__int64 start, __int64 stop, IAsyncRead b = 0;
}
- if(!CalcDuration) {
+ if (!CalcDuration) {
AddStream(h.pid, b, DWORD(h.bytes - (GetPos() - pos)));
}
}
Seek(h.next);
- } else if(m_type == pva) {
+ } else if (m_type == pva) {
pvahdr h;
- if(!Read(h)) {
+ if (!Read(h)) {
continue;
}
- if(h.fpts) {
- if(m_rtMin == _I64_MAX) {
+ if (h.fpts) {
+ if (m_rtMin == _I64_MAX) {
m_rtMin = h.pts;
m_posMin = GetPos();
}
- if(m_rtMin < h.pts && m_rtMax < h.pts) {
+ if (m_rtMin < h.pts && m_rtMax < h.pts) {
m_rtMax = h.pts;
m_posMax = GetPos();
}
@@ -483,13 +483,13 @@ HRESULT CMpegSplitterFile::SearchStreams(__int64 start, __int64 stop, IAsyncRead __int64 pos = GetPos();
- if(h.streamid == 1) {
+ if (h.streamid == 1) {
AddStream(h.streamid, 0xe0, h.length);
- } else if(h.streamid == 2) {
+ } else if (h.streamid == 2) {
AddStream(h.streamid, 0xc0, h.length);
}
- if(h.length) {
+ if (h.length) {
Seek(pos + h.length);
}
}
@@ -500,8 +500,8 @@ HRESULT CMpegSplitterFile::SearchStreams(__int64 start, __int64 stop, IAsyncRead DWORD CMpegSplitterFile::AddStream(WORD pid, BYTE pesid, DWORD len)
{
- if(pid) {
- if(pesid) {
+ if (pid) {
+ if (pesid) {
m_pid2pes[pid] = pesid;
} else {
m_pid2pes.Lookup(pid, pesid);
@@ -514,24 +514,24 @@ DWORD CMpegSplitterFile::AddStream(WORD pid, BYTE pesid, DWORD len) int type = unknown;
- if(pesid >= 0xe0 && pesid < 0xf0) { // mpeg video
+ if (pesid >= 0xe0 && pesid < 0xf0) { // mpeg video
__int64 pos = GetPos();
- if(type == unknown) {
+ if (type == unknown) {
CMpegSplitterFile::seqhdr h;
- if(!m_streams[video].Find(s) && Read(h, len, &s.mt)) {
+ if (!m_streams[video].Find(s) && Read(h, len, &s.mt)) {
type = video;
}
}
- if(type == unknown) {
+ if (type == unknown) {
Seek(pos);
// PPS and SPS can be present on differents packets
// and can also be split into multiple packets
if (!avch.Lookup(pid))
memset(&avch[pid], 0, sizeof(CMpegSplitterFile::avchdr));
#if defined(MVC_SUPPORT)
- if(!m_streams[video].Find(s) && !m_streams[stereo].Find(s) && Read(avch[pid], len, &s.mt))
+ if (!m_streams[video].Find(s) && !m_streams[stereo].Find(s) && Read(avch[pid], len, &s.mt))
{
if (avch[pid].spspps[index_subsetsps].complete)
type = stereo;
@@ -539,64 +539,64 @@ DWORD CMpegSplitterFile::AddStream(WORD pid, BYTE pesid, DWORD len) type = video;
}
#else
- if(!m_streams[video].Find(s) && Read(avch[pid], len, &s.mt)) {
+ if (!m_streams[video].Find(s) && Read(avch[pid], len, &s.mt)) {
type = video;
}
#endif
}
- } else if(pesid >= 0xc0 && pesid < 0xe0) { // mpeg audio
+ } else if (pesid >= 0xc0 && pesid < 0xe0) { // mpeg audio
__int64 pos = GetPos();
- if(type == unknown) {
+ if (type == unknown) {
CMpegSplitterFile::aachdr h;
- if(!m_streams[audio].Find(s) && Read(h, len, &s.mt)) {
+ if (!m_streams[audio].Find(s) && Read(h, len, &s.mt)) {
type = audio;
}
}
- if(type == unknown) {
+ if (type == unknown) {
Seek(pos);
CMpegSplitterFile::mpahdr h;
- if(!m_streams[audio].Find(s) && Read(h, len, false, &s.mt)) {
+ if (!m_streams[audio].Find(s) && Read(h, len, false, &s.mt)) {
type = audio;
}
}
- } else if(pesid == 0xbd || pesid == 0xfd) { // private stream 1
- if(s.pid) {
- if(!m_streams[audio].Find(s) && !m_streams[video].Find(s)) {
+ } else if (pesid == 0xbd || pesid == 0xfd) { // private stream 1
+ if (s.pid) {
+ if (!m_streams[audio].Find(s) && !m_streams[video].Find(s)) {
__int64 pos = GetPos();
// AC3
- if(type == unknown) {
+ if (type == unknown) {
CMpegSplitterFile::ac3hdr h;
- if(Read(h, len, &s.mt, false, (m_AC3CoreOnly == 1))) {
+ if (Read(h, len, &s.mt, false, (m_AC3CoreOnly == 1))) {
type = audio;
}
}
// DTS
- if(type == unknown) {
+ if (type == unknown) {
Seek(pos);
CMpegSplitterFile::dtshdr h;
- if(Read(h, len, &s.mt, false)) {
+ if (Read(h, len, &s.mt, false)) {
type = audio;
}
}
// VC1
- if(type == unknown) {
+ if (type == unknown) {
Seek(pos);
CMpegSplitterFile::vc1hdr h;
- if(!m_streams[video].Find(s) && Read(h, len, &s.mt, m_nVC1_GuidFlag)) {
+ if (!m_streams[video].Find(s) && Read(h, len, &s.mt, m_nVC1_GuidFlag)) {
type = video;
}
}
// DVB subtitles
- if(type == unknown) {
+ if (type == unknown) {
Seek(pos);
CMpegSplitterFile::dvbsub h;
- if(!m_streams[video].Find(s) && Read(h, len, &s.mt)) {
+ if (!m_streams[video].Find(s) && Read(h, len, &s.mt)) {
type = subpic;
}
}
@@ -604,7 +604,7 @@ DWORD CMpegSplitterFile::AddStream(WORD pid, BYTE pesid, DWORD len) int iProgram;
const CHdmvClipInfo::Stream *pClipInfo;
const program* pProgram = FindProgram (s.pid, iProgram, pClipInfo);
- if((type == unknown) && (pProgram != NULL)) {
+ if ((type == unknown) && (pProgram != NULL)) {
PES_STREAM_TYPE StreamType = INVALID;
Seek(pos);
@@ -613,14 +613,14 @@ DWORD CMpegSplitterFile::AddStream(WORD pid, BYTE pesid, DWORD len) switch (StreamType) {
case AUDIO_STREAM_LPCM : {
CMpegSplitterFile::hdmvlpcmhdr h;
- if(!m_streams[audio].Find(s) && Read(h, &s.mt)) {
+ if (!m_streams[audio].Find(s) && Read(h, &s.mt)) {
type = audio;
}
}
break;
case PRESENTATION_GRAPHICS_STREAM : {
CMpegSplitterFile::hdmvsubhdr h;
- if(!m_streams[subpic].Find(s) && Read(h, &s.mt, pClipInfo ? pClipInfo->m_LanguageCode : NULL)) {
+ if (!m_streams[subpic].Find(s) && Read(h, &s.mt, pClipInfo ? pClipInfo->m_LanguageCode : NULL)) {
m_bIsHdmv = true;
type = subpic;
}
@@ -628,15 +628,15 @@ DWORD CMpegSplitterFile::AddStream(WORD pid, BYTE pesid, DWORD len) break;
}
}
- } else if((m_AC3CoreOnly != 1) && m_init){
+ } else if ((m_AC3CoreOnly != 1) && m_init) {
int iProgram;
const CHdmvClipInfo::Stream *pClipInfo;
const program* pProgram = FindProgram (s.pid, iProgram, pClipInfo);
- if((type == unknown) && (pProgram != NULL) && AUDIO_STREAM_AC3_TRUE_HD == pProgram->streams[iProgram].type) {
+ if ((type == unknown) && (pProgram != NULL) && AUDIO_STREAM_AC3_TRUE_HD == pProgram->streams[iProgram].type) {
const stream* source = m_streams[audio].FindStream(s.pid);
- if(source && source->mt.subtype == MEDIASUBTYPE_DOLBY_AC3) {
+ if (source && source->mt.subtype == MEDIASUBTYPE_DOLBY_AC3) {
CMpegSplitterFile::ac3hdr h;
- if(Read(h, len, &s.mt, false, (m_AC3CoreOnly == 1)) && s.mt.subtype == MEDIASUBTYPE_DOLBY_TRUEHD) {
+ if (Read(h, len, &s.mt, false, (m_AC3CoreOnly == 1)) && s.mt.subtype == MEDIASUBTYPE_DOLBY_TRUEHD) {
m_streams[audio].Replace((stream&)*source, s, this);
}
}
@@ -646,7 +646,7 @@ DWORD CMpegSplitterFile::AddStream(WORD pid, BYTE pesid, DWORD len) #if (EVO_SUPPORT != 0)
else if (pesid == 0xfd) { // TODO EVO SUPPORT
CMpegSplitterFile::vc1hdr h;
- if(!m_streams[video].Find(s) && Read(h, len, &s.mt, m_nVC1_GuidFlag)) {
+ if (!m_streams[video].Find(s) && Read(h, len, &s.mt, m_nVC1_GuidFlag)) {
type = video;
}
}
@@ -656,98 +656,98 @@ DWORD CMpegSplitterFile::AddStream(WORD pid, BYTE pesid, DWORD len) WORD w = (WORD)BitRead(16, true);
DWORD dw = (DWORD)BitRead(32, true);
- if(b >= 0x80 && b < 0x88 || w == 0x0b77) { // ac3
+ if (b >= 0x80 && b < 0x88 || w == 0x0b77) { // ac3
s.ps1id = (b >= 0x80 && b < 0x88) ? (BYTE)(BitRead(32) >> 24) : 0x80;
CMpegSplitterFile::ac3hdr h;
- if(!m_streams[audio].Find(s) && Read(h, len, &s.mt)) {
+ if (!m_streams[audio].Find(s) && Read(h, len, &s.mt)) {
type = audio;
}
- } else if(b >= 0x88 && b < 0x90 || dw == 0x7ffe8001) { // dts
+ } else if (b >= 0x88 && b < 0x90 || dw == 0x7ffe8001) { // dts
s.ps1id = (b >= 0x88 && b < 0x90) ? (BYTE)(BitRead(32) >> 24) : 0x88;
CMpegSplitterFile::dtshdr h;
- if(!m_streams[audio].Find(s) && Read(h, len, &s.mt)) {
+ if (!m_streams[audio].Find(s) && Read(h, len, &s.mt)) {
type = audio;
}
- } else if(b >= 0xa0 && b < 0xa8) { // lpcm
+ } else if (b >= 0xa0 && b < 0xa8) { // lpcm
s.ps1id = (b >= 0xa0 && b < 0xa8) ? (BYTE)(BitRead(32) >> 24) : 0xa0;
CMpegSplitterFile::lpcmhdr h;
- if(Read(h, &s.mt) && !m_streams[audio].Find(s)) { // note the reversed order, the header should be stripped always even if it's not a new stream
+ if (Read(h, &s.mt) && !m_streams[audio].Find(s)) { // note the reversed order, the header should be stripped always even if it's not a new stream
type = audio;
}
- } else if(b >= 0x20 && b < 0x40) { // DVD subpic
+ } else if (b >= 0x20 && b < 0x40) { // DVD subpic
s.ps1id = (BYTE)BitRead(8);
CMpegSplitterFile::dvdspuhdr h;
- if(!m_streams[subpic].Find(s) && Read(h, &s.mt)) {
+ if (!m_streams[subpic].Find(s) && Read(h, &s.mt)) {
type = subpic;
}
- } else if(b >= 0x70 && b < 0x80) { // SVCD subpic
+ } else if (b >= 0x70 && b < 0x80) { // SVCD subpic
s.ps1id = (BYTE)BitRead(8);
CMpegSplitterFile::svcdspuhdr h;
- if(!m_streams[subpic].Find(s) && Read(h, &s.mt)) {
+ if (!m_streams[subpic].Find(s) && Read(h, &s.mt)) {
type = subpic;
}
- } else if(b >= 0x00 && b < 0x10) { // CVD subpic
+ } else if (b >= 0x00 && b < 0x10) { // CVD subpic
s.ps1id = (BYTE)BitRead(8);
CMpegSplitterFile::cvdspuhdr h;
- if(!m_streams[subpic].Find(s) && Read(h, &s.mt)) {
+ if (!m_streams[subpic].Find(s) && Read(h, &s.mt)) {
type = subpic;
}
- } else if(w == 0xffa0 || w == 0xffa1) { // ps2-mpg audio
+ } else if (w == 0xffa0 || w == 0xffa1) { // ps2-mpg audio
s.ps1id = (BYTE)BitRead(8);
s.pid = (WORD)((BitRead(8) << 8) | BitRead(16)); // pid = 0xa000 | track id
CMpegSplitterFile::ps2audhdr h;
- if(!m_streams[audio].Find(s) && Read(h, &s.mt)) {
+ if (!m_streams[audio].Find(s) && Read(h, &s.mt)) {
type = audio;
}
- } else if(w == 0xff90) { // ps2-mpg ac3 or subtitles
+ } else if (w == 0xff90) { // ps2-mpg ac3 or subtitles
s.ps1id = (BYTE)BitRead(8);
s.pid = (WORD)((BitRead(8) << 8) | BitRead(16)); // pid = 0x9000 | track id
w = (WORD)BitRead(16, true);
- if(w == 0x0b77) {
+ if (w == 0x0b77) {
CMpegSplitterFile::ac3hdr h;
- if(!m_streams[audio].Find(s) && Read(h, len, &s.mt)) {
+ if (!m_streams[audio].Find(s) && Read(h, len, &s.mt)) {
type = audio;
}
- } else if(w == 0x0000) { // usually zero...
+ } else if (w == 0x0000) { // usually zero...
CMpegSplitterFile::ps2subhdr h;
- if(!m_streams[subpic].Find(s) && Read(h, &s.mt)) {
+ if (!m_streams[subpic].Find(s) && Read(h, &s.mt)) {
type = subpic;
}
}
}
#if (EVO_SUPPORT != 0)
- else if(b >= 0xc0 && b < 0xc8) { // dolby digital +
+ else if (b >= 0xc0 && b < 0xc8) { // dolby digital +
s.ps1id = (BYTE)BitRead(8);
s.pid = (WORD)((BitRead(8) << 8) | BitRead(16)); // pid = 0x9000 | track id
w = (WORD)BitRead(16, true);
- if(w == 0x0b77) {
+ if (w == 0x0b77) {
CMpegSplitterFile::ac3hdr h;
- if(!m_streams[audio].Find(s) && Read(h, len, &s.mt)) {
+ if (!m_streams[audio].Find(s) && Read(h, len, &s.mt)) {
type = audio;
}
}
}
#endif
}
- } else if(pesid == 0xbe) { // padding
- } else if(pesid == 0xbf) { // private stream 2
+ } else if (pesid == 0xbe) { // padding
+ } else if (pesid == 0xbf) { // private stream 2
}
- if(type != unknown && !m_streams[type].Find(s)) {
- if(s.pid) {
- for(int i = 0; i < unknown; i++) {
- if(m_streams[i].Find(s)) {
+ if (type != unknown && !m_streams[type].Find(s)) {
+ if (s.pid) {
+ for (int i = 0; i < unknown; i++) {
+ if (m_streams[i].Find(s)) {
/*ASSERT(0);*/
return s;
}
@@ -768,7 +768,7 @@ void CMpegSplitterFile::AddHdmvPGStream(WORD pid, const char* language_code) s.pesid = 0xbd;
CMpegSplitterFile::hdmvsubhdr h;
- if(!m_streams[subpic].Find(s) && Read(h, &s.mt, language_code)) {
+ if (!m_streams[subpic].Find(s) && Read(h, &s.mt, language_code)) {
m_streams[subpic].Insert(s, this);
}
}
@@ -789,38 +789,38 @@ void CMpegSplitterFile::UpdatePrograms(const trhdr& h, bool UpdateLang) {
CAutoLock cAutoLock(&m_csProps);
- if(h.payload && h.payloadstart && h.pid == 0) {
+ if (h.payload && h.payloadstart && h.pid == 0) {
trsechdr h2;
- if(Read(h2) && h2.table_id == 0) {
+ if (Read(h2) && h2.table_id == 0) {
CAtlMap<WORD, bool> newprograms;
int len = h2.section_length;
len -= 5+4;
- for(int i = len/4; i > 0; i--) {
+ for (int i = len/4; i > 0; i--) {
WORD program_number = (WORD)BitRead(16);
BYTE reserved = (BYTE)BitRead(3);
WORD pid = (WORD)BitRead(13);
UNUSED_ALWAYS(reserved);
- if(program_number != 0) {
+ if (program_number != 0) {
m_programs[pid].program_number = program_number;
newprograms[program_number] = true;
}
}
POSITION pos = m_programs.GetStartPosition();
- while(pos) {
+ while (pos) {
const CAtlMap<WORD, program>::CPair* pPair = m_programs.GetNext(pos);
- if(!newprograms.Lookup(pPair->m_value.program_number)) {
+ if (!newprograms.Lookup(pPair->m_value.program_number)) {
m_programs.RemoveKey(pPair->m_key);
}
}
}
- } else if(CAtlMap<WORD, program>::CPair* pPair = m_programs.Lookup(h.pid)) {
- if(h.payload && h.payloadstart) {
+ } else if (CAtlMap<WORD, program>::CPair* pPair = m_programs.Lookup(h.pid)) {
+ if (h.payload && h.payloadstart) {
trsechdr h2;
- if(Read(h2) && h2.table_id == 2) {
+ if (Read(h2) && h2.table_id == 2) {
int len = h2.section_length;
len -= 5+4;
@@ -829,8 +829,8 @@ void CMpegSplitterFile::UpdatePrograms(const trhdr& h, bool UpdateLang) CGolombBuffer gb(buffer, len);
int max_len = h.bytes - 9;
-
- if(len > max_len) {
+
+ if (len > max_len) {
memset(pPair->m_value.ts_buffer, 0, sizeof(pPair->m_value.ts_buffer));
pPair->m_value.ts_len_cur = max_len;
pPair->m_value.ts_len_packet = len;
@@ -841,9 +841,9 @@ void CMpegSplitterFile::UpdatePrograms(const trhdr& h, bool UpdateLang) }
}
} else {
- if(pPair->m_value.ts_len_cur > 0) {
+ if (pPair->m_value.ts_len_cur > 0) {
int len = pPair->m_value.ts_len_packet - pPair->m_value.ts_len_cur;
- if(len > h.bytes) {
+ if (len > h.bytes) {
ByteRead(pPair->m_value.ts_buffer + pPair->m_value.ts_len_cur, h.bytes);
pPair->m_value.ts_len_cur += h.bytes;
} else {
@@ -858,7 +858,7 @@ void CMpegSplitterFile::UpdatePrograms(const trhdr& h, bool UpdateLang) void CMpegSplitterFile::UpdatePrograms(CGolombBuffer gb, WORD pid, bool UpdateLang)
{
- if(CAtlMap<WORD, program>::CPair* pPair = m_programs.Lookup(pid))
+ if (CAtlMap<WORD, program>::CPair* pPair = m_programs.Lookup(pid))
{
memset(pPair->m_value.streams, 0, sizeof(pPair->m_value.streams));
@@ -873,14 +873,14 @@ void CMpegSplitterFile::UpdatePrograms(CGolombBuffer gb, WORD pid, bool UpdateLa UNUSED_ALWAYS(reserved2);
len -= (4 + program_info_length);
- if(len <= 0)
+ if (len <= 0)
return;
- while(program_info_length-- > 0) {
+ while (program_info_length-- > 0) {
gb.BitRead(8);
}
- for(int i = 0; i < countof(pPair->m_value.streams) && len >= 5; i++) {
+ for (int i = 0; i < countof(pPair->m_value.streams) && len >= 5; i++) {
BYTE stream_type = (BYTE)gb.BitRead(8);
BYTE nreserved1 = (BYTE)gb.BitRead(3);
WORD pid = (WORD)gb.BitRead(13);
@@ -891,14 +891,14 @@ void CMpegSplitterFile::UpdatePrograms(CGolombBuffer gb, WORD pid, bool UpdateLa pPair->m_value.streams[i].pid = pid;
pPair->m_value.streams[i].type = (PES_STREAM_TYPE)stream_type;
-
- if(m_ForcedSub) {
- if(stream_type == PRESENTATION_GRAPHICS_STREAM) {
+
+ if (m_ForcedSub) {
+ if (stream_type == PRESENTATION_GRAPHICS_STREAM) {
stream s;
s.pid = pid;
CMpegSplitterFile::hdmvsubhdr hdr;
- if(Read(hdr, &s.mt, NULL)) {
- if(!m_streams[subpic].Find(s)) {
+ if (Read(hdr, &s.mt, NULL)) {
+ if (!m_streams[subpic].Find(s)) {
m_streams[subpic].Insert(s, this);
}
}
@@ -906,43 +906,43 @@ void CMpegSplitterFile::UpdatePrograms(CGolombBuffer gb, WORD pid, bool UpdateLa }
len -= (5 + ES_info_length);
- if(len < 0)
+ if (len < 0)
break;
- if(ES_info_length<=2)
+ if (ES_info_length<=2)
continue;
- if(UpdateLang) {
+ if (UpdateLang) {
int info_length = ES_info_length;
- for(;;) {
+ for (;;) {
BYTE descriptor_tag = gb.BitRead(8);
BYTE descriptor_length = gb.BitRead(8);
info_length -= (2 + descriptor_length);
- if(info_length < 0)
+ if (info_length < 0)
break;
char ch[4];
- switch(descriptor_tag) {
+ switch (descriptor_tag) {
case 0x0a: // ISO 639 language descriptor
case 0x56: // Teletext descriptor
case 0x59: // Subtitling descriptor
gb.ReadBuffer((BYTE *)ch, 3);
ch[3] = 0;
- for(int i = 3; i < descriptor_length; i++) {
+ for (int i = 3; i < descriptor_length; i++) {
gb.BitRead(8);
}
- if(!(ch[0] == 'u' && ch[1] == 'n' && ch[2] == 'd')) {
+ if (!(ch[0] == 'u' && ch[1] == 'n' && ch[2] == 'd')) {
m_pPMT_Lang[pid] = ISO6392ToLanguage(ch);
}
break;
default:
- for(int i = 0; i < descriptor_length; i++) {
+ for (int i = 0; i < descriptor_length; i++) {
gb.BitRead(8);
}
break;
}
- if(info_length<=2) break;
+ if (info_length<=2) break;
}
} else {
- while(ES_info_length-- > 0) {
+ while (ES_info_length-- > 0) {
gb.BitRead(8);
}
}
@@ -970,11 +970,11 @@ const CMpegSplitterFile::program* CMpegSplitterFile::FindProgram(WORD pid, int & POSITION pos = m_programs.GetStartPosition();
- while(pos) {
+ while (pos) {
program* p = &m_programs.GetNextValue(pos);
- for(int i = 0; i < countof(p->streams); i++) {
- if(p->streams[i].pid == pid) {
+ for (int i = 0; i < countof(p->streams); i++) {
+ if (p->streams[i].pid == pid) {
iStream = i;
return p;
}
diff --git a/src/filters/parser/MpegSplitter/MpegSplitterFile.h b/src/filters/parser/MpegSplitter/MpegSplitterFile.h index 300dd30c1..46c4f23ec 100644 --- a/src/filters/parser/MpegSplitter/MpegSplitterFile.h +++ b/src/filters/parser/MpegSplitter/MpegSplitterFile.h @@ -78,21 +78,22 @@ public: }
};
- enum {video, audio, subpic,
+ enum {video, audio, subpic,
#if defined(MVC_SUPPORT)
- stereo,
+ stereo,
#endif
- unknown};
+ unknown
+ };
class CStreamList : public CAtlList<stream>
{
public:
void Insert(stream& s, CMpegSplitterFile *_pFile) {
s.m_pFile = _pFile;
- if(_pFile->m_TrackPriority) {
- for(POSITION pos = GetHeadPosition(); pos; GetNext(pos)) {
+ if (_pFile->m_TrackPriority) {
+ for (POSITION pos = GetHeadPosition(); pos; GetNext(pos)) {
stream& s2 = GetAt(pos);
- if(s < s2) {
+ if (s < s2) {
InsertBefore(pos, s);
return;
}
@@ -100,9 +101,9 @@ public: AddTail(s);
} else {
AddTail(s);
- if(GetCount() > 1) {
+ if (GetCount() > 1) {
for (size_t j=0; j<GetCount(); j++) {
- for(size_t i=0; i<GetCount()-1; i++) {
+ for (size_t i=0; i<GetCount()-1; i++) {
if (GetAt(FindIndex(i)) > GetAt(FindIndex(i+1))) {
SwapElements(FindIndex(i), FindIndex(i+1));
}
@@ -115,9 +116,9 @@ public: void Replace(stream& source, stream& dest, CMpegSplitterFile *_pFile) {
source.m_pFile = _pFile;
dest.m_pFile = _pFile;
- for(POSITION pos = GetHeadPosition(); pos; GetNext(pos)) {
+ for (POSITION pos = GetHeadPosition(); pos; GetNext(pos)) {
stream& s = GetAt(pos);
- if(source == s) {
+ if (source == s) {
SetAt(pos, dest);
return;
}
@@ -130,15 +131,15 @@ public: type == audio ? L"Audio" :
type == subpic ? L"Subtitle" :
#if defined(MVC_SUPPORT)
- type == stereo ? L"Stereo" :
+ type == stereo ? L"Stereo" :
#endif
L"Unknown";
}
const stream* FindStream(int pid) {
- for(POSITION pos = GetHeadPosition(); pos; GetNext(pos)) {
+ for (POSITION pos = GetHeadPosition(); pos; GetNext(pos)) {
const stream& s = GetAt(pos);
- if(s.pid == pid) {
+ if (s.pid == pid) {
return &s;
}
}
diff --git a/src/filters/parser/MpegSplitter/MpegSplitterSettingsWnd.cpp b/src/filters/parser/MpegSplitter/MpegSplitterSettingsWnd.cpp index ff194e856..b813d4d37 100644 --- a/src/filters/parser/MpegSplitter/MpegSplitterSettingsWnd.cpp +++ b/src/filters/parser/MpegSplitter/MpegSplitterSettingsWnd.cpp @@ -42,11 +42,11 @@ bool CMpegSplitterSettingsWnd::OnConnect(const CInterfaceList<IUnknown, &IID_IUn m_pMSF.Release();
POSITION pos = pUnks.GetHeadPosition();
- while(pos && !(m_pMSF = pUnks.GetNext(pos))) {
+ while (pos && !(m_pMSF = pUnks.GetNext(pos))) {
;
}
- if(!m_pMSF) {
+ if (!m_pMSF) {
return false;
}
@@ -63,7 +63,7 @@ bool CMpegSplitterSettingsWnd::OnActivate() int nPosY = 10;
m_grpDefault.Create (ResStr(IDS_OPTIONS_CAPTION), WS_VISIBLE|WS_CHILD | BS_GROUPBOX, CRect (10, nPosY, 320, nPosY+285), this, (UINT)IDC_STATIC);
-
+
nPosY += VERTICAL_SPACING;
m_cbFastStreamChange.Create (ResStr(IDS_MPEGSPLITTER_FSTREAM_CHANGE), WS_VISIBLE|WS_CHILD|WS_TABSTOP|BS_AUTOCHECKBOX|BS_LEFTTEXT, CRect (LEFT_SPACING, nPosY, 305, nPosY+15), this, IDC_PP_FAST_STREAM_SELECT);
@@ -72,7 +72,7 @@ bool CMpegSplitterSettingsWnd::OnActivate() nPosY += VERTICAL_SPACING;
m_cbTrackPriority.Create (_T("Change Audio-track Priority"), WS_VISIBLE|WS_CHILD|WS_TABSTOP|BS_AUTOCHECKBOX|BS_LEFTTEXT, CRect (LEFT_SPACING, nPosY, 305, nPosY+15), this, IDC_PP_TRACK_PRIORITY);
-
+
nPosY += VERTICAL_SPACING;
m_txtAudioLanguageOrder.Create (ResStr(IDS_MPEGSPLITTER_LANG_ORDER), WS_VISIBLE|WS_CHILD, CRect (LEFT_SPACING, nPosY, 200, nPosY+15), this, (UINT)IDC_STATIC);
nPosY += 15;
@@ -101,7 +101,7 @@ bool CMpegSplitterSettingsWnd::OnActivate() m_cbAC3Core.Create (_T("AC-3 Core"), WS_VISIBLE|WS_CHILD|WS_TABSTOP|BS_AUTORADIOBUTTON|BS_TOP|BS_MULTILINE, CRect (LEFT_SPACING + 15 + 95, nPosY, LEFT_SPACING + 15 + 185, nPosY+20), this, IDC_PP_AC3CORE);
m_cbAsIs.Create (_T("As Source"), WS_VISIBLE|WS_CHILD|WS_TABSTOP|BS_AUTORADIOBUTTON|BS_TOP|BS_MULTILINE, CRect (LEFT_SPACING + 15 + 190, nPosY, LEFT_SPACING + 15 + 260, nPosY+20), this, IDC_PP_ASIS);
- if(m_pMSF) {
+ if (m_pMSF) {
m_cbFastStreamChange.SetCheck(m_pMSF->GetFastStreamChange());
m_cbForcedSub.SetCheck(m_pMSF->GetForcedSub());
m_cbTrackPriority.SetCheck(m_pMSF->GetTrackPriority());
@@ -119,7 +119,7 @@ bool CMpegSplitterSettingsWnd::OnActivate() #endif
- for(CWnd* pWnd = GetWindow(GW_CHILD); pWnd; pWnd = pWnd->GetNextWindow()) {
+ for (CWnd* pWnd = GetWindow(GW_CHILD); pWnd; pWnd = pWnd->GetNextWindow()) {
pWnd->SetFont(&m_font, FALSE);
}
@@ -134,14 +134,14 @@ bool CMpegSplitterSettingsWnd::OnApply() {
OnDeactivate();
- if(m_pMSF) {
+ if (m_pMSF) {
m_pMSF->SetFastStreamChange(m_cbFastStreamChange.GetCheck());
m_pMSF->SetForcedSub(m_cbForcedSub.GetCheck());
m_pMSF->SetTrackPriority(m_cbTrackPriority.GetCheck());
m_pMSF->SetVC1_GuidFlag(m_cbVC1_GuidFlag.GetCurSel() + 1);
m_pMSF->SetTrueHD(m_cbTrueHD.GetCheck() ? 0 : m_cbAC3Core.GetCheck() ? 1 : 2);
-#ifdef REGISTER_FILTER
+#ifdef REGISTER_FILTER
CString str = _T("");
m_edtAudioLanguageOrder.GetWindowText(str);
m_pMSF->SetAudioLanguageOrder(str.GetBuffer());
diff --git a/src/filters/parser/OggSplitter/OggFile.cpp b/src/filters/parser/OggSplitter/OggFile.cpp index 6df7d81cf..ac7ce7227 100644 --- a/src/filters/parser/OggSplitter/OggFile.cpp +++ b/src/filters/parser/OggSplitter/OggFile.cpp @@ -4,7 +4,7 @@ COggFile::COggFile(IAsyncReader* pAsyncReader, HRESULT& hr)
: CBaseSplitterFile(pAsyncReader, hr, DEFAULT_CACHE_LENGTH, false)
{
- if(FAILED(hr)) {
+ if (FAILED(hr)) {
return;
}
hr = Init();
@@ -13,7 +13,7 @@ COggFile::COggFile(IAsyncReader* pAsyncReader, HRESULT& hr) HRESULT COggFile::Init()
{
Seek(0);
- if(!Sync()) {
+ if (!Sync()) {
return E_FAIL;
}
@@ -25,11 +25,11 @@ bool COggFile::Sync(HANDLE hBreak) __int64 start = GetPos();
DWORD dw;
- for(__int64 i = 0, j = hBreak ? GetLength() - start : 65536;
+ for (__int64 i = 0, j = hBreak ? GetLength() - start : 65536;
i < j && S_OK == ByteRead((BYTE*)&dw, sizeof(dw))
&& ((i&0xffff) || !hBreak || WaitForSingleObject(hBreak, 0) != WAIT_OBJECT_0);
i++, Seek(start + i)) {
- if(dw == 'SggO') {
+ if (dw == 'SggO') {
Seek(start + i);
return true;
}
@@ -51,27 +51,27 @@ bool COggFile::Read(OggPage& page, bool fFull, HANDLE hBreak) page.m_lens.RemoveAll();
page.SetCount(0);
- if(!Read(page.m_hdr, hBreak)) {
+ if (!Read(page.m_hdr, hBreak)) {
return false;
}
int pagelen = 0, packetlen = 0;
- for(BYTE i = 0; i < page.m_hdr.number_page_segments; i++) {
+ for (BYTE i = 0; i < page.m_hdr.number_page_segments; i++) {
BYTE b;
- if(S_OK != ByteRead(&b, 1)) {
+ if (S_OK != ByteRead(&b, 1)) {
return false;
}
packetlen += b;
- if(1/*b < 0xff*/) {
+ if (1/*b < 0xff*/) {
page.m_lens.AddTail(packetlen);
pagelen += packetlen;
packetlen = 0;
}
}
- if(fFull) {
+ if (fFull) {
page.SetCount(pagelen);
- if(S_OK != ByteRead(page.GetData(), page.GetCount())) {
+ if (S_OK != ByteRead(page.GetData(), page.GetCount())) {
return false;
}
} else {
diff --git a/src/filters/parser/OggSplitter/OggSplitter.cpp b/src/filters/parser/OggSplitter/OggSplitter.cpp index 8851b8053..c770f2007 100644 --- a/src/filters/parser/OggSplitter/OggSplitter.cpp +++ b/src/filters/parser/OggSplitter/OggSplitter.cpp @@ -100,13 +100,13 @@ public: return(pos >= 0 && pos < m_len);
}
unsigned int showbits(int cnt) { // a bit unclean, but works and can read backwards too! :P
- if(!hasbits(cnt)) {
+ if (!hasbits(cnt)) {
ASSERT(0);
return 0;
}
unsigned int ret = 0, off = 0;
BYTE* p = m_p;
- if(cnt < 0) {
+ if (cnt < 0) {
p += (m_pos+cnt)>>3;
off = (m_pos+cnt)&7;
cnt = abs(cnt);
@@ -120,7 +120,7 @@ public: off = 0;
cnt -= 8 - off;
}
- while(cnt > 0) {
+ while (cnt > 0) {
ret |= (*p++&((1<<min(cnt,8))-1)) << off;
off += 8;
cnt -= 8;
@@ -158,7 +158,7 @@ STDMETHODIMP COggSplitterFilter::QueryFilterInfo(FILTER_INFO* pInfo) wcscpy(pInfo->achName, OggSourceName);
}
pInfo->pGraph = m_pGraph;
- if(m_pGraph) {
+ if (m_pGraph) {
m_pGraph->AddRef();
}
@@ -174,10 +174,10 @@ HRESULT COggSplitterFilter::CreateOutputs(IAsyncReader* pAsyncReader) m_pFile.Free();
m_pFile.Attach(DNew COggFile(pAsyncReader, hr));
- if(!m_pFile) {
+ if (!m_pFile) {
return E_OUTOFMEMORY;
}
- if(FAILED(hr)) {
+ if (FAILED(hr)) {
m_pFile.Free();
return hr;
}
@@ -189,14 +189,14 @@ HRESULT COggSplitterFilter::CreateOutputs(IAsyncReader* pAsyncReader) m_pFile->Seek(0);
OggPage page;
- for(int i = 0, nWaitForMore = 0; m_pFile->Read(page), i<100; i++) {
+ for (int i = 0, nWaitForMore = 0; m_pFile->Read(page), i<100; i++) {
BYTE* p = page.GetData();
- if(!p) {
+ if (!p) {
break;
}
- if(!(page.m_hdr.header_type_flag & OggPageHeader::continued)) {
- if(!memcmp(p, "fishead", 7) || !memcmp(p, "fisbone", 7)) {
+ if (!(page.m_hdr.header_type_flag & OggPageHeader::continued)) {
+ if (!memcmp(p, "fishead", 7) || !memcmp(p, "fisbone", 7)) {
continue;
}
@@ -207,42 +207,42 @@ HRESULT COggSplitterFilter::CreateOutputs(IAsyncReader* pAsyncReader) HRESULT hr;
- if(type >= 0x80 && type <= 0x82 && !memcmp(p, "theora", 6)) {
- if(type == 0x80) {
+ if (type >= 0x80 && type <= 0x82 && !memcmp(p, "theora", 6)) {
+ if (type == 0x80) {
name.Format(L"Theora %d", i);
CAutoPtr<CBaseSplitterOutputPin> pPinOut;
pPinOut.Attach(DNew COggTheoraOutputPin(page.GetData(), name, this, this, &hr));
AddOutputPin(page.m_hdr.bitstream_serial_number, pPinOut);
nWaitForMore++;
}
- } else if(type == 1 && (page.m_hdr.header_type_flag & OggPageHeader::first)) {
+ } else if (type == 1 && (page.m_hdr.header_type_flag & OggPageHeader::first)) {
CAutoPtr<CBaseSplitterOutputPin> pPinOut;
- if(!memcmp(p, "vorbis", 6)) {
+ if (!memcmp(p, "vorbis", 6)) {
name.Format(L"Vorbis %d", i);
pPinOut.Attach(DNew COggVorbisOutputPin((OggVorbisIdHeader*)(p+6), name, this, this, &hr));
nWaitForMore++;
- } else if(!memcmp(p, "video", 5)) {
+ } else if (!memcmp(p, "video", 5)) {
name.Format(L"Video %d", i);
pPinOut.Attach(DNew COggVideoOutputPin((OggStreamHeader*)p, name, this, this, &hr));
- } else if(!memcmp(p, "audio", 5)) {
+ } else if (!memcmp(p, "audio", 5)) {
name.Format(L"Audio %d", i);
pPinOut.Attach(DNew COggAudioOutputPin((OggStreamHeader*)p, name, this, this, &hr));
- } else if(!memcmp(p, "text", 4)) {
+ } else if (!memcmp(p, "text", 4)) {
name.Format(L"Text %d", i);
pPinOut.Attach(DNew COggTextOutputPin((OggStreamHeader*)p, name, this, this, &hr));
- } else if(!memcmp(p, "Direct Show Samples embedded in Ogg", 35)) {
+ } else if (!memcmp(p, "Direct Show Samples embedded in Ogg", 35)) {
name.Format(L"DirectShow %d", i);
pPinOut.Attach(DNew COggDirectShowOutputPin((AM_MEDIA_TYPE*)(p+35+sizeof(GUID)), name, this, this, &hr));
}
AddOutputPin(page.m_hdr.bitstream_serial_number, pPinOut);
- } else if(type == 3 && !memcmp(p, "vorbis", 6)) {
- if(COggSplitterOutputPin* pOggPin =
+ } else if (type == 3 && !memcmp(p, "vorbis", 6)) {
+ if (COggSplitterOutputPin* pOggPin =
dynamic_cast<COggSplitterOutputPin*>(GetOutputPin(page.m_hdr.bitstream_serial_number))) {
pOggPin->AddComment(p+6, page.GetCount()-6-1);
}
- } else if(type == 0x7F && page.GetCount()>12 && *(long*)(p+8) == 0x43614C66) { // Flac
+ } else if (type == 0x7F && page.GetCount()>12 && *(long*)(p+8) == 0x43614C66) { // Flac
// Ogg Flac : method 1
CAutoPtr<CBaseSplitterOutputPin> pPinOut;
name.Format(L"Flac %d", i);
@@ -258,37 +258,37 @@ HRESULT COggSplitterFilter::CreateOutputs(IAsyncReader* pAsyncReader) pPinOut.Attach(DNew COggFlacOutputPin(p, page.GetCount(), name, this, this, &hr));
AddOutputPin(page.m_hdr.bitstream_serial_number, pPinOut);
}
- } else if(!(type&1) && nWaitForMore == 0) {
+ } else if (!(type&1) && nWaitForMore == 0) {
break;
}
}
- if(COggTheoraOutputPin* p = dynamic_cast<COggTheoraOutputPin*>(GetOutputPin(page.m_hdr.bitstream_serial_number))) {
+ if (COggTheoraOutputPin* p = dynamic_cast<COggTheoraOutputPin*>(GetOutputPin(page.m_hdr.bitstream_serial_number))) {
p->UnpackInitPage(page);
- if(p->IsInitialized()) {
+ if (p->IsInitialized()) {
nWaitForMore--;
}
}
- if(COggVorbisOutputPin* p = dynamic_cast<COggVorbisOutputPin*>(GetOutputPin(page.m_hdr.bitstream_serial_number))) {
+ if (COggVorbisOutputPin* p = dynamic_cast<COggVorbisOutputPin*>(GetOutputPin(page.m_hdr.bitstream_serial_number))) {
p->UnpackInitPage(page);
- if(p->IsInitialized()) {
+ if (p->IsInitialized()) {
nWaitForMore--;
}
}
}
- if(m_pOutputs.IsEmpty()) {
+ if (m_pOutputs.IsEmpty()) {
return E_FAIL;
}
- if(m_pFile->IsRandomAccess()) {
+ if (m_pFile->IsRandomAccess()) {
m_pFile->Seek(max(m_pFile->GetLength()-65536, 0));
OggPage page;
- while(m_pFile->Read(page)) {
+ while (m_pFile->Read(page)) {
COggSplitterOutputPin* pOggPin = dynamic_cast<COggSplitterOutputPin*>(GetOutputPin(page.m_hdr.bitstream_serial_number));
- if(!pOggPin || page.m_hdr.granule_position == -1) {
+ if (!pOggPin || page.m_hdr.granule_position == -1) {
continue;
}
REFERENCE_TIME rt = pOggPin->GetRefTime(page.m_hdr.granule_position);
@@ -309,19 +309,19 @@ HRESULT COggSplitterFilter::CreateOutputs(IAsyncReader* pAsyncReader) tagmap[L"DESCRIPTION"] = L"DESC";
POSITION pos2 = tagmap.GetStartPosition();
- while(pos2) {
+ while (pos2) {
CStringW oggtag, dsmtag;
tagmap.GetNextAssoc(pos2, oggtag, dsmtag);
POSITION pos = m_pOutputs.GetHeadPosition();
- while(pos) {
+ while (pos) {
COggSplitterOutputPin* pOggPin = dynamic_cast<COggSplitterOutputPin*>((CBaseOutputPin*)m_pOutputs.GetNext(pos));
- if(!pOggPin) {
+ if (!pOggPin) {
continue;
}
CStringW value = pOggPin->GetComment(oggtag);
- if(!value.IsEmpty()) {
+ if (!value.IsEmpty()) {
SetProperty(dsmtag, value);
break;
}
@@ -329,27 +329,27 @@ HRESULT COggSplitterFilter::CreateOutputs(IAsyncReader* pAsyncReader) }
POSITION pos = m_pOutputs.GetHeadPosition();
- while(pos && !ChapGetCount()) {
+ while (pos && !ChapGetCount()) {
COggSplitterOutputPin* pOggPin = dynamic_cast<COggSplitterOutputPin*>((CBaseOutputPin*)m_pOutputs.GetNext(pos));
- if(!pOggPin) {
+ if (!pOggPin) {
continue;
}
- for(int i = 1; pOggPin; i++) {
+ for (int i = 1; pOggPin; i++) {
CStringW key;
key.Format(L"CHAPTER%02d", i);
CStringW time = pOggPin->GetComment(key);
- if(time.IsEmpty()) {
+ if (time.IsEmpty()) {
break;
}
key.Format(L"CHAPTER%02dNAME", i);
CStringW name = pOggPin->GetComment(key);
- if(name.IsEmpty()) {
+ if (name.IsEmpty()) {
name.Format(L"Chapter %d", i);
}
int h, m, s, ms;
WCHAR c;
- if(7 != swscanf(time, L"%d%c%d%c%d%c%d", &h, &c, &m, &c, &s, &c, &ms)) {
+ if (7 != swscanf(time, L"%d%c%d%c%d%c%d", &h, &c, &m, &c, &s, &c, &ms)) {
break;
}
REFERENCE_TIME rt = ((((REFERENCE_TIME)h*60+m)*60+s)*1000+ms)*10000;
@@ -364,7 +364,7 @@ HRESULT COggSplitterFilter::CreateOutputs(IAsyncReader* pAsyncReader) bool COggSplitterFilter::DemuxInit()
{
SetThreadName((DWORD)-1, "COggSplitterFilter");
- if(!m_pFile) {
+ if (!m_pFile) {
return false;
}
@@ -373,9 +373,9 @@ bool COggSplitterFilter::DemuxInit() void COggSplitterFilter::DemuxSeek(REFERENCE_TIME rt)
{
- if(rt <= 0 ) {
+ if (rt <= 0 ) {
m_pFile->Seek(0);
- } else if(m_rtDuration > 0) {
+ } else if (m_rtDuration > 0) {
// oh, the horror...
__int64 len = m_pFile->GetLength();
@@ -384,19 +384,19 @@ void COggSplitterFilter::DemuxSeek(REFERENCE_TIME rt) REFERENCE_TIME rtMinDiff = _I64_MAX;
- while(1) {
+ while (1) {
__int64 endpos = startpos;
REFERENCE_TIME rtPos = -1;
OggPage page;
m_pFile->Seek(startpos);
- while(m_pFile->Read(page, false)) {
- if(page.m_hdr.granule_position == -1) {
+ while (m_pFile->Read(page, false)) {
+ if (page.m_hdr.granule_position == -1) {
continue;
}
COggSplitterOutputPin* pOggPin = dynamic_cast<COggSplitterOutputPin*>(GetOutputPin(page.m_hdr.bitstream_serial_number));
- if(!pOggPin) {
+ if (!pOggPin) {
ASSERT(0);
continue;
}
@@ -409,10 +409,10 @@ void COggSplitterFilter::DemuxSeek(REFERENCE_TIME rt) __int64 rtDiff = rtPos - rt;
- if(rtDiff < 0) {
+ if (rtDiff < 0) {
rtDiff = -rtDiff;
- if(rtDiff < 1000000 || rtDiff >= rtMinDiff) {
+ if (rtDiff < 1000000 || rtDiff >= rtMinDiff) {
m_pFile->Seek(startpos);
break;
}
@@ -422,17 +422,17 @@ void COggSplitterFilter::DemuxSeek(REFERENCE_TIME rt) __int64 newpos = startpos;
- if(rtPos < rt && rtPos < m_rtDuration) {
+ if (rtPos < rt && rtPos < m_rtDuration) {
newpos = startpos + (__int64)((1.0*(rt - rtPos)/(m_rtDuration - rtPos)) * (len - startpos)) + 1024;
- if(newpos < endpos) {
+ if (newpos < endpos) {
newpos = endpos + 1024;
}
- } else if(rtPos > rt && rtPos > 0) {
+ } else if (rtPos > rt && rtPos > 0) {
newpos = startpos - (__int64)((1.0*(rtPos - rt)/(rtPos - 0)) * (startpos - 0)) - 1024;
- if(newpos >= startpos) {
+ if (newpos >= startpos) {
newpos = startpos - 1024;
}
- } else if(rtPos == rt) {
+ } else if (rtPos == rt) {
m_pFile->Seek(startpos);
break;
} else {
@@ -449,51 +449,51 @@ void COggSplitterFilter::DemuxSeek(REFERENCE_TIME rt) m_pFile->Seek(startpos);
POSITION pos = m_pOutputs.GetHeadPosition();
- while(pos) {
+ while (pos) {
COggSplitterOutputPin* pPin = dynamic_cast<COggSplitterOutputPin*>(static_cast<CBaseSplitterOutputPin*>(m_pOutputs.GetNext(pos)));
- if(!dynamic_cast<COggVideoOutputPin*>(pPin) && !dynamic_cast<COggTheoraOutputPin*>(pPin)) {
+ if (!dynamic_cast<COggVideoOutputPin*>(pPin) && !dynamic_cast<COggTheoraOutputPin*>(pPin)) {
continue;
}
bool fKeyFrameFound = false, fSkipKeyFrame = true;
__int64 endpos = _I64_MAX;
- while(!(fKeyFrameFound && !fSkipKeyFrame) && startpos > 0) {
+ while (!(fKeyFrameFound && !fSkipKeyFrame) && startpos > 0) {
OggPage page;
- while(!(fKeyFrameFound && !fSkipKeyFrame) && m_pFile->GetPos() < endpos && m_pFile->Read(page)) {
- if(page.m_hdr.granule_position == -1) {
+ while (!(fKeyFrameFound && !fSkipKeyFrame) && m_pFile->GetPos() < endpos && m_pFile->Read(page)) {
+ if (page.m_hdr.granule_position == -1) {
continue;
}
- if(pPin != dynamic_cast<COggSplitterOutputPin*>(GetOutputPin(page.m_hdr.bitstream_serial_number))) {
+ if (pPin != dynamic_cast<COggSplitterOutputPin*>(GetOutputPin(page.m_hdr.bitstream_serial_number))) {
continue;
}
- if(pPin->GetRefTime(page.m_hdr.granule_position) > rt) {
+ if (pPin->GetRefTime(page.m_hdr.granule_position) > rt) {
break;
}
- if(!fKeyFrameFound) {
+ if (!fKeyFrameFound) {
pPin->UnpackPage(page);
CAutoPtr<OggPacket> p;
- while(p = pPin->GetPacket()) {
- if(p->bSyncPoint) {
+ while (p = pPin->GetPacket()) {
+ if (p->bSyncPoint) {
fKeyFrameFound = true;
fSkipKeyFrame = p->fSkip;
}
}
- if(fKeyFrameFound) {
+ if (fKeyFrameFound) {
break;
}
} else {
pPin->UnpackPage(page);
CAutoPtr<OggPacket> p;
- while(p = pPin->GetPacket()) {
- if(!p->fSkip) {
+ while (p = pPin->GetPacket()) {
+ if (!p->fSkip) {
fSkipKeyFrame = false;
break;
}
@@ -501,7 +501,7 @@ void COggSplitterFilter::DemuxSeek(REFERENCE_TIME rt) }
}
- if(!(fKeyFrameFound && !fSkipKeyFrame)) {
+ if (!(fKeyFrameFound && !fSkipKeyFrame)) {
endpos = startpos;
startpos = max(startpos - 10*65536, 0);
}
@@ -516,25 +516,25 @@ void COggSplitterFilter::DemuxSeek(REFERENCE_TIME rt) fKeyFrameFound = false;
OggPage page;
- while(!fKeyFrameFound && m_pFile->Read(page)) {
- if(page.m_hdr.granule_position == -1) {
+ while (!fKeyFrameFound && m_pFile->Read(page)) {
+ if (page.m_hdr.granule_position == -1) {
continue;
}
- if(pPin != dynamic_cast<COggSplitterOutputPin*>(GetOutputPin(page.m_hdr.bitstream_serial_number))) {
+ if (pPin != dynamic_cast<COggSplitterOutputPin*>(GetOutputPin(page.m_hdr.bitstream_serial_number))) {
continue;
}
REFERENCE_TIME rtPos = pPin->GetRefTime(page.m_hdr.granule_position);
- if(rtPos > rt) {
+ if (rtPos > rt) {
break;
}
pPin->UnpackPage(page);
CAutoPtr<OggPacket> p;
- while(p = pPin->GetPacket()) {
- if(p->bSyncPoint) {
+ while (p = pPin->GetPacket()) {
+ if (p->bSyncPoint) {
fKeyFrameFound = true;
break;
}
@@ -556,22 +556,22 @@ bool COggSplitterFilter::DemuxLoop() HRESULT hr = S_OK;
OggPage page;
- while(SUCCEEDED(hr) && !CheckRequest(NULL) && m_pFile->Read(page, true, GetRequestHandle())) {
+ while (SUCCEEDED(hr) && !CheckRequest(NULL) && m_pFile->Read(page, true, GetRequestHandle())) {
COggSplitterOutputPin* pOggPin = dynamic_cast<COggSplitterOutputPin*>(GetOutputPin(page.m_hdr.bitstream_serial_number));
- if(!pOggPin) {
+ if (!pOggPin) {
ASSERT(0);
continue;
}
- if(!pOggPin->IsConnected()) {
+ if (!pOggPin->IsConnected()) {
continue;
}
- if(FAILED(hr = pOggPin->UnpackPage(page))) {
+ if (FAILED(hr = pOggPin->UnpackPage(page))) {
ASSERT(0);
break;
}
CAutoPtr<OggPacket> p;
- while(!CheckRequest(NULL) && SUCCEEDED(hr) && (p = pOggPin->GetPacket())) {
- if(!p->fSkip) {
+ while (!CheckRequest(NULL) && SUCCEEDED(hr) && (p = pOggPin->GetPacket())) {
+ if (!p->fSkip) {
hr = DeliverPacket(p);
}
}
@@ -605,24 +605,24 @@ void COggSplitterOutputPin::AddComment(BYTE* p, int len) {
bitstream bs(p, len);
bs.getbits(bs.getbits(32)*8);
- for(int n = bs.getbits(32); n-- > 0; ) {
+ for (int n = bs.getbits(32); n-- > 0; ) {
CStringA str;
- for(int len = bs.getbits(32); len-- > 0; ) {
+ for (int len = bs.getbits(32); len-- > 0; ) {
str += (CHAR)bs.getbits(8);
}
CAtlList<CStringA> sl;
Explode(str, sl, '=', 2);
- if(sl.GetCount() == 2) {
+ if (sl.GetCount() == 2) {
CAutoPtr<CComment> p(DNew CComment(UTF8To16(sl.GetHead()), UTF8To16(sl.GetTail())));
- if(p->m_key == L"LANGUAGE") {
+ if (p->m_key == L"LANGUAGE") {
CString lang = ISO6392ToLanguage(sl.GetTail()), iso6392 = LanguageToISO6392(CString(p->m_value));
- if(p->m_value.GetLength() == 3 && !lang.IsEmpty()) {
+ if (p->m_value.GetLength() == 3 && !lang.IsEmpty()) {
SetName(CStringW(lang));
SetProperty(L"LANG", p->m_value);
- } else if(!iso6392.IsEmpty()) {
+ } else if (!iso6392.IsEmpty()) {
SetName(p->m_value);
SetProperty(L"LANG", CStringW(iso6392));
} else {
@@ -642,9 +642,9 @@ CStringW COggSplitterOutputPin::GetComment(CStringW key) key.MakeUpper();
CAtlList<CStringW> sl;
POSITION pos = m_pComments.GetHeadPosition();
- while(pos) {
+ while (pos) {
CComment* p = m_pComments.GetNext(pos);
- if(key == p->m_key) {
+ if (key == p->m_key) {
sl.AddTail(p->m_value);
}
}
@@ -663,7 +663,7 @@ void COggSplitterOutputPin::ResetState(DWORD seqnum) HRESULT COggSplitterOutputPin::UnpackPage(OggPage& page)
{
- if(m_lastseqnum != page.m_hdr.page_sequence_number - 1) {
+ if (m_lastseqnum != page.m_hdr.page_sequence_number - 1) {
ResetState(page.m_hdr.page_sequence_number);
return S_FALSE; // FIXME
} else {
@@ -671,18 +671,18 @@ HRESULT COggSplitterOutputPin::UnpackPage(OggPage& page) }
POSITION first = page.m_lens.GetHeadPosition();
- while(first && page.m_lens.GetAt(first) == 255) {
+ while (first && page.m_lens.GetAt(first) == 255) {
page.m_lens.GetNext(first);
}
- if(!first) {
+ if (!first) {
first = page.m_lens.GetTailPosition();
}
POSITION last = page.m_lens.GetTailPosition();
- while(last && page.m_lens.GetAt(last) == 255) {
+ while (last && page.m_lens.GetAt(last) == 255) {
page.m_lens.GetPrev(last);
}
- if(!last) {
+ if (!last) {
last = page.m_lens.GetTailPosition();
}
@@ -690,36 +690,36 @@ HRESULT COggSplitterOutputPin::UnpackPage(OggPage& page) int i = 0, j = 0, len = 0;
- for(POSITION pos = page.m_lens.GetHeadPosition(); pos; page.m_lens.GetNext(pos)) {
+ for (POSITION pos = page.m_lens.GetHeadPosition(); pos; page.m_lens.GetNext(pos)) {
len = page.m_lens.GetAt(pos);
j += len;
- if(len < 255 || pos == page.m_lens.GetTailPosition()) {
- if(first == pos && (page.m_hdr.header_type_flag & OggPageHeader::continued)) {
+ if (len < 255 || pos == page.m_lens.GetTailPosition()) {
+ if (first == pos && (page.m_hdr.header_type_flag & OggPageHeader::continued)) {
// ASSERT(m_lastpacket);
- if(m_lastpacket) {
+ if (m_lastpacket) {
int size = m_lastpacket->GetCount();
m_lastpacket->SetCount(size + j-i);
memcpy(m_lastpacket->GetData() + size, pData + i, j-i);
CAutoLock csAutoLock(&m_csPackets);
- if(len < 255) {
+ if (len < 255) {
m_packets.AddTail(m_lastpacket);
}
}
} else {
CAutoPtr<OggPacket> p(DNew OggPacket());
- if(last == pos && page.m_hdr.granule_position != -1) {
+ if (last == pos && page.m_hdr.granule_position != -1) {
p->bDiscontinuity = m_fSkip;
REFERENCE_TIME rtLast = m_rtLast;
m_rtLast = GetRefTime(page.m_hdr.granule_position);
// some bad encodings have a +/-1 frame difference from the normal timeline,
// but these seem to cancel eachother out nicely so we can just ignore them
// to make it play a bit more smooth.
- if(abs(rtLast - m_rtLast) == GetRefTime(1)) {
+ if (abs(rtLast - m_rtLast) == GetRefTime(1)) {
m_rtLast = rtLast; // FIXME
}
m_fSkip = false;
@@ -727,19 +727,19 @@ HRESULT COggSplitterOutputPin::UnpackPage(OggPage& page) p->TrackNumber = page.m_hdr.bitstream_serial_number;
- if(S_OK == UnpackPacket(p, pData + i, j-i)) {
+ if (S_OK == UnpackPacket(p, pData + i, j-i)) {
//if(p->TrackNumber == 1)
//TRACE(_T("[%d]: %d, %I64d -> %I64d (skip=%d, disc=%d, sync=%d)\n"),
// (int)p->TrackNumber, p->GetCount(), p->rtStart, p->rtStop,
// (int)m_fSkip, (int)p->bDiscontinuity, (int)p->bSyncPoint);
- if(p->rtStart <= p->rtStop && p->rtStop <= p->rtStart + 10000000i64*60) {
+ if (p->rtStart <= p->rtStop && p->rtStop <= p->rtStart + 10000000i64*60) {
CAutoLock csAutoLock(&m_csPackets);
m_rtLast = p->rtStop;
p->fSkip = m_fSkip;
- if(len < 255) {
+ if (len < 255) {
m_packets.AddTail(p);
} else {
m_lastpacket = p;
@@ -761,7 +761,7 @@ CAutoPtr<OggPacket> COggSplitterOutputPin::GetPacket() {
CAutoPtr<OggPacket> p;
CAutoLock csAutoLock(&m_csPackets);
- if(m_packets.GetCount()) {
+ if (m_packets.GetCount()) {
p = m_packets.RemoveHead();
}
return p;
@@ -824,16 +824,16 @@ HRESULT COggVorbisOutputPin::UnpackInitPage(OggPage& page) {
HRESULT hr = __super::UnpackPage(page);
- while(m_packets.GetCount()) {
+ while (m_packets.GetCount()) {
Packet* p = m_packets.GetHead();
- if(p->GetCount() >= 6 && p->GetAt(0) == 0x05) {
+ if (p->GetCount() >= 6 && p->GetAt(0) == 0x05) {
// yeah, right, we are going to be parsing this backwards! :P
bitstream bs(p->GetData(), p->GetCount(), true);
- while(bs.hasbits(-1) && bs.getbits(-1) != 1) {
+ while (bs.hasbits(-1) && bs.getbits(-1) != 1) {
;
}
- for(int cnt = 0; bs.hasbits(-8-16-16-1-6); cnt++) {
+ for (int cnt = 0; bs.hasbits(-8-16-16-1-6); cnt++) {
unsigned int modes = bs.showbits(-6) + 1;
unsigned int mapping = bs.getbits(-8);
@@ -842,7 +842,7 @@ HRESULT COggVorbisOutputPin::UnpackInitPage(OggPage& page) unsigned int blockflag = bs.getbits(-1);
UNUSED_ALWAYS(mapping);
- if(transformtype != 0 || windowtype != 0) {
+ if (transformtype != 0 || windowtype != 0) {
ASSERT(modes == cnt);
UNREFERENCED_PARAMETER(modes);
break;
@@ -853,7 +853,7 @@ HRESULT COggVorbisOutputPin::UnpackInitPage(OggPage& page) }
int cnt = m_initpackets.GetCount();
- if(cnt <= 3 && (p->GetCount() >= 6 && p->GetAt(0) == 1+cnt*2)) {
+ if (cnt <= 3 && (p->GetCount() >= 6 && p->GetAt(0) == 1+cnt*2)) {
VORBISFORMAT2* vf2 = (VORBISFORMAT2*)m_mts[0].Format();
vf2->HeaderSize[cnt] = p->GetCount();
int len = m_mts[0].FormatLength();
@@ -874,16 +874,16 @@ REFERENCE_TIME COggVorbisOutputPin::GetRefTime(__int64 granule_position) HRESULT COggVorbisOutputPin::UnpackPacket(CAutoPtr<OggPacket>& p, BYTE* pData, int len)
{
- if(len > 0 && m_blockflags.GetCount()) {
+ if (len > 0 && m_blockflags.GetCount()) {
bitstream bs(pData, len);
- if(bs.getbits(1) == 0) {
+ if (bs.getbits(1) == 0) {
int x = m_blockflags.GetCount()-1, n = 0;
- while(x) {
+ while (x) {
n++;
x >>= 1;
}
DWORD blocksize = m_blocksize[m_blockflags[bs.getbits(n)]?1:0];
- if(m_lastblocksize) {
+ if (m_lastblocksize) {
m_rtLast += GetRefTime((m_lastblocksize + blocksize) >> 2);
}
m_lastblocksize = blocksize;
@@ -900,7 +900,7 @@ HRESULT COggVorbisOutputPin::UnpackPacket(CAutoPtr<OggPacket>& p, BYTE* pData, i HRESULT COggVorbisOutputPin::DeliverPacket(CAutoPtr<OggPacket> p)
{
- if(p->GetCount() > 0 && (p->GetAt(0)&1)) {
+ if (p->GetCount() > 0 && (p->GetAt(0)&1)) {
return S_OK;
}
@@ -913,9 +913,9 @@ HRESULT COggVorbisOutputPin::DeliverNewSegment(REFERENCE_TIME tStart, REFERENCE_ m_lastblocksize = 0;
- if(m_mt.subtype == MEDIASUBTYPE_Vorbis) {
+ if (m_mt.subtype == MEDIASUBTYPE_Vorbis) {
POSITION pos = m_initpackets.GetHeadPosition();
- while(pos) {
+ while (pos) {
Packet* pi = m_initpackets.GetNext(pos);
CAutoPtr<OggPacket> p(DNew OggPacket());
p->TrackNumber = pi->TrackNumber;
@@ -941,7 +941,7 @@ COggFlacOutputPin::COggFlacOutputPin(BYTE* h, int nCount, LPCWSTR pName, CBaseFi Buffer.BitRead(1); // Last-metadata-block flag
if (Buffer.BitRead(7) != 0) { // Should be a STREAMINFO block
- if(phr) {
+ if (phr) {
*phr = VFW_E_INVALID_FILE_FORMAT;
}
return;
@@ -999,7 +999,7 @@ HRESULT COggFlacOutputPin::UnpackPacket(CAutoPtr<OggPacket>& p, BYTE* pData, int HRESULT COggFlacOutputPin::DeliverPacket(CAutoPtr<OggPacket> p)
{
- if(p->GetCount() > 0 && (p->GetAt(0)&1)) {
+ if (p->GetCount() > 0 && (p->GetAt(0)&1)) {
return S_OK;
}
@@ -1012,9 +1012,9 @@ HRESULT COggFlacOutputPin::DeliverNewSegment(REFERENCE_TIME tStart, REFERENCE_TI m_lastblocksize = 0;
- if(m_mt.subtype == MEDIASUBTYPE_FLAC_FRAMED) {
+ if (m_mt.subtype == MEDIASUBTYPE_FLAC_FRAMED) {
POSITION pos = m_initpackets.GetHeadPosition();
- while(pos) {
+ while (pos) {
Packet* pi = m_initpackets.GetNext(pos);
CAutoPtr<OggPacket> p(DNew OggPacket());
p->TrackNumber = pi->TrackNumber;
@@ -1038,7 +1038,7 @@ COggDirectShowOutputPin::COggDirectShowOutputPin(AM_MEDIA_TYPE* pmt, LPCWSTR pNa memcpy((AM_MEDIA_TYPE*)&mt, pmt, FIELD_OFFSET(AM_MEDIA_TYPE, pUnk));
mt.SetFormat((BYTE*)(pmt+1), pmt->cbFormat);
mt.SetSampleSize(1);
- if(mt.majortype == MEDIATYPE_Video) { // TODO: find samples for audio and find out what to return in GetRefTime...
+ if (mt.majortype == MEDIATYPE_Video) { // TODO: find samples for audio and find out what to return in GetRefTime...
m_mts.Add(mt);
}
}
@@ -1047,9 +1047,9 @@ REFERENCE_TIME COggDirectShowOutputPin::GetRefTime(__int64 granule_position) {
REFERENCE_TIME rt = 0;
- if(m_mt.majortype == MEDIATYPE_Video) {
+ if (m_mt.majortype == MEDIATYPE_Video) {
rt = granule_position * ((VIDEOINFOHEADER*)m_mt.Format())->AvgTimePerFrame;
- } else if(m_mt.majortype == MEDIATYPE_Audio) {
+ } else if (m_mt.majortype == MEDIATYPE_Audio) {
rt = granule_position; // ((WAVEFORMATEX*)m_mt.Format())-> // TODO
}
@@ -1062,15 +1062,15 @@ HRESULT COggDirectShowOutputPin::UnpackPacket(CAutoPtr<OggPacket>& p, BYTE* pDat BYTE hdr = pData[i++];
- if(!(hdr&1)) {
+ if (!(hdr&1)) {
// TODO: verify if this was still present in the old format (haven't found one sample yet)
BYTE nLenBytes = (hdr>>6)|((hdr&2)<<1);
__int64 Length = 0;
- for(int j = 0; j < nLenBytes; j++) {
+ for (int j = 0; j < nLenBytes; j++) {
Length |= (__int64)pData[i++] << (j << 3);
}
- if(len < i) {
+ if (len < i) {
ASSERT(0);
return E_FAIL;
}
@@ -1109,14 +1109,14 @@ HRESULT COggStreamOutputPin::UnpackPacket(CAutoPtr<OggPacket>& p, BYTE* pData, i BYTE hdr = pData[i++];
- if(!(hdr&1)) {
+ if (!(hdr&1)) {
BYTE nLenBytes = (hdr>>6)|((hdr&2)<<1);
__int64 Length = 0;
- for(int j = 0; j < nLenBytes; j++) {
+ for (int j = 0; j < nLenBytes; j++) {
Length |= (__int64)pData[i++] << (j << 3);
}
- if(len < i) {
+ if (len < i) {
ASSERT(0);
return E_FAIL;
}
@@ -1154,7 +1154,7 @@ COggVideoOutputPin::COggVideoOutputPin(OggStreamHeader* h, LPCWSTR pName, CBaseF pvih->bmiHeader.biHeight = h->v.h;
pvih->bmiHeader.biBitCount = (WORD)h->bps;
pvih->bmiHeader.biCompression = mt.subtype.Data1;
- switch(pvih->bmiHeader.biCompression) {
+ switch (pvih->bmiHeader.biCompression) {
case BI_RGB:
case BI_BITFIELDS:
mt.subtype =
@@ -1239,7 +1239,7 @@ COggTheoraOutputPin::COggTheoraOutputPin(BYTE* p, LPCWSTR pName, CBaseFilter* pF vih->hdr.bmiHeader.biBitCount = 24;
m_nFpsNum = (p[22]<<24)|(p[23]<<16)|(p[24]<<8)|p[25];
m_nFpsDenum = (p[26]<<24)|(p[27]<<16)|(p[28]<<8)|p[29];
- if(m_nFpsNum) {
+ if (m_nFpsNum) {
m_rtAvgTimePerFrame = (REFERENCE_TIME)(10000000.0 * m_nFpsDenum / m_nFpsNum);
vih->hdr.AvgTimePerFrame = m_rtAvgTimePerFrame;
}
@@ -1261,7 +1261,7 @@ HRESULT COggTheoraOutputPin::UnpackInitPage(OggPage& page) {
HRESULT hr = __super::UnpackPage(page);
- while(m_packets.GetCount()) {
+ while (m_packets.GetCount()) {
Packet* p = m_packets.GetHead();
CMediaType& mt = m_mts[0];
@@ -1300,7 +1300,7 @@ REFERENCE_TIME COggTheoraOutputPin::GetRefTime(__int64 granule_position) HRESULT COggTheoraOutputPin::UnpackPacket(CAutoPtr<OggPacket>& p, BYTE* pData, int len)
{
- if(!pData) {
+ if (!pData) {
return E_FAIL;
}
@@ -1309,7 +1309,7 @@ HRESULT COggTheoraOutputPin::UnpackPacket(CAutoPtr<OggPacket>& p, BYTE* pData, i p->rtStop = m_rtLast+1;
p->SetData(pData, len);
- if(!(*pData & 0x80) && m_mt.majortype == MEDIATYPE_Video) {
+ if (!(*pData & 0x80) && m_mt.majortype == MEDIATYPE_Video) {
p->rtStop = p->rtStart + ((MPEG2VIDEOINFO*)m_mt.Format())->hdr.AvgTimePerFrame;
}
diff --git a/src/filters/parser/RealMediaSplitter/RealMediaSplitter.cpp b/src/filters/parser/RealMediaSplitter/RealMediaSplitter.cpp index aeb975c10..0329135d6 100644 --- a/src/filters/parser/RealMediaSplitter/RealMediaSplitter.cpp +++ b/src/filters/parser/RealMediaSplitter/RealMediaSplitter.cpp @@ -38,7 +38,7 @@ template<typename T> static void bswap(T& var)
{
BYTE* s = (BYTE*)&var;
- for(BYTE* d = s + sizeof(var)-1; s < d; s++, d--) {
+ for (BYTE* d = s + sizeof(var)-1; s < d; s++, d--) {
*s ^= *d, *d ^= *s, *s ^= *d;
}
}
@@ -193,7 +193,7 @@ STDMETHODIMP CRealMediaSplitterFilter::QueryFilterInfo(FILTER_INFO* pInfo) wcscpy(pInfo->achName, RMSourceName);
}
pInfo->pGraph = m_pGraph;
- if(m_pGraph) {
+ if (m_pGraph) {
m_pGraph->AddRef();
}
@@ -206,7 +206,7 @@ HRESULT CRealMediaSplitterFilter::CreateOutputs(IAsyncReader* pAsyncReader) {
DWORD dw;
- if(FAILED(pAsyncReader->SyncRead(0, 4, (BYTE*)&dw)) || dw != 'FMR.') {
+ if (FAILED(pAsyncReader->SyncRead(0, 4, (BYTE*)&dw)) || dw != 'FMR.') {
return E_FAIL;
}
}
@@ -216,10 +216,10 @@ HRESULT CRealMediaSplitterFilter::CreateOutputs(IAsyncReader* pAsyncReader) m_pFile.Free();
m_pFile.Attach(DNew CRMFile(pAsyncReader, hr));
- if(!m_pFile) {
+ if (!m_pFile) {
return E_OUTOFMEMORY;
}
- if(FAILED(hr)) {
+ if (FAILED(hr)) {
m_pFile.Free();
return hr;
}
@@ -230,12 +230,12 @@ HRESULT CRealMediaSplitterFilter::CreateOutputs(IAsyncReader* pAsyncReader) m_rtStop = 10000i64*m_pFile->m_p.tDuration;
POSITION pos = m_pFile->m_mps.GetHeadPosition();
- while(pos) {
+ while (pos) {
MediaProperies* pmp = m_pFile->m_mps.GetNext(pos);
CStringW name;
name.Format(L"Output %02d", pmp->stream);
- if(!pmp->name.IsEmpty()) {
+ if (!pmp->name.IsEmpty()) {
name += L" (" + CStringW(pmp->name) + L")";
}
@@ -244,7 +244,7 @@ HRESULT CRealMediaSplitterFilter::CreateOutputs(IAsyncReader* pAsyncReader) CMediaType mt;
mt.SetSampleSize(max(pmp->maxPacketSize*16/**/, 1));
- if(pmp->mime == "video/x-pn-realvideo") {
+ if (pmp->mime == "video/x-pn-realvideo") {
mt.majortype = MEDIATYPE_Video;
mt.formattype = FORMAT_VideoInfo;
@@ -259,7 +259,7 @@ HRESULT CRealMediaSplitterFilter::CreateOutputs(IAsyncReader* pAsyncReader) ASSERT(rvi.fcc1 == 'ODIV');
mt.subtype = FOURCCMap(rvi.fcc2);
- if(rvi.fps > 0x10000) {
+ if (rvi.fps > 0x10000) {
pvih->AvgTimePerFrame = REFERENCE_TIME(10000000i64 / ((float)rvi.fps/0x10000));
}
pvih->dwBitRate = pmp->avgBitRate;
@@ -273,7 +273,7 @@ HRESULT CRealMediaSplitterFilter::CreateOutputs(IAsyncReader* pAsyncReader) mts.Add(mt);
- if(pmp->width > 0 && pmp->height > 0) {
+ if (pmp->width > 0 && pmp->height > 0) {
BITMAPINFOHEADER bmi = pvih->bmiHeader;
mt.formattype = FORMAT_VideoInfo2;
VIDEOINFOHEADER2* pvih2 = (VIDEOINFOHEADER2*)mt.ReallocFormatBuffer(sizeof(VIDEOINFOHEADER2) + pmp->typeSpecData.GetCount());
@@ -287,7 +287,7 @@ HRESULT CRealMediaSplitterFilter::CreateOutputs(IAsyncReader* pAsyncReader) mts.InsertAt(0, mt);
}
- } else if(pmp->mime == "audio/x-pn-realaudio") {
+ } else if (pmp->mime == "audio/x-pn-realaudio") {
mt.majortype = MEDIATYPE_Audio;
mt.formattype = FORMAT_WaveFormatEx;
mt.bTemporalCompression = 1;
@@ -305,8 +305,8 @@ HRESULT CRealMediaSplitterFilter::CreateOutputs(IAsyncReader* pAsyncReader) fccstr[4] = 0;
BYTE* fmt = pmp->typeSpecData.GetData();
- for(size_t i = 0; i < pmp->typeSpecData.GetCount()-4; i++, fmt++) {
- if(fmt[0] == '.' || fmt[1] == 'r' || fmt[2] == 'a') {
+ for (size_t i = 0; i < pmp->typeSpecData.GetCount()-4; i++, fmt++) {
+ if (fmt[0] == '.' || fmt[1] == 'r' || fmt[2] == 'a') {
break;
}
}
@@ -316,7 +316,7 @@ HRESULT CRealMediaSplitterFilter::CreateOutputs(IAsyncReader* pAsyncReader) BYTE* extra = NULL;
- if(rai.version2 == 4) {
+ if (rai.version2 == 4) {
rainfo4 rai4 = *(rainfo4*)fmt;
rai4.bswap();
pwfe->nChannels = rai4.channels;
@@ -328,11 +328,11 @@ HRESULT CRealMediaSplitterFilter::CreateOutputs(IAsyncReader* pAsyncReader) p += len;
len = *p++;
ASSERT(len == 4);
- if(len == 4) {
+ if (len == 4) {
fcc = MAKEFOURCC(p[0],p[1],p[2],p[3]);
}
extra = p + len + 3;
- } else if(rai.version2 == 5) {
+ } else if (rai.version2 == 5) {
rainfo5 rai5 = *(rainfo5*)fmt;
rai5.bswap();
pwfe->nChannels = rai5.channels;
@@ -351,7 +351,7 @@ HRESULT CRealMediaSplitterFilter::CreateOutputs(IAsyncReader* pAsyncReader) bswap(fcc);
- switch(fcc) {
+ switch (fcc) {
case '14_4':
pwfe->wFormatTag = WAVE_FORMAT_14_4;
break;
@@ -378,19 +378,19 @@ HRESULT CRealMediaSplitterFilter::CreateOutputs(IAsyncReader* pAsyncReader) break;
}
- if(pwfe->wFormatTag) {
+ if (pwfe->wFormatTag) {
mts.Add(mt);
- if(fcc == 'DNET') {
+ if (fcc == 'DNET') {
mt.subtype = FOURCCMap(pwfe->wFormatTag = WAVE_FORMAT_DOLBY_AC3);
mts.InsertAt(0, mt);
- } else if(fcc == 'RAAC' || fcc == 'RACP') {
+ } else if (fcc == 'RAAC' || fcc == 'RACP') {
mt.subtype = FOURCCMap(pwfe->wFormatTag = WAVE_FORMAT_AAC);
int extralen = *(DWORD*)extra;
extra += 4;
::bswap(extralen);
ASSERT(*extra == 2); // always 2? why? what does it mean?
- if(*extra == 2) {
+ if (*extra == 2) {
extra++;
extralen--;
WAVEFORMATEX* pwfe = (WAVEFORMATEX*)mt.ReallocFormatBuffer(sizeof(WAVEFORMATEX) + extralen);
@@ -403,7 +403,7 @@ HRESULT CRealMediaSplitterFilter::CreateOutputs(IAsyncReader* pAsyncReader) mts.InsertAt(0, mt);
}
}
- } else if(pmp->mime == "logical-fileinfo") {
+ } else if (pmp->mime == "logical-fileinfo") {
CAtlMap<CStringA, CStringA, CStringElementTraits<CStringA> > lfi;
CStringA key, value;
@@ -415,19 +415,19 @@ HRESULT CRealMediaSplitterFilter::CreateOutputs(IAsyncReader* pAsyncReader) bswap(cnt);
p += 4;
- if(cnt > 0xffff) { // different format?
+ if (cnt > 0xffff) { // different format?
p += 2;
cnt = p <= end-4 ? *(DWORD*)p : 0;
bswap(cnt);
p += 4;
}
- while(p < end-4 && cnt-- > 0) {
+ while (p < end-4 && cnt-- > 0) {
BYTE* base = p;
DWORD len = *(DWORD*)p;
bswap(len);
p += 4;
- if(base + len > end) {
+ if (base + len > end) {
break;
}
@@ -452,20 +452,20 @@ HRESULT CRealMediaSplitterFilter::CreateOutputs(IAsyncReader* pAsyncReader) }
POSITION pos = lfi.GetStartPosition();
- while(pos) {
+ while (pos) {
lfi.GetNextAssoc(pos, key, value);
int n = 0;
- if(key.Find("CHAPTER") == 0 && key.Find("TIME") == key.GetLength()-4
+ if (key.Find("CHAPTER") == 0 && key.Find("TIME") == key.GetLength()-4
&& (n = strtol(key.Mid(7), NULL, 10)) > 0) {
int h, m, s, ms;
char c;
- if(7 != sscanf(value, "%d%c%d%c%d%c%d", &h, &c, &m, &c, &s, &c, &ms)) {
+ if (7 != sscanf(value, "%d%c%d%c%d%c%d", &h, &c, &m, &c, &s, &c, &ms)) {
continue;
}
key.Format("CHAPTER%02dNAME", n);
- if(!lfi.Lookup(key, value) || value.IsEmpty()) {
+ if (!lfi.Lookup(key, value) || value.IsEmpty()) {
value.Format("Chapter %d", n);
}
@@ -476,7 +476,7 @@ HRESULT CRealMediaSplitterFilter::CreateOutputs(IAsyncReader* pAsyncReader) }
}
- if(mts.IsEmpty()) {
+ if (mts.IsEmpty()) {
TRACE(_T("Unsupported RealMedia stream (%d): %s\n"), pmp->stream, CString(pmp->mime));
continue;
}
@@ -484,20 +484,20 @@ HRESULT CRealMediaSplitterFilter::CreateOutputs(IAsyncReader* pAsyncReader) HRESULT hr;
CAutoPtr<CBaseSplitterOutputPin> pPinOut(DNew CRealMediaSplitterOutputPin(mts, name, this, this, &hr));
- if(SUCCEEDED(AddOutputPin((DWORD)pmp->stream, pPinOut))) {
- if(!m_rtStop) {
+ if (SUCCEEDED(AddOutputPin((DWORD)pmp->stream, pPinOut))) {
+ if (!m_rtStop) {
m_pFile->m_p.tDuration = max(m_pFile->m_p.tDuration, pmp->tDuration);
}
}
}
pos = m_pFile->m_subs.GetHeadPosition();
- for(DWORD stream = 0; pos; stream++) {
+ for (DWORD stream = 0; pos; stream++) {
CRMFile::subtitle& s = m_pFile->m_subs.GetNext(pos);
CStringW name;
name.Format(L"Subtitle %02d", stream);
- if(!s.name.IsEmpty()) {
+ if (!s.name.IsEmpty()) {
name += L" (" + CStringW(CString(s.name)) + L")";
}
@@ -528,13 +528,13 @@ bool CRealMediaSplitterFilter::DemuxInit() {
SetThreadName((DWORD)-1, "CRealMediaSplitterFilter");
- if(!m_pFile) {
+ if (!m_pFile) {
return false;
}
// reindex if needed
- if(m_pFile->m_irs.GetCount() == 0) {
+ if (m_pFile->m_irs.GetCount() == 0) {
m_nOpenProgress = 0;
m_rtDuration = 0;
@@ -544,24 +544,24 @@ bool CRealMediaSplitterFilter::DemuxInit() UINT32 nPacket = 0;
POSITION pos = m_pFile->m_dcs.GetHeadPosition();
- while(pos && !m_fAbort) {
+ while (pos && !m_fAbort) {
DataChunk* pdc = m_pFile->m_dcs.GetNext(pos);
m_pFile->Seek(pdc->pos);
- for(UINT32 i = 0; i < pdc->nPackets && !m_fAbort; i++, nPacket++) {
+ for (UINT32 i = 0; i < pdc->nPackets && !m_fAbort; i++, nPacket++) {
UINT64 filepos = m_pFile->GetPos();
HRESULT hr;
MediaPacketHeader mph;
- if(S_OK != (hr = m_pFile->Read(mph, false))) {
+ if (S_OK != (hr = m_pFile->Read(mph, false))) {
break;
}
m_rtDuration = max((__int64)(10000i64*mph.tStart), m_rtDuration);
- if(mph.stream == stream && (mph.flags&MediaPacketHeader::PN_KEYFRAME_FLAG) && tLastStart != mph.tStart) {
+ if (mph.stream == stream && (mph.flags&MediaPacketHeader::PN_KEYFRAME_FLAG) && tLastStart != mph.tStart) {
CAutoPtr<IndexRecord> pir(DNew IndexRecord);
pir->tStart = mph.tStart;
pir->ptrFilePos = (UINT32)filepos;
@@ -574,8 +574,8 @@ bool CRealMediaSplitterFilter::DemuxInit() m_nOpenProgress = m_pFile->GetPos()*100/m_pFile->GetLength();
DWORD cmd;
- if(CheckRequest(&cmd)) {
- if(cmd == CMD_EXIT) {
+ if (CheckRequest(&cmd)) {
+ if (cmd == CMD_EXIT) {
m_fAbort = true;
} else {
Reply(S_OK);
@@ -586,7 +586,7 @@ bool CRealMediaSplitterFilter::DemuxInit() m_nOpenProgress = 100;
- if(m_fAbort) {
+ if (m_fAbort) {
m_pFile->m_irs.RemoveAll();
}
@@ -602,7 +602,7 @@ bool CRealMediaSplitterFilter::DemuxInit() void CRealMediaSplitterFilter::DemuxSeek(REFERENCE_TIME rt)
{
- if(rt <= 0) {
+ if (rt <= 0) {
m_seekpos = m_pFile->m_dcs.GetHeadPosition();
m_seekpacket = 0;
m_seekfilepos = m_pFile->m_dcs.GetHead()->pos;
@@ -610,23 +610,23 @@ void CRealMediaSplitterFilter::DemuxSeek(REFERENCE_TIME rt) m_seekpos = NULL;
POSITION pos = m_pFile->m_irs.GetTailPosition();
- while(pos && !m_seekpos) {
+ while (pos && !m_seekpos) {
IndexRecord* pir = m_pFile->m_irs.GetPrev(pos);
- if(pir->tStart <= rt/10000) {
+ if (pir->tStart <= rt/10000) {
m_seekpacket = pir->packet;
pos = m_pFile->m_dcs.GetTailPosition();
- while(pos && !m_seekpos) {
+ while (pos && !m_seekpos) {
POSITION tmp = pos;
DataChunk* pdc = m_pFile->m_dcs.GetPrev(pos);
- if(pdc->pos <= pir->ptrFilePos) {
+ if (pdc->pos <= pir->ptrFilePos) {
m_seekpos = tmp;
m_seekfilepos = pir->ptrFilePos;
POSITION pos = m_pFile->m_dcs.GetHeadPosition();
- while(pos != m_seekpos) {
+ while (pos != m_seekpos) {
m_seekpacket -= m_pFile->m_dcs.GetNext(pos)->nPackets;
}
}
@@ -669,7 +669,7 @@ void CRealMediaSplitterFilter::DemuxSeek(REFERENCE_TIME rt) }
}
- if(!m_seekpos) {
+ if (!m_seekpos) {
m_seekpos = m_pFile->m_dcs.GetHeadPosition();
m_seekpacket = 0;
m_seekfilepos = m_pFile->m_dcs.GetAt(m_seekpos)->pos;
@@ -683,7 +683,7 @@ bool CRealMediaSplitterFilter::DemuxLoop() POSITION pos;
pos = m_pFile->m_subs.GetHeadPosition();
- for(DWORD stream = 0; pos && SUCCEEDED(hr) && !CheckRequest(NULL); stream++) {
+ for (DWORD stream = 0; pos && SUCCEEDED(hr) && !CheckRequest(NULL); stream++) {
CRMFile::subtitle& s = m_pFile->m_subs.GetNext(pos);
CAutoPtr<Packet> p(DNew Packet);
@@ -717,14 +717,14 @@ bool CRealMediaSplitterFilter::DemuxLoop() }
pos = m_seekpos;
- while(pos && SUCCEEDED(hr) && !CheckRequest(NULL)) {
+ while (pos && SUCCEEDED(hr) && !CheckRequest(NULL)) {
DataChunk* pdc = m_pFile->m_dcs.GetNext(pos);
m_pFile->Seek(m_seekfilepos > 0 ? m_seekfilepos : pdc->pos);
- for(UINT32 i = m_seekpacket; i < pdc->nPackets && SUCCEEDED(hr) && !CheckRequest(NULL); i++) {
+ for (UINT32 i = m_seekpacket; i < pdc->nPackets && SUCCEEDED(hr) && !CheckRequest(NULL); i++) {
MediaPacketHeader mph;
- if(S_OK != (hr = m_pFile->Read(mph))) {
+ if (S_OK != (hr = m_pFile->Read(mph))) {
break;
}
@@ -748,7 +748,7 @@ bool CRealMediaSplitterFilter::DemuxLoop() STDMETHODIMP CRealMediaSplitterFilter::GetKeyFrameCount(UINT& nKFs)
{
- if(!m_pFile) {
+ if (!m_pFile) {
return E_UNEXPECTED;
}
nKFs = m_pFile->m_irs.GetCount();
@@ -760,16 +760,16 @@ STDMETHODIMP CRealMediaSplitterFilter::GetKeyFrames(const GUID* pFormat, REFEREN CheckPointer(pFormat, E_POINTER);
CheckPointer(pKFs, E_POINTER);
- if(!m_pFile) {
+ if (!m_pFile) {
return E_UNEXPECTED;
}
- if(*pFormat != TIME_FORMAT_MEDIA_TIME) {
+ if (*pFormat != TIME_FORMAT_MEDIA_TIME) {
return E_INVALIDARG;
}
UINT nKFsTmp = 0;
POSITION pos = m_pFile->m_irs.GetHeadPosition();
- for(int i = 0; pos && nKFsTmp < nKFs; i++) {
+ for (int i = 0; pos && nKFsTmp < nKFs; i++) {
pKFs[nKFsTmp++] = 10000i64*m_pFile->m_irs.GetNext(pos)->tStart;
}
nKFs = nKFsTmp;
@@ -804,7 +804,7 @@ HRESULT CRealMediaSplitterOutputPin::DeliverSegments() {
HRESULT hr;
- if(m_segments.GetCount() == 0) {
+ if (m_segments.GetCount() == 0) {
m_segments.Clear();
return S_OK;
}
@@ -819,7 +819,7 @@ HRESULT CRealMediaSplitterOutputPin::DeliverSegments() DWORD len = 0, total = 0;
POSITION pos = m_segments.GetHeadPosition();
- while(pos) {
+ while (pos) {
segment* s = m_segments.GetNext(pos);
len = max(len, s->offset + s->data.GetCount());
total += s->data.GetCount();
@@ -833,14 +833,14 @@ HRESULT CRealMediaSplitterOutputPin::DeliverSegments() *pData++ = m_segments.fMerged ? 0 : m_segments.GetCount()-1;
- if(m_segments.fMerged) {
+ if (m_segments.fMerged) {
*((DWORD*)pData) = 1;
pData += 4;
*((DWORD*)pData) = 0;
pData += 4;
} else {
pos = m_segments.GetHeadPosition();
- while(pos) {
+ while (pos) {
*((DWORD*)pData) = 1;
pData += 4;
*((DWORD*)pData) = m_segments.GetNext(pos)->offset;
@@ -849,7 +849,7 @@ HRESULT CRealMediaSplitterOutputPin::DeliverSegments() }
pos = m_segments.GetHeadPosition();
- while(pos) {
+ while (pos) {
segment* s = m_segments.GetNext(pos);
memcpy(pData + s->offset, s->data.GetData(), s->data.GetCount());
}
@@ -867,15 +867,15 @@ HRESULT CRealMediaSplitterOutputPin::DeliverPacket(CAutoPtr<Packet> p) ASSERT(p->rtStart < p->rtStop);
- if(m_mt.subtype == MEDIASUBTYPE_WAVE_DOLBY_AC3) {
+ if (m_mt.subtype == MEDIASUBTYPE_WAVE_DOLBY_AC3) {
WORD* s = (WORD*)p->GetData();
WORD* e = s + p->GetCount()/2;
- while(s < e) {
+ while (s < e) {
bswap(*s++);
}
}
- if(m_mt.subtype == MEDIASUBTYPE_RV10 || m_mt.subtype == MEDIASUBTYPE_RV20
+ if (m_mt.subtype == MEDIASUBTYPE_RV10 || m_mt.subtype == MEDIASUBTYPE_RV20
|| m_mt.subtype == MEDIASUBTYPE_RV30 || m_mt.subtype == MEDIASUBTYPE_RV40
|| m_mt.subtype == MEDIASUBTYPE_RV41) {
CAutoLock cAutoLock(&m_csQueue);
@@ -884,27 +884,27 @@ HRESULT CRealMediaSplitterOutputPin::DeliverPacket(CAutoPtr<Packet> p) BYTE* pIn = p->GetData();
BYTE* pInOrg = pIn;
- if(m_segments.rtStart != p->rtStart) {
- if(S_OK != (hr = DeliverSegments())) {
+ if (m_segments.rtStart != p->rtStart) {
+ if (S_OK != (hr = DeliverSegments())) {
return hr;
}
}
- if(!m_segments.fDiscontinuity && p->bDiscontinuity) {
+ if (!m_segments.fDiscontinuity && p->bDiscontinuity) {
m_segments.fDiscontinuity = true;
}
m_segments.fSyncPoint = !!p->bSyncPoint;
m_segments.rtStart = p->rtStart;
- while(pIn - pInOrg < len) {
+ while (pIn - pInOrg < len) {
BYTE hdr = *pIn++;
DWORD packetlen = 0, packetoffset = 0;
- if((hdr&0xc0) == 0x40) {
+ if ((hdr&0xc0) == 0x40) {
pIn++;
packetlen = len - (pIn - pInOrg);
} else {
- if((hdr&0x40) == 0) {
+ if ((hdr&0x40) == 0) {
pIn++; //BYTE subseq = (*pIn++)&0x7f;
}
@@ -913,10 +913,10 @@ HRESULT CRealMediaSplitterOutputPin::DeliverPacket(CAutoPtr<Packet> p) var = (var<<8)|(*pIn++); \
GetWORD(packetlen);
- if(packetlen&0x8000) {
+ if (packetlen&0x8000) {
m_segments.fMerged = true;
}
- if((packetlen&0x4000) == 0) {
+ if ((packetlen&0x4000) == 0) {
GetWORD(packetlen);
packetlen &= 0x3fffffff;
} else {
@@ -924,7 +924,7 @@ HRESULT CRealMediaSplitterOutputPin::DeliverPacket(CAutoPtr<Packet> p) }
GetWORD(packetoffset);
- if((packetoffset&0x4000) == 0) {
+ if ((packetoffset&0x4000) == 0) {
GetWORD(packetoffset);
packetoffset &= 0x3fffffff;
} else {
@@ -933,9 +933,9 @@ HRESULT CRealMediaSplitterOutputPin::DeliverPacket(CAutoPtr<Packet> p) #undef GetWORD
- if((hdr&0xc0) == 0xc0) {
+ if ((hdr&0xc0) == 0xc0) {
m_segments.rtStart = 10000i64*packetoffset - m_rtStart, packetoffset = 0;
- } else if((hdr&0xc0) == 0x80) {
+ } else if ((hdr&0xc0) == 0x80) {
packetoffset = packetlen - packetoffset;
}
@@ -952,14 +952,14 @@ HRESULT CRealMediaSplitterOutputPin::DeliverPacket(CAutoPtr<Packet> p) pIn += len2;
- if((hdr&0x80) || packetoffset+len2 >= packetlen) {
- if(S_OK != (hr = DeliverSegments())) {
+ if ((hdr&0x80) || packetoffset+len2 >= packetlen) {
+ if (S_OK != (hr = DeliverSegments())) {
return hr;
}
}
}
- } else if(m_mt.subtype == MEDIASUBTYPE_RAAC || m_mt.subtype == MEDIASUBTYPE_RACP
- || m_mt.subtype == MEDIASUBTYPE_AAC) {
+ } else if (m_mt.subtype == MEDIASUBTYPE_RAAC || m_mt.subtype == MEDIASUBTYPE_RACP
+ || m_mt.subtype == MEDIASUBTYPE_AAC) {
BYTE* ptr = p->GetData()+2;
CAtlList<WORD> sizes;
@@ -967,7 +967,7 @@ HRESULT CRealMediaSplitterOutputPin::DeliverPacket(CAutoPtr<Packet> p) int remaining = p->GetCount()-2;
int expected = *(ptr-1)>>4;
- while(total < remaining) {
+ while (total < remaining) {
int size = (ptr[0]<<8)|(ptr[1]);
sizes.AddTail(size);
total += size;
@@ -985,7 +985,7 @@ HRESULT CRealMediaSplitterOutputPin::DeliverPacket(CAutoPtr<Packet> p) BOOL bDiscontinuity = p->bDiscontinuity;
POSITION pos = sizes.GetHeadPosition();
- while(pos) {
+ while (pos) {
WORD size = sizes.GetNext(pos);
CAutoPtr<Packet> p(DNew Packet);
@@ -996,7 +996,7 @@ HRESULT CRealMediaSplitterOutputPin::DeliverPacket(CAutoPtr<Packet> p) p->SetData(ptr, size);
ptr += size;
bDiscontinuity = false;
- if(S_OK != (hr = __super::DeliverPacket(p))) {
+ if (S_OK != (hr = __super::DeliverPacket(p))) {
break;
}
}
@@ -1025,7 +1025,7 @@ CRealMediaSourceFilter::CRealMediaSourceFilter(LPUNKNOWN pUnk, HRESULT* phr) CRMFile::CRMFile(IAsyncReader* pAsyncReader, HRESULT& hr)
: CBaseSplitterFile(pAsyncReader, hr)
{
- if(FAILED(hr)) {
+ if (FAILED(hr)) {
return;
}
hr = Init();
@@ -1043,7 +1043,7 @@ HRESULT CRMFile::Read(ChunkHdr& hdr) {
memset(&hdr, 0, sizeof(hdr));
HRESULT hr;
- if(S_OK != (hr = Read(hdr.object_id))
+ if (S_OK != (hr = Read(hdr.object_id))
|| S_OK != (hr = Read(hdr.size))
|| S_OK != (hr = Read(hdr.object_version))) {
return hr;
@@ -1059,15 +1059,15 @@ HRESULT CRMFile::Read(MediaPacketHeader& mph, bool fFull) HRESULT hr;
UINT16 object_version;
- if(S_OK != (hr = Read(object_version))) {
+ if (S_OK != (hr = Read(object_version))) {
return hr;
}
- if(object_version != 0 && object_version != 1) {
+ if (object_version != 0 && object_version != 1) {
return S_OK;
}
UINT8 flags;
- if(S_OK != (hr = Read(mph.len))
+ if (S_OK != (hr = Read(mph.len))
|| S_OK != (hr = Read(mph.stream))
|| S_OK != (hr = Read(mph.tStart))
|| S_OK != (hr = Read(mph.reserved))
@@ -1083,9 +1083,9 @@ HRESULT CRMFile::Read(MediaPacketHeader& mph, bool fFull) ASSERT(len >= 0);
len = max(len, 0);
- if(fFull) {
+ if (fFull) {
mph.pData.SetCount(len);
- if(mph.len > 0 && S_OK != (hr = ByteRead(mph.pData.GetData(), len))) {
+ if (mph.len > 0 && S_OK != (hr = ByteRead(mph.pData.GetData(), len))) {
return hr;
}
} else {
@@ -1104,148 +1104,148 @@ HRESULT CRMFile::Init() HRESULT hr;
ChunkHdr hdr;
- while(GetRemaining() && S_OK == (hr = Read(hdr))) {
+ while (GetRemaining() && S_OK == (hr = Read(hdr))) {
__int64 pos = GetPos() - sizeof(hdr);
- if(fFirstChunk && hdr.object_id != '.RMF') {
+ if (fFirstChunk && hdr.object_id != '.RMF') {
return E_FAIL;
}
fFirstChunk = false;
- if(pos + hdr.size > GetLength() && hdr.object_id != 'DATA') { // truncated?
+ if (pos + hdr.size > GetLength() && hdr.object_id != 'DATA') { // truncated?
break;
}
- if(hdr.object_id == 0x2E7261FD) { // '.ra+0xFD'
+ if (hdr.object_id == 0x2E7261FD) { // '.ra+0xFD'
return E_FAIL;
}
- if(hdr.object_version == 0) {
- switch(hdr.object_id) {
+ if (hdr.object_version == 0) {
+ switch (hdr.object_id) {
case '.RMF':
- if(S_OK != (hr = Read(m_fh.version))) {
+ if (S_OK != (hr = Read(m_fh.version))) {
return hr;
}
- if(hdr.size == 0x10) {
+ if (hdr.size == 0x10) {
WORD w = 0;
- if(S_OK != (hr = Read(w))) {
+ if (S_OK != (hr = Read(w))) {
return hr;
}
m_fh.nHeaders = w;
- } else if(S_OK != (hr = Read(m_fh.nHeaders))) {
+ } else if (S_OK != (hr = Read(m_fh.nHeaders))) {
return hr;
}
break;
case 'CONT':
UINT16 slen;
- if(S_OK != (hr = Read(slen))) {
+ if (S_OK != (hr = Read(slen))) {
return hr;
}
- if(slen > 0 && S_OK != (hr = ByteRead((BYTE*)m_cd.title.GetBufferSetLength(slen), slen))) {
+ if (slen > 0 && S_OK != (hr = ByteRead((BYTE*)m_cd.title.GetBufferSetLength(slen), slen))) {
return hr;
}
- if(S_OK != (hr = Read(slen))) {
+ if (S_OK != (hr = Read(slen))) {
return hr;
}
- if(slen > 0 && S_OK != (hr = ByteRead((BYTE*)m_cd.author.GetBufferSetLength(slen), slen))) {
+ if (slen > 0 && S_OK != (hr = ByteRead((BYTE*)m_cd.author.GetBufferSetLength(slen), slen))) {
return hr;
}
- if(S_OK != (hr = Read(slen))) {
+ if (S_OK != (hr = Read(slen))) {
return hr;
}
- if(slen > 0 && S_OK != (hr = ByteRead((BYTE*)m_cd.copyright.GetBufferSetLength(slen), slen))) {
+ if (slen > 0 && S_OK != (hr = ByteRead((BYTE*)m_cd.copyright.GetBufferSetLength(slen), slen))) {
return hr;
}
- if(S_OK != (hr = Read(slen))) {
+ if (S_OK != (hr = Read(slen))) {
return hr;
}
- if(slen > 0 && S_OK != (hr = ByteRead((BYTE*)m_cd.comment.GetBufferSetLength(slen), slen))) {
+ if (slen > 0 && S_OK != (hr = ByteRead((BYTE*)m_cd.comment.GetBufferSetLength(slen), slen))) {
return hr;
}
break;
case 'PROP':
- if(S_OK != (hr = Read(m_p.maxBitRate))) {
+ if (S_OK != (hr = Read(m_p.maxBitRate))) {
return hr;
}
- if(S_OK != (hr = Read(m_p.avgBitRate))) {
+ if (S_OK != (hr = Read(m_p.avgBitRate))) {
return hr;
}
- if(S_OK != (hr = Read(m_p.maxPacketSize))) {
+ if (S_OK != (hr = Read(m_p.maxPacketSize))) {
return hr;
}
- if(S_OK != (hr = Read(m_p.avgPacketSize))) {
+ if (S_OK != (hr = Read(m_p.avgPacketSize))) {
return hr;
}
- if(S_OK != (hr = Read(m_p.nPackets))) {
+ if (S_OK != (hr = Read(m_p.nPackets))) {
return hr;
}
- if(S_OK != (hr = Read(m_p.tDuration))) {
+ if (S_OK != (hr = Read(m_p.tDuration))) {
return hr;
}
- if(S_OK != (hr = Read(m_p.tPreroll))) {
+ if (S_OK != (hr = Read(m_p.tPreroll))) {
return hr;
}
- if(S_OK != (hr = Read(m_p.ptrIndex))) {
+ if (S_OK != (hr = Read(m_p.ptrIndex))) {
return hr;
}
- if(S_OK != (hr = Read(m_p.ptrData))) {
+ if (S_OK != (hr = Read(m_p.ptrData))) {
return hr;
}
- if(S_OK != (hr = Read(m_p.nStreams))) {
+ if (S_OK != (hr = Read(m_p.nStreams))) {
return hr;
}
UINT16 flags;
- if(S_OK != (hr = Read(flags))) {
+ if (S_OK != (hr = Read(flags))) {
return hr;
}
m_p.flags = (Properies::flags_t)flags;
break;
case 'MDPR': {
CAutoPtr<MediaProperies> mp(DNew MediaProperies);
- if(S_OK != (hr = Read(mp->stream))) {
+ if (S_OK != (hr = Read(mp->stream))) {
return hr;
}
- if(S_OK != (hr = Read(mp->maxBitRate))) {
+ if (S_OK != (hr = Read(mp->maxBitRate))) {
return hr;
}
- if(S_OK != (hr = Read(mp->avgBitRate))) {
+ if (S_OK != (hr = Read(mp->avgBitRate))) {
return hr;
}
- if(S_OK != (hr = Read(mp->maxPacketSize))) {
+ if (S_OK != (hr = Read(mp->maxPacketSize))) {
return hr;
}
- if(S_OK != (hr = Read(mp->avgPacketSize))) {
+ if (S_OK != (hr = Read(mp->avgPacketSize))) {
return hr;
}
- if(S_OK != (hr = Read(mp->tStart))) {
+ if (S_OK != (hr = Read(mp->tStart))) {
return hr;
}
- if(S_OK != (hr = Read(mp->tPreroll))) {
+ if (S_OK != (hr = Read(mp->tPreroll))) {
return hr;
}
- if(S_OK != (hr = Read(mp->tDuration))) {
+ if (S_OK != (hr = Read(mp->tDuration))) {
return hr;
}
UINT8 slen;
- if(S_OK != (hr = Read(slen))) {
+ if (S_OK != (hr = Read(slen))) {
return hr;
}
- if(slen > 0 && S_OK != (hr = ByteRead((BYTE*)mp->name.GetBufferSetLength(slen), slen))) {
+ if (slen > 0 && S_OK != (hr = ByteRead((BYTE*)mp->name.GetBufferSetLength(slen), slen))) {
return hr;
}
- if(S_OK != (hr = Read(slen))) {
+ if (S_OK != (hr = Read(slen))) {
return hr;
}
- if(slen > 0 && S_OK != (hr = ByteRead((BYTE*)mp->mime.GetBufferSetLength(slen), slen))) {
+ if (slen > 0 && S_OK != (hr = ByteRead((BYTE*)mp->mime.GetBufferSetLength(slen), slen))) {
return hr;
}
UINT32 tsdlen;
- if(S_OK != (hr = Read(tsdlen))) {
+ if (S_OK != (hr = Read(tsdlen))) {
return hr;
}
mp->typeSpecData.SetCount(tsdlen);
- if(tsdlen > 0 && S_OK != (hr = ByteRead(mp->typeSpecData.GetData(), tsdlen))) {
+ if (tsdlen > 0 && S_OK != (hr = ByteRead(mp->typeSpecData.GetData(), tsdlen))) {
return hr;
}
mp->width = mp->height = 0;
@@ -1255,10 +1255,10 @@ HRESULT CRMFile::Init() }
case 'DATA': {
CAutoPtr<DataChunk> dc(DNew DataChunk);
- if(S_OK != (hr = Read(dc->nPackets))) {
+ if (S_OK != (hr = Read(dc->nPackets))) {
return hr;
}
- if(S_OK != (hr = Read(dc->ptrNext))) {
+ if (S_OK != (hr = Read(dc->ptrNext))) {
return hr;
}
dc->pos = GetPos();
@@ -1268,33 +1268,33 @@ HRESULT CRMFile::Init() }
case 'INDX': {
IndexChunkHeader ich;
- if(S_OK != (hr = Read(ich.nIndices))) {
+ if (S_OK != (hr = Read(ich.nIndices))) {
return hr;
}
- if(S_OK != (hr = Read(ich.stream))) {
+ if (S_OK != (hr = Read(ich.stream))) {
return hr;
}
- if(S_OK != (hr = Read(ich.ptrNext))) {
+ if (S_OK != (hr = Read(ich.ptrNext))) {
return hr;
}
int stream = GetMasterStream();
- while(ich.nIndices-- > 0) {
+ while (ich.nIndices-- > 0) {
UINT16 object_version;
- if(S_OK != (hr = Read(object_version))) {
+ if (S_OK != (hr = Read(object_version))) {
return hr;
}
- if(object_version == 0) {
+ if (object_version == 0) {
CAutoPtr<IndexRecord> ir(DNew IndexRecord);
- if(S_OK != (hr = Read(ir->tStart))) {
+ if (S_OK != (hr = Read(ir->tStart))) {
return hr;
}
- if(S_OK != (hr = Read(ir->ptrFilePos))) {
+ if (S_OK != (hr = Read(ir->ptrFilePos))) {
return hr;
}
- if(S_OK != (hr = Read(ir->packet))) {
+ if (S_OK != (hr = Read(ir->packet))) {
return hr;
}
- if(ich.stream == stream) {
+ if (ich.stream == stream) {
m_irs.AddTail(ir);
}
}
@@ -1302,17 +1302,17 @@ HRESULT CRMFile::Init() break;
}
case '.SUB':
- if(hdr.size > sizeof(hdr)) {
+ if (hdr.size > sizeof(hdr)) {
int size = hdr.size - sizeof(hdr);
CAutoVectorPtr<char> buff;
- if(!buff.Allocate(size)) {
+ if (!buff.Allocate(size)) {
return E_OUTOFMEMORY;
}
char* p = buff;
- if(S_OK != (hr = ByteRead((BYTE*)p, size))) {
+ if (S_OK != (hr = ByteRead((BYTE*)p, size))) {
return hr;
}
- for(char* end = p + size; p < end; ) {
+ for (char* end = p + size; p < end; ) {
subtitle s;
s.name = p;
p += s.name.GetLength()+1;
@@ -1327,7 +1327,7 @@ HRESULT CRMFile::Init() }
}
- if(hdr.object_id == 'CONT' && BitRead(32, true) == 'DATA') {
+ if (hdr.object_id == 'CONT' && BitRead(32, true) == 'DATA') {
hdr.size = GetPos() - pos;
}
@@ -1336,7 +1336,7 @@ HRESULT CRMFile::Init() || GetPos() == pos + sizeof(hdr));
pos += hdr.size;
- if(pos > GetPos()) {
+ if (pos > GetPos()) {
Seek(pos);
}
}
@@ -1352,7 +1352,7 @@ unsigned int GetBits2(int n, unsigned char*& p, unsigned int& bit_offset, unsign bit_offset += n;
bit_buffer <<= n;
- if(bit_offset > (32-16)) {
+ if (bit_offset > (32-16)) {
p += bit_offset >> 3;
bit_offset &= 7;
bit_buffer = (unsigned int)p[0] << 24;
@@ -1382,25 +1382,25 @@ void GetDimensions(unsigned char* p, unsigned int* wi, unsigned int* hi) GetBits(13);
w = cw[GetBits(3)];
- if(w == 0) {
+ if (w == 0) {
do {
c = GetBits(8);
w += (c << 2);
- } while(c == 255);
+ } while (c == 255);
}
c = GetBits(3);
h = ch1[c];
- if(h == 0) {
+ if (h == 0) {
c = ((c << 1) | GetBits(1)) & 3;
h = ch2[c];
- if(h == 0) {
+ if (h == 0) {
do {
c = GetBits(8);
h += (c << 2);
- } while(c == 255);
+ } while (c == 255);
}
}
@@ -1451,25 +1451,25 @@ void GetDimensions_X10(unsigned char* p, unsigned int* wi, unsigned int* hi, GetBits(16);
w = cw[GetBits(3)];
- if(w == 0) {
+ if (w == 0) {
do {
c = GetBits(8);
w += (c << 2);
- } while(c == 255);
+ } while (c == 255);
}
c = GetBits(3);
h = ch1[c];
- if(h == 0) {
+ if (h == 0) {
c = ((c << 1) | GetBits(1)) & 3;
h = ch2[c];
- if(h == 0) {
+ if (h == 0) {
do {
c = GetBits(8);
h += (c << 2);
- } while(c == 255);
+ } while (c == 255);
}
}
@@ -1480,23 +1480,23 @@ void GetDimensions_X10(unsigned char* p, unsigned int* wi, unsigned int* hi, void CRMFile::GetDimensions()
{
POSITION pos = m_mps.GetHeadPosition();
- while(pos) {
+ while (pos) {
UINT64 filepos = GetPos();
MediaProperies* pmp = m_mps.GetNext(pos);
- if(pmp->mime == "video/x-pn-realvideo") {
+ if (pmp->mime == "video/x-pn-realvideo") {
pmp->width = pmp->height = 0;
rvinfo rvi = *(rvinfo*)pmp->typeSpecData.GetData();
rvi.bswap();
- if(rvi.fcc2 != '04VR' && rvi.fcc2 != '14VR') {
+ if (rvi.fcc2 != '04VR' && rvi.fcc2 != '14VR') {
continue;
}
MediaPacketHeader mph;
- while(S_OK == Read(mph)) {
- if(mph.stream != pmp->stream || mph.len == 0
+ while (S_OK == Read(mph)) {
+ if (mph.stream != pmp->stream || mph.len == 0
|| !(mph.flags&MediaPacketHeader::PN_KEYFRAME_FLAG)) {
continue;
}
@@ -1508,10 +1508,10 @@ void CRMFile::GetDimensions() BYTE hdr = *p++;
DWORD packetlen = 0, packetoffset = 0;
- if((hdr&0xc0) == 0x40) {
+ if ((hdr&0xc0) == 0x40) {
packetlen = len - (++p - p0);
} else {
- if((hdr&0x40) == 0) {
+ if ((hdr&0x40) == 0) {
p++;
}
@@ -1520,7 +1520,7 @@ void CRMFile::GetDimensions() var = (var<<8)|(*p++); \
GetWORD(packetlen);
- if((packetlen&0x4000) == 0) {
+ if ((packetlen&0x4000) == 0) {
GetWORD(packetlen);
packetlen &= 0x3fffffff;
} else {
@@ -1528,7 +1528,7 @@ void CRMFile::GetDimensions() }
GetWORD(packetoffset);
- if((packetoffset&0x4000) == 0) {
+ if ((packetoffset&0x4000) == 0) {
GetWORD(packetoffset);
packetoffset &= 0x3fffffff;
} else {
@@ -1537,9 +1537,9 @@ void CRMFile::GetDimensions() #undef GetWORD
- if((hdr&0xc0) == 0xc0) {
+ if ((hdr&0xc0) == 0xc0) {
packetoffset = 0;
- } else if((hdr&0xc0) == 0x80) {
+ } else if ((hdr&0xc0) == 0x80) {
packetoffset = packetlen - packetoffset;
}
@@ -1548,15 +1548,15 @@ void CRMFile::GetDimensions() len = min(len - (p - p0), packetlen - packetoffset);
- if(len > 0) {
+ if (len > 0) {
bool repeat_field;
- if(rvi.fcc2 == '14VR') {
+ if (rvi.fcc2 == '14VR') {
::GetDimensions_X10(p, &pmp->width, &pmp->height, &pmp->interlaced, &pmp->top_field_first, &repeat_field);
} else {
::GetDimensions(p, &pmp->width, &pmp->height);
}
- if(rvi.w == pmp->width && rvi.h == pmp->height) {
+ if (rvi.w == pmp->width && rvi.h == pmp->height) {
pmp->width = pmp->height = 0;
}
@@ -1574,17 +1574,17 @@ int CRMFile::GetMasterStream() int s1 = -1, s2 = -1;
POSITION pos = m_mps.GetHeadPosition();
- while(pos) {
+ while (pos) {
MediaProperies* pmp = m_mps.GetNext(pos);
- if(pmp->mime == "video/x-pn-realvideo") {
+ if (pmp->mime == "video/x-pn-realvideo") {
s1 = pmp->stream;
break;
- } else if(pmp->mime == "audio/x-pn-realaudio" && s2 == -1) {
+ } else if (pmp->mime == "audio/x-pn-realaudio" && s2 == -1) {
s2 = pmp->stream;
}
}
- if(s1 == -1) {
+ if (s1 == -1) {
s1 = s2;
}
@@ -1608,7 +1608,7 @@ CRealVideoDecoder::CRealVideoDecoder(LPUNKNOWN lpunk, HRESULT* phr) CRealVideoDecoder::~CRealVideoDecoder()
{
- if(m_hDrvDll) {
+ if (m_hDrvDll) {
FreeLibrary(m_hDrvDll);
}
}
@@ -1630,16 +1630,16 @@ HRESULT CRealVideoDecoder::InitRV(const CMediaType* pmt) {11, rvi.w, rvi.h, 0, 0, rvi.type1, 1, rvi.type2};
#pragma pack(pop)
- if(FAILED(hr = RVInit(&i, &m_dwCookie))) {
+ if (FAILED(hr = RVInit(&i, &m_dwCookie))) {
return hr;
}
- if(rvi.fcc2 <= '03VR' && rvi.type2 >= 0x20200002) {
+ if (rvi.fcc2 <= '03VR' && rvi.type2 >= 0x20200002) {
int nWidthHeight = (1+((rvi.type1>>16)&7));
UINT32* pWH = DNew UINT32[nWidthHeight*2];
pWH[0] = rvi.w;
pWH[1] = rvi.h;
- for(int i = 2; i < nWidthHeight*2; i++) {
+ for (int i = 2; i < nWidthHeight*2; i++) {
pWH[i] = rvi.morewh[i-2]*4;
}
#pragma pack(push, 1)
@@ -1659,7 +1659,7 @@ HRESULT CRealVideoDecoder::InitRV(const CMediaType* pmt) void CRealVideoDecoder::FreeRV()
{
- if(m_dwCookie) {
+ if (m_dwCookie) {
RVFree(m_dwCookie);
m_dwCookie = 0;
}
@@ -1672,12 +1672,12 @@ HRESULT CRealVideoDecoder::Transform(IMediaSample* pIn) HRESULT hr;
BYTE* pDataIn = NULL;
- if(FAILED(hr = pIn->GetPointer(&pDataIn))) {
+ if (FAILED(hr = pIn->GetPointer(&pDataIn))) {
return hr;
}
long len = pIn->GetActualDataLength();
- if(len <= 0) {
+ if (len <= 0) {
return S_OK; // nothing to do
}
@@ -1703,7 +1703,7 @@ HRESULT CRealVideoDecoder::Transform(IMediaSample* pIn) pDataIn += offset;
- if(m_fDropFrames && m_timestamp+1 == transform_in.timestamp) {
+ if (m_fDropFrames && m_timestamp+1 == transform_in.timestamp) {
m_timestamp = transform_in.timestamp;
return S_OK;
}
@@ -1714,7 +1714,7 @@ HRESULT CRealVideoDecoder::Transform(IMediaSample* pIn) ::GetDimensions_X10(pDataIn, &tmp1, &tmp2, &interlaced, &tmp3, &tmp4);
int size = tmp1*tmp2;
- if( m_lastBuffSizeDim < size ) {
+ if ( m_lastBuffSizeDim < size ) {
_aligned_free(m_pI420);
_aligned_free(m_pI420Tmp);
@@ -1748,19 +1748,19 @@ HRESULT CRealVideoDecoder::Transform(IMediaSample* pIn) m_timestamp = transform_in.timestamp;
- if(FAILED(hr)) {
+ if (FAILED(hr)) {
TRACE(_T("RV returned an error code!!!\n"));
ASSERT(!(transform_out.unk1&1)); // error allowed when the "render" flag is not set
// return hr;
}
- if(pIn->IsPreroll() == S_OK || rtStart < 0 || !(transform_out.unk1&1)) {
+ if (pIn->IsPreroll() == S_OK || rtStart < 0 || !(transform_out.unk1&1)) {
return S_OK;
}
CComPtr<IMediaSample> pOut;
BYTE* pDataOut = NULL;
- if(/*FAILED(hr = GetDeliveryBuffer(transform_out.w, transform_out.h, &pOut)) // TODO
+ if (/*FAILED(hr = GetDeliveryBuffer(transform_out.w, transform_out.h, &pOut)) // TODO
&& */ FAILED(hr = GetDeliveryBuffer(m_w, m_h, &pOut))
|| FAILED(hr = pOut->GetPointer(&pDataOut))) {
return hr;
@@ -1768,7 +1768,7 @@ HRESULT CRealVideoDecoder::Transform(IMediaSample* pIn) BYTE* pI420[3] = {m_pI420, m_pI420Tmp, NULL};
- if(interlaced) {
+ if (interlaced) {
int size = m_w*m_h;
DeinterlaceBlend(pI420[1], pI420[0], m_w, m_h, m_w, m_w);
DeinterlaceBlend(pI420[1]+size, pI420[0]+size, m_w/2, m_h/2, m_w/2, m_w/2);
@@ -1776,10 +1776,10 @@ HRESULT CRealVideoDecoder::Transform(IMediaSample* pIn) pI420[2] = pI420[1], pI420[1] = pI420[0], pI420[0] = pI420[2];
}
- if(transform_out.w != m_w || transform_out.h != m_h) {
+ if (transform_out.w != m_w || transform_out.h != m_h) {
Resize(pI420[0], transform_out.w, transform_out.h, pI420[1], m_w, m_h);
// only one of these can be true, and when it happens the result image must be in the tmp buffer
- if(transform_out.w == m_w || transform_out.h == m_h) {
+ if (transform_out.w == m_w || transform_out.h == m_h) {
pI420[2] = pI420[1], pI420[1] = pI420[0], pI420[0] = pI420[2];
}
}
@@ -1803,21 +1803,21 @@ void CRealVideoDecoder::Resize(BYTE* pIn, DWORD wi, DWORD hi, BYTE* pOut, DWORD int si = wi*hi, so = wo*ho;
ASSERT(((si*so)&3) == 0);
- if(wi < wo) {
+ if (wi < wo) {
ResizeWidth(pIn, wi, hi, pOut, wo, ho);
ResizeWidth(pIn + si, wi/2, hi/2, pOut + so, wo/2, ho/2);
ResizeWidth(pIn + si + si/4, wi/2, hi/2, pOut + so + so/4, wo/2, ho/2);
- if(hi == ho) {
+ if (hi == ho) {
return;
}
ResizeHeight(pOut, wo, hi, pIn, wo, ho);
ResizeHeight(pOut + so, wo/2, hi/2, pIn + so, wo/2, ho/2);
ResizeHeight(pOut + so + so/4, wo/2, hi/2, pIn + so + so/4, wo/2, ho/2);
- } else if(hi < ho) {
+ } else if (hi < ho) {
ResizeHeight(pIn, wi, hi, pOut, wo, ho);
ResizeHeight(pIn + si, wi/2, hi/2, pOut + so, wo/2, ho/2);
ResizeHeight(pIn + si + si/4, wi/2, hi/2, pOut + so + so/4, wo/2, ho/2);
- if(wi == wo) {
+ if (wi == wo) {
return;
}
ASSERT(0); // this is uncreachable code, but anyway... looks nice being so symmetric
@@ -1829,8 +1829,8 @@ void CRealVideoDecoder::Resize(BYTE* pIn, DWORD wi, DWORD hi, BYTE* pOut, DWORD void CRealVideoDecoder::ResizeWidth(BYTE* pIn, DWORD wi, DWORD hi, BYTE* pOut, DWORD wo, DWORD ho)
{
- for(DWORD y = 0; y < hi; y++, pIn += wi, pOut += wo) {
- if(wi == wo) {
+ for (DWORD y = 0; y < hi; y++, pIn += wi, pOut += wo) {
+ if (wi == wo) {
memcpy(pOut, pIn, wo);
} else {
ResizeRow(pIn, wi, 1, pOut, wo, 1);
@@ -1840,10 +1840,10 @@ void CRealVideoDecoder::ResizeWidth(BYTE* pIn, DWORD wi, DWORD hi, BYTE* pOut, D void CRealVideoDecoder::ResizeHeight(BYTE* pIn, DWORD wi, DWORD hi, BYTE* pOut, DWORD wo, DWORD ho)
{
- if(hi == ho) {
+ if (hi == ho) {
memcpy(pOut, pIn, wo*ho);
} else {
- for(DWORD x = 0; x < wo; x++, pIn++, pOut++) {
+ for (DWORD x = 0; x < wo; x++, pIn++, pOut++) {
ResizeRow(pIn, hi, wo, pOut, ho, wo);
}
}
@@ -1853,8 +1853,8 @@ void CRealVideoDecoder::ResizeRow(BYTE* pIn, DWORD wi, DWORD dpi, BYTE* pOut, DW {
ASSERT(wi < wo);
- if(dpo == 1) {
- for(DWORD i = 0, j = 0, dj = (wi<<16)/wo; i < wo-1; i++, pOut++, j += dj)
+ if (dpo == 1) {
+ for (DWORD i = 0, j = 0, dj = (wi<<16)/wo; i < wo-1; i++, pOut++, j += dj)
// pOut[i] = pIn[j>>16];
{
BYTE* p = &pIn[j>>16];
@@ -1864,7 +1864,7 @@ void CRealVideoDecoder::ResizeRow(BYTE* pIn, DWORD wi, DWORD dpi, BYTE* pOut, DW *pOut = pIn[wi-1];
} else {
- for(DWORD i = 0, j = 0, dj = (wi<<16)/wo; i < wo-1; i++, pOut += dpo, j += dj)
+ for (DWORD i = 0, j = 0, dj = (wi<<16)/wo; i < wo-1; i++, pOut += dpo, j += dj)
// *pOut = pIn[dpi*(j>>16)];
{
BYTE* p = &pIn[dpi*(j>>16)];
@@ -1878,7 +1878,7 @@ void CRealVideoDecoder::ResizeRow(BYTE* pIn, DWORD wi, DWORD dpi, BYTE* pOut, DW HRESULT CRealVideoDecoder::CheckInputType(const CMediaType* mtIn)
{
- if(mtIn->majortype != MEDIATYPE_Video
+ if (mtIn->majortype != MEDIATYPE_Video
|| mtIn->subtype != MEDIASUBTYPE_RV20
&& mtIn->subtype != MEDIASUBTYPE_RV30
&& mtIn->subtype != MEDIASUBTYPE_RV40
@@ -1886,16 +1886,16 @@ HRESULT CRealVideoDecoder::CheckInputType(const CMediaType* mtIn) return VFW_E_TYPE_NOT_ACCEPTED;
}
- if(mtIn->formattype == FORMAT_VideoInfo2) {
+ if (mtIn->formattype == FORMAT_VideoInfo2) {
VIDEOINFOHEADER2* vih2 = (VIDEOINFOHEADER2*)mtIn->Format();
- if(vih2->dwPictAspectRatioX < vih2->bmiHeader.biWidth
+ if (vih2->dwPictAspectRatioX < vih2->bmiHeader.biWidth
|| vih2->dwPictAspectRatioY < vih2->bmiHeader.biHeight) {
return VFW_E_TYPE_NOT_ACCEPTED;
}
}
- if(!m_pInput->IsConnected()) {
- if(m_hDrvDll) {
+ if (!m_pInput->IsConnected()) {
+ if (m_hDrvDll) {
FreeLibrary(m_hDrvDll);
m_hDrvDll = NULL;
}
@@ -1912,37 +1912,37 @@ HRESULT CRealVideoDecoder::CheckInputType(const CMediaType* mtIn) CRegKey key;
TCHAR buff[_MAX_PATH];
ULONG len = sizeof(buff);
- if(ERROR_SUCCESS == key.Open(HKEY_CLASSES_ROOT, _T("Software\\RealNetworks\\Preferences\\DT_Codecs"), KEY_READ)
+ if (ERROR_SUCCESS == key.Open(HKEY_CLASSES_ROOT, _T("Software\\RealNetworks\\Preferences\\DT_Codecs"), KEY_READ)
&& ERROR_SUCCESS == key.QueryStringValue(NULL, buff, &len) && _tcslen(buff) > 0) {
oldpath = buff;
TCHAR c = oldpath[oldpath.GetLength()-1];
- if(c != '\\' && c != '/') {
+ if (c != '\\' && c != '/') {
oldpath += '\\';
}
key.Close();
}
len = sizeof(buff);
- if(ERROR_SUCCESS == key.Open(HKEY_CLASSES_ROOT, _T("Helix\\HelixSDK\\10.0\\Preferences\\DT_Codecs"), KEY_READ)
+ if (ERROR_SUCCESS == key.Open(HKEY_CLASSES_ROOT, _T("Helix\\HelixSDK\\10.0\\Preferences\\DT_Codecs"), KEY_READ)
&& ERROR_SUCCESS == key.QueryStringValue(NULL, buff, &len) && _tcslen(buff) > 0) {
newpath = buff;
TCHAR c = newpath[newpath.GetLength()-1];
- if(c != '\\' && c != '/') {
+ if (c != '\\' && c != '/') {
newpath += '\\';
}
key.Close();
}
- if(!newpath.IsEmpty()) {
+ if (!newpath.IsEmpty()) {
paths.AddTail(newpath + newdll);
}
- if(!oldpath.IsEmpty()) {
+ if (!oldpath.IsEmpty()) {
paths.AddTail(oldpath + newdll);
}
paths.AddTail(newdll); // default dll paths
- if(!newpath.IsEmpty()) {
+ if (!newpath.IsEmpty()) {
paths.AddTail(newpath + olddll);
}
- if(!oldpath.IsEmpty()) {
+ if (!oldpath.IsEmpty()) {
paths.AddTail(oldpath + olddll);
}
paths.AddTail(olddll); // default dll paths
@@ -1952,39 +1952,39 @@ HRESULT CRealVideoDecoder::CheckInputType(const CMediaType* mtIn) if (pos) {
m_hDrvDll = LoadLibrary(paths.GetNext(pos));
}
- } while(pos && !m_hDrvDll);
+ } while (pos && !m_hDrvDll);
- if(m_hDrvDll) {
+ if (m_hDrvDll) {
RVCustomMessage = (PRVCustomMessage)GetProcAddress(m_hDrvDll, "RV20toYUV420CustomMessage");
RVFree = (PRVFree)GetProcAddress(m_hDrvDll, "RV20toYUV420Free");
RVHiveMessage = (PRVHiveMessage)GetProcAddress(m_hDrvDll, "RV20toYUV420HiveMessage");
RVInit = (PRVInit)GetProcAddress(m_hDrvDll, "RV20toYUV420Init");
RVTransform = (PRVTransform)GetProcAddress(m_hDrvDll, "RV20toYUV420Transform");
- if(!RVCustomMessage) {
+ if (!RVCustomMessage) {
RVCustomMessage = (PRVCustomMessage)GetProcAddress(m_hDrvDll, "RV40toYUV420CustomMessage");
}
- if(!RVFree) {
+ if (!RVFree) {
RVFree = (PRVFree)GetProcAddress(m_hDrvDll, "RV40toYUV420Free");
}
- if(!RVHiveMessage) {
+ if (!RVHiveMessage) {
RVHiveMessage = (PRVHiveMessage)GetProcAddress(m_hDrvDll, "RV40toYUV420HiveMessage");
}
- if(!RVInit) {
+ if (!RVInit) {
RVInit = (PRVInit)GetProcAddress(m_hDrvDll, "RV40toYUV420Init");
}
- if(!RVTransform) {
+ if (!RVTransform) {
RVTransform = (PRVTransform)GetProcAddress(m_hDrvDll, "RV40toYUV420Transform");
}
}
- if(!m_hDrvDll || !RVCustomMessage
+ if (!m_hDrvDll || !RVCustomMessage
|| !RVFree || !RVHiveMessage
|| !RVInit || !RVTransform) {
return VFW_E_TYPE_NOT_ACCEPTED;
}
- if(FAILED(InitRV(mtIn))) {
+ if (FAILED(InitRV(mtIn))) {
return VFW_E_TYPE_NOT_ACCEPTED;
}
}
@@ -1994,9 +1994,9 @@ HRESULT CRealVideoDecoder::CheckInputType(const CMediaType* mtIn) HRESULT CRealVideoDecoder::CheckTransform(const CMediaType* mtIn, const CMediaType* mtOut)
{
- if(m_pOutput && m_pOutput->IsConnected()) {
+ if (m_pOutput && m_pOutput->IsConnected()) {
BITMAPINFOHEADER bih1, bih2;
- if(ExtractBIH(mtOut, &bih1) && ExtractBIH(&m_pOutput->CurrentMediaType(), &bih2)
+ if (ExtractBIH(mtOut, &bih1) && ExtractBIH(&m_pOutput->CurrentMediaType(), &bih2)
&& abs(bih1.biHeight) != abs(bih2.biHeight)) {
return VFW_E_TYPE_NOT_ACCEPTED;
}
@@ -2008,7 +2008,7 @@ HRESULT CRealVideoDecoder::CheckTransform(const CMediaType* mtIn, const CMediaTy HRESULT CRealVideoDecoder::StartStreaming()
{
const CMediaType& mt = m_pInput->CurrentMediaType();
- if(FAILED(InitRV(&mt))) {
+ if (FAILED(InitRV(&mt))) {
return E_FAIL;
}
@@ -2050,10 +2050,10 @@ HRESULT CRealVideoDecoder::NewSegment(REFERENCE_TIME tStart, REFERENCE_TIME tSto HRESULT CRealVideoDecoder::AlterQuality(Quality q)
{
- if(q.Late > 500*10000i64) {
+ if (q.Late > 500*10000i64) {
m_fDropFrames = true;
}
- if(q.Late <= 0) {
+ if (q.Late <= 0) {
m_fDropFrames = false;
}
// TRACE(_T("CRealVideoDecoder::AlterQuality: Type=%d, Proportion=%d, Late=%I64d, TimeStamp=%I64d\n"), q.Type, q.Proportion, q.Late, q.TimeStamp);
@@ -2071,7 +2071,7 @@ CRealAudioDecoder::CRealAudioDecoder(LPUNKNOWN lpunk, HRESULT* phr) , m_hDrvDll(NULL)
, m_dwCookie(0)
{
- if(phr) {
+ if (phr) {
*phr = S_OK;
}
}
@@ -2079,7 +2079,7 @@ CRealAudioDecoder::CRealAudioDecoder(LPUNKNOWN lpunk, HRESULT* phr) CRealAudioDecoder::~CRealAudioDecoder()
{
// FreeRA();
- if(m_hDrvDll) {
+ if (m_hDrvDll) {
FreeLibrary(m_hDrvDll);
}
}
@@ -2090,7 +2090,7 @@ HRESULT CRealAudioDecoder::InitRA(const CMediaType* pmt) HRESULT hr;
- if(RAOpenCodec2 && FAILED(hr = RAOpenCodec2(&m_dwCookie, m_dllpath))
+ if (RAOpenCodec2 && FAILED(hr = RAOpenCodec2(&m_dwCookie, m_dllpath))
|| RAOpenCodec && FAILED(hr = RAOpenCodec(&m_dwCookie))) {
return VFW_E_TYPE_NOT_ACCEPTED;
}
@@ -2101,13 +2101,13 @@ HRESULT CRealAudioDecoder::InitRA(const CMediaType* pmt) // cbSize being really sizeof(WAVEFORMATEX) is less than this,
// especially with our rm splitter ;)
DWORD cbSize = pwfe->cbSize;
- if(cbSize == sizeof(WAVEFORMATEX)) {
+ if (cbSize == sizeof(WAVEFORMATEX)) {
ASSERT(0);
cbSize = 0;
}
WORD wBitsPerSample = pwfe->wBitsPerSample;
- if(!wBitsPerSample) {
+ if (!wBitsPerSample) {
wBitsPerSample = 16;
}
@@ -2125,21 +2125,21 @@ HRESULT CRealAudioDecoder::InitRA(const CMediaType* pmt) CAutoVectorPtr<BYTE> pBuff;
- if(pmt->subtype == MEDIASUBTYPE_AAC) {
+ if (pmt->subtype == MEDIASUBTYPE_AAC) {
pBuff.Allocate(cbSize+1);
pBuff[0] = 0x02;
memcpy(pBuff+1, pwfe+1, cbSize);
initdata.extralen = cbSize+1;
initdata.extra = pBuff;
} else {
- if(pmt->FormatLength() <= sizeof(WAVEFORMATEX) + cbSize) { // must have type_specific_data appended
+ if (pmt->FormatLength() <= sizeof(WAVEFORMATEX) + cbSize) { // must have type_specific_data appended
return VFW_E_TYPE_NOT_ACCEPTED;
}
BYTE* fmt = pmt->Format() + sizeof(WAVEFORMATEX) + cbSize;
- for(int i = 0, len = pmt->FormatLength() - (sizeof(WAVEFORMATEX) + cbSize); i < len-4; i++, fmt++) {
- if(fmt[0] == '.' || fmt[1] == 'r' || fmt[2] == 'a') {
+ for (int i = 0, len = pmt->FormatLength() - (sizeof(WAVEFORMATEX) + cbSize); i < len-4; i++, fmt++) {
+ if (fmt[0] == '.' || fmt[1] == 'r' || fmt[2] == 'a') {
break;
}
}
@@ -2149,21 +2149,21 @@ HRESULT CRealAudioDecoder::InitRA(const CMediaType* pmt) BYTE* p;
- if(m_rai.version2 == 4) {
+ if (m_rai.version2 == 4) {
p = (BYTE*)((rainfo4*)fmt+1);
int len = *p++;
p += len;
len = *p++;
p += len;
ASSERT(len == 4);
- } else if(m_rai.version2 == 5) {
+ } else if (m_rai.version2 == 5) {
p = (BYTE*)((rainfo5*)fmt+1);
} else {
return VFW_E_TYPE_NOT_ACCEPTED;
}
p += 3;
- if(m_rai.version2 == 5) {
+ if (m_rai.version2 == 5) {
p++;
}
@@ -2173,15 +2173,15 @@ HRESULT CRealAudioDecoder::InitRA(const CMediaType* pmt) initdata.extra = p + 4;
}
- if(FAILED(hr = RAInitDecoder(m_dwCookie, &initdata))) {
+ if (FAILED(hr = RAInitDecoder(m_dwCookie, &initdata))) {
return VFW_E_TYPE_NOT_ACCEPTED;
}
- if(RASetPwd) {
+ if (RASetPwd) {
RASetPwd(m_dwCookie, "Ardubancel Quazanga");
}
- if(RASetFlavor && FAILED(hr = RASetFlavor(m_dwCookie, m_rai.flavor))) {
+ if (RASetFlavor && FAILED(hr = RASetFlavor(m_dwCookie, m_rai.flavor))) {
return VFW_E_TYPE_NOT_ACCEPTED;
}
@@ -2190,7 +2190,7 @@ HRESULT CRealAudioDecoder::InitRA(const CMediaType* pmt) void CRealAudioDecoder::FreeRA()
{
- if(m_dwCookie) {
+ if (m_dwCookie) {
RAFreeDecoder(m_dwCookie);
RACloseCodec(m_dwCookie);
m_dwCookie = 0;
@@ -2204,19 +2204,19 @@ HRESULT CRealAudioDecoder::Receive(IMediaSample* pIn) HRESULT hr;
AM_SAMPLE2_PROPERTIES* const pProps = m_pInput->SampleProps();
- if(pProps->dwStreamId != AM_STREAM_MEDIA) {
+ if (pProps->dwStreamId != AM_STREAM_MEDIA) {
return m_pOutput->Deliver(pIn);
}
BYTE* pDataIn = NULL;
- if(FAILED(hr = pIn->GetPointer(&pDataIn))) {
+ if (FAILED(hr = pIn->GetPointer(&pDataIn))) {
return hr;
}
BYTE* pDataInOrg = pDataIn;
UNUSED_ALWAYS(pDataInOrg);
long len = pIn->GetActualDataLength();
- if(len <= 0) {
+ if (len <= 0) {
return S_OK;
}
@@ -2227,7 +2227,7 @@ HRESULT CRealAudioDecoder::Receive(IMediaSample* pIn) return S_OK;
*/
- if(S_OK == pIn->IsSyncPoint()) {
+ if (S_OK == pIn->IsSyncPoint()) {
m_bufflen = 0;
m_rtBuffStart = rtStart;
m_fBuffDiscontinuity = pIn->IsDiscontinuity() == S_OK;
@@ -2240,7 +2240,7 @@ HRESULT CRealAudioDecoder::Receive(IMediaSample* pIn) int h = m_rai.sub_packet_h;
int sps = m_rai.sub_packet_size;
- if(m_pInput->CurrentMediaType().subtype == MEDIASUBTYPE_RAAC
+ if (m_pInput->CurrentMediaType().subtype == MEDIASUBTYPE_RAAC
|| m_pInput->CurrentMediaType().subtype == MEDIASUBTYPE_RACP
|| m_pInput->CurrentMediaType().subtype == MEDIASUBTYPE_AAC) {
src = pDataIn;
@@ -2252,17 +2252,17 @@ HRESULT CRealAudioDecoder::Receive(IMediaSample* pIn) len = w*h;
- if(m_bufflen >= len) {
+ if (m_bufflen >= len) {
ASSERT(m_bufflen == len);
src = m_buff;
dst = m_buff + len;
- if(sps > 0
+ if (sps > 0
&& (m_pInput->CurrentMediaType().subtype == MEDIASUBTYPE_COOK
|| m_pInput->CurrentMediaType().subtype == MEDIASUBTYPE_ATRC)) {
- for(int y = 0; y < h; y++) {
- for(int x = 0, w2 = w / sps; x < w2; x++) {
+ for (int y = 0; y < h; y++) {
+ for (int x = 0, w2 = w / sps; x < w2; x++) {
// TRACE(_T("--- %d, %d\n"), (h*x+((h+1)/2)*(y&1)+(y>>1)), sps*(h*x+((h+1)/2)*(y&1)+(y>>1)));
memcpy(dst + sps*(h*x+((h+1)/2)*(y&1)+(y>>1)), src, sps);
src += sps;
@@ -2271,7 +2271,7 @@ HRESULT CRealAudioDecoder::Receive(IMediaSample* pIn) src = m_buff + len;
dst = m_buff + len*2;
- } else if(m_pInput->CurrentMediaType().subtype == MEDIASUBTYPE_SIPR) {
+ } else if (m_pInput->CurrentMediaType().subtype == MEDIASUBTYPE_SIPR) {
// http://mplayerhq.hu/pipermail/mplayer-dev-eng/2002-August/010569.html
static BYTE sipr_swaps[38][2]= {
@@ -2283,19 +2283,19 @@ HRESULT CRealAudioDecoder::Receive(IMediaSample* pIn) };
int bs=h*w*2/96; // nibbles per subpacket
- for(int n=0; n<38; n++) {
+ for (int n=0; n<38; n++) {
int i=bs*sipr_swaps[n][0];
int o=bs*sipr_swaps[n][1];
// swap nibbles of block 'i' with 'o' TODO: optimize
- for(int j=0; j<bs; j++) {
+ for (int j=0; j<bs; j++) {
int x=(i&1) ? (src[(i>>1)]>>4) : (src[(i>>1)]&15);
int y=(o&1) ? (src[(o>>1)]>>4) : (src[(o>>1)]&15);
- if(o&1) {
+ if (o&1) {
src[(o>>1)]=(src[(o>>1)]&0x0F)|(x<<4);
} else {
src[(o>>1)]=(src[(o>>1)]&0xF0)|x;
}
- if(i&1) {
+ if (i&1) {
src[(i>>1)]=(src[(i>>1)]&0x0F)|(y<<4);
} else {
src[(i>>1)]=(src[(i>>1)]&0xF0)|y;
@@ -2312,16 +2312,16 @@ HRESULT CRealAudioDecoder::Receive(IMediaSample* pIn) rtStart = m_rtBuffStart;
- for(; src < dst; src += w) {
+ for (; src < dst; src += w) {
CComPtr<IMediaSample> pOut;
BYTE* pDataOut = NULL;
- if(FAILED(hr = m_pOutput->GetDeliveryBuffer(&pOut, NULL, NULL, 0))
+ if (FAILED(hr = m_pOutput->GetDeliveryBuffer(&pOut, NULL, NULL, 0))
|| FAILED(hr = pOut->GetPointer(&pDataOut))) {
return hr;
}
AM_MEDIA_TYPE* pmt;
- if(SUCCEEDED(pOut->GetMediaType(&pmt)) && pmt) {
+ if (SUCCEEDED(pOut->GetMediaType(&pmt)) && pmt) {
CMediaType mt(*pmt);
m_pOutput->SetMediaType(&mt);
DeleteMediaType(pmt);
@@ -2329,7 +2329,7 @@ HRESULT CRealAudioDecoder::Receive(IMediaSample* pIn) hr = RADecode(m_dwCookie, src, w, pDataOut, &len, -1);
- if(FAILED(hr)) {
+ if (FAILED(hr)) {
TRACE(_T("RA returned an error code!!!\n"));
continue;
// return hr;
@@ -2350,7 +2350,7 @@ HRESULT CRealAudioDecoder::Receive(IMediaSample* pIn) DbgLog((LOG_TRACE, 0, _T("A: rtStart=%I64d, rtStop=%I64d, disc=%d, sync=%d"),
rtStart, rtStop, pOut->IsDiscontinuity() == S_OK, pOut->IsSyncPoint() == S_OK));
- if(rtStart >= 0 && S_OK != (hr = m_pOutput->Deliver(pOut))) {
+ if (rtStart >= 0 && S_OK != (hr = m_pOutput->Deliver(pOut))) {
return hr;
}
@@ -2364,7 +2364,7 @@ HRESULT CRealAudioDecoder::Receive(IMediaSample* pIn) HRESULT CRealAudioDecoder::CheckInputType(const CMediaType* mtIn)
{
- if(mtIn->majortype != MEDIATYPE_Audio
+ if (mtIn->majortype != MEDIATYPE_Audio
|| mtIn->subtype != MEDIASUBTYPE_14_4
&& mtIn->subtype != MEDIASUBTYPE_28_8
&& mtIn->subtype != MEDIASUBTYPE_ATRC
@@ -2377,8 +2377,8 @@ HRESULT CRealAudioDecoder::CheckInputType(const CMediaType* mtIn) return VFW_E_TYPE_NOT_ACCEPTED;
}
- if(!m_pInput->IsConnected()) {
- if(m_hDrvDll) {
+ if (!m_pInput->IsConnected()) {
+ if (m_hDrvDll) {
FreeLibrary(m_hDrvDll);
m_hDrvDll = NULL;
}
@@ -2394,7 +2394,7 @@ HRESULT CRealAudioDecoder::CheckInputType(const CMediaType* mtIn) 0
};
- if(!_tcscmp(_T("RACP"), fourcc) || !_tcscmp(_T("\xff"), fourcc)) {
+ if (!_tcscmp(_T("RACP"), fourcc) || !_tcscmp(_T("\xff"), fourcc)) {
_tcscpy(fourcc, _T("RAAC"));
}
@@ -2404,37 +2404,37 @@ HRESULT CRealAudioDecoder::CheckInputType(const CMediaType* mtIn) CRegKey key;
TCHAR buff[_MAX_PATH];
ULONG len = sizeof(buff);
- if(ERROR_SUCCESS == key.Open(HKEY_CLASSES_ROOT, _T("Software\\RealNetworks\\Preferences\\DT_Codecs"), KEY_READ)
+ if (ERROR_SUCCESS == key.Open(HKEY_CLASSES_ROOT, _T("Software\\RealNetworks\\Preferences\\DT_Codecs"), KEY_READ)
&& ERROR_SUCCESS == key.QueryStringValue(NULL, buff, &len) && _tcslen(buff) > 0) {
oldpath = buff;
TCHAR c = oldpath[oldpath.GetLength()-1];
- if(c != '\\' && c != '/') {
+ if (c != '\\' && c != '/') {
oldpath += '\\';
}
key.Close();
}
len = sizeof(buff);
- if(ERROR_SUCCESS == key.Open(HKEY_CLASSES_ROOT, _T("Helix\\HelixSDK\\10.0\\Preferences\\DT_Codecs"), KEY_READ)
+ if (ERROR_SUCCESS == key.Open(HKEY_CLASSES_ROOT, _T("Helix\\HelixSDK\\10.0\\Preferences\\DT_Codecs"), KEY_READ)
&& ERROR_SUCCESS == key.QueryStringValue(NULL, buff, &len) && _tcslen(buff) > 0) {
newpath = buff;
TCHAR c = newpath[newpath.GetLength()-1];
- if(c != '\\' && c != '/') {
+ if (c != '\\' && c != '/') {
newpath += '\\';
}
key.Close();
}
- if(!newpath.IsEmpty()) {
+ if (!newpath.IsEmpty()) {
paths.AddTail(newpath + newdll);
}
- if(!oldpath.IsEmpty()) {
+ if (!oldpath.IsEmpty()) {
paths.AddTail(oldpath + newdll);
}
paths.AddTail(newdll); // default dll paths
- if(!newpath.IsEmpty()) {
+ if (!newpath.IsEmpty()) {
paths.AddTail(newpath + olddll);
}
- if(!oldpath.IsEmpty()) {
+ if (!oldpath.IsEmpty()) {
paths.AddTail(oldpath + olddll);
}
paths.AddTail(olddll); // default dll paths
@@ -2444,9 +2444,9 @@ HRESULT CRealAudioDecoder::CheckInputType(const CMediaType* mtIn) if (pos) {
m_hDrvDll = LoadLibrary(paths.GetNext(pos));
}
- } while(pos && !m_hDrvDll);
+ } while (pos && !m_hDrvDll);
- if(m_hDrvDll) {
+ if (m_hDrvDll) {
RACloseCodec = (PCloseCodec)GetProcAddress(m_hDrvDll, "RACloseCodec");
RADecode = (PDecode)GetProcAddress(m_hDrvDll, "RADecode");
RAFlush = (PFlush)GetProcAddress(m_hDrvDll, "RAFlush");
@@ -2460,25 +2460,25 @@ HRESULT CRealAudioDecoder::CheckInputType(const CMediaType* mtIn) RASetPwd = (PSetPwd)GetProcAddress(m_hDrvDll, "RASetPwd");
}
- if(!m_hDrvDll || !RACloseCodec || !RADecode /*|| !RAFlush*/
+ if (!m_hDrvDll || !RACloseCodec || !RADecode /*|| !RAFlush*/
|| !RAFreeDecoder || !RAGetFlavorProperty || !RAInitDecoder
|| !(RAOpenCodec || RAOpenCodec2) /*|| !RASetFlavor*/) {
return VFW_E_TYPE_NOT_ACCEPTED;
}
- if(m_hDrvDll) {
+ if (m_hDrvDll) {
char buff[_MAX_PATH];
GetModuleFileNameA(m_hDrvDll, buff, MAX_PATH);
CPathA p(buff);
p.RemoveFileSpec();
p.AddBackslash();
m_dllpath = p.m_strPath;
- if(RASetDLLAccessPath) {
+ if (RASetDLLAccessPath) {
RASetDLLAccessPath("DT_Codecs=" + m_dllpath);
}
}
- if(FAILED(InitRA(mtIn))) {
+ if (FAILED(InitRA(mtIn))) {
return VFW_E_TYPE_NOT_ACCEPTED;
}
}
@@ -2504,20 +2504,20 @@ HRESULT CRealAudioDecoder::CheckTransform(const CMediaType* mtIn, const CMediaTy HRESULT CRealAudioDecoder::DecideBufferSize(IMemAllocator* pAllocator, ALLOCATOR_PROPERTIES* pProperties)
{
- if(m_pInput->IsConnected() == FALSE) {
+ if (m_pInput->IsConnected() == FALSE) {
return E_UNEXPECTED;
}
CComPtr<IMemAllocator> pAllocatorIn;
m_pInput->GetAllocator(&pAllocatorIn);
- if(!pAllocatorIn) {
+ if (!pAllocatorIn) {
return E_UNEXPECTED;
}
WAVEFORMATEX* pwfe = (WAVEFORMATEX*)m_pOutput->CurrentMediaType().Format();
WORD wBitsPerSample = pwfe->wBitsPerSample;
- if(!wBitsPerSample) {
+ if (!wBitsPerSample) {
wBitsPerSample = 16;
}
@@ -2529,7 +2529,7 @@ HRESULT CRealAudioDecoder::DecideBufferSize(IMemAllocator* pAllocator, ALLOCATOR HRESULT hr;
ALLOCATOR_PROPERTIES Actual;
- if(FAILED(hr = pAllocator->SetProperties(pProperties, &Actual))) {
+ if (FAILED(hr = pAllocator->SetProperties(pProperties, &Actual))) {
return hr;
}
@@ -2540,7 +2540,7 @@ HRESULT CRealAudioDecoder::DecideBufferSize(IMemAllocator* pAllocator, ALLOCATOR HRESULT CRealAudioDecoder::GetMediaType(int iPosition, CMediaType* pmt)
{
- if(m_pInput->IsConnected() == FALSE) {
+ if (m_pInput->IsConnected() == FALSE) {
return E_UNEXPECTED;
}
@@ -2548,14 +2548,14 @@ HRESULT CRealAudioDecoder::GetMediaType(int iPosition, CMediaType* pmt) pmt->subtype = MEDIASUBTYPE_PCM;
WAVEFORMATEX* pwfe = (WAVEFORMATEX*)pmt->ReallocFormatBuffer(sizeof(WAVEFORMATEX));
- if(iPosition < 0) {
+ if (iPosition < 0) {
return E_INVALIDARG;
}
- if(iPosition > (pwfe->nChannels > 2 && pwfe->nChannels <= 6 ? 1 : 0)) {
+ if (iPosition > (pwfe->nChannels > 2 && pwfe->nChannels <= 6 ? 1 : 0)) {
return VFW_S_NO_MORE_ITEMS;
}
- if(!pwfe->wBitsPerSample) {
+ if (!pwfe->wBitsPerSample) {
pwfe->wBitsPerSample = 16;
}
@@ -2564,7 +2564,7 @@ HRESULT CRealAudioDecoder::GetMediaType(int iPosition, CMediaType* pmt) pwfe->nBlockAlign = pwfe->nChannels*pwfe->wBitsPerSample>>3;
pwfe->nAvgBytesPerSec = pwfe->nSamplesPerSec*pwfe->nBlockAlign;
- if(iPosition == 0 && pwfe->nChannels > 2 && pwfe->nChannels <= 6) {
+ if (iPosition == 0 && pwfe->nChannels > 2 && pwfe->nChannels <= 6) {
static DWORD chmask[] = {
KSAUDIO_SPEAKER_DIRECTOUT,
KSAUDIO_SPEAKER_MONO,
diff --git a/src/filters/parser/SSFSplitter/SSFSplitter.cpp b/src/filters/parser/SSFSplitter/SSFSplitter.cpp index 6c8532e57..bf1cf34d4 100644 --- a/src/filters/parser/SSFSplitter/SSFSplitter.cpp +++ b/src/filters/parser/SSFSplitter/SSFSplitter.cpp @@ -81,10 +81,10 @@ namespace ssf }
int NextByte() {
- if(!m_pFile) {
+ if (!m_pFile) {
ThrowError(_T("m_pFile is NULL"));
}
- if(!m_pFile->GetRemaining()) {
+ if (!m_pFile->GetRemaining()) {
return EOS;
}
return (int)m_pFile->BitRead(8);
@@ -96,10 +96,10 @@ int CSSFSplitterFilter::SegmentItemEx::Compare(const void* a, const void* b) {
const SegmentItemEx* si1 = (const SegmentItemEx*)a;
const SegmentItemEx* si2 = (const SegmentItemEx*)b;
- if(si1->start < si2->start) {
+ if (si1->start < si2->start) {
return -1;
}
- if(si2->start < si1->start) {
+ if (si2->start < si1->start) {
return +1;
}
return 0;
@@ -122,17 +122,17 @@ HRESULT CSSFSplitterFilter::CreateOutputs(IAsyncReader* pAsyncReader) m_pFile.Free();
m_pFile.Attach(DNew CBaseSplitterFile(pAsyncReader, hr));
- if(!m_pFile) {
+ if (!m_pFile) {
return E_OUTOFMEMORY;
}
- if(FAILED(hr)) {
+ if (FAILED(hr)) {
m_pFile.Free();
return hr;
}
try {
m_ssf.Parse(ssf::InputStreamBSF(m_pFile));
- } catch(ssf::Exception&) {
+ } catch (ssf::Exception&) {
return E_FAIL;
}
@@ -141,17 +141,17 @@ HRESULT CSSFSplitterFilter::CreateOutputs(IAsyncReader* pAsyncReader) m_rtNewStart = m_rtCurrent = 0;
m_rtNewStop = m_rtStop = m_rtDuration = 0;
- if(ssf::Reference* pRootRef = m_ssf.GetRootRef()) {
+ if (ssf::Reference* pRootRef = m_ssf.GetRootRef()) {
ssf::WCharOutputStream s;
ssf::StringMapW<float> offset;
POSITION pos = pRootRef->m_nodes.GetHeadPosition();
- while(pos) {
- if(ssf::Definition* pDef = dynamic_cast<ssf::Definition*>(pRootRef->m_nodes.GetNext(pos))) {
+ while (pos) {
+ if (ssf::Definition* pDef = dynamic_cast<ssf::Definition*>(pRootRef->m_nodes.GetNext(pos))) {
try {
ssf::Definition::Time time;
- if(pDef->m_type == L"subtitle" && pDef->GetAsTime(time, offset) && (*pDef)[L"@"].IsValue()) {
+ if (pDef->m_type == L"subtitle" && pDef->GetAsTime(time, offset) && (*pDef)[L"@"].IsValue()) {
SegmentItemEx si;
si.pDef = pDef;
si.start = time.start.value;
@@ -162,7 +162,7 @@ HRESULT CSSFSplitterFilter::CreateOutputs(IAsyncReader* pAsyncReader) continue;
}
- } catch(ssf::Exception&) {
+ } catch (ssf::Exception&) {
}
pDef->Dump(s);
@@ -193,16 +193,16 @@ HRESULT CSSFSplitterFilter::CreateOutputs(IAsyncReader* pAsyncReader) CAtlArray<SegmentItemEx> subs;
subs.SetCount(m_subs.GetCount());
pos = m_subs.GetHeadPosition();
- for(size_t i = 0; pos; i++) {
+ for (size_t i = 0; pos; i++) {
subs.SetAt(i, m_subs.GetNext(pos));
}
qsort(subs.GetData(), subs.GetCount(), sizeof(SegmentItemEx), SegmentItemEx::Compare);
m_subs.RemoveAll();
- for(size_t i = 0; i < subs.GetCount(); i++) {
+ for (size_t i = 0; i < subs.GetCount(); i++) {
m_subs.AddTail(subs[i]);
}
- if(!m_ssf.m_segments.IsEmpty()) {
+ if (!m_ssf.m_segments.IsEmpty()) {
m_rtNewStop = m_rtStop = m_rtDuration = 10000000i64*m_ssf.m_segments.GetTail().m_stop;
}
}
@@ -218,7 +218,7 @@ bool CSSFSplitterFilter::DemuxInit() void CSSFSplitterFilter::DemuxSeek(REFERENCE_TIME rt)
{
- if(rt <= 0) {
+ if (rt <= 0) {
} else {
// TODO
}
@@ -230,7 +230,7 @@ bool CSSFSplitterFilter::DemuxLoop() POSITION pos = m_subs.GetHeadPosition();
- while(pos && SUCCEEDED(hr) && !CheckRequest(NULL)) {
+ while (pos && SUCCEEDED(hr) && !CheckRequest(NULL)) {
SegmentItemEx& si = m_subs.GetNext(pos);
ssf::WCharOutputStream s;
diff --git a/src/filters/parser/StreamDriveThru/StreamDriveThru.cpp b/src/filters/parser/StreamDriveThru/StreamDriveThru.cpp index 8e5e09192..b6cac313a 100644 --- a/src/filters/parser/StreamDriveThru/StreamDriveThru.cpp +++ b/src/filters/parser/StreamDriveThru/StreamDriveThru.cpp @@ -72,7 +72,7 @@ CStreamDriveThruFilter::CStreamDriveThruFilter(LPUNKNOWN pUnk, HRESULT* phr) : CBaseFilter(NAME("CStreamDriveThruFilter"), pUnk, &m_csLock, __uuidof(this))
, m_position(0)
{
- if(phr) {
+ if (phr) {
*phr = S_OK;
}
@@ -106,10 +106,10 @@ STDMETHODIMP CStreamDriveThruFilter::NonDelegatingQueryInterface(REFIID riid, vo DWORD CStreamDriveThruFilter::ThreadProc()
{
- while(1) {
+ while (1) {
DWORD cmd = GetRequest();
- switch(cmd) {
+ switch (cmd) {
default:
case CMD_EXIT:
Reply(S_OK);
@@ -127,7 +127,7 @@ DWORD CStreamDriveThruFilter::ThreadProc() CComPtr<IAsyncReader> pAsyncReader;
CComPtr<IStream> pStream;
- if(!m_pInput || !m_pInput->IsConnected() || FAILED(m_pInput->GetAsyncReader(&pAsyncReader))
+ if (!m_pInput || !m_pInput->IsConnected() || FAILED(m_pInput->GetAsyncReader(&pAsyncReader))
|| !m_pOutput || !m_pOutput->IsConnected() || FAILED(m_pOutput->GetStream(&pStream))) {
break;
}
@@ -135,16 +135,16 @@ DWORD CStreamDriveThruFilter::ThreadProc() LARGE_INTEGER li = {0};
ULARGE_INTEGER uli = {0};
- if(FAILED(pStream->Seek(li, STREAM_SEEK_SET, NULL))
+ if (FAILED(pStream->Seek(li, STREAM_SEEK_SET, NULL))
|| FAILED(pStream->SetSize(uli))) {
break;
}
- if(CComQIPtr<IFileSinkFilter2> pFSF = GetFilterFromPin(m_pOutput->GetConnected())) {
+ if (CComQIPtr<IFileSinkFilter2> pFSF = GetFilterFromPin(m_pOutput->GetConnected())) {
pFSF->SetMode(AM_FILE_OVERWRITE);
LPOLESTR pfn;
- if(SUCCEEDED(pFSF->GetCurFile(&pfn, NULL))) {
+ if (SUCCEEDED(pFSF->GetCurFile(&pfn, NULL))) {
pFSF->SetFileName(pfn, NULL);
CoTaskMemFree(pfn);
}
@@ -154,23 +154,23 @@ DWORD CStreamDriveThruFilter::ThreadProc() BYTE buff[PACKETSIZE];
do {
- while(!CheckRequest(&cmd)) {
+ while (!CheckRequest(&cmd)) {
CAutoLock csAutoLock(&m_csLock);
LONGLONG total = 0, available = 0;
- if(FAILED(pAsyncReader->Length(&total, &available)) || m_position >= total) {
+ if (FAILED(pAsyncReader->Length(&total, &available)) || m_position >= total) {
cmd = CMD_STOP;
break;
}
LONG size = (LONG)min(PACKETSIZE, total - m_position);
- if(FAILED(pAsyncReader->SyncRead(m_position, size, buff))) {
+ if (FAILED(pAsyncReader->SyncRead(m_position, size, buff))) {
cmd = CMD_STOP;
break;
}
ULONG written = 0;
- if(FAILED(pStream->Write(buff, (ULONG)size, &written)) || (ULONG)size != written) {
+ if (FAILED(pStream->Write(buff, (ULONG)size, &written)) || (ULONG)size != written) {
cmd = CMD_STOP;
break;
}
@@ -178,24 +178,24 @@ DWORD CStreamDriveThruFilter::ThreadProc() m_position += size;
}
- if(cmd == CMD_PAUSE) {
+ if (cmd == CMD_PAUSE) {
Reply(S_OK); // reply to CMD_PAUSE
- while(!CheckRequest(&cmd)) {
+ while (!CheckRequest(&cmd)) {
Sleep(50);
}
Reply(S_OK); // reply to something
}
- } while(cmd == CMD_RUN);
+ } while (cmd == CMD_RUN);
uli.QuadPart = m_position;
pStream->SetSize(uli);
- if(CComPtr<IPin> pPin = m_pOutput->GetConnected()) {
+ if (CComPtr<IPin> pPin = m_pOutput->GetConnected()) {
pPin->EndOfStream();
}
- } while(false);
+ } while (false);
break;
}
@@ -213,9 +213,9 @@ CBasePin* CStreamDriveThruFilter::GetPin(int n) {
CAutoLock csAutoLock(&m_csLock);
- if(n == 0) {
+ if (n == 0) {
return m_pInput;
- } else if(n == 1) {
+ } else if (n == 1) {
return m_pOutput;
}
@@ -226,7 +226,7 @@ STDMETHODIMP CStreamDriveThruFilter::Stop() {
HRESULT hr;
- if(FAILED(hr = __super::Stop())) {
+ if (FAILED(hr = __super::Stop())) {
return hr;
}
@@ -239,7 +239,7 @@ STDMETHODIMP CStreamDriveThruFilter::Pause() {
HRESULT hr;
- if(FAILED(hr = __super::Pause())) {
+ if (FAILED(hr = __super::Pause())) {
return hr;
}
@@ -252,7 +252,7 @@ STDMETHODIMP CStreamDriveThruFilter::Run(REFERENCE_TIME tStart) {
HRESULT hr;
- if(FAILED(hr = __super::Run(tStart))) {
+ if (FAILED(hr = __super::Run(tStart))) {
return hr;
}
@@ -272,7 +272,7 @@ STDMETHODIMP CStreamDriveThruFilter::CheckCapabilities(DWORD* pCapabilities) {
CheckPointer(pCapabilities, E_POINTER);
- if(*pCapabilities == 0) {
+ if (*pCapabilities == 0) {
return S_OK;
}
@@ -314,9 +314,9 @@ STDMETHODIMP CStreamDriveThruFilter::GetDuration(LONGLONG* pDuration) CheckPointer(pDuration, E_POINTER);
CheckPointer(m_pInput, VFW_E_NOT_CONNECTED);
- if(CComQIPtr<IAsyncReader> pAsyncReader = m_pInput->GetConnected()) {
+ if (CComQIPtr<IAsyncReader> pAsyncReader = m_pInput->GetConnected()) {
LONGLONG total, available;
- if(SUCCEEDED(pAsyncReader->Length(&total, &available))) {
+ if (SUCCEEDED(pAsyncReader->Length(&total, &available))) {
*pDuration = total;
return S_OK;
}
@@ -415,11 +415,11 @@ HRESULT CStreamDriveThruInputPin::CheckConnect(IPin* pPin) {
HRESULT hr;
- if(FAILED(hr = __super::CheckConnect(pPin))) {
+ if (FAILED(hr = __super::CheckConnect(pPin))) {
return hr;
}
- if(!CComQIPtr<IAsyncReader>(pPin)) {
+ if (!CComQIPtr<IAsyncReader>(pPin)) {
return E_NOINTERFACE;
}
@@ -430,7 +430,7 @@ HRESULT CStreamDriveThruInputPin::BreakConnect() {
HRESULT hr;
- if(FAILED(hr = __super::BreakConnect())) {
+ if (FAILED(hr = __super::BreakConnect())) {
return hr;
}
@@ -443,7 +443,7 @@ HRESULT CStreamDriveThruInputPin::CompleteConnect(IPin* pPin) {
HRESULT hr;
- if(FAILED(hr = __super::CompleteConnect(pPin))) {
+ if (FAILED(hr = __super::CompleteConnect(pPin))) {
return hr;
}
@@ -509,11 +509,11 @@ HRESULT CStreamDriveThruOutputPin::DecideBufferSize(IMemAllocator* pAlloc, ALLOC pProperties->cbBuffer = PACKETSIZE;
ALLOCATOR_PROPERTIES Actual;
- if(FAILED(hr = pAlloc->SetProperties(pProperties, &Actual))) {
+ if (FAILED(hr = pAlloc->SetProperties(pProperties, &Actual))) {
return hr;
}
- if(Actual.cbBuffer < pProperties->cbBuffer) {
+ if (Actual.cbBuffer < pProperties->cbBuffer) {
return E_FAIL;
}
ASSERT(Actual.cBuffers == pProperties->cBuffers);
@@ -532,10 +532,10 @@ HRESULT CStreamDriveThruOutputPin::GetMediaType(int iPosition, CMediaType* pmt) {
CAutoLock cAutoLock(m_pLock);
- if(iPosition < 0) {
+ if (iPosition < 0) {
return E_INVALIDARG;
}
- if(iPosition > 0) {
+ if (iPosition > 0) {
return VFW_S_NO_MORE_ITEMS;
}
@@ -551,11 +551,11 @@ HRESULT CStreamDriveThruOutputPin::CheckConnect(IPin* pPin) {
HRESULT hr;
- if(FAILED(hr = __super::CheckConnect(pPin))) {
+ if (FAILED(hr = __super::CheckConnect(pPin))) {
return hr;
}
- if(!CComQIPtr<IStream>(pPin)) {
+ if (!CComQIPtr<IStream>(pPin)) {
return E_NOINTERFACE;
}
@@ -566,7 +566,7 @@ HRESULT CStreamDriveThruOutputPin::BreakConnect() {
HRESULT hr;
- if(FAILED(hr = __super::BreakConnect())) {
+ if (FAILED(hr = __super::BreakConnect())) {
return hr;
}
@@ -579,7 +579,7 @@ HRESULT CStreamDriveThruOutputPin::CompleteConnect(IPin* pPin) {
HRESULT hr;
- if(FAILED(hr = __super::CompleteConnect(pPin))) {
+ if (FAILED(hr = __super::CompleteConnect(pPin))) {
return hr;
}
diff --git a/src/filters/reader/CDDAReader/CDDAReader.cpp b/src/filters/reader/CDDAReader/CDDAReader.cpp index b8211bb8d..b000a43bb 100644 --- a/src/filters/reader/CDDAReader/CDDAReader.cpp +++ b/src/filters/reader/CDDAReader/CDDAReader.cpp @@ -49,7 +49,7 @@ int g_cTemplates = countof(g_Templates); STDAPI DllRegisterServer()
{
- if(GetVersion()&0x80000000) {
+ if (GetVersion()&0x80000000) {
::MessageBox(NULL, _T("Sorry, this will only run on Windows NT based operating system."), _T("CDDA Reader"), MB_OK);
return E_NOTIMPL;
}
@@ -90,12 +90,12 @@ CFilterApp theApp; CCDDAReader::CCDDAReader(IUnknown* pUnk, HRESULT* phr)
: CAsyncReader(NAME("CCDDAReader"), pUnk, &m_stream, phr, __uuidof(this))
{
- if(phr) {
+ if (phr) {
*phr = S_OK;
}
- if(GetVersion()&0x80000000) {
- if(phr) {
+ if (GetVersion()&0x80000000) {
+ if (phr) {
*phr = E_NOTIMPL;
}
return;
@@ -120,7 +120,7 @@ STDMETHODIMP CCDDAReader::NonDelegatingQueryInterface(REFIID riid, void** ppv) STDMETHODIMP CCDDAReader::Load(LPCOLESTR pszFileName, const AM_MEDIA_TYPE* pmt)
{
- if(!m_stream.Load(pszFileName)) {
+ if (!m_stream.Load(pszFileName)) {
return E_FAIL;
}
@@ -139,7 +139,7 @@ STDMETHODIMP CCDDAReader::GetCurFile(LPOLESTR* ppszFileName, AM_MEDIA_TYPE* pmt) CheckPointer(ppszFileName, E_POINTER);
*ppszFileName = (LPOLESTR)CoTaskMemAlloc((m_fn.GetLength()+1)*sizeof(WCHAR));
- if(!(*ppszFileName)) {
+ if (!(*ppszFileName)) {
return E_OUTOFMEMORY;
}
@@ -174,7 +174,7 @@ STDMETHODIMP CCDDAReader::get_AuthorName(BSTR* pbstrAuthorName) {
CheckPointer(pbstrAuthorName, E_POINTER);
CString str = m_stream.m_trackArtist;
- if(str.IsEmpty()) {
+ if (str.IsEmpty()) {
str = m_stream.m_discArtist;
}
*pbstrAuthorName = str.AllocSysString();
@@ -185,7 +185,7 @@ STDMETHODIMP CCDDAReader::get_Title(BSTR* pbstrTitle) {
CheckPointer(pbstrTitle, E_POINTER);
CString str = m_stream.m_trackTitle;
- if(str.IsEmpty()) {
+ if (str.IsEmpty()) {
str = m_stream.m_discTitle;
}
*pbstrTitle = str.AllocSysString();
@@ -274,7 +274,7 @@ CCDDAStream::CCDDAStream() CCDDAStream::~CCDDAStream()
{
- if(m_hDrive != INVALID_HANDLE_VALUE) {
+ if (m_hDrive != INVALID_HANDLE_VALUE) {
CloseHandle(m_hDrive);
m_hDrive = INVALID_HANDLE_VALUE;
}
@@ -286,31 +286,31 @@ bool CCDDAStream::Load(const WCHAR* fnw) int iDriveLetter = path.Find(_T(":\\"))-1;
int iTrackIndex = CString(path).MakeLower().Find(_T(".cda"))-1;
- if(iDriveLetter < 0 || iTrackIndex <= iDriveLetter) {
+ if (iDriveLetter < 0 || iTrackIndex <= iDriveLetter) {
return false;
}
CString drive = CString(_T("\\\\.\\")) + path[iDriveLetter] + _T(":");
- while(iTrackIndex > 0 && _istdigit(path[iTrackIndex-1])) {
+ while (iTrackIndex > 0 && _istdigit(path[iTrackIndex-1])) {
iTrackIndex--;
}
- if(1 != _stscanf(path.Mid(iTrackIndex), _T("%d"), &iTrackIndex)) {
+ if (1 != _stscanf(path.Mid(iTrackIndex), _T("%d"), &iTrackIndex)) {
return false;
}
- if(m_hDrive != INVALID_HANDLE_VALUE) {
+ if (m_hDrive != INVALID_HANDLE_VALUE) {
CloseHandle(m_hDrive);
m_hDrive = INVALID_HANDLE_VALUE;
}
m_hDrive = CreateFile(drive, GENERIC_READ, FILE_SHARE_READ, NULL,
OPEN_EXISTING, FILE_ATTRIBUTE_READONLY|FILE_FLAG_SEQUENTIAL_SCAN, (HANDLE)NULL);
- if(m_hDrive == INVALID_HANDLE_VALUE) {
+ if (m_hDrive == INVALID_HANDLE_VALUE) {
return false;
}
DWORD BytesReturned;
- if(!DeviceIoControl(m_hDrive, IOCTL_CDROM_READ_TOC, NULL, 0, &m_TOC, sizeof(m_TOC), &BytesReturned, 0)
+ if (!DeviceIoControl(m_hDrive, IOCTL_CDROM_READ_TOC, NULL, 0, &m_TOC, sizeof(m_TOC), &BytesReturned, 0)
|| !(m_TOC.FirstTrack <= iTrackIndex && iTrackIndex <= m_TOC.LastTrack)) {
CloseHandle(m_hDrive);
m_hDrive = INVALID_HANDLE_VALUE;
@@ -319,13 +319,13 @@ bool CCDDAStream::Load(const WCHAR* fnw) // MMC-3 Draft Revision 10g: Table 222 – Q Sub-channel control field
m_TOC.TrackData[iTrackIndex-1].Control &= 5;
- if(!(m_TOC.TrackData[iTrackIndex-1].Control == 0 || m_TOC.TrackData[iTrackIndex-1].Control == 1)) {
+ if (!(m_TOC.TrackData[iTrackIndex-1].Control == 0 || m_TOC.TrackData[iTrackIndex-1].Control == 1)) {
CloseHandle(m_hDrive);
m_hDrive = INVALID_HANDLE_VALUE;
return false;
}
- if(m_TOC.TrackData[iTrackIndex-1].Control&8) {
+ if (m_TOC.TrackData[iTrackIndex-1].Control&8) {
m_header.frm.pcm.wf.nChannels = 4;
}
@@ -344,7 +344,7 @@ bool CCDDAStream::Load(const WCHAR* fnw) TOCEx.SessionTrack = iTrackIndex;
WORD size = 0;
ASSERT(MINIMUM_CDROM_READ_TOC_EX_SIZE == sizeof(size));
- if(!DeviceIoControl(m_hDrive, IOCTL_CDROM_READ_TOC_EX, &TOCEx, sizeof(TOCEx), &size, sizeof(size), &BytesReturned, 0)) {
+ if (!DeviceIoControl(m_hDrive, IOCTL_CDROM_READ_TOC_EX, &TOCEx, sizeof(TOCEx), &size, sizeof(size), &BytesReturned, 0)) {
break;
}
@@ -354,7 +354,7 @@ bool CCDDAStream::Load(const WCHAR* fnw) pCDTextData.Allocate(size);
memset(pCDTextData, 0, size);
- if(!DeviceIoControl(m_hDrive, IOCTL_CDROM_READ_TOC_EX, &TOCEx, sizeof(TOCEx), pCDTextData, size, &BytesReturned, 0)) {
+ if (!DeviceIoControl(m_hDrive, IOCTL_CDROM_READ_TOC_EX, &TOCEx, sizeof(TOCEx), pCDTextData, size, &BytesReturned, 0)) {
break;
}
@@ -362,13 +362,13 @@ bool CCDDAStream::Load(const WCHAR* fnw) CDROM_TOC_CD_TEXT_DATA_BLOCK* pDesc = ((CDROM_TOC_CD_TEXT_DATA*)(BYTE*)pCDTextData)->Descriptors;
CStringArray str[16];
- for(int i = 0; i < 16; i++) {
+ for (int i = 0; i < 16; i++) {
str[i].SetSize(1+m_TOC.LastTrack);
}
CString last;
- for(int i = 0; size >= sizeof(CDROM_TOC_CD_TEXT_DATA_BLOCK); i++, size -= sizeof(CDROM_TOC_CD_TEXT_DATA_BLOCK), pDesc++) {
- if(pDesc->TrackNumber > m_TOC.LastTrack) {
+ for (int i = 0; size >= sizeof(CDROM_TOC_CD_TEXT_DATA_BLOCK); i++, size -= sizeof(CDROM_TOC_CD_TEXT_DATA_BLOCK), pDesc++) {
+ if (pDesc->TrackNumber > m_TOC.LastTrack) {
continue;
}
@@ -386,14 +386,14 @@ bool CCDDAStream::Load(const WCHAR* fnw) : CString(CStringW((WCHAR*)pDesc->WText+tlen+1, lenW-(tlen+1))))
: _T("");
- if((pDesc->PackType -= 0x80) >= 0x10) {
+ if ((pDesc->PackType -= 0x80) >= 0x10) {
continue;
}
- if(pDesc->CharacterPosition == 0) {
+ if (pDesc->CharacterPosition == 0) {
str[pDesc->PackType][pDesc->TrackNumber] = text;
- } else if(pDesc->CharacterPosition <= 0xf) {
- if(pDesc->CharacterPosition < 0xf && last.GetLength() > 0) {
+ } else if (pDesc->CharacterPosition <= 0xf) {
+ if (pDesc->CharacterPosition < 0xf && last.GetLength() > 0) {
str[pDesc->PackType][pDesc->TrackNumber] = last + text;
} else {
str[pDesc->PackType][pDesc->TrackNumber] += text;
@@ -407,7 +407,7 @@ bool CCDDAStream::Load(const WCHAR* fnw) m_trackTitle = str[0][iTrackIndex];
m_discArtist = str[1][0];
m_trackArtist = str[1][iTrackIndex];
- } while(0);
+ } while (0);
return true;
@@ -415,7 +415,7 @@ bool CCDDAStream::Load(const WCHAR* fnw) HRESULT CCDDAStream::SetPointer(LONGLONG llPos)
{
- if(llPos < 0 || llPos > m_llLength) {
+ if (llPos < 0 || llPos > m_llLength) {
return S_FALSE;
}
m_llPosition = llPos;
@@ -432,7 +432,7 @@ HRESULT CCDDAStream::Read(PBYTE pbBuffer, DWORD dwBytesToRead, BOOL bAlign, LPDW LONGLONG pos = m_llPosition;
size_t len = (size_t)dwBytesToRead;
- if(pos < sizeof(m_header) && len > 0) {
+ if (pos < sizeof(m_header) && len > 0) {
size_t l = (size_t)min(len, sizeof(m_header) - pos);
memcpy(pbBuffer, &((BYTE*)&m_header)[pos], l);
pbBuffer += l;
@@ -442,7 +442,7 @@ HRESULT CCDDAStream::Read(PBYTE pbBuffer, DWORD dwBytesToRead, BOOL bAlign, LPDW pos -= sizeof(m_header);
- while(pos >= 0 && pos < m_llLength && len > 0) {
+ while (pos >= 0 && pos < m_llLength && len > 0) {
RAW_READ_INFO rawreadinfo;
rawreadinfo.SectorCount = 1;
rawreadinfo.TrackMode = CDDA;
@@ -467,7 +467,7 @@ HRESULT CCDDAStream::Read(PBYTE pbBuffer, DWORD dwBytesToRead, BOOL bAlign, LPDW len -= l;
}
- if(pdwBytesRead) {
+ if (pdwBytesRead) {
*pdwBytesRead = pbBuffer - pbBufferOrg;
}
m_llPosition += pbBuffer - pbBufferOrg;
@@ -478,7 +478,7 @@ HRESULT CCDDAStream::Read(PBYTE pbBuffer, DWORD dwBytesToRead, BOOL bAlign, LPDW LONGLONG CCDDAStream::Size(LONGLONG* pSizeAvailable)
{
LONGLONG size = sizeof(m_header) + m_llLength;
- if(pSizeAvailable) {
+ if (pSizeAvailable) {
*pSizeAvailable = size;
}
return size;
diff --git a/src/filters/reader/CDXAReader/CDXAReader.cpp b/src/filters/reader/CDXAReader/CDXAReader.cpp index 3bbb81bde..5fd451f21 100644 --- a/src/filters/reader/CDXAReader/CDXAReader.cpp +++ b/src/filters/reader/CDXAReader/CDXAReader.cpp @@ -100,7 +100,7 @@ static DWORD build_edc(const void* in, unsigned from, unsigned upto) const BYTE* p = (BYTE*)in + from;
DWORD result = 0;
- for(; from < upto; from++) {
+ for (; from < upto; from++) {
result = EDC_crctable[(result ^ *p++) & 0xffL] ^ (result >> 8);
}
@@ -162,7 +162,7 @@ CFilterApp theApp; CCDXAReader::CCDXAReader(IUnknown* pUnk, HRESULT* phr)
: CAsyncReader(NAME("CCDXAReader"), pUnk, &m_stream, phr, __uuidof(this))
{
- if(phr) {
+ if (phr) {
*phr = S_OK;
}
}
@@ -183,7 +183,7 @@ STDMETHODIMP CCDXAReader::Load(LPCOLESTR pszFileName, const AM_MEDIA_TYPE *pmt) CMediaType mt;
m_mt = mt;
- if(!m_stream.Load(pszFileName)) {
+ if (!m_stream.Load(pszFileName)) {
return E_FAIL;
}
@@ -198,12 +198,12 @@ STDMETHODIMP CCDXAReader::Load(LPCOLESTR pszFileName, const AM_MEDIA_TYPE *pmt) STDMETHODIMP CCDXAReader::GetCurFile(LPOLESTR* ppszFileName, AM_MEDIA_TYPE* pmt)
{
- if(!ppszFileName) {
+ if (!ppszFileName) {
return E_POINTER;
}
*ppszFileName = (LPOLESTR)CoTaskMemAlloc((m_fn.GetLength()+1)*sizeof(WCHAR));
- if(!(*ppszFileName)) {
+ if (!(*ppszFileName)) {
return E_OUTOFMEMORY;
}
@@ -227,7 +227,7 @@ CCDXAStream::CCDXAStream() CCDXAStream::~CCDXAStream()
{
- if(m_hFile != INVALID_HANDLE_VALUE) {
+ if (m_hFile != INVALID_HANDLE_VALUE) {
CloseHandle(m_hFile);
m_hFile = INVALID_HANDLE_VALUE;
}
@@ -235,20 +235,20 @@ CCDXAStream::~CCDXAStream() bool CCDXAStream::Load(const WCHAR* fnw)
{
- if(m_hFile != INVALID_HANDLE_VALUE) {
+ if (m_hFile != INVALID_HANDLE_VALUE) {
CloseHandle(m_hFile);
m_hFile = INVALID_HANDLE_VALUE;
}
m_hFile = CreateFile(CString(fnw), GENERIC_READ, FILE_SHARE_READ, NULL,
OPEN_EXISTING, FILE_ATTRIBUTE_READONLY|FILE_FLAG_SEQUENTIAL_SCAN, (HANDLE)NULL);
- if(m_hFile == INVALID_HANDLE_VALUE) {
+ if (m_hFile == INVALID_HANDLE_VALUE) {
return false;
}
BYTE hdr[RIFFCDXA_HEADER_SIZE];
DWORD NumberOfBytesRead;
- if(!ReadFile(m_hFile, (LPVOID)hdr, RIFFCDXA_HEADER_SIZE, &NumberOfBytesRead, NULL)
+ if (!ReadFile(m_hFile, (LPVOID)hdr, RIFFCDXA_HEADER_SIZE, &NumberOfBytesRead, NULL)
|| *((DWORD*)&hdr[0]) != 'FFIR' || *((DWORD*)&hdr[8]) != 'AXDC'
|| *((DWORD*)&hdr[4]) != (*((DWORD*)&hdr[0x28])+0x24)) {
CloseHandle(m_hFile);
@@ -261,7 +261,7 @@ bool CCDXAStream::Load(const WCHAR* fnw) m_llLength = int((size.QuadPart - RIFFCDXA_HEADER_SIZE) / RAW_SECTOR_SIZE) * RAW_DATA_SIZE;
- if(!LookForMediaSubType()) {
+ if (!LookForMediaSubType()) {
m_llPosition = m_llLength = 0;
CloseHandle(m_hFile);
m_hFile = INVALID_HANDLE_VALUE;
@@ -287,11 +287,11 @@ HRESULT CCDXAStream::Read(PBYTE pbBuffer, DWORD dwBytesToRead, BOOL bAlign, LPDW PBYTE pbBufferOrg = pbBuffer;
LONGLONG pos = m_llPosition;
- while(pos >= 0 && pos < m_llLength && dwBytesToRead > 0) {
+ while (pos >= 0 && pos < m_llLength && dwBytesToRead > 0) {
UINT sector = m_nFirstSector + int(pos/RAW_DATA_SIZE);
__int64 offset = pos%RAW_DATA_SIZE;
- if(m_nBufferedSector != (int)sector) {
+ if (m_nBufferedSector != (int)sector) {
LARGE_INTEGER FilePointer;
FilePointer.QuadPart = RIFFCDXA_HEADER_SIZE + sector*RAW_SECTOR_SIZE;
SetFilePointerEx(m_hFile, FilePointer, &FilePointer, FILE_BEGIN);
@@ -301,18 +301,18 @@ HRESULT CCDXAStream::Read(PBYTE pbBuffer, DWORD dwBytesToRead, BOOL bAlign, LPDW DWORD NumberOfBytesRead = 0;
int nRetries = 3;
- while(nRetries--) {
+ while (nRetries--) {
NumberOfBytesRead = 0;
- if(!ReadFile(m_hFile, m_sector, RAW_SECTOR_SIZE, &NumberOfBytesRead, NULL)
+ if (!ReadFile(m_hFile, m_sector, RAW_SECTOR_SIZE, &NumberOfBytesRead, NULL)
|| NumberOfBytesRead != RAW_SECTOR_SIZE) {
break;
}
- if(*(DWORD*)&m_sector[RAW_SECTOR_SIZE-4] == 0) { // no CRC? it happens...
+ if (*(DWORD*)&m_sector[RAW_SECTOR_SIZE-4] == 0) { // no CRC? it happens...
break;
}
- if(build_edc(m_sector, RAW_SYNC_SIZE + RAW_HEADER_SIZE, RAW_SECTOR_SIZE) == 0) {
+ if (build_edc(m_sector, RAW_SYNC_SIZE + RAW_HEADER_SIZE, RAW_SECTOR_SIZE) == 0) {
break;
}
@@ -330,12 +330,12 @@ HRESULT CCDXAStream::Read(PBYTE pbBuffer, DWORD dwBytesToRead, BOOL bAlign, LPDW dwBytesToRead -= l;
}
- if(pdwBytesRead) {
+ if (pdwBytesRead) {
*pdwBytesRead = pbBuffer - pbBufferOrg;
}
m_llPosition += pbBuffer - pbBufferOrg;
- if(dwBytesToRead != 0) {
+ if (dwBytesToRead != 0) {
return S_FALSE;
}
@@ -344,7 +344,7 @@ HRESULT CCDXAStream::Read(PBYTE pbBuffer, DWORD dwBytesToRead, BOOL bAlign, LPDW LONGLONG CCDXAStream::Size(LONGLONG* pSizeAvailable)
{
- if(pSizeAvailable) {
+ if (pSizeAvailable) {
*pSizeAvailable = m_llLength;
}
return m_llLength;
@@ -375,22 +375,22 @@ bool CCDXAStream::LookForMediaSubType() m_llPosition = 0;
- for(int iSectorsRead = 0;
+ for (int iSectorsRead = 0;
Read(buff, RAW_DATA_SIZE, 1, NULL) == S_OK && iSectorsRead < 1000;
iSectorsRead++) {
- if(*((DWORD*)&buff[0]) == 0xba010000) {
+ if (*((DWORD*)&buff[0]) == 0xba010000) {
m_llPosition = 0;
m_llLength -= iSectorsRead*RAW_DATA_SIZE;
m_nFirstSector = iSectorsRead;
- if((buff[4]&0xc4) == 0x44) {
+ if ((buff[4]&0xc4) == 0x44) {
m_subtype = MEDIASUBTYPE_MPEG2_PROGRAM;
- } else if((buff[4]&0xf1) == 0x21) {
+ } else if ((buff[4]&0xf1) == 0x21) {
m_subtype = MEDIASUBTYPE_MPEG1System;
}
return !!(m_subtype != MEDIASUBTYPE_NULL);
- } else if(*((DWORD*)&buff[0]) == 'SggO') {
+ } else if (*((DWORD*)&buff[0]) == 'SggO') {
m_llPosition = 0;
m_llLength -= iSectorsRead*RAW_DATA_SIZE;
m_nFirstSector = iSectorsRead;
@@ -398,7 +398,7 @@ bool CCDXAStream::LookForMediaSubType() m_subtype = MEDIASUBTYPE_Ogg;
return true;
- } else if(*((DWORD*)&buff[0]) == 0xA3DF451A) {
+ } else if (*((DWORD*)&buff[0]) == 0xA3DF451A) {
m_llPosition = 0;
m_llLength -= iSectorsRead*RAW_DATA_SIZE;
m_nFirstSector = iSectorsRead;
@@ -406,7 +406,7 @@ bool CCDXAStream::LookForMediaSubType() m_subtype = MEDIASUBTYPE_Matroska;
return true;
- } else if(*((DWORD*)&buff[0]) == 'FMR.') {
+ } else if (*((DWORD*)&buff[0]) == 'FMR.') {
m_llPosition = 0;
m_llLength -= iSectorsRead*RAW_DATA_SIZE;
m_nFirstSector = iSectorsRead;
@@ -414,7 +414,7 @@ bool CCDXAStream::LookForMediaSubType() m_subtype = MEDIASUBTYPE_RealMedia;
return true;
- } else if(*((DWORD*)&buff[0]) == 'FFIR' && *((DWORD*)&buff[8]) == ' IVA') {
+ } else if (*((DWORD*)&buff[0]) == 'FFIR' && *((DWORD*)&buff[8]) == ' IVA') {
m_llPosition = 0;
m_llLength = min(m_llLength, *((DWORD*)&buff[4])+8);
m_nFirstSector = iSectorsRead;
@@ -422,8 +422,8 @@ bool CCDXAStream::LookForMediaSubType() m_subtype = MEDIASUBTYPE_Avi;
return true;
- } else if(*((DWORD*)&buff[4]) == 'voom' || *((DWORD*)&buff[4]) == 'tadm'
- || *((DWORD*)&buff[4]) == 'pytf' && *((DWORD*)&buff[8]) == 'mosi' && *((DWORD*)&buff[16]) == '14pm') {
+ } else if (*((DWORD*)&buff[4]) == 'voom' || *((DWORD*)&buff[4]) == 'tadm'
+ || *((DWORD*)&buff[4]) == 'pytf' && *((DWORD*)&buff[8]) == 'mosi' && *((DWORD*)&buff[16]) == '14pm') {
m_llPosition = 0;
m_llLength -= iSectorsRead*RAW_DATA_SIZE;
m_nFirstSector = iSectorsRead;
@@ -438,22 +438,22 @@ bool CCDXAStream::LookForMediaSubType() CRegKey majorkey;
CString majortype = _T("\\Media Type\\{e436eb83-524f-11ce-9f53-0020af0ba770}");
- if(ERROR_SUCCESS == majorkey.Open(HKEY_CLASSES_ROOT, majortype, KEY_READ)) {
+ if (ERROR_SUCCESS == majorkey.Open(HKEY_CLASSES_ROOT, majortype, KEY_READ)) {
TCHAR subtype[256+1];
DWORD len = 256;
- for(int i = 0; ERROR_SUCCESS == majorkey.EnumKey(i, subtype, &len); i++, len = 256) {
+ for (int i = 0; ERROR_SUCCESS == majorkey.EnumKey(i, subtype, &len); i++, len = 256) {
CRegKey subkey;
- if(ERROR_SUCCESS != subkey.Open(HKEY_CLASSES_ROOT, majortype + _T("\\") + subtype, KEY_READ)) {
+ if (ERROR_SUCCESS != subkey.Open(HKEY_CLASSES_ROOT, majortype + _T("\\") + subtype, KEY_READ)) {
continue;
}
- for(int j = 0; true; j++) {
+ for (int j = 0; true; j++) {
TCHAR number[10];
_stprintf(number, sizeof(number)/sizeof(TCHAR), _T("%d"), j);
TCHAR pattern[256+1];
ULONG len = 256;
- if(ERROR_SUCCESS != subkey.QueryStringValue(number, pattern, &len)) {
+ if (ERROR_SUCCESS != subkey.QueryStringValue(number, pattern, &len)) {
break;
}
@@ -466,13 +466,13 @@ bool CCDXAStream::LookForMediaSubType() int nMatches = 0, nTries = 0;
- for(int k = 0, l; nTries >= 0 && (l = p.Find(',', k)) >= 0; k = l+1, nTries++) {
+ for (int k = 0, l; nTries >= 0 && (l = p.Find(',', k)) >= 0; k = l+1, nTries++) {
CString s = p.Mid(k, l-k);
TRACE(s + '\n');
TCHAR* end = NULL;
- switch(nTries&3) {
+ switch (nTries&3) {
case 0:
offset = _tcstol(s, &end, 10);
break;
@@ -490,27 +490,27 @@ bool CCDXAStream::LookForMediaSubType() break;
}
- if(nTries >= 0 && (nTries&3) == 3) {
- if(cb > 0 && val.GetCount() > 0 && cb == val.GetCount()) {
- if(offset >= 0 && S_OK == SetPointer(offset)
+ if (nTries >= 0 && (nTries&3) == 3) {
+ if (cb > 0 && val.GetCount() > 0 && cb == val.GetCount()) {
+ if (offset >= 0 && S_OK == SetPointer(offset)
|| S_OK == SetPointer(m_llLength + offset)) {
CAutoVectorPtr<BYTE> pData;
- if(pData.Allocate(cb)) {
+ if (pData.Allocate(cb)) {
DWORD BytesRead = 0;
- if(S_OK == Read(pData, cb, 1, &BytesRead) && cb == BytesRead) {
- if(mask.GetCount() < cb) {
+ if (S_OK == Read(pData, cb, 1, &BytesRead) && cb == BytesRead) {
+ if (mask.GetCount() < cb) {
size_t i = mask.GetCount();
mask.SetCount(cb);
- for(; i < cb; i++) {
+ for (; i < cb; i++) {
mask[i] = 0xff;
}
}
- for(unsigned int i = 0; i < cb; i++) {
+ for (unsigned int i = 0; i < cb; i++) {
pData[i] &= (BYTE)mask[i];
}
- if(memcmp(pData, val.GetData(), cb) == 0) {
+ if (memcmp(pData, val.GetData(), cb) == 0) {
nMatches++;
}
}
@@ -525,7 +525,7 @@ bool CCDXAStream::LookForMediaSubType() }
}
- if(nMatches > 0 && nMatches*4 == nTries) {
+ if (nMatches > 0 && nMatches*4 == nTries) {
m_subtype = GUIDFromCString(subtype);
return S_OK;
}
diff --git a/src/filters/reader/UDPReader/UDPReader.cpp b/src/filters/reader/UDPReader/UDPReader.cpp index 1fe035f6a..3025e8f3a 100644 --- a/src/filters/reader/UDPReader/UDPReader.cpp +++ b/src/filters/reader/UDPReader/UDPReader.cpp @@ -74,7 +74,7 @@ CFilterApp theApp; CUDPReader::CUDPReader(IUnknown* pUnk, HRESULT* phr)
: CAsyncReader(NAME("CUDPReader"), pUnk, &m_stream, phr, __uuidof(this))
{
- if(phr) {
+ if (phr) {
*phr = S_OK;
}
}
@@ -96,7 +96,7 @@ STDMETHODIMP CUDPReader::NonDelegatingQueryInterface(REFIID riid, void** ppv) STDMETHODIMP CUDPReader::Load(LPCOLESTR pszFileName, const AM_MEDIA_TYPE* pmt)
{
- if(!m_stream.Load(pszFileName)) {
+ if (!m_stream.Load(pszFileName)) {
return E_FAIL;
}
@@ -112,12 +112,12 @@ STDMETHODIMP CUDPReader::Load(LPCOLESTR pszFileName, const AM_MEDIA_TYPE* pmt) STDMETHODIMP CUDPReader::GetCurFile(LPOLESTR* ppszFileName, AM_MEDIA_TYPE* pmt)
{
- if(!ppszFileName) {
+ if (!ppszFileName) {
return E_POINTER;
}
*ppszFileName = (LPOLESTR)CoTaskMemAlloc((m_fn.GetLength()+1)*sizeof(WCHAR));
- if(!(*ppszFileName)) {
+ if (!(*ppszFileName)) {
return E_OUTOFMEMORY;
}
@@ -142,15 +142,15 @@ CUDPStream::~CUDPStream() void CUDPStream::Clear()
{
- if(m_socket !=INVALID_SOCKET) {
+ if (m_socket !=INVALID_SOCKET) {
closesocket(m_socket);
m_socket = INVALID_SOCKET;
}
- if(CAMThread::ThreadExists()) {
+ if (CAMThread::ThreadExists()) {
CAMThread::CallWorker(CMD_EXIT);
CAMThread::Close();
}
- while(!m_packets.IsEmpty()) {
+ while (!m_packets.IsEmpty()) {
delete m_packets.RemoveHead();
}
m_pos = m_len = 0;
@@ -161,18 +161,18 @@ void CUDPStream::Append(BYTE* buff, int len) {
CAutoLock cAutoLock(&m_csLock);
- if(m_packets.GetCount() > 1) {
+ if (m_packets.GetCount() > 1) {
__int64 size = m_packets.GetTail()->m_end - m_packets.GetHead()->m_start;
- if(!m_drop && (m_pos >= BUFF_SIZE_FIRST && size >= BUFF_SIZE_FIRST || size >= 2*BUFF_SIZE_FIRST)) {
+ if (!m_drop && (m_pos >= BUFF_SIZE_FIRST && size >= BUFF_SIZE_FIRST || size >= 2*BUFF_SIZE_FIRST)) {
m_drop = true;
TRACE(_T("DROP ON\n"));
- } else if(m_drop && size <= BUFF_SIZE_FIRST) {
+ } else if (m_drop && size <= BUFF_SIZE_FIRST) {
m_drop = false;
TRACE(_T("DROP OFF\n"));
}
- if(m_drop) {
+ if (m_drop) {
return;
}
}
@@ -195,7 +195,7 @@ bool CUDPStream::Load(const WCHAR* fnw) CAtlList<CStringW> sl;
Explode(url, sl, ':');
- if(sl.GetCount() != 3) {
+ if (sl.GetCount() != 3) {
return false;
}
@@ -205,23 +205,23 @@ bool CUDPStream::Load(const WCHAR* fnw) m_ip = CString(sl.RemoveHead()).TrimLeft('/');
int port = _wtoi(Explode(sl.RemoveHead(), sl, '/', 2));
- if(port < 0 || port > 0xffff) {
+ if (port < 0 || port > 0xffff) {
return false;
}
m_port = port;
- if(sl.GetCount() != 2 || FAILED(GUIDFromCString(CString(sl.GetTail()), m_subtype))) {
+ if (sl.GetCount() != 2 || FAILED(GUIDFromCString(CString(sl.GetTail()), m_subtype))) {
m_subtype = MEDIASUBTYPE_NULL; // TODO: detect subtype
}
CAMThread::Create();
- if(FAILED(CAMThread::CallWorker(CMD_RUN))) {
+ if (FAILED(CAMThread::CallWorker(CMD_RUN))) {
Clear();
return false;
}
clock_t start = clock();
- while(clock() - start < 3000 && m_len < 1000000) {
+ while (clock() - start < 3000 && m_len < 1000000) {
Sleep(100);
}
@@ -232,7 +232,7 @@ HRESULT CUDPStream::SetPointer(LONGLONG llPos) {
CAutoLock cAutoLock(&m_csLock);
- if(m_packets.IsEmpty() && llPos != 0
+ if (m_packets.IsEmpty() && llPos != 0
|| !m_packets.IsEmpty() && llPos < m_packets.GetHead()->m_start
|| !m_packets.IsEmpty() && llPos > m_packets.GetTail()->m_end) {
TRACE(_T("CUDPStream: SetPointer error\n"));
@@ -251,15 +251,15 @@ HRESULT CUDPStream::Read(PBYTE pbBuffer, DWORD dwBytesToRead, BOOL bAlign, LPDWO DWORD len = dwBytesToRead;
BYTE* ptr = pbBuffer;
- while(len > 0 && !m_packets.IsEmpty()) {
+ while (len > 0 && !m_packets.IsEmpty()) {
POSITION pos = m_packets.GetHeadPosition();
- while(pos && len > 0) {
+ while (pos && len > 0) {
packet_t* p = m_packets.GetNext(pos);
- if(p->m_start <= m_pos && m_pos < p->m_end) {
+ if (p->m_start <= m_pos && m_pos < p->m_end) {
int size;
- if(m_pos < p->m_start) {
+ if (m_pos < p->m_start) {
ASSERT(0);
size = min(len, p->m_start - m_pos);
memset(ptr, 0, size);
@@ -274,8 +274,8 @@ HRESULT CUDPStream::Read(PBYTE pbBuffer, DWORD dwBytesToRead, BOOL bAlign, LPDWO len -= size;
}
- if(p->m_end <= m_pos - 2048 && BUFF_SIZE_FIRST <= m_pos) {
- while(m_packets.GetHeadPosition() != pos) {
+ if (p->m_end <= m_pos - 2048 && BUFF_SIZE_FIRST <= m_pos) {
+ while (m_packets.GetHeadPosition() != pos) {
delete m_packets.RemoveHead();
}
}
@@ -283,7 +283,7 @@ HRESULT CUDPStream::Read(PBYTE pbBuffer, DWORD dwBytesToRead, BOOL bAlign, LPDWO }
}
- if(pdwBytesRead) {
+ if (pdwBytesRead) {
*pdwBytesRead = ptr - pbBuffer;
}
@@ -293,7 +293,7 @@ HRESULT CUDPStream::Read(PBYTE pbBuffer, DWORD dwBytesToRead, BOOL bAlign, LPDWO LONGLONG CUDPStream::Size(LONGLONG* pSizeAvailable)
{
CAutoLock cAutoLock(&m_csLock);
- if(pSizeAvailable) {
+ if (pSizeAvailable) {
*pSizeAvailable = m_len;
}
return 0;
@@ -329,24 +329,24 @@ DWORD CUDPStream::ThreadProc() imr.imr_multiaddr.s_addr = inet_addr(CStringA(m_ip));
imr.imr_interface.s_addr = INADDR_ANY;
- if((m_socket = socket(AF_INET, SOCK_DGRAM, 0))!=INVALID_SOCKET) {
+ if ((m_socket = socket(AF_INET, SOCK_DGRAM, 0))!=INVALID_SOCKET) {
/* u_long argp = 1;
ioctlsocket(m_socket, FIONBIO, &argp);
*/
DWORD dw = TRUE;
- if(setsockopt(m_socket, SOL_SOCKET, SO_REUSEADDR, (const char*)&dw, sizeof(dw))==SOCKET_ERROR) {
+ if (setsockopt(m_socket, SOL_SOCKET, SO_REUSEADDR, (const char*)&dw, sizeof(dw))==SOCKET_ERROR) {
closesocket(m_socket);
m_socket = INVALID_SOCKET;
}
- if(bind(m_socket, (struct sockaddr*)&addr, sizeof(addr))==SOCKET_ERROR) {
+ if (bind(m_socket, (struct sockaddr*)&addr, sizeof(addr))==SOCKET_ERROR) {
closesocket(m_socket);
m_socket = INVALID_SOCKET;
}
- if(IN_MULTICAST(htonl(imr.imr_multiaddr.s_addr))) {
+ if (IN_MULTICAST(htonl(imr.imr_multiaddr.s_addr))) {
int ret = setsockopt(m_socket, IPPROTO_IP, IP_ADD_MEMBERSHIP, (const char*)&imr, sizeof(imr));
- if(ret < 0) {
+ if (ret < 0) {
ret = ::WSAGetLastError();
}
ret = ret;
@@ -362,22 +362,22 @@ DWORD CUDPStream::ThreadProc() // log = _tfopen(_T("c:\\udp.txt"), _T("wt"));
#endif
- while(1) {
+ while (1) {
DWORD cmd = GetRequest();
- switch(cmd) {
+ switch (cmd) {
default:
case CMD_EXIT:
- if(m_socket!=INVALID_SOCKET) {
+ if (m_socket!=INVALID_SOCKET) {
closesocket(m_socket);
m_socket = INVALID_SOCKET;
}
WSACleanup();
#ifdef _DEBUG
- if(dump) {
+ if (dump) {
fclose(dump);
}
- if(log) {
+ if (log) {
fclose(log);
}
#endif
@@ -390,23 +390,23 @@ DWORD CUDPStream::ThreadProc() char buff[65536*2];
int buffsize = 0;
- for(unsigned int i = 0; ; i++) {
- if(!(i&0xff)) {
- if(CheckRequest(NULL)) {
+ for (unsigned int i = 0; ; i++) {
+ if (!(i&0xff)) {
+ if (CheckRequest(NULL)) {
break;
}
}
int fromlen = sizeof(addr);
int len = recvfrom(m_socket, &buff[buffsize], 65536, 0, (SOCKADDR*)&addr, &fromlen);
- if(len <= 0) {
+ if (len <= 0) {
Sleep(1);
continue;
}
#ifdef _DEBUG
- if(log) {
- if(buffsize >= len && !memcmp(&buff[buffsize-len], &buff[buffsize], len)) {
+ if (log) {
+ if (buffsize >= len && !memcmp(&buff[buffsize-len], &buff[buffsize], len)) {
DWORD pid = ((buff[buffsize+1]<<8)|buff[buffsize+2])&0x1fff;
DWORD counter = buff[buffsize+3]&0xf;
_ftprintf(log, _T("%04d %2d DUP\n"), pid, counter);
@@ -416,24 +416,24 @@ DWORD CUDPStream::ThreadProc() buffsize += len;
- if(buffsize >= 65536 || m_len == 0) {
+ if (buffsize >= 65536 || m_len == 0) {
#ifdef _DEBUG
- if(dump) {
+ if (dump) {
fwrite(buff, buffsize, 1, dump);
}
- if(log) {
+ if (log) {
static BYTE pid2counter[0x2000];
static bool init = false;
- if(!init) {
+ if (!init) {
memset(pid2counter, 0, sizeof(pid2counter));
init = true;
}
- for(int i = 0; i < buffsize; i += 188) {
+ for (int i = 0; i < buffsize; i += 188) {
DWORD pid = ((buff[i+1]<<8)|buff[i+2])&0x1fff;
DWORD counter = buff[i+3]&0xf;
- if(pid2counter[pid] != ((counter-1+16)&15)) {
+ if (pid2counter[pid] != ((counter-1+16)&15)) {
_ftprintf(log, _T("%04x %2d -> %2d\n"), pid, pid2counter[pid], counter);
}
pid2counter[pid] = counter;
diff --git a/src/filters/reader/VTSReader/VTSReader.cpp b/src/filters/reader/VTSReader/VTSReader.cpp index 75e1f620b..4967433b6 100644 --- a/src/filters/reader/VTSReader/VTSReader.cpp +++ b/src/filters/reader/VTSReader/VTSReader.cpp @@ -46,7 +46,7 @@ int g_cTemplates = countof(g_Templates); STDAPI DllRegisterServer()
{
- if(GetVersion()&0x80000000) {
+ if (GetVersion()&0x80000000) {
return E_NOTIMPL;
}
@@ -81,12 +81,12 @@ CFilterApp theApp; CVTSReader::CVTSReader(IUnknown* pUnk, HRESULT* phr)
: CAsyncReader(NAME("CVTSReader"), pUnk, &m_stream, phr, __uuidof(this))
{
- if(phr) {
+ if (phr) {
*phr = S_OK;
}
- if(GetVersion()&0x80000000) {
- if(phr) {
+ if (GetVersion()&0x80000000) {
+ if (phr) {
*phr = E_NOTIMPL;
}
return;
@@ -115,7 +115,7 @@ STDMETHODIMP CVTSReader::QueryFilterInfo(FILTER_INFO* pInfo) wcscpy(pInfo->achName, VTSReaderName);
pInfo->pGraph = m_pGraph;
- if(m_pGraph) {
+ if (m_pGraph) {
m_pGraph->AddRef();
}
@@ -126,7 +126,7 @@ STDMETHODIMP CVTSReader::QueryFilterInfo(FILTER_INFO* pInfo) STDMETHODIMP CVTSReader::Load(LPCOLESTR pszFileName, const AM_MEDIA_TYPE* pmt)
{
- if(!m_stream.Load(pszFileName)) {
+ if (!m_stream.Load(pszFileName)) {
return E_FAIL;
}
@@ -149,12 +149,12 @@ STDMETHODIMP CVTSReader::Load(LPCOLESTR pszFileName, const AM_MEDIA_TYPE* pmt) STDMETHODIMP CVTSReader::GetCurFile(LPOLESTR* ppszFileName, AM_MEDIA_TYPE* pmt)
{
- if(!ppszFileName) {
+ if (!ppszFileName) {
return E_POINTER;
}
*ppszFileName = (LPOLESTR)CoTaskMemAlloc((m_fn.GetLength()+1)*sizeof(WCHAR));
- if(!(*ppszFileName)) {
+ if (!(*ppszFileName)) {
return E_OUTOFMEMORY;
}
@@ -237,9 +237,9 @@ HRESULT CVTSStream::Read(PBYTE pbBuffer, DWORD dwBytesToRead, BOOL bAlign, LPDWO DWORD len = dwBytesToRead;
BYTE* ptr = pbBuffer;
- while(len > 0) {
+ while (len > 0) {
BYTE buff[2048];
- if(!m_vob->Read(buff)) {
+ if (!m_vob->Read(buff)) {
break;
}
@@ -249,7 +249,7 @@ HRESULT CVTSStream::Read(PBYTE pbBuffer, DWORD dwBytesToRead, BOOL bAlign, LPDWO m_off = (m_off + size)&2047;
- if(m_off > 0) {
+ if (m_off > 0) {
m_vob->Seek(m_vob->GetPosition()-1);
}
@@ -257,7 +257,7 @@ HRESULT CVTSStream::Read(PBYTE pbBuffer, DWORD dwBytesToRead, BOOL bAlign, LPDWO len -= size;
}
- if(pdwBytesRead) {
+ if (pdwBytesRead) {
*pdwBytesRead = ptr - pbBuffer;
}
@@ -267,7 +267,7 @@ HRESULT CVTSStream::Read(PBYTE pbBuffer, DWORD dwBytesToRead, BOOL bAlign, LPDWO LONGLONG CVTSStream::Size(LONGLONG* pSizeAvailable)
{
LONGLONG len = 2048i64*m_vob->GetLength();
- if(pSizeAvailable) {
+ if (pSizeAvailable) {
*pSizeAvailable = len;
}
return(len);
diff --git a/src/filters/renderer/MpcAudioRenderer/MpcAudioRenderer.cpp b/src/filters/renderer/MpcAudioRenderer/MpcAudioRenderer.cpp index 40de4c814..d7eabe73f 100644 --- a/src/filters/renderer/MpcAudioRenderer/MpcAudioRenderer.cpp +++ b/src/filters/renderer/MpcAudioRenderer/MpcAudioRenderer.cpp @@ -101,23 +101,23 @@ CFilterApp theApp; static GUID lpSoundGUID = {0xdef00000, 0x9c6d, 0x47ed, {0xaa, 0xf1, 0x4d, 0xda, 0x8f, 0x2b, 0x5c, 0x03}}; //DSDEVID_DefaultPlayback from dsound.h
-bool CALLBACK DSEnumProc2(LPGUID lpGUID,
- LPCTSTR lpszDesc,
- LPCTSTR lpszDrvName,
- LPVOID lpContext )
+bool CALLBACK DSEnumProc2(LPGUID lpGUID,
+ LPCTSTR lpszDesc,
+ LPCTSTR lpszDrvName,
+ LPVOID lpContext )
{
CString *pStr = (CString *)lpContext;
ASSERT ( pStr );
CString strGUID = *pStr;
- if (lpGUID != NULL) // NULL only for "Primary Sound Driver".
- {
- if(strGUID == lpszDesc) {
+ if (lpGUID != NULL) // NULL only for "Primary Sound Driver".
+ {
+ if (strGUID == lpszDesc) {
memcpy((VOID *)&lpSoundGUID, lpGUID, sizeof(GUID));
}
- }
+ }
- return TRUE;
+ return TRUE;
}
CMpcAudioRenderer::CMpcAudioRenderer(LPUNKNOWN punk, HRESULT *phr)
@@ -152,18 +152,18 @@ CMpcAudioRenderer::CMpcAudioRenderer(LPUNKNOWN punk, HRESULT *phr) TCHAR buff[256];
ULONG len;
- if(ERROR_SUCCESS == key.Open(HKEY_CURRENT_USER, _T("Software\\Gabest\\Filters\\MPC Audio Renderer"), KEY_READ)) {
+ if (ERROR_SUCCESS == key.Open(HKEY_CURRENT_USER, _T("Software\\Gabest\\Filters\\MPC Audio Renderer"), KEY_READ)) {
DWORD dw;
- if(ERROR_SUCCESS == key.QueryDWORDValue(_T("UseWasapi"), dw)) {
+ if (ERROR_SUCCESS == key.QueryDWORDValue(_T("UseWasapi"), dw)) {
m_useWASAPI = !!dw;
}
- if(ERROR_SUCCESS == key.QueryDWORDValue(_T("MuteFastForward"), dw)) {
+ if (ERROR_SUCCESS == key.QueryDWORDValue(_T("MuteFastForward"), dw)) {
m_bMuteFastForward = !!dw;
}
len = sizeof(buff)/sizeof(buff[0]);
memset(buff, 0, sizeof(buff));
- if(ERROR_SUCCESS == key.QueryStringValue(_T("SoundDevice"), buff, &len)) {
- m_csSound_Device = CString(buff);
+ if (ERROR_SUCCESS == key.QueryStringValue(_T("SoundDevice"), buff, &len)) {
+ m_csSound_Device = CString(buff);
}
}
#else
@@ -242,7 +242,7 @@ HRESULT CMpcAudioRenderer::CheckMediaType(const CMediaType *pmt) return VFW_E_TYPE_NOT_ACCEPTED;
}
- if(m_useWASAPI) {
+ if (m_useWASAPI) {
hr=CheckAudioClient((WAVEFORMATEX *)NULL);
if (FAILED(hr)) {
TRACE(_T("CMpcAudioRenderer::CheckMediaType Error on check audio client\n"));
@@ -570,13 +570,13 @@ STDMETHODIMP CMpcAudioRenderer::CreatePage(const GUID& guid, IPropertyPage** ppP {
CheckPointer(ppPage, E_POINTER);
- if(*ppPage != NULL) {
+ if (*ppPage != NULL) {
return E_INVALIDARG;
}
HRESULT hr;
- if(guid == __uuidof(CMpcAudioRendererSettingsWnd)) {
+ if (guid == __uuidof(CMpcAudioRendererSettingsWnd)) {
(*ppPage = DNew CInternalPropertyPageTempl<CMpcAudioRendererSettingsWnd>(NULL, &hr))->AddRef();
}
@@ -588,7 +588,7 @@ STDMETHODIMP CMpcAudioRenderer::Apply() {
#ifdef REGISTER_FILTER
CRegKey key;
- if(ERROR_SUCCESS == key.Create(HKEY_CURRENT_USER, _T("Software\\Gabest\\Filters\\MPC Audio Renderer"))) {
+ if (ERROR_SUCCESS == key.Create(HKEY_CURRENT_USER, _T("Software\\Gabest\\Filters\\MPC Audio Renderer"))) {
key.SetDWORDValue(_T("UseWasapi"), m_useWASAPIAfterRestart);
key.SetDWORDValue(_T("MuteFastForward"), m_bMuteFastForward);
key.SetStringValue(_T("SoundDevice"), m_csSound_Device);
@@ -1079,115 +1079,115 @@ HRESULT CMpcAudioRenderer::CheckAudioClient(WAVEFORMATEX *pWaveFormatEx) HRESULT CMpcAudioRenderer::GetAvailableAudioDevices(IMMDeviceCollection **ppMMDevices)
{
- HRESULT hr;
-
- CComPtr<IMMDeviceEnumerator> enumerator;
- TRACE(_T("CMpcAudioRenderer::GetAvailableAudioDevices\n"));
- hr = enumerator.CoCreateInstance(__uuidof(MMDeviceEnumerator));
-
- if (FAILED(hr))
- {
- TRACE(_T("CMpcAudioRenderer::GetAvailableAudioDevices - failed to get MMDeviceEnumerator\n"));
- return S_FALSE;
- }
-
- //IMMDevice* pEndpoint = NULL;
- //IPropertyStore* pProps = NULL;
- //LPWSTR pwszID = NULL;
-
- enumerator->EnumAudioEndpoints(eRender, DEVICE_STATE_ACTIVE, ppMMDevices);
- UINT count(0);
- hr = (*ppMMDevices)->GetCount(&count);
- return hr;
+ HRESULT hr;
+
+ CComPtr<IMMDeviceEnumerator> enumerator;
+ TRACE(_T("CMpcAudioRenderer::GetAvailableAudioDevices\n"));
+ hr = enumerator.CoCreateInstance(__uuidof(MMDeviceEnumerator));
+
+ if (FAILED(hr))
+ {
+ TRACE(_T("CMpcAudioRenderer::GetAvailableAudioDevices - failed to get MMDeviceEnumerator\n"));
+ return S_FALSE;
+ }
+
+ //IMMDevice* pEndpoint = NULL;
+ //IPropertyStore* pProps = NULL;
+ //LPWSTR pwszID = NULL;
+
+ enumerator->EnumAudioEndpoints(eRender, DEVICE_STATE_ACTIVE, ppMMDevices);
+ UINT count(0);
+ hr = (*ppMMDevices)->GetCount(&count);
+ return hr;
}
HRESULT CMpcAudioRenderer::GetAudioDevice(IMMDevice **ppMMDevice)
{
- TRACE(_T("CMpcAudioRenderer::GetAudioDevice\n"));
-
- CComPtr<IMMDeviceEnumerator> enumerator;
- IMMDeviceCollection* devices;
- IPropertyStore* pProps = NULL;
- HRESULT hr = enumerator.CoCreateInstance(__uuidof(MMDeviceEnumerator));
-
- if (hr != S_OK)
- {
- TRACE(_T("CMpcAudioRenderer::GetAudioDevice - failed to create MMDeviceEnumerator!\n"));
- return hr;
- }
-
- TRACE(_T("CMpcAudioRenderer::GetAudioDevice - Target end point: %s\n"), m_csSound_Device);
-
- if (GetAvailableAudioDevices(&devices) == S_OK && devices)
- {
- UINT count(0);
- hr = devices->GetCount(&count);
- if (hr != S_OK)
- {
- TRACE(_T("CMpcAudioRenderer::GetAudioDevice - devices->GetCount failed: (0x%08x)\n"), hr);
- return hr;
- }
-
- for (ULONG i = 0 ; i < count ; i++)
- {
- LPWSTR pwszID = NULL;
- IMMDevice *endpoint = NULL;
- hr = devices->Item(i, &endpoint);
- if (hr == S_OK)
- {
- hr = endpoint->GetId(&pwszID);
- if (hr == S_OK)
- {
- if(endpoint->OpenPropertyStore(STGM_READ, &pProps) == S_OK)
- {
-
- PROPVARIANT varName;
- PropVariantInit(&varName);
+ TRACE(_T("CMpcAudioRenderer::GetAudioDevice\n"));
+
+ CComPtr<IMMDeviceEnumerator> enumerator;
+ IMMDeviceCollection* devices;
+ IPropertyStore* pProps = NULL;
+ HRESULT hr = enumerator.CoCreateInstance(__uuidof(MMDeviceEnumerator));
+
+ if (hr != S_OK)
+ {
+ TRACE(_T("CMpcAudioRenderer::GetAudioDevice - failed to create MMDeviceEnumerator!\n"));
+ return hr;
+ }
- // Found the configured audio endpoint
- if ((pProps->GetValue(PKEY_Device_FriendlyName, &varName) == S_OK) && (m_csSound_Device == varName.pwszVal))
+ TRACE(_T("CMpcAudioRenderer::GetAudioDevice - Target end point: %s\n"), m_csSound_Device);
+
+ if (GetAvailableAudioDevices(&devices) == S_OK && devices)
+ {
+ UINT count(0);
+ hr = devices->GetCount(&count);
+ if (hr != S_OK)
+ {
+ TRACE(_T("CMpcAudioRenderer::GetAudioDevice - devices->GetCount failed: (0x%08x)\n"), hr);
+ return hr;
+ }
+
+ for (ULONG i = 0 ; i < count ; i++)
+ {
+ LPWSTR pwszID = NULL;
+ IMMDevice *endpoint = NULL;
+ hr = devices->Item(i, &endpoint);
+ if (hr == S_OK)
+ {
+ hr = endpoint->GetId(&pwszID);
+ if (hr == S_OK)
{
- TRACE(_T("CMpcAudioRenderer::GetAudioDevice - devices->GetId OK, num: (%d), pwszVal: %s, pwszID: %s\n"), i, varName.pwszVal, pwszID);
- enumerator->GetDevice(pwszID, ppMMDevice);
- SAFE_RELEASE(devices);
- *(ppMMDevice) = endpoint;
- CoTaskMemFree(pwszID);
- pwszID = NULL;
- PropVariantClear(&varName);
- SAFE_RELEASE(pProps);
- return S_OK;
+ if (endpoint->OpenPropertyStore(STGM_READ, &pProps) == S_OK)
+ {
+
+ PROPVARIANT varName;
+ PropVariantInit(&varName);
+
+ // Found the configured audio endpoint
+ if ((pProps->GetValue(PKEY_Device_FriendlyName, &varName) == S_OK) && (m_csSound_Device == varName.pwszVal))
+ {
+ TRACE(_T("CMpcAudioRenderer::GetAudioDevice - devices->GetId OK, num: (%d), pwszVal: %s, pwszID: %s\n"), i, varName.pwszVal, pwszID);
+ enumerator->GetDevice(pwszID, ppMMDevice);
+ SAFE_RELEASE(devices);
+ *(ppMMDevice) = endpoint;
+ CoTaskMemFree(pwszID);
+ pwszID = NULL;
+ PropVariantClear(&varName);
+ SAFE_RELEASE(pProps);
+ return S_OK;
+ }
+ else
+ {
+ PropVariantClear(&varName);
+ SAFE_RELEASE(pProps);
+ SAFE_RELEASE(endpoint);
+ CoTaskMemFree(pwszID);
+ pwszID = NULL;
+ }
+ }
}
else
{
- PropVariantClear(&varName);
- SAFE_RELEASE(pProps);
- SAFE_RELEASE(endpoint);
- CoTaskMemFree(pwszID);
- pwszID = NULL;
+ TRACE(_T("CMpcAudioRenderer::GetAudioDevice - devices->GetId failed: (0x%08x)\n"), hr);
}
}
- }
- else
- {
- TRACE(_T("CMpcAudioRenderer::GetAudioDevice - devices->GetId failed: (0x%08x)\n"), hr);
- }
- }
- else
- {
- TRACE(_T("CMpcAudioRenderer::GetAudioDevice - devices->Item failed: (0x%08x)\n"), hr);
- }
-
- CoTaskMemFree(pwszID);
- pwszID = NULL;
- }
- }
-
- TRACE(_T("CMpcAudioRenderer::GetAudioDevice - Unable to find selected audio device, using the default end point!\n"));
- hr = enumerator->GetDefaultAudioEndpoint(eRender, eConsole, ppMMDevice);
-
- SAFE_RELEASE(devices);
-
- return hr;
+ else
+ {
+ TRACE(_T("CMpcAudioRenderer::GetAudioDevice - devices->Item failed: (0x%08x)\n"), hr);
+ }
+
+ CoTaskMemFree(pwszID);
+ pwszID = NULL;
+ }
+ }
+
+ TRACE(_T("CMpcAudioRenderer::GetAudioDevice - Unable to find selected audio device, using the default end point!\n"));
+ hr = enumerator->GetDefaultAudioEndpoint(eRender, eConsole, ppMMDevice);
+
+ SAFE_RELEASE(devices);
+
+ return hr;
}
bool CMpcAudioRenderer::CheckFormatChanged(WAVEFORMATEX *pWaveFormatEx, WAVEFORMATEX **ppNewWaveFormatEx)
diff --git a/src/filters/renderer/MpcAudioRenderer/MpcAudioRendererSettingsWnd.cpp b/src/filters/renderer/MpcAudioRenderer/MpcAudioRendererSettingsWnd.cpp index 1aa5031b0..cf452c85d 100644 --- a/src/filters/renderer/MpcAudioRenderer/MpcAudioRendererSettingsWnd.cpp +++ b/src/filters/renderer/MpcAudioRenderer/MpcAudioRendererSettingsWnd.cpp @@ -44,11 +44,11 @@ bool CMpcAudioRendererSettingsWnd::OnConnect(const CInterfaceList<IUnknown, &IID m_pMAR.Release();
POSITION pos = pUnks.GetHeadPosition();
- while(pos && !(m_pMAR = pUnks.GetNext(pos))) {
+ while (pos && !(m_pMAR = pUnks.GetNext(pos))) {
;
}
- if(!m_pMAR) {
+ if (!m_pMAR) {
return false;
}
@@ -60,26 +60,26 @@ void CMpcAudioRendererSettingsWnd::OnDisconnect() m_pMAR.Release();
}
-bool CALLBACK DSEnumProc(LPGUID lpGUID,
- LPCTSTR lpszDesc,
- LPCTSTR lpszDrvName,
- LPVOID lpContext )
+bool CALLBACK DSEnumProc(LPGUID lpGUID,
+ LPCTSTR lpszDesc,
+ LPCTSTR lpszDrvName,
+ LPVOID lpContext )
{
- CComboBox *pCombo = (CComboBox*)lpContext;
- ASSERT ( pCombo );
- LPGUID lpTemp = NULL;
-
- if (lpGUID != NULL) // NULL only for "Primary Sound Driver".
- {
- if ((lpTemp = (LPGUID)malloc(sizeof(GUID))) == NULL)
- {
- return TRUE;
- }
- memcpy(lpTemp, lpGUID, sizeof(GUID));
- }
- pCombo->AddString ( lpszDesc );
- free(lpTemp);
- return TRUE;
+ CComboBox *pCombo = (CComboBox*)lpContext;
+ ASSERT ( pCombo );
+ LPGUID lpTemp = NULL;
+
+ if (lpGUID != NULL) // NULL only for "Primary Sound Driver".
+ {
+ if ((lpTemp = (LPGUID)malloc(sizeof(GUID))) == NULL)
+ {
+ return TRUE;
+ }
+ memcpy(lpTemp, lpGUID, sizeof(GUID));
+ }
+ pCombo->AddString ( lpszDesc );
+ free(lpTemp);
+ return TRUE;
}
bool CMpcAudioRendererSettingsWnd::OnActivate()
@@ -94,14 +94,14 @@ bool CMpcAudioRendererSettingsWnd::OnActivate() nPosY += VERTICAL_SPACING + 5;
m_txtSoundDevice.Create (ResStr (IDS_ARS_SOUND_DEVICE), WS_VISIBLE|WS_CHILD, CRect (LEFT_SPACING, nPosY, 100, nPosY+15), this, (UINT)IDC_STATIC);
m_cbSoundDevice.Create (WS_VISIBLE|WS_CHILD|CBS_DROPDOWNLIST|WS_VSCROLL, CRect (110, nPosY-4, 325, nPosY+90), this, IDC_PP_SOUND_DEVICE);
-
+
SetClassLongPtr(GetDlgItem(IDC_PP_SOUND_DEVICE)->m_hWnd, GCLP_HCURSOR, (long) AfxGetApp()->LoadStandardCursor(IDC_HAND));
DirectSoundEnumerate((LPDSENUMCALLBACK)DSEnumProc, (VOID*)&m_cbSoundDevice);
if ( m_cbSoundDevice.GetCount() > 0 ) {
int idx = m_cbSoundDevice.FindString(0, m_pMAR->GetSoundDevice());
- if( idx < 0) {
+ if ( idx < 0) {
m_cbSoundDevice.SetCurSel(0);
}
else {
@@ -112,7 +112,7 @@ bool CMpcAudioRendererSettingsWnd::OnActivate() m_cbWasapiMode.SetCheck(m_pMAR->GetWasapiMode());
m_cbMuteFastForward.SetCheck(m_pMAR->GetMuteFastForward());
- for(CWnd* pWnd = GetWindow(GW_CHILD); pWnd; pWnd = pWnd->GetNextWindow()) {
+ for (CWnd* pWnd = GetWindow(GW_CHILD); pWnd; pWnd = pWnd->GetNextWindow()) {
pWnd->SetFont(&m_font, FALSE);
}
@@ -127,12 +127,12 @@ bool CMpcAudioRendererSettingsWnd::OnApply() {
OnDeactivate();
- if(m_pMAR) {
+ if (m_pMAR) {
m_pMAR->SetWasapiMode(m_cbWasapiMode.GetCheck());
m_pMAR->SetMuteFastForward(m_cbMuteFastForward.GetCheck());
CString str;
int idx = m_cbSoundDevice.GetCurSel();
- if( !(idx < 0) ) {
+ if ( !(idx < 0) ) {
m_cbSoundDevice.GetLBText( idx, str );
m_pMAR->SetSoundDevice(str);
}
diff --git a/src/filters/renderer/SyncClock/Interfaces.h b/src/filters/renderer/SyncClock/Interfaces.h index ae3ee5253..7b8abfcc0 100644 --- a/src/filters/renderer/SyncClock/Interfaces.h +++ b/src/filters/renderer/SyncClock/Interfaces.h @@ -19,7 +19,7 @@ * along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
-
+
#pragma once
const IID IID_ISyncClock = {0xa62888fb, 0x8e37, 0x44d2, {0x88, 0x50, 0xb3, 0xe3, 0xf2, 0xc1, 0x16, 0x9f}};
diff --git a/src/filters/renderer/SyncClock/SyncClock.cpp b/src/filters/renderer/SyncClock/SyncClock.cpp index eaa9e871b..39b330bea 100644 --- a/src/filters/renderer/SyncClock/SyncClock.cpp +++ b/src/filters/renderer/SyncClock/SyncClock.cpp @@ -19,7 +19,7 @@ * along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
-
+
#include "stdafx.h"
#include <InitGuid.h>
#include "SyncClock.h"
@@ -93,9 +93,9 @@ STDMETHODIMP CSyncClockFilter::NonDelegatingQueryInterface( REFIID riid, void ** {
CheckPointer(ppv, E_POINTER);
- if(riid == IID_IReferenceClock) {
+ if (riid == IID_IReferenceClock) {
return GetInterface(static_cast<IReferenceClock*>(&m_Clock), ppv);
- } else if(riid == IID_ISyncClock) {
+ } else if (riid == IID_ISyncClock) {
return GetInterface(static_cast<ISyncClock*>(this), ppv);
} else {
return CBaseFilter::NonDelegatingQueryInterface(riid, ppv);
diff --git a/src/filters/renderer/SyncClock/SyncClock.h b/src/filters/renderer/SyncClock/SyncClock.h index bbb4e6f71..4ae26ce2c 100644 --- a/src/filters/renderer/SyncClock/SyncClock.h +++ b/src/filters/renderer/SyncClock/SyncClock.h @@ -19,7 +19,7 @@ * along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
-
+
#pragma once
#include <atlbase.h>
diff --git a/src/filters/renderer/SyncClock/stdafx.cpp b/src/filters/renderer/SyncClock/stdafx.cpp index a328b326e..26b4ebbee 100644 --- a/src/filters/renderer/SyncClock/stdafx.cpp +++ b/src/filters/renderer/SyncClock/stdafx.cpp @@ -19,5 +19,5 @@ * along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
-
+
#include "stdafx.h"
diff --git a/src/filters/renderer/SyncClock/stdafx.h b/src/filters/renderer/SyncClock/stdafx.h index 800cef726..9cb3f0d17 100644 --- a/src/filters/renderer/SyncClock/stdafx.h +++ b/src/filters/renderer/SyncClock/stdafx.h @@ -19,7 +19,7 @@ * along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
-
+
#pragma once
#include "../../../DSUtil/SharedInclude.h"
diff --git a/src/filters/renderer/VideoRenderers/AllocatorCommon.cpp b/src/filters/renderer/VideoRenderers/AllocatorCommon.cpp index 62c98d783..5f0a7c23b 100644 --- a/src/filters/renderer/VideoRenderers/AllocatorCommon.cpp +++ b/src/filters/renderer/VideoRenderers/AllocatorCommon.cpp @@ -35,7 +35,7 @@ bool IsVMR9InGraph(IFilterGraph* pFG)
{
BeginEnumFilters(pFG, pEF, pBF)
- if(CComQIPtr<IVMRWindowlessControl9>(pBF)) {
+ if (CComQIPtr<IVMRWindowlessControl9>(pBF)) {
return true;
}
EndEnumFilters
@@ -103,7 +103,7 @@ HRESULT CreateEVR(const CLSID& clsid, HWND hWnd, bool bFullscreen, ISubPicAlloca *ppAP = DNew DSObjects::CEVRAllocatorPresenter(hWnd, bFullscreen, hr, Error);
(*ppAP)->AddRef();
- if(FAILED(hr)) {
+ if (FAILED(hr)) {
Error += L"\n";
Error += GetWindowsErrorMessage(hr, NULL);
MessageBox(hWnd, Error, L"Error creating EVR Custom renderer", MB_OK | MB_ICONERROR);
@@ -185,8 +185,8 @@ CString GetWindowsErrorMessage(HRESULT _Error, HMODULE _Module) CString errmsg;
LPVOID lpMsgBuf;
- if(FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER|FORMAT_MESSAGE_FROM_SYSTEM|FORMAT_MESSAGE_IGNORE_INSERTS|FORMAT_MESSAGE_FROM_HMODULE,
- _Module, _Error, MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), (LPTSTR)&lpMsgBuf, 0, NULL)) {
+ if (FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER|FORMAT_MESSAGE_FROM_SYSTEM|FORMAT_MESSAGE_IGNORE_INSERTS|FORMAT_MESSAGE_FROM_HMODULE,
+ _Module, _Error, MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), (LPTSTR)&lpMsgBuf, 0, NULL)) {
errmsg = (LPCTSTR)lpMsgBuf;
LocalFree(lpMsgBuf);
}
diff --git a/src/filters/renderer/VideoRenderers/AllocatorCommon7.cpp b/src/filters/renderer/VideoRenderers/AllocatorCommon7.cpp index 02d41e59a..b72091b36 100644 --- a/src/filters/renderer/VideoRenderers/AllocatorCommon7.cpp +++ b/src/filters/renderer/VideoRenderers/AllocatorCommon7.cpp @@ -35,7 +35,7 @@ bool IsVMR7InGraph(IFilterGraph* pFG)
{
BeginEnumFilters(pFG, pEF, pBF)
- if(CComQIPtr<IVMRWindowlessControl>(pBF)) {
+ if (CComQIPtr<IVMRWindowlessControl>(pBF)) {
return true;
}
EndEnumFilters
@@ -73,7 +73,7 @@ HRESULT CreateAP7(const CLSID& clsid, HWND hWnd, ISubPicAllocatorPresenter** ppA (*ppAP)->AddRef();
- if(FAILED(hr)) {
+ if (FAILED(hr)) {
(*ppAP)->Release();
*ppAP = NULL;
}
diff --git a/src/filters/renderer/VideoRenderers/D3DFont.cpp b/src/filters/renderer/VideoRenderers/D3DFont.cpp index 5b741ad30..e791c2d9f 100644 --- a/src/filters/renderer/VideoRenderers/D3DFont.cpp +++ b/src/filters/renderer/VideoRenderers/D3DFont.cpp @@ -131,7 +131,7 @@ HRESULT CD3DFont::CreateGDIFont( HDC hDC, HFONT* pFont ) CLIP_DEFAULT_PRECIS, ANTIALIASED_QUALITY,
VARIABLE_PITCH, m_strFontName );
- if( *pFont == NULL ) {
+ if ( *pFont == NULL ) {
return E_FAIL;
}
@@ -152,7 +152,7 @@ HRESULT CD3DFont::PaintAlphabet( HDC hDC, BOOL bMeasureOnly ) TCHAR str[2] = _T("x"); // One-character, null-terminated string
// Calculate the spacing between characters based on line height
- if( 0 == GetTextExtentPoint32( hDC, str, 1, &size ) ) {
+ if ( 0 == GetTextExtentPoint32( hDC, str, 1, &size ) ) {
return E_FAIL;
}
m_dwSpacing = (DWORD) ceil(size.cy * 0.3f);
@@ -162,25 +162,25 @@ HRESULT CD3DFont::PaintAlphabet( HDC hDC, BOOL bMeasureOnly ) DWORD y = 0;
// For each character, draw text on the DC and advance the current position
- for( char c = 32; c < 127; c++ ) {
+ for ( char c = 32; c < 127; c++ ) {
str[0] = c;
- if( 0 == GetTextExtentPoint32( hDC, str, 1, &size ) ) {
+ if ( 0 == GetTextExtentPoint32( hDC, str, 1, &size ) ) {
return E_FAIL;
}
- if( (DWORD)(x + size.cx + m_dwSpacing) > m_dwTexWidth ) {
+ if ( (DWORD)(x + size.cx + m_dwSpacing) > m_dwTexWidth ) {
x = m_dwSpacing;
y += size.cy + 1;
}
// Check to see if there's room to write the character here
- if( y + size.cy > m_dwTexHeight ) {
+ if ( y + size.cy > m_dwTexHeight ) {
return D3DERR_MOREDATA;
}
- if( !bMeasureOnly ) {
+ if ( !bMeasureOnly ) {
// Perform the actual drawing
- if( 0 == ExtTextOut( hDC, x+0, y+0, ETO_OPAQUE, NULL, str, 1, NULL ) ) {
+ if ( 0 == ExtTextOut( hDC, x+0, y+0, ETO_OPAQUE, NULL, str, 1, NULL ) ) {
return E_FAIL;
}
@@ -223,7 +223,7 @@ HRESULT CD3DFont::InitDeviceObjects( LPDIRECT3DDEVICE9 pd3dDevice ) SetMapMode( hDC, MM_TEXT );
hr = CreateGDIFont( hDC, &hFont );
- if( FAILED(hr) ) {
+ if ( FAILED(hr) ) {
goto LCleanReturn;
}
@@ -232,12 +232,12 @@ HRESULT CD3DFont::InitDeviceObjects( LPDIRECT3DDEVICE9 pd3dDevice ) // Calculate the dimensions for the smallest power-of-two texture which
// can hold all the printable characters
m_dwTexWidth = m_dwTexHeight = 128;
- while( D3DERR_MOREDATA == ( hr = PaintAlphabet( hDC, true ) ) ) {
+ while ( D3DERR_MOREDATA == ( hr = PaintAlphabet( hDC, true ) ) ) {
m_dwTexWidth *= 2;
m_dwTexHeight *= 2;
}
- if( FAILED(hr) ) {
+ if ( FAILED(hr) ) {
goto LCleanReturn;
}
@@ -246,7 +246,7 @@ HRESULT CD3DFont::InitDeviceObjects( LPDIRECT3DDEVICE9 pd3dDevice ) D3DCAPS9 d3dCaps;
m_pd3dDevice->GetDeviceCaps( &d3dCaps );
- if( m_dwTexWidth > d3dCaps.MaxTextureWidth ) {
+ if ( m_dwTexWidth > d3dCaps.MaxTextureWidth ) {
m_fTextScale = (FLOAT)d3dCaps.MaxTextureWidth / (FLOAT)m_dwTexWidth;
m_dwTexWidth = m_dwTexHeight = d3dCaps.MaxTextureWidth;
@@ -255,7 +255,7 @@ HRESULT CD3DFont::InitDeviceObjects( LPDIRECT3DDEVICE9 pd3dDevice ) do {
// If we've already tried fitting the new text, the scale is still
// too large. Reduce and try again.
- if( !bFirstRun) {
+ if ( !bFirstRun) {
m_fTextScale *= 0.9f;
}
@@ -264,14 +264,14 @@ HRESULT CD3DFont::InitDeviceObjects( LPDIRECT3DDEVICE9 pd3dDevice ) DeleteObject( SelectObject( hDC, hFontOld ) );
hr = CreateGDIFont( hDC, &hFont );
- if( FAILED(hr) ) {
+ if ( FAILED(hr) ) {
goto LCleanReturn;
}
hFontOld = (HFONT) SelectObject( hDC, hFont );
bFirstRun = false;
- } while( D3DERR_MOREDATA == ( hr = PaintAlphabet( hDC, true ) ) );
+ } while ( D3DERR_MOREDATA == ( hr = PaintAlphabet( hDC, true ) ) );
}
@@ -279,7 +279,7 @@ HRESULT CD3DFont::InitDeviceObjects( LPDIRECT3DDEVICE9 pd3dDevice ) hr = m_pd3dDevice->CreateTexture( m_dwTexWidth, m_dwTexHeight, 1,
0, D3DFMT_A4R4G4B4,
D3DPOOL_MANAGED, &m_pTexture, NULL );
- if( FAILED(hr) ) {
+ if ( FAILED(hr) ) {
goto LCleanReturn;
}
@@ -307,7 +307,7 @@ HRESULT CD3DFont::InitDeviceObjects( LPDIRECT3DDEVICE9 pd3dDevice ) // Paint the alphabet onto the selected bitmap
hr = PaintAlphabet( hDC, false );
- if( FAILED(hr) ) {
+ if ( FAILED(hr) ) {
goto LCleanReturn;
}
@@ -320,9 +320,9 @@ HRESULT CD3DFont::InitDeviceObjects( LPDIRECT3DDEVICE9 pd3dDevice ) BYTE bAlpha; // 4-bit measure of pixel intensity
DWORD x, y;
- for( y=0; y < m_dwTexHeight; y++ ) {
+ for ( y=0; y < m_dwTexHeight; y++ ) {
pDst16 = (WORD*)pDstRow;
- for( x=0; x < m_dwTexWidth; x++ ) {
+ for ( x=0; x < m_dwTexWidth; x++ ) {
bAlpha = (BYTE)((pBitmapBits[m_dwTexWidth*y + x] & 0xff) >> 4);
if (bAlpha > 0) {
*pDst16++ = (WORD) ((bAlpha << 12) | 0x0fff);
@@ -337,7 +337,7 @@ HRESULT CD3DFont::InitDeviceObjects( LPDIRECT3DDEVICE9 pd3dDevice ) // Done updating texture, so clean up used objects
LCleanReturn:
- if( m_pTexture ) {
+ if ( m_pTexture ) {
m_pTexture->UnlockRect(0);
}
@@ -362,26 +362,26 @@ HRESULT CD3DFont::RestoreDeviceObjects() // Create vertex buffer for the letters
int vertexSize = max( sizeof(FONT2DVERTEX), sizeof(FONT3DVERTEX ) );
- if( FAILED( hr = m_pd3dDevice->CreateVertexBuffer( MAX_NUM_VERTICES * vertexSize,
- D3DUSAGE_WRITEONLY | D3DUSAGE_DYNAMIC, 0,
- D3DPOOL_DEFAULT, &m_pVB, NULL ) ) ) {
+ if ( FAILED( hr = m_pd3dDevice->CreateVertexBuffer( MAX_NUM_VERTICES * vertexSize,
+ D3DUSAGE_WRITEONLY | D3DUSAGE_DYNAMIC, 0,
+ D3DPOOL_DEFAULT, &m_pVB, NULL ) ) ) {
return hr;
}
bool bSupportsAlphaBlend = true;
LPDIRECT3D9 pd3d9 = NULL;
- if( SUCCEEDED( m_pd3dDevice->GetDirect3D( &pd3d9 ) ) ) {
+ if ( SUCCEEDED( m_pd3dDevice->GetDirect3D( &pd3d9 ) ) ) {
D3DCAPS9 Caps;
D3DDISPLAYMODE Mode;
LPDIRECT3DSURFACE9 pSurf = NULL;
D3DSURFACE_DESC Desc;
m_pd3dDevice->GetDeviceCaps( &Caps );
m_pd3dDevice->GetDisplayMode( 0, &Mode );
- if( SUCCEEDED( m_pd3dDevice->GetRenderTarget( 0, &pSurf ) ) ) {
+ if ( SUCCEEDED( m_pd3dDevice->GetRenderTarget( 0, &pSurf ) ) ) {
pSurf->GetDesc( &Desc );
- if( FAILED( pd3d9->CheckDeviceFormat( Caps.AdapterOrdinal, Caps.DeviceType, Mode.Format,
- D3DUSAGE_RENDERTARGET | D3DUSAGE_QUERY_POSTPIXELSHADER_BLENDING, D3DRTYPE_SURFACE,
- Desc.Format ) ) ) {
+ if ( FAILED( pd3d9->CheckDeviceFormat( Caps.AdapterOrdinal, Caps.DeviceType, Mode.Format,
+ D3DUSAGE_RENDERTARGET | D3DUSAGE_QUERY_POSTPIXELSHADER_BLENDING, D3DRTYPE_SURFACE,
+ Desc.Format ) ) ) {
bSupportsAlphaBlend = false;
}
SAFE_RELEASE( pSurf );
@@ -390,7 +390,7 @@ HRESULT CD3DFont::RestoreDeviceObjects() }
// Create the state blocks for rendering text
- for( UINT which=0; which<2; which++ ) {
+ for ( UINT which=0; which<2; which++ ) {
m_pd3dDevice->BeginStateBlock();
m_pd3dDevice->SetTexture( 0, m_pTexture );
@@ -400,7 +400,7 @@ HRESULT CD3DFont::RestoreDeviceObjects() m_pd3dDevice->SetRenderState( D3DRS_ZENABLE, FALSE );
}
- if( bSupportsAlphaBlend ) {
+ if ( bSupportsAlphaBlend ) {
m_pd3dDevice->SetRenderState( D3DRS_ALPHABLENDENABLE, TRUE );
m_pd3dDevice->SetRenderState( D3DRS_SRCBLEND, D3DBLEND_SRCALPHA );
m_pd3dDevice->SetRenderState( D3DRS_DESTBLEND, D3DBLEND_INVSRCALPHA );
@@ -435,7 +435,7 @@ HRESULT CD3DFont::RestoreDeviceObjects() m_pd3dDevice->SetSamplerState( 0, D3DSAMP_MAGFILTER, D3DTEXF_POINT );
m_pd3dDevice->SetSamplerState( 0, D3DSAMP_MIPFILTER, D3DTEXF_NONE );
- if( which==0 ) {
+ if ( which==0 ) {
m_pd3dDevice->EndStateBlock( &m_pStateBlockSaved );
} else {
m_pd3dDevice->EndStateBlock( &m_pStateBlockDrawText );
@@ -482,7 +482,7 @@ HRESULT CD3DFont::DeleteDeviceObjects() //-----------------------------------------------------------------------------
HRESULT CD3DFont::GetTextExtent( const TCHAR* strText, SIZE* pSize )
{
- if( NULL==strText || NULL==pSize ) {
+ if ( NULL==strText || NULL==pSize ) {
return E_FAIL;
}
@@ -491,15 +491,15 @@ HRESULT CD3DFont::GetTextExtent( const TCHAR* strText, SIZE* pSize ) FLOAT fWidth = 0.0f;
FLOAT fHeight = fRowHeight;
- while( *strText ) {
+ while ( *strText ) {
TCHAR c = *strText++;
- if( c == _T('\n') ) {
+ if ( c == _T('\n') ) {
fRowWidth = 0.0f;
fHeight += fRowHeight;
}
- if( (c-32) < 0 || (c-32) >= 128-32 ) {
+ if ( (c-32) < 0 || (c-32) >= 128-32 ) {
continue;
}
@@ -508,7 +508,7 @@ HRESULT CD3DFont::GetTextExtent( const TCHAR* strText, SIZE* pSize ) fRowWidth += (tx2-tx1)*m_dwTexWidth - 2*m_dwSpacing;
- if( fRowWidth > fWidth ) {
+ if ( fRowWidth > fWidth ) {
fWidth = fRowWidth;
}
}
@@ -533,7 +533,7 @@ HRESULT CD3DFont::DrawTextScaled( FLOAT x, FLOAT y, FLOAT z, FLOAT fXScale, FLOAT fYScale, DWORD dwColor,
const TCHAR* strText, DWORD dwFlags )
{
- if( m_pd3dDevice == NULL ) {
+ if ( m_pd3dDevice == NULL ) {
return E_FAIL;
}
@@ -545,7 +545,7 @@ HRESULT CD3DFont::DrawTextScaled( FLOAT x, FLOAT y, FLOAT z, m_pd3dDevice->SetStreamSource( 0, m_pVB, 0, sizeof(FONT2DVERTEX) );
// Set filter states
- if( dwFlags & D3DFONT_FILTERED ) {
+ if ( dwFlags & D3DFONT_FILTERED ) {
m_pd3dDevice->SetSamplerState( 0, D3DSAMP_MINFILTER, D3DTEXF_LINEAR );
m_pd3dDevice->SetSamplerState( 0, D3DSAMP_MAGFILTER, D3DTEXF_LINEAR );
}
@@ -555,17 +555,17 @@ HRESULT CD3DFont::DrawTextScaled( FLOAT x, FLOAT y, FLOAT z, FLOAT fLineHeight = ( m_fTexCoords[0][3] - m_fTexCoords[0][1] ) * m_dwTexHeight;
// Center the text block in the viewport
- if( dwFlags & D3DFONT_CENTERED_X ) {
+ if ( dwFlags & D3DFONT_CENTERED_X ) {
const TCHAR* strTextTmp = strText;
float xFinal = 0.0f;
- while( *strTextTmp ) {
+ while ( *strTextTmp ) {
TCHAR c = *strTextTmp++;
- if( c == _T('\n') ) {
+ if ( c == _T('\n') ) {
break; // Isn't supported.
}
- if( (c-32) < 0 || (c-32) >= 128-32 ) {
+ if ( (c-32) < 0 || (c-32) >= 128-32 ) {
continue;
}
@@ -581,7 +581,7 @@ HRESULT CD3DFont::DrawTextScaled( FLOAT x, FLOAT y, FLOAT z, x = -xFinal/vp.Width;
}
- if( dwFlags & D3DFONT_CENTERED_Y ) {
+ if ( dwFlags & D3DFONT_CENTERED_Y ) {
y = -fLineHeight/vp.Height;
}
@@ -599,15 +599,15 @@ HRESULT CD3DFont::DrawTextScaled( FLOAT x, FLOAT y, FLOAT z, DWORD dwNumTriangles = 0L;
m_pVB->Lock( 0, 0, (void**)&pVertices, D3DLOCK_DISCARD );
- while( *strText ) {
+ while ( *strText ) {
TCHAR c = *strText++;
- if( c == _T('\n') ) {
+ if ( c == _T('\n') ) {
sx = fStartX;
sy += fYScale*vp.Height;
}
- if( (c-32) < 0 || (c-32) >= 128-32 ) {
+ if ( (c-32) < 0 || (c-32) >= 128-32 ) {
continue;
}
@@ -622,7 +622,7 @@ HRESULT CD3DFont::DrawTextScaled( FLOAT x, FLOAT y, FLOAT z, w *= (fXScale*vp.Height)/fLineHeight;
h *= (fYScale*vp.Height)/fLineHeight;
- if( c != _T(' ') ) {
+ if ( c != _T(' ') ) {
*pVertices++ = InitFont2DVertex( D3DXVECTOR4(sx+0-0.5f,sy+h-0.5f,sz,rhw), dwColor, tx1, ty2 );
*pVertices++ = InitFont2DVertex( D3DXVECTOR4(sx+0-0.5f,sy+0-0.5f,sz,rhw), dwColor, tx1, ty1 );
*pVertices++ = InitFont2DVertex( D3DXVECTOR4(sx+w-0.5f,sy+h-0.5f,sz,rhw), dwColor, tx2, ty2 );
@@ -631,7 +631,7 @@ HRESULT CD3DFont::DrawTextScaled( FLOAT x, FLOAT y, FLOAT z, *pVertices++ = InitFont2DVertex( D3DXVECTOR4(sx+0-0.5f,sy+0-0.5f,sz,rhw), dwColor, tx1, ty1 );
dwNumTriangles += 2;
- if( dwNumTriangles*3 > (MAX_NUM_VERTICES-6) ) {
+ if ( dwNumTriangles*3 > (MAX_NUM_VERTICES-6) ) {
// Unlock, render, and relock the vertex buffer
m_pVB->Unlock();
m_pd3dDevice->DrawPrimitive( D3DPT_TRIANGLELIST, 0, dwNumTriangles );
@@ -645,7 +645,7 @@ HRESULT CD3DFont::DrawTextScaled( FLOAT x, FLOAT y, FLOAT z, // Unlock and render the vertex buffer
m_pVB->Unlock();
- if( dwNumTriangles > 0 ) {
+ if ( dwNumTriangles > 0 ) {
m_pd3dDevice->DrawPrimitive( D3DPT_TRIANGLELIST, 0, dwNumTriangles );
}
@@ -664,7 +664,7 @@ HRESULT CD3DFont::DrawTextScaled( FLOAT x, FLOAT y, FLOAT z, HRESULT CD3DFont::DrawText( FLOAT sx, FLOAT sy, DWORD dwColor,
const TCHAR* strText, DWORD dwFlags )
{
- if( m_pd3dDevice == NULL ) {
+ if ( m_pd3dDevice == NULL ) {
return E_FAIL;
}
@@ -676,25 +676,25 @@ HRESULT CD3DFont::DrawText( FLOAT sx, FLOAT sy, DWORD dwColor, m_pd3dDevice->SetStreamSource( 0, m_pVB, 0, sizeof(FONT2DVERTEX) );
// Set filter states
- if( dwFlags & D3DFONT_FILTERED ) {
+ if ( dwFlags & D3DFONT_FILTERED ) {
m_pd3dDevice->SetSamplerState( 0, D3DSAMP_MINFILTER, D3DTEXF_LINEAR );
m_pd3dDevice->SetSamplerState( 0, D3DSAMP_MAGFILTER, D3DTEXF_LINEAR );
}
// Center the text block in the viewport
- if( dwFlags & D3DFONT_CENTERED_X ) {
+ if ( dwFlags & D3DFONT_CENTERED_X ) {
D3DVIEWPORT9 vp;
m_pd3dDevice->GetViewport( &vp );
const TCHAR* strTextTmp = strText;
float xFinal = 0.0f;
- while( *strTextTmp ) {
+ while ( *strTextTmp ) {
TCHAR c = *strTextTmp++;
- if( c == _T('\n') ) {
+ if ( c == _T('\n') ) {
break; // Isn't supported.
}
- if( (c-32) < 0 || (c-32) >= 128-32 ) {
+ if ( (c-32) < 0 || (c-32) >= 128-32 ) {
continue;
}
@@ -708,7 +708,7 @@ HRESULT CD3DFont::DrawText( FLOAT sx, FLOAT sy, DWORD dwColor, sx = (vp.Width-xFinal)/2.0f;
}
- if( dwFlags & D3DFONT_CENTERED_Y ) {
+ if ( dwFlags & D3DFONT_CENTERED_Y ) {
D3DVIEWPORT9 vp;
m_pd3dDevice->GetViewport( &vp );
float fLineHeight = ((m_fTexCoords[0][3]-m_fTexCoords[0][1])*m_dwTexHeight);
@@ -724,15 +724,15 @@ HRESULT CD3DFont::DrawText( FLOAT sx, FLOAT sy, DWORD dwColor, DWORD dwNumTriangles = 0;
m_pVB->Lock( 0, 0, (void**)&pVertices, D3DLOCK_DISCARD );
- while( *strText ) {
+ while ( *strText ) {
TCHAR c = *strText++;
- if( c == _T('\n') ) {
+ if ( c == _T('\n') ) {
sx = fStartX;
sy += (m_fTexCoords[0][3]-m_fTexCoords[0][1])*m_dwTexHeight;
}
- if( (c-32) < 0 || (c-32) >= 128-32 ) {
+ if ( (c-32) < 0 || (c-32) >= 128-32 ) {
continue;
}
@@ -744,7 +744,7 @@ HRESULT CD3DFont::DrawText( FLOAT sx, FLOAT sy, DWORD dwColor, FLOAT w = (tx2-tx1) * m_dwTexWidth / m_fTextScale;
FLOAT h = (ty2-ty1) * m_dwTexHeight / m_fTextScale;
- if( c != _T(' ') ) {
+ if ( c != _T(' ') ) {
*pVertices++ = InitFont2DVertex( D3DXVECTOR4(sx+0-0.5f,sy+h-0.5f,0.9f,1.0f), dwColor, tx1, ty2 );
*pVertices++ = InitFont2DVertex( D3DXVECTOR4(sx+0-0.5f,sy+0-0.5f,0.9f,1.0f), dwColor, tx1, ty1 );
*pVertices++ = InitFont2DVertex( D3DXVECTOR4(sx+w-0.5f,sy+h-0.5f,0.9f,1.0f), dwColor, tx2, ty2 );
@@ -753,7 +753,7 @@ HRESULT CD3DFont::DrawText( FLOAT sx, FLOAT sy, DWORD dwColor, *pVertices++ = InitFont2DVertex( D3DXVECTOR4(sx+0-0.5f,sy+0-0.5f,0.9f,1.0f), dwColor, tx1, ty1 );
dwNumTriangles += 2;
- if( dwNumTriangles*3 > (MAX_NUM_VERTICES-6) ) {
+ if ( dwNumTriangles*3 > (MAX_NUM_VERTICES-6) ) {
// Unlock, render, and relock the vertex buffer
m_pVB->Unlock();
m_pd3dDevice->DrawPrimitive( D3DPT_TRIANGLELIST, 0, dwNumTriangles );
@@ -768,7 +768,7 @@ HRESULT CD3DFont::DrawText( FLOAT sx, FLOAT sy, DWORD dwColor, // Unlock and render the vertex buffer
m_pVB->Unlock();
- if( dwNumTriangles > 0 ) {
+ if ( dwNumTriangles > 0 ) {
m_pd3dDevice->DrawPrimitive( D3DPT_TRIANGLELIST, 0, dwNumTriangles );
}
@@ -786,7 +786,7 @@ HRESULT CD3DFont::DrawText( FLOAT sx, FLOAT sy, DWORD dwColor, //-----------------------------------------------------------------------------
HRESULT CD3DFont::Render3DText( const TCHAR* strText, DWORD dwFlags )
{
- if( m_pd3dDevice == NULL ) {
+ if ( m_pd3dDevice == NULL ) {
return E_FAIL;
}
@@ -798,7 +798,7 @@ HRESULT CD3DFont::Render3DText( const TCHAR* strText, DWORD dwFlags ) m_pd3dDevice->SetStreamSource( 0, m_pVB, 0, sizeof(FONT3DVERTEX) );
// Set filter states
- if( dwFlags & D3DFONT_FILTERED ) {
+ if ( dwFlags & D3DFONT_FILTERED ) {
m_pd3dDevice->SetSamplerState( 0, D3DSAMP_MINFILTER, D3DTEXF_LINEAR );
m_pd3dDevice->SetSamplerState( 0, D3DSAMP_MAGFILTER, D3DTEXF_LINEAR );
}
@@ -808,19 +808,19 @@ HRESULT CD3DFont::Render3DText( const TCHAR* strText, DWORD dwFlags ) FLOAT y = 0.0f;
// Center the text block at the origin (not the viewport)
- if( dwFlags & D3DFONT_CENTERED_X ) {
+ if ( dwFlags & D3DFONT_CENTERED_X ) {
SIZE sz;
GetTextExtent( strText, &sz );
x = -(((FLOAT)sz.cx)/10.0f)/2.0f;
}
- if( dwFlags & D3DFONT_CENTERED_Y ) {
+ if ( dwFlags & D3DFONT_CENTERED_Y ) {
SIZE sz;
GetTextExtent( strText, &sz );
y = -(((FLOAT)sz.cy)/10.0f)/2.0f;
}
// Turn off culling for two-sided text
- if( dwFlags & D3DFONT_TWOSIDED ) {
+ if ( dwFlags & D3DFONT_TWOSIDED ) {
m_pd3dDevice->SetRenderState( D3DRS_CULLMODE, D3DCULL_NONE );
}
@@ -834,13 +834,13 @@ HRESULT CD3DFont::Render3DText( const TCHAR* strText, DWORD dwFlags ) DWORD dwNumTriangles = 0L;
m_pVB->Lock( 0, 0, (void**)&pVertices, D3DLOCK_DISCARD );
- while( (c = *strText++) != 0 ) {
- if( c == '\n' ) {
+ while ( (c = *strText++) != 0 ) {
+ if ( c == '\n' ) {
x = fStartX;
y -= (m_fTexCoords[0][3]-m_fTexCoords[0][1])*m_dwTexHeight/10.0f;
}
- if( (c-32) < 0 || (c-32) >= 128-32 ) {
+ if ( (c-32) < 0 || (c-32) >= 128-32 ) {
continue;
}
@@ -852,7 +852,7 @@ HRESULT CD3DFont::Render3DText( const TCHAR* strText, DWORD dwFlags ) FLOAT w = (tx2-tx1) * m_dwTexWidth / ( 10.0f * m_fTextScale );
FLOAT h = (ty2-ty1) * m_dwTexHeight / ( 10.0f * m_fTextScale );
- if( c != _T(' ') ) {
+ if ( c != _T(' ') ) {
*pVertices++ = InitFont3DVertex( D3DXVECTOR3(x+0,y+0,0), D3DXVECTOR3(0,0,-1), tx1, ty2 );
*pVertices++ = InitFont3DVertex( D3DXVECTOR3(x+0,y+h,0), D3DXVECTOR3(0,0,-1), tx1, ty1 );
*pVertices++ = InitFont3DVertex( D3DXVECTOR3(x+w,y+0,0), D3DXVECTOR3(0,0,-1), tx2, ty2 );
@@ -861,7 +861,7 @@ HRESULT CD3DFont::Render3DText( const TCHAR* strText, DWORD dwFlags ) *pVertices++ = InitFont3DVertex( D3DXVECTOR3(x+0,y+h,0), D3DXVECTOR3(0,0,-1), tx1, ty1 );
dwNumTriangles += 2;
- if( dwNumTriangles*3 > (MAX_NUM_VERTICES-6) ) {
+ if ( dwNumTriangles*3 > (MAX_NUM_VERTICES-6) ) {
// Unlock, render, and relock the vertex buffer
m_pVB->Unlock();
m_pd3dDevice->DrawPrimitive( D3DPT_TRIANGLELIST, 0, dwNumTriangles );
@@ -875,7 +875,7 @@ HRESULT CD3DFont::Render3DText( const TCHAR* strText, DWORD dwFlags ) // Unlock and render the vertex buffer
m_pVB->Unlock();
- if( dwNumTriangles > 0 ) {
+ if ( dwNumTriangles > 0 ) {
m_pd3dDevice->DrawPrimitive( D3DPT_TRIANGLELIST, 0, dwNumTriangles );
}
diff --git a/src/filters/renderer/VideoRenderers/DX7AllocatorPresenter.cpp b/src/filters/renderer/VideoRenderers/DX7AllocatorPresenter.cpp index e9dfdddfe..752160d6e 100644 --- a/src/filters/renderer/VideoRenderers/DX7AllocatorPresenter.cpp +++ b/src/filters/renderer/VideoRenderers/DX7AllocatorPresenter.cpp @@ -34,7 +34,7 @@ using namespace DSObjects; static HRESULT TextureBlt(IDirect3DDevice7* pD3DDev, IDirectDrawSurface7* pTexture, Vector dst[4], CRect src)
{
- if(!pTexture) {
+ if (!pTexture) {
return E_POINTER;
}
@@ -44,7 +44,7 @@ static HRESULT TextureBlt(IDirect3DDevice7* pD3DDev, IDirectDrawSurface7* pTextu do {
DDSURFACEDESC2 ddsd;
INITDDSTRUCT(ddsd);
- if(FAILED(hr = pTexture->GetSurfaceDesc(&ddsd))) {
+ if (FAILED(hr = pTexture->GetSurfaceDesc(&ddsd))) {
break;
}
@@ -62,7 +62,7 @@ static HRESULT TextureBlt(IDirect3DDevice7* pD3DDev, IDirectDrawSurface7* pTextu {(float)dst[3].x, (float)dst[3].y, (float)dst[3].z, 1.0f/(float)dst[3].z, (float)src.right / w, (float)src.bottom / h},
};
- for(int i = 0; i < countof(pVertices); i++) {
+ for (int i = 0; i < countof(pVertices); i++) {
pVertices[i].x -= 0.5;
pVertices[i].y -= 0.5;
}
@@ -82,7 +82,7 @@ static HRESULT TextureBlt(IDirect3DDevice7* pD3DDev, IDirectDrawSurface7* pTextu //
- if(FAILED(hr = pD3DDev->BeginScene())) {
+ if (FAILED(hr = pD3DDev->BeginScene())) {
break;
}
@@ -96,7 +96,7 @@ static HRESULT TextureBlt(IDirect3DDevice7* pD3DDev, IDirectDrawSurface7* pTextu pD3DDev->SetTexture(0, NULL);
return S_OK;
- } while(0);
+ } while (0);
return E_FAIL;
}
@@ -112,7 +112,7 @@ CDX7AllocatorPresenter::CDX7AllocatorPresenter(HWND hWnd, HRESULT& hr) : CSubPicAllocatorPresenterImpl(hWnd, hr, NULL)
, m_ScreenSize(0, 0)
{
- if(FAILED(hr)) {
+ if (FAILED(hr)) {
return;
}
@@ -128,12 +128,12 @@ CDX7AllocatorPresenter::CDX7AllocatorPresenter(HWND hWnd, HRESULT& hr) return;
}
- if(FAILED(hr = pDirectDrawCreateEx(NULL, (VOID**)&m_pDD, IID_IDirectDraw7, NULL))
+ if (FAILED(hr = pDirectDrawCreateEx(NULL, (VOID**)&m_pDD, IID_IDirectDraw7, NULL))
|| FAILED(hr = m_pDD->SetCooperativeLevel(AfxGetMainWnd()->GetSafeHwnd(), DDSCL_NORMAL))) {
return;
}
- if(!(m_pD3D = m_pDD)) {
+ if (!(m_pD3D = m_pDD)) {
hr = E_NOINTERFACE;
return;
}
@@ -153,7 +153,7 @@ HRESULT CDX7AllocatorPresenter::CreateDevice() DDSURFACEDESC2 ddsd;
INITDDSTRUCT(ddsd);
- if(FAILED(m_pDD->GetDisplayMode(&ddsd)) ||
+ if (FAILED(m_pDD->GetDisplayMode(&ddsd)) ||
ddsd.ddpfPixelFormat.dwRGBBitCount <= 8) {
return DDERR_INVALIDMODE;
}
@@ -167,12 +167,12 @@ HRESULT CDX7AllocatorPresenter::CreateDevice() INITDDSTRUCT(ddsd);
ddsd.dwFlags = DDSD_CAPS;
ddsd.ddsCaps.dwCaps = DDSCAPS_PRIMARYSURFACE;
- if(FAILED(hr = m_pDD->CreateSurface(&ddsd, &m_pPrimary, NULL))) {
+ if (FAILED(hr = m_pDD->CreateSurface(&ddsd, &m_pPrimary, NULL))) {
return hr;
}
CComPtr<IDirectDrawClipper> pcClipper;
- if(FAILED(hr = m_pDD->CreateClipper(0, &pcClipper, NULL))) {
+ if (FAILED(hr = m_pDD->CreateClipper(0, &pcClipper, NULL))) {
return hr;
}
pcClipper->SetHWnd(0, m_hWnd);
@@ -185,12 +185,12 @@ HRESULT CDX7AllocatorPresenter::CreateDevice() ddsd.ddsCaps.dwCaps = /*DDSCAPS_OFFSCREENPLAIN |*/ DDSCAPS_VIDEOMEMORY | DDSCAPS_3DDEVICE;
ddsd.dwWidth = m_ScreenSize.cx;
ddsd.dwHeight = m_ScreenSize.cy;
- if(FAILED(hr = m_pDD->CreateSurface(&ddsd, &m_pBackBuffer, NULL))) {
+ if (FAILED(hr = m_pDD->CreateSurface(&ddsd, &m_pBackBuffer, NULL))) {
return hr;
}
pcClipper = NULL;
- if(FAILED(hr = m_pDD->CreateClipper(0, &pcClipper, NULL))) {
+ if (FAILED(hr = m_pDD->CreateClipper(0, &pcClipper, NULL))) {
return hr;
}
BYTE rgnDataBuffer[1024];
@@ -202,19 +202,19 @@ HRESULT CDX7AllocatorPresenter::CreateDevice() // m_pD3DDev
- if(FAILED(hr = m_pD3D->CreateDevice(IID_IDirect3DHALDevice, m_pBackBuffer, &m_pD3DDev))) { // this seems to fail if the desktop size is too large (width or height >2048)
+ if (FAILED(hr = m_pD3D->CreateDevice(IID_IDirect3DHALDevice, m_pBackBuffer, &m_pD3DDev))) { // this seems to fail if the desktop size is too large (width or height >2048)
return hr;
}
//
CComPtr<ISubPicProvider> pSubPicProvider;
- if(m_pSubPicQueue) {
+ if (m_pSubPicQueue) {
m_pSubPicQueue->GetSubPicProvider(&pSubPicProvider);
}
CSize size;
- switch(GetRenderersSettings().nSPCMaxRes) {
+ switch (GetRenderersSettings().nSPCMaxRes) {
case 0:
default:
size = m_ScreenSize;
@@ -248,11 +248,11 @@ HRESULT CDX7AllocatorPresenter::CreateDevice() break;
}
- if(m_pAllocator) {
+ if (m_pAllocator) {
m_pAllocator->ChangeDevice(m_pD3DDev);
} else {
m_pAllocator = DNew CDX7SubPicAllocator(m_pD3DDev, size, GetRenderersSettings().fSPCPow2Tex);
- if(!m_pAllocator || FAILED(hr)) {
+ if (!m_pAllocator || FAILED(hr)) {
return E_FAIL;
}
}
@@ -261,11 +261,11 @@ HRESULT CDX7AllocatorPresenter::CreateDevice() m_pSubPicQueue = GetRenderersSettings().nSPCSize > 0
? (ISubPicQueue*)DNew CSubPicQueue(GetRenderersSettings().nSPCSize, !GetRenderersSettings().fSPCAllowAnimationWhenBuffering, m_pAllocator, &hr)
: (ISubPicQueue*)DNew CSubPicQueueNoThread(m_pAllocator, &hr);
- if(!m_pSubPicQueue || FAILED(hr)) {
+ if (!m_pSubPicQueue || FAILED(hr)) {
return E_FAIL;
}
- if(pSubPicProvider) {
+ if (pSubPicProvider) {
m_pSubPicQueue->SetSubPicProvider(pSubPicProvider);
}
@@ -294,18 +294,18 @@ HRESULT CDX7AllocatorPresenter::AllocSurfaces() ddsd.ddpfPixelFormat.dwGBitMask = 0x0000FF00;
ddsd.ddpfPixelFormat.dwBBitMask = 0x000000FF;
- if(s.iAPSurfaceUsage == VIDRNDT_AP_TEXTURE2D || s.iAPSurfaceUsage == VIDRNDT_AP_TEXTURE3D) {
+ if (s.iAPSurfaceUsage == VIDRNDT_AP_TEXTURE2D || s.iAPSurfaceUsage == VIDRNDT_AP_TEXTURE3D) {
ddsd.ddsCaps.dwCaps |= DDSCAPS_TEXTURE;
// ddsd.ddpfPixelFormat.dwFlags |= DDPF_ALPHAPIXELS;
// ddsd.ddpfPixelFormat.dwRGBAlphaBitMask = 0xFF000000;
}
HRESULT hr = m_pDD->CreateSurface(&ddsd, &m_pVideoSurface, NULL);
- if(FAILED(hr)) {
+ if (FAILED(hr)) {
// FIXME: eh, dx9 has no problem creating a 32bpp surface under a 16bpp desktop, but dx7 fails here (textures are ok)
DDSURFACEDESC2 ddsd2;
INITDDSTRUCT(ddsd2);
- if(!(s.iAPSurfaceUsage == VIDRNDT_AP_TEXTURE2D || s.iAPSurfaceUsage == VIDRNDT_AP_TEXTURE3D)
+ if (!(s.iAPSurfaceUsage == VIDRNDT_AP_TEXTURE2D || s.iAPSurfaceUsage == VIDRNDT_AP_TEXTURE3D)
&& SUCCEEDED(m_pDD->GetDisplayMode(&ddsd2))
&& ddsd2.ddpfPixelFormat.dwRGBBitCount == 16) {
ddsd.ddpfPixelFormat.dwRGBBitCount = 16;
@@ -315,12 +315,12 @@ HRESULT CDX7AllocatorPresenter::AllocSurfaces() hr = m_pDD->CreateSurface(&ddsd, &m_pVideoSurface, NULL);
}
- if(FAILED(hr)) {
+ if (FAILED(hr)) {
return hr;
}
}
- if(s.iAPSurfaceUsage == VIDRNDT_AP_TEXTURE3D) {
+ if (s.iAPSurfaceUsage == VIDRNDT_AP_TEXTURE3D) {
m_pVideoTexture = m_pVideoSurface;
}
@@ -356,7 +356,7 @@ STDMETHODIMP_(bool) CDX7AllocatorPresenter::Paint(bool fAll) CAutoLock cAutoLock(this);
- if(m_WindowRect.right <= m_WindowRect.left || m_WindowRect.bottom <= m_WindowRect.top
+ if (m_WindowRect.right <= m_WindowRect.left || m_WindowRect.bottom <= m_WindowRect.top
|| m_NativeVideoSize.cx <= 0 || m_NativeVideoSize.cy <= 0
|| !m_pPrimary || !m_pBackBuffer || !m_pVideoSurface) {
return false;
@@ -371,7 +371,7 @@ STDMETHODIMP_(bool) CDX7AllocatorPresenter::Paint(bool fAll) CRect rDstPri(m_WindowRect);
MapWindowRect(m_hWnd, HWND_DESKTOP, &rDstPri);
- if(fAll) {
+ if (fAll) {
// clear the backbuffer
CRect rl(0, 0, rDstVid.left, rSrcPri.bottom);
@@ -386,8 +386,8 @@ STDMETHODIMP_(bool) CDX7AllocatorPresenter::Paint(bool fAll) // paint the video on the backbuffer
- if(!rDstVid.IsRectEmpty()) {
- if(m_pVideoTexture) {
+ if (!rDstVid.IsRectEmpty()) {
+ if (m_pVideoTexture) {
Vector v[4];
Transform(rDstVid, v);
hr = TextureBlt(m_pD3DDev, m_pVideoTexture, v, rSrcVid);
@@ -409,7 +409,7 @@ STDMETHODIMP_(bool) CDX7AllocatorPresenter::Paint(bool fAll) hr = m_pPrimary->Blt(rDstPri, m_pBackBuffer, rSrcPri, DDBLT_WAIT, NULL);
- if(hr == DDERR_SURFACELOST) {
+ if (hr == DDERR_SURFACELOST) {
m_bPendingResetDevice = true;
SendResetRequest();
return false;
@@ -430,7 +430,7 @@ STDMETHODIMP_(bool) CDX7AllocatorPresenter::ResetDevice() {
HRESULT hr;
DeleteSurfaces();
- if(FAILED(hr = CreateDevice()) || FAILED(hr = AllocSurfaces())) {
+ if (FAILED(hr = CreateDevice()) || FAILED(hr = AllocSurfaces())) {
//DDERR_UNSUPPORTEDMODE - 0x8876024e
TRACE("ResetDevice failed: 0x%08x\n", (LONG)hr);
m_bDeviceResetRequested = false;
@@ -455,26 +455,26 @@ STDMETHODIMP CDX7AllocatorPresenter::GetDIB(BYTE* lpDib, DWORD* size) DDSURFACEDESC2 ddsd;
INITDDSTRUCT(ddsd);
- if(FAILED(m_pVideoSurface->GetSurfaceDesc(&ddsd))) {
+ if (FAILED(m_pVideoSurface->GetSurfaceDesc(&ddsd))) {
return E_FAIL;
}
- if(ddsd.ddpfPixelFormat.dwRGBBitCount != 16 && ddsd.ddpfPixelFormat.dwRGBBitCount != 32) {
+ if (ddsd.ddpfPixelFormat.dwRGBBitCount != 16 && ddsd.ddpfPixelFormat.dwRGBBitCount != 32) {
return E_FAIL;
}
DWORD required = sizeof(BITMAPINFOHEADER) + (ddsd.dwWidth*ddsd.dwHeight*32>>3);
- if(!lpDib) {
+ if (!lpDib) {
*size = required;
return S_OK;
}
- if(*size < required) {
+ if (*size < required) {
return E_OUTOFMEMORY;
}
*size = required;
INITDDSTRUCT(ddsd);
- if(FAILED(hr = m_pVideoSurface->Lock(NULL, &ddsd, DDLOCK_WAIT|DDLOCK_SURFACEMEMORYPTR|DDLOCK_READONLY|DDLOCK_NOSYSLOCK, NULL))) {
+ if (FAILED(hr = m_pVideoSurface->Lock(NULL, &ddsd, DDLOCK_WAIT|DDLOCK_SURFACEMEMORYPTR|DDLOCK_READONLY|DDLOCK_NOSYSLOCK, NULL))) {
// TODO
return hr;
}
diff --git a/src/filters/renderer/VideoRenderers/DX9AllocatorPresenter.cpp b/src/filters/renderer/VideoRenderers/DX9AllocatorPresenter.cpp index 192c42406..f4c5a664b 100644 --- a/src/filters/renderer/VideoRenderers/DX9AllocatorPresenter.cpp +++ b/src/filters/renderer/VideoRenderers/DX9AllocatorPresenter.cpp @@ -74,7 +74,7 @@ CDX9AllocatorPresenter::CDX9AllocatorPresenter(HWND hWnd, bool bFullscreen, HRES {
HINSTANCE hDll;
- if(FAILED(hr)) {
+ if (FAILED(hr)) {
_Error += L"ISubPicAllocatorPresenterImpl failed\n";
return;
}
@@ -85,7 +85,7 @@ CDX9AllocatorPresenter::CDX9AllocatorPresenter(HWND hWnd, bool bFullscreen, HRES m_pD3DXCreateFont = NULL;
m_pD3DXCreateSprite = NULL;
hDll = GetRenderersData()->GetD3X9Dll();
- if(hDll) {
+ if (hDll) {
(FARPROC&)m_pD3DXLoadSurfaceFromMemory = GetProcAddress(hDll, "D3DXLoadSurfaceFromMemory");
(FARPROC&)m_pD3DXLoadSurfaceFromSurface = GetProcAddress(hDll, "D3DXLoadSurfaceFromSurface");
(FARPROC&)m_pD3DXCreateLine = GetProcAddress(hDll, "D3DXCreateLine");
@@ -115,13 +115,13 @@ CDX9AllocatorPresenter::CDX9AllocatorPresenter(HWND hWnd, bool bFullscreen, HRES if (m_pDirect3DCreate9Ex) {
m_pDirect3DCreate9Ex(D3D_SDK_VERSION, &m_pD3DEx);
- if(!m_pD3DEx) {
+ if (!m_pD3DEx) {
m_pDirect3DCreate9Ex(D3D9b_SDK_VERSION, &m_pD3DEx);
}
}
- if(!m_pD3DEx) {
+ if (!m_pD3DEx) {
m_pD3D.Attach(Direct3DCreate9(D3D_SDK_VERSION));
- if(!m_pD3D) {
+ if (!m_pD3D) {
m_pD3D.Attach(Direct3DCreate9(D3D9b_SDK_VERSION));
}
} else {
@@ -537,8 +537,8 @@ void CDX9AllocatorPresenter::VSyncThread() m_DetectedRefreshTime = ThisValue;
m_DetectedRefreshTimePrim = 0;
}
- if(_isnan(m_DetectedRefreshTime)) {m_DetectedRefreshTime = 0.0;}
- if(_isnan(m_DetectedRefreshTimePrim)) {m_DetectedRefreshTimePrim = 0.0;}
+ if (_isnan(m_DetectedRefreshTime)) {m_DetectedRefreshTime = 0.0;}
+ if (_isnan(m_DetectedRefreshTimePrim)) {m_DetectedRefreshTimePrim = 0.0;}
ModerateFloat(m_DetectedRefreshTime, ThisValue, m_DetectedRefreshTimePrim, 1.5);
if (m_DetectedRefreshTime > 0.0) {
@@ -709,7 +709,7 @@ HRESULT CDX9AllocatorPresenter::CreateDevice(CString &_Error) CleanupRenderingEngine();
- if(!m_pD3D) {
+ if (!m_pD3D) {
_Error += L"Failed to create D3D9\n";
return E_UNEXPECTED;
}
@@ -792,7 +792,7 @@ HRESULT CDX9AllocatorPresenter::CreateDevice(CString &_Error) } else if (m_bForceInputHighColorResolution || m_bHighColorResolution) {
m_SurfaceType = D3DFMT_A2R10G10B10;
} else {
- if(m_nPCIVendor == PCIV_ATI)
+ if (m_nPCIVendor == PCIV_ATI)
m_SurfaceType = D3DFMT_X8R8G8B8;
else
m_SurfaceType = D3DFMT_A8R8G8B8;
@@ -808,7 +808,7 @@ HRESULT CDX9AllocatorPresenter::CreateDevice(CString &_Error) if (m_bHighColorResolution) {
pp.BackBufferFormat = D3DFMT_A2R10G10B10;
} else {
- pp.BackBufferFormat = D3DFMT_X8R8G8B8;
+ pp.BackBufferFormat = D3DFMT_X8R8G8B8;
}
pp.Windowed = false;
pp.BackBufferCount = 3;
@@ -909,7 +909,7 @@ HRESULT CDX9AllocatorPresenter::CreateDevice(CString &_Error) m_BackbufferType = pp.BackBufferFormat;
}
- while(hr == D3DERR_DEVICELOST) {
+ while (hr == D3DERR_DEVICELOST) {
TRACE("D3DERR_DEVICELOST. Trying to Reset.\n");
hr = m_pD3DDev->TestCooperativeLevel();
}
@@ -927,7 +927,7 @@ HRESULT CDX9AllocatorPresenter::CreateDevice(CString &_Error) m_pD3DDevEx->SetGPUThreadPriority(7);
}
- if(FAILED(hr)) {
+ if (FAILED(hr)) {
_Error += L"CreateDevice failed\n";
CStringW str;
str.Format(L"Error code: 0x%X\n", hr);
@@ -944,12 +944,12 @@ HRESULT CDX9AllocatorPresenter::CreateDevice(CString &_Error) InitRenderingEngine();
CComPtr<ISubPicProvider> pSubPicProvider;
- if(m_pSubPicQueue) {
+ if (m_pSubPicQueue) {
m_pSubPicQueue->GetSubPicProvider(&pSubPicProvider);
}
CSize size;
- switch(GetRenderersSettings().nSPCMaxRes) {
+ switch (GetRenderersSettings().nSPCMaxRes) {
case 0:
default:
size = m_ScreenSize;
@@ -983,11 +983,11 @@ HRESULT CDX9AllocatorPresenter::CreateDevice(CString &_Error) break;
}
- if(m_pAllocator) {
+ if (m_pAllocator) {
m_pAllocator->ChangeDevice(m_pD3DDev);
} else {
m_pAllocator = DNew CDX9SubPicAllocator(m_pD3DDev, size, GetRenderersSettings().fSPCPow2Tex, false);
- if(!m_pAllocator) {
+ if (!m_pAllocator) {
_Error += L"CDX9SubPicAllocator failed\n";
return E_FAIL;
@@ -998,13 +998,13 @@ HRESULT CDX9AllocatorPresenter::CreateDevice(CString &_Error) m_pSubPicQueue = GetRenderersSettings().nSPCSize > 0
? (ISubPicQueue*)DNew CSubPicQueue(GetRenderersSettings().nSPCSize, !GetRenderersSettings().fSPCAllowAnimationWhenBuffering, m_pAllocator, &hr)
: (ISubPicQueue*)DNew CSubPicQueueNoThread(m_pAllocator, &hr);
- if(!m_pSubPicQueue || FAILED(hr)) {
+ if (!m_pSubPicQueue || FAILED(hr)) {
_Error += L"m_pSubPicQueue failed\n";
return E_FAIL;
}
- if(pSubPicProvider) {
+ if (pSubPicProvider) {
m_pSubPicQueue->SetSubPicProvider(pSubPicProvider);
}
@@ -1066,7 +1066,7 @@ void CDX9AllocatorPresenter::DeleteSurfaces() UINT CDX9AllocatorPresenter::GetAdapter(IDirect3D9* pD3D, bool bGetAdapter)
{
- if(m_hWnd == NULL || pD3D == NULL) {
+ if (m_hWnd == NULL || pD3D == NULL) {
return D3DADAPTER_DEFAULT;
}
@@ -1074,11 +1074,11 @@ UINT CDX9AllocatorPresenter::GetAdapter(IDirect3D9* pD3D, bool bGetAdapter) m_nPCIVendor = 0;
CRenderersSettings& s = GetRenderersSettings();
- if(bGetAdapter && (pD3D->GetAdapterCount()>1) && (s.D3D9RenderDevice != _T(""))) {
+ if (bGetAdapter && (pD3D->GetAdapterCount()>1) && (s.D3D9RenderDevice != _T(""))) {
TCHAR strGUID[50];
D3DADAPTER_IDENTIFIER9 adapterIdentifier;
- for(UINT adp = 0, num_adp = pD3D->GetAdapterCount(); adp < num_adp; ++adp) {
+ for (UINT adp = 0, num_adp = pD3D->GetAdapterCount(); adp < num_adp; ++adp) {
if (pD3D->GetAdapterIdentifier(adp, 0, &adapterIdentifier) == S_OK) {
if ((::StringFromGUID2(adapterIdentifier.DeviceIdentifier, strGUID, 50) > 0) && (s.D3D9RenderDevice == strGUID)) {
m_D3D9Device = adapterIdentifier.Description;
@@ -1090,14 +1090,14 @@ UINT CDX9AllocatorPresenter::GetAdapter(IDirect3D9* pD3D, bool bGetAdapter) }
HMONITOR hMonitor = MonitorFromWindow(m_hWnd, MONITOR_DEFAULTTONEAREST);
- if(hMonitor == NULL) {
+ if (hMonitor == NULL) {
return D3DADAPTER_DEFAULT;
}
- for(UINT adp = 0, num_adp = pD3D->GetAdapterCount(); adp < num_adp; ++adp) {
+ for (UINT adp = 0, num_adp = pD3D->GetAdapterCount(); adp < num_adp; ++adp) {
HMONITOR hAdpMon = pD3D->GetAdapterMonitor(adp);
- if(hAdpMon == hMonitor) {
- if(bGetAdapter) {
+ if (hAdpMon == hMonitor) {
+ if (bGetAdapter) {
D3DADAPTER_IDENTIFIER9 adapterIdentifier;
if (pD3D->GetAdapterIdentifier(adp, 0, &adapterIdentifier) == S_OK) {
m_D3D9Device = adapterIdentifier.Description;
@@ -1185,7 +1185,7 @@ bool CDX9AllocatorPresenter::GetVBlank(int &_ScanLine, int &_bInVBlank, bool _bM int ScanLine = 0;
_ScanLine = 0;
_bInVBlank = 0;
-
+
if (m_pDirectDraw) {
DWORD ScanLineGet = 0;
m_pDirectDraw->GetScanLine(&ScanLineGet);
@@ -1511,7 +1511,7 @@ STDMETHODIMP_(bool) CDX9AllocatorPresenter::Paint(bool fAll) LONGLONG StartPaint = pApp->GetPerfCounter();
CAutoLock cRenderLock(&m_RenderLock);
- if(m_WindowRect.right <= m_WindowRect.left || m_WindowRect.bottom <= m_WindowRect.top
+ if (m_WindowRect.right <= m_WindowRect.left || m_WindowRect.bottom <= m_WindowRect.top
|| m_NativeVideoSize.cx <= 0 || m_NativeVideoSize.cy <= 0
|| !m_pVideoSurface) {
if (m_OrderedPaint) {
@@ -1569,7 +1569,7 @@ STDMETHODIMP_(bool) CDX9AllocatorPresenter::Paint(bool fAll) m_pOSDTexture = NULL;
m_pOSDSurface = NULL;
if ((m_VMR9AlphaBitmap.dwFlags & VMRBITMAP_DISABLE) == 0 && (BYTE *)m_VMR9AlphaBitmapData) {
- if( (m_pD3DXLoadSurfaceFromMemory != NULL) &&
+ if ( (m_pD3DXLoadSurfaceFromMemory != NULL) &&
SUCCEEDED(hr = m_pD3DDev->CreateTexture(rcSrc.Width(), rcSrc.Height(), 1,
D3DUSAGE_RENDERTARGET, D3DFMT_A8R8G8B8,
D3DPOOL_DEFAULT, &m_pOSDTexture, NULL)) ) {
@@ -1633,7 +1633,7 @@ STDMETHODIMP_(bool) CDX9AllocatorPresenter::Paint(bool fAll) BOOL Data;
//Sleep(5);
LONGLONG FlushStartTime = pApp->GetPerfCounter();
- while(S_FALSE == pEventQuery->GetData( &Data, sizeof(Data), D3DGETDATA_FLUSH )) {
+ while (S_FALSE == pEventQuery->GetData( &Data, sizeof(Data), D3DGETDATA_FLUSH )) {
if (!s.m_RenderSettings.iVMRFlushGPUWait) {
break;
}
@@ -1766,7 +1766,7 @@ STDMETHODIMP_(bool) CDX9AllocatorPresenter::Paint(bool fAll) if (!m_bPendingResetDevice) {
bool fResetDevice = false;
- if(hr == D3DERR_DEVICELOST && m_pD3DDev->TestCooperativeLevel() == D3DERR_DEVICENOTRESET) {
+ if (hr == D3DERR_DEVICELOST && m_pD3DDev->TestCooperativeLevel() == D3DERR_DEVICENOTRESET) {
TRACE("Reset Device: D3D Device Lost\n");
fResetDevice = true;
}
@@ -1795,17 +1795,17 @@ STDMETHODIMP_(bool) CDX9AllocatorPresenter::Paint(bool fAll) }
}
- if(s.fResetDevice) {
+ if (s.fResetDevice) {
LONGLONG time = GetRenderersData()->GetPerfCounter();
if (time > m_LastAdapterCheck + 20000000) { // check every 2 sec.
m_LastAdapterCheck = time;
#ifdef _DEBUG
D3DDEVICE_CREATION_PARAMETERS Parameters;
- if(SUCCEEDED(m_pD3DDev->GetCreationParameters(&Parameters))) {
+ if (SUCCEEDED(m_pD3DDev->GetCreationParameters(&Parameters))) {
ASSERT(Parameters.AdapterOrdinal == m_CurrentAdapter);
}
#endif
- if(m_CurrentAdapter != GetAdapter(m_pD3D)) {
+ if (m_CurrentAdapter != GetAdapter(m_pD3D)) {
TRACE("Reset Device: D3D adapter changed\n");
fResetDevice = true;
}
@@ -1817,7 +1817,7 @@ STDMETHODIMP_(bool) CDX9AllocatorPresenter::Paint(bool fAll) }
}
- if(fResetDevice) {
+ if (fResetDevice) {
m_bPendingResetDevice = true;
SendResetRequest();
}
@@ -1863,7 +1863,7 @@ STDMETHODIMP_(bool) CDX9AllocatorPresenter::ResetDevice() TRACE("ResetDevice\n");
_ASSERT(m_MainThreadId == GetCurrentThreadId());
StopWorkerThreads();
-
+
// In VMR-9 deleting the surfaces before we are told to is bad !
// Can't comment out this because CDX9AllocatorPresenter is used by EVR Custom
// Why is EVR using a presenter for DX9 anyway ?!
@@ -1876,7 +1876,7 @@ STDMETHODIMP_(bool) CDX9AllocatorPresenter::ResetDevice() // In VMR-9 'AllocSurfaces' call is redundant afaik because
// 'CreateDevice' calls 'm_pIVMRSurfAllocNotify->ChangeD3DDevice' which in turn calls
// 'CVMR9AllocatorPresenter::InitializeDevice' which calls 'AllocSurfaces'
- if(FAILED(hr = CreateDevice(Error)) || FAILED(hr = AllocSurfaces())) {
+ if (FAILED(hr = CreateDevice(Error)) || FAILED(hr = AllocSurfaces())) {
// TODO: We should probably pause player
#ifdef _DEBUG
Error += GetWindowsErrorMessage(hr, NULL);
@@ -2209,14 +2209,14 @@ void CDX9AllocatorPresenter::DrawStats() strText.Format(L"DirectX SDK : %d", GetRenderersData()->GetDXSdkRelease());
DrawText(rc, strText, 1);
OffsetRect (&rc, 0, TextHeight);
-
- if(m_D3D9Device != _T("")) {
+
+ if (m_D3D9Device != _T("")) {
strText = "Render device: " + m_D3D9Device;
DrawText(rc, strText, 1);
OffsetRect (&rc, 0, TextHeight);
}
- if(m_Decoder != _T("")) {
+ if (m_Decoder != _T("")) {
strText = "Decoder : " + m_Decoder;
DrawText(rc, strText, 1);
OffsetRect (&rc, 0, TextHeight);
@@ -2310,34 +2310,38 @@ STDMETHODIMP CDX9AllocatorPresenter::GetDIB(BYTE* lpDib, DWORD* size) m_pVideoSurface[m_nCurSurface]->GetDesc(&desc);
DWORD required = sizeof(BITMAPINFOHEADER) + (desc.Width * desc.Height * 32 >> 3);
- if(!lpDib) {
+ if (!lpDib) {
*size = required;
return S_OK;
}
- if(*size < required) {
+ if (*size < required) {
return E_OUTOFMEMORY;
}
*size = required;
D3DLOCKED_RECT r;
CComPtr<IDirect3DSurface9> pSurface;
- if(m_bFullFloatingPointProcessing || m_bHalfFloatingPointProcessing || m_bHighColorResolution) {
+ if (m_bFullFloatingPointProcessing || m_bHalfFloatingPointProcessing || m_bHighColorResolution) {
CComPtr<IDirect3DSurface9> fSurface = m_pVideoSurface[m_nCurSurface];
- if(FAILED(hr = m_pD3DDev->CreateOffscreenPlainSurface(desc.Width, desc.Height, D3DFMT_A8R8G8B8, D3DPOOL_DEFAULT, &fSurface, NULL))
- || FAILED(hr = m_pD3DXLoadSurfaceFromSurface(fSurface, NULL, NULL, m_pVideoSurface[m_nCurSurface], NULL, NULL, D3DX_DEFAULT, 0))) return hr;
+ if (FAILED(hr = m_pD3DDev->CreateOffscreenPlainSurface(desc.Width, desc.Height, D3DFMT_A8R8G8B8, D3DPOOL_DEFAULT, &fSurface, NULL))
+ || FAILED(hr = m_pD3DXLoadSurfaceFromSurface(fSurface, NULL, NULL, m_pVideoSurface[m_nCurSurface], NULL, NULL, D3DX_DEFAULT, 0))) return hr;
pSurface = fSurface;
- if(FAILED(hr = pSurface->LockRect(&r, NULL, D3DLOCK_READONLY))) {
+ if (FAILED(hr = pSurface->LockRect(&r, NULL, D3DLOCK_READONLY))) {
pSurface = NULL;
- if(FAILED(hr = m_pD3DDev->CreateOffscreenPlainSurface(desc.Width, desc.Height, D3DFMT_A8R8G8B8, D3DPOOL_SYSTEMMEM, &pSurface, NULL))
- || FAILED(hr = m_pD3DDev->GetRenderTargetData(fSurface, pSurface))
- || FAILED(hr = pSurface->LockRect(&r, NULL, D3DLOCK_READONLY))) return hr;}}
+ if (FAILED(hr = m_pD3DDev->CreateOffscreenPlainSurface(desc.Width, desc.Height, D3DFMT_A8R8G8B8, D3DPOOL_SYSTEMMEM, &pSurface, NULL))
+ || FAILED(hr = m_pD3DDev->GetRenderTargetData(fSurface, pSurface))
+ || FAILED(hr = pSurface->LockRect(&r, NULL, D3DLOCK_READONLY))) return hr;
+ }
+ }
else {
pSurface = m_pVideoSurface[m_nCurSurface];
- if(FAILED(hr = pSurface->LockRect(&r, NULL, D3DLOCK_READONLY))) {
+ if (FAILED(hr = pSurface->LockRect(&r, NULL, D3DLOCK_READONLY))) {
pSurface = NULL;
- if(FAILED(hr = m_pD3DDev->CreateOffscreenPlainSurface(desc.Width, desc.Height, desc.Format, D3DPOOL_SYSTEMMEM, &pSurface, NULL))
- || FAILED(hr = m_pD3DDev->GetRenderTargetData(m_pVideoSurface[m_nCurSurface], pSurface))
- || FAILED(hr = pSurface->LockRect(&r, NULL, D3DLOCK_READONLY))) return hr;}}
+ if (FAILED(hr = m_pD3DDev->CreateOffscreenPlainSurface(desc.Width, desc.Height, desc.Format, D3DPOOL_SYSTEMMEM, &pSurface, NULL))
+ || FAILED(hr = m_pD3DDev->GetRenderTargetData(m_pVideoSurface[m_nCurSurface], pSurface))
+ || FAILED(hr = pSurface->LockRect(&r, NULL, D3DLOCK_READONLY))) return hr;
+ }
+ }
BITMAPINFOHEADER* bih = (BITMAPINFOHEADER*)lpDib;
memset(bih, 0, sizeof(BITMAPINFOHEADER));
diff --git a/src/filters/renderer/VideoRenderers/DX9RenderingEngine.cpp b/src/filters/renderer/VideoRenderers/DX9RenderingEngine.cpp index dd8e45cff..2cb4aa516 100644 --- a/src/filters/renderer/VideoRenderers/DX9RenderingEngine.cpp +++ b/src/filters/renderer/VideoRenderers/DX9RenderingEngine.cpp @@ -48,16 +48,16 @@ static void AdjustQuad(MYD3DVERTEX<texcoords>* v, double dx, double dy) {
double offset = 0.5;
- for(int i = 0; i < 4; i++) {
+ for (int i = 0; i < 4; i++) {
v[i].x -= offset;
v[i].y -= offset;
- for(int j = 0; j < max(texcoords-1, 1); j++) {
+ for (int j = 0; j < max(texcoords-1, 1); j++) {
v[i].t[j].u -= offset*dx;
v[i].t[j].v -= offset*dy;
}
- if(texcoords > 1) {
+ if (texcoords > 1) {
v[i].t[texcoords-1].u -= offset;
v[i].t[texcoords-1].v -= offset;
}
@@ -67,13 +67,13 @@ static void AdjustQuad(MYD3DVERTEX<texcoords>* v, double dx, double dy) template<int texcoords>
static HRESULT TextureBlt(IDirect3DDevice9* pD3DDev, MYD3DVERTEX<texcoords> v[4], D3DTEXTUREFILTERTYPE filter)
{
- if(!pD3DDev) {
+ if (!pD3DDev) {
return E_POINTER;
}
DWORD FVF = 0;
- switch(texcoords) {
+ switch (texcoords) {
case 1:
FVF = D3DFVF_TEX1;
break;
@@ -113,7 +113,7 @@ static HRESULT TextureBlt(IDirect3DDevice9* pD3DDev, MYD3DVERTEX<texcoords> v[4] hr = pD3DDev->SetRenderState(D3DRS_SCISSORTESTENABLE, FALSE);
hr = pD3DDev->SetRenderState(D3DRS_COLORWRITEENABLE, D3DCOLORWRITEENABLE_ALPHA|D3DCOLORWRITEENABLE_BLUE|D3DCOLORWRITEENABLE_GREEN|D3DCOLORWRITEENABLE_RED);
- for(int i = 0; i < texcoords; i++) {
+ for (int i = 0; i < texcoords; i++) {
hr = pD3DDev->SetSamplerState(i, D3DSAMP_MAGFILTER, filter);
hr = pD3DDev->SetSamplerState(i, D3DSAMP_MINFILTER, filter);
hr = pD3DDev->SetSamplerState(i, D3DSAMP_MIPFILTER, D3DTEXF_NONE);
@@ -134,7 +134,7 @@ static HRESULT TextureBlt(IDirect3DDevice9* pD3DDev, MYD3DVERTEX<texcoords> v[4] //
- for(int i = 0; i < texcoords; i++) {
+ for (int i = 0; i < texcoords; i++) {
pD3DDev->SetTexture(i, NULL);
}
@@ -182,12 +182,12 @@ void CDX9RenderingEngine::CleanupRenderingEngine() CleanupFinalPass();
POSITION pos = m_pCustomScreenSpacePixelShaders.GetHeadPosition();
- while(pos) {
+ while (pos) {
CExternalPixelShader &Shader = m_pCustomScreenSpacePixelShaders.GetNext(pos);
Shader.m_pPixelShader = NULL;
}
pos = m_pCustomPixelShaders.GetHeadPosition();
- while(pos) {
+ while (pos) {
CExternalPixelShader &Shader = m_pCustomPixelShaders.GetNext(pos);
Shader.m_pPixelShader = NULL;
}
@@ -215,10 +215,10 @@ HRESULT CDX9RenderingEngine::CreateVideoSurfaces() int nTexturesNeeded = settings.iAPSurfaceUsage == VIDRNDT_AP_TEXTURE3D ? m_nNbDXSurface : 1;
for (int i = 0; i < nTexturesNeeded; i++) {
- if(FAILED(hr = m_pD3DDev->CreateTexture(
- m_NativeVideoSize.cx, m_NativeVideoSize.cy, 1,
- D3DUSAGE_RENDERTARGET, m_SurfaceType,
- D3DPOOL_DEFAULT, &m_pVideoTexture[i], NULL))) {
+ if (FAILED(hr = m_pD3DDev->CreateTexture(
+ m_NativeVideoSize.cx, m_NativeVideoSize.cy, 1,
+ D3DUSAGE_RENDERTARGET, m_SurfaceType,
+ D3DPOOL_DEFAULT, &m_pVideoTexture[i], NULL))) {
return hr;
}
@@ -361,7 +361,7 @@ HRESULT CDX9RenderingEngine::RenderVideoDrawPath(IDirect3DSurface9* pRenderTarge long stop = clock();
long diff = stop - start;
- if(diff >= 10*60*CLOCKS_PER_SEC) {
+ if (diff >= 10*60*CLOCKS_PER_SEC) {
start = stop; // reset after 10 min (ps float has its limits in both range and accuracy)
}
@@ -389,7 +389,7 @@ HRESULT CDX9RenderingEngine::RenderVideoDrawPath(IDirect3DSurface9* pRenderTarge bool first = true;
POSITION pos = m_pCustomPixelShaders.GetHeadPosition();
- while(pos) {
+ while (pos) {
CComPtr<IDirect3DSurface9> pTemporarySurface;
hr = m_pTemporaryVideoTextures[dest]->GetSurfaceLevel(0, &pTemporarySurface);
hr = m_pD3DDev->SetRenderTarget(0, pTemporarySurface);
@@ -972,44 +972,44 @@ HRESULT CDX9RenderingEngine::InitFinalPass() m_pFinalPixelShader = NULL;
if (!m_pDitherTexture) {
- // Create the dither texture
- hr = m_pD3DDev->CreateTexture(DITHER_MATRIX_SIZE, DITHER_MATRIX_SIZE,
- 1,
- D3DUSAGE_DYNAMIC,
- D3DFMT_A16B16G16R16F,
- D3DPOOL_DEFAULT,
- &m_pDitherTexture,
- NULL);
+ // Create the dither texture
+ hr = m_pD3DDev->CreateTexture(DITHER_MATRIX_SIZE, DITHER_MATRIX_SIZE,
+ 1,
+ D3DUSAGE_DYNAMIC,
+ D3DFMT_A16B16G16R16F,
+ D3DPOOL_DEFAULT,
+ &m_pDitherTexture,
+ NULL);
- if (FAILED(hr)) {
- CleanupFinalPass();
- return hr;
- }
+ if (FAILED(hr)) {
+ CleanupFinalPass();
+ return hr;
+ }
- D3DLOCKED_RECT lockedRect;
- hr = m_pDitherTexture->LockRect(0, &lockedRect, NULL, D3DLOCK_DISCARD);
- if (FAILED(hr)) {
- CleanupFinalPass();
- return hr;
- }
+ D3DLOCKED_RECT lockedRect;
+ hr = m_pDitherTexture->LockRect(0, &lockedRect, NULL, D3DLOCK_DISCARD);
+ if (FAILED(hr)) {
+ CleanupFinalPass();
+ return hr;
+ }
- char* outputRowIterator = static_cast<char*>(lockedRect.pBits);
- for (int y = 0; y < DITHER_MATRIX_SIZE; y++) {
- unsigned short* outputIterator = reinterpret_cast<unsigned short*>(outputRowIterator);
- for (int x = 0; x < DITHER_MATRIX_SIZE; x++) {
- for (int i = 0; i < 4; i++) {
- *outputIterator++ = DITHER_MATRIX[y][x];
+ char* outputRowIterator = static_cast<char*>(lockedRect.pBits);
+ for (int y = 0; y < DITHER_MATRIX_SIZE; y++) {
+ unsigned short* outputIterator = reinterpret_cast<unsigned short*>(outputRowIterator);
+ for (int x = 0; x < DITHER_MATRIX_SIZE; x++) {
+ for (int i = 0; i < 4; i++) {
+ *outputIterator++ = DITHER_MATRIX[y][x];
+ }
}
- }
- outputRowIterator += lockedRect.Pitch;
- }
+ outputRowIterator += lockedRect.Pitch;
+ }
- hr = m_pDitherTexture->UnlockRect(0);
- if (FAILED(hr)) {
- CleanupFinalPass();
- return hr;
- }
+ hr = m_pDitherTexture->UnlockRect(0);
+ if (FAILED(hr)) {
+ CleanupFinalPass();
+ return hr;
+ }
}
// Initialize the color management if necessary
@@ -1382,7 +1382,7 @@ HRESULT CDX9RenderingEngine::FinalPass(IDirect3DTexture9* pTexture) {w, h, 0.5f, 2.0f, 1, 1},
};
- for(int i = 0; i < countof(v); i++) {
+ for (int i = 0; i < countof(v); i++) {
v[i].x -= 0.5;
v[i].y -= 0.5;
}
@@ -1550,7 +1550,7 @@ HRESULT CDX9RenderingEngine::DrawRect(DWORD _Color, DWORD _Alpha, const CRect &_ HRESULT CDX9RenderingEngine::AlphaBlt(RECT* pSrc, RECT* pDst, IDirect3DTexture9* pTexture)
{
- if(!pSrc || !pDst) {
+ if (!pSrc || !pDst) {
return E_POINTER;
}
@@ -1560,7 +1560,7 @@ HRESULT CDX9RenderingEngine::AlphaBlt(RECT* pSrc, RECT* pDst, IDirect3DTexture9* D3DSURFACE_DESC d3dsd;
ZeroMemory(&d3dsd, sizeof(d3dsd));
- if(FAILED(pTexture->GetLevelDesc(0, &d3dsd)) /*|| d3dsd.Type != D3DRTYPE_TEXTURE*/) {
+ if (FAILED(pTexture->GetLevelDesc(0, &d3dsd)) /*|| d3dsd.Type != D3DRTYPE_TEXTURE*/) {
return E_FAIL;
}
@@ -1577,8 +1577,8 @@ HRESULT CDX9RenderingEngine::AlphaBlt(RECT* pSrc, RECT* pDst, IDirect3DTexture9* {(float)dst.left, (float)dst.bottom, 0.5f, 2.0f, (float)src.left / w, (float)src.bottom / h},
{(float)dst.right, (float)dst.bottom, 0.5f, 2.0f, (float)src.right / w, (float)src.bottom / h},
};
-
- for(int i = 0; i < countof(pVertices); i++) {
+
+ for (int i = 0; i < countof(pVertices); i++) {
pVertices[i].x -= 0.5;
pVertices[i].y -= 0.5;
}
diff --git a/src/filters/renderer/VideoRenderers/DX9RenderingEngine.h b/src/filters/renderer/VideoRenderers/DX9RenderingEngine.h index 38ffe2a27..acdae17cb 100644 --- a/src/filters/renderer/VideoRenderers/DX9RenderingEngine.h +++ b/src/filters/renderer/VideoRenderers/DX9RenderingEngine.h @@ -95,7 +95,7 @@ namespace DSObjects CStringA m_SourceTarget;
HRESULT Compile(CPixelShaderCompiler *pCompiler) {
HRESULT hr = pCompiler->CompileShader(m_SourceData, "main", m_SourceTarget, 0, &m_pPixelShader);
- if(FAILED(hr)) {
+ if (FAILED(hr)) {
return hr;
}
diff --git a/src/filters/renderer/VideoRenderers/DXRAllocatorPresenter.cpp b/src/filters/renderer/VideoRenderers/DXRAllocatorPresenter.cpp index da927616e..6547c513b 100644 --- a/src/filters/renderer/VideoRenderers/DXRAllocatorPresenter.cpp +++ b/src/filters/renderer/VideoRenderers/DXRAllocatorPresenter.cpp @@ -37,7 +37,7 @@ CDXRAllocatorPresenter::CDXRAllocatorPresenter(HWND hWnd, HRESULT& hr, CString & : CSubPicAllocatorPresenterImpl(hWnd, hr, &_Error)
, m_ScreenSize(0, 0)
{
- if(FAILED(hr)) {
+ if (FAILED(hr)) {
_Error += L"ISubPicAllocatorPresenterImpl failed\n";
return;
}
@@ -47,7 +47,7 @@ CDXRAllocatorPresenter::CDXRAllocatorPresenter(HWND hWnd, HRESULT& hr, CString & CDXRAllocatorPresenter::~CDXRAllocatorPresenter()
{
- if(m_pSRCB) {
+ if (m_pSRCB) {
// nasty, but we have to let it know about our death somehow
((CSubRenderCallback*)(ISubRenderCallback*)m_pSRCB)->SetDXRAP(NULL);
}
@@ -73,8 +73,8 @@ STDMETHODIMP CDXRAllocatorPresenter::NonDelegatingQueryInterface(REFIID riid, vo return GetInterface((IVMRWindowlessControl*)this, ppv);
*/
- if(riid != IID_IUnknown && m_pDXR) {
- if(SUCCEEDED(m_pDXR->QueryInterface(riid, ppv))) {
+ if (riid != IID_IUnknown && m_pDXR) {
+ if (SUCCEEDED(m_pDXR->QueryInterface(riid, ppv))) {
return S_OK;
}
}
@@ -87,7 +87,7 @@ HRESULT CDXRAllocatorPresenter::SetDevice(IDirect3DDevice9* pD3DDev) CheckPointer(pD3DDev, E_POINTER);
CSize size;
- switch(GetRenderersSettings().nSPCMaxRes) {
+ switch (GetRenderersSettings().nSPCMaxRes) {
case 0:
default:
size = m_ScreenSize;
@@ -121,11 +121,11 @@ HRESULT CDXRAllocatorPresenter::SetDevice(IDirect3DDevice9* pD3DDev) break;
}
- if(m_pAllocator) {
+ if (m_pAllocator) {
m_pAllocator->ChangeDevice(pD3DDev);
} else {
m_pAllocator = DNew CDX9SubPicAllocator(pD3DDev, size, GetRenderersSettings().fSPCPow2Tex, true);
- if(!m_pAllocator) {
+ if (!m_pAllocator) {
return E_FAIL;
}
}
@@ -135,11 +135,11 @@ HRESULT CDXRAllocatorPresenter::SetDevice(IDirect3DDevice9* pD3DDev) m_pSubPicQueue = GetRenderersSettings().nSPCSize > 0
? (ISubPicQueue*)DNew CSubPicQueue(GetRenderersSettings().nSPCSize, !GetRenderersSettings().fSPCAllowAnimationWhenBuffering, m_pAllocator, &hr)
: (ISubPicQueue*)DNew CSubPicQueueNoThread(m_pAllocator, &hr);
- if(!m_pSubPicQueue || FAILED(hr)) {
+ if (!m_pSubPicQueue || FAILED(hr)) {
return E_FAIL;
}
- if(m_SubPicProvider) {
+ if (m_SubPicProvider) {
m_pSubPicQueue->SetSubPicProvider(m_SubPicProvider);
}
@@ -152,7 +152,7 @@ HRESULT CDXRAllocatorPresenter::Render( {
__super::SetPosition(CRect(0, 0, width, height), CRect(left, top, right, bottom)); // needed? should be already set by the player
SetTime(rtStart);
- if(atpf > 0 && m_pSubPicQueue) {
+ if (atpf > 0 && m_pSubPicQueue) {
m_pSubPicQueue->SetFPS(10000000.0 / atpf);
}
AlphaBltSubPic(CSize(width, height));
@@ -165,22 +165,22 @@ STDMETHODIMP CDXRAllocatorPresenter::CreateRenderer(IUnknown** ppRenderer) {
CheckPointer(ppRenderer, E_POINTER);
- if(m_pDXR) {
+ if (m_pDXR) {
return E_UNEXPECTED;
}
m_pDXR.CoCreateInstance(CLSID_DXR, GetOwner());
- if(!m_pDXR) {
+ if (!m_pDXR) {
return E_FAIL;
}
CComQIPtr<ISubRender> pSR = m_pDXR;
- if(!pSR) {
+ if (!pSR) {
m_pDXR = NULL;
return E_FAIL;
}
m_pSRCB = DNew CSubRenderCallback(this);
- if(FAILED(pSR->SetCallback(m_pSRCB))) {
+ if (FAILED(pSR->SetCallback(m_pSRCB))) {
m_pDXR = NULL;
return E_FAIL;
}
@@ -198,12 +198,12 @@ STDMETHODIMP CDXRAllocatorPresenter::CreateRenderer(IUnknown** ppRenderer) STDMETHODIMP_(void) CDXRAllocatorPresenter::SetPosition(RECT w, RECT v)
{
- if(CComQIPtr<IBasicVideo> pBV = m_pDXR) {
+ if (CComQIPtr<IBasicVideo> pBV = m_pDXR) {
pBV->SetDefaultSourcePosition();
pBV->SetDestinationPosition(v.left, v.top, v.right - v.left, v.bottom - v.top);
}
- if(CComQIPtr<IVideoWindow> pVW = m_pDXR) {
+ if (CComQIPtr<IVideoWindow> pVW = m_pDXR) {
pVW->SetWindowPosition(w.left, w.top, w.right - w.left, w.bottom - w.top);
}
}
@@ -212,12 +212,12 @@ STDMETHODIMP_(SIZE) CDXRAllocatorPresenter::GetVideoSize(bool fCorrectAR) {
SIZE size = {0, 0};
- if(!fCorrectAR) {
- if(CComQIPtr<IBasicVideo> pBV = m_pDXR) {
+ if (!fCorrectAR) {
+ if (CComQIPtr<IBasicVideo> pBV = m_pDXR) {
pBV->GetVideoSize(&size.cx, &size.cy);
}
} else {
- if(CComQIPtr<IBasicVideo2> pBV2 = m_pDXR) {
+ if (CComQIPtr<IBasicVideo2> pBV2 = m_pDXR) {
pBV2->GetPreferredAspectRatio(&size.cx, &size.cy);
}
}
@@ -233,7 +233,7 @@ STDMETHODIMP_(bool) CDXRAllocatorPresenter::Paint(bool fAll) STDMETHODIMP CDXRAllocatorPresenter::GetDIB(BYTE* lpDib, DWORD* size)
{
HRESULT hr = E_NOTIMPL;
- if(CComQIPtr<IBasicVideo> pBV = m_pDXR) {
+ if (CComQIPtr<IBasicVideo> pBV = m_pDXR) {
hr = pBV->GetCurrentImage((long*)size, (long*)lpDib);
}
return hr;
diff --git a/src/filters/renderer/VideoRenderers/EVRAllocatorPresenter.cpp b/src/filters/renderer/VideoRenderers/EVRAllocatorPresenter.cpp index 1f126b4bc..4634b9db1 100644 --- a/src/filters/renderer/VideoRenderers/EVRAllocatorPresenter.cpp +++ b/src/filters/renderer/VideoRenderers/EVRAllocatorPresenter.cpp @@ -297,18 +297,18 @@ STDMETHODIMP CEVRAllocatorPresenter::CreateRenderer(IUnknown** ppRenderer) CComPtr<IMFVideoRenderer> pMFVR;
CComQIPtr<IMFGetService, &__uuidof(IMFGetService)> pMFGS = pBF;
CComQIPtr<IEVRFilterConfig> pConfig = pBF;
- if(SUCCEEDED(hr)) {
- if(FAILED(pConfig->SetNumberOfStreams(3))) { // TODO - maybe need other number of input stream ...
+ if (SUCCEEDED(hr)) {
+ if (FAILED(pConfig->SetNumberOfStreams(3))) { // TODO - maybe need other number of input stream ...
break;
}
}
hr = pMFGS->GetService (MR_VIDEO_RENDER_SERVICE, IID_IMFVideoRenderer, (void**)&pMFVR);
- if(SUCCEEDED(hr)) {
+ if (SUCCEEDED(hr)) {
hr = QueryInterface (__uuidof(IMFVideoPresenter), (void**)&pVP);
}
- if(SUCCEEDED(hr)) {
+ if (SUCCEEDED(hr)) {
hr = pMFVR->InitializeRenderer (NULL, pVP);
}
@@ -322,7 +322,7 @@ STDMETHODIMP CEVRAllocatorPresenter::CreateRenderer(IUnknown** ppRenderer) m_fUseInternalTimer = false;
#endif
- if(FAILED(hr)) {
+ if (FAILED(hr)) {
*ppRenderer = NULL;
} else {
*ppRenderer = pBF.Detach();
@@ -341,27 +341,27 @@ STDMETHODIMP_(bool) CEVRAllocatorPresenter::Paint(bool fAll) STDMETHODIMP CEVRAllocatorPresenter::NonDelegatingQueryInterface(REFIID riid, void** ppv)
{
HRESULT hr;
- if(riid == __uuidof(IMFClockStateSink)) {
+ if (riid == __uuidof(IMFClockStateSink)) {
hr = GetInterface((IMFClockStateSink*)this, ppv);
- } else if(riid == __uuidof(IMFVideoPresenter)) {
+ } else if (riid == __uuidof(IMFVideoPresenter)) {
hr = GetInterface((IMFVideoPresenter*)this, ppv);
- } else if(riid == __uuidof(IMFTopologyServiceLookupClient)) {
+ } else if (riid == __uuidof(IMFTopologyServiceLookupClient)) {
hr = GetInterface((IMFTopologyServiceLookupClient*)this, ppv);
- } else if(riid == __uuidof(IMFVideoDeviceID)) {
+ } else if (riid == __uuidof(IMFVideoDeviceID)) {
hr = GetInterface((IMFVideoDeviceID*)this, ppv);
- } else if(riid == __uuidof(IMFGetService)) {
+ } else if (riid == __uuidof(IMFGetService)) {
hr = GetInterface((IMFGetService*)this, ppv);
- } else if(riid == __uuidof(IMFAsyncCallback)) {
+ } else if (riid == __uuidof(IMFAsyncCallback)) {
hr = GetInterface((IMFAsyncCallback*)this, ppv);
- } else if(riid == __uuidof(IMFVideoDisplayControl)) {
+ } else if (riid == __uuidof(IMFVideoDisplayControl)) {
hr = GetInterface((IMFVideoDisplayControl*)this, ppv);
- } else if(riid == __uuidof(IEVRTrustedVideoPlugin)) {
+ } else if (riid == __uuidof(IEVRTrustedVideoPlugin)) {
hr = GetInterface((IEVRTrustedVideoPlugin*)this, ppv);
- } else if(riid == IID_IQualProp) {
+ } else if (riid == IID_IQualProp) {
hr = GetInterface((IQualProp*)this, ppv);
- } else if(riid == __uuidof(IMFRateSupport)) {
+ } else if (riid == __uuidof(IMFRateSupport)) {
hr = GetInterface((IMFRateSupport*)this, ppv);
- } else if(riid == __uuidof(IDirect3DDeviceManager9))
+ } else if (riid == __uuidof(IDirect3DDeviceManager9))
// hr = GetInterface((IDirect3DDeviceManager9*)this, ppv);
{
hr = m_pD3DManager->QueryInterface (__uuidof(IDirect3DDeviceManager9), (void**) ppv);
@@ -764,7 +764,7 @@ HRESULT CEVRAllocatorPresenter::CreateProposedOutputType(IMFMediaType* pMixerTyp bool bDoneSomething = true;
- if(m_AspectRatio.cx >= 1 && m_AspectRatio.cy >= 1) { //if any of these is 0, it will stuck into a infinite loop
+ if (m_AspectRatio.cx >= 1 && m_AspectRatio.cy >= 1) { //if any of these is 0, it will stuck into a infinite loop
while (bDoneSomething) {
bDoneSomething = false;
INT MinNum = min(m_AspectRatio.cx, m_AspectRatio.cy);
@@ -924,13 +924,13 @@ HRESULT CEVRAllocatorPresenter::GetMediaTypeMerit(IMFMediaType* pType, int* pMer break;
case FCC('AYUV'):
*pMerit = 3;
- break;
- case D3DFMT_X8R8G8B8:
- if (m_bForceInputHighColorResolution) {
+ break;
+ case D3DFMT_X8R8G8B8:
+ if (m_bForceInputHighColorResolution) {
*pMerit = 63;
- } else {
+ } else {
*pMerit = 1;
- }
+ }
break;
case D3DFMT_A8R8G8B8:// an accepted format, but fails on most surface types
case D3DFMT_A8B8G8R8:
@@ -1245,7 +1245,7 @@ STDMETHODIMP CEVRAllocatorPresenter::GetIdealVideoSize(SIZE *pszMin, SIZE *pszMa D3DDISPLAYMODE d3ddm;
ZeroMemory(&d3ddm, sizeof(d3ddm));
- if(SUCCEEDED(m_pD3D->GetAdapterDisplayMode(GetAdapter(m_pD3D), &d3ddm))) {
+ if (SUCCEEDED(m_pD3D->GetAdapterDisplayMode(GetAdapter(m_pD3D), &d3ddm))) {
pszMax->cx = d3ddm.Width;
pszMax->cy = d3ddm.Height;
}
@@ -1439,16 +1439,16 @@ STDMETHODIMP CEVRAllocatorPresenter::GetNativeVideoSize(LONG* lpWidth, LONG* lpH // This function should be called...
ASSERT (FALSE);
- if(lpWidth) {
+ if (lpWidth) {
*lpWidth = m_NativeVideoSize.cx;
}
- if(lpHeight) {
+ if (lpHeight) {
*lpHeight = m_NativeVideoSize.cy;
}
- if(lpARWidth) {
+ if (lpARWidth) {
*lpARWidth = m_AspectRatio.cx;
}
- if(lpARHeight) {
+ if (lpARHeight) {
*lpARHeight = m_AspectRatio.cy;
}
return S_OK;
@@ -1480,7 +1480,7 @@ STDMETHODIMP CEVRAllocatorPresenter::InitializeDevice(IMFMediaType* pMediaType) }
if (SUCCEEDED(hr)) {
- for(int i = 0; i < m_nNbDXSurface; i++) {
+ for (int i = 0; i < m_nNbDXSurface; i++) {
CComPtr<IMFSample> pMFSample;
hr = pfMFCreateVideoSampleFromSurface (m_pVideoSurface[i], &pMFSample);
@@ -1581,9 +1581,9 @@ void CEVRAllocatorPresenter::GetMixerThread() ExtractAvgTimePerFrame (&mt, m_rtTimePerFrame);
m_bInterlaced = ExtractInterlaced(&mt);
-
+
CComPtr<IPin> pPinTo;
- if(SUCCEEDED(pPin->ConnectedTo(&pPinTo)) && pPinTo) {
+ if (SUCCEEDED(pPin->ConnectedTo(&pPinTo)) && pPinTo) {
m_Decoder = GetFilterName(GetFilterFromPin(pPinTo));
}
}
@@ -1593,7 +1593,7 @@ void CEVRAllocatorPresenter::GetMixerThread() }
// Update internal subtitle clock
- if(m_fUseInternalTimer && m_pSubPicQueue) {
+ if (m_fUseInternalTimer && m_pSubPicQueue) {
m_fps = (float)(10000000.0 / m_rtTimePerFrame);
m_pSubPicQueue->SetFPS(m_fps);
}
@@ -1856,7 +1856,7 @@ STDMETHODIMP_(bool) CEVRAllocatorPresenter::ResetDevice() bool bResult = __super::ResetDevice();
- for(int i = 0; i < m_nNbDXSurface; i++) {
+ for (int i = 0; i < m_nNbDXSurface; i++) {
CComPtr<IMFSample> pMFSample;
HRESULT hr = pfMFCreateVideoSampleFromSurface (m_pVideoSurface[i], &pMFSample);
@@ -1904,7 +1904,7 @@ STDMETHODIMP_(bool) CEVRAllocatorPresenter::DisplayChange() m_bSyncStatsAvailable = false;
bool bResult = __super::DisplayChange();
-
+
return bResult;
}
@@ -2012,18 +2012,18 @@ void CEVRAllocatorPresenter::RenderThread() m_pcFrames++;
bStepForward = true;
m_nStepCount = 0;
-/*
- } else if (m_nStepCount > 0) {
- pMFSample->GetUINT32(GUID_SURFACE_INDEX, (UINT32 *)&m_nCurSurface);
- ++m_OrderedPaint;
- if (!g_bExternalSubtitleTime) {
- __super::SetTime (g_tSegmentStart + nsSampleTime);
- }
- Paint(true);
- m_nDroppedUpdate = 0;
- CompleteFrameStep (false);
- bStepForward = true;
-*/
+ /*
+ } else if (m_nStepCount > 0) {
+ pMFSample->GetUINT32(GUID_SURFACE_INDEX, (UINT32 *)&m_nCurSurface);
+ ++m_OrderedPaint;
+ if (!g_bExternalSubtitleTime) {
+ __super::SetTime (g_tSegmentStart + nsSampleTime);
+ }
+ Paint(true);
+ m_nDroppedUpdate = 0;
+ CompleteFrameStep (false);
+ bStepForward = true;
+ */
} else if ((m_nRenderState == Started)) {
LONGLONG CurrentCounter = GetRenderersData()->GetPerfCounter();
// Calculate wake up timer
diff --git a/src/filters/renderer/VideoRenderers/IPinHook.cpp b/src/filters/renderer/VideoRenderers/IPinHook.cpp index d982ba47a..ed671b30a 100644 --- a/src/filters/renderer/VideoRenderers/IPinHook.cpp +++ b/src/filters/renderer/VideoRenderers/IPinHook.cpp @@ -191,7 +191,7 @@ static HRESULT ( STDMETHODCALLTYPE *ReceiveOrg )( IMemInputPinC * This, IMediaSa static HRESULT STDMETHODCALLTYPE ReceiveMineI(IMemInputPinC * This, IMediaSample *pSample)
{
REFERENCE_TIME rtStart, rtStop;
- if(pSample && SUCCEEDED(pSample->GetTime(&rtStart, &rtStop))) {
+ if (pSample && SUCCEEDED(pSample->GetTime(&rtStart, &rtStop))) {
g_tSampleStart = rtStart;
}
return ReceiveOrg(This, pSample);
@@ -201,7 +201,7 @@ static HRESULT STDMETHODCALLTYPE ReceiveMine(IMemInputPinC * This, IMediaSample {
// Support ffdshow queueing.
// To avoid black out on pause, we have to lock g_ffdshowReceive to synchronize with CMainFrame::OnPlayPause.
- if(queue_ffdshow_support) {
+ if (queue_ffdshow_support) {
CAutoLock lck(&g_ffdshowReceive);
return ReceiveMineI(This,pSample);
}
@@ -236,7 +236,7 @@ void UnhookNewSegmentAndReceive() bool HookNewSegmentAndReceive(IPinC* pPinC, IMemInputPinC* pMemInputPinC)
{
- if(!pPinC || !pMemInputPinC || (GetVersion()&0x80000000)) {
+ if (!pPinC || !pMemInputPinC || (GetVersion()&0x80000000)) {
return false;
}
@@ -250,7 +250,7 @@ bool HookNewSegmentAndReceive(IPinC* pPinC, IMemInputPinC* pMemInputPinC) // Casimir666 : change sizeof(IPinC) to sizeof(IPinCVtbl) to fix crash with EVR hack on Vista!
res = VirtualProtect(pPinC->lpVtbl, sizeof(IPinCVtbl), PAGE_WRITECOPY, &flOldProtect);
- if(NewSegmentOrg == NULL) {
+ if (NewSegmentOrg == NULL) {
NewSegmentOrg = pPinC->lpVtbl->NewSegment;
}
pPinC->lpVtbl->NewSegment = NewSegmentMine; // Function sets global variable(s)
@@ -258,7 +258,7 @@ bool HookNewSegmentAndReceive(IPinC* pPinC, IMemInputPinC* pMemInputPinC) // Casimir666 : change sizeof(IMemInputPinC) to sizeof(IMemInputPinCVtbl) to fix crash with EVR hack on Vista!
res = VirtualProtect(pMemInputPinC->lpVtbl, sizeof(IMemInputPinCVtbl), PAGE_WRITECOPY, &flOldProtect);
- if(ReceiveOrg == NULL) {
+ if (ReceiveOrg == NULL) {
ReceiveOrg = pMemInputPinC->lpVtbl->Receive;
}
pMemInputPinC->lpVtbl->Receive = ReceiveMine; // Function sets global variable(s)
@@ -301,10 +301,10 @@ static void LOG_TOFILE(LPCTSTR FileName, LPCTSTR fmt, ...) va_list args;
va_start(args, fmt);
int nCount = _vsctprintf(fmt, args) + 1;
- if(TCHAR* buff = DNew TCHAR[nCount]) {
+ if (TCHAR* buff = DNew TCHAR[nCount]) {
FILE* f;
_vstprintf_s(buff, nCount, fmt, args);
- if(_tfopen_s(&f, FileName, _T("at")) == 0) {
+ if (_tfopen_s(&f, FileName, _T("at")) == 0) {
fseek(f, 0, 2);
_ftprintf(f, _T("%s\n"), buff);
fclose(f);
@@ -322,7 +322,7 @@ static void LOG(LPCTSTR fmt, ...) TCHAR buff[3000];
FILE* f;
_vstprintf_s(buff, countof(buff), fmt, args);
- if(_tfopen_s(&f, LOG_FILE_DXVA, _T("at")) == 0) {
+ if (_tfopen_s(&f, LOG_FILE_DXVA, _T("at")) == 0) {
fseek(f, 0, 2);
_ftprintf(f, _T("%s\n"), buff);
fclose(f);
@@ -332,7 +332,7 @@ static void LOG(LPCTSTR fmt, ...) }
static void LOGPF(LPCTSTR prefix, const DDPIXELFORMAT* p, int n)
{
- for(int i = 0; i < n; i++) {
+ for (int i = 0; i < n; i++) {
LOG(_T("%s[%d].dwSize = %d"), prefix, i, p[i].dwSize);
LOG(_T("%s[%d].dwFlags = %08x"), prefix, i, p[i].dwFlags);
LOG(_T("%s[%d].dwFourCC = %4.4hs"), prefix, i, &p[i].dwFourCC);
@@ -346,7 +346,7 @@ static void LOGPF(LPCTSTR prefix, const DDPIXELFORMAT* p, int n) static void LOGUDI(LPCTSTR prefix, const AMVAUncompDataInfo* p, int n)
{
- for(int i = 0; i < n; i++) {
+ for (int i = 0; i < n; i++) {
LOG(_T("%s[%d].dwUncompWidth = %d"), prefix, i, p[i].dwUncompWidth);
LOG(_T("%s[%d].dwUncompHeight = %d"), prefix, i, p[i].dwUncompHeight);
@@ -711,7 +711,7 @@ static HRESULT STDMETHODCALLTYPE GetVideoAcceleratorGUIDsMine(IAMVideoAccelerato {
LOG(_T("\nGetVideoAcceleratorGUIDs"));
- if(pdwNumGuidsSupported) {
+ if (pdwNumGuidsSupported) {
LOG(_T("[in] *pdwNumGuidsSupported = %d"), *pdwNumGuidsSupported);
}
@@ -719,11 +719,11 @@ static HRESULT STDMETHODCALLTYPE GetVideoAcceleratorGUIDsMine(IAMVideoAccelerato LOG(_T("hr = %08x"), hr);
- if(pdwNumGuidsSupported) {
+ if (pdwNumGuidsSupported) {
LOG(_T("[out] *pdwNumGuidsSupported = %d"), *pdwNumGuidsSupported);
- if(pGuidsSupported) {
- for(DWORD i = 0; i < *pdwNumGuidsSupported; i++) {
+ if (pGuidsSupported) {
+ for (DWORD i = 0; i < *pdwNumGuidsSupported; i++) {
LOG(_T("[out] pGuidsSupported[%d] = %s"), i, CStringFromGUID(pGuidsSupported[i]));
}
}
@@ -736,11 +736,11 @@ static HRESULT STDMETHODCALLTYPE GetUncompFormatsSupportedMine(IAMVideoAccelerat {
LOG(_T("\nGetUncompFormatsSupported"));
- if(pGuid) {
+ if (pGuid) {
LOG(_T("[in] *pGuid = %s"), CStringFromGUID(*pGuid));
}
- if(pdwNumFormatsSupported) {
+ if (pdwNumFormatsSupported) {
LOG(_T("[in] *pdwNumFormatsSupported = %d"), *pdwNumFormatsSupported);
}
@@ -748,10 +748,10 @@ static HRESULT STDMETHODCALLTYPE GetUncompFormatsSupportedMine(IAMVideoAccelerat LOG(_T("hr = %08x"), hr);
- if(pdwNumFormatsSupported) {
+ if (pdwNumFormatsSupported) {
LOG(_T("[out] *pdwNumFormatsSupported = %d"), *pdwNumFormatsSupported);
- if(pFormatsSupported) {
+ if (pFormatsSupported) {
LOGPF(_T("[out] pFormatsSupported"), pFormatsSupported, *pdwNumFormatsSupported);
}
}
@@ -775,14 +775,14 @@ static HRESULT STDMETHODCALLTYPE GetCompBufferInfoMine(IAMVideoAcceleratorC * Th {
LOG(_T("\nGetCompBufferInfo"));
- if(pGuid) {
+ if (pGuid) {
g_guidDXVADecoder = *pGuid;
g_nDXVAVersion = 1;
#ifdef _DEBUG
LOG(_T("[in] *pGuid = %s"), CStringFromGUID(*pGuid));
- if(pdwNumTypesCompBuffers) {
+ if (pdwNumTypesCompBuffers) {
LOG(_T("[in] *pdwNumTypesCompBuffers = %d"), *pdwNumTypesCompBuffers);
}
#endif
@@ -820,14 +820,14 @@ static HRESULT STDMETHODCALLTYPE BeginFrameMine(IAMVideoAcceleratorC * This, con {
LOG(_T("\nBeginFrame"));
- if(amvaBeginFrameInfo) {
+ if (amvaBeginFrameInfo) {
LOG(_T("[in] amvaBeginFrameInfo->dwDestSurfaceIndex = %08x"), amvaBeginFrameInfo->dwDestSurfaceIndex);
LOG(_T("[in] amvaBeginFrameInfo->pInputData = %08x"), amvaBeginFrameInfo->pInputData);
LOG(_T("[in] amvaBeginFrameInfo->dwSizeInputData = %08x"), amvaBeginFrameInfo->dwSizeInputData);
LOG(_T("[in] amvaBeginFrameInfo->pOutputData = %08x"), amvaBeginFrameInfo->pOutputData);
LOG(_T("[in] amvaBeginFrameInfo->dwSizeOutputData = %08x"), amvaBeginFrameInfo->dwSizeOutputData);
}
- if(amvaBeginFrameInfo && (amvaBeginFrameInfo->dwSizeInputData == 4)) {
+ if (amvaBeginFrameInfo && (amvaBeginFrameInfo->dwSizeInputData == 4)) {
LOG(_T("[in] amvaBeginFrameInfo->pInputData => dwDestSurfaceIndex = %ld "),
((DWORD*)amvaBeginFrameInfo->pInputData)[0]);
}
@@ -844,7 +844,7 @@ static HRESULT STDMETHODCALLTYPE EndFrameMine(IAMVideoAcceleratorC * This, const {
LOG(_T("\nEndFrame"));
- if(pEndFrameInfo) {
+ if (pEndFrameInfo) {
LOG(_T("[in] pEndFrameInfo->dwSizeMiscData = %08x"), pEndFrameInfo->dwSizeMiscData);
LOG(_T("[in] pEndFrameInfo->pMiscData = %08x"), pEndFrameInfo->pMiscData);
@@ -904,7 +904,7 @@ static HRESULT STDMETHODCALLTYPE ExecuteMine(IAMVideoAcceleratorC* This, DWORD d #ifdef _DEBUG
LOG(_T("\nExecute"));
LOG(_T("[in] dwFunction = %08x"), dwFunction);
- if(lpPrivateInputData) {
+ if (lpPrivateInputData) {
if (dwFunction == 0x01000000) {
DXVA_BufferDescription* pBuffDesc = (DXVA_BufferDescription*)lpPrivateInputData;
@@ -951,7 +951,7 @@ static HRESULT STDMETHODCALLTYPE ExecuteMine(IAMVideoAcceleratorC* This, DWORD d LOG(_T("[in] lpPrivateOutputData = %08x"), lpPrivateOutputData);
LOG(_T("[in] cbPrivateOutputData = %08x"), cbPrivateOutputData);
LOG(_T("[in] dwNumBuffers = %08x"), dwNumBuffers);
- if(pamvaBufferInfo) {
+ if (pamvaBufferInfo) {
for (DWORD i=0; i<dwNumBuffers; i++) {
LOG(_T("[in] pamvaBufferInfo, buffer description %d"), i);
LOG(_T("[in] pamvaBufferInfo->dwTypeIndex = %08x"), pamvaBufferInfo[i].dwTypeIndex);
@@ -1000,7 +1000,7 @@ static HRESULT STDMETHODCALLTYPE ExecuteMine(IAMVideoAcceleratorC* This, DWORD d LOG(_T("hr = %08x"), hr);
- if(lpPrivateOutputData && (dwFunction == 0x01000000)) {
+ if (lpPrivateOutputData && (dwFunction == 0x01000000)) {
LOG(_T("[out] *lpPrivateOutputData : Result = %08x"), ((DWORD*)lpPrivateOutputData)[0]);
}
@@ -1038,42 +1038,42 @@ void HookAMVideoAccelerator(IAMVideoAcceleratorC* pAMVideoAcceleratorC) res = VirtualProtect(pAMVideoAcceleratorC->lpVtbl, sizeof(IAMVideoAcceleratorC), PAGE_WRITECOPY, &flOldProtect);
#ifdef _DEBUG
- if(GetVideoAcceleratorGUIDsOrg == NULL) {
+ if (GetVideoAcceleratorGUIDsOrg == NULL) {
GetVideoAcceleratorGUIDsOrg = pAMVideoAcceleratorC->lpVtbl->GetVideoAcceleratorGUIDs;
}
- if(GetUncompFormatsSupportedOrg == NULL) {
+ if (GetUncompFormatsSupportedOrg == NULL) {
GetUncompFormatsSupportedOrg = pAMVideoAcceleratorC->lpVtbl->GetUncompFormatsSupported;
}
- if(GetInternalMemInfoOrg == NULL) {
+ if (GetInternalMemInfoOrg == NULL) {
GetInternalMemInfoOrg = pAMVideoAcceleratorC->lpVtbl->GetInternalMemInfo;
}
#endif
- if(GetCompBufferInfoOrg == NULL) {
+ if (GetCompBufferInfoOrg == NULL) {
GetCompBufferInfoOrg = pAMVideoAcceleratorC->lpVtbl->GetCompBufferInfo;
}
#ifdef _DEBUG
- if(GetInternalCompBufferInfoOrg == NULL) {
+ if (GetInternalCompBufferInfoOrg == NULL) {
GetInternalCompBufferInfoOrg = pAMVideoAcceleratorC->lpVtbl->GetInternalCompBufferInfo;
}
- if(BeginFrameOrg == NULL) {
+ if (BeginFrameOrg == NULL) {
BeginFrameOrg = pAMVideoAcceleratorC->lpVtbl->BeginFrame;
}
- if(EndFrameOrg == NULL) {
+ if (EndFrameOrg == NULL) {
EndFrameOrg = pAMVideoAcceleratorC->lpVtbl->EndFrame;
}
- if(GetBufferOrg == NULL) {
+ if (GetBufferOrg == NULL) {
GetBufferOrg = pAMVideoAcceleratorC->lpVtbl->GetBuffer;
}
- if(ReleaseBufferOrg == NULL) {
+ if (ReleaseBufferOrg == NULL) {
ReleaseBufferOrg = pAMVideoAcceleratorC->lpVtbl->ReleaseBuffer;
}
- if(ExecuteOrg == NULL) {
+ if (ExecuteOrg == NULL) {
ExecuteOrg = pAMVideoAcceleratorC->lpVtbl->Execute;
}
- if(QueryRenderStatusOrg == NULL) {
+ if (QueryRenderStatusOrg == NULL) {
QueryRenderStatusOrg = pAMVideoAcceleratorC->lpVtbl->QueryRenderStatus;
}
- if(DisplayFrameOrg == NULL) {
+ if (DisplayFrameOrg == NULL) {
DisplayFrameOrg = pAMVideoAcceleratorC->lpVtbl->DisplayFrame;
}
@@ -1143,7 +1143,7 @@ public : DECLARE_IUNKNOWN;
STDMETHODIMP NonDelegatingQueryInterface(REFIID riid, void** ppv) {
- if(riid == __uuidof(IDirectXVideoDecoder)) {
+ if (riid == __uuidof(IDirectXVideoDecoder)) {
return GetInterface((IDirectXVideoDecoder*)this, ppv);
} else {
return __super::NonDelegatingQueryInterface(riid, ppv);
diff --git a/src/filters/renderer/VideoRenderers/MacrovisionKicker.cpp b/src/filters/renderer/VideoRenderers/MacrovisionKicker.cpp index 4fd82c1f4..9dd33c1e7 100644 --- a/src/filters/renderer/VideoRenderers/MacrovisionKicker.cpp +++ b/src/filters/renderer/VideoRenderers/MacrovisionKicker.cpp @@ -45,10 +45,10 @@ void CMacrovisionKicker::SetInner(IUnknown* pUnk) STDMETHODIMP CMacrovisionKicker::NonDelegatingQueryInterface(REFIID riid, void** ppv)
{
- if(riid == __uuidof(IUnknown)) {
+ if (riid == __uuidof(IUnknown)) {
return __super::NonDelegatingQueryInterface(riid, ppv);
}
- if(riid == __uuidof(IKsPropertySet) && CComQIPtr<IKsPropertySet>(m_pInner)) {
+ if (riid == __uuidof(IKsPropertySet) && CComQIPtr<IKsPropertySet>(m_pInner)) {
return GetInterface((IKsPropertySet*)this, ppv);
}
@@ -61,8 +61,8 @@ STDMETHODIMP CMacrovisionKicker::NonDelegatingQueryInterface(REFIID riid, void** STDMETHODIMP CMacrovisionKicker::Set(REFGUID PropSet, ULONG Id, LPVOID pInstanceData, ULONG InstanceLength, LPVOID pPropertyData, ULONG DataLength)
{
- if(CComQIPtr<IKsPropertySet> pKsPS = m_pInner) {
- if(PropSet == AM_KSPROPSETID_CopyProt && Id == AM_PROPERTY_COPY_MACROVISION
+ if (CComQIPtr<IKsPropertySet> pKsPS = m_pInner) {
+ if (PropSet == AM_KSPROPSETID_CopyProt && Id == AM_PROPERTY_COPY_MACROVISION
/*&& DataLength == 4 && *(DWORD*)pPropertyData*/) {
TRACE(_T("Oops, no-no-no, no macrovision please\n"));
return S_OK;
@@ -76,7 +76,7 @@ STDMETHODIMP CMacrovisionKicker::Set(REFGUID PropSet, ULONG Id, LPVOID pInstance STDMETHODIMP CMacrovisionKicker::Get(REFGUID PropSet, ULONG Id, LPVOID pInstanceData, ULONG InstanceLength, LPVOID pPropertyData, ULONG DataLength, ULONG* pBytesReturned)
{
- if(CComQIPtr<IKsPropertySet> pKsPS = m_pInner) {
+ if (CComQIPtr<IKsPropertySet> pKsPS = m_pInner) {
return pKsPS->Get(PropSet, Id, pInstanceData, InstanceLength, pPropertyData, DataLength, pBytesReturned);
}
@@ -85,7 +85,7 @@ STDMETHODIMP CMacrovisionKicker::Get(REFGUID PropSet, ULONG Id, LPVOID pInstance STDMETHODIMP CMacrovisionKicker::QuerySupported(REFGUID PropSet, ULONG Id, ULONG* pTypeSupport)
{
- if(CComQIPtr<IKsPropertySet> pKsPS = m_pInner) {
+ if (CComQIPtr<IKsPropertySet> pKsPS = m_pInner) {
return pKsPS->QuerySupported(PropSet, Id, pTypeSupport);
}
diff --git a/src/filters/renderer/VideoRenderers/OuterEVR.h b/src/filters/renderer/VideoRenderers/OuterEVR.h index ac941c75e..de8897aea 100644 --- a/src/filters/renderer/VideoRenderers/OuterEVR.h +++ b/src/filters/renderer/VideoRenderers/OuterEVR.h @@ -48,7 +48,7 @@ namespace DSObjects STDMETHODIMP NonDelegatingQueryInterface(REFIID riid, void** ppv) {
HRESULT hr;
- if(riid == __uuidof(IVMRMixerBitmap9)) {
+ if (riid == __uuidof(IVMRMixerBitmap9)) {
return GetInterface((IVMRMixerBitmap9*)this, ppv);
}
if (riid == __uuidof(IMediaFilter)) {
@@ -62,8 +62,8 @@ namespace DSObjects }
hr = m_pEVR ? m_pEVR->QueryInterface(riid, ppv) : E_NOINTERFACE;
- if(m_pEVR && FAILED(hr)) {
- if(riid == __uuidof(IVMRffdshow9)) { // Support ffdshow queueing. We show ffdshow that this is patched Media Player Classic.
+ if (m_pEVR && FAILED(hr)) {
+ if (riid == __uuidof(IVMRffdshow9)) { // Support ffdshow queueing. We show ffdshow that this is patched Media Player Classic.
return GetInterface((IVMRffdshow9*)this, ppv);
}
}
diff --git a/src/filters/renderer/VideoRenderers/OuterVMR.cpp b/src/filters/renderer/VideoRenderers/OuterVMR.cpp index a243cccf1..34e88f5a3 100644 --- a/src/filters/renderer/VideoRenderers/OuterVMR.cpp +++ b/src/filters/renderer/VideoRenderers/OuterVMR.cpp @@ -28,7 +28,7 @@ using namespace DSObjects;
STDMETHODIMP COuterVMR9::GetNativeVideoSize(LONG* lpWidth, LONG* lpHeight, LONG* lpARWidth, LONG* lpARHeight) {
- if(CComQIPtr<IVMRWindowlessControl9> pWC9 = m_pVMR) {
+ if (CComQIPtr<IVMRWindowlessControl9> pWC9 = m_pVMR) {
return pWC9->GetNativeVideoSize(lpWidth, lpHeight, lpARWidth, lpARHeight);
}
@@ -36,7 +36,7 @@ STDMETHODIMP COuterVMR9::GetNativeVideoSize(LONG* lpWidth, LONG* lpHeight, LONG* }
STDMETHODIMP COuterVMR9::GetVideoPosition(LPRECT lpSRCRect, LPRECT lpDSTRect) {
- if(CComQIPtr<IVMRWindowlessControl9> pWC9 = m_pVMR) {
+ if (CComQIPtr<IVMRWindowlessControl9> pWC9 = m_pVMR) {
return pWC9->GetVideoPosition(lpSRCRect, lpDSTRect);
}
@@ -44,7 +44,7 @@ STDMETHODIMP COuterVMR9::GetVideoPosition(LPRECT lpSRCRect, LPRECT lpDSTRect) { }
STDMETHODIMP COuterVMR9::GetAspectRatioMode(DWORD* lpAspectRatioMode) {
- if(CComQIPtr<IVMRWindowlessControl9> pWC9 = m_pVMR) {
+ if (CComQIPtr<IVMRWindowlessControl9> pWC9 = m_pVMR) {
*lpAspectRatioMode = VMR_ARMODE_NONE;
return S_OK;
}
@@ -54,7 +54,7 @@ STDMETHODIMP COuterVMR9::GetAspectRatioMode(DWORD* lpAspectRatioMode) { // IVideoWindow
STDMETHODIMP COuterVMR9::get_Width(long* pWidth) {
- if(CComQIPtr<IVMRWindowlessControl9> pWC9 = m_pVMR) {
+ if (CComQIPtr<IVMRWindowlessControl9> pWC9 = m_pVMR) {
CRect s, d;
HRESULT hr = pWC9->GetVideoPosition(&s, &d);
*pWidth = d.Width();
@@ -65,7 +65,7 @@ STDMETHODIMP COuterVMR9::get_Width(long* pWidth) { }
STDMETHODIMP COuterVMR9::get_Height(long* pHeight) {
- if(CComQIPtr<IVMRWindowlessControl9> pWC9 = m_pVMR) {
+ if (CComQIPtr<IVMRWindowlessControl9> pWC9 = m_pVMR) {
CRect s, d;
HRESULT hr = pWC9->GetVideoPosition(&s, &d);
*pHeight = d.Height();
@@ -98,7 +98,7 @@ STDMETHODIMP COuterVMR9::GetSourcePosition(long* pLeft, long* pTop, long* pWidth }
STDMETHODIMP COuterVMR9::GetDestinationPosition(long* pLeft, long* pTop, long* pWidth, long* pHeight) {
- if(CComQIPtr<IVMRWindowlessControl9> pWC9 = m_pVMR) {
+ if (CComQIPtr<IVMRWindowlessControl9> pWC9 = m_pVMR) {
CRect s, d;
HRESULT hr = pWC9->GetVideoPosition(&s, &d);
*pLeft = d.left;
@@ -112,7 +112,7 @@ STDMETHODIMP COuterVMR9::GetDestinationPosition(long* pLeft, long* pTop, long* p }
STDMETHODIMP COuterVMR9::GetVideoSize(long* pWidth, long* pHeight) {
- if(CComQIPtr<IVMRWindowlessControl9> pWC9 = m_pVMR) {
+ if (CComQIPtr<IVMRWindowlessControl9> pWC9 = m_pVMR) {
LONG aw, ah;
// return pWC9->GetNativeVideoSize(pWidth, pHeight, &aw, &ah);
// DVD Nav. bug workaround fix
@@ -125,7 +125,7 @@ STDMETHODIMP COuterVMR9::GetVideoSize(long* pWidth, long* pHeight) { }
STDMETHODIMP COuterVMR9::GetPreferredAspectRatio(long* plAspectX, long* plAspectY) {
- if(CComQIPtr<IVMRWindowlessControl9> pWC9 = m_pVMR) {
+ if (CComQIPtr<IVMRWindowlessControl9> pWC9 = m_pVMR) {
LONG w, h;
return pWC9->GetNativeVideoSize(&w, &h, plAspectX, plAspectY);
}
diff --git a/src/filters/renderer/VideoRenderers/OuterVMR.h b/src/filters/renderer/VideoRenderers/OuterVMR.h index ec7650f65..567d45c9d 100644 --- a/src/filters/renderer/VideoRenderers/OuterVMR.h +++ b/src/filters/renderer/VideoRenderers/OuterVMR.h @@ -53,22 +53,22 @@ namespace DSObjects HRESULT hr;
// Casimir666 : in renderless mode, do the inlaying in place of VMR
- if(riid == __uuidof(IVMRMixerBitmap9)) {
+ if (riid == __uuidof(IVMRMixerBitmap9)) {
return GetInterface((IVMRMixerBitmap9*)this, ppv);
}
hr = m_pVMR ? m_pVMR->QueryInterface(riid, ppv) : E_NOINTERFACE;
- if(m_pVMR && FAILED(hr)) {
- if(riid == __uuidof(IVideoWindow)) {
+ if (m_pVMR && FAILED(hr)) {
+ if (riid == __uuidof(IVideoWindow)) {
return GetInterface((IVideoWindow*)this, ppv);
}
- if(riid == __uuidof(IBasicVideo)) {
+ if (riid == __uuidof(IBasicVideo)) {
return GetInterface((IBasicVideo*)this, ppv);
}
- if(riid == __uuidof(IBasicVideo2)) {
+ if (riid == __uuidof(IBasicVideo2)) {
return GetInterface((IBasicVideo2*)this, ppv);
}
- if(riid == __uuidof(IVMRffdshow9)) { // Support ffdshow queueing. We show ffdshow that this is patched Media Player Classic.
+ if (riid == __uuidof(IVMRffdshow9)) { // Support ffdshow queueing. We show ffdshow that this is patched Media Player Classic.
return GetInterface((IVMRffdshow9*)this, ppv);
}
/* if(riid == __uuidof(IVMRWindowlessControl))
diff --git a/src/filters/renderer/VideoRenderers/PixelShaderCompiler.cpp b/src/filters/renderer/VideoRenderers/PixelShaderCompiler.cpp index 75342cde5..fff93a356 100644 --- a/src/filters/renderer/VideoRenderers/PixelShaderCompiler.cpp +++ b/src/filters/renderer/VideoRenderers/PixelShaderCompiler.cpp @@ -35,15 +35,15 @@ CPixelShaderCompiler::CPixelShaderCompiler(IDirect3DDevice9* pD3DDev, bool fStay HINSTANCE hDll;
hDll = GetRenderersData()->GetD3X9Dll();
- if(hDll) {
+ if (hDll) {
m_pD3DXCompileShader = (D3DXCompileShaderPtr)GetProcAddress(hDll, "D3DXCompileShader");
m_pD3DXDisassembleShader = (D3DXDisassembleShaderPtr)GetProcAddress(hDll, "D3DXDisassembleShader");
}
- if(!fStaySilent) {
- if(!hDll) {
+ if (!fStaySilent) {
+ if (!hDll) {
AfxMessageBox(ResStr(IDS_PIXELSHADERCOMPILER_0), MB_OK);
- } else if(!m_pD3DXCompileShader || !m_pD3DXDisassembleShader) {
+ } else if (!m_pD3DXCompileShader || !m_pD3DXDisassembleShader) {
AfxMessageBox(ResStr(IDS_PIXELSHADERCOMPILER_1), MB_OK);
}
}
@@ -62,7 +62,7 @@ HRESULT CPixelShaderCompiler::CompileShader( CString* disasm,
CString* errmsg)
{
- if(!m_pD3DXCompileShader || !m_pD3DXDisassembleShader) {
+ if (!m_pD3DXCompileShader || !m_pD3DXDisassembleShader) {
return E_FAIL;
}
@@ -71,11 +71,11 @@ HRESULT CPixelShaderCompiler::CompileShader( CComPtr<ID3DXBuffer> pShader, pDisAsm, pErrorMsgs;
hr = m_pD3DXCompileShader(pSrcData, strlen(pSrcData), NULL, NULL, pFunctionName, pProfile, Flags, &pShader, &pErrorMsgs, NULL);
- if(FAILED(hr)) {
- if(errmsg) {
+ if (FAILED(hr)) {
+ if (errmsg) {
CStringA msg = "Unexpected compiler error";
- if(pErrorMsgs) {
+ if (pErrorMsgs) {
int len = pErrorMsgs->GetBufferSize();
memcpy(msg.GetBufferSetLength(len), pErrorMsgs->GetBufferPointer(), len);
}
@@ -86,19 +86,19 @@ HRESULT CPixelShaderCompiler::CompileShader( return hr;
}
- if(ppPixelShader) {
- if(!m_pD3DDev) {
+ if (ppPixelShader) {
+ if (!m_pD3DDev) {
return E_FAIL;
}
hr = m_pD3DDev->CreatePixelShader((DWORD*)pShader->GetBufferPointer(), ppPixelShader);
- if(FAILED(hr)) {
+ if (FAILED(hr)) {
return hr;
}
}
- if(disasm) {
+ if (disasm) {
hr = m_pD3DXDisassembleShader((DWORD*)pShader->GetBufferPointer(), FALSE, NULL, &pDisAsm);
- if(SUCCEEDED(hr) && pDisAsm) {
+ if (SUCCEEDED(hr) && pDisAsm) {
*disasm = CStringA((const char*)pDisAsm->GetBufferPointer());
}
}
diff --git a/src/filters/renderer/VideoRenderers/QT7AllocatorPresenter.cpp b/src/filters/renderer/VideoRenderers/QT7AllocatorPresenter.cpp index de1099997..5d2d1fb1b 100644 --- a/src/filters/renderer/VideoRenderers/QT7AllocatorPresenter.cpp +++ b/src/filters/renderer/VideoRenderers/QT7AllocatorPresenter.cpp @@ -65,7 +65,7 @@ HRESULT CQT7AllocatorPresenter::AllocSurfaces() ddsd.ddpfPixelFormat.dwBBitMask = 0x000000FF;
HRESULT hr = m_pDD->CreateSurface(&ddsd, &m_pVideoSurfaceOff, NULL);
- if(FAILED(hr)) {
+ if (FAILED(hr)) {
return E_FAIL;
}
@@ -97,7 +97,7 @@ STDMETHODIMP CQT7AllocatorPresenter::BeginBlt(const BITMAP& bm) m_NativeVideoSize = m_AspectRatio = CSize(bm.bmWidth, abs(bm.bmHeight));
HRESULT hr;
- if(FAILED(hr = AllocSurfaces())) {
+ if (FAILED(hr = AllocSurfaces())) {
return hr;
}
@@ -106,7 +106,7 @@ STDMETHODIMP CQT7AllocatorPresenter::BeginBlt(const BITMAP& bm) STDMETHODIMP CQT7AllocatorPresenter::DoBlt(const BITMAP& bm)
{
- if(!m_pVideoSurface || !m_pVideoSurfaceOff) {
+ if (!m_pVideoSurface || !m_pVideoSurfaceOff) {
return E_FAIL;
}
@@ -114,7 +114,7 @@ STDMETHODIMP CQT7AllocatorPresenter::DoBlt(const BITMAP& bm) DDSURFACEDESC2 ddsd;
INITDDSTRUCT(ddsd);
- if(FAILED(m_pVideoSurfaceOff->GetSurfaceDesc(&ddsd))) {
+ if (FAILED(m_pVideoSurfaceOff->GetSurfaceDesc(&ddsd))) {
return E_FAIL;
}
@@ -122,9 +122,9 @@ STDMETHODIMP CQT7AllocatorPresenter::DoBlt(const BITMAP& bm) UINT h = abs(bm.bmHeight);
int bpp = bm.bmBitsPixel;
- if((bpp == 16 || bpp == 24 || bpp == 32) && w == ddsd.dwWidth && h == ddsd.dwHeight) {
+ if ((bpp == 16 || bpp == 24 || bpp == 32) && w == ddsd.dwWidth && h == ddsd.dwHeight) {
INITDDSTRUCT(ddsd);
- if(SUCCEEDED(m_pVideoSurfaceOff->Lock(NULL, &ddsd, DDLOCK_WAIT|DDLOCK_SURFACEMEMORYPTR|DDLOCK_WRITEONLY, NULL))) {
+ if (SUCCEEDED(m_pVideoSurfaceOff->Lock(NULL, &ddsd, DDLOCK_WAIT|DDLOCK_SURFACEMEMORYPTR|DDLOCK_WRITEONLY, NULL))) {
BitBltFromRGBToRGB(
w, h,
(BYTE*)ddsd.lpSurface, ddsd.lPitch, ddsd.ddpfPixelFormat.dwRGBBitCount,
@@ -134,14 +134,14 @@ STDMETHODIMP CQT7AllocatorPresenter::DoBlt(const BITMAP& bm) }
}
- if(!fOk) {
+ if (!fOk) {
DDBLTFX fx;
INITDDSTRUCT(fx);
fx.dwFillColor = 0;
m_pVideoSurfaceOff->Blt(NULL, NULL, NULL, DDBLT_WAIT|DDBLT_COLORFILL, &fx);
HDC hDC;
- if(SUCCEEDED(m_pVideoSurfaceOff->GetDC(&hDC))) {
+ if (SUCCEEDED(m_pVideoSurfaceOff->GetDC(&hDC))) {
CString str;
str.Format(_T("Sorry, this format is not supported"));
diff --git a/src/filters/renderer/VideoRenderers/QT9AllocatorPresenter.cpp b/src/filters/renderer/VideoRenderers/QT9AllocatorPresenter.cpp index ff6fe0f8f..3004a7600 100644 --- a/src/filters/renderer/VideoRenderers/QT9AllocatorPresenter.cpp +++ b/src/filters/renderer/VideoRenderers/QT9AllocatorPresenter.cpp @@ -49,9 +49,9 @@ HRESULT CQT9AllocatorPresenter::AllocSurfaces() m_pVideoSurfaceOff = NULL;
- if(FAILED(hr = m_pD3DDev->CreateOffscreenPlainSurface(
- m_NativeVideoSize.cx, m_NativeVideoSize.cy, D3DFMT_X8R8G8B8,
- D3DPOOL_DEFAULT, &m_pVideoSurfaceOff, NULL))) {
+ if (FAILED(hr = m_pD3DDev->CreateOffscreenPlainSurface(
+ m_NativeVideoSize.cx, m_NativeVideoSize.cy, D3DFMT_X8R8G8B8,
+ D3DPOOL_DEFAULT, &m_pVideoSurfaceOff, NULL))) {
return hr;
}
@@ -73,7 +73,7 @@ STDMETHODIMP CQT9AllocatorPresenter::BeginBlt(const BITMAP& bm) CAutoLock cRenderLock(&m_RenderLock);
DeleteSurfaces();
m_NativeVideoSize = m_AspectRatio = CSize(bm.bmWidth, abs(bm.bmHeight));
- if(FAILED(AllocSurfaces())) {
+ if (FAILED(AllocSurfaces())) {
return E_FAIL;
}
return S_OK;
@@ -81,7 +81,7 @@ STDMETHODIMP CQT9AllocatorPresenter::BeginBlt(const BITMAP& bm) STDMETHODIMP CQT9AllocatorPresenter::DoBlt(const BITMAP& bm)
{
- if(!m_pVideoSurface || !m_pVideoSurfaceOff) {
+ if (!m_pVideoSurface || !m_pVideoSurfaceOff) {
return E_FAIL;
}
@@ -89,7 +89,7 @@ STDMETHODIMP CQT9AllocatorPresenter::DoBlt(const BITMAP& bm) D3DSURFACE_DESC d3dsd;
ZeroMemory(&d3dsd, sizeof(d3dsd));
- if(FAILED(m_pVideoSurfaceOff->GetDesc(&d3dsd))) {
+ if (FAILED(m_pVideoSurfaceOff->GetDesc(&d3dsd))) {
return E_FAIL;
}
@@ -100,9 +100,9 @@ STDMETHODIMP CQT9AllocatorPresenter::DoBlt(const BITMAP& bm) d3dsd.Format == D3DFMT_R8G8B8 || d3dsd.Format == D3DFMT_X8R8G8B8 || d3dsd.Format == D3DFMT_A8R8G8B8 ? 32 :
d3dsd.Format == D3DFMT_R5G6B5 ? 16 : 0;
- if((bpp == 16 || bpp == 24 || bpp == 32) && w == d3dsd.Width && h == d3dsd.Height) {
+ if ((bpp == 16 || bpp == 24 || bpp == 32) && w == d3dsd.Width && h == d3dsd.Height) {
D3DLOCKED_RECT r;
- if(SUCCEEDED(m_pVideoSurfaceOff->LockRect(&r, NULL, 0))) {
+ if (SUCCEEDED(m_pVideoSurfaceOff->LockRect(&r, NULL, 0))) {
BitBltFromRGBToRGB(
w, h,
(BYTE*)r.pBits, r.Pitch, dbpp,
@@ -112,11 +112,11 @@ STDMETHODIMP CQT9AllocatorPresenter::DoBlt(const BITMAP& bm) }
}
- if(!fOk) {
+ if (!fOk) {
m_pD3DDev->ColorFill(m_pVideoSurfaceOff, NULL, 0);
HDC hDC;
- if(SUCCEEDED(m_pVideoSurfaceOff->GetDC(&hDC))) {
+ if (SUCCEEDED(m_pVideoSurfaceOff->GetDC(&hDC))) {
CString str;
str.Format(_T("Sorry, this color format is not supported"));
diff --git a/src/filters/renderer/VideoRenderers/RM7AllocatorPresenter.cpp b/src/filters/renderer/VideoRenderers/RM7AllocatorPresenter.cpp index 6833d6510..509161ce5 100644 --- a/src/filters/renderer/VideoRenderers/RM7AllocatorPresenter.cpp +++ b/src/filters/renderer/VideoRenderers/RM7AllocatorPresenter.cpp @@ -68,7 +68,7 @@ HRESULT CRM7AllocatorPresenter::AllocSurfaces() ddsd.ddpfPixelFormat.dwBBitMask = 0x000000FF;
HRESULT hr = m_pDD->CreateSurface(&ddsd, &m_pVideoSurfaceOff, NULL);
- if(FAILED(hr)) {
+ if (FAILED(hr)) {
return E_FAIL;
}
@@ -88,11 +88,11 @@ HRESULT CRM7AllocatorPresenter::AllocSurfaces() hr = m_pDD->CreateSurface(&ddsd, &m_pVideoSurfaceYUY2, NULL);
- if(FAILED(m_pVideoSurfaceOff->Blt(NULL, m_pVideoSurfaceYUY2, NULL, DDBLT_WAIT, NULL))) {
+ if (FAILED(m_pVideoSurfaceOff->Blt(NULL, m_pVideoSurfaceYUY2, NULL, DDBLT_WAIT, NULL))) {
m_pVideoSurfaceYUY2 = NULL;
}
- if(m_pVideoSurfaceYUY2) {
+ if (m_pVideoSurfaceYUY2) {
INITDDSTRUCT(fx);
fx.dwFillColor = 0x80108010;
m_pVideoSurfaceYUY2->Blt(NULL, NULL, NULL, DDBLT_WAIT|DDBLT_COLORFILL, &fx);
@@ -115,7 +115,7 @@ void CRM7AllocatorPresenter::DeleteSurfaces() STDMETHODIMP CRM7AllocatorPresenter::Blt(UCHAR* pImageData, RMABitmapInfoHeader* pBitmapInfo, REF(PNxRect) inDestRect, REF(PNxRect) inSrcRect)
{
- if(!m_pVideoSurface || !m_pVideoSurfaceOff) {
+ if (!m_pVideoSurface || !m_pVideoSurfaceOff) {
return E_FAIL;
}
@@ -123,13 +123,13 @@ STDMETHODIMP CRM7AllocatorPresenter::Blt(UCHAR* pImageData, RMABitmapInfoHeader* bool fYUY2 = false;
CRect src((RECT*)&inSrcRect), dst((RECT*)&inDestRect), src2(CPoint(0,0), src.Size());
- if(src.Width() > dst.Width() || src.Height() > dst.Height()) {
+ if (src.Width() > dst.Width() || src.Height() > dst.Height()) {
return E_FAIL;
}
DDSURFACEDESC2 ddsd;
- if(pBitmapInfo->biCompression == '024I') {
+ if (pBitmapInfo->biCompression == '024I') {
DWORD pitch = pBitmapInfo->biWidth;
DWORD size = pitch*abs(pBitmapInfo->biHeight);
@@ -137,22 +137,22 @@ STDMETHODIMP CRM7AllocatorPresenter::Blt(UCHAR* pImageData, RMABitmapInfoHeader* BYTE* u = pImageData + size + src.top*(pitch/2) + src.left/2;
BYTE* v = pImageData + size + size/4 + src.top*(pitch/2) + src.left/2;
- if(m_pVideoSurfaceYUY2) {
+ if (m_pVideoSurfaceYUY2) {
INITDDSTRUCT(ddsd);
- if(SUCCEEDED(m_pVideoSurfaceYUY2->Lock(src2, &ddsd, DDLOCK_WAIT|DDLOCK_SURFACEMEMORYPTR|DDLOCK_WRITEONLY, NULL))) {
+ if (SUCCEEDED(m_pVideoSurfaceYUY2->Lock(src2, &ddsd, DDLOCK_WAIT|DDLOCK_SURFACEMEMORYPTR|DDLOCK_WRITEONLY, NULL))) {
BitBltFromI420ToYUY2(src.Width(), src.Height(), (BYTE*)ddsd.lpSurface, ddsd.lPitch, y, u, v, pitch);
m_pVideoSurfaceYUY2->Unlock(src2);
fYUY2 = true;
}
} else {
INITDDSTRUCT(ddsd);
- if(SUCCEEDED(m_pVideoSurfaceOff->Lock(src2, &ddsd, DDLOCK_WAIT|DDLOCK_SURFACEMEMORYPTR|DDLOCK_WRITEONLY, NULL))) {
+ if (SUCCEEDED(m_pVideoSurfaceOff->Lock(src2, &ddsd, DDLOCK_WAIT|DDLOCK_SURFACEMEMORYPTR|DDLOCK_WRITEONLY, NULL))) {
BitBltFromI420ToRGB(src.Width(), src.Height(), (BYTE*)ddsd.lpSurface, ddsd.lPitch, ddsd.ddpfPixelFormat.dwRGBBitCount, y, u, v, pitch);
m_pVideoSurfaceOff->Unlock(src2);
fRGB = true;
}
}
- } else if(pBitmapInfo->biCompression == '2YUY') {
+ } else if (pBitmapInfo->biCompression == '2YUY') {
DWORD w = pBitmapInfo->biWidth;
DWORD h = abs(pBitmapInfo->biHeight);
DWORD pitch = pBitmapInfo->biWidth*2;
@@ -161,23 +161,23 @@ STDMETHODIMP CRM7AllocatorPresenter::Blt(UCHAR* pImageData, RMABitmapInfoHeader* BYTE* yvyu = pImageData + src.top*pitch + src.left*2;
- if(m_pVideoSurfaceYUY2) {
+ if (m_pVideoSurfaceYUY2) {
INITDDSTRUCT(ddsd);
- if(SUCCEEDED(m_pVideoSurfaceYUY2->Lock(src2, &ddsd, DDLOCK_WAIT|DDLOCK_SURFACEMEMORYPTR|DDLOCK_WRITEONLY, NULL))) {
+ if (SUCCEEDED(m_pVideoSurfaceYUY2->Lock(src2, &ddsd, DDLOCK_WAIT|DDLOCK_SURFACEMEMORYPTR|DDLOCK_WRITEONLY, NULL))) {
BitBltFromYUY2ToYUY2(src.Width(), src.Height(), (BYTE*)ddsd.lpSurface, ddsd.lPitch, yvyu, pitch);
m_pVideoSurfaceYUY2->Unlock(src2);
fYUY2 = true;
}
} else {
INITDDSTRUCT(ddsd);
- if(SUCCEEDED(m_pVideoSurfaceOff->Lock(src2, &ddsd, DDLOCK_WAIT|DDLOCK_SURFACEMEMORYPTR|DDLOCK_WRITEONLY, NULL))) {
+ if (SUCCEEDED(m_pVideoSurfaceOff->Lock(src2, &ddsd, DDLOCK_WAIT|DDLOCK_SURFACEMEMORYPTR|DDLOCK_WRITEONLY, NULL))) {
BitBltFromYUY2ToRGB(src.Width(), src.Height(), (BYTE*)ddsd.lpSurface, ddsd.lPitch, ddsd.ddpfPixelFormat.dwRGBBitCount, yvyu, pitch);
m_pVideoSurfaceOff->Unlock(src2);
fRGB = true;
}
}
- } else if(pBitmapInfo->biCompression == 0 || pBitmapInfo->biCompression == 3
- || pBitmapInfo->biCompression == 'BGRA') {
+ } else if (pBitmapInfo->biCompression == 0 || pBitmapInfo->biCompression == 3
+ || pBitmapInfo->biCompression == 'BGRA') {
DWORD w = pBitmapInfo->biWidth;
DWORD h = abs(pBitmapInfo->biHeight);
DWORD pitch = pBitmapInfo->biWidth*pBitmapInfo->biBitCount>>3;
@@ -187,9 +187,9 @@ STDMETHODIMP CRM7AllocatorPresenter::Blt(UCHAR* pImageData, RMABitmapInfoHeader* BYTE* rgb = pImageData + src.top*pitch + src.left*(pBitmapInfo->biBitCount>>3);
INITDDSTRUCT(ddsd);
- if(SUCCEEDED(m_pVideoSurfaceOff->Lock(src2, &ddsd, DDLOCK_WAIT|DDLOCK_SURFACEMEMORYPTR|DDLOCK_WRITEONLY, NULL))) {
+ if (SUCCEEDED(m_pVideoSurfaceOff->Lock(src2, &ddsd, DDLOCK_WAIT|DDLOCK_SURFACEMEMORYPTR|DDLOCK_WRITEONLY, NULL))) {
BYTE* lpSurface = (BYTE*)ddsd.lpSurface;
- if(pBitmapInfo->biHeight > 0) {
+ if (pBitmapInfo->biHeight > 0) {
lpSurface += ddsd.lPitch*(src.Height()-1);
ddsd.lPitch = -ddsd.lPitch;
}
@@ -199,14 +199,14 @@ STDMETHODIMP CRM7AllocatorPresenter::Blt(UCHAR* pImageData, RMABitmapInfoHeader* }
}
- if(!fRGB && !fYUY2) {
+ if (!fRGB && !fYUY2) {
DDBLTFX fx;
INITDDSTRUCT(fx);
fx.dwFillColor = 0;
m_pVideoSurfaceOff->Blt(NULL, NULL, NULL, DDBLT_WAIT|DDBLT_COLORFILL, &fx);
HDC hDC;
- if(SUCCEEDED(m_pVideoSurfaceOff->GetDC(&hDC))) {
+ if (SUCCEEDED(m_pVideoSurfaceOff->GetDC(&hDC))) {
CString str;
str.Format(_T("Sorry, this format is not supported"));
@@ -223,10 +223,10 @@ STDMETHODIMP CRM7AllocatorPresenter::Blt(UCHAR* pImageData, RMABitmapInfoHeader* HRESULT hr;
- if(fRGB) {
+ if (fRGB) {
hr = m_pVideoSurface->Blt(dst, m_pVideoSurfaceOff, src2, DDBLT_WAIT, NULL);
}
- if(fYUY2) {
+ if (fYUY2) {
hr = m_pVideoSurface->Blt(dst, m_pVideoSurfaceYUY2, src2, DDBLT_WAIT, NULL);
}
@@ -240,7 +240,7 @@ STDMETHODIMP CRM7AllocatorPresenter::BeginOptimizedBlt(RMABitmapInfoHeader* pBit CAutoLock cAutoLock(this);
DeleteSurfaces();
m_NativeVideoSize = m_AspectRatio = CSize(pBitmapInfo->biWidth, abs(pBitmapInfo->biHeight));
- if(FAILED(AllocSurfaces())) {
+ if (FAILED(AllocSurfaces())) {
return E_FAIL;
}
return PNR_NOTIMPL;
diff --git a/src/filters/renderer/VideoRenderers/RM9AllocatorPresenter.cpp b/src/filters/renderer/VideoRenderers/RM9AllocatorPresenter.cpp index eb344cdc5..5eacf168a 100644 --- a/src/filters/renderer/VideoRenderers/RM9AllocatorPresenter.cpp +++ b/src/filters/renderer/VideoRenderers/RM9AllocatorPresenter.cpp @@ -53,21 +53,21 @@ HRESULT CRM9AllocatorPresenter::AllocSurfaces() HRESULT hr;
- if(FAILED(hr = m_pD3DDev->CreateOffscreenPlainSurface(
- m_NativeVideoSize.cx, m_NativeVideoSize.cy, D3DFMT_X8R8G8B8,
- D3DPOOL_DEFAULT, &m_pVideoSurfaceOff, NULL))) {
+ if (FAILED(hr = m_pD3DDev->CreateOffscreenPlainSurface(
+ m_NativeVideoSize.cx, m_NativeVideoSize.cy, D3DFMT_X8R8G8B8,
+ D3DPOOL_DEFAULT, &m_pVideoSurfaceOff, NULL))) {
return hr;
}
m_pD3DDev->ColorFill(m_pVideoSurfaceOff, NULL, 0);
- if(FAILED(hr = m_pD3DDev->CreateOffscreenPlainSurface(
- m_NativeVideoSize.cx, m_NativeVideoSize.cy, D3DFMT_YUY2,
- D3DPOOL_DEFAULT, &m_pVideoSurfaceYUY2, NULL))) {
+ if (FAILED(hr = m_pD3DDev->CreateOffscreenPlainSurface(
+ m_NativeVideoSize.cx, m_NativeVideoSize.cy, D3DFMT_YUY2,
+ D3DPOOL_DEFAULT, &m_pVideoSurfaceYUY2, NULL))) {
m_pVideoSurfaceYUY2 = NULL;
}
- if(m_pVideoSurfaceYUY2) {
+ if (m_pVideoSurfaceYUY2) {
m_pD3DDev->ColorFill(m_pVideoSurfaceOff, NULL, 0x80108010);
}
@@ -87,7 +87,7 @@ void CRM9AllocatorPresenter::DeleteSurfaces() STDMETHODIMP CRM9AllocatorPresenter::Blt(UCHAR* pImageData, RMABitmapInfoHeader* pBitmapInfo, REF(PNxRect) inDestRect, REF(PNxRect) inSrcRect)
{
- if(!m_pVideoSurface || !m_pVideoSurfaceOff) {
+ if (!m_pVideoSurface || !m_pVideoSurfaceOff) {
return E_FAIL;
}
@@ -95,13 +95,13 @@ STDMETHODIMP CRM9AllocatorPresenter::Blt(UCHAR* pImageData, RMABitmapInfoHeader* bool fYUY2 = false;
CRect src((RECT*)&inSrcRect), dst((RECT*)&inDestRect), src2(CPoint(0,0), src.Size());
- if(src.Width() > dst.Width() || src.Height() > dst.Height()) {
+ if (src.Width() > dst.Width() || src.Height() > dst.Height()) {
return E_FAIL;
}
D3DSURFACE_DESC d3dsd;
ZeroMemory(&d3dsd, sizeof(d3dsd));
- if(FAILED(m_pVideoSurfaceOff->GetDesc(&d3dsd))) {
+ if (FAILED(m_pVideoSurfaceOff->GetDesc(&d3dsd))) {
return E_FAIL;
}
@@ -109,7 +109,7 @@ STDMETHODIMP CRM9AllocatorPresenter::Blt(UCHAR* pImageData, RMABitmapInfoHeader* d3dsd.Format == D3DFMT_R8G8B8 || d3dsd.Format == D3DFMT_X8R8G8B8 || d3dsd.Format == D3DFMT_A8R8G8B8 ? 32 :
d3dsd.Format == D3DFMT_R5G6B5 ? 16 : 0;
- if(pBitmapInfo->biCompression == '024I') {
+ if (pBitmapInfo->biCompression == '024I') {
DWORD pitch = pBitmapInfo->biWidth;
DWORD size = pitch*abs(pBitmapInfo->biHeight);
@@ -117,22 +117,22 @@ STDMETHODIMP CRM9AllocatorPresenter::Blt(UCHAR* pImageData, RMABitmapInfoHeader* BYTE* u = pImageData + size + src.top*(pitch/2) + src.left/2;
BYTE* v = pImageData + size + size/4 + src.top*(pitch/2) + src.left/2;
- if(m_pVideoSurfaceYUY2) {
+ if (m_pVideoSurfaceYUY2) {
D3DLOCKED_RECT r;
- if(SUCCEEDED(m_pVideoSurfaceYUY2->LockRect(&r, src2, 0))) {
+ if (SUCCEEDED(m_pVideoSurfaceYUY2->LockRect(&r, src2, 0))) {
BitBltFromI420ToYUY2(src.Width(), src.Height(), (BYTE*)r.pBits, r.Pitch, y, u, v, pitch);
m_pVideoSurfaceYUY2->UnlockRect();
fYUY2 = true;
}
} else {
D3DLOCKED_RECT r;
- if(SUCCEEDED(m_pVideoSurfaceOff->LockRect(&r, src2, 0))) {
+ if (SUCCEEDED(m_pVideoSurfaceOff->LockRect(&r, src2, 0))) {
BitBltFromI420ToRGB(src.Width(), src.Height(), (BYTE*)r.pBits, r.Pitch, dbpp, y, u, v, pitch);
m_pVideoSurfaceOff->UnlockRect();
fRGB = true;
}
}
- } else if(pBitmapInfo->biCompression == '2YUY') {
+ } else if (pBitmapInfo->biCompression == '2YUY') {
DWORD w = pBitmapInfo->biWidth;
DWORD h = abs(pBitmapInfo->biHeight);
DWORD pitch = pBitmapInfo->biWidth*2;
@@ -141,23 +141,23 @@ STDMETHODIMP CRM9AllocatorPresenter::Blt(UCHAR* pImageData, RMABitmapInfoHeader* BYTE* yvyu = pImageData + src.top*pitch + src.left*2;
- if(m_pVideoSurfaceYUY2) {
+ if (m_pVideoSurfaceYUY2) {
D3DLOCKED_RECT r;
- if(SUCCEEDED(m_pVideoSurfaceYUY2->LockRect(&r, src2, 0))) {
+ if (SUCCEEDED(m_pVideoSurfaceYUY2->LockRect(&r, src2, 0))) {
BitBltFromYUY2ToYUY2(src.Width(), src.Height(), (BYTE*)r.pBits, r.Pitch, yvyu, pitch);
m_pVideoSurfaceYUY2->UnlockRect();
fYUY2 = true;
}
} else {
D3DLOCKED_RECT r;
- if(SUCCEEDED(m_pVideoSurfaceOff->LockRect(&r, src2, 0))) {
+ if (SUCCEEDED(m_pVideoSurfaceOff->LockRect(&r, src2, 0))) {
BitBltFromYUY2ToRGB(src.Width(), src.Height(), (BYTE*)r.pBits, r.Pitch, dbpp, yvyu, pitch);
m_pVideoSurfaceOff->UnlockRect();
fRGB = true;
}
}
- } else if(pBitmapInfo->biCompression == 0 || pBitmapInfo->biCompression == 3
- || pBitmapInfo->biCompression == 'BGRA') {
+ } else if (pBitmapInfo->biCompression == 0 || pBitmapInfo->biCompression == 3
+ || pBitmapInfo->biCompression == 'BGRA') {
DWORD w = pBitmapInfo->biWidth;
DWORD h = abs(pBitmapInfo->biHeight);
DWORD pitch = pBitmapInfo->biWidth*pBitmapInfo->biBitCount>>3;
@@ -167,9 +167,9 @@ STDMETHODIMP CRM9AllocatorPresenter::Blt(UCHAR* pImageData, RMABitmapInfoHeader* BYTE* rgb = pImageData + src.top*pitch + src.left*(pBitmapInfo->biBitCount>>3);
D3DLOCKED_RECT r;
- if(SUCCEEDED(m_pVideoSurfaceOff->LockRect(&r, src2, 0))) {
+ if (SUCCEEDED(m_pVideoSurfaceOff->LockRect(&r, src2, 0))) {
BYTE* pBits = (BYTE*)r.pBits;
- if(pBitmapInfo->biHeight > 0) {
+ if (pBitmapInfo->biHeight > 0) {
pBits += r.Pitch*(src.Height()-1);
r.Pitch = -r.Pitch;
}
@@ -179,11 +179,11 @@ STDMETHODIMP CRM9AllocatorPresenter::Blt(UCHAR* pImageData, RMABitmapInfoHeader* }
}
- if(!fRGB && !fYUY2) {
+ if (!fRGB && !fYUY2) {
m_pD3DDev->ColorFill(m_pVideoSurfaceOff, NULL, 0);
HDC hDC;
- if(SUCCEEDED(m_pVideoSurfaceOff->GetDC(&hDC))) {
+ if (SUCCEEDED(m_pVideoSurfaceOff->GetDC(&hDC))) {
CString str;
str.Format(_T("Sorry, this format is not supported"));
@@ -199,10 +199,10 @@ STDMETHODIMP CRM9AllocatorPresenter::Blt(UCHAR* pImageData, RMABitmapInfoHeader* HRESULT hr;
- if(fRGB) {
+ if (fRGB) {
hr = m_pD3DDev->StretchRect(m_pVideoSurfaceOff, src2, m_pVideoSurface[m_nCurSurface], dst, D3DTEXF_NONE);
}
- if(fYUY2) {
+ if (fYUY2) {
hr = m_pD3DDev->StretchRect(m_pVideoSurfaceYUY2, src2, m_pVideoSurface[m_nCurSurface], dst, D3DTEXF_NONE);
}
@@ -217,7 +217,7 @@ STDMETHODIMP CRM9AllocatorPresenter::BeginOptimizedBlt(RMABitmapInfoHeader* pBit CAutoLock cRenderLock(&m_RenderLock);
DeleteSurfaces();
m_NativeVideoSize = m_AspectRatio = CSize(pBitmapInfo->biWidth, abs(pBitmapInfo->biHeight));
- if(FAILED(AllocSurfaces())) {
+ if (FAILED(AllocSurfaces())) {
return E_FAIL;
}
return PNR_NOTIMPL;
diff --git a/src/filters/renderer/VideoRenderers/SyncRenderer.cpp b/src/filters/renderer/VideoRenderers/SyncRenderer.cpp index 6d6d35f00..03bdafaf4 100644 --- a/src/filters/renderer/VideoRenderers/SyncRenderer.cpp +++ b/src/filters/renderer/VideoRenderers/SyncRenderer.cpp @@ -94,7 +94,7 @@ CBaseAP::CBaseAP(HWND hWnd, bool bFullscreen, HRESULT& hr, CString &_Error): m_llEstVBlankTime(0),
m_CurrentAdapter(0)
{
- if(FAILED(hr)) {
+ if (FAILED(hr)) {
_Error += L"ISubPicAllocatorPresenterImpl failed\n";
return;
}
@@ -105,7 +105,7 @@ CBaseAP::CBaseAP(HWND hWnd, bool bFullscreen, HRESULT& hr, CString &_Error): m_pD3DXCreateFont = NULL;
m_pD3DXCreateSprite = NULL;
hDll = GetRenderersData()->GetD3X9Dll();
- if(hDll) {
+ if (hDll) {
(FARPROC &)m_pD3DXLoadSurfaceFromMemory = GetProcAddress(hDll, "D3DXLoadSurfaceFromMemory");
(FARPROC &)m_pD3DXCreateLine = GetProcAddress(hDll, "D3DXCreateLine");
(FARPROC &)m_pD3DXCreateFont = GetProcAddress(hDll, "D3DXCreateFontW");
@@ -135,16 +135,16 @@ CBaseAP::CBaseAP(HWND hWnd, bool bFullscreen, HRESULT& hr, CString &_Error): if (m_pDirect3DCreate9Ex) {
DEBUG_ONLY(_tprintf(_T("m_pDirect3DCreate9Ex\n")));
m_pDirect3DCreate9Ex(D3D_SDK_VERSION, &m_pD3DEx);
- if(!m_pD3DEx) {
+ if (!m_pD3DEx) {
m_pDirect3DCreate9Ex(D3D9b_SDK_VERSION, &m_pD3DEx);
}
}
- if(!m_pD3DEx) {
+ if (!m_pD3DEx) {
m_pD3D.Attach(Direct3DCreate9(D3D_SDK_VERSION));
- if(!m_pD3D) {
+ if (!m_pD3D) {
m_pD3D.Attach(Direct3DCreate9(D3D9b_SDK_VERSION));
}
- if(m_pD3D) {
+ if (m_pD3D) {
DEBUG_ONLY(_tprintf(_T("m_pDirect3DCreate9\n")));
}
} else {
@@ -205,16 +205,16 @@ void CBaseAP::AdjustQuad(MYD3DVERTEX<texcoords>* v, double dx, double dy) {
double offset = 0.5;
- for(int i = 0; i < 4; i++) {
+ for (int i = 0; i < 4; i++) {
v[i].x -= offset;
v[i].y -= offset;
- for(int j = 0; j < max(texcoords-1, 1); j++) {
+ for (int j = 0; j < max(texcoords-1, 1); j++) {
v[i].t[j].u -= offset*dx;
v[i].t[j].v -= offset*dy;
}
- if(texcoords > 1) {
+ if (texcoords > 1) {
v[i].t[texcoords-1].u -= offset;
v[i].t[texcoords-1].v -= offset;
}
@@ -224,12 +224,12 @@ void CBaseAP::AdjustQuad(MYD3DVERTEX<texcoords>* v, double dx, double dy) template<int texcoords>
HRESULT CBaseAP::TextureBlt(IDirect3DDevice9* pD3DDev, MYD3DVERTEX<texcoords> v[4], D3DTEXTUREFILTERTYPE filter = D3DTEXF_LINEAR)
{
- if(!pD3DDev) {
+ if (!pD3DDev) {
return E_POINTER;
}
DWORD FVF = 0;
- switch(texcoords) {
+ switch (texcoords) {
case 1:
FVF = D3DFVF_TEX1;
break;
@@ -268,7 +268,7 @@ HRESULT CBaseAP::TextureBlt(IDirect3DDevice9* pD3DDev, MYD3DVERTEX<texcoords> v[ hr = pD3DDev->SetRenderState(D3DRS_SCISSORTESTENABLE, FALSE);
hr = pD3DDev->SetRenderState(D3DRS_COLORWRITEENABLE, D3DCOLORWRITEENABLE_ALPHA|D3DCOLORWRITEENABLE_BLUE|D3DCOLORWRITEENABLE_GREEN|D3DCOLORWRITEENABLE_RED);
- for(int i = 0; i < texcoords; i++) {
+ for (int i = 0; i < texcoords; i++) {
hr = pD3DDev->SetSamplerState(i, D3DSAMP_MAGFILTER, filter);
hr = pD3DDev->SetSamplerState(i, D3DSAMP_MINFILTER, filter);
hr = pD3DDev->SetSamplerState(i, D3DSAMP_MIPFILTER, D3DTEXF_NONE);
@@ -284,7 +284,7 @@ HRESULT CBaseAP::TextureBlt(IDirect3DDevice9* pD3DDev, MYD3DVERTEX<texcoords> v[ v[3] = tmp;
hr = pD3DDev->DrawPrimitiveUP(D3DPT_TRIANGLEFAN, 2, v, sizeof(v[0]));
- for(int i = 0; i < texcoords; i++) {
+ for (int i = 0; i < texcoords; i++) {
pD3DDev->SetTexture(i, NULL);
}
@@ -293,7 +293,7 @@ HRESULT CBaseAP::TextureBlt(IDirect3DDevice9* pD3DDev, MYD3DVERTEX<texcoords> v[ HRESULT CBaseAP::DrawRectBase(IDirect3DDevice9* pD3DDev, MYD3DVERTEX<0> v[4])
{
- if(!pD3DDev) {
+ if (!pD3DDev) {
return E_POINTER;
}
@@ -401,17 +401,17 @@ HRESULT CBaseAP::CreateDXDevice(CString &_Error) m_pResizerPixelShader[3] = 0;
POSITION pos = m_pPixelShadersScreenSpace.GetHeadPosition();
- while(pos) {
+ while (pos) {
CExternalPixelShader &Shader = m_pPixelShadersScreenSpace.GetNext(pos);
Shader.m_pPixelShader = NULL;
}
pos = m_pPixelShaders.GetHeadPosition();
- while(pos) {
+ while (pos) {
CExternalPixelShader &Shader = m_pPixelShaders.GetNext(pos);
Shader.m_pPixelShader = NULL;
}
- if(!m_pD3D) {
+ if (!m_pD3D) {
_Error += L"Failed to create Direct3D device\n";
return E_UNEXPECTED;
}
@@ -419,7 +419,7 @@ HRESULT CBaseAP::CreateDXDevice(CString &_Error) D3DDISPLAYMODE d3ddm;
ZeroMemory(&d3ddm, sizeof(d3ddm));
m_CurrentAdapter = GetAdapter(m_pD3D);
- if(FAILED(m_pD3D->GetAdapterDisplayMode(m_CurrentAdapter, &d3ddm))) {
+ if (FAILED(m_pD3D->GetAdapterDisplayMode(m_CurrentAdapter, &d3ddm))) {
_Error += L"Can not retrieve display mode data\n";
return E_UNEXPECTED;
}
@@ -454,7 +454,7 @@ HRESULT CBaseAP::CreateDXDevice(CString &_Error) pp.Flags = D3DPRESENTFLAG_VIDEO;
m_bHighColorResolution = s.m_RenderSettings.iEVRHighColorResolution;
if (m_bHighColorResolution) {
- if(FAILED(m_pD3D->CheckDeviceType(D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL, d3ddm.Format, D3DFMT_A2R10G10B10, false))) {
+ if (FAILED(m_pD3D->CheckDeviceType(D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL, d3ddm.Format, D3DFMT_A2R10G10B10, false))) {
m_strStatsMsg[MSG_ERROR].Format (L"10 bit RGB is not supported by this graphics device in this resolution.");
m_bHighColorResolution = false;
}
@@ -509,7 +509,7 @@ HRESULT CBaseAP::CreateDXDevice(CString &_Error) m_DisplayType = d3ddm.Format;
m_bHighColorResolution = s.m_RenderSettings.iEVRHighColorResolution;
if (m_bHighColorResolution) {
- if(FAILED(m_pD3D->CheckDeviceType(D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL, d3ddm.Format, D3DFMT_A2R10G10B10, false))) {
+ if (FAILED(m_pD3D->CheckDeviceType(D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL, d3ddm.Format, D3DFMT_A2R10G10B10, false))) {
m_strStatsMsg[MSG_ERROR].Format (L"10 bit RGB is not supported by this graphics device in this resolution.");
m_bHighColorResolution = false;
}
@@ -546,7 +546,7 @@ HRESULT CBaseAP::CreateDXDevice(CString &_Error) }
}
- while(hr == D3DERR_DEVICELOST) {
+ while (hr == D3DERR_DEVICELOST) {
TRACE("D3DERR_DEVICELOST. Trying to Reset.\n");
hr = m_pD3DDev->TestCooperativeLevel();
}
@@ -565,14 +565,14 @@ HRESULT CBaseAP::CreateDXDevice(CString &_Error) m_pPSC.Attach(DNew CPixelShaderCompiler(m_pD3DDev, true));
m_filter = D3DTEXF_NONE;
- if(m_caps.StretchRectFilterCaps&D3DPTFILTERCAPS_MINFLINEAR && m_caps.StretchRectFilterCaps&D3DPTFILTERCAPS_MAGFLINEAR) {
+ if (m_caps.StretchRectFilterCaps&D3DPTFILTERCAPS_MINFLINEAR && m_caps.StretchRectFilterCaps&D3DPTFILTERCAPS_MAGFLINEAR) {
m_filter = D3DTEXF_LINEAR;
}
m_bicubicA = 0;
CSize size;
- switch(GetRenderersSettings().nSPCMaxRes) {
+ switch (GetRenderersSettings().nSPCMaxRes) {
case 0:
default:
size = m_ScreenSize;
@@ -606,11 +606,11 @@ HRESULT CBaseAP::CreateDXDevice(CString &_Error) break;
}
- if(m_pAllocator) {
+ if (m_pAllocator) {
m_pAllocator->ChangeDevice(m_pD3DDev);
} else {
m_pAllocator = DNew CDX9SubPicAllocator(m_pD3DDev, size, GetRenderersSettings().fSPCPow2Tex, false);
- if(!m_pAllocator) {
+ if (!m_pAllocator) {
_Error += L"CDX9SubPicAllocator failed\n";
return E_FAIL;
}
@@ -619,7 +619,7 @@ HRESULT CBaseAP::CreateDXDevice(CString &_Error) hr = S_OK;
CComPtr<ISubPicProvider> pSubPicProvider;
- if(m_pSubPicQueue) {
+ if (m_pSubPicQueue) {
DEBUG_ONLY(_tprintf(_T("m_pSubPicQueue != NULL\n")));
m_pSubPicQueue->GetSubPicProvider(&pSubPicProvider);
}
@@ -628,12 +628,12 @@ HRESULT CBaseAP::CreateDXDevice(CString &_Error) m_pSubPicQueue = GetRenderersSettings().nSPCSize > 0
? (ISubPicQueue*)DNew CSubPicQueue(GetRenderersSettings().nSPCSize, !GetRenderersSettings().fSPCAllowAnimationWhenBuffering, m_pAllocator, &hr)
: (ISubPicQueue*)DNew CSubPicQueueNoThread(m_pAllocator, &hr);
- if(!m_pSubPicQueue || FAILED(hr)) {
+ if (!m_pSubPicQueue || FAILED(hr)) {
_Error += L"m_pSubPicQueue failed\n";
return E_FAIL;
}
- if(pSubPicProvider) {
+ if (pSubPicProvider) {
m_pSubPicQueue->SetSubPicProvider(pSubPicProvider);
}
@@ -715,19 +715,19 @@ HRESULT CBaseAP::ResetDXDevice(CString &_Error) m_pResizerPixelShader[3] = 0;
POSITION pos = m_pPixelShadersScreenSpace.GetHeadPosition();
- while(pos) {
+ while (pos) {
CExternalPixelShader &Shader = m_pPixelShadersScreenSpace.GetNext(pos);
Shader.m_pPixelShader = NULL;
}
pos = m_pPixelShaders.GetHeadPosition();
- while(pos) {
+ while (pos) {
CExternalPixelShader &Shader = m_pPixelShaders.GetNext(pos);
Shader.m_pPixelShader = NULL;
}
D3DDISPLAYMODE d3ddm;
ZeroMemory(&d3ddm, sizeof(d3ddm));
- if(FAILED(m_pD3D->GetAdapterDisplayMode(GetAdapter(m_pD3D), &d3ddm))) {
+ if (FAILED(m_pD3D->GetAdapterDisplayMode(GetAdapter(m_pD3D), &d3ddm))) {
_Error += L"Can not retrieve display mode data\n";
return E_UNEXPECTED;
}
@@ -755,7 +755,7 @@ HRESULT CBaseAP::ResetDXDevice(CString &_Error) } else {
pp.BackBufferFormat = d3ddm.Format;
}
- if(FAILED(m_pD3DEx->CheckDeviceType(D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL, pp.BackBufferFormat, pp.BackBufferFormat, false))) {
+ if (FAILED(m_pD3DEx->CheckDeviceType(D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL, pp.BackBufferFormat, pp.BackBufferFormat, false))) {
_Error += L"10 bit RGB is not supported by this graphics device in exclusive mode fullscreen.\n";
return hr;
}
@@ -791,7 +791,7 @@ HRESULT CBaseAP::ResetDXDevice(CString &_Error) m_BackbufferType = D3DFMT_A2R10G10B10;
pp.BackBufferFormat = D3DFMT_A2R10G10B10;
}
- if(FAILED(m_pD3DEx->CheckDeviceType(D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL, pp.BackBufferFormat, pp.BackBufferFormat, false))) {
+ if (FAILED(m_pD3DEx->CheckDeviceType(D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL, pp.BackBufferFormat, pp.BackBufferFormat, false))) {
_Error += L"10 bit RGB is not supported by this graphics device in windowed mode.\n";
return hr;
}
@@ -830,7 +830,7 @@ HRESULT CBaseAP::ResetDXDevice(CString &_Error) m_pPSC.Attach(DNew CPixelShaderCompiler(m_pD3DDev, true));
m_filter = D3DTEXF_NONE;
- if((m_caps.StretchRectFilterCaps&D3DPTFILTERCAPS_MINFLINEAR)
+ if ((m_caps.StretchRectFilterCaps&D3DPTFILTERCAPS_MINFLINEAR)
&& (m_caps.StretchRectFilterCaps&D3DPTFILTERCAPS_MAGFLINEAR)) {
m_filter = D3DTEXF_LINEAR;
}
@@ -838,11 +838,11 @@ HRESULT CBaseAP::ResetDXDevice(CString &_Error) m_bicubicA = 0;
CComPtr<ISubPicProvider> pSubPicProvider;
- if(m_pSubPicQueue) {
+ if (m_pSubPicQueue) {
m_pSubPicQueue->GetSubPicProvider(&pSubPicProvider);
}
CSize size;
- switch(GetRenderersSettings().nSPCMaxRes) {
+ switch (GetRenderersSettings().nSPCMaxRes) {
case 0:
default:
size = m_ScreenSize;
@@ -876,11 +876,11 @@ HRESULT CBaseAP::ResetDXDevice(CString &_Error) break;
}
- if(m_pAllocator) {
+ if (m_pAllocator) {
m_pAllocator->ChangeDevice(m_pD3DDev);
} else {
m_pAllocator = DNew CDX9SubPicAllocator(m_pD3DDev, size, GetRenderersSettings().fSPCPow2Tex, false);
- if(!m_pAllocator) {
+ if (!m_pAllocator) {
_Error += L"CDX9SubPicAllocator failed\n";
return E_FAIL;
@@ -891,13 +891,13 @@ HRESULT CBaseAP::ResetDXDevice(CString &_Error) m_pSubPicQueue = GetRenderersSettings().nSPCSize > 0
? (ISubPicQueue*)DNew CSubPicQueue(GetRenderersSettings().nSPCSize, !GetRenderersSettings().fSPCAllowAnimationWhenBuffering, m_pAllocator, &hr)
: (ISubPicQueue*)DNew CSubPicQueueNoThread(m_pAllocator, &hr);
- if(!m_pSubPicQueue || FAILED(hr)) {
+ if (!m_pSubPicQueue || FAILED(hr)) {
_Error += L"m_pSubPicQueue failed\n";
return E_FAIL;
}
- if(pSubPicProvider) {
+ if (pSubPicProvider) {
m_pSubPicQueue->SetSubPicProvider(pSubPicProvider);
}
@@ -928,7 +928,7 @@ HRESULT CBaseAP::AllocSurfaces(D3DFORMAT Format) CRenderersSettings& s = GetRenderersSettings();
- for(int i = 0; i < m_nDXSurface+2; i++) {
+ for (int i = 0; i < m_nDXSurface+2; i++) {
m_pVideoTexture[i] = NULL;
m_pVideoSurface[i] = NULL;
}
@@ -938,26 +938,26 @@ HRESULT CBaseAP::AllocSurfaces(D3DFORMAT Format) m_SurfaceType = Format;
HRESULT hr;
- if(s.iAPSurfaceUsage == VIDRNDT_AP_TEXTURE2D || s.iAPSurfaceUsage == VIDRNDT_AP_TEXTURE3D) {
+ if (s.iAPSurfaceUsage == VIDRNDT_AP_TEXTURE2D || s.iAPSurfaceUsage == VIDRNDT_AP_TEXTURE3D) {
int nTexturesNeeded = s.iAPSurfaceUsage == VIDRNDT_AP_TEXTURE3D ? m_nDXSurface+2 : 1;
- for(int i = 0; i < nTexturesNeeded; i++) {
- if(FAILED(hr = m_pD3DDev->CreateTexture(
- m_NativeVideoSize.cx, m_NativeVideoSize.cy, 1, D3DUSAGE_RENDERTARGET, Format, D3DPOOL_DEFAULT, &m_pVideoTexture[i], NULL))) {
+ for (int i = 0; i < nTexturesNeeded; i++) {
+ if (FAILED(hr = m_pD3DDev->CreateTexture(
+ m_NativeVideoSize.cx, m_NativeVideoSize.cy, 1, D3DUSAGE_RENDERTARGET, Format, D3DPOOL_DEFAULT, &m_pVideoTexture[i], NULL))) {
return hr;
}
- if(FAILED(hr = m_pVideoTexture[i]->GetSurfaceLevel(0, &m_pVideoSurface[i]))) {
+ if (FAILED(hr = m_pVideoTexture[i]->GetSurfaceLevel(0, &m_pVideoSurface[i]))) {
return hr;
}
}
- if(s.iAPSurfaceUsage == VIDRNDT_AP_TEXTURE2D) {
- for(int i = 0; i < m_nDXSurface+2; i++) {
+ if (s.iAPSurfaceUsage == VIDRNDT_AP_TEXTURE2D) {
+ for (int i = 0; i < m_nDXSurface+2; i++) {
m_pVideoTexture[i] = NULL;
}
}
} else {
- if(FAILED(hr = m_pD3DDev->CreateOffscreenPlainSurface(m_NativeVideoSize.cx, m_NativeVideoSize.cy, D3DFMT_X8R8G8B8, D3DPOOL_DEFAULT, &m_pVideoSurface[m_nCurSurface], NULL))) {
+ if (FAILED(hr = m_pD3DDev->CreateOffscreenPlainSurface(m_NativeVideoSize.cx, m_NativeVideoSize.cy, D3DFMT_X8R8G8B8, D3DPOOL_DEFAULT, &m_pVideoSurface[m_nCurSurface], NULL))) {
return hr;
}
}
@@ -971,7 +971,7 @@ void CBaseAP::DeleteSurfaces() CAutoLock cAutoLock(this);
CAutoLock cRenderLock(&m_allocatorLock);
- for(int i = 0; i < m_nDXSurface+2; i++) {
+ for (int i = 0; i < m_nDXSurface+2; i++) {
m_pVideoTexture[i] = NULL;
m_pVideoSurface[i] = NULL;
}
@@ -979,18 +979,18 @@ void CBaseAP::DeleteSurfaces() UINT CBaseAP::GetAdapter(IDirect3D9* pD3D)
{
- if(m_hWnd == NULL || pD3D == NULL) {
+ if (m_hWnd == NULL || pD3D == NULL) {
return D3DADAPTER_DEFAULT;
}
HMONITOR hMonitor = MonitorFromWindow(m_hWnd, MONITOR_DEFAULTTONEAREST);
- if(hMonitor == NULL) {
+ if (hMonitor == NULL) {
return D3DADAPTER_DEFAULT;
}
- for(UINT adp = 0, num_adp = pD3D->GetAdapterCount(); adp < num_adp; ++adp) {
+ for (UINT adp = 0, num_adp = pD3D->GetAdapterCount(); adp < num_adp; ++adp) {
HMONITOR hAdpMon = pD3D->GetAdapterMonitor(adp);
- if(hAdpMon == hMonitor) {
+ if (hAdpMon == hMonitor) {
return adp;
}
}
@@ -1008,7 +1008,7 @@ bool CBaseAP::ClipToSurface(IDirect3DSurface9* pSurface, CRect& s, CRect& d) {
D3DSURFACE_DESC d3dsd;
ZeroMemory(&d3dsd, sizeof(d3dsd));
- if(FAILED(pSurface->GetDesc(&d3dsd))) {
+ if (FAILED(pSurface->GetDesc(&d3dsd))) {
return false;
}
@@ -1016,25 +1016,25 @@ bool CBaseAP::ClipToSurface(IDirect3DSurface9* pSurface, CRect& s, CRect& d) int sw = s.Width(), sh = s.Height();
int dw = d.Width(), dh = d.Height();
- if(d.left >= w || d.right < 0 || d.top >= h || d.bottom < 0
+ if (d.left >= w || d.right < 0 || d.top >= h || d.bottom < 0
|| sw <= 0 || sh <= 0 || dw <= 0 || dh <= 0) {
s.SetRectEmpty();
d.SetRectEmpty();
return true;
}
- if(d.right > w) {
+ if (d.right > w) {
s.right -= (d.right-w)*sw/dw;
d.right = w;
}
- if(d.bottom > h) {
+ if (d.bottom > h) {
s.bottom -= (d.bottom-h)*sh/dh;
d.bottom = h;
}
- if(d.left < 0) {
+ if (d.left < 0) {
s.left += (0-d.left)*sw/dw;
d.left = 0;
}
- if(d.top < 0) {
+ if (d.top < 0) {
s.top += (0-d.top)*sh/dh;
d.top = 0;
}
@@ -1089,18 +1089,18 @@ HRESULT CBaseAP::InitResizers(float bicubicA, bool bNeedScreenSizeTexture) m_pScreenSizeTemporaryTexture[0] = NULL;
m_pScreenSizeTemporaryTexture[1] = NULL;
- for(int i = 0; i < countof(m_pResizerPixelShader); i++) {
+ for (int i = 0; i < countof(m_pResizerPixelShader); i++) {
m_pResizerPixelShader[i] = NULL;
}
- if(m_caps.PixelShaderVersion < D3DPS_VERSION(2, 0)) {
+ if (m_caps.PixelShaderVersion < D3DPS_VERSION(2, 0)) {
return E_FAIL;
}
LPCSTR pProfile = m_caps.PixelShaderVersion >= D3DPS_VERSION(3, 0) ? "ps_3_0" : "ps_2_0";
CStringA str;
- if(!LoadResource(IDF_SHADER_RESIZER, str, _T("FILE"))) {
+ if (!LoadResource(IDF_SHADER_RESIZER, str, _T("FILE"))) {
return E_FAIL;
}
@@ -1111,28 +1111,28 @@ HRESULT CBaseAP::InitResizers(float bicubicA, bool bNeedScreenSizeTexture) LPCSTR pEntries[] = {"main_bilinear", "main_bicubic1pass", "main_bicubic2pass_pass1", "main_bicubic2pass_pass2"};
ASSERT(countof(pEntries) == countof(m_pResizerPixelShader));
- for(int i = 0; i < countof(pEntries); i++) {
+ for (int i = 0; i < countof(pEntries); i++) {
CString ErrorMessage;
CString DissAssembly;
hr = m_pPSC->CompileShader(str, pEntries[i], pProfile, 0, &m_pResizerPixelShader[i], &DissAssembly, &ErrorMessage);
- if(FAILED(hr)) {
+ if (FAILED(hr)) {
TRACE("%ws", ErrorMessage.GetString());
ASSERT (0);
return hr;
}
}
- if(m_bicubicA || bNeedScreenSizeTexture) {
- if(FAILED(m_pD3DDev->CreateTexture(
- min(m_ScreenSize.cx, (int)m_caps.MaxTextureWidth), min(max(m_ScreenSize.cy, m_NativeVideoSize.cy), (int)m_caps.MaxTextureHeight), 1, D3DUSAGE_RENDERTARGET, D3DFMT_A8R8G8B8,
- D3DPOOL_DEFAULT, &m_pScreenSizeTemporaryTexture[0], NULL))) {
+ if (m_bicubicA || bNeedScreenSizeTexture) {
+ if (FAILED(m_pD3DDev->CreateTexture(
+ min(m_ScreenSize.cx, (int)m_caps.MaxTextureWidth), min(max(m_ScreenSize.cy, m_NativeVideoSize.cy), (int)m_caps.MaxTextureHeight), 1, D3DUSAGE_RENDERTARGET, D3DFMT_A8R8G8B8,
+ D3DPOOL_DEFAULT, &m_pScreenSizeTemporaryTexture[0], NULL))) {
ASSERT(0);
m_pScreenSizeTemporaryTexture[0] = NULL; // will do 1 pass then
}
}
- if(m_bicubicA || bNeedScreenSizeTexture) {
- if(FAILED(m_pD3DDev->CreateTexture(
- min(m_ScreenSize.cx, (int)m_caps.MaxTextureWidth), min(max(m_ScreenSize.cy, m_NativeVideoSize.cy), (int)m_caps.MaxTextureHeight), 1, D3DUSAGE_RENDERTARGET, D3DFMT_A8R8G8B8,
- D3DPOOL_DEFAULT, &m_pScreenSizeTemporaryTexture[1], NULL))) {
+ if (m_bicubicA || bNeedScreenSizeTexture) {
+ if (FAILED(m_pD3DDev->CreateTexture(
+ min(m_ScreenSize.cx, (int)m_caps.MaxTextureWidth), min(max(m_ScreenSize.cy, m_NativeVideoSize.cy), (int)m_caps.MaxTextureHeight), 1, D3DUSAGE_RENDERTARGET, D3DFMT_A8R8G8B8,
+ D3DPOOL_DEFAULT, &m_pScreenSizeTemporaryTexture[1], NULL))) {
ASSERT(0);
m_pScreenSizeTemporaryTexture[1] = NULL; // will do 1 pass then
}
@@ -1145,7 +1145,7 @@ HRESULT CBaseAP::TextureCopy(IDirect3DTexture9* pTexture) HRESULT hr;
D3DSURFACE_DESC desc;
- if(!pTexture || FAILED(pTexture->GetLevelDesc(0, &desc))) {
+ if (!pTexture || FAILED(pTexture->GetLevelDesc(0, &desc))) {
return E_FAIL;
}
@@ -1157,7 +1157,7 @@ HRESULT CBaseAP::TextureCopy(IDirect3DTexture9* pTexture) {0, h, 0.5f, 2.0f, 0, 1},
{w, h, 0.5f, 2.0f, 1, 1},
};
- for(int i = 0; i < countof(v); i++) {
+ for (int i = 0; i < countof(v); i++) {
v[i].x -= 0.5;
v[i].y -= 0.5;
}
@@ -1174,7 +1174,7 @@ HRESULT CBaseAP::DrawRect(DWORD _Color, DWORD _Alpha, const CRect &_Rect) {float(_Rect.left), float(_Rect.bottom), 0.5f, 2.0f, Color},
{float(_Rect.right), float(_Rect.bottom), 0.5f, 2.0f, Color},
};
- for(int i = 0; i < countof(v); i++) {
+ for (int i = 0; i < countof(v); i++) {
v[i].x -= 0.5;
v[i].y -= 0.5;
}
@@ -1186,7 +1186,7 @@ HRESULT CBaseAP::TextureResize(IDirect3DTexture9* pTexture, Vector dst[4], D3DTE HRESULT hr;
D3DSURFACE_DESC desc;
- if(!pTexture || FAILED(pTexture->GetLevelDesc(0, &desc))) {
+ if (!pTexture || FAILED(pTexture->GetLevelDesc(0, &desc))) {
return E_FAIL;
}
@@ -1214,7 +1214,7 @@ HRESULT CBaseAP::TextureResizeBilinear(IDirect3DTexture9* pTexture, Vector dst[4 HRESULT hr;
D3DSURFACE_DESC desc;
- if(!pTexture || FAILED(pTexture->GetLevelDesc(0, &desc))) {
+ if (!pTexture || FAILED(pTexture->GetLevelDesc(0, &desc))) {
return E_FAIL;
}
@@ -1247,7 +1247,7 @@ HRESULT CBaseAP::TextureResizeBicubic1pass(IDirect3DTexture9* pTexture, Vector d HRESULT hr;
D3DSURFACE_DESC desc;
- if(!pTexture || FAILED(pTexture->GetLevelDesc(0, &desc))) {
+ if (!pTexture || FAILED(pTexture->GetLevelDesc(0, &desc))) {
return E_FAIL;
}
@@ -1362,7 +1362,7 @@ HRESULT CBaseAP::TextureResizeBicubic2pass(IDirect3DTexture9* pTexture, Vector d HRESULT CBaseAP::AlphaBlt(RECT* pSrc, RECT* pDst, IDirect3DTexture9* pTexture)
{
- if(!pSrc || !pDst) {
+ if (!pSrc || !pDst) {
return E_POINTER;
}
@@ -1373,7 +1373,7 @@ HRESULT CBaseAP::AlphaBlt(RECT* pSrc, RECT* pDst, IDirect3DTexture9* pTexture) do {
D3DSURFACE_DESC d3dsd;
ZeroMemory(&d3dsd, sizeof(d3dsd));
- if(FAILED(pTexture->GetLevelDesc(0, &d3dsd)) /*|| d3dsd.Type != D3DRTYPE_TEXTURE*/) {
+ if (FAILED(pTexture->GetLevelDesc(0, &d3dsd)) /*|| d3dsd.Type != D3DRTYPE_TEXTURE*/) {
break;
}
@@ -1433,7 +1433,7 @@ HRESULT CBaseAP::AlphaBlt(RECT* pSrc, RECT* pDst, IDirect3DTexture9* pTexture) m_pD3DDev->SetRenderState(D3DRS_DESTBLEND, db);
return S_OK;
- } while(0);
+ } while (0);
return E_FAIL;
}
@@ -1550,7 +1550,7 @@ STDMETHODIMP_(bool) CBaseAP::Paint(bool fAll) llSyncOffset = REFERENCE_TIME(10000.0 * dSyncOffset); // Reference time units (100 ns)
m_llEstVBlankTime = llCurRefTime + llSyncOffset; // Estimated time for the start of next vblank
- if(m_WindowRect.right <= m_WindowRect.left || m_WindowRect.bottom <= m_WindowRect.top
+ if (m_WindowRect.right <= m_WindowRect.left || m_WindowRect.bottom <= m_WindowRect.top
|| m_NativeVideoSize.cx <= 0 || m_NativeVideoSize.cy <= 0
|| !m_pVideoSurface) {
return false;
@@ -1567,18 +1567,18 @@ STDMETHODIMP_(bool) CBaseAP::Paint(bool fAll) m_pD3DDev->GetBackBuffer(0, 0, D3DBACKBUFFER_TYPE_MONO, &pBackBuffer);
m_pD3DDev->SetRenderTarget(0, pBackBuffer);
hr = m_pD3DDev->Clear(0, NULL, D3DCLEAR_TARGET, 0, 1.0f, 0);
- if(!rDstVid.IsRectEmpty()) {
- if(m_pVideoTexture[m_nCurSurface]) {
+ if (!rDstVid.IsRectEmpty()) {
+ if (m_pVideoTexture[m_nCurSurface]) {
CComPtr<IDirect3DTexture9> pVideoTexture = m_pVideoTexture[m_nCurSurface];
- if(m_pVideoTexture[m_nDXSurface] && m_pVideoTexture[m_nDXSurface+1] && !m_pPixelShaders.IsEmpty()) {
+ if (m_pVideoTexture[m_nDXSurface] && m_pVideoTexture[m_nDXSurface+1] && !m_pPixelShaders.IsEmpty()) {
static __int64 counter = 0;
static long start = clock();
long stop = clock();
long diff = stop - start;
- if(diff >= 10*60*CLOCKS_PER_SEC) {
+ if (diff >= 10*60*CLOCKS_PER_SEC) {
start = stop; // reset after 10 min (ps float has its limits in both range and accuracy)
}
@@ -1598,7 +1598,7 @@ STDMETHODIMP_(bool) CBaseAP::Paint(bool fAll) hr = m_pD3DDev->GetRenderTarget(0, &pRT);
POSITION pos = m_pPixelShaders.GetHeadPosition();
- while(pos) {
+ while (pos) {
pVideoTexture = m_pVideoTexture[dst];
hr = m_pD3DDev->SetRenderTarget(0, m_pVideoSurface[dst]);
@@ -1610,7 +1610,7 @@ STDMETHODIMP_(bool) CBaseAP::Paint(bool fAll) TextureCopy(m_pVideoTexture[src]);
src = dst;
- if(++dst >= m_nDXSurface+2) {
+ if (++dst >= m_nDXSurface+2) {
dst = m_nDXSurface;
}
}
@@ -1626,7 +1626,7 @@ STDMETHODIMP_(bool) CBaseAP::Paint(bool fAll) float A = 0;
- switch(iDX9Resizer) {
+ switch (iDX9Resizer) {
case 3:
A = -0.60f;
break;
@@ -1660,13 +1660,13 @@ STDMETHODIMP_(bool) CBaseAP::Paint(bool fAll) }
}
- if(rSrcVid.Size() != rDstVid.Size()) {
- if(iDX9Resizer == 0 || iDX9Resizer == 1) {
+ if (rSrcVid.Size() != rDstVid.Size()) {
+ if (iDX9Resizer == 0 || iDX9Resizer == 1) {
D3DTEXTUREFILTERTYPE Filter = iDX9Resizer == 0 ? D3DTEXF_POINT : D3DTEXF_LINEAR;
hr = TextureResize(pVideoTexture, dst, Filter, rSrcVid);
- } else if(iDX9Resizer == 2) {
+ } else if (iDX9Resizer == 2) {
hr = TextureResizeBilinear(pVideoTexture, dst, rSrcVid);
- } else if(iDX9Resizer >= 3) {
+ } else if (iDX9Resizer >= 3) {
hr = TextureResizeBicubic2pass(pVideoTexture, dst, rSrcVid);
}
} else {
@@ -1680,7 +1680,7 @@ STDMETHODIMP_(bool) CBaseAP::Paint(bool fAll) long stop = clock() + 333;
long diff = stop - start;
- if(diff >= 10*60*CLOCKS_PER_SEC) {
+ if (diff >= 10*60*CLOCKS_PER_SEC) {
start = stop; // reset after 10 min (ps float has its limits in both range and accuracy)
}
@@ -1697,7 +1697,7 @@ STDMETHODIMP_(bool) CBaseAP::Paint(bool fAll) int src = 1, dst = 0;
POSITION pos = m_pPixelShadersScreenSpace.GetHeadPosition();
- while(pos) {
+ while (pos) {
if (m_pPixelShadersScreenSpace.GetTailPosition() == pos) {
m_pD3DDev->SetRenderTarget(0, pBackBuffer);
} else {
@@ -1719,7 +1719,7 @@ STDMETHODIMP_(bool) CBaseAP::Paint(bool fAll) hr = m_pD3DDev->SetPixelShader(NULL);
}
} else {
- if(pBackBuffer) {
+ if (pBackBuffer) {
ClipToSurface(pBackBuffer, rSrcVid, rDstVid);
// rSrcVid has to be aligned on mod2 for yuy2->rgb conversion with StretchRect
rSrcVid.left &= ~1;
@@ -1727,7 +1727,7 @@ STDMETHODIMP_(bool) CBaseAP::Paint(bool fAll) rSrcVid.top &= ~1;
rSrcVid.bottom &= ~1;
hr = m_pD3DDev->StretchRect(m_pVideoSurface[m_nCurSurface], rSrcVid, pBackBuffer, rDstVid, m_filter);
- if(FAILED(hr)) {
+ if (FAILED(hr)) {
return false;
}
}
@@ -1740,7 +1740,7 @@ STDMETHODIMP_(bool) CBaseAP::Paint(bool fAll) m_pOSDTexture = NULL;
m_pOSDSurface = NULL;
if ((m_VMR9AlphaBitmap.dwFlags & VMRBITMAP_DISABLE) == 0 && (BYTE *)m_VMR9AlphaBitmapData) {
- if( (m_pD3DXLoadSurfaceFromMemory != NULL) &&
+ if ( (m_pD3DXLoadSurfaceFromMemory != NULL) &&
SUCCEEDED(hr = m_pD3DDev->CreateTexture(rcSrc.Width(), rcSrc.Height(), 1,
D3DUSAGE_RENDERTARGET, D3DFMT_A8R8G8B8,
D3DPOOL_DEFAULT, &m_pOSDTexture, NULL)) ) {
@@ -1777,7 +1777,7 @@ STDMETHODIMP_(bool) CBaseAP::Paint(bool fAll) hr = m_pD3DDev->Present(rSrcPri, rDstPri, NULL, NULL);
}
}
- if(FAILED(hr)) {
+ if (FAILED(hr)) {
DEBUG_ONLY(_tprintf(_T("Device lost or something\n")));
}
// Calculate timing statistics
@@ -1832,7 +1832,7 @@ STDMETHODIMP_(bool) CBaseAP::Paint(bool fAll) }
bool fResetDevice = m_bPendingResetDevice;
- if(hr == D3DERR_DEVICELOST && m_pD3DDev->TestCooperativeLevel() == D3DERR_DEVICENOTRESET || hr == S_PRESENT_MODE_CHANGED) {
+ if (hr == D3DERR_DEVICELOST && m_pD3DDev->TestCooperativeLevel() == D3DERR_DEVICENOTRESET || hr == S_PRESENT_MODE_CHANGED) {
fResetDevice = true;
}
if (SettingsNeedResetDevice()) {
@@ -1851,17 +1851,17 @@ STDMETHODIMP_(bool) CBaseAP::Paint(bool fAll) }
}
- if(s.fResetDevice) {
+ if (s.fResetDevice) {
LONGLONG time = GetRenderersData()->GetPerfCounter();
if (time > m_LastAdapterCheck + 20000000) { // check every 2 sec.
m_LastAdapterCheck = time;
#ifdef _DEBUG
D3DDEVICE_CREATION_PARAMETERS Parameters;
- if(SUCCEEDED(m_pD3DDev->GetCreationParameters(&Parameters))) {
+ if (SUCCEEDED(m_pD3DDev->GetCreationParameters(&Parameters))) {
ASSERT(Parameters.AdapterOrdinal == m_CurrentAdapter);
}
#endif
- if(m_CurrentAdapter != GetAdapter(m_pD3D)) {
+ if (m_CurrentAdapter != GetAdapter(m_pD3D)) {
fResetDevice = true;
}
#ifdef _DEBUG
@@ -1872,7 +1872,7 @@ STDMETHODIMP_(bool) CBaseAP::Paint(bool fAll) }
}
- if(fResetDevice) {
+ if (fResetDevice) {
m_bPendingResetDevice = true;
SendResetRequest();
}
@@ -1892,7 +1892,7 @@ STDMETHODIMP_(bool) CBaseAP::ResetDevice() DeleteSurfaces();
HRESULT hr;
CString Error;
- if(FAILED(hr = CreateDXDevice(Error)) || FAILED(hr = AllocSurfaces())) {
+ if (FAILED(hr = CreateDXDevice(Error)) || FAILED(hr = AllocSurfaces())) {
m_bDeviceResetRequested = false;
return false;
}
@@ -2310,20 +2310,20 @@ STDMETHODIMP CBaseAP::GetDIB(BYTE* lpDib, DWORD* size) m_pVideoSurface[m_nCurSurface]->GetDesc(&desc);
DWORD required = sizeof(BITMAPINFOHEADER) + (desc.Width * desc.Height * 32 >> 3);
- if(!lpDib) {
+ if (!lpDib) {
*size = required;
return S_OK;
}
- if(*size < required) {
+ if (*size < required) {
return E_OUTOFMEMORY;
}
*size = required;
CComPtr<IDirect3DSurface9> pSurface = m_pVideoSurface[m_nCurSurface];
D3DLOCKED_RECT r;
- if(FAILED(hr = pSurface->LockRect(&r, NULL, D3DLOCK_READONLY))) {
+ if (FAILED(hr = pSurface->LockRect(&r, NULL, D3DLOCK_READONLY))) {
pSurface = NULL;
- if(FAILED(hr = m_pD3DDev->CreateOffscreenPlainSurface(desc.Width, desc.Height, desc.Format, D3DPOOL_SYSTEMMEM, &pSurface, NULL))
+ if (FAILED(hr = m_pD3DDev->CreateOffscreenPlainSurface(desc.Width, desc.Height, desc.Format, D3DPOOL_SYSTEMMEM, &pSurface, NULL))
|| FAILED(hr = m_pD3DDev->GetRenderTargetData(m_pVideoSurface[m_nCurSurface], pSurface))
|| FAILED(hr = pSurface->LockRect(&r, NULL, D3DLOCK_READONLY))) {
return hr;
@@ -2365,13 +2365,13 @@ STDMETHODIMP CBaseAP::SetPixelShader2(LPCSTR pSrcData, LPCSTR pTarget, bool bScr pPixelShaders = &m_pPixelShaders;
}
- if(!pSrcData && !pTarget) {
+ if (!pSrcData && !pTarget) {
pPixelShaders->RemoveAll();
m_pD3DDev->SetPixelShader(NULL);
return S_OK;
}
- if(!pSrcData || !pTarget) {
+ if (!pSrcData || !pTarget) {
return E_INVALIDARG;
}
@@ -2382,7 +2382,7 @@ STDMETHODIMP CBaseAP::SetPixelShader2(LPCSTR pSrcData, LPCSTR pTarget, bool bScr CComPtr<IDirect3DPixelShader9> pPixelShader;
HRESULT hr = Shader.Compile(m_pPSC);
- if(FAILED(hr)) {
+ if (FAILED(hr)) {
return hr;
}
@@ -2583,18 +2583,18 @@ STDMETHODIMP CSyncAP::CreateRenderer(IUnknown** ppRenderer) CComPtr<IMFVideoRenderer> pMFVR;
CComQIPtr<IMFGetService, &__uuidof(IMFGetService)> pMFGS = pBF;
CComQIPtr<IEVRFilterConfig> pConfig = pBF;
- if(SUCCEEDED(hr)) {
- if(FAILED(pConfig->SetNumberOfStreams(3))) { // TODO - maybe need other number of input stream ...
+ if (SUCCEEDED(hr)) {
+ if (FAILED(pConfig->SetNumberOfStreams(3))) { // TODO - maybe need other number of input stream ...
break;
}
}
hr = pMFGS->GetService (MR_VIDEO_RENDER_SERVICE, IID_IMFVideoRenderer, (void**)&pMFVR);
- if(SUCCEEDED(hr)) {
+ if (SUCCEEDED(hr)) {
hr = QueryInterface(__uuidof(IMFVideoPresenter), (void**)&pVP);
}
- if(SUCCEEDED(hr)) {
+ if (SUCCEEDED(hr)) {
hr = pMFVR->InitializeRenderer(NULL, pVP);
}
@@ -2602,7 +2602,7 @@ STDMETHODIMP CSyncAP::CreateRenderer(IUnknown** ppRenderer) CComQIPtr<IMemInputPin> pMemInputPin = pPin;
m_bUseInternalTimer = HookNewSegmentAndReceive((IPinC*)(IPin*)pPin, (IMemInputPinC*)(IMemInputPin*)pMemInputPin);
- if(FAILED(hr)) {
+ if (FAILED(hr)) {
*ppRenderer = NULL;
} else {
*ppRenderer = pBF.Detach();
@@ -2620,29 +2620,29 @@ STDMETHODIMP_(bool) CSyncAP::Paint(bool fAll) STDMETHODIMP CSyncAP::NonDelegatingQueryInterface(REFIID riid, void** ppv)
{
HRESULT hr;
- if(riid == __uuidof(IMFClockStateSink)) {
+ if (riid == __uuidof(IMFClockStateSink)) {
hr = GetInterface((IMFClockStateSink*)this, ppv);
- } else if(riid == __uuidof(IMFVideoPresenter)) {
+ } else if (riid == __uuidof(IMFVideoPresenter)) {
hr = GetInterface((IMFVideoPresenter*)this, ppv);
- } else if(riid == __uuidof(IMFTopologyServiceLookupClient)) {
+ } else if (riid == __uuidof(IMFTopologyServiceLookupClient)) {
hr = GetInterface((IMFTopologyServiceLookupClient*)this, ppv);
- } else if(riid == __uuidof(IMFVideoDeviceID)) {
+ } else if (riid == __uuidof(IMFVideoDeviceID)) {
hr = GetInterface((IMFVideoDeviceID*)this, ppv);
- } else if(riid == __uuidof(IMFGetService)) {
+ } else if (riid == __uuidof(IMFGetService)) {
hr = GetInterface((IMFGetService*)this, ppv);
- } else if(riid == __uuidof(IMFAsyncCallback)) {
+ } else if (riid == __uuidof(IMFAsyncCallback)) {
hr = GetInterface((IMFAsyncCallback*)this, ppv);
- } else if(riid == __uuidof(IMFVideoDisplayControl)) {
+ } else if (riid == __uuidof(IMFVideoDisplayControl)) {
hr = GetInterface((IMFVideoDisplayControl*)this, ppv);
- } else if(riid == __uuidof(IEVRTrustedVideoPlugin)) {
+ } else if (riid == __uuidof(IEVRTrustedVideoPlugin)) {
hr = GetInterface((IEVRTrustedVideoPlugin*)this, ppv);
- } else if(riid == IID_IQualProp) {
+ } else if (riid == IID_IQualProp) {
hr = GetInterface((IQualProp*)this, ppv);
- } else if(riid == __uuidof(IMFRateSupport)) {
+ } else if (riid == __uuidof(IMFRateSupport)) {
hr = GetInterface((IMFRateSupport*)this, ppv);
- } else if(riid == __uuidof(IDirect3DDeviceManager9)) {
+ } else if (riid == __uuidof(IDirect3DDeviceManager9)) {
hr = m_pD3DManager->QueryInterface (__uuidof(IDirect3DDeviceManager9), (void**) ppv);
- } else if(riid == __uuidof(ISyncClockAdviser)) {
+ } else if (riid == __uuidof(ISyncClockAdviser)) {
hr = GetInterface((ISyncClockAdviser*)this, ppv);
} else {
hr = __super::NonDelegatingQueryInterface(riid, ppv);
@@ -2685,7 +2685,7 @@ STDMETHODIMP CSyncAP::OnClockSetRate(MFTIME hnsSystemTime, float flRate) bool CSyncAP::GetState(DWORD dwMilliSecsTimeout, FILTER_STATE *State, HRESULT &_ReturnValue)
{
CAutoLock lock(&m_SampleQueueLock);
- switch(m_nRenderState) {
+ switch (m_nRenderState) {
case Started:
*State = State_Running;
break;
@@ -2953,7 +2953,7 @@ HRESULT CSyncAP::CreateProposedOutputType(IMFMediaType* pMixerType, IMFMediaType bool bDoneSomething = true;
- if(m_AspectRatio.cx >= 1 && m_AspectRatio.cy >= 1) {
+ if (m_AspectRatio.cx >= 1 && m_AspectRatio.cy >= 1) {
while (bDoneSomething) {
bDoneSomething = false;
INT MinNum = min(m_AspectRatio.cx, m_AspectRatio.cy);
@@ -3130,7 +3130,7 @@ bool CSyncAP::GetSampleFromMixer() UINT dwSurface;
bool newSample = false;
- while(SUCCEEDED(hr)) { // Get as many frames as there are and that we have samples for
+ while (SUCCEEDED(hr)) { // Get as many frames as there are and that we have samples for
CComPtr<IMFSample> pSample;
CComPtr<IMFSample> pNewSample;
if (FAILED(GetFreeSample(&pSample))) { // All samples are taken for the moment. Better luck next time
@@ -3268,7 +3268,7 @@ STDMETHODIMP CSyncAP::GetIdealVideoSize(SIZE *pszMin, SIZE *pszMax) D3DDISPLAYMODE d3ddm;
ZeroMemory(&d3ddm, sizeof(d3ddm));
- if(SUCCEEDED(m_pD3D->GetAdapterDisplayMode(GetAdapter(m_pD3D), &d3ddm))) {
+ if (SUCCEEDED(m_pD3D->GetAdapterDisplayMode(GetAdapter(m_pD3D), &d3ddm))) {
pszMax->cx = d3ddm.Width;
pszMax->cy = d3ddm.Height;
}
@@ -3455,16 +3455,16 @@ STDMETHODIMP CSyncAP::GetNativeVideoSize(LONG* lpWidth, LONG* lpHeight, LONG* lp // This function should be called...
ASSERT (FALSE);
- if(lpWidth) {
+ if (lpWidth) {
*lpWidth = m_NativeVideoSize.cx;
}
- if(lpHeight) {
+ if (lpHeight) {
*lpHeight = m_NativeVideoSize.cy;
}
- if(lpARWidth) {
+ if (lpARWidth) {
*lpARWidth = m_AspectRatio.cx;
}
- if(lpARHeight) {
+ if (lpARHeight) {
*lpARHeight = m_AspectRatio.cy;
}
return S_OK;
@@ -3491,7 +3491,7 @@ STDMETHODIMP CSyncAP::InitializeDevice(AM_MEDIA_TYPE* pMediaType) hr = AllocSurfaces(D3DFMT_X8R8G8B8);
}
- for(int i = 0; i < m_nDXSurface; i++) {
+ for (int i = 0; i < m_nDXSurface; i++) {
CComPtr<IMFSample> pMFSample;
hr = pfMFCreateVideoSampleFromSurface(m_pVideoSurface[i], &pMFSample);
if (SUCCEEDED (hr)) {
@@ -3534,7 +3534,7 @@ void CSyncAP::MixerThread() CAutoLock AutoLock(&m_ImageProcessingLock);
bNewSample = GetSampleFromMixer();
}
- if(m_bUseInternalTimer && m_pSubPicQueue) {
+ if (m_bUseInternalTimer && m_pSubPicQueue) {
m_pSubPicQueue->SetFPS(m_fps);
}
}
@@ -3771,7 +3771,7 @@ STDMETHODIMP_(bool) CSyncAP::ResetDevice() bool bResult = __super::ResetDevice();
- for(int i = 0; i < m_nDXSurface; i++) {
+ for (int i = 0; i < m_nDXSurface; i++) {
CComPtr<IMFSample> pMFSample;
HRESULT hr = pfMFCreateVideoSampleFromSurface (m_pVideoSurface[i], &pMFSample);
if (SUCCEEDED (hr)) {
@@ -3897,7 +3897,7 @@ HRESULT CSyncAP::BeginStreaming() pEVR->QueryFilterInfo(&filterInfo); // This addref's the pGraph member
BeginEnumFilters(filterInfo.pGraph, pEF, pBF)
- if(CComQIPtr<IAMAudioRendererStats> pAS = pBF) {
+ if (CComQIPtr<IAMAudioRendererStats> pAS = pBF) {
m_pAudioStats = pAS;
};
EndEnumFilters
@@ -3925,7 +3925,7 @@ HRESULT CreateSyncRenderer(const CLSID& clsid, HWND hWnd, bool bFullscreen, ISub *ppAP = DNew CSyncAP(hWnd, bFullscreen, hr, Error);
(*ppAP)->AddRef();
- if(FAILED(hr)) {
+ if (FAILED(hr)) {
Error += L"\n";
Error += GetWindowsErrorMessage(hr, NULL);
MessageBox(hWnd, Error, L"Error creating EVR Sync", MB_OK | MB_ICONERROR);
@@ -4131,7 +4131,7 @@ STDMETHODIMP CSyncRenderer::NonDelegatingQueryInterface(REFIID riid, void** ppv) {
HRESULT hr;
- if(riid == __uuidof(IVMRMixerBitmap9)) {
+ if (riid == __uuidof(IVMRMixerBitmap9)) {
return GetInterface((IVMRMixerBitmap9*)this, ppv);
}
@@ -4150,8 +4150,8 @@ STDMETHODIMP CSyncRenderer::NonDelegatingQueryInterface(REFIID riid, void** ppv) }
hr = m_pEVR ? m_pEVR->QueryInterface(riid, ppv) : E_NOINTERFACE;
- if(m_pEVR && FAILED(hr)) {
- if(riid == __uuidof(IVMRffdshow9)) { // Support ffdshow queueing. We show ffdshow that this is patched Media Player Classic.
+ if (m_pEVR && FAILED(hr)) {
+ if (riid == __uuidof(IVMRffdshow9)) { // Support ffdshow queueing. We show ffdshow that this is patched Media Player Classic.
return GetInterface((IVMRffdshow9*)this, ppv);
}
}
@@ -4185,11 +4185,11 @@ CGenlock::CGenlock(DOUBLE target, DOUBLE limit, INT lineD, INT colD, DOUBLE cloc CGenlock::~CGenlock()
{
ResetTiming();
- if(syncOffsetFifo != NULL) {
+ if (syncOffsetFifo != NULL) {
delete syncOffsetFifo;
syncOffsetFifo = NULL;
}
- if(frameCycleFifo != NULL) {
+ if (frameCycleFifo != NULL) {
delete frameCycleFifo;
frameCycleFifo = NULL;
}
diff --git a/src/filters/renderer/VideoRenderers/SyncRenderer.h b/src/filters/renderer/VideoRenderers/SyncRenderer.h index d4ff8acd0..ee1e71e58 100644 --- a/src/filters/renderer/VideoRenderers/SyncRenderer.h +++ b/src/filters/renderer/VideoRenderers/SyncRenderer.h @@ -139,7 +139,7 @@ namespace GothSync CStringA m_SourceTarget;
HRESULT Compile(CPixelShaderCompiler *pCompiler) {
HRESULT hr = pCompiler->CompileShader(m_SourceData, "main", m_SourceTarget, 0, &m_pPixelShader);
- if(FAILED(hr)) {
+ if (FAILED(hr)) {
return hr;
}
return S_OK;
diff --git a/src/filters/renderer/VideoRenderers/VMR7AllocatorPresenter.cpp b/src/filters/renderer/VideoRenderers/VMR7AllocatorPresenter.cpp index e629432bc..eeace4d7c 100644 --- a/src/filters/renderer/VideoRenderers/VMR7AllocatorPresenter.cpp +++ b/src/filters/renderer/VideoRenderers/VMR7AllocatorPresenter.cpp @@ -42,11 +42,11 @@ CVMR7AllocatorPresenter::CVMR7AllocatorPresenter(HWND hWnd, HRESULT& hr) : CDX7AllocatorPresenter(hWnd, hr)
, m_fUseInternalTimer(false)
{
- if(FAILED(hr)) {
+ if (FAILED(hr)) {
return;
}
- if(FAILED(hr = m_pSA.CoCreateInstance(CLSID_AllocPresenter))) {
+ if (FAILED(hr = m_pSA.CoCreateInstance(CLSID_AllocPresenter))) {
hr = E_FAIL;
return;
}
@@ -66,13 +66,13 @@ STDMETHODIMP CVMR7AllocatorPresenter::NonDelegatingQueryInterface(REFIID riid, v HRESULT CVMR7AllocatorPresenter::CreateDevice()
{
HRESULT hr = __super::CreateDevice();
- if(FAILED(hr)) {
+ if (FAILED(hr)) {
return hr;
}
- if(m_pIVMRSurfAllocNotify) {
+ if (m_pIVMRSurfAllocNotify) {
HMONITOR hMonitor = MonitorFromWindow(m_hWnd, MONITOR_DEFAULTTONEAREST);
- if(FAILED(hr = m_pIVMRSurfAllocNotify->ChangeDDrawDevice(m_pDD, hMonitor))) {
+ if (FAILED(hr = m_pIVMRSurfAllocNotify->ChangeDDrawDevice(m_pDD, hMonitor))) {
return hr; //return false;
}
}
@@ -102,25 +102,25 @@ STDMETHODIMP CVMR7AllocatorPresenter::CreateRenderer(IUnknown** ppRenderer) do {
CComPtr<IBaseFilter> pBF;
- if(FAILED(hr = pBF.CoCreateInstance(CLSID_VideoMixingRenderer))) {
+ if (FAILED(hr = pBF.CoCreateInstance(CLSID_VideoMixingRenderer))) {
break;
}
CComQIPtr<IVMRFilterConfig> pConfig = pBF;
- if(!pConfig) {
+ if (!pConfig) {
break;
}
- if(FAILED(hr = pConfig->SetRenderingMode(VMRMode_Renderless))) {
+ if (FAILED(hr = pConfig->SetRenderingMode(VMRMode_Renderless))) {
break;
}
CComQIPtr<IVMRSurfaceAllocatorNotify> pSAN = pBF;
- if(!pSAN) {
+ if (!pSAN) {
break;
}
- if(FAILED(hr = pSAN->AdviseSurfaceAllocator(MY_USER_ID, static_cast<IVMRSurfaceAllocator*>(this)))
+ if (FAILED(hr = pSAN->AdviseSurfaceAllocator(MY_USER_ID, static_cast<IVMRSurfaceAllocator*>(this)))
|| FAILED(hr = AdviseNotify(pSAN))) {
break;
}
@@ -132,7 +132,7 @@ STDMETHODIMP CVMR7AllocatorPresenter::CreateRenderer(IUnknown** ppRenderer) *ppRenderer = (IUnknown*)pBF.Detach();
return S_OK;
- } while(0);
+ } while (0);
return E_FAIL;
}
@@ -147,11 +147,11 @@ STDMETHODIMP_(void) CVMR7AllocatorPresenter::SetTime(REFERENCE_TIME rtNow) STDMETHODIMP CVMR7AllocatorPresenter::AllocateSurface(DWORD_PTR dwUserID, VMRALLOCATIONINFO* lpAllocInfo, DWORD* lpdwBuffer, LPDIRECTDRAWSURFACE7* lplpSurface)
{
- if(!lpAllocInfo || !lpdwBuffer || !lplpSurface) {
+ if (!lpAllocInfo || !lpdwBuffer || !lplpSurface) {
return E_POINTER;
}
- if(!m_pIVMRSurfAllocNotify) {
+ if (!m_pIVMRSurfAllocNotify) {
return E_FAIL;
}
@@ -164,28 +164,28 @@ STDMETHODIMP CVMR7AllocatorPresenter::AllocateSurface(DWORD_PTR dwUserID, VMRALL // then that might stall for about 30 seconds because of some unknown buggy code
// behind <ddraw surface>->Release()
- if(lpAllocInfo->lpHdr->biBitCount < 16) {
+ if (lpAllocInfo->lpHdr->biBitCount < 16) {
return E_FAIL;
}
hr = m_pSA->AllocateSurface(dwUserID, lpAllocInfo, lpdwBuffer, lplpSurface);
- if(FAILED(hr)) {
+ if (FAILED(hr)) {
return hr;
}
m_NativeVideoSize = CSize(abs(lpAllocInfo->lpHdr->biWidth), abs(lpAllocInfo->lpHdr->biHeight));
m_AspectRatio = m_NativeVideoSize;
int arx = lpAllocInfo->szAspectRatio.cx, ary = lpAllocInfo->szAspectRatio.cy;
- if(arx > 0 && ary > 0) {
+ if (arx > 0 && ary > 0) {
m_AspectRatio.SetSize(arx, ary);
}
- if(FAILED(hr = AllocSurfaces())) {
+ if (FAILED(hr = AllocSurfaces())) {
return hr;
}
// test if the colorspace is acceptable
- if(FAILED(hr = m_pVideoSurface->Blt(NULL, *lplpSurface, NULL, DDBLT_WAIT, NULL))) {
+ if (FAILED(hr = m_pVideoSurface->Blt(NULL, *lplpSurface, NULL, DDBLT_WAIT, NULL))) {
DeleteSurfaces();
return hr;
}
@@ -208,7 +208,7 @@ STDMETHODIMP CVMR7AllocatorPresenter::PrepareSurface(DWORD_PTR dwUserID, IDirect {
SetThreadName((DWORD)-1, "CVMR7AllocatorPresenter");
- if(!lpSurface) {
+ if (!lpSurface) {
return E_POINTER;
}
@@ -229,7 +229,7 @@ STDMETHODIMP CVMR7AllocatorPresenter::AdviseNotify(IVMRSurfaceAllocatorNotify* l HRESULT hr;
HMONITOR hMonitor = MonitorFromWindow(m_hWnd, MONITOR_DEFAULTTONEAREST);
- if(FAILED(hr = m_pIVMRSurfAllocNotify->SetDDrawDevice(m_pDD, hMonitor))) {
+ if (FAILED(hr = m_pIVMRSurfAllocNotify->SetDDrawDevice(m_pDD, hMonitor))) {
return hr;
}
@@ -256,7 +256,7 @@ STDMETHODIMP CVMR7AllocatorPresenter::StopPresenting(DWORD_PTR dwUserID) STDMETHODIMP CVMR7AllocatorPresenter::PresentImage(DWORD_PTR dwUserID, VMRPRESENTATIONINFO* lpPresInfo)
{
- if(!lpPresInfo || !lpPresInfo->lpSurf) {
+ if (!lpPresInfo || !lpPresInfo->lpSurf) {
return E_POINTER;
}
@@ -266,14 +266,14 @@ STDMETHODIMP CVMR7AllocatorPresenter::PresentImage(DWORD_PTR dwUserID, VMRPRESEN m_pVideoSurface->Blt(NULL, lpPresInfo->lpSurf, NULL, DDBLT_WAIT, NULL);
}
- if(lpPresInfo->rtEnd > lpPresInfo->rtStart) {
+ if (lpPresInfo->rtEnd > lpPresInfo->rtStart) {
REFERENCE_TIME rtTimePerFrame = lpPresInfo->rtEnd - lpPresInfo->rtStart;
m_fps = 10000000.0 / rtTimePerFrame;
- if(m_pSubPicQueue) {
+ if (m_pSubPicQueue) {
m_pSubPicQueue->SetFPS(m_fps);
- if(m_fUseInternalTimer && !g_bExternalSubtitleTime) {
+ if (m_fUseInternalTimer && !g_bExternalSubtitleTime) {
__super::SetTime(g_tSegmentStart + g_tSampleStart);
}
}
@@ -281,10 +281,10 @@ STDMETHODIMP CVMR7AllocatorPresenter::PresentImage(DWORD_PTR dwUserID, VMRPRESEN CSize VideoSize = m_NativeVideoSize;
int arx = lpPresInfo->szAspectRatio.cx, ary = lpPresInfo->szAspectRatio.cy;
- if(arx > 0 && ary > 0) {
+ if (arx > 0 && ary > 0) {
VideoSize.cx = VideoSize.cy*arx/ary;
}
- if(VideoSize != GetVideoSize()) {
+ if (VideoSize != GetVideoSize()) {
m_AspectRatio.SetSize(arx, ary);
AfxGetApp()->m_pMainWnd->PostMessage(WM_REARRANGERENDERLESS);
}
@@ -305,16 +305,16 @@ STDMETHODIMP CVMR7AllocatorPresenter::GetNativeVideoSize(LONG* lpWidth, LONG* lp CSize vs = m_NativeVideoSize, ar = m_AspectRatio;
// DVD Nav. bug workaround fix
vs.cx = vs.cy * ar.cx / ar.cy;
- if(lpWidth) {
+ if (lpWidth) {
*lpWidth = vs.cx;
}
- if(lpHeight) {
+ if (lpHeight) {
*lpHeight = vs.cy;
}
- if(lpARWidth) {
+ if (lpARWidth) {
*lpARWidth = ar.cx;
}
- if(lpARHeight) {
+ if (lpARHeight) {
*lpARHeight = ar.cy;
}
return S_OK;
@@ -346,7 +346,7 @@ STDMETHODIMP CVMR7AllocatorPresenter::GetVideoPosition(LPRECT lpSRCRect, LPRECT STDMETHODIMP CVMR7AllocatorPresenter::GetAspectRatioMode(DWORD* lpAspectRatioMode)
{
- if(lpAspectRatioMode) {
+ if (lpAspectRatioMode) {
*lpAspectRatioMode = AM_ARMODE_STRETCHED;
}
return S_OK;
@@ -384,7 +384,7 @@ STDMETHODIMP CVMR7AllocatorPresenter::SetBorderColor(COLORREF Clr) STDMETHODIMP CVMR7AllocatorPresenter::GetBorderColor(COLORREF* lpClr)
{
- if(lpClr) {
+ if (lpClr) {
*lpClr = 0;
}
return S_OK;
diff --git a/src/filters/renderer/VideoRenderers/VMR9AllocatorPresenter.cpp b/src/filters/renderer/VideoRenderers/VMR9AllocatorPresenter.cpp index bbb99e9f2..0a5e1c7c4 100644 --- a/src/filters/renderer/VideoRenderers/VMR9AllocatorPresenter.cpp +++ b/src/filters/renderer/VideoRenderers/VMR9AllocatorPresenter.cpp @@ -58,13 +58,13 @@ STDMETHODIMP CVMR9AllocatorPresenter::NonDelegatingQueryInterface(REFIID riid, v HRESULT CVMR9AllocatorPresenter::CreateDevice(CString &_Error)
{
HRESULT hr = __super::CreateDevice(_Error);
- if(FAILED(hr)) {
+ if (FAILED(hr)) {
return hr;
}
- if(m_pIVMRSurfAllocNotify) {
+ if (m_pIVMRSurfAllocNotify) {
HMONITOR hMonitor = m_pD3D->GetAdapterMonitor(m_CurrentAdapter);
- if(FAILED(hr = m_pIVMRSurfAllocNotify->ChangeD3DDevice(m_pD3DDev, hMonitor))) {
+ if (FAILED(hr = m_pIVMRSurfAllocNotify->ChangeD3DDevice(m_pD3DDev, hMonitor))) {
_Error += L"m_pIVMRSurfAllocNotify->ChangeD3DDevice failed";
return hr; //return false;
}
@@ -105,30 +105,30 @@ STDMETHODIMP CVMR9AllocatorPresenter::CreateRenderer(IUnknown** ppRenderer) CComQIPtr<IMemInputPin> pMemInputPin = pPin;
m_fUseInternalTimer = HookNewSegmentAndReceive((IPinC*)(IPin*)pPin, (IMemInputPinC*)(IMemInputPin*)pMemInputPin);
- if(CComQIPtr<IAMVideoAccelerator> pAMVA = pPin) {
+ if (CComQIPtr<IAMVideoAccelerator> pAMVA = pPin) {
HookAMVideoAccelerator((IAMVideoAcceleratorC*)(IAMVideoAccelerator*)pAMVA);
}
CComQIPtr<IVMRFilterConfig9> pConfig = pBF;
- if(!pConfig) {
+ if (!pConfig) {
break;
}
CRenderersSettings& s = GetRenderersSettings();
- if(s.fVMR9MixerMode) {
- if(FAILED(hr = pConfig->SetNumberOfStreams(1))) {
+ if (s.fVMR9MixerMode) {
+ if (FAILED(hr = pConfig->SetNumberOfStreams(1))) {
break;
}
- if(CComQIPtr<IVMRMixerControl9> pMC = pBF) {
+ if (CComQIPtr<IVMRMixerControl9> pMC = pBF) {
DWORD dwPrefs;
pMC->GetMixingPrefs(&dwPrefs);
// See http://msdn.microsoft.com/en-us/library/dd390928(VS.85).aspx
dwPrefs |= MixerPref9_NonSquareMixing;
dwPrefs |= MixerPref9_NoDecimation;
- if(s.fVMR9MixerYUV && !IsVistaOrAbove()) {
+ if (s.fVMR9MixerYUV && !IsVistaOrAbove()) {
dwPrefs &= ~MixerPref9_RenderTargetMask;
dwPrefs |= MixerPref9_RenderTargetYUV;
}
@@ -136,16 +136,16 @@ STDMETHODIMP CVMR9AllocatorPresenter::CreateRenderer(IUnknown** ppRenderer) }
}
- if(FAILED(hr = pConfig->SetRenderingMode(VMR9Mode_Renderless))) {
+ if (FAILED(hr = pConfig->SetRenderingMode(VMR9Mode_Renderless))) {
break;
}
CComQIPtr<IVMRSurfaceAllocatorNotify9> pSAN = pBF;
- if(!pSAN) {
+ if (!pSAN) {
break;
}
- if(FAILED(hr = pSAN->AdviseSurfaceAllocator(MY_USER_ID, static_cast<IVMRSurfaceAllocator9*>(this)))
+ if (FAILED(hr = pSAN->AdviseSurfaceAllocator(MY_USER_ID, static_cast<IVMRSurfaceAllocator9*>(this)))
|| FAILED(hr = AdviseNotify(pSAN))) {
break;
}
@@ -153,7 +153,7 @@ STDMETHODIMP CVMR9AllocatorPresenter::CreateRenderer(IUnknown** ppRenderer) *ppRenderer = (IUnknown*)pBF.Detach();
return S_OK;
- } while(0);
+ } while (0);
return E_FAIL;
}
@@ -171,17 +171,17 @@ STDMETHODIMP CVMR9AllocatorPresenter::InitializeDevice(DWORD_PTR dwUserID, VMR9A CAutoLock lock(this);
CAutoLock cRenderLock(&m_RenderLock);
- if(!lpAllocInfo || !lpNumBuffers) {
+ if (!lpAllocInfo || !lpNumBuffers) {
return E_POINTER;
}
- if(!m_pIVMRSurfAllocNotify) {
+ if (!m_pIVMRSurfAllocNotify) {
return E_FAIL;
}
// WTF: Is this some kind of forgotten debug code ?
- if((GetAsyncKeyState(VK_CONTROL)&0x80000000))
- if(lpAllocInfo->Format == '21VY' || lpAllocInfo->Format == '024I') {
+ if ((GetAsyncKeyState(VK_CONTROL)&0x80000000))
+ if (lpAllocInfo->Format == '21VY' || lpAllocInfo->Format == '024I') {
return E_FAIL;
}
@@ -203,12 +203,12 @@ STDMETHODIMP CVMR9AllocatorPresenter::InitializeDevice(DWORD_PTR dwUserID, VMR9A HRESULT hr;
- if(lpAllocInfo->dwFlags & VMR9AllocFlag_3DRenderTarget) {
+ if (lpAllocInfo->dwFlags & VMR9AllocFlag_3DRenderTarget) {
lpAllocInfo->dwFlags |= VMR9AllocFlag_TextureSurface;
}
hr = m_pIVMRSurfAllocNotify->AllocateSurfaceHelper(lpAllocInfo, lpNumBuffers, &m_pSurfaces[0]);
- if(FAILED(hr)) {
+ if (FAILED(hr)) {
return hr;
}
@@ -219,7 +219,7 @@ STDMETHODIMP CVMR9AllocatorPresenter::InitializeDevice(DWORD_PTR dwUserID, VMR9A CSize VideoSize = GetVisibleVideoSize();
int arx = lpAllocInfo->szAspectRatio.cx;
int ary = lpAllocInfo->szAspectRatio.cy;
- if(arx > 0 && ary > 0) {
+ if (arx > 0 && ary > 0) {
arx = arx / ((float) m_NativeVideoSize.cx / VideoSize.cx);
ary = ary / ((float) m_NativeVideoSize.cy / VideoSize.cy);
m_AspectRatio.SetSize(arx, ary);
@@ -227,13 +227,13 @@ STDMETHODIMP CVMR9AllocatorPresenter::InitializeDevice(DWORD_PTR dwUserID, VMR9A m_AspectRatio = VideoSize;
}
- if(FAILED(hr = AllocSurfaces())) {
+ if (FAILED(hr = AllocSurfaces())) {
return hr;
}
- if(!(lpAllocInfo->dwFlags & VMR9AllocFlag_TextureSurface)) {
+ if (!(lpAllocInfo->dwFlags & VMR9AllocFlag_TextureSurface)) {
// test if the colorspace is acceptable
- if(FAILED(hr = m_pD3DDev->StretchRect(m_pSurfaces[0], NULL, m_pVideoSurface[m_nCurSurface], NULL, D3DTEXF_NONE))) {
+ if (FAILED(hr = m_pD3DDev->StretchRect(m_pSurfaces[0], NULL, m_pVideoSurface[m_nCurSurface], NULL, D3DTEXF_NONE))) {
DeleteSurfaces();
return E_FAIL;
}
@@ -260,7 +260,7 @@ STDMETHODIMP CVMR9AllocatorPresenter::TerminateDevice(DWORD_PTR dwUserID) STDMETHODIMP CVMR9AllocatorPresenter::GetSurface(DWORD_PTR dwUserID, DWORD SurfaceIndex, DWORD SurfaceFlags, IDirect3DSurface9** lplpSurface)
{
- if(!lplpSurface) {
+ if (!lplpSurface) {
return E_POINTER;
}
@@ -271,7 +271,7 @@ STDMETHODIMP CVMR9AllocatorPresenter::GetSurface(DWORD_PTR dwUserID, DWORD Surfa SurfaceIndex = 0
m_pSurfaces.GetCount() = 0
- Scenario:
+ Scenario:
Thread 1:
Wait on m_RenderLock in this function
Thread 2:
@@ -279,15 +279,15 @@ STDMETHODIMP CVMR9AllocatorPresenter::GetSurface(DWORD_PTR dwUserID, DWORD Surfa (Happens by calling ex CDX9AllocatorPresenter::ResetDevice)
When thread 2 releases the lock thread 1 gets it and boom!
-
+
Possible solution: Adding object lock and moving m_RenderLock to try to fix this threading issue.
This problem occurs when moving the window from display a to display b.
-
+
NOTE: This is just a workaround.
CDX9AllocatorPresenter doesn't follow the rules which is why this happened.
And it is used by EVR custom (which it really shouldn't) so i can't easily fix it without breaking EVR custom.
*/
- if(SurfaceIndex >= m_pSurfaces.GetCount()) {
+ if (SurfaceIndex >= m_pSurfaces.GetCount()) {
return E_FAIL;
}
@@ -314,7 +314,7 @@ STDMETHODIMP CVMR9AllocatorPresenter::AdviseNotify(IVMRSurfaceAllocatorNotify9* HRESULT hr;
HMONITOR hMonitor = m_pD3D->GetAdapterMonitor(GetAdapter(m_pD3D));
- if(FAILED(hr = m_pIVMRSurfAllocNotify->SetD3DDevice(m_pD3DDev, hMonitor))) {
+ if (FAILED(hr = m_pIVMRSurfAllocNotify->SetD3DDevice(m_pD3DDev, hMonitor))) {
return hr;
}
@@ -409,18 +409,18 @@ STDMETHODIMP CVMR9AllocatorPresenter::PresentImage(DWORD_PTR dwUserID, VMR9Prese HRESULT hr;
- if(!lpPresInfo || !lpPresInfo->lpSurf) {
+ if (!lpPresInfo || !lpPresInfo->lpSurf) {
return E_POINTER;
}
CAutoLock cAutoLock(this);
CAutoLock cRenderLock(&m_RenderLock);
- if(lpPresInfo->rtEnd > lpPresInfo->rtStart) {
- if(m_pSubPicQueue) {
+ if (lpPresInfo->rtEnd > lpPresInfo->rtStart) {
+ if (m_pSubPicQueue) {
m_pSubPicQueue->SetFPS(m_fps);
- if(m_fUseInternalTimer && !g_bExternalSubtitleTime) {
+ if (m_fUseInternalTimer && !g_bExternalSubtitleTime) {
__super::SetTime(g_tSegmentStart + g_tSampleStart);
}
}
@@ -429,12 +429,12 @@ STDMETHODIMP CVMR9AllocatorPresenter::PresentImage(DWORD_PTR dwUserID, VMR9Prese CSize VideoSize = GetVisibleVideoSize();
int arx = lpPresInfo->szAspectRatio.cx;
int ary = lpPresInfo->szAspectRatio.cy;
- if(arx > 0 && ary > 0) {
+ if (arx > 0 && ary > 0) {
arx = arx / ((float) m_NativeVideoSize.cx / VideoSize.cx);
ary = ary / ((float) m_NativeVideoSize.cy / VideoSize.cy);
VideoSize.cx = VideoSize.cy*arx/ary;
}
- if(VideoSize != GetVideoSize()) {
+ if (VideoSize != GetVideoSize()) {
m_AspectRatio.SetSize(arx, ary);
AfxGetApp()->m_pMainWnd->PostMessage(WM_REARRANGERENDERLESS);
}
@@ -443,9 +443,9 @@ STDMETHODIMP CVMR9AllocatorPresenter::PresentImage(DWORD_PTR dwUserID, VMR9Prese CComPtr<IDirect3DTexture9> pTexture;
lpPresInfo->lpSurf->GetContainer(IID_IDirect3DTexture9, (void**)&pTexture);
- if(pTexture) {
+ if (pTexture) {
m_pVideoSurface[m_nCurSurface] = lpPresInfo->lpSurf;
- if(m_pVideoTexture[m_nCurSurface]) {
+ if (m_pVideoTexture[m_nCurSurface]) {
m_pVideoTexture[m_nCurSurface] = pTexture;
}
} else {
@@ -483,16 +483,16 @@ STDMETHODIMP CVMR9AllocatorPresenter::PresentImage(DWORD_PTR dwUserID, VMR9Prese STDMETHODIMP CVMR9AllocatorPresenter::GetNativeVideoSize(LONG* lpWidth, LONG* lpHeight, LONG* lpARWidth, LONG* lpARHeight)
{
- if(lpWidth) {
+ if (lpWidth) {
*lpWidth = m_NativeVideoSize.cx;
}
- if(lpHeight) {
+ if (lpHeight) {
*lpHeight = m_NativeVideoSize.cy;
}
- if(lpARWidth) {
+ if (lpARWidth) {
*lpARWidth = m_AspectRatio.cx;
}
- if(lpARHeight) {
+ if (lpARHeight) {
*lpARHeight = m_AspectRatio.cy;
}
return S_OK;
@@ -522,7 +522,7 @@ STDMETHODIMP CVMR9AllocatorPresenter::GetVideoPosition(LPRECT lpSRCRect, LPRECT STDMETHODIMP CVMR9AllocatorPresenter::GetAspectRatioMode(DWORD* lpAspectRatioMode)
{
- if(lpAspectRatioMode) {
+ if (lpAspectRatioMode) {
*lpAspectRatioMode = AM_ARMODE_STRETCHED;
}
return S_OK;
@@ -560,7 +560,7 @@ STDMETHODIMP CVMR9AllocatorPresenter::SetBorderColor(COLORREF Clr) STDMETHODIMP CVMR9AllocatorPresenter::GetBorderColor(COLORREF* lpClr)
{
- if(lpClr) {
+ if (lpClr) {
*lpClr = 0;
}
return S_OK;
diff --git a/src/filters/renderer/VideoRenderers/madVRAllocatorPresenter.cpp b/src/filters/renderer/VideoRenderers/madVRAllocatorPresenter.cpp index 965289318..68b85bc75 100644 --- a/src/filters/renderer/VideoRenderers/madVRAllocatorPresenter.cpp +++ b/src/filters/renderer/VideoRenderers/madVRAllocatorPresenter.cpp @@ -33,8 +33,8 @@ using namespace DSObjects; interface __declspec(uuid("D6EE8031-214E-4E9E-A3A7-458925F933AB"))
IMadVRExclusiveModeInfo :
public IUnknown {
- STDMETHOD_(BOOL, IsExclusiveModeActive)(void) = 0;
- STDMETHOD_(BOOL, IsMadVRSeekbarEnabled)(void) = 0;
+ STDMETHOD_(BOOL, IsExclusiveModeActive)(void) = 0;
+ STDMETHOD_(BOOL, IsMadVRSeekbarEnabled)(void) = 0;
};
@@ -46,7 +46,7 @@ CmadVRAllocatorPresenter::CmadVRAllocatorPresenter(HWND hWnd, HRESULT& hr, CStri : CSubPicAllocatorPresenterImpl(hWnd, hr, &_Error)
, m_ScreenSize(0, 0)
{
- if(FAILED(hr)) {
+ if (FAILED(hr)) {
_Error += L"ISubPicAllocatorPresenterImpl failed\n";
return;
}
@@ -56,7 +56,7 @@ CmadVRAllocatorPresenter::CmadVRAllocatorPresenter(HWND hWnd, HRESULT& hr, CStri CmadVRAllocatorPresenter::~CmadVRAllocatorPresenter()
{
- if(m_pSRCB) {
+ if (m_pSRCB) {
// nasty, but we have to let it know about our death somehow
((CSubRenderCallback*)(ISubRenderCallback2*)m_pSRCB)->SetDXRAP(NULL);
}
@@ -82,8 +82,8 @@ STDMETHODIMP CmadVRAllocatorPresenter::NonDelegatingQueryInterface(REFIID riid, return GetInterface((IVMRWindowlessControl*)this, ppv);
*/
- if(riid != IID_IUnknown && m_pDXR) {
- if(SUCCEEDED(m_pDXR->QueryInterface(riid, ppv))) {
+ if (riid != IID_IUnknown && m_pDXR) {
+ if (SUCCEEDED(m_pDXR->QueryInterface(riid, ppv))) {
return S_OK;
}
}
@@ -102,7 +102,7 @@ HRESULT CmadVRAllocatorPresenter::SetDevice(IDirect3DDevice9* pD3DDev) }
CSize size;
- switch(GetRenderersSettings().nSPCMaxRes) {
+ switch (GetRenderersSettings().nSPCMaxRes) {
case 0:
default:
size = m_ScreenSize;
@@ -136,11 +136,11 @@ HRESULT CmadVRAllocatorPresenter::SetDevice(IDirect3DDevice9* pD3DDev) break;
}
- if(m_pAllocator) {
+ if (m_pAllocator) {
m_pAllocator->ChangeDevice(pD3DDev);
} else {
m_pAllocator = DNew CDX9SubPicAllocator(pD3DDev, size, GetRenderersSettings().fSPCPow2Tex, true);
- if(!m_pAllocator) {
+ if (!m_pAllocator) {
return E_FAIL;
}
}
@@ -150,11 +150,11 @@ HRESULT CmadVRAllocatorPresenter::SetDevice(IDirect3DDevice9* pD3DDev) m_pSubPicQueue = GetRenderersSettings().nSPCSize > 0
? (ISubPicQueue*)DNew CSubPicQueue(GetRenderersSettings().nSPCSize, !GetRenderersSettings().fSPCAllowAnimationWhenBuffering, m_pAllocator, &hr)
: (ISubPicQueue*)DNew CSubPicQueueNoThread(m_pAllocator, &hr);
- if(!m_pSubPicQueue || FAILED(hr)) {
+ if (!m_pSubPicQueue || FAILED(hr)) {
return E_FAIL;
}
- if(m_SubPicProvider) {
+ if (m_SubPicProvider) {
m_pSubPicQueue->SetSubPicProvider(m_SubPicProvider);
}
@@ -167,7 +167,7 @@ HRESULT CmadVRAllocatorPresenter::Render( {
__super::SetPosition(CRect(0, 0, width, height), CRect(left, top, right, bottom)); // needed? should be already set by the player
SetTime(rtStart);
- if(atpf > 0 && m_pSubPicQueue) {
+ if (atpf > 0 && m_pSubPicQueue) {
m_fps = (double)(10000000.0 / atpf);
m_pSubPicQueue->SetFPS(m_fps);
}
@@ -181,22 +181,22 @@ STDMETHODIMP CmadVRAllocatorPresenter::CreateRenderer(IUnknown** ppRenderer) {
CheckPointer(ppRenderer, E_POINTER);
- if(m_pDXR) {
+ if (m_pDXR) {
return E_UNEXPECTED;
}
m_pDXR.CoCreateInstance(CLSID_madVR, GetOwner());
- if(!m_pDXR) {
+ if (!m_pDXR) {
return E_FAIL;
}
CComQIPtr<ISubRender> pSR = m_pDXR;
- if(!pSR) {
+ if (!pSR) {
m_pDXR = NULL;
return E_FAIL;
}
m_pSRCB = DNew CSubRenderCallback(this);
- if(FAILED(pSR->SetCallback(m_pSRCB))) {
+ if (FAILED(pSR->SetCallback(m_pSRCB))) {
m_pDXR = NULL;
return E_FAIL;
}
@@ -214,12 +214,12 @@ STDMETHODIMP CmadVRAllocatorPresenter::CreateRenderer(IUnknown** ppRenderer) STDMETHODIMP_(void) CmadVRAllocatorPresenter::SetPosition(RECT w, RECT v)
{
- if(CComQIPtr<IBasicVideo> pBV = m_pDXR) {
+ if (CComQIPtr<IBasicVideo> pBV = m_pDXR) {
pBV->SetDefaultSourcePosition();
pBV->SetDestinationPosition(v.left, v.top, v.right - v.left, v.bottom - v.top);
}
- if(CComQIPtr<IVideoWindow> pVW = m_pDXR) {
+ if (CComQIPtr<IVideoWindow> pVW = m_pDXR) {
pVW->SetWindowPosition(w.left, w.top, w.right - w.left, w.bottom - w.top);
}
}
@@ -228,12 +228,12 @@ STDMETHODIMP_(SIZE) CmadVRAllocatorPresenter::GetVideoSize(bool fCorrectAR) {
SIZE size = {0, 0};
- if(!fCorrectAR) {
- if(CComQIPtr<IBasicVideo> pBV = m_pDXR) {
+ if (!fCorrectAR) {
+ if (CComQIPtr<IBasicVideo> pBV = m_pDXR) {
pBV->GetVideoSize(&size.cx, &size.cy);
}
} else {
- if(CComQIPtr<IBasicVideo2> pBV2 = m_pDXR) {
+ if (CComQIPtr<IBasicVideo2> pBV2 = m_pDXR) {
pBV2->GetPreferredAspectRatio(&size.cx, &size.cy);
}
}
@@ -249,7 +249,7 @@ STDMETHODIMP_(bool) CmadVRAllocatorPresenter::Paint(bool fAll) STDMETHODIMP CmadVRAllocatorPresenter::GetDIB(BYTE* lpDib, DWORD* size)
{
HRESULT hr = E_NOTIMPL;
- if(CComQIPtr<IBasicVideo> pBV = m_pDXR) {
+ if (CComQIPtr<IBasicVideo> pBV = m_pDXR) {
hr = pBV->GetCurrentImage((long*)size, (long*)lpDib);
}
return hr;
diff --git a/src/filters/renderer/VideoRenderers/madVRAllocatorPresenter.h b/src/filters/renderer/VideoRenderers/madVRAllocatorPresenter.h index eb7fe682a..3d28452a3 100644 --- a/src/filters/renderer/VideoRenderers/madVRAllocatorPresenter.h +++ b/src/filters/renderer/VideoRenderers/madVRAllocatorPresenter.h @@ -29,8 +29,8 @@ interface __declspec(uuid("ABA34FDA-DD22-4E00-9AB4-4ABF927D0B0C"))
IMadVRTextOsd :
public IUnknown {
- STDMETHOD(OsdDisplayMessage)(LPCWSTR text, DWORD milliseconds) = 0;
- STDMETHOD(OsdClearMessage)(void) = 0;
+ STDMETHOD(OsdDisplayMessage)(LPCWSTR text, DWORD milliseconds) = 0;
+ STDMETHOD(OsdClearMessage)(void) = 0;
};
namespace DSObjects
diff --git a/src/filters/source/BaseSource/BaseSource.cpp b/src/filters/source/BaseSource/BaseSource.cpp index 1c26cb6ba..a2bdc6fb2 100644 --- a/src/filters/source/BaseSource/BaseSource.cpp +++ b/src/filters/source/BaseSource/BaseSource.cpp @@ -58,7 +58,7 @@ STDMETHODIMP CBaseStream::NonDelegatingQueryInterface(REFIID riid, void** ppv) void CBaseStream::UpdateFromSeek()
{
- if(ThreadExists()) {
+ if (ThreadExists()) {
// next time around the loop, the worker thread will
// pick up the position change.
// We need to flush all the existing data - we must do that here
@@ -81,7 +81,7 @@ void CBaseStream::UpdateFromSeek() HRESULT CBaseStream::SetRate(double dRate)
{
- if(dRate <= 0) {
+ if (dRate <= 0) {
return E_INVALIDARG;
}
@@ -118,7 +118,7 @@ HRESULT CBaseStream::ChangeStop() {
{
CAutoLock lock(CSourceSeeking::m_pLock);
- if(m_rtPosition < m_rtStop) {
+ if (m_rtPosition < m_rtStop) {
return S_OK;
}
}
@@ -146,12 +146,12 @@ HRESULT CBaseStream::FillBuffer(IMediaSample* pSample) {
CAutoLock cAutoLockShared(&m_cSharedState);
- if(m_rtPosition >= m_rtStop) {
+ if (m_rtPosition >= m_rtStop) {
return S_FALSE;
}
BYTE* pOut = NULL;
- if(FAILED(hr = pSample->GetPointer(&pOut)) || !pOut) {
+ if (FAILED(hr = pSample->GetPointer(&pOut)) || !pOut) {
return S_FALSE;
}
@@ -160,7 +160,7 @@ HRESULT CBaseStream::FillBuffer(IMediaSample* pSample) long len = pSample->GetSize();
hr = FillBuffer(pSample, nFrame, pOut, len);
- if(hr != S_OK) {
+ if (hr != S_OK) {
return hr;
}
@@ -178,7 +178,7 @@ HRESULT CBaseStream::FillBuffer(IMediaSample* pSample) pSample->SetSyncPoint(TRUE);
- if(m_bDiscontinuity) {
+ if (m_bDiscontinuity) {
pSample->SetDiscontinuity(TRUE);
m_bDiscontinuity = FALSE;
}
diff --git a/src/filters/source/BaseSource/BaseSource.h b/src/filters/source/BaseSource/BaseSource.h index fea572b3c..16ef46866 100644 --- a/src/filters/source/BaseSource/BaseSource.h +++ b/src/filters/source/BaseSource/BaseSource.h @@ -35,7 +35,7 @@ protected: public:
CBaseSource(TCHAR* name, LPUNKNOWN lpunk, HRESULT* phr, const CLSID& clsid)
: CSource(name, lpunk, clsid) {
- if(phr) {
+ if (phr) {
*phr = S_OK;
}
}
@@ -54,16 +54,16 @@ public: STDMETHODIMP Load(LPCOLESTR pszFileName, const AM_MEDIA_TYPE* pmt) {
// TODO: destroy any already existing pins and create new, now we are just going die nicely instead of doing it :)
- if(GetPinCount() > 0) {
+ if (GetPinCount() > 0) {
return VFW_E_ALREADY_CONNECTED;
}
HRESULT hr = S_OK;
- if(!(DNew TStream(pszFileName, this, &hr))) {
+ if (!(DNew TStream(pszFileName, this, &hr))) {
return E_OUTOFMEMORY;
}
- if(FAILED(hr)) {
+ if (FAILED(hr)) {
return hr;
}
@@ -74,13 +74,13 @@ public: STDMETHODIMP GetCurFile(LPOLESTR* ppszFileName, AM_MEDIA_TYPE* pmt) {
size_t nCount;
- if(!ppszFileName) {
+ if (!ppszFileName) {
return E_POINTER;
}
nCount = m_fn.GetLength()+1;
*ppszFileName = (LPOLESTR)CoTaskMemAlloc(nCount*sizeof(WCHAR));
- if(!(*ppszFileName)) {
+ if (!(*ppszFileName)) {
return E_OUTOFMEMORY;
}
diff --git a/src/filters/source/D2VSource/D2VSource.cpp b/src/filters/source/D2VSource/D2VSource.cpp index d120b744a..42229c984 100644 --- a/src/filters/source/D2VSource/D2VSource.cpp +++ b/src/filters/source/D2VSource/D2VSource.cpp @@ -80,7 +80,7 @@ CFilterApp theApp; CD2VSource::CD2VSource(LPUNKNOWN lpunk, HRESULT* phr)
: CBaseSource<CD2VStream>(NAME("CD2VSource"), lpunk, phr, __uuidof(this))
{
- if(phr) {
+ if (phr) {
*phr = S_OK;
}
}
@@ -100,22 +100,22 @@ CD2VStream::CD2VStream(const WCHAR* fn, CSource* pParent, HRESULT* phr) CAutoLock cAutoLock(&m_cSharedState);
m_pDecoder.Attach(DNew CMPEG2Dec());
- if(!m_pDecoder) {
- if(phr) {
+ if (!m_pDecoder) {
+ if (phr) {
*phr = E_OUTOFMEMORY;
}
return;
}
- if(!m_pDecoder->Open(CString(fn), CMPEG2Dec::YUY2)) {
- if(phr) {
+ if (!m_pDecoder->Open(CString(fn), CMPEG2Dec::YUY2)) {
+ if (phr) {
*phr = E_FAIL;
}
return;
}
- if(!m_pFrameBuffer.Allocate(m_pDecoder->Clip_Width*m_pDecoder->Clip_Height*4)) {
- if(phr) {
+ if (!m_pFrameBuffer.Allocate(m_pDecoder->Clip_Width*m_pDecoder->Clip_Height*4)) {
+ if (phr) {
*phr = E_OUTOFMEMORY;
}
return;
@@ -124,7 +124,7 @@ CD2VStream::CD2VStream(const WCHAR* fn, CSource* pParent, HRESULT* phr) m_AvgTimePerFrame = 10000000000i64/m_pDecoder->VF_FrameRate;
m_rtDuration = m_rtStop = m_AvgTimePerFrame*m_pDecoder->VF_FrameLimit;
- if(phr) {
+ if (phr) {
*phr = m_rtDuration > 0 ? S_OK : E_FAIL;
}
}
@@ -144,7 +144,7 @@ HRESULT CD2VStream::DecideBufferSize(IMemAllocator* pAlloc, ALLOCATOR_PROPERTIES HRESULT hr = NOERROR;
int w, h, bpp;
- if(!GetDim(w, h, bpp)) {
+ if (!GetDim(w, h, bpp)) {
return E_FAIL;
}
@@ -152,11 +152,11 @@ HRESULT CD2VStream::DecideBufferSize(IMemAllocator* pAlloc, ALLOCATOR_PROPERTIES pProperties->cbBuffer = w*h*bpp>>3;
ALLOCATOR_PROPERTIES Actual;
- if(FAILED(hr = pAlloc->SetProperties(pProperties, &Actual))) {
+ if (FAILED(hr = pAlloc->SetProperties(pProperties, &Actual))) {
return hr;
}
- if(Actual.cbBuffer < pProperties->cbBuffer) {
+ if (Actual.cbBuffer < pProperties->cbBuffer) {
return E_FAIL;
}
ASSERT(Actual.cBuffers == pProperties->cBuffers);
@@ -166,12 +166,12 @@ HRESULT CD2VStream::DecideBufferSize(IMemAllocator* pAlloc, ALLOCATOR_PROPERTIES HRESULT CD2VStream::FillBuffer(IMediaSample* pSample, int nFrame, BYTE* pOut, long& len)
{
- if(!m_pDecoder) {
+ if (!m_pDecoder) {
return S_FALSE;
}
AM_MEDIA_TYPE* pmt;
- if(SUCCEEDED(pSample->GetMediaType(&pmt)) && pmt) {
+ if (SUCCEEDED(pSample->GetMediaType(&pmt)) && pmt) {
CMediaType mt(*pmt);
SetMediaType(&mt);
@@ -179,7 +179,7 @@ HRESULT CD2VStream::FillBuffer(IMediaSample* pSample, int nFrame, BYTE* pOut, lo }
int w, h, bpp;
- if(!GetDim(w, h, bpp)) {
+ if (!GetDim(w, h, bpp)) {
return S_FALSE;
}
@@ -192,7 +192,7 @@ HRESULT CD2VStream::FillBuffer(IMediaSample* pSample, int nFrame, BYTE* pOut, lo m_pDecoder->Decode(pIn, (unsigned long)(nFrame), pitchIn);
- for(int y = 0, p = min(pitchIn, pitchOut);
+ for (int y = 0, p = min(pitchIn, pitchOut);
y < h;
y++, pIn += pitchIn, pOut += pitchOut) {
memcpy(pOut, pIn, p);
@@ -207,10 +207,10 @@ HRESULT CD2VStream::GetMediaType(int iPosition, CMediaType* pmt) {
CAutoLock cAutoLock(m_pFilter->pStateLock());
- if(iPosition < 0) {
+ if (iPosition < 0) {
return E_INVALIDARG;
}
- if(iPosition > 0) {
+ if (iPosition > 0) {
return VFW_S_NO_MORE_ITEMS;
}
@@ -237,8 +237,8 @@ HRESULT CD2VStream::GetMediaType(int iPosition, CMediaType* pmt) HRESULT CD2VStream::SetMediaType(const CMediaType* pmt)
{
- if(m_pDecoder) {
- if(pmt->subtype == MEDIASUBTYPE_YUY2) {
+ if (m_pDecoder) {
+ if (pmt->subtype == MEDIASUBTYPE_YUY2) {
m_pDecoder->m_dstFormat = CMPEG2Dec::YUY2;
} else {
return E_FAIL;
@@ -259,7 +259,7 @@ HRESULT CD2VStream::CheckMediaType(const CMediaType* pmt) STDMETHODIMP CD2VStream::Notify(IBaseFilter* pSender, Quality q)
{
- if(q.Late > 0 && q.Late < 100000000) {
+ if (q.Late > 0 && q.Late < 100000000) {
CAutoLock cAutoLockShared(&m_cSharedState);
m_rtSampleTime += (q.Late/m_AvgTimePerFrame)*m_AvgTimePerFrame;
@@ -273,11 +273,11 @@ STDMETHODIMP CD2VStream::Notify(IBaseFilter* pSender, Quality q) bool CD2VStream::GetDim(int& w, int& h, int& bpp)
{
- if(m_mt.formattype == FORMAT_VideoInfo) {
+ if (m_mt.formattype == FORMAT_VideoInfo) {
w = ((VIDEOINFOHEADER*)m_mt.pbFormat)->bmiHeader.biWidth;
h = abs(((VIDEOINFOHEADER*)m_mt.pbFormat)->bmiHeader.biHeight);
bpp = ((VIDEOINFOHEADER*)m_mt.pbFormat)->bmiHeader.biBitCount;
- } else if(m_mt.formattype == FORMAT_VideoInfo2) {
+ } else if (m_mt.formattype == FORMAT_VideoInfo2) {
w = ((VIDEOINFOHEADER2*)m_mt.pbFormat)->bmiHeader.biWidth;
h = abs(((VIDEOINFOHEADER2*)m_mt.pbFormat)->bmiHeader.biHeight);
bpp = ((VIDEOINFOHEADER2*)m_mt.pbFormat)->bmiHeader.biBitCount;
diff --git a/src/filters/source/DTSAC3Source/DTSAC3Source.cpp b/src/filters/source/DTSAC3Source/DTSAC3Source.cpp index a1259e811..0b6fec8a4 100644 --- a/src/filters/source/DTSAC3Source/DTSAC3Source.cpp +++ b/src/filters/source/DTSAC3Source/DTSAC3Source.cpp @@ -36,8 +36,8 @@ enum { unknown,
AC3,
EAC3,
-// TrueHD,
-// TrueHDAC3,
+ // TrueHD,
+ // TrueHDAC3,
MLP,
DTS,
DTSHD,
@@ -48,9 +48,9 @@ enum { bool isDTSSync(const DWORD sync)
{
if (sync == 0x0180fe7f || //16 bits and big endian bitstream
- sync == 0x80017ffe || //16 bits and little endian bitstream
- sync == 0x00e8ff1f || //14 bits and big endian bitstream
- sync == 0xe8001fff) //14 bits and little endian bitstream
+ sync == 0x80017ffe || //16 bits and little endian bitstream
+ sync == 0x00e8ff1f || //14 bits and big endian bitstream
+ sync == 0xe8001fff) //14 bits and little endian bitstream
return true;
else
return false;
@@ -59,17 +59,17 @@ bool isDTSSync(const DWORD sync) DWORD ParseWAVECDHeader(const BYTE wh[44])
{
if (*(DWORD*)wh != 0x46464952 //"RIFF"
- || *(DWORDLONG*)(wh+8) != 0x20746d6645564157 //"WAVEfmt "
- || *(DWORD*)(wh+36) != 0x61746164) { //"data"
+ || *(DWORDLONG*)(wh+8) != 0x20746d6645564157 //"WAVEfmt "
+ || *(DWORD*)(wh+36) != 0x61746164) { //"data"
return 0;
- }
+ }
PCMWAVEFORMAT pcmwf = *(PCMWAVEFORMAT*)(wh+20);
if (pcmwf.wf.wFormatTag != 1
- || pcmwf.wf.nChannels != 2
- || pcmwf.wf.nSamplesPerSec != 44100
- || pcmwf.wf.nAvgBytesPerSec != 176400
- || pcmwf.wf.nBlockAlign != 4
- || pcmwf.wBitsPerSample != 16) {
+ || pcmwf.wf.nChannels != 2
+ || pcmwf.wf.nSamplesPerSec != 44100
+ || pcmwf.wf.nAvgBytesPerSec != 176400
+ || pcmwf.wf.nBlockAlign != 4
+ || pcmwf.wBitsPerSample != 16) {
return 0;
}
return *(DWORD*)(wh+40); //return size of "data"
@@ -79,9 +79,9 @@ int ParseAC3IEC61937Header(const BYTE *buf) {
WORD* wbuf = (WORD*)buf;
if (*(DWORD*)buf == IEC61937_SYNC_WORD
- && wbuf[2] == 0x0001
- && wbuf[3] > 0 && wbuf[3] < (6144-8)*8
- && wbuf[4] == 0x0B77 ) {
+ && wbuf[2] == 0x0001
+ && wbuf[3] > 0 && wbuf[3] < (6144-8)*8
+ && wbuf[4] == 0x0B77 ) {
return 6144;
}
return 0;
@@ -201,7 +201,7 @@ CDTSAC3Stream::CDTSAC3Stream(const WCHAR* wfn, CSource* pParent, HRESULT* phr) bool waveheader = false;
do {
- if(!m_file.Open(fn, CFile::modeRead|CFile::shareDenyNone, &ex)) {
+ if (!m_file.Open(fn, CFile::modeRead|CFile::shareDenyNone, &ex)) {
hr = AmHresultFromWin32 (ex.m_lOsError);
break;
}
@@ -209,7 +209,7 @@ CDTSAC3Stream::CDTSAC3Stream(const WCHAR* wfn, CSource* pParent, HRESULT* phr) DWORD id = 0;
DWORD id2 = 0;
if (m_file.Read(&id, sizeof(id)) != sizeof(id) ||
- m_file.Read(&id2, sizeof(id2)) != sizeof(id2))
+ m_file.Read(&id2, sizeof(id2)) != sizeof(id2))
break;
// WAVE-CD header
@@ -220,8 +220,8 @@ CDTSAC3Stream::CDTSAC3Stream(const WCHAR* wfn, CSource* pParent, HRESULT* phr) BYTE buf[44];
m_file.SeekToBegin();
if (m_file.Read(&buf, 44) != 44
- || ParseWAVECDHeader(buf) == 0
- || m_file.Read(&id, sizeof(id)) != sizeof(id))
+ || ParseWAVECDHeader(buf) == 0
+ || m_file.Read(&id, sizeof(id)) != sizeof(id))
break;
waveheader = true;
}
@@ -230,7 +230,7 @@ CDTSAC3Stream::CDTSAC3Stream(const WCHAR* wfn, CSource* pParent, HRESULT* phr) // search DTS and AC3 headers (skip garbage in the beginning)
if (!isDTSSync(id) && (WORD)id!=AC3_SYNC_WORD
- && id!=IEC61937_SYNC_WORD /*&& id2!=TRUEHD_SYNC_WORD*/) {
+ && id!=IEC61937_SYNC_WORD /*&& id2!=TRUEHD_SYNC_WORD*/) {
if (ext != _T(".dtswav") && ext != _T(".dts") && ext != _T(".wav") && ext != _T(".ac3") && ext != _T(".eac3")) //check only specific extensions
break;
m_file.Seek(m_dataOffset, CFile::begin);
@@ -260,7 +260,7 @@ CDTSAC3Stream::CDTSAC3Stream(const WCHAR* wfn, CSource* pParent, HRESULT* phr) dts_state_t* m_dts_state;
m_dts_state = dts_init(0);
int fsize = 0, flags, targeted_bitrate;
- if((fsize = dts_syncinfo(m_dts_state, buf, &flags, &m_samplerate, &targeted_bitrate, &m_framelength)) < 96) { //minimal valid fsize = 96
+ if ((fsize = dts_syncinfo(m_dts_state, buf, &flags, &m_samplerate, &targeted_bitrate, &m_framelength)) < 96) { //minimal valid fsize = 96
break;
}
m_streamtype = DTS;
@@ -288,7 +288,7 @@ CDTSAC3Stream::CDTSAC3Stream(const WCHAR* wfn, CSource* pParent, HRESULT* phr) zero_bytes = 2048 - fsize;
m_streamtype = DTSPaded;
}
- }
+ }
/*const int bitratetbl[32] = {
32000, 56000, 64000, 96000,
@@ -305,7 +305,7 @@ CDTSAC3Stream::CDTSAC3Stream(const WCHAR* wfn, CSource* pParent, HRESULT* phr) // [22] 1411200 is actually 1234800 for 14-bit DTS-CD audio
};*/
const int channels[16] = {1, 2, 2, 2, 2, 3, 3, 4, 4, 5, 6, 6, 6, 7, 8, 8};
-
+
// calculate actual bitrate
m_framesize = fsize + HD_size + zero_bytes;
m_bitrate = int ((m_framesize) * 8i64 * m_samplerate / m_framelength);
@@ -325,11 +325,11 @@ CDTSAC3Stream::CDTSAC3Stream(const WCHAR* wfn, CSource* pParent, HRESULT* phr) if (m_bitrate!=0)
m_AvgTimePerFrame = 10000000i64 * m_framesize * 8 / m_bitrate;
-
+
m_wFormatTag = WAVE_FORMAT_DTS;
m_subtype = MEDIASUBTYPE_DTS;
-
- // AC3 & E-AC3
+
+ // AC3 & E-AC3
} else if ((WORD)id == AC3_SYNC_WORD) {
BYTE buf[20];
if (m_file.Read(&buf, 8) != 8)
@@ -358,7 +358,7 @@ CDTSAC3Stream::CDTSAC3Stream(const WCHAR* wfn, CSource* pParent, HRESULT* phr) }
}
*/
- // E-AC3 header
+ // E-AC3 header
} else if (bsid == 16) {
int frametype;
fsize = ParseEAC3Header(buf, &m_samplerate, &m_channels, &m_framelength, &frametype);
@@ -390,7 +390,7 @@ CDTSAC3Stream::CDTSAC3Stream(const WCHAR* wfn, CSource* pParent, HRESULT* phr) m_wFormatTag = WAVE_FORMAT_UNKNOWN;
m_subtype = MEDIASUBTYPE_DOLBY_AC3;
- // SPDIF AC3
+ // SPDIF AC3
} else if (waveheader && id == IEC61937_SYNC_WORD) {
BYTE buf[16];
if (m_file.Read(&buf, 16) != 16)
@@ -398,7 +398,7 @@ CDTSAC3Stream::CDTSAC3Stream(const WCHAR* wfn, CSource* pParent, HRESULT* phr) m_framesize = ParseAC3IEC61937Header(buf);
if (m_framesize == 0)
break;
-
+
m_wFormatTag = WAVE_FORMAT_DOLBY_AC3_SPDIF;
m_channels = 2;
m_samplerate = 44100;
@@ -410,42 +410,42 @@ CDTSAC3Stream::CDTSAC3Stream(const WCHAR* wfn, CSource* pParent, HRESULT* phr) m_subtype = MEDIASUBTYPE_DOLBY_AC3_SPDIF;
m_streamtype = SPDIF_AC3;
- /*
- // TrueHD
- } else if (id2 == TRUEHD_SYNC_WORD) {
- BYTE buf[20];
- if (m_file.Read(&buf, 20) != 20)
- break;
- int fsize = 0;
- int fsize2 = 0;
- fsize = ParseTrueHDHeader(buf, &m_samplerate, &m_channels, &m_framelength);
- if (fsize == 0)
- break;
- m_streamtype = TrueHD;
- m_fixedframesize = false;
+ /*
+ // TrueHD
+ } else if (id2 == TRUEHD_SYNC_WORD) {
+ BYTE buf[20];
+ if (m_file.Read(&buf, 20) != 20)
+ break;
+ int fsize = 0;
+ int fsize2 = 0;
+ fsize = ParseTrueHDHeader(buf, &m_samplerate, &m_channels, &m_framelength);
+ if (fsize == 0)
+ break;
+ m_streamtype = TrueHD;
+ m_fixedframesize = false;
- if (m_samplerate!=0)
- m_AvgTimePerFrame = 10000000i64 * m_framelength / m_samplerate;
+ if (m_samplerate!=0)
+ m_AvgTimePerFrame = 10000000i64 * m_framelength / m_samplerate;
- // TrueHD+AC3
- if (m_file.Read(&buf, 8) == 8) {
- int samplerate2, channels2, framelength2, bitrate2;
- fsize2 = ParseAC3Header(buf, &samplerate2, &channels2, &framelength2, &bitrate2);
- if (fsize2 > 0) {
- m_streamtype = TrueHDAC3;
+ // TrueHD+AC3
+ if (m_file.Read(&buf, 8) == 8) {
+ int samplerate2, channels2, framelength2, bitrate2;
+ fsize2 = ParseAC3Header(buf, &samplerate2, &channels2, &framelength2, &bitrate2);
+ if (fsize2 > 0) {
+ m_streamtype = TrueHDAC3;
- if (samplerate2!=0)
- m_AvgTimePerFrame = 10000000i64 * framelength2 / samplerate2;
+ if (samplerate2!=0)
+ m_AvgTimePerFrame = 10000000i64 * framelength2 / samplerate2;
+ }
}
- }
- m_framesize = fsize + fsize2;
- m_bitrate = int ((m_framesize) * 8i64 * m_samplerate / m_framelength);
- //m_bitdepth = 24;
+ m_framesize = fsize + fsize2;
+ m_bitrate = int ((m_framesize) * 8i64 * m_samplerate / m_framelength);
+ //m_bitdepth = 24;
- m_wFormatTag = WAVE_FORMAT_UNKNOWN;
- m_subtype = MEDIASUBTYPE_DOLBY_TRUEHD;
- */
+ m_wFormatTag = WAVE_FORMAT_UNKNOWN;
+ m_subtype = MEDIASUBTYPE_DOLBY_TRUEHD;
+ */
} else {
break;
}
@@ -456,7 +456,7 @@ CDTSAC3Stream::CDTSAC3Stream(const WCHAR* wfn, CSource* pParent, HRESULT* phr) hr = S_OK;
} while (false);
- if(phr) {
+ if (phr) {
*phr = hr;
}
}
@@ -476,11 +476,11 @@ HRESULT CDTSAC3Stream::DecideBufferSize(IMemAllocator* pAlloc, ALLOCATOR_PROPERT pProperties->cbBuffer = m_framesize;
ALLOCATOR_PROPERTIES Actual;
- if(FAILED(hr = pAlloc->SetProperties(pProperties, &Actual))) {
+ if (FAILED(hr = pAlloc->SetProperties(pProperties, &Actual))) {
return hr;
}
- if(Actual.cbBuffer < pProperties->cbBuffer) {
+ if (Actual.cbBuffer < pProperties->cbBuffer) {
return E_FAIL;
}
ASSERT(Actual.cBuffers == pProperties->cBuffers);
@@ -496,9 +496,9 @@ HRESULT CDTSAC3Stream::FillBuffer(IMediaSample* pSample, int nFrame, BYTE* pOut, const GUID* subtype = &m_mt.subtype;
UNUSED_ALWAYS(subtype);
- if(*majortype == MEDIATYPE_Audio) {
+ if (*majortype == MEDIATYPE_Audio) {
m_file.Seek(m_dataOffset + nFrame*m_framesize, CFile::begin);
- if((int)m_file.Read(pOut, m_framesize) < m_framesize) {
+ if ((int)m_file.Read(pOut, m_framesize) < m_framesize) {
return S_FALSE;
}
pOut += m_framesize;
@@ -530,8 +530,8 @@ bool CDTSAC3Stream::CheckAC3(const CMediaType* pmt) return pmt->majortype == MEDIATYPE_Audio
&& pmt->subtype == MEDIASUBTYPE_DOLBY_AC3
&& pmt->formattype == FORMAT_WaveFormatEx
- && (((WAVEFORMATEX*)pmt->pbFormat)->wFormatTag == WAVE_FORMAT_UNKNOWN
- || ((WAVEFORMATEX*)pmt->pbFormat)->wFormatTag == WAVE_FORMAT_DOLBY_AC3);
+ && (((WAVEFORMATEX*)pmt->pbFormat)->wFormatTag == WAVE_FORMAT_UNKNOWN
+ || ((WAVEFORMATEX*)pmt->pbFormat)->wFormatTag == WAVE_FORMAT_DOLBY_AC3);
}
bool CDTSAC3Stream::CheckSPDIFAC3(const CMediaType* pmt)
@@ -560,7 +560,7 @@ HRESULT CDTSAC3Stream::GetMediaType(int iPosition, CMediaType* pmt) pmt->majortype = MEDIATYPE_Audio;
pmt->subtype = m_subtype;
pmt->formattype = FORMAT_WaveFormatEx;
-
+
WAVEFORMATEX* wfe = (WAVEFORMATEX*)pmt->AllocFormatBuffer(sizeof(WAVEFORMATEX));
wfe->wFormatTag = m_wFormatTag;
wfe->nChannels = m_channels;
@@ -573,8 +573,8 @@ HRESULT CDTSAC3Stream::GetMediaType(int iPosition, CMediaType* pmt) if (m_streamtype == SPDIF_AC3) {
wfe->nBlockAlign = 4;
pmt->SetSampleSize(m_framesize);
-// } else if (m_streamtype == TrueHD) {
-// pmt->SetSampleSize(0);
+ // } else if (m_streamtype == TrueHD) {
+ // pmt->SetSampleSize(0);
}
} else {
@@ -589,8 +589,8 @@ HRESULT CDTSAC3Stream::GetMediaType(int iPosition, CMediaType* pmt) HRESULT CDTSAC3Stream::CheckMediaType(const CMediaType* pmt)
{
return CheckDTS(pmt) || CheckDTS2(pmt)
- || CheckAC3(pmt) || CheckSPDIFAC3(pmt)
-// || CheckTrueHD(pmt)
+ || CheckAC3(pmt) || CheckSPDIFAC3(pmt)
+ // || CheckTrueHD(pmt)
? S_OK
: E_INVALIDARG;
}
diff --git a/src/filters/source/DTSAC3Source/DTSAC3Source.h b/src/filters/source/DTSAC3Source/DTSAC3Source.h index bf9a25dfe..48dec8f32 100644 --- a/src/filters/source/DTSAC3Source/DTSAC3Source.h +++ b/src/filters/source/DTSAC3Source/DTSAC3Source.h @@ -54,7 +54,7 @@ class CDTSAC3Stream : public CBaseStream bool CheckDTS2(const CMediaType* pmt);
bool CheckAC3(const CMediaType* pmt);
bool CheckSPDIFAC3(const CMediaType* pmt);
-// bool CheckTrueHD(const CMediaType* pmt);
+ // bool CheckTrueHD(const CMediaType* pmt);
public:
CDTSAC3Stream(const WCHAR* wfn, CSource* pParent, HRESULT* phr);
diff --git a/src/filters/source/FLACSource/FLACSource.cpp b/src/filters/source/FLACSource/FLACSource.cpp index 8a0c6f4fd..939fb72d3 100644 --- a/src/filters/source/FLACSource/FLACSource.cpp +++ b/src/filters/source/FLACSource/FLACSource.cpp @@ -119,7 +119,7 @@ CFLACStream::CFLACStream(const WCHAR* wfn, CSource* pParent, HRESULT* phr) HRESULT hr = E_FAIL;
do {
- if(!m_file.Open(fn, CFile::modeRead|CFile::shareDenyNone, &ex)) {
+ if (!m_file.Open(fn, CFile::modeRead|CFile::shareDenyNone, &ex)) {
hr = AmHresultFromWin32 (ex.m_lOsError);
break;
}
@@ -153,7 +153,7 @@ CFLACStream::CFLACStream(const WCHAR* wfn, CSource* pParent, HRESULT* phr) hr = S_OK;
} while (false);
- if(phr) {
+ if (phr) {
*phr = hr;
}
}
@@ -173,11 +173,11 @@ HRESULT CFLACStream::DecideBufferSize(IMemAllocator* pAlloc, ALLOCATOR_PROPERTIE pProperties->cbBuffer = m_nMaxFrameSize;
ALLOCATOR_PROPERTIES Actual;
- if(FAILED(hr = pAlloc->SetProperties(pProperties, &Actual))) {
+ if (FAILED(hr = pAlloc->SetProperties(pProperties, &Actual))) {
return hr;
}
- if(Actual.cbBuffer < pProperties->cbBuffer) {
+ if (Actual.cbBuffer < pProperties->cbBuffer) {
return E_FAIL;
}
ASSERT(Actual.cBuffers == pProperties->cBuffers);
@@ -222,7 +222,7 @@ HRESULT CFLACStream::GetMediaType(int iPosition, CMediaType* pmt) {
CAutoLock cAutoLock(m_pFilter->pStateLock());
- if(iPosition == 0) {
+ if (iPosition == 0) {
pmt->majortype = MEDIATYPE_Audio;
pmt->subtype = MEDIASUBTYPE_FLAC_FRAMED;
pmt->formattype = FORMAT_WaveFormatEx;
diff --git a/src/filters/source/FLICSource/FLICSource.cpp b/src/filters/source/FLICSource/FLICSource.cpp index e85e278a2..c06cbfeb1 100644 --- a/src/filters/source/FLICSource/FLICSource.cpp +++ b/src/filters/source/FLICSource/FLICSource.cpp @@ -110,16 +110,16 @@ STDMETHODIMP CFLICSource::NonDelegatingQueryInterface(REFIID riid, void** ppv) STDMETHODIMP CFLICSource::Load(LPCOLESTR pszFileName, const AM_MEDIA_TYPE* pmt)
{
- if(GetPinCount() > 0) {
+ if (GetPinCount() > 0) {
return VFW_E_ALREADY_CONNECTED;
}
HRESULT hr = S_OK;
- if(!(DNew CFLICStream(pszFileName, this, &hr))) {
+ if (!(DNew CFLICStream(pszFileName, this, &hr))) {
return E_OUTOFMEMORY;
}
- if(FAILED(hr)) {
+ if (FAILED(hr)) {
return hr;
}
@@ -130,12 +130,12 @@ STDMETHODIMP CFLICSource::Load(LPCOLESTR pszFileName, const AM_MEDIA_TYPE* pmt) STDMETHODIMP CFLICSource::GetCurFile(LPOLESTR* ppszFileName, AM_MEDIA_TYPE* pmt)
{
- if(!ppszFileName) {
+ if (!ppszFileName) {
return E_POINTER;
}
*ppszFileName = (LPOLESTR)CoTaskMemAlloc((m_fn.GetLength()+1)*sizeof(WCHAR));
- if(!(*ppszFileName)) {
+ if (!(*ppszFileName)) {
return E_OUTOFMEMORY;
}
@@ -162,15 +162,15 @@ CFLICStream::CFLICStream(const WCHAR* wfn, CFLICSource* pParent, HRESULT* phr) CString fn(wfn);
- if(!m_flic.Open(fn, CFile::modeRead|CFile::shareDenyNone)) {
- if(phr) *phr = E_FAIL;
+ if (!m_flic.Open(fn, CFile::modeRead|CFile::shareDenyNone)) {
+ if (phr) *phr = E_FAIL;
return;
}
- if(m_flic.Read(&m_hdr, sizeof(m_hdr)) != sizeof(m_hdr)
+ if (m_flic.Read(&m_hdr, sizeof(m_hdr)) != sizeof(m_hdr)
|| (m_hdr.type != 0xAF11 && m_hdr.type != 0xAF12)
|| m_hdr.depth != 8) {
- if(phr) *phr = E_FAIL;
+ if (phr) *phr = E_FAIL;
return;
}
@@ -185,7 +185,7 @@ CFLICStream::CFLICStream(const WCHAR* wfn, CFLICSource* pParent, HRESULT* phr) {
__int64 pos = m_flic.GetPosition();
FLIC_PREFIX fp;
- if(m_flic.Read(&fp, sizeof(fp)) != sizeof(fp) || fp.type != 0xF100) {
+ if (m_flic.Read(&fp, sizeof(fp)) != sizeof(fp) || fp.type != 0xF100) {
m_flic.Seek(pos, CFile::begin);
} else {
m_flic.Seek(pos + fp.size, CFile::begin);
@@ -196,37 +196,37 @@ CFLICStream::CFLICStream(const WCHAR* wfn, CFLICSource* pParent, HRESULT* phr) unsigned int nFrames = 0;
m_frames.SetCount(m_hdr.frames);
while (nFrames < m_hdr.frames && m_flic.Read(&ffe.hdr, sizeof(ffe.hdr)) == sizeof(ffe.hdr) && ffe.hdr.type == 0xF1FA) {
-
+
ffe.pos = m_flic.GetPosition();
ffe.fKeyframe = false;
int chunk = 0;
- while(chunk < ffe.hdr.chunks) {
+ while (chunk < ffe.hdr.chunks) {
FLIC_CHUNK fc;
- if(m_flic.Read(&fc, sizeof(fc)) != sizeof(fc)) {
+ if (m_flic.Read(&fc, sizeof(fc)) != sizeof(fc)) {
break;
}
ffe.fKeyframe = ffe.fKeyframe
- || fc.type == FLIC_BRUN
- || fc.type == FLIC_BLACK
- || fc.type == FLIC_COPY
- || fc.type == DTA_BRUN
- || fc.type == DTA_COPY
- || fc.type == KEY_IMAGE;
+ || fc.type == FLIC_BRUN
+ || fc.type == FLIC_BLACK
+ || fc.type == FLIC_COPY
+ || fc.type == DTA_BRUN
+ || fc.type == DTA_COPY
+ || fc.type == KEY_IMAGE;
ULONGLONG pos = m_flic.GetPosition() + fc.size - sizeof(fc);
- if(pos < m_flic.GetLength()) {
+ if (pos < m_flic.GetLength()) {
m_flic.Seek(pos, CFile::begin);
} else break;
chunk++;
}
- if(chunk < ffe.hdr.chunks) {
+ if (chunk < ffe.hdr.chunks) {
break;
}
ULONGLONG pos = ffe.pos + ffe.hdr.size - sizeof(ffe.hdr);
- if(pos < m_flic.GetLength()) {
+ if (pos < m_flic.GetLength()) {
m_flic.Seek(pos, CFile::begin);
} else break;
@@ -237,21 +237,21 @@ CFLICStream::CFLICStream(const WCHAR* wfn, CFLICSource* pParent, HRESULT* phr) m_frames.SetCount(nFrames); // if the file is incomplete, then truncate the index
m_frames[0].fKeyframe = true;
} else {
- if(phr) *phr = E_FAIL;
+ if (phr) *phr = E_FAIL;
return;
}
m_nLastFrameNum = -1;
memset(m_pPalette, 0, sizeof(m_pPalette));
m_nBufferSize = m_hdr.width*m_hdr.height*32>>3;
- if(!m_pFrameBuffer.Allocate(m_nBufferSize)) {
- if(phr) *phr = E_OUTOFMEMORY;
+ if (!m_pFrameBuffer.Allocate(m_nBufferSize)) {
+ if (phr) *phr = E_OUTOFMEMORY;
return;
}
m_rtDuration = m_rtStop = m_AvgTimePerFrame*nFrames;
- if(phr) {
+ if (phr) {
*phr = m_rtDuration > 0 ? S_OK : E_FAIL;
}
}
@@ -271,7 +271,7 @@ STDMETHODIMP CFLICStream::NonDelegatingQueryInterface(REFIID riid, void** ppv) void CFLICStream::UpdateFromSeek()
{
- if(ThreadExists()) {
+ if (ThreadExists()) {
// next time around the loop, the worker thread will
// pick up the position change.
// We need to flush all the existing data - we must do that here
@@ -294,7 +294,7 @@ void CFLICStream::UpdateFromSeek() HRESULT CFLICStream::SetRate(double dRate)
{
- if(dRate <= 0) {
+ if (dRate <= 0) {
return E_INVALIDARG;
}
@@ -331,7 +331,7 @@ HRESULT CFLICStream::ChangeStop() {
{
CAutoLock lock(CSourceSeeking::m_pLock);
- if(m_rtPosition < m_rtStop) {
+ if (m_rtPosition < m_rtStop) {
return S_OK;
}
}
@@ -364,11 +364,11 @@ HRESULT CFLICStream::DecideBufferSize(IMemAllocator* pAlloc, ALLOCATOR_PROPERTIE pProperties->cbBuffer = m_nBufferSize;
ALLOCATOR_PROPERTIES Actual;
- if(FAILED(hr = pAlloc->SetProperties(pProperties, &Actual))) {
+ if (FAILED(hr = pAlloc->SetProperties(pProperties, &Actual))) {
return hr;
}
- if(Actual.cbBuffer < pProperties->cbBuffer) {
+ if (Actual.cbBuffer < pProperties->cbBuffer) {
return E_FAIL;
}
ASSERT(Actual.cBuffers == pProperties->cBuffers);
@@ -383,18 +383,18 @@ HRESULT CFLICStream::FillBuffer(IMediaSample* pSample) {
CAutoLock cAutoLockShared(&m_cSharedState);
- if(m_rtPosition >= m_rtStop) {
+ if (m_rtPosition >= m_rtStop) {
return S_FALSE;
}
BYTE* pDataIn = m_pFrameBuffer;
BYTE* pDataOut = NULL;
- if(!pDataIn || FAILED(hr = pSample->GetPointer(&pDataOut)) || !pDataOut) {
+ if (!pDataIn || FAILED(hr = pSample->GetPointer(&pDataOut)) || !pDataOut) {
return S_FALSE;
}
AM_MEDIA_TYPE* pmt;
- if(SUCCEEDED(pSample->GetMediaType(&pmt)) && pmt) {
+ if (SUCCEEDED(pSample->GetMediaType(&pmt)) && pmt) {
CMediaType mt(*pmt);
SetMediaType(&mt);
@@ -402,11 +402,11 @@ HRESULT CFLICStream::FillBuffer(IMediaSample* pSample) }
int w, h, bpp;
- if(m_mt.formattype == FORMAT_VideoInfo) {
+ if (m_mt.formattype == FORMAT_VideoInfo) {
w = ((VIDEOINFOHEADER*)m_mt.pbFormat)->bmiHeader.biWidth;
h = abs(((VIDEOINFOHEADER*)m_mt.pbFormat)->bmiHeader.biHeight);
bpp = ((VIDEOINFOHEADER*)m_mt.pbFormat)->bmiHeader.biBitCount;
- } else if(m_mt.formattype == FORMAT_VideoInfo2) {
+ } else if (m_mt.formattype == FORMAT_VideoInfo2) {
w = ((VIDEOINFOHEADER2*)m_mt.pbFormat)->bmiHeader.biWidth;
h = abs(((VIDEOINFOHEADER2*)m_mt.pbFormat)->bmiHeader.biHeight);
bpp = ((VIDEOINFOHEADER2*)m_mt.pbFormat)->bmiHeader.biBitCount;
@@ -422,17 +422,17 @@ HRESULT CFLICStream::FillBuffer(IMediaSample* pSample) {
SeekToNearestKeyFrame(nFrame);
- while(m_nLastFrameNum < nFrame && !m_bFlushing) {
+ while (m_nLastFrameNum < nFrame && !m_bFlushing) {
ExtractFrame(++m_nLastFrameNum);
}
- for(int y = 0, p = min(pitchIn, pitchOut);
+ for (int y = 0, p = min(pitchIn, pitchOut);
y < h;
y++, pDataIn += pitchIn, pDataOut += pitchOut) {
BYTE* src = pDataIn;
BYTE* end = src + p;
DWORD* dst = (DWORD*)pDataOut;
- while(src < end) {
+ while (src < end) {
*dst++ = m_pPalette[*src++];
}
}
@@ -452,7 +452,7 @@ HRESULT CFLICStream::FillBuffer(IMediaSample* pSample) pSample->SetSyncPoint(TRUE);
- if(m_bDiscontinuity) {
+ if (m_bDiscontinuity) {
pSample->SetDiscontinuity(TRUE);
m_bDiscontinuity = FALSE;
}
@@ -464,10 +464,10 @@ HRESULT CFLICStream::GetMediaType(int iPosition, CMediaType* pmt) {
CAutoLock cAutoLock(m_pFilter->pStateLock());
- if(iPosition < 0) {
+ if (iPosition < 0) {
return E_INVALIDARG;
}
- if(iPosition > 0) {
+ if (iPosition > 0) {
return VFW_S_NO_MORE_ITEMS;
}
@@ -499,7 +499,7 @@ HRESULT CFLICStream::CheckConnect(IPin* pPin) HRESULT CFLICStream::CheckMediaType(const CMediaType* pmt)
{
- if(pmt->majortype == MEDIATYPE_Video
+ if (pmt->majortype == MEDIATYPE_Video
&& pmt->subtype == MEDIASUBTYPE_RGB32
&& pmt->formattype == FORMAT_VideoInfo) {
return S_OK;
@@ -517,17 +517,17 @@ STDMETHODIMP CFLICStream::Notify(IBaseFilter* pSender, Quality q) void CFLICStream::SeekToNearestKeyFrame(int nFrame)
{
- if(m_nLastFrameNum == nFrame) {
+ if (m_nLastFrameNum == nFrame) {
return;
}
- if(m_nLastFrameNum > nFrame) {
+ if (m_nLastFrameNum > nFrame) {
m_nLastFrameNum = -1;
}
- for(int i = m_nLastFrameNum+1, j = min((int)m_frames.GetCount(), nFrame); i < j; i++) {
+ for (int i = m_nLastFrameNum+1, j = min((int)m_frames.GetCount(), nFrame); i < j; i++) {
FLIC_FRAME_ENTRY& ffe = m_frames[i];
- if(ffe.fKeyframe) {
+ if (ffe.fKeyframe) {
m_nLastFrameNum = i-1;
}
}
@@ -543,18 +543,18 @@ void CFLICStream::ExtractFrame(int nFrame) m_flic.Seek(ffe.pos, CFile::begin);
int chunk = 0;
- while(chunk < ffe.hdr.chunks) {
+ while (chunk < ffe.hdr.chunks) {
FLIC_CHUNK fc;
- if(m_flic.Read(&fc, sizeof(fc)) != sizeof(fc)) {
+ if (m_flic.Read(&fc, sizeof(fc)) != sizeof(fc)) {
break;
}
ULONGLONG next = m_flic.GetPosition() + fc.size - sizeof(fc);
- if(next >= m_flic.GetLength()) {
+ if (next >= m_flic.GetLength()) {
break;
}
- switch(fc.type) {
+ switch (fc.type) {
case FLIC_64_COLOR:
fNewPalette = _colorchunk(true);
break;
@@ -590,7 +590,7 @@ void CFLICStream::ExtractFrame(int nFrame) chunk++;
}
- if(chunk < ffe.hdr.chunks) {
+ if (chunk < ffe.hdr.chunks) {
ASSERT(0);
}
@@ -616,7 +616,7 @@ bool CFLICStream::_colorchunk(bool f64) WORD packets;
m_flic.Read(&packets, sizeof(packets));
- while(packets--) {
+ while (packets--) {
BYTE skip2;
m_flic.Read(&skip2, sizeof(skip2));
skip += skip2;
@@ -625,7 +625,7 @@ bool CFLICStream::_colorchunk(bool f64) m_flic.Read(&count, sizeof(count));
int len = (count == 0 ? (256-skip) : count);
- while(len-- > 0) {
+ while (len-- > 0) {
BYTE r, g, b;
m_flic.Read(&r, sizeof(r));
m_flic.Read(&g, sizeof(g));
@@ -645,17 +645,17 @@ void CFLICStream::_brunchunk() BYTE* tmp = m_pFrameBuffer;
int lines = m_hdr.height;
- while(lines--) {
+ while (lines--) {
BYTE packets;
m_flic.Read(&packets, sizeof(packets));
BYTE* ptr = tmp;
- while(ptr < tmp + m_hdr.width) {
+ while (ptr < tmp + m_hdr.width) {
signed char count;
m_flic.Read(&count, sizeof(count));
- if(count >= 0) {
+ if (count >= 0) {
BYTE c;
m_flic.Read(&c, sizeof(c));
memset(ptr, c, count);
@@ -680,13 +680,13 @@ void CFLICStream::_lcchunk() WORD lines;
m_flic.Read(&lines, sizeof(lines));
- while(lines--) {
+ while (lines--) {
BYTE* ptr = tmp;
BYTE packets;
m_flic.Read(&packets, sizeof(packets));
- while(packets--) {
+ while (packets--) {
BYTE skip;
m_flic.Read(&skip, sizeof(skip));
@@ -695,7 +695,7 @@ void CFLICStream::_lcchunk() signed char count;
m_flic.Read(&count, sizeof(count));
- if(count >= 0) {
+ if (count >= 0) {
m_flic.Read(ptr, count);
ptr += count;
} else {
@@ -717,12 +717,12 @@ void CFLICStream::_deltachunk() WORD lines;
m_flic.Read(&lines, sizeof(lines));
- while(lines--) {
+ while (lines--) {
signed short packets;
m_flic.Read(&packets, sizeof(packets));
- if(packets < 0) {
- if(packets&0x4000) {
+ if (packets < 0) {
+ if (packets&0x4000) {
tmp += -packets * m_hdr.width;
lines++;
} else {
@@ -733,7 +733,7 @@ void CFLICStream::_deltachunk() } else {
BYTE* ptr = tmp;
- while(packets--) {
+ while (packets--) {
BYTE skip;
m_flic.Read(&skip, sizeof(skip));
@@ -742,7 +742,7 @@ void CFLICStream::_deltachunk() signed char count;
m_flic.Read(&count, sizeof(count));
- if(count >= 0) {
+ if (count >= 0) {
// Fix vulnerability : http://www.team509.com/modules.php?name=News&file=article&sid=38
if ((count << 1) + (long)(ptr - m_pFrameBuffer) < m_nBufferSize) {
m_flic.Read(ptr, count << 1);
@@ -754,7 +754,7 @@ void CFLICStream::_deltachunk() WORD c;
m_flic.Read(&c, sizeof(c));
count = -count;
- while(count-- > 0) {
+ while (count-- > 0) {
*ptr++ = c>>8;
*ptr++ = c&0xff;
}
diff --git a/src/filters/source/ShoutcastSource/ShoutcastSource.cpp b/src/filters/source/ShoutcastSource/ShoutcastSource.cpp index 77d1305a9..77baa25fc 100644 --- a/src/filters/source/ShoutcastSource/ShoutcastSource.cpp +++ b/src/filters/source/ShoutcastSource/ShoutcastSource.cpp @@ -58,7 +58,7 @@ typedef struct { bool ExtractHeader(CSocket& socket) {
BYTE buff[4];
- if(4 != socket.Receive(buff, 4, MSG_PEEK)) {
+ if (4 != socket.Receive(buff, 4, MSG_PEEK)) {
return false;
}
@@ -111,7 +111,7 @@ class CShoutcastSourceApp : public CFilterApp {
public:
BOOL InitInstance() {
- if(!__super::InitInstance()) {
+ if (!__super::InitInstance()) {
return FALSE;
}
/*
@@ -121,7 +121,7 @@ public: return FALSE;
}
*/
- if(!AfxSocketInit(NULL)) {
+ if (!AfxSocketInit(NULL)) {
AfxMessageBox(_T("AfxSocketInit failed!"));
return FALSE;
}
@@ -166,13 +166,13 @@ STDMETHODIMP CShoutcastSource::NonDelegatingQueryInterface(REFIID riid, void** p STDMETHODIMP CShoutcastSource::Load(LPCOLESTR pszFileName, const AM_MEDIA_TYPE* pmt)
{
- if(GetPinCount() > 0) {
+ if (GetPinCount() > 0) {
return VFW_E_ALREADY_CONNECTED;
}
HRESULT hr = E_OUTOFMEMORY;
- if(!(DNew CShoutcastStream(pszFileName, this, &hr)) || FAILED(hr)) {
+ if (!(DNew CShoutcastStream(pszFileName, this, &hr)) || FAILED(hr)) {
return hr;
}
@@ -183,12 +183,12 @@ STDMETHODIMP CShoutcastSource::Load(LPCOLESTR pszFileName, const AM_MEDIA_TYPE* STDMETHODIMP CShoutcastSource::GetCurFile(LPOLESTR* ppszFileName, AM_MEDIA_TYPE* pmt)
{
- if(!ppszFileName) {
+ if (!ppszFileName) {
return E_POINTER;
}
*ppszFileName = (LPOLESTR)CoTaskMemAlloc((m_fn.GetLength()+1)*sizeof(WCHAR));
- if(!(*ppszFileName)) {
+ if (!(*ppszFileName)) {
return E_OUTOFMEMORY;
}
@@ -208,11 +208,11 @@ ULONG CShoutcastSource::GetMiscFlags() STDMETHODIMP CShoutcastSource::QueryProgress(LONGLONG* pllTotal, LONGLONG* pllCurrent)
{
- if(m_iPins == 1) {
- if(pllTotal) {
+ if (m_iPins == 1) {
+ if (pllTotal) {
*pllTotal = 100;
}
- if(pllCurrent) {
+ if (pllCurrent) {
*pllCurrent = (static_cast<CShoutcastStream*>(m_paStreams[0]))->GetBufferFullness();
}
return S_OK;
@@ -232,7 +232,7 @@ STDMETHODIMP CShoutcastSource::get_Title(BSTR* pbstrTitle) {
CheckPointer(pbstrTitle, E_POINTER);
- if(m_iPins == 1) {
+ if (m_iPins == 1) {
*pbstrTitle = (static_cast<CShoutcastStream*>(m_paStreams[0]))->GetTitle().AllocSysString();
return S_OK;
}
@@ -251,7 +251,7 @@ CShoutcastStream::CShoutcastStream(const WCHAR* wfn, CShoutcastSource* pParent, *phr = S_OK;
CString fn(wfn);
- if(fn.Find(_T("://")) < 0) {
+ if (fn.Find(_T("://")) < 0) {
fn = _T("http://") + fn;
}
@@ -267,25 +267,25 @@ CShoutcastStream::CShoutcastStream(const WCHAR* wfn, CShoutcastSource* pParent, // http://www.oddsock.org/icecast2yp/ // more ogg via icecast2
#endif
- if(!m_url.CrackUrl(fn)) {
+ if (!m_url.CrackUrl(fn)) {
*phr = E_FAIL;
return;
}
- if(m_url.GetUrlPathLength() == 0) {
+ if (m_url.GetUrlPathLength() == 0) {
m_url.SetUrlPath(_T("/"));
}
- if(m_url.GetPortNumber() == ATL_URL_INVALID_PORT_NUMBER) {
+ if (m_url.GetPortNumber() == ATL_URL_INVALID_PORT_NUMBER) {
m_url.SetPortNumber(ATL_URL_DEFAULT_HTTP_PORT);
}
- if(m_url.GetScheme() != ATL_URL_SCHEME_HTTP) {
+ if (m_url.GetScheme() != ATL_URL_SCHEME_HTTP) {
*phr = E_FAIL;
return;
}
- if(!m_socket.Create() || !m_socket.Connect(m_url)) {
+ if (!m_socket.Create() || !m_socket.Connect(m_url)) {
*phr = E_FAIL;
return;
}
@@ -306,10 +306,10 @@ void CShoutcastStream::EmptyBuffer() LONGLONG CShoutcastStream::GetBufferFullness()
{
CAutoLock cAutoLock(&m_queue);
- if(!m_fBuffering) {
+ if (!m_fBuffering) {
return 100;
}
- if(m_queue.IsEmpty()) {
+ if (m_queue.IsEmpty()) {
return 0;
}
LONGLONG ret = 100i64*(m_queue.GetTail().rtStart - m_queue.GetHead().rtStart) / AVGBUFFERLENGTH;
@@ -333,11 +333,11 @@ HRESULT CShoutcastStream::DecideBufferSize(IMemAllocator* pAlloc, ALLOCATOR_PROP pProperties->cbBuffer = MAXFRAMESIZE;
ALLOCATOR_PROPERTIES Actual;
- if(FAILED(hr = pAlloc->SetProperties(pProperties, &Actual))) {
+ if (FAILED(hr = pAlloc->SetProperties(pProperties, &Actual))) {
return hr;
}
- if(Actual.cbBuffer < pProperties->cbBuffer) {
+ if (Actual.cbBuffer < pProperties->cbBuffer) {
return E_FAIL;
}
ASSERT(Actual.cBuffers == pProperties->cBuffers);
@@ -350,7 +350,7 @@ HRESULT CShoutcastStream::FillBuffer(IMediaSample* pSample) HRESULT hr;
BYTE* pData = NULL;
- if(FAILED(hr = pSample->GetPointer(&pData)) || !pData) {
+ if (FAILED(hr = pSample->GetPointer(&pData)) || !pData) {
return S_FALSE;
}
@@ -358,7 +358,7 @@ HRESULT CShoutcastStream::FillBuffer(IMediaSample* pSample) // do we have to refill our buffer?
{
CAutoLock cAutoLock(&m_queue);
- if(!m_queue.IsEmpty() && m_queue.GetHead().rtStart < m_queue.GetTail().rtStart - MINBUFFERLENGTH) {
+ if (!m_queue.IsEmpty() && m_queue.GetHead().rtStart < m_queue.GetTail().rtStart - MINBUFFERLENGTH) {
break; // nope, that's great
}
}
@@ -366,15 +366,15 @@ HRESULT CShoutcastStream::FillBuffer(IMediaSample* pSample) TRACE(_T("START BUFFERING\n"));
m_fBuffering = true;
- while(1) {
- if(fExitThread) { // playback stopped?
+ while (1) {
+ if (fExitThread) { // playback stopped?
return S_FALSE;
}
Sleep(50);
CAutoLock cAutoLock(&m_queue);
- if(!m_queue.IsEmpty() && m_queue.GetHead().rtStart < m_queue.GetTail().rtStart - AVGBUFFERLENGTH) {
+ if (!m_queue.IsEmpty() && m_queue.GetHead().rtStart < m_queue.GetTail().rtStart - AVGBUFFERLENGTH) {
break; // this is enough
}
}
@@ -388,12 +388,12 @@ HRESULT CShoutcastStream::FillBuffer(IMediaSample* pSample) TRACE(_T("END BUFFERING\n"));
m_fBuffering = false;
- } while(false);
+ } while (false);
{
CAutoLock cAutoLock(&m_queue);
ASSERT(!m_queue.IsEmpty());
- if(!m_queue.IsEmpty()) {
+ if (!m_queue.IsEmpty()) {
mp3frame f = m_queue.RemoveHead();
DWORD len = min(pSample->GetSize(), f.len);
memcpy(pData, f.pData, len);
@@ -412,10 +412,10 @@ HRESULT CShoutcastStream::GetMediaType(int iPosition, CMediaType* pmt) {
CAutoLock cAutoLock(m_pFilter->pStateLock());
- if(iPosition < 0) {
+ if (iPosition < 0) {
return E_INVALIDARG;
}
- if(iPosition > 0) {
+ if (iPosition > 0) {
return VFW_S_NO_MORE_ITEMS;
}
@@ -437,7 +437,7 @@ HRESULT CShoutcastStream::GetMediaType(int iPosition, CMediaType* pmt) HRESULT CShoutcastStream::CheckMediaType(const CMediaType* pmt)
{
- if(pmt->majortype == MEDIATYPE_Audio
+ if (pmt->majortype == MEDIATYPE_Audio
&& pmt->subtype == MEDIASUBTYPE_MP3
&& pmt->formattype == FORMAT_WaveFormatEx) {
return S_OK;
@@ -460,7 +460,7 @@ UINT CShoutcastStream::SocketThreadProc() AfxSocketInit();
CAutoVectorPtr<BYTE> pData;
- if(!m_socket.Create() || !m_socket.Connect(m_url)
+ if (!m_socket.Create() || !m_socket.Connect(m_url)
|| !pData.Allocate(max(m_socket.m_metaint, MAXFRAMESIZE))) {
m_socket.Close();
return 1;
@@ -468,10 +468,10 @@ UINT CShoutcastStream::SocketThreadProc() REFERENCE_TIME m_rtSampleTime = 0;
- while(!fExitThread) {
+ while (!fExitThread) {
int len = MAXFRAMESIZE;
len = m_socket.Receive(pData, len);
- if(len <= 0) {
+ if (len <= 0) {
break;
}
@@ -480,7 +480,7 @@ UINT CShoutcastStream::SocketThreadProc() f.rtStop = (f.rtStart = m_rtSampleTime) + (10000000i64 * len * 8/m_socket.m_bitrate);
m_rtSampleTime = f.rtStop;
f.title = m_socket.m_title;
- if(f.title.IsEmpty()) {
+ if (f.title.IsEmpty()) {
f.title = m_socket.m_url;
}
@@ -499,7 +499,7 @@ HRESULT CShoutcastStream::OnThreadCreate() fExitThread = true;
m_hSocketThread = AfxBeginThread(::SocketThreadProc, this)->m_hThread;
- while(fExitThread) {
+ while (fExitThread) {
Sleep(10);
}
@@ -527,25 +527,25 @@ HRESULT CShoutcastStream::Inactive() int CShoutcastStream::CShoutcastSocket::Receive(void* lpBuf, int nBufLen, int nFlags)
{
- if(nFlags&MSG_PEEK) {
+ if (nFlags&MSG_PEEK) {
return __super::Receive(lpBuf, nBufLen, nFlags);
}
- if(m_metaint > 0 && m_nBytesRead + nBufLen > m_metaint) {
+ if (m_metaint > 0 && m_nBytesRead + nBufLen > m_metaint) {
nBufLen = m_metaint - m_nBytesRead;
}
int len = __super::Receive(lpBuf, nBufLen, nFlags);
- if(len <= 0) {
+ if (len <= 0) {
return len;
}
- if((m_nBytesRead += len) == m_metaint) {
+ if ((m_nBytesRead += len) == m_metaint) {
m_nBytesRead = 0;
static BYTE buff[255*16], b = 0;
memset(buff, 0, sizeof(buff));
- if(1 == __super::Receive(&b, 1) && b && b*16 == __super::Receive(buff, b*16)) {
+ if (1 == __super::Receive(&b, 1) && b && b*16 == __super::Receive(buff, b*16)) {
CStringA str = (LPCSTR)buff;
TRACE(_T("Metainfo: %s\n"), CString(str));
@@ -553,10 +553,10 @@ int CShoutcastStream::CShoutcastSocket::Receive(void* lpBuf, int nBufLen, int nF CStringA title("StreamTitle='"), url("StreamUrl='");
int i = str.Find(title);
- if(i >= 0) {
+ if (i >= 0) {
i += title.GetLength();
int j = str.Find('\'', i);
- if(j > i) {
+ if (j > i) {
m_title = str.Mid(i, j - i);
}
} else {
@@ -564,27 +564,27 @@ int CShoutcastStream::CShoutcastSocket::Receive(void* lpBuf, int nBufLen, int nF }
i = str.Find(url);
- if(i >= 0) {
+ if (i >= 0) {
i += url.GetLength();
int j = str.Find('\'', i);
- if(j > i) {
+ if (j > i) {
m_url = str.Mid(i, j - i);
}
}
}
- } else if(m_metaint > 0) {
+ } else if (m_metaint > 0) {
char* p = (char*)lpBuf;
char* p0 = p;
char* pend = p + len - 13;
- for(; p < pend; p++) {
- if(strncmp(p, "StreamTitle='", 13)) {
+ for (; p < pend; p++) {
+ if (strncmp(p, "StreamTitle='", 13)) {
continue;
}
TRACE(_T("!!!!!!!!!StreamTitle found inside mp3 data!!!!!!!!! offset=%d\n"), p - p0);
TRACE(_T("resyncing...\n"));
- while(p-- > p0) {
- if((BYTE)*p >= 0x20) {
+ while (p-- > p0) {
+ if ((BYTE)*p >= 0x20) {
continue;
}
@@ -592,14 +592,14 @@ int CShoutcastStream::CShoutcastSocket::Receive(void* lpBuf, int nBufLen, int nF p += 1 + *p*16;
len = (p0 + len) - p;
TRACE(_T("returning the remaining bytes in the packet: %d\n"), len);
- if(len <= 0) {
+ if (len <= 0) {
TRACE(_T("nothing to return, reading a bit more in\n"));
- if(len < 0) {
+ if (len < 0) {
__super::Receive(lpBuf, -len, nFlags);
}
int len = __super::Receive(lpBuf, nBufLen, nFlags);
- if(len <= 0) {
+ if (len <= 0) {
return len;
}
}
@@ -619,7 +619,7 @@ int CShoutcastStream::CShoutcastSocket::Receive(void* lpBuf, int nBufLen, int nF bool CShoutcastStream::CShoutcastSocket::Connect(CUrl& url)
{
- if(!__super::Connect(url.GetHostName(), url.GetPortNumber())) {
+ if (!__super::Connect(url.GetHostName(), url.GetPortNumber())) {
return false;
}
@@ -647,18 +647,18 @@ bool CShoutcastStream::CShoutcastSocket::Connect(CUrl& url) str.Empty();
BYTE cur = 0, prev = 0;
- while(Receive(&cur, 1) == 1 && cur && !(cur == '\n' && prev == '\n')) {
- if(cur == '\r') {
+ while (Receive(&cur, 1) == 1 && cur && !(cur == '\n' && prev == '\n')) {
+ if (cur == '\r') {
continue;
}
- if(cur == '\n') {
+ if (cur == '\n') {
str.MakeLower();
- if(str.Find("icy 200 ok") >= 0) {
+ if (str.Find("icy 200 ok") >= 0) {
fOK = true;
- } else if(1 == sscanf(str, "icy-br:%d", &m_bitrate)) {
+ } else if (1 == sscanf(str, "icy-br:%d", &m_bitrate)) {
m_bitrate *= 1000;
- } else if(1 == sscanf(str, "icy-metaint:%d", &metaint)) {
+ } else if (1 == sscanf(str, "icy-metaint:%d", &metaint)) {
metaint = metaint;
}
str.Empty();
@@ -670,7 +670,7 @@ bool CShoutcastStream::CShoutcastSocket::Connect(CUrl& url) cur = 0;
}
- if(!fOK && GetLastError() == WSAECONNRESET && !fTryAgain) {
+ if (!fOK && GetLastError() == WSAECONNRESET && !fTryAgain) {
str.Format(
"GET %s HTTP/1.0\r\n"
"Icy-MetaData:1\r\n"
@@ -683,9 +683,9 @@ bool CShoutcastStream::CShoutcastSocket::Connect(CUrl& url) } else {
fTryAgain = false;
}
- } while(fTryAgain);
+ } while (fTryAgain);
- if(!fOK || m_bitrate == 0) {
+ if (!fOK || m_bitrate == 0) {
Close();
return false;
}
@@ -702,10 +702,10 @@ bool CShoutcastStream::CShoutcastSocket::FindSync() m_channels = (DWORD)-1;
BYTE b;
- for(int i = MAXFRAMESIZE; i > 0; i--, Receive(&b, 1)) {
+ for (int i = MAXFRAMESIZE; i > 0; i--, Receive(&b, 1)) {
mp3hdr h;
- if(h.ExtractHeader(*this) && m_bitrate == h.bitrate) {
- if(h.bitrate > 1) {
+ if (h.ExtractHeader(*this) && m_bitrate == h.bitrate) {
+ if (h.bitrate > 1) {
m_bitrate = h.bitrate;
}
m_freq = h.freq;
diff --git a/src/filters/source/ShoutcastSource/ShoutcastSource.h b/src/filters/source/ShoutcastSource/ShoutcastSource.h index 3e873955c..405293f1a 100644 --- a/src/filters/source/ShoutcastSource/ShoutcastSource.h +++ b/src/filters/source/ShoutcastSource/ShoutcastSource.h @@ -128,7 +128,7 @@ class CShoutcastStream : public CSourceStream delete pData;
}
mp3frame& operator = (const mp3frame& f) {
- if(this != &f) {
+ if (this != &f) {
len = f.len;
pData = f.pData;
rtStart = f.rtStart;
diff --git a/src/filters/source/SubtitleSource/SubtitleSource.cpp b/src/filters/source/SubtitleSource/SubtitleSource.cpp index e7911ec4e..8d18f154a 100644 --- a/src/filters/source/SubtitleSource/SubtitleSource.cpp +++ b/src/filters/source/SubtitleSource/SubtitleSource.cpp @@ -119,14 +119,14 @@ class CSubtitleSourceApp : public CFilterApp {
public:
BOOL InitInstance() {
- if(!__super::InitInstance()) {
+ if (!__super::InitInstance()) {
return FALSE;
}
_WIDTH = GetProfileInt(_T("SubtitleSource"), _T("w"), 640);
_HEIGHT = GetProfileInt(_T("SubtitleSource"), _T("h"), 480);
_ATPF = GetProfileInt(_T("SubtitleSource"), _T("atpf"), 400000);
- if(_ATPF <= 0) {
+ if (_ATPF <= 0) {
_ATPF = 400000;
}
WriteProfileInt(_T("SubtitleSource"), _T("w"), _WIDTH);
@@ -168,16 +168,16 @@ STDMETHODIMP CSubtitleSource::NonDelegatingQueryInterface(REFIID riid, void** pp STDMETHODIMP CSubtitleSource::Load(LPCOLESTR pszFileName, const AM_MEDIA_TYPE* pmt)
{
- if(GetPinCount() > 0) {
+ if (GetPinCount() > 0) {
return VFW_E_ALREADY_CONNECTED;
}
HRESULT hr = S_OK;
- if(!(DNew CSubtitleStream(pszFileName, this, &hr))) {
+ if (!(DNew CSubtitleStream(pszFileName, this, &hr))) {
return E_OUTOFMEMORY;
}
- if(FAILED(hr)) {
+ if (FAILED(hr)) {
return hr;
}
@@ -191,7 +191,7 @@ STDMETHODIMP CSubtitleSource::GetCurFile(LPOLESTR* ppszFileName, AM_MEDIA_TYPE* if (!ppszFileName) {
return E_POINTER;
}
-
+
*ppszFileName = (LPOLESTR)CoTaskMemAlloc((m_fn.GetLength() + 1) * sizeof(WCHAR));
if (!*ppszFileName) {
return E_OUTOFMEMORY;
@@ -224,8 +224,8 @@ CSubtitleStream::CSubtitleStream(const WCHAR* wfn, CSubtitleSource* pParent, HRE CString fn(wfn);
- if(!m_rts.Open(fn, DEFAULT_CHARSET)) {
- if(phr) {
+ if (!m_rts.Open(fn, DEFAULT_CHARSET)) {
+ if (phr) {
*phr = E_FAIL;
}
return;
@@ -236,13 +236,13 @@ CSubtitleStream::CSubtitleStream(const WCHAR* wfn, CSubtitleSource* pParent, HRE m_rts.Sort();
m_rtDuration = 0;
- for(int i = 0, cnt = m_rts.GetCount(); i < cnt; i++) {
+ for (int i = 0, cnt = m_rts.GetCount(); i < cnt; i++) {
m_rtDuration = max(m_rtDuration, 10000i64*m_rts[i].end);
}
m_rtStop = m_rtDuration;
- if(phr) {
+ if (phr) {
*phr = m_rtDuration > 0 ? S_OK : E_FAIL;
}
}
@@ -262,7 +262,7 @@ STDMETHODIMP CSubtitleStream::NonDelegatingQueryInterface(REFIID riid, void** pp void CSubtitleStream::UpdateFromSeek()
{
- if(ThreadExists()) {
+ if (ThreadExists()) {
// next time around the loop, the worker thread will
// pick up the position change.
// We need to flush all the existing data - we must do that here
@@ -285,7 +285,7 @@ void CSubtitleStream::UpdateFromSeek() HRESULT CSubtitleStream::SetRate(double dRate)
{
- if(dRate <= 0) {
+ if (dRate <= 0) {
return E_INVALIDARG;
}
@@ -355,18 +355,18 @@ HRESULT CSubtitleStream::OnThreadCreate() {
CAutoLock cAutoLockShared(&m_cSharedState);
- if(m_mt.majortype == MEDIATYPE_Video && m_mt.subtype == MEDIASUBTYPE_ARGB32) {
+ if (m_mt.majortype == MEDIATYPE_Video && m_mt.subtype == MEDIASUBTYPE_ARGB32) {
m_nPosition = m_rtStart/_ATPF;
- } else if(m_mt.majortype == MEDIATYPE_Video && m_mt.subtype == MEDIASUBTYPE_RGB32) {
+ } else if (m_mt.majortype == MEDIATYPE_Video && m_mt.subtype == MEDIASUBTYPE_RGB32) {
int m_nSegments = 0;
- if(!m_rts.SearchSubs((int)(m_rtStart/10000), 10000000/_ATPF, &m_nPosition, &m_nSegments)) {
+ if (!m_rts.SearchSubs((int)(m_rtStart/10000), 10000000/_ATPF, &m_nPosition, &m_nSegments)) {
m_nPosition = m_nSegments;
}
} else {
m_nPosition = m_rts.SearchSub((int)(m_rtStart/10000), 25);
- if(m_nPosition < 0) {
+ if (m_nPosition < 0) {
m_nPosition = 0;
- } else if(m_rts[m_nPosition].end <= (int)(m_rtStart/10000)) {
+ } else if (m_rts[m_nPosition].end <= (int)(m_rtStart/10000)) {
m_nPosition++;
}
}
@@ -383,7 +383,7 @@ HRESULT CSubtitleStream::DecideBufferSize(IMemAllocator* pAlloc, ALLOCATOR_PROPE HRESULT hr = NOERROR;
- if(m_mt.majortype == MEDIATYPE_Video) {
+ if (m_mt.majortype == MEDIATYPE_Video) {
pProperties->cBuffers = 2;
pProperties->cbBuffer = ((VIDEOINFOHEADER*)m_mt.pbFormat)->bmiHeader.biSizeImage;
} else {
@@ -392,11 +392,11 @@ HRESULT CSubtitleStream::DecideBufferSize(IMemAllocator* pAlloc, ALLOCATOR_PROPE }
ALLOCATOR_PROPERTIES Actual;
- if(FAILED(hr = pAlloc->SetProperties(pProperties, &Actual))) {
+ if (FAILED(hr = pAlloc->SetProperties(pProperties, &Actual))) {
return hr;
}
- if(Actual.cbBuffer < pProperties->cbBuffer) {
+ if (Actual.cbBuffer < pProperties->cbBuffer) {
return E_FAIL;
}
ASSERT(Actual.cBuffers == pProperties->cBuffers);
@@ -412,12 +412,12 @@ HRESULT CSubtitleStream::FillBuffer(IMediaSample* pSample) CAutoLock cAutoLockShared(&m_cSharedState);
BYTE* pData = NULL;
- if(FAILED(hr = pSample->GetPointer(&pData)) || !pData) {
+ if (FAILED(hr = pSample->GetPointer(&pData)) || !pData) {
return S_FALSE;
}
AM_MEDIA_TYPE* pmt;
- if(SUCCEEDED(pSample->GetMediaType(&pmt)) && pmt) {
+ if (SUCCEEDED(pSample->GetMediaType(&pmt)) && pmt) {
CMediaType mt(*pmt);
SetMediaType(&mt);
DeleteMediaType(pmt);
@@ -426,10 +426,10 @@ HRESULT CSubtitleStream::FillBuffer(IMediaSample* pSample) int len = 0;
REFERENCE_TIME rtStart, rtStop;
- if(m_mt.majortype == MEDIATYPE_Video && m_mt.subtype == MEDIASUBTYPE_ARGB32) {
+ if (m_mt.majortype == MEDIATYPE_Video && m_mt.subtype == MEDIASUBTYPE_ARGB32) {
rtStart = (REFERENCE_TIME)((m_nPosition*_ATPF - m_rtStart) / m_dRateSeeking);
rtStop = (REFERENCE_TIME)(((m_nPosition+1)*_ATPF - m_rtStart) / m_dRateSeeking);
- if(m_rtStart+rtStart >= m_rtDuration) {
+ if (m_rtStart+rtStart >= m_rtDuration) {
return S_FALSE;
}
@@ -444,22 +444,22 @@ HRESULT CSubtitleStream::FillBuffer(IMediaSample* pSample) len = spd.h*spd.pitch;
- for(int y = 0; y < spd.h; y++) {
+ for (int y = 0; y < spd.h; y++) {
memsetd((DWORD*)(pData + spd.pitch*y), 0xff000000, spd.w*4);
}
RECT bbox;
m_rts.Render(spd, m_nPosition*_ATPF, 10000000.0/_ATPF, bbox);
- for(int y = 0; y < spd.h; y++) {
+ for (int y = 0; y < spd.h; y++) {
DWORD* p = (DWORD*)(pData + spd.pitch*y);
- for(int x = 0; x < spd.w; x++, p++) {
+ for (int x = 0; x < spd.w; x++, p++) {
*p = (0xff000000-(*p&0xff000000))|(*p&0xffffff);
}
}
- } else if(m_mt.majortype == MEDIATYPE_Video && m_mt.subtype == MEDIASUBTYPE_RGB32) {
+ } else if (m_mt.majortype == MEDIATYPE_Video && m_mt.subtype == MEDIASUBTYPE_RGB32) {
const STSSegment* stss = m_rts.GetSegment(m_nPosition);
- if(!stss) {
+ if (!stss) {
return S_FALSE;
}
@@ -474,13 +474,13 @@ HRESULT CSubtitleStream::FillBuffer(IMediaSample* pSample) len = spd.h*spd.pitch;
- for(int y = 0; y < spd.h; y++) {
+ for (int y = 0; y < spd.h; y++) {
DWORD c1 = 0xff606060, c2 = 0xffa0a0a0;
- if(y&32) {
+ if (y&32) {
c1 ^= c2, c2 ^= c1, c1 ^= c2;
}
DWORD* p = (DWORD*)(pData + spd.pitch*y);
- for(int x = 0; x < spd.w; x+=32, p+=32) {
+ for (int x = 0; x < spd.w; x+=32, p+=32) {
memsetd(p, (x&32) ? c1 : c2, min(spd.w-x,32)*4);
}
}
@@ -491,20 +491,20 @@ HRESULT CSubtitleStream::FillBuffer(IMediaSample* pSample) rtStart = (REFERENCE_TIME)((10000i64*stss->start - m_rtStart) / m_dRateSeeking);
rtStop = (REFERENCE_TIME)((10000i64*stss->end - m_rtStart) / m_dRateSeeking);
} else {
- if(m_nPosition >= m_rts.GetCount()) {
+ if (m_nPosition >= m_rts.GetCount()) {
return S_FALSE;
}
STSEntry& stse = m_rts[m_nPosition];
- if(stse.start >= m_rtStop/10000) {
+ if (stse.start >= m_rtStop/10000) {
return S_FALSE;
}
- if(m_mt.majortype == MEDIATYPE_Subtitle && m_mt.subtype == MEDIASUBTYPE_UTF8) {
+ if (m_mt.majortype == MEDIATYPE_Subtitle && m_mt.subtype == MEDIASUBTYPE_UTF8) {
CStringA str = UTF16To8(m_rts.GetStrW(m_nPosition, false));
memcpy((char*)pData, str, len = str.GetLength());
- } else if(m_mt.majortype == MEDIATYPE_Subtitle && (m_mt.subtype == MEDIASUBTYPE_SSA || m_mt.subtype == MEDIASUBTYPE_ASS)) {
+ } else if (m_mt.majortype == MEDIATYPE_Subtitle && (m_mt.subtype == MEDIASUBTYPE_SSA || m_mt.subtype == MEDIASUBTYPE_ASS)) {
CStringW line;
line.Format(L"%d,%d,%s,%s,%d,%d,%d,%s,%s",
stse.readorder, stse.layer, CStringW(stse.style), CStringW(stse.actor),
@@ -513,7 +513,7 @@ HRESULT CSubtitleStream::FillBuffer(IMediaSample* pSample) CStringA str = UTF16To8(line);
memcpy((char*)pData, str, len = str.GetLength());
- } else if(m_mt.majortype == MEDIATYPE_Text && m_mt.subtype == MEDIASUBTYPE_NULL) {
+ } else if (m_mt.majortype == MEDIATYPE_Text && m_mt.subtype == MEDIASUBTYPE_NULL) {
CStringA str = m_rts.GetStrA(m_nPosition, false);
memcpy((char*)pData, str, len = str.GetLength());
} else {
@@ -532,7 +532,7 @@ HRESULT CSubtitleStream::FillBuffer(IMediaSample* pSample) pSample->SetSyncPoint(TRUE);
- if(m_bDiscontinuity) {
+ if (m_bDiscontinuity) {
pSample->SetDiscontinuity(TRUE);
m_bDiscontinuity = FALSE;
}
@@ -552,7 +552,7 @@ HRESULT CSubtitleStream::CheckMediaType(const CMediaType* pmt) CMediaType mt;
GetMediaType(&mt);
- if(mt.majortype == pmt->majortype && mt.subtype == pmt->subtype) {
+ if (mt.majortype == pmt->majortype && mt.subtype == pmt->subtype) {
return NOERROR;
}
@@ -634,7 +634,7 @@ HRESULT CSubtitleSourceSSA::GetMediaType(CMediaType* pmt) CFile f;
TCHAR path[_MAX_PATH], fn[_MAX_PATH];
- if(!GetTempPath(MAX_PATH, path) || !GetTempFileName(path, _T("mpc_sts"), 0, fn)) {
+ if (!GetTempPath(MAX_PATH, path) || !GetTempFileName(path, _T("mpc_sts"), 0, fn)) {
return E_FAIL;
}
@@ -642,7 +642,7 @@ HRESULT CSubtitleSourceSSA::GetMediaType(CMediaType* pmt) _tcscat(fn, _T(".ssa"));
- if(!sts.SaveAs(fn, EXTSSA, -1, CTextFile::UTF8) || !f.Open(fn, CFile::modeRead)) {
+ if (!sts.SaveAs(fn, EXTSSA, -1, CTextFile::UTF8) || !f.Open(fn, CFile::modeRead)) {
return E_FAIL;
}
@@ -685,7 +685,7 @@ HRESULT CSubtitleSourceASS::GetMediaType(CMediaType* pmt) CFile f;
TCHAR path[_MAX_PATH], fn[_MAX_PATH];
- if(!GetTempPath(MAX_PATH, path) || !GetTempFileName(path, _T("mpc_sts"), 0, fn)) {
+ if (!GetTempPath(MAX_PATH, path) || !GetTempFileName(path, _T("mpc_sts"), 0, fn)) {
return E_FAIL;
}
@@ -693,7 +693,7 @@ HRESULT CSubtitleSourceASS::GetMediaType(CMediaType* pmt) _tcscat(fn, _T(".ass"));
- if(!sts.SaveAs(fn, EXTASS, -1, CTextFile::UTF8) || !f.Open(fn, CFile::modeRead)) {
+ if (!sts.SaveAs(fn, EXTASS, -1, CTextFile::UTF8) || !f.Open(fn, CFile::modeRead)) {
return E_FAIL;
}
diff --git a/src/filters/switcher/AudioSwitcher/Audio.cpp b/src/filters/switcher/AudioSwitcher/Audio.cpp index 8f5a905ef..e6c872e28 100644 --- a/src/filters/switcher/AudioSwitcher/Audio.cpp +++ b/src/filters/switcher/AudioSwitcher/Audio.cpp @@ -32,7 +32,7 @@ static long audio_pointsample_8(void *dst, void *src, long accum, long samp_frac do {
*d++ = s[accum>>19];
accum += samp_frac;
- } while(--cnt);
+ } while (--cnt);
return accum;
}
@@ -45,7 +45,7 @@ static long audio_pointsample_16(void *dst, void *src, long accum, long samp_fra do {
*d++ = s[accum>>19];
accum += samp_frac;
- } while(--cnt);
+ } while (--cnt);
return accum;
}
@@ -58,7 +58,7 @@ static long audio_pointsample_32(void *dst, void *src, long accum, long samp_fra do {
*d++ = s[accum>>19];
accum += samp_frac;
- } while(--cnt);
+ } while (--cnt);
return accum;
}
@@ -79,7 +79,7 @@ static long audio_downsample_mono8(void *dst, void *src, long *filter_bank, int s_ptr = s + (accum>>19);
do {
sum += *fb_ptr++ * (int)*s_ptr++;
- } while(--w);
+ } while (--w);
if (sum < 0) {
*d++ = 0;
@@ -90,7 +90,7 @@ static long audio_downsample_mono8(void *dst, void *src, long *filter_bank, int }
accum += samp_frac;
- } while(--cnt);
+ } while (--cnt);
return accum;
}
@@ -111,7 +111,7 @@ static long audio_downsample_mono16(void *dst, void *src, long *filter_bank, int s_ptr = s + (accum>>19);
do {
sum += *fb_ptr++ * (int)*s_ptr++;
- } while(--w);
+ } while (--w);
if (sum < -0x20000000) {
*d++ = -0x8000;
@@ -122,7 +122,7 @@ static long audio_downsample_mono16(void *dst, void *src, long *filter_bank, int }
accum += samp_frac;
- } while(--cnt);
+ } while (--cnt);
return accum;
}
@@ -144,7 +144,7 @@ static void make_downsample_filter(long *filter_bank, int filter_width, long sam filt_max = (16384.0 * 524288.0) / samp_frac;
- for(i=0; i<128*filter_width; i++) {
+ for (i=0; i<128*filter_width; i++) {
int y = 0;
double d = i / filtwidth_frac;
@@ -153,22 +153,22 @@ static void make_downsample_filter(long *filter_bank, int filter_width, long sam }
filter_bank[permute_index(128*filter_width + i, filter_width)]
- = filter_bank[permute_index(128*filter_width - i, filter_width)]
- = y;
+ = filter_bank[permute_index(128*filter_width - i, filter_width)]
+ = y;
}
// Normalize the filter to correct for integer roundoff errors
- for(i=0; i<256*filter_width; i+=filter_width) {
+ for (i=0; i<256*filter_width; i+=filter_width) {
v=0;
- for(j=0; j<filter_width; j++) {
+ for (j=0; j<filter_width; j++) {
v += filter_bank[i+j];
}
// _RPT2(0,"error[%02x] = %04x\n", i/filter_width, 0x4000 - v);
v = (0x4000 - v)/filter_width;
- for(j=0; j<filter_width; j++) {
+ for (j=0; j<filter_width; j++) {
filter_bank[i+j] += v;
}
}
@@ -182,10 +182,10 @@ AudioStreamResampler::AudioStreamResampler(int bps, long org_rate, long new_rate this->bps = bps;
- if(bps == 1) {
+ if (bps == 1) {
ptsampleRout = audio_pointsample_8;
dnsampleRout = audio_downsample_mono8;
- } else if(bps >= 2) {
+ } else if (bps >= 2) {
ptsampleRout = audio_pointsample_16;
dnsampleRout = audio_downsample_mono16;
} else {
@@ -202,14 +202,14 @@ AudioStreamResampler::AudioStreamResampler(int bps, long org_rate, long new_rate // If this is a high-quality downsample, allocate memory for the filter bank
- if(fHighQuality) {
- if(samp_frac>0x80000) {
+ if (fHighQuality) {
+ if (samp_frac>0x80000) {
// HQ downsample: allocate filter bank
filter_width = ((samp_frac + 0x7ffff)>>19)<<1 <<1;
filter_bank = DNew long[filter_width * 256];
- if(!filter_bank) {
+ if (!filter_bank) {
filter_width = 1;
return;
}
@@ -239,7 +239,7 @@ long AudioStreamResampler::Downsample(void* input, long samplesin, void* output, //
// We need (n/2) points to the left and (n/2-1) points to the right.
- while(samplesin > 0 && samplesout > 0) {
+ while (samplesin > 0 && samplesout > 0) {
long srcSamples, dstSamples;
int nhold;
@@ -253,14 +253,14 @@ long AudioStreamResampler::Downsample(void* input, long samplesin, void* output, // Don't exceed the buffer (BUFFER_SIZE - holdover).
- if(srcSamples > BUFFER_SIZE - holdover) {
+ if (srcSamples > BUFFER_SIZE - holdover) {
srcSamples = BUFFER_SIZE - holdover;
}
// Read into buffer.
srcSamples = min(srcSamples, samplesin);
- if(!srcSamples) {
+ if (!srcSamples) {
break;
}
@@ -274,12 +274,12 @@ long AudioStreamResampler::Downsample(void* input, long samplesin, void* output, dstSamples = (((__int64)(srcSamples+holdover-filter_width)<<19) + 0x7ffff - accum) / samp_frac + 1;
- if(dstSamples > samplesout) {
+ if (dstSamples > samplesout) {
dstSamples = samplesout;
}
- if(dstSamples >= 1) {
- if(filter_bank) {
+ if (dstSamples >= 1) {
+ if (filter_bank) {
accum = dnsampleRout(output, cbuffer, filter_bank, filter_width, accum, samp_frac, dstSamples);
} else {
accum = ptsampleRout(output, cbuffer, accum, samp_frac, dstSamples);
diff --git a/src/filters/switcher/AudioSwitcher/AudioSwitcher.cpp b/src/filters/switcher/AudioSwitcher/AudioSwitcher.cpp index 48c3c6338..699706379 100644 --- a/src/filters/switcher/AudioSwitcher/AudioSwitcher.cpp +++ b/src/filters/switcher/AudioSwitcher/AudioSwitcher.cpp @@ -94,8 +94,8 @@ CAudioSwitcherFilter::CAudioSwitcherFilter(LPUNKNOWN lpunk, HRESULT* phr) {
memset(m_pSpeakerToChannelMap, 0, sizeof(m_pSpeakerToChannelMap));
- if(phr) {
- if(FAILED(*phr)) {
+ if (phr) {
+ if (FAILED(*phr)) {
return;
} else {
*phr = S_OK;
@@ -112,7 +112,7 @@ STDMETHODIMP CAudioSwitcherFilter::NonDelegatingQueryInterface(REFIID riid, void HRESULT CAudioSwitcherFilter::CheckMediaType(const CMediaType* pmt)
{
- if(pmt->formattype == FORMAT_WaveFormatEx
+ if (pmt->formattype == FORMAT_WaveFormatEx
&& ((WAVEFORMATEX*)pmt->pbFormat)->nChannels > 2
&& ((WAVEFORMATEX*)pmt->pbFormat)->wFormatTag != WAVE_FORMAT_EXTENSIBLE) {
return VFW_E_INVALIDMEDIATYPE; // stupid iviaudio tries to fool us
@@ -137,15 +137,15 @@ __forceinline void mix(DWORD mask, int ch, int bps, BYTE* src, BYTE* dst) {
U sum = 0;
- for(int i = 0, j = ch; i < j; i++) {
- if(mask & (1<<i)) {
+ for (int i = 0, j = ch; i < j; i++) {
+ if (mask & (1<<i)) {
sum += *(T*)&src[bps*i];
}
}
- if(sum < Umin) {
+ if (sum < Umin) {
sum = Umin;
- } else if(sum > Umax) {
+ } else if (sum > Umax) {
sum = Umax;
}
@@ -157,8 +157,8 @@ __forceinline void mix<int, INT64, (-1<<24), (+1<<24)-1>(DWORD mask, int ch, int {
INT64 sum = 0;
- for(int i = 0, j = ch; i < j; i++) {
- if(mask & (1<<i)) {
+ for (int i = 0, j = ch; i < j; i++) {
+ if (mask & (1<<i)) {
int tmp;
memcpy((BYTE*)&tmp+1, &src[bps*i], 3);
sum += tmp >> 8;
@@ -176,22 +176,22 @@ __forceinline void mix4(DWORD mask, BYTE* src, BYTE* dst) U sum = 0;
int bps = sizeof T;
- if(mask & (1<<0)) {
+ if (mask & (1<<0)) {
sum += *(T*)&src[bps*0];
}
- if(mask & (1<<1)) {
+ if (mask & (1<<1)) {
sum += *(T*)&src[bps*1];
}
- if(mask & (1<<2)) {
+ if (mask & (1<<2)) {
sum += *(T*)&src[bps*2];
}
- if(mask & (1<<3)) {
+ if (mask & (1<<3)) {
sum += *(T*)&src[bps*3];
}
- if(sum < Umin) {
+ if (sum < Umin) {
sum = Umin;
- } else if(sum > Umax) {
+ } else if (sum > Umax) {
sum = Umax;
}
@@ -201,15 +201,15 @@ __forceinline void mix4(DWORD mask, BYTE* src, BYTE* dst) template<class T>
T clamp(double s, T smin, T smax)
{
- if(s < -1) {
+ if (s < -1) {
s = -1;
- } else if(s > 1) {
+ } else if (s > 1) {
s = 1;
}
T t = (T)(s * smax);
- if(t < smin) {
+ if (t < smin) {
t = smin;
- } else if(t > smax) {
+ } else if (t > smax) {
t = smax;
}
return t;
@@ -219,7 +219,7 @@ HRESULT CAudioSwitcherFilter::Transform(IMediaSample* pIn, IMediaSample* pOut) {
CStreamSwitcherInputPin* pInPin = GetInputPin();
CStreamSwitcherOutputPin* pOutPin = GetOutputPin();
- if(!pInPin || !pOutPin) {
+ if (!pInPin || !pOutPin) {
return __super::Transform(pIn, pOut);
}
@@ -233,7 +233,7 @@ HRESULT CAudioSwitcherFilter::Transform(IMediaSample* pIn, IMediaSample* pOut) int lenout = (UINT64)len * wfeout->nSamplesPerSec / wfe->nSamplesPerSec;
REFERENCE_TIME rtStart, rtStop;
- if(SUCCEEDED(pIn->GetTime(&rtStart, &rtStop))) {
+ if (SUCCEEDED(pIn->GetTime(&rtStart, &rtStop))) {
rtStart += m_rtAudioTimeShift;
rtStop += m_rtAudioTimeShift;
pOut->SetTime(&rtStart, &rtStop);
@@ -249,14 +249,14 @@ HRESULT CAudioSwitcherFilter::Transform(IMediaSample* pIn, IMediaSample* pOut) m_rtNextStart += rtDur;
m_rtNextStop += rtDur;
- if(pIn->IsDiscontinuity() == S_OK) {
+ if (pIn->IsDiscontinuity() == S_OK) {
m_sample_max = 0.1f;
}
WORD tag = wfe->wFormatTag;
bool fPCM = tag == WAVE_FORMAT_PCM || tag == WAVE_FORMAT_EXTENSIBLE && wfex->SubFormat == KSDATAFORMAT_SUBTYPE_PCM;
bool fFloat = tag == WAVE_FORMAT_IEEE_FLOAT || tag == WAVE_FORMAT_EXTENSIBLE && wfex->SubFormat == KSDATAFORMAT_SUBTYPE_IEEE_FLOAT;
- if(!fPCM && !fFloat) {
+ if (!fPCM && !fFloat) {
return __super::Transform(pIn, pOut);
}
@@ -264,26 +264,26 @@ HRESULT CAudioSwitcherFilter::Transform(IMediaSample* pIn, IMediaSample* pOut) BYTE* pDataOut = NULL;
HRESULT hr;
- if(FAILED(hr = pIn->GetPointer(&pDataIn))) {
+ if (FAILED(hr = pIn->GetPointer(&pDataIn))) {
return hr;
}
- if(FAILED(hr = pOut->GetPointer(&pDataOut))) {
+ if (FAILED(hr = pOut->GetPointer(&pDataOut))) {
return hr;
}
- if(!pDataIn || !pDataOut || len < 0 || lenout < 0) {
+ if (!pDataIn || !pDataOut || len < 0 || lenout < 0) {
return S_FALSE;
}
// len = 0 doesn't mean it's failed, return S_OK otherwise might screw the sound
- if(len == 0) {
+ if (len == 0) {
pOut->SetActualDataLength(0);
return S_OK;
}
- if(m_fCustomChannelMapping) {
+ if (m_fCustomChannelMapping) {
size_t channelsCount = m_chs[wfe->nChannels-1].GetCount();
- if(channelsCount > 0 && wfeout->nChannels <= channelsCount) {
- for(int i = 0; i < wfeout->nChannels; i++) {
+ if (channelsCount > 0 && wfeout->nChannels <= channelsCount) {
+ for (int i = 0; i < wfeout->nChannels; i++) {
DWORD mask = m_chs[wfe->nChannels-1][i].Channel;
BYTE* src = pDataIn;
@@ -292,34 +292,34 @@ HRESULT CAudioSwitcherFilter::Transform(IMediaSample* pIn, IMediaSample* pOut) int srcstep = bps*wfe->nChannels;
int dststep = bps*wfeout->nChannels;
int channels = min(18, wfe->nChannels);
- if(fPCM && wfe->wBitsPerSample == 8) {
- for(int k = 0; k < len; k++, src += srcstep, dst += dststep) {
+ if (fPCM && wfe->wBitsPerSample == 8) {
+ for (int k = 0; k < len; k++, src += srcstep, dst += dststep) {
mix<unsigned char, INT64, 0, UCHAR_MAX>(mask, channels, bps, src, dst);
}
- } else if(fPCM && wfe->wBitsPerSample == 16) {
+ } else if (fPCM && wfe->wBitsPerSample == 16) {
if (wfe->nChannels != 4 || wfeout->nChannels != 4) {
- for(int k = 0; k < len; k++, src += srcstep, dst += dststep) {
+ for (int k = 0; k < len; k++, src += srcstep, dst += dststep) {
mix<short, INT64, SHRT_MIN, SHRT_MAX>(mask, channels, bps, src, dst);
}
} else { // most popular channels count
- for(int k = 0; k < len; k++, src += srcstep, dst += dststep) {
+ for (int k = 0; k < len; k++, src += srcstep, dst += dststep) {
mix4<short, INT64, SHRT_MIN, SHRT_MAX>(mask, src, dst);
}
}
- } else if(fPCM && wfe->wBitsPerSample == 24) {
- for(int k = 0; k < len; k++, src += srcstep, dst += dststep) {
+ } else if (fPCM && wfe->wBitsPerSample == 24) {
+ for (int k = 0; k < len; k++, src += srcstep, dst += dststep) {
mix<int, INT64, (-1<<24), (+1<<24)-1>(mask, channels, bps, src, dst);
}
- } else if(fPCM && wfe->wBitsPerSample == 32) {
- for(int k = 0; k < len; k++, src += srcstep, dst += dststep) {
+ } else if (fPCM && wfe->wBitsPerSample == 32) {
+ for (int k = 0; k < len; k++, src += srcstep, dst += dststep) {
mix<int, __int64, INT_MIN, INT_MAX>(mask, channels, bps, src, dst);
}
- } else if(fFloat && wfe->wBitsPerSample == 32) {
- for(int k = 0; k < len; k++, src += srcstep, dst += dststep) {
+ } else if (fFloat && wfe->wBitsPerSample == 32) {
+ for (int k = 0; k < len; k++, src += srcstep, dst += dststep) {
mix<float, double, -1, 1>(mask, channels, bps, src, dst);
}
- } else if(fFloat && wfe->wBitsPerSample == 64) {
- for(int k = 0; k < len; k++, src += srcstep, dst += dststep) {
+ } else if (fFloat && wfe->wBitsPerSample == 64) {
+ for (int k = 0; k < len; k++, src += srcstep, dst += dststep) {
mix<double, double, -1, 1>(mask, channels, bps, src, dst);
}
}
@@ -327,32 +327,32 @@ HRESULT CAudioSwitcherFilter::Transform(IMediaSample* pIn, IMediaSample* pOut) } else {
BYTE* pDataOut = NULL;
HRESULT hr;
- if(FAILED(hr = pOut->GetPointer(&pDataOut)) || !pDataOut) {
+ if (FAILED(hr = pOut->GetPointer(&pDataOut)) || !pDataOut) {
return hr;
}
memset(pDataOut, 0, pOut->GetSize());
}
} else {
HRESULT hr;
- if(S_OK != (hr = __super::Transform(pIn, pOut))) {
+ if (S_OK != (hr = __super::Transform(pIn, pOut))) {
return hr;
}
}
- if(m_fDownSampleTo441
+ if (m_fDownSampleTo441
&& wfe->nSamplesPerSec > 44100 && wfeout->nSamplesPerSec == 44100
&& wfe->wBitsPerSample <= 16 && fPCM) {
- if(BYTE* buff = DNew BYTE[len*bps]) {
- for(int ch = 0; ch < wfeout->nChannels; ch++) {
+ if (BYTE* buff = DNew BYTE[len*bps]) {
+ for (int ch = 0; ch < wfeout->nChannels; ch++) {
memset(buff, 0, len*bps);
- for(int i = 0; i < len; i++) {
+ for (int i = 0; i < len; i++) {
memcpy(buff + i*bps, (char*)pDataOut + (ch + i*wfeout->nChannels)*bps, bps);
}
m_pResamplers[ch]->Downsample(buff, len, buff, lenout);
- for(int i = 0; i < lenout; i++) {
+ for (int i = 0; i < lenout; i++) {
memcpy((char*)pDataOut + (ch + i*wfeout->nChannels)*bps, buff + i*bps, bps);
}
}
@@ -361,73 +361,73 @@ HRESULT CAudioSwitcherFilter::Transform(IMediaSample* pIn, IMediaSample* pOut) }
}
- if(m_fNormalize || m_boost_mul > 1) {
+ if (m_fNormalize || m_boost_mul > 1) {
int samples = lenout*wfeout->nChannels;
- if(double* buff = DNew double[samples]) {
- for(int i = 0; i < samples; i++) {
- if(fPCM && wfe->wBitsPerSample == 8) {
+ if (double* buff = DNew double[samples]) {
+ for (int i = 0; i < samples; i++) {
+ if (fPCM && wfe->wBitsPerSample == 8) {
buff[i] = (double)((BYTE*)pDataOut)[i] / UCHAR_MAX;
- } else if(fPCM && wfe->wBitsPerSample == 16) {
+ } else if (fPCM && wfe->wBitsPerSample == 16) {
buff[i] = (double)((short*)pDataOut)[i] / SHRT_MAX;
- } else if(fPCM && wfe->wBitsPerSample == 24) {
+ } else if (fPCM && wfe->wBitsPerSample == 24) {
int tmp;
memcpy(((BYTE*)&tmp)+1, &pDataOut[i*3], 3);
buff[i] = (float)(tmp >> 8) / ((1<<23)-1);
- } else if(fPCM && wfe->wBitsPerSample == 32) {
+ } else if (fPCM && wfe->wBitsPerSample == 32) {
buff[i] = (double)((int*)pDataOut)[i] / INT_MAX;
- } else if(fFloat && wfe->wBitsPerSample == 32) {
+ } else if (fFloat && wfe->wBitsPerSample == 32) {
buff[i] = (double)((float*)pDataOut)[i];
- } else if(fFloat && wfe->wBitsPerSample == 64) {
+ } else if (fFloat && wfe->wBitsPerSample == 64) {
buff[i] = ((double*)pDataOut)[i];
}
}
double sample_mul = 1;
- if(m_fNormalize) {
- for(int i = 0; i < samples; i++) {
+ if (m_fNormalize) {
+ for (int i = 0; i < samples; i++) {
double s = buff[i];
- if(s < 0) {
+ if (s < 0) {
s = -s;
}
- if(s > 1) {
+ if (s > 1) {
s = 1;
}
- if(m_sample_max < s) {
+ if (m_sample_max < s) {
m_sample_max = s;
}
}
sample_mul = 1.0f / m_sample_max;
- if(m_fNormalizeRecover) {
+ if (m_fNormalizeRecover) {
m_sample_max -= 1.0*rtDur/200000000; // -5%/sec
}
- if(m_sample_max < 0.1) {
+ if (m_sample_max < 0.1) {
m_sample_max = 0.1;
}
}
- if(m_boost_mul > 1) {
+ if (m_boost_mul > 1) {
sample_mul *= m_boost_mul;
}
- for(int i = 0; i < samples; i++) {
+ for (int i = 0; i < samples; i++) {
double s = buff[i] * sample_mul;
- if(fPCM && wfe->wBitsPerSample == 8) {
+ if (fPCM && wfe->wBitsPerSample == 8) {
((BYTE*)pDataOut)[i] = clamp<BYTE>(s, 0, UCHAR_MAX);
- } else if(fPCM && wfe->wBitsPerSample == 16) {
+ } else if (fPCM && wfe->wBitsPerSample == 16) {
((short*)pDataOut)[i] = clamp<short>(s, SHRT_MIN, SHRT_MAX);
- } else if(fPCM && wfe->wBitsPerSample == 24) {
+ } else if (fPCM && wfe->wBitsPerSample == 24) {
int tmp = clamp<int>(s, -1<<23, (1<<23)-1);
memcpy(&pDataOut[i*3], &tmp, 3);
- } else if(fPCM && wfe->wBitsPerSample == 32) {
+ } else if (fPCM && wfe->wBitsPerSample == 32) {
((int*)pDataOut)[i] = clamp<int>(s, INT_MIN, INT_MAX);
- } else if(fFloat && wfe->wBitsPerSample == 32) {
+ } else if (fFloat && wfe->wBitsPerSample == 32) {
((float*)pDataOut)[i] = clamp<float>(s, -1, +1);
- } else if(fFloat && wfe->wBitsPerSample == 64) {
+ } else if (fFloat && wfe->wBitsPerSample == 64) {
((double*)pDataOut)[i] = clamp<double>(s, -1, +1);
}
}
@@ -445,24 +445,24 @@ CMediaType CAudioSwitcherFilter::CreateNewOutputMediaType(CMediaType mt, long& c {
CStreamSwitcherInputPin* pInPin = GetInputPin();
CStreamSwitcherOutputPin* pOutPin = GetOutputPin();
- if(!pInPin || !pOutPin || ((WAVEFORMATEX*)mt.pbFormat)->wFormatTag == WAVE_FORMAT_DOLBY_AC3_SPDIF) {
+ if (!pInPin || !pOutPin || ((WAVEFORMATEX*)mt.pbFormat)->wFormatTag == WAVE_FORMAT_DOLBY_AC3_SPDIF) {
return __super::CreateNewOutputMediaType(mt, cbBuffer);
}
WAVEFORMATEX* wfe = (WAVEFORMATEX*)pInPin->CurrentMediaType().pbFormat;
- if(m_fCustomChannelMapping) {
+ if (m_fCustomChannelMapping) {
m_chs[wfe->nChannels-1].RemoveAll();
DWORD mask = DWORD((__int64(1)<<wfe->nChannels)-1);
- for(int i = 0; i < 18; i++) {
- if(m_pSpeakerToChannelMap[wfe->nChannels-1][i]&mask) {
+ for (int i = 0; i < 18; i++) {
+ if (m_pSpeakerToChannelMap[wfe->nChannels-1][i]&mask) {
ChMap cm = {1<<i, m_pSpeakerToChannelMap[wfe->nChannels-1][i]};
m_chs[wfe->nChannels-1].Add(cm);
}
}
- if(m_chs[wfe->nChannels-1].GetCount() > 0) {
+ if (m_chs[wfe->nChannels-1].GetCount() > 0) {
mt.ReallocFormatBuffer(sizeof(WAVEFORMATEXTENSIBLE));
WAVEFORMATEXTENSIBLE* wfex = (WAVEFORMATEXTENSIBLE*)mt.pbFormat;
wfex->Format.cbSize = sizeof(WAVEFORMATEXTENSIBLE)-sizeof(WAVEFORMATEX);
@@ -475,7 +475,7 @@ CMediaType CAudioSwitcherFilter::CreateNewOutputMediaType(CMediaType mt, long& c KSDATAFORMAT_SUBTYPE_PCM; // can't happen
wfex->dwChannelMask = 0;
- for(size_t i = 0; i < m_chs[wfe->nChannels-1].GetCount(); i++) {
+ for (size_t i = 0; i < m_chs[wfe->nChannels-1].GetCount(); i++) {
wfex->dwChannelMask |= m_chs[wfe->nChannels-1][i].Speaker;
}
@@ -487,8 +487,8 @@ CMediaType CAudioSwitcherFilter::CreateNewOutputMediaType(CMediaType mt, long& c WAVEFORMATEX* wfeout = (WAVEFORMATEX*)mt.pbFormat;
- if(m_fDownSampleTo441) {
- if(wfeout->nSamplesPerSec > 44100 && wfeout->wBitsPerSample <= 16) {
+ if (m_fDownSampleTo441) {
+ if (wfeout->nSamplesPerSec > 44100 && wfeout->wBitsPerSample <= 16) {
wfeout->nSamplesPerSec = 44100;
wfeout->nAvgBytesPerSec = wfeout->nBlockAlign*wfeout->nSamplesPerSec;
}
@@ -511,7 +511,7 @@ void CAudioSwitcherFilter::OnNewOutputMediaType(const CMediaType& mtIn, const CM const WAVEFORMATEX* wfeout = (WAVEFORMATEX*)mtOut.pbFormat;
m_pResamplers.RemoveAll();
- for(int i = 0; i < wfeout->nChannels; i++) {
+ for (int i = 0; i < wfeout->nChannels; i++) {
CAutoPtr<AudioStreamResampler> pResampler;
pResampler.Attach(DNew AudioStreamResampler(wfeout->wBitsPerSample>>3, wfe->nSamplesPerSec, wfeout->nSamplesPerSec, true));
m_pResamplers.Add(pResampler);
@@ -539,20 +539,20 @@ HRESULT CAudioSwitcherFilter::DeliverNewSegment(REFERENCE_TIME tStart, REFERENCE STDMETHODIMP CAudioSwitcherFilter::GetInputSpeakerConfig(DWORD* pdwChannelMask)
{
- if(!pdwChannelMask) {
+ if (!pdwChannelMask) {
return E_POINTER;
}
*pdwChannelMask = 0;
CStreamSwitcherInputPin* pInPin = GetInputPin();
- if(!pInPin || !pInPin->IsConnected()) {
+ if (!pInPin || !pInPin->IsConnected()) {
return E_UNEXPECTED;
}
WAVEFORMATEX* wfe = (WAVEFORMATEX*)pInPin->CurrentMediaType().pbFormat;
- if(wfe->wFormatTag == WAVE_FORMAT_EXTENSIBLE) {
+ if (wfe->wFormatTag == WAVE_FORMAT_EXTENSIBLE) {
WAVEFORMATEXTENSIBLE* wfex = (WAVEFORMATEXTENSIBLE*)wfe;
*pdwChannelMask = wfex->dwChannelMask;
} else {
@@ -564,7 +564,7 @@ STDMETHODIMP CAudioSwitcherFilter::GetInputSpeakerConfig(DWORD* pdwChannelMask) STDMETHODIMP CAudioSwitcherFilter::GetSpeakerConfig(bool* pfCustomChannelMapping, DWORD pSpeakerToChannelMap[18][18])
{
- if(pfCustomChannelMapping) {
+ if (pfCustomChannelMapping) {
*pfCustomChannelMapping = m_fCustomChannelMapping;
}
memcpy(pSpeakerToChannelMap, m_pSpeakerToChannelMap, sizeof(m_pSpeakerToChannelMap));
@@ -574,7 +574,7 @@ STDMETHODIMP CAudioSwitcherFilter::GetSpeakerConfig(bool* pfCustomChannelMapping STDMETHODIMP CAudioSwitcherFilter::SetSpeakerConfig(bool fCustomChannelMapping, DWORD pSpeakerToChannelMap[18][18])
{
- if(m_State == State_Stopped || m_fCustomChannelMapping != fCustomChannelMapping
+ if (m_State == State_Stopped || m_fCustomChannelMapping != fCustomChannelMapping
|| memcmp(m_pSpeakerToChannelMap, pSpeakerToChannelMap, sizeof(m_pSpeakerToChannelMap))) {
PauseGraph;
@@ -606,7 +606,7 @@ STDMETHODIMP_(bool) CAudioSwitcherFilter::IsDownSamplingTo441Enabled() STDMETHODIMP CAudioSwitcherFilter::EnableDownSamplingTo441(bool fEnable)
{
- if(m_fDownSampleTo441 != fEnable) {
+ if (m_fDownSampleTo441 != fEnable) {
PauseGraph;
m_fDownSampleTo441 = fEnable;
ResumeGraph;
@@ -636,7 +636,7 @@ STDMETHODIMP CAudioSwitcherFilter::GetNormalizeBoost(bool& fNormalize, bool& fNo STDMETHODIMP CAudioSwitcherFilter::SetNormalizeBoost(bool fNormalize, bool fNormalizeRecover, float boost_dB)
{
- if(m_fNormalize != fNormalize) {
+ if (m_fNormalize != fNormalize) {
m_sample_max = 0.1f;
}
m_fNormalize = fNormalize;
@@ -650,7 +650,7 @@ STDMETHODIMP CAudioSwitcherFilter::SetNormalizeBoost(bool fNormalize, bool fNorm STDMETHODIMP CAudioSwitcherFilter::Enable(long lIndex, DWORD dwFlags)
{
HRESULT hr = __super::Enable(lIndex, dwFlags);
- if(S_OK == hr) {
+ if (S_OK == hr) {
m_sample_max = 0.1f;
}
return hr;
diff --git a/src/filters/switcher/AudioSwitcher/StreamSwitcher.cpp b/src/filters/switcher/AudioSwitcher/StreamSwitcher.cpp index 6a7f764fd..c37026f45 100644 --- a/src/filters/switcher/AudioSwitcher/StreamSwitcher.cpp +++ b/src/filters/switcher/AudioSwitcher/StreamSwitcher.cpp @@ -59,16 +59,16 @@ HRESULT GetPeer(CStreamSwitcherFilter* pFilter, T** ppT) *ppT = NULL;
CBasePin* pPin = pFilter->GetInputPin();
- if(!pPin) {
+ if (!pPin) {
return E_NOTIMPL;
}
CComPtr<IPin> pConnected;
- if(FAILED(pPin->ConnectedTo(&pConnected))) {
+ if (FAILED(pPin->ConnectedTo(&pConnected))) {
return E_NOTIMPL;
}
- if(CComQIPtr<T> pT = pConnected) {
+ if (CComQIPtr<T> pT = pConnected) {
*ppT = pT.Detach();
return S_OK;
}
@@ -207,7 +207,7 @@ STDMETHODIMP CStreamSwitcherPassThru::GetRate(double* pdRate) STDMETHODIMP CStreamSwitcherPassThru::SetRate(double dRate)
{
- if(0.0 == dRate) {
+ if (0.0 == dRate) {
return E_INVALIDARG;
}
CallPeerSeekingAll(SetRate(dRate));
@@ -257,7 +257,7 @@ STDMETHODIMP CStreamSwitcherPassThru::get_Rate(double* pdRate) STDMETHODIMP CStreamSwitcherPassThru::put_Rate(double dRate)
{
- if(0.0 == dRate) {
+ if (0.0 == dRate) {
return E_INVALIDARG;
}
CallPeerAll(put_Rate(dRate));
@@ -310,7 +310,7 @@ STDMETHODIMP CStreamSwitcherAllocator::GetBuffer( {
HRESULT hr = VFW_E_NOT_COMMITTED;
- if(!m_bCommitted) {
+ if (!m_bCommitted) {
return hr;
}
/*
@@ -318,37 +318,37 @@ STDMETHODIMP CStreamSwitcherAllocator::GetBuffer( m_pPin->m_evBlock.Wait();
TRACE(_T("CStreamSwitcherAllocator::GetBuffer m_pPin->m_evBlock.Wait() - %x\n"), this);
*/
- if(m_fMediaTypeChanged) {
- if(!m_pPin || !m_pPin->m_pFilter) {
+ if (m_fMediaTypeChanged) {
+ if (!m_pPin || !m_pPin->m_pFilter) {
return hr;
}
CStreamSwitcherOutputPin* pOut = (static_cast<CStreamSwitcherFilter*>(m_pPin->m_pFilter))->GetOutputPin();
- if(!pOut || !pOut->CurrentAllocator()) {
+ if (!pOut || !pOut->CurrentAllocator()) {
return hr;
}
ALLOCATOR_PROPERTIES Properties, Actual;
- if(FAILED(pOut->CurrentAllocator()->GetProperties(&Actual))) {
+ if (FAILED(pOut->CurrentAllocator()->GetProperties(&Actual))) {
return hr;
}
- if(FAILED(GetProperties(&Properties))) {
+ if (FAILED(GetProperties(&Properties))) {
return hr;
}
- if(!m_bCommitted || Properties.cbBuffer < Actual.cbBuffer) {
+ if (!m_bCommitted || Properties.cbBuffer < Actual.cbBuffer) {
Properties.cbBuffer = Actual.cbBuffer;
- if(FAILED(Decommit())) {
+ if (FAILED(Decommit())) {
return hr;
}
- if(FAILED(SetProperties(&Properties, &Actual))) {
+ if (FAILED(SetProperties(&Properties, &Actual))) {
return hr;
}
- if(FAILED(Commit())) {
+ if (FAILED(Commit())) {
return hr;
}
ASSERT(Actual.cbBuffer >= Properties.cbBuffer);
- if(Actual.cbBuffer < Properties.cbBuffer) {
+ if (Actual.cbBuffer < Properties.cbBuffer) {
return hr;
}
}
@@ -356,7 +356,7 @@ STDMETHODIMP CStreamSwitcherAllocator::GetBuffer( hr = CMemAllocator::GetBuffer(ppBuffer, pStartTime, pEndTime, dwFlags);
- if(m_fMediaTypeChanged && SUCCEEDED(hr)) {
+ if (m_fMediaTypeChanged && SUCCEEDED(hr)) {
(*ppBuffer)->SetMediaType(&m_mt);
m_fMediaTypeChanged = false;
}
@@ -408,7 +408,7 @@ STDMETHODIMP CStreamSwitcherInputPin::DynamicQueryAccept(const AM_MEDIA_TYPE* pm STDMETHODIMP CStreamSwitcherInputPin::NotifyEndOfStream(HANDLE hNotifyEvent)
{
- if(m_hNotifyEvent) {
+ if (m_hNotifyEvent) {
SetEvent(m_hNotifyEvent);
}
m_hNotifyEvent = hNotifyEvent;
@@ -443,10 +443,10 @@ HRESULT CStreamSwitcherInputPin::QueryAcceptDownstream(const AM_MEDIA_TYPE* pmt) CStreamSwitcherOutputPin* pOut = (static_cast<CStreamSwitcherFilter*>(m_pFilter))->GetOutputPin();
- if(pOut && pOut->IsConnected()) {
- if(CComPtr<IPinConnection> pPC = pOut->CurrentPinConnection()) {
+ if (pOut && pOut->IsConnected()) {
+ if (CComPtr<IPinConnection> pPC = pOut->CurrentPinConnection()) {
hr = pPC->DynamicQueryAccept(pmt);
- if(hr == S_OK) {
+ if (hr == S_OK) {
return S_OK;
}
}
@@ -459,7 +459,7 @@ HRESULT CStreamSwitcherInputPin::QueryAcceptDownstream(const AM_MEDIA_TYPE* pmt) void CStreamSwitcherInputPin::Block(bool fBlock)
{
- if(fBlock) {
+ if (fBlock) {
m_evBlock.Reset();
} else {
m_evBlock.Set();
@@ -468,7 +468,7 @@ void CStreamSwitcherInputPin::Block(bool fBlock) HRESULT CStreamSwitcherInputPin::InitializeOutputSample(IMediaSample* pInSample, IMediaSample** ppOutSample)
{
- if(!pInSample || !ppOutSample) {
+ if (!pInSample || !ppOutSample) {
return E_POINTER;
}
@@ -479,7 +479,7 @@ HRESULT CStreamSwitcherInputPin::InitializeOutputSample(IMediaSample* pInSample, DWORD dwFlags = m_bSampleSkipped ? AM_GBF_PREVFRAMESKIPPED : 0;
- if(!(m_SampleProps.dwSampleFlags & AM_SAMPLE_SPLICEPOINT)) {
+ if (!(m_SampleProps.dwSampleFlags & AM_SAMPLE_SPLICEPOINT)) {
dwFlags |= AM_GBF_NOTASYNCPOINT;
}
@@ -488,15 +488,15 @@ HRESULT CStreamSwitcherInputPin::InitializeOutputSample(IMediaSample* pInSample, , m_SampleProps.dwSampleFlags & AM_SAMPLE_STOPVALID ? &m_SampleProps.tStop : NULL
, dwFlags);
- if(FAILED(hr)) {
+ if (FAILED(hr)) {
return hr;
}
- if(!pOutSample) {
+ if (!pOutSample) {
return E_FAIL;
}
- if(CComQIPtr<IMediaSample2> pOutSample2 = pOutSample) {
+ if (CComQIPtr<IMediaSample2> pOutSample2 = pOutSample) {
AM_SAMPLE2_PROPERTIES OutProps;
EXECUTE_ASSERT(SUCCEEDED(pOutSample2->GetProperties(FIELD_OFFSET(AM_SAMPLE2_PROPERTIES, tStart), (PBYTE)&OutProps)));
OutProps.dwTypeSpecificFlags = m_SampleProps.dwTypeSpecificFlags;
@@ -509,25 +509,25 @@ HRESULT CStreamSwitcherInputPin::InitializeOutputSample(IMediaSample* pInSample, OutProps.cbData = FIELD_OFFSET(AM_SAMPLE2_PROPERTIES, dwStreamId);
hr = pOutSample2->SetProperties(FIELD_OFFSET(AM_SAMPLE2_PROPERTIES, dwStreamId), (PBYTE)&OutProps);
- if(m_SampleProps.dwSampleFlags & AM_SAMPLE_DATADISCONTINUITY) {
+ if (m_SampleProps.dwSampleFlags & AM_SAMPLE_DATADISCONTINUITY) {
m_bSampleSkipped = FALSE;
}
} else {
- if(m_SampleProps.dwSampleFlags & AM_SAMPLE_TIMEVALID) {
+ if (m_SampleProps.dwSampleFlags & AM_SAMPLE_TIMEVALID) {
pOutSample->SetTime(&m_SampleProps.tStart, &m_SampleProps.tStop);
}
- if(m_SampleProps.dwSampleFlags & AM_SAMPLE_SPLICEPOINT) {
+ if (m_SampleProps.dwSampleFlags & AM_SAMPLE_SPLICEPOINT) {
pOutSample->SetSyncPoint(TRUE);
}
- if(m_SampleProps.dwSampleFlags & AM_SAMPLE_DATADISCONTINUITY) {
+ if (m_SampleProps.dwSampleFlags & AM_SAMPLE_DATADISCONTINUITY) {
pOutSample->SetDiscontinuity(TRUE);
m_bSampleSkipped = FALSE;
}
LONGLONG MediaStart, MediaEnd;
- if(pInSample->GetMediaTime(&MediaStart, &MediaEnd) == NOERROR) {
+ if (pInSample->GetMediaTime(&MediaStart, &MediaEnd) == NOERROR) {
pOutSample->SetMediaTime(&MediaStart, &MediaEnd);
}
}
@@ -556,7 +556,7 @@ HRESULT CStreamSwitcherInputPin::CheckConnect(IPin* pPin) HRESULT CStreamSwitcherInputPin::CompleteConnect(IPin* pReceivePin)
{
HRESULT hr = __super::CompleteConnect(pReceivePin);
- if(FAILED(hr)) {
+ if (FAILED(hr)) {
return hr;
}
@@ -575,13 +575,13 @@ HRESULT CStreamSwitcherInputPin::CompleteConnect(IPin* pReceivePin) if (pPin) {
pBF = GetFilterFromPin(pPin);
}
- while(pPin && pBF) {
- if(IsSplitter(pBF)) {
+ while (pPin && pBF) {
+ if (IsSplitter(pBF)) {
pinName = GetPinName(pPin);
}
CLSID clsid = GetCLSID(pBF);
- if(clsid == CLSID_AviSplitter || clsid == CLSID_OggSplitter) {
+ if (clsid == CLSID_AviSplitter || clsid == CLSID_OggSplitter) {
m_fCanBlock = true;
}
@@ -589,29 +589,29 @@ HRESULT CStreamSwitcherInputPin::CompleteConnect(IPin* pReceivePin) CountPins(pBF, nIn, nOut, nInC, nOutC);
fForkedSomewhere = fForkedSomewhere || nIn > 1 || nOut > 1;
- if(CComQIPtr<IFileSourceFilter> pFSF = pBF) {
+ if (CComQIPtr<IFileSourceFilter> pFSF = pBF) {
WCHAR* pszName = NULL;
AM_MEDIA_TYPE mt;
- if(SUCCEEDED(pFSF->GetCurFile(&pszName, &mt)) && pszName) {
+ if (SUCCEEDED(pFSF->GetCurFile(&pszName, &mt)) && pszName) {
fileName = pszName;
CoTaskMemFree(pszName);
fileName.Replace('\\', '/');
CStringW fn = fileName.Mid(fileName.ReverseFind('/')+1);
- if(!fn.IsEmpty()) {
+ if (!fn.IsEmpty()) {
fileName = fn;
}
// Haali & LAVFSplitter return only one "Audio" pin name, cause CMainFrame::OnInitMenuPopup lookup find the wrong popmenu,
// add space at the end to prevent this, internal filter never return "Audio" only.
- if(!pinName.IsEmpty()) {
+ if (!pinName.IsEmpty()) {
fileName = pinName + L" ";
}
WCHAR* pName = DNew WCHAR[fileName.GetLength()+1];
- if(pName) {
+ if (pName) {
wcscpy(pName, fileName);
- if(m_pName) {
+ if (m_pName) {
delete [] m_pName;
}
m_pName = pName;
@@ -629,7 +629,7 @@ HRESULT CStreamSwitcherInputPin::CompleteConnect(IPin* pReceivePin) }
}
- if(!fForkedSomewhere) {
+ if (!fForkedSomewhere) {
m_fCanBlock = true;
}
@@ -657,7 +657,7 @@ HRESULT CStreamSwitcherInputPin::Inactive() STDMETHODIMP CStreamSwitcherInputPin::QueryAccept(const AM_MEDIA_TYPE* pmt)
{
HRESULT hr = __super::QueryAccept(pmt);
- if(S_OK != hr) {
+ if (S_OK != hr) {
return hr;
}
@@ -670,15 +670,15 @@ STDMETHODIMP CStreamSwitcherInputPin::ReceiveConnection(IPin* pConnector, const // CAutoLock cAutoLock(&((CStreamSwitcherFilter*)m_pFilter)->m_csReceive);
HRESULT hr;
- if(S_OK != (hr = QueryAcceptDownstream(pmt))) {
+ if (S_OK != (hr = QueryAcceptDownstream(pmt))) {
return VFW_E_TYPE_NOT_ACCEPTED;
}
- if(m_Connected && m_Connected != pConnector) {
+ if (m_Connected && m_Connected != pConnector) {
return VFW_E_ALREADY_CONNECTED;
}
- if(m_Connected) {
+ if (m_Connected) {
m_Connected->Release(), m_Connected = NULL;
}
@@ -689,7 +689,7 @@ STDMETHODIMP CStreamSwitcherInputPin::GetAllocator(IMemAllocator** ppAllocator) {
CheckPointer(ppAllocator, E_POINTER);
- if(m_pAllocator == NULL) {
+ if (m_pAllocator == NULL) {
(m_pAllocator = &m_Allocator)->AddRef();
}
@@ -701,7 +701,7 @@ STDMETHODIMP CStreamSwitcherInputPin::GetAllocator(IMemAllocator** ppAllocator) STDMETHODIMP CStreamSwitcherInputPin::NotifyAllocator(IMemAllocator* pAllocator, BOOL bReadOnly)
{
HRESULT hr = __super::NotifyAllocator(pAllocator, bReadOnly);
- if(FAILED(hr)) {
+ if (FAILED(hr)) {
return hr;
}
@@ -719,11 +719,11 @@ STDMETHODIMP CStreamSwitcherInputPin::BeginFlush() CStreamSwitcherFilter* pSSF = static_cast<CStreamSwitcherFilter*>(m_pFilter);
CStreamSwitcherOutputPin* pOut = pSSF->GetOutputPin();
- if(!IsConnected() || !pOut || !pOut->IsConnected()) {
+ if (!IsConnected() || !pOut || !pOut->IsConnected()) {
return VFW_E_NOT_CONNECTED;
}
- if(FAILED(hr = __super::BeginFlush())) {
+ if (FAILED(hr = __super::BeginFlush())) {
return hr;
}
@@ -739,11 +739,11 @@ STDMETHODIMP CStreamSwitcherInputPin::EndFlush() CStreamSwitcherFilter* pSSF = static_cast<CStreamSwitcherFilter*>(m_pFilter);
CStreamSwitcherOutputPin* pOut = pSSF->GetOutputPin();
- if(!IsConnected() || !pOut || !pOut->IsConnected()) {
+ if (!IsConnected() || !pOut || !pOut->IsConnected()) {
return VFW_E_NOT_CONNECTED;
}
- if(FAILED(hr = __super::EndFlush())) {
+ if (FAILED(hr = __super::EndFlush())) {
return hr;
}
@@ -757,11 +757,11 @@ STDMETHODIMP CStreamSwitcherInputPin::EndOfStream() CStreamSwitcherFilter* pSSF = static_cast<CStreamSwitcherFilter*>(m_pFilter);
CStreamSwitcherOutputPin* pOut = pSSF->GetOutputPin();
- if(!IsConnected() || !pOut || !pOut->IsConnected()) {
+ if (!IsConnected() || !pOut || !pOut->IsConnected()) {
return VFW_E_NOT_CONNECTED;
}
- if(m_hNotifyEvent) {
+ if (m_hNotifyEvent) {
SetEvent(m_hNotifyEvent), m_hNotifyEvent = NULL;
return S_OK;
}
@@ -774,7 +774,7 @@ STDMETHODIMP CStreamSwitcherInputPin::EndOfStream() STDMETHODIMP CStreamSwitcherInputPin::Receive(IMediaSample* pSample)
{
AM_MEDIA_TYPE* pmt = NULL;
- if(SUCCEEDED(pSample->GetMediaType(&pmt)) && pmt) {
+ if (SUCCEEDED(pSample->GetMediaType(&pmt)) && pmt) {
const CMediaType mt(*pmt);
DeleteMediaType(pmt), pmt = NULL;
SetMediaType(&mt);
@@ -786,14 +786,14 @@ STDMETHODIMP CStreamSwitcherInputPin::Receive(IMediaSample* pSample) // strategy is useless because of this, ARRRRRRGHHHHHH.
#ifdef BLOCKSTREAM
- if(m_fCanBlock) {
+ if (m_fCanBlock) {
m_evBlock.Wait();
}
#endif
- if(!IsActive()) {
+ if (!IsActive()) {
#ifdef BLOCKSTREAM
- if(m_fCanBlock) {
+ if (m_fCanBlock) {
return S_FALSE;
}
#endif
@@ -809,11 +809,11 @@ STDMETHODIMP CStreamSwitcherInputPin::Receive(IMediaSample* pSample) ASSERT(pOut->GetConnected());
HRESULT hr = __super::Receive(pSample);
- if(S_OK != hr) {
+ if (S_OK != hr) {
return hr;
}
- if(m_SampleProps.dwStreamId != AM_STREAM_MEDIA) {
+ if (m_SampleProps.dwStreamId != AM_STREAM_MEDIA) {
return pOut->Deliver(pSample);
}
@@ -824,7 +824,7 @@ STDMETHODIMP CStreamSwitcherInputPin::Receive(IMediaSample* pSample) hr = pOut->CurrentAllocator()->GetProperties(&actual);
REFERENCE_TIME rtStart = 0, rtStop = 0;
- if(S_OK == pSample->GetTime(&rtStart, &rtStop)) {
+ if (S_OK == pSample->GetTime(&rtStart, &rtStop)) {
//
}
@@ -835,7 +835,7 @@ STDMETHODIMP CStreamSwitcherInputPin::Receive(IMediaSample* pSample) bool fTypeChanged = false;
- if(mtOut != pOut->CurrentMediaType() || cbBuffer > actual.cbBuffer) {
+ if (mtOut != pOut->CurrentMediaType() || cbBuffer > actual.cbBuffer) {
fTypeChanged = true;
m_SampleProps.dwSampleFlags |= AM_SAMPLE_TYPECHANGED/*|AM_SAMPLE_DATADISCONTINUITY|AM_SAMPLE_TIMEDISCONTINUITY*/;
@@ -853,13 +853,13 @@ STDMETHODIMP CStreamSwitcherInputPin::Receive(IMediaSample* pSample) }
*/
- if(props.cBuffers < 8 && mtOut.majortype == MEDIATYPE_Audio) {
+ if (props.cBuffers < 8 && mtOut.majortype == MEDIATYPE_Audio) {
props.cBuffers = 8;
}
props.cbBuffer = cbBuffer;
- if(actual.cbAlign != props.cbAlign
+ if (actual.cbAlign != props.cbAlign
|| actual.cbPrefix != props.cbPrefix
|| actual.cBuffers < props.cBuffers
|| actual.cbBuffer < props.cbBuffer) {
@@ -872,19 +872,19 @@ STDMETHODIMP CStreamSwitcherInputPin::Receive(IMediaSample* pSample) }
CComPtr<IMediaSample> pOutSample;
- if(FAILED(InitializeOutputSample(pSample, &pOutSample))) {
+ if (FAILED(InitializeOutputSample(pSample, &pOutSample))) {
return E_FAIL;
}
pmt = NULL;
- if(SUCCEEDED(pOutSample->GetMediaType(&pmt)) && pmt) {
+ if (SUCCEEDED(pOutSample->GetMediaType(&pmt)) && pmt) {
const CMediaType mt(*pmt);
DeleteMediaType(pmt), pmt = NULL;
// TODO
ASSERT(0);
}
- if(fTypeChanged) {
+ if (fTypeChanged) {
pOut->SetMediaType(&mtOut);
(static_cast<CStreamSwitcherFilter*>(m_pFilter))->OnNewOutputMediaType(m_mt, mtOut);
pOutSample->SetMediaType(&mtOut);
@@ -896,7 +896,7 @@ STDMETHODIMP CStreamSwitcherInputPin::Receive(IMediaSample* pSample) //
- if(S_OK == hr) {
+ if (S_OK == hr) {
hr = pOut->Deliver(pOutSample);
m_bSampleSkipped = FALSE;
/*
@@ -905,12 +905,12 @@ STDMETHODIMP CStreamSwitcherInputPin::Receive(IMediaSample* pSample) ASSERT(0);
}
*/
- } else if(S_FALSE == hr) {
+ } else if (S_FALSE == hr) {
hr = S_OK;
pOutSample = NULL;
m_bSampleSkipped = TRUE;
- if(!m_bQualityChanged) {
+ if (!m_bQualityChanged) {
m_pFilter->NotifyEvent(EC_QUALITY_CHANGE, 0, 0);
m_bQualityChanged = TRUE;
}
@@ -921,7 +921,7 @@ STDMETHODIMP CStreamSwitcherInputPin::Receive(IMediaSample* pSample) STDMETHODIMP CStreamSwitcherInputPin::NewSegment(REFERENCE_TIME tStart, REFERENCE_TIME tStop, double dRate)
{
- if(!IsConnected()) {
+ if (!IsConnected()) {
return S_OK;
}
@@ -930,7 +930,7 @@ STDMETHODIMP CStreamSwitcherInputPin::NewSegment(REFERENCE_TIME tStart, REFERENC CStreamSwitcherFilter* pSSF = static_cast<CStreamSwitcherFilter*>(m_pFilter);
CStreamSwitcherOutputPin* pOut = pSSF->GetOutputPin();
- if(!pOut || !pOut->IsConnected()) {
+ if (!pOut || !pOut->IsConnected()) {
return VFW_E_NOT_CONNECTED;
}
@@ -953,16 +953,16 @@ STDMETHODIMP CStreamSwitcherOutputPin::NonDelegatingQueryInterface(REFIID riid, ValidateReadWritePtr(ppv, sizeof(PVOID));
*ppv = NULL;
- if(riid == IID_IMediaPosition || riid == IID_IMediaSeeking) {
- if(m_pStreamSwitcherPassThru == NULL) {
+ if (riid == IID_IMediaPosition || riid == IID_IMediaSeeking) {
+ if (m_pStreamSwitcherPassThru == NULL) {
HRESULT hr = S_OK;
m_pStreamSwitcherPassThru = (IUnknown*)(INonDelegatingUnknown*)
DNew CStreamSwitcherPassThru(GetOwner(), &hr, static_cast<CStreamSwitcherFilter*>(m_pFilter));
- if(!m_pStreamSwitcherPassThru) {
+ if (!m_pStreamSwitcherPassThru) {
return E_OUTOFMEMORY;
}
- if(FAILED(hr)) {
+ if (FAILED(hr)) {
return hr;
}
}
@@ -984,9 +984,9 @@ HRESULT CStreamSwitcherOutputPin::QueryAcceptUpstream(const AM_MEDIA_TYPE* pmt) CStreamSwitcherInputPin* pIn = (static_cast<CStreamSwitcherFilter*>(m_pFilter))->GetInputPin();
- if(pIn && pIn->IsConnected() && (pIn->IsUsingOwnAllocator() || pIn->CurrentMediaType() == *pmt)) {
- if(CComQIPtr<IPin> pPinTo = pIn->GetConnected()) {
- if(S_OK != (hr = pPinTo->QueryAccept(pmt))) {
+ if (pIn && pIn->IsConnected() && (pIn->IsUsingOwnAllocator() || pIn->CurrentMediaType() == *pmt)) {
+ if (CComQIPtr<IPin> pPinTo = pIn->GetConnected()) {
+ if (S_OK != (hr = pPinTo->QueryAccept(pmt))) {
return VFW_E_TYPE_NOT_ACCEPTED;
}
} else {
@@ -1002,27 +1002,27 @@ HRESULT CStreamSwitcherOutputPin::QueryAcceptUpstream(const AM_MEDIA_TYPE* pmt) HRESULT CStreamSwitcherOutputPin::DecideBufferSize(IMemAllocator* pAllocator, ALLOCATOR_PROPERTIES* pProperties)
{
CStreamSwitcherInputPin* pIn = (static_cast<CStreamSwitcherFilter*>(m_pFilter))->GetInputPin();
- if(!pIn || !pIn->IsConnected()) {
+ if (!pIn || !pIn->IsConnected()) {
return E_UNEXPECTED;
}
CComPtr<IMemAllocator> pAllocatorIn;
pIn->GetAllocator(&pAllocatorIn);
- if(!pAllocatorIn) {
+ if (!pAllocatorIn) {
return E_UNEXPECTED;
}
HRESULT hr;
- if(FAILED(hr = pAllocatorIn->GetProperties(pProperties))) {
+ if (FAILED(hr = pAllocatorIn->GetProperties(pProperties))) {
return hr;
}
- if(pProperties->cBuffers < 8 && pIn->CurrentMediaType().majortype == MEDIATYPE_Audio) {
+ if (pProperties->cBuffers < 8 && pIn->CurrentMediaType().majortype == MEDIATYPE_Audio) {
pProperties->cBuffers = 8;
}
ALLOCATOR_PROPERTIES Actual;
- if(FAILED(hr = pAllocator->SetProperties(pProperties, &Actual))) {
+ if (FAILED(hr = pAllocator->SetProperties(pProperties, &Actual))) {
return hr;
}
@@ -1069,21 +1069,21 @@ HRESULT CStreamSwitcherOutputPin::CheckMediaType(const CMediaType* pmt) HRESULT CStreamSwitcherOutputPin::GetMediaType(int iPosition, CMediaType* pmt)
{
CStreamSwitcherInputPin* pIn = (static_cast<CStreamSwitcherFilter*>(m_pFilter))->GetInputPin();
- if(!pIn || !pIn->IsConnected()) {
+ if (!pIn || !pIn->IsConnected()) {
return E_UNEXPECTED;
}
CComPtr<IEnumMediaTypes> pEM;
- if(FAILED(pIn->GetConnected()->EnumMediaTypes(&pEM))) {
+ if (FAILED(pIn->GetConnected()->EnumMediaTypes(&pEM))) {
return VFW_S_NO_MORE_ITEMS;
}
- if(iPosition > 0 && FAILED(pEM->Skip(iPosition))) {
+ if (iPosition > 0 && FAILED(pEM->Skip(iPosition))) {
return VFW_S_NO_MORE_ITEMS;
}
AM_MEDIA_TYPE* tmp = NULL;
- if(S_OK != pEM->Next(1, &tmp, NULL) || !tmp) {
+ if (S_OK != pEM->Next(1, &tmp, NULL) || !tmp) {
return VFW_S_NO_MORE_ITEMS;
}
@@ -1103,7 +1103,7 @@ HRESULT CStreamSwitcherOutputPin::GetMediaType(int iPosition, CMediaType* pmt) STDMETHODIMP CStreamSwitcherOutputPin::QueryAccept(const AM_MEDIA_TYPE* pmt)
{
HRESULT hr = __super::QueryAccept(pmt);
- if(S_OK != hr) {
+ if (S_OK != hr) {
return hr;
}
@@ -1115,7 +1115,7 @@ STDMETHODIMP CStreamSwitcherOutputPin::QueryAccept(const AM_MEDIA_TYPE* pmt) STDMETHODIMP CStreamSwitcherOutputPin::Notify(IBaseFilter* pSender, Quality q)
{
CStreamSwitcherInputPin* pIn = (static_cast<CStreamSwitcherFilter*>(m_pFilter))->GetInputPin();
- if(!pIn || !pIn->IsConnected()) {
+ if (!pIn || !pIn->IsConnected()) {
return VFW_E_NOT_CONNECTED;
}
return pIn->PassNotify(q);
@@ -1127,11 +1127,11 @@ STDMETHODIMP CStreamSwitcherOutputPin::Render(IPin* ppinOut, IGraphBuilder* pGra {
CComPtr<IBaseFilter> pBF;
pBF.CoCreateInstance(CLSID_DSoundRender);
- if(!pBF || FAILED(pGraph->AddFilter(pBF, L"Default DirectSound Device"))) {
+ if (!pBF || FAILED(pGraph->AddFilter(pBF, L"Default DirectSound Device"))) {
return E_FAIL;
}
- if(FAILED(pGraph->ConnectDirect(ppinOut, GetFirstDisconnectedPin(pBF, PINDIR_INPUT), NULL))) {
+ if (FAILED(pGraph->ConnectDirect(ppinOut, GetFirstDisconnectedPin(pBF, PINDIR_INPUT), NULL))) {
pGraph->RemoveFilter(pBF);
return E_FAIL;
}
@@ -1151,7 +1151,7 @@ STDMETHODIMP CStreamSwitcherOutputPin::Backout(IPin* ppinOut, IGraphBuilder* pGr CStreamSwitcherFilter::CStreamSwitcherFilter(LPUNKNOWN lpunk, HRESULT* phr, const CLSID& clsid)
: CBaseFilter(NAME("CStreamSwitcherFilter"), lpunk, &m_csState, clsid)
{
- if(phr) {
+ if (phr) {
*phr = S_OK;
}
@@ -1163,13 +1163,13 @@ CStreamSwitcherFilter::CStreamSwitcherFilter(LPUNKNOWN lpunk, HRESULT* phr, cons hr = S_OK;
pInput.Attach(DNew CStreamSwitcherInputPin(this, &hr, L"Channel 1"));
- if(!pInput || FAILED(hr)) {
+ if (!pInput || FAILED(hr)) {
break;
}
hr = S_OK;
pOutput.Attach(DNew CStreamSwitcherOutputPin(this, &hr));
- if(!pOutput || FAILED(hr)) {
+ if (!pOutput || FAILED(hr)) {
break;
}
@@ -1179,9 +1179,9 @@ CStreamSwitcherFilter::CStreamSwitcherFilter(LPUNKNOWN lpunk, HRESULT* phr, cons m_pOutput = pOutput.Detach();
return;
- } while(false);
+ } while (false);
- if(phr) {
+ if (phr) {
*phr = E_FAIL;
}
}
@@ -1191,7 +1191,7 @@ CStreamSwitcherFilter::~CStreamSwitcherFilter() CAutoLock cAutoLock(&m_csPins);
POSITION pos = m_pInputs.GetHeadPosition();
- while(pos) {
+ while (pos) {
delete m_pInputs.GetNext(pos);
}
m_pInputs.RemoveAll();
@@ -1221,9 +1221,9 @@ CBasePin* CStreamSwitcherFilter::GetPin(int n) {
CAutoLock cAutoLock(&m_csPins);
- if(n < 0 || n >= GetPinCount()) {
+ if (n < 0 || n >= GetPinCount()) {
return NULL;
- } else if(n == 0) {
+ } else if (n == 0) {
return m_pOutput;
} else {
return m_pInputs.GetAt(m_pInputs.FindIndex(n-1));
@@ -1237,8 +1237,8 @@ int CStreamSwitcherFilter::GetConnectedInputPinCount() int nConnected = 0;
POSITION pos = m_pInputs.GetHeadPosition();
- while(pos) {
- if(m_pInputs.GetNext(pos)->IsConnected()) {
+ while (pos) {
+ if (m_pInputs.GetNext(pos)->IsConnected()) {
nConnected++;
}
}
@@ -1248,12 +1248,12 @@ int CStreamSwitcherFilter::GetConnectedInputPinCount() CStreamSwitcherInputPin* CStreamSwitcherFilter::GetConnectedInputPin(int n)
{
- if(n >= 0) {
+ if (n >= 0) {
POSITION pos = m_pInputs.GetHeadPosition();
- while(pos) {
+ while (pos) {
CStreamSwitcherInputPin* pPin = m_pInputs.GetNext(pos);
- if(pPin->IsConnected()) {
- if(n == 0) {
+ if (pPin->IsConnected()) {
+ if (n == 0) {
return(pPin);
}
n--;
@@ -1278,22 +1278,22 @@ CStreamSwitcherOutputPin* CStreamSwitcherFilter::GetOutputPin() HRESULT CStreamSwitcherFilter::CompleteConnect(PIN_DIRECTION dir, CBasePin* pPin, IPin* pReceivePin)
{
- if(dir == PINDIR_INPUT) {
+ if (dir == PINDIR_INPUT) {
CAutoLock cAutoLock(&m_csPins);
int nConnected = GetConnectedInputPinCount();
- if(nConnected == 1) {
+ if (nConnected == 1) {
m_pInput = static_cast<CStreamSwitcherInputPin*>(pPin);
}
- if((size_t)nConnected == m_pInputs.GetCount()) {
+ if ((size_t)nConnected == m_pInputs.GetCount()) {
CStringW name;
name.Format(L"Channel %d", ++m_PinVersion);
HRESULT hr = S_OK;
CStreamSwitcherInputPin* pPin = DNew CStreamSwitcherInputPin(this, &hr, name);
- if(!pPin || FAILED(hr)) {
+ if (!pPin || FAILED(hr)) {
delete pPin;
return E_FAIL;
}
@@ -1313,7 +1313,7 @@ void CStreamSwitcherFilter::SelectInput(CStreamSwitcherInputPin* pInput) // release blocked GetBuffer in our own allocator & block all Receive
POSITION pos = m_pInputs.GetHeadPosition();
- while(pos) {
+ while (pos) {
CStreamSwitcherInputPin* pPin = m_pInputs.GetNext(pos);
pPin->Block(false);
// a few Receive calls can arrive here, but since m_pInput == NULL neighter of them gets delivered
@@ -1321,12 +1321,12 @@ void CStreamSwitcherFilter::SelectInput(CStreamSwitcherInputPin* pInput) }
// this will let waiting GetBuffer() calls go on inside our Receive()
- if(m_pOutput) {
+ if (m_pOutput) {
m_pOutput->DeliverBeginFlush();
m_pOutput->DeliverEndFlush();
}
- if(!pInput) {
+ if (!pInput) {
return;
}
@@ -1345,17 +1345,17 @@ HRESULT CStreamSwitcherFilter::Transform(IMediaSample* pIn, IMediaSample* pOut) BYTE* pDataOut = NULL;
HRESULT hr;
- if(FAILED(hr = pIn->GetPointer(&pDataIn))) {
+ if (FAILED(hr = pIn->GetPointer(&pDataIn))) {
return hr;
}
- if(FAILED(hr = pOut->GetPointer(&pDataOut))) {
+ if (FAILED(hr = pOut->GetPointer(&pDataOut))) {
return hr;
}
long len = pIn->GetActualDataLength();
long size = pOut->GetSize();
- if(!pDataIn || !pDataOut /*|| len > size || len <= 0*/) {
+ if (!pDataIn || !pDataOut /*|| len > size || len <= 0*/) {
return S_FALSE; // FIXME
}
@@ -1394,7 +1394,7 @@ HRESULT CStreamSwitcherFilter::DeliverNewSegment(REFERENCE_TIME tStart, REFERENC STDMETHODIMP CStreamSwitcherFilter::Count(DWORD* pcStreams)
{
- if(!pcStreams) {
+ if (!pcStreams) {
return E_POINTER;
}
@@ -1410,38 +1410,38 @@ STDMETHODIMP CStreamSwitcherFilter::Info(long lIndex, AM_MEDIA_TYPE** ppmt, DWOR CAutoLock cAutoLock(&m_csPins);
CBasePin* pPin = GetConnectedInputPin(lIndex);
- if(!pPin) {
+ if (!pPin) {
return E_INVALIDARG;
}
- if(ppmt) {
+ if (ppmt) {
*ppmt = CreateMediaType(&m_pOutput->CurrentMediaType());
}
- if(pdwFlags) {
+ if (pdwFlags) {
*pdwFlags = (m_pInput == pPin) ? AMSTREAMSELECTINFO_EXCLUSIVE : 0;
}
- if(plcid) {
+ if (plcid) {
*plcid = 0;
}
- if(pdwGroup) {
+ if (pdwGroup) {
*pdwGroup = 0;
}
- if(ppszName) {
+ if (ppszName) {
*ppszName = (WCHAR*)CoTaskMemAlloc((wcslen(pPin->Name())+1)*sizeof(WCHAR));
- if(*ppszName) {
+ if (*ppszName) {
wcscpy(*ppszName, pPin->Name());
}
}
- if(ppObject) {
+ if (ppObject) {
*ppObject = NULL;
}
- if(ppUnk) {
+ if (ppUnk) {
*ppUnk = NULL;
}
@@ -1450,14 +1450,14 @@ STDMETHODIMP CStreamSwitcherFilter::Info(long lIndex, AM_MEDIA_TYPE** ppmt, DWOR STDMETHODIMP CStreamSwitcherFilter::Enable(long lIndex, DWORD dwFlags)
{
- if(dwFlags != AMSTREAMSELECTENABLE_ENABLE) {
+ if (dwFlags != AMSTREAMSELECTENABLE_ENABLE) {
return E_NOTIMPL;
}
PauseGraph;
CStreamSwitcherInputPin* pNewInput = GetConnectedInputPin(lIndex);
- if(!pNewInput) {
+ if (!pNewInput) {
return E_INVALIDARG;
}
diff --git a/src/filters/transform/AVI2AC3Filter/AVI2AC3Filter.cpp b/src/filters/transform/AVI2AC3Filter/AVI2AC3Filter.cpp index f905c59c1..bd79a7b91 100644 --- a/src/filters/transform/AVI2AC3Filter/AVI2AC3Filter.cpp +++ b/src/filters/transform/AVI2AC3Filter/AVI2AC3Filter.cpp @@ -76,7 +76,7 @@ CFilterApp theApp; CAVI2AC3Filter::CAVI2AC3Filter(LPUNKNOWN lpunk, HRESULT* phr)
: CTransformFilter(NAME("CAVI2AC3Filter"), lpunk, __uuidof(this))
{
- if(phr) {
+ if (phr) {
*phr = S_OK;
}
}
@@ -90,45 +90,45 @@ HRESULT CAVI2AC3Filter::Transform(IMediaSample* pSample, IMediaSample* pOutSampl HRESULT hr;
BYTE* pIn = NULL;
- if(FAILED(hr = pSample->GetPointer(&pIn))) {
+ if (FAILED(hr = pSample->GetPointer(&pIn))) {
return hr;
}
BYTE* pInOrg = pIn;
long len = pSample->GetActualDataLength();
- if(len <= 0) {
+ if (len <= 0) {
return S_FALSE;
}
BYTE* pOut = NULL;
- if(FAILED(hr = pOutSample->GetPointer(&pOut))) {
+ if (FAILED(hr = pOutSample->GetPointer(&pOut))) {
return hr;
}
BYTE* pOutOrg = pOut;
int size = pOutSample->GetSize();
- if((CheckAC3(&m_pInput->CurrentMediaType()) || CheckDTS(&m_pInput->CurrentMediaType()))
+ if ((CheckAC3(&m_pInput->CurrentMediaType()) || CheckDTS(&m_pInput->CurrentMediaType()))
&& (CheckWAVEAC3(&m_pOutput->CurrentMediaType()) || CheckWAVEDTS(&m_pOutput->CurrentMediaType()))) {
- if(*(DWORD*)pIn == 0xBA010000) {
+ if (*(DWORD*)pIn == 0xBA010000) {
pIn += 14;
}
- if(*(DWORD*)pIn == 0xBD010000) {
+ if (*(DWORD*)pIn == 0xBD010000) {
pIn += 8 + 1 + pIn[8] + 1 + 3;
}
len -= (pInOrg - pIn);
- if(size < len) {
+ if (size < len) {
return E_FAIL;
}
memcpy(pOut, pIn, len);
pOut += len;
- } else if((CheckWAVEAC3(&m_pInput->CurrentMediaType()) || CheckWAVEDTS(&m_pInput->CurrentMediaType()))
- && (CheckAC3(&m_pOutput->CurrentMediaType()) || CheckDTS(&m_pOutput->CurrentMediaType()))) {
- if((m_pOutput->CurrentMediaType().majortype == MEDIATYPE_DVD_ENCRYPTED_PACK
+ } else if ((CheckWAVEAC3(&m_pInput->CurrentMediaType()) || CheckWAVEDTS(&m_pInput->CurrentMediaType()))
+ && (CheckAC3(&m_pOutput->CurrentMediaType()) || CheckDTS(&m_pOutput->CurrentMediaType()))) {
+ if ((m_pOutput->CurrentMediaType().majortype == MEDIATYPE_DVD_ENCRYPTED_PACK
|| m_pOutput->CurrentMediaType().majortype == MEDIATYPE_MPEG2_PES)
&& (len + 12 + 3) >= 0x10000) { // damn, this can happen if the interleave time is too big
REFERENCE_TIME rtStart = 0, rtStop = 1;
@@ -137,15 +137,15 @@ HRESULT CAVI2AC3Filter::Transform(IMediaSample* pSample, IMediaSample* pOutSampl bool fDiscontinuity = (S_OK == pOutSample->IsDiscontinuity());
int pos = 0;
- while(pos < len) {
+ while (pos < len) {
int curlen = min(len - pos, 2013);
pos += 2013;
CComPtr<IMediaSample> pOutSample;
hr = InitializeOutputSample(pSample, &pOutSample);
- if(fDiscontinuity) {
- if(fHasTime) {
+ if (fDiscontinuity) {
+ if (fHasTime) {
rtStop = rtStart + (rtStop - rtStart) * curlen / len;
pOutSample->SetTime(&rtStart, &rtStop);
}
@@ -157,7 +157,7 @@ HRESULT CAVI2AC3Filter::Transform(IMediaSample* pSample, IMediaSample* pOutSampl }
BYTE* pOut = NULL;
- if(FAILED(hr = pOutSample->GetPointer(&pOut))) {
+ if (FAILED(hr = pOutSample->GetPointer(&pOut))) {
return hr;
}
BYTE* pOutOrg = pOut;
@@ -167,8 +167,8 @@ HRESULT CAVI2AC3Filter::Transform(IMediaSample* pSample, IMediaSample* pOutSampl const GUID* majortype = &m_pOutput->CurrentMediaType().majortype;
const GUID* subtype = &m_pOutput->CurrentMediaType().subtype;
- if(*majortype == MEDIATYPE_DVD_ENCRYPTED_PACK) {
- if(size < curlen + 32 + 3) {
+ if (*majortype == MEDIATYPE_DVD_ENCRYPTED_PACK) {
+ if (size < curlen + 32 + 3) {
return E_FAIL;
}
@@ -184,8 +184,8 @@ HRESULT CAVI2AC3Filter::Transform(IMediaSample* pSample, IMediaSample* pOutSampl majortype = &MEDIATYPE_MPEG2_PES;
}
- if(*majortype == MEDIATYPE_MPEG2_PES) {
- if(size < curlen + 20 + 3) {
+ if (*majortype == MEDIATYPE_MPEG2_PES) {
+ if (size < curlen + 20 + 3) {
return E_FAIL;
}
@@ -205,22 +205,22 @@ HRESULT CAVI2AC3Filter::Transform(IMediaSample* pSample, IMediaSample* pOutSampl Private1Header[4] = (packetlen>>8)&0xff;
Private1Header[5] = packetlen&0xff;
- if(*subtype == MEDIASUBTYPE_DTS) {
+ if (*subtype == MEDIASUBTYPE_DTS) {
Private1Header[17] += 8;
}
- if(*subtype == MEDIASUBTYPE_DOLBY_AC3) {
- for(int i = 0; i < curlen; i++) {
- if(*(DWORD*)&pIn[i] == 0x770B) {
+ if (*subtype == MEDIASUBTYPE_DOLBY_AC3) {
+ for (int i = 0; i < curlen; i++) {
+ if (*(DWORD*)&pIn[i] == 0x770B) {
i++;
Private1Header[19] = (i>>8)&0xff;
Private1Header[20] = i&0xff;
break;
}
}
- } else if(*subtype == MEDIASUBTYPE_DTS) {
- for(int i = 0; i < curlen; i++) {
- if(*(DWORD*)&pIn[i] == 0x0180FE7F) {
+ } else if (*subtype == MEDIASUBTYPE_DTS) {
+ for (int i = 0; i < curlen; i++) {
+ if (*(DWORD*)&pIn[i] == 0x0180FE7F) {
i++;
Private1Header[19] = (i>>8)&0xff;
Private1Header[20] = i&0xff;
@@ -235,8 +235,8 @@ HRESULT CAVI2AC3Filter::Transform(IMediaSample* pSample, IMediaSample* pOutSampl majortype = &MEDIATYPE_Audio;
}
- if(*majortype == MEDIATYPE_Audio) {
- if(size < curlen) {
+ if (*majortype == MEDIATYPE_Audio) {
+ if (size < curlen) {
return E_FAIL;
}
memcpy(pOut, pIn, curlen);
@@ -254,8 +254,8 @@ HRESULT CAVI2AC3Filter::Transform(IMediaSample* pSample, IMediaSample* pOutSampl const GUID* majortype = &m_pOutput->CurrentMediaType().majortype;
const GUID* subtype = &m_pOutput->CurrentMediaType().subtype;
- if(*majortype == MEDIATYPE_DVD_ENCRYPTED_PACK) {
- if(size < len + 32 + 3) {
+ if (*majortype == MEDIATYPE_DVD_ENCRYPTED_PACK) {
+ if (size < len + 32 + 3) {
return E_FAIL;
}
@@ -271,8 +271,8 @@ HRESULT CAVI2AC3Filter::Transform(IMediaSample* pSample, IMediaSample* pOutSampl majortype = &MEDIATYPE_MPEG2_PES;
}
- if(*majortype == MEDIATYPE_MPEG2_PES) {
- if(size < len + 20 + 3) {
+ if (*majortype == MEDIATYPE_MPEG2_PES) {
+ if (size < len + 20 + 3) {
return E_FAIL;
}
@@ -292,7 +292,7 @@ HRESULT CAVI2AC3Filter::Transform(IMediaSample* pSample, IMediaSample* pOutSampl Private1Header[4] = (packetlen>>8)&0xff;
Private1Header[5] = packetlen&0xff;
- if(*subtype == MEDIASUBTYPE_DTS) {
+ if (*subtype == MEDIASUBTYPE_DTS) {
Private1Header[17] += 8;
}
@@ -302,8 +302,8 @@ HRESULT CAVI2AC3Filter::Transform(IMediaSample* pSample, IMediaSample* pOutSampl majortype = &MEDIATYPE_Audio;
}
- if(*majortype == MEDIATYPE_Audio) {
- if(size < len) {
+ if (*majortype == MEDIATYPE_Audio) {
+ if (size < len) {
return E_FAIL;
}
@@ -375,13 +375,13 @@ HRESULT CAVI2AC3Filter::CheckTransform(const CMediaType* mtIn, const CMediaType* HRESULT CAVI2AC3Filter::DecideBufferSize(IMemAllocator* pAllocator, ALLOCATOR_PROPERTIES* pProperties)
{
- if(m_pInput->IsConnected() == FALSE) {
+ if (m_pInput->IsConnected() == FALSE) {
return E_UNEXPECTED;
}
CComPtr<IMemAllocator> pAllocatorIn;
m_pInput->GetAllocator(&pAllocatorIn);
- if(!pAllocatorIn) {
+ if (!pAllocatorIn) {
return E_UNEXPECTED;
}
@@ -394,7 +394,7 @@ HRESULT CAVI2AC3Filter::DecideBufferSize(IMemAllocator* pAllocator, ALLOCATOR_PR HRESULT hr;
ALLOCATOR_PROPERTIES Actual;
- if(FAILED(hr = pAllocator->SetProperties(pProperties, &Actual))) {
+ if (FAILED(hr = pAllocator->SetProperties(pProperties, &Actual))) {
return hr;
}
@@ -405,7 +405,7 @@ HRESULT CAVI2AC3Filter::DecideBufferSize(IMemAllocator* pAllocator, ALLOCATOR_PR HRESULT CAVI2AC3Filter::GetMediaType(int iPosition, CMediaType* pMediaType)
{
- if(m_pInput->IsConnected() == FALSE) {
+ if (m_pInput->IsConnected() == FALSE) {
return E_UNEXPECTED;
}
@@ -413,11 +413,11 @@ HRESULT CAVI2AC3Filter::GetMediaType(int iPosition, CMediaType* pMediaType) const GUID& subtype = m_pInput->CurrentMediaType().subtype;
UNUSED_ALWAYS(majortype);
- if(CheckAC3(&m_pInput->CurrentMediaType()) || CheckDTS(&m_pInput->CurrentMediaType())) {
- if(iPosition < 0) {
+ if (CheckAC3(&m_pInput->CurrentMediaType()) || CheckDTS(&m_pInput->CurrentMediaType())) {
+ if (iPosition < 0) {
return E_INVALIDARG;
}
- if(iPosition > 0) {
+ if (iPosition > 0) {
return VFW_S_NO_MORE_ITEMS;
}
@@ -433,24 +433,24 @@ HRESULT CAVI2AC3Filter::GetMediaType(int iPosition, CMediaType* pMediaType) wfe->nChannels = 2;
wfe->nBlockAlign = 1;
- if(subtype == MEDIASUBTYPE_DOLBY_AC3) {
+ if (subtype == MEDIASUBTYPE_DOLBY_AC3) {
pMediaType->subtype = MEDIASUBTYPE_WAVE_DOLBY_AC3;
wfe->wFormatTag = WAVE_FORMAT_DOLBY_AC3;
- } else if(subtype == MEDIASUBTYPE_DTS) {
+ } else if (subtype == MEDIASUBTYPE_DTS) {
pMediaType->subtype = MEDIASUBTYPE_WAVE_DTS;
wfe->wFormatTag = WAVE_FORMAT_DVD_DTS;
} else {
return E_INVALIDARG;
}
- } else if(CheckWAVEAC3(&m_pInput->CurrentMediaType()) || CheckWAVEDTS(&m_pInput->CurrentMediaType())) {
- if(iPosition < 0) {
+ } else if (CheckWAVEAC3(&m_pInput->CurrentMediaType()) || CheckWAVEDTS(&m_pInput->CurrentMediaType())) {
+ if (iPosition < 0) {
return E_INVALIDARG;
}
- if(iPosition > 4) {
+ if (iPosition > 4) {
return VFW_S_NO_MORE_ITEMS;
}
- if(subtype == MEDIASUBTYPE_WAVE_DOLBY_AC3) {
+ if (subtype == MEDIASUBTYPE_WAVE_DOLBY_AC3) {
pMediaType->subtype = MEDIASUBTYPE_DOLBY_AC3;
pMediaType->formattype = FORMAT_WaveFormatEx;
@@ -464,7 +464,7 @@ HRESULT CAVI2AC3Filter::GetMediaType(int iPosition, CMediaType* pMediaType) wfe->wfx.nSamplesPerSec = 48000;
wfe->wfx.nChannels = 6;
wfe->bBigEndian = TRUE;
- } else if(subtype == MEDIASUBTYPE_WAVE_DTS) {
+ } else if (subtype == MEDIASUBTYPE_WAVE_DTS) {
pMediaType->subtype = MEDIASUBTYPE_DTS;
pMediaType->formattype = FORMAT_WaveFormatEx;
@@ -479,7 +479,7 @@ HRESULT CAVI2AC3Filter::GetMediaType(int iPosition, CMediaType* pMediaType) return E_INVALIDARG;
}
- switch(iPosition) {
+ switch (iPosition) {
case 0:
pMediaType->majortype = MEDIATYPE_Audio;
break;
diff --git a/src/filters/transform/BaseVideoFilter/BaseVideoFilter.cpp b/src/filters/transform/BaseVideoFilter/BaseVideoFilter.cpp index efc3db23d..d3f08c13a 100644 --- a/src/filters/transform/BaseVideoFilter/BaseVideoFilter.cpp +++ b/src/filters/transform/BaseVideoFilter/BaseVideoFilter.cpp @@ -37,23 +37,23 @@ CBaseVideoFilter::CBaseVideoFilter(TCHAR* pName, LPUNKNOWN lpunk, HRESULT* phr, : CTransformFilter(pName, lpunk, clsid)
, m_cBuffers(cBuffers)
{
- if(phr) {
+ if (phr) {
*phr = S_OK;
}
m_pInput = DNew CBaseVideoInputPin(NAME("CBaseVideoInputPin"), this, phr, L"Video");
- if(!m_pInput) {
+ if (!m_pInput) {
*phr = E_OUTOFMEMORY;
}
- if(FAILED(*phr)) {
+ if (FAILED(*phr)) {
return;
}
m_pOutput = DNew CBaseVideoOutputPin(NAME("CBaseVideoOutputPin"), this, phr, L"Output");
- if(!m_pOutput) {
+ if (!m_pOutput) {
*phr = E_OUTOFMEMORY;
}
- if(FAILED(*phr)) {
+ if (FAILED(*phr)) {
delete m_pInput, m_pInput = NULL;
return;
}
@@ -84,7 +84,7 @@ int CBaseVideoFilter::GetPinCount() CBasePin* CBaseVideoFilter::GetPin(int n)
{
- switch(n) {
+ switch (n) {
case 0:
return m_pInput;
case 1:
@@ -105,18 +105,18 @@ HRESULT CBaseVideoFilter::Receive(IMediaSample* pIn) HRESULT hr;
AM_SAMPLE2_PROPERTIES* const pProps = m_pInput->SampleProps();
- if(pProps->dwStreamId != AM_STREAM_MEDIA) {
+ if (pProps->dwStreamId != AM_STREAM_MEDIA) {
return m_pOutput->Deliver(pIn);
}
AM_MEDIA_TYPE* pmt;
- if(SUCCEEDED(pIn->GetMediaType(&pmt)) && pmt) {
+ if (SUCCEEDED(pIn->GetMediaType(&pmt)) && pmt) {
CMediaType mt(*pmt);
m_pInput->SetMediaType(&mt);
DeleteMediaType(pmt);
}
- if(FAILED(hr = Transform(pIn))) {
+ if (FAILED(hr = Transform(pIn))) {
return hr;
}
@@ -129,16 +129,16 @@ HRESULT CBaseVideoFilter::GetDeliveryBuffer(int w, int h, IMediaSample** ppOut) HRESULT hr;
- if(FAILED(hr = ReconnectOutput(w, h))) {
+ if (FAILED(hr = ReconnectOutput(w, h))) {
return hr;
}
- if(FAILED(hr = m_pOutput->GetDeliveryBuffer(ppOut, NULL, NULL, 0))) {
+ if (FAILED(hr = m_pOutput->GetDeliveryBuffer(ppOut, NULL, NULL, 0))) {
return hr;
}
AM_MEDIA_TYPE* pmt;
- if(SUCCEEDED((*ppOut)->GetMediaType(&pmt)) && pmt) {
+ if (SUCCEEDED((*ppOut)->GetMediaType(&pmt)) && pmt) {
CMediaType mt = *pmt;
m_pOutput->SetMediaType(&mt);
DeleteMediaType(pmt);
@@ -149,7 +149,7 @@ HRESULT CBaseVideoFilter::GetDeliveryBuffer(int w, int h, IMediaSample** ppOut) // FIXME: hell knows why but without this the overlay mixer starts very skippy
// (don't enable this for other renderers, the old for example will go crazy if you do)
- if(GetCLSID(m_pOutput->GetConnected()) == CLSID_OverlayMixer) {
+ if (GetCLSID(m_pOutput->GetConnected()) == CLSID_OverlayMixer) {
(*ppOut)->SetDiscontinuity(TRUE);
}
@@ -161,10 +161,10 @@ HRESULT CBaseVideoFilter::ReconnectOutput(int w, int h, bool bSendSample, int re CMediaType& mt = m_pOutput->CurrentMediaType();
bool m_update_aspect = false;
- if(f_need_set_aspect) {
+ if (f_need_set_aspect) {
int wout = 0, hout = 0, arxout = 0, aryout = 0;
ExtractDim(&mt, wout, hout, arxout, aryout);
- if(arxout != m_arx || aryout != m_ary) {
+ if (arxout != m_arx || aryout != m_ary) {
TRACE(_T("\nCBaseVideoFilter::ReconnectOutput; wout = %d, hout = %d, current = %dx%d, set = %dx%d\n"), wout, hout, arxout, aryout, m_arx, m_ary);
m_update_aspect = true;
}
@@ -174,7 +174,7 @@ HRESULT CBaseVideoFilter::ReconnectOutput(int w, int h, bool bSendSample, int re int h_org = m_h;
bool fForceReconnection = false;
- if(w != m_w || h != m_h) {
+ if (w != m_w || h != m_h) {
fForceReconnection = true;
m_w = w;
m_h = h;
@@ -182,15 +182,15 @@ HRESULT CBaseVideoFilter::ReconnectOutput(int w, int h, bool bSendSample, int re HRESULT hr = S_OK;
- if(m_update_aspect || fForceReconnection || m_w != m_wout || m_h != m_hout || m_arx != m_arxout || m_ary != m_aryout) {
- if(GetCLSID(m_pOutput->GetConnected()) == CLSID_VideoRenderer) {
+ if (m_update_aspect || fForceReconnection || m_w != m_wout || m_h != m_hout || m_arx != m_arxout || m_ary != m_aryout) {
+ if (GetCLSID(m_pOutput->GetConnected()) == CLSID_VideoRenderer) {
NotifyEvent(EC_ERRORABORT, 0, 0);
return E_FAIL;
}
BITMAPINFOHEADER* bmi = NULL;
- if(mt.formattype == FORMAT_VideoInfo) {
+ if (mt.formattype == FORMAT_VideoInfo) {
VIDEOINFOHEADER* vih = (VIDEOINFOHEADER*)mt.Format();
if (realWidth > 0 && realHeight > 0) {
SetRect(&vih->rcSource, 0, 0, realWidth, realHeight);
@@ -202,7 +202,7 @@ HRESULT CBaseVideoFilter::ReconnectOutput(int w, int h, bool bSendSample, int re bmi = &vih->bmiHeader;
bmi->biXPelsPerMeter = m_w * m_ary;
bmi->biYPelsPerMeter = m_h * m_arx;
- } else if(mt.formattype == FORMAT_VideoInfo2) {
+ } else if (mt.formattype == FORMAT_VideoInfo2) {
VIDEOINFOHEADER2* vih = (VIDEOINFOHEADER2*)mt.Format();
if (realWidth > 0 && realHeight > 0) {
SetRect(&vih->rcSource, 0, 0, realWidth, realHeight);
@@ -226,12 +226,12 @@ HRESULT CBaseVideoFilter::ReconnectOutput(int w, int h, bool bSendSample, int re ASSERT(SUCCEEDED(hr)); // should better not fail, after all "mt" is the current media type, just with a different resolution
HRESULT hr1 = 0;
CComPtr<IMediaSample> pOut;
- if(SUCCEEDED(hr1 = m_pOutput->GetConnected()->ReceiveConnection(m_pOutput, &mt))) {
+ if (SUCCEEDED(hr1 = m_pOutput->GetConnected()->ReceiveConnection(m_pOutput, &mt))) {
if (bSendSample) {
HRESULT hr2 = 0;
if (SUCCEEDED(hr2 = m_pOutput->GetDeliveryBuffer(&pOut, NULL, NULL, 0))) {
AM_MEDIA_TYPE* pmt;
- if(SUCCEEDED(pOut->GetMediaType(&pmt)) && pmt) {
+ if (SUCCEEDED(pOut->GetMediaType(&pmt)) && pmt) {
CMediaType mt = *pmt;
m_pOutput->SetMediaType(&mt);
DeleteMediaType(pmt);
@@ -275,19 +275,19 @@ HRESULT CBaseVideoFilter::CopyBuffer(BYTE* pOut, BYTE** ppIn, int w, int h, int int pitchOut = 0;
- if(bihOut.biCompression == BI_RGB || bihOut.biCompression == BI_BITFIELDS) {
+ if (bihOut.biCompression == BI_RGB || bihOut.biCompression == BI_BITFIELDS) {
pitchOut = bihOut.biWidth*bihOut.biBitCount>>3;
- if(bihOut.biHeight > 0) {
+ if (bihOut.biHeight > 0) {
pOut += pitchOut*(h-1);
pitchOut = -pitchOut;
- if(h < 0) {
+ if (h < 0) {
h = -h;
}
}
}
- if(h < 0) {
+ if (h < 0) {
h = -h;
ppIn[0] += pitchIn*(h-1);
ppIn[1] += (pitchIn>>1)*((h>>1)-1);
@@ -295,12 +295,12 @@ HRESULT CBaseVideoFilter::CopyBuffer(BYTE* pOut, BYTE** ppIn, int w, int h, int pitchIn = -pitchIn;
}
- if(subtype == MEDIASUBTYPE_I420 || subtype == MEDIASUBTYPE_IYUV || subtype == MEDIASUBTYPE_YV12) {
+ if (subtype == MEDIASUBTYPE_I420 || subtype == MEDIASUBTYPE_IYUV || subtype == MEDIASUBTYPE_YV12) {
BYTE* pIn = ppIn[0];
BYTE* pInU = ppIn[1];
BYTE* pInV = ppIn[2];
- if(subtype == MEDIASUBTYPE_YV12) {
+ if (subtype == MEDIASUBTYPE_YV12) {
BYTE* tmp = pInU;
pInU = pInV;
pInV = tmp;
@@ -309,7 +309,7 @@ HRESULT CBaseVideoFilter::CopyBuffer(BYTE* pOut, BYTE** ppIn, int w, int h, int BYTE* pOutU = pOut + bihOut.biWidth*h;
BYTE* pOutV = pOut + bihOut.biWidth*h*5/4;
- if(bihOut.biCompression == '21VY') {
+ if (bihOut.biCompression == '21VY') {
BYTE* tmp = pOutU;
pOutU = pOutV;
pOutV = tmp;
@@ -317,43 +317,43 @@ HRESULT CBaseVideoFilter::CopyBuffer(BYTE* pOut, BYTE** ppIn, int w, int h, int ASSERT(w <= abs(pitchIn));
- if(bihOut.biCompression == '2YUY') {
+ if (bihOut.biCompression == '2YUY') {
if (!fInterlaced) {
BitBltFromI420ToYUY2(w, h, pOut, bihOut.biWidth*2, pIn, pInU, pInV, pitchIn);
} else {
BitBltFromI420ToYUY2Interlaced(w, h, pOut, bihOut.biWidth*2, pIn, pInU, pInV, pitchIn);
}
- } else if(bihOut.biCompression == '024I' || bihOut.biCompression == 'VUYI' || bihOut.biCompression == '21VY') {
+ } else if (bihOut.biCompression == '024I' || bihOut.biCompression == 'VUYI' || bihOut.biCompression == '21VY') {
BitBltFromI420ToI420(w, h, pOut, pOutU, pOutV, bihOut.biWidth, pIn, pInU, pInV, pitchIn);
- } else if(bihOut.biCompression == BI_RGB || bihOut.biCompression == BI_BITFIELDS) {
- if(!BitBltFromI420ToRGB(w, h, pOut, pitchOut, bihOut.biBitCount, pIn, pInU, pInV, pitchIn)) {
- for(int y = 0; y < h; y++, pOut += pitchOut) {
+ } else if (bihOut.biCompression == BI_RGB || bihOut.biCompression == BI_BITFIELDS) {
+ if (!BitBltFromI420ToRGB(w, h, pOut, pitchOut, bihOut.biBitCount, pIn, pInU, pInV, pitchIn)) {
+ for (int y = 0; y < h; y++, pOut += pitchOut) {
memset(pOut, 0, pitchOut);
}
}
}
- } else if(subtype == MEDIASUBTYPE_YUY2) {
- if(bihOut.biCompression == '2YUY') {
+ } else if (subtype == MEDIASUBTYPE_YUY2) {
+ if (bihOut.biCompression == '2YUY') {
BitBltFromYUY2ToYUY2(w, h, pOut, bihOut.biWidth*2, ppIn[0], pitchIn);
- } else if(bihOut.biCompression == BI_RGB || bihOut.biCompression == BI_BITFIELDS) {
- if(!BitBltFromYUY2ToRGB(w, h, pOut, pitchOut, bihOut.biBitCount, ppIn[0], pitchIn)) {
- for(int y = 0; y < h; y++, pOut += pitchOut) {
+ } else if (bihOut.biCompression == BI_RGB || bihOut.biCompression == BI_BITFIELDS) {
+ if (!BitBltFromYUY2ToRGB(w, h, pOut, pitchOut, bihOut.biBitCount, ppIn[0], pitchIn)) {
+ for (int y = 0; y < h; y++, pOut += pitchOut) {
memset(pOut, 0, pitchOut);
}
}
}
- } else if(subtype == MEDIASUBTYPE_ARGB32 || subtype == MEDIASUBTYPE_RGB32 || subtype == MEDIASUBTYPE_RGB24 || subtype == MEDIASUBTYPE_RGB565) {
+ } else if (subtype == MEDIASUBTYPE_ARGB32 || subtype == MEDIASUBTYPE_RGB32 || subtype == MEDIASUBTYPE_RGB24 || subtype == MEDIASUBTYPE_RGB565) {
int sbpp =
subtype == MEDIASUBTYPE_ARGB32 || subtype == MEDIASUBTYPE_RGB32 ? 32 :
subtype == MEDIASUBTYPE_RGB24 ? 24 :
subtype == MEDIASUBTYPE_RGB565 ? 16 : 0;
- if(bihOut.biCompression == '2YUY') {
+ if (bihOut.biCompression == '2YUY') {
// TODO
// BitBltFromRGBToYUY2();
- } else if(bihOut.biCompression == BI_RGB || bihOut.biCompression == BI_BITFIELDS) {
- if(!BitBltFromRGBToRGB(w, h, pOut, pitchOut, bihOut.biBitCount, ppIn[0], pitchIn, sbpp)) {
- for(int y = 0; y < h; y++, pOut += pitchOut) {
+ } else if (bihOut.biCompression == BI_RGB || bihOut.biCompression == BI_BITFIELDS) {
+ if (!BitBltFromRGBToRGB(w, h, pOut, pitchOut, bihOut.biBitCount, ppIn[0], pitchIn, sbpp)) {
+ for (int y = 0; y < h; y++, pOut += pitchOut) {
memset(pOut, 0, pitchOut);
}
}
@@ -388,15 +388,15 @@ HRESULT CBaseVideoFilter::CheckInputType(const CMediaType* mtIn) HRESULT CBaseVideoFilter::CheckTransform(const CMediaType* mtIn, const CMediaType* mtOut)
{
- if(FAILED(CheckInputType(mtIn)) || mtOut->majortype != MEDIATYPE_Video) {
+ if (FAILED(CheckInputType(mtIn)) || mtOut->majortype != MEDIATYPE_Video) {
return VFW_E_TYPE_NOT_ACCEPTED;
}
- if(mtIn->majortype == MEDIATYPE_Video
+ if (mtIn->majortype == MEDIATYPE_Video
&& (mtIn->subtype == MEDIASUBTYPE_YV12
|| mtIn->subtype == MEDIASUBTYPE_I420
|| mtIn->subtype == MEDIASUBTYPE_IYUV)) {
- if(mtOut->subtype != MEDIASUBTYPE_YV12
+ if (mtOut->subtype != MEDIASUBTYPE_YV12
&& mtOut->subtype != MEDIASUBTYPE_I420
&& mtOut->subtype != MEDIASUBTYPE_IYUV
&& mtOut->subtype != MEDIASUBTYPE_YUY2
@@ -406,21 +406,21 @@ HRESULT CBaseVideoFilter::CheckTransform(const CMediaType* mtIn, const CMediaTyp && mtOut->subtype != MEDIASUBTYPE_RGB565) {
return VFW_E_TYPE_NOT_ACCEPTED;
}
- } else if(mtIn->majortype == MEDIATYPE_Video
- && (mtIn->subtype == MEDIASUBTYPE_YUY2)) {
- if(mtOut->subtype != MEDIASUBTYPE_YUY2
+ } else if (mtIn->majortype == MEDIATYPE_Video
+ && (mtIn->subtype == MEDIASUBTYPE_YUY2)) {
+ if (mtOut->subtype != MEDIASUBTYPE_YUY2
&& mtOut->subtype != MEDIASUBTYPE_ARGB32
&& mtOut->subtype != MEDIASUBTYPE_RGB32
&& mtOut->subtype != MEDIASUBTYPE_RGB24
&& mtOut->subtype != MEDIASUBTYPE_RGB565) {
return VFW_E_TYPE_NOT_ACCEPTED;
}
- } else if(mtIn->majortype == MEDIATYPE_Video
- && (mtIn->subtype == MEDIASUBTYPE_ARGB32
- || mtIn->subtype == MEDIASUBTYPE_RGB32
- || mtIn->subtype == MEDIASUBTYPE_RGB24
- || mtIn->subtype == MEDIASUBTYPE_RGB565)) {
- if(mtOut->subtype != MEDIASUBTYPE_ARGB32
+ } else if (mtIn->majortype == MEDIATYPE_Video
+ && (mtIn->subtype == MEDIASUBTYPE_ARGB32
+ || mtIn->subtype == MEDIASUBTYPE_RGB32
+ || mtIn->subtype == MEDIASUBTYPE_RGB24
+ || mtIn->subtype == MEDIASUBTYPE_RGB565)) {
+ if (mtOut->subtype != MEDIASUBTYPE_ARGB32
&& mtOut->subtype != MEDIASUBTYPE_RGB32
&& mtOut->subtype != MEDIASUBTYPE_RGB24
&& mtOut->subtype != MEDIASUBTYPE_RGB565) {
@@ -443,7 +443,7 @@ HRESULT CBaseVideoFilter::CheckOutputType(const CMediaType& mtOut) HRESULT CBaseVideoFilter::DecideBufferSize(IMemAllocator* pAllocator, ALLOCATOR_PROPERTIES* pProperties)
{
- if(m_pInput->IsConnected() == FALSE) {
+ if (m_pInput->IsConnected() == FALSE) {
return E_UNEXPECTED;
}
@@ -460,7 +460,7 @@ HRESULT CBaseVideoFilter::DecideBufferSize(IMemAllocator* pAllocator, ALLOCATOR_ HRESULT hr;
ALLOCATOR_PROPERTIES Actual;
- if(FAILED(hr = pAllocator->SetProperties(pProperties, &Actual))) {
+ if (FAILED(hr = pAllocator->SetProperties(pProperties, &Actual))) {
return hr;
}
@@ -497,7 +497,7 @@ HRESULT CBaseVideoFilter::GetMediaType(int iPosition, CMediaType* pmt) VIDEO_OUTPUT_FORMATS* fmts;
int nFormatCount;
- if(m_pInput->IsConnected() == FALSE) {
+ if (m_pInput->IsConnected() == FALSE) {
return E_UNEXPECTED;
}
@@ -508,20 +508,20 @@ HRESULT CBaseVideoFilter::GetMediaType(int iPosition, CMediaType* pmt) bool fFoundDVDNavigator = false;
CComPtr<IBaseFilter> pBF = this;
CComPtr<IPin> pPin = m_pInput;
- for(; !fFoundDVDNavigator && (pBF = GetUpStreamFilter(pBF, pPin)); pPin = GetFirstPin(pBF)) {
+ for (; !fFoundDVDNavigator && (pBF = GetUpStreamFilter(pBF, pPin)); pPin = GetFirstPin(pBF)) {
fFoundDVDNavigator = !!(GetCLSID(pBF) == CLSID_DVDNavigator);
}
- if(fFoundDVDNavigator || m_pInput->CurrentMediaType().formattype == FORMAT_VideoInfo2) {
+ if (fFoundDVDNavigator || m_pInput->CurrentMediaType().formattype == FORMAT_VideoInfo2) {
iPosition = iPosition*2;
}
//
GetOutputFormats (nFormatCount, &fmts);
- if(iPosition < 0) {
+ if (iPosition < 0) {
return E_INVALIDARG;
}
- if(iPosition >= 2*nFormatCount) {
+ if (iPosition >= 2*nFormatCount) {
return VFW_S_NO_MORE_ITEMS;
}
@@ -544,7 +544,7 @@ HRESULT CBaseVideoFilter::GetMediaType(int iPosition, CMediaType* pmt) bihOut.biCompression = fmts[iPosition/2].biCompression;
bihOut.biSizeImage = w*h*bihOut.biBitCount>>3;
- if(iPosition&1) {
+ if (iPosition&1) {
pmt->formattype = FORMAT_VideoInfo;
VIDEOINFOHEADER* vih = (VIDEOINFOHEADER*)pmt->AllocFormatBuffer(sizeof(VIDEOINFOHEADER));
memset(vih, 0, sizeof(VIDEOINFOHEADER));
@@ -558,7 +558,7 @@ HRESULT CBaseVideoFilter::GetMediaType(int iPosition, CMediaType* pmt) vih->bmiHeader = bihOut;
vih->dwPictAspectRatioX = arx;
vih->dwPictAspectRatioY = ary;
- if(IsVideoInterlaced()) {
+ if (IsVideoInterlaced()) {
vih->dwInterlaceFlags = AMINTERLACE_IsInterlaced | AMINTERLACE_DisplayModeBobOrWeave;
}
}
@@ -599,7 +599,7 @@ HRESULT CBaseVideoFilter::GetMediaType(int iPosition, CMediaType* pmt) HRESULT CBaseVideoFilter::SetMediaType(PIN_DIRECTION dir, const CMediaType* pmt)
{
- if(dir == PINDIR_INPUT) {
+ if (dir == PINDIR_INPUT) {
m_w = m_h = m_arx = m_ary = 0;
ExtractDim(pmt, m_w, m_h, m_arx, m_ary);
m_win = m_w;
@@ -612,18 +612,18 @@ HRESULT CBaseVideoFilter::SetMediaType(PIN_DIRECTION dir, const CMediaType* pmt) GetOutputSize(m_w, m_h, m_arx, m_ary, RealWidth, RealHeight, vsfilter);
DWORD a = m_arx, b = m_ary;
- while(a) {
+ while (a) {
int tmp = a;
a = b % tmp;
b = tmp;
}
- if(b) {
+ if (b) {
m_arx /= b, m_ary /= b;
}
- } else if(dir == PINDIR_OUTPUT) {
+ } else if (dir == PINDIR_OUTPUT) {
int wout = 0, hout = 0, arxout = 0, aryout = 0;
ExtractDim(pmt, wout, hout, arxout, aryout);
- if(m_w == wout && m_h == hout && m_arx == arxout && m_ary == aryout) {
+ if (m_w == wout && m_h == hout && m_arx == arxout && m_ary == aryout) {
m_wout = wout;
m_hout = hout;
m_arxout = arxout;
@@ -641,7 +641,7 @@ HRESULT CBaseVideoFilter::SetMediaType(PIN_DIRECTION dir, const CMediaType* pmt) CBaseVideoInputAllocator::CBaseVideoInputAllocator(HRESULT* phr)
: CMemAllocator(NAME("CBaseVideoInputAllocator"), NULL, phr)
{
- if(phr) {
+ if (phr) {
*phr = S_OK;
}
}
@@ -653,13 +653,13 @@ void CBaseVideoInputAllocator::SetMediaType(const CMediaType& mt) STDMETHODIMP CBaseVideoInputAllocator::GetBuffer(IMediaSample** ppBuffer, REFERENCE_TIME* pStartTime, REFERENCE_TIME* pEndTime, DWORD dwFlags)
{
- if(!m_bCommitted) {
+ if (!m_bCommitted) {
return VFW_E_NOT_COMMITTED;
}
HRESULT hr = __super::GetBuffer(ppBuffer, pStartTime, pEndTime, dwFlags);
- if(SUCCEEDED(hr) && m_mt.majortype != GUID_NULL) {
+ if (SUCCEEDED(hr) && m_mt.majortype != GUID_NULL) {
(*ppBuffer)->SetMediaType(&m_mt);
m_mt.majortype = GUID_NULL;
}
@@ -686,7 +686,7 @@ STDMETHODIMP CBaseVideoInputPin::GetAllocator(IMemAllocator** ppAllocator) {
CheckPointer(ppAllocator, E_POINTER);
- if(m_pAllocator == NULL) {
+ if (m_pAllocator == NULL) {
HRESULT hr = S_OK;
m_pAllocator = DNew CBaseVideoInputAllocator(&hr);
m_pAllocator->AddRef();
@@ -701,34 +701,34 @@ STDMETHODIMP CBaseVideoInputPin::ReceiveConnection(IPin* pConnector, const AM_ME {
CAutoLock cObjectLock(m_pLock);
- if(m_Connected) {
+ if (m_Connected) {
CMediaType mt(*pmt);
- if(FAILED(CheckMediaType(&mt))) {
+ if (FAILED(CheckMediaType(&mt))) {
return VFW_E_TYPE_NOT_ACCEPTED;
}
ALLOCATOR_PROPERTIES props, actual;
CComPtr<IMemAllocator> pMemAllocator;
- if(FAILED(GetAllocator(&pMemAllocator))
+ if (FAILED(GetAllocator(&pMemAllocator))
|| FAILED(pMemAllocator->Decommit())
|| FAILED(pMemAllocator->GetProperties(&props))) {
return E_FAIL;
}
BITMAPINFOHEADER bih;
- if(ExtractBIH(pmt, &bih) && bih.biSizeImage) {
+ if (ExtractBIH(pmt, &bih) && bih.biSizeImage) {
props.cbBuffer = bih.biSizeImage;
}
- if(FAILED(pMemAllocator->SetProperties(&props, &actual))
+ if (FAILED(pMemAllocator->SetProperties(&props, &actual))
|| FAILED(pMemAllocator->Commit())
|| props.cbBuffer != actual.cbBuffer) {
return E_FAIL;
}
- if(m_pAllocator) {
+ if (m_pAllocator) {
m_pAllocator->SetMediaType(mt);
}
@@ -751,9 +751,9 @@ CBaseVideoOutputPin::CBaseVideoOutputPin(TCHAR* pObjectName, CBaseVideoFilter* p HRESULT CBaseVideoOutputPin::CheckMediaType(const CMediaType* mtOut)
{
- if(IsConnected()) {
+ if (IsConnected()) {
HRESULT hr = (static_cast<CBaseVideoFilter*>(m_pFilter))->CheckOutputType(*mtOut);
- if(FAILED(hr)) {
+ if (FAILED(hr)) {
return hr;
}
}
diff --git a/src/filters/transform/BufferFilter/BufferFilter.cpp b/src/filters/transform/BufferFilter/BufferFilter.cpp index 51f021b8a..9c624f96c 100644 --- a/src/filters/transform/BufferFilter/BufferFilter.cpp +++ b/src/filters/transform/BufferFilter/BufferFilter.cpp @@ -76,24 +76,24 @@ CBufferFilter::CBufferFilter(LPUNKNOWN lpunk, HRESULT* phr) do {
m_pInput = DNew CTransformInputPin(NAME("Transform input pin"), this, &hr, L"In");
- if(!m_pInput) {
+ if (!m_pInput) {
hr = E_OUTOFMEMORY;
}
- if(FAILED(hr)) {
+ if (FAILED(hr)) {
break;
}
m_pOutput = DNew CBufferFilterOutputPin(this, &hr);
- if(!m_pOutput) {
+ if (!m_pOutput) {
hr = E_OUTOFMEMORY;
}
- if(FAILED(hr)) {
+ if (FAILED(hr)) {
delete m_pInput, m_pInput = NULL;
break;
}
- } while(false);
+ } while (false);
- if(phr) {
+ if (phr) {
*phr = hr;
}
}
@@ -113,11 +113,11 @@ STDMETHODIMP CBufferFilter::NonDelegatingQueryInterface(REFIID riid, void** ppv) STDMETHODIMP CBufferFilter::SetBuffers(int nBuffers)
{
- if(!m_pOutput) {
+ if (!m_pOutput) {
return E_FAIL;
}
- if(m_pOutput->IsConnected()) { // TODO: allow "on-the-fly" changes
+ if (m_pOutput->IsConnected()) { // TODO: allow "on-the-fly" changes
return VFW_E_ALREADY_CONNECTED;
}
@@ -149,7 +149,7 @@ HRESULT CBufferFilter::Receive(IMediaSample* pSample) {
/* Check for other streams and pass them on */
AM_SAMPLE2_PROPERTIES* const pProps = m_pInput->SampleProps();
- if(pProps->dwStreamId != AM_STREAM_MEDIA) {
+ if (pProps->dwStreamId != AM_STREAM_MEDIA) {
return m_pOutput->Deliver(pSample);
}
@@ -162,7 +162,7 @@ HRESULT CBufferFilter::Receive(IMediaSample* pSample) // Set up the output sample
hr = InitializeOutputSample(pSample, &pOutSample);
- if(FAILED(hr)) {
+ if (FAILED(hr)) {
return hr;
}
@@ -176,13 +176,13 @@ HRESULT CBufferFilter::Receive(IMediaSample* pSample) // Stop the clock and log it (if PERF is defined)
MSR_STOP(m_idTransform);
- if(FAILED(hr)) {
+ if (FAILED(hr)) {
DbgLog((LOG_TRACE,1,TEXT("Error from transform")));
} else {
// the Transform() function can return S_FALSE to indicate that the
// sample should not be delivered; we only deliver the sample if it's
// really S_OK (same as NOERROR, of course.)
- if(hr == NOERROR) {
+ if (hr == NOERROR) {
hr = m_pOutput->Deliver(pOutSample);
m_bSampleSkipped = FALSE; // last thing no longer dropped
} else {
@@ -190,14 +190,14 @@ HRESULT CBufferFilter::Receive(IMediaSample* pSample) // We should return NOERROR from Receive() in this cause because returning S_FALSE
// from Receive() means that this is the end of the stream and no more data should
// be sent.
- if(S_FALSE == hr) {
+ if (S_FALSE == hr) {
// Release the sample before calling notify to avoid
// deadlocks if the sample holds a lock on the system
// such as DirectDraw buffers do
pOutSample->Release();
m_bSampleSkipped = TRUE;
- if(!m_bQualityChanged) {
+ if (!m_bQualityChanged) {
NotifyEvent(EC_QUALITY_CHANGE,0,0);
m_bQualityChanged = TRUE;
}
@@ -224,7 +224,7 @@ HRESULT CBufferFilter::Transform(IMediaSample* pIn, IMediaSample* pOut) long len = pIn->GetActualDataLength();
long size = pOut->GetSize();
- if(!pDataIn || !pDataOut || len > size || len <= 0) {
+ if (!pDataIn || !pDataOut || len > size || len <= 0) {
return S_FALSE;
}
@@ -247,13 +247,13 @@ HRESULT CBufferFilter::CheckTransform(const CMediaType* mtIn, const CMediaType* HRESULT CBufferFilter::DecideBufferSize(IMemAllocator* pAllocator, ALLOCATOR_PROPERTIES* pProperties)
{
- if(m_pInput->IsConnected() == FALSE) {
+ if (m_pInput->IsConnected() == FALSE) {
return E_UNEXPECTED;
}
CComPtr<IMemAllocator> pAllocatorIn;
m_pInput->GetAllocator(&pAllocatorIn);
- if(!pAllocatorIn) {
+ if (!pAllocatorIn) {
return E_UNEXPECTED;
}
@@ -263,7 +263,7 @@ HRESULT CBufferFilter::DecideBufferSize(IMemAllocator* pAllocator, ALLOCATOR_PRO HRESULT hr;
ALLOCATOR_PROPERTIES Actual;
- if(FAILED(hr = pAllocator->SetProperties(pProperties, &Actual))) {
+ if (FAILED(hr = pAllocator->SetProperties(pProperties, &Actual))) {
return hr;
}
@@ -274,15 +274,15 @@ HRESULT CBufferFilter::DecideBufferSize(IMemAllocator* pAllocator, ALLOCATOR_PRO HRESULT CBufferFilter::GetMediaType(int iPosition, CMediaType* pMediaType)
{
- if(m_pInput->IsConnected() == FALSE) {
+ if (m_pInput->IsConnected() == FALSE) {
return E_UNEXPECTED;
}
// TODO: offer all input types from upstream and allow reconnection at least in stopped state
- if(iPosition < 0) {
+ if (iPosition < 0) {
return E_INVALIDARG;
}
- if(iPosition > 0) {
+ if (iPosition > 0) {
return VFW_S_NO_MORE_ITEMS;
}
@@ -294,8 +294,8 @@ HRESULT CBufferFilter::GetMediaType(int iPosition, CMediaType* pMediaType) HRESULT CBufferFilter::StopStreaming()
{
CBufferFilterOutputPin* pPin = static_cast<CBufferFilterOutputPin*>(m_pOutput);
- if(m_pInput && pPin && pPin->m_pOutputQueue) {
- while(!m_pInput->IsFlushing() && pPin->m_pOutputQueue->GetQueueCount() > 0) {
+ if (m_pInput && pPin && pPin->m_pOutputQueue) {
+ while (!m_pInput->IsFlushing() && pPin->m_pOutputQueue->GetQueueCount() > 0) {
Sleep(50);
}
}
@@ -316,15 +316,15 @@ HRESULT CBufferFilterOutputPin::Active() {
CAutoLock lock_it(m_pLock);
- if(m_Connected && !m_pOutputQueue) {
+ if (m_Connected && !m_pOutputQueue) {
HRESULT hr = NOERROR;
m_pOutputQueue.Attach(DNew CBufferFilterOutputQueue(m_Connected, &hr));
- if(!m_pOutputQueue) {
+ if (!m_pOutputQueue) {
hr = E_OUTOFMEMORY;
}
- if(FAILED(hr)) {
+ if (FAILED(hr)) {
m_pOutputQueue.Free();
return hr;
}
@@ -342,7 +342,7 @@ HRESULT CBufferFilterOutputPin::Inactive() HRESULT CBufferFilterOutputPin::Deliver(IMediaSample* pMediaSample)
{
- if(!m_pOutputQueue) {
+ if (!m_pOutputQueue) {
return NOERROR;
}
pMediaSample->AddRef();
diff --git a/src/filters/transform/DeCSSFilter/DeCSSFilter.cpp b/src/filters/transform/DeCSSFilter/DeCSSFilter.cpp index 511d32613..6f5ddb799 100644 --- a/src/filters/transform/DeCSSFilter/DeCSSFilter.cpp +++ b/src/filters/transform/DeCSSFilter/DeCSSFilter.cpp @@ -80,19 +80,19 @@ public: // IKsPropertySet
STDMETHODIMP Set(REFGUID PropSet, ULONG Id, LPVOID InstanceData, ULONG InstanceLength, LPVOID PropertyData, ULONG DataLength) {
- if(CComQIPtr<IKsPropertySet> pKsPS = (static_cast<CDeCSSFilter*>(m_pFilter))->m_pOutput->GetConnected()) {
+ if (CComQIPtr<IKsPropertySet> pKsPS = (static_cast<CDeCSSFilter*>(m_pFilter))->m_pOutput->GetConnected()) {
return pKsPS->Set(PropSet, Id, InstanceData, InstanceLength, PropertyData, DataLength);
}
return E_NOTIMPL;
}
STDMETHODIMP Get(REFGUID PropSet, ULONG Id, LPVOID InstanceData, ULONG InstanceLength, LPVOID PropertyData, ULONG DataLength, ULONG* pBytesReturned) {
- if(CComQIPtr<IKsPropertySet> pKsPS = (static_cast<CDeCSSFilter*>(m_pFilter))->m_pOutput->GetConnected()) {
+ if (CComQIPtr<IKsPropertySet> pKsPS = (static_cast<CDeCSSFilter*>(m_pFilter))->m_pOutput->GetConnected()) {
return pKsPS->Get(PropSet, Id, InstanceData, InstanceLength, PropertyData, DataLength, pBytesReturned);
}
return E_NOTIMPL;
}
STDMETHODIMP QuerySupported(REFGUID PropSet, ULONG Id, ULONG* pTypeSupport) {
- if(CComQIPtr<IKsPropertySet> pKsPS = (static_cast<CDeCSSFilter*>(m_pFilter))->m_pOutput->GetConnected()) {
+ if (CComQIPtr<IKsPropertySet> pKsPS = (static_cast<CDeCSSFilter*>(m_pFilter))->m_pOutput->GetConnected()) {
return pKsPS->QuerySupported(PropSet, Id, pTypeSupport);
}
return E_NOTIMPL;
@@ -102,23 +102,23 @@ public: CDeCSSFilter::CDeCSSFilter(LPUNKNOWN lpunk, HRESULT* phr)
: CTransformFilter(NAME("CDeCSSFilter"), lpunk, __uuidof(this))
{
- if(phr) {
+ if (phr) {
*phr = S_OK;
}
m_pInput = DNew CKsPSInputPin(NAME("CKsPSInputPin"), this, phr, L"In");
- if(!m_pInput) {
+ if (!m_pInput) {
*phr = E_OUTOFMEMORY;
}
- if(FAILED(*phr)) {
+ if (FAILED(*phr)) {
return;
}
m_pOutput = DNew CTransformOutputPin(NAME("CTransformOutputPin"), this, phr, L"Out");
- if(!m_pOutput) {
+ if (!m_pOutput) {
*phr = E_OUTOFMEMORY;
}
- if(FAILED(*phr)) {
+ if (FAILED(*phr)) {
delete m_pInput, m_pInput = NULL;
return;
}
@@ -131,7 +131,7 @@ CDeCSSFilter::~CDeCSSFilter() HRESULT CDeCSSFilter::Transform(IMediaSample* pIn, IMediaSample* pOut)
{
AM_MEDIA_TYPE* pmt;
- if(SUCCEEDED(pIn->GetMediaType(&pmt)) && pmt) {
+ if (SUCCEEDED(pIn->GetMediaType(&pmt)) && pmt) {
CMediaType mt = *pmt;
m_pInput->SetMediaType(&mt);
mt.majortype = m_pOutput->CurrentMediaType().majortype;
@@ -149,36 +149,36 @@ HRESULT CDeCSSFilter::Transform(IMediaSample* pIn, IMediaSample* pOut) long len = pIn->GetActualDataLength();
long size = pOut->GetSize();
- if(len == 0 || pDataIn == NULL) { // format changes do not carry any data
+ if (len == 0 || pDataIn == NULL) { // format changes do not carry any data
pOut->SetActualDataLength(0);
return S_OK;
}
- if(m_pOutput->CurrentMediaType().majortype == MEDIATYPE_MPEG2_PES) {
- if(*(DWORD*)pDataIn == 0xBA010000) {
+ if (m_pOutput->CurrentMediaType().majortype == MEDIATYPE_MPEG2_PES) {
+ if (*(DWORD*)pDataIn == 0xBA010000) {
len -= 14;
pDataIn += 14;
- if(int stuffing = (pDataIn[-1]&7)) {
+ if (int stuffing = (pDataIn[-1]&7)) {
len -= stuffing;
pDataIn += stuffing;
}
}
- if(len <= 0) {
+ if (len <= 0) {
return S_FALSE;
}
- if(*(DWORD*)pDataIn == 0xBB010000) {
+ if (*(DWORD*)pDataIn == 0xBB010000) {
len -= 4;
pDataIn += 4;
int hdrlen = ((pDataIn[0]<<8)|pDataIn[1]) + 2;
len -= hdrlen;
pDataIn += hdrlen;
}
- if(len <= 0) {
+ if (len <= 0) {
return S_FALSE;
}
}
- if(!pDataIn || !pDataOut || len > size || len < 0) {
+ if (!pDataIn || !pDataOut || len > size || len < 0) {
return S_FALSE;
}
@@ -205,7 +205,7 @@ HRESULT CDeCSSFilter::CheckTransform(const CMediaType* mtIn, const CMediaType* m HRESULT CDeCSSFilter::DecideBufferSize(IMemAllocator* pAllocator, ALLOCATOR_PROPERTIES* pProperties)
{
- if(m_pInput->IsConnected() == FALSE) {
+ if (m_pInput->IsConnected() == FALSE) {
return E_UNEXPECTED;
}
@@ -216,7 +216,7 @@ HRESULT CDeCSSFilter::DecideBufferSize(IMemAllocator* pAllocator, ALLOCATOR_PROP HRESULT hr;
ALLOCATOR_PROPERTIES Actual;
- if(FAILED(hr = pAllocator->SetProperties(pProperties, &Actual))) {
+ if (FAILED(hr = pAllocator->SetProperties(pProperties, &Actual))) {
return hr;
}
@@ -227,22 +227,22 @@ HRESULT CDeCSSFilter::DecideBufferSize(IMemAllocator* pAllocator, ALLOCATOR_PROP HRESULT CDeCSSFilter::GetMediaType(int iPosition, CMediaType* pmt)
{
- if(m_pInput->IsConnected() == FALSE) {
+ if (m_pInput->IsConnected() == FALSE) {
return E_UNEXPECTED;
}
- if(iPosition < 0) {
+ if (iPosition < 0) {
return E_INVALIDARG;
}
- if(iPosition > 1) {
+ if (iPosition > 1) {
return VFW_S_NO_MORE_ITEMS;
}
CopyMediaType(pmt, &m_pInput->CurrentMediaType());
- if(iPosition == 0) {
+ if (iPosition == 0) {
pmt->majortype = MEDIATYPE_MPEG2_PACK;
}
- if(iPosition == 1) {
+ if (iPosition == 1) {
pmt->majortype = MEDIATYPE_MPEG2_PES;
}
diff --git a/src/filters/transform/MPCVideoDec/CpuId.cpp b/src/filters/transform/MPCVideoDec/CpuId.cpp index 52668fc03..c6d86f8f9 100644 --- a/src/filters/transform/MPCVideoDec/CpuId.cpp +++ b/src/filters/transform/MPCVideoDec/CpuId.cpp @@ -41,11 +41,11 @@ CCpuId::CCpuId(void)
{
-unsigned nHighestFeature;
-unsigned nHighestFeatureEx;
-int nBuff[4];
-char szMan[13];
-//char szFeatures[256];
+ unsigned nHighestFeature;
+ unsigned nHighestFeatureEx;
+ int nBuff[4];
+ char szMan[13];
+ //char szFeatures[256];
// Get CPU manufacturer and highest CPUID
__cpuid(nBuff, 0);
@@ -54,9 +54,9 @@ char szMan[13]; *(int*)&szMan[4] = nBuff[3];
*(int*)&szMan[8] = nBuff[2];
szMan[12] = 0;
- if(strcmp(szMan, "AuthenticAMD") == 0)
+ if (strcmp(szMan, "AuthenticAMD") == 0)
m_nType = PROCESSOR_AMD;
- else if(strcmp(szMan, "GenuineIntel") == 0)
+ else if (strcmp(szMan, "GenuineIntel") == 0)
m_nType = PROCESSOR_INTEL;
else
m_nType = PROCESSOR_UNKNOWN;
@@ -92,19 +92,19 @@ char szMan[13]; // Get CPU features
m_nCPUFeatures = 0;
//szFeatures[0] = 0;
- if(nHighestFeature >= 1)
+ if (nHighestFeature >= 1)
{
__cpuid(nBuff, 1);
- if(nBuff[3] & 1<<23) m_nCPUFeatures|=MPC_MM_MMX;
- if(nBuff[3] & 1<<25) m_nCPUFeatures|=MPC_MM_SSE;
- if(nBuff[3] & 1<<26) m_nCPUFeatures|=MPC_MM_SSE2;
- if(nBuff[2] & 1<<0) m_nCPUFeatures|=MPC_MM_SSE3;
+ if (nBuff[3] & 1<<23) m_nCPUFeatures|=MPC_MM_MMX;
+ if (nBuff[3] & 1<<25) m_nCPUFeatures|=MPC_MM_SSE;
+ if (nBuff[3] & 1<<26) m_nCPUFeatures|=MPC_MM_SSE2;
+ if (nBuff[2] & 1<<0) m_nCPUFeatures|=MPC_MM_SSE3;
// Intel specific:
- if(m_nType == PROCESSOR_INTEL)
+ if (m_nType == PROCESSOR_INTEL)
{
- if(nBuff[2] & 1<<9) m_nCPUFeatures|=MPC_MM_SSSE3;
- // if(nBuff[2] & 1<<7) strcat(szFeatures, "EST ");
+ if (nBuff[2] & 1<<9) m_nCPUFeatures|=MPC_MM_SSSE3;
+ //if (nBuff[2] & 1<<7) strcat(szFeatures, "EST ");
}
//if(nBuff[3] & 1<<28)
@@ -112,16 +112,16 @@ char szMan[13]; }
// AMD specific:
- if(m_nType == PROCESSOR_AMD)
+ if (m_nType == PROCESSOR_AMD)
{
// Get extended features
__cpuid(nBuff, 0x80000000);
- if(nHighestFeatureEx >= 0x80000001)
+ if (nHighestFeatureEx >= 0x80000001)
{
__cpuid(nBuff, 0x80000001);
- if(nBuff[3] & 1<<31) m_nCPUFeatures|=MPC_MM_3DNOW;
- // if(nBuff[3] & 1<<30) strcat(szFeatures, "Ex3DNow! ");
- if(nBuff[3] & 1<<22) m_nCPUFeatures|=MPC_MM_MMXEXT;
+ if (nBuff[3] & 1<<31) m_nCPUFeatures|=MPC_MM_3DNOW;
+ //if (nBuff[3] & 1<<30) strcat(szFeatures, "Ex3DNow! ");
+ if (nBuff[3] & 1<<22) m_nCPUFeatures|=MPC_MM_MMXEXT;
}
// Get level 1 cache size
diff --git a/src/filters/transform/MPCVideoDec/DXVADecoder.cpp b/src/filters/transform/MPCVideoDec/DXVADecoder.cpp index 50d29e964..30626d1d3 100644 --- a/src/filters/transform/MPCVideoDec/DXVADecoder.cpp +++ b/src/filters/transform/MPCVideoDec/DXVADecoder.cpp @@ -563,14 +563,14 @@ int CDXVADecoder::FindOldestFrame() void CDXVADecoder::SetTypeSpecificFlags(PICTURE_STORE* pPicture, IMediaSample* pMS)
{
- if(CComQIPtr<IMediaSample2> pMS2 = pMS) {
+ if (CComQIPtr<IMediaSample2> pMS2 = pMS) {
AM_SAMPLE2_PROPERTIES props;
- if(SUCCEEDED(pMS2->GetProperties(sizeof(props), (BYTE*)&props))) {
+ if (SUCCEEDED(pMS2->GetProperties(sizeof(props), (BYTE*)&props))) {
props.dwTypeSpecificFlags &= ~0x7f;
- if(pPicture->n1FieldType == PICT_FRAME) {
+ if (pPicture->n1FieldType == PICT_FRAME) {
props.dwTypeSpecificFlags |= AM_VIDEO_FLAG_WEAVE;
- } else if(pPicture->n1FieldType == PICT_TOP_FIELD) {
+ } else if (pPicture->n1FieldType == PICT_TOP_FIELD) {
props.dwTypeSpecificFlags |= AM_VIDEO_FLAG_FIELD1FIRST;
}
diff --git a/src/filters/transform/MPCVideoDec/DXVADecoderH264.cpp b/src/filters/transform/MPCVideoDec/DXVADecoderH264.cpp index 6035ab60b..b280363c7 100644 --- a/src/filters/transform/MPCVideoDec/DXVADecoderH264.cpp +++ b/src/filters/transform/MPCVideoDec/DXVADecoderH264.cpp @@ -59,7 +59,7 @@ void CDXVADecoderH264::Init() memset (&m_pSliceShort, 0, sizeof (DXVA_Slice_H264_Short)*MAX_SLICES);
m_DXVAPicParams.MbsConsecutiveFlag = 1;
- if(m_pFilter->GetPCIVendor() == PCIV_Intel) {
+ if (m_pFilter->GetPCIVendor() == PCIV_Intel) {
m_DXVAPicParams.Reserved16Bits = 0x534c;
} else {
m_DXVAPicParams.Reserved16Bits = 0;
@@ -101,7 +101,7 @@ void CDXVADecoderH264::CopyBitstream(BYTE* pDXVABuffer, BYTE* pBuffer, UINT& nSi #if 0
// Test to place Nal on multiple of 128 bytes (seems to be not necessary)
- if(!m_bUseLongSlice) {
+ if (!m_bUseLongSlice) {
while (Nalu.ReadNext()) {
switch (Nalu.GetType()) {
case NALU_TYPE_SLICE:
@@ -137,19 +137,19 @@ void CDXVADecoderH264::CopyBitstream(BYTE* pDXVABuffer, BYTE* pBuffer, UINT& nSi case NALU_TYPE_SLICE:
case NALU_TYPE_IDR:
// Skip the NALU if the data length is below 0
- if(Nalu.GetDataLength() < 0) {
+ if (Nalu.GetDataLength() < 0) {
break;
}
// For AVC1, put startcode 0x000001
- pDXVABuffer[0]=pDXVABuffer[1]=0;pDXVABuffer[2]=1;
- if(Nalu.GetDataLength() < 0)
+ pDXVABuffer[0]=pDXVABuffer[1]=0; pDXVABuffer[2]=1;
+ if (Nalu.GetDataLength() < 0)
break;
// Copy NALU
__try {
memcpy (pDXVABuffer+3, Nalu.GetDataBuffer(), Nalu.GetDataLength());
- }__except(EXCEPTION_EXECUTE_HANDLER) { break; }
+ } __except (EXCEPTION_EXECUTE_HANDLER) { break; }
// Update slice control buffer
nDxvaNalLength = Nalu.GetDataLength()+3;
@@ -200,7 +200,7 @@ HRESULT CDXVADecoderH264::DecodeFrame (BYTE* pDataIn, UINT nSize, REFERENCE_TIME if (m_nWaitingPics >= m_nPicEntryNumber) {
Flush();
m_bFlushed = false;
- return S_FALSE;
+ return S_FALSE;
}
if (FFH264DecodeBuffer (m_pFilter->GetAVCtx(), pDataIn, nSize, &nFramePOC, &nOutPOC, &rtOutStart) == -1) {
@@ -212,7 +212,7 @@ HRESULT CDXVADecoderH264::DecodeFrame (BYTE* pDataIn, UINT nSize, REFERENCE_TIME switch (Nalu.GetType()) {
case NALU_TYPE_SLICE:
case NALU_TYPE_IDR:
- if(m_bUseLongSlice) {
+ if (m_bUseLongSlice) {
m_pSliceLong[nSlices].BSNALunitDataLocation = nNalOffset;
m_pSliceLong[nSlices].SliceBytesInBuffer = Nalu.GetDataLength()+3; //.GetRoundedDataLength();
m_pSliceLong[nSlices].slice_id = nSlices;
diff --git a/src/filters/transform/MPCVideoDec/DXVADecoderVC1.cpp b/src/filters/transform/MPCVideoDec/DXVADecoderVC1.cpp index 55c993771..acca5ccc1 100644 --- a/src/filters/transform/MPCVideoDec/DXVADecoderVC1.cpp +++ b/src/filters/transform/MPCVideoDec/DXVADecoderVC1.cpp @@ -144,7 +144,7 @@ HRESULT CDXVADecoderVC1::DecodeFrame (BYTE* pDataIn, UINT nSize, REFERENCE_TIME CHECK_HR (EndFrame(nSurfaceIndex));
// ***************
- if(nFrameSize) { // Decoding Second Field
+ if (nFrameSize) { // Decoding Second Field
FFVC1UpdatePictureParam (&m_PictureParams, m_pFilter->GetAVCtx(), NULL, NULL, pDataIn, nSize, NULL, TRUE);
CHECK_HR (BeginFrame(nSurfaceIndex, pSampleToDeliver));
@@ -223,8 +223,8 @@ void CDXVADecoderVC1::SetExtraData (BYTE* pDataIn, UINT nSize) // iWMV9 - i9IRU - iOHIT - iINSO - iWMVA - 0 - 0 - 0 | Section 3.2.5
m_PictureParams.bBidirectionalAveragingMode = (1 << 7) |
- (GetConfigIntraResidUnsigned() <<6) | // i9IRU
- (GetConfigResidDiffAccelerator() <<5); // iOHIT
+ (GetConfigIntraResidUnsigned() <<6) | // i9IRU
+ (GetConfigResidDiffAccelerator() <<5); // iOHIT
}
BYTE* CDXVADecoderVC1::FindNextStartCode(BYTE* pBuffer, UINT nSize, UINT& nPacketSize)
@@ -262,7 +262,7 @@ void CDXVADecoderVC1::CopyBitstream(BYTE* pDXVABuffer, BYTE* pBuffer, UINT& nSiz {
int nDummy;
- if(m_PictureParams.bSecondField) {
+ if (m_PictureParams.bSecondField) {
memcpy (pDXVABuffer, (BYTE*)pBuffer, nSize);
} else {
if ( (*((DWORD*)pBuffer) & 0x00FFFFFF) != 0x00010000) {
diff --git a/src/filters/transform/MPCVideoDec/FfmpegContext.c b/src/filters/transform/MPCVideoDec/FfmpegContext.c index d10f25a09..d6bb45b49 100644 --- a/src/filters/transform/MPCVideoDec/FfmpegContext.c +++ b/src/filters/transform/MPCVideoDec/FfmpegContext.c @@ -40,7 +40,7 @@ #include "mpeg12.h"
#if defined(REGISTER_FILTER) && _WIN64
- void *__imp_toupper = toupper;
+void *__imp_toupper = toupper;
#endif
int av_h264_decode_frame(struct AVCodecContext* avctx, int* nOutPOC, int64_t* rtStartTime, uint8_t *buf, int buf_size);
@@ -163,7 +163,7 @@ int FFH264CheckCompatibility(int nWidth, int nHeight, struct AVCodecContext* pAV if (cur_sps != NULL) {
int max_ref_frames = 0;
- if(cur_sps->bit_depth_luma > 8) {
+ if (cur_sps->bit_depth_luma > 8) {
return DXVA_HIGH_BIT;
}
@@ -178,7 +178,7 @@ int FFH264CheckCompatibility(int nWidth, int nHeight, struct AVCodecContext* pAV no_level51_support = 0;
// max ref frames is 16 for HD and 11 otherwise
- if(nWidth >= 1280) {
+ if (nWidth >= 1280) {
max_ref_frames = 16;
} else {
max_ref_frames = 11;
@@ -196,7 +196,7 @@ int FFH264CheckCompatibility(int nWidth, int nHeight, struct AVCodecContext* pAV no_level51_support = 0;
} else if (nPCIVendor == PCIV_ATI) {
// HD4xxx, HD5xxx, and HD6xxx AMD/ATI cards support level 5.1 since drivers v8.14.1.6105 (Catalyst 10.4)
- if(nPCIDevice > 0x6700) {
+ if (nPCIDevice > 0x6700) {
if (DriverVersionCheck(VideoDriverVersion, 8, 14, 1, 6105)) {
no_level51_support = 0;
max_ref_frames = 16;
@@ -315,7 +315,7 @@ HRESULT FFH264BuildPicParams (DXVA_PicParams_H264* pDXVAPicParams, DXVA_Qmatrix_ pDXVAPicParams->bit_depth_luma_minus8 = cur_sps->bit_depth_luma - 8; // bit_depth_luma_minus8
pDXVAPicParams->bit_depth_chroma_minus8 = cur_sps->bit_depth_chroma - 8; // bit_depth_chroma_minus8
-
+
// pDXVAPicParams->StatusReportFeedbackNumber = SET IN DecodeFrame;
// pDXVAPicParams->CurrFieldOrderCnt = SET IN UpdateRefFramesList;
// pDXVAPicParams->FieldOrderCntList = SET IN UpdateRefFramesList;
@@ -327,9 +327,9 @@ HRESULT FFH264BuildPicParams (DXVA_PicParams_H264* pDXVAPicParams, DXVA_Qmatrix_ pDXVAPicParams->log2_max_frame_num_minus4 = cur_sps->log2_max_frame_num - 4; // log2_max_frame_num_minus4;
pDXVAPicParams->pic_order_cnt_type = cur_sps->poc_type; // pic_order_cnt_type;
- if(cur_sps->poc_type == 0)
+ if (cur_sps->poc_type == 0)
pDXVAPicParams->log2_max_pic_order_cnt_lsb_minus4 = cur_sps->log2_max_poc_lsb - 4; // log2_max_pic_order_cnt_lsb_minus4;
- else if(cur_sps->poc_type == 1)
+ else if (cur_sps->poc_type == 1)
pDXVAPicParams->delta_pic_order_always_zero_flag = cur_sps->delta_pic_order_always_zero_flag;
pDXVAPicParams->direct_8x8_inference_flag = cur_sps->direct_8x8_inference_flag;
pDXVAPicParams->entropy_coding_mode_flag = cur_pps->cabac; // entropy_coding_mode_flag;
@@ -383,7 +383,7 @@ void FFH264UpdateRefFramesList (DXVA_PicParams_H264* pDXVAPicParams, struct AVCo Picture* pic;
UCHAR AssociatedFlag;
- for(i=0; i<16; i++) {
+ for (i=0; i<16; i++) {
if (i < h->short_ref_count) {
// Short list reference frames
pic = h->short_ref[h->short_ref_count - i - 1];
@@ -455,7 +455,7 @@ void FF264UpdateRefFrameSliceLong(DXVA_PicParams_H264* pDXVAPicParams, DXVA_Slic HRESULT hr = E_FAIL;
unsigned int i;
- for(i=0; i<32; i++) {
+ for (i=0; i<32; i++) {
pSlice->RefPicList[0][i].AssociatedFlag = 1;
pSlice->RefPicList[0][i].bPicEntry = 255;
pSlice->RefPicList[0][i].Index7Bits = 127;
@@ -464,13 +464,13 @@ void FF264UpdateRefFrameSliceLong(DXVA_PicParams_H264* pDXVAPicParams, DXVA_Slic pSlice->RefPicList[1][i].Index7Bits = 127;
}
- if(h->slice_type != AV_PICTURE_TYPE_I && h->slice_type != AV_PICTURE_TYPE_SI) {
- if(h->ref_count[0] > 0) {
- for(i=0; i < h->ref_count[0]; i++) {
+ if (h->slice_type != AV_PICTURE_TYPE_I && h->slice_type != AV_PICTURE_TYPE_SI) {
+ if (h->ref_count[0] > 0) {
+ for (i=0; i < h->ref_count[0]; i++) {
pSlice->RefPicList[0][i].Index7Bits = FFH264FindRefFrameIndex (h->ref_list[0][i].frame_num, pDXVAPicParams);
pSlice->RefPicList[0][i].AssociatedFlag = 0;
- if((h->s.picture_structure != PICT_FRAME)) {
- if((h->sei_pic_struct == SEI_PIC_STRUCT_BOTTOM_FIELD) ||
+ if ((h->s.picture_structure != PICT_FRAME)) {
+ if ((h->sei_pic_struct == SEI_PIC_STRUCT_BOTTOM_FIELD) ||
(h->sei_pic_struct == SEI_PIC_STRUCT_TOP_BOTTOM) ||
(h->sei_pic_struct == SEI_PIC_STRUCT_TOP_BOTTOM_TOP)) {
pSlice->RefPicList[0][i].AssociatedFlag = 1;
@@ -482,13 +482,13 @@ void FF264UpdateRefFrameSliceLong(DXVA_PicParams_H264* pDXVAPicParams, DXVA_Slic pSlice->num_ref_idx_l0_active_minus1 = 0;
}
- if(h->slice_type == AV_PICTURE_TYPE_B || h->slice_type == AV_PICTURE_TYPE_S || h->slice_type == AV_PICTURE_TYPE_BI) {
- if(h->ref_count[1] > 0) {
- for(i=0; i < h->ref_count[1]; i++) {
+ if (h->slice_type == AV_PICTURE_TYPE_B || h->slice_type == AV_PICTURE_TYPE_S || h->slice_type == AV_PICTURE_TYPE_BI) {
+ if (h->ref_count[1] > 0) {
+ for (i=0; i < h->ref_count[1]; i++) {
pSlice->RefPicList[1][i].Index7Bits = FFH264FindRefFrameIndex (h->ref_list[1][i].frame_num, pDXVAPicParams);
pSlice->RefPicList[1][i].AssociatedFlag = 0;
- if((h->s.picture_structure != PICT_FRAME)) {
- if((h->sei_pic_struct == SEI_PIC_STRUCT_BOTTOM_FIELD) ||
+ if ((h->s.picture_structure != PICT_FRAME)) {
+ if ((h->sei_pic_struct == SEI_PIC_STRUCT_BOTTOM_FIELD) ||
(h->sei_pic_struct == SEI_PIC_STRUCT_TOP_BOTTOM) ||
(h->sei_pic_struct == SEI_PIC_STRUCT_TOP_BOTTOM_TOP)) {
pSlice->RefPicList[1][i].AssociatedFlag = 1;
@@ -501,15 +501,15 @@ void FF264UpdateRefFrameSliceLong(DXVA_PicParams_H264* pDXVAPicParams, DXVA_Slic }
- if(h->slice_type == AV_PICTURE_TYPE_I || h->slice_type == AV_PICTURE_TYPE_SI) {
- for(i = 0; i<16; i++) {
+ if (h->slice_type == AV_PICTURE_TYPE_I || h->slice_type == AV_PICTURE_TYPE_SI) {
+ for (i = 0; i<16; i++) {
pSlice->RefPicList[0][i].bPicEntry = 0xff;
}
}
- if(h->slice_type == AV_PICTURE_TYPE_P || h->slice_type == AV_PICTURE_TYPE_I ||
+ if (h->slice_type == AV_PICTURE_TYPE_P || h->slice_type == AV_PICTURE_TYPE_I ||
h->slice_type ==AV_PICTURE_TYPE_SP || h->slice_type == AV_PICTURE_TYPE_SI) {
- for(i = 0; i < 16; i++) {
+ for (i = 0; i < 16; i++) {
pSlice->RefPicList[1][i].bPicEntry = 0xff;
}
}
@@ -532,16 +532,16 @@ HRESULT FFVC1UpdatePictureParam (DXVA_PictureParameters* pPicParams, struct AVCo // WARNING : vc1->interlace is not reliable (always set for progressive video on HD-DVD material)
if (vc1->fcm == 0) {
- if(nFieldType) {
+ if (nFieldType) {
*nFieldType = PICT_FRAME;
}
} else { // fcm : 2 or 3 frame or field interlaced
- if(nFieldType) {
+ if (nFieldType) {
*nFieldType = (vc1->tff ? PICT_TOP_FIELD : PICT_BOTTOM_FIELD);
}
}
- if(b_SecondField) {
+ if (b_SecondField) {
vc1->second_field = 1;
vc1->s.picture_structure = PICT_TOP_FIELD + vc1->tff;
vc1->s.pict_type = (vc1->fptype & 1) ? AV_PICTURE_TYPE_P : AV_PICTURE_TYPE_I;
@@ -549,7 +549,7 @@ HRESULT FFVC1UpdatePictureParam (DXVA_PictureParameters* pPicParams, struct AVCo vc1->s.pict_type = (vc1->fptype & 1) ? AV_PICTURE_TYPE_BI : AV_PICTURE_TYPE_B;
}
- if(nFrameSize) {
+ if (nFrameSize) {
*nFrameSize = out_nFrameSize;
}
@@ -560,8 +560,8 @@ HRESULT FFVC1UpdatePictureParam (DXVA_PictureParameters* pPicParams, struct AVCo // Init Init Init Todo
// iWMV9 - i9IRU - iOHIT - iINSO - iWMVA - 0 - 0 - 0 | Section 3.2.5
pPicParams->bBidirectionalAveragingMode = (pPicParams->bBidirectionalAveragingMode & 0xE0) | // init in SetExtraData
- ((vc1->lumshift!=0 || vc1->lumscale!=32) ? 0x10 : 0)| // iINSO
- ((vc1->profile == PROFILE_ADVANCED) <<3 ); // iWMVA
+ ((vc1->lumshift!=0 || vc1->lumscale!=32) ? 0x10 : 0)| // iINSO
+ ((vc1->profile == PROFILE_ADVANCED) <<3 ); // iWMVA
// Section 3.2.20.3
pPicParams->bPicSpatialResid8 = (vc1->panscanflag << 7) | (vc1->refdist_flag << 6) |
@@ -598,22 +598,22 @@ HRESULT FFVC1UpdatePictureParam (DXVA_PictureParameters* pPicParams, struct AVCo }
// Section 3.2.16
- if(nSliceType) {
+ if (nSliceType) {
*nSliceType = vc1->s.pict_type;
}
// TODO : not finish...
pPicParams->bMVprecisionAndChromaRelation = ((vc1->mv_mode == MV_PMODE_1MV_HPEL_BILIN) << 3) | // 0 for non-bilinear luma motion, 1 for bilinear
- (1 << 2) | // 0 for WMV8, 1 for WMV9 motion
- (0 << 1) | // 1 for WMV8 quarter sample luma motion
- (0); // 0 for quarter sample chroma motion, 1 for half sample chroma
+ (1 << 2) | // 0 for WMV8, 1 for WMV9 motion
+ (0 << 1) | // 1 for WMV8 quarter sample luma motion
+ (0); // 0 for quarter sample chroma motion, 1 for half sample chroma
// Cf §7.1.1.25 in VC1 specification, §3.2.14.3 in DXVA spec
pPicParams->bRcontrol = vc1->rnd;
- pPicParams->bPicDeblocked = ((vc1->profile == PROFILE_ADVANCED && vc1->overlap == 1 &&
- pPicParams->bPicBackwardPrediction == 0) << 6) |
- ((vc1->profile != PROFILE_ADVANCED && vc1->rangeredfrm) << 5) |
+ pPicParams->bPicDeblocked = ((vc1->profile == PROFILE_ADVANCED && vc1->overlap == 1 &&
+ pPicParams->bPicBackwardPrediction == 0) << 6) |
+ ((vc1->profile != PROFILE_ADVANCED && vc1->rangeredfrm) << 5) |
(vc1->s.loop_filter << 1);
return S_OK;
@@ -701,13 +701,13 @@ HRESULT FFMpeg2DecodeFrame (DXVA_PictureParameters* pPicParams, DXVA_QmatrixData // pPicParams->bReservedBits; // ??
pPicParams->wBitstreamFcodes = (s->mpeg_f_code[0][0]<<12) | (s->mpeg_f_code[0][1]<<8) |
- (s->mpeg_f_code[1][0]<<4) | (s->mpeg_f_code[1][1]);
+ (s->mpeg_f_code[1][0]<<4) | (s->mpeg_f_code[1][1]);
pPicParams->wBitstreamPCEelements = (s->intra_dc_precision<<14) | (s->picture_structure<<12) |
- (s->top_field_first<<11) | (s->frame_pred_frame_dct<<10)|
- (s->concealment_motion_vectors<<9) | (s->q_scale_type<<8)|
- (s->intra_vlc_format<<7) | (s->alternate_scan<<6)|
- (s->repeat_first_field<<5) | (s->chroma_420_type<<4)|
- (s->progressive_frame<<3);
+ (s->top_field_first<<11) | (s->frame_pred_frame_dct<<10)|
+ (s->concealment_motion_vectors<<9) | (s->q_scale_type<<8)|
+ (s->intra_vlc_format<<7) | (s->alternate_scan<<6)|
+ (s->repeat_first_field<<5) | (s->chroma_420_type<<4)|
+ (s->progressive_frame<<3);
// TODO : could be interesting to parameter concealment method?
// pPicParams->bBitstreamConcealmentNeed;
@@ -746,10 +746,10 @@ int FFIsSkipped(struct AVCodecContext* pAVCtx) int FFGetThreadType(enum CodecID nCodecId, int nThreadCount)
{
- if(!nThreadCount) {
+ if (!nThreadCount) {
return 0;
}
- switch(nCodecId)
+ switch (nCodecId)
{
case CODEC_ID_H264 :
return FF_THREAD_FRAME|FF_THREAD_SLICE;
diff --git a/src/filters/transform/MPCVideoDec/H264RandomAccess.cpp b/src/filters/transform/MPCVideoDec/H264RandomAccess.cpp index 228452c4c..be4751524 100644 --- a/src/filters/transform/MPCVideoDec/H264RandomAccess.cpp +++ b/src/filters/transform/MPCVideoDec/H264RandomAccess.cpp @@ -24,7 +24,7 @@ CH264RandomAccess::CH264RandomAccess()
{
- flush(0);
+ flush(0);
}
CH264RandomAccess::~CH264RandomAccess()
@@ -33,59 +33,59 @@ CH264RandomAccess::~CH264RandomAccess() void CH264RandomAccess::flush(int threadCount)
{
- m_RecoveryMode = 1;
- m_RecoveryFrameCount = 0;
- m_ThreadDelay = threadCount;
+ m_RecoveryMode = 1;
+ m_RecoveryFrameCount = 0;
+ m_ThreadDelay = threadCount;
}
BOOL CH264RandomAccess::searchRecoveryPoint(AVCodecContext* pAVCtx, BYTE *buf, int buf_size)
{
- if (m_RecoveryMode == 1) {
+ if (m_RecoveryMode == 1) {
int recoveryPoint = avcodec_h264_search_recovery_point(pAVCtx, buf, buf_size, &m_RecoveryFrameCount);
- switch (recoveryPoint) {
- case 3: // IDRS
- m_RecoveryMode = 0;
- return TRUE;
- case 2: // SEI recovery
- m_RecoveryMode = 2;
- return TRUE;
- case 1: // I Frame
- m_RecoveryMode = 2;
- m_RecoveryFrameCount = 0;
- return TRUE;
- default:
- return FALSE;
- }
- } else {
- return TRUE;
- }
+ switch (recoveryPoint) {
+ case 3: // IDRS
+ m_RecoveryMode = 0;
+ return TRUE;
+ case 2: // SEI recovery
+ m_RecoveryMode = 2;
+ return TRUE;
+ case 1: // I Frame
+ m_RecoveryMode = 2;
+ m_RecoveryFrameCount = 0;
+ return TRUE;
+ default:
+ return FALSE;
+ }
+ } else {
+ return TRUE;
+ }
}
void CH264RandomAccess::judgeFrameUsability(AVFrame *pFrame, int *got_picture_ptr)
{
- if ((m_ThreadDelay > 1 && --m_ThreadDelay > 0) || m_RecoveryMode == 0 || pFrame->h264_max_frame_num == 0) {
- return;
- }
+ if ((m_ThreadDelay > 1 && --m_ThreadDelay > 0) || m_RecoveryMode == 0 || pFrame->h264_max_frame_num == 0) {
+ return;
+ }
- if (m_RecoveryMode == 1 || m_RecoveryMode == 2) {
- m_RecoveryFrameCount = (m_RecoveryFrameCount + pFrame->h264_frame_num_decoded) % pFrame->h264_max_frame_num;
- m_RecoveryMode = 3;
- }
+ if (m_RecoveryMode == 1 || m_RecoveryMode == 2) {
+ m_RecoveryFrameCount = (m_RecoveryFrameCount + pFrame->h264_frame_num_decoded) % pFrame->h264_max_frame_num;
+ m_RecoveryMode = 3;
+ }
- if (m_RecoveryMode == 3) {
- if (m_RecoveryFrameCount <= pFrame->h264_frame_num_decoded) {
- m_RecoveryPOC = pFrame->h264_poc_decoded;
- m_RecoveryMode = 4;
- }
- }
+ if (m_RecoveryMode == 3) {
+ if (m_RecoveryFrameCount <= pFrame->h264_frame_num_decoded) {
+ m_RecoveryPOC = pFrame->h264_poc_decoded;
+ m_RecoveryMode = 4;
+ }
+ }
- if (m_RecoveryMode == 4) {
- if (pFrame->h264_poc_outputed >= m_RecoveryPOC) {
- m_RecoveryMode = 0;
- }
- }
+ if (m_RecoveryMode == 4) {
+ if (pFrame->h264_poc_outputed >= m_RecoveryPOC) {
+ m_RecoveryMode = 0;
+ }
+ }
- if (m_RecoveryMode != 0) {
- *got_picture_ptr = 0;
- }
+ if (m_RecoveryMode != 0) {
+ *got_picture_ptr = 0;
+ }
}
diff --git a/src/filters/transform/MPCVideoDec/H264RandomAccess.h b/src/filters/transform/MPCVideoDec/H264RandomAccess.h index 933881be9..86c6f9d17 100644 --- a/src/filters/transform/MPCVideoDec/H264RandomAccess.h +++ b/src/filters/transform/MPCVideoDec/H264RandomAccess.h @@ -25,16 +25,16 @@ struct AVFrame; class CH264RandomAccess
{
public:
- CH264RandomAccess();
- ~CH264RandomAccess();
+ CH264RandomAccess();
+ ~CH264RandomAccess();
- void flush(int threadCount);
- BOOL searchRecoveryPoint(AVCodecContext* pAVCtx, BYTE *buf, int buf_size);
- void judgeFrameUsability(AVFrame *pFrame, int *got_picture_ptr);
+ void flush(int threadCount);
+ BOOL searchRecoveryPoint(AVCodecContext* pAVCtx, BYTE *buf, int buf_size);
+ void judgeFrameUsability(AVFrame *pFrame, int *got_picture_ptr);
private:
- int m_RecoveryMode; // 0: OK; 1: Searching; 2: Found; 3:
- int m_RecoveryFrameCount;
- int m_RecoveryPOC;
- int m_ThreadDelay;
+ int m_RecoveryMode; // 0: OK; 1: Searching; 2: Found; 3:
+ int m_RecoveryFrameCount;
+ int m_RecoveryPOC;
+ int m_ThreadDelay;
};
diff --git a/src/filters/transform/MPCVideoDec/MPCVideoDecFilter.cpp b/src/filters/transform/MPCVideoDec/MPCVideoDecFilter.cpp index 094b4bbea..8e94299e3 100644 --- a/src/filters/transform/MPCVideoDec/MPCVideoDecFilter.cpp +++ b/src/filters/transform/MPCVideoDec/MPCVideoDecFilter.cpp @@ -195,20 +195,20 @@ FFMPEG_CODECS ffCodecs[] = { // AMV Video
{ &MEDIASUBTYPE_AMVV, CODEC_ID_AMV, NULL },
- // MJPEG
- { &MEDIASUBTYPE_MJPG, CODEC_ID_MJPEG, NULL },
- { &MEDIASUBTYPE_QTJpeg, CODEC_ID_MJPEG, NULL },
- { &MEDIASUBTYPE_MJPA, CODEC_ID_MJPEG, NULL },
- { &MEDIASUBTYPE_MJPB, CODEC_ID_MJPEGB, NULL },
+ // MJPEG
+ { &MEDIASUBTYPE_MJPG, CODEC_ID_MJPEG, NULL },
+ { &MEDIASUBTYPE_QTJpeg, CODEC_ID_MJPEG, NULL },
+ { &MEDIASUBTYPE_MJPA, CODEC_ID_MJPEG, NULL },
+ { &MEDIASUBTYPE_MJPB, CODEC_ID_MJPEGB, NULL },
// TSCC
- { &MEDIASUBTYPE_TSCC, CODEC_ID_TSCC, NULL },
+ { &MEDIASUBTYPE_TSCC, CODEC_ID_TSCC, NULL },
// Indeo 3/4/5
- { &MEDIASUBTYPE_IV31, CODEC_ID_INDEO3, NULL },
- { &MEDIASUBTYPE_IV32, CODEC_ID_INDEO3, NULL },
- { &MEDIASUBTYPE_IV41, CODEC_ID_INDEO4, NULL },
- { &MEDIASUBTYPE_IV50, CODEC_ID_INDEO5, NULL },
+ { &MEDIASUBTYPE_IV31, CODEC_ID_INDEO3, NULL },
+ { &MEDIASUBTYPE_IV32, CODEC_ID_INDEO3, NULL },
+ { &MEDIASUBTYPE_IV41, CODEC_ID_INDEO4, NULL },
+ { &MEDIASUBTYPE_IV50, CODEC_ID_INDEO5, NULL },
#endif /* HAS_FFMPEG_VIDEO_DECODERS */
// H264/AVC
@@ -523,15 +523,15 @@ CMPCVideoDecFilter::CMPCVideoDecFilter(LPUNKNOWN lpunk, HRESULT* phr) {
HWND hWnd = NULL;
- if(IsVistaOrAbove()) {
+ if (IsVistaOrAbove()) {
for (int i=0; i<countof(ffCodecs); i++) {
- if(ffCodecs[i].nFFCodec == CODEC_ID_H264) {
+ if (ffCodecs[i].nFFCodec == CODEC_ID_H264) {
ffCodecs[i].DXVAModes = &DXVA_H264_VISTA;
}
}
}
- if(phr) {
+ if (phr) {
*phr = S_OK;
}
@@ -539,7 +539,7 @@ CMPCVideoDecFilter::CMPCVideoDecFilter(LPUNKNOWN lpunk, HRESULT* phr) delete m_pOutput;
}
m_pOutput = DNew CVideoDecOutputPin(NAME("CVideoDecOutputPin"), this, phr, L"Output");
- if(!m_pOutput) {
+ if (!m_pOutput) {
*phr = E_OUTOFMEMORY;
}
@@ -595,55 +595,55 @@ CMPCVideoDecFilter::CMPCVideoDecFilter(LPUNKNOWN lpunk, HRESULT* phr) #ifdef REGISTER_FILTER
CRegKey key;
- if(ERROR_SUCCESS == key.Open(HKEY_CURRENT_USER, _T("Software\\Gabest\\Filters\\MPC Video Decoder"), KEY_READ)) {
+ if (ERROR_SUCCESS == key.Open(HKEY_CURRENT_USER, _T("Software\\Gabest\\Filters\\MPC Video Decoder"), KEY_READ)) {
DWORD dw;
- #if HAS_FFMPEG_VIDEO_DECODERS
- if(ERROR_SUCCESS == key.QueryDWORDValue(_T("ThreadNumber"), dw)) {
+#if HAS_FFMPEG_VIDEO_DECODERS
+ if (ERROR_SUCCESS == key.QueryDWORDValue(_T("ThreadNumber"), dw)) {
m_nThreadNumber = dw;
}
- #if INTERNAL_DECODER_H264
- if(ERROR_SUCCESS == key.QueryDWORDValue(_T("DiscardMode"), dw)) {
+#if INTERNAL_DECODER_H264
+ if (ERROR_SUCCESS == key.QueryDWORDValue(_T("DiscardMode"), dw)) {
m_nDiscardMode = dw;
}
- #endif
- if(ERROR_SUCCESS == key.QueryDWORDValue(_T("ErrorRecognition"), dw)) {
+#endif
+ if (ERROR_SUCCESS == key.QueryDWORDValue(_T("ErrorRecognition"), dw)) {
m_nErrorRecognition = dw;
}
- if(ERROR_SUCCESS == key.QueryDWORDValue(_T("IDCTAlgo"), dw)) {
+ if (ERROR_SUCCESS == key.QueryDWORDValue(_T("IDCTAlgo"), dw)) {
m_nIDCTAlgo = dw;
}
- if(ERROR_SUCCESS == key.QueryDWORDValue(_T("ActiveCodecs"), dw)) {
+ if (ERROR_SUCCESS == key.QueryDWORDValue(_T("ActiveCodecs"), dw)) {
m_nActiveCodecs = dw;
}
- if(ERROR_SUCCESS == key.QueryDWORDValue(_T("ARMode"), dw)) {
+ if (ERROR_SUCCESS == key.QueryDWORDValue(_T("ARMode"), dw)) {
m_nARMode = dw;
}
- #endif
- if(ERROR_SUCCESS == key.QueryDWORDValue(_T("DXVACheckCompatibility"), dw)) {
+#endif
+ if (ERROR_SUCCESS == key.QueryDWORDValue(_T("DXVACheckCompatibility"), dw)) {
m_nDXVACheckCompatibility = dw;
}
- if(ERROR_SUCCESS == key.QueryDWORDValue(_T("DisableDXVA_SD"), dw)) {
+ if (ERROR_SUCCESS == key.QueryDWORDValue(_T("DisableDXVA_SD"), dw)) {
m_nDXVA_SD = dw;
}
}
#else
- #if HAS_FFMPEG_VIDEO_DECODERS
+#if HAS_FFMPEG_VIDEO_DECODERS
m_nThreadNumber = AfxGetApp()->GetProfileInt(_T("Filters\\MPC Video Decoder"), _T("ThreadNumber"), m_nThreadNumber);
- #if INTERNAL_DECODER_H264
+#if INTERNAL_DECODER_H264
m_nDiscardMode = AfxGetApp()->GetProfileInt(_T("Filters\\MPC Video Decoder"), _T("DiscardMode"), m_nDiscardMode);
- #endif
+#endif
m_nErrorRecognition = AfxGetApp()->GetProfileInt(_T("Filters\\MPC Video Decoder"), _T("ErrorRecognition"), m_nErrorRecognition);
m_nIDCTAlgo = AfxGetApp()->GetProfileInt(_T("Filters\\MPC Video Decoder"), _T("IDCTAlgo"), m_nIDCTAlgo);
m_nARMode = AfxGetApp()->GetProfileInt(_T("Filters\\MPC Video Decoder"), _T("ARMode"), m_nARMode);
- #endif
+#endif
m_nDXVACheckCompatibility = AfxGetApp()->GetProfileInt(_T("Filters\\MPC Video Decoder"), _T("DXVACheckCompatibility"), m_nDXVACheckCompatibility);
m_nDXVA_SD = AfxGetApp()->GetProfileInt(_T("Filters\\MPC Video Decoder"), _T("DisableDXVA_SD"), m_nDXVA_SD);
#endif
- if(m_nErrorRecognition != AV_EF_CAREFUL && m_nErrorRecognition != AV_EF_COMPLIANT && m_nErrorRecognition != AV_EF_AGGRESSIVE) {
+ if (m_nErrorRecognition != AV_EF_CAREFUL && m_nErrorRecognition != AV_EF_COMPLIANT && m_nErrorRecognition != AV_EF_AGGRESSIVE) {
m_nErrorRecognition = AV_EF_CAREFUL;
}
- if(m_nDXVACheckCompatibility > 3) {
+ if (m_nDXVACheckCompatibility > 3) {
m_nDXVACheckCompatibility = 1; // skip level check by default
}
@@ -810,9 +810,9 @@ int CMPCVideoDecFilter::FindCodec(const CMediaType* mtIn) break;
case CODEC_ID_MPEG4 :
if ((*ffCodecs[i].clsMinorType == MEDIASUBTYPE_DX50) || // DivX
- (*ffCodecs[i].clsMinorType == MEDIASUBTYPE_dx50) ||
- (*ffCodecs[i].clsMinorType == MEDIASUBTYPE_DIVX) ||
- (*ffCodecs[i].clsMinorType == MEDIASUBTYPE_divx) ) {
+ (*ffCodecs[i].clsMinorType == MEDIASUBTYPE_dx50) ||
+ (*ffCodecs[i].clsMinorType == MEDIASUBTYPE_DIVX) ||
+ (*ffCodecs[i].clsMinorType == MEDIASUBTYPE_divx) ) {
bCodecActivated = (m_nActiveCodecs & MPCVD_DIVX) != 0;
} else {
bCodecActivated = (m_nActiveCodecs & MPCVD_XVID) != 0; // Xvid/MPEG-4
@@ -1009,16 +1009,16 @@ HRESULT CMPCVideoDecFilter::CheckInputType(const CMediaType* mtIn) bool CMPCVideoDecFilter::IsMultiThreadSupported(enum CodecID nCodec)
{
return
- (
- nCodec==CODEC_ID_H264 ||
- nCodec==CODEC_ID_MPEG1VIDEO ||
- nCodec==CODEC_ID_FFV1 ||
- nCodec==CODEC_ID_DVVIDEO ||
- nCodec==CODEC_ID_VP8 ||
- nCodec==CODEC_ID_THEORA ||
- nCodec==CODEC_ID_RV30 ||
- nCodec==CODEC_ID_RV40
- );
+ (
+ nCodec==CODEC_ID_H264 ||
+ nCodec==CODEC_ID_MPEG1VIDEO ||
+ nCodec==CODEC_ID_FFV1 ||
+ nCodec==CODEC_ID_DVVIDEO ||
+ nCodec==CODEC_ID_VP8 ||
+ nCodec==CODEC_ID_THEORA ||
+ nCodec==CODEC_ID_RV30 ||
+ nCodec==CODEC_ID_RV40
+ );
}
CString CMPCVideoDecFilter::GetFileExtension()
@@ -1056,7 +1056,7 @@ HRESULT CMPCVideoDecFilter::SetMediaType(PIN_DIRECTION direction,const CMediaTyp if (nNewCodec != m_nCodecNb) {
CLSID ClsidSourceFilter = GetCLSID(m_pInput->GetConnected());
- if((ClsidSourceFilter == __uuidof(COggSourceFilter)) || (ClsidSourceFilter == __uuidof(COggSplitterFilter))) {
+ if ((ClsidSourceFilter == __uuidof(COggSourceFilter)) || (ClsidSourceFilter == __uuidof(COggSplitterFilter))) {
m_bTheoraMTSupport = false;
}
@@ -1082,25 +1082,25 @@ HRESULT CMPCVideoDecFilter::SetMediaType(PIN_DIRECTION direction,const CMediaTyp m_h264RandomAccess.flush(m_pAVCtx->thread_count);
- if(pmt->formattype == FORMAT_VideoInfo) {
+ if (pmt->formattype == FORMAT_VideoInfo) {
VIDEOINFOHEADER* vih = (VIDEOINFOHEADER*)pmt->pbFormat;
m_pAVCtx->width = vih->bmiHeader.biWidth;
m_pAVCtx->height = abs(vih->bmiHeader.biHeight);
m_pAVCtx->codec_tag = vih->bmiHeader.biCompression;
m_pAVCtx->bits_per_coded_sample = vih->bmiHeader.biBitCount;
- } else if(pmt->formattype == FORMAT_VideoInfo2) {
+ } else if (pmt->formattype == FORMAT_VideoInfo2) {
VIDEOINFOHEADER2* vih2 = (VIDEOINFOHEADER2*)pmt->pbFormat;
m_pAVCtx->width = vih2->bmiHeader.biWidth;
m_pAVCtx->height = abs(vih2->bmiHeader.biHeight);
m_pAVCtx->codec_tag = vih2->bmiHeader.biCompression;
m_pAVCtx->bits_per_coded_sample = vih2->bmiHeader.biBitCount;
- } else if(pmt->formattype == FORMAT_MPEGVideo) {
+ } else if (pmt->formattype == FORMAT_MPEGVideo) {
MPEG1VIDEOINFO* mpgv = (MPEG1VIDEOINFO*)pmt->pbFormat;
m_pAVCtx->width = mpgv->hdr.bmiHeader.biWidth;
m_pAVCtx->height = abs(mpgv->hdr.bmiHeader.biHeight);
m_pAVCtx->codec_tag = mpgv->hdr.bmiHeader.biCompression;
m_pAVCtx->bits_per_coded_sample = mpgv->hdr.bmiHeader.biBitCount;
- } else if(pmt->formattype == FORMAT_MPEG2Video) {
+ } else if (pmt->formattype == FORMAT_MPEG2Video) {
MPEG2VIDEOINFO* mpg2v = (MPEG2VIDEOINFO*)pmt->pbFormat;
m_pAVCtx->width = mpg2v->hdr.bmiHeader.biWidth;
m_pAVCtx->height = abs(mpg2v->hdr.bmiHeader.biHeight);
@@ -1119,11 +1119,11 @@ HRESULT CMPCVideoDecFilter::SetMediaType(PIN_DIRECTION direction,const CMediaTyp m_nWidth = m_pAVCtx->width;
m_nHeight = m_pAVCtx->height;
- if(m_pAVCtx->codec_tag == MAKEFOURCC('m','p','g','2')) {
+ if (m_pAVCtx->codec_tag == MAKEFOURCC('m','p','g','2')) {
m_pAVCtx->codec_tag = MAKEFOURCC('M','P','E','G');
}
- if(m_nCodecId == CODEC_ID_RV10 || m_nCodecId == CODEC_ID_RV20 || m_nCodecId == CODEC_ID_RV30 || m_nCodecId == CODEC_ID_RV40) {
+ if (m_nCodecId == CODEC_ID_RV10 || m_nCodecId == CODEC_ID_RV20 || m_nCodecId == CODEC_ID_RV30 || m_nCodecId == CODEC_ID_RV40) {
m_bReorderBFrame = false;
}
@@ -1154,7 +1154,7 @@ HRESULT CMPCVideoDecFilter::SetMediaType(PIN_DIRECTION direction,const CMediaTyp do {
m_bDXVACompatible = false;
- if(!DXVACheckFramesize(PictWidth(), PictHeight(), m_nPCIVendor)) { // check frame size
+ if (!DXVACheckFramesize(PictWidth(), PictHeight(), m_nPCIVendor)) { // check frame size
break;
}
@@ -1163,11 +1163,11 @@ HRESULT CMPCVideoDecFilter::SetMediaType(PIN_DIRECTION direction,const CMediaTyp break;
}
int nCompat = FFH264CheckCompatibility (PictWidthRounded(), PictHeightRounded(), m_pAVCtx, (BYTE*)m_pAVCtx->extradata, m_pAVCtx->extradata_size, m_nPCIVendor, m_nPCIDevice, m_VideoDriverVersion);
- if(nCompat) {
+ if (nCompat) {
if ( nCompat == DXVA_HIGH_BIT ||
- m_nDXVACheckCompatibility == 0 || // full check
- m_nDXVACheckCompatibility == 1 && nCompat != DXVA_UNSUPPORTED_LEVEL || // skip level check
- m_nDXVACheckCompatibility == 2 && nCompat != DXVA_TOO_MANY_REF_FRAMES) { // skip reference frame check
+ m_nDXVACheckCompatibility == 0 || // full check
+ m_nDXVACheckCompatibility == 1 && nCompat != DXVA_UNSUPPORTED_LEVEL || // skip level check
+ m_nDXVACheckCompatibility == 2 && nCompat != DXVA_TOO_MANY_REF_FRAMES) { // skip reference frame check
break;
}
}
@@ -1312,8 +1312,8 @@ void CMPCVideoDecFilter::AllocExtradata(AVCodecContext* pAVCtx, const CMediaType if (size) {
CLSID ClsidSourceFilter = GetCLSID(m_pInput->GetConnected());
- if(((ClsidSourceFilter == __uuidof(CRealMediaSourceFilter)) || (ClsidSourceFilter == __uuidof(CRealMediaSplitterFilter))) &&
- (m_nCodecId == CODEC_ID_RV10 || m_nCodecId == CODEC_ID_RV20 || m_nCodecId == CODEC_ID_RV30) && (size > 26)) {
+ if (((ClsidSourceFilter == __uuidof(CRealMediaSourceFilter)) || (ClsidSourceFilter == __uuidof(CRealMediaSplitterFilter))) &&
+ (m_nCodecId == CODEC_ID_RV10 || m_nCodecId == CODEC_ID_RV20 || m_nCodecId == CODEC_ID_RV30) && (size > 26)) {
size -= 26;
data += 26;
}
@@ -1359,7 +1359,7 @@ HRESULT CMPCVideoDecFilter::CompleteConnect(PIN_DIRECTION direction, IPin* pRece }
CLSID ClsidSourceFilter = GetCLSID(m_pInput->GetConnected());
- if((ClsidSourceFilter == __uuidof(CMpegSourceFilter)) || (ClsidSourceFilter == __uuidof(CMpegSplitterFilter))) {
+ if ((ClsidSourceFilter == __uuidof(CMpegSourceFilter)) || (ClsidSourceFilter == __uuidof(CMpegSplitterFilter))) {
m_bReorderBFrame = false;
}
}
@@ -1378,13 +1378,13 @@ HRESULT CMPCVideoDecFilter::DecideBufferSize(IMemAllocator* pAllocator, ALLOCATO HRESULT hr;
ALLOCATOR_PROPERTIES Actual;
- if(m_pInput->IsConnected() == FALSE) {
+ if (m_pInput->IsConnected() == FALSE) {
return E_UNEXPECTED;
}
pProperties->cBuffers = GetPicEntryNumber();
- if(FAILED(hr = pAllocator->SetProperties(pProperties, &Actual))) {
+ if (FAILED(hr = pAllocator->SetProperties(pProperties, &Actual))) {
return hr;
}
@@ -1435,15 +1435,15 @@ HRESULT CMPCVideoDecFilter::BreakConnect(PIN_DIRECTION dir) void CMPCVideoDecFilter::SetTypeSpecificFlags(IMediaSample* pMS)
{
- if(CComQIPtr<IMediaSample2> pMS2 = pMS) {
+ if (CComQIPtr<IMediaSample2> pMS2 = pMS) {
AM_SAMPLE2_PROPERTIES props;
- if(SUCCEEDED(pMS2->GetProperties(sizeof(props), (BYTE*)&props))) {
+ if (SUCCEEDED(pMS2->GetProperties(sizeof(props), (BYTE*)&props))) {
props.dwTypeSpecificFlags &= ~0x7f;
- if(!m_pFrame->interlaced_frame) {
+ if (!m_pFrame->interlaced_frame) {
props.dwTypeSpecificFlags |= AM_VIDEO_FLAG_WEAVE;
} else {
- if(m_pFrame->top_field_first) {
+ if (m_pFrame->top_field_first) {
props.dwTypeSpecificFlags |= AM_VIDEO_FLAG_FIELD1FIRST;
}
}
@@ -1510,19 +1510,19 @@ void CMPCVideoDecFilter::InitSwscale() m_nOutCsp = GetCspFromMediaType(m_pOutput->CurrentMediaType().subtype);
m_pSwsContext = sws_getCachedContext(
- NULL,
- m_pAVCtx->width,
- m_pAVCtx->height,
- m_pAVCtx->pix_fmt,
- m_pAVCtx->width,
- m_pAVCtx->height,
- csp_ffdshow2lavc(m_nOutCsp),
- sws_Flags|SWS_PRINT_INFO,
- NULL,
- NULL,
- NULL,
- ¶ms,
- (m_nThreadNumber ? m_nThreadNumber : m_pCpuId->GetProcessorNumber()));
+ NULL,
+ m_pAVCtx->width,
+ m_pAVCtx->height,
+ m_pAVCtx->pix_fmt,
+ m_pAVCtx->width,
+ m_pAVCtx->height,
+ csp_ffdshow2lavc(m_nOutCsp),
+ sws_Flags|SWS_PRINT_INFO,
+ NULL,
+ NULL,
+ NULL,
+ ¶ms,
+ (m_nThreadNumber ? m_nThreadNumber : m_pCpuId->GetProcessorNumber()));
m_nSwOutBpp = bihOut.biBitCount;
m_pOutSize.cx = bihOut.biWidth;
@@ -1555,7 +1555,7 @@ HRESULT CMPCVideoDecFilter::SoftwareDecode(IMediaSample* pIn, BYTE* pDataIn, int av_init_packet(&avpkt);
if (!bFlush && m_nCodecId == CODEC_ID_H264) {
- if(!m_h264RandomAccess.searchRecoveryPoint(m_pAVCtx, pDataIn, nSize)) {
+ if (!m_h264RandomAccess.searchRecoveryPoint(m_pAVCtx, pDataIn, nSize)) {
return S_OK;
}
}
@@ -1618,7 +1618,7 @@ HRESULT CMPCVideoDecFilter::SoftwareDecode(IMediaSample* pIn, BYTE* pDataIn, int continue;
}
- if(pIn->IsPreroll() == S_OK || rtStart < 0) {
+ if (pIn->IsPreroll() == S_OK || rtStart < 0) {
return S_OK;
}
@@ -1626,15 +1626,15 @@ HRESULT CMPCVideoDecFilter::SoftwareDecode(IMediaSample* pIn, BYTE* pDataIn, int BYTE* pDataOut = NULL;
UpdateAspectRatio();
- if(FAILED(hr = GetDeliveryBuffer(m_pAVCtx->width, m_pAVCtx->height, &pOut)) || FAILED(hr = pOut->GetPointer(&pDataOut))) {
+ if (FAILED(hr = GetDeliveryBuffer(m_pAVCtx->width, m_pAVCtx->height, &pOut)) || FAILED(hr = pOut->GetPointer(&pDataOut))) {
return hr;
}
if (m_nCodecId == CODEC_ID_THEORA ||
- m_nCodecId == CODEC_ID_VP8 && m_rtAvrTimePerFrame == 10000) { // need more tests
- rtStart = m_pFrame->pkt_pts;
- rtStop = m_pFrame->pkt_dts;
- } else if((m_nCodecId == CODEC_ID_RV10 || m_nCodecId == CODEC_ID_RV20 || m_nCodecId == CODEC_ID_RV30 || m_nCodecId == CODEC_ID_RV40) && m_pFrame->pict_type == AV_PICTURE_TYPE_B) {
+ m_nCodecId == CODEC_ID_VP8 && m_rtAvrTimePerFrame == 10000) { // need more tests
+ rtStart = m_pFrame->pkt_pts;
+ rtStop = m_pFrame->pkt_dts;
+ } else if ((m_nCodecId == CODEC_ID_RV10 || m_nCodecId == CODEC_ID_RV20 || m_nCodecId == CODEC_ID_RV30 || m_nCodecId == CODEC_ID_RV40) && m_pFrame->pict_type == AV_PICTURE_TYPE_B) {
rtStart = m_rtPrevStop;
rtStop = rtStart + m_rtAvrTimePerFrame;
} else {
@@ -1679,7 +1679,7 @@ HRESULT CMPCVideoDecFilter::SoftwareDecode(IMediaSample* pIn, BYTE* pDataIn, int }
}
int nTempCsp = m_nOutCsp;
- if(outcspInfo->id==FF_CSP_420P) {
+ if (outcspInfo->id==FF_CSP_420P) {
csp_yuv_adj_to_plane(nTempCsp,outcspInfo,odd2even(m_pOutSize.cy),(unsigned char**)dst,(stride_t*)dstStride);
} else {
csp_yuv_adj_to_plane(nTempCsp,outcspInfo,m_pAVCtx->height,(unsigned char**)dst,(stride_t*)dstStride);
@@ -1823,7 +1823,7 @@ HRESULT CMPCVideoDecFilter::Transform(IMediaSample* pIn) REFERENCE_TIME rtStart = _I64_MIN;
REFERENCE_TIME rtStop = _I64_MIN;
- if(FAILED(hr = pIn->GetPointer(&pDataIn))) {
+ if (FAILED(hr = pIn->GetPointer(&pDataIn))) {
return hr;
}
@@ -1851,14 +1851,14 @@ HRESULT CMPCVideoDecFilter::Transform(IMediaSample* pIn) // rtStart = rtStop = m_rtLastStart + m_nCountEstimated*m_rtAvrTimePerFrame;
//}
- if(FAILED(hr)) {
+ if (FAILED(hr)) {
rtStart = rtStop = _I64_MIN;
}
if (rtStop <= rtStart && rtStop != _I64_MIN) {
rtStop = rtStart + m_rtAvrTimePerFrame / m_dRate;
}
- if(m_nDXVAMode == MODE_SOFTWARE) {
+ if (m_nDXVAMode == MODE_SOFTWARE) {
UpdateFrameTime(rtStart, rtStop);
}
@@ -1932,13 +1932,13 @@ HRESULT CMPCVideoDecFilter::Transform(IMediaSample* pIn) void CMPCVideoDecFilter::UpdateAspectRatio()
{
- if(((m_nARMode) && (m_pAVCtx)) && ((m_pAVCtx->sample_aspect_ratio.num>0) && (m_pAVCtx->sample_aspect_ratio.den>0))) {
+ if (((m_nARMode) && (m_pAVCtx)) && ((m_pAVCtx->sample_aspect_ratio.num>0) && (m_pAVCtx->sample_aspect_ratio.den>0))) {
CSize SAR(m_pAVCtx->sample_aspect_ratio.num, m_pAVCtx->sample_aspect_ratio.den);
- if(m_sar != SAR) {
+ if (m_sar != SAR) {
m_sar = SAR;
CSize aspect(m_nWidth * SAR.cx, m_nHeight * SAR.cy);
int lnko = LNKO(aspect.cx, aspect.cy);
- if(lnko > 1) {
+ if (lnko > 1) {
aspect.cx /= lnko, aspect.cy /= lnko;
}
SetAspect(aspect);
@@ -2329,15 +2329,15 @@ STDMETHODIMP CMPCVideoDecFilter::CreatePage(const GUID& guid, IPropertyPage** pp {
CheckPointer(ppPage, E_POINTER);
- if(*ppPage != NULL) {
+ if (*ppPage != NULL) {
return E_INVALIDARG;
}
HRESULT hr;
- if(guid == __uuidof(CMPCVideoDecSettingsWnd)) {
+ if (guid == __uuidof(CMPCVideoDecSettingsWnd)) {
(*ppPage = DNew CInternalPropertyPageTempl<CMPCVideoDecSettingsWnd>(NULL, &hr))->AddRef();
- } else if(guid == __uuidof(CMPCVideoDecCodecWnd)) {
+ } else if (guid == __uuidof(CMPCVideoDecCodecWnd)) {
(*ppPage = DNew CInternalPropertyPageTempl<CMPCVideoDecCodecWnd>(NULL, &hr))->AddRef();
}
@@ -2349,7 +2349,7 @@ STDMETHODIMP CMPCVideoDecFilter::Apply() {
#ifdef REGISTER_FILTER
CRegKey key;
- if(ERROR_SUCCESS == key.Create(HKEY_CURRENT_USER, _T("Software\\Gabest\\Filters\\MPC Video Decoder"))) {
+ if (ERROR_SUCCESS == key.Create(HKEY_CURRENT_USER, _T("Software\\Gabest\\Filters\\MPC Video Decoder"))) {
key.SetDWORDValue(_T("ThreadNumber"), m_nThreadNumber);
key.SetDWORDValue(_T("DiscardMode"), m_nDiscardMode);
key.SetDWORDValue(_T("ErrorRecognition"), m_nErrorRecognition);
diff --git a/src/filters/transform/MPCVideoDec/MPCVideoDecFilter.h b/src/filters/transform/MPCVideoDec/MPCVideoDecFilter.h index c25465876..3b7690224 100644 --- a/src/filters/transform/MPCVideoDec/MPCVideoDecFilter.h +++ b/src/filters/transform/MPCVideoDec/MPCVideoDecFilter.h @@ -108,8 +108,8 @@ protected: int m_nPosB;
int m_nWidth; // Frame width give to input pin
int m_nHeight; // Frame height give to input pin
-
- bool m_bTheoraMTSupport;
+
+ bool m_bTheoraMTSupport;
// Buffer management for truncated stream (store stream chunks & reference time sent by splitter)
BYTE* m_pFFBuffer;
diff --git a/src/filters/transform/MPCVideoDec/MPCVideoDecSettingsWnd.cpp b/src/filters/transform/MPCVideoDec/MPCVideoDecSettingsWnd.cpp index a2713a6a4..b72be5d82 100644 --- a/src/filters/transform/MPCVideoDec/MPCVideoDecSettingsWnd.cpp +++ b/src/filters/transform/MPCVideoDec/MPCVideoDecSettingsWnd.cpp @@ -83,11 +83,11 @@ bool CMPCVideoDecSettingsWnd::OnConnect(const CInterfaceList<IUnknown, &IID_IUnk m_pMDF.Release();
POSITION pos = pUnks.GetHeadPosition();
- while(pos && !(m_pMDF = pUnks.GetNext(pos))) {
+ while (pos && !(m_pMDF = pUnks.GetNext(pos))) {
;
}
- if(!m_pMDF) {
+ if (!m_pMDF) {
return false;
}
@@ -113,7 +113,7 @@ bool CMPCVideoDecSettingsWnd::OnActivate() m_cbThreadNumber.Create (WS_VISIBLE|WS_CHILD|CBS_DROPDOWNLIST|WS_VSCROLL, CRect (230, nPosY-4, 290, nPosY+90), this, IDC_PP_THREAD_NUMBER);
m_cbThreadNumber.AddString(_T("Auto"));
CString ThreadNumberStr;
- for(int i=0; i<16; i++) {
+ for (int i=0; i<16; i++) {
ThreadNumberStr.Format(_T("%d"), i+1);
m_cbThreadNumber.AddString(ThreadNumberStr);
}
@@ -192,7 +192,7 @@ bool CMPCVideoDecSettingsWnd::OnActivate() m_edtDXVAMode.ShowWindow (SW_HIDE);
}
- for(CWnd* pWnd = GetWindow(GW_CHILD); pWnd; pWnd = pWnd->GetNextWindow()) {
+ for (CWnd* pWnd = GetWindow(GW_CHILD); pWnd; pWnd = pWnd->GetNextWindow()) {
pWnd->SetFont(&m_font, FALSE);
}
@@ -228,7 +228,7 @@ bool CMPCVideoDecSettingsWnd::OnApply() {
OnDeactivate();
- if(m_pMDF && m_cbDXVACompatibilityCheck.m_hWnd) {
+ if (m_pMDF && m_cbDXVACompatibilityCheck.m_hWnd) {
#if HAS_FFMPEG_VIDEO_DECODERS
#if INTERNAL_DECODER_H264
m_pMDF->SetThreadNumber (m_cbThreadNumber.GetCurSel());
@@ -268,11 +268,11 @@ bool CMPCVideoDecCodecWnd::OnConnect(const CInterfaceList<IUnknown, &IID_IUnknow m_pMDF.Release();
POSITION pos = pUnks.GetHeadPosition();
- while(pos && !(m_pMDF = pUnks.GetNext(pos))) {
+ while (pos && !(m_pMDF = pUnks.GetNext(pos))) {
;
}
- if(!m_pMDF) {
+ if (!m_pMDF) {
return false;
}
@@ -341,7 +341,7 @@ bool CMPCVideoDecCodecWnd::OnActivate() m_lstCodecs.SetCheck (nPos++, (nActiveCodecs & MPCVD_RV) != 0);
#endif
- for(CWnd* pWnd = GetWindow(GW_CHILD); pWnd; pWnd = pWnd->GetNextWindow()) {
+ for (CWnd* pWnd = GetWindow(GW_CHILD); pWnd; pWnd = pWnd->GetNextWindow()) {
pWnd->SetFont(&m_font, FALSE);
}
@@ -356,7 +356,7 @@ bool CMPCVideoDecCodecWnd::OnApply() {
OnDeactivate();
- if(m_pMDF) {
+ if (m_pMDF) {
int nActiveCodecs = 0;
int nPos = 0;
diff --git a/src/filters/transform/MPCVideoDec/stdafx.cpp b/src/filters/transform/MPCVideoDec/stdafx.cpp index a321c46cd..61e5632a5 100644 --- a/src/filters/transform/MPCVideoDec/stdafx.cpp +++ b/src/filters/transform/MPCVideoDec/stdafx.cpp @@ -31,9 +31,9 @@ void LOG(LPCTSTR fmt, ...) {
va_list args;
va_start(args, fmt);
- if(TCHAR* buff = new TCHAR[_vsctprintf(fmt, args) + 1]) {
+ if (TCHAR* buff = new TCHAR[_vsctprintf(fmt, args) + 1]) {
_vstprintf(buff, fmt, args);
- if(FILE* f = _tfopen(LOG_FILE, _T("at"))) {
+ if (FILE* f = _tfopen(LOG_FILE, _T("at"))) {
fseek(f, 0, 2);
_ftprintf(f, _T("%s\n"), buff);
fclose(f);
diff --git a/src/filters/transform/MpaDecFilter/MpaDecFilter.cpp b/src/filters/transform/MpaDecFilter/MpaDecFilter.cpp index c81d3c1bc..03bf72bcd 100644 --- a/src/filters/transform/MpaDecFilter/MpaDecFilter.cpp +++ b/src/filters/transform/MpaDecFilter/MpaDecFilter.cpp @@ -166,10 +166,10 @@ const AMOVIESETUP_MEDIATYPE sudPinTypesIn[] = { #ifdef REGISTER_FILTER
#ifdef _WIN64
- #ifdef _DEBUG
- extern "C" int mingw_app_type = 1; /* 0:console, 1:windows. */
- #endif
- void *__imp_toupper = toupper;
+#ifdef _DEBUG
+extern "C" int mingw_app_type = 1; /* 0:console, 1:windows. */
+#endif
+void *__imp_toupper = toupper;
#endif
const AMOVIESETUP_MEDIATYPE sudPinTypesOut[] = {
@@ -324,23 +324,23 @@ CMpaDecFilter::CMpaDecFilter(LPUNKNOWN lpunk, HRESULT* phr) , m_boost(1)
, m_bResync(false)
{
- if(phr) {
+ if (phr) {
*phr = S_OK;
}
m_pInput = DNew CMpaDecInputPin(this, phr, L"In");
- if(!m_pInput) {
+ if (!m_pInput) {
*phr = E_OUTOFMEMORY;
}
- if(FAILED(*phr)) {
+ if (FAILED(*phr)) {
return;
}
m_pOutput = DNew CTransformOutputPin(NAME("CTransformOutputPin"), this, phr, L"Out");
- if(!m_pOutput) {
+ if (!m_pOutput) {
*phr = E_OUTOFMEMORY;
}
- if(FAILED(*phr)) {
+ if (FAILED(*phr)) {
delete m_pInput, m_pInput = NULL;
return;
}
@@ -365,27 +365,27 @@ CMpaDecFilter::CMpaDecFilter(LPUNKNOWN lpunk, HRESULT* phr) #ifdef REGISTER_FILTER
CRegKey key;
- if(ERROR_SUCCESS == key.Open(HKEY_CURRENT_USER, _T("Software\\Gabest\\Filters\\MPEG Audio Decoder"), KEY_READ)) {
+ if (ERROR_SUCCESS == key.Open(HKEY_CURRENT_USER, _T("Software\\Gabest\\Filters\\MPEG Audio Decoder"), KEY_READ)) {
DWORD dw;
- if(ERROR_SUCCESS == key.QueryDWORDValue(_T("SampleFormat"), dw)) {
+ if (ERROR_SUCCESS == key.QueryDWORDValue(_T("SampleFormat"), dw)) {
m_iSampleFormat = (MPCSampleFormat)dw;
}
- if(ERROR_SUCCESS == key.QueryDWORDValue(_T("Normalize"), dw)) {
+ if (ERROR_SUCCESS == key.QueryDWORDValue(_T("Normalize"), dw)) {
m_fNormalize = !!dw;
}
- if(ERROR_SUCCESS == key.QueryDWORDValue(_T("Boost"), dw)) {
+ if (ERROR_SUCCESS == key.QueryDWORDValue(_T("Boost"), dw)) {
m_boost = *(float*)&dw;
}
- if(ERROR_SUCCESS == key.QueryDWORDValue(_T("Ac3SpeakerConfig"), dw)) {
+ if (ERROR_SUCCESS == key.QueryDWORDValue(_T("Ac3SpeakerConfig"), dw)) {
m_iSpeakerConfig[ac3] = (int)dw;
}
- if(ERROR_SUCCESS == key.QueryDWORDValue(_T("DtsSpeakerConfig"), dw)) {
+ if (ERROR_SUCCESS == key.QueryDWORDValue(_T("DtsSpeakerConfig"), dw)) {
m_iSpeakerConfig[dts] = (int)dw;
}
- if(ERROR_SUCCESS == key.QueryDWORDValue(_T("Ac3DynamicRangeControl"), dw)) {
+ if (ERROR_SUCCESS == key.QueryDWORDValue(_T("Ac3DynamicRangeControl"), dw)) {
m_fDynamicRangeControl[ac3] = !!dw;
}
- if(ERROR_SUCCESS == key.QueryDWORDValue(_T("DtsDynamicRangeControl"), dw)) {
+ if (ERROR_SUCCESS == key.QueryDWORDValue(_T("DtsDynamicRangeControl"), dw)) {
m_fDynamicRangeControl[dts] = !!dw;
}
}
@@ -484,12 +484,12 @@ HRESULT CMpaDecFilter::Receive(IMediaSample* pIn) HRESULT hr;
AM_SAMPLE2_PROPERTIES* const pProps = m_pInput->SampleProps();
- if(pProps->dwStreamId != AM_STREAM_MEDIA) {
+ if (pProps->dwStreamId != AM_STREAM_MEDIA) {
return m_pOutput->Deliver(pIn);
}
AM_MEDIA_TYPE* pmt;
- if(SUCCEEDED(pIn->GetMediaType(&pmt)) && pmt) {
+ if (SUCCEEDED(pIn->GetMediaType(&pmt)) && pmt) {
CMediaType mt(*pmt);
m_pInput->SetMediaType(&mt);
DeleteMediaType(pmt);
@@ -499,7 +499,7 @@ HRESULT CMpaDecFilter::Receive(IMediaSample* pIn) }
BYTE* pDataIn = NULL;
- if(FAILED(hr = pIn->GetPointer(&pDataIn))) {
+ if (FAILED(hr = pIn->GetPointer(&pDataIn))) {
return hr;
}
@@ -510,29 +510,29 @@ HRESULT CMpaDecFilter::Receive(IMediaSample* pIn) REFERENCE_TIME rtStart = _I64_MIN, rtStop = _I64_MIN;
hr = pIn->GetTime(&rtStart, &rtStop);
- if(SUCCEEDED(hr)) {
+ if (SUCCEEDED(hr)) {
TRACE(_T("CMpaDecFilter::Receive(): rtStart = %10I64d, rtStop = %10I64d\n"), rtStart, rtStop);
} else {
TRACE(_T("CMpaDecFilter::Receive(): frame without timestamp\n"));
}
- if(pIn->IsDiscontinuity() == S_OK) {
+ if (pIn->IsDiscontinuity() == S_OK) {
m_fDiscontinuity = true;
m_buff.RemoveAll();
m_rtStart = rtStart;
m_sample_max = 0.1f;
m_bResync = true;
- if(FAILED(hr)) {
+ if (FAILED(hr)) {
TRACE(_T("CMpaDecFilter::Receive() : Discontinuity without timestamp\n"));
return S_OK;
}
}
- if(SUCCEEDED(hr) && ((_abs64((m_rtStart - rtStart)) > MAX_JITTER) || m_bResync)) {
- m_buff.RemoveAll();
+ if (SUCCEEDED(hr) && ((_abs64((m_rtStart - rtStart)) > MAX_JITTER) || m_bResync)) {
+ m_buff.RemoveAll();
m_rtStart = rtStart;
m_bResync = false;
- }
+ }
int bufflen = m_buff.GetCount();
m_buff.SetCount(bufflen + len, 4096);
@@ -543,81 +543,81 @@ HRESULT CMpaDecFilter::Receive(IMediaSample* pIn) #if defined(REGISTER_FILTER) | HAS_FFMPEG_AUDIO_DECODERS
enum CodecID nCodecId = FindCodec(subtype);
- if(nCodecId != CODEC_ID_NONE) {
+ if (nCodecId != CODEC_ID_NONE) {
return ProcessFFmpeg(nCodecId);
}
#endif
- if(0) {} // needed if decoders are disabled below
+ if (0) {} // needed if decoders are disabled below
#if defined(REGISTER_FILTER) | INTERNAL_DECODER_LPCM
- else if(subtype == MEDIASUBTYPE_DVD_LPCM_AUDIO) {
+ else if (subtype == MEDIASUBTYPE_DVD_LPCM_AUDIO) {
hr = ProcessLPCM();
- } else if(subtype == MEDIASUBTYPE_HDMV_LPCM_AUDIO) {
+ } else if (subtype == MEDIASUBTYPE_HDMV_LPCM_AUDIO) {
hr = ProcessHdmvLPCM(!!pIn->IsSyncPoint());
}
#endif
#if defined(REGISTER_FILTER) | INTERNAL_DECODER_AC3
- else if(subtype == MEDIASUBTYPE_DOLBY_AC3 ||
- subtype == MEDIASUBTYPE_WAVE_DOLBY_AC3 ||
- subtype == MEDIASUBTYPE_DOLBY_DDPLUS ||
- subtype == MEDIASUBTYPE_DOLBY_TRUEHD) {
+ else if (subtype == MEDIASUBTYPE_DOLBY_AC3 ||
+ subtype == MEDIASUBTYPE_WAVE_DOLBY_AC3 ||
+ subtype == MEDIASUBTYPE_DOLBY_DDPLUS ||
+ subtype == MEDIASUBTYPE_DOLBY_TRUEHD) {
hr = ProcessAC3();
}
#endif
#if defined(REGISTER_FILTER) | INTERNAL_DECODER_DTS
- else if(subtype == MEDIASUBTYPE_DTS || subtype == MEDIASUBTYPE_WAVE_DTS) {
+ else if (subtype == MEDIASUBTYPE_DTS || subtype == MEDIASUBTYPE_WAVE_DTS) {
hr = ProcessDTS();
}
#endif
#if defined(REGISTER_FILTER) | INTERNAL_DECODER_PS2AUDIO
- else if(subtype == MEDIASUBTYPE_PS2_PCM) {
+ else if (subtype == MEDIASUBTYPE_PS2_PCM) {
hr = ProcessPS2PCM();
- } else if(subtype == MEDIASUBTYPE_PS2_ADPCM) {
+ } else if (subtype == MEDIASUBTYPE_PS2_ADPCM) {
hr = ProcessPS2ADPCM();
}
#endif
#if defined(REGISTER_FILTER) | INTERNAL_DECODER_FLAC
- else if(subtype == MEDIASUBTYPE_FLAC_FRAMED) {
+ else if (subtype == MEDIASUBTYPE_FLAC_FRAMED) {
hr = ProcessFlac();
}
#endif
#if defined(REGISTER_FILTER) | INTERNAL_DECODER_PCM
- else if(subtype == MEDIASUBTYPE_PCM_NONE ||
- subtype == MEDIASUBTYPE_PCM_RAW) {
- if(m_buff.GetCount() < 480) {
+ else if (subtype == MEDIASUBTYPE_PCM_NONE ||
+ subtype == MEDIASUBTYPE_PCM_RAW) {
+ if (m_buff.GetCount() < 480) {
return S_OK;
}
hr = ProcessPCMraw();
- } else if(subtype == MEDIASUBTYPE_PCM_TWOS) {
- if(m_buff.GetCount() < 960) {
+ } else if (subtype == MEDIASUBTYPE_PCM_TWOS) {
+ if (m_buff.GetCount() < 960) {
return S_OK;
}
hr = ProcessPCMintBE();
- } else if(subtype == MEDIASUBTYPE_PCM_SOWT) {
- if(m_buff.GetCount() < 960) {
+ } else if (subtype == MEDIASUBTYPE_PCM_SOWT) {
+ if (m_buff.GetCount() < 960) {
return S_OK;
}
hr = ProcessPCMintLE();
- } else if(subtype == MEDIASUBTYPE_PCM_IN24 ||
- subtype == MEDIASUBTYPE_PCM_IN32) {
- if(m_buff.GetCount() < 1920) {
+ } else if (subtype == MEDIASUBTYPE_PCM_IN24 ||
+ subtype == MEDIASUBTYPE_PCM_IN32) {
+ if (m_buff.GetCount() < 1920) {
return S_OK;
}
hr = ProcessPCMintBE();
- } else if(subtype == MEDIASUBTYPE_PCM_IN24_le ||
- subtype == MEDIASUBTYPE_PCM_IN32_le) {
- if(m_buff.GetCount() < 1920) {
+ } else if (subtype == MEDIASUBTYPE_PCM_IN24_le ||
+ subtype == MEDIASUBTYPE_PCM_IN32_le) {
+ if (m_buff.GetCount() < 1920) {
return S_OK;
}
hr = ProcessPCMintLE();
- } else if(subtype == MEDIASUBTYPE_PCM_FL32 ||
- subtype == MEDIASUBTYPE_PCM_FL64) {
- if(m_buff.GetCount() < 3840) {
+ } else if (subtype == MEDIASUBTYPE_PCM_FL32 ||
+ subtype == MEDIASUBTYPE_PCM_FL64) {
+ if (m_buff.GetCount() < 3840) {
return S_OK;
}
hr = ProcessPCMfloatBE();
- } else if(subtype == MEDIASUBTYPE_PCM_FL32_le ||
- subtype == MEDIASUBTYPE_PCM_FL64_le) {
- if(m_buff.GetCount() < 3840) {
+ } else if (subtype == MEDIASUBTYPE_PCM_FL32_le ||
+ subtype == MEDIASUBTYPE_PCM_FL64_le) {
+ if (m_buff.GetCount() < 3840) {
return S_OK;
}
hr = ProcessPCMfloatLE();
@@ -655,25 +655,25 @@ HRESULT CMpaDecFilter::ProcessLPCM() long nSamples = len/(BytesPerDoubleChannelSample);
int16 Temp[2][8];
for (int i=0; i<nSamples; i++) {
- for(int j = 0; j < nChannels; j++) {
+ for (int j = 0; j < nChannels; j++) {
uint16 All = *((uint16 *)pDataIn);
pDataIn += 2;
int16 Part1 = (All & 0xFF) << 8 | (All & 0xFF00) >> 8;
Temp[0][j] = Part1;
}
- for(int j = 0; j < nChannels; j++) {
+ for (int j = 0; j < nChannels; j++) {
uint16 All = *((uint16 *)pDataIn);
pDataIn += 2;
int16 Part1 = (All & 0xFF) << 8 | (All & 0xFF00) >> 8;
Temp[1][j] = Part1;
}
- for(int j = 0; j < nChannels; j++) {
+ for (int j = 0; j < nChannels; j++) {
int nRemap = remap->ch[j];
*pDataOut = float(Temp[0][nRemap]) / float(SHRT_MAX);
++pDataOut;
}
- for(int j = 0; j < nChannels; j++) {
+ for (int j = 0; j < nChannels; j++) {
int nRemap = remap->ch[j];
*pDataOut = float(Temp[1][nRemap]) / float(SHRT_MAX);
++pDataOut;
@@ -687,13 +687,13 @@ HRESULT CMpaDecFilter::ProcessLPCM() int32 Temp[2][8];
for (int i=0; i<nSamples; i++) {
// Start by upper 16 bits
- for(int j = 0; j < nChannels; j++) {
+ for (int j = 0; j < nChannels; j++) {
uint32 All = *((uint16 *)pDataIn);
pDataIn += 2;
uint32 Part1 = (All & 0xFF) << 24 | (All & 0xFF00) << 8;
Temp[0][j] = Part1;
}
- for(int j = 0; j < nChannels; j++) {
+ for (int j = 0; j < nChannels; j++) {
uint32 All = *((uint16 *)pDataIn);
pDataIn += 2;
uint32 Part1 = (All & 0xFF) << 24 | (All & 0xFF00) << 8;
@@ -701,24 +701,24 @@ HRESULT CMpaDecFilter::ProcessLPCM() }
// Continue with lower bits
- for(int j = 0; j < nChannels; j++) {
+ for (int j = 0; j < nChannels; j++) {
uint32 All = *((uint8 *)pDataIn);
pDataIn += 1;
Temp[0][j] = int32(Temp[0][j] | (All << 8)) >> 8;
}
- for(int j = 0; j < nChannels; j++) {
+ for (int j = 0; j < nChannels; j++) {
uint32 All = *((uint8 *)pDataIn);
pDataIn += 1;
Temp[1][j] = int32(Temp[1][j] | (All << 8)) >> 8;
}
// Convert into float
- for(int j = 0; j < nChannels; j++) {
+ for (int j = 0; j < nChannels; j++) {
int nRemap = remap->ch[j];
*pDataOut = float(Temp[0][nRemap]) / float(1<<23);
++pDataOut;
}
- for(int j = 0; j < nChannels; j++) {
+ for (int j = 0; j < nChannels; j++) {
int nRemap = remap->ch[j];
*pDataOut = float(Temp[1][nRemap]) / float(1<<23);
++pDataOut;
@@ -731,13 +731,13 @@ HRESULT CMpaDecFilter::ProcessLPCM() int32 Temp[2][8];
for (int i=0; i<nSamples; i++) {
// Start by upper 16 bits
- for(int j = 0; j < nChannels; j++) {
+ for (int j = 0; j < nChannels; j++) {
uint32 All = *((uint16 *)pDataIn);
pDataIn += 2;
uint32 Part1 = (All & 0xFF) << 24 | (All & 0xFF00) << 8;
Temp[0][j] = Part1;
}
- for(int j = 0; j < nChannels; j++) {
+ for (int j = 0; j < nChannels; j++) {
uint32 All = *((uint16 *)pDataIn);
pDataIn += 2;
uint32 Part1 = (All & 0xFF) << 24 | (All & 0xFF00) << 8;
@@ -745,7 +745,7 @@ HRESULT CMpaDecFilter::ProcessLPCM() }
// Continue with lower bits
- for(int j = 0; j < nChannels; j++) {
+ for (int j = 0; j < nChannels; j++) {
uint32 All = *((uint8 *)pDataIn);
pDataIn += 1;
Temp[0][j] = int32(Temp[0][j] | ((All&0xf0) << 8)) >> 8;
@@ -753,12 +753,12 @@ HRESULT CMpaDecFilter::ProcessLPCM() }
// Convert into float
- for(int j = 0; j < nChannels; j++) {
+ for (int j = 0; j < nChannels; j++) {
int nRemap = remap->ch[j];
*pDataOut = float(Temp[0][nRemap]) / float(1<<23);
++pDataOut;
}
- for(int j = 0; j < nChannels; j++) {
+ for (int j = 0; j < nChannels; j++) {
int nRemap = remap->ch[j];
*pDataOut = float(Temp[1][nRemap]) / float(1<<23);
++pDataOut;
@@ -799,7 +799,7 @@ HRESULT CMpaDecFilter::ProcessHdmvLPCM(bool bAlignOldBuffer) // Blu ray LPCM switch (wfein->wBitsPerSample) {
case 16 :
for (int i=0; i<nFrames; i++) {
- for(int j = 0; j < nChannels; j++) {
+ for (int j = 0; j < nChannels; j++) {
BYTE nRemap = remap->ch[j];
*pDataOut = (float)(short)(pDataIn[nRemap*2]<<8 | pDataIn[nRemap*2+1]) / 32768;
pDataOut++;
@@ -810,7 +810,7 @@ HRESULT CMpaDecFilter::ProcessHdmvLPCM(bool bAlignOldBuffer) // Blu ray LPCM case 24 :
case 20 :
for (int i=0; i<nFrames; i++) {
- for(int j = 0; j < nChannels; j++) {
+ for (int j = 0; j < nChannels; j++) {
BYTE nRemap = remap->ch[j];
*pDataOut = (float)(long)(pDataIn[nRemap*3]<<24 | pDataIn[nRemap*3+1]<<16 | pDataIn[nRemap*3+2]<<8) / 0x80000000;
pDataOut++;
@@ -831,17 +831,17 @@ HRESULT CMpaDecFilter::ProcessA52(BYTE* p, int buffsize, int& size, bool& fEnoug {
int flags, sample_rate, bit_rate;
- if((size = a52_syncinfo(p, &flags, &sample_rate, &bit_rate)) > 0) {
+ if ((size = a52_syncinfo(p, &flags, &sample_rate, &bit_rate)) > 0) {
// TRACE(_T("ac3: size=%d, flags=%08x, sample_rate=%d, bit_rate=%d\n"), size, flags, sample_rate, bit_rate);
fEnoughData = size <= buffsize;
- if(fEnoughData) {
+ if (fEnoughData) {
int iSpeakerConfig = GetSpeakerConfig(ac3);
- if(iSpeakerConfig < 0) {
+ if (iSpeakerConfig < 0) {
HRESULT hr;
- if(S_OK != (hr = DeliverBitstream(p, size, sample_rate, 1536, 0x0001))) {
+ if (S_OK != (hr = DeliverBitstream(p, size, sample_rate, 1536, 0x0001))) {
return hr;
}
} else {
@@ -851,8 +851,8 @@ HRESULT CMpaDecFilter::ProcessA52(BYTE* p, int buffsize, int& size, bool& fEnoug sample_t level = 1, gain = 1, bias = 0;
level *= gain;
- if(a52_frame(m_a52_state, p, &flags, &level, bias) == 0) {
- if(GetDynamicRangeControl(ac3)) {
+ if (a52_frame(m_a52_state, p, &flags, &level, bias) == 0) {
+ if (GetDynamicRangeControl(ac3)) {
a52_dynrng(m_a52_state, NULL, NULL);
}
@@ -865,20 +865,20 @@ HRESULT CMpaDecFilter::ProcessA52(BYTE* p, int buffsize, int& size, bool& fEnoug int i = 0;
- for(; i < 6 && a52_block(m_a52_state) == 0; i++) {
+ for (; i < 6 && a52_block(m_a52_state) == 0; i++) {
sample_t* samples = a52_samples(m_a52_state);
- for(int j = 0; j < 256; j++, samples++) {
- for(int ch = 0; ch < scmap.nChannels; ch++) {
+ for (int j = 0; j < 256; j++, samples++) {
+ for (int ch = 0; ch < scmap.nChannels; ch++) {
ASSERT(scmap.ch[ch] != -1);
*p++ = (float)(*(samples + 256*scmap.ch[ch]) / level);
}
}
}
- if(i == 6) {
+ if (i == 6) {
HRESULT hr;
- if(S_OK != (hr = Deliver(pBuff, sample_rate, scmap.nChannels, scmap.dwChannelMask))) {
+ if (S_OK != (hr = Deliver(pBuff, sample_rate, scmap.nChannels, scmap.dwChannelMask))) {
return hr;
}
}
@@ -898,20 +898,20 @@ HRESULT CMpaDecFilter::ProcessAC3() BYTE* base = p;
BYTE* end = p + m_buff.GetCount();
- while(end - p >= 7) {
+ while (end - p >= 7) {
int size = 0, flags, sample_rate, bit_rate;
- if((size = a52_syncinfo(p, &flags, &sample_rate, &bit_rate)) > 0) {
+ if ((size = a52_syncinfo(p, &flags, &sample_rate, &bit_rate)) > 0) {
// TRACE(_T("ac3: size=%d, flags=%08x, sample_rate=%d, bit_rate=%d\n"), size, flags, sample_rate, bit_rate);
bool fEnoughData = p + size <= end;
- if(fEnoughData) {
+ if (fEnoughData) {
int iSpeakerConfig = GetSpeakerConfig(ac3);
- if(iSpeakerConfig < 0) {
+ if (iSpeakerConfig < 0) {
HRESULT hr;
- if(S_OK != (hr = Deliver(p, size, bit_rate, 0x0001))) {
+ if (S_OK != (hr = Deliver(p, size, bit_rate, 0x0001))) {
return hr;
}
} else {
@@ -921,8 +921,8 @@ HRESULT CMpaDecFilter::ProcessAC3() sample_t level = 1, gain = 1, bias = 0;
level *= gain;
- if(a52_frame(m_a52_state, p, &flags, &level, bias) == 0) {
- if(GetDynamicRangeControl(ac3)) {
+ if (a52_frame(m_a52_state, p, &flags, &level, bias) == 0) {
+ if (GetDynamicRangeControl(ac3)) {
a52_dynrng(m_a52_state, NULL, NULL);
}
@@ -935,20 +935,20 @@ HRESULT CMpaDecFilter::ProcessAC3() int i = 0;
- for(; i < 6 && a52_block(m_a52_state) == 0; i++) {
+ for (; i < 6 && a52_block(m_a52_state) == 0; i++) {
sample_t* samples = a52_samples(m_a52_state);
- for(int j = 0; j < 256; j++, samples++) {
- for(int ch = 0; ch < scmap.nChannels; ch++) {
+ for (int j = 0; j < 256; j++, samples++) {
+ for (int ch = 0; ch < scmap.nChannels; ch++) {
ASSERT(scmap.ch[ch] != -1);
*p++ = (float)(*(samples + 256*scmap.ch[ch]) / level);
}
}
}
- if(i == 6) {
+ if (i == 6) {
HRESULT hr;
- if(S_OK != (hr = Deliver(pBuff, sample_rate, scmap.nChannels, scmap.dwChannelMask))) {
+ if (S_OK != (hr = Deliver(pBuff, sample_rate, scmap.nChannels, scmap.dwChannelMask))) {
return hr;
}
}
@@ -962,7 +962,7 @@ HRESULT CMpaDecFilter::ProcessAC3() end = base + (end - p);
p = base;
- if(!fEnoughData) {
+ if (!fEnoughData) {
break;
}
} else {
@@ -984,7 +984,7 @@ HRESULT CMpaDecFilter::ProcessAC3() BYTE* base = p;
BYTE* end = p + m_buff.GetCount();
- while(p < end && end - p >= AC3_HEADER_SIZE) {
+ while (p < end && end - p >= AC3_HEADER_SIZE) {
int size = 0;
bool fEnoughData = true;
@@ -1045,7 +1045,7 @@ HRESULT CMpaDecFilter::ProcessAC3() memmove(base, p, end - p);
end = base + (end - p);
p = base;
- if(!fEnoughData) {
+ if (!fEnoughData) {
break;
}
}
@@ -1072,7 +1072,7 @@ HRESULT CMpaDecFilter::ProcessFFmpeg(enum CodecID nCodecId) m_bResync = true;
return S_OK;
}
-
+
if (size <= 0) {
return hr;
}
@@ -1093,21 +1093,21 @@ HRESULT CMpaDecFilter::ProcessDTS() BYTE* base = p;
BYTE* end = p + m_buff.GetCount();
- while(end - p >= 14) {
+ while (end - p >= 14) {
int size = 0, flags, sample_rate, bit_rate, frame_length;
- if((size = dts_syncinfo(m_dts_state, p, &flags, &sample_rate, &bit_rate, &frame_length)) > 0) {
+ if ((size = dts_syncinfo(m_dts_state, p, &flags, &sample_rate, &bit_rate, &frame_length)) > 0) {
// TRACE(_T("dts: size=%d, flags=%08x, sample_rate=%d, bit_rate=%d, frame_length=%d\n"), size, flags, sample_rate, bit_rate, frame_length);
bit_rate = int (size * 8i64 * sample_rate / frame_length); // calculate actual bitrate
bool fEnoughData = p + size <= end;
- if(fEnoughData) {
+ if (fEnoughData) {
int iSpeakerConfig = GetSpeakerConfig(dts);
- if(iSpeakerConfig < 0) {
+ if (iSpeakerConfig < 0) {
HRESULT hr;
- if(S_OK != (hr = DeliverBitstream(p, size, sample_rate, frame_length, 0x000b))) {
+ if (S_OK != (hr = DeliverBitstream(p, size, sample_rate, frame_length, 0x000b))) {
return hr;
}
} else {
@@ -1117,8 +1117,8 @@ HRESULT CMpaDecFilter::ProcessDTS() sample_t level = 1, gain = 1, bias = 0;
level *= gain;
- if(dts_frame(m_dts_state, p, &flags, &level, bias) == 0) {
- if(GetDynamicRangeControl(dts)) {
+ if (dts_frame(m_dts_state, p, &flags, &level, bias) == 0) {
+ if (GetDynamicRangeControl(dts)) {
dts_dynrng(m_dts_state, NULL, NULL);
}
@@ -1133,20 +1133,20 @@ HRESULT CMpaDecFilter::ProcessDTS() int i = 0;
- for(; i < blocks && dts_block(m_dts_state) == 0; i++) {
+ for (; i < blocks && dts_block(m_dts_state) == 0; i++) {
sample_t* samples = dts_samples(m_dts_state);
- for(int j = 0; j < 256; j++, samples++) {
- for(int ch = 0; ch < scmap.nChannels; ch++) {
+ for (int j = 0; j < 256; j++, samples++) {
+ for (int ch = 0; ch < scmap.nChannels; ch++) {
ASSERT(scmap.ch[ch] != -1);
*p++ = (float)(*(samples + 256*scmap.ch[ch]) / level);
}
}
}
- if(i == blocks) {
+ if (i == blocks) {
HRESULT hr;
- if(S_OK != (hr = Deliver(pBuff, sample_rate, scmap.nChannels, scmap.dwChannelMask))) {
+ if (S_OK != (hr = Deliver(pBuff, sample_rate, scmap.nChannels, scmap.dwChannelMask))) {
return hr;
}
}
@@ -1160,7 +1160,7 @@ HRESULT CMpaDecFilter::ProcessDTS() end = base + (end - p);
p = base;
- if(!fEnoughData) {
+ if (!fEnoughData) {
break;
}
} else {
@@ -1184,17 +1184,17 @@ HRESULT CMpaDecFilter::ProcessPCMraw() //'raw ' pBuff.SetCount(nSamples);
float* f = pBuff.GetData();
- switch(wfe->wBitsPerSample) {
+ switch (wfe->wBitsPerSample) {
case 8: { //unsigned 8-bit
BYTE* b = m_buff.GetData();
- for(int i = 0; i < nSamples; i++) {
+ for (int i = 0; i < nSamples; i++) {
f[i] = (float)(CHAR)(b[i] - 128) / 128;
}
}
break;
case 16: { //signed big-endian 16 bit
USHORT* d = (USHORT*)m_buff.GetData();//signed take as an unsigned to shift operations.
- for(int i = 0; i < nSamples; i++) {
+ for (int i = 0; i < nSamples; i++) {
f[i] = (float)(SHORT)(d[i] << 8 | d[i] >> 8) / 32768;
}
}
@@ -1202,7 +1202,7 @@ HRESULT CMpaDecFilter::ProcessPCMraw() //'raw ' }
HRESULT hr;
- if(S_OK != (hr = Deliver(pBuff, wfe->nSamplesPerSec, wfe->nChannels))) {
+ if (S_OK != (hr = Deliver(pBuff, wfe->nSamplesPerSec, wfe->nChannels))) {
return hr;
}
@@ -1219,24 +1219,24 @@ HRESULT CMpaDecFilter::ProcessPCMintBE() //'twos', big-endian 'in24' and 'in32' pBuff.SetCount(nSamples);
float* f = pBuff.GetData();
- switch(wfe->wBitsPerSample) {
+ switch (wfe->wBitsPerSample) {
case 8: { //signed 8-bit
CHAR* b = (CHAR*)m_buff.GetData();
- for(int i = 0; i < nSamples; i++) {
+ for (int i = 0; i < nSamples; i++) {
f[i] = (float)b[i] / 128;
}
}
break;
case 16: { //signed big-endian 16-bit
USHORT* d = (USHORT*)m_buff.GetData();//signed take as an unsigned to shift operations.
- for(int i = 0; i < nSamples; i++) {
+ for (int i = 0; i < nSamples; i++) {
f[i] = (float)(SHORT)(d[i] << 8 | d[i] >> 8) / 32768;
}
}
break;
case 24: { //signed big-endian 24-bit
BYTE* b = (BYTE*)m_buff.GetData();
- for(int i = 0; i < nSamples; i++) {
+ for (int i = 0; i < nSamples; i++) {
f[i] = (float)(signed int)((unsigned int)b[3*i] << 24 |
(unsigned int)b[3*i+1] << 16 |
(unsigned int)b[3*i+2] << 8) / 2147483648;
@@ -1245,7 +1245,7 @@ HRESULT CMpaDecFilter::ProcessPCMintBE() //'twos', big-endian 'in24' and 'in32' break;
case 32: { //signed big-endian 32-bit
UINT* q = (UINT*)m_buff.GetData();//signed take as an unsigned to shift operations.
- for(int i = 0; i < nSamples; i++) {
+ for (int i = 0; i < nSamples; i++) {
f[i] = (float)(INT)(q[i] >> 24 |
(q[i] & 0x00ff0000) >> 8 |
(q[i] & 0x0000ff00) << 8 |
@@ -1256,7 +1256,7 @@ HRESULT CMpaDecFilter::ProcessPCMintBE() //'twos', big-endian 'in24' and 'in32' }
HRESULT hr;
- if(S_OK != (hr = Deliver(pBuff, wfe->nSamplesPerSec, wfe->nChannels))) {
+ if (S_OK != (hr = Deliver(pBuff, wfe->nSamplesPerSec, wfe->nChannels))) {
return hr;
}
@@ -1273,24 +1273,24 @@ HRESULT CMpaDecFilter::ProcessPCMintLE() //'sowt', little-endian 'in24' and 'in3 pBuff.SetCount(nSamples);
float* f = pBuff.GetData();
- switch(wfe->wBitsPerSample) {
+ switch (wfe->wBitsPerSample) {
case 8: { //signed 8-bit
CHAR* b = (CHAR*)m_buff.GetData();
- for(int i = 0; i < nSamples; i++) {
+ for (int i = 0; i < nSamples; i++) {
f[i] = (float)b[i] / 128;
}
}
break;
case 16: { //signed little-endian 16-bit
SHORT* d = (SHORT*)m_buff.GetData();
- for(int i = 0; i < nSamples; i++) {
+ for (int i = 0; i < nSamples; i++) {
f[i] = (float)d[i] / 32768;
}
}
break;
case 24: { //signed little-endian 32-bit
BYTE* b = (BYTE*)m_buff.GetData();
- for(int i = 0; i < nSamples; i++) {
+ for (int i = 0; i < nSamples; i++) {
f[i] = (float)(signed int)((unsigned int)b[3*i] << 8 |
(unsigned int)b[3*i+1] << 16 |
(unsigned int)b[3*i+2] << 24) / 2147483648;
@@ -1299,7 +1299,7 @@ HRESULT CMpaDecFilter::ProcessPCMintLE() //'sowt', little-endian 'in24' and 'in3 break;
case 32: { //signed little-endian 32-bit
INT* q = (INT*)m_buff.GetData();
- for(int i = 0; i < nSamples; i++) {
+ for (int i = 0; i < nSamples; i++) {
f[i] = (float)q[i] / 2147483648;
}
}
@@ -1307,7 +1307,7 @@ HRESULT CMpaDecFilter::ProcessPCMintLE() //'sowt', little-endian 'in24' and 'in3 }
HRESULT hr;
- if(S_OK != (hr = Deliver(pBuff, wfe->nSamplesPerSec, wfe->nChannels))) {
+ if (S_OK != (hr = Deliver(pBuff, wfe->nSamplesPerSec, wfe->nChannels))) {
return hr;
}
@@ -1324,11 +1324,11 @@ HRESULT CMpaDecFilter::ProcessPCMfloatBE() //big-endian 'fl32' and 'fl64' pBuff.SetCount(nSamples);
float* f = pBuff.GetData();
- switch(wfe->wBitsPerSample) {
+ switch (wfe->wBitsPerSample) {
case 32: {
unsigned int* q = (unsigned int*)m_buff.GetData();
unsigned int* vf = (unsigned int*)f;
- for(int i = 0; i < nSamples; i++) {
+ for (int i = 0; i < nSamples; i++) {
vf[i] = q[i] >> 24 |
(q[i] & 0x00ff0000) >> 8 |
(q[i] & 0x0000ff00) << 8 |
@@ -1339,7 +1339,7 @@ HRESULT CMpaDecFilter::ProcessPCMfloatBE() //big-endian 'fl32' and 'fl64' case 64: {
unsigned __int64* q = (unsigned __int64*)m_buff.GetData();
unsigned __int64 x;
- for(int i = 0; i < nSamples; i++) {
+ for (int i = 0; i < nSamples; i++) {
x = q[i] >>56 |
(q[i] & 0x00FF000000000000) >> 40 |
(q[i] & 0x0000FF0000000000) >> 24 |
@@ -1355,7 +1355,7 @@ HRESULT CMpaDecFilter::ProcessPCMfloatBE() //big-endian 'fl32' and 'fl64' }
HRESULT hr;
- if(S_OK != (hr = Deliver(pBuff, wfe->nSamplesPerSec, wfe->nChannels))) {
+ if (S_OK != (hr = Deliver(pBuff, wfe->nSamplesPerSec, wfe->nChannels))) {
return hr;
}
@@ -1372,17 +1372,17 @@ HRESULT CMpaDecFilter::ProcessPCMfloatLE() //little-endian 'fl32' and 'fl64' pBuff.SetCount(nSamples);
float* f = pBuff.GetData();
- switch(wfe->wBitsPerSample) {
+ switch (wfe->wBitsPerSample) {
case 32: {
float* q = (float*)m_buff.GetData();
- for(int i = 0; i < nSamples; i++) {
+ for (int i = 0; i < nSamples; i++) {
f[i] = q[i];
}
}
break;
case 64: {
double* q = (double*)m_buff.GetData();
- for(int i = 0; i < nSamples; i++) {
+ for (int i = 0; i < nSamples; i++) {
f[i] = (float)q[i];
}
}
@@ -1390,7 +1390,7 @@ HRESULT CMpaDecFilter::ProcessPCMfloatLE() //little-endian 'fl32' and 'fl64' }
HRESULT hr;
- if(S_OK != (hr = Deliver(pBuff, wfe->nSamplesPerSec, wfe->nChannels))) {
+ if (S_OK != (hr = Deliver(pBuff, wfe->nSamplesPerSec, wfe->nChannels))) {
return hr;
}
@@ -1415,30 +1415,30 @@ HRESULT CMpaDecFilter::ProcessPS2PCM() pBuff.SetCount(samples*channels);
float* f = pBuff.GetData();
- while(end - p >= size) {
+ while (end - p >= size) {
DWORD* dw = (DWORD*)p;
- if(dw[0] == 'dhSS') {
+ if (dw[0] == 'dhSS') {
p += dw[1] + 8;
- } else if(dw[0] == 'dbSS') {
+ } else if (dw[0] == 'dbSS') {
p += 8;
m_ps2_state.sync = true;
} else {
- if(m_ps2_state.sync) {
+ if (m_ps2_state.sync) {
short* s = (short*)p;
- for(int i = 0; i < samples; i++)
- for(int j = 0; j < channels; j++) {
+ for (int i = 0; i < samples; i++)
+ for (int j = 0; j < channels; j++) {
f[i*channels+j] = (float)s[j*samples+i] / 32768;
}
} else {
- for(int i = 0, j = samples*channels; i < j; i++) {
+ for (int i = 0, j = samples*channels; i < j; i++) {
f[i] = 0;
}
}
HRESULT hr;
- if(S_OK != (hr = Deliver(pBuff, wfe->nSamplesPerSec, wfe->nChannels))) {
+ if (S_OK != (hr = Deliver(pBuff, wfe->nSamplesPerSec, wfe->nChannels))) {
return hr;
}
@@ -1462,7 +1462,7 @@ static void decodeps2adpcm(ps2_state_t& s, int channel, BYTE* pin, double* pout) int unk = pin[1]; // ?
UNUSED_ALWAYS(unk);
- if(tbl_index >= 10) {
+ if (tbl_index >= 10) {
ASSERT(0);
return;
}
@@ -1477,7 +1477,7 @@ static void decodeps2adpcm(ps2_state_t& s, int channel, BYTE* pin, double* pout) double& a = s.a[channel];
double& b = s.b[channel];
- for(int i = 0; i < 28; i++) {
+ for (int i = 0; i < 28; i++) {
short input = (short)(((pin[2+i/2] >> ((i&1) << 2)) & 0xf) << 12) >> shift;
double output = a * tbl[1] + b * tbl[0] + input;
@@ -1503,37 +1503,37 @@ HRESULT CMpaDecFilter::ProcessPS2ADPCM() pBuff.SetCount(samples*channels);
float* f = pBuff.GetData();
- while(end - p >= size) {
+ while (end - p >= size) {
DWORD* dw = (DWORD*)p;
- if(dw[0] == 'dhSS') {
+ if (dw[0] == 'dhSS') {
p += dw[1] + 8;
- } else if(dw[0] == 'dbSS') {
+ } else if (dw[0] == 'dbSS') {
p += 8;
m_ps2_state.sync = true;
} else {
- if(m_ps2_state.sync) {
+ if (m_ps2_state.sync) {
double* tmp = DNew double[samples*channels];
- for(int channel = 0, j = 0, k = 0; channel < channels; channel++, j += wfe->dwInterleave)
- for(DWORD i = 0; i < wfe->dwInterleave; i += 16, k += 28) {
+ for (int channel = 0, j = 0, k = 0; channel < channels; channel++, j += wfe->dwInterleave)
+ for (DWORD i = 0; i < wfe->dwInterleave; i += 16, k += 28) {
decodeps2adpcm(m_ps2_state, channel, p + i + j, tmp + k);
}
- for(int i = 0, k = 0; i < samples; i++)
- for(int j = 0; j < channels; j++, k++) {
+ for (int i = 0, k = 0; i < samples; i++)
+ for (int j = 0; j < channels; j++, k++) {
f[k] = (float)tmp[j*samples+i];
}
delete [] tmp;
} else {
- for(int i = 0, j = samples*channels; i < j; i++) {
+ for (int i = 0, j = samples*channels; i < j; i++) {
f[i] = 0;
}
}
HRESULT hr;
- if(S_OK != (hr = Deliver(pBuff, wfe->nSamplesPerSec, wfe->nChannels))) {
+ if (S_OK != (hr = Deliver(pBuff, wfe->nSamplesPerSec, wfe->nChannels))) {
return hr;
}
@@ -1567,13 +1567,13 @@ HRESULT CMpaDecFilter::GetDeliveryBuffer(IMediaSample** pSample, BYTE** pData) HRESULT hr;
*pData = NULL;
- if(FAILED(hr = m_pOutput->GetDeliveryBuffer(pSample, NULL, NULL, 0))
+ if (FAILED(hr = m_pOutput->GetDeliveryBuffer(pSample, NULL, NULL, 0))
|| FAILED(hr = (*pSample)->GetPointer(pData))) {
return hr;
}
AM_MEDIA_TYPE* pmt = NULL;
- if(SUCCEEDED((*pSample)->GetMediaType(&pmt)) && pmt) {
+ if (SUCCEEDED((*pSample)->GetMediaType(&pmt)) && pmt) {
CMediaType mt = *pmt;
m_pOutput->SetMediaType(&mt);
DeleteMediaType(pmt);
@@ -1594,13 +1594,13 @@ HRESULT CMpaDecFilter::Deliver(CAtlArray<float>& pBuff, DWORD nSamplesPerSec, WO int nSamples = pBuff.GetCount()/wfe->nChannels;
- if(FAILED(hr = ReconnectOutput(nSamples, mt))) {
+ if (FAILED(hr = ReconnectOutput(nSamples, mt))) {
return hr;
}
CComPtr<IMediaSample> pOut;
BYTE* pDataOut = NULL;
- if(FAILED(GetDeliveryBuffer(&pOut, &pDataOut))) {
+ if (FAILED(GetDeliveryBuffer(&pOut, &pDataOut))) {
return E_FAIL;
}
@@ -1608,11 +1608,11 @@ HRESULT CMpaDecFilter::Deliver(CAtlArray<float>& pBuff, DWORD nSamplesPerSec, WO REFERENCE_TIME rtStart = m_rtStart, rtStop = m_rtStart + rtDur;
m_rtStart += rtDur;
//TRACE(_T("CMpaDecFilter: %I64d - %I64d\n"), rtStart/10000, rtStop/10000);
- if(rtStart < 0 /*200000*/ /* < 0, FIXME: 0 makes strange noises */) {
+ if (rtStart < 0 /*200000*/ /* < 0, FIXME: 0 makes strange noises */) {
return S_OK;
}
- if(hr == S_OK) {
+ if (hr == S_OK) {
m_pOutput->SetMediaType(&mt);
pOut->SetMediaType(&mt);
}
@@ -1636,13 +1636,13 @@ HRESULT CMpaDecFilter::Deliver(CAtlArray<float>& pBuff, DWORD nSamplesPerSec, WO // TODO: move this into the audio switcher
float sample_mul = 1;
- if(m_fNormalize) {
- for(int i = 0, len = pBuff.GetCount(); i < len; i++) {
+ if (m_fNormalize) {
+ for (int i = 0, len = pBuff.GetCount(); i < len; i++) {
float f = *pDataIn++;
- if(f < 0) {
+ if (f < 0) {
f = -f;
}
- if(m_sample_max < f) {
+ if (m_sample_max < f) {
m_sample_max = f;
}
}
@@ -1653,28 +1653,28 @@ HRESULT CMpaDecFilter::Deliver(CAtlArray<float>& pBuff, DWORD nSamplesPerSec, WO bool fBoost = m_boost > 1;
double boost = 1+log10(m_boost);
- for(int i = 0, len = pBuff.GetCount(); i < len; i++) {
+ for (int i = 0, len = pBuff.GetCount(); i < len; i++) {
float f = *pDataIn++;
// TODO: move this into the audio switcher
- if(m_fNormalize) {
+ if (m_fNormalize) {
f *= sample_mul;
}
- if(fBoost) {
+ if (fBoost) {
f *= boost;
}
- if(f < -1) {
+ if (f < -1) {
f = -1;
- } else if(f > 1) {
+ } else if (f > 1) {
f = 1;
}
#define round(x) ((x) > 0 ? (x) + 0.5 : (x) - 0.5)
- switch(sf) {
+ switch (sf) {
default:
case SF_PCM16:
*(short*)pDataOut = (short)round(f * SHRT_MAX);
@@ -1707,15 +1707,15 @@ HRESULT CMpaDecFilter::DeliverBitstream(BYTE* pBuff, int size, int sample_rate, bool isDTSWAV = false;
int length = 0;
-
+
if (type == 0x0b) { // DTS
if (size == 4096 && sample_rate == 44100 && samples == 1024) { // DTSWAV
length = size;
isDTSWAV = true;
}
- else while(length < size+16) {
- length += 2048;
- }
+ else while (length < size+16) {
+ length += 2048;
+ }
} else { //if (type == 0x01) { // AC3
length = samples*4;
}
@@ -1727,13 +1727,13 @@ HRESULT CMpaDecFilter::DeliverBitstream(BYTE* pBuff, int size, int sample_rate, mt = CreateMediaTypeSPDIF();
}
- if(FAILED(hr = ReconnectOutput(length, mt))) {
+ if (FAILED(hr = ReconnectOutput(length, mt))) {
return hr;
}
CComPtr<IMediaSample> pOut;
BYTE* pDataOut = NULL;
- if(FAILED(GetDeliveryBuffer(&pOut, &pDataOut))) {
+ if (FAILED(GetDeliveryBuffer(&pOut, &pDataOut))) {
return E_FAIL;
}
@@ -1748,17 +1748,17 @@ HRESULT CMpaDecFilter::DeliverBitstream(BYTE* pBuff, int size, int sample_rate, pDataOutW[3] = size*8;
_swab((char*)pBuff, (char*)&pDataOutW[4], size+1); //if the size is odd, the function "_swab" lose the last byte. need add one.
}
-
+
REFERENCE_TIME rtDur;
rtDur = 10000000i64 * samples / sample_rate;
REFERENCE_TIME rtStart = m_rtStart, rtStop = m_rtStart + rtDur;
m_rtStart += rtDur;
- if(rtStart < 0) {
+ if (rtStart < 0) {
return S_OK;
}
- if(hr == S_OK) {
+ if (hr == S_OK) {
m_pOutput->SetMediaType(&mt);
pOut->SetMediaType(&mt);
}
@@ -1781,29 +1781,29 @@ HRESULT CMpaDecFilter::ReconnectOutput(int nSamples, CMediaType& mt) HRESULT hr;
CComQIPtr<IMemInputPin> pPin = m_pOutput->GetConnected();
- if(!pPin) {
+ if (!pPin) {
return E_NOINTERFACE;
}
CComPtr<IMemAllocator> pAllocator;
- if(FAILED(hr = pPin->GetAllocator(&pAllocator)) || !pAllocator) {
+ if (FAILED(hr = pPin->GetAllocator(&pAllocator)) || !pAllocator) {
return hr;
}
ALLOCATOR_PROPERTIES props, actual;
- if(FAILED(hr = pAllocator->GetProperties(&props))) {
+ if (FAILED(hr = pAllocator->GetProperties(&props))) {
return hr;
}
WAVEFORMATEX* wfe = (WAVEFORMATEX*)mt.Format();
long cbBuffer = nSamples * wfe->nBlockAlign;
- if(mt != m_pOutput->CurrentMediaType() || cbBuffer > props.cbBuffer) {
- if(cbBuffer > props.cbBuffer) {
+ if (mt != m_pOutput->CurrentMediaType() || cbBuffer > props.cbBuffer) {
+ if (cbBuffer > props.cbBuffer) {
props.cBuffers = 4;
props.cbBuffer = cbBuffer*3/2;
- if(FAILED(hr = m_pOutput->DeliverBeginFlush())
+ if (FAILED(hr = m_pOutput->DeliverBeginFlush())
|| FAILED(hr = m_pOutput->DeliverEndFlush())
|| FAILED(hr = pAllocator->Decommit())
|| FAILED(hr = pAllocator->SetProperties(&props, &actual))
@@ -1811,7 +1811,7 @@ HRESULT CMpaDecFilter::ReconnectOutput(int nSamples, CMediaType& mt) return hr;
}
- if(props.cBuffers > actual.cBuffers || props.cbBuffer > actual.cbBuffer) {
+ if (props.cBuffers > actual.cBuffers || props.cbBuffer > actual.cbBuffer) {
NotifyEvent(EC_ERRORABORT, hr, 0);
return E_FAIL;
}
@@ -1837,7 +1837,7 @@ CMediaType CMpaDecFilter::CreateMediaType(MPCSampleFormat sf, DWORD nSamplesPerS wfe->wFormatTag = (WORD)mt.subtype.Data1;
wfe->nChannels = nChannels;
wfe->nSamplesPerSec = nSamplesPerSec;
- switch(sf) {
+ switch (sf) {
default:
case SF_PCM16:
wfe->wBitsPerSample = 16;
@@ -1855,11 +1855,11 @@ CMediaType CMpaDecFilter::CreateMediaType(MPCSampleFormat sf, DWORD nSamplesPerS mt.SetSampleSize (wfe->wBitsPerSample*wfe->nChannels/8);
// FIXME: 24/32 bit only seems to work with WAVE_FORMAT_EXTENSIBLE
- if(dwChannelMask == 0 && (sf == SF_PCM24 || sf == SF_PCM32)) {
+ if (dwChannelMask == 0 && (sf == SF_PCM24 || sf == SF_PCM32)) {
dwChannelMask = nChannels == 2 ? (SPEAKER_FRONT_LEFT|SPEAKER_FRONT_RIGHT) : SPEAKER_FRONT_CENTER;
}
- if(dwChannelMask) {
+ if (dwChannelMask) {
wfex.Format.wFormatTag = WAVE_FORMAT_EXTENSIBLE;
wfex.Format.cbSize = sizeof(wfex) - sizeof(wfex.Format);
wfex.dwChannelMask = dwChannelMask;
@@ -1882,41 +1882,41 @@ CMediaType CMpaDecFilter::CreateMediaTypeSPDIF(DWORD nSamplesPerSec) HRESULT CMpaDecFilter::CheckInputType(const CMediaType* mtIn)
{
#if defined(REGISTER_FILTER) | INTERNAL_DECODER_LPCM
- if(mtIn->subtype == MEDIASUBTYPE_DVD_LPCM_AUDIO) {
+ if (mtIn->subtype == MEDIASUBTYPE_DVD_LPCM_AUDIO) {
WAVEFORMATEX* wfe = (WAVEFORMATEX*)mtIn->Format();
- if(wfe->nChannels < 1 || wfe->nChannels > 8 || (wfe->wBitsPerSample != 16 && wfe->wBitsPerSample != 20 && wfe->wBitsPerSample != 24)) {
+ if (wfe->nChannels < 1 || wfe->nChannels > 8 || (wfe->wBitsPerSample != 16 && wfe->wBitsPerSample != 20 && wfe->wBitsPerSample != 24)) {
return VFW_E_TYPE_NOT_ACCEPTED;
}
- } else if(mtIn->subtype == MEDIASUBTYPE_HDMV_LPCM_AUDIO) {
+ } else if (mtIn->subtype == MEDIASUBTYPE_HDMV_LPCM_AUDIO) {
WAVEFORMATEX* wfe = (WAVEFORMATEX*)mtIn->Format();
UNUSED_ALWAYS(wfe);
return S_OK;
}
#else
- if(0) {}
+ if (0) {}
#endif
#if defined(REGISTER_FILTER) | INTERNAL_DECODER_PS2AUD
- else if(mtIn->subtype == MEDIASUBTYPE_PS2_ADPCM) {
+ else if (mtIn->subtype == MEDIASUBTYPE_PS2_ADPCM) {
WAVEFORMATEXPS2* wfe = (WAVEFORMATEXPS2*)mtIn->Format();
UNUSED_ALWAYS(wfe);
- if(wfe->dwInterleave & 0xf) { // has to be a multiple of the block size (16 bytes)
+ if (wfe->dwInterleave & 0xf) { // has to be a multiple of the block size (16 bytes)
return VFW_E_TYPE_NOT_ACCEPTED;
}
}
#endif
#if defined(REGISTER_FILTER) | INTERNAL_DECODER_FLAC
- else if(mtIn->subtype == MEDIASUBTYPE_FLAC_FRAMED) {
+ else if (mtIn->subtype == MEDIASUBTYPE_FLAC_FRAMED) {
return S_OK;
}
#endif
#if defined(REGISTER_FILTER) | INTERNAL_DECODER_NELLYMOSER
- else if(mtIn->subtype == MEDIASUBTYPE_NELLYMOSER) {
+ else if (mtIn->subtype == MEDIASUBTYPE_NELLYMOSER) {
return S_OK;
}
#endif
- for(int i = 0; i < countof(sudPinTypesIn); i++) {
- if(*sudPinTypesIn[i].clsMajorType == mtIn->majortype
+ for (int i = 0; i < countof(sudPinTypesIn); i++) {
+ if (*sudPinTypesIn[i].clsMajorType == mtIn->majortype
&& *sudPinTypesIn[i].clsMinorType == mtIn->subtype) {
return S_OK;
}
@@ -1936,7 +1936,7 @@ HRESULT CMpaDecFilter::CheckTransform(const CMediaType* mtIn, const CMediaType* HRESULT CMpaDecFilter::DecideBufferSize(IMemAllocator* pAllocator, ALLOCATOR_PROPERTIES* pProperties)
{
- if(m_pInput->IsConnected() == FALSE) {
+ if (m_pInput->IsConnected() == FALSE) {
return E_UNEXPECTED;
}
@@ -1952,7 +1952,7 @@ HRESULT CMpaDecFilter::DecideBufferSize(IMemAllocator* pAllocator, ALLOCATOR_PRO HRESULT hr;
ALLOCATOR_PROPERTIES Actual;
- if(FAILED(hr = pAllocator->SetProperties(pProperties, &Actual))) {
+ if (FAILED(hr = pAllocator->SetProperties(pProperties, &Actual))) {
return hr;
}
@@ -1963,14 +1963,14 @@ HRESULT CMpaDecFilter::DecideBufferSize(IMemAllocator* pAllocator, ALLOCATOR_PRO HRESULT CMpaDecFilter::GetMediaType(int iPosition, CMediaType* pmt)
{
- if(m_pInput->IsConnected() == FALSE) {
+ if (m_pInput->IsConnected() == FALSE) {
return E_UNEXPECTED;
}
- if(iPosition < 0) {
+ if (iPosition < 0) {
return E_INVALIDARG;
}
- if(iPosition > 0) {
+ if (iPosition > 0) {
return VFW_S_NO_MORE_ITEMS;
}
@@ -1982,18 +1982,18 @@ HRESULT CMpaDecFilter::GetMediaType(int iPosition, CMediaType* pmt) }
#if defined(REGISTER_FILTER) | INTERNAL_DECODER_AC3 | INTERNAL_DECODER_DTS
- if(GetSpeakerConfig(ac3) < 0 && (subtype == MEDIASUBTYPE_DOLBY_AC3 ||
- subtype == MEDIASUBTYPE_WAVE_DOLBY_AC3 ||
- subtype == MEDIASUBTYPE_DOLBY_DDPLUS ||
- subtype == MEDIASUBTYPE_DOLBY_TRUEHD)
+ if (GetSpeakerConfig(ac3) < 0 && (subtype == MEDIASUBTYPE_DOLBY_AC3 ||
+ subtype == MEDIASUBTYPE_WAVE_DOLBY_AC3 ||
+ subtype == MEDIASUBTYPE_DOLBY_DDPLUS ||
+ subtype == MEDIASUBTYPE_DOLBY_TRUEHD)
|| GetSpeakerConfig(dts) < 0 && (subtype == MEDIASUBTYPE_DTS || subtype == MEDIASUBTYPE_WAVE_DTS)) {
*pmt = CreateMediaTypeSPDIF();
}
#else
- if(0) {}
+ if (0) {}
#endif
#if defined(REGISTER_FILTER) | INTERNAL_DECODER_VORBIS
- else if(subtype == MEDIASUBTYPE_Vorbis2) {
+ else if (subtype == MEDIASUBTYPE_Vorbis2) {
VORBISFORMAT2 *vf2 = (VORBISFORMAT2 *)mt.Format();
scmap_t* scmap = &m_scmap_default[vf2->Channels-1];
*pmt = CreateMediaType(GetSampleFormat(), vf2->SamplesPerSec, vf2->Channels, scmap->dwChannelMask);
@@ -2009,7 +2009,7 @@ HRESULT CMpaDecFilter::GetMediaType(int iPosition, CMediaType* pmt) HRESULT CMpaDecFilter::StartStreaming()
{
HRESULT hr = __super::StartStreaming();
- if(FAILED(hr)) {
+ if (FAILED(hr)) {
return hr;
}
@@ -2071,7 +2071,7 @@ STDMETHODIMP_(MPCSampleFormat) CMpaDecFilter::GetSampleFormat() STDMETHODIMP CMpaDecFilter::SetNormalize(bool fNormalize)
{
CAutoLock cAutoLock(&m_csProps);
- if(m_fNormalize != fNormalize) {
+ if (m_fNormalize != fNormalize) {
m_sample_max = 0.1f;
}
m_fNormalize = fNormalize;
@@ -2087,7 +2087,7 @@ STDMETHODIMP_(bool) CMpaDecFilter::GetNormalize() STDMETHODIMP CMpaDecFilter::SetSpeakerConfig(enctype et, int sc)
{
CAutoLock cAutoLock(&m_csProps);
- if(et >= 0 && et < etlast) {
+ if (et >= 0 && et < etlast) {
m_iSpeakerConfig[et] = sc;
}
return S_OK;
@@ -2096,7 +2096,7 @@ STDMETHODIMP CMpaDecFilter::SetSpeakerConfig(enctype et, int sc) STDMETHODIMP_(int) CMpaDecFilter::GetSpeakerConfig(enctype et)
{
CAutoLock cAutoLock(&m_csProps);
- if(et >= 0 && et < etlast) {
+ if (et >= 0 && et < etlast) {
return m_iSpeakerConfig[et];
}
return -1;
@@ -2105,7 +2105,7 @@ STDMETHODIMP_(int) CMpaDecFilter::GetSpeakerConfig(enctype et) STDMETHODIMP CMpaDecFilter::SetDynamicRangeControl(enctype et, bool fDRC)
{
CAutoLock cAutoLock(&m_csProps);
- if(et >= 0 && et < etlast) {
+ if (et >= 0 && et < etlast) {
m_fDynamicRangeControl[et] = fDRC;
} else {
return E_INVALIDARG;
@@ -2116,7 +2116,7 @@ STDMETHODIMP CMpaDecFilter::SetDynamicRangeControl(enctype et, bool fDRC) STDMETHODIMP_(bool) CMpaDecFilter::GetDynamicRangeControl(enctype et)
{
CAutoLock cAutoLock(&m_csProps);
- if(et >= 0 && et < etlast) {
+ if (et >= 0 && et < etlast) {
return m_fDynamicRangeControl[et];
}
return false;
@@ -2146,7 +2146,7 @@ STDMETHODIMP CMpaDecFilter::SaveSettings() CAutoLock cAutoLock(&m_csProps);
#ifdef REGISTER_FILTER
CRegKey key;
- if(ERROR_SUCCESS == key.Create(HKEY_CURRENT_USER, _T("Software\\Gabest\\Filters\\MPEG Audio Decoder"))) {
+ if (ERROR_SUCCESS == key.Create(HKEY_CURRENT_USER, _T("Software\\Gabest\\Filters\\MPEG Audio Decoder"))) {
key.SetDWORDValue(_T("SampleFormat"), m_iSampleFormat);
key.SetDWORDValue(_T("Normalize"), m_fNormalize);
key.SetDWORDValue(_T("Boost"), *(DWORD*)&m_boost);
@@ -2185,13 +2185,13 @@ STDMETHODIMP CMpaDecFilter::CreatePage(const GUID& guid, IPropertyPage** ppPage) {
CheckPointer(ppPage, E_POINTER);
- if(*ppPage != NULL) {
+ if (*ppPage != NULL) {
return E_INVALIDARG;
}
HRESULT hr;
- if(guid == __uuidof(CMpaDecSettingsWnd)) {
+ if (guid == __uuidof(CMpaDecSettingsWnd)) {
(*ppPage = DNew CInternalPropertyPageTempl<CMpaDecSettingsWnd>(NULL, &hr))->AddRef();
}
@@ -2236,8 +2236,8 @@ void CMpaDecFilter::FlacDeliverBuffer (unsigned blocksize, const __int32 * cons switch (wfein->wBitsPerSample) {
case 16 :
- for(unsigned i = 0; i < blocksize; i++) {
- for(int nChannel = 0; nChannel < wfein->nChannels; nChannel++) {
+ for (unsigned i = 0; i < blocksize; i++) {
+ for (int nChannel = 0; nChannel < wfein->nChannels; nChannel++) {
FLAC__int16 nVal = (FLAC__int16)buffer[nChannel][i];
*pDataOut = (float)nVal / SHRT_MAX;
pDataOut++;
@@ -2246,8 +2246,8 @@ void CMpaDecFilter::FlacDeliverBuffer (unsigned blocksize, const __int32 * cons break;
case 20 :
case 24 :
- for(unsigned i = 0; i < blocksize; i++) {
- for(int nChannel = 0; nChannel < wfein->nChannels; nChannel++) {
+ for (unsigned i = 0; i < blocksize; i++) {
+ for (int nChannel = 0; nChannel < wfein->nChannels; nChannel++) {
FLAC__int32 nVal = (FLAC__int32)buffer[nChannel][i];
*pDataOut = (float)nVal / INT24_MAX;
pDataOut++;
@@ -2369,7 +2369,7 @@ HRESULT CMpaDecFilter::DeliverFFmpeg(enum CodecID nCodecId, BYTE* p, int buffsiz if (used_bytes < 0) {
TRACE(_T("CMpaDecFilter::DeliverFFmpeg() - audio parsing failed (ret: %d)\n"), -used_bytes);
return E_FAIL;
- } else if(used_bytes == 0 && pOut_size == 0) {
+ } else if (used_bytes == 0 && pOut_size == 0) {
TRACE(_T("CMpaDecFilter::DeliverFFmpeg() - could not process buffer while parsing\n"));
break;
}
@@ -2393,7 +2393,7 @@ HRESULT CMpaDecFilter::DeliverFFmpeg(enum CodecID nCodecId, BYTE* p, int buffsiz } else {
continue;
}
- } else {
+ } else {
avpkt.data = (uint8_t *)m_pFFBuffer;
avpkt.size = buffsize;
@@ -2437,7 +2437,7 @@ HRESULT CMpaDecFilter::DeliverFFmpeg(enum CodecID nCodecId, BYTE* p, int buffsiz pDataOut = pBuff.GetData();
for (size_t i=0; i<pBuff.GetCount()/m_pAVCtx->channels; i++) {
- for(int ch=0; ch<m_pAVCtx->channels; ch++) {
+ for (int ch=0; ch<m_pAVCtx->channels; ch++) {
*pDataOut = (float)((int16_t*)m_pFrame->data[0]) [scmap->ch[ch]+i*m_pAVCtx->channels] / SHRT_MAX;
pDataOut++;
}
@@ -2449,7 +2449,7 @@ HRESULT CMpaDecFilter::DeliverFFmpeg(enum CodecID nCodecId, BYTE* p, int buffsiz pDataOut = pBuff.GetData();
for (size_t i=0; i<pBuff.GetCount()/m_pAVCtx->channels; i++) {
- for(int ch=0; ch<m_pAVCtx->channels; ch++) {
+ for (int ch=0; ch<m_pAVCtx->channels; ch++) {
*pDataOut = (float)((int32_t*)m_pFrame->data[0]) [scmap->ch[ch]+i*m_pAVCtx->channels] / INT_MAX;
pDataOut++;
}
@@ -2465,9 +2465,9 @@ HRESULT CMpaDecFilter::DeliverFFmpeg(enum CodecID nCodecId, BYTE* p, int buffsiz break;
}
- if(pBuff.GetCount() > 0) {
+ if (pBuff.GetCount() > 0) {
hr = Deliver(pBuff, m_pAVCtx->sample_rate, scmap->nChannels, scmap->dwChannelMask);
- if(FAILED(hr)) {
+ if (FAILED(hr)) {
return hr;
}
}
@@ -2499,7 +2499,7 @@ bool CMpaDecFilter::InitFFmpeg(enum CodecID nCodecId) default :
m_pAVCodec = avcodec_find_decoder(nCodecId);
}
-
+
if (m_pAVCodec) {
DWORD nSamples, nBytesPerSec;
WORD nChannels, nBitsPerSample, nBlockAlign;
@@ -2518,15 +2518,15 @@ bool CMpaDecFilter::InitFFmpeg(enum CodecID nCodecId) m_pAVCtx->bit_rate = nBytesPerSec << 3;
m_pAVCtx->bits_per_coded_sample = nBitsPerSample;
m_pAVCtx->block_align = nBlockAlign;
-
+
m_pAVCtx->err_recognition = AV_EF_CAREFUL;
- m_pAVCtx->codec_id = nCodecId;
+ m_pAVCtx->codec_id = nCodecId;
if (m_pAVCodec->capabilities & CODEC_CAP_TRUNCATED) {
m_pAVCtx->flags |= CODEC_FLAG_TRUNCATED;
}
-
+
// have issue when use parser on TrueHD ... try to fix later
- if(nCodecId != CODEC_ID_TRUEHD && nCodecId != CODEC_ID_AAC && nCodecId != CODEC_ID_AAC_LATM) {
+ if (nCodecId != CODEC_ID_TRUEHD && nCodecId != CODEC_ID_AAC && nCodecId != CODEC_ID_AAC_LATM) {
m_pParser = av_parser_init(nCodecId);
}
@@ -2535,7 +2535,7 @@ bool CMpaDecFilter::InitFFmpeg(enum CodecID nCodecId) DWORD formatlen = m_pInput->CurrentMediaType().cbFormat;
unsigned extralen = 0;
getExtraData((BYTE *)format, &format_type, formatlen, NULL, &extralen);
-
+
m_pAVCtx->extradata_size = extralen;
m_pAVCtx->extradata = (const unsigned char*)calloc(1, m_pAVCtx->extradata_size + FF_INPUT_BUFFER_PADDING_SIZE);
getExtraData((BYTE *)format, &format_type, formatlen, (BYTE *)m_pAVCtx->extradata, NULL);
diff --git a/src/filters/transform/MpaDecFilter/MpaDecSettingsWnd.cpp b/src/filters/transform/MpaDecFilter/MpaDecSettingsWnd.cpp index 6d1b25f53..9cc33b002 100644 --- a/src/filters/transform/MpaDecFilter/MpaDecSettingsWnd.cpp +++ b/src/filters/transform/MpaDecFilter/MpaDecSettingsWnd.cpp @@ -48,11 +48,11 @@ bool CMpaDecSettingsWnd::OnConnect(const CInterfaceList<IUnknown, &IID_IUnknown> m_pMDF.Release();
POSITION pos = pUnks.GetHeadPosition();
- while(pos && !(m_pMDF = pUnks.GetNext(pos))) {
+ while (pos && !(m_pMDF = pUnks.GetNext(pos))) {
;
}
- if(!m_pMDF) {
+ if (!m_pMDF) {
return false;
}
@@ -106,8 +106,8 @@ bool CMpaDecSettingsWnd::OnActivate() m_outputformat_combo.SetItemData(m_outputformat_combo.AddString(_T("IEEE Float")), SF_FLOAT32);
m_outputformat_combo.SetCurSel(0);
- for(int i = 0; i < m_outputformat_combo.GetCount(); i++)
- if((int)m_outputformat_combo.GetItemData(i) == m_outputformat) {
+ for (int i = 0; i < m_outputformat_combo.GetCount(); i++)
+ if ((int)m_outputformat_combo.GetItemData(i) == m_outputformat) {
m_outputformat_combo.SetCurSel(i);
}
@@ -132,8 +132,8 @@ bool CMpaDecSettingsWnd::OnActivate() m_ac3spkcfg_combo.SetItemData(m_ac3spkcfg_combo.AddString(ResStr(IDS_MPA_CHANNEL_1)), A52_CHANNEL1);
m_ac3spkcfg_combo.SetItemData(m_ac3spkcfg_combo.AddString(ResStr(IDS_MPA_CHANNEL_2)), A52_CHANNEL2);
- for(int i = 0, sel = abs(m_ac3spkcfg) & A52_CHANNEL_MASK; i < m_ac3spkcfg_combo.GetCount(); i++)
- if((int)m_ac3spkcfg_combo.GetItemData(i) == sel) {
+ for (int i = 0, sel = abs(m_ac3spkcfg) & A52_CHANNEL_MASK; i < m_ac3spkcfg_combo.GetCount(); i++)
+ if ((int)m_ac3spkcfg_combo.GetItemData(i) == sel) {
m_ac3spkcfg_combo.SetCurSel(i);
}
@@ -143,7 +143,7 @@ bool CMpaDecSettingsWnd::OnActivate() m_ac3lfe_check.Create(_T("LFE"), dwStyle|BS_AUTOCHECKBOX, CRect(CPoint(r.left, r.bottom + 3), CSize(50, m_fontheight)), this, IDC_PP_CHECK4);
m_ac3lfe_check.SetCheck(!!(abs(m_ac3spkcfg) & A52_LFE));
- for(int i = 0, h = max(20, m_fontheight)+1; i < countof(m_ac3spkcfg_radio); i++, p.y += h) {
+ for (int i = 0, h = max(20, m_fontheight)+1; i < countof(m_ac3spkcfg_radio); i++, p.y += h) {
static const TCHAR* labels[] = {m_strDecodeToSpeaker, _T("SPDIF")};
m_ac3spkcfg_radio[i].Create(labels[i], dwStyle|BS_AUTORADIOBUTTON|(i == 0 ? WS_GROUP : 0), CRect(p + CPoint(10, 0), CSize(140, h)), this, IDC_PP_RADIO1+i);
}
@@ -173,8 +173,8 @@ bool CMpaDecSettingsWnd::OnActivate() m_dtsspkcfg_combo.SetItemData(m_dtsspkcfg_combo.AddString(ResStr(IDS_MPA_2F_2R)), DTS_2F2R);
m_dtsspkcfg_combo.SetItemData(m_dtsspkcfg_combo.AddString(ResStr(IDS_MPA_3F_2R)), DTS_3F2R);
- for(int i = 0, sel = abs(m_dtsspkcfg) & DTS_CHANNEL_MASK; i < m_dtsspkcfg_combo.GetCount(); i++)
- if((int)m_dtsspkcfg_combo.GetItemData(i) == sel) {
+ for (int i = 0, sel = abs(m_dtsspkcfg) & DTS_CHANNEL_MASK; i < m_dtsspkcfg_combo.GetCount(); i++)
+ if ((int)m_dtsspkcfg_combo.GetItemData(i) == sel) {
m_dtsspkcfg_combo.SetCurSel(i);
}
@@ -184,7 +184,7 @@ bool CMpaDecSettingsWnd::OnActivate() m_dtslfe_check.Create(_T("LFE"), dwStyle|BS_AUTOCHECKBOX, CRect(CPoint(r.left, r.bottom + 3), CSize(50, m_fontheight)), this, IDC_PP_CHECK5);
m_dtslfe_check.SetCheck(!!(abs(m_dtsspkcfg) & DTS_LFE));
- for(int i = 0, h = max(20, m_fontheight)+1; i < countof(m_dtsspkcfg_radio); i++, p.y += h) {
+ for (int i = 0, h = max(20, m_fontheight)+1; i < countof(m_dtsspkcfg_radio); i++, p.y += h) {
static const TCHAR* labels[] = {m_strDecodeToSpeaker, _T("SPDIF")};
m_dtsspkcfg_radio[i].Create(labels[i], dwStyle|BS_AUTORADIOBUTTON|(i == 0 ? WS_GROUP : 0), CRect(p + CPoint(10, 0), CSize(140, h)), this, IDC_PP_RADIO3+i);
}
@@ -196,7 +196,7 @@ bool CMpaDecSettingsWnd::OnActivate() m_dtsspkcfg_check.Create(ResStr(IDS_MPA_DYNRANGE), dwStyle|WS_DISABLED|BS_AUTOCHECKBOX, CRect(p + CPoint(10, 0), CSize(205, m_fontheight)), this, IDC_PP_CHECK2);
m_dtsspkcfg_check.SetCheck(m_dtsdrc);
- for(CWnd* pWnd = GetWindow(GW_CHILD); pWnd; pWnd = pWnd->GetNextWindow()) {
+ for (CWnd* pWnd = GetWindow(GW_CHILD); pWnd; pWnd = pWnd->GetNextWindow()) {
pWnd->SetFont(&m_font, FALSE);
}
@@ -207,18 +207,18 @@ void CMpaDecSettingsWnd::OnDeactivate() {
m_outputformat = m_outputformat_combo.GetItemData(m_outputformat_combo.GetCurSel());
m_ac3spkcfg = m_ac3spkcfg_combo.GetItemData(m_ac3spkcfg_combo.GetCurSel());
- if(!!m_ac3lfe_check.GetCheck()) {
+ if (!!m_ac3lfe_check.GetCheck()) {
m_ac3spkcfg |= A52_LFE;
}
- if(IsDlgButtonChecked(IDC_PP_RADIO2)) {
+ if (IsDlgButtonChecked(IDC_PP_RADIO2)) {
m_ac3spkcfg = -m_ac3spkcfg;
}
m_ac3drc = !!m_ac3spkcfg_check.GetCheck();
m_dtsspkcfg = m_dtsspkcfg_combo.GetItemData(m_dtsspkcfg_combo.GetCurSel());
- if(!!m_dtslfe_check.GetCheck()) {
+ if (!!m_dtslfe_check.GetCheck()) {
m_dtsspkcfg |= DTS_LFE;
}
- if(IsDlgButtonChecked(IDC_PP_RADIO4)) {
+ if (IsDlgButtonChecked(IDC_PP_RADIO4)) {
m_dtsspkcfg = -m_dtsspkcfg;
}
m_dtsdrc = !!m_dtsspkcfg_check.GetCheck();
@@ -228,7 +228,7 @@ bool CMpaDecSettingsWnd::OnApply() {
OnDeactivate();
- if(m_pMDF) {
+ if (m_pMDF) {
m_pMDF->SetSampleFormat((MPCSampleFormat)m_outputformat);
m_pMDF->SetSpeakerConfig(IMpaDecFilter::ac3, m_ac3spkcfg);
m_pMDF->SetDynamicRangeControl(IMpaDecFilter::ac3, m_ac3drc);
diff --git a/src/filters/transform/Mpeg2DecFilter/Mpeg2DecFilter.cpp b/src/filters/transform/Mpeg2DecFilter/Mpeg2DecFilter.cpp index e9388d1e1..8bae2404f 100644 --- a/src/filters/transform/Mpeg2DecFilter/Mpeg2DecFilter.cpp +++ b/src/filters/transform/Mpeg2DecFilter/Mpeg2DecFilter.cpp @@ -93,21 +93,21 @@ STDAPI DllUnregisterServer() #include <detours/detours.h>
BOOL (__stdcall * Real_IsDebuggerPresent)(void)
-= IsDebuggerPresent;
+ = IsDebuggerPresent;
LONG (__stdcall * Real_ChangeDisplaySettingsExA)(LPCSTR a0,
LPDEVMODEA a1,
HWND a2,
DWORD a3,
LPVOID a4)
-= ChangeDisplaySettingsExA;
+ = ChangeDisplaySettingsExA;
LONG (__stdcall * Real_ChangeDisplaySettingsExW)(LPCWSTR a0,
LPDEVMODEW a1,
HWND a2,
DWORD a3,
LPVOID a4)
-= ChangeDisplaySettingsExW;
+ = ChangeDisplaySettingsExW;
BOOL WINAPI Mine_IsDebuggerPresent()
@@ -118,17 +118,17 @@ BOOL WINAPI Mine_IsDebuggerPresent() LONG WINAPI Mine_ChangeDisplaySettingsEx(LONG ret, DWORD dwFlags, LPVOID lParam)
{
- if(dwFlags&CDS_VIDEOPARAMETERS) {
+ if (dwFlags&CDS_VIDEOPARAMETERS) {
VIDEOPARAMETERS* vp = (VIDEOPARAMETERS*)lParam;
- if(vp->Guid == GUIDFromCString(_T("{02C62061-1097-11d1-920F-00A024DF156E}"))
+ if (vp->Guid == GUIDFromCString(_T("{02C62061-1097-11d1-920F-00A024DF156E}"))
&& (vp->dwFlags&VP_FLAGS_COPYPROTECT)) {
- if(vp->dwCommand == VP_COMMAND_GET) {
- if((vp->dwTVStandard&VP_TV_STANDARD_WIN_VGA) && vp->dwTVStandard != VP_TV_STANDARD_WIN_VGA) {
+ if (vp->dwCommand == VP_COMMAND_GET) {
+ if ((vp->dwTVStandard&VP_TV_STANDARD_WIN_VGA) && vp->dwTVStandard != VP_TV_STANDARD_WIN_VGA) {
TRACE(_T("Ooops, tv-out enabled? macrovision checks suck..."));
vp->dwTVStandard = VP_TV_STANDARD_WIN_VGA;
}
- } else if(vp->dwCommand == VP_COMMAND_SET) {
+ } else if (vp->dwCommand == VP_COMMAND_SET) {
TRACE(_T("Ooops, as I already told ya, no need for any macrovision bs here"));
return 0;
}
@@ -156,7 +156,7 @@ public: BOOL InitInstance() {
long lError;
- if(!__super::InitInstance()) {
+ if (!__super::InitInstance()) {
return FALSE;
}
@@ -191,15 +191,15 @@ CMpeg2DecFilter::CMpeg2DecFilter(LPUNKNOWN lpunk, HRESULT* phr) delete m_pInput;
// delete m_pOutput;
- if(FAILED(*phr)) {
+ if (FAILED(*phr)) {
return;
}
m_pInput = DNew CMpeg2DecInputPin(this, phr, L"Video");
- if(!m_pInput) {
+ if (!m_pInput) {
*phr = E_OUTOFMEMORY;
}
- if(FAILED(*phr)) {
+ if (FAILED(*phr)) {
return;
}
@@ -208,18 +208,18 @@ CMpeg2DecFilter::CMpeg2DecFilter(LPUNKNOWN lpunk, HRESULT* phr) // if(FAILED(*phr)) return;
m_pSubpicInput = DNew CSubpicInputPin(this, phr);
- if(!m_pSubpicInput) {
+ if (!m_pSubpicInput) {
*phr = E_OUTOFMEMORY;
}
- if(FAILED(*phr)) {
+ if (FAILED(*phr)) {
return;
}
m_pClosedCaptionOutput = DNew CClosedCaptionOutputPin(this, m_pLock, phr);
- if(!m_pClosedCaptionOutput) {
+ if (!m_pClosedCaptionOutput) {
*phr = E_OUTOFMEMORY;
}
- if(FAILED(*phr)) {
+ if (FAILED(*phr)) {
return;
}
@@ -235,38 +235,38 @@ CMpeg2DecFilter::CMpeg2DecFilter(LPUNKNOWN lpunk, HRESULT* phr) #ifdef REGISTER_FILTER
CRegKey key;
- if(ERROR_SUCCESS == key.Open(HKEY_CURRENT_USER, _T("Software\\Gabest\\Filters\\MPEG Video Decoder"), KEY_READ)) {
+ if (ERROR_SUCCESS == key.Open(HKEY_CURRENT_USER, _T("Software\\Gabest\\Filters\\MPEG Video Decoder"), KEY_READ)) {
DWORD dw;
- if(ERROR_SUCCESS == key.QueryDWORDValue(_T("DeinterlaceMethod"), dw)) {
+ if (ERROR_SUCCESS == key.QueryDWORDValue(_T("DeinterlaceMethod"), dw)) {
SetDeinterlaceMethod((ditype)dw);
}
- if(ERROR_SUCCESS == key.QueryDWORDValue(_T("Brightness"), dw)) {
+ if (ERROR_SUCCESS == key.QueryDWORDValue(_T("Brightness"), dw)) {
SetBrightness(*(float*)&dw);
}
- if(ERROR_SUCCESS == key.QueryDWORDValue(_T("Contrast"), dw)) {
+ if (ERROR_SUCCESS == key.QueryDWORDValue(_T("Contrast"), dw)) {
SetContrast(*(float*)&dw);
}
- if(ERROR_SUCCESS == key.QueryDWORDValue(_T("Hue"), dw)) {
+ if (ERROR_SUCCESS == key.QueryDWORDValue(_T("Hue"), dw)) {
SetHue(*(float*)&dw);
}
- if(ERROR_SUCCESS == key.QueryDWORDValue(_T("Saturation"), dw)) {
+ if (ERROR_SUCCESS == key.QueryDWORDValue(_T("Saturation"), dw)) {
SetSaturation(*(float*)&dw);
}
- if(ERROR_SUCCESS == key.QueryDWORDValue(_T("ForcedSubtitles"), dw)) {
+ if (ERROR_SUCCESS == key.QueryDWORDValue(_T("ForcedSubtitles"), dw)) {
EnableForcedSubtitles(!!dw);
}
- if(ERROR_SUCCESS == key.QueryDWORDValue(_T("PlanarYUV"), dw)) {
+ if (ERROR_SUCCESS == key.QueryDWORDValue(_T("PlanarYUV"), dw)) {
EnablePlanarYUV(!!dw);
}
- if(ERROR_SUCCESS == key.QueryDWORDValue(_T("Interlaced"), dw)) {
+ if (ERROR_SUCCESS == key.QueryDWORDValue(_T("Interlaced"), dw)) {
EnableInterlaced(!!dw);
}
- if(ERROR_SUCCESS == key.QueryDWORDValue(_T("ReadARFromStream"), dw)) {
+ if (ERROR_SUCCESS == key.QueryDWORDValue(_T("ReadARFromStream"), dw)) {
EnableReadARFromStream(!!dw);
}
}
#else
- DWORD dw;
+ DWORD dw;
dw = AfxGetApp()->GetProfileInt(_T("Filters\\MPEG Video Decoder"), _T("DeinterlaceMethod"), m_ditype);
SetDeinterlaceMethod((ditype)dw);
dw = AfxGetApp()->GetProfileInt(_T("Filters\\MPEG Video Decoder"), _T("Brightness"), *(DWORD*)&m_bright);
@@ -304,7 +304,7 @@ STDMETHODIMP CMpeg2DecFilter::Apply() {
#ifdef REGISTER_FILTER
CRegKey key;
- if(ERROR_SUCCESS == key.Create(HKEY_CURRENT_USER, _T("Software\\Gabest\\Filters\\MPEG Video Decoder"))) {
+ if (ERROR_SUCCESS == key.Create(HKEY_CURRENT_USER, _T("Software\\Gabest\\Filters\\MPEG Video Decoder"))) {
key.SetDWORDValue(_T("DeinterlaceMethod"), m_ditype);
key.SetDWORDValue(_T("Brightness"), *(DWORD*)&m_bright);
key.SetDWORDValue(_T("Contrast"), *(DWORD*)&m_cont);
@@ -352,7 +352,7 @@ int CMpeg2DecFilter::GetPinCount() CBasePin* CMpeg2DecFilter::GetPin(int n)
{
- switch(n) {
+ switch (n) {
case 0:
return m_pInput;
case 1:
@@ -398,7 +398,7 @@ void CMpeg2DecFilter::InputTypeChanged() TRACE(_T("ResetMpeg2Decoder()\n"));
- for(int i = 0; i < countof(m_dec->m_pictures); i++) {
+ for (int i = 0; i < countof(m_dec->m_pictures); i++) {
m_dec->m_pictures[i].rtStart = m_dec->m_pictures[i].rtStop = _I64_MIN+1;
m_dec->m_pictures[i].fDelivered = false;
m_dec->m_pictures[i].flags &= ~PIC_MASK_CODING_TYPE;
@@ -409,10 +409,10 @@ void CMpeg2DecFilter::InputTypeChanged() BYTE* pSequenceHeader = NULL;
DWORD cbSequenceHeader = 0;
- if(mt.formattype == FORMAT_MPEGVideo) {
+ if (mt.formattype == FORMAT_MPEGVideo) {
pSequenceHeader = ((MPEG1VIDEOINFO*)mt.Format())->bSequenceHeader;
cbSequenceHeader = ((MPEG1VIDEOINFO*)mt.Format())->cbSequenceHeader;
- } else if(mt.formattype == FORMAT_MPEG2_VIDEO) {
+ } else if (mt.formattype == FORMAT_MPEG2_VIDEO) {
pSequenceHeader = (BYTE*)((MPEG2VIDEOINFO*)mt.Format())->dwSequenceHeader;
cbSequenceHeader = ((MPEG2VIDEOINFO*)mt.Format())->cbSequenceHeader;
}
@@ -437,13 +437,13 @@ void CMpeg2DecFilter::SetDeinterlaceMethod() DWORD oldflags = m_fb.flags;
DWORD newflags = m_dec->m_info.m_display_picture->flags;
- if(!(seqflags & SEQ_FLAG_PROGRESSIVE_SEQUENCE)
+ if (!(seqflags & SEQ_FLAG_PROGRESSIVE_SEQUENCE)
&& !(oldflags & PIC_FLAG_REPEAT_FIRST_FIELD)
&& (newflags & PIC_FLAG_PROGRESSIVE_FRAME)) {
- if(!m_fFilm && (newflags & PIC_FLAG_REPEAT_FIRST_FIELD)) {
+ if (!m_fFilm && (newflags & PIC_FLAG_REPEAT_FIRST_FIELD)) {
TRACE(_T("m_fFilm = true\n"));
m_fFilm = true;
- } else if(m_fFilm && !(newflags & PIC_FLAG_REPEAT_FIRST_FIELD)) {
+ } else if (m_fFilm && !(newflags & PIC_FLAG_REPEAT_FIRST_FIELD)) {
TRACE(_T("m_fFilm = false\n"));
m_fFilm = false;
}
@@ -451,17 +451,17 @@ void CMpeg2DecFilter::SetDeinterlaceMethod() const CMediaType& mt = m_pOutput->CurrentMediaType();
- if(mt.formattype == FORMAT_VideoInfo2 && (((VIDEOINFOHEADER2*)mt.pbFormat)->dwInterlaceFlags & AMINTERLACE_IsInterlaced)) {
+ if (mt.formattype == FORMAT_VideoInfo2 && (((VIDEOINFOHEADER2*)mt.pbFormat)->dwInterlaceFlags & AMINTERLACE_IsInterlaced)) {
m_fb.di = DIWeave;
} else {
m_fb.di = GetDeinterlaceMethod();
- if(m_fb.di == DIAuto || m_fb.di != DIWeave && m_fb.di != DIBlend && m_fb.di != DIBob && m_fb.di != DIFieldShift && m_fb.di != DIELA) {
- if(seqflags & SEQ_FLAG_PROGRESSIVE_SEQUENCE) {
+ if (m_fb.di == DIAuto || m_fb.di != DIWeave && m_fb.di != DIBlend && m_fb.di != DIBob && m_fb.di != DIFieldShift && m_fb.di != DIELA) {
+ if (seqflags & SEQ_FLAG_PROGRESSIVE_SEQUENCE) {
m_fb.di = DIWeave; // hurray!
- } else if(m_fFilm) {
+ } else if (m_fFilm) {
m_fb.di = DIWeave; // we are lucky
- } else if(!(m_fb.flags & PIC_FLAG_PROGRESSIVE_FRAME)) {
+ } else if (!(m_fb.flags & PIC_FLAG_PROGRESSIVE_FRAME)) {
m_fb.di = DIBlend; // ok, clear thing
} else
// big trouble here, the progressive_frame bit is not reliable :'(
@@ -479,33 +479,33 @@ void CMpeg2DecFilter::SetDeinterlaceMethod() void CMpeg2DecFilter::SetTypeSpecificFlags(IMediaSample* pMS)
{
- if(CComQIPtr<IMediaSample2> pMS2 = pMS) {
+ if (CComQIPtr<IMediaSample2> pMS2 = pMS) {
AM_SAMPLE2_PROPERTIES props;
- if(SUCCEEDED(pMS2->GetProperties(sizeof(props), (BYTE*)&props))) {
+ if (SUCCEEDED(pMS2->GetProperties(sizeof(props), (BYTE*)&props))) {
props.dwTypeSpecificFlags &= ~0x7f;
const CMediaType& mt = m_pOutput->CurrentMediaType();
- if(mt.formattype == FORMAT_VideoInfo2 && (((VIDEOINFOHEADER2*)mt.pbFormat)->dwInterlaceFlags & AMINTERLACE_IsInterlaced)) {
+ if (mt.formattype == FORMAT_VideoInfo2 && (((VIDEOINFOHEADER2*)mt.pbFormat)->dwInterlaceFlags & AMINTERLACE_IsInterlaced)) {
// props.dwTypeSpecificFlags |= AM_VIDEO_FLAG_WEAVE;
- if(m_dec->m_info.m_sequence->flags & SEQ_FLAG_PROGRESSIVE_SEQUENCE) {
+ if (m_dec->m_info.m_sequence->flags & SEQ_FLAG_PROGRESSIVE_SEQUENCE) {
props.dwTypeSpecificFlags |= AM_VIDEO_FLAG_WEAVE;
}
- if(m_fb.flags & PIC_FLAG_TOP_FIELD_FIRST) {
+ if (m_fb.flags & PIC_FLAG_TOP_FIELD_FIRST) {
props.dwTypeSpecificFlags |= AM_VIDEO_FLAG_FIELD1FIRST;
}
- if(m_fb.flags & PIC_FLAG_REPEAT_FIRST_FIELD) {
+ if (m_fb.flags & PIC_FLAG_REPEAT_FIRST_FIELD) {
props.dwTypeSpecificFlags |= AM_VIDEO_FLAG_REPEAT_FIELD;
}
- if((m_fb.flags & PIC_MASK_CODING_TYPE) == PIC_FLAG_CODING_TYPE_I) {
+ if ((m_fb.flags & PIC_MASK_CODING_TYPE) == PIC_FLAG_CODING_TYPE_I) {
props.dwTypeSpecificFlags |= AM_VIDEO_FLAG_I_SAMPLE;
}
- if((m_fb.flags & PIC_MASK_CODING_TYPE) == PIC_FLAG_CODING_TYPE_P) {
+ if ((m_fb.flags & PIC_MASK_CODING_TYPE) == PIC_FLAG_CODING_TYPE_P) {
props.dwTypeSpecificFlags |= AM_VIDEO_FLAG_P_SAMPLE;
}
- if((m_fb.flags & PIC_MASK_CODING_TYPE) == PIC_FLAG_CODING_TYPE_B) {
+ if ((m_fb.flags & PIC_MASK_CODING_TYPE) == PIC_FLAG_CODING_TYPE_B) {
props.dwTypeSpecificFlags |= AM_VIDEO_FLAG_B_SAMPLE;
}
}
@@ -520,7 +520,7 @@ HRESULT CMpeg2DecFilter::Transform(IMediaSample* pIn) HRESULT hr;
BYTE* pDataIn = NULL;
- if(FAILED(hr = pIn->GetPointer(&pDataIn))) {
+ if (FAILED(hr = pIn->GetPointer(&pDataIn))) {
return hr;
}
@@ -528,24 +528,24 @@ HRESULT CMpeg2DecFilter::Transform(IMediaSample* pIn) (static_cast<CDeCSSInputPin*>(m_pInput))->StripPacket(pDataIn, len);
- if(pIn->IsDiscontinuity() == S_OK) {
+ if (pIn->IsDiscontinuity() == S_OK) {
InputTypeChanged();
}
REFERENCE_TIME rtStart = _I64_MIN, rtStop = _I64_MIN;
hr = pIn->GetTime(&rtStart, &rtStop);
- if(FAILED(hr)) {
+ if (FAILED(hr)) {
rtStart = rtStop = _I64_MIN;
}
- while(len >= 0) {
+ while (len >= 0) {
mpeg2_state_t state = m_dec->mpeg2_parse();
#ifndef _WIN64
__asm emms; // this one is missing somewhere in the precompiled mmx obj files
#endif
- switch(state) {
+ switch (state) {
case STATE_BUFFER:
- if(len > 0) {
+ if (len > 0) {
m_dec->mpeg2_buffer(pDataIn, pDataIn + len);
len = 0;
} else {
@@ -574,7 +574,7 @@ HRESULT CMpeg2DecFilter::Transform(IMediaSample* pIn) mpeg2_picture_t* picture = m_dec->m_info.m_display_picture;
mpeg2_fbuf_t* fbuf = m_dec->m_info.m_display_fbuf;
- if(picture && !(picture->flags&PIC_FLAG_SKIP) && fbuf) {
+ if (picture && !(picture->flags&PIC_FLAG_SKIP) && fbuf) {
ASSERT(!picture->fDelivered);
picture->fDelivered = true;
@@ -585,7 +585,7 @@ HRESULT CMpeg2DecFilter::Transform(IMediaSample* pIn) int h = m_dec->m_info.m_sequence->picture_height;
int pitch = (m_dec->m_info.m_sequence->width + 31) & ~31;
- if(m_fb.w != w || m_fb.h != h || m_fb.pitch != pitch) {
+ if (m_fb.w != w || m_fb.h != h || m_fb.pitch != pitch) {
m_fb.Alloc(w, h, pitch);
m_fInitializedBuffer = false;
}
@@ -593,7 +593,7 @@ HRESULT CMpeg2DecFilter::Transform(IMediaSample* pIn) // start - end
m_fb.rtStart = picture->rtStart;
- if(m_fb.rtStart == _I64_MIN) {
+ if (m_fb.rtStart == _I64_MIN) {
m_fb.rtStart = m_fb.rtStop;
}
m_fb.rtStop = m_fb.rtStart + m_AvgTimePerFrame * picture->nb_fields / (m_dec->m_info.m_display_picture_2nd ? 1 : 2);
@@ -609,13 +609,13 @@ HRESULT CMpeg2DecFilter::Transform(IMediaSample* pIn) UpdateAspectRatio();
hr = DeliverFast();
- if(hr != S_OK) {
+ if (hr != S_OK) {
hr = DeliverNormal();
}
- if(hr != S_OK) {
+ if (hr != S_OK) {
return hr;
}
- if(hr == S_OK && !m_fWaitForKeyFrame) {
+ if (hr == S_OK && !m_fWaitForKeyFrame) {
m_fInitializedBuffer = true;
}
}
@@ -642,7 +642,7 @@ void CMpeg2DecFilter::UpdateAspectRatio() CSize dar(m_dec->m_info.m_sequence->picture_width * m_par.cx,
m_dec->m_info.m_sequence->picture_height * m_par.cy);
int lnko = LNKO(dar.cx, dar.cy);
- if(lnko > 1) {
+ if (lnko > 1) {
dar.cx /= lnko, dar.cy /= lnko;
}
SetAspect(dar);
@@ -656,7 +656,7 @@ HRESULT CMpeg2DecFilter::DeliverFast() CAutoLock cAutoLock(&m_csReceive);
mpeg2_fbuf_t* fbuf = m_dec->m_info.m_display_fbuf;
- if(!fbuf) {
+ if (!fbuf) {
return S_FALSE;
}
@@ -664,7 +664,7 @@ HRESULT CMpeg2DecFilter::DeliverFast() CAutoLock cAutoLock2(&m_csProps);
- if(GetCLSID(m_pInput->GetConnected()) == CLSID_DVDNavigator
+ if (GetCLSID(m_pInput->GetConnected()) == CLSID_DVDNavigator
|| m_pSubpicInput->HasAnythingToRender(m_fb.rtStart)
|| fabs(m_bright) > EPSILON || fabs(m_cont-1.0) > EPSILON
|| fabs(m_hue) > EPSILON || fabs(m_sat-1.0) > EPSILON) {
@@ -672,28 +672,28 @@ HRESULT CMpeg2DecFilter::DeliverFast() }
}
- if((m_fb.flags & PIC_MASK_CODING_TYPE) == PIC_FLAG_CODING_TYPE_I) {
+ if ((m_fb.flags & PIC_MASK_CODING_TYPE) == PIC_FLAG_CODING_TYPE_I) {
m_fWaitForKeyFrame = false;
}
- if(m_fb.rtStart < 0 || m_fWaitForKeyFrame) {
+ if (m_fb.rtStart < 0 || m_fWaitForKeyFrame) {
return S_OK;
}
const CMediaType& mt = m_pOutput->CurrentMediaType();
- if(mt.subtype != MEDIASUBTYPE_I420 && mt.subtype != MEDIASUBTYPE_IYUV && mt.subtype != MEDIASUBTYPE_YV12) {
+ if (mt.subtype != MEDIASUBTYPE_I420 && mt.subtype != MEDIASUBTYPE_IYUV && mt.subtype != MEDIASUBTYPE_YV12) {
return S_FALSE;
}
CComPtr<IMediaSample> pOut;
BYTE* pDataOut = NULL;
- if(FAILED(hr = GetDeliveryBuffer(m_fb.w, m_fb.h, &pOut))
+ if (FAILED(hr = GetDeliveryBuffer(m_fb.w, m_fb.h, &pOut))
|| FAILED(hr = pOut->GetPointer(&pDataOut))) {
return hr;
}
- if(mt.subtype != MEDIASUBTYPE_I420 && mt.subtype != MEDIASUBTYPE_IYUV && mt.subtype != MEDIASUBTYPE_YV12) {
+ if (mt.subtype != MEDIASUBTYPE_I420 && mt.subtype != MEDIASUBTYPE_IYUV && mt.subtype != MEDIASUBTYPE_YV12) {
return S_FALSE;
}
@@ -709,15 +709,15 @@ HRESULT CMpeg2DecFilter::DeliverFast() BYTE* u = y + dstpitch*h;
BYTE* v = y + dstpitch*h*5/4;
- if(bihOut.biCompression == '21VY') {
+ if (bihOut.biCompression == '21VY') {
BYTE* tmp = u;
u = v;
v = tmp;
}
- if(m_fb.di == DIWeave) {
+ if (m_fb.di == DIWeave) {
BitBltFromI420ToI420(w, h, y, u, v, dstpitch, fbuf->buf[0], fbuf->buf[1], fbuf->buf[2], srcpitch);
- } else if(m_fb.di == DIBlend) {
+ } else if (m_fb.di == DIBlend) {
DeinterlaceBlend(y, fbuf->buf[0], w, h, dstpitch, srcpitch);
DeinterlaceBlend(u, fbuf->buf[1], w/2, h/2, dstpitch/2, srcpitch/2);
DeinterlaceBlend(v, fbuf->buf[2], w/2, h/2, dstpitch/2, srcpitch/2);
@@ -725,16 +725,16 @@ HRESULT CMpeg2DecFilter::DeliverFast() return S_FALSE;
}
- if(h == 1088) {
+ if (h == 1088) {
memset(y + dstpitch*(h-8), 0xff, dstpitch*8);
memset(u + dstpitch*(h-8)/4, 0x80, dstpitch*8/4);
memset(v + dstpitch*(h-8)/4, 0x80, dstpitch*8/4);
}
- if(CMpeg2DecInputPin* pPin = dynamic_cast<CMpeg2DecInputPin*>(m_pInput)) {
+ if (CMpeg2DecInputPin* pPin = dynamic_cast<CMpeg2DecInputPin*>(m_pInput)) {
CAutoLock cAutoLock(&pPin->m_csRateLock);
- if(m_rate.Rate != pPin->m_ratechange.Rate) {
+ if (m_rate.Rate != pPin->m_ratechange.Rate) {
m_rate.Rate = pPin->m_ratechange.Rate;
m_rate.StartTime = m_fb.rtStart;
}
@@ -765,7 +765,7 @@ HRESULT CMpeg2DecFilter::DeliverNormal() CAutoLock cAutoLock(&m_csReceive);
mpeg2_fbuf_t* fbuf = m_dec->m_info.m_display_fbuf;
- if(!fbuf) {
+ if (!fbuf) {
return S_FALSE;
}
@@ -781,26 +781,26 @@ HRESULT CMpeg2DecFilter::DeliverNormal() // deinterlace
- if(m_fb.di == DIWeave) {
+ if (m_fb.di == DIWeave) {
BitBltFromI420ToI420(w, h, m_fb.buf[0], m_fb.buf[1], m_fb.buf[2], dpitch, fbuf->buf[0], fbuf->buf[1], fbuf->buf[2], spitch);
- } else if(m_fb.di == DIBlend) {
+ } else if (m_fb.di == DIBlend) {
DeinterlaceBlend(m_fb.buf[0], fbuf->buf[0], w, h, dpitch, spitch);
DeinterlaceBlend(m_fb.buf[1], fbuf->buf[1], w/2, h/2, dpitch/2, spitch/2);
DeinterlaceBlend(m_fb.buf[2], fbuf->buf[2], w/2, h/2, dpitch/2, spitch/2);
- } else if(m_fb.di == DIBob) {
+ } else if (m_fb.di == DIBob) {
DeinterlaceBob(m_fb.buf[0], fbuf->buf[0], w, h, dpitch, spitch, tff);
DeinterlaceBob(m_fb.buf[1], fbuf->buf[1], w/2, h/2, dpitch/2, spitch/2, tff);
DeinterlaceBob(m_fb.buf[2], fbuf->buf[2], w/2, h/2, dpitch/2, spitch/2, tff);
m_fb.rtStart = rtStart;
m_fb.rtStop = (rtStart + rtStop) / 2;
- } else if(m_fb.di == DIFieldShift) {
+ } else if (m_fb.di == DIFieldShift) {
int soffset = tff ? 0 : spitch;
int doffset = tff ? 0 : dpitch;
BitBltFromRGBToRGB(w, h/2, m_fb.buf[0] + doffset, dpitch*2, 8, fbuf->buf[0] + soffset, spitch*2, 8);
BitBltFromRGBToRGB(w/2, h/4, m_fb.buf[1] + doffset/2, dpitch, 8, fbuf->buf[1] + soffset/2, spitch, 8);
BitBltFromRGBToRGB(w/2, h/4, m_fb.buf[2] + doffset/2, dpitch, 8, fbuf->buf[2] + soffset/2, spitch, 8);
- } else if(m_fb.di == DIELA) {
+ } else if (m_fb.di == DIELA) {
DeinterlaceELA(m_fb.buf[0], fbuf->buf[0], w, h, dpitch, spitch, tff);
DeinterlaceELA(m_fb.buf[1], fbuf->buf[1], w/2, h/2, dpitch/2, spitch/2, tff);
DeinterlaceELA(m_fb.buf[2], fbuf->buf[2], w/2, h/2, dpitch/2, spitch/2, tff);
@@ -814,12 +814,12 @@ HRESULT CMpeg2DecFilter::DeliverNormal() if (m_fb.di == DIWeave || m_fInitializedBuffer) {
hr = Deliver(false);
- if(FAILED(hr)) {
+ if (FAILED(hr)) {
return hr;
}
}
- if(m_fb.di == DIBob) {
+ if (m_fb.di == DIBob) {
DeinterlaceBob(m_fb.buf[0], fbuf->buf[0], w, h, dpitch, spitch, !tff);
DeinterlaceBob(m_fb.buf[1], fbuf->buf[1], w/2, h/2, dpitch/2, spitch/2, !tff);
DeinterlaceBob(m_fb.buf[2], fbuf->buf[2], w/2, h/2, dpitch/2, spitch/2, !tff);
@@ -834,13 +834,13 @@ HRESULT CMpeg2DecFilter::DeliverNormal() // deliver
hr = Deliver(false);
- } else if(m_fb.di == DIFieldShift) {
+ } else if (m_fb.di == DIFieldShift) {
int soffset = !tff ? 0 : spitch;
int doffset = !tff ? 0 : dpitch;
BitBltFromRGBToRGB(w, h/2, m_fb.buf[0] + doffset, dpitch*2, 8, fbuf->buf[0] + soffset, spitch*2, 8);
BitBltFromRGBToRGB(w/2, h/4, m_fb.buf[1] + doffset/2, dpitch, 8, fbuf->buf[1] + soffset/2, spitch, 8);
BitBltFromRGBToRGB(w/2, h/4, m_fb.buf[2] + doffset/2, dpitch, 8, fbuf->buf[2] + soffset/2, spitch, 8);
- } else if(m_fb.di == DIELA) {
+ } else if (m_fb.di == DIELA) {
DeinterlaceELA(m_fb.buf[0], fbuf->buf[0], w, h, dpitch, spitch, !tff);
DeinterlaceELA(m_fb.buf[1], fbuf->buf[1], w/2, h/2, dpitch/2, spitch/2, !tff);
DeinterlaceELA(m_fb.buf[2], fbuf->buf[2], w/2, h/2, dpitch/2, spitch/2, !tff);
@@ -857,11 +857,11 @@ HRESULT CMpeg2DecFilter::Deliver(bool fRepeatLast) {
CAutoLock cAutoLock(&m_csReceive);
- if((m_fb.flags&PIC_MASK_CODING_TYPE) == PIC_FLAG_CODING_TYPE_I) {
+ if ((m_fb.flags&PIC_MASK_CODING_TYPE) == PIC_FLAG_CODING_TYPE_I) {
m_fWaitForKeyFrame = false;
}
- if(m_fb.rtStart < 0 || m_fWaitForKeyFrame) {
+ if (m_fb.rtStart < 0 || m_fWaitForKeyFrame) {
return S_OK;
}
@@ -869,12 +869,12 @@ HRESULT CMpeg2DecFilter::Deliver(bool fRepeatLast) CComPtr<IMediaSample> pOut;
BYTE* pDataOut = NULL;
- if(FAILED(hr = GetDeliveryBuffer(m_fb.w, m_fb.h, &pOut))
+ if (FAILED(hr = GetDeliveryBuffer(m_fb.w, m_fb.h, &pOut))
|| FAILED(hr = pOut->GetPointer(&pDataOut))) {
return hr;
}
- if(m_fb.h == 1088) {
+ if (m_fb.h == 1088) {
memset(m_fb.buf[0] + m_fb.w*(m_fb.h-8), 0xff, m_fb.pitch*8);
memset(m_fb.buf[1] + m_fb.w*(m_fb.h-8)/4, 0x80, m_fb.pitch*8/4);
memset(m_fb.buf[2] + m_fb.w*(m_fb.h-8)/4, 0x80, m_fb.pitch*8/4);
@@ -882,7 +882,7 @@ HRESULT CMpeg2DecFilter::Deliver(bool fRepeatLast) BYTE** buf = &m_fb.buf[0];
- if(m_pSubpicInput->HasAnythingToRender(m_fb.rtStart)) {
+ if (m_pSubpicInput->HasAnythingToRender(m_fb.rtStart)) {
BitBltFromI420ToI420(m_fb.w, m_fb.h,
m_fb.buf[3], m_fb.buf[4], m_fb.buf[5], m_fb.pitch,
m_fb.buf[0], m_fb.buf[1], m_fb.buf[2], m_fb.pitch);
@@ -896,10 +896,10 @@ HRESULT CMpeg2DecFilter::Deliver(bool fRepeatLast) //
- if(CMpeg2DecInputPin* pPin = dynamic_cast<CMpeg2DecInputPin*>(m_pInput)) {
+ if (CMpeg2DecInputPin* pPin = dynamic_cast<CMpeg2DecInputPin*>(m_pInput)) {
CAutoLock cAutoLock(&pPin->m_csRateLock);
- if(m_rate.Rate != pPin->m_ratechange.Rate) {
+ if (m_rate.Rate != pPin->m_ratechange.Rate) {
m_rate.Rate = pPin->m_ratechange.Rate;
m_rate.StartTime = m_fb.rtStart;
}
@@ -927,18 +927,18 @@ HRESULT CMpeg2DecFilter::Deliver(bool fRepeatLast) HRESULT CMpeg2DecFilter::CheckConnect(PIN_DIRECTION dir, IPin* pPin)
{
- if(dir == PINDIR_OUTPUT) {
- if(GetCLSID(m_pInput->GetConnected()) == CLSID_DVDNavigator) {
+ if (dir == PINDIR_OUTPUT) {
+ if (GetCLSID(m_pInput->GetConnected()) == CLSID_DVDNavigator) {
// one of these needed for dynamic format changes
CLSID clsid = GetCLSID(pPin);
DWORD ver = 0;
- if(CComQIPtr<IFilterVersion> pFV = GetFilterFromPin(pPin)) {
+ if (CComQIPtr<IFilterVersion> pFV = GetFilterFromPin(pPin)) {
ver = pFV->GetFilterVersion();
}
- if(clsid != CLSID_OverlayMixer
+ if (clsid != CLSID_OverlayMixer
/*&& clsid != CLSID_OverlayMixer2*/
&& clsid != CLSID_VideoMixingRenderer
&& clsid != CLSID_VideoMixingRenderer9
@@ -961,20 +961,20 @@ int NextMpegStartCode(CGolombBuffer& gb, BYTE& code, __int64 len) gb.BitByteAlign();
DWORD dw = (DWORD)-1;
do {
- if(len-- == 0) {
+ if (len-- == 0) {
return false;
}
dw = (dw << 8) | (BYTE)gb.BitRead(8);
- } while((dw&0xffffff00) != 0x00000100);
+ } while ((dw&0xffffff00) != 0x00000100);
code = (BYTE)(dw&0xff);
return true;
}
HRESULT CMpeg2DecFilter::CheckInputType(const CMediaType* mtIn)
{
- if(mtIn->formattype == FORMAT_MPEG2_VIDEO && mtIn->pbFormat) {
+ if (mtIn->formattype == FORMAT_MPEG2_VIDEO && mtIn->pbFormat) {
MPEG2VIDEOINFO* vih = (MPEG2VIDEOINFO*)mtIn->pbFormat;
- if(vih->cbSequenceHeader > 0 && (vih->dwSequenceHeader[0] & 0x00ffffff) != 0x00010000) {
+ if (vih->cbSequenceHeader > 0 && (vih->dwSequenceHeader[0] & 0x00ffffff) != 0x00010000) {
return VFW_E_TYPE_NOT_ACCEPTED;
}
BYTE* pSequenceHeader = (BYTE*)vih->dwSequenceHeader;
@@ -982,20 +982,20 @@ HRESULT CMpeg2DecFilter::CheckInputType(const CMediaType* mtIn) BYTE id = 0;
CGolombBuffer gb(pSequenceHeader, cbSequenceHeader);
- while(gb.GetPos() < gb.GetSize() && id != 0xb5) {
- if(!NextMpegStartCode(gb, id, cbSequenceHeader)) {
+ while (gb.GetPos() < gb.GetSize() && id != 0xb5) {
+ if (!NextMpegStartCode(gb, id, cbSequenceHeader)) {
break;
}
}
- if(id == 0xb5) {
+ if (id == 0xb5) {
gb.BitRead(4); // startcodeid
gb.BitRead(1); // profile_levelescape
gb.BitRead(3); // profile
gb.BitRead(4); // level
gb.BitRead(1); // interlaced
BYTE chroma = gb.BitRead(2);
- if(chroma >= 2) {// current support only 4:2:0 profile
- return VFW_E_TYPE_NOT_ACCEPTED;
+ if (chroma >= 2) { // current support only 4:2:0 profile
+ return VFW_E_TYPE_NOT_ACCEPTED;
}
}
}
@@ -1028,12 +1028,12 @@ DWORD g_clock; HRESULT CMpeg2DecFilter::StartStreaming()
{
HRESULT hr = __super::StartStreaming();
- if(FAILED(hr)) {
+ if (FAILED(hr)) {
return hr;
}
m_dec.Attach(DNew CMpeg2Dec());
- if(!m_dec) {
+ if (!m_dec) {
return E_OUTOFMEMORY;
}
@@ -1058,9 +1058,9 @@ HRESULT CMpeg2DecFilter::StopStreaming() HRESULT CMpeg2DecFilter::AlterQuality(Quality q)
{
- if(q.Late > 100*10000i64) {
+ if (q.Late > 100*10000i64) {
m_fDropFrames = true;
- } else if(q.Late <= 0) {
+ } else if (q.Late <= 0) {
m_fDropFrames = false;
}
@@ -1085,13 +1085,13 @@ STDMETHODIMP CMpeg2DecFilter::CreatePage(const GUID& guid, IPropertyPage** ppPag {
CheckPointer(ppPage, E_POINTER);
- if(*ppPage != NULL) {
+ if (*ppPage != NULL) {
return E_INVALIDARG;
}
HRESULT hr;
- if(guid == __uuidof(CMpeg2DecSettingsWnd)) {
+ if (guid == __uuidof(CMpeg2DecSettingsWnd)) {
(*ppPage = DNew CInternalPropertyPageTempl<CMpeg2DecSettingsWnd>(NULL, &hr))->AddRef();
}
@@ -1118,7 +1118,7 @@ void CMpeg2DecFilter::CalcBrCont(BYTE* YTbl, float bright, float cont) int Cont = (int)(cont * 512);
int Bright = (int)bright;
- for(int i = 0; i < 256; i++) {
+ for (int i = 0; i < 256; i++) {
int y = ((Cont * (i - 16)) >> 9) + Bright + 16;
YTbl[i] = min(max(y, 0), 255);
// YTbl[i] = min(max(y, 16), 235);
@@ -1132,8 +1132,8 @@ void CMpeg2DecFilter::CalcHueSat(BYTE* UTbl, BYTE* VTbl, float hue, float sat) int Sin = (int)(sin(Hue) * 4096);
int Cos = (int)(cos(Hue) * 4096);
- for(int y = 0; y < 256; y++) {
- for(int x = 0; x < 256; x++) {
+ for (int y = 0; y < 256; y++) {
+ for (int x = 0; x < 256; x++) {
int u = x - 128;
int v = y - 128;
int ux = (u * Cos + v * Sin) >> 12;
@@ -1152,10 +1152,10 @@ void CMpeg2DecFilter::ApplyBrContHueSat(BYTE* srcy, BYTE* srcu, BYTE* srcv, int {
CAutoLock cAutoLock(&m_csProps);
- if(fabs(m_bright) > EPSILON || fabs(m_cont-1.0) > EPSILON) {
+ if (fabs(m_bright) > EPSILON || fabs(m_cont-1.0) > EPSILON) {
int size = pitch*h;
- if((g_cpuid.m_flags&CCpuID::sse2) && ((DWORD_PTR)srcy & 15) == 0) {
+ if ((g_cpuid.m_flags&CCpuID::sse2) && ((DWORD_PTR)srcy & 15) == 0) {
short Cont = (short)(min(max(m_cont, 0) * 512, (1<<16)-1));
short Bright = (short)(m_bright + 16);
@@ -1165,7 +1165,7 @@ void CMpeg2DecFilter::ApplyBrContHueSat(BYTE* srcy, BYTE* srcu, BYTE* srcv, int __m128i _16 = _mm_set1_epi16(16);
__m128i _512 = _mm_set1_epi16(512);
- for(int i = 0, j = size>>4; i < j; i++) {
+ for (int i = 0, j = size>>4; i < j; i++) {
__m128i r = _mm_load_si128((__m128i*)&srcy[i*16]);
__m128i rl = _mm_unpacklo_epi8(r, zero);
@@ -1201,7 +1201,7 @@ void CMpeg2DecFilter::ApplyBrContHueSat(BYTE* srcy, BYTE* srcu, BYTE* srcv, int size &= 15;
}
- for(; size > 0; size--) {
+ for (; size > 0; size--) {
*srcy++ = m_YTbl[*srcy];
}
}
@@ -1210,8 +1210,8 @@ void CMpeg2DecFilter::ApplyBrContHueSat(BYTE* srcy, BYTE* srcu, BYTE* srcv, int w /= 2;
h /= 2;
- if(fabs(m_hue) > EPSILON || fabs(m_sat-1.0) > EPSILON) {
- for(int size = pitch*h; size > 0; size--) {
+ if (fabs(m_hue) > EPSILON || fabs(m_sat-1.0) > EPSILON) {
+ for (int size = pitch*h; size > 0; size--) {
WORD uv = (*srcv<<8)|*srcu;
*srcu++ = m_UTbl[uv];
*srcv++ = m_VTbl[uv];
@@ -1339,15 +1339,15 @@ CMpeg2DecInputPin::CMpeg2DecInputPin(CTransformFilter* pFilter, HRESULT* phr, LP STDMETHODIMP CMpeg2DecInputPin::Set(REFGUID PropSet, ULONG Id, LPVOID pInstanceData, ULONG InstanceLength, LPVOID pPropertyData, ULONG DataLength)
{
- if(PropSet != AM_KSPROPSETID_TSRateChange /*&& PropSet != AM_KSPROPSETID_DVD_RateChange*/) {
+ if (PropSet != AM_KSPROPSETID_TSRateChange /*&& PropSet != AM_KSPROPSETID_DVD_RateChange*/) {
return __super::Set(PropSet, Id, pInstanceData, InstanceLength, pPropertyData, DataLength);
}
- if(PropSet == AM_KSPROPSETID_TSRateChange)
- switch(Id) {
+ if (PropSet == AM_KSPROPSETID_TSRateChange)
+ switch (Id) {
case AM_RATE_SimpleRateChange: {
AM_SimpleRateChange* p = (AM_SimpleRateChange*)pPropertyData;
- if(!m_CorrectTS) {
+ if (!m_CorrectTS) {
return E_PROP_ID_UNSUPPORTED;
}
CAutoLock cAutoLock(&m_csRateLock);
@@ -1357,7 +1357,7 @@ STDMETHODIMP CMpeg2DecInputPin::Set(REFGUID PropSet, ULONG Id, LPVOID pInstanceD break;
case AM_RATE_UseRateVersion: {
WORD* p = (WORD*)pPropertyData;
- if(*p > 0x0101) {
+ if (*p > 0x0101) {
return E_PROP_ID_UNSUPPORTED;
}
}
@@ -1388,12 +1388,12 @@ STDMETHODIMP CMpeg2DecInputPin::Set(REFGUID PropSet, ULONG Id, LPVOID pInstanceD STDMETHODIMP CMpeg2DecInputPin::Get(REFGUID PropSet, ULONG Id, LPVOID pInstanceData, ULONG InstanceLength, LPVOID pPropertyData, ULONG DataLength, ULONG* pBytesReturned)
{
- if(PropSet != AM_KSPROPSETID_TSRateChange /*&& PropSet != AM_KSPROPSETID_DVD_RateChange*/) {
+ if (PropSet != AM_KSPROPSETID_TSRateChange /*&& PropSet != AM_KSPROPSETID_DVD_RateChange*/) {
return __super::Get(PropSet, Id, pInstanceData, InstanceLength, pPropertyData, DataLength, pBytesReturned);
}
- if(PropSet == AM_KSPROPSETID_TSRateChange)
- switch(Id) {
+ if (PropSet == AM_KSPROPSETID_TSRateChange)
+ switch (Id) {
case AM_RATE_SimpleRateChange: {
AM_SimpleRateChange* p = (AM_SimpleRateChange*)pPropertyData;
UNUSED_ALWAYS(p);
@@ -1455,12 +1455,12 @@ STDMETHODIMP CMpeg2DecInputPin::Get(REFGUID PropSet, ULONG Id, LPVOID pInstanceD STDMETHODIMP CMpeg2DecInputPin::QuerySupported(REFGUID PropSet, ULONG Id, ULONG* pTypeSupport)
{
- if(PropSet != AM_KSPROPSETID_TSRateChange /*&& PropSet != AM_KSPROPSETID_DVD_RateChange*/) {
+ if (PropSet != AM_KSPROPSETID_TSRateChange /*&& PropSet != AM_KSPROPSETID_DVD_RateChange*/) {
return __super::QuerySupported(PropSet, Id, pTypeSupport);
}
- if(PropSet == AM_KSPROPSETID_TSRateChange)
- switch(Id) {
+ if (PropSet == AM_KSPROPSETID_TSRateChange)
+ switch (Id) {
case AM_RATE_SimpleRateChange:
*pTypeSupport = KSPROPERTY_SUPPORT_GET | KSPROPERTY_SUPPORT_SET;
break;
@@ -1523,15 +1523,15 @@ HRESULT CMpeg2DecOutputPin::Active() // TODO
- if(m_Connected && !m_pOutputQueue) {
+ if (m_Connected && !m_pOutputQueue) {
HRESULT hr = NOERROR;
m_pOutputQueue.Attach(DNew COutputQueue(m_Connected, &hr));
- if(!m_pOutputQueue) {
+ if (!m_pOutputQueue) {
hr = E_OUTOFMEMORY;
}
- if(FAILED(hr)) {
+ if (FAILED(hr)) {
m_pOutputQueue.Free();
return hr;
}
@@ -1549,7 +1549,7 @@ HRESULT CMpeg2DecOutputPin::Inactive() HRESULT CMpeg2DecOutputPin::Deliver(IMediaSample* pMediaSample)
{
- if(!m_pOutputQueue) {
+ if (!m_pOutputQueue) {
return NOERROR;
}
pMediaSample->AddRef();
@@ -1623,16 +1623,16 @@ HRESULT CSubpicInputPin::SetMediaType(const CMediaType* mtIn) bool CSubpicInputPin::HasAnythingToRender(REFERENCE_TIME rt)
{
- if(!IsConnected()) {
+ if (!IsConnected()) {
return false;
}
CAutoLock cAutoLock(&m_csReceive);
POSITION pos = m_sps.GetHeadPosition();
- while(pos) {
+ while (pos) {
spu* sp = m_sps.GetNext(pos);
- if(sp->m_rtStart <= rt && rt < sp->m_rtStop && (/*sp->m_psphli ||*/ sp->m_fForced || m_spon)) {
+ if (sp->m_rtStart <= rt && rt < sp->m_rtStop && (/*sp->m_psphli ||*/ sp->m_fForced || m_spon)) {
return true;
}
}
@@ -1648,18 +1648,18 @@ void CSubpicInputPin::RenderSubpics(REFERENCE_TIME rt, BYTE** yuv, int w, int h) // remove no longer needed things first
pos = m_sps.GetHeadPosition();
- while(pos) {
+ while (pos) {
POSITION cur = pos;
spu* sp = m_sps.GetNext(pos);
- if(sp->m_rtStop <= rt) {
+ if (sp->m_rtStop <= rt) {
m_sps.RemoveAt(cur);
}
}
pos = m_sps.GetHeadPosition();
- while(pos) {
+ while (pos) {
spu* sp = m_sps.GetNext(pos);
- if(sp->m_rtStart <= rt && rt < sp->m_rtStop
+ if (sp->m_rtStart <= rt && rt < sp->m_rtStop
&& (m_spon || sp->m_fForced && ((static_cast<CMpeg2DecFilter*>(m_pFilter))->IsForcedSubtitlesEnabled() || sp->m_psphli))) {
sp->Render(rt, yuv, w, h, m_sppal, m_fsppal);
}
@@ -1671,14 +1671,14 @@ HRESULT CSubpicInputPin::Transform(IMediaSample* pSample) HRESULT hr;
AM_MEDIA_TYPE* pmt;
- if(SUCCEEDED(pSample->GetMediaType(&pmt)) && pmt) {
+ if (SUCCEEDED(pSample->GetMediaType(&pmt)) && pmt) {
CMediaType mt(*pmt);
SetMediaType(&mt);
DeleteMediaType(pmt);
}
BYTE* pDataIn = NULL;
- if(FAILED(hr = pSample->GetPointer(&pDataIn))) {
+ if (FAILED(hr = pSample->GetPointer(&pDataIn))) {
return hr;
}
@@ -1686,16 +1686,16 @@ HRESULT CSubpicInputPin::Transform(IMediaSample* pSample) StripPacket(pDataIn, len);
- if(len <= 0) {
+ if (len <= 0) {
return S_FALSE;
}
- if(m_mt.subtype == MEDIASUBTYPE_SVCD_SUBPICTURE) {
+ if (m_mt.subtype == MEDIASUBTYPE_SVCD_SUBPICTURE) {
pDataIn += 4;
len -= 4;
}
- if(len <= 0) {
+ if (len <= 0) {
return S_FALSE;
}
@@ -1706,17 +1706,17 @@ HRESULT CSubpicInputPin::Transform(IMediaSample* pSample) bool fRefresh = false;
- if(FAILED(hr)) {
- if(!m_sps.IsEmpty()) {
+ if (FAILED(hr)) {
+ if (!m_sps.IsEmpty()) {
spu* sp = m_sps.GetTail();
sp->SetCount(sp->GetCount() + len);
memcpy(sp->GetData() + sp->GetCount() - len, pDataIn, len);
}
} else {
POSITION pos = m_sps.GetTailPosition();
- while(pos) {
+ while (pos) {
spu* sp = m_sps.GetPrev(pos);
- if(sp->m_rtStop == _I64_MAX) {
+ if (sp->m_rtStop == _I64_MAX) {
sp->m_rtStop = rtStart;
break;
}
@@ -1724,11 +1724,11 @@ HRESULT CSubpicInputPin::Transform(IMediaSample* pSample) CAutoPtr<spu> p;
- if(m_mt.subtype == MEDIASUBTYPE_DVD_SUBPICTURE) {
+ if (m_mt.subtype == MEDIASUBTYPE_DVD_SUBPICTURE) {
p.Attach(DNew dvdspu());
- } else if(m_mt.subtype == MEDIASUBTYPE_CVD_SUBPICTURE) {
+ } else if (m_mt.subtype == MEDIASUBTYPE_CVD_SUBPICTURE) {
p.Attach(DNew cvdspu());
- } else if(m_mt.subtype == MEDIASUBTYPE_SVCD_SUBPICTURE) {
+ } else if (m_mt.subtype == MEDIASUBTYPE_SVCD_SUBPICTURE) {
p.Attach(DNew svcdspu());
} else {
return E_FAIL;
@@ -1740,7 +1740,7 @@ HRESULT CSubpicInputPin::Transform(IMediaSample* pSample) p->SetCount(len);
memcpy(p->GetData(), pDataIn, len);
- if(m_sphli && p->m_rtStart == PTS2RT(m_sphli->StartPTM)) {
+ if (m_sphli && p->m_rtStart == PTS2RT(m_sphli->StartPTM)) {
p->m_psphli = m_sphli;
fRefresh = true;
}
@@ -1748,11 +1748,11 @@ HRESULT CSubpicInputPin::Transform(IMediaSample* pSample) m_sps.AddTail(p);
}
- if(!m_sps.IsEmpty()) {
+ if (!m_sps.IsEmpty()) {
m_sps.GetTail()->Parse();
}
- if(fRefresh) {
+ if (fRefresh) {
// ((CMpeg2DecFilter*)m_pFilter)->Deliver(true);
}
@@ -1770,13 +1770,13 @@ STDMETHODIMP CSubpicInputPin::EndFlush() STDMETHODIMP CSubpicInputPin::Set(REFGUID PropSet, ULONG Id, LPVOID pInstanceData, ULONG InstanceLength, LPVOID pPropertyData, ULONG DataLength)
{
- if(PropSet != AM_KSPROPSETID_DvdSubPic) {
+ if (PropSet != AM_KSPROPSETID_DvdSubPic) {
return __super::Set(PropSet, Id, pInstanceData, InstanceLength, pPropertyData, DataLength);
}
bool fRefresh = false;
- switch(Id) {
+ switch (Id) {
case AM_PROPERTY_DVDSUBPIC_PALETTE: {
CAutoLock cAutoLock(&m_csReceive);
@@ -1794,11 +1794,11 @@ STDMETHODIMP CSubpicInputPin::Set(REFGUID PropSet, ULONG Id, LPVOID pInstanceDat m_sphli.Free();
- if(pSPHLI->HLISS) {
+ if (pSPHLI->HLISS) {
POSITION pos = m_sps.GetHeadPosition();
- while(pos) {
+ while (pos) {
spu* sp = m_sps.GetNext(pos);
- if(sp->m_rtStart <= PTS2RT(pSPHLI->StartPTM) && PTS2RT(pSPHLI->StartPTM) < sp->m_rtStop) {
+ if (sp->m_rtStart <= PTS2RT(pSPHLI->StartPTM) && PTS2RT(pSPHLI->StartPTM) < sp->m_rtStop) {
fRefresh = true;
sp->m_psphli.Free();
sp->m_psphli.Attach(DNew AM_PROPERTY_SPHLI);
@@ -1806,20 +1806,20 @@ STDMETHODIMP CSubpicInputPin::Set(REFGUID PropSet, ULONG Id, LPVOID pInstanceDat }
}
- if(!fRefresh) { // save it for later, a subpic might be late for this hli
+ if (!fRefresh) { // save it for later, a subpic might be late for this hli
m_sphli.Attach(DNew AM_PROPERTY_SPHLI);
memcpy((AM_PROPERTY_SPHLI*)m_sphli, pSPHLI, sizeof(AM_PROPERTY_SPHLI));
}
} else {
POSITION pos = m_sps.GetHeadPosition();
- while(pos) {
+ while (pos) {
spu* sp = m_sps.GetNext(pos);
fRefresh |= !!sp->m_psphli;
sp->m_psphli.Free();
}
}
- if(pSPHLI->HLISS)
+ if (pSPHLI->HLISS)
DbgLog((LOG_TRACE, 0, _T("hli: %I64d - %I64d, (%d,%d) - (%d,%d)"),
PTS2RT(pSPHLI->StartPTM)/10000, PTS2RT(pSPHLI->EndPTM)/10000,
pSPHLI->StartX, pSPHLI->StartY, pSPHLI->StopX, pSPHLI->StopY));
@@ -1836,7 +1836,7 @@ STDMETHODIMP CSubpicInputPin::Set(REFGUID PropSet, ULONG Id, LPVOID pInstanceDat return E_PROP_ID_UNSUPPORTED;
}
- if(fRefresh) {
+ if (fRefresh) {
(static_cast<CMpeg2DecFilter*>(m_pFilter))->Deliver(true);
}
@@ -1845,11 +1845,11 @@ STDMETHODIMP CSubpicInputPin::Set(REFGUID PropSet, ULONG Id, LPVOID pInstanceDat STDMETHODIMP CSubpicInputPin::QuerySupported(REFGUID PropSet, ULONG Id, ULONG* pTypeSupport)
{
- if(PropSet != AM_KSPROPSETID_DvdSubPic) {
+ if (PropSet != AM_KSPROPSETID_DvdSubPic) {
return __super::QuerySupported(PropSet, Id, pTypeSupport);
}
- switch(Id) {
+ switch (Id) {
case AM_PROPERTY_DVDSUBPIC_PALETTE:
*pTypeSupport = KSPROPERTY_SUPPORT_SET;
break;
@@ -1879,7 +1879,7 @@ static __inline BYTE GetNibble(BYTE* p, DWORD* offset, int& nField, int& fAligne static __inline BYTE GetHalfNibble(BYTE* p, DWORD* offset, int& nField, int& n)
{
BYTE ret = (p[offset[nField]] >> (n << 1)) & 0x03;
- if(!n) {
+ if (!n) {
offset[nField]++;
}
n = (n-1+4)&3;
@@ -1888,7 +1888,7 @@ static __inline BYTE GetHalfNibble(BYTE* p, DWORD* offset, int& nField, int& n) static __inline void DrawPixel(BYTE** yuv, CPoint pt, int pitch, AM_DVD_YUV& c)
{
- if(c.Reserved == 0) {
+ if (c.Reserved == 0) {
return;
}
@@ -1896,7 +1896,7 @@ static __inline void DrawPixel(BYTE** yuv, CPoint pt, int pitch, AM_DVD_YUV& c) // *p = (*p*(15-contrast) + sppal[color].Y*contrast)>>4;
*p -= (*p - c.Y) * c.Reserved >> 4;
- if(pt.y&1) {
+ if (pt.y&1) {
return; // since U/V is half res there is no need to overwrite the same line again
}
@@ -1921,32 +1921,32 @@ static __inline void DrawPixel(BYTE** yuv, CPoint pt, int pitch, AM_DVD_YUV& c) static __inline void DrawPixels(BYTE** yuv, int pitch, CPoint pt, int len, AM_DVD_YUV& c, CRect& rc)
{
- if(pt.y < rc.top || pt.y >= rc.bottom) {
+ if (pt.y < rc.top || pt.y >= rc.bottom) {
return;
}
- if(pt.x < rc.left) {
+ if (pt.x < rc.left) {
len -= rc.left - pt.x;
pt.x = rc.left;
}
- if(pt.x + len > rc.right) {
+ if (pt.x + len > rc.right) {
len = rc.right - pt.x;
}
- if(len <= 0 || pt.x >= rc.right) {
+ if (len <= 0 || pt.x >= rc.right) {
return;
}
- if(c.Reserved == 0) {
- if(rc.IsRectEmpty()) {
+ if (c.Reserved == 0) {
+ if (rc.IsRectEmpty()) {
return;
}
- if(pt.y < rc.top || pt.y >= rc.bottom
+ if (pt.y < rc.top || pt.y >= rc.bottom
|| pt.x+len < rc.left || pt.x >= rc.right) {
return;
}
}
- while(len-- > 0) {
+ while (len-- > 0) {
DrawPixel(yuv, pt, pitch, c);
pt.x++;
}
@@ -1963,7 +1963,7 @@ bool CSubpicInputPin::dvdspu::Parse() WORD packetsize = (p[0]<<8)|p[1];
WORD datasize = (p[2]<<8)|p[3];
- if(packetsize > GetCount() || datasize > packetsize) {
+ if (packetsize > GetCount() || datasize > packetsize) {
return false;
}
@@ -1977,16 +1977,16 @@ bool CSubpicInputPin::dvdspu::Parse() int pts = GetWORD;
next = GetWORD;
- if(next > packetsize || next < datasize) {
+ if (next > packetsize || next < datasize) {
return false;
}
REFERENCE_TIME rt = m_rtStart + 1024*PTS2RT(pts);
- for(bool fBreak = false; !fBreak; ) {
+ for (bool fBreak = false; !fBreak; ) {
int len = 0;
- switch(p[i]) {
+ switch (p[i]) {
case 0x00:
len = 0;
break;
@@ -2016,12 +2016,12 @@ bool CSubpicInputPin::dvdspu::Parse() break;
}
- if(i+len >= packetsize) {
+ if (i+len >= packetsize) {
TRACE(_T("Warning: Wrong subpicture parameter block ending\n"));
break;
}
- switch(p[i++]) {
+ switch (p[i++]) {
case 0x00: // forced start displaying
m_fForced = true;
break;
@@ -2070,7 +2070,7 @@ bool CSubpicInputPin::dvdspu::Parse() offset_t o = {rt, m_sphli};
m_offsets.AddTail(o); // is it always going to be sorted?
- } while(i <= next && i < packetsize);
+ } while (i <= next && i < packetsize);
return true;
}
@@ -2087,14 +2087,14 @@ void CSubpicInputPin::dvdspu::Render(REFERENCE_TIME rt, BYTE** yuv, int w, int h CRect rcclip(0, 0, w, h);
rcclip &= rc;
- if(m_psphli) {
+ if (m_psphli) {
rcclip &= CRect(m_psphli->StartX, m_psphli->StartY, m_psphli->StopX, m_psphli->StopY);
sphli = *m_psphli;
- } else if(m_offsets.GetCount() > 1) {
+ } else if (m_offsets.GetCount() > 1) {
POSITION pos = m_offsets.GetTailPosition();
- while(pos) {
+ while (pos) {
const offset_t& o = m_offsets.GetPrev(pos);
- if(rt >= o.rt) {
+ if (rt >= o.rt) {
sphli = o.sphli;
break;
}
@@ -2116,22 +2116,22 @@ void CSubpicInputPin::dvdspu::Render(REFERENCE_TIME rt, BYTE** yuv, int w, int h DWORD end[2] = {offset[1], (p[2]<<8)|p[3]};
- while((nField == 0 && offset[0] < end[0]) || (nField == 1 && offset[1] < end[1])) {
+ while ((nField == 0 && offset[0] < end[0]) || (nField == 1 && offset[1] < end[1])) {
DWORD code;
- if((code = GetNibble(p, offset, nField, fAligned)) >= 0x4
+ if ((code = GetNibble(p, offset, nField, fAligned)) >= 0x4
|| (code = (code << 4) | GetNibble(p, offset, nField, fAligned)) >= 0x10
|| (code = (code << 4) | GetNibble(p, offset, nField, fAligned)) >= 0x40
|| (code = (code << 4) | GetNibble(p, offset, nField, fAligned)) >= 0x100) {
DrawPixels(yuv, w, pt, code >> 2, pal[code&3], rcclip);
- if((pt.x += code >> 2) < rc.right) {
+ if ((pt.x += code >> 2) < rc.right) {
continue;
}
}
DrawPixels(yuv, w, pt, rc.right - pt.x, pal[code&3], rcclip);
- if(!fAligned) {
+ if (!fAligned) {
GetNibble(p, offset, nField, fAligned); // align to byte
}
@@ -2150,14 +2150,14 @@ bool CSubpicInputPin::cvdspu::Parse() WORD packetsize = (p[0]<<8)|p[1];
WORD datasize = (p[2]<<8)|p[3];
- if(packetsize > GetCount() || datasize > packetsize) {
+ if (packetsize > GetCount() || datasize > packetsize) {
return false;
}
p = GetData() + datasize;
- for(int i = datasize, j = packetsize-4; i <= j; i+=4, p+=4) {
- switch(p[0]) {
+ for (int i = datasize, j = packetsize-4; i <= j; i+=4, p+=4) {
+ switch (p[0]) {
case 0x0c:
break;
case 0x04:
@@ -2234,10 +2234,10 @@ void CSubpicInputPin::cvdspu::Render(REFERENCE_TIME rt, BYTE** yuv, int w, int h DWORD end[2] = {offset[1], (p[2]<<8)|p[3]};
- while((nField == 0 && offset[0] < end[0]) || (nField == 1 && offset[1] < end[1])) {
+ while ((nField == 0 && offset[0] < end[0]) || (nField == 1 && offset[1] < end[1])) {
BYTE code;
- if((code = GetNibble(p, offset, nField, fAligned)) >= 0x4) {
+ if ((code = GetNibble(p, offset, nField, fAligned)) >= 0x4) {
DrawPixels(yuv, w, pt, code >> 2, m_sppal[0][code&3], rcclip);
pt.x += code >> 2;
continue;
@@ -2246,7 +2246,7 @@ void CSubpicInputPin::cvdspu::Render(REFERENCE_TIME rt, BYTE** yuv, int w, int h code = GetNibble(p, offset, nField, fAligned);
DrawPixels(yuv, w, pt, rc.right - pt.x, m_sppal[0][code&3], rcclip);
- if(!fAligned) {
+ if (!fAligned) {
GetNibble(p, offset, nField, fAligned); // align to byte
}
@@ -2263,14 +2263,14 @@ bool CSubpicInputPin::svcdspu::Parse() BYTE* p = GetData();
BYTE* p0 = p;
- if(GetCount() < 2) {
+ if (GetCount() < 2) {
return false;
}
WORD packetsize = (p[0]<<8)|p[1];
p += 2;
- if(packetsize > GetCount()) {
+ if (packetsize > GetCount()) {
return false;
}
@@ -2278,7 +2278,7 @@ bool CSubpicInputPin::svcdspu::Parse() *p++; // unknown
- if(duration) {
+ if (duration) {
m_rtStop = m_rtStart + 10000i64*((p[0]<<24)|(p[1]<<16)|(p[2]<<8)|p[3])/90;
p += 4;
}
@@ -2292,14 +2292,14 @@ bool CSubpicInputPin::svcdspu::Parse() m_sphli.StopY += (p[0]<<8)|p[1];
p += 2;
- for(int i = 0; i < 4; i++) {
+ for (int i = 0; i < 4; i++) {
m_sppal[i].Y = *p++;
m_sppal[i].U = *p++;
m_sppal[i].V = *p++;
m_sppal[i].Reserved = *p++ >> 4;
}
- if(*p++&0xc0) {
+ if (*p++&0xc0) {
p += 4; // duration of the shift operation should be here, but it is untested
}
@@ -2333,16 +2333,16 @@ void CSubpicInputPin::svcdspu::Render(REFERENCE_TIME rt, BYTE** yuv, int w, int DWORD end[2] = {offset[1], (p[2]<<8)|p[3]};
- while((nField == 0 && offset[0] < end[0]) || (nField == 1 && offset[1] < end[1])) {
+ while ((nField == 0 && offset[0] < end[0]) || (nField == 1 && offset[1] < end[1])) {
BYTE code = GetHalfNibble(p, offset, nField, n);
BYTE repeat = 1 + (code == 0 ? GetHalfNibble(p, offset, nField, n) : 0);
DrawPixels(yuv, w, pt, repeat, m_sppal[code&3], rcclip);
- if((pt.x += repeat) < rc.right) {
+ if ((pt.x += repeat) < rc.right) {
continue;
}
- while(n != 3) {
+ while (n != 3) {
GetHalfNibble(p, offset, nField, n); // align to byte
}
@@ -2370,10 +2370,10 @@ HRESULT CClosedCaptionOutputPin::CheckMediaType(const CMediaType* mtOut) HRESULT CClosedCaptionOutputPin::GetMediaType(int iPosition, CMediaType* pmt)
{
- if(iPosition < 0) {
+ if (iPosition < 0) {
return E_INVALIDARG;
}
- if(iPosition > 0) {
+ if (iPosition > 0) {
return VFW_S_NO_MORE_ITEMS;
}
@@ -2394,7 +2394,7 @@ HRESULT CClosedCaptionOutputPin::DecideBufferSize(IMemAllocator* pAllocator, ALL HRESULT hr;
ALLOCATOR_PROPERTIES Actual;
- if(FAILED(hr = pAllocator->SetProperties(pProperties, &Actual))) {
+ if (FAILED(hr = pAllocator->SetProperties(pProperties, &Actual))) {
return hr;
}
@@ -2407,7 +2407,7 @@ HRESULT CClosedCaptionOutputPin::Deliver(const void* ptr, int len) {
HRESULT hr = S_FALSE;
- if(len > 4 && ptr && *(DWORD*)ptr == 0xf8014343 && IsConnected()) {
+ if (len > 4 && ptr && *(DWORD*)ptr == 0xf8014343 && IsConnected()) {
CComPtr<IMediaSample> pSample;
GetDeliveryBuffer(&pSample, NULL, NULL, 0);
BYTE* pData = NULL;
diff --git a/src/filters/transform/Mpeg2DecFilter/Mpeg2DecFilter.h b/src/filters/transform/Mpeg2DecFilter/Mpeg2DecFilter.h index 4831659bd..4fcb46154 100644 --- a/src/filters/transform/Mpeg2DecFilter/Mpeg2DecFilter.h +++ b/src/filters/transform/Mpeg2DecFilter/Mpeg2DecFilter.h @@ -86,7 +86,7 @@ class __declspec(uuid("39F498AF-1A09-4275-B193-673B0BA3D478")) p += (size/4 + 31) & ~31;
}
void Free() {
- if(buf_base) {
+ if (buf_base) {
_aligned_free(buf_base);
}
buf_base = NULL;
@@ -113,7 +113,7 @@ public: DECLARE_IUNKNOWN
STDMETHODIMP NonDelegatingQueryInterface(REFIID riid, void** ppv);
-
+
HRESULT DeliverFast();
HRESULT DeliverNormal();
HRESULT Deliver(bool fRepeatLast);
diff --git a/src/filters/transform/Mpeg2DecFilter/Mpeg2DecSettingsWnd.cpp b/src/filters/transform/Mpeg2DecFilter/Mpeg2DecSettingsWnd.cpp index 9d06b13a9..d04376728 100644 --- a/src/filters/transform/Mpeg2DecFilter/Mpeg2DecSettingsWnd.cpp +++ b/src/filters/transform/Mpeg2DecFilter/Mpeg2DecSettingsWnd.cpp @@ -51,11 +51,11 @@ bool CMpeg2DecSettingsWnd::OnConnect(const CInterfaceList<IUnknown, &IID_IUnknow m_pM2DF.Release();
POSITION pos = pUnks.GetHeadPosition();
- while(pos && !(m_pM2DF = pUnks.GetNext(pos))) {
+ while (pos && !(m_pM2DF = pUnks.GetNext(pos))) {
;
}
- if(!m_pM2DF) {
+ if (!m_pM2DF) {
return false;
}
@@ -110,8 +110,8 @@ bool CMpeg2DecSettingsWnd::OnActivate() m_ditype_combo.SetItemData(m_ditype_combo.AddString(_T("Field Shift")), (DWORD)DIFieldShift);
m_ditype_combo.SetItemData(m_ditype_combo.AddString(_T("ELA")), (DWORD)DIELA);
m_ditype_combo.SetCurSel(0);
- for(int i = 0; i < m_ditype_combo.GetCount(); i++)
- if((int)m_ditype_combo.GetItemData(i) == m_ditype) {
+ for (int i = 0; i < m_ditype_combo.GetCount(); i++)
+ if ((int)m_ditype_combo.GetItemData(i) == m_ditype) {
m_ditype_combo.SetCurSel(i);
}
@@ -119,7 +119,7 @@ bool CMpeg2DecSettingsWnd::OnActivate() p.y += m_fontheight + 20;
- for(int i = 0, h = max(20, m_fontheight)+1; i < countof(m_procamp_slider); i++, p.y += h) {
+ for (int i = 0, h = max(20, m_fontheight)+1; i < countof(m_procamp_slider); i++, p.y += h) {
static const TCHAR* labels[] = {m_strBrightness, m_strContrast, m_strHue, m_strSaturation};
m_procamp_static[i].Create(labels[i], dwStyle, CRect(p, CSize(70, h)), this);
m_procamp_slider[i].Create(dwStyle, CRect(p + CPoint(80, 0), CSize(201, h)), this, IDC_PP_SLIDER1+i);
@@ -153,7 +153,7 @@ bool CMpeg2DecSettingsWnd::OnActivate() ResStr(IDS_MPEG2DECSETTINGSWND_8),
dwStyle, CRect(p, CSize(320, m_fontheight * 4)), this);
- for(CWnd* pWnd = GetWindow(GW_CHILD); pWnd; pWnd = pWnd->GetNextWindow()) {
+ for (CWnd* pWnd = GetWindow(GW_CHILD); pWnd; pWnd = pWnd->GetNextWindow()) {
pWnd->SetFont(&m_font, FALSE);
}
@@ -177,7 +177,7 @@ bool CMpeg2DecSettingsWnd::OnApply() {
OnDeactivate();
- if(m_pM2DF) {
+ if (m_pM2DF) {
m_pM2DF->SetDeinterlaceMethod(m_ditype);
m_pM2DF->SetBrightness(m_procamp[0]);
m_pM2DF->SetContrast(m_procamp[1]);
diff --git a/src/filters/transform/VSFilter/AvgLines.cpp b/src/filters/transform/VSFilter/AvgLines.cpp index 2a0b89311..a8bc535aa 100644 --- a/src/filters/transform/VSFilter/AvgLines.cpp +++ b/src/filters/transform/VSFilter/AvgLines.cpp @@ -20,18 +20,18 @@ 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)) {
+ if ((g_cpuid.m_flags & CCpuID::sse2) && !((DWORD)tmp&0xf) && !((DWORD)pitch&0xf)) {
__asm {
mov esi, tmp
mov ebx, pitch
@@ -51,10 +51,10 @@ void AvgLines8(BYTE* dst, DWORD h, DWORD pitch) 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) {
+ } else if (g_cpuid.m_flags & CCpuID::mmx) {
__asm {
mov esi, tmp
mov ebx, pitch
@@ -94,19 +94,19 @@ void AvgLines8(BYTE* dst, DWORD h, DWORD pitch) 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
#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);
}
@@ -118,7 +118,7 @@ void AvgLines8(BYTE* dst, DWORD h, DWORD pitch) void AvgLines555(BYTE* dst, DWORD h, DWORD pitch)
{
- if(h <= 1) {
+ if (h <= 1) {
return;
}
@@ -128,7 +128,7 @@ 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
@@ -185,7 +185,7 @@ void AvgLines555(BYTE* dst, DWORD h, DWORD pitch) }
#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)|
@@ -193,7 +193,7 @@ void AvgLines555(BYTE* dst, DWORD h, DWORD pitch) }
}
- if(!(h&1) && h >= 2) {
+ if (!(h&1) && h >= 2) {
dst += (h-2)*pitch;
memcpy(dst + pitch, dst, pitch);
}
@@ -205,7 +205,7 @@ void AvgLines555(BYTE* dst, DWORD h, DWORD pitch) void AvgLines565(BYTE* dst, DWORD h, DWORD pitch)
{
- if(h <= 1) {
+ if (h <= 1) {
return;
}
@@ -215,7 +215,7 @@ 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
@@ -271,7 +271,7 @@ void AvgLines565(BYTE* dst, DWORD h, DWORD pitch) 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)|
@@ -279,7 +279,7 @@ void AvgLines565(BYTE* dst, DWORD h, DWORD pitch) }
#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)|
@@ -287,7 +287,7 @@ void AvgLines565(BYTE* dst, DWORD h, DWORD pitch) }
}
- 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 575b2103d..cf6b66f8a 100644 --- a/src/filters/transform/VSFilter/Copy.cpp +++ b/src/filters/transform/VSFilter/Copy.cpp @@ -33,60 +33,60 @@ 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) {
+ for (; d < dstend; sub+=4, d++) {
+ if (sub[3] < 0xff) {
*d = *((DWORD*)sub)&0xffffff;
}
}
@@ -99,7 +99,7 @@ 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) {
+ if (fScale2x) {
wIn <<= 1, hIn <<= 1;
}
@@ -118,27 +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) {
+ 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);
@@ -147,7 +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);
}
}
@@ -157,7 +157,7 @@ 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;
}
@@ -170,7 +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),
@@ -187,14 +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;
@@ -203,7 +203,7 @@ void CDirectVobSubFilter::PrintMessages(BYTE* pOut) }
}
- if(msg.IsEmpty()) {
+ if (msg.IsEmpty()) {
return;
}
@@ -229,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;
}
@@ -244,7 +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 a9685ef4a..8168b6d83 100644 --- a/src/filters/transform/VSFilter/DirectVobSub.cpp +++ b/src/filters/transform/VSFilter/DirectVobSub.cpp @@ -54,8 +54,8 @@ 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)) {
+ 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));
@@ -77,7 +77,7 @@ STDMETHODIMP CDirectVobSub::get_FileName(WCHAR* fn) {
CAutoLock cAutoLock(&m_propsLock);
- if(!fn) {
+ if (!fn) {
return E_POINTER;
}
@@ -94,12 +94,12 @@ STDMETHODIMP CDirectVobSub::put_FileName(WCHAR* fn) {
CAutoLock cAutoLock(&m_propsLock);
- if(!fn) {
+ if (!fn) {
return E_POINTER;
}
CString tmp = fn;
- if(!m_FileName.Left(m_FileName.ReverseFind('.')+1).CompareNoCase(tmp.Left(tmp.ReverseFind('.')+1))) {
+ if (!m_FileName.Left(m_FileName.ReverseFind('.')+1).CompareNoCase(tmp.Left(tmp.ReverseFind('.')+1))) {
return S_FALSE;
}
@@ -139,12 +139,12 @@ STDMETHODIMP CDirectVobSub::put_SelectedLanguage(int iSelected) {
CAutoLock cAutoLock(&m_propsLock);
- if(m_iSelectedLanguage == iSelected) {
+ if (m_iSelectedLanguage == iSelected) {
return S_FALSE;
}
int nCount;
- if(FAILED(get_LanguageCount(&nCount))
+ if (FAILED(get_LanguageCount(&nCount))
|| iSelected < 0
|| iSelected >= nCount) {
return E_FAIL;
@@ -166,7 +166,7 @@ STDMETHODIMP CDirectVobSub::put_HideSubtitles(bool fHideSubtitles) {
CAutoLock cAutoLock(&m_propsLock);
- if(m_fHideSubtitles == fHideSubtitles) {
+ if (m_fHideSubtitles == fHideSubtitles) {
return S_FALSE;
}
@@ -188,7 +188,7 @@ STDMETHODIMP CDirectVobSub::put_PreBuffering(bool fDoPreBuffering) {
CAutoLock cAutoLock(&m_propsLock);
- if((m_uSubPictToBuffer > 0) == fDoPreBuffering) {
+ if ((m_uSubPictToBuffer > 0) == fDoPreBuffering) {
return S_FALSE;
}
@@ -208,7 +208,7 @@ STDMETHODIMP CDirectVobSub::put_SubPictToBuffer(unsigned int uSubPictToBuffer) {
CAutoLock cAutoLock(&m_propsLock);
- if(m_uSubPictToBuffer == uSubPictToBuffer) {
+ if (m_uSubPictToBuffer == uSubPictToBuffer) {
return S_FALSE;
}
@@ -228,7 +228,7 @@ STDMETHODIMP CDirectVobSub::put_AnimWhenBuffering(bool fAnimWhenBuffering) {
CAutoLock cAutoLock(&m_propsLock);
- if(m_fAnimWhenBuffering == fAnimWhenBuffering) {
+ if (m_fAnimWhenBuffering == fAnimWhenBuffering) {
return S_FALSE;
}
@@ -241,13 +241,13 @@ STDMETHODIMP CDirectVobSub::get_Placement(bool* fOverridePlacement, int* xperc, {
CAutoLock cAutoLock(&m_propsLock);
- if(fOverridePlacement) {
+ if (fOverridePlacement) {
*fOverridePlacement = m_fOverridePlacement;
}
- if(xperc) {
+ if (xperc) {
*xperc = m_PlacementXperc;
}
- if(yperc) {
+ if (yperc) {
*yperc = m_PlacementYperc;
}
@@ -258,7 +258,7 @@ STDMETHODIMP CDirectVobSub::put_Placement(bool fOverridePlacement, int xperc, in {
CAutoLock cAutoLock(&m_propsLock);
- if(m_fOverridePlacement == fOverridePlacement && m_PlacementXperc == xperc && m_PlacementYperc == yperc) {
+ if (m_fOverridePlacement == fOverridePlacement && m_PlacementXperc == xperc && m_PlacementYperc == yperc) {
return S_FALSE;
}
@@ -273,13 +273,13 @@ STDMETHODIMP CDirectVobSub::get_VobSubSettings(bool* fBuffer, bool* fOnlyShowFor {
CAutoLock cAutoLock(&m_propsLock);
- if(fBuffer) {
+ if (fBuffer) {
*fBuffer = m_fBufferVobSub;
}
- if(fOnlyShowForcedSubs) {
+ if (fOnlyShowForcedSubs) {
*fOnlyShowForcedSubs = m_fOnlyShowForcedVobSubs;
}
- if(fPolygonize) {
+ if (fPolygonize) {
*fPolygonize = m_fPolygonize;
}
@@ -290,7 +290,7 @@ STDMETHODIMP CDirectVobSub::put_VobSubSettings(bool fBuffer, bool fOnlyShowForce {
CAutoLock cAutoLock(&m_propsLock);
- if(m_fBufferVobSub == fBuffer && m_fOnlyShowForcedVobSubs == fOnlyShowForcedSubs && m_fPolygonize == fPolygonize) {
+ if (m_fBufferVobSub == fBuffer && m_fOnlyShowForcedVobSubs == fOnlyShowForcedSubs && m_fPolygonize == fPolygonize) {
return S_FALSE;
}
@@ -305,10 +305,10 @@ 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 {
return E_INVALIDARG;
@@ -322,16 +322,16 @@ STDMETHODIMP CDirectVobSub::get_TextSettings(void* lf, int lflen, COLORREF* colo ((LOGFONT*)lf)->lfUnderline = m_defStyle.fUnderline;
}
- if(color) {
+ if (color) {
*color = m_defStyle.colors[0];
}
- if(fShadow) {
+ if (fShadow) {
*fShadow = (m_defStyle.shadowDepthX!=0) || (m_defStyle.shadowDepthY!=0);
}
- if(fOutline) {
+ if (fOutline) {
*fOutline = (m_defStyle.outlineWidthX+m_defStyle.outlineWidthY)>0;
}
- if(fAdvancedRenderer) {
+ if (fAdvancedRenderer) {
*fAdvancedRenderer = m_fAdvancedRenderer;
}
@@ -342,10 +342,10 @@ 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 {
return E_INVALIDARG;
@@ -358,7 +358,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);
@@ -378,10 +378,10 @@ STDMETHODIMP CDirectVobSub::get_Flip(bool* fPicture, bool* fSubtitles) {
CAutoLock cAutoLock(&m_propsLock);
- if(fPicture) {
+ if (fPicture) {
*fPicture = m_fFlipPicture;
}
- if(fSubtitles) {
+ if (fSubtitles) {
*fSubtitles = m_fFlipSubtitles;
}
@@ -392,7 +392,7 @@ STDMETHODIMP CDirectVobSub::put_Flip(bool fPicture, bool fSubtitles) {
CAutoLock cAutoLock(&m_propsLock);
- if(m_fFlipPicture == fPicture && m_fFlipSubtitles == fSubtitles) {
+ if (m_fFlipPicture == fPicture && m_fFlipSubtitles == fSubtitles) {
return S_FALSE;
}
@@ -413,7 +413,7 @@ STDMETHODIMP CDirectVobSub::put_OSD(bool fOSD) {
CAutoLock cAutoLock(&m_propsLock);
- if(m_fOSD == fOSD) {
+ if (m_fOSD == fOSD) {
return S_FALSE;
}
@@ -433,7 +433,7 @@ STDMETHODIMP CDirectVobSub::put_SaveFullPath(bool fSaveFullPath) {
CAutoLock cAutoLock(&m_propsLock);
- if(m_fSaveFullPath == fSaveFullPath) {
+ if (m_fSaveFullPath == fSaveFullPath) {
return S_FALSE;
}
@@ -446,13 +446,13 @@ STDMETHODIMP CDirectVobSub::get_SubtitleTiming(int* delay, int* speedmul, int* s {
CAutoLock cAutoLock(&m_propsLock);
- if(delay) {
+ if (delay) {
*delay = m_SubtitleDelay;
}
- if(speedmul) {
+ if (speedmul) {
*speedmul = m_SubtitleSpeedMul;
}
- if(speeddiv) {
+ if (speeddiv) {
*speeddiv = m_SubtitleSpeedDiv;
}
@@ -463,13 +463,13 @@ STDMETHODIMP CDirectVobSub::put_SubtitleTiming(int delay, int speedmul, int spee {
CAutoLock cAutoLock(&m_propsLock);
- if(m_SubtitleDelay == delay && m_SubtitleSpeedMul == speedmul && m_SubtitleSpeedDiv == speeddiv) {
+ if (m_SubtitleDelay == delay && m_SubtitleSpeedMul == speedmul && m_SubtitleSpeedDiv == speeddiv) {
return S_FALSE;
}
m_SubtitleDelay = delay;
m_SubtitleSpeedMul = speedmul;
- if(speeddiv > 0) {
+ if (speeddiv > 0) {
m_SubtitleSpeedDiv = speeddiv;
}
@@ -480,10 +480,10 @@ STDMETHODIMP CDirectVobSub::get_MediaFPS(bool* fEnabled, double* fps) {
CAutoLock cAutoLock(&m_propsLock);
- if(fEnabled) {
+ if (fEnabled) {
*fEnabled = m_fMediaFPSEnabled;
}
- if(fps) {
+ if (fps) {
*fps = m_MediaFPS;
}
@@ -494,12 +494,12 @@ STDMETHODIMP CDirectVobSub::put_MediaFPS(bool fEnabled, double fps) {
CAutoLock cAutoLock(&m_propsLock);
- if(m_fMediaFPSEnabled == fEnabled && m_MediaFPS == fps) {
+ if (m_fMediaFPSEnabled == fEnabled && m_MediaFPS == fps) {
return S_FALSE;
}
m_fMediaFPSEnabled = fEnabled;
- if(fps > 0) {
+ if (fps > 0) {
m_MediaFPS = fps;
}
@@ -510,7 +510,7 @@ STDMETHODIMP CDirectVobSub::get_ZoomRect(NORMALIZEDRECT* rect) {
CAutoLock cAutoLock(&m_propsLock);
- if(!rect) {
+ if (!rect) {
return E_POINTER;
}
@@ -523,11 +523,11 @@ STDMETHODIMP CDirectVobSub::put_ZoomRect(NORMALIZEDRECT* rect) {
CAutoLock cAutoLock(&m_propsLock);
- if(!rect) {
+ if (!rect) {
return E_POINTER;
}
- if(!memcmp(&m_ZoomRect, rect, sizeof(m_ZoomRect))) {
+ if (!memcmp(&m_ZoomRect, rect, sizeof(m_ZoomRect))) {
return S_FALSE;
}
@@ -581,7 +581,7 @@ STDMETHODIMP CDirectVobSub::IsSubtitleReloaderLocked(bool* fLocked) {
CAutoLock cAutoLock(&m_propsLock);
- if(!fLocked) {
+ if (!fLocked) {
return E_POINTER;
}
@@ -597,14 +597,14 @@ STDMETHODIMP CDirectVobSub::LockSubtitleReloader(bool fLock) {
CAutoLock cAutoLock(&m_propsLock);
- if(fLock) {
+ if (fLock) {
m_nReloaderDisableCount++;
} else {
m_nReloaderDisableCount--;
}
ASSERT(m_nReloaderDisableCount >= 0);
- if(m_nReloaderDisableCount < 0) {
+ if (m_nReloaderDisableCount < 0) {
m_nReloaderDisableCount = 0;
}
@@ -617,7 +617,7 @@ STDMETHODIMP CDirectVobSub::get_SubtitleReloader(bool* fDisabled) CAutoLock cAutoLock(&m_propsLock);
- if(fDisabled) {
+ if (fDisabled) {
*fDisabled = !!theApp.GetProfileInt(ResStr(IDS_R_GENERAL), ResStr(IDS_RG_DISABLERELOADER), 0);
}
@@ -632,7 +632,7 @@ STDMETHODIMP CDirectVobSub::put_SubtitleReloader(bool fDisable) bool b;
get_SubtitleReloader(&b);
- if(b == fDisable) {
+ if (b == fDisable) {
return S_FALSE;
}
@@ -647,19 +647,19 @@ STDMETHODIMP CDirectVobSub::get_ExtendPicture(int* horizontal, int* vertical, in CAutoLock cAutoLock(&m_propsLock);
- if(horizontal) {
+ if (horizontal) {
*horizontal = theApp.GetProfileInt(ResStr(IDS_R_GENERAL), ResStr(IDS_RG_MOD32FIX), 0) & 1;
}
- if(vertical) {
+ if (vertical) {
*vertical = theApp.GetProfileInt(ResStr(IDS_R_GENERAL), ResStr(IDS_RG_EXTPIC), 0);
}
- if(resx2) {
+ if (resx2) {
*resx2 = theApp.GetProfileInt(ResStr(IDS_R_GENERAL), ResStr(IDS_RG_RESX2), 2) & 3;
}
- if(resx2minw) {
+ if (resx2minw) {
*resx2minw = theApp.GetProfileInt(ResStr(IDS_R_GENERAL), ResStr(IDS_RG_RESX2MINW), 384);
}
- if(resx2minh) {
+ if (resx2minh) {
*resx2minh = theApp.GetProfileInt(ResStr(IDS_R_GENERAL), ResStr(IDS_RG_RESX2MINH), 288);
}
@@ -674,7 +674,7 @@ 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) {
+ if (i[0] == horizontal && i[1] == vertical && i[2] == resx2 && i[3] == resx2minw && i[4] == resx2minh) {
return S_FALSE;
}
@@ -693,16 +693,16 @@ STDMETHODIMP CDirectVobSub::get_LoadSettings(int* level, bool* fExternalLoad, bo CAutoLock cAutoLock(&m_propsLock);
- if(level) {
+ if (level) {
*level = theApp.GetProfileInt(ResStr(IDS_R_GENERAL), ResStr(IDS_RG_LOADLEVEL), 0) & 3;
}
- if(fExternalLoad) {
+ if (fExternalLoad) {
*fExternalLoad = !!theApp.GetProfileInt(ResStr(IDS_R_GENERAL), ResStr(IDS_RG_EXTERNALLOAD), 1);
}
- if(fWebLoad) {
+ if (fWebLoad) {
*fWebLoad = !!theApp.GetProfileInt(ResStr(IDS_R_GENERAL), ResStr(IDS_RG_WEBLOAD), 0);
}
- if(fEmbeddedLoad) {
+ if (fEmbeddedLoad) {
*fEmbeddedLoad = !!theApp.GetProfileInt(ResStr(IDS_R_GENERAL), ResStr(IDS_RG_EMBEDDEDLOAD), 1);
}
@@ -718,7 +718,7 @@ 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) {
+ if (i == level && b[0] == fExternalLoad && b[1] == fWebLoad && b[2] == fEmbeddedLoad) {
return S_FALSE;
}
@@ -766,7 +766,7 @@ 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;
}
diff --git a/src/filters/transform/VSFilter/DirectVobSubFilter.cpp b/src/filters/transform/VSFilter/DirectVobSubFilter.cpp index f6573aaec..162224810 100644 --- a/src/filters/transform/VSFilter/DirectVobSubFilter.cpp +++ b/src/filters/transform/VSFilter/DirectVobSubFilter.cpp @@ -100,25 +100,25 @@ CDirectVobSubFilter::CDirectVobSubFilter(LPUNKNOWN punk, HRESULT* phr, const GUI CDirectVobSubFilter::~CDirectVobSubFilter()
{
CAutoLock cAutoLock(&m_csQueueLock);
- if(m_pSubPicQueue) {
+ if (m_pSubPicQueue) {
m_pSubPicQueue->Invalidate();
}
m_pSubPicQueue = NULL;
- if(m_hfont) {
+ if (m_hfont) {
DeleteObject(m_hfont);
m_hfont = 0;
}
- if(m_hbm) {
+ if (m_hbm) {
DeleteObject(m_hbm);
m_hbm = 0;
}
- if(m_hdc) {
+ if (m_hdc) {
DeleteObject(m_hdc);
m_hdc = 0;
}
- for(size_t i = 0; i < m_pTextInput.GetCount(); i++) {
+ for (size_t i = 0; i < m_pTextInput.GetCount(); i++) {
delete m_pTextInput[i];
}
@@ -149,15 +149,15 @@ void CDirectVobSubFilter::GetOutputSize(int& w, int& h, int& arx, int& ary, int& h = s.cy;
vsfilter = 1; // enable workaround, see BaseVideoFilter.cpp
- if(w != os.cx) {
- while(arx < 100) {
+ if (w != os.cx) {
+ while (arx < 100) {
arx *= 10, ary *= 10;
}
arx = arx * w / os.cx;
}
- if(h != os.cy) {
- while(ary < 100) {
+ if (h != os.cy) {
+ while (ary < 100) {
arx *= 10, ary *= 10;
}
ary = ary * h / os.cy;
@@ -170,15 +170,15 @@ 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;
}
}
@@ -191,7 +191,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);
}
@@ -200,7 +200,7 @@ HRESULT CDirectVobSubFilter::Transform(IMediaSample* pIn) //
BYTE* pDataIn = NULL;
- if(FAILED(pIn->GetPointer(&pDataIn)) || !pDataIn) {
+ if (FAILED(pIn->GetPointer(&pDataIn)) || !pDataIn) {
return S_FALSE;
}
@@ -216,11 +216,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;
@@ -229,10 +229,10 @@ 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;
}
}
@@ -243,7 +243,7 @@ HRESULT CDirectVobSubFilter::Transform(IMediaSample* pIn) CComPtr<IMediaSample> pOut;
BYTE* pDataOut = NULL;
- if(FAILED(hr = GetDeliveryBuffer(spd.w, spd.h, &pOut))
+ if (FAILED(hr = GetDeliveryBuffer(spd.w, spd.h, &pOut))
|| FAILED(hr = pOut->GetPointer(&pDataOut))) {
return hr;
}
@@ -264,15 +264,15 @@ HRESULT CDirectVobSubFilter::Transform(IMediaSample* pIn) bool fOutputFlipped = bihOut.biHeight >= 0 && bihOut.biCompression <= 3;
bool fFlip = fInputFlipped != fOutputFlipped;
- if(m_fFlipPicture) {
+ if (m_fFlipPicture) {
fFlip = !fFlip;
}
- if(m_fMSMpeg4Fix) {
+ if (m_fMSMpeg4Fix) {
fFlip = !fFlip;
}
bool fFlipSub = fOutputFlipped;
- if(m_fFlipSubtitles) {
+ if (m_fFlipSubtitles) {
fFlipSub = !fFlipSub;
}
@@ -281,13 +281,13 @@ HRESULT CDirectVobSubFilter::Transform(IMediaSample* pIn) {
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;
}
@@ -307,13 +307,13 @@ 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 && (size_t)n < m_pTextInput.GetCount()) {
+ if (n >= 0 && (size_t)n < m_pTextInput.GetCount()) {
return m_pTextInput[n];
}
@@ -329,17 +329,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);
}
@@ -347,15 +347,15 @@ HRESULT CDirectVobSubFilter::JoinFilterGraph(IFilterGraph* pGraph, LPCWSTR pName }
/*removeme*/
- if(!g_RegOK) {
+ if (!g_RegOK) {
DllRegisterServer();
g_RegOK = true;
}
} else {
- if(m_hSystrayThread) {
+ 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);
}
@@ -372,13 +372,13 @@ 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();
}
@@ -390,11 +390,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)) {
+ if (FAILED(hr)) {
return hr;
}
- if(dir == PINDIR_INPUT) {
+ if (dir == PINDIR_INPUT) {
CAutoLock cAutoLock(&m_csReceive);
REFERENCE_TIME atpf =
@@ -409,7 +409,7 @@ HRESULT CDirectVobSubFilter::SetMediaType(PIN_DIRECTION dir, const CMediaType* p }
InitSubPicQueue();
- } else if(dir == PINDIR_OUTPUT) {
+ } else if (dir == PINDIR_OUTPUT) {
}
@@ -418,8 +418,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);
@@ -427,19 +427,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))
+ 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) {
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,12 +456,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;
@@ -522,19 +522,19 @@ void CDirectVobSubFilter::InitSubPicQueue() ExtractBIH(&m_pInput->CurrentMediaType(), &bihIn);
m_spd.type = -1;
- if(subtype == MEDIASUBTYPE_YV12) {
+ if (subtype == MEDIASUBTYPE_YV12) {
m_spd.type = MSP_YV12;
- } else if(subtype == MEDIASUBTYPE_I420 || subtype == MEDIASUBTYPE_IYUV) {
+ } else if (subtype == MEDIASUBTYPE_I420 || subtype == MEDIASUBTYPE_IYUV) {
m_spd.type = MSP_IYUV;
- } else if(subtype == MEDIASUBTYPE_YUY2) {
+ } else if (subtype == MEDIASUBTYPE_YUY2) {
m_spd.type = MSP_YUY2;
- } else if(subtype == MEDIASUBTYPE_RGB32) {
+ } else if (subtype == MEDIASUBTYPE_RGB32) {
m_spd.type = MSP_RGB32;
- } else if(subtype == MEDIASUBTYPE_RGB24) {
+ } else if (subtype == MEDIASUBTYPE_RGB24) {
m_spd.type = MSP_RGB24;
- } else if(subtype == MEDIASUBTYPE_RGB565) {
+ } else if (subtype == MEDIASUBTYPE_RGB565) {
m_spd.type = MSP_RGB16;
- } else if(subtype == MEDIASUBTYPE_RGB555) {
+ } else if (subtype == MEDIASUBTYPE_RGB555) {
m_spd.type = MSP_RGB15;
}
m_spd.w = m_w;
@@ -546,7 +546,7 @@ 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)) {
+ if (AdjustFrameSize(window)) {
video += video;
}
ASSERT(window == CSize(m_w, m_h));
@@ -560,17 +560,17 @@ void CDirectVobSubFilter::InitSubPicQueue() ? (ISubPicQueue*)new CSubPicQueue(m_uSubPictToBuffer, !m_fAnimWhenBuffering, pSubPicAllocator, &hr)
: (ISubPicQueue*)new CSubPicQueueNoThread(pSubPicAllocator, &hr);
- if(FAILED(hr)) {
+ if (FAILED(hr)) {
m_pSubPicQueue = NULL;
}
UpdateSubtitle(false);
- if(m_hbm) {
+ if (m_hbm) {
DeleteObject(m_hbm);
m_hbm = NULL;
}
- if(m_hdc) {
+ if (m_hdc) {
DeleteDC(m_hdc);
m_hdc = NULL;
}
@@ -594,40 +594,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) {
+ switch (vertical&0x7f) {
case 1:
h = s.cx * 9 / 16;
- if(s.cy < h || !!(vertical&0x80)) {
+ 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)) {
+ if (s.cy < h || !!(vertical&0x80)) {
s.cy = (h + 3) & ~3;
}
break;
case 3:
h = 480;
- if(s.cy < h || !!(vertical&0x80)) {
+ if (s.cy < h || !!(vertical&0x80)) {
s.cy = (h + 3) & ~3;
}
break;
case 4:
h = 576;
- if(s.cy < h || !!(vertical&0x80)) {
+ if (s.cy < h || !!(vertical&0x80)) {
s.cy = (h + 3) & ~3;
}
break;
}
- if(horizontal == 1) {
+ if (horizontal == 1) {
s.cx = (s.cx + 31) & ~31;
s.cy = (s.cy + 1) & ~1;
}
@@ -637,14 +637,14 @@ bool CDirectVobSubFilter::AdjustFrameSize(CSize& s) STDMETHODIMP CDirectVobSubFilter::Count(DWORD* pcStreams)
{
- if(!pcStreams) {
+ if (!pcStreams) {
return E_POINTER;
}
*pcStreams = 0;
int nLangs = 0;
- if(SUCCEEDED(get_LanguageCount(&nLangs))) {
+ if (SUCCEEDED(get_LanguageCount(&nLangs))) {
(*pcStreams) += nLangs;
}
@@ -664,25 +664,25 @@ int CDirectVobSubFilter::FindPreferedLanguage(bool fHideToo) int nLangs;
get_LanguageCount(&nLangs);
- if(nLangs <= 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)) {
+ if (!l.CompareNoCase(lang)) {
return(ret);
}
}
@@ -699,28 +699,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)) {
+ 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;
@@ -732,20 +732,20 @@ void CDirectVobSubFilter::UpdatePreferedLanguages(CString l) CString hidesubs;
hidesubs.LoadString(IDS_M_HIDESUBTITLES);
- for(k = 1; k < j; k++) {
- if(!langs[k].CompareNoCase(hidesubs)) {
+ 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);
@@ -755,35 +755,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) {
+ 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);
}
@@ -797,20 +797,20 @@ 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) {
+ if (ppmt) {
*ppmt = CreateMediaType(&m_pInput->CurrentMediaType());
}
- if(pdwFlags) {
+ if (pdwFlags) {
*pdwFlags = 0;
- if(i == -1 && !m_fHideSubtitles
+ if (i == -1 && !m_fHideSubtitles
|| i >= 0 && i < nLangs && i == m_iSelectedLanguage
|| i == nLangs && m_fHideSubtitles
|| i == nLangs+1 && !m_fFlipPicture
@@ -819,50 +819,50 @@ STDMETHODIMP CDirectVobSubFilter::Info(long lIndex, AM_MEDIA_TYPE** ppmt, DWORD* }
}
- if(plcid) {
+ if (plcid) {
*plcid = 0;
}
- if(pdwGroup) {
+ if (pdwGroup) {
*pdwGroup = 0x648E51;
}
- if(ppszName) {
+ if (ppszName) {
*ppszName = NULL;
CStringW str;
- if(i == -1) {
+ if (i == -1) {
str = ResStr(IDS_M_SHOWSUBTITLES);
- } else if(i >= 0 && i < nLangs) {
+ } else if (i >= 0 && i < nLangs) {
get_LanguageName(i, ppszName);
- } else if(i == nLangs) {
+ } else if (i == nLangs) {
str = ResStr(IDS_M_HIDESUBTITLES);
- } else if(i == nLangs+1) {
+ } else if (i == nLangs+1) {
str = ResStr(IDS_M_ORIGINALPICTURE);
- if(pdwGroup) {
+ if (pdwGroup) {
(*pdwGroup)++;
}
- } else if(i == nLangs+2) {
+ } else if (i == nLangs+2) {
str = ResStr(IDS_M_FLIPPEDPICTURE);
- if(pdwGroup) {
+ if (pdwGroup) {
(*pdwGroup)++;
}
}
- if(!str.IsEmpty()) {
+ if (!str.IsEmpty()) {
*ppszName = (WCHAR*)CoTaskMemAlloc((str.GetLength()+1)*sizeof(WCHAR));
- if(*ppszName == NULL) {
+ if (*ppszName == NULL) {
return S_FALSE;
}
wcscpy(*ppszName, str);
}
}
- if(ppObject) {
+ if (ppObject) {
*ppObject = NULL;
}
- if(ppUnk) {
+ if (ppUnk) {
*ppUnk = NULL;
}
@@ -871,7 +871,7 @@ STDMETHODIMP CDirectVobSubFilter::Info(long lIndex, AM_MEDIA_TYPE** ppmt, DWORD* STDMETHODIMP CDirectVobSubFilter::GetClassID(CLSID* pClsid)
{
- if(pClsid == NULL) {
+ if (pClsid == NULL) {
return E_POINTER;
}
*pClsid = m_clsid;
@@ -885,7 +885,7 @@ STDMETHODIMP CDirectVobSubFilter::GetPages(CAUUID* pPages) pPages->cElems = 7;
pPages->pElems = (GUID*)CoTaskMemAlloc(sizeof(GUID)*pPages->cElems);
- if(pPages->pElems == NULL) {
+ if (pPages->pElems == NULL) {
return E_OUTOFMEMORY;
}
@@ -907,7 +907,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;
}
@@ -919,12 +919,12 @@ 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) {
+ while (pos) {
(*nLangs) += m_pSubStreams.GetNext(pos)->GetStreamCount();
}
}
@@ -936,11 +936,11 @@ STDMETHODIMP CDirectVobSubFilter::get_LanguageName(int iLanguage, WCHAR** ppName {
HRESULT hr = CDirectVobSub::get_LanguageName(iLanguage, ppName);
- if(!ppName) {
+ if (!ppName) {
return E_POINTER;
}
- if(hr == NOERROR) {
+ if (hr == NOERROR) {
CAutoLock cAutolock(&m_csQueueLock);
hr = E_INVALIDARG;
@@ -948,10 +948,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;
@@ -968,7 +968,7 @@ STDMETHODIMP CDirectVobSubFilter::put_SelectedLanguage(int iSelected) {
HRESULT hr = CDirectVobSub::put_SelectedLanguage(iSelected);
- if(hr == NOERROR) {
+ if (hr == NOERROR) {
UpdateSubtitle(false);
}
@@ -979,7 +979,7 @@ STDMETHODIMP CDirectVobSubFilter::put_HideSubtitles(bool fHideSubtitles) {
HRESULT hr = CDirectVobSub::put_HideSubtitles(fHideSubtitles);
- if(hr == NOERROR) {
+ if (hr == NOERROR) {
UpdateSubtitle(false);
}
@@ -991,7 +991,7 @@ STDMETHODIMP CDirectVobSubFilter::put_PreBuffering(bool fDoPreBuffering) {
HRESULT hr = CDirectVobSub::put_PreBuffering(fDoPreBuffering);
- if(hr == NOERROR && m_pInput && m_pInput->IsConnected()) {
+ if (hr == NOERROR && m_pInput && m_pInput->IsConnected()) {
InitSubPicQueue();
}
@@ -1002,7 +1002,7 @@ STDMETHODIMP CDirectVobSubFilter::put_SubPictToBuffer(unsigned int uSubPictToBuf {
HRESULT hr = CDirectVobSub::put_SubPictToBuffer(uSubPictToBuffer);
- if(hr == NOERROR && m_pInput && m_pInput->IsConnected()) {
+ if (hr == NOERROR && m_pInput && m_pInput->IsConnected()) {
InitSubPicQueue();
}
@@ -1013,7 +1013,7 @@ STDMETHODIMP CDirectVobSubFilter::put_AnimWhenBuffering(bool fAnimWhenBuffering) {
HRESULT hr = CDirectVobSub::put_AnimWhenBuffering(fAnimWhenBuffering);
- if(hr == NOERROR && m_pInput && m_pInput->IsConnected()) {
+ if (hr == NOERROR && m_pInput && m_pInput->IsConnected()) {
InitSubPicQueue();
}
@@ -1024,7 +1024,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);
}
@@ -1035,7 +1035,7 @@ STDMETHODIMP CDirectVobSubFilter::put_VobSubSettings(bool fBuffer, bool fOnlySho {
HRESULT hr = CDirectVobSub::put_VobSubSettings(fBuffer, fOnlyShowForcedSubs, fReserved);
- if(hr == NOERROR) {
+ if (hr == NOERROR) {
// UpdateSubtitle(false);
InvalidateSubtitle();
}
@@ -1047,7 +1047,7 @@ STDMETHODIMP CDirectVobSubFilter::put_TextSettings(void* lf, int lflen, COLORREF {
HRESULT hr = CDirectVobSub::put_TextSettings(lf, lflen, color, fShadow, fOutline, fAdvancedRenderer);
- if(hr == NOERROR) {
+ if (hr == NOERROR) {
// UpdateSubtitle(true);
InvalidateSubtitle();
}
@@ -1059,7 +1059,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();
}
@@ -1072,9 +1072,9 @@ 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) {
+ if (fps) {
*fps = m_MediaFPS;
}
}
@@ -1087,13 +1087,13 @@ 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;
}
}
@@ -1117,7 +1117,7 @@ STDMETHODIMP CDirectVobSubFilter::put_TextSettings(STSStyle* pDefStyle) {
HRESULT hr = CDirectVobSub::put_TextSettings(pDefStyle);
- if(hr == NOERROR) {
+ if (hr == NOERROR) {
UpdateSubtitle(true);
}
@@ -1128,7 +1128,7 @@ STDMETHODIMP CDirectVobSubFilter::put_AspectRatioSettings(CSimpleTextSubtitle::E {
HRESULT hr = CDirectVobSub::put_AspectRatioSettings(ePARCompensationType);
- if(hr == NOERROR) {
+ if (hr == NOERROR) {
UpdateSubtitle(true);
}
@@ -1140,7 +1140,7 @@ STDMETHODIMP CDirectVobSubFilter::put_AspectRatioSettings(CSimpleTextSubtitle::E STDMETHODIMP CDirectVobSubFilter::HasConfigDialog(int iSelected)
{
int nLangs;
- if(FAILED(get_LanguageCount(&nLangs))) {
+ if (FAILED(get_LanguageCount(&nLangs))) {
return E_FAIL;
}
return E_FAIL;
@@ -1164,17 +1164,17 @@ CDirectVobSubFilter2::CDirectVobSubFilter2(LPUNKNOWN punk, HRESULT* phr, const G HRESULT CDirectVobSubFilter2::CheckConnect(PIN_DIRECTION dir, IPin* pPin)
{
CPinInfo pi;
- if(FAILED(pPin->QueryPinInfo(&pi))) {
+ if (FAILED(pPin->QueryPinInfo(&pi))) {
return E_FAIL;
}
- if(CComQIPtr<IDirectVobSub>(pi.pFilter)) {
+ if (CComQIPtr<IDirectVobSub>(pi.pFilter)) {
return E_FAIL;
}
- if(dir == PINDIR_INPUT) {
+ if (dir == PINDIR_INPUT) {
CFilterInfo fi;
- if(SUCCEEDED(pi.pFilter->QueryFilterInfo(&fi))
+ if (SUCCEEDED(pi.pFilter->QueryFilterInfo(&fi))
&& !_wcsnicmp(fi.achName, L"Overlay Mixer", 13)) {
return(E_FAIL);
}
@@ -1186,9 +1186,9 @@ HRESULT CDirectVobSubFilter2::CheckConnect(PIN_DIRECTION dir, IPin* pPin) HRESULT CDirectVobSubFilter2::JoinFilterGraph(IFilterGraph* pGraph, LPCWSTR pName)
{
- if(pGraph) {
+ if (pGraph) {
BeginEnumFilters(pGraph, pEF, pBF) {
- if(pBF != (IBaseFilter*)this && CComQIPtr<IDirectVobSub>(pBF)) {
+ if (pBF != (IBaseFilter*)this && CComQIPtr<IDirectVobSub>(pBF)) {
return E_FAIL;
}
}
@@ -1204,26 +1204,26 @@ 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()) {
+ if (!get_Forced()) {
BeginEnumFilters(pGraph, pEF, pBF) {
- if(CComQIPtr<IDirectVobSub>(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))
+ if (pInPin && SUCCEEDED(pInPin->ConnectedTo(&pPin))
|| pOutPin && SUCCEEDED(pOutPin->ConnectedTo(&pPin))) {
continue;
}
- if(pOutPin && GetFilterName(pBF) == _T("Overlay Mixer")) {
+ if (pOutPin && GetFilterName(pBF) == _T("Overlay Mixer")) {
continue;
}
@@ -1245,7 +1245,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;
}
@@ -1257,15 +1257,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);
}
@@ -1285,11 +1285,11 @@ HRESULT CDirectVobSubFilter2::CheckInputType(const CMediaType* mtIn) {
HRESULT hr = __super::CheckInputType(mtIn);
- if(FAILED(hr) || m_pInput->IsConnected()) {
+ if (FAILED(hr) || m_pInput->IsConnected()) {
return hr;
}
- if(!ShouldWeAutoload(m_pGraph)) {
+ if (!ShouldWeAutoload(m_pGraph)) {
return VFW_E_TYPE_NOT_ACCEPTED;
}
@@ -1309,8 +1309,8 @@ 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;
}
}
@@ -1319,21 +1319,21 @@ bool CDirectVobSubFilter2::ShouldWeAutoload(IFilterGraph* pGraph) bool m_fExternalLoad, m_fWebLoad, m_fEmbeddedLoad;
get_LoadSettings(&level, &m_fExternalLoad, &m_fWebLoad, &m_fEmbeddedLoad);
- if(level < 0 || level >= 2) {
+ 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))
+ 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
@@ -1351,13 +1351,13 @@ bool CDirectVobSubFilter2::ShouldWeAutoload(IFilterGraph* pGraph) || (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) {
+ if (pmt->majortype == MEDIATYPE_Text || pmt->majortype == MEDIATYPE_Subtitle) {
fRet = true;
break;
}
}
EndEnumMediaTypes(pmt)
- if(fRet) {
+ if (fRet) {
break;
}
}
@@ -1370,9 +1370,9 @@ bool CDirectVobSubFilter2::ShouldWeAutoload(IFilterGraph* pGraph) CStringW fn;
BeginEnumFilters(pGraph, pEF, pBF) {
- if(CComQIPtr<IFileSourceFilter> pFSF = 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);
@@ -1382,12 +1382,12 @@ 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) {
+ if (fTemp) {
m_fHideSubtitles = true;
}
}
@@ -1397,12 +1397,12 @@ bool CDirectVobSubFilter2::ShouldWeAutoload(IFilterGraph* pGraph) void CDirectVobSubFilter2::GetRidOfInternalScriptRenderer()
{
- while(CComPtr<IBaseFilter> pBF = FindFilter(L"{48025243-2D39-11CE-875D-00608CB78066}", m_pGraph)) {
+ 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
+ if (SUCCEEDED(pPin->QueryDirection(&dir)) && dir == PINDIR_INPUT
&& SUCCEEDED(pPin->ConnectedTo(&pPinTo))) {
m_pGraph->Disconnect(pPinTo);
m_pGraph->Disconnect(pPin);
@@ -1411,7 +1411,7 @@ void CDirectVobSubFilter2::GetRidOfInternalScriptRenderer() }
EndEnumPins
- if(FAILED(m_pGraph->RemoveFilter(pBF))) {
+ if (FAILED(m_pGraph->RemoveFilter(pBF))) {
break;
}
}
@@ -1431,11 +1431,11 @@ 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()) {
+ if (!path.IsEmpty()) {
paths.Add(path);
}
}
@@ -1443,49 +1443,49 @@ bool CDirectVobSubFilter::Open() CAtlArray<SubFile> ret;
GetSubFileNames(m_FileName, paths, ret);
- for(size_t i = 0; i < ret.GetCount(); i++) {
- if(m_frd.files.Find(ret[i].fn)) {
+ for (size_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(size_t i = 0; i < m_pTextInput.GetCount(); i++) {
- if(m_pTextInput[i]->IsConnected()) {
+ for (size_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())) {
+ if (S_FALSE == put_SelectedLanguage(FindPreferedLanguage())) {
UpdateSubtitle(false); // make sure pSubPicProvider of our queue gets updated even if the stream number hasn't changed
}
@@ -1498,7 +1498,7 @@ void CDirectVobSubFilter::UpdateSubtitle(bool fApplyDefStyle) {
CAutoLock cAutolock(&m_csQueueLock);
- if(!m_pSubPicQueue) {
+ if (!m_pSubPicQueue) {
return;
}
@@ -1506,13 +1506,13 @@ void CDirectVobSubFilter::UpdateSubtitle(bool fApplyDefStyle) 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;
@@ -1529,33 +1529,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;
@@ -1581,14 +1581,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;
}
@@ -1599,7 +1599,7 @@ void CDirectVobSubFilter::SetSubtitle(ISubStream* pSubStream, bool fApplyDefStyl m_nSubtitleId = (DWORD_PTR)pSubStream;
- if(m_pSubPicQueue) {
+ if (m_pSubPicQueue) {
m_pSubPicQueue->SetSubPicProvider(CComQIPtr<ISubPicProvider>(pSubStream));
}
}
@@ -1608,8 +1608,8 @@ void CDirectVobSubFilter::InvalidateSubtitle(REFERENCE_TIME rtInvalidate, DWORD_ {
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);
}
}
@@ -1622,17 +1622,17 @@ void CDirectVobSubFilter::AddSubStream(ISubStream* pSubStream) CAutoLock cAutoLock(&m_csQueueLock);
POSITION pos = m_pSubStreams.Find(pSubStream);
- if(!pos) {
+ if (!pos) {
m_pSubStreams.AddTail(pSubStream);
}
int len = m_pTextInput.GetCount();
- for(size_t i = 0; i < m_pTextInput.GetCount(); i++)
- if(m_pTextInput[i]->IsConnected()) {
+ for (size_t i = 0; i < m_pTextInput.GetCount(); i++)
+ 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));
}
@@ -1643,26 +1643,26 @@ void CDirectVobSubFilter::RemoveSubStream(ISubStream* pSubStream) CAutoLock cAutoLock(&m_csQueueLock);
POSITION pos = m_pSubStreams.Find(pSubStream);
- if(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) {
+ if (!pMES) {
return;
}
CComBSTR bstr1("Text"), bstr2(" ");
str.Trim();
- if(!str.IsEmpty()) {
+ if (!str.IsEmpty()) {
bstr2 = CStringA(str);
}
@@ -1675,7 +1675,7 @@ void CDirectVobSubFilter::SetupFRD(CStringArray& paths, CAtlArray<HANDLE>& handl {
CAutoLock cAutolock(&m_csSubLock);
- for(size_t i = 2; i < handles.GetCount(); i++) {
+ for (size_t i = 2; i < handles.GetCount(); i++) {
FindCloseChangeNotification(handles[i]);
}
@@ -1688,11 +1688,11 @@ 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;
}
@@ -1701,17 +1701,17 @@ void CDirectVobSubFilter::SetupFRD(CStringArray& paths, CAtlArray<HANDLE>& handl bool fFound = false;
- for(ptrdiff_t j = 0; !fFound && j < paths.GetCount(); j++) {
- if(paths[j] == fn) {
+ 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) {
+ if (h != INVALID_HANDLE_VALUE) {
handles.Add(h);
}
}
@@ -1727,35 +1727,35 @@ 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) {
+ 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;
@@ -1767,15 +1767,15 @@ DWORD CDirectVobSubFilter::ThreadProc() }
}
- if(j > 0) {
+ if (j > 0) {
SetupFRD(paths, handles);
} 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)
+ if (CFileGetStatus(m_frd.files.GetNext(pos), status)
&& m_frd.mtime[i] != status.m_mtime) {
Open();
SetupFRD(paths, handles);
@@ -1788,7 +1788,7 @@ DWORD CDirectVobSubFilter::ThreadProc() }
}
- for(size_t i = 2; i < handles.GetCount(); i++) {
+ for (size_t i = 2; i < handles.GetCount(); i++) {
FindCloseChangeNotification(handles[i]);
}
diff --git a/src/filters/transform/VSFilter/DirectVobSubPropPage.cpp b/src/filters/transform/VSFilter/DirectVobSubPropPage.cpp index a273d6a00..00cec53fd 100644 --- a/src/filters/transform/VSFilter/DirectVobSubPropPage.cpp +++ b/src/filters/transform/VSFilter/DirectVobSubPropPage.cpp @@ -48,7 +48,7 @@ BOOL WINAPI MyGetDialogSize(int iResourceID, DLGPROC pDlgProc, LPARAM lParam, SI pDlgProc,
lParam);
- if(hwnd == NULL) {
+ if (hwnd == NULL) {
return FALSE;
}
@@ -67,7 +67,7 @@ STDMETHODIMP CDVSBasePPage::GetPageInfo(LPPROPPAGEINFO pPageInfo) AFX_MANAGE_STATE(AfxGetStaticModuleState());
CString str;
- if(!str.LoadString(m_TitleId)) {
+ if (!str.LoadString(m_TitleId)) {
return E_FAIL;
}
@@ -84,7 +84,7 @@ STDMETHODIMP CDVSBasePPage::GetPageInfo(LPPROPPAGEINFO pPageInfo) LPOLESTR pszTitle;
HRESULT hr = AMGetWideString(wszTitle, &pszTitle);
- if(FAILED(hr)) {
+ if (FAILED(hr)) {
NOTE("No caption memory");
return hr;
}
@@ -114,12 +114,12 @@ STDMETHODIMP CDVSBasePPage::Activate(HWND hwndParent, LPCRECT pRect, BOOL fModal return E_UNEXPECTED;
}
*/
- if(m_hwnd) {
+ if (m_hwnd) {
return E_UNEXPECTED;
}
m_hwnd = CreateDialogParam(AfxGetResourceHandle(), MAKEINTRESOURCE(m_DialogId), hwndParent, DialogProc, (LPARAM)this);
- if(m_hwnd == NULL) {
+ if (m_hwnd == NULL) {
return E_OUTOFMEMORY;
}
@@ -140,21 +140,21 @@ CDVSBasePPage::CDVSBasePPage(TCHAR* pName, LPUNKNOWN lpunk, int DialogId, int Ti INT_PTR CDVSBasePPage::OnReceiveMessage(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
{
- switch(uMsg) {
+ switch (uMsg) {
case WM_COMMAND: {
- if(m_bIsInitialized) {
+ if (m_bIsInitialized) {
m_bDirty = TRUE;
- if(m_pPageSite) {
+ if (m_pPageSite) {
m_pPageSite->OnStatusChange(PROPPAGESTATUS_DIRTY);
}
- switch(HIWORD(wParam)) {
+ switch (HIWORD(wParam)) {
case BN_CLICKED:
case CBN_SELCHANGE:
case EN_CHANGE: {
AFX_MANAGE_STATE(AfxGetStaticModuleState());
- if(!m_fDisableInstantUpdate
+ if (!m_fDisableInstantUpdate
&& !(HIWORD(wParam) == BN_CLICKED && LOWORD(wParam) == IDC_INSTANTUPDATE)
&& LOWORD(wParam) != IDC_EDIT1 && LOWORD(wParam) != IDC_ANIMWHENBUFFERING
&& !!theApp.GetProfileInt(ResStr(IDS_R_GENERAL), ResStr(IDS_RG_INSTANTUPDATE), 1)) {
@@ -178,7 +178,7 @@ INT_PTR CDVSBasePPage::OnReceiveMessage(HWND hwnd, UINT uMsg, WPARAM wParam, LPA HRESULT CDVSBasePPage::OnConnect(IUnknown* pUnknown)
{
- if(!(m_pDirectVobSub = pUnknown)) {
+ if (!(m_pDirectVobSub = pUnknown)) {
return E_NOINTERFACE;
}
@@ -195,7 +195,7 @@ HRESULT CDVSBasePPage::OnConnect(IUnknown* pUnknown) HRESULT CDVSBasePPage::OnDisconnect()
{
- if(m_pDirectVobSub == NULL) {
+ if (m_pDirectVobSub == NULL) {
return E_UNEXPECTED;
}
@@ -244,7 +244,7 @@ HRESULT CDVSBasePPage::OnApplyChanges() AFX_MANAGE_STATE(AfxGetStaticModuleState());
- if(m_bIsInitialized) {
+ if (m_bIsInitialized) {
OnDeactivate();
UpdateObjectData(true);
m_pDirectVobSub->UpdateRegistry(); // *
@@ -261,11 +261,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);
}
@@ -276,18 +276,18 @@ void CDVSBasePPage::AttachControls() void CDVSBasePPage::DetachControls()
{
- if(!m_fAttached) {
+ 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) {
+ if (pControl) {
pControl->Detach();
}
}
@@ -324,8 +324,8 @@ CDVSMainPPage::~CDVSMainPPage() void CDVSMainPPage::FreeLangs()
{
- if(m_nLangs > 0 && m_ppLangs) {
- for(ptrdiff_t i = 0; i < m_nLangs; i++) {
+ if (m_nLangs > 0 && m_ppLangs) {
+ for (ptrdiff_t i = 0; i < m_nLangs; i++) {
CoTaskMemFree(m_ppLangs[i]);
}
CoTaskMemFree(m_ppLangs);
@@ -342,11 +342,11 @@ void CDVSMainPPage::AllocLangs(int nLangs) bool CDVSMainPPage::OnMessage(UINT uMsg, WPARAM wParam, LPARAM lParam)
{
- switch(uMsg) {
+ switch (uMsg) {
case WM_COMMAND: {
- switch(HIWORD(wParam)) {
+ switch (HIWORD(wParam)) {
case BN_CLICKED: {
- if(LOWORD(wParam) == IDC_OPEN) {
+ if (LOWORD(wParam) == IDC_OPEN) {
AFX_MANAGE_STATE(AfxGetStaticModuleState());
CFileDialog fd(TRUE, NULL, NULL,
@@ -355,20 +355,20 @@ bool CDVSMainPPage::OnMessage(UINT uMsg, WPARAM wParam, LPARAM lParam) _T("All files (*.*)|*.*||"),
CDialog::FromHandle(m_Dlg), 0);
- if(fd.DoModal() == IDOK) {
+ if (fd.DoModal() == IDOK) {
m_fnedit.SetWindowText(fd.GetPathName());
}
return true;
- } else if(LOWORD(wParam) == IDC_FONT) {
+ } else if (LOWORD(wParam) == IDC_FONT) {
AFX_MANAGE_STATE(AfxGetStaticModuleState());
CStyleEditorDialog dlg(_T("Default"), &m_defStyle, CWnd::FromHandle(m_hwnd));
- if(dlg.DoModal() == IDOK) {
+ if (dlg.DoModal() == IDOK) {
m_defStyle = dlg.m_stss;
CString str = m_defStyle.fontName;
- if(str.GetLength() > 18) {
+ if (str.GetLength() > 18) {
str = str.Left(16).TrimRight() + _T("...");
}
m_font.SetWindowText(str);
@@ -388,12 +388,12 @@ 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++) {
+ for (ptrdiff_t i = 0; i < m_nLangs; i++) {
m_pDirectVobSub->get_LanguageName(i, &m_ppLangs[i]);
}
m_pDirectVobSub->get_SelectedLanguage(&m_iSelectedLanguage);
@@ -409,7 +409,7 @@ void CDVSMainPPage::UpdateObjectData(bool fSave) int nLangs;
m_pDirectVobSub->get_LanguageCount(&nLangs);
AllocLangs(nLangs);
- for(ptrdiff_t i = 0; i < m_nLangs; i++) {
+ for (ptrdiff_t i = 0; i < m_nLangs; i++) {
m_pDirectVobSub->get_LanguageName(i, &m_ppLangs[i]);
}
m_pDirectVobSub->get_SelectedLanguage(&m_iSelectedLanguage);
@@ -422,7 +422,7 @@ void CDVSMainPPage::UpdateObjectData(bool fSave) void CDVSMainPPage::UpdateControlData(bool fSave)
{
- if(fSave) {
+ if (fSave) {
CString fn;
m_fnedit.GetWindowText(fn);
#ifdef UNICODE
@@ -453,7 +453,7 @@ 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++) {
+ for (ptrdiff_t i = 0; i < m_nLangs; i++) {
m_langs.AddString(CString(m_ppLangs[i]));
}
m_langs.SetCurSel(m_iSelectedLanguage);
@@ -503,17 +503,17 @@ CDVSGeneralPPage::CDVSGeneralPPage(LPUNKNOWN pUnk, HRESULT* phr) : bool CDVSGeneralPPage::OnMessage(UINT uMsg, WPARAM wParam, LPARAM lParam)
{
- switch(uMsg) {
+ switch (uMsg) {
case WM_COMMAND: {
- switch(HIWORD(wParam)) {
+ switch (HIWORD(wParam)) {
case CBN_SELCHANGE: {
AFX_MANAGE_STATE(AfxGetStaticModuleState());
- if(LOWORD(wParam) == IDC_RESX2COMBO) {
+ 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) {
+ } 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);
@@ -531,7 +531,7 @@ 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 {
@@ -542,17 +542,17 @@ void CDVSGeneralPPage::UpdateObjectData(bool fSave) void CDVSGeneralPPage::UpdateControlData(bool fSave)
{
- if(fSave) {
- if(m_verext.GetCurSel() >= 0) {
+ 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) {
+ 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) {
+ if (m_load.GetCurSel() >= 0) {
m_LoadLevel = m_load.GetItemData(m_load.GetCurSel());
}
m_fExternalLoad = !!m_extload.GetCheck();
@@ -625,11 +625,11 @@ CDVSMiscPPage::CDVSMiscPPage(LPUNKNOWN pUnk, HRESULT* phr) : bool CDVSMiscPPage::OnMessage(UINT uMsg, WPARAM wParam, LPARAM lParam)
{
- switch(uMsg) {
+ switch (uMsg) {
case WM_COMMAND: {
- switch(HIWORD(wParam)) {
+ switch (HIWORD(wParam)) {
case BN_CLICKED: {
- if(LOWORD(wParam) == IDC_INSTANTUPDATE) {
+ if (LOWORD(wParam) == IDC_INSTANTUPDATE) {
AFX_MANAGE_STATE(AfxGetStaticModuleState());
theApp.WriteProfileInt(ResStr(IDS_R_GENERAL), ResStr(IDS_RG_INSTANTUPDATE), !!m_instupd.GetCheck());
return true;
@@ -646,7 +646,7 @@ 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);
@@ -667,7 +667,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();
@@ -704,11 +704,11 @@ CDVSTimingPPage::CDVSTimingPPage(LPUNKNOWN pUnk, HRESULT* phr) : bool CDVSTimingPPage::OnMessage(UINT uMsg, WPARAM wParam, LPARAM lParam)
{
- switch(uMsg) {
+ switch (uMsg) {
case WM_COMMAND: {
- switch(HIWORD(wParam)) {
+ switch (HIWORD(wParam)) {
case BN_CLICKED: {
- if(LOWORD(wParam) == IDC_MODFPS) {
+ if (LOWORD(wParam) == IDC_MODFPS) {
AFX_MANAGE_STATE(AfxGetStaticModuleState());
m_fps.EnableWindow(!!m_modfps.GetCheck());
return true;
@@ -725,7 +725,7 @@ 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 {
@@ -736,12 +736,12 @@ 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) {
+ if (_stscanf(fpsstr, _T("%f"), &fps) == 1) {
m_MediaFPS = fps;
}
#if _MFC_VER >= 0x0700
@@ -784,7 +784,7 @@ CDVSAboutPPage::CDVSAboutPPage(LPUNKNOWN lpunk, HRESULT* phr) : bool CDVSAboutPPage::OnMessage(UINT uMsg, WPARAM wParam, LPARAM lParam)
{
- switch(uMsg) {
+ switch (uMsg) {
case WM_INITDIALOG: {
#ifdef _VSMOD
SetDlgItemTextA( m_Dlg, IDC_VERSION, "DirectVobSub 2.40."MAKE_STR(MPC_VERSION_PATCH)"."MAKE_STR(MPC_VERSION_REV)" "MAKE_STR(VERSION_ARCH)", MOD\nCopyright 2001-2011 MPC-HC & VSFilterMod Teams" );
@@ -794,13 +794,13 @@ bool CDVSAboutPPage::OnMessage(UINT uMsg, WPARAM wParam, LPARAM lParam) }
break;
case WM_COMMAND: {
- switch(HIWORD(wParam)) {
+ switch (HIWORD(wParam)) {
case BN_CLICKED: {
- if(LOWORD(wParam) == IDC_HOMEPAGEBTN) {
+ 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) {
+ } 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;
@@ -828,11 +828,11 @@ CDVSZoomPPage::CDVSZoomPPage(LPUNKNOWN pUnk, HRESULT* phr) : bool CDVSZoomPPage::OnMessage(UINT uMsg, WPARAM wParam, LPARAM lParam)
{
- switch(uMsg) {
+ switch (uMsg) {
case WM_COMMAND: {
- switch(HIWORD(wParam)) {
+ switch (HIWORD(wParam)) {
case EN_CHANGE: {
- if(LOWORD(wParam) == IDC_EDIT1 || LOWORD(wParam) == IDC_EDIT2
+ if (LOWORD(wParam) == IDC_EDIT1 || LOWORD(wParam) == IDC_EDIT2
|| LOWORD(wParam) == IDC_EDIT7 || LOWORD(wParam) == IDC_EDIT8) {
AFX_MANAGE_STATE(AfxGetStaticModuleState());
UpdateControlData(true);
@@ -852,7 +852,7 @@ 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;
@@ -871,7 +871,7 @@ void CDVSZoomPPage::UpdateControlData(bool fSave) void CDVSZoomPPage::UpdateObjectData(bool fSave)
{
- if(fSave) {
+ if (fSave) {
m_pDirectVobSub->put_ZoomRect(&m_rect);
} else {
m_pDirectVobSub->get_ZoomRect(&m_rect);
@@ -894,14 +894,14 @@ CDVSColorPPage::CDVSColorPPage(LPUNKNOWN pUnk, HRESULT* phr) : bool CDVSColorPPage::OnMessage(UINT uMsg, WPARAM wParam, LPARAM lParam)
{
- switch(uMsg) {
+ switch (uMsg) {
case WM_COMMAND: {
- switch(HIWORD(wParam)) {
+ switch (HIWORD(wParam)) {
case LBN_DBLCLK:
- if((HWND)lParam == m_dynchglist.m_hWnd) {
+ if ((HWND)lParam == m_dynchglist.m_hWnd) {
int old = -1;
m_pDirectVobSub->get_ColorFormat(&old);
- if(FAILED(m_pDirectVobSub->put_ColorFormat(m_dynchglist.GetCurSel()))) {
+ if (FAILED(m_pDirectVobSub->put_ColorFormat(m_dynchglist.GetCurSel()))) {
m_dynchglist.SetCurSel(old);
}
@@ -910,11 +910,11 @@ bool CDVSColorPPage::OnMessage(UINT uMsg, WPARAM wParam, LPARAM lParam) break;
case BN_CLICKED: {
- switch(LOWORD(wParam)) {
+ switch (LOWORD(wParam)) {
case IDC_COLORCHANGE: {
int old = -1;
m_pDirectVobSub->get_ColorFormat(&old);
- if(FAILED(m_pDirectVobSub->put_ColorFormat(m_dynchglist.GetCurSel()))) {
+ if (FAILED(m_pDirectVobSub->put_ColorFormat(m_dynchglist.GetCurSel()))) {
m_dynchglist.SetCurSel(old);
}
@@ -922,7 +922,7 @@ bool CDVSColorPPage::OnMessage(UINT uMsg, WPARAM wParam, LPARAM lParam) }
case IDC_COLORUP: {
int sel = m_preflist.GetCurSel();
- if(sel > 0) {
+ if (sel > 0) {
CString str;
m_preflist.GetText(sel, str);
int iPos = (int)m_preflist.GetItemData(sel);
@@ -937,7 +937,7 @@ bool CDVSColorPPage::OnMessage(UINT uMsg, WPARAM wParam, LPARAM lParam) }
case IDC_COLORDOWN: {
int sel = m_preflist.GetCurSel();
- if(sel >= 0 && sel < m_preflist.GetCount()-1) {
+ if (sel >= 0 && sel < m_preflist.GetCount()-1) {
CString str;
m_preflist.GetText(sel, str);
int iPos = (int)m_preflist.GetItemData(sel);
@@ -963,18 +963,18 @@ bool CDVSColorPPage::OnMessage(UINT uMsg, WPARAM wParam, LPARAM lParam) void CDVSColorPPage::UpdateObjectData(bool fSave)
{
- if(fSave) {
+ 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);
}
@@ -993,21 +993,21 @@ void CDVSColorPPage::UpdateControlData(bool fSave) BYTE* pData = NULL;
UINT nSize;
- if(!theApp.GetProfileBinary(ResStr(IDS_R_GENERAL), ResStr(IDS_RG_COLORFORMATS), &pData, &nSize)
+ if (!theApp.GetProfileBinary(ResStr(IDS_R_GENERAL), ResStr(IDS_RG_COLORFORMATS), &pData, &nSize)
|| !pData || nSize != VIHSIZE) {
- if(pData) {
+ if (pData) {
delete [] pData, pData = NULL;
}
nSize = VIHSIZE;
pData = new BYTE[VIHSIZE];
- for(size_t i = 0; i < VIHSIZE; i++) {
+ for (size_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]));
@@ -1041,14 +1041,14 @@ CDVSPathsPPage::CDVSPathsPPage(LPUNKNOWN pUnk, HRESULT* phr) : bool CDVSPathsPPage::OnMessage(UINT uMsg, WPARAM wParam, LPARAM lParam)
{
- switch(uMsg) {
+ switch (uMsg) {
case WM_COMMAND: {
- switch(HIWORD(wParam)) {
+ switch (HIWORD(wParam)) {
case LBN_SELCHANGE:
- if((HWND)lParam == m_pathlist.m_hWnd) {
+ if ((HWND)lParam == m_pathlist.m_hWnd) {
int i = m_pathlist.GetCurSel();
m_remove.EnableWindow(i >= 3 ? TRUE : FALSE);
- if(i >= 0) {
+ if (i >= 0) {
CString path;
m_pathlist.GetText(i, path);
m_path.SetWindowText(path);
@@ -1058,14 +1058,14 @@ bool CDVSPathsPPage::OnMessage(UINT uMsg, WPARAM wParam, LPARAM lParam) break;
case LBN_SELCANCEL:
- if((HWND)lParam == m_pathlist.m_hWnd) {
+ if ((HWND)lParam == m_pathlist.m_hWnd) {
m_remove.EnableWindow(FALSE);
return true;
}
break;
case BN_CLICKED: {
- switch(LOWORD(wParam)) {
+ switch (LOWORD(wParam)) {
case IDC_BROWSE: {
TCHAR pathbuff[MAX_PATH];
@@ -1080,7 +1080,7 @@ bool CDVSPathsPPage::OnMessage(UINT uMsg, WPARAM wParam, LPARAM lParam) bi.iImage = 0;
LPITEMIDLIST iil = SHBrowseForFolder(&bi);
- if(iil) {
+ if (iil) {
SHGetPathFromIDList(iil, pathbuff);
m_path.SetWindowText(pathbuff);
}
@@ -1091,10 +1091,10 @@ bool CDVSPathsPPage::OnMessage(UINT uMsg, WPARAM wParam, LPARAM lParam) case IDC_REMOVE: {
int i = m_pathlist.GetCurSel();
- if(i >= 0) {
+ if (i >= 0) {
m_pathlist.DeleteString(i);
i = min(i, m_pathlist.GetCount()-1);
- if(i >= 0 && m_pathlist.GetCount() > 0) {
+ if (i >= 0 && m_pathlist.GetCount() > 0) {
m_pathlist.SetCurSel(i);
m_remove.EnableWindow(i >= 3 ? TRUE : FALSE);
}
@@ -1107,7 +1107,7 @@ bool CDVSPathsPPage::OnMessage(UINT uMsg, WPARAM wParam, LPARAM lParam) case IDC_ADD: {
CString path;
m_path.GetWindowText(path);
- if(!path.IsEmpty() && m_pathlist.FindString(-1, path) < 0) {
+ if (!path.IsEmpty() && m_pathlist.FindString(-1, path) < 0) {
m_pathlist.AddString(path);
}
@@ -1127,18 +1127,18 @@ 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 {
tmp.Format(ResStr(IDS_RP_PATH), i++);
path = theApp.GetProfileString(ResStr(IDS_R_DEFTEXTPATHES), tmp, chk);
- if(path != chk) {
+ if (path != chk) {
theApp.WriteProfileString(ResStr(IDS_R_DEFTEXTPATHES), tmp, _T(""));
}
- } while(path != chk);
+ } 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]);
}
@@ -1146,27 +1146,27 @@ void CDVSPathsPPage::UpdateObjectData(bool fSave) CString chk(_T("123456789")), path, tmp;
int i = 0;
do {
- if(!path.IsEmpty()) {
+ 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 {
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]);
}
diff --git a/src/filters/transform/VSFilter/Scale2x.cpp b/src/filters/transform/VSFilter/Scale2x.cpp index ab869ab0b..f2f725d04 100644 --- a/src/filters/transform/VSFilter/Scale2x.cpp +++ b/src/filters/transform/VSFilter/Scale2x.cpp @@ -37,11 +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;
}
@@ -68,7 +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
@@ -181,7 +181,7 @@ void Scale2x_YUY2_MMX( BYTE* s1, BYTE* d1, int w ) 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;
@@ -224,7 +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
@@ -248,11 +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)|
@@ -279,11 +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)|
@@ -310,11 +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];
@@ -341,7 +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
@@ -408,7 +408,7 @@ void Scale2x_XRGB32_MMX( BYTE* s1, BYTE* d1, int w ) 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];
@@ -441,7 +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;
@@ -458,17 +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 0cd270f06..76986dee8 100644 --- a/src/filters/transform/VSFilter/StyleEditorDialog.cpp +++ b/src/filters/transform/VSFilter/StyleEditorDialog.cpp @@ -106,10 +106,10 @@ void CStyleEditorDialog::DoDataExchange(CDataExchange* pDX) void CStyleEditorDialog::UpdateControlData(bool fSave)
{
- if(fSave) {
+ if (fSave) {
UpdateData();
- if(m_iCharset >= 0) {
+ if (m_iCharset >= 0) {
m_stss.charSet = m_charset.GetItemData(m_iCharset);
}
m_stss.fontSpacing = m_spacing;
@@ -124,25 +124,25 @@ void CStyleEditorDialog::UpdateControlData(bool fSave) m_stss.scrAlignment = m_screenalignment+1;
m_stss.marginRect = m_margin;
- for(ptrdiff_t i = 0; i < 4; i++) {
+ 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]) {
+ 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) {
+ while (m_stss.fontAngleZ < 0) {
m_stss.fontAngleZ += 360;
}
m_angle = fmod(m_stss.fontAngleZ, 360);
@@ -165,7 +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);
@@ -181,7 +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();
}
@@ -225,15 +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) {
+ 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;
}
@@ -268,20 +268,20 @@ void CStyleEditorDialog::OnBnClickedCheck1() UpdateData();
int avg = 0;
- for(ptrdiff_t i = 0; i < 4; i++) {
+ for (ptrdiff_t i = 0; i < 4; i++) {
avg += m_alphasliders[i].GetPos();
}
avg /= 4;
- for(ptrdiff_t i = 0; i < 4; i++) {
+ 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++) {
+ for (ptrdiff_t i = 0; i < 4; i++) {
m_alphasliders[i].SetPos(pos);
}
}
diff --git a/src/filters/transform/VSFilter/Systray.cpp b/src/filters/transform/VSFilter/Systray.cpp index 174729d53..4e23411b3 100644 --- a/src/filters/transform/VSFilter/Systray.cpp +++ b/src/filters/transform/VSFilter/Systray.cpp @@ -43,8 +43,8 @@ LRESULT CALLBACK HookProc(UINT code, WPARAM wParam, LPARAM lParam) {
MSG* msg = (MSG*)lParam;
- if(msg->message == WM_KEYDOWN) {
- switch(msg->wParam) {
+ if (msg->message == WM_KEYDOWN) {
+ switch (msg->wParam) {
case VK_F13:
PostMessage(HWND_BROADCAST, WM_DVSPREVSUB, 0, 0);
break;
@@ -75,13 +75,13 @@ class CSystrayWindow : public CWnd void StepSub(int dir) {
int iSelected, nLangs;
- if(FAILED(m_tbid->dvs->get_LanguageCount(&nLangs))) {
+ if (FAILED(m_tbid->dvs->get_LanguageCount(&nLangs))) {
return;
}
- if(FAILED(m_tbid->dvs->get_SelectedLanguage(&iSelected))) {
+ if (FAILED(m_tbid->dvs->get_SelectedLanguage(&iSelected))) {
return;
}
- if(nLangs > 0) {
+ if (nLangs > 0) {
m_tbid->dvs->put_SelectedLanguage((iSelected+dir+nLangs)%nLangs);
}
}
@@ -92,7 +92,7 @@ class CSystrayWindow : public CWnd void ToggleSub() {
bool fShow;
- if(FAILED(m_tbid->dvs->get_HideSubtitles(&fShow))) {
+ if (FAILED(m_tbid->dvs->get_HideSubtitles(&fShow))) {
return;
}
m_tbid->dvs->put_HideSubtitles(!fShow);
@@ -134,11 +134,11 @@ 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);
}
@@ -164,7 +164,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;
}
@@ -174,9 +174,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);
}
@@ -219,7 +219,7 @@ LRESULT CSystrayWindow::OnTaskBarRestart(WPARAM, LPARAM) {
AFX_MANAGE_STATE(AfxGetStaticModuleState());
- if(m_tbid->fShowIcon) {
+ if (m_tbid->fShowIcon) {
NOTIFYICONDATA tnid;
ZeroMemory(&tnid, sizeof(NOTIFYICONDATA));
tnid.cbSize = sizeof(NOTIFYICONDATA);
@@ -233,7 +233,7 @@ LRESULT CSystrayWindow::OnTaskBarRestart(WPARAM, LPARAM) BOOL res = Shell_NotifyIcon(NIM_ADD, &tnid);
- if(tnid.hIcon) {
+ if (tnid.hIcon) {
DestroyIcon(tnid.hIcon);
}
@@ -245,13 +245,13 @@ 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) {
+ 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
@@ -260,13 +260,13 @@ LRESULT CSystrayWindow::OnNotifyIcon(WPARAM wParam, LPARAM lParam) CComPtr<IBaseFilter> pBF2;
BeginEnumFilters(m_tbid->graph, pEF, pBF) {
- if(!CComQIPtr<IDirectVobSub>(pBF)) {
+ if (!CComQIPtr<IDirectVobSub>(pBF)) {
continue;
}
- if(CComQIPtr<IVideoWindow> pVW = m_tbid->graph) {
+ if (CComQIPtr<IVideoWindow> pVW = m_tbid->graph) {
HWND hwnd;
- if(SUCCEEDED(pVW->get_Owner((OAHWND*)&hwnd))
+ if (SUCCEEDED(pVW->get_Owner((OAHWND*)&hwnd))
|| SUCCEEDED(pVW->get_MessageDrain((OAHWND*)&hwnd))) {
hWnd = hwnd;
}
@@ -278,7 +278,7 @@ LRESULT CSystrayWindow::OnNotifyIcon(WPARAM wParam, LPARAM lParam) }
EndEnumFilters
- if(pBF2) {
+ if (pBF2) {
ShowPPage(pBF2, hWnd);
}
}
@@ -293,11 +293,11 @@ LRESULT CSystrayWindow::OnNotifyIcon(WPARAM wParam, LPARAM lParam) BeginEnumFilters(m_tbid->graph, pEF, pBF) {
CString name = GetFilterName(pBF);
- if(name.IsEmpty()) {
+ if (name.IsEmpty()) {
continue;
}
- if(CComQIPtr<IAMStreamSelect> pSS = pBF) {
+ if (CComQIPtr<IAMStreamSelect> pSS = pBF) {
pStreams.Add(pSS);
names.Add(name);
}
@@ -307,7 +307,7 @@ LRESULT CSystrayWindow::OnNotifyIcon(WPARAM wParam, LPARAM lParam) CMenu popup;
popup.CreatePopupMenu();
- for(size_t j = 0; j < pStreams.GetCount(); j++) {
+ for (size_t j = 0; j < pStreams.GetCount(); j++) {
bool fMMSwitcher = !names[j].Compare(_T("Morgan Stream Switcher"));
DWORD cStreams = 0;
@@ -315,12 +315,12 @@ LRESULT CSystrayWindow::OnNotifyIcon(WPARAM wParam, LPARAM lParam) DWORD flags, group, prevgroup = (DWORD)-1;
- for(UINT i = 0; i < cStreams; i++) {
+ 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) {
+ if (S_OK == pStreams[j]->Info(i, 0, &flags, 0, &group, &pName, 0, 0)) {
+ if (prevgroup != group && i > 1) {
+ if (fMMSwitcher) {
cStreams = i;
break;
}
@@ -328,14 +328,14 @@ LRESULT CSystrayWindow::OnNotifyIcon(WPARAM wParam, LPARAM lParam) }
prevgroup = group;
- if(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) {
+ if (cStreams > 0) {
popup.AppendMenu(MF_SEPARATOR);
}
}
@@ -344,8 +344,8 @@ LRESULT CSystrayWindow::OnNotifyIcon(WPARAM wParam, LPARAM lParam) 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
+ 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);
}
@@ -359,12 +359,12 @@ LRESULT CSystrayWindow::OnNotifyIcon(WPARAM wParam, LPARAM lParam) UINT id = popup.TrackPopupMenu(TPM_LEFTBUTTON|TPM_RETURNCMD, p.x, p.y, CWnd::FromHandle(hWnd), 0);
PostMessage(WM_NULL);
- if(id & (1<<15)) {
+ 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) {
+ } else if (id & (1<<14)) {
+ if (CComQIPtr<IVideoWindow> pVW = m_tbid->graph) {
HWND hwnd;
- if(SUCCEEDED(pVW->get_Owner((OAHWND*)&hwnd))
+ if (SUCCEEDED(pVW->get_Owner((OAHWND*)&hwnd))
|| SUCCEEDED(pVW->get_MessageDrain((OAHWND*)&hwnd))) {
hWnd = hwnd;
}
@@ -389,14 +389,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);
}
@@ -420,11 +420,11 @@ static TCHAR* CallPPage(IFilterGraph* pGraph, int idx, HWND hWnd) BeginEnumFilters(pGraph, pEF, pBF) {
CComQIPtr<ISpecifyPropertyPages> pSPS = pBF;
- if(!pSPS) {
+ 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... :)
@@ -437,21 +437,21 @@ 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 {
ret = new TCHAR[wcslen(wstr)+1];
- if(ret) {
+ if (ret) {
_tcscpy(ret, CString(wstr));
}
}
}
- if(caGUID.pElems) {
+ if (caGUID.pElems) {
CoTaskMemFree(caGUID.pElems);
}
- if(wstr) {
+ if (wstr) {
free(wstr);
}
diff --git a/src/filters/transform/VSFilter/VSFilter.cpp b/src/filters/transform/VSFilter/VSFilter.cpp index a26e84bfd..29765c482 100644 --- a/src/filters/transform/VSFilter/VSFilter.cpp +++ b/src/filters/transform/VSFilter/VSFilter.cpp @@ -44,7 +44,7 @@ extern "C" BOOL WINAPI DllEntryPoint(HINSTANCE, ULONG, LPVOID); BOOL CVSFilterApp::InitInstance()
{
- if(!CWinApp::InitInstance()) {
+ if (!CWinApp::InitInstance()) {
return FALSE;
}
@@ -137,15 +137,15 @@ 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);
}
@@ -161,14 +161,14 @@ STDAPI DllUnregisterServer() void CALLBACK DirectVobSub(HWND hwnd, HINSTANCE hinst, LPSTR lpszCmdLine, int nCmdShow)
{
- if(FAILED(::CoInitialize(0))) {
+ 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/plugins.cpp b/src/filters/transform/VSFilter/plugins.cpp index defdaf0f3..abef007fe 100644 --- a/src/filters/transform/VSFilter/plugins.cpp +++ b/src/filters/transform/VSFilter/plugins.cpp @@ -69,36 +69,36 @@ namespace Plugin }
bool Render(SubPicDesc& dst, REFERENCE_TIME rt, float fps) {
- if(!m_pSubPicProvider) {
+ if (!m_pSubPicProvider) {
return false;
}
CSize size(dst.w, dst.h);
- if(!m_pSubPicQueue) {
+ if (!m_pSubPicQueue) {
CComPtr<ISubPicAllocator> pAllocator = new CMemSubPicAllocator(dst.type, size);
HRESULT hr;
- if(!(m_pSubPicQueue = new CSubPicQueueNoThread(pAllocator, &hr)) || FAILED(hr)) {
+ if (!(m_pSubPicQueue = new CSubPicQueueNoThread(pAllocator, &hr)) || FAILED(hr)) {
m_pSubPicQueue = NULL;
return false;
}
}
- if(m_SubPicProviderId != (DWORD_PTR)(ISubPicProvider*)m_pSubPicProvider) {
+ if (m_SubPicProviderId != (DWORD_PTR)(ISubPicProvider*)m_pSubPicProvider) {
m_pSubPicQueue->SetSubPicProvider(m_pSubPicProvider);
m_SubPicProviderId = (DWORD_PTR)(ISubPicProvider*)m_pSubPicProvider;
}
CComPtr<ISubPic> pSubPic;
- if(!m_pSubPicQueue->LookupSubPic(rt, pSubPic)) {
+ if (!m_pSubPicQueue->LookupSubPic(rt, pSubPic)) {
return false;
}
CRect r;
pSubPic->GetDirtyRect(r);
- if(dst.type == MSP_RGB32 || dst.type == MSP_RGB24 || dst.type == MSP_RGB16 || dst.type == MSP_RGB15) {
+ if (dst.type == MSP_RGB32 || dst.type == MSP_RGB24 || dst.type == MSP_RGB16 || dst.type == MSP_RGB15) {
dst.h = -dst.h;
}
@@ -118,35 +118,35 @@ namespace Plugin fs.m_mtime = 0;
CFileGetStatus(fn, fs);
- while(1) {
+ while (1) {
DWORD i = WaitForMultipleObjects(handles.GetCount(), handles.GetData(), FALSE, 1000);
- if(WAIT_OBJECT_0 == i) {
+ 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])) {
+ } 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) {
+ if (fs.m_mtime < fs2.m_mtime) {
fs.m_mtime = fs2.m_mtime;
- if(CComQIPtr<ISubStream> pSubStream = m_pSubPicProvider) {
+ if (CComQIPtr<ISubStream> pSubStream = m_pSubPicProvider) {
CAutoLock cAutoLock(&m_csSubLock);
pSubStream->Reload();
}
}
}
- } else if(WAIT_TIMEOUT == i) {
+ } else if (WAIT_TIMEOUT == i) {
CString fn2 = GetFileName();
- if(fn != fn2) {
+ if (fn != fn2) {
CPath p(fn2);
p.RemoveFileSpec();
HANDLE h = FindFirstChangeNotification(p, FALSE, FILE_NOTIFY_CHANGE_LAST_WRITE);
- if(h != INVALID_HANDLE_VALUE) {
+ if (h != INVALID_HANDLE_VALUE) {
fn = fn2;
handles.SetCount(1);
handles.Add(h);
@@ -159,7 +159,7 @@ namespace Plugin m_hThread = 0;
- for(size_t i = 1; i < handles.GetCount(); i++) {
+ for (size_t i = 1; i < handles.GetCount(); i++) {
FindCloseChangeNotification(handles[i]);
}
@@ -171,7 +171,7 @@ namespace Plugin {
public:
CVobSubFilter(CString fn = _T("")) {
- if(!fn.IsEmpty()) {
+ if (!fn.IsEmpty()) {
Open(fn);
}
}
@@ -180,9 +180,9 @@ namespace Plugin SetFileName(_T(""));
m_pSubPicProvider = NULL;
- if(CVobSubFile* vsf = new CVobSubFile(&m_csSubLock)) {
+ if (CVobSubFile* vsf = new CVobSubFile(&m_csSubLock)) {
m_pSubPicProvider = (ISubPicProvider*)vsf;
- if(vsf->Open(CString(fn))) {
+ if (vsf->Open(CString(fn))) {
SetFileName(fn);
} else {
m_pSubPicProvider = NULL;
@@ -201,7 +201,7 @@ namespace Plugin CTextSubFilter(CString fn = _T(""), int CharSet = DEFAULT_CHARSET, float fps = -1)
: m_CharSet(CharSet) {
m_fps = fps;
- if(!fn.IsEmpty()) {
+ if (!fn.IsEmpty()) {
Open(fn, CharSet);
}
}
@@ -214,10 +214,10 @@ namespace Plugin SetFileName(_T(""));
m_pSubPicProvider = NULL;
- if(!m_pSubPicProvider) {
- if(ssf::CRenderer* ssf = new ssf::CRenderer(&m_csSubLock)) {
+ if (!m_pSubPicProvider) {
+ if (ssf::CRenderer* ssf = new ssf::CRenderer(&m_csSubLock)) {
m_pSubPicProvider = (ISubPicProvider*)ssf;
- if(ssf->Open(CString(fn))) {
+ if (ssf->Open(CString(fn))) {
SetFileName(fn);
} else {
m_pSubPicProvider = NULL;
@@ -225,10 +225,10 @@ namespace Plugin }
}
- if(!m_pSubPicProvider) {
- if(CRenderedTextSubtitle* rts = new CRenderedTextSubtitle(&m_csSubLock)) {
+ if (!m_pSubPicProvider) {
+ if (CRenderedTextSubtitle* rts = new CRenderedTextSubtitle(&m_csSubLock)) {
m_pSubPicProvider = (ISubPicProvider*)rts;
- if(rts->Open(CString(fn), CharSet)) {
+ if (rts->Open(CString(fn), CharSet)) {
SetFileName(fn);
} else {
m_pSubPicProvider = NULL;
@@ -296,7 +296,7 @@ namespace Plugin CFileDialog fd(TRUE, NULL, GetFileName(), OFN_EXPLORER|OFN_ENABLESIZING|OFN_HIDEREADONLY,
_T("VobSub files (*.idx;*.sub)|*.idx;*.sub||"), CWnd::FromHandle(hwnd), 0);
- if(fd.DoModal() != IDOK) {
+ if (fd.DoModal() != IDOK) {
return 1;
}
@@ -335,7 +335,7 @@ namespace Plugin fd.m_pOFN->lpfnHook = (LPOFNHOOKPROC)OpenHookProc;
fd.m_pOFN->lCustData = (LPARAM)DEFAULT_CHARSET;
- if(fd.DoModal() != IDOK) {
+ if (fd.DoModal() != IDOK) {
return 1;
}
@@ -343,7 +343,7 @@ namespace Plugin }
void StringProc(const FilterActivation* fa, const FilterFunctions* ff, char* str) {
- if(!GetFileName().IsEmpty()) {
+ if (!GetFileName().IsEmpty()) {
sprintf(str, " (%s, %d)", CStringA(GetFileName()), GetCharSet());
} else {
sprintf(str, " (empty)");
@@ -373,7 +373,7 @@ namespace Plugin void baseDeinitProc(FilterActivation* fa, const FilterFunctions* ff)
{
CVirtualDubFilter* f = *(CVirtualDubFilter**)fa->filter_data;
- if(f) {
+ if (f) {
delete f, f = NULL;
}
}
@@ -399,7 +399,7 @@ namespace Plugin void baseStringProc(const FilterActivation* fa, const FilterFunctions* ff, char* str)
{
CVirtualDubFilter* f = *(CVirtualDubFilter**)fa->filter_data;
- if(f) {
+ if (f) {
f->StringProc(fa, ff, str);
}
}
@@ -414,7 +414,7 @@ namespace Plugin {
FilterActivation* fa = (FilterActivation*)lpVoid;
CVirtualDubFilter* f = *(CVirtualDubFilter**)fa->filter_data;
- if(f) {
+ if (f) {
delete f;
}
f = new CVobSubVirtualDubFilter(CString(*argv[0].asString()));
@@ -425,7 +425,7 @@ namespace Plugin {
FilterActivation* fa = (FilterActivation*)lpVoid;
CVirtualDubFilter* f = *(CVirtualDubFilter**)fa->filter_data;
- if(f) {
+ if (f) {
delete f;
}
f = new CTextSubVirtualDubFilter(CString(*argv[0].asString()), argv[1].asInt());
@@ -498,11 +498,11 @@ namespace Plugin 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) {
+ if (!fd_vobsub) {
return 1;
}
fd_textsub = ff->addFilter(fm, &filterDef_textsub, sizeof(FilterDefinition));
- if(!fd_textsub) {
+ if (!fd_textsub) {
return 1;
}
@@ -573,7 +573,7 @@ namespace Plugin 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) {
+ if (fd.DoModal() != IDOK) {
return 1;
}
@@ -618,7 +618,7 @@ namespace Plugin CFileDialog fd(TRUE, NULL, GetFileName(), OFN_ENABLESIZING|OFN_HIDEREADONLY,
formats, CWnd::FromHandle((HWND)hwnd), sizeof(OPENFILENAME));
#endif
- if(fd.DoModal() != IDOK) {
+ if (fd.DoModal() != IDOK) {
return 1;
}
@@ -626,7 +626,7 @@ namespace Plugin }
void StringProc(const VDXFilterActivation* fa, const VDXFilterFunctions* ff, char* str) {
- if(!GetFileName().IsEmpty()) {
+ if (!GetFileName().IsEmpty()) {
sprintf(str, " (%s, %d)", CStringA(GetFileName()), GetCharSet());
} else {
sprintf(str, " (empty)");
@@ -654,7 +654,7 @@ namespace Plugin void baseDeinitProc(VDXFilterActivation* fa, const VDXFilterFunctions* ff)
{
CVirtualDubFilter* f = *(CVirtualDubFilter**)fa->filter_data;
- if(f) {
+ if (f) {
delete f, f = NULL;
}
}
@@ -680,7 +680,7 @@ namespace Plugin void baseStringProc(const VDXFilterActivation* fa, const VDXFilterFunctions* ff, char* str)
{
CVirtualDubFilter* f = *(CVirtualDubFilter**)fa->filter_data;
- if(f) {
+ if (f) {
f->StringProc(fa, ff, str);
}
}
@@ -695,7 +695,7 @@ namespace Plugin {
VDXFilterActivation* fa = (VDXFilterActivation*)lpVoid;
CVirtualDubFilter* f = *(CVirtualDubFilter**)fa->filter_data;
- if(f) {
+ if (f) {
delete f;
}
f = new CVobSubVirtualDubFilter(CString(*argv[0].asString()));
@@ -706,7 +706,7 @@ namespace Plugin {
VDXFilterActivation* fa = (VDXFilterActivation*)lpVoid;
CVirtualDubFilter* f = *(CVirtualDubFilter**)fa->filter_data;
- if(f) {
+ if (f) {
delete f;
}
f = new CTextSubVirtualDubFilter(CString(*argv[0].asString()), argv[1].asInt());
@@ -778,7 +778,7 @@ namespace Plugin 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)))
+ if (!(fd_vobsub = ff->addFilter(fm, &filterDef_vobsub, sizeof(VDXFilterDefinition)))
|| !(fd_textsub = ff->addFilter(fm, &filterDef_textsub, sizeof(VDXFilterDefinition)))) {
return 1;
}
@@ -840,7 +840,7 @@ namespace Plugin CVobSubAvisynthFilter(PClip c, const char* fn, IScriptEnvironment* env)
: CVobSubFilter(CString(fn))
, CAvisynthFilter(c, env) {
- if(!m_pSubPicProvider) {
+ if (!m_pSubPicProvider) {
env->ThrowError("VobSub: Can't open \"%s\"", fn);
}
}
@@ -857,7 +857,7 @@ namespace Plugin 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)
+ if (!m_pSubPicProvider)
#ifdef _VSMOD
env->ThrowError("TextSubMod: Can't open \"%s\"", fn);
#else
@@ -980,7 +980,7 @@ namespace Plugin CVobSubAvisynthFilter(PClip c, const char* fn, IScriptEnvironment* env)
: CVobSubFilter(CString(fn))
, CAvisynthFilter(c, env) {
- if(!m_pSubPicProvider) {
+ if (!m_pSubPicProvider) {
env->ThrowError("VobSub: Can't open \"%s\"", fn);
}
}
@@ -997,7 +997,7 @@ namespace Plugin 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)
+ if (!m_pSubPicProvider)
#ifdef _VSMOD
env->ThrowError("TextSubMod: Can't open \"%s\"", fn);
#else
@@ -1103,11 +1103,11 @@ namespace Plugin UINT_PTR CALLBACK OpenHookProc(HWND hDlg, UINT uiMsg, WPARAM wParam, LPARAM lParam)
{
- switch(uiMsg) {
+ switch (uiMsg) {
case WM_NOTIFY: {
OPENFILENAME* ofn = ((OFNOTIFY *)lParam)->lpOFN;
- if(((NMHDR *)lParam)->code == CDN_FILEOK) {
+ if (((NMHDR *)lParam)->code == CDN_FILEOK) {
ofn->lCustData = (LPARAM)CharSetList[SendMessage(GetDlgItem(hDlg, IDC_COMBO1), CB_GETCURSEL, 0, 0)];
}
@@ -1121,11 +1121,11 @@ UINT_PTR CALLBACK OpenHookProc(HWND hDlg, UINT uiMsg, WPARAM wParam, LPARAM lPar SetWindowLongPtr(hDlg, GWL_USERDATA, lParam);
#endif
- for(ptrdiff_t i = 0; i < CharSetLen; i++) {
+ 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) {
+ if (CharSetList[i] == (int)((OPENFILENAME*)lParam)->lCustData) {
SendMessage(GetDlgItem(hDlg, IDC_COMBO1), CB_SETCURSEL, i, 0);
}
}
|