Some compiler SNAFUs on windows.

This commit is contained in:
Pavel Krajcevski 2013-10-21 15:49:42 -04:00
parent 53403fd1a9
commit 692cfbcf77
4 changed files with 19 additions and 10 deletions

View file

@ -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<typename T> T log2(T x) { return static_cast<T>(log((long double)x) / log(2.0)); }
#endif
namespace FasTC {
template<typename PixelType>

View file

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

View file

@ -158,9 +158,9 @@ TEST(Image, ComputeMSSIM) {
FasTC::Image<FasTC::IPixel> 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<float>(
(static_cast<double>(i) * static_cast<double>(j)) /
(static_cast<double>(w) * static_cast<double>(h));
(static_cast<double>(w) * static_cast<double>(h)));
}
}

View file

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