clang format

This commit is contained in:
jcdr428 2022-04-19 21:23:06 +00:00
parent c906a873e0
commit c02b8c7819
2 changed files with 29 additions and 33 deletions

@ -112,12 +112,10 @@ void writeTimestamp(uint8_t* buffer, time_t time)
bool canUse8BitUnicode(const std::string& utf8Str) bool canUse8BitUnicode(const std::string& utf8Str)
{ {
bool rv = true; bool rv = true;
convertUTF::IterateUTF8Chars(utf8Str, convertUTF::IterateUTF8Chars(utf8Str, [&](auto c) {
[&](auto c) rv = (c < 0x100);
{ return rv;
rv = (c < 0x100); });
return rv;
});
return rv; return rv;
} }
@ -142,35 +140,31 @@ std::vector<std::uint8_t> serializeDString(const std::string& str, size_t fieldL
if (canUse8BitUnicode(utf8Str)) if (canUse8BitUnicode(utf8Str))
{ {
rv.push_back(8); rv.push_back(8);
IterateUTF8Chars(utf8Str, IterateUTF8Chars(utf8Str, [&](auto c) {
[&](auto c) rv.push_back(c);
{ return rv.size() < maxHeaderAndContentLength;
rv.push_back(c); });
return rv.size() < maxHeaderAndContentLength;
});
} }
else else
{ {
rv.push_back(16); rv.push_back(16);
IterateUTF8Chars(utf8Str, IterateUTF8Chars(utf8Str, [&](auto c) {
[&](auto c) UTF16 high_surrogate, low_surrogate;
{ std::tie(high_surrogate, low_surrogate) = ConvertUTF32toUTF16(c);
UTF16 high_surrogate, low_surrogate; auto spaceLeft = maxHeaderAndContentLength - rv.size();
std::tie(high_surrogate, low_surrogate) = ConvertUTF32toUTF16(c); if ((spaceLeft < 2) || (low_surrogate && spaceLeft < 4))
auto spaceLeft = maxHeaderAndContentLength - rv.size(); {
if ((spaceLeft < 2) || (low_surrogate && spaceLeft < 4)) return false;
{ }
return false; rv.push_back((uint8_t)(high_surrogate >> 8));
} rv.push_back((uint8_t)high_surrogate);
rv.push_back((uint8_t)(high_surrogate >> 8)); if (low_surrogate)
rv.push_back((uint8_t)high_surrogate); {
if (low_surrogate) rv.push_back((uint8_t)(low_surrogate >> 8));
{ rv.push_back((uint8_t)low_surrogate);
rv.push_back((uint8_t)(low_surrogate >> 8)); }
rv.push_back((uint8_t)low_surrogate); return true;
} });
return true;
});
} }
auto contentLength = (uint8_t)rv.size(); auto contentLength = (uint8_t)rv.size();
auto paddingSize = maxHeaderAndContentLength - rv.size(); auto paddingSize = maxHeaderAndContentLength - rv.size();

@ -652,7 +652,8 @@ void TsMuxerWindow::onTsMuxerCodecInfoReceived()
} }
if (fileDuration == 0 && !mplsFileList.isEmpty()) if (fileDuration == 0 && !mplsFileList.isEmpty())
{ {
foreach (const MPLSFileInfo &mplsFile, mplsFileList) fileDuration += mplsFile.duration; foreach (const MPLSFileInfo &mplsFile, mplsFileList)
fileDuration += mplsFile.duration;
} }
m_updateMeta = true; m_updateMeta = true;
@ -1330,7 +1331,8 @@ void TsMuxerWindow::updateCustomChapters()
offset = 0; offset = 0;
ChapterList chapters = item->data(ChaptersRole).value<ChapterList>(); ChapterList chapters = item->data(ChaptersRole).value<ChapterList>();
foreach (double chapter, chapters) chaptersSet << qint64((chapter + offset) * 1000000); foreach (double chapter, chapters)
chaptersSet << qint64((chapter + offset) * 1000000);
prevDuration = item->data(FileDurationRole).toDouble(); prevDuration = item->data(FileDurationRole).toDouble();
} }