Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 35 additions & 0 deletions .clang-tidy
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
---
Checks: '-clang-diagnostic-*,clang-analyzer-*,cppcoreguidelines-*,modernize-*,-modernize-use-trailing-return-type'
WarningsAsErrors: true
HeaderFilterRegex: '.*'
FormatStyle: google
CheckOptions:
- key: cert-dcl16-c.NewSuffixes
value: 'L;LL;LU;LLU'
- key: cert-oop54-cpp.WarnOnlyIfThisHasSuspiciousField
value: '0'
- key: cppcoreguidelines-explicit-virtual-functions.IgnoreDestructors
value: '1'
- key: cppcoreguidelines-non-private-member-variables-in-classes.IgnoreClassesWithAllMemberVariablesBeingPublic
value: '1'
- key: google-readability-braces-around-statements.ShortStatementLines
value: '1'
- key: google-readability-function-size.StatementThreshold
value: '800'
- key: google-readability-namespace-comments.ShortNamespaceLines
value: '10'
- key: google-readability-namespace-comments.SpacesBeforeComments
value: '2'
- key: modernize-loop-convert.MaxCopySize
value: '16'
- key: modernize-loop-convert.MinConfidence
value: reasonable
- key: modernize-loop-convert.NamingStyle
value: CamelCase
- key: modernize-pass-by-value.IncludeStyle
value: llvm
- key: modernize-replace-auto-ptr.IncludeStyle
value: llvm
- key: modernize-use-nullptr.NullMacros
value: 'NULL'
...
21 changes: 10 additions & 11 deletions src/app/FilePacketComparer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@

#include "Formatting.h"

#include <array>
#include <cstddef>
#include <filesystem>
#include <iomanip>
Expand Down Expand Up @@ -80,7 +81,7 @@ std::optional<CompareFile> parseFileNameAndStreamIndex(const std::string &variab
{
file.streamIndex = std::stoi(variable.substr(columnPos + 1));
}
catch (const std::exception &e)
catch (const std::exception &)
{
return {};
}
Expand All @@ -106,8 +107,8 @@ Demuxer openInput(std::shared_ptr<IFFmpegLibraries> ffmpegLibraries, const std::
return demuxer;
}

ComparisonMode checkStreamsAndGetComparMode(Demuxer & demuxer1,
Demuxer & demuxer2,
ComparisonMode checkStreamsAndGetComparMode(Demuxer &demuxer1,
Demuxer &demuxer2,
const int streamIndex1,
const int streamIndex2)
{
Expand Down Expand Up @@ -138,14 +139,14 @@ ComparisonMode checkStreamsAndGetComparMode(Demuxer & demuxer1,
codecDescriptor1->codecName + " and name 2 " +
codecDescriptor2->codecName);

if (codecDescriptor1->codecName.find("pcm") == 0)
if (codecDescriptor1->codecName.starts_with("pcm"))
return ComparisonMode::Data;
return ComparisonMode::Packets;
}

bool compareData(const ByteVector &data1, const ByteVector &data2)
{
return std::equal(data1.begin(), data1.end(), data2.begin(), data2.end());
return std::ranges::equal(data1, data2);
}

void compareQueuePacketsAndDrain(PacketQueue &queue1, PacketQueue &queue2)
Expand All @@ -158,9 +159,6 @@ void compareQueuePacketsAndDrain(PacketQueue &queue1, PacketQueue &queue2)
queue1.pop();
queue2.pop();

const auto streamIndex1 = packet1.getStreamIndex();
const auto streamIndex2 = packet2.getStreamIndex();

static int packetCount = -1;
++packetCount;

Expand Down Expand Up @@ -333,12 +331,13 @@ int main(int argc, char const *argv[])
const auto compareMode = checkStreamsAndGetComparMode(
demuxer1, demuxer2, settings->file1.streamIndex, settings->file2.streamIndex);

PacketQueue packetQueue[2];
DataQueue dataQueue[2];
std::array<PacketQueue, 2> packetQueue;
std::array<DataQueue, 2> dataQueue;

auto addPacketToQueue = [&packetQueue, &dataQueue, compareMode](avcodec::AVPacketWrapper &&packet,
const int streamIndex,
const int queueIndex) {
const int queueIndex)
{
const auto packetStreamIndex = packet.getStreamIndex();
if (packetStreamIndex != streamIndex)
return;
Expand Down
6 changes: 4 additions & 2 deletions src/lib/AVCodec/wrappers/AVChannelInternal.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -146,8 +146,10 @@ ChannelLayout bitMaskToChannelLayout(const uint64_t mask, const bool isAmbisonic
{
ChannelLayout layout;

std::bitset<64> bits(mask);
for (int bitPosition = 0; bitPosition < 64; ++bitPosition)
constexpr auto MAX_CHANNELS = 64;

std::bitset<MAX_CHANNELS> bits(mask);
for (int bitPosition = 0; bitPosition < MAX_CHANNELS; ++bitPosition)
{
if (bits.test(bitPosition))
{
Expand Down
36 changes: 18 additions & 18 deletions src/lib/AVCodec/wrappers/AVCodecContextWrapper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ namespace internal

} // namespace internal

AVCodecContextWrapper::AVCodecContextWrapper(AVCodecContext * codecContext,
AVCodecContextWrapper::AVCodecContextWrapper(AVCodecContext *codecContext,
std::shared_ptr<IFFmpegLibraries> ffmpegLibraries)
: codecContext(codecContext), ffmpegLibraries(ffmpegLibraries)
{
Expand All @@ -53,7 +53,8 @@ AVCodecContextWrapper::AVCodecContextWrapper(std::shared_ptr<IFFmpegLibraries> f
throw std::runtime_error("Provided ffmpeg libraries pointer must not be null");
}

AVCodecContextWrapper &AVCodecContextWrapper::operator=(AVCodecContextWrapper &&codecContextWrapper)
AVCodecContextWrapper &
AVCodecContextWrapper::operator=(AVCodecContextWrapper &&codecContextWrapper) noexcept
{
this->codecContext = codecContextWrapper.codecContext;
this->codecContextOwnership = codecContextWrapper.codecContextOwnership;
Expand All @@ -62,12 +63,11 @@ AVCodecContextWrapper &AVCodecContextWrapper::operator=(AVCodecContextWrapper &&
return *this;
}

AVCodecContextWrapper::AVCodecContextWrapper(AVCodecContextWrapper &&codecContextWrapper)
AVCodecContextWrapper::AVCodecContextWrapper(AVCodecContextWrapper &&codecContextWrapper) noexcept
: codecContext(codecContextWrapper.codecContext),
codecContextOwnership(codecContextWrapper.codecContextOwnership),
ffmpegLibraries(std::move(codecContextWrapper.ffmpegLibraries))
{
this->codecContext = codecContextWrapper.codecContext;
this->codecContextOwnership = codecContextWrapper.codecContextOwnership;
codecContextWrapper.codecContext = nullptr;
this->ffmpegLibraries = std::move(codecContextWrapper.ffmpegLibraries);
}

AVCodecContextWrapper::~AVCodecContextWrapper()
Expand Down Expand Up @@ -173,56 +173,56 @@ AVCodecContextWrapper::decodeVideo2(const avcodec::AVPacketWrapper &packet)

avutil::MediaType AVCodecContextWrapper::getCodecType() const
{
AVMediaType type;
AVMediaType type{};
CAST_AVCODEC_GET_MEMBER(AVCodecContext, this->codecContext, type, codec_type);
return avutil::toMediaType(type);
}

AVCodecID AVCodecContextWrapper::getCodecID() const
{
AVCodecID id;
AVCodecID id{};
CAST_AVCODEC_GET_MEMBER(AVCodecContext, this->codecContext, id, codec_id);
return id;
}

avutil::PixelFormatDescriptor AVCodecContextWrapper::getPixelFormat() const
{
AVPixelFormat avPixelFormat;
AVPixelFormat avPixelFormat{};
CAST_AVCODEC_GET_MEMBER(AVCodecContext, this->codecContext, avPixelFormat, pix_fmt);
return avutil::convertAVPixFmtDescriptor(avPixelFormat, this->ffmpegLibraries);
}

Size AVCodecContextWrapper::getSize() const
{
int width;
int width{};
CAST_AVCODEC_GET_MEMBER(AVCodecContext, this->codecContext, width, width);

int height;
int height{};
CAST_AVCODEC_GET_MEMBER(AVCodecContext, this->codecContext, height, height);

return {width, height};
return {.width = width, .height = height};
}

avutil::ColorSpace AVCodecContextWrapper::getColorspace() const
{
AVColorSpace avColorspace;
AVColorSpace avColorspace{};
CAST_AVCODEC_GET_MEMBER(AVCodecContext, this->codecContext, avColorspace, colorspace);
return avutil::toColorspace(avColorspace);
}

Rational AVCodecContextWrapper::getTimeBase() const
{
AVRational timebase;
AVRational timebase{};
CAST_AVCODEC_GET_MEMBER(AVCodecContext, this->codecContext, timebase, time_base);
return Rational({timebase.num, timebase.den});
return fromAVRational(timebase);
}

ByteVector AVCodecContextWrapper::getExtradata() const
{
uint8_t *extradata;
uint8_t *extradata{};
CAST_AVCODEC_GET_MEMBER(AVCodecContext, this->codecContext, extradata, extradata);

int extradataSize;
int extradataSize{};
CAST_AVCODEC_GET_MEMBER(AVCodecContext, this->codecContext, extradataSize, extradata_size);

return copyDataFromRawArray(extradata, extradataSize);
Expand Down
18 changes: 9 additions & 9 deletions src/lib/AVCodec/wrappers/AVCodecContextWrapper.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,9 @@ class AVCodecContextWrapper
AVCodecContextWrapper(libffmpeg::internal::AVCodecContext *codecContext,
std::shared_ptr<IFFmpegLibraries> ffmpegLibraries);
AVCodecContextWrapper(const AVCodecContextWrapper &) = delete;
AVCodecContextWrapper &operator =(AVCodecContextWrapper &&);
AVCodecContextWrapper &operator=(AVCodecContextWrapper &&) noexcept;
AVCodecContextWrapper &operator=(const AVCodecContextWrapper &) = delete;
AVCodecContextWrapper(AVCodecContextWrapper &&wrapper);
AVCodecContextWrapper(AVCodecContextWrapper &&wrapper) noexcept;
~AVCodecContextWrapper();

bool openContextForDecoding(const avcodec::AVCodecParametersWrapper &codecParameters);
Expand All @@ -47,13 +47,13 @@ class AVCodecContextWrapper
// This is the old FFMpeg 2 interface before pushPacket/pullFrame.
DecodeResult decodeVideo2(const avcodec::AVPacketWrapper &packet);

avutil::MediaType getCodecType() const;
libffmpeg::internal::AVCodecID getCodecID() const;
avutil::PixelFormatDescriptor getPixelFormat() const;
Size getSize() const;
avutil::ColorSpace getColorspace() const;
Rational getTimeBase() const;
ByteVector getExtradata() const;
[[nodiscard]] avutil::MediaType getCodecType() const;
[[nodiscard]] libffmpeg::internal::AVCodecID getCodecID() const;
[[nodiscard]] avutil::PixelFormatDescriptor getPixelFormat() const;
[[nodiscard]] Size getSize() const;
[[nodiscard]] avutil::ColorSpace getColorspace() const;
[[nodiscard]] Rational getTimeBase() const;
[[nodiscard]] ByteVector getExtradata() const;

private:
/* It depends on how the wrapper is created who has ownership of this.
Expand Down
Loading