Skip to content

Commit

Permalink
Don't include all of the standard namespace. (libmythtv/decoders)
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 4055915 commit 990c37b
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 24 deletions.
19 changes: 9 additions & 10 deletions mythtv/libs/libmythtv/decoders/avformatdecoder.cpp
Expand Up @@ -5,7 +5,6 @@
#include <cstdint>
#include <iostream>
#include <unistd.h>
using namespace std;

#include <QTextCodec>
#include <QFileInfo>
Expand Down Expand Up @@ -654,7 +653,7 @@ bool AvFormatDecoder::DoFastForward(long long desiredFrame, bool discardFrames)
m_framesRead = m_lastKey;

normalframes = (exactseeks) ? desiredFrame - m_framesPlayed : 0;
normalframes = max(normalframes, 0);
normalframes = std::max(normalframes, 0);
m_noDtsHack = false;
}
else
Expand Down Expand Up @@ -1749,7 +1748,7 @@ void AvFormatDecoder::UpdateATSCCaptionTracks(void)

uint pidx = 0;
uint sidx = 0;
std::array<map<int,uint>,2> lang_cc_cnt;
std::array<std::map<int,uint>,2> lang_cc_cnt;
while (true)
{
bool pofr = pidx >= (uint)m_pmtTracks.size();
Expand Down Expand Up @@ -1969,9 +1968,9 @@ int AvFormatDecoder::ScanStreams(bool novideo)
m_selectedTrack[kTrackTypeVideo].m_av_stream_index = -1;
m_fps = 0;
}
map<int,uint> lang_sub_cnt;
std::map<int,uint> lang_sub_cnt;
uint subtitleStreamCount = 0;
map<int,uint> lang_aud_cnt;
std::map<int,uint> lang_aud_cnt;
uint audioStreamCount = 0;

if (m_ringBuffer && m_ringBuffer->IsDVD() &&
Expand Down Expand Up @@ -2341,8 +2340,8 @@ int AvFormatDecoder::ScanStreams(bool novideo)
m_avcParser->Reset();

QSize dim = get_video_dim(*enc);
int width = max(dim.width(), 16);
int height = max(dim.height(), 16);
int width = std::max(dim.width(), 16);
int height = std::max(dim.height(), 16);
QString dec = "ffmpeg";
uint thread_count = 1;
QString codecName;
Expand Down Expand Up @@ -3039,7 +3038,7 @@ void AvFormatDecoder::HandleGopStart(
if (reset_kfd)
{
m_keyframeDist = tempKeyFrameDist;
m_maxKeyframeDist = max(m_keyframeDist, m_maxKeyframeDist);
m_maxKeyframeDist = std::max(m_keyframeDist, m_maxKeyframeDist);

m_parent->SetKeyframeDistance(m_keyframeDist);

Expand Down Expand Up @@ -3602,7 +3601,7 @@ bool AvFormatDecoder::ProcessVideoFrame(AVStream *Stream, AVFrame *AvFrame)
// frames, without an intervening ATSC frame, to cause a switch back to
// considering SCTE frames. The number 10 is somewhat arbitrarily chosen.

uint cc_len = static_cast<uint>(max(AvFrame->scte_cc_len,0));
uint cc_len = static_cast<uint>(std::max(AvFrame->scte_cc_len,0));
uint8_t *cc_buf = AvFrame->scte_cc_buf;
bool scte = true;

Expand All @@ -3613,7 +3612,7 @@ bool AvFormatDecoder::ProcessVideoFrame(AVStream *Stream, AVFrame *AvFrame)
// If both ATSC and SCTE caption data are available, prefer ATSC
if ((AvFrame->atsc_cc_len > 0) || m_ignoreScte)
{
cc_len = static_cast<uint>(max(AvFrame->atsc_cc_len, 0));
cc_len = static_cast<uint>(std::max(AvFrame->atsc_cc_len, 0));
cc_buf = AvFrame->atsc_cc_buf;
scte = false;
// If we explicitly saw ATSC, then reset ignore_scte count.
Expand Down
19 changes: 9 additions & 10 deletions mythtv/libs/libmythtv/decoders/decoderbase.cpp
@@ -1,6 +1,5 @@

#include <algorithm>
using namespace std;

#include "mythconfig.h"

Expand Down Expand Up @@ -471,8 +470,8 @@ bool DecoderBase::FindPosition(long long desired_value, bool search_adjusted,
upper++;
}
// keep in bounds
lower = max(lower, 0LL);
upper = min(upper, size - 1LL);
lower = std::max(lower, 0LL);
upper = std::min(upper, size - 1LL);

upper_bound = upper;
lower_bound = lower;
Expand Down Expand Up @@ -565,7 +564,7 @@ bool DecoderBase::DoRewind(long long desiredFrame, bool discardFrames)
// And flush pre-seek frame if we are allowed to and need to..
int normalframes = (uint64_t)(desiredFrame - (m_framesPlayed - 1)) > m_seekSnap
? desiredFrame - m_framesPlayed : 0;
normalframes = max(normalframes, 0);
normalframes = std::max(normalframes, 0);
SeekReset(m_lastKey, normalframes, true, discardFrames);

if (discardFrames || (m_ringBuffer && m_ringBuffer->IsDisc()))
Expand Down Expand Up @@ -728,7 +727,7 @@ bool DecoderBase::DoFastForward(long long desiredFrame, bool discardFrames)
// that point the decoding is more than one frame ahead of display.
if (desiredFrame+1 < m_framesPlayed)
return DoRewind(desiredFrame, discardFrames);
desiredFrame = max(desiredFrame, m_framesPlayed);
desiredFrame = std::max(desiredFrame, m_framesPlayed);

// Save rawframe state, for later restoration...
bool oldrawstate = m_getRawFrames;
Expand Down Expand Up @@ -796,7 +795,7 @@ bool DecoderBase::DoFastForward(long long desiredFrame, bool discardFrames)
// And flush pre-seek frame if we are allowed to and need to..
int normalframes = (uint64_t)(desiredFrame - (m_framesPlayed - 1)) > m_seekSnap
? desiredFrame - m_framesPlayed : 0;
normalframes = max(normalframes, 0);
normalframes = std::max(normalframes, 0);
SeekReset(m_lastKey, normalframes, needflush, discardFrames);

if (discardFrames || m_transcoding)
Expand Down Expand Up @@ -961,7 +960,7 @@ int DecoderBase::SetTrack(uint Type, int TrackNo)
if (TrackNo >= static_cast<int>(m_tracks[Type].size()))
return -1;

m_currentTrack[Type] = max(-1, TrackNo);
m_currentTrack[Type] = std::max(-1, TrackNo);
if (m_currentTrack[Type] < 0)
{
m_selectedTrack[Type].m_av_stream_index = -1;
Expand Down Expand Up @@ -995,9 +994,9 @@ int DecoderBase::ChangeTrack(uint Type, int Dir)
if (size)
{
if (Dir > 0)
next_track = (max(-1, m_currentTrack[Type]) + 1) % size;
next_track = (std::max(-1, m_currentTrack[Type]) + 1) % size;
else
next_track = (max(+0, m_currentTrack[Type]) + size - 1) % size;
next_track = (std::max(+0, m_currentTrack[Type]) + size - 1) % size;
}
return SetTrack(Type, next_track);
}
Expand All @@ -1009,7 +1008,7 @@ int DecoderBase::NextTrack(uint Type)
int next_track = -1;
int size = static_cast<int>(m_tracks[Type].size());
if (size)
next_track = (max(0, m_currentTrack[Type]) + 1) % size;
next_track = (std::max(0, m_currentTrack[Type]) + 1) % size;
return next_track;
}

Expand Down
7 changes: 3 additions & 4 deletions mythtv/libs/libmythtv/decoders/decoderbase.h
Expand Up @@ -4,7 +4,6 @@
#include <array>
#include <cstdint>
#include <vector>
using namespace std;

#include "io/mythmediabuffer.h"
#include "remoteencoder.h"
Expand Down Expand Up @@ -109,7 +108,7 @@ class StreamInfo
return (this->m_stream_id < b.m_stream_id);
}
};
using sinfo_vec_t = vector<StreamInfo>;
using sinfo_vec_t = std::vector<StreamInfo>;

inline AVRational AVRationalInit(int num, int den = 1) {
AVRational result;
Expand Down Expand Up @@ -323,7 +322,7 @@ class DecoderBase
MarkTypes m_positionMapType {MARK_UNSET};

mutable QMutex m_positionMapLock {QMutex::Recursive};
vector<PosMapEntry> m_positionMap;
std::vector<PosMapEntry> m_positionMap;
frm_pos_map_t m_frameToDurMap; // guarded by m_positionMapLock
frm_pos_map_t m_durToFrameMap; // guarded by m_positionMapLock
mutable QDateTime m_lastPositionMapUpdate; // guarded by m_positionMapLock
Expand Down Expand Up @@ -355,7 +354,7 @@ class DecoderBase
std::array<StreamInfo, kTrackTypeCount> m_selectedTrack;

/// language preferences for auto-selection of streams
vector<int> m_languagePreference;
std::vector<int> m_languagePreference;
MythCodecContext *m_mythCodecCtx { nullptr };
VideoDisplayProfile m_videoDisplayProfile;

Expand Down

0 comments on commit 990c37b

Please sign in to comment.