Skip to content

Commit

Permalink
Don't include all of the standard namespace. (mythcommflag)
Browse files Browse the repository at this point in the history
Including all of the standard namespace is considered bad practice. It
defeats the purpose of namespaces, and pollutes the global name table.
  • Loading branch information
linuxdude42 committed Oct 2, 2020
1 parent 4beae8e commit b233bfb
Show file tree
Hide file tree
Showing 14 changed files with 146 additions and 155 deletions.
6 changes: 3 additions & 3 deletions mythtv/programs/mythcommflag/BlankFrameDetector.cpp
Expand Up @@ -102,11 +102,11 @@ computeBlankMap(FrameAnalyzer::FrameMap *blankMap, long long nframes,
}

qsort(blankmedian, nblanks, sizeof(*blankmedian), sort_ascending_uchar);
blankno = min(nblanks - 1, (long long)roundf(nblanks * MEDIANPCTILE));
blankno = std::min(nblanks - 1, (long long)roundf(nblanks * MEDIANPCTILE));
uchar maxmedian = blankmedian[blankno];

qsort(blankstddev, nblanks, sizeof(*blankstddev), sort_ascending_float);
long long stddevno = min(nblanks - 1, (long long)roundf(nblanks * STDDEVPCTILE));
long long stddevno = std::min(nblanks - 1, (long long)roundf(nblanks * STDDEVPCTILE));
float maxstddev = blankstddev[stddevno];

/* Determine effective percentile ranges (for debugging). */
Expand Down Expand Up @@ -597,7 +597,7 @@ BlankFrameDetector::computeForLogoSurplus(
/* End of logo break includes beginning of blank-frame break. */
overlap = true;
m_breakMap.erase(jj);
m_breakMap.insert(iibb, max(iiee, jjee) - iibb);
m_breakMap.insert(iibb, std::max(iiee, jjee) - iibb);
}
else if (jjbb < iibb && iibb < jjee)
{
Expand Down
28 changes: 14 additions & 14 deletions mythtv/programs/mythcommflag/BorderDetector.cpp
Expand Up @@ -103,16 +103,16 @@ BorderDetector::getDimensions(const AVFrame *pgm, int pgmheight,
* TUNABLE: Margins to avoid noise at the extreme edges of the signal
* (VBI?). (Really, just a special case of VERTSLOP and HORIZSLOP, below.)
*/
const int VERTMARGIN = max(2, pgmheight * 1 / 60);
const int HORIZMARGIN = max(2, pgmwidth * 1 / 80);
const int VERTMARGIN = std::max(2, pgmheight * 1 / 60);
const int HORIZMARGIN = std::max(2, pgmwidth * 1 / 80);

/*
* TUNABLE: Slop to accommodate any jagged letterboxing/pillarboxing edges,
* or noise between edges and content. (Really, a more general case of
* VERTMARGIN and HORIZMARGIN, above.)
*/
const int VERTSLOP = max(kMaxLines, pgmheight * 1 / 120);
const int HORIZSLOP = max(kMaxLines, pgmwidth * 1 / 160);
const int VERTSLOP = std::max(kMaxLines, pgmheight * 1 / 120);
const int HORIZSLOP = std::max(kMaxLines, pgmwidth * 1 / 160);

struct timeval start {};
struct timeval end {};
Expand Down Expand Up @@ -153,7 +153,7 @@ BorderDetector::getDimensions(const AVFrame *pgm, int pgmheight,
continue; /* Exclude logo area from analysis. */

uchar val = pgm->data[0][rr * pgmwidth + cc];
int range = max(maxval, val) - min(minval, val) + 1;
int range = std::max(maxval, val) - std::min(minval, val) + 1;
if (range > kMaxRange)
{
if (outliers++ < MAXOUTLIERS)
Expand All @@ -177,8 +177,8 @@ BorderDetector::getDimensions(const AVFrame *pgm, int pgmheight,
found_left:
if (newcol != saved + 1 + HORIZSLOP)
{
newcol = min(maxcol1, saved + 1 + HORIZSLOP);
newwidth = max(0, maxcol1 - newcol);
newcol = std::min(maxcol1, saved + 1 + HORIZSLOP);
newwidth = std::max(0, maxcol1 - newcol);
left = true;
}

Expand All @@ -205,7 +205,7 @@ BorderDetector::getDimensions(const AVFrame *pgm, int pgmheight,
continue; /* Exclude logo area from analysis. */

uchar val = pgm->data[0][rr * pgmwidth + cc];
int range = max(maxval, val) - min(minval, val) + 1;
int range = std::max(maxval, val) - std::min(minval, val) + 1;
if (range > kMaxRange)
{
if (outliers++ < MAXOUTLIERS)
Expand All @@ -229,7 +229,7 @@ BorderDetector::getDimensions(const AVFrame *pgm, int pgmheight,
found_right:
if (newwidth != saved - mincol - HORIZSLOP)
{
newwidth = max(0, saved - mincol - HORIZSLOP);
newwidth = std::max(0, saved - mincol - HORIZSLOP);
right = true;
}

Expand Down Expand Up @@ -258,7 +258,7 @@ BorderDetector::getDimensions(const AVFrame *pgm, int pgmheight,
continue; /* Exclude logo area from analysis. */

uchar val = pgm->data[0][rr * pgmwidth + cc];
int range = max(maxval, val) - min(minval, val) + 1;
int range = std::max(maxval, val) - std::min(minval, val) + 1;
if (range > kMaxRange)
{
if (outliers++ < MAXOUTLIERS)
Expand All @@ -282,8 +282,8 @@ BorderDetector::getDimensions(const AVFrame *pgm, int pgmheight,
found_top:
if (newrow != saved + 1 + VERTSLOP)
{
newrow = min(maxrow1, saved + 1 + VERTSLOP);
newheight = max(0, maxrow1 - newrow);
newrow = std::min(maxrow1, saved + 1 + VERTSLOP);
newheight = std::max(0, maxrow1 - newrow);
top = true;
}

Expand All @@ -307,7 +307,7 @@ BorderDetector::getDimensions(const AVFrame *pgm, int pgmheight,
continue; /* Exclude logo area from analysis. */

uchar val = pgm->data[0][rr * pgmwidth + cc];
int range = max(maxval, val) - min(minval, val) + 1;
int range = std::max(maxval, val) - std::min(minval, val) + 1;
if (range > kMaxRange)
{
if (outliers++ < MAXOUTLIERS)
Expand All @@ -331,7 +331,7 @@ BorderDetector::getDimensions(const AVFrame *pgm, int pgmheight,
found_bottom:
if (newheight != saved - minrow - VERTSLOP)
{
newheight = max(0, saved - minrow - VERTSLOP);
newheight = std::max(0, saved - minrow - VERTSLOP);
bottom = true;
}

Expand Down
40 changes: 19 additions & 21 deletions mythtv/programs/mythcommflag/ClassicCommDetector.cpp
Expand Up @@ -10,8 +10,6 @@
#include <chrono> // for milliseconds
#include <thread> // for sleep_for

using namespace std;

// Qt headers
#include <QCoreApplication>
#include <QString>
Expand Down Expand Up @@ -175,9 +173,9 @@ void ClassicCommDetector::Init()
m_fps = m_player->GetFrameRate();

m_preRoll = (long long)(
max(int64_t(0), int64_t(m_recordingStartedAt.secsTo(m_startedAt))) * m_fps);
std::max(int64_t(0), int64_t(m_recordingStartedAt.secsTo(m_startedAt))) * m_fps);
m_postRoll = (long long)(
max(int64_t(0), int64_t(m_stopsAt.secsTo(m_recordingStopsAt))) * m_fps);
std::max(int64_t(0), int64_t(m_stopsAt.secsTo(m_recordingStopsAt))) * m_fps);

// CommDetectBorder's default value of 20 predates the change to use
// ffmpeg's lowres decoding capability by 5 years.
Expand Down Expand Up @@ -326,7 +324,7 @@ bool ClassicCommDetector::go()
m_logoDetector = new ClassicLogoDetector(this, m_width, m_height,
logoDetectBorder);

requiredHeadStart += max(
requiredHeadStart += std::max(
int64_t(0), int64_t(m_recordingStartedAt.secsTo(m_startedAt)));
requiredHeadStart += m_logoDetector->getRequiredAvailableBufferForSearch();

Expand Down Expand Up @@ -366,18 +364,18 @@ bool ClassicCommDetector::go()

if (m_showProgress)
{
cerr << "Finding Logo";
cerr.flush();
std::cerr << "Finding Logo";
std::cerr.flush();
}
LOG(VB_GENERAL, LOG_INFO, "Finding Logo");

m_logoInfoAvailable = m_logoDetector->searchForLogo(m_player);

if (m_showProgress)
{
cerr << "\b\b\b\b\b\b\b\b\b\b\b\b "
"\b\b\b\b\b\b\b\b\b\b\b\b";
cerr.flush();
std::cerr << "\b\b\b\b\b\b\b\b\b\b\b\b "
"\b\b\b\b\b\b\b\b\b\b\b\b";
std::cerr.flush();
}
}

Expand All @@ -398,9 +396,9 @@ bool ClassicCommDetector::go()
if (m_showProgress)
{
if (myTotalFrames)
cerr << "\r 0%/ \r" << flush;
std::cerr << "\r 0%/ \r" << std::flush;
else
cerr << "\r 0/ \r" << flush;
std::cerr << "\r 0/ \r" << std::flush;
}


Expand Down Expand Up @@ -520,13 +518,13 @@ bool ClassicCommDetector::go()
{
QString tmp = QString("\r%1%/%2fps \r")
.arg(percentage, 3).arg((int)flagFPS, 4);
cerr << qPrintable(tmp) << flush;
std::cerr << qPrintable(tmp) << std::flush;
}
else
{
QString tmp = QString("\r%1/%2fps \r")
.arg(currentFrameNumber, 6).arg((int)flagFPS, 4);
cerr << qPrintable(tmp) << flush;
std::cerr << qPrintable(tmp) << std::flush;
}
}

Expand Down Expand Up @@ -598,11 +596,11 @@ bool ClassicCommDetector::go()
#endif

if (myTotalFrames)
cerr << "\b\b\b\b\b\b \b\b\b\b\b\b";
std::cerr << "\b\b\b\b\b\b \b\b\b\b\b\b";
else
cerr << "\b\b\b\b\b\b\b\b\b\b\b\b\b "
"\b\b\b\b\b\b\b\b\b\b\b\b\b";
cerr.flush();
std::cerr << "\b\b\b\b\b\b\b\b\b\b\b\b\b "
"\b\b\b\b\b\b\b\b\b\b\b\b\b";
std::cerr.flush();
}

return true;
Expand Down Expand Up @@ -2519,12 +2517,12 @@ void ClassicCommDetector::logoDetectorBreathe()
}

void ClassicCommDetector::PrintFullMap(
ostream &out, const frm_dir_map_t *comm_breaks, bool verbose) const
std::ostream &out, const frm_dir_map_t *comm_breaks, bool verbose) const
{
if (verbose)
{
QByteArray tmp = FrameInfoEntry::GetHeader().toLatin1();
out << tmp.constData() << " mark" << endl;
out << tmp.constData() << " mark" << std::endl;
}

for (long long i = 1; i < m_curFrameNumber; i++)
Expand All @@ -2550,7 +2548,7 @@ void ClassicCommDetector::PrintFullMap(
out << "\n";
}

out << flush;
out << std::flush;
}

/* vim: set expandtab tabstop=4 shiftwidth=4: */
2 changes: 1 addition & 1 deletion mythtv/programs/mythcommflag/ClassicCommDetector.h
Expand Up @@ -62,7 +62,7 @@ class ClassicCommDetector : public CommDetectorBase
void requestCommBreakMapUpdate(void) override; // CommDetectorBase

void PrintFullMap(
ostream &out, const frm_dir_map_t *comm_breaks,
std::ostream &out, const frm_dir_map_t *comm_breaks,
bool verbose) const override; // CommDetectorBase

void logoDetectorBreathe();
Expand Down
24 changes: 12 additions & 12 deletions mythtv/programs/mythcommflag/ClassicLogoDetector.cpp
Expand Up @@ -318,44 +318,44 @@ void ClassicLogoDetector::DumpLogo(bool fromCurrentFrame,
if (!m_logoInfoAvailable)
return;

cerr << "\nLogo Data ";
std::cerr << "\nLogo Data ";
if (fromCurrentFrame)
cerr << "from current frame\n";
std::cerr << "from current frame\n";

cerr << "\n ";
std::cerr << "\n ";

for(unsigned int x = m_logoMinX - 2; x <= (m_logoMaxX + 2); x++)
cerr << (x % 10);
cerr << "\n";
std::cerr << (x % 10);
std::cerr << "\n";

for(unsigned int y = m_logoMinY - 2; y <= (m_logoMaxY + 2); y++)
{
QString tmp = QString("%1: ").arg(y, 3);
QString ba = tmp.toLatin1();
cerr << ba.constData();
std::cerr << ba.constData();
for(unsigned int x = m_logoMinX - 2; x <= (m_logoMaxX + 2); x++)
{
if (fromCurrentFrame)
{
cerr << scrPixels[framePtr[y * m_width + x] / 50];
std::cerr << scrPixels[framePtr[y * m_width + x] / 50];
}
else
{
switch (m_logoMask[y * m_width + x])
{
case 0:
case 2: cerr << " ";
case 2: std::cerr << " ";
break;
case 1: cerr << "*";
case 1: std::cerr << "*";
break;
case 3: cerr << ".";
case 3: std::cerr << ".";
break;
}
}
}
cerr << "\n";
std::cerr << "\n";
}
cerr.flush();
std::cerr.flush();
}


Expand Down
@@ -1,5 +1,4 @@
#include <algorithm>
using namespace std;

#include "ClassicSceneChangeDetector.h"
#include "Histogram.h"
Expand Down

0 comments on commit b233bfb

Please sign in to comment.