Skip to content

Commit

Permalink
clang format check
Browse files Browse the repository at this point in the history
  • Loading branch information
jcdr428 committed Aug 9, 2023
1 parent 3adcc08 commit 5ee4fc2
Show file tree
Hide file tree
Showing 12 changed files with 63 additions and 70 deletions.
10 changes: 6 additions & 4 deletions libmediation/fs/osdep/directory_win32.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,12 +38,14 @@ uint64_t getFileSize(const std::string& fileName)
bool createDir(const std::string& dirName, const bool createParentDirs)
{
const bool ok = preCreateDir(
[](auto&& parentDir) {
[](auto&& parentDir)
{
return parentDir.empty() || parentDir[parentDir.size() - 1] == ':' || parentDir == "\\\\." ||
parentDir == R"(\\.\)" || // UNC patch prefix
(strStartWith(parentDir, R"(\\.\)") && parentDir[parentDir.size() - 1] == '}'); // UNC patch prefix
parentDir == R"(\\.\)" || // UNC patch prefix
(strStartWith(parentDir, R"(\\.\)") && parentDir[parentDir.size() - 1] == '}'); // UNC patch prefix
},
[](auto&& parentDir) {
[](auto&& parentDir)
{
if (CreateDirectory(toWide(parentDir).data(), nullptr) == 0)
{
if (GetLastError() != ERROR_ALREADY_EXISTS)
Expand Down
4 changes: 2 additions & 2 deletions libmediation/types/types.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -514,8 +514,8 @@ std::vector<wchar_t> toWide(const char* utf8Str, const int sz)
return mbtwc_wrapper(CP_UTF8, utf8Str, sz, static_cast<std::size_t>(requiredSiz));
}
/* utf8Str is not a valid UTF-8 string. try converting it according to the currently active code page in order
* to keep compatibility with meta files saved by older versions of the GUI which put the file name through
* QString::toLocal8Bit, which uses the ACP on Windows. */
* to keep compatibility with meta files saved by older versions of the GUI which put the file name through
* QString::toLocal8Bit, which uses the ACP on Windows. */
return fromAcp(utf8Str, sz);
}

Expand Down
6 changes: 3 additions & 3 deletions tsMuxer/ac3StreamReader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -185,9 +185,9 @@ int AC3StreamReader::readPacketTHD(AVPacket& avPacket)
{
LTRACE(LT_INFO, 2,
getCodecInfo().displayName
<< " stream (track " << m_streamIndex << "): overlapped frame detected at position "
<< floatToTime((avPacket.pts - PTS_CONST_OFFSET) / (double)INTERNAL_PTS_FREQ, ',')
<< ". Remove frame.");
<< " stream (track " << m_streamIndex << "): overlapped frame detected at position "
<< floatToTime((avPacket.pts - PTS_CONST_OFFSET) / (double)INTERNAL_PTS_FREQ, ',')
<< ". Remove frame.");
}

m_delayedAc3Packet = avPacket;
Expand Down
10 changes: 3 additions & 7 deletions tsMuxer/hevc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -50,9 +50,8 @@ int HevcUnit::deserialize()
nuh_layer_id = m_reader.getBits(6);
nuh_temporal_id_plus1 = m_reader.getBits(3);
if (nuh_temporal_id_plus1 == 0 ||
(nuh_temporal_id_plus1 != 1 &&
(nal_unit_type == NalType::VPS || nal_unit_type == NalType::SPS ||
nal_unit_type == NalType::EOS || nal_unit_type == NalType::EOB)))
(nuh_temporal_id_plus1 != 1 && (nal_unit_type == NalType::VPS || nal_unit_type == NalType::SPS ||
nal_unit_type == NalType::EOS || nal_unit_type == NalType::EOB)))
return 1;
return 0;
}
Expand Down Expand Up @@ -173,10 +172,7 @@ std::string HevcUnitWithProfile::getProfileString() const

// ------------------------- HevcVpsUnit -------------------

HevcVpsUnit::HevcVpsUnit()
: vps_id(0), num_units_in_tick(0), time_scale(0), num_units_in_tick_bit_pos(-1)
{
}
HevcVpsUnit::HevcVpsUnit() : vps_id(0), num_units_in_tick(0), time_scale(0), num_units_in_tick_bit_pos(-1) {}

int HevcVpsUnit::deserialize()
{
Expand Down
61 changes: 29 additions & 32 deletions tsMuxer/iso_writer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -112,12 +112,10 @@ void writeTimestamp(uint8_t *buffer, const time_t time)
bool canUse8BitUnicode(const std::string &utf8Str)
{
bool rv = true;
convertUTF::IterateUTF8Chars(utf8Str,
[&](auto c)
{
rv = (c < 0x100);
return rv;
});
convertUTF::IterateUTF8Chars(utf8Str, [&](auto c) {
rv = (c < 0x100);
return rv;
});
return rv;
}

Expand All @@ -142,35 +140,31 @@ std::vector<std::uint8_t> serializeDString(const std::string &str, const size_t
if (canUse8BitUnicode(utf8Str))
{
rv.push_back(8);
IterateUTF8Chars(utf8Str,
[&](auto c)
{
rv.push_back(c);
return rv.size() < maxHeaderAndContentLength;
});
IterateUTF8Chars(utf8Str, [&](auto c) {
rv.push_back(c);
return rv.size() < maxHeaderAndContentLength;
});
}
else
{
rv.push_back(16);
IterateUTF8Chars(utf8Str,
[&](auto c)
{
UTF16 high_surrogate, low_surrogate;
std::tie(high_surrogate, low_surrogate) = ConvertUTF32toUTF16(c);
const auto spaceLeft = maxHeaderAndContentLength - rv.size();
if ((spaceLeft < 2) || (low_surrogate && spaceLeft < 4))
{
return false;
}
rv.push_back(static_cast<uint8_t>(high_surrogate >> 8));
rv.push_back(static_cast<uint8_t>(high_surrogate));
if (low_surrogate)
{
rv.push_back(static_cast<uint8_t>(low_surrogate >> 8));
rv.push_back(static_cast<uint8_t>(low_surrogate));
}
return true;
});
IterateUTF8Chars(utf8Str, [&](auto c) {
UTF16 high_surrogate, low_surrogate;
std::tie(high_surrogate, low_surrogate) = ConvertUTF32toUTF16(c);
const auto spaceLeft = maxHeaderAndContentLength - rv.size();
if ((spaceLeft < 2) || (low_surrogate && spaceLeft < 4))
{
return false;
}
rv.push_back(static_cast<uint8_t>(high_surrogate >> 8));
rv.push_back(static_cast<uint8_t>(high_surrogate));
if (low_surrogate)
{
rv.push_back(static_cast<uint8_t>(low_surrogate >> 8));
rv.push_back(static_cast<uint8_t>(low_surrogate));
}
return true;
});
}
const auto contentLength = static_cast<uint8_t>(rv.size());
const auto paddingSize = maxHeaderAndContentLength - rv.size();
Expand Down Expand Up @@ -580,7 +574,10 @@ int64_t ISOFile::size() const { return m_entry ? m_entry->m_fileSize : -1; }
// ------------------------------ IsoWriter ----------------------------------

IsoWriter::IsoWriter(const IsoHeaderData &hdrData)
: m_impId(hdrData.impId), m_appId(hdrData.appId), m_volumeId(hdrData.volumeId), m_buffer{},
: m_impId(hdrData.impId),
m_appId(hdrData.appId),
m_volumeId(hdrData.volumeId),
m_buffer{},
m_currentTime(hdrData.fileTime),
m_metadataMappingFile(nullptr),
m_partitionStartAddress(0),
Expand Down
2 changes: 1 addition & 1 deletion tsMuxer/matroskaDemuxer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ int MatroskaDemuxer::matroska_parse_index()

while (res == 0)
{
if (!(id = ebml_peek_id(&level_up)))
if ((id = ebml_peek_id(&level_up)) == 0)
{
res = -BufferedReader::DATA_EOF;
break;
Expand Down
5 changes: 1 addition & 4 deletions tsMuxer/mpegVideo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -171,10 +171,7 @@ uint8_t* MPEGSequenceHeader::deserializeExtension(BitStreamReader& bitReader)
return skipProcessedBytes(bitReader);
}

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

uint8_t* MPEGSequenceHeader::deserializeDisplayExtension(BitStreamReader& bitReader)
{
Expand Down
9 changes: 5 additions & 4 deletions tsMuxer/simplePacketizerReader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,8 @@ int SimplePacketizerReader::flushPacket(AVPacket& avPacket)
int skipBeforeBytes = 0;
if (m_tmpBufferLen >= getHeaderLen())
{
const int size = decodeFrame(m_tmpBuffer.data(), m_tmpBuffer.data() + m_tmpBufferLen, skipBytes, skipBeforeBytes);
const int size =
decodeFrame(m_tmpBuffer.data(), m_tmpBuffer.data() + m_tmpBufferLen, skipBytes, skipBeforeBytes);
if (size + skipBytes + skipBeforeBytes <= 0 && size != NOT_ENOUGH_BUFFER)
return 0;
}
Expand Down Expand Up @@ -170,9 +171,9 @@ int SimplePacketizerReader::readPacket(AVPacket& avPacket)
{
LTRACE(LT_INFO, 2,
getCodecInfo().displayName
<< " stream (track " << m_streamIndex << "): bad frame detected at position"
<< floatToTime((avPacket.pts - PTS_CONST_OFFSET) / (double)INTERNAL_PTS_FREQ, ',')
<< ". Resync stream.");
<< " stream (track " << m_streamIndex << "): bad frame detected at position"
<< floatToTime((avPacket.pts - PTS_CONST_OFFSET) / (double)INTERNAL_PTS_FREQ, ',')
<< ". Resync stream.");
m_needSync = true;
return 0;
}
Expand Down
2 changes: 1 addition & 1 deletion tsMuxer/srtStreamReader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -241,7 +241,7 @@ uint8_t* SRTStreamReader::renderNextMessage(uint32_t& renderedLen)
}
return rez;
}
m_sourceText.pop(); // delete empty line (messages separator)
m_sourceText.pop(); // delete empty line (messages separator)
m_processedSize += m_origSize.front();
m_origSize.pop();
rez = m_srtRender->doConvert(m_renderedText, m_animation, m_inTime, m_outTime, renderedLen);
Expand Down
5 changes: 2 additions & 3 deletions tsMuxer/textSubtitles.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -420,9 +420,8 @@ uint8_t* TextToPGSConverter::doConvert(std::string& text, const TextAnimation& a
m_paletteVersion++;
curPos += composePresentationSegment(curPos, CompositionMode::Update, updateTime,
updateTime - windowsTransferTime, objectWindowTop, true, forced);
curPos +=
composePaletteDefinition(buildPalette(toCurve(opacity)), curPos, updateTime - windowsTransferTime,
updateTime - windowsTransferTime);
curPos += composePaletteDefinition(buildPalette(toCurve(opacity)), curPos, updateTime - windowsTransferTime,
updateTime - windowsTransferTime);
curPos += composeEnd(curPos, updateTime - 90, updateTime - 90);

updateTime = static_cast<int64_t>(alignToGrid(updateTime + fpsPts));
Expand Down
12 changes: 6 additions & 6 deletions tsMuxer/vc1StreamReader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -67,12 +67,12 @@ int VC1StreamReader::getTSDescriptor(uint8_t* dstBuff, bool blurayMode, bool hdm
return 0;

dstBuff[0] = static_cast<int>(TSDescriptorTag::REGISTRATION); // descriptor tag
dstBuff[1] = 0x06; // descriptor len
dstBuff[2] = 0x56; // "V"
dstBuff[3] = 0x43; // "C"
dstBuff[4] = 0x2D; // "-"
dstBuff[5] = 0x31; // "1"
dstBuff[6] = 0x01; // profile and level subdescriptor
dstBuff[1] = 0x06; // descriptor len
dstBuff[2] = 0x56; // "V"
dstBuff[3] = 0x43; // "C"
dstBuff[4] = 0x2D; // "-"
dstBuff[5] = 0x31; // "1"
dstBuff[6] = 0x01; // profile and level subdescriptor

const int profile = static_cast<int>(sequence.profile) << 4;
switch (sequence.profile)
Expand Down
7 changes: 4 additions & 3 deletions tsMuxer/vvcStreamReader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -120,14 +120,15 @@ int VVCStreamReader::getTSDescriptor(uint8_t* dstBuff, bool blurayMode, const bo
if (hdmvDescriptors)
{
*dstBuff++ = static_cast<uint8_t>(TSDescriptorTag::HDMV); // descriptor tag
*dstBuff++ = 8; // descriptor length
*dstBuff++ = 8; // descriptor length
memcpy(dstBuff, "HDMV\xff", 5);
dstBuff += 5;

*dstBuff++ = static_cast<int>(StreamType::VIDEO_H266); // stream_coding_type
int video_format, frame_rate_index, aspect_ratio_index;
M2TSStreamInfo::blurayStreamParams(getFPS(), getInterlaced(), getStreamWidth(), getStreamHeight(),
static_cast<int>(getStreamAR()), &video_format, &frame_rate_index, &aspect_ratio_index);
static_cast<int>(getStreamAR()), &video_format, &frame_rate_index,
&aspect_ratio_index);

*dstBuff++ = (video_format << 4) + frame_rate_index;
*dstBuff++ = (aspect_ratio_index << 4) + 0xf;
Expand Down Expand Up @@ -338,7 +339,7 @@ int VVCStreamReader::intDecodeNAL(uint8_t* buff)
m_slice->decodeBuffer(curPos, FFMIN(curPos + MAX_SLICE_HEADER, nextNal));
rez = m_slice->deserialize(m_sps, m_pps);
if (rez)
return rez; // not enough buffer or error
return rez; // not enough buffer or error
if (nalType >= VvcUnit::NalType::IDR_W_RADL)
m_lastIFrame = true;
m_fullPicOrder = toFullPicOrder(m_slice, m_sps->log2_max_pic_order_cnt_lsb);
Expand Down

0 comments on commit 5ee4fc2

Please sign in to comment.