diff options
Diffstat (limited to 'src/Subtitles')
-rw-r--r-- | src/Subtitles/ColorConvTable.cpp | 2 | ||||
-rw-r--r-- | src/Subtitles/RTS.cpp | 32 | ||||
-rw-r--r-- | src/Subtitles/STS.cpp | 9 | ||||
-rw-r--r-- | src/Subtitles/SubtitleHelpers.cpp | 14 | ||||
-rw-r--r-- | src/Subtitles/USFSubtitles.cpp | 40 |
5 files changed, 45 insertions, 52 deletions
diff --git a/src/Subtitles/ColorConvTable.cpp b/src/Subtitles/ColorConvTable.cpp index 092d91e17..245fafdac 100644 --- a/src/Subtitles/ColorConvTable.cpp +++ b/src/Subtitles/ColorConvTable.cpp @@ -723,7 +723,6 @@ DWORD ColorConvTable::A8Y8U8V8_To_ARGB_PC_BT709(int a8, int y8, int u8, int v8) DWORD ColorConvTable::A8Y8U8V8_PC_To_TV(int a8, int y8, int u8, int v8) { - const int FRACTION_SCALE = 1 << 16; const int YUV_MIN = 16; const int cy = int(219.0 / 255 * FRACTION_SCALE + 0.5); const int cuv = int(224.0 / 255 * FRACTION_SCALE + 0.5); @@ -735,7 +734,6 @@ DWORD ColorConvTable::A8Y8U8V8_PC_To_TV(int a8, int y8, int u8, int v8) DWORD ColorConvTable::A8Y8U8V8_TV_To_PC(int a8, int y8, int u8, int v8) { - const int FRACTION_SCALE = 1 << 16; const int YUV_MIN = 16; const int cy = int(255 / 219.0 * FRACTION_SCALE + 0.5); const int cuv = int(255 / 224.0 * FRACTION_SCALE + 0.5); diff --git a/src/Subtitles/RTS.cpp b/src/Subtitles/RTS.cpp index 8796bc80f..ecce8ec72 100644 --- a/src/Subtitles/RTS.cpp +++ b/src/Subtitles/RTS.cpp @@ -1971,8 +1971,8 @@ bool CRenderedTextSubtitle::ParseSSATag(SSATagsList& tagsList, const CStringW& s tag.paramsInt.Add(wcstol(tag.params[0], nullptr, 10));
tag.params.RemoveAt(0);
} else if (nParams == 4) {
- for (size_t i = 0; i < nParams; i++) {
- tag.paramsInt.Add(wcstol(tag.params[i], nullptr, 10));
+ for (size_t n = 0; n < nParams; n++) {
+ tag.paramsInt.Add(wcstol(tag.params[n], nullptr, 10));
}
tag.params.RemoveAll();
}
@@ -1981,8 +1981,8 @@ bool CRenderedTextSubtitle::ParseSSATag(SSATagsList& tagsList, const CStringW& s case SSA_fade: {
size_t nParams = tag.params.GetCount();
if (nParams == 7 || nParams == 2) {
- for (size_t i = 0; i < nParams; i++) {
- tag.paramsInt.Add(wcstol(tag.params[i], nullptr, 10));
+ for (size_t n = 0; n < nParams; n++) {
+ tag.paramsInt.Add(wcstol(tag.params[n], nullptr, 10));
}
tag.params.RemoveAll();
}
@@ -1991,11 +1991,11 @@ bool CRenderedTextSubtitle::ParseSSATag(SSATagsList& tagsList, const CStringW& s case SSA_move: {
size_t nParams = tag.params.GetCount();
if (nParams == 4 || nParams == 6) {
- for (size_t i = 0; i < 4; i++) {
- tag.paramsReal.Add(wcstod(tag.params[i], nullptr));
+ for (size_t n = 0; n < 4; n++) {
+ tag.paramsReal.Add(wcstod(tag.params[n], nullptr));
}
- for (size_t i = 4; i < nParams; i++) {
- tag.paramsInt.Add(wcstol(tag.params[i], nullptr, 10));
+ for (size_t n = 4; n < nParams; n++) {
+ tag.paramsInt.Add(wcstol(tag.params[n], nullptr, 10));
}
tag.params.RemoveAll();
}
@@ -2005,8 +2005,8 @@ bool CRenderedTextSubtitle::ParseSSATag(SSATagsList& tagsList, const CStringW& s case SSA_pos: {
size_t nParams = tag.params.GetCount();
if (nParams == 2) {
- for (size_t i = 0; i < nParams; i++) {
- tag.paramsReal.Add(wcstod(tag.params[i], nullptr));
+ for (size_t n = 0; n < nParams; n++) {
+ tag.paramsReal.Add(wcstod(tag.params[n], nullptr));
}
tag.params.RemoveAll();
}
@@ -2924,10 +2924,10 @@ STDMETHODIMP CRenderedTextSubtitle::Render(SubPicDesc& spd, REFERENCE_TIME rt, d Init(CSize(spd.w, spd.h), spd.vidrect);
}
- int t = (int)(rt / 10000);
+ int time = (int)(rt / 10000);
int segment;
- const STSSegment* stss = SearchSubs(t, fps, &segment);
+ const STSSegment* stss = SearchSubs(time, fps, &segment);
if (!stss) {
return S_FALSE;
}
@@ -2941,7 +2941,7 @@ STDMETHODIMP CRenderedTextSubtitle::Render(SubPicDesc& spd, REFERENCE_TIME rt, d m_subtitleCache.GetNextAssoc(pos, entry, pSub);
STSEntry& stse = GetAt(entry);
- if (stse.end < t) {
+ if (stse.end < time) {
delete pSub;
m_subtitleCache.RemoveKey(entry);
}
@@ -2969,7 +2969,7 @@ STDMETHODIMP CRenderedTextSubtitle::Render(SubPicDesc& spd, REFERENCE_TIME rt, d {
int start = TranslateStart(entry, fps);
- m_time = t - start;
+ m_time = time - start;
m_delay = TranslateEnd(entry, fps) - start;
}
@@ -3006,9 +3006,7 @@ STDMETHODIMP CRenderedTextSubtitle::Render(SubPicDesc& spd, REFERENCE_TIME rt, d int t2 = s->m_effects[k]->t[1];
if (t2 < t1) {
- int t = t1;
- t1 = t2;
- t2 = t;
+ std::swap(t1, t2);
}
if (t1 <= 0 && t2 <= 0) {
diff --git a/src/Subtitles/STS.cpp b/src/Subtitles/STS.cpp index 11a7d9b4a..701a51535 100644 --- a/src/Subtitles/STS.cpp +++ b/src/Subtitles/STS.cpp @@ -509,7 +509,6 @@ static bool OpenSubRipper(CTextFile* file, CSimpleTextSubtitle& ret, int CharSet }
int num2;
- WCHAR wc;
if (swscanf_s(tmp, L"%d%c", &num2, &wc, 1) == 1 && bFoundEmpty) {
num = num2;
break;
@@ -2763,17 +2762,15 @@ bool CSimpleTextSubtitle::SaveAs(CString fn, Subtitle::SubType type, if (type == Subtitle::ASS && m_fScaledBAS) {
str += _T("ScaledBorderAndShadow: Yes\n");
}
- str += _T("PlayResX: %d\n");
- str += _T("PlayResY: %d\n");
+ str.AppendFormat(_T("PlayResX: %d\n"), m_dstScreenSize.cx);
+ str.AppendFormat(_T("PlayResY: %d\n"), m_dstScreenSize.cy);
str += _T("Timer: 100.0000\n");
str += _T("\n");
str += (type == Subtitle::SSA)
? _T("[V4 Styles]\nFormat: Name, Fontname, Fontsize, PrimaryColour, SecondaryColour, TertiaryColour, BackColour, Bold, Italic, BorderStyle, Outline, Shadow, Alignment, MarginL, MarginR, MarginV, AlphaLevel, Encoding\n")
: _T("[V4+ Styles]\nFormat: Name, Fontname, Fontsize, PrimaryColour, SecondaryColour, OutlineColour, BackColour, Bold, Italic, Underline, StrikeOut, ScaleX, ScaleY, Spacing, Angle, BorderStyle, Outline, Shadow, Alignment, MarginL, MarginR, MarginV, Encoding\n");
- CString str2;
- str2.Format(str, m_dstScreenSize.cx, m_dstScreenSize.cy);
- f.WriteString(str2);
+ f.WriteString(str);
str = (type == Subtitle::SSA)
? _T("Style: %s,%s,%d,&H%06x,&H%06x,&H%06x,&H%06x,%d,%d,%d,%.2f,%.2f,%d,%d,%d,%d,%d,%d\n")
diff --git a/src/Subtitles/SubtitleHelpers.cpp b/src/Subtitles/SubtitleHelpers.cpp index 8dcea6ad3..c44567675 100644 --- a/src/Subtitles/SubtitleHelpers.cpp +++ b/src/Subtitles/SubtitleHelpers.cpp @@ -1,6 +1,6 @@ /* * (C) 2003-2006 Gabest - * (C) 2006-2014 see Authors.txt + * (C) 2006-2015 see Authors.txt * * This file is part of MPC-HC. * @@ -109,12 +109,12 @@ void Subtitle::GetSubFileNames(CString fn, const CAtlArray<CString>& paths, CAtl HANDLE hFile = FindFirstFile(path + title + _T("*"), &wfd); if (hFile != INVALID_HANDLE_VALUE) { do { - CString fn = path + wfd.cFileName; + CString fn2 = path + wfd.cFileName; if (std::regex_match(&wfd.cFileName[titleLength], reSub)) { - subs.AddTail(fn); + subs.AddTail(fn2); } else if (std::regex_match(&wfd.cFileName[titleLength], reVid)) { // Convert to lower-case and cut the extension for easier matching - vids.AddTail(fn.Left(fn.ReverseFind(_T('.'))).MakeLower()); + vids.AddTail(fn2.Left(fn2.ReverseFind(_T('.'))).MakeLower()); } } while (FindNextFile(hFile, &wfd)); @@ -123,8 +123,8 @@ void Subtitle::GetSubFileNames(CString fn, const CAtlArray<CString>& paths, CAtl POSITION posSub = subs.GetHeadPosition(); while (posSub) { - CString& fn = subs.GetNext(posSub); - CString fnlower = fn; + CString& fn2 = subs.GetNext(posSub); + CString fnlower = fn2; fnlower.MakeLower(); // Check if there is an exact match for another video file @@ -139,7 +139,7 @@ void Subtitle::GetSubFileNames(CString fn, const CAtlArray<CString>& paths, CAtl if (!bMatchAnotherVid) { SubFile f; - f.fn = fn; + f.fn = fn2; ret.Add(f); } } diff --git a/src/Subtitles/USFSubtitles.cpp b/src/Subtitles/USFSubtitles.cpp index 737dad5e0..dedd644c1 100644 --- a/src/Subtitles/USFSubtitles.cpp +++ b/src/Subtitles/USFSubtitles.cpp @@ -458,9 +458,9 @@ bool CUSFSubtitles::ParseUSFSubtitles(CComPtr<IXMLDOMNode> pNode) // metadata
BeginEnumChildren(pNode, pChild) {
- DeclareNameAndValue(pChild, name, val);
+ DeclareNameAndValue(pChild, childName, childVal);
- if (name == L"metadata") {
+ if (childName == L"metadata") {
ParseMetadata(pChild, metadata);
}
}
@@ -469,13 +469,13 @@ bool CUSFSubtitles::ParseUSFSubtitles(CComPtr<IXMLDOMNode> pNode) // styles
BeginEnumChildren(pNode, pChild) {
- DeclareNameAndValue(pChild, name, val);
+ DeclareNameAndValue(pChild, childName, childVal);
- if (name == L"styles") {
+ if (childName == L"styles") {
BeginEnumChildren(pChild, pGrandChild) { // :)
- DeclareNameAndValue(pGrandChild, name, val);
+ DeclareNameAndValue(pGrandChild, grandChildName, grandChildVal);
- if (name == L"style") {
+ if (grandChildName == L"style") {
CAutoPtr<style_t> s(DEBUG_NEW style_t);
if (s) {
ParseStyle(pGrandChild, s);
@@ -491,13 +491,13 @@ bool CUSFSubtitles::ParseUSFSubtitles(CComPtr<IXMLDOMNode> pNode) // effects
BeginEnumChildren(pNode, pChild) {
- DeclareNameAndValue(pChild, name, val);
+ DeclareNameAndValue(pChild, childName, childVal);
- if (name == L"effects") {
+ if (childName == L"effects") {
BeginEnumChildren(pChild, pGrandChild) { // :)
- DeclareNameAndValue(pGrandChild, name, val);
+ DeclareNameAndValue(pGrandChild, grandChildName, grandChildVal);
- if (name == L"effect") {
+ if (grandChildName == L"effect") {
CAutoPtr<effect_t> e(DEBUG_NEW effect_t);
if (e) {
ParseEffect(pGrandChild, e);
@@ -513,13 +513,13 @@ bool CUSFSubtitles::ParseUSFSubtitles(CComPtr<IXMLDOMNode> pNode) // subtitles
BeginEnumChildren(pNode, pChild) {
- DeclareNameAndValue(pChild, name, val);
+ DeclareNameAndValue(pChild, childName, childVal);
- if (name == L"subtitles") {
+ if (childName == L"subtitles") {
BeginEnumChildren(pChild, pGrandChild) { // :)
- DeclareNameAndValue(pGrandChild, name, val);
+ DeclareNameAndValue(pGrandChild, grandChildName, grandChildVal);
- if (name == L"subtitle") {
+ if (grandChildName == L"subtitle") {
CStringW sstart = GetAttrib(L"start", pGrandChild);
CStringW sstop = GetAttrib(L"stop", pGrandChild);
CStringW sduration = GetAttrib(L"duration", pGrandChild);
@@ -563,13 +563,13 @@ void CUSFSubtitles::ParseMetadata(CComPtr<IXMLDOMNode> pNode, metadata_t& m) m.comment = GetText(pNode);
} else if (name == L"author") {
BeginEnumChildren(pNode, pChild) {
- DeclareNameAndValue(pChild, name, val);
+ DeclareNameAndValue(pChild, childName, childVal);
- if (name == L"name") {
+ if (childName == L"name") {
m.author.name = GetText(pChild);
- } else if (name == L"email") {
+ } else if (childName == L"email") {
m.author.email = GetText(pChild);
- } else if (name == L"url") {
+ } else if (childName == L"url") {
m.author.url = GetText(pChild);
}
}
@@ -646,9 +646,9 @@ void CUSFSubtitles::ParseEffect(CComPtr<IXMLDOMNode> pNode, effect_t* e) e->name = GetAttrib(L"name", pNode);
} else if (name == L"keyframes") {
BeginEnumChildren(pNode, pChild) {
- DeclareNameAndValue(pChild, name, val);
+ DeclareNameAndValue(pChild, childName, childVal);
- if (name == L"keyframe") {
+ if (childName == L"keyframe") {
CAutoPtr<keyframe_t> k(DEBUG_NEW keyframe_t);
if (k) {
ParseKeyframe(pChild, k);
|