mirror of
https://github.com/yuzu-emu/FasTC.git
synced 2024-11-27 21:54:15 +01:00
Fix a few compiler warnings and add the BPTCEncoder license.
This commit is contained in:
parent
28cf254fe5
commit
29bd1368e6
@ -473,7 +473,7 @@ double BC7CompressionMode::CompressSingleColor(
|
||||
|
||||
const float *errorWeights = BC7C::GetErrorMetric();
|
||||
float error = 0.0;
|
||||
for(int i = 0; i < kNumColorChannels; i++) {
|
||||
for(uint32 i = 0; i < kNumColorChannels; i++) {
|
||||
float e = static_cast<float>(dist[i]) * errorWeights[i];
|
||||
error += e * e;
|
||||
}
|
||||
|
16
BPTCEncoder/src/LICENSE.txt
Normal file
16
BPTCEncoder/src/LICENSE.txt
Normal file
@ -0,0 +1,16 @@
|
||||
//--------------------------------------------------------------------------------------
|
||||
// Copyright 2011 Intel Corporation
|
||||
// All Rights Reserved
|
||||
//
|
||||
// Permission is granted to use, copy, distribute and prepare derivative works of this
|
||||
// software for any purpose and without fee, provided, that the above copyright notice
|
||||
// and this statement appear in all copies. Intel makes no representations about the
|
||||
// suitability of this software for any purpose. THIS SOFTWARE IS PROVIDED "AS IS."
|
||||
// INTEL SPECIFICALLY DISCLAIMS ALL WARRANTIES, EXPRESS OR IMPLIED, AND ALL LIABILITY,
|
||||
// INCLUDING CONSEQUENTIAL AND OTHER INDIRECT DAMAGES, FOR THE USE OF THIS SOFTWARE,
|
||||
// INCLUDING LIABILITY FOR INFRINGEMENT OF ANY PROPRIETARY RIGHTS, AND INCLUDING THE
|
||||
// WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. Intel does not
|
||||
// assume any responsibility for any errors which may appear in this software nor any
|
||||
// responsibility to update it.
|
||||
//
|
||||
//--------------------------------------------------------------------------------------
|
@ -58,8 +58,8 @@ class CompressedImage : public Image {
|
||||
|
||||
private:
|
||||
ECompressionFormat m_Format;
|
||||
uint32 m_DataSz;
|
||||
uint32 *m_RGBAData;
|
||||
uint32 m_DataSz;
|
||||
|
||||
void InitData(const unsigned char *withData);
|
||||
public:
|
||||
|
@ -275,13 +275,11 @@ namespace PVRTCC {
|
||||
|
||||
if(bDebugImages) {
|
||||
Image dbgMod(h, w);
|
||||
uint8 modDepth[4] = { 8, 4, 4, 4 };
|
||||
|
||||
for(int i = 0; i < h*w; i++) {
|
||||
for(uint32 i = 0; i < h*w; i++) {
|
||||
float fb = static_cast<float>(modValues[i]);
|
||||
uint8 val = static_cast<uint8>((fb / 8.0f) * 15.0f);
|
||||
|
||||
for(int k = 1; k < 4; k++) {
|
||||
for(uint32 k = 1; k < 4; k++) {
|
||||
dbgMod(i%w, i/w).Component(k) = val;
|
||||
}
|
||||
dbgMod(i%w, i/w).A() = 0xFF;
|
||||
|
@ -303,8 +303,8 @@ const Pixel & Image::operator()(uint32 i, uint32 j) const {
|
||||
void Image::DebugOutput(const char *filename) const {
|
||||
uint32 *outPixels = new uint32[m_Width * m_Height];
|
||||
const uint8 fullDepth[4] = { 8, 8, 8, 8 };
|
||||
for(int j = 0; j < m_Height; j++) {
|
||||
for(int i = 0; i < m_Width; i++) {
|
||||
for(uint32 j = 0; j < m_Height; j++) {
|
||||
for(uint32 i = 0; i < m_Width; i++) {
|
||||
uint32 idx = j * m_Width + i;
|
||||
Pixel p = m_Pixels[idx];
|
||||
p.ChangeBitDepth(fullDepth);
|
||||
|
@ -187,12 +187,17 @@ TEST(Block, GetLerpValue) {
|
||||
}
|
||||
|
||||
TEST(Block, Get2BPPLerpValue) {
|
||||
uint8 noModData[8] = { 0xDA, 0x27, 0xE4, 0x1B, 0x0, 0x0, 0x0, 0x0 };
|
||||
union {
|
||||
uint8 noModDataBytes[8];
|
||||
uint32 noModDataInts[2];
|
||||
} noModDataVals;
|
||||
const uint8 noModData[8] = { 0xDA, 0x27, 0xE4, 0x1B, 0x0, 0x0, 0x0, 0x0 };
|
||||
memcpy(noModDataVals.noModDataBytes, noModData, sizeof(noModData));
|
||||
PVRTCC::Block b(noModData);
|
||||
|
||||
uint32 dataInt = *(reinterpret_cast<const uint32 *>(noModData));
|
||||
uint32 noModInt = noModDataVals.noModDataInts[0];
|
||||
for(uint32 i = 0; i < 32; i++) {
|
||||
EXPECT_EQ(b.Get2BPPLerpValue(i), (dataInt >> i) & 0x1);
|
||||
EXPECT_EQ(b.Get2BPPLerpValue(i), (noModInt >> i) & 0x1);
|
||||
}
|
||||
|
||||
uint8 modData[8];
|
||||
|
@ -72,8 +72,8 @@ TEST(Decompressor, DecompressWhite) {
|
||||
DecompressionJob dcj (pvrData, outData, kWidth, kHeight);
|
||||
PVRTCC::Decompress(dcj);
|
||||
|
||||
for(int i = 0; i < kWidth; i++) {
|
||||
for(int j = 0; j < kHeight; j++) {
|
||||
for(uint32 i = 0; i < kWidth; i++) {
|
||||
for(uint32 j = 0; j < kHeight; j++) {
|
||||
const uint32 *pixelData = reinterpret_cast<const uint32 *>(outData);
|
||||
const uint32 p = pixelData[j*kWidth + i];
|
||||
EXPECT_EQ(PixelPrinter(p), PixelPrinter(0xFFFFFFFF));
|
||||
@ -87,7 +87,7 @@ TEST(Decompressor, DecompressGray) {
|
||||
|
||||
uint8 pvrData[512];
|
||||
|
||||
for(int i = 0; i < 512; i += 8) {
|
||||
for(uint32 i = 0; i < 512; i += 8) {
|
||||
uint8 grayBlock[8] = { 0xAA, 0xAA, 0xAA, 0xAA, 0xF0, 0xBD, 0x0F, 0xC2 };
|
||||
memcpy(pvrData + i, grayBlock, 8);
|
||||
}
|
||||
@ -97,8 +97,8 @@ TEST(Decompressor, DecompressGray) {
|
||||
DecompressionJob dcj (pvrData, outData, kWidth, kHeight);
|
||||
PVRTCC::Decompress(dcj);
|
||||
|
||||
for(int i = 0; i < kWidth; i++) {
|
||||
for(int j = 0; j < kHeight; j++) {
|
||||
for(uint32 i = 0; i < kWidth; i++) {
|
||||
for(uint32 j = 0; j < kHeight; j++) {
|
||||
const uint32 *pixelData = reinterpret_cast<const uint32 *>(outData);
|
||||
const uint32 p = pixelData[j*kWidth + i];
|
||||
EXPECT_EQ(PixelPrinter(p), PixelPrinter(0xFF818080));
|
||||
|
@ -61,8 +61,8 @@ TEST(Image, NonSpecificConstructor) {
|
||||
PVRTCC::Pixel p;
|
||||
|
||||
PVRTCC::Image img (4, 4);
|
||||
for(int i = 0; i < 4; i++) {
|
||||
for(int j = 0; j < 4; j++) {
|
||||
for(uint32 i = 0; i < 4; i++) {
|
||||
for(uint32 j = 0; j < 4; j++) {
|
||||
EXPECT_TRUE(img(i, j) == p);
|
||||
}
|
||||
}
|
||||
@ -70,16 +70,16 @@ TEST(Image, NonSpecificConstructor) {
|
||||
|
||||
TEST(Image, SpecificConstructor) {
|
||||
PVRTCC::Pixel pxs[16];
|
||||
for(int i = 0; i < 4; i++) {
|
||||
for(int j = 0; j < 4; j++) {
|
||||
for(uint32 i = 0; i < 4; i++) {
|
||||
for(uint32 j = 0; j < 4; j++) {
|
||||
pxs[j*4 + i].R() = i;
|
||||
pxs[j*4 + i].G() = j;
|
||||
}
|
||||
}
|
||||
|
||||
PVRTCC::Image img(4, 4, pxs);
|
||||
for(int i = 0; i < 4; i++) {
|
||||
for(int j = 0; j < 4; j++) {
|
||||
for(uint32 i = 0; i < 4; i++) {
|
||||
for(uint32 j = 0; j < 4; j++) {
|
||||
EXPECT_TRUE(img(i, j) == pxs[j*4 + i]);
|
||||
}
|
||||
}
|
||||
@ -87,8 +87,8 @@ TEST(Image, SpecificConstructor) {
|
||||
|
||||
TEST(Image, CopyConstructor) {
|
||||
PVRTCC::Pixel pxs[16];
|
||||
for(int i = 0; i < 4; i++) {
|
||||
for(int j = 0; j < 4; j++) {
|
||||
for(uint32 i = 0; i < 4; i++) {
|
||||
for(uint32 j = 0; j < 4; j++) {
|
||||
pxs[j*4 + i].R() = i;
|
||||
pxs[j*4 + i].G() = j;
|
||||
}
|
||||
@ -96,8 +96,8 @@ TEST(Image, CopyConstructor) {
|
||||
|
||||
PVRTCC::Image img(4, 4, pxs);
|
||||
PVRTCC::Image img2(img);
|
||||
for(int i = 0; i < 4; i++) {
|
||||
for(int j = 0; j < 4; j++) {
|
||||
for(uint32 i = 0; i < 4; i++) {
|
||||
for(uint32 j = 0; j < 4; j++) {
|
||||
EXPECT_TRUE(img2(i, j) == pxs[j*4 + i]);
|
||||
}
|
||||
}
|
||||
@ -105,8 +105,8 @@ TEST(Image, CopyConstructor) {
|
||||
|
||||
TEST(Image, AssignmentOperator) {
|
||||
PVRTCC::Pixel pxs[16];
|
||||
for(int i = 0; i < 4; i++) {
|
||||
for(int j = 0; j < 4; j++) {
|
||||
for(uint32 i = 0; i < 4; i++) {
|
||||
for(uint32 j = 0; j < 4; j++) {
|
||||
pxs[j*4 + i].R() = i;
|
||||
pxs[j*4 + i].G() = j;
|
||||
}
|
||||
@ -114,8 +114,8 @@ TEST(Image, AssignmentOperator) {
|
||||
|
||||
PVRTCC::Image img(4, 4, pxs);
|
||||
PVRTCC::Image img2 = img;
|
||||
for(int i = 0; i < 4; i++) {
|
||||
for(int j = 0; j < 4; j++) {
|
||||
for(uint32 i = 0; i < 4; i++) {
|
||||
for(uint32 j = 0; j < 4; j++) {
|
||||
EXPECT_TRUE(img2(i, j) == pxs[j*4 + i]);
|
||||
}
|
||||
}
|
||||
@ -123,8 +123,8 @@ TEST(Image, AssignmentOperator) {
|
||||
|
||||
TEST(Image, BilinearUpscale) {
|
||||
PVRTCC::Pixel pxs[16];
|
||||
for(int i = 0; i < 4; i++) {
|
||||
for(int j = 0; j < 4; j++) {
|
||||
for(uint32 i = 0; i < 4; i++) {
|
||||
for(uint32 j = 0; j < 4; j++) {
|
||||
pxs[j*4 + i].R() = i*2;
|
||||
pxs[j*4 + i].G() = j*2;
|
||||
}
|
||||
@ -161,8 +161,8 @@ TEST(Image, BilinearUpscaleMaintainsPixels) {
|
||||
const uint32 h = 4;
|
||||
|
||||
PVRTCC::Pixel pxs[16];
|
||||
for(int i = 0; i < w; i++) {
|
||||
for(int j = 0; j < h; j++) {
|
||||
for(uint32 i = 0; i < w; i++) {
|
||||
for(uint32 j = 0; j < h; j++) {
|
||||
pxs[j*w + i].R() = rand() % 256;
|
||||
pxs[j*w + i].G() = rand() % 256;
|
||||
pxs[j*w + i].B() = rand() % 256;
|
||||
@ -191,8 +191,8 @@ TEST(Image, NonuniformBilinearUpscale) {
|
||||
const uint32 kHeight = 8;
|
||||
|
||||
PVRTCC::Pixel pxs[kWidth * kHeight];
|
||||
for(int i = 0; i < kWidth; i++) {
|
||||
for(int j = 0; j < kHeight; j++) {
|
||||
for(uint32 i = 0; i < kWidth; i++) {
|
||||
for(uint32 j = 0; j < kHeight; j++) {
|
||||
pxs[j*kWidth + i].R() = i*4;
|
||||
pxs[j*kWidth + i].G() = j*2;
|
||||
}
|
||||
@ -226,13 +226,13 @@ TEST(Image, BilinearUpscaleWrapped) {
|
||||
PVRTCC::Pixel pxs[16];
|
||||
|
||||
// Make sure that our bit depth is less than full...
|
||||
for(int i = 0; i < 16; i++) {
|
||||
for(uint32 i = 0; i < 16; i++) {
|
||||
const uint8 newBitDepth[4] = { 6, 5, 6, 5 };
|
||||
pxs[i].ChangeBitDepth(newBitDepth);
|
||||
}
|
||||
|
||||
for(int i = 0; i < 4; i++) {
|
||||
for(int j = 0; j < 4; j++) {
|
||||
for(uint32 i = 0; i < 4; i++) {
|
||||
for(uint32 j = 0; j < 4; j++) {
|
||||
pxs[j*4 + i].R() = i*4;
|
||||
pxs[j*4 + i].G() = j*4;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user