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 /src/Subtitles | |
parent | e736ccc10964dfcd571d1b0f07327819c31a63a9 (diff) |
apply astyle
git-svn-id: https://mpc-hc.svn.sourceforge.net/svnroot/mpc-hc/trunk@4039 10f7b99b-c216-0410-bff0-8a66a9350fd8
Diffstat (limited to 'src/Subtitles')
36 files changed, 2767 insertions, 2759 deletions
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;
}
|