mirror of
https://github.com/yuzu-emu/FasTC
synced 2024-11-22 10:24:02 +00:00
Fix another bug that I thought I fixed... I should really make integration tests
This commit is contained in:
parent
f47c880198
commit
c8e19252e3
3 changed files with 15 additions and 8 deletions
|
@ -1572,8 +1572,9 @@ void Compress(const FasTC::CompressionJob &cj, CompressionSettings settings) {
|
|||
const uint32 kBlockSz = GetBlockSize(FasTC::eCompressionFormat_BPTC);
|
||||
uint8 *outBuf = cj.OutBuf() + cj.CoordsToBlockIdx(cj.XStart(), cj.YStart()) * kBlockSz;
|
||||
|
||||
const uint32 endY = std::min(cj.YEnd(), cj.Height() - 4);
|
||||
uint32 startX = cj.XStart();
|
||||
for(uint32 j = cj.YStart(); j <= cj.YEnd(); j += 4) {
|
||||
for(uint32 j = cj.YStart(); j <= endY; j += 4) {
|
||||
const uint32 endX = j == cj.YEnd()? cj.XEnd() : cj.Width();
|
||||
for(uint32 i = startX; i < endX; i += 4) {
|
||||
|
||||
|
|
|
@ -14,6 +14,7 @@
|
|||
// algorithms used in this code.
|
||||
|
||||
#include "DXTCompressor.h"
|
||||
#include <algorithm>
|
||||
#include <cassert>
|
||||
#include <cstdlib>
|
||||
#include <cstring>
|
||||
|
@ -45,8 +46,9 @@ namespace DXTC
|
|||
uint8 *outBuf = cj.OutBuf() + startBlock * kBlockSz;
|
||||
|
||||
const uint32 *inPixels = reinterpret_cast<const uint32 *>(cj.InBuf());
|
||||
uint32 endY = std::min(cj.YEnd(), cj.Height() - 4);
|
||||
uint32 startX = cj.XStart();
|
||||
for(uint32 j = cj.YStart(); j <= cj.YEnd(); j += 4) {
|
||||
for(uint32 j = cj.YStart(); j <= endY; j += 4) {
|
||||
const uint32 endX = j == cj.YEnd()? cj.XEnd() : cj.Width();
|
||||
for(uint32 i = startX; i < endX; i += 4) {
|
||||
|
||||
|
@ -75,10 +77,11 @@ namespace DXTC
|
|||
uint8 *outBuf = cj.OutBuf() + startBlock * kBlockSz;
|
||||
|
||||
const uint32 *inPixels = reinterpret_cast<const uint32 *>(cj.InBuf());
|
||||
uint32 endY = std::min(cj.YEnd(), cj.Height() - 4);
|
||||
uint32 startX = cj.XStart();
|
||||
bool done = false;
|
||||
for(uint32 j = cj.YStart(); !done; j += 4) {
|
||||
for(uint32 i = startX; !done && i < cj.Width(); i += 4) {
|
||||
for(uint32 j = cj.YStart(); j <= endY; j += 4) {
|
||||
const uint32 endX = j == cj.YEnd()? cj.XEnd() : cj.Width();
|
||||
for(uint32 i = startX; i < endX; i += 4) {
|
||||
|
||||
const uint32 kOffset = j*cj.Width() + i;
|
||||
ExtractBlock(inPixels + kOffset, cj.Width(), block);
|
||||
|
@ -89,8 +92,8 @@ namespace DXTC
|
|||
EmitWord(outBuf, ColorTo565(maxColor));
|
||||
EmitWord(outBuf, ColorTo565(minColor));
|
||||
EmitColorIndices(block, outBuf, minColor, maxColor);
|
||||
done = i+4 >= cj.XEnd() && j+(i+4 == cj.Width()? 4 : 0) >= cj.YEnd();
|
||||
}
|
||||
startX = 0;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -52,6 +52,7 @@
|
|||
|
||||
#include "rg_etc1.h"
|
||||
#include "ETCCompressor.h"
|
||||
#include <algorithm>
|
||||
#include <cstring>
|
||||
|
||||
namespace ETCC {
|
||||
|
@ -62,11 +63,13 @@ namespace ETCC {
|
|||
params.m_quality = rg_etc1::cLowQuality;
|
||||
rg_etc1::pack_etc1_block_init();
|
||||
|
||||
const uint32 kBlockSz = GetBlockSize(FasTC::eCompressionFormat_ETC1);
|
||||
uint32 kBlockSz = GetBlockSize(FasTC::eCompressionFormat_ETC1);
|
||||
const uint32 startBlock = cj.CoordsToBlockIdx(cj.XStart(), cj.YStart());
|
||||
uint8 *outBuf = cj.OutBuf() + startBlock * kBlockSz;
|
||||
|
||||
const uint32 endY = std::min(cj.YEnd(), cj.Height() - 4);
|
||||
uint32 startX = cj.XStart();
|
||||
for(uint32 j = cj.YStart(); j <= cj.YEnd(); j += 4) {
|
||||
for(uint32 j = cj.YStart(); j <= endY; j += 4) {
|
||||
const uint32 endX = j == cj.YEnd()? cj.XEnd() : cj.Width();
|
||||
for(uint32 i = startX; i < endX; i += 4) {
|
||||
|
||||
|
|
Loading…
Reference in a new issue