mirror of
https://github.com/yuzu-emu/FasTC.git
synced 2024-11-28 01:14:24 +01:00
Fix some MSVC compiler snafus
This commit is contained in:
parent
c3cb8403b5
commit
baab69dc99
@ -1402,7 +1402,7 @@ double BC7CompressionMode::Compress(
|
||||
}
|
||||
}
|
||||
|
||||
const bool rotated = bestAlphaIndices[anchorIdx] >> (nAlphaIndexBits - 1);
|
||||
const bool rotated = (bestAlphaIndices[anchorIdx] >> (nAlphaIndexBits - 1)) > 0;
|
||||
if(m_Attributes->hasRotation && rotated) {
|
||||
uint8 * bp1 = reinterpret_cast<uint8 *>(&pixel1[sidx]);
|
||||
uint8 * bp2 = reinterpret_cast<uint8 *>(&pixel2[sidx]);
|
||||
@ -1660,8 +1660,8 @@ namespace BC7C {
|
||||
double gdiff = sad(unCompData[k+1], inBuf[k+1]);
|
||||
double bdiff = sad(unCompData[k+2], inBuf[k+2]);
|
||||
double adiff = sad(unCompData[k+3], inBuf[k+3]);
|
||||
const float asrc = static_cast<double>(inBuf[k+3]);
|
||||
const float adst = static_cast<double>(unCompData[k+3]);
|
||||
const double asrc = static_cast<double>(inBuf[k+3]);
|
||||
const double adst = static_cast<double>(unCompData[k+3]);
|
||||
double avga = ((asrc + adst)*0.5)/255.0;
|
||||
diffSum += (rdiff + gdiff + bdiff + adiff) * avga;
|
||||
}
|
||||
@ -2581,7 +2581,7 @@ namespace BC7C {
|
||||
|
||||
assert(idxMode < 2);
|
||||
assert(rotMode < 4);
|
||||
assert(shapeIdx < ((mode == 0)? 16 : 64));
|
||||
assert(shapeIdx < ((mode == 0)? 16U : 64U));
|
||||
|
||||
uint32 cp = attrs->colorChannelPrecision;
|
||||
const uint32 shift = 8 - cp;
|
||||
|
@ -139,7 +139,7 @@ double Image::ComputePSNR(Image *other) {
|
||||
const unsigned char *pixelDataRaw = ourData + i;
|
||||
const unsigned char *pixelDataUncomp = otherData + i;
|
||||
|
||||
float r[4], u[4];
|
||||
double r[4], u[4];
|
||||
for(uint32 c = 0; c < 4; c++) {
|
||||
if(c == 3) {
|
||||
r[c] = pixelDataRaw[c] / 255.0;
|
||||
|
@ -40,13 +40,18 @@
|
||||
*
|
||||
* <http://gamma.cs.unc.edu/FasTC/>
|
||||
*/
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
||||
#define _CRT_SECURE_NO_WARNINGS
|
||||
|
||||
#include <cstdlib>
|
||||
#include <cstdio>
|
||||
#include <cstring>
|
||||
#include <fstream>
|
||||
#include <iostream>
|
||||
#include <SDKDDKVer.h>
|
||||
#include <Windows.h>
|
||||
|
||||
#include "BlockStats.h"
|
||||
#include "ThreadSafeStreambuf.h"
|
||||
#include "TexComp.h"
|
||||
#include "ImageFile.h"
|
||||
#include "Image.h"
|
||||
@ -211,15 +216,18 @@ int _tmain(int argc, _TCHAR* argv[])
|
||||
return 1;
|
||||
}
|
||||
|
||||
Image img (*file.GetImage())
|
||||
Image img (*file.GetImage());
|
||||
if(format == eCompressionFormat_PVRTC) {
|
||||
img.SetBlockStreamOrder(false);
|
||||
}
|
||||
|
||||
int numBlocks = (img.GetWidth() * img.GetHeight())/16;
|
||||
BlockStatManager *statManager = NULL;
|
||||
std::ofstream logFile;
|
||||
ThreadSafeStreambuf streamBuf(std::cout);
|
||||
std::ostream logStream(&streamBuf);
|
||||
if(bSaveLog) {
|
||||
statManager = new BlockStatManager(numBlocks);
|
||||
char logname[256];
|
||||
sprintf(logname, "%s.log", basename);
|
||||
logFile.open(logname);
|
||||
}
|
||||
|
||||
SCompressionSettings settings;
|
||||
@ -230,15 +238,15 @@ int _tmain(int argc, _TCHAR* argv[])
|
||||
settings.iQuality = quality;
|
||||
settings.iNumCompressions = numCompressions;
|
||||
settings.iJobSize = numJobs;
|
||||
settings.pStatManager = statManager;
|
||||
settings.logStream = &logStream;
|
||||
|
||||
CompressedImage *ci = img->Compress(settings);
|
||||
CompressedImage *ci = CompressImage(&img, settings);
|
||||
if(NULL == ci) {
|
||||
fprintf(stderr, "Error compressing image!\n");
|
||||
return 1;
|
||||
}
|
||||
|
||||
double PSNR = img->ComputePSNR(*ci);
|
||||
double PSNR = img.ComputePSNR(ci);
|
||||
if(PSNR > 0.0) {
|
||||
fprintf(stdout, "PSNR: %.3f\n", PSNR);
|
||||
}
|
||||
@ -246,12 +254,6 @@ int _tmain(int argc, _TCHAR* argv[])
|
||||
fprintf(stderr, "Error computing PSNR\n");
|
||||
}
|
||||
|
||||
if(bSaveLog) {
|
||||
strcat_s(basename, ".log");
|
||||
statManager->ToFile(basename);
|
||||
basename[strlen(basename) - 4] = '\0';
|
||||
}
|
||||
|
||||
if(format == eCompressionFormat_BPTC) {
|
||||
strcat_s(basename, "-bc7.png");
|
||||
} else if(format == eCompressionFormat_PVRTC) {
|
||||
@ -263,8 +265,8 @@ int _tmain(int argc, _TCHAR* argv[])
|
||||
|
||||
// Cleanup
|
||||
delete ci;
|
||||
if(statManager)
|
||||
delete statManager;
|
||||
if(bSaveLog)
|
||||
logFile.close();
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
@ -134,7 +134,7 @@ bool ImageLoaderPNG::ReadData() {
|
||||
}
|
||||
|
||||
const int numPixels = m_Width * m_Height;
|
||||
png_uint_32 bpr = png_get_rowbytes(png_ptr, info_ptr);
|
||||
png_size_t bpr = png_get_rowbytes(png_ptr, info_ptr);
|
||||
png_bytep rowData = new png_byte[bpr];
|
||||
|
||||
switch(colorType) {
|
||||
|
@ -77,7 +77,7 @@ public:
|
||||
unsigned char *stream = &(writer.m_RawFileData[writer.m_StreamPosition]);
|
||||
memcpy(stream, outBytes, byteCountToWrite);
|
||||
|
||||
writer.m_StreamPosition += byteCountToWrite;
|
||||
writer.m_StreamPosition += static_cast<uint32>(byteCountToWrite);
|
||||
}
|
||||
|
||||
static void FlushStream(png_structp png_ptr) { /* Do nothing... */ }
|
||||
|
@ -50,6 +50,11 @@
|
||||
* <http://gamma.cs.unc.edu/FasTC/>
|
||||
*/
|
||||
|
||||
#if _MSC_VER
|
||||
# define _CRT_SECURE_NO_WARNINGS
|
||||
# define snprintf _snprintf
|
||||
#endif
|
||||
|
||||
#include "Image.h"
|
||||
|
||||
#include <algorithm>
|
||||
@ -58,11 +63,6 @@
|
||||
#include <cstdio>
|
||||
#include <cmath>
|
||||
|
||||
#if _MSC_VER
|
||||
# define _CRT_SECURE_NO_WARNINGS
|
||||
# define snprintf _snprintf
|
||||
#endif
|
||||
|
||||
#include "Pixel.h"
|
||||
|
||||
#include "../../Base/include/Image.h"
|
||||
@ -287,7 +287,7 @@ void Image::ContentAwareDownscale(uint32 xtimes, uint32 ytimes,
|
||||
float g = a * ConvertChannelToFloat(m_Pixels[i].G(), bitDepth[2]);
|
||||
float b = a * ConvertChannelToFloat(m_Pixels[i].B(), bitDepth[3]);
|
||||
|
||||
I[i] = r * 0.21 + g * 0.71 + b * 0.07;
|
||||
I[i] = r * 0.21f + g * 0.71f + b * 0.07f;
|
||||
}
|
||||
|
||||
// Use central differences to calculate Ix, Iy, Ixx, Iyy...
|
||||
|
@ -175,7 +175,7 @@ namespace PVRTCC {
|
||||
uint16 v = static_cast<uint16>(val);
|
||||
v = (v + (1 << (bitsWasted - 1))) >> bitsWasted;
|
||||
v = ::std::min<uint16>(::std::max<uint16>(0, v), (1 << newDepth) - 1);
|
||||
return v;
|
||||
return static_cast<uint8>(v);
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user