From 89110be6026601b1ded7a6e24289a960c9a1058d Mon Sep 17 00:00:00 2001 From: Pavel Krajcevski Date: Tue, 15 Oct 2013 00:31:33 -0400 Subject: [PATCH] Get rid of a bunch of MSVC compiler warnings. --- Base/include/Pixel.h | 3 ++- Base/include/VectorBase.h | 5 +++-- Base/src/Color.cpp | 2 +- Base/src/Image.cpp | 8 ++++---- Core/src/CompressedImage.cpp | 4 ++++ PVRTCEncoder/src/Compressor.cpp | 4 ++-- PVRTCEncoder/src/PVRTCImage.cpp | 6 +++--- 7 files changed, 19 insertions(+), 13 deletions(-) diff --git a/Base/include/Pixel.h b/Base/include/Pixel.h index bea4816..54555c9 100644 --- a/Base/include/Pixel.h +++ b/Base/include/Pixel.h @@ -104,7 +104,8 @@ class Pixel : public Vector4 { // smaller to larger bit depths. void ChangeBitDepth(const uint8 (&newDepth)[4]); - static float ConvertChannelToFloat(uint8 channel, uint8 bitDepth) { + template + static float ConvertChannelToFloat(IntType channel, uint8 bitDepth) { float denominator = static_cast((1 << bitDepth) - 1); return static_cast(channel) / denominator; } diff --git a/Base/include/VectorBase.h b/Base/include/VectorBase.h index f870799..45b0fba 100644 --- a/Base/include/VectorBase.h +++ b/Base/include/VectorBase.h @@ -39,6 +39,7 @@ namespace FasTC { T vec[N]; public: + typedef T ScalarType; VectorBase() { } VectorBase(const VectorBase &other) { @@ -194,7 +195,7 @@ namespace FasTC { static inline VectorType ScalarMultiply(const VectorType &v, const ScalarType &s) { VectorType a; for(int i = 0; i < VectorType::Size; i++) - a(i) = v(i) * s; + a(i) = static_cast(v(i) * s); return a; } @@ -211,7 +212,7 @@ namespace FasTC { static inline VectorType ScalarDivide(const VectorType &v, const ScalarType &s) { VectorType a; for(int i = 0; i < VectorType::Size; i++) - a(i) = v(i) / s; + a(i) = static_cast(v(i) / s); return a; } diff --git a/Base/src/Color.cpp b/Base/src/Color.cpp index a046f58..5db3b89 100644 --- a/Base/src/Color.cpp +++ b/Base/src/Color.cpp @@ -75,7 +75,7 @@ namespace FasTC { // Tests for equality by comparing the values and the bit depths. bool Color::operator==(const Color &other) const { - static const float kEpsilon = 0.001; + static const float kEpsilon = 0.001f; for(uint32 c = 0; c < 4; c++) { if(fabs(Component(c) - other.Component(c)) > kEpsilon) { return false; diff --git a/Base/src/Image.cpp b/Base/src/Image.cpp index c2c9d33..2f913a2 100644 --- a/Base/src/Image.cpp +++ b/Base/src/Image.cpp @@ -221,7 +221,7 @@ double Image::ComputePSNR(Image *other) { static Image FilterValid(const Image &img, uint32 size, double sigma) { assert(size % 2); Image gaussian(size, size); - GenerateGaussianKernel(gaussian, size, sigma); + GenerateGaussianKernel(gaussian, size, static_cast(sigma)); double sum = 0.0; for(uint32 j = 0; j < size; j++) { @@ -285,8 +285,8 @@ double Image::ComputeSSIM(Image *other) { for(uint32 j = 0; j < GetHeight(); j++) { for(uint32 i = 0; i < GetWidth(); i++) { - img1(i, j) = 255.0 * static_cast(img1(i, j)); - img2(i, j) = 255.0 * static_cast(img2(i, j)); + img1(i, j) = 255.0f * static_cast(img1(i, j)); + img2(i, j) = 255.0f * static_cast(img2(i, j)); } } @@ -498,7 +498,7 @@ void Image::Filter(const Image &kernel) { for(uint32 j = 0; j < k.GetHeight(); j++) { for(uint32 i = 0; i < k.GetWidth(); i++) { - k(i, j) = static_cast(k(i, j)) / sum; + k(i, j) = static_cast(k(i, j) / sum); } } diff --git a/Core/src/CompressedImage.cpp b/Core/src/CompressedImage.cpp index f6f4f1f..66b64e7 100644 --- a/Core/src/CompressedImage.cpp +++ b/Core/src/CompressedImage.cpp @@ -113,7 +113,11 @@ bool CompressedImage::DecompressImage(unsigned char *outBuf, unsigned int outBuf switch(m_Format) { case eCompressionFormat_PVRTC: { +#ifndef NDEBUG + PVRTCC::Decompress(dj, false, PVRTCC::eWrapMode_Wrap, true); +#else PVRTCC::Decompress(dj); +#endif } break; diff --git a/PVRTCEncoder/src/Compressor.cpp b/PVRTCEncoder/src/Compressor.cpp index 03c1c42..37277d5 100644 --- a/PVRTCEncoder/src/Compressor.cpp +++ b/PVRTCEncoder/src/Compressor.cpp @@ -188,7 +188,7 @@ namespace PVRTCC { uint32 idx = static_cast(xx) + width * static_cast(yy); uint8 ix = static_cast(255.0f * LookupIntensity(labels, pixels, idx) + 0.5f); - if(ix >= i0) { + if(ix > i0) { ng++; } @@ -415,7 +415,7 @@ namespace PVRTCC { for(uint32 j = 0; j < blocksH; j++) { for(uint32 i = 0; i < blocksW; i++) { - float minIntensity = 1.1, maxIntensity = -0.1; + float minIntensity = 1.1f, maxIntensity = -0.1f; uint32 minIntensityIdx = 0, maxIntensityIdx = 0; for(uint32 y = j*4; y <= (j+1)*4; y++) for(uint32 x = i*4; x <= (i+1)*4; x++) { diff --git a/PVRTCEncoder/src/PVRTCImage.cpp b/PVRTCEncoder/src/PVRTCImage.cpp index 1402e06..a992df3 100644 --- a/PVRTCEncoder/src/PVRTCImage.cpp +++ b/PVRTCEncoder/src/PVRTCImage.cpp @@ -224,7 +224,7 @@ static Pixel AveragePixels(const ::std::vector &pixels) { Pixel result; for(uint32 c = 0; c < 4; c++) { - result.Component(c) = sum[c] / pixels.size(); + result.Component(c) = static_cast(sum[c] / pixels.size()); } return result; @@ -337,7 +337,7 @@ void Image::ContentAwareDownscale(uint32 xtimes, uint32 ytimes, Iy[idx] = (I[yphidx] - I[ymhidx]) / 2.0f; for(uint32 c = 0; c <= 3; c++) { - #define CPNT(dx) Pixel::ConvertChannelToFloat(GetPixels()[dx].Component(c), bitDepth[c]) + #define CPNT(dx) Pixel::ConvertChannelToFloat(static_cast(GetPixels()[dx].Component(c)), bitDepth[c]) Ix[c][idx] = (CPNT(xphidx) - CPNT(xmhidx)) / 2.0f; Ixx[c][idx] = (CPNT(xphidx) - 2.0f*CPNT(idx) + CPNT(xmhidx)) / 2.0f; Iyy[c][idx] = (CPNT(yphidx) - 2.0f*CPNT(idx) + CPNT(ymhidx)) / 2.0f; @@ -378,7 +378,7 @@ void Image::ContentAwareDownscale(uint32 xtimes, uint32 ytimes, float denom = Ixsq + Iysq; for(uint32 c = 0; c < 4; c++) { - float I0 = Pixel::ConvertChannelToFloat(current.Component(c), bitDepth[c]); + float I0 = Pixel::ConvertChannelToFloat(static_cast(current.Component(c)), bitDepth[c]); float It = Ixx[c][idx] + Iyy[c][idx]; if(fabs(denom) > 1e-6) { It -= (Ixsq * Ixx[c][idx] +