Fix some MSVC rot

This commit is contained in:
Pavel Krajcevski 2016-02-17 12:27:09 -05:00
parent 13d8407163
commit e8b58e3fd0
6 changed files with 38 additions and 43 deletions

View File

@ -122,14 +122,4 @@ TARGET_LINK_LIBRARIES(${TEST_NAME} FasTCBase)
TARGET_LINK_LIBRARIES(${TEST_NAME} FasTCIO)
TARGET_LINK_LIBRARIES(${TEST_NAME} FasTCCore)
IF(MSVC)
ADD_TEST(${TEST_NAME}
${CMAKE_COMMAND} -E chdir ${CMAKE_BINARY_DIR}
${CMAKE_CURRENT_BINARY_DIR}/Debug/${TEST_NAME}
)
ELSE()
ADD_TEST(${TEST_NAME}
${CMAKE_COMMAND} -E chdir ${CMAKE_BINARY_DIR}
${CMAKE_CURRENT_BINARY_DIR}/${TEST_NAME}
)
ENDIF()
ADD_TEST(NAME ${TEST_NAME} WORKING_DIRECTORY ${CMAKE_BINARY_DIR} COMMAND ${TEST_NAME})

View File

@ -133,8 +133,8 @@ namespace FasTC {
Image<IPixel> *channelTwo,
Image<IPixel> *channelThree);
extern void DiscreteCosineXForm(Image<IPixel> *img, int blockSize);
extern void InvDiscreteCosineXForm(Image<IPixel> *img, int blockSize);
extern void DiscreteCosineXForm(Image<IPixel> *img, uint32 blockSize);
extern void InvDiscreteCosineXForm(Image<IPixel> *img, uint32 blockSize);
} // namespace FasTC
#endif // __TEXCOMP_IMAGE_H__

View File

@ -43,6 +43,9 @@
#include "FasTC/Image.h"
#define _USE_MATH_DEFINES
#include <cmath>
#include <algorithm>
#include <cstdlib>
#include <cstdio>
@ -50,9 +53,6 @@
#include <cassert>
#include <iostream>
#define _USE_MATH_DEFINES
#include <cmath>
#include "FasTC/Color.h"
#include "FasTC/Pixel.h"
#include "FasTC/IPixel.h"
@ -737,7 +737,7 @@ static void IDCT(Image<IPixel> *img) {
if (u == 0 && v == 0) {
idct /= N;
} else if (u == 0 || v == 0) {
idct *= sqrt(2) / N;
idct *= sqrtf(2) / N;
} else {
idct *= 2 / N;
}
@ -751,20 +751,20 @@ static void IDCT(Image<IPixel> *img) {
*img = new_img;
}
static void RunDCTBlockFn(Image<IPixel> *img, int blockSize, DCTBlockFn fn) {
static void RunDCTBlockFn(Image<IPixel> *img, uint32 blockSize, DCTBlockFn fn) {
assert (NULL != fn);
assert (0 < blockSize);
assert (static_cast<uint32>(blockSize) < img->GetWidth());
assert (static_cast<uint32>(blockSize) < img->GetHeight());
assert (blockSize < img->GetWidth());
assert (blockSize < img->GetHeight());
Image<IPixel> block(blockSize, blockSize);
for (unsigned int j = 0; j < img->GetHeight(); j += blockSize) {
for (unsigned int i = 0; i < img->GetWidth(); i += blockSize) {
for (uint32 j = 0; j < img->GetHeight(); j += blockSize) {
for (uint32 i = 0; i < img->GetWidth(); i += blockSize) {
// Populate block
for (int y = 0; y < blockSize; ++y) {
for (int x = 0; x < blockSize; ++x) {
IPixel xx = std::min(img->GetWidth() - 1, i + x);
IPixel yy = std::min(img->GetHeight() - 1, j + y);
for (uint32 y = 0; y < blockSize; ++y) {
for (uint32 x = 0; x < blockSize; ++x) {
uint32 xx = std::min(img->GetWidth() - 1, i + x);
uint32 yy = std::min(img->GetHeight() - 1, j + y);
block(x, y) = (*img)(xx, yy);
}
}
@ -773,8 +773,8 @@ static void RunDCTBlockFn(Image<IPixel> *img, int blockSize, DCTBlockFn fn) {
fn(&block);
// Put it back in the original image
for (int y = 0; y < blockSize; ++y) {
for (int x = 0; x < blockSize; ++x) {
for (uint32 y = 0; y < blockSize; ++y) {
for (uint32 x = 0; x < blockSize; ++x) {
if (i + x >= img->GetWidth()) {
continue;
}
@ -793,11 +793,11 @@ static void RunDCTBlockFn(Image<IPixel> *img, int blockSize, DCTBlockFn fn) {
}
}
void DiscreteCosineXForm(Image<IPixel> *img, int blockSize) {
void DiscreteCosineXForm(Image<IPixel> *img, uint32 blockSize) {
RunDCTBlockFn(img, blockSize, DCT);
}
void InvDiscreteCosineXForm(Image<IPixel> *img, int blockSize) {
void InvDiscreteCosineXForm(Image<IPixel> *img, uint32 blockSize) {
RunDCTBlockFn(img, blockSize, IDCT);
}

View File

@ -58,6 +58,7 @@
#include "Utils.h"
#include <cstdlib>
#include <functional>
TEST(Image, NonSpecificConstructor) {
FasTC::Pixel p;
@ -188,16 +189,20 @@ TEST(Image, SplitImage) {
for(uint32 j = 0; j < h; j++) {
for(uint32 i = 0; i < w; i++) {
EXPECT_EQ(i1(i, j), img(i, j).R());
EXPECT_EQ(i2(i, j), img(i, j).G());
EXPECT_EQ(i3(i, j), img(i, j).B());
EXPECT_FLOAT_EQ(i1(i, j), img(i, j).R());
EXPECT_FLOAT_EQ(i2(i, j), img(i, j).G());
EXPECT_FLOAT_EQ(i3(i, j), img(i, j).B());
}
}
FasTC::Image<FasTC::Color> img2(w, h);
for(uint32 j = 0; j < h; j++) {
for(uint32 i = 0; i < w; i++) {
img2(i, j) = FasTC::Color(j, i, i*j, 255);
const float r = static_cast<float>(j);
const float g = static_cast<float>(i);
const float b = static_cast<float>(i*j);
const float a = 255.0f;
img2(i, j) = FasTC::Color(r, g, b, a);
}
}
@ -205,9 +210,9 @@ TEST(Image, SplitImage) {
for(uint32 j = 0; j < h; j++) {
for(uint32 i = 0; i < w; i++) {
EXPECT_EQ(i1(i, j), img2(i, j).R());
EXPECT_EQ(i2(i, j), img2(i, j).G());
EXPECT_EQ(i3(i, j), img2(i, j).B());
EXPECT_FLOAT_EQ(i1(i, j), img2(i, j).R());
EXPECT_FLOAT_EQ(i2(i, j), img2(i, j).G());
EXPECT_FLOAT_EQ(i3(i, j), img2(i, j).B());
}
}
}
@ -247,7 +252,7 @@ TEST(Image, IDCT) {
FasTC::Image<FasTC::IPixel> img(w, h);
for (uint32 j = 0; j < h; ++j) {
for (uint32 i = 0; i < w; ++i) {
img(i, j) = static_cast<FasTC::IPixel>(i + j);
img(i, j) = static_cast<float>(i + j);
}
}
@ -260,7 +265,7 @@ TEST(Image, IDCT) {
// First make sure they're different
for (uint32 j = 0; j < h; ++j) {
for (uint32 i = 0; i < w; ++i) {
EXPECT_NE(img(i, j), orig(i, j));
EXPECT_PRED2(std::not_equal_to<float>(), img(i, j), orig(i, j));
}
}

View File

@ -71,7 +71,7 @@ void gen_random(char *s, const int len) {
"ABCDEFGHIJKLMNOPQRSTUVWXYZ"
"abcdefghijklmnopqrstuvwxyz";
srand(time(NULL));
srand(static_cast<unsigned int>(time(NULL)));
for (int i = 0; i < len; ++i) {
s[i] = alphanum[rand() % (sizeof(alphanum) - 1)];
}

View File

@ -459,7 +459,7 @@ namespace PVRTCC {
neighbors[2] = &(labels[idxr(i+1, j+1)]);
// Add bottom label
neighbors[3] = &(labels[idxr(i, j+1)]);
neighbors[3] = &(labels[idxr(i, j+1)]);
// Add bottom left label
neighbors[4] = &(labels[idxr(i-1, j+1)]);
@ -571,9 +571,9 @@ namespace PVRTCC {
#endif
// Average all of the values together now...
FasTC::Color high, low;
Indexer localIdxr(4, 4);
Indexer localIdxr(4, 4);
for(uint32 y = 0; y < localIdxr.GetHeight(); y++)
for(uint32 x = 0; x < localIdxr.GetWidth(); x++) {
for(uint32 x = 0; x < localIdxr.GetWidth(); x++) {
uint32 idx = localIdxr(x, y);
FasTC::Color c = blockColors[0][idx];
if(c.A() < 0.0f) {