From 29bd1368e689e97cb17218c8b2326458df9d90cf Mon Sep 17 00:00:00 2001 From: Pavel Krajcevski Date: Sun, 15 Sep 2013 14:56:09 -0400 Subject: [PATCH] Fix a few compiler warnings and add the BPTCEncoder license. --- BPTCEncoder/src/BC7Compressor.cpp | 2 +- BPTCEncoder/src/LICENSE.txt | 16 +++++++++ Core/include/CompressedImage.h | 2 +- PVRTCEncoder/src/Decompressor.cpp | 6 ++-- PVRTCEncoder/src/Image.cpp | 4 +-- PVRTCEncoder/test/BlockTest.cpp | 11 ++++-- PVRTCEncoder/test/DecompressorTest.cpp | 10 +++--- PVRTCEncoder/test/ImageTest.cpp | 46 +++++++++++++------------- 8 files changed, 58 insertions(+), 39 deletions(-) create mode 100644 BPTCEncoder/src/LICENSE.txt diff --git a/BPTCEncoder/src/BC7Compressor.cpp b/BPTCEncoder/src/BC7Compressor.cpp index 5013cee..a5f0e86 100755 --- a/BPTCEncoder/src/BC7Compressor.cpp +++ b/BPTCEncoder/src/BC7Compressor.cpp @@ -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(dist[i]) * errorWeights[i]; error += e * e; } diff --git a/BPTCEncoder/src/LICENSE.txt b/BPTCEncoder/src/LICENSE.txt new file mode 100644 index 0000000..a3d5186 --- /dev/null +++ b/BPTCEncoder/src/LICENSE.txt @@ -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. +// +//-------------------------------------------------------------------------------------- diff --git a/Core/include/CompressedImage.h b/Core/include/CompressedImage.h index 016df4d..58d0bb8 100644 --- a/Core/include/CompressedImage.h +++ b/Core/include/CompressedImage.h @@ -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: diff --git a/PVRTCEncoder/src/Decompressor.cpp b/PVRTCEncoder/src/Decompressor.cpp index 18f7c61..1308cd5 100644 --- a/PVRTCEncoder/src/Decompressor.cpp +++ b/PVRTCEncoder/src/Decompressor.cpp @@ -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(modValues[i]); uint8 val = static_cast((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; diff --git a/PVRTCEncoder/src/Image.cpp b/PVRTCEncoder/src/Image.cpp index 75399e3..cf3f123 100644 --- a/PVRTCEncoder/src/Image.cpp +++ b/PVRTCEncoder/src/Image.cpp @@ -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); diff --git a/PVRTCEncoder/test/BlockTest.cpp b/PVRTCEncoder/test/BlockTest.cpp index db04a18..ca23353 100644 --- a/PVRTCEncoder/test/BlockTest.cpp +++ b/PVRTCEncoder/test/BlockTest.cpp @@ -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(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]; diff --git a/PVRTCEncoder/test/DecompressorTest.cpp b/PVRTCEncoder/test/DecompressorTest.cpp index 492baf0..8f2ff6c 100644 --- a/PVRTCEncoder/test/DecompressorTest.cpp +++ b/PVRTCEncoder/test/DecompressorTest.cpp @@ -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(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(outData); const uint32 p = pixelData[j*kWidth + i]; EXPECT_EQ(PixelPrinter(p), PixelPrinter(0xFF818080)); diff --git a/PVRTCEncoder/test/ImageTest.cpp b/PVRTCEncoder/test/ImageTest.cpp index d48a195..7b71635 100644 --- a/PVRTCEncoder/test/ImageTest.cpp +++ b/PVRTCEncoder/test/ImageTest.cpp @@ -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; }