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

github.com/mpc-hc/mpc-hc.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorXhmikosR <xhmikosr@users.sourceforge.net>2012-02-05 13:27:07 +0400
committerXhmikosR <xhmikosr@users.sourceforge.net>2012-02-05 13:27:07 +0400
commit6cb2939b677159a85147c6500835c194ee1ccf86 (patch)
tree54994b57d8df3203b276d15ee73c46d227ea6826 /src/Subtitles/libssf
parente736ccc10964dfcd571d1b0f07327819c31a63a9 (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/libssf')
-rw-r--r--src/Subtitles/libssf/Arabic.cpp6
-rw-r--r--src/Subtitles/libssf/Array.h8
-rw-r--r--src/Subtitles/libssf/Exception.cpp2
-rw-r--r--src/Subtitles/libssf/File.cpp92
-rw-r--r--src/Subtitles/libssf/FontWrapper.cpp4
-rw-r--r--src/Subtitles/libssf/Glyph.cpp44
-rw-r--r--src/Subtitles/libssf/GlyphPath.cpp44
-rw-r--r--src/Subtitles/libssf/Node.cpp136
-rw-r--r--src/Subtitles/libssf/NodeFactory.cpp28
-rw-r--r--src/Subtitles/libssf/Rasterizer.cpp150
-rw-r--r--src/Subtitles/libssf/Renderer.cpp176
-rw-r--r--src/Subtitles/libssf/Renderer.h10
-rw-r--r--src/Subtitles/libssf/Split.cpp14
-rw-r--r--src/Subtitles/libssf/Stream.cpp90
-rw-r--r--src/Subtitles/libssf/StringMap.h2
-rw-r--r--src/Subtitles/libssf/Subtitle.cpp144
-rw-r--r--src/Subtitles/libssf/SubtitleFile.cpp84
17 files changed, 517 insertions, 517 deletions
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;
}