mirror of
https://github.com/yuzu-emu/FasTC.git
synced 2025-01-09 15:05:36 +00:00
Fix some indentation and signedness mismatch
This commit is contained in:
parent
53b8d4c9a9
commit
b43373c0aa
|
@ -1478,12 +1478,11 @@ namespace BC7C
|
||||||
// implementation has an 4:1 compression ratio.
|
// implementation has an 4:1 compression ratio.
|
||||||
void CompressImageBC7(const unsigned char *inBuf, unsigned char *outBuf, unsigned int width, unsigned int height)
|
void CompressImageBC7(const unsigned char *inBuf, unsigned char *outBuf, unsigned int width, unsigned int height)
|
||||||
{
|
{
|
||||||
uint32 block[16];
|
|
||||||
BC7CompressionMode::MaxAnnealingIterations = min(BC7CompressionMode::kMaxAnnealingIterations, GetQualityLevel());
|
BC7CompressionMode::MaxAnnealingIterations = min(BC7CompressionMode::kMaxAnnealingIterations, GetQualityLevel());
|
||||||
|
|
||||||
for(int j = 0; j < height; j += 4)
|
for(uint32 j = 0; j < height; j += 4)
|
||||||
{
|
{
|
||||||
for(int i = 0; i < width; i += 4)
|
for(uint32 i = 0; i < width; i += 4)
|
||||||
{
|
{
|
||||||
// ExtractBlock(inBuf + i * 4, width, block);
|
// ExtractBlock(inBuf + i * 4, width, block);
|
||||||
CompressBC7Block((const uint32 *)inBuf, outBuf);
|
CompressBC7Block((const uint32 *)inBuf, outBuf);
|
||||||
|
@ -1521,12 +1520,11 @@ namespace BC7C
|
||||||
unsigned int height,
|
unsigned int height,
|
||||||
BlockStatManager &statManager
|
BlockStatManager &statManager
|
||||||
) {
|
) {
|
||||||
uint32 block[16];
|
|
||||||
BC7CompressionMode::MaxAnnealingIterations = min(BC7CompressionMode::kMaxAnnealingIterations, GetQualityLevel());
|
BC7CompressionMode::MaxAnnealingIterations = min(BC7CompressionMode::kMaxAnnealingIterations, GetQualityLevel());
|
||||||
|
|
||||||
for(int j = 0; j < height; j += 4)
|
for(uint32 j = 0; j < height; j += 4)
|
||||||
{
|
{
|
||||||
for(int i = 0; i < width; i += 4)
|
for(uint32 i = 0; i < width; i += 4)
|
||||||
{
|
{
|
||||||
// ExtractBlock(inBuf + i * 4, width, block);
|
// ExtractBlock(inBuf + i * 4, width, block);
|
||||||
CompressBC7Block((const uint32 *)inBuf, outBuf, statManager);
|
CompressBC7Block((const uint32 *)inBuf, outBuf, statManager);
|
||||||
|
|
|
@ -5,6 +5,12 @@
|
||||||
#include <limits.h>
|
#include <limits.h>
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
|
|
||||||
|
///////////////////////////////////////////////////////////////////////////////
|
||||||
|
//
|
||||||
|
// Static helper functions
|
||||||
|
//
|
||||||
|
///////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
template <typename T>
|
template <typename T>
|
||||||
static inline T min(const T &a, const T &b) {
|
static inline T min(const T &a, const T &b) {
|
||||||
return (a > b)? b : a;
|
return (a > b)? b : a;
|
||||||
|
@ -15,6 +21,11 @@ static inline T abs(const T &a) {
|
||||||
return (a > 0)? a : -a;
|
return (a > 0)? a : -a;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
template <typename T>
|
||||||
|
static inline T sad(const T &a, const T &b) {
|
||||||
|
return (a > b)? a - b : b - a;
|
||||||
|
}
|
||||||
|
|
||||||
void ReportError(const char *str) {
|
void ReportError(const char *str) {
|
||||||
fprintf(stderr, "ImageLoader.cpp -- ERROR: %s\n", str);
|
fprintf(stderr, "ImageLoader.cpp -- ERROR: %s\n", str);
|
||||||
}
|
}
|
||||||
|
@ -59,8 +70,8 @@ unsigned int ImageLoader::GetChannelForPixel(uint32 x, uint32 y, uint32 ch) {
|
||||||
const uint32 val = data[pixelIdx];
|
const uint32 val = data[pixelIdx];
|
||||||
|
|
||||||
if(prec < 8) {
|
if(prec < 8) {
|
||||||
uint32 ret = 0;
|
int32 ret = 0;
|
||||||
for(uint32 precLeft = 8; precLeft > 0; precLeft -= min(prec, abs(prec - precLeft))) {
|
for(uint32 precLeft = 8; precLeft > 0; precLeft -= min(prec, sad(prec, precLeft))) {
|
||||||
|
|
||||||
if(prec > precLeft) {
|
if(prec > precLeft) {
|
||||||
const int toShift = prec - precLeft;
|
const int toShift = prec - precLeft;
|
||||||
|
@ -77,7 +88,7 @@ unsigned int ImageLoader::GetChannelForPixel(uint32 x, uint32 y, uint32 ch) {
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
else if(prec > 8) {
|
else if(prec > 8) {
|
||||||
const int toShift = prec - 8;
|
const int32 toShift = prec - 8;
|
||||||
return val >> toShift;
|
return val >> toShift;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -113,12 +124,12 @@ bool ImageLoader::LoadImage() {
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
int byteIdx = 0;
|
int byteIdx = 0;
|
||||||
for(int i = 0; i < ah; i+=4) {
|
for(uint32 i = 0; i < ah; i+=4) {
|
||||||
for(int j = 0; j < aw; j+= 4) {
|
for(uint32 j = 0; j < aw; j+= 4) {
|
||||||
|
|
||||||
// For each block, visit the pixels in sequential order
|
// For each block, visit the pixels in sequential order
|
||||||
for(int y = i; y < i+4; y++) {
|
for(uint32 y = i; y < i+4; y++) {
|
||||||
for(int x = j; x < j+4; x++) {
|
for(uint32 x = j; x < j+4; x++) {
|
||||||
|
|
||||||
if(y >= m_Height || x >= m_Width) {
|
if(y >= m_Height || x >= m_Width) {
|
||||||
m_PixelData[byteIdx++] = 0; // r
|
m_PixelData[byteIdx++] = 0; // r
|
||||||
|
|
Loading…
Reference in a new issue