Skip to content

Commit

Permalink
reSharper: Remove redundant casts
Browse files Browse the repository at this point in the history
  • Loading branch information
jcdr428 committed Aug 9, 2023
1 parent cdc9750 commit 5386d1a
Show file tree
Hide file tree
Showing 22 changed files with 43 additions and 43 deletions.
6 changes: 3 additions & 3 deletions libmediation/types/types.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -461,12 +461,12 @@ char* strnstr(char* s1, const char* s2, const size_t len)
size_t l1 = len;
const size_t l2 = strlen(s2);
if (!l2)
return (char*)s1;
return s1;
while (l1 >= l2)
{
l1--;
if (!memcmp(s1, s2, l2))
return (char*)s1;
return s1;
s1++;
}
return nullptr;
Expand All @@ -476,7 +476,7 @@ uint32_t random32()
{
static std::random_device dev;
static std::minstd_rand raand(dev());
return static_cast<std::uint32_t>(raand());
return raand();
}

#ifdef _WIN32
Expand Down
2 changes: 1 addition & 1 deletion tsMuxer/aacStreamReader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ const std::string AACStreamReader::getStreamInfo()
{
std::ostringstream str;
str << "Sample Rate: " << m_sample_rate / 1000 << "KHz ";
str << "Channels: " << (int)m_channels;
str << "Channels: " << m_channels;
return str.str();
}

Expand Down
4 changes: 2 additions & 2 deletions tsMuxer/ac3Codec.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -555,9 +555,9 @@ const std::string AC3Codec::getStreamInfo()
channels = mlp.m_channels;

if (m_lfeon)
str << (int)(channels - 1) << ".1";
str << channels - 1 << ".1";
else
str << (int)channels;
str << channels;
return str.str();
}

Expand Down
8 changes: 4 additions & 4 deletions tsMuxer/bitStream.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,12 @@ void updateBits(const BitStreamReader& bitReader, const int bitOffset, const int

void updateBits(uint8_t* buffer, const int bitOffset, const int bitLen, const int value)
{
uint8_t* ptr = (uint8_t*)buffer + bitOffset / 8;
uint8_t* ptr = buffer + bitOffset / 8;
BitStreamWriter bitWriter{};
const int byteOffset = bitOffset % 8;
bitWriter.setBuffer(ptr, ptr + (bitLen / 8 + 5));

const uint8_t* ptr_end = (uint8_t*)buffer + (bitOffset + bitLen) / 8;
const uint8_t* ptr_end = buffer + (bitOffset + bitLen) / 8;
const int endBitsPostfix = 8 - ((bitOffset + bitLen) % 8);

if (byteOffset > 0)
Expand All @@ -34,10 +34,10 @@ void updateBits(uint8_t* buffer, const int bitOffset, const int bitLen, const in

void moveBits(uint8_t* buffer, const int oldBitOffset, const int newBitOffset, int len)
{
uint8_t* src = (uint8_t*)buffer + (oldBitOffset >> 3);
uint8_t* src = buffer + (oldBitOffset >> 3);
BitStreamReader reader{};
reader.setBuffer(src, src + len / 8 + 1);
uint8_t* dst = (uint8_t*)buffer + (newBitOffset >> 3);
uint8_t* dst = buffer + (newBitOffset >> 3);
BitStreamWriter writer{};
writer.setBuffer(dst, dst + len / 8 + 1);
writer.skipBits(newBitOffset % 8);
Expand Down
2 changes: 1 addition & 1 deletion tsMuxer/combinedH264Demuxer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ void CombinedH264Reader::fillPids(const PIDSet& acceptedPIDs, const int pid)
CombinedH264Demuxer::CombinedH264Demuxer(const BufferedReaderManager& readManager, const char* streamName)
: AbstractDemuxer(), CombinedH264Reader(), m_readManager(readManager)
{
m_bufferedReader = (const_cast<BufferedReaderManager&>(m_readManager)).getReader(streamName);
m_bufferedReader = m_readManager.getReader(streamName);
m_readerID = m_bufferedReader->createReader(MAX_TMP_BUFFER_SIZE);
if (m_bufferedReader == nullptr)
THROW(ERR_COMMON,
Expand Down
2 changes: 1 addition & 1 deletion tsMuxer/dtsStreamReader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -595,7 +595,7 @@ int DTSStreamReader::decodeFrame(uint8_t* buff, uint8_t* end, int& skipBytes, in
const auto exHeader = reinterpret_cast<uint8_t*>(curPtr32);
const int dataRest = static_cast<int>(buff + i_frame_size - exHeader);
const int frameSize =
(int)((exHeader[0] << 2) + (exHeader[1] >> 6) - 4); // remove 4 bytes of ext world
(exHeader[0] << 2) + (exHeader[1] >> 6) - 4; // remove 4 bytes of ext world
if (dataRest - frameSize == 0 || dataRest - frameSize == 1)
{
m_dtsEsChannels = (static_cast<int>(exHeader[1]) >> 2) & 0x07;
Expand Down
2 changes: 1 addition & 1 deletion tsMuxer/ioContextDemuxer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ IOContextDemuxer::IOContextDemuxer(const BufferedReaderManager& readManager)
: tracks(), m_readManager(readManager), m_lastReadRez(0)
{
m_lastProcessedBytes = 0;
m_bufferedReader = (const_cast<BufferedReaderManager&>(m_readManager)).getReader("");
m_bufferedReader = m_readManager.getReader("");
m_readerID = m_bufferedReader->createReader(TS_FRAME_SIZE);
m_curPos = m_bufEnd = nullptr;
m_processedBytes = 0;
Expand Down
4 changes: 2 additions & 2 deletions tsMuxer/lpcmStreamReader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -616,9 +616,9 @@ const std::string LPCMStreamReader::getStreamInfo()
str << "Sample Rate: " << m_freq / 1000 << "KHz ";
str << "Channels: ";
if (m_lfeExists)
str << (int)m_channels - 1 << ".1";
str << m_channels - 1 << ".1";
else
str << (int)m_channels;
str << m_channels;
str << " Bits per sample: " << m_bitsPerSample << "bit";
return str.str();
}
Expand Down
4 changes: 2 additions & 2 deletions tsMuxer/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -220,13 +220,13 @@ string getBlurayStreamDir(const string& mplsName)
{
string dirName = extractFileDir(mplsName);
dirName = toNativeSeparators(dirName);
size_t tmp = dirName.substr(0, (size_t)(dirName.size() - 1)).find_last_of(getDirSeparator());
size_t tmp = dirName.substr(0, dirName.size() - 1).find_last_of(getDirSeparator());
if (tmp != string::npos)
{
dirName = dirName.substr(0, tmp + 1);
if (strEndWith(dirName, string("BACKUP") + getDirSeparator()))
{
tmp = dirName.substr(0, (size_t)(dirName.size() - 1)).find_last_of(getDirSeparator());
tmp = dirName.substr(0, dirName.size() - 1).find_last_of(getDirSeparator());
if (tmp == string::npos)
return "";
dirName = dirName.substr(0, tmp + 1);
Expand Down
2 changes: 1 addition & 1 deletion tsMuxer/matroskaDemuxer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -466,7 +466,7 @@ void MatroskaDemuxer::decompressData(uint8_t *data, const int size)
return;

zstream.avail_in = size;
zstream.next_in = (Bytef *)data;
zstream.next_in = data;
int curSize = size;
do
{
Expand Down
4 changes: 2 additions & 2 deletions tsMuxer/metaDemuxer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -429,7 +429,7 @@ int METADemuxer::addStream(const string codec, const string& codecStreamName, co
}
else
{
dataReader = (const_cast<BufferedReaderManager&>(m_readManager)).getReader(fileList[0].c_str());
dataReader = m_readManager.getReader(fileList[0].c_str());
}
}
else if (strEndWith(tmpname, ".ts") || strEndWith(tmpname, ".m2ts") || strEndWith(tmpname, ".mts") ||
Expand Down Expand Up @@ -482,7 +482,7 @@ int METADemuxer::addStream(const string codec, const string& codecStreamName, co
}
else
{
dataReader = (const_cast<BufferedReaderManager&>(m_readManager)).getReader(fileList[0].c_str());
dataReader = m_readManager.getReader(fileList[0].c_str());
}
if (dataReader == nullptr)
{
Expand Down
2 changes: 1 addition & 1 deletion tsMuxer/movDemuxer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1280,7 +1280,7 @@ int MovDemuxer::mov_read_extradata(const MOVAtom atom)
uint8_t* buf = st->codec_priv + oldSize;

// !!! PROBLEM WITH MP4 SIZE ABOVE 4GB: TODO...
AV_WB32(buf, (uint32_t)(atom.size + 8));
AV_WB32(buf, static_cast<uint32_t>(atom.size) + 8);
AV_WB32(buf + 4, my_htonl(atom.type));
get_buffer(buf + 8, static_cast<int>(atom.size));
st->codec_priv_size = static_cast<int>(newSize);
Expand Down
2 changes: 1 addition & 1 deletion tsMuxer/mpegAudioStreamReader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ const std::string MpegAudioStreamReader::getStreamInfo()
std::ostringstream str;
str << "Bitrate: " << m_bit_rate / 1000 << "Kbps ";
str << "Sample Rate: " << m_sample_rate / 1000 << "KHz ";
str << "Channels: " << (int)m_nb_channels << " ";
str << "Channels: " << m_nb_channels << " ";
str << "Layer: " << m_layer;
return str.str();
}
2 changes: 1 addition & 1 deletion tsMuxer/mpegVideo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@ uint8_t* MPEGSequenceHeader::deserializeExtension(BitStreamReader& bitReader)

uint8_t* MPEGSequenceHeader::deserializeMatrixExtension(BitStreamReader& bitReader)
{
return (uint8_t*)bitReader.getBuffer();
return bitReader.getBuffer();
}

uint8_t* MPEGSequenceHeader::deserializeDisplayExtension(BitStreamReader& bitReader)
Expand Down
4 changes: 2 additions & 2 deletions tsMuxer/nalUnits.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1283,12 +1283,12 @@ int SliceUnit::deserialize(uint8_t* buffer, uint8_t* end, const std::map<uint32_
void NALUnit::updateBits(const int bitOffset, const int bitLen, const int value) const
{
// uint8_t* ptr = m_getbitContextBuffer + (bitOffset/8);
uint8_t* ptr = (uint8_t*)bitReader.getBuffer() + bitOffset / 8;
uint8_t* ptr = bitReader.getBuffer() + bitOffset / 8;
BitStreamWriter bitWriter{};
const int byteOffset = bitOffset % 8;
bitWriter.setBuffer(ptr, ptr + (bitLen / 8 + 5));

const uint8_t* ptr_end = (uint8_t*)bitReader.getBuffer() + (bitOffset + bitLen) / 8;
const uint8_t* ptr_end = bitReader.getBuffer() + (bitOffset + bitLen) / 8;
const int endBitsPostfix = 8 - ((bitOffset + bitLen) % 8);

if (byteOffset > 0)
Expand Down
2 changes: 1 addition & 1 deletion tsMuxer/programStreamDemuxer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ ProgramStreamDemuxer::ProgramStreamDemuxer(const BufferedReaderManager& readMana
{
memset(m_psm_es_type, 0, sizeof(m_psm_es_type));
memset(m_lpcpHeaderAdded, 0, sizeof(m_lpcpHeaderAdded));
m_bufferedReader = (const_cast<BufferedReaderManager&>(m_readManager)).getReader(m_streamName.c_str());
m_bufferedReader = m_readManager.getReader(m_streamName.c_str());
m_readerID = m_bufferedReader->createReader(MAX_PES_HEADER_SIZE);
m_lastReadRez = 0;
m_lastPesLen = 0;
Expand Down
10 changes: 5 additions & 5 deletions tsMuxer/psgStreamReader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -430,8 +430,8 @@ int PGSStreamReader::readPacket(AVPacket& avPacket)
PGSRenderedBlock& block = m_renderedBlocks[0];
avPacket.data = block.data;
avPacket.size = FFMIN(MAX_AV_PACKET_SIZE, block.len);
avPacket.pts = (int64_t)(block.pts * INT_FREQ_TO_TS_FREQ);
avPacket.dts = (int64_t)(block.dts * INT_FREQ_TO_TS_FREQ);
avPacket.pts = block.pts * INT_FREQ_TO_TS_FREQ;
avPacket.dts = block.dts * INT_FREQ_TO_TS_FREQ;
block.data += avPacket.size;
block.len -= avPacket.size;
if (block.len == 0)
Expand Down Expand Up @@ -593,7 +593,7 @@ int PGSStreamReader::readPacket(AVPacket& avPacket)
return NEED_MORE_DATA;
}
const uint8_t segment_type = *m_curPos;
const auto segment_len = (uint16_t)AV_RB16(m_curPos + 1);
const auto segment_len = AV_RB16(m_curPos + 1);
if (m_bufEnd - m_curPos < 3ll + segment_len)
{
m_tmpBufferLen = m_bufEnd - m_curPos;
Expand Down Expand Up @@ -722,7 +722,7 @@ int PGSStreamReader::flushPacket(AVPacket& avPacket) { return 0; }

void PGSStreamReader::setBuffer(uint8_t* data, const int dataLen, bool lastBlock)
{
if ((size_t)(m_tmpBufferLen + dataLen) > m_tmpBuffer.size())
if (m_tmpBufferLen + dataLen > m_tmpBuffer.size())
m_tmpBuffer.resize(m_tmpBufferLen + dataLen);

if (!m_tmpBuffer.empty())
Expand Down Expand Up @@ -792,7 +792,7 @@ void PGSStreamReader::intDecodeStream(uint8_t* buffer, const size_t len)
}

const uint8_t segment_type = *curPos;
const auto segment_len = (uint16_t)AV_RB16(curPos + 1);
const auto segment_len = AV_RB16(curPos + 1);
if (bufEnd - curPos < 3ll + segment_len)
return;

Expand Down
10 changes: 5 additions & 5 deletions tsMuxer/textSubtitles.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -422,12 +422,12 @@ uint8_t* TextToPGSConverter::doConvert(std::string& text, const TextAnimation& a
{
palette_update_flag = 1;
m_paletteVersion++;
curPos += composePresentationSegment(curPos, CompositionMode::Update, (int64_t)updateTime,
(int64_t)updateTime - windowsTransferTime, objectWindowTop, true, forced);
curPos += composePresentationSegment(curPos, CompositionMode::Update, updateTime,
updateTime - windowsTransferTime, objectWindowTop, true, forced);
curPos +=
composePaletteDefinition(buildPalette(toCurve(opacity)), curPos, (int64_t)updateTime - windowsTransferTime,
(int64_t)updateTime - windowsTransferTime);
curPos += composeEnd(curPos, (int64_t)updateTime - 90, (int64_t)updateTime - 90);
composePaletteDefinition(buildPalette(toCurve(opacity)), curPos, updateTime - windowsTransferTime,
updateTime - windowsTransferTime);
curPos += composeEnd(curPos, updateTime - 90, updateTime - 90);

updateTime = static_cast<int64_t>(alignToGrid(updateTime + fpsPts));
opacity -= opacityOutDelta;
Expand Down
2 changes: 1 addition & 1 deletion tsMuxer/tsDemuxer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ bool isM2TSExt(const std::string& streamName)
TSDemuxer::TSDemuxer(const BufferedReaderManager& readManager, const char* streamName) : m_readManager(readManager)
{
m_firstPCRTime = -1;
m_bufferedReader = (const_cast<BufferedReaderManager&>(m_readManager)).getReader(streamName);
m_bufferedReader = m_readManager.getReader(streamName);
m_readerID = m_bufferedReader->createReader(TS_FRAME_SIZE);
if (m_bufferedReader == nullptr)
THROW(ERR_COMMON,
Expand Down
4 changes: 2 additions & 2 deletions tsMuxer/tsMuxer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -519,7 +519,7 @@ void TSMuxer::processM2TSPCR(const int64_t pcrVal, const int64_t pcrGAP)
const int m2tsFrameCnt = calcM2tsFrameCnt();
const int64_t hiResPCR = pcrVal * 300 - pcrGAP;
const uint64_t pcrValDif = hiResPCR - m_prevM2TSPCR; // m2ts pcr clock based on full 27Mhz counter
const double pcrIncPerFrame = static_cast<double>(pcrValDif + 0.1) / static_cast<double>(m2tsFrameCnt);
const double pcrIncPerFrame = (pcrValDif + 0.1) / static_cast<double>(m2tsFrameCnt);

auto curM2TSPCR = static_cast<double>(m_prevM2TSPCR);
uint8_t* curPos;
Expand Down Expand Up @@ -1418,7 +1418,7 @@ void TSMuxer::setSubMode(AbstractMuxer* mainMuxer, const bool flushInterleavedBl
void TSMuxer::joinToMasterFile()
{
m_isExternalFile = true;
m_muxFile = dynamic_cast<TSMuxer*>(m_sublingMuxer)->getDstFile();
m_muxFile = m_sublingMuxer->getDstFile();
}

void TSMuxer::setMasterMode(AbstractMuxer* subMuxer, const bool flushInterleavedBlock)
Expand Down
4 changes: 2 additions & 2 deletions tsMuxer/vc1Parser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,12 +34,12 @@ static inline int decode012(BitStreamReader& bitReader)

void VC1Unit::updateBits(const int bitOffset, const int bitLen, const int value) const
{
uint8_t* ptr = (uint8_t*)bitReader.getBuffer() + bitOffset / 8;
uint8_t* ptr = bitReader.getBuffer() + bitOffset / 8;
BitStreamWriter bitWriter{};
const int byteOffset = bitOffset % 8;
bitWriter.setBuffer(ptr, ptr + (bitLen / 8 + 5));

const uint8_t* ptr_end = (uint8_t*)bitReader.getBuffer() + (bitOffset + bitLen) / 8;
const uint8_t* ptr_end = bitReader.getBuffer() + (bitOffset + bitLen) / 8;
const int endBitsPostfix = 8 - ((bitOffset + bitLen) % 8);

if (byteOffset > 0)
Expand Down
4 changes: 2 additions & 2 deletions tsMuxer/vvc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -63,12 +63,12 @@ int VvcUnit::deserialize()

void VvcUnit::updateBits(const int bitOffset, const int bitLen, const int value) const
{
uint8_t* ptr = (uint8_t*)m_reader.getBuffer() + bitOffset / 8;
uint8_t* ptr = m_reader.getBuffer() + bitOffset / 8;
BitStreamWriter bitWriter{};
const int byteOffset = bitOffset % 8;
bitWriter.setBuffer(ptr, ptr + (bitLen / 8 + 5));

const uint8_t* ptr_end = (uint8_t*)m_reader.getBuffer() + (bitOffset + bitLen) / 8;
const uint8_t* ptr_end = m_reader.getBuffer() + (bitOffset + bitLen) / 8;
const int endBitsPostfix = 8 - ((bitOffset + bitLen) % 8);

if (byteOffset > 0)
Expand Down

0 comments on commit 5386d1a

Please sign in to comment.