Apply cmake-format and clang-format

This commit is contained in:
Martchus 2019-05-04 21:03:09 +02:00
parent 3288d49d62
commit c17db5f2f6
7 changed files with 32 additions and 28 deletions

View File

@ -176,7 +176,8 @@ set(META_REQUIRED_CPP_UNIT_VERSION 1.14.0)
set(META_ADD_DEFAULT_CPP_UNIT_TEST_APPLICATION ON) set(META_ADD_DEFAULT_CPP_UNIT_TEST_APPLICATION ON)
# find c++utilities # find c++utilities
set(CONFIGURATION_PACKAGE_SUFFIX "" CACHE STRING "sets the suffix for find_package() calls to packages configured via c++utilities") set(CONFIGURATION_PACKAGE_SUFFIX ""
CACHE STRING "sets the suffix for find_package() calls to packages configured via c++utilities")
find_package(c++utilities${CONFIGURATION_PACKAGE_SUFFIX} 5.0.0 REQUIRED) find_package(c++utilities${CONFIGURATION_PACKAGE_SUFFIX} 5.0.0 REQUIRED)
use_cpp_utilities(VISIBILITY PUBLIC) use_cpp_utilities(VISIBILITY PUBLIC)

View File

@ -607,7 +607,7 @@ Id3v2FrameMaker::Id3v2FrameMaker(Id3v2Frame &frame, std::uint8_t version, Diagno
} else if (((version >= 3 && m_frameId == Id3v2FrameIds::lComment) || (version < 3 && m_frameId == Id3v2FrameIds::sComment)) } else if (((version >= 3 && m_frameId == Id3v2FrameIds::lComment) || (version < 3 && m_frameId == Id3v2FrameIds::sComment))
|| ((version >= 3 && m_frameId == Id3v2FrameIds::lUnsynchronizedLyrics) || ((version >= 3 && m_frameId == Id3v2FrameIds::lUnsynchronizedLyrics)
|| (version < 3 && m_frameId == Id3v2FrameIds::sUnsynchronizedLyrics))) { || (version < 3 && m_frameId == Id3v2FrameIds::sUnsynchronizedLyrics))) {
// make comment frame or the unsynchronized lyrics frame // make comment frame or the unsynchronized lyrics frame
m_frame.makeComment(m_data, m_decompressedSize, *values.front(), version, diag); m_frame.makeComment(m_data, m_decompressedSize, *values.front(), version, diag);

View File

@ -1239,7 +1239,7 @@ void MatroskaContainer::internalMakeFile(Diagnostics &diag, AbortableProgressFee
segment.clusterEndOffset = level1Element->endOffset(); segment.clusterEndOffset = level1Element->endOffset();
if (segment.cuesElement if (segment.cuesElement
&& segment.cuesUpdater.updateOffsets( && segment.cuesUpdater.updateOffsets(
clusterReadOffset, level1Element->startOffset() - 4 - segment.sizeDenotationLength - ebmlHeaderSize) clusterReadOffset, level1Element->startOffset() - 4 - segment.sizeDenotationLength - ebmlHeaderSize)
&& newCuesPos == ElementPosition::BeforeData) { && newCuesPos == ElementPosition::BeforeData) {
cuesInvalidated = true; cuesInvalidated = true;
} }
@ -1326,13 +1326,13 @@ void MatroskaContainer::internalMakeFile(Diagnostics &diag, AbortableProgressFee
if (rewriteRequired) { if (rewriteRequired) {
if (newTagPos != ElementPosition::AfterData if (newTagPos != ElementPosition::AfterData
&& (!fileInfo().forceTagPosition() && (!fileInfo().forceTagPosition()
|| (fileInfo().tagPosition() == ElementPosition::Keep && currentTagPos == ElementPosition::Keep))) { || (fileInfo().tagPosition() == ElementPosition::Keep && currentTagPos == ElementPosition::Keep))) {
// rewriting might be avoided by writing the tags at the end // rewriting might be avoided by writing the tags at the end
newTagPos = ElementPosition::AfterData; newTagPos = ElementPosition::AfterData;
rewriteRequired = false; rewriteRequired = false;
} else if (newCuesPos != ElementPosition::AfterData } else if (newCuesPos != ElementPosition::AfterData
&& (!fileInfo().forceIndexPosition() && (!fileInfo().forceIndexPosition()
|| (fileInfo().indexPosition() == ElementPosition::Keep && currentCuesPos == ElementPosition::Keep))) { || (fileInfo().indexPosition() == ElementPosition::Keep && currentCuesPos == ElementPosition::Keep))) {
// rewriting might be avoided by writing the cues at the end // rewriting might be avoided by writing the cues at the end
newCuesPos = ElementPosition::AfterData; newCuesPos = ElementPosition::AfterData;
rewriteRequired = false; rewriteRequired = false;

View File

@ -437,9 +437,9 @@ TrackHeaderInfo Mp4Track::verifyPresentTrackHeader() const
info.requiredSize = m_tkhdAtom->dataSize() + 8; info.requiredSize = m_tkhdAtom->dataSize() + 8;
// -> add 12 byte to size if update from version 0 to version 1 is required (which needs 12 byte more) // -> add 12 byte to size if update from version 0 to version 1 is required (which needs 12 byte more)
if ((info.version == 0) if ((info.version == 0)
&& (static_cast<std::uint64_t>((m_creationTime - startDate).totalSeconds()) > numeric_limits<std::uint32_t>::max() && (static_cast<std::uint64_t>((m_creationTime - startDate).totalSeconds()) > numeric_limits<std::uint32_t>::max()
|| static_cast<std::uint64_t>((m_modificationTime - startDate).totalSeconds()) > numeric_limits<std::uint32_t>::max() || static_cast<std::uint64_t>((m_modificationTime - startDate).totalSeconds()) > numeric_limits<std::uint32_t>::max()
|| static_cast<std::uint64_t>(m_duration.totalSeconds() * m_timeScale) > numeric_limits<std::uint32_t>::max())) { || static_cast<std::uint64_t>(m_duration.totalSeconds() * m_timeScale) > numeric_limits<std::uint32_t>::max())) {
info.requiredSize += 12; info.requiredSize += 12;
} }
// -> add 8 byte to the size because it must be denoted using a 64-bit integer // -> add 8 byte to the size because it must be denoted using a 64-bit integer
@ -592,7 +592,8 @@ std::unique_ptr<Mpeg4ElementaryStreamInfo> Mp4Track::parseMpeg4ElementaryStreamI
if (esInfo->ocrFlag()) { if (esInfo->ocrFlag()) {
esInfo->ocrId = reader.readUInt16BE(); esInfo->ocrId = reader.readUInt16BE();
} }
for (Mpeg4Descriptor *esDescChild = esDesc.denoteFirstChild(static_cast<std::uint32_t>(static_cast<std::uint64_t>(reader.stream()->tellg()) - esDesc.startOffset())); for (Mpeg4Descriptor *esDescChild
= esDesc.denoteFirstChild(static_cast<std::uint32_t>(static_cast<std::uint64_t>(reader.stream()->tellg()) - esDesc.startOffset()));
esDescChild; esDescChild = esDescChild->nextSibling()) { esDescChild; esDescChild = esDescChild->nextSibling()) {
esDescChild->parse(diag); esDescChild->parse(diag);
switch (esDescChild->id()) { switch (esDescChild->id()) {
@ -1107,10 +1108,10 @@ std::uint64_t Mp4Track::requiredSize(Diagnostics &diag) const
} }
// ... mdhd total size // ... mdhd total size
if (static_cast<std::uint64_t>((m_creationTime - startDate).totalSeconds()) > numeric_limits<std::uint32_t>::max() if (static_cast<std::uint64_t>((m_creationTime - startDate).totalSeconds()) > numeric_limits<std::uint32_t>::max()
|| static_cast<std::uint64_t>((m_modificationTime - startDate).totalSeconds()) > numeric_limits<std::uint32_t>::max() || static_cast<std::uint64_t>((m_modificationTime - startDate).totalSeconds()) > numeric_limits<std::uint32_t>::max()
|| static_cast<std::uint64_t>(m_duration.totalSeconds() * m_timeScale) > numeric_limits<std::uint32_t>::max()) { || static_cast<std::uint64_t>(m_duration.totalSeconds() * m_timeScale) > numeric_limits<std::uint32_t>::max()) {
// write version 1 where those fields are 64-bit // write version 1 where those fields are 64-bit
size += 44; size += 44;
} else { } else {
// write version 0 where those fields are 32-bit // write version 0 where those fields are 32-bit
size += 32; size += 32;
@ -1201,9 +1202,11 @@ void Mp4Track::makeTrackHeader(Diagnostics &diag)
const auto creationTime = static_cast<std::uint64_t>((m_creationTime - startDate).totalSeconds()); const auto creationTime = static_cast<std::uint64_t>((m_creationTime - startDate).totalSeconds());
const auto modificationTime = static_cast<std::uint64_t>((m_modificationTime - startDate).totalSeconds()); const auto modificationTime = static_cast<std::uint64_t>((m_modificationTime - startDate).totalSeconds());
const auto duration = static_cast<std::uint64_t>(m_duration.totalSeconds() * m_timeScale); const auto duration = static_cast<std::uint64_t>(m_duration.totalSeconds() * m_timeScale);
const std::uint8_t version = (info.version == 0) && (creationTime > numeric_limits<std::uint32_t>::max() const std::uint8_t version = (info.version == 0)
|| modificationTime > numeric_limits<std::uint32_t>::max() && (creationTime > numeric_limits<std::uint32_t>::max() || modificationTime > numeric_limits<std::uint32_t>::max()
|| duration > numeric_limits<std::uint32_t>::max()) ? 1 : info.version; || duration > numeric_limits<std::uint32_t>::max())
? 1
: info.version;
// make version and flags // make version and flags
writer().writeByte(version); writer().writeByte(version);
@ -1276,9 +1279,10 @@ void Mp4Track::makeMedia(Diagnostics &diag)
const auto creationTime = static_cast<std::uint64_t>((m_creationTime - startDate).totalSeconds()); const auto creationTime = static_cast<std::uint64_t>((m_creationTime - startDate).totalSeconds());
const auto modificationTime = static_cast<std::uint64_t>((m_modificationTime - startDate).totalSeconds()); const auto modificationTime = static_cast<std::uint64_t>((m_modificationTime - startDate).totalSeconds());
const auto duration = static_cast<std::uint64_t>(m_duration.totalSeconds() * m_timeScale); const auto duration = static_cast<std::uint64_t>(m_duration.totalSeconds() * m_timeScale);
const std::uint8_t version = (creationTime > numeric_limits<std::uint32_t>::max() const std::uint8_t version = (creationTime > numeric_limits<std::uint32_t>::max() || modificationTime > numeric_limits<std::uint32_t>::max()
|| modificationTime > numeric_limits<std::uint32_t>::max() || duration > numeric_limits<std::uint32_t>::max())
|| duration > numeric_limits<std::uint32_t>::max()) ? 1 : 0; ? 1
: 0;
writer().writeUInt32BE(version != 0 ? 44 : 32); // size writer().writeUInt32BE(version != 0 ? 44 : 32); // size
writer().writeUInt32BE(Mp4AtomIds::MediaHeader); writer().writeUInt32BE(Mp4AtomIds::MediaHeader);
writer().writeByte(version); // version writer().writeByte(version); // version
@ -1311,7 +1315,8 @@ void Mp4Track::makeMedia(Diagnostics &diag)
language = 0; language = 0;
break; break;
} }
diag.emplace_back(DiagLevel::Warning, "Assigned language \"" % m_language + "\" is of an invalid format. Setting language to undefined.", "making mdhd atom"); diag.emplace_back(DiagLevel::Warning, "Assigned language \"" % m_language + "\" is of an invalid format. Setting language to undefined.",
"making mdhd atom");
language = 0x55C4; // und(efined) language = 0x55C4; // und(efined)
break; break;
} }

View File

@ -56,10 +56,9 @@ void MpegAudioFrameStream::internalParseHeader(Diagnostics &diag)
m_size = xingSize; m_size = xingSize;
} }
} }
m_bitrate = frame.isXingFramefieldPresent() m_bitrate = frame.isXingFramefieldPresent() ? ((static_cast<double>(m_size) * 8.0)
? ((static_cast<double>(m_size) * 8.0) / (static_cast<double>(frame.xingFrameCount() * frame.sampleCount()) / static_cast<double>(frame.samplingFrequency())) / 1024.0)
/ (static_cast<double>(frame.xingFrameCount() * frame.sampleCount()) / static_cast<double>(frame.samplingFrequency())) / 1024.0) : frame.bitrate();
: frame.bitrate();
m_duration = TimeSpan::fromSeconds(static_cast<double>(m_size) / (m_bytesPerSecond = static_cast<std::uint32_t>(m_bitrate * 125))); m_duration = TimeSpan::fromSeconds(static_cast<double>(m_size) / (m_bytesPerSecond = static_cast<std::uint32_t>(m_bitrate * 125)));
} }

View File

@ -439,7 +439,7 @@ void OggContainer::internalMakeFile(Diagnostics &diag, AbortableProgressFeedback
// prevent making the comment twice if it spreads over multiple pages/segments // prevent making the comment twice if it spreads over multiple pages/segments
if (!currentParams->removed if (!currentParams->removed
&& ((m_iterator.currentPageIndex() == currentParams->firstPageIndex && ((m_iterator.currentPageIndex() == currentParams->firstPageIndex
&& m_iterator.currentSegmentIndex() == currentParams->firstSegmentIndex))) { && m_iterator.currentSegmentIndex() == currentParams->firstSegmentIndex))) {
makeVorbisCommentSegment(buffer, copyHelper, newSegmentSizes, currentComment, currentParams, diag); makeVorbisCommentSegment(buffer, copyHelper, newSegmentSizes, currentComment, currentParams, diag);
} }

View File

@ -202,10 +202,9 @@ void WaveAudioStream::internalParseHeader(Diagnostics &diag)
MpegAudioFrame frame; MpegAudioFrame frame;
frame.parseHeader(m_reader, diag); frame.parseHeader(m_reader, diag);
MpegAudioFrameStream::addInfo(frame, *this); MpegAudioFrameStream::addInfo(frame, *this);
m_bitrate = frame.isXingFramefieldPresent() m_bitrate = frame.isXingFramefieldPresent() ? ((static_cast<double>(m_size) * 8.0)
? ((static_cast<double>(m_size) * 8.0) / (static_cast<double>(frame.xingFrameCount() * frame.sampleCount()) / static_cast<double>(frame.samplingFrequency())) / 1024.0)
/ (static_cast<double>(frame.xingFrameCount() * frame.sampleCount()) / static_cast<double>(frame.samplingFrequency())) / 1024.0) : frame.bitrate();
: frame.bitrate();
m_bytesPerSecond = static_cast<std::uint32_t>(m_bitrate * 125); m_bytesPerSecond = static_cast<std::uint32_t>(m_bitrate * 125);
m_duration = TimeSpan::fromSeconds(static_cast<double>(m_size) / (m_bitrate * 128.0)); m_duration = TimeSpan::fromSeconds(static_cast<double>(m_size) / (m_bitrate * 128.0));
} }