From 692cfbcf774d58a6083c52e0af39464303d45f12 Mon Sep 17 00:00:00 2001 From: Pavel Krajcevski Date: Mon, 21 Oct 2013 15:49:42 -0400 Subject: [PATCH] Some compiler SNAFUs on windows. --- Base/src/Image.cpp | 5 +++++ Base/test/TestColor.cpp | 10 +++++----- Base/test/TestImage.cpp | 4 ++-- PVRTCEncoder/src/Compressor.cpp | 10 +++++++--- 4 files changed, 19 insertions(+), 10 deletions(-) diff --git a/Base/src/Image.cpp b/Base/src/Image.cpp index bc44449..8eb19f7 100644 --- a/Base/src/Image.cpp +++ b/Base/src/Image.cpp @@ -59,6 +59,11 @@ static inline T sad( const T &a, const T &b ) { return (a > b)? a - b : b - a; } +// wtf +#ifdef _MSC_VER +template T log2(T x) { return static_cast(log((long double)x) / log(2.0)); } +#endif + namespace FasTC { template diff --git a/Base/test/TestColor.cpp b/Base/test/TestColor.cpp index 9ea7d11..f4920db 100644 --- a/Base/test/TestColor.cpp +++ b/Base/test/TestColor.cpp @@ -53,7 +53,7 @@ #include "gtest/gtest.h" #include "Color.h" -static const float kEpsilon = 1e-6; +static const float kEpsilon = 1e-6f; TEST(Color, DefaultConstructor) { FasTC::Color c; @@ -72,8 +72,8 @@ TEST(Color, AssignmentConstructor) { } TEST(Color, VectorOperators) { - FasTC::Color a(0.1, 0.2, 0.3, 0.4); - FasTC::Color b(0.2, 0.3, 0.4, 0.5); + FasTC::Color a(0.1f, 0.2f, 0.3f, 0.4f); + FasTC::Color b(0.2f, 0.3f, 0.4f, 0.5f); FasTC::Color c = a + b; EXPECT_NEAR(c.R(), 0.3, kEpsilon); @@ -90,8 +90,8 @@ TEST(Color, VectorOperators) { } TEST(Color, EqualityComparison) { - FasTC::Color a(0.1, 0.2, 0.3, 0.4); - FasTC::Color b(0.2, 0.3, 0.4, 0.5); + FasTC::Color a(0.1f, 0.2f, 0.3f, 0.4f); + FasTC::Color b(0.2f, 0.3f, 0.4f, 0.5f); EXPECT_TRUE(a == a && b == b); EXPECT_FALSE(a == b && b == a); diff --git a/Base/test/TestImage.cpp b/Base/test/TestImage.cpp index ff9d8d3..3a63b13 100644 --- a/Base/test/TestImage.cpp +++ b/Base/test/TestImage.cpp @@ -158,9 +158,9 @@ TEST(Image, ComputeMSSIM) { FasTC::Image img(w, h); for(uint32 j = 0; j < h; j++) { for(uint32 i = 0; i < w; i++) { - img(i, j) = + img(i, j) = static_cast( (static_cast(i) * static_cast(j)) / - (static_cast(w) * static_cast(h)); + (static_cast(w) * static_cast(h))); } } diff --git a/PVRTCEncoder/src/Compressor.cpp b/PVRTCEncoder/src/Compressor.cpp index c872073..5d15d64 100644 --- a/PVRTCEncoder/src/Compressor.cpp +++ b/PVRTCEncoder/src/Compressor.cpp @@ -907,9 +907,13 @@ namespace PVRTCC { void DebugOutputLabels(const char *outputPrefix, const CompressionLabel *labels, uint32 width, uint32 height) { - ::std::string prefix(outputPrefix); - DebugOutputImage((prefix + ::std::string("HighLabels")).c_str(), labels, width, height, HighLabelDistance); - DebugOutputImage((prefix + ::std::string("LowLabels")).c_str(), labels, width, height, LowLabelDistance); + ::std::string highName = ::std::string(outputPrefix); + highName += ::std::string("HighLabels"); + DebugOutputImage(highName.c_str(), labels, width, height, HighLabelDistance); + + ::std::string lowName = ::std::string(outputPrefix); + lowName += ::std::string("LowLabels"); + DebugOutputImage(lowName.c_str(), labels, width, height, LowLabelDistance); } #endif