From 5ee4fc28048421b64bf2dfd56bc73b7201579825 Mon Sep 17 00:00:00 2001 From: jcdr428 Date: Wed, 9 Aug 2023 15:31:24 +0100 Subject: [PATCH] clang format check --- libmediation/fs/osdep/directory_win32.cpp | 10 ++-- libmediation/types/types.cpp | 4 +- tsMuxer/ac3StreamReader.cpp | 6 +-- tsMuxer/hevc.cpp | 10 ++-- tsMuxer/iso_writer.cpp | 61 +++++++++++------------ tsMuxer/matroskaDemuxer.cpp | 2 +- tsMuxer/mpegVideo.cpp | 5 +- tsMuxer/simplePacketizerReader.cpp | 9 ++-- tsMuxer/srtStreamReader.cpp | 2 +- tsMuxer/textSubtitles.cpp | 5 +- tsMuxer/vc1StreamReader.cpp | 12 ++--- tsMuxer/vvcStreamReader.cpp | 7 +-- 12 files changed, 63 insertions(+), 70 deletions(-) diff --git a/libmediation/fs/osdep/directory_win32.cpp b/libmediation/fs/osdep/directory_win32.cpp index 0bed8bec..ec5edcdb 100644 --- a/libmediation/fs/osdep/directory_win32.cpp +++ b/libmediation/fs/osdep/directory_win32.cpp @@ -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) diff --git a/libmediation/types/types.cpp b/libmediation/types/types.cpp index 63c1457b..cef8eb7f 100644 --- a/libmediation/types/types.cpp +++ b/libmediation/types/types.cpp @@ -514,8 +514,8 @@ std::vector toWide(const char* utf8Str, const int sz) return mbtwc_wrapper(CP_UTF8, utf8Str, sz, static_cast(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); } diff --git a/tsMuxer/ac3StreamReader.cpp b/tsMuxer/ac3StreamReader.cpp index f5c4baa9..10d08018 100644 --- a/tsMuxer/ac3StreamReader.cpp +++ b/tsMuxer/ac3StreamReader.cpp @@ -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; diff --git a/tsMuxer/hevc.cpp b/tsMuxer/hevc.cpp index 139c08e2..f16a304b 100644 --- a/tsMuxer/hevc.cpp +++ b/tsMuxer/hevc.cpp @@ -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; } @@ -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() { diff --git a/tsMuxer/iso_writer.cpp b/tsMuxer/iso_writer.cpp index c18c50f2..d5739d50 100644 --- a/tsMuxer/iso_writer.cpp +++ b/tsMuxer/iso_writer.cpp @@ -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; } @@ -142,35 +140,31 @@ std::vector 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(high_surrogate >> 8)); - rv.push_back(static_cast(high_surrogate)); - if (low_surrogate) - { - rv.push_back(static_cast(low_surrogate >> 8)); - rv.push_back(static_cast(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(high_surrogate >> 8)); + rv.push_back(static_cast(high_surrogate)); + if (low_surrogate) + { + rv.push_back(static_cast(low_surrogate >> 8)); + rv.push_back(static_cast(low_surrogate)); + } + return true; + }); } const auto contentLength = static_cast(rv.size()); const auto paddingSize = maxHeaderAndContentLength - rv.size(); @@ -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), diff --git a/tsMuxer/matroskaDemuxer.cpp b/tsMuxer/matroskaDemuxer.cpp index a0d350fc..6a7882de 100644 --- a/tsMuxer/matroskaDemuxer.cpp +++ b/tsMuxer/matroskaDemuxer.cpp @@ -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; diff --git a/tsMuxer/mpegVideo.cpp b/tsMuxer/mpegVideo.cpp index 38e87505..7de8a569 100644 --- a/tsMuxer/mpegVideo.cpp +++ b/tsMuxer/mpegVideo.cpp @@ -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) { diff --git a/tsMuxer/simplePacketizerReader.cpp b/tsMuxer/simplePacketizerReader.cpp index 43632b13..d7f50935 100644 --- a/tsMuxer/simplePacketizerReader.cpp +++ b/tsMuxer/simplePacketizerReader.cpp @@ -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; } @@ -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; } diff --git a/tsMuxer/srtStreamReader.cpp b/tsMuxer/srtStreamReader.cpp index 94296a2a..ebf3faa5 100644 --- a/tsMuxer/srtStreamReader.cpp +++ b/tsMuxer/srtStreamReader.cpp @@ -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); diff --git a/tsMuxer/textSubtitles.cpp b/tsMuxer/textSubtitles.cpp index 10bae156..02654bc6 100644 --- a/tsMuxer/textSubtitles.cpp +++ b/tsMuxer/textSubtitles.cpp @@ -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(alignToGrid(updateTime + fpsPts)); diff --git a/tsMuxer/vc1StreamReader.cpp b/tsMuxer/vc1StreamReader.cpp index 3d5db22a..1effa480 100644 --- a/tsMuxer/vc1StreamReader.cpp +++ b/tsMuxer/vc1StreamReader.cpp @@ -67,12 +67,12 @@ int VC1StreamReader::getTSDescriptor(uint8_t* dstBuff, bool blurayMode, bool hdm return 0; dstBuff[0] = static_cast(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(sequence.profile) << 4; switch (sequence.profile) diff --git a/tsMuxer/vvcStreamReader.cpp b/tsMuxer/vvcStreamReader.cpp index 3702998d..ce393d58 100644 --- a/tsMuxer/vvcStreamReader.cpp +++ b/tsMuxer/vvcStreamReader.cpp @@ -120,14 +120,15 @@ int VVCStreamReader::getTSDescriptor(uint8_t* dstBuff, bool blurayMode, const bo if (hdmvDescriptors) { *dstBuff++ = static_cast(TSDescriptorTag::HDMV); // descriptor tag - *dstBuff++ = 8; // descriptor length + *dstBuff++ = 8; // descriptor length memcpy(dstBuff, "HDMV\xff", 5); dstBuff += 5; *dstBuff++ = static_cast(StreamType::VIDEO_H266); // stream_coding_type int video_format, frame_rate_index, aspect_ratio_index; M2TSStreamInfo::blurayStreamParams(getFPS(), getInterlaced(), getStreamWidth(), getStreamHeight(), - static_cast(getStreamAR()), &video_format, &frame_rate_index, &aspect_ratio_index); + static_cast(getStreamAR()), &video_format, &frame_rate_index, + &aspect_ratio_index); *dstBuff++ = (video_format << 4) + frame_rate_index; *dstBuff++ = (aspect_ratio_index << 4) + 0xf; @@ -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);