mirror of
https://github.com/yuzu-emu/FasTC.git
synced 2024-11-27 16:34:23 +01:00
Fix some MSVC rot
This commit is contained in:
parent
13d8407163
commit
e8b58e3fd0
@ -122,14 +122,4 @@ TARGET_LINK_LIBRARIES(${TEST_NAME} FasTCBase)
|
|||||||
TARGET_LINK_LIBRARIES(${TEST_NAME} FasTCIO)
|
TARGET_LINK_LIBRARIES(${TEST_NAME} FasTCIO)
|
||||||
TARGET_LINK_LIBRARIES(${TEST_NAME} FasTCCore)
|
TARGET_LINK_LIBRARIES(${TEST_NAME} FasTCCore)
|
||||||
|
|
||||||
IF(MSVC)
|
ADD_TEST(NAME ${TEST_NAME} WORKING_DIRECTORY ${CMAKE_BINARY_DIR} COMMAND ${TEST_NAME})
|
||||||
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()
|
|
@ -133,8 +133,8 @@ namespace FasTC {
|
|||||||
Image<IPixel> *channelTwo,
|
Image<IPixel> *channelTwo,
|
||||||
Image<IPixel> *channelThree);
|
Image<IPixel> *channelThree);
|
||||||
|
|
||||||
extern void DiscreteCosineXForm(Image<IPixel> *img, int blockSize);
|
extern void DiscreteCosineXForm(Image<IPixel> *img, uint32 blockSize);
|
||||||
extern void InvDiscreteCosineXForm(Image<IPixel> *img, int blockSize);
|
extern void InvDiscreteCosineXForm(Image<IPixel> *img, uint32 blockSize);
|
||||||
} // namespace FasTC
|
} // namespace FasTC
|
||||||
|
|
||||||
#endif // __TEXCOMP_IMAGE_H__
|
#endif // __TEXCOMP_IMAGE_H__
|
||||||
|
@ -43,6 +43,9 @@
|
|||||||
|
|
||||||
#include "FasTC/Image.h"
|
#include "FasTC/Image.h"
|
||||||
|
|
||||||
|
#define _USE_MATH_DEFINES
|
||||||
|
#include <cmath>
|
||||||
|
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
#include <cstdlib>
|
#include <cstdlib>
|
||||||
#include <cstdio>
|
#include <cstdio>
|
||||||
@ -50,9 +53,6 @@
|
|||||||
#include <cassert>
|
#include <cassert>
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
|
|
||||||
#define _USE_MATH_DEFINES
|
|
||||||
#include <cmath>
|
|
||||||
|
|
||||||
#include "FasTC/Color.h"
|
#include "FasTC/Color.h"
|
||||||
#include "FasTC/Pixel.h"
|
#include "FasTC/Pixel.h"
|
||||||
#include "FasTC/IPixel.h"
|
#include "FasTC/IPixel.h"
|
||||||
@ -737,7 +737,7 @@ static void IDCT(Image<IPixel> *img) {
|
|||||||
if (u == 0 && v == 0) {
|
if (u == 0 && v == 0) {
|
||||||
idct /= N;
|
idct /= N;
|
||||||
} else if (u == 0 || v == 0) {
|
} else if (u == 0 || v == 0) {
|
||||||
idct *= sqrt(2) / N;
|
idct *= sqrtf(2) / N;
|
||||||
} else {
|
} else {
|
||||||
idct *= 2 / N;
|
idct *= 2 / N;
|
||||||
}
|
}
|
||||||
@ -751,20 +751,20 @@ static void IDCT(Image<IPixel> *img) {
|
|||||||
*img = new_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 (NULL != fn);
|
||||||
assert (0 < blockSize);
|
assert (0 < blockSize);
|
||||||
assert (static_cast<uint32>(blockSize) < img->GetWidth());
|
assert (blockSize < img->GetWidth());
|
||||||
assert (static_cast<uint32>(blockSize) < img->GetHeight());
|
assert (blockSize < img->GetHeight());
|
||||||
|
|
||||||
Image<IPixel> block(blockSize, blockSize);
|
Image<IPixel> block(blockSize, blockSize);
|
||||||
for (unsigned int j = 0; j < img->GetHeight(); j += blockSize) {
|
for (uint32 j = 0; j < img->GetHeight(); j += blockSize) {
|
||||||
for (unsigned int i = 0; i < img->GetWidth(); i += blockSize) {
|
for (uint32 i = 0; i < img->GetWidth(); i += blockSize) {
|
||||||
// Populate block
|
// Populate block
|
||||||
for (int y = 0; y < blockSize; ++y) {
|
for (uint32 y = 0; y < blockSize; ++y) {
|
||||||
for (int x = 0; x < blockSize; ++x) {
|
for (uint32 x = 0; x < blockSize; ++x) {
|
||||||
IPixel xx = std::min(img->GetWidth() - 1, i + x);
|
uint32 xx = std::min(img->GetWidth() - 1, i + x);
|
||||||
IPixel yy = std::min(img->GetHeight() - 1, j + y);
|
uint32 yy = std::min(img->GetHeight() - 1, j + y);
|
||||||
block(x, y) = (*img)(xx, yy);
|
block(x, y) = (*img)(xx, yy);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -773,8 +773,8 @@ static void RunDCTBlockFn(Image<IPixel> *img, int blockSize, DCTBlockFn fn) {
|
|||||||
fn(&block);
|
fn(&block);
|
||||||
|
|
||||||
// Put it back in the original image
|
// Put it back in the original image
|
||||||
for (int y = 0; y < blockSize; ++y) {
|
for (uint32 y = 0; y < blockSize; ++y) {
|
||||||
for (int x = 0; x < blockSize; ++x) {
|
for (uint32 x = 0; x < blockSize; ++x) {
|
||||||
if (i + x >= img->GetWidth()) {
|
if (i + x >= img->GetWidth()) {
|
||||||
continue;
|
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);
|
RunDCTBlockFn(img, blockSize, DCT);
|
||||||
}
|
}
|
||||||
|
|
||||||
void InvDiscreteCosineXForm(Image<IPixel> *img, int blockSize) {
|
void InvDiscreteCosineXForm(Image<IPixel> *img, uint32 blockSize) {
|
||||||
RunDCTBlockFn(img, blockSize, IDCT);
|
RunDCTBlockFn(img, blockSize, IDCT);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -58,6 +58,7 @@
|
|||||||
#include "Utils.h"
|
#include "Utils.h"
|
||||||
|
|
||||||
#include <cstdlib>
|
#include <cstdlib>
|
||||||
|
#include <functional>
|
||||||
|
|
||||||
TEST(Image, NonSpecificConstructor) {
|
TEST(Image, NonSpecificConstructor) {
|
||||||
FasTC::Pixel p;
|
FasTC::Pixel p;
|
||||||
@ -188,16 +189,20 @@ TEST(Image, SplitImage) {
|
|||||||
|
|
||||||
for(uint32 j = 0; j < h; j++) {
|
for(uint32 j = 0; j < h; j++) {
|
||||||
for(uint32 i = 0; i < w; i++) {
|
for(uint32 i = 0; i < w; i++) {
|
||||||
EXPECT_EQ(i1(i, j), img(i, j).R());
|
EXPECT_FLOAT_EQ(i1(i, j), img(i, j).R());
|
||||||
EXPECT_EQ(i2(i, j), img(i, j).G());
|
EXPECT_FLOAT_EQ(i2(i, j), img(i, j).G());
|
||||||
EXPECT_EQ(i3(i, j), img(i, j).B());
|
EXPECT_FLOAT_EQ(i3(i, j), img(i, j).B());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
FasTC::Image<FasTC::Color> img2(w, h);
|
FasTC::Image<FasTC::Color> img2(w, h);
|
||||||
for(uint32 j = 0; j < h; j++) {
|
for(uint32 j = 0; j < h; j++) {
|
||||||
for(uint32 i = 0; i < w; i++) {
|
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 j = 0; j < h; j++) {
|
||||||
for(uint32 i = 0; i < w; i++) {
|
for(uint32 i = 0; i < w; i++) {
|
||||||
EXPECT_EQ(i1(i, j), img2(i, j).R());
|
EXPECT_FLOAT_EQ(i1(i, j), img2(i, j).R());
|
||||||
EXPECT_EQ(i2(i, j), img2(i, j).G());
|
EXPECT_FLOAT_EQ(i2(i, j), img2(i, j).G());
|
||||||
EXPECT_EQ(i3(i, j), img2(i, j).B());
|
EXPECT_FLOAT_EQ(i3(i, j), img2(i, j).B());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -247,7 +252,7 @@ TEST(Image, IDCT) {
|
|||||||
FasTC::Image<FasTC::IPixel> img(w, h);
|
FasTC::Image<FasTC::IPixel> img(w, h);
|
||||||
for (uint32 j = 0; j < h; ++j) {
|
for (uint32 j = 0; j < h; ++j) {
|
||||||
for (uint32 i = 0; i < w; ++i) {
|
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
|
// First make sure they're different
|
||||||
for (uint32 j = 0; j < h; ++j) {
|
for (uint32 j = 0; j < h; ++j) {
|
||||||
for (uint32 i = 0; i < w; ++i) {
|
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));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -71,7 +71,7 @@ void gen_random(char *s, const int len) {
|
|||||||
"ABCDEFGHIJKLMNOPQRSTUVWXYZ"
|
"ABCDEFGHIJKLMNOPQRSTUVWXYZ"
|
||||||
"abcdefghijklmnopqrstuvwxyz";
|
"abcdefghijklmnopqrstuvwxyz";
|
||||||
|
|
||||||
srand(time(NULL));
|
srand(static_cast<unsigned int>(time(NULL)));
|
||||||
for (int i = 0; i < len; ++i) {
|
for (int i = 0; i < len; ++i) {
|
||||||
s[i] = alphanum[rand() % (sizeof(alphanum) - 1)];
|
s[i] = alphanum[rand() % (sizeof(alphanum) - 1)];
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user