Skip to content

Commit

Permalink
Fix compilation ubuntu and fix warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
root authored and root committed Sep 28, 2023
1 parent 8239cb1 commit 22fb303
Show file tree
Hide file tree
Showing 7 changed files with 48 additions and 39 deletions.
6 changes: 3 additions & 3 deletions YUViewLib/src/ffmpeg/AVCodecParametersWrapper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ typedef struct AVCodecParameters_57_58_59_60
AVMediaType codec_type;
AVCodecID codec_id;
uint32_t codec_tag;
uint8_t * extradata;
uint8_t *extradata;
int extradata_size;
int format;
int64_t bit_rate;
Expand All @@ -69,8 +69,8 @@ typedef struct AVCodecParameters_57_58_59_60

} // namespace

AVCodecParametersWrapper::AVCodecParametersWrapper(AVCodecParameters * p,
const LibraryVersions &libraryVersionsv)
AVCodecParametersWrapper::AVCodecParametersWrapper(AVCodecParameters *p,
const LibraryVersions &libraryVersions)
{
this->param = p;
this->libraryVersions = libraryVersions;
Expand Down
28 changes: 28 additions & 0 deletions YUViewLib/src/ffmpeg/FFMpegLibrariesTypes.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -53,4 +53,32 @@ QString timestampToString(int64_t timestamp, AVRational timebase)
.arg(milliseconds, 3, 10, QChar('0'));
}

Version Version::fromFFmpegVersion(const unsigned ffmpegVersion)
{
Version v;
v.major = AV_VERSION_MAJOR(ffmpegVersion);
v.minor = AV_VERSION_MINOR(ffmpegVersion);
v.micro = AV_VERSION_MICRO(ffmpegVersion);
return v;
}

std::string to_string(const Version &version)
{
std::ostringstream stream;
stream << "v" << version.major;
if (version.minor)
{
stream << "." << version.minor.value();
if (version.micro)
stream << "." << version.micro.value();
}
return stream.str();
}

std::ostream &operator<<(std::ostream &stream, const Version &version)
{
stream << to_string(version);
return stream;
}

} // namespace FFmpeg
29 changes: 3 additions & 26 deletions YUViewLib/src/ffmpeg/FFMpegLibrariesTypes.h
Original file line number Diff line number Diff line change
Expand Up @@ -406,38 +406,15 @@ struct Version
return false;
}

static Version fromFFmpegVersion(const unsigned ffmpegVersion)
{
Version v;
v.major = AV_VERSION_MAJOR(ffmpegVersion);
v.minor = AV_VERSION_MINOR(ffmpegVersion);
v.micro = AV_VERSION_MICRO(ffmpegVersion);
return v;
}
static Version fromFFmpegVersion(const unsigned ffmpegVersion);

int major{};
std::optional<int> minor{};
std::optional<int> micro{};
};

inline std::string to_string(const Version &version)
{
std::ostringstream stream;
stream << "v" << version.major;
if (version.minor)
{
stream << "." << version.minor.value();
if (version.micro)
stream << "." << version.micro.value();
}
return stream.str();
}

static std::ostream &operator<<(std::ostream &stream, const Version &version)
{
stream << to_string(version);
return stream;
}
std::string to_string(const Version &version);
std::ostream &operator<<(std::ostream &stream, const Version &version);

struct LibraryVersions
{
Expand Down
2 changes: 1 addition & 1 deletion YUViewLib/src/ffmpeg/LibraryLoader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ bool LibraryLoader::load(std::filesystem::path pathToLib)
return success;
};

void *LibraryLoader::resolve(std::string functionName)
FunctionPointer LibraryLoader::resolve(std::string functionName)
{
auto functionPointer = this->library.resolve(functionName.c_str());
return functionPointer;
Expand Down
8 changes: 5 additions & 3 deletions YUViewLib/src/ffmpeg/LibraryLoader.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@
#include <QLibrary>
#include <filesystem>

typedef void (*FunctionPointer)();

namespace FFmpeg
{

Expand All @@ -43,9 +45,9 @@ class LibraryLoader
public:
LibraryLoader(/* args */) = default;

void unload();
bool load(std::filesystem::path pathToLib);
void *resolve(std::string functionName);
void unload();
bool load(std::filesystem::path pathToLib);
FunctionPointer resolve(std::string functionName);

auto getLibraryPath() const { return this->libraryPath; }

Expand Down
4 changes: 2 additions & 2 deletions YUViewLib/src/ffmpeg/MotionVector.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ parseMotionData(const LibraryVersions &libraryVersions, const uint8_t *data, con
if (libraryVersions.avutil.major == 54)
{
const auto nrMotionVectors = dataSize / sizeof(AVMotionVector_54);
for (int index = 0; index < nrMotionVectors; ++index)
for (size_t index = 0; index < nrMotionVectors; ++index)
{
const auto byteOffset = sizeof(AVMotionVector_54) * index;
const auto p = reinterpret_cast<const AVMotionVector_54 *>(data + byteOffset);
Expand All @@ -94,7 +94,7 @@ parseMotionData(const LibraryVersions &libraryVersions, const uint8_t *data, con
libraryVersions.avutil.major == 57)
{
const auto nrMotionVectors = dataSize / sizeof(AVMotionVector_55_56_57);
for (int index = 0; index < nrMotionVectors; ++index)
for (size_t index = 0; index < nrMotionVectors; ++index)
{
const auto byteOffset = sizeof(AVMotionVector_55_56_57) * index;
const auto p = reinterpret_cast<const AVMotionVector_55_56_57 *>(data + byteOffset);
Expand Down
10 changes: 6 additions & 4 deletions YUViewLib/src/parser/AVFormat/ParserAVFormat.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ vector<QTreeWidgetItem *> ParserAVFormat::getStreamInfo()

std::string ParserAVFormat::getShortStreamDescription(const int streamIndex) const
{
if (streamIndex >= this->shortStreamInfoAllStreams.size())
if (streamIndex < 0 || streamIndex >= static_cast<int>(this->shortStreamInfoAllStreams.size()))
return {};
return this->shortStreamInfoAllStreams.at(streamIndex);
}
Expand Down Expand Up @@ -245,7 +245,7 @@ bool ParserAVFormat::parseExtradata_mpeg2(ByteVector &extradata)
}

std::map<std::string, unsigned>
ParserAVFormat::parseByteVectorAnnexBStartCodes(ByteVector & data,
ParserAVFormat::parseByteVectorAnnexBStartCodes(ByteVector &data,
PacketDataFormat dataFormat,
BitratePlotModel::BitrateEntry packetBitrateEntry,
std::shared_ptr<TreeItem> item)
Expand All @@ -256,7 +256,8 @@ ParserAVFormat::parseByteVectorAnnexBStartCodes(ByteVector & d
return {};
}

auto getNextNalStart = [&data, &dataFormat](ByteVector::iterator searchStart) {
auto getNextNalStart = [&data, &dataFormat](ByteVector::iterator searchStart)
{
if (dataFormat == PacketDataFormat::RawNAL)
{
if (std::distance(searchStart, data.end()) <= 3)
Expand Down Expand Up @@ -343,7 +344,8 @@ bool ParserAVFormat::parseAVPacket(unsigned packetID,

auto timeBase = timeBaseAllStreams[packet.getStreamIndex()];

auto formatTimestamp = [](int64_t timestamp, AVRational timebase) -> std::string {
auto formatTimestamp = [](int64_t timestamp, AVRational timebase) -> std::string
{
std::ostringstream ss;
ss << timestamp << " (";
if (timestamp < 0)
Expand Down

0 comments on commit 22fb303

Please sign in to comment.