clang-tidy: apply to newly merged stuff

Signed-off-by: Rosen Penev <rosenp@gmail.com>
This commit is contained in:
Rosen Penev 2023-01-01 12:36:32 -08:00
parent e87de698f3
commit d458bf2540
15 changed files with 92 additions and 92 deletions

View File

@ -61,12 +61,15 @@ struct MatroskaTag {
matroskaTypeEnum _type; matroskaTypeEnum _type;
matroskaProcessEnum _process; matroskaProcessEnum _process;
MatroskaTag(uint64_t id, const std::string& label, matroskaTypeEnum type, matroskaProcessEnum process) : MatroskaTag(uint64_t id, std::string label, matroskaTypeEnum type, matroskaProcessEnum process) :
_id(id), _label(label), _type(type), _process(process) { _id(id), _label(std::move(label)), _type(type), _process(process) {
} }
MatroskaTag(uint64_t id, const std::string& label) : MatroskaTag(uint64_t id, std::string label) :
_id(id), _label(label), _type(matroskaTypeEnum::UndefinedType), _process(matroskaProcessEnum::Undefined) { _id(id),
_label(std::move(label)),
_type(matroskaTypeEnum::UndefinedType),
_process(matroskaProcessEnum::Undefined) {
} }
bool isSkipped() const { bool isSkipped() const {
@ -141,7 +144,7 @@ class EXIV2API MatroskaVideo : public Image {
@param b The byte, which stores the information to calculate the size @param b The byte, which stores the information to calculate the size
@return Return the size of the block. @return Return the size of the block.
*/ */
[[nodiscard]] uint32_t findBlockSize(byte b); [[nodiscard]] static uint32_t findBlockSize(byte b);
/*! /*!
@brief Check for a valid tag and decode the block at the current IO position. @brief Check for a valid tag and decode the block at the current IO position.
Calls contentManagement() or skips to next tag, if required. Calls contentManagement() or skips to next tag, if required.

View File

@ -79,7 +79,7 @@ class QuickTimeVideo : public Image {
@brief Check for a valid tag and decode the block at the current IO @brief Check for a valid tag and decode the block at the current IO
position. Calls tagDecoder() or skips to next tag, if required. position. Calls tagDecoder() or skips to next tag, if required.
*/ */
void decodeBlock(std::string const& parent_box = ""); void decodeBlock(std::string const& entered_from = "");
/*! /*!
@brief Interpret tag information, and call the respective function @brief Interpret tag information, and call the respective function
to save it in the respective XMP container. Decodes a Tag to save it in the respective XMP container. Decodes a Tag

View File

@ -71,7 +71,7 @@ class EXIV2API RiffVideo : public Image {
//! @name Accessors //! @name Accessors
//@{ //@{
[[nodiscard]] std::string mimeType() const override; [[nodiscard]] std::string mimeType() const override;
[[nodiscard]] const char* printAudioEncoding(uint64_t i); [[nodiscard]] static const char* printAudioEncoding(uint64_t i);
//@} //@}
protected: protected:
@ -155,7 +155,7 @@ class EXIV2API RiffVideo : public Image {
@param divisor The Divisor required to calculate sample rate. @param divisor The Divisor required to calculate sample rate.
@return Return the sample rate of the stream. @return Return the sample rate of the stream.
*/ */
[[nodiscard]] double returnSampleRate(Exiv2::DataBuf& buf, size_t divisor = 1); [[nodiscard]] static double returnSampleRate(Exiv2::DataBuf& buf, size_t divisor = 1);
/*! /*!
@brief Calculates Aspect Ratio of a video, and stores it in the @brief Calculates Aspect Ratio of a video, and stores it in the
respective XMP container. respective XMP container.
@ -171,9 +171,9 @@ class EXIV2API RiffVideo : public Image {
*/ */
void fillDuration(double frame_rate, size_t frame_count); void fillDuration(double frame_rate, size_t frame_count);
[[nodiscard]] bool equalsRiffTag(Exiv2::DataBuf& buf, const char* str); [[nodiscard]] static bool equalsRiffTag(Exiv2::DataBuf& buf, const char* str);
void copyTagValue(DataBuf& buf_dest, DataBuf& buf_src, size_t index = RIFF_TAG_SIZE); static void copyTagValue(DataBuf& buf_dest, DataBuf& buf_src, size_t index = RIFF_TAG_SIZE);
private: private:
static constexpr size_t RIFF_TAG_SIZE = 0x4; static constexpr size_t RIFF_TAG_SIZE = 0x4;

View File

@ -94,9 +94,9 @@ int main(int argc, char* const argv[]) {
if (tagInfo) { if (tagInfo) {
Exiv2::TypeId type = i->typeId(); Exiv2::TypeId type = i->typeId();
if (type != tagInfo->typeId_ && if (type != tagInfo->typeId_ &&
!(tagInfo->typeId_ == Exiv2::comment && type == Exiv2::undefined) // comment is stored as undefined (tagInfo->typeId_ != Exiv2::comment || type != Exiv2::undefined) // comment is stored as undefined
&& !(shortLong.find(i->key()) != shortLong.end() && && (shortLong.find(i->key()) == shortLong.end() ||
(type == Exiv2::unsignedShort || type == Exiv2::unsignedLong)) // can be short or long! (type != Exiv2::unsignedShort && type != Exiv2::unsignedLong)) // can be short or long!
) { ) {
std::cerr << i->key() << " type " << i->typeName() << " (" << type << ")" std::cerr << i->key() << " type " << i->typeName() << " (" << type << ")"
<< " expected " << Exiv2::TypeInfo::typeName(tagInfo->typeId_) << " (" << tagInfo->typeId_ << ")" << " expected " << Exiv2::TypeInfo::typeName(tagInfo->typeId_) << " (" << tagInfo->typeId_ << ")"

View File

@ -28,7 +28,7 @@
#include <iostream> #include <iostream>
#include "config.h" #include "config.h"
//#ifdef EXV_ENABLE_VIDEO // #ifdef EXV_ENABLE_VIDEO
#include "asfvideo.hpp" #include "asfvideo.hpp"
#include "basicio.hpp" #include "basicio.hpp"
#include "convert.hpp" #include "convert.hpp"
@ -40,8 +40,8 @@
#include "types.hpp" #include "types.hpp"
// + standard includes // + standard includes
#include <ctype.h>
#include <cassert> #include <cassert>
#include <cctype>
#include <cstring> #include <cstring>
// ***************************************************************************** // *****************************************************************************
@ -215,12 +215,9 @@ void getGUID(byte buf[], char GUID[]) {
@return Returns true if the buffer data is equivalent to Header GUID. @return Returns true if the buffer data is equivalent to Header GUID.
*/ */
bool isASFType(byte buf[]) { bool isASFType(byte buf[]) {
if (buf[0] == 0x30 && buf[1] == 0x26 && buf[2] == 0xb2 && buf[3] == 0x75 && buf[4] == 0x8e && buf[5] == 0x66 && return buf[0] == 0x30 && buf[1] == 0x26 && buf[2] == 0xb2 && buf[3] == 0x75 && buf[4] == 0x8e && buf[5] == 0x66 &&
buf[6] == 0xcf && buf[7] == 0x11 && buf[8] == 0xa6 && buf[9] == 0xd9 && buf[10] == 0x00 && buf[11] == 0xaa && buf[6] == 0xcf && buf[7] == 0x11 && buf[8] == 0xa6 && buf[9] == 0xd9 && buf[10] == 0x00 && buf[11] == 0xaa &&
buf[12] == 0x00 && buf[13] == 0x62 && buf[14] == 0xce && buf[15] == 0x6c) buf[12] == 0x00 && buf[13] == 0x62 && buf[14] == 0xce && buf[15] == 0x6c;
return true;
return false;
} }
} // namespace Exiv2::Internal } // namespace Exiv2::Internal
@ -341,7 +338,7 @@ void AsfVideo::decodeBlock() {
while (count--) { while (count--) {
std::memset(buf.data(), 0x0, buf.size()); std::memset(buf.data(), 0x0, buf.size());
io_->read(buf.data(), 1); io_->read(buf.data(), 1);
tempLength = (int)buf.data()[0]; tempLength = static_cast<int>(buf.data()[0]);
io_->read(buf.data(), tempLength); io_->read(buf.data(), tempLength);
v->read(Util::toString16(buf)); v->read(Util::toString16(buf));
@ -383,12 +380,12 @@ void AsfVideo::extendedStreamProperties(uint64_t size) {
void AsfVideo::contentDescription(uint64_t size) { void AsfVideo::contentDescription(uint64_t size) {
const size_t pos = io_->tell(); const size_t pos = io_->tell();
size_t length[5]; size_t length[5];
for (int i = 0; i < 5; ++i) { for (size_t& i : length) {
byte buf[2]; byte buf[2];
io_->read(buf, 2); io_->read(buf, 2);
if (io_->error() || io_->eof()) if (io_->error() || io_->eof())
throw Error(ErrorCode::kerFailedToReadImageData); throw Error(ErrorCode::kerFailedToReadImageData);
length[i] = getUShort(buf, littleEndian); i = getUShort(buf, littleEndian);
} }
for (int i = 0; i < 5; ++i) { for (int i = 0; i < 5; ++i) {
DataBuf buf(length[i]); DataBuf buf(length[i]);
@ -398,7 +395,7 @@ void AsfVideo::contentDescription(uint64_t size) {
throw Error(ErrorCode::kerFailedToReadImageData); throw Error(ErrorCode::kerFailedToReadImageData);
const TagDetails* td = find(contentDescriptionTags, i); const TagDetails* td = find(contentDescriptionTags, i);
assert(td); assert(td);
std::string str((const char*)buf.data(), length[i]); std::string str(reinterpret_cast<const char*>(buf.data()), length[i]);
if (convertStringCharset(str, "UCS-2LE", "UTF-8")) { if (convertStringCharset(str, "UCS-2LE", "UTF-8")) {
xmpData()[td->label_] = str; xmpData()[td->label_] = str;
} else { } else {
@ -436,7 +433,7 @@ void AsfVideo::streamProperties() {
io_->read(buf.data(), BUFF_MIN_SIZE); io_->read(buf.data(), BUFF_MIN_SIZE);
std::memset(buf.data(), 0x0, buf.size()); std::memset(buf.data(), 0x0, buf.size());
io_->read(buf.data(), 1); io_->read(buf.data(), 1);
streamNumber_ = (int)buf.data()[0] & 127; streamNumber_ = static_cast<int>(buf.data()[0]) & 127;
io_->read(buf.data(), 5); io_->read(buf.data(), 5);
std::memset(buf.data(), 0x0, buf.size()); std::memset(buf.data(), 0x0, buf.size());
@ -553,16 +550,17 @@ void AsfVideo::metadataHandler(int meta) {
if (dataType == 6) { if (dataType == 6) {
io_->read(guidBuf, GUI_SIZE); io_->read(guidBuf, GUI_SIZE);
getGUID(guidBuf, fileID); getGUID(guidBuf, fileID);
} else } else {
// Sanity check with an "unreasonably" large number // Sanity check with an "unreasonably" large number
if (dataLength > 5000) { if (dataLength > 5000) {
#ifndef SUPPRESS_WARNINGS #ifndef SUPPRESS_WARNINGS
EXV_ERROR << "Xmp.video.Metadata dataLength was found to be larger than 5000 " EXV_ERROR << "Xmp.video.Metadata dataLength was found to be larger than 5000 "
<< " entries considered invalid; not read.\n"; << " entries considered invalid; not read.\n";
#endif #endif
io_->seek(io_->tell() + dataLength, BasicIo::beg); io_->seek(io_->tell() + dataLength, BasicIo::beg);
} else } else
io_->read(buf.data(), dataLength); io_->read(buf.data(), dataLength);
}
} }
else if (meta == 2) { else if (meta == 2) {
@ -655,11 +653,11 @@ void AsfVideo::fileProperties() {
void AsfVideo::aspectRatio() { void AsfVideo::aspectRatio() {
// TODO - Make a better unified method to handle all cases of Aspect Ratio // TODO - Make a better unified method to handle all cases of Aspect Ratio
double aspectRatio = (double)width_ / height_; double aspectRatio = static_cast<double>(width_) / height_;
aspectRatio = floor(aspectRatio * 10) / 10; aspectRatio = floor(aspectRatio * 10) / 10;
xmpData()["Xmp.video.AspectRatio"] = aspectRatio; xmpData()["Xmp.video.AspectRatio"] = aspectRatio;
int aR = (int)((aspectRatio * 10.0) + 0.1); auto aR = static_cast<int>((aspectRatio * 10.0) + 0.1);
switch (aR) { switch (aR) {
case 13: case 13:
@ -715,4 +713,4 @@ bool isAsfType(BasicIo& iIo, bool advance) {
} }
} // namespace Exiv2 } // namespace Exiv2
//#endif // EXV_ENABLE_VIDEO // #endif // EXV_ENABLE_VIDEO

View File

@ -171,7 +171,7 @@ class BrotliDecoderWrapper {
BrotliDecoderState* decoder_; BrotliDecoderState* decoder_;
public: public:
BrotliDecoderWrapper() : decoder_(BrotliDecoderCreateInstance(NULL, NULL, NULL)) { BrotliDecoderWrapper() : decoder_(BrotliDecoderCreateInstance(nullptr, nullptr, nullptr)) {
if (!decoder_) { if (!decoder_) {
throw Error(ErrorCode::kerMallocFailed); throw Error(ErrorCode::kerMallocFailed);
} }

View File

@ -1573,7 +1573,7 @@ bool convertStringCharsetIconv(std::string& str, const char* from, const char* t
bool ret = true; bool ret = true;
iconv_t cd; iconv_t cd;
cd = iconv_open(to, from); cd = iconv_open(to, from);
if (cd == (iconv_t)(-1)) { if (cd == iconv_t(-1)) {
#ifndef SUPPRESS_WARNINGS #ifndef SUPPRESS_WARNINGS
EXV_WARNING << "iconv_open: " << strError() << "\n"; EXV_WARNING << "iconv_open: " << strError() << "\n";
#endif #endif

View File

@ -16,9 +16,8 @@ std::string string_from_unterminated(const char* data, size_t data_length) {
namespace Util { namespace Util {
char returnHEX(int n) { char returnHEX(int n) {
if (n >= 0 && n <= 9) if (n >= 0 && n <= 9)
return (char)(n + 48); return static_cast<char>(n + 48);
else return static_cast<char>(n + 55);
return (char)(n + 55);
} }
std::string toString16(Exiv2::DataBuf& buf) { std::string toString16(Exiv2::DataBuf& buf) {

View File

@ -98,7 +98,7 @@ inline binaryToStringHelper<T> binaryToString(const Slice<T> sl) noexcept {
} }
/// @brief indent output for kpsRecursive in \em printStructure() \em . /// @brief indent output for kpsRecursive in \em printStructure() \em .
std::string indent(size_t depth); std::string indent(size_t i);
} // namespace Exiv2::Internal } // namespace Exiv2::Internal

View File

@ -38,7 +38,7 @@ PNG tags : http://www.sno.phy.queensu.ca/~phil/exiftool/TagNames/PNG
*/ */
namespace { namespace {
constexpr size_t nullSeparators = 2; constexpr size_t nullSeparators = 2;
} } // namespace
// ***************************************************************************** // *****************************************************************************
// class member definitions // class member definitions

View File

@ -206,6 +206,7 @@ class LoaderTiff : public Loader {
public: public:
//! Constructor //! Constructor
LoaderTiff(PreviewId id, const Image& image, int parIdx); LoaderTiff(PreviewId id, const Image& image, int parIdx);
~LoaderTiff() override = default;
LoaderTiff(const LoaderTiff&) = delete; LoaderTiff(const LoaderTiff&) = delete;
LoaderTiff& operator=(const LoaderTiff&) = delete; LoaderTiff& operator=(const LoaderTiff&) = delete;

View File

@ -21,7 +21,7 @@
// included header files // included header files
#include "config.h" #include "config.h"
//#ifdef EXV_ENABLE_VIDEO // #ifdef EXV_ENABLE_VIDEO
#include "basicio.hpp" #include "basicio.hpp"
#include "error.hpp" #include "error.hpp"
#include "futils.hpp" #include "futils.hpp"
@ -36,8 +36,7 @@
// ***************************************************************************** // *****************************************************************************
// class member definitions // class member definitions
namespace Exiv2 { namespace Exiv2::Internal {
namespace Internal {
/*! /*!
@brief Dummy TIFF header structure. @brief Dummy TIFF header structure.
@ -49,7 +48,7 @@ class DummyTiffHeader : public TiffHeaderBase {
//! Default constructor //! Default constructor
DummyTiffHeader(ByteOrder byteOrder); DummyTiffHeader(ByteOrder byteOrder);
//! Destructor //! Destructor
~DummyTiffHeader(); ~DummyTiffHeader() override = default;
//@} //@}
//! @name Manipulators //! @name Manipulators
@ -63,9 +62,6 @@ class DummyTiffHeader : public TiffHeaderBase {
DummyTiffHeader::DummyTiffHeader(ByteOrder byteOrder) : TiffHeaderBase(42, 0, byteOrder, 0) { DummyTiffHeader::DummyTiffHeader(ByteOrder byteOrder) : TiffHeaderBase(42, 0, byteOrder, 0) {
} }
DummyTiffHeader::~DummyTiffHeader() {
}
bool DummyTiffHeader::read(const byte* /*pData*/, size_t /*size*/) { bool DummyTiffHeader::read(const byte* /*pData*/, size_t /*size*/) {
return true; return true;
} }
@ -426,8 +422,7 @@ constexpr TagDetails nikonAVITags[] = {{0x0003, "Xmp.video.Make"},
enum streamTypeInfo { Audio = 1, MIDI, Text, Video }; enum streamTypeInfo { Audio = 1, MIDI, Text, Video };
} // namespace Internal } // namespace Exiv2::Internal
} // namespace Exiv2
namespace Exiv2 { namespace Exiv2 {
using namespace Exiv2::Internal; using namespace Exiv2::Internal;
@ -479,8 +474,8 @@ void RiffVideo::printStructure(std::ostream& out, PrintStructureOption option, s
const uint64_t bufMaxSize = 200; const uint64_t bufMaxSize = 200;
io_->seek(0, BasicIo::beg); // rewind io_->seek(0, BasicIo::beg); // rewind
while (!io_->eof() && (uint64_t)io_->tell() < filesize) { while (!io_->eof() && static_cast<uint64_t>(io_->tell()) < filesize) {
uint64_t offset = (uint64_t)io_->tell(); auto offset = static_cast<uint64_t>(io_->tell());
byte size_buff[RIFF_TAG_SIZE]; byte size_buff[RIFF_TAG_SIZE];
io_->read(chunkId.data(), RIFF_TAG_SIZE); io_->read(chunkId.data(), RIFF_TAG_SIZE);
io_->read(size_buff, RIFF_TAG_SIZE); io_->read(size_buff, RIFF_TAG_SIZE);
@ -494,7 +489,8 @@ void RiffVideo::printStructure(std::ostream& out, PrintStructureOption option, s
if (bPrint) { if (bPrint) {
out << Internal::indent(depth) out << Internal::indent(depth)
<< Internal::stringFormat(" %s | %12u | %12u | ", (const char*)chunkId.data(), size, (uint32_t)offset) << Internal::stringFormat(" %s | %12u | %12u | ", reinterpret_cast<const char*>(chunkId.data()), size,
static_cast<uint32_t>(offset))
<< Internal::binaryToString(makeSlice(payload, 0, payload.size() > 32 ? 32 : payload.size())) << std::endl; << Internal::binaryToString(makeSlice(payload, 0, payload.size() > 32 ? 32 : payload.size())) << std::endl;
} }
@ -507,7 +503,7 @@ void RiffVideo::printStructure(std::ostream& out, PrintStructureOption option, s
bool bPrintPayload = (equalsRiffTag(chunkId, RIFF_CHUNK_HEADER_XMP) && option == kpsXMP) || bool bPrintPayload = (equalsRiffTag(chunkId, RIFF_CHUNK_HEADER_XMP) && option == kpsXMP) ||
(equalsRiffTag(chunkId, RIFF_CHUNK_HEADER_ICCP) && option == kpsIccProfile); (equalsRiffTag(chunkId, RIFF_CHUNK_HEADER_ICCP) && option == kpsIccProfile);
if (bPrintPayload) { if (bPrintPayload) {
out.write((const char*)payload.data(), payload.size()); out.write(reinterpret_cast<const char*>(payload.data()), payload.size());
} }
if (offset && io_->tell() % 2) if (offset && io_->tell() % 2)
@ -560,7 +556,8 @@ void RiffVideo::decodeBlock() {
if (io_->eof() || equalsRiffTag(buf2, "MOVI") || equalsRiffTag(buf2, "DATA")) { if (io_->eof() || equalsRiffTag(buf2, "MOVI") || equalsRiffTag(buf2, "DATA")) {
continueTraversing_ = false; continueTraversing_ = false;
return; return;
} else if (equalsRiffTag(buf2, "HDRL") || equalsRiffTag(buf2, "STRL")) { }
if (equalsRiffTag(buf2, "HDRL") || equalsRiffTag(buf2, "STRL")) {
decodeBlock(); decodeBlock();
} else { } else {
io_->read(buf.data(), RIFF_TAG_SIZE); io_->read(buf.data(), RIFF_TAG_SIZE);
@ -578,7 +575,7 @@ void RiffVideo::tagDecoder(Exiv2::DataBuf& buf, size_t size) {
listFlag = true; listFlag = true;
listEnd = false; listEnd = false;
while ((uint64_t)(io_->tell()) < cur_pos + size) while (static_cast<uint64_t>(io_->tell()) < cur_pos + size)
decodeBlock(); decodeBlock();
listEnd = true; listEnd = true;
@ -762,7 +759,7 @@ void RiffVideo::nikonTagsHandler() {
while (dataSize) { while (dataSize) {
std::memset(buf.data(), 0x0, buf.size()); std::memset(buf.data(), 0x0, buf.size());
io_->read(buf.data(), 1); io_->read(buf.data(), 1);
str[(RIFF_TAG_SIZE - dataSize) * 2] = (char)(Exiv2::getULong(buf.data(), littleEndian) + 48); str[(RIFF_TAG_SIZE - dataSize) * 2] = static_cast<char>(Exiv2::getULong(buf.data(), littleEndian) + 48);
--dataSize; --dataSize;
} }
xmpData_["Xmp.video.MakerNoteVersion"] = str; xmpData_["Xmp.video.MakerNoteVersion"] = str;
@ -817,7 +814,7 @@ void RiffVideo::nikonTagsHandler() {
case 0x001b: case 0x001b:
case 0x0016: case 0x0016:
copyTagValue(buf2, buf); copyTagValue(buf2, buf);
denominator = (double)Exiv2::getLong(buf2.data(), littleEndian); denominator = static_cast<double>(Exiv2::getLong(buf2.data(), littleEndian));
if (denominator != 0) if (denominator != 0)
xmpData_[exvGettext(td->label_)] = Exiv2::getLong(buf.data(), littleEndian) / denominator; xmpData_[exvGettext(td->label_)] = Exiv2::getLong(buf.data(), littleEndian) / denominator;
else else
@ -901,7 +898,7 @@ void RiffVideo::junkHandler(size_t size) {
io_->read(buf.data(), 8); io_->read(buf.data(), 8);
copyTagValue(buf2, buf); copyTagValue(buf2, buf);
xmpData_["Xmp.video.FNumber"] = xmpData_["Xmp.video.FNumber"] =
(double)Exiv2::getLong(buf.data(), littleEndian) / Exiv2::getLong(buf2.data(), littleEndian); static_cast<double>(Exiv2::getLong(buf.data(), littleEndian)) / Exiv2::getLong(buf2.data(), littleEndian);
; ;
io_->seek(cur_pos + 131, BasicIo::beg); io_->seek(cur_pos + 131, BasicIo::beg);
@ -943,7 +940,7 @@ void RiffVideo::aviHeaderTagsHandler(size_t size) {
uint64_t cur_pos = io_->tell(); uint64_t cur_pos = io_->tell();
enum aviHeaderTags { frameRate, maxDataRate, frameCount = 4, streamCount = 6, imageWidth_h = 8, imageHeight_h, last }; enum aviHeaderTags { frameRate, maxDataRate, frameCount = 4, streamCount = 6, imageWidth_h = 8, imageHeight_h, last };
for (aviHeaderTags tag = frameRate; tag != aviHeaderTags::last; tag = aviHeaderTags(tag + 1)) { for (aviHeaderTags tag = frameRate; tag != aviHeaderTags::last; tag = static_cast<aviHeaderTags>(tag + 1)) {
std::memset(buf.data(), 0x0, buf.size()); std::memset(buf.data(), 0x0, buf.size());
io_->read(buf.data(), RIFF_TAG_SIZE); io_->read(buf.data(), RIFF_TAG_SIZE);
@ -1001,7 +998,7 @@ void RiffVideo::streamHandler(size_t size) {
sampleSize = 11, sampleSize = 11,
last last
}; };
for (streamHeaderTags tag = codec; tag != streamHeaderTags::last; tag = streamHeaderTags(tag + 1)) { for (streamHeaderTags tag = codec; tag != streamHeaderTags::last; tag = static_cast<streamHeaderTags>(tag + 1)) {
std::memset(buf.data(), 0x0, buf.size()); std::memset(buf.data(), 0x0, buf.size());
io_->read(buf.data(), RIFF_TAG_SIZE); // the position is advanced by the number of bytes read, that's why we need io_->read(buf.data(), RIFF_TAG_SIZE); // the position is advanced by the number of bytes read, that's why we need
// to iterate sequentially , not only on switch values. // to iterate sequentially , not only on switch values.
@ -1073,7 +1070,7 @@ void RiffVideo::streamFormatHandler(size_t size) {
numImportantColors, numImportantColors,
last last
}; };
for (bmptags tag = imageWidth; tag != bmptags::last; tag = bmptags(tag + 1)) { for (bmptags tag = imageWidth; tag != bmptags::last; tag = static_cast<bmptags>(tag + 1)) {
std::memset(buf.data(), 0x0, buf.size()); std::memset(buf.data(), 0x0, buf.size());
switch (tag) { switch (tag) {
@ -1131,7 +1128,7 @@ void RiffVideo::streamFormatHandler(size_t size) {
int c = 0; int c = 0;
const TagDetails* td; const TagDetails* td;
enum audioFormatTags { encoding, numberOfChannels, audioSampleRate, avgBytesPerSec = 4, bitsPerSample = 7, last }; enum audioFormatTags { encoding, numberOfChannels, audioSampleRate, avgBytesPerSec = 4, bitsPerSample = 7, last };
for (audioFormatTags tag = encoding; tag != audioFormatTags::last; tag = audioFormatTags(tag + 1)) { for (audioFormatTags tag = encoding; tag != audioFormatTags::last; tag = static_cast<audioFormatTags>(tag + 1)) {
io_->read(buf.data(), 2); io_->read(buf.data(), 2);
switch (tag) { switch (tag) {
@ -1175,7 +1172,7 @@ void RiffVideo::streamFormatHandler(size_t size) {
} // RiffVideo::streamFormatHandler } // RiffVideo::streamFormatHandler
double RiffVideo::returnSampleRate(Exiv2::DataBuf& buf, size_t divisor) { double RiffVideo::returnSampleRate(Exiv2::DataBuf& buf, size_t divisor) {
return ((double)Exiv2::getULong(buf.data(), littleEndian) / divisor); return (static_cast<double>(Exiv2::getULong(buf.data(), littleEndian)) / divisor);
} // RiffVideo::returnSampleRate } // RiffVideo::returnSampleRate
const char* RiffVideo::printAudioEncoding(uint64_t i) { const char* RiffVideo::printAudioEncoding(uint64_t i) {
@ -1190,11 +1187,11 @@ const char* RiffVideo::printAudioEncoding(uint64_t i) {
void RiffVideo::fillAspectRatio(size_t width, size_t height) { void RiffVideo::fillAspectRatio(size_t width, size_t height) {
if (height == 0) if (height == 0)
return; return;
double aspectRatio = (double)width / height; double aspectRatio = static_cast<double>(width) / height;
aspectRatio = floor(aspectRatio * 10) / 10; aspectRatio = floor(aspectRatio * 10) / 10;
xmpData_["Xmp.video.AspectRatio"] = aspectRatio; xmpData_["Xmp.video.AspectRatio"] = aspectRatio;
int aR = (int)((aspectRatio * 10.0) + 0.1); auto aR = static_cast<int>((aspectRatio * 10.0) + 0.1);
switch (aR) { switch (aR) {
case 13: case 13:
@ -1228,7 +1225,7 @@ void RiffVideo::fillDuration(double frame_rate, size_t frame_count) {
if (frame_rate == 0) if (frame_rate == 0)
return; return;
uint64_t duration = static_cast<uint64_t>(frame_count * 1000. / frame_rate); auto duration = static_cast<uint64_t>(frame_count * 1000. / frame_rate);
xmpData_["Xmp.video.FileDataRate"] = io_->size() / (1048576. * duration); xmpData_["Xmp.video.FileDataRate"] = io_->size() / (1048576. * duration);
xmpData_["Xmp.video.Duration"] = duration; // Duration in number of seconds xmpData_["Xmp.video.Duration"] = duration; // Duration in number of seconds
} // RiffVideo::fillDuration } // RiffVideo::fillDuration
@ -1257,4 +1254,4 @@ bool isRiffType(BasicIo& iIo, bool advance) {
} }
} // namespace Exiv2 } // namespace Exiv2
//#endif // EXV_ENABLE_VIDEO // #endif // EXV_ENABLE_VIDEO

View File

@ -61,10 +61,9 @@ typename std::enable_if<std::is_signed<T>::value && sizeof(T) >= sizeof(int), bo
if (((summand_2 >= 0) && (summand_1 > std::numeric_limits<T>::max() - summand_2)) || if (((summand_2 >= 0) && (summand_1 > std::numeric_limits<T>::max() - summand_2)) ||
((summand_2 < 0) && (summand_1 < std::numeric_limits<T>::min() - summand_2))) { ((summand_2 < 0) && (summand_1 < std::numeric_limits<T>::min() - summand_2))) {
return true; return true;
} else {
result = summand_1 + summand_2;
return false;
} }
result = summand_1 + summand_2;
return false;
} }
/*! /*!
@ -92,10 +91,9 @@ typename std::enable_if<std::is_signed<T>::value && sizeof(T) < sizeof(int), boo
const int res = summand_1 + summand_2; const int res = summand_1 + summand_2;
if ((res > std::numeric_limits<T>::max()) || (res < std::numeric_limits<T>::min())) { if ((res > std::numeric_limits<T>::max()) || (res < std::numeric_limits<T>::min())) {
return true; return true;
} else {
result = static_cast<T>(res);
return false;
} }
result = static_cast<T>(res);
return false;
} }
/*! /*!

View File

@ -939,27 +939,31 @@ std::ostream& SonyMakerNote::printAFPointSelected(std::ostream& os, const Value&
if (std::any_of(models1.begin(), models1.end(), [&model](auto& m) { return startsWith(model, m); })) { if (std::any_of(models1.begin(), models1.end(), [&model](auto& m) { return startsWith(model, m); })) {
EXV_PRINT_TAG(sonyAFPointSelectedSet1)(os, value.toUint32(0), metadata); EXV_PRINT_TAG(sonyAFPointSelectedSet1)(os, value.toUint32(0), metadata);
return os; return os;
} else if (std::any_of(models2.begin(), models2.end(), [&model](auto& m) { return startsWith(model, m); }) && }
status && aFAreaModeSetting == 4) { if (std::any_of(models2.begin(), models2.end(), [&model](auto& m) { return startsWith(model, m); }) && status &&
aFAreaModeSetting == 4) {
EXV_PRINT_TAG(sonyAFPointSelectedSet1)(os, value.toUint32(0), metadata); EXV_PRINT_TAG(sonyAFPointSelectedSet1)(os, value.toUint32(0), metadata);
return os; return os;
} else if (std::any_of(models3.begin(), models3.end(), [&model](auto& m) { return startsWith(model, m); }) && }
status && aFAreaModeSetting != 8) { if (std::any_of(models3.begin(), models3.end(), [&model](auto& m) { return startsWith(model, m); }) && status &&
aFAreaModeSetting != 8) {
EXV_PRINT_TAG(sonyAFPointSelectedSet2)(os, value, metadata); EXV_PRINT_TAG(sonyAFPointSelectedSet2)(os, value, metadata);
return os; return os;
} else if (startsWith(model, "ILCA-99M2") && status && aFAreaModeSetting != 8) { }
if (startsWith(model, "ILCA-99M2") && status && aFAreaModeSetting != 8) {
EXV_PRINT_TAG(sonyAFPointSelectedSet3)(os, value, metadata); EXV_PRINT_TAG(sonyAFPointSelectedSet3)(os, value, metadata);
return os; return os;
} else if (startsWith(model, "ILCA-") && status && aFAreaModeSetting == 8) { }
if (startsWith(model, "ILCA-") && status && aFAreaModeSetting == 8) {
EXV_PRINT_TAG(sonyAFPointSelectedSet4)(os, value.toUint32(0), metadata); EXV_PRINT_TAG(sonyAFPointSelectedSet4)(os, value.toUint32(0), metadata);
return os; return os;
} else if (std::any_of(models4.begin(), models4.end(), [&model](auto& m) { return startsWith(model, m); })) { }
if (std::any_of(models4.begin(), models4.end(), [&model](auto& m) { return startsWith(model, m); })) {
EXV_PRINT_TAG(sonyAFPointSelectedSet5)(os, value.toUint32(0), metadata); EXV_PRINT_TAG(sonyAFPointSelectedSet5)(os, value.toUint32(0), metadata);
return os; return os;
} else {
os << _("n/a");
return os;
} }
os << _("n/a");
return os;
} }
std::ostream& SonyMakerNote::printAFPointsUsed(std::ostream& os, const Value& value, const ExifData* metadata) { std::ostream& SonyMakerNote::printAFPointsUsed(std::ostream& os, const Value& value, const ExifData* metadata) {
@ -980,13 +984,13 @@ std::ostream& SonyMakerNote::printAFPointsUsed(std::ostream& os, const Value& va
if (std::none_of(models1.begin(), models1.end(), [&model](auto& m) { return startsWith(model, m); })) { if (std::none_of(models1.begin(), models1.end(), [&model](auto& m) { return startsWith(model, m); })) {
EXV_PRINT_TAG_BITLIST_ALL_LE(sonyAFPointsUsedSet1)(os, value, metadata); EXV_PRINT_TAG_BITLIST_ALL_LE(sonyAFPointsUsedSet1)(os, value, metadata);
return os; return os;
} else if (std::any_of(models2.begin(), models2.end(), [&model](auto& m) { return startsWith(model, m); })) { }
if (std::any_of(models2.begin(), models2.end(), [&model](auto& m) { return startsWith(model, m); })) {
EXV_PRINT_TAG_BITLIST_ALL_LE(sonyAFPointsUsedSet2)(os, value, metadata); EXV_PRINT_TAG_BITLIST_ALL_LE(sonyAFPointsUsedSet2)(os, value, metadata);
return os; return os;
} else {
os << _("n/a");
return os;
} }
os << _("n/a");
return os;
} }
std::ostream& SonyMakerNote::printAFTracking(std::ostream& os, const Value& value, const ExifData* metadata) { std::ostream& SonyMakerNote::printAFTracking(std::ostream& os, const Value& value, const ExifData* metadata) {

View File

@ -11,7 +11,7 @@ using namespace Exiv2;
namespace { namespace {
constexpr std::array validMarkers{"8BIM", "AgHg", "DCSR", "PHUT"}; constexpr std::array validMarkers{"8BIM", "AgHg", "DCSR", "PHUT"};
} } // namespace
TEST(Photoshop_isIrb, returnsTrueWithValidMarkers) { TEST(Photoshop_isIrb, returnsTrueWithValidMarkers) {
for (const auto& marker : validMarkers) { for (const auto& marker : validMarkers) {