Get rid of a bunch of MSVC compiler warnings.

This commit is contained in:
Pavel Krajcevski 2013-10-15 00:31:33 -04:00
parent a9d8f4ca6e
commit 89110be602
7 changed files with 19 additions and 13 deletions

View file

@ -104,7 +104,8 @@ class Pixel : public Vector4<uint16> {
// smaller to larger bit depths.
void ChangeBitDepth(const uint8 (&newDepth)[4]);
static float ConvertChannelToFloat(uint8 channel, uint8 bitDepth) {
template<typename IntType>
static float ConvertChannelToFloat(IntType channel, uint8 bitDepth) {
float denominator = static_cast<float>((1 << bitDepth) - 1);
return static_cast<float>(channel) / denominator;
}

View file

@ -39,6 +39,7 @@ namespace FasTC {
T vec[N];
public:
typedef T ScalarType;
VectorBase() { }
VectorBase(const VectorBase<T, N> &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<VectorType::ScalarType>(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<VectorType::ScalarType>(v(i) / s);
return a;
}

View file

@ -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;

View file

@ -221,7 +221,7 @@ double Image<PixelType>::ComputePSNR(Image<PixelType> *other) {
static Image<IPixel> FilterValid(const Image<IPixel> &img, uint32 size, double sigma) {
assert(size % 2);
Image<IPixel> gaussian(size, size);
GenerateGaussianKernel(gaussian, size, sigma);
GenerateGaussianKernel(gaussian, size, static_cast<float>(sigma));
double sum = 0.0;
for(uint32 j = 0; j < size; j++) {
@ -285,8 +285,8 @@ double Image<PixelType>::ComputeSSIM(Image<PixelType> *other) {
for(uint32 j = 0; j < GetHeight(); j++) {
for(uint32 i = 0; i < GetWidth(); i++) {
img1(i, j) = 255.0 * static_cast<float>(img1(i, j));
img2(i, j) = 255.0 * static_cast<float>(img2(i, j));
img1(i, j) = 255.0f * static_cast<float>(img1(i, j));
img2(i, j) = 255.0f * static_cast<float>(img2(i, j));
}
}
@ -498,7 +498,7 @@ void Image<PixelType>::Filter(const Image<IPixel> &kernel) {
for(uint32 j = 0; j < k.GetHeight(); j++) {
for(uint32 i = 0; i < k.GetWidth(); i++) {
k(i, j) = static_cast<float>(k(i, j)) / sum;
k(i, j) = static_cast<float>(k(i, j) / sum);
}
}

View file

@ -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;

View file

@ -188,7 +188,7 @@ namespace PVRTCC {
uint32 idx = static_cast<uint32>(xx) + width * static_cast<uint32>(yy);
uint8 ix = static_cast<uint8>(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++) {

View file

@ -224,7 +224,7 @@ static Pixel AveragePixels(const ::std::vector<Pixel> &pixels) {
Pixel result;
for(uint32 c = 0; c < 4; c++) {
result.Component(c) = sum[c] / pixels.size();
result.Component(c) = static_cast<uint16>(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<uint8>(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<uint8>(current.Component(c)), bitDepth[c]);
float It = Ixx[c][idx] + Iyy[c][idx];
if(fabs(denom) > 1e-6) {
It -= (Ixsq * Ixx[c][idx] +