Skip to content

Commit

Permalink
[r6673] Subtitles: Замена макроса _countof на constexpr функцию std::…
Browse files Browse the repository at this point in the history
…size.

SubPic: Замена макроса _countof на constexpr функцию std::size.
  • Loading branch information
v0lt committed Nov 10, 2021
1 parent 6338bfa commit 84331a5
Show file tree
Hide file tree
Showing 6 changed files with 16 additions and 16 deletions.
4 changes: 2 additions & 2 deletions src/SubPic/DX9SubPic.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*
* (C) 2003-2006 Gabest
* (C) 2006-2018 see Authors.txt
* (C) 2006-2021 see Authors.txt
*
* This file is part of MPC-BE.
*
Expand Down Expand Up @@ -258,7 +258,7 @@ STDMETHODIMP CDX9SubPic::AlphaBlt(RECT* pSrc, RECT* pDst, SubPicDesc* pTarget)
{(float)dst.right, (float)dst.bottom, 0.5f, 2.0f, (float)src.right / w, (float)src.bottom / h},
};

for (ptrdiff_t i = 0; i < _countof(pVertices); i++) {
for (ptrdiff_t i = 0; i < std::size(pVertices); i++) {
pVertices[i].x -= 0.5f;
pVertices[i].y -= 0.5f;
}
Expand Down
4 changes: 2 additions & 2 deletions src/Subtitles/HdmvSub.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ CHdmvSub::~CHdmvSub()
SAFE_DELETE_ARRAY(m_pSegBuffer);
SAFE_DELETE_ARRAY(m_DefaultCLUT.Palette);

for (int i = 0; i < _countof(m_CLUT); i++) {
for (int i = 0; i < std::size(m_CLUT); i++) {
SAFE_DELETE_ARRAY(m_CLUT[i].Palette);
}
}
Expand Down Expand Up @@ -454,7 +454,7 @@ void CHdmvSub::ParseObject(CGolombBuffer* pGBuffer, USHORT nUnitSize)
}

SHORT object_id = pGBuffer->ReadShort();
if (object_id > _countof(m_ParsedObjects)) {
if (object_id > std::size(m_ParsedObjects)) {
TRACE_HDMVSUB(L"CHdmvSub::ParseObject() : FAILED, object_id - %d", object_id);
return;
}
Expand Down
6 changes: 3 additions & 3 deletions src/Subtitles/Rasterizer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -831,9 +831,9 @@ bool Rasterizer::Rasterize(int xsub, int ysub, int fBlur, double fGaussianBlur)

const tSpanBuffer* pOutline[2] = {&m_pOutlineData->mOutline, &m_pOutlineData->mWideOutline};

for (ptrdiff_t i = _countof(pOutline)-1; i >= 0; i--) {
auto it = pOutline[i]->cbegin();
auto itEnd = pOutline[i]->cend();
for (ptrdiff_t i = std::size(pOutline)-1; i >= 0; i--) {
auto it = pOutline[i]->cbegin();
auto itEnd = pOutline[i]->cend();
byte* buffer = (i == 0) ? m_pOverlayData->mpOverlayBufferBody : m_pOverlayData->mpOverlayBufferBorder;

for (; it != itEnd; ++it) {
Expand Down
8 changes: 4 additions & 4 deletions src/Subtitles/STS.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@ static struct htmlcolor {

CHtmlColorMap::CHtmlColorMap()
{
for (size_t i = 0; i < _countof(htmlcolors); i++) {
for (size_t i = 0; i < std::size(htmlcolors); i++) {
SetAt(htmlcolors[i].name, htmlcolors[i].color);
}
}
Expand Down Expand Up @@ -238,7 +238,7 @@ WCHAR* CharSetNames[] = {
L"BALTIC",
};

int CharSetLen = _countof(CharSetList);
int CharSetLen = std::size(CharSetList);

//

Expand Down Expand Up @@ -488,8 +488,8 @@ static bool OpenSubRipper(CTextFile* file, CSimpleTextSubtitle& ret, int CharSet
int hh1, mm1, ss1, ms1, hh2, mm2, ss2, ms2;
WCHAR msStr1[5] = {0}, msStr2[5] = {0};
int c = swscanf_s(buff, L"%d%c%d%c%d%4[^-] --> %d%c%d%c%d%4s\n",
&hh1, &sep, 1, &mm1, &sep, 1, &ss1, msStr1, _countof(msStr1),
&hh2, &sep, 1, &mm2, &sep, 1, &ss2, msStr2, _countof(msStr2));
&hh1, &sep, 1, &mm1, &sep, 1, &ss1, msStr1, std::size(msStr1),
&hh2, &sep, 1, &mm2, &sep, 1, &ss2, msStr2, std::size(msStr2));

if (c == 1) { // numbering
num = hh1;
Expand Down
4 changes: 2 additions & 2 deletions src/Subtitles/VobSubFile.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*
* (C) 2003-2006 Gabest
* (C) 2006-2020 see Authors.txt
* (C) 2006-2021 see Authors.txt
*
* This file is part of MPC-BE.
*
Expand Down Expand Up @@ -204,7 +204,7 @@ struct lang_type {

int find_lang(unsigned short id)
{
int lo = 0, hi = _countof(lang_tbl) - 1;
int lo = 0, hi = std::size(lang_tbl) - 1;

while (lo < hi) {
int mid = (lo + hi) >> 1;
Expand Down
6 changes: 3 additions & 3 deletions src/Subtitles/VobSubFileRipper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ void CVobSubFileRipper::Log(log_t type, LPCWSTR lpszFormat, ...)

va_list args;
va_start(args, lpszFormat);
_vstprintf_s(buff, _countof(buff), lpszFormat, args);
_vstprintf_s(buff, std::size(buff), lpszFormat, args);
va_end(args);

CString msg;
Expand Down Expand Up @@ -1075,7 +1075,7 @@ STDMETHODIMP CVobSubFileRipper::LoadParamFile(CString fn)

m_rd.selids[langnum] = true;
} else if (_istalpha(lang[0])) {
n = swscanf_s(lang, L"%s", langid, _countof(langid));
n = swscanf_s(lang, L"%s", langid, std::size(langid));
if (n != 1) {
break;
}
Expand Down Expand Up @@ -1205,7 +1205,7 @@ void VSFRipperData::Copy(VSFRipperData& rd)
PGC& src = rd.pgcs[i];
PGC& dst = pgcs[i];
dst.nAngles = src.nAngles;
for (size_t j = 0; j < _countof(dst.angles); j++) {
for (size_t j = 0; j < std::size(dst.angles); j++) {
dst.angles[j].Copy(src.angles[j]);
}
dst.iSelAngle = src.iSelAngle;
Expand Down

0 comments on commit 84331a5

Please sign in to comment.