diff --git a/include/exiv2/quicktimevideo.hpp b/include/exiv2/quicktimevideo.hpp index a665178a..6d56749c 100644 --- a/include/exiv2/quicktimevideo.hpp +++ b/include/exiv2/quicktimevideo.hpp @@ -55,15 +55,23 @@ class QuickTimeVideo : public Image { QuickTimeVideo(BasicIo::UniquePtr io); //@} + //! @name NOT Implemented + //@{ + //! Copy constructor + QuickTimeVideo(const QuickTimeVideo&) = delete; + //! Assignment operator + QuickTimeVideo& operator=(const QuickTimeVideo&) = delete; + //@} + //! @name Manipulators //@{ - void readMetadata(); - void writeMetadata(); + void readMetadata() override; + void writeMetadata() override; //@} //! @name Accessors //@{ - std::string mimeType() const; + std::string mimeType() const override; //@} protected: @@ -198,22 +206,13 @@ class QuickTimeVideo : public Image { */ void aspectRatio(); - private: - //! @name NOT Implemented - //@{ - //! Copy constructor - QuickTimeVideo(const QuickTimeVideo& rhs); - //! Assignment operator - QuickTimeVideo& operator=(const QuickTimeVideo& rhs); - //@} - private: //! Variable which stores Time Scale unit, used to calculate time. uint64_t timeScale_ = 0; //! Variable which stores current stream being processsed. int currentStream_ = 0; //! Variable to check the end of metadata traversing. - bool continueTraversing_ = 0; + bool continueTraversing_ = false; //! Variable to store height and width of a video frame. uint64_t height_ = 0, width_ = 0; diff --git a/src/easyaccess.cpp b/src/easyaccess.cpp index 4ec18dee..af950a2e 100644 --- a/src/easyaccess.cpp +++ b/src/easyaccess.cpp @@ -238,12 +238,12 @@ ExifData::const_iterator lensName(const ExifData& ed) { "Exif.Sony1.LensID", "Exif.Sony2.LensID", "Exif.Sony1.LensSpec", "Exif.Sony2.LensSpec", "Exif.OlympusEq.LensType", "Exif.Panasonic.LensType", "Exif.Samsung2.LensType"}; - for (size_t i = 0; i < std::size(keys); ++i) { - Exiv2::ExifData::const_iterator pos = ed.findKey(ExifKey(keys[i])); + for (auto& key : keys) { + auto pos = ed.findKey(ExifKey(key)); if (pos != ed.end()) { // Exif.NikonLd4.LensID and Exif.NikonLd4.LensIDNumber are usually together included, // one of them has value 0 (which means undefined), so skip tag with value 0 - if (strncmp(keys[i], "Exif.NikonLd4", 13) == 0) { + if (strncmp(key, "Exif.NikonLd4", 13) == 0) { if (pos->getValue()->toInt64(0) > 0) return pos; } else diff --git a/src/matroskavideo.cpp b/src/matroskavideo.cpp index a51ccd29..68c2fda5 100644 --- a/src/matroskavideo.cpp +++ b/src/matroskavideo.cpp @@ -21,7 +21,7 @@ // included header files #include "config.h" -//#ifdef EXV_ENABLE_VIDEO +// #ifdef EXV_ENABLE_VIDEO #include "basicio.hpp" #include "error.hpp" #include "futils.hpp" @@ -30,16 +30,15 @@ #include "tags_int.hpp" // + standard includes -#include #include #include #include +#include #include #include // ***************************************************************************** // class member definitions -namespace Exiv2 { -namespace Internal { +namespace Exiv2::Internal { /*! Tag Look-up list for Matroska Type Video Files @@ -570,8 +569,7 @@ const std::array streamRate = {MatroskaTag(0x1, "Xmp.video.Frame return true; } -} // namespace Internal -} // namespace Exiv2 +} // namespace Exiv2::Internal namespace Exiv2 { @@ -847,7 +845,7 @@ void MatroskaVideo::decodeDateTags(const MatroskaTag* tag, const byte* buf, size case TimecodeScale: if (!convertToUint64(buf, size, value)) return; - time_code_scale_ = (double)value / (double)1000000000; + time_code_scale_ = static_cast(value) / static_cast(1000000000); xmpData_[tag->_label] = time_code_scale_; break; default: @@ -873,7 +871,7 @@ void MatroskaVideo::decodeFloatTags(const MatroskaTag* tag, const byte* buf, siz if (internalMt) { switch (stream_) { case 1: // video - frame_rate = (double)1000000000 / (double)key; + frame_rate = static_cast(1000000000) / static_cast(key); break; case 2: // audio frame_rate = static_cast(key / 1000); @@ -893,11 +891,11 @@ void MatroskaVideo::decodeFloatTags(const MatroskaTag* tag, const byte* buf, siz } void MatroskaVideo::aspectRatio() { - double aspectRatio = (double)width_ / (double)height_; + double aspectRatio = static_cast(width_) / static_cast(height_); aspectRatio = floor(aspectRatio * 10) / 10; xmpData_["Xmp.video.AspectRatio"] = aspectRatio; - int aR = (int)((aspectRatio * 10.0) + 0.1); + auto aR = static_cast((aspectRatio * 10.0) + 0.1); switch (aR) { case 13: @@ -930,22 +928,21 @@ void MatroskaVideo::aspectRatio() { uint32_t MatroskaVideo::findBlockSize(byte b) { if (b & 128) return 1; - else if (b & 64) + if (b & 64) return 2; - else if (b & 32) + if (b & 32) return 3; - else if (b & 16) + if (b & 16) return 4; - else if (b & 8) + if (b & 8) return 5; - else if (b & 4) + if (b & 4) return 6; - else if (b & 2) + if (b & 2) return 7; - else if (b & 1) + if (b & 1) return 8; - else - return 0; + return 0; } Image::UniquePtr newMkvInstance(BasicIo::UniquePtr io, bool /*create*/) { @@ -973,4 +970,4 @@ bool isMkvType(BasicIo& iIo, bool advance) { return result; } -} // namespace Exiv2 \ No newline at end of file +} // namespace Exiv2 diff --git a/src/nikonmn_int.cpp b/src/nikonmn_int.cpp index 1d16ace8..9aacdae9 100644 --- a/src/nikonmn_int.cpp +++ b/src/nikonmn_int.cpp @@ -994,9 +994,9 @@ static void printFlashCompensationValue(std::ostream& os, const unsigned char va float output = 0.0; if (value < 128) { if (value != 0) - output = float(value) * float(-1.0); + output = static_cast(value) * static_cast(-1.0); } else { - output = float(256.0) - float(value); + output = static_cast(256.0) - static_cast(value); } os.precision(1); if (value != 0) diff --git a/src/quicktimevideo.cpp b/src/quicktimevideo.cpp index 00db1fc1..883e03c6 100644 --- a/src/quicktimevideo.cpp +++ b/src/quicktimevideo.cpp @@ -36,8 +36,7 @@ #include // ***************************************************************************** // class member definitions -namespace Exiv2 { -namespace Internal { +namespace Exiv2::Internal { extern const TagVocabulary qTimeFileType[] = { {"3g2a", "3GPP2 Media (.3G2) compliant with 3GPP2 C.S0050-0 V1.0"}, @@ -465,8 +464,8 @@ bool ignoreList(Exiv2::DataBuf& buf) { "mdat", "edts", "junk", "iods", "alis", "stsc", "stsz", "stco", "ctts", "stss", "skip", "wide", "cmvd", }; - for (int i = 0; i < 13; ++i) - if (equalsQTimeTag(buf, ignoreList[i])) + for (auto i : ignoreList) + if (equalsQTimeTag(buf, i)) return true; return false; @@ -484,14 +483,13 @@ bool dataIgnoreList(Exiv2::DataBuf& buf) { "moov", "mdia", "minf", "dinf", "alis", "stbl", "cmov", "meta", }; - for (int i = 0; i < 8; ++i) - if (equalsQTimeTag(buf, ignoreList[i])) + for (auto i : ignoreList) + if (equalsQTimeTag(buf, i)) return true; return false; } -} // namespace Internal -} // namespace Exiv2 +} // namespace Exiv2::Internal namespace Exiv2 { @@ -524,7 +522,7 @@ void QuickTimeVideo::readMetadata() { continueTraversing_ = true; height_ = width_ = 1; - xmpData_["Xmp.video.FileSize"] = (double)io_->size() / (double)1048576; + xmpData_["Xmp.video.FileSize"] = static_cast(io_->size()) / static_cast(1048576); xmpData_["Xmp.video.MimeType"] = mimeType(); while (continueTraversing_) @@ -570,7 +568,7 @@ void QuickTimeVideo::decodeBlock(std::string const& entered_from) { enforce(size - hdrsize <= std::numeric_limits::max(), Exiv2::ErrorCode::kerCorruptedMetadata); // std::cerr<<"Tag=>"<"<(size - hdrsize); + const auto newsize = static_cast(size - hdrsize); if (newsize > buf.size()) { buf.resize(newsize); } @@ -765,14 +763,16 @@ void QuickTimeVideo::CameraTagsDecoder(size_t size_external) { io_->readOrThrow(buf.data(), 14); xmpData_["Xmp.video.Model"] = Exiv2::toString(buf.data()); io_->readOrThrow(buf.data(), 4); - xmpData_["Xmp.video.ExposureTime"] = "1/" + Exiv2::toString(ceil(buf.read_uint32(0, littleEndian) / (double)10)); + xmpData_["Xmp.video.ExposureTime"] = + "1/" + Exiv2::toString(ceil(buf.read_uint32(0, littleEndian) / static_cast(10))); io_->readOrThrow(buf.data(), 4); io_->readOrThrow(buf2.data(), 4); - xmpData_["Xmp.video.FNumber"] = buf.read_uint32(0, littleEndian) / (double)buf2.read_uint32(0, littleEndian); + xmpData_["Xmp.video.FNumber"] = + buf.read_uint32(0, littleEndian) / static_cast(buf2.read_uint32(0, littleEndian)); io_->readOrThrow(buf.data(), 4); io_->readOrThrow(buf2.data(), 4); xmpData_["Xmp.video.ExposureCompensation"] = - buf.read_uint32(0, littleEndian) / (double)buf2.read_uint32(0, littleEndian); + buf.read_uint32(0, littleEndian) / static_cast(buf2.read_uint32(0, littleEndian)); io_->readOrThrow(buf.data(), 10); io_->readOrThrow(buf.data(), 4); td = find(whiteBalance, buf.read_uint32(0, littleEndian)); @@ -780,7 +780,8 @@ void QuickTimeVideo::CameraTagsDecoder(size_t size_external) { xmpData_["Xmp.video.WhiteBalance"] = exvGettext(td->label_); io_->readOrThrow(buf.data(), 4); io_->readOrThrow(buf2.data(), 4); - xmpData_["Xmp.video.FocalLength"] = buf.read_uint32(0, littleEndian) / (double)buf2.read_uint32(0, littleEndian); + xmpData_["Xmp.video.FocalLength"] = + buf.read_uint32(0, littleEndian) / static_cast(buf2.read_uint32(0, littleEndian)); io_->seek(static_cast(95), BasicIo::cur); io_->readOrThrow(buf.data(), 48); buf.write_uint8(48, 0); @@ -820,7 +821,7 @@ void QuickTimeVideo::userDataDecoder(size_t size_external) { if (size <= 12) break; - else if (equalsQTimeTag(buf, "DcMD") || equalsQTimeTag(buf, "NCDT")) + if (equalsQTimeTag(buf, "DcMD") || equalsQTimeTag(buf, "NCDT")) userDataDecoder(size - 8); else if (equalsQTimeTag(buf, "NCTG")) @@ -892,64 +893,64 @@ void QuickTimeVideo::NikonTagsDecoder(size_t size_external) { std::memset(buf.data(), 0x0, buf.size()); io_->readOrThrow(buf.data(), 1); - td2 = find(PictureControlAdjust, (int)buf.data()[0] & 7); + td2 = find(PictureControlAdjust, static_cast(buf.data()[0]) & 7); if (td2) xmpData_["Xmp.video.PictureControlAdjust"] = exvGettext(td2->label_); else - xmpData_["Xmp.video.PictureControlAdjust"] = (int)buf.data()[0] & 7; + xmpData_["Xmp.video.PictureControlAdjust"] = static_cast(buf.data()[0]) & 7; io_->readOrThrow(buf.data(), 1); - td2 = find(NormalSoftHard, (int)buf.data()[0] & 7); + td2 = find(NormalSoftHard, static_cast(buf.data()[0]) & 7); if (td2) xmpData_["Xmp.video.PictureControlQuickAdjust"] = exvGettext(td2->label_); io_->readOrThrow(buf.data(), 1); - td2 = find(NormalSoftHard, (int)buf.data()[0] & 7); + td2 = find(NormalSoftHard, static_cast(buf.data()[0]) & 7); if (td2) xmpData_["Xmp.video.Sharpness"] = exvGettext(td2->label_); else - xmpData_["Xmp.video.Sharpness"] = (int)buf.data()[0] & 7; + xmpData_["Xmp.video.Sharpness"] = static_cast(buf.data()[0]) & 7; io_->readOrThrow(buf.data(), 1); - td2 = find(NormalSoftHard, (int)buf.data()[0] & 7); + td2 = find(NormalSoftHard, static_cast(buf.data()[0]) & 7); if (td2) xmpData_["Xmp.video.Contrast"] = exvGettext(td2->label_); else - xmpData_["Xmp.video.Contrast"] = (int)buf.data()[0] & 7; + xmpData_["Xmp.video.Contrast"] = static_cast(buf.data()[0]) & 7; io_->readOrThrow(buf.data(), 1); - td2 = find(NormalSoftHard, (int)buf.data()[0] & 7); + td2 = find(NormalSoftHard, static_cast(buf.data()[0]) & 7); if (td2) xmpData_["Xmp.video.Brightness"] = exvGettext(td2->label_); else - xmpData_["Xmp.video.Brightness"] = (int)buf.data()[0] & 7; + xmpData_["Xmp.video.Brightness"] = static_cast(buf.data()[0]) & 7; io_->readOrThrow(buf.data(), 1); - td2 = find(Saturation, (int)buf.data()[0] & 7); + td2 = find(Saturation, static_cast(buf.data()[0]) & 7); if (td2) xmpData_["Xmp.video.Saturation"] = exvGettext(td2->label_); else - xmpData_["Xmp.video.Saturation"] = (int)buf.data()[0] & 7; + xmpData_["Xmp.video.Saturation"] = static_cast(buf.data()[0]) & 7; io_->readOrThrow(buf.data(), 1); - xmpData_["Xmp.video.HueAdjustment"] = (int)buf.data()[0] & 7; + xmpData_["Xmp.video.HueAdjustment"] = static_cast(buf.data()[0]) & 7; io_->readOrThrow(buf.data(), 1); - td2 = find(FilterEffect, (int)buf.data()[0]); + td2 = find(FilterEffect, static_cast(buf.data()[0])); if (td2) xmpData_["Xmp.video.FilterEffect"] = exvGettext(td2->label_); else - xmpData_["Xmp.video.FilterEffect"] = (int)buf.data()[0]; + xmpData_["Xmp.video.FilterEffect"] = static_cast(buf.data()[0]); io_->readOrThrow(buf.data(), 1); - td2 = find(ToningEffect, (int)buf.data()[0]); + td2 = find(ToningEffect, static_cast(buf.data()[0])); if (td2) xmpData_["Xmp.video.ToningEffect"] = exvGettext(td2->label_); else - xmpData_["Xmp.video.ToningEffect"] = (int)buf.data()[0]; + xmpData_["Xmp.video.ToningEffect"] = static_cast(buf.data()[0]); io_->readOrThrow(buf.data(), 1); - xmpData_["Xmp.video.ToningSaturation"] = (int)buf.data()[0]; + xmpData_["Xmp.video.ToningSaturation"] = static_cast(buf.data()[0]); io_->seek(local_pos + dataLength, BasicIo::beg); } @@ -962,12 +963,12 @@ void QuickTimeVideo::NikonTagsDecoder(size_t size_external) { io_->readOrThrow(buf.data(), 2); xmpData_["Xmp.video.TimeZone"] = Exiv2::getShort(buf.data(), bigEndian); io_->readOrThrow(buf.data(), 1); - td2 = find(YesNo, (int)buf.data()[0]); + td2 = find(YesNo, static_cast(buf.data()[0])); if (td2) xmpData_["Xmp.video.DayLightSavings"] = exvGettext(td2->label_); io_->readOrThrow(buf.data(), 1); - td2 = find(DateDisplayFormat, (int)buf.data()[0]); + td2 = find(DateDisplayFormat, static_cast(buf.data()[0])); if (td2) xmpData_["Xmp.video.DateDisplayFormat"] = exvGettext(td2->label_); @@ -1030,8 +1031,8 @@ void QuickTimeVideo::NikonTagsDecoder(size_t size_external) { io_->readOrThrow(buf.data(), 4); io_->readOrThrow(buf2.data(), 4); if (td) - xmpData_[exvGettext(td->label_)] = - Exiv2::toString((double)buf.read_uint32(0, bigEndian) / (double)buf2.read_uint32(0, bigEndian)); + xmpData_[exvGettext(td->label_)] = Exiv2::toString(static_cast(buf.read_uint32(0, bigEndian)) / + static_cast(buf2.read_uint32(0, bigEndian))); // Sanity check with an "unreasonably" large number if (dataLength > 200 || dataLength < 8) { @@ -1107,7 +1108,8 @@ void QuickTimeVideo::timeToSampleDecoder() { timeOfFrames = Safe::add(timeOfFrames, temp * buf.read_uint32(0, bigEndian)); } if (currentStream_ == Video) - xmpData_["Xmp.video.FrameRate"] = (double)totalframes * (double)timeScale_ / (double)timeOfFrames; + xmpData_["Xmp.video.FrameRate"] = + static_cast(totalframes) * static_cast(timeScale_) / static_cast(timeOfFrames); } // QuickTimeVideo::timeToSampleDecoder void QuickTimeVideo::sampleDesc(size_t size) { @@ -1537,11 +1539,11 @@ void QuickTimeVideo::movieHeaderDecoder(size_t size) { void QuickTimeVideo::aspectRatio() { // TODO - Make a better unified method to handle all cases of Aspect Ratio - double aspectRatio = (double)width_ / (double)height_; + double aspectRatio = static_cast(width_) / static_cast(height_); aspectRatio = floor(aspectRatio * 10) / 10; xmpData_["Xmp.video.AspectRatio"] = aspectRatio; - int aR = (int)((aspectRatio * 10.0) + 0.1); + auto aR = static_cast((aspectRatio * 10.0) + 0.1); switch (aR) { case 13: diff --git a/src/sonymn_int.cpp b/src/sonymn_int.cpp index c2a5c32c..99c4c005 100644 --- a/src/sonymn_int.cpp +++ b/src/sonymn_int.cpp @@ -1034,8 +1034,8 @@ std::ostream& SonyMakerNote::printWBShiftABGMPrecise(std::ostream& os, const Val } std::ios::fmtflags f(os.flags()); - const auto temp0 = static_cast(value.toInt64(0)) / double(1000.0); - const auto temp1 = static_cast(value.toInt64(1)) / double(1000.0); + const auto temp0 = static_cast(value.toInt64(0)) / (1000.0); + const auto temp1 = static_cast(value.toInt64(1)) / (1000.0); os << "A/B: "; if (temp0 == 0) { @@ -1067,7 +1067,7 @@ std::ostream& SonyMakerNote::printExposureStandardAdjustment(std::ostream& os, c std::ios::fmtflags f(os.flags()); const auto [r, s] = value.toRational(); - os << std::fixed << std::setprecision(1) << (double(r) / double(s)); + os << std::fixed << std::setprecision(1) << (static_cast(r) / static_cast(s)); os.flags(f); return os; diff --git a/src/tags_int.hpp b/src/tags_int.hpp index 05877edd..5eaa1afe 100644 --- a/src/tags_int.hpp +++ b/src/tags_int.hpp @@ -51,7 +51,7 @@ struct StringTagDetails { bool operator==(const char* key) const { return (strcmp(val_, key) == 0); } - bool operator==(const std::string key) const { + bool operator==(const std::string& key) const { return (key == val_); } }; // struct TagDetails