Compare commits

...

7 Commits

Author SHA1 Message Date
Devin AI
cd90be696c doc: idct/RGB565 coloring probes
Co-Authored-By: wch <usernamecole7@gmail.com>
2026-10-02 22:16:47 +00:00
Devin AI
81440c32a3 exif: reproduce IFD0 tag re-mask via (u16)tag
Adds the u16 truncation on tag that base emits as an extra clrlwi
between the type read and the switch compare; normalized diff ops
drop 43->25. Residual: {tag,type} two-web coloring and the bltlr
bound-leaf fold.

Co-Authored-By: wch <usernamecole7@gmail.com>
2026-10-02 22:12:43 +00:00
Devin AI
1c7cf40c89 tmc: carry parked tmcjpeg verified states — exif aliasing/u16-clamp/range-fold decodes, texturecvtr store-order + Y8U8V8 idioms, iqdec/reschange best-forms (NonMatching units only)
Co-Authored-By: wch <usernamecole7@gmail.com>
2026-10-02 21:42:50 +00:00
coah
d0e5483630 decomp: preserve CHANSVm string-load deletion errors (#963) 2026-10-02 16:35:31 -05:00
coah
d725e02301 link(ut_ArchiveFontBase): Matching after 23/23 code match (#962)
Flip NonMatching→Matching after #961 match(ut_ArchiveFontBase 23/23).
Full 43U rebuild keeps DOL SHA1 26116613f624061ba99c8d1a299aaa6efa85670d.

Co-authored-by: linker <linker@users.noreply.github.com>
2026-10-02 16:27:44 -05:00
devin-ai-integration[bot]
87eaad4a42 decomp(CDBRecord): dead-fn literal fossils + Encrypt 284/284 insn-equal (#960)
Restores ~15 link-deadstripped retail fns whose emitted .data fossil
literals exist in the orig object; DOL-verified byte-identical at the
expected vaddrs. CDBRecordEncrypt auto-inlines dead CDBRecordGetFileSize:
284/284 instructions identical. Unit stays NonMatching: Encrypt's 57-byte
residual is an equal-cost register-packing tie-break (18 source probes
documented in tools/decomp-assist/CDBRecord.attempts.md).

Co-authored-by: devin <devin@cognition.ai>
Co-authored-by: coah80 <usernamecole7@gmail.com>
2026-10-02 16:25:40 -05:00
coah
e32aad81fb match(ut_ArchiveFontBase 23/23) (rt7f, prior-art ref) (worker 2fe052a9) (#961) 2026-10-02 16:23:57 -05:00
14 changed files with 3078 additions and 381 deletions

View File

@@ -53,9 +53,9 @@ Progress
<!-- progress:start -->
| Decompiled | Matched | Linked | Data |
|:---:|:---:|:---:|:---:|
| 99.59% | 91.12% | 74.40% | 99.42% |
| 99.59% | 91.16% | 74.57% | 99.56% |
units 963/1027 complete, functions 12376/12563 matched.
units 964/1027 complete, functions 12378/12563 matched.
decompiled = code with a C/C++ implementation (objdiff fuzzy), matched = byte-exact code, linked = code actually linked into the DOL, data = byte-exact data
<!-- progress:end -->

View File

@@ -1299,7 +1299,7 @@ config.libs = [
Object(Matching, "ut/ut_RomFont.cpp"),
Object(Matching, "ut/ut_ResFontBase.cpp"),
Object(Matching, "ut/ut_ResFont.cpp"),
Object(NonMatching, "ut/ut_ArchiveFontBase.cpp"),
Object(Matching, "ut/ut_ArchiveFontBase.cpp"),
Object(Matching, "ut/ut_ArchiveFont.cpp"),
Object(Matching, "ut/ut_CharWriter.cpp"),
Object(Matching, "ut/ut_TextWriterBase.cpp"),

View File

@@ -252,14 +252,17 @@ namespace nw4r {
}
inline void updateSheetFlags(const void* glgrHdr, u32 groupIdx, u16* sheetOffsets, u32 flagsStep, const u32* sheetFlags) {
const GlyphGroups* glgr = (GlyphGroups*)((u8*)glgrHdr + sizeof(BinaryBlockHeader));
for (int sheetI = 0; sheetI < glgr->sheetCount; sheetI++) {
u32 groupBitIdx = sheetI + groupIdx * flagsStep * 8;
const GlyphGroups* glgr = (const GlyphGroups*)((const u8*)glgrHdr + sizeof(BinaryBlockHeader));
int sheetIndex;
u32 groupBitOffset;
u16* sheetOffset = sheetOffsets;
groupBitOffset = groupIdx * flagsStep * 8;
for (sheetIndex = 0; sheetIndex < glgr->sheetCount; sheetOffset++, sheetIndex++) {
u32 groupBitIdx = sheetIndex + groupBitOffset;
const u32* bitBlockPtr = sheetFlags + (groupBitIdx & ~0x1F) / 32;
u32 bitBlock = *(u32*)bitBlockPtr;
u32 bitBlock = *bitBlockPtr;
if (((bitBlock << (groupBitIdx & 0x1F)) & 0x80000000) != 0) {
sheetOffsets[sheetI] = 1;
*sheetOffset = 1;
}
}
}
@@ -268,14 +271,16 @@ namespace nw4r {
const u32* bitBlocksPtr, u32 sheetFlagsSize) {
HeaderedGlyphGroups* pGlgr = (HeaderedGlyphGroups*)glgrHdr;
for (int i = 0; i < pGlgr->inner.sheetCount; i++) {
sheetOffsets[i] = 0;
int i;
u16* sheetOffset;
for (i = 0, sheetOffset = sheetOffsets; i < pGlgr->inner.sheetCount; sheetOffset++, i++) {
*sheetOffset = 0;
}
for (int i = 0; i < pGlgr->inner.nameCount; i++) {
const char* includedGroups = ctx->pIncludedGroups;
u16 offset = pGlgr->inner.nameOffsets[i];
char* name = (char*)((u8*)hdr + offset);
char* name = (char*)(offset + (u32)hdr);
if (*includedGroups != 0) {
if (!ArchiveFontBase::IncludeName(includedGroups, name)) {
continue;
@@ -288,21 +293,23 @@ namespace nw4r {
inline void convertSheetOffsetBooleansToOffsets(const void* glgrHdr, u16* sheetOffsets) {
HeaderedGlyphGroups* pGlgr = (HeaderedGlyphGroups*)glgrHdr;
int i;
u16 glyphIdxOffset = 0;
for (int i = 0; i < pGlgr->inner.sheetCount; i++) {
if (sheetOffsets[i] == 1) {
sheetOffsets[i] = glyphIdxOffset;
u16* sheetOffset;
for (i = 0, sheetOffset = sheetOffsets; i < pGlgr->inner.sheetCount; sheetOffset++, i++) {
if (*sheetOffset == 1) {
*sheetOffset = glyphIdxOffset;
} else {
sheetOffsets[i] = -1;
*sheetOffset = -1;
glyphIdxOffset += pGlgr->inner.sheetGlyphCount;
}
}
}
inline void copyFlagOffsets(ArchiveFontBase::ConstructContext* ctx, u16* sheetOffsetsScratch, u32 workSize, u32 scratchSize) {
inline void copyFlagOffsets(ArchiveFontBase::ConstructContext* ctx, u16* sheetOffsetsScratch, u32 workSize, const u16* sheetOffsetsScratchEnd) {
u8* sheetOffsets = ctx->pWorkCurr;
ctx->pWorkCurr = sheetOffsets + workSize;
memmove(sheetOffsets, sheetOffsetsScratch, scratchSize);
memmove(sheetOffsets, sheetOffsetsScratch, (sheetOffsetsScratchEnd - sheetOffsetsScratch) * sizeof(u16));
ctx->pSheetOffsets = (u16*)sheetOffsets;
}
@@ -311,31 +318,64 @@ namespace nw4r {
// *sheetOffsetsScratch = (u16*)ROUNDDOWN((u32)((u8*)fontData + remWorkSpace) - sheetOffsetsSize, 2);
// return sheetOffsetsSize;
// }
ArchiveFontBase::ConstructState ArchiveFontBase::ConstructOpAnalyzeGLGR(ConstructContext* ctx, CachedStreamReader* reader) {
u32 glgrInnerLen;
HeaderedGlyphGroups* pGlgr;
const ArchiveFontBinaryLayout* font;
u8* glgrEnd;
class FontGlyphGroupsAcs {
public:
explicit FontGlyphGroupsAcs(const ArchiveFontBinaryLayout* font)
: mFont(font), mGroups(&font->glgr) {}
const GlyphGroups& GetGroups() const { return mGroups->inner; }
void SetSheetFlags(u32 flagsStep, const u32* sheetFlags) {
mFlagsStep = flagsStep;
mSheetFlags = sheetFlags;
}
u16 GetNumSheet() const { return mGroups->inner.sheetCount; }
int GetGlyphsPerSheet() const { return mGroups->inner.sheetGlyphCount; }
u16 GetNumSet() const { return mGroups->inner.nameCount; }
const char* GetSetName(int groupIndex) const {
const u16 nameOffset = mGroups->inner.nameOffsets[groupIndex];
return (const char*)(nameOffset + (u32)mFont);
}
bool IsUseSheet(int groupIndex, int sheetIndex) const {
const u32 groupBitIndex = sheetIndex + groupIndex * mFlagsStep * 8;
const u32* bitBlock = mSheetFlags + (groupBitIndex & ~0x1F) / 32;
return ((*bitBlock << (groupBitIndex & 0x1F)) & 0x80000000) != 0;
}
private:
const ArchiveFontBinaryLayout* mFont;
const HeaderedGlyphGroups* mGroups;
u32 mFlagsStep;
const u32* mSheetFlags;
};
ArchiveFontBase::ConstructState ArchiveFontBase::ConstructOpAnalyzeGLGR(ConstructContext* ctx, CachedStreamReader* reader) {
const u32* flagsSheets;
u32 sheetOffsetsSize;
u32 flagsSheetsOff;
u32 glgrInnerLen;
const ArchiveFontBinaryLayout* font;
u16 sheetGlyphCount;
u32 countSheet;
HeaderedGlyphGroups* pGlgr;
u8* glgrEnd;
u32 expectedMaxSize;
u32 dataBlockCount;
u16* sheetOffsetsScratch;
int groupIndex;
font = (ArchiveFontBinaryLayout*)ctx->pWorkCurr;
glgrInnerLen = ctx->mNextBlockHdr.size - sizeof(BinaryBlockHeader);
// Check for RFNA
if (font->hdr.signature != SIGNATURE_FONT_ARCHIVE) {
return CONSTRUCT_STATE_FATAL_ERR;
}
// Check that there's enough data available, and the space to
// put that data
ENSURE_READER_HAS_SIZE(ctx, reader, glgrInnerLen);
ENSURE_WORK_HAS_SIZE(ctx, glgrInnerLen);
expectedMaxSize = ctx->mNextBlockHdr.size + sizeof(BinaryFileHeader);
// Copy the glgr to work
{
pGlgr = (HeaderedGlyphGroups*)&font->glgr;
glgrEnd = (u8*)pGlgr + (u32)ctx->mNextBlockHdr.size;
@@ -348,80 +388,45 @@ namespace nw4r {
return CONSTRUCT_STATE_FATAL_ERR;
}
// Before here is fine (other than regswaps)
// u16 sheetGlyphCount = FORCE_REACCESS_2(font->glgr.inner.sheetGlyphCount, u16); // 0x1C
// u16 dataBlockCount = FORCE_REACCESS_2(font->hdr.dataBlocks, u16); // 0x0E
// FORCE_REACCESS_2(font->glgr.inner.sheetCount, u16);
// return ConstructOpAnalyzeGLGRInner(ctx, font, pGlgr, glgrEnd);
FontGlyphGroupsAcs gg(font);
sheetGlyphCount = gg.GetGlyphsPerSheet();
dataBlockCount = font->hdr.dataBlocks;
countSheet = gg.GetNumSheet();
const u32 stepSheetFlags = detail::CalcSizeFlagSet(countSheet);
flagsSheetsOff = detail::CalcOffsetSheetFlags(gg.GetGroups().nameCount, countSheet, gg.GetGroups().smthCount_0x0a,
gg.GetGroups().smthCount_0x0c);
flagsSheets = (const u32*)((flagsSheetsOff & ~3) + (u32)font);
gg.SetSheetFlags(stepSheetFlags, flagsSheets);
// u32 fontSizeToEndOfGlgr;
u16 countSheet;
u16 sheetGlyphCount, dataBlockCount;
u32 stepSheetFlags;
u32 flagsSheetsOff;
const u32* flagsSheets;
u32 sheetOffsetsSize;
u16* sheetOffsetsScratch;
u32 sheetOffsetsScratchSize;
sheetGlyphCount = font->glgr.inner.sheetGlyphCount; // 0x1C
dataBlockCount = font->hdr.dataBlocks; // 0x0E
// countName = font->glgr.inner.nameCount;
countSheet = font->glgr.inner.sheetCount;
// count0A = font->glgr.inner.smthCount_0x0a;
// count0C = font->glgr.inner.smthCount_0x0c;
stepSheetFlags = detail::CalcSizeFlagSet(countSheet);
flagsSheetsOff = detail::CalcOffsetSheetFlags(font->glgr.inner.nameCount, countSheet, font->glgr.inner.smthCount_0x0a,
font->glgr.inner.smthCount_0x0c);
flagsSheets = (const u32*)font + (flagsSheetsOff >> 2);
sheetOffsetsSize = ROUNDUP(countSheet * sizeof(u16), 4);
sheetOffsetsSize = (RoundUp)(countSheet * sizeof(u16), 4);
sheetOffsetsScratch = (u16*)ROUNDDOWN((u32)((u8*)font + ctx->remWorkSpace()) - sheetOffsetsSize, 2);
pGlgr = (HeaderedGlyphGroups*)&font->glgr;
ENSURE_WORK_HAS_SIZE(ctx, glgrEnd - (u8*)font + sheetOffsetsSize);
// if (ctx->pWorkEnd - workCurr < fontSizeToEndOfGlgr + sheetOffsetsSize) {
// return CONSTRUCT_STATE_FATAL_ERR;
// }
// Clear sheet offsets scratch
// for (s32 i = 0; i < pGlgr->inner.sheetCount; i++) {
// sheetOffsetsScratch[i] = 0;
// }
{
u16* sheetOffset;
int sheetIndex;
for (sheetIndex = 0, sheetOffset = sheetOffsetsScratch; sheetIndex < gg.GetNumSheet(); sheetOffset++, sheetIndex++) {
*sheetOffset = 0;
}
for (groupIndex = 0; groupIndex < gg.GetNumSet(); groupIndex++) {
const char* includedGroups = ctx->pIncludedGroups;
const char* name = gg.GetSetName(groupIndex);
if (*includedGroups && !ArchiveFontBase::IncludeName(includedGroups, name)) {
continue;
}
for (int sheetIndex = 0; sheetIndex < gg.GetNumSheet(); sheetIndex++) {
if (gg.IsUseSheet(groupIndex, sheetIndex)) {
sheetOffsetsScratch[sheetIndex] = 1;
}
}
}
}
// for (s32 i = 0; i < pGlgr->inner.nameCount; i++) {
// // const char* includedGroups = ctx->pIncludedGroups;
// u16 offset = pGlgr->inner.nameOffsets[i];
// const char* name = (char*)((u8*)font + offset);
// if (*ctx->pIncludedGroups != 0) {
// if (!ArchiveFontBase::IncludeName(ctx->pIncludedGroups, name)) {
// continue;
// }
// }
// updateSheetFlags(pGlgr, i, sheetOffsetsScratch, stepSheetFlags, flagsSheets);
// }
setSheetOffsetBooleans(ctx, pGlgr, font, sheetOffsetsScratch, flagsSheets, stepSheetFlags);
// u16 glyphIdxOffset = 0;
// for (s32 i = 0; i < pGlgr->inner.sheetCount; i++) {
// if (sheetOffsetsScratch[i] == 1) {
// sheetOffsetsScratch[i] = glyphIdxOffset;
// } else {
// sheetOffsetsScratch[i] = -1;
// glyphIdxOffset += pGlgr->inner.sheetGlyphCount;
// }
// }
convertSheetOffsetBooleansToOffsets(pGlgr, sheetOffsetsScratch);
sheetOffsetsScratchSize = (u32)countSheet << 1;
sheetOffsetsScratchSize += (sheetOffsetsScratchSize >> 31);
sheetOffsetsScratchSize &= ~1;
copyFlagOffsets(ctx, sheetOffsetsScratch, sheetOffsetsSize, sheetOffsetsScratchSize);
copyFlagOffsets(ctx, sheetOffsetsScratch, sheetOffsetsSize, sheetOffsetsScratch + (u16)countSheet);
ctx->mSheetCount = countSheet;
ctx->mGlyphsPerSheet = sheetGlyphCount;

View File

@@ -10,16 +10,18 @@ static TMCHuffmanEntry readHuffmanEntry(const TMCHuffmanEntry* entries, u32 inde
return entries[index];
}
static void readHuffmanLimit(const TMCHuffmanEntry* entries, TMCHuffmanEntry* limit) {
limit->bitLength = entries->bitLength;
limit->symbol = entries->symbol;
static TMCHuffmanEntry readHuffmanLimit(const TMCHuffmanEntry* entries) {
TMCHuffmanEntry limit;
limit.bitLength = entries->bitLength;
limit.symbol = entries->symbol;
return limit;
}
static inline s32 decodeLongHuffman(s32 bitCount, u32* huff_tbl, u8* symbols, TMCCJPEGDecWork* work, TMCHuffmanEntry* limit, TMCHuffmanEntry* decoded) {
u16* entry;
static inline s32 decodeLongHuffman(s32 bitCount, const TMCHuffmanEntry* table, const u8* symbols, TMCCJPEGDecWork* work) {
u32 bitData;
u32 code;
u32 length;
const TMCHuffmanEntry* entry;
if (bitCount <= 17) {
s32 result = TMCJPEGDEC_load_buff(work);
@@ -28,16 +30,16 @@ static inline s32 decodeLongHuffman(s32 bitCount, u32* huff_tbl, u8* symbols, TM
}
}
bitCount = work->bitCount;
entry = (u16*)(huff_tbl + 9);
bitData = work->bitBuf;
length = 9;
bitCount -= 9;
code = (bitData >> bitCount) & 0x1FF;
work->bitCount = bitCount;
length = 9;
entry = table + 9;
goto read_entry;
while (1) {
length++;
entry += 2;
entry++;
if (length > 16) {
return TMCC_ERROR_OVERFLOW;
}
@@ -49,23 +51,18 @@ static inline s32 decodeLongHuffman(s32 bitCount, u32* huff_tbl, u8* symbols, TM
code |= (bitData >> bitCount) & 1;
read_entry:
{
limit->bitLength = entry[0];
limit->symbol = entry[1];
*decoded = *limit;
if (code > (u32)decoded->bitLength) {
TMCHuffmanEntry decoded;
decoded = readHuffmanLimit(entry);
if (code > (u32)decoded.bitLength) {
continue;
}
{
u32 relativeCode = code - limit->bitLength;
u32 symbolIndex = relativeCode + limit->symbol;
return symbols[symbolIndex & 0xFF];
}
code = code - entry->bitLength + entry->symbol;
return symbols[code & 0xFF];
}
}
}
static inline s32 decodeACHuffman(s32 bitCount, u32* huff_tbl, u8* symbols, TMCCJPEGDecWork* work, TMCHuffmanEntry* limit, TMCHuffmanEntry* decoded) {
u16* entry;
static inline s32 decodeACHuffman(s32 bitCount, const TMCHuffmanEntry* entry, const u8* symbols, TMCCJPEGDecWork* work) {
u32 bitData;
u32 code;
u32 length;
@@ -77,16 +74,16 @@ static inline s32 decodeACHuffman(s32 bitCount, u32* huff_tbl, u8* symbols, TMCC
}
}
bitCount = work->bitCount;
entry = (u16*)(huff_tbl + 9);
bitData = work->bitBuf;
length = 9;
bitCount -= 9;
code = (bitData >> bitCount) & 0x1FF;
work->bitCount = bitCount;
length = 9;
entry += 9;
goto read_entry;
while (1) {
length++;
entry += 2;
entry++;
if (length > 16) {
return TMCC_ERROR_OVERFLOW;
}
@@ -98,49 +95,38 @@ static inline s32 decodeACHuffman(s32 bitCount, u32* huff_tbl, u8* symbols, TMCC
code |= (bitData >> bitCount) & 1;
read_entry:
{
limit->bitLength = entry[0];
limit->symbol = entry[1];
*decoded = *limit;
if (code > (u32)decoded->bitLength) {
TMCHuffmanEntry decoded;
decoded = readHuffmanLimit(entry);
if (code > (u32)decoded.bitLength) {
continue;
}
{
u32 relativeCode = code - limit->bitLength;
u32 symbolIndex = relativeCode + limit->symbol;
return symbols[symbolIndex & 0xFF];
}
code = code - entry->bitLength + entry->symbol;
return symbols[code & 0xFF];
}
}
}
s32 TMCJPEGDEC_decode_iquant(s32* block, u8* conv_row_ptr, u32* dc_predict_row_ptr, TMCCJPEGDecWork* work) {
TMCHuffmanEntry dcEntry;
TMCHuffmanEntry dcDecoded;
TMCHuffmanEntry dcLimit;
TMCHuffmanEntry acDecoded;
TMCHuffmanEntry acLimit;
u8* huff_sym;
u16* ac_fast;
s32 idx;
u32* huff_tbl;
s32 bit_pos;
u32 bit_data;
u32 tmp;
s32 r;
s32 blk0;
TMCHuffmanEntry acEntry;
s32 extra;
s32 t;
s32 zz;
s32 idx;
s32 r;
u32 bit_data;
s32 bit_pos;
const TMCHuffmanEntry* dc_fast;
u32 tmp;
s32 q;
u16* dc_fast;
s32 zz;
s32 t;
s32 extra;
u32* huff_tbl;
u8* huff_sym;
const TMCHuffmanEntry* ac_fast;
const u8* zztbl;
s32* conv_row;
TMCHuffmanEntry dcEntry;
TMCHuffmanEntry acEntry;
conv_row = (s32*)conv_row_ptr;
bit_pos = work->bitCount;
dc_fast = work->pDCFast;
dc_fast = (const TMCHuffmanEntry*)work->pDCFast;
if (bit_pos <= 8) {
r = TMCJPEGDEC_load_buff(work);
@@ -151,40 +137,45 @@ s32 TMCJPEGDEC_decode_iquant(s32* block, u8* conv_row_ptr, u32* dc_predict_row_p
bit_pos = work->bitCount;
bit_data = work->bitBuf;
tmp = bit_pos - 8;
tmp = ((bit_data >> tmp) & 0xFF) << 2;
{
dcEntry = readHuffmanEntry((const TMCHuffmanEntry*)dc_fast, (bit_data >> (bit_pos - 8)) & 0xFF);
dcEntry = readHuffmanEntry(dc_fast, tmp >> 2);
r = dcEntry.bitLength;
extra = dcEntry.symbol;
}
if (r != 0) {
work->bitCount = bit_pos - r;
bit_pos -= r;
work->bitCount = bit_pos;
r = extra;
} else {
huff_sym = work->pDCHuffSym;
huff_tbl = work->pDCHuffTbl;
r = decodeLongHuffman(bit_pos, huff_tbl, huff_sym, work, &dcLimit, &dcDecoded);
r = decodeLongHuffman(bit_pos, (const TMCHuffmanEntry*)huff_tbl, huff_sym, work);
if (r < 0) {
return r;
}
}
blk0 = conv_row[0];
blk0 = ((s32*)conv_row_ptr)[0];
if (r != 0) {
if (work->bitCount <= r) {
s32 load_ret;
if (load_ret = TMCJPEGDEC_load_buff(work), load_ret < 0) {
bit_pos = work->bitCount;
if (bit_pos <= r) {
s32 load_ret = TMCJPEGDEC_load_buff(work);
if (load_ret < 0) {
return load_ret;
}
}
tmp = 1UL << r;
bit_pos = work->bitCount - r;
work->bitCount = bit_pos;
bit_pos = work->bitCount;
bit_data = work->bitBuf;
tmp = 1 << r;
extra = tmp - 1;
bit_pos -= r;
work->bitCount = bit_pos;
extra = extra & (bit_data >> bit_pos);
if (((s32)tmp >> 1) > extra) {
extra -= (tmp - 1);
extra -= tmp - 1;
}
dc_predict_row_ptr[0] += extra;
}
@@ -192,7 +183,7 @@ s32 TMCJPEGDEC_decode_iquant(s32* block, u8* conv_row_ptr, u32* dc_predict_row_p
*block = dc_predict_row_ptr[0] * blk0;
{
ac_fast = work->pACFast;
ac_fast = (const TMCHuffmanEntry*)work->pACFast;
huff_tbl = work->pACHuffTbl;
huff_sym = work->pACHuffSym;
@@ -210,7 +201,7 @@ s32 TMCJPEGDEC_decode_iquant(s32* block, u8* conv_row_ptr, u32* dc_predict_row_p
zztbl = TMCJPEGDEC_Zigzag_data;
bit_data = work->bitBuf;
t = bit_pos - 8;
acEntry = readHuffmanEntry((const TMCHuffmanEntry*)ac_fast, (bit_data >> t) & 0xFF);
acEntry = readHuffmanEntry(ac_fast, (bit_data >> t) & 0xFF);
do {
s32 ac_thresh = acEntry.bitLength;
@@ -221,7 +212,7 @@ s32 TMCJPEGDEC_decode_iquant(s32* block, u8* conv_row_ptr, u32* dc_predict_row_p
r = acEntry.symbol;
} else {
bit_pos = work->bitCount;
r = decodeACHuffman(bit_pos, huff_tbl, huff_sym, work, &acLimit, &acDecoded);
r = decodeACHuffman(bit_pos, (const TMCHuffmanEntry*)huff_tbl, huff_sym, work);
if (r < 0) {
return r;
}
@@ -245,18 +236,19 @@ s32 TMCJPEGDEC_decode_iquant(s32* block, u8* conv_row_ptr, u32* dc_predict_row_p
return r;
}
}
tmp = 1UL << t;
bit_pos = work->bitCount - t;
work->bitCount = bit_pos;
bit_pos = work->bitCount;
tmp = 1 << t;
bit_data = work->bitBuf;
extra = tmp - 1;
extra = extra & (bit_data >> bit_pos);
bit_pos -= t;
work->bitCount = bit_pos;
t = bit_pos - 8;
q = conv_row[(u8)zz];
acEntry = readHuffmanEntry((const TMCHuffmanEntry*)ac_fast, (bit_data >> t) & 0xFF);
extra = extra & (bit_data >> bit_pos);
q = ((s32*)conv_row_ptr)[(u8)zz];
acEntry = readHuffmanEntry(ac_fast, (bit_data >> t) & 0xFF);
if (((s32)tmp >> 1) > extra) {
extra -= (tmp - 1);
extra -= tmp - 1;
}
block[(u8)zz] = extra * q;
@@ -277,7 +269,7 @@ s32 TMCJPEGDEC_decode_iquant(s32* block, u8* conv_row_ptr, u32* dc_predict_row_p
bit_pos = work->bitCount;
t = bit_pos - 8;
tmp = ((bit_data >> t) & 0xFF) << 2;
acEntry = readHuffmanEntry((const TMCHuffmanEntry*)ac_fast, tmp >> 2);
acEntry = readHuffmanEntry(ac_fast, tmp >> 2);
idx += 16;
}

View File

@@ -3,8 +3,8 @@
#include <tmc_jpeg_internal.h>
static s32 TMCJPEGDEC_exif_parse(const u8* data, u32 size, TMCCJPEGDecExifData* pInfo);
static void TMCJPEGDEC_IFD0_tag_parse(TMCCJPEGDecExifData* pInfo, u16 byteOrder, const u8* entry);
static void TMCJPEGDEC_IFD1_tag_parse(TMCCJPEGDecExifData* pInfo, u16 byteOrder, const u8* entry);
static void TMCJPEGDEC_IFD0_tag_parse(TMCCJPEGDecExifData* pInfo, u16 byteOrder, u8* entry);
static void TMCJPEGDEC_IFD1_tag_parse(TMCCJPEGDecExifData* pInfo, u16 byteOrder, u8* entry);
static s32 TMCJPEGDEC_ThumbnailCheck(TMCCJPEGDecInitParam* param, TMCCJPEGDecExifInfo* info, u32 totalSize);
static u16 readU16(const u8* p, u16 byteOrder) {
@@ -16,7 +16,7 @@ static u16 readU16(const u8* p, u16 byteOrder) {
}
static u16 readExifU16(const u8* data, u16 byteOrder) {
u16 value = data[0] | data[1] << 8;
u32 value = data[0] | data[1] << 8;
if (byteOrder == 0x4949) {
return (u16)value;
}
@@ -246,9 +246,9 @@ static s32 TMCJPEGDEC_exif_parse(const u8* data, u32 size, TMCCJPEGDecExifData*
u32 ifdOffset;
const u8* entries;
u16 remaining;
u16 index;
s32 entriesSize;
u16 count;
s32 entriesSize;
u16 index;
pInfo->thumbnailData = (u8*)data;
pInfo->dataEnd = (u8*)data + size;
pInfo->nextIfdOffset = 0;
@@ -280,7 +280,7 @@ static s32 TMCJPEGDEC_exif_parse(const u8* data, u32 size, TMCCJPEGDecExifData*
return -161;
}
for (index = 0; index < count; index++) {
TMCJPEGDEC_IFD0_tag_parse(pInfo, byteOrder, entries);
TMCJPEGDEC_IFD0_tag_parse(pInfo, byteOrder, (u8*)entries);
entries += 12;
}
remaining -= entriesSize;
@@ -309,7 +309,7 @@ static s32 TMCJPEGDEC_exif_parse(const u8* data, u32 size, TMCCJPEGDecExifData*
return -161;
}
for (index = 0; index < count; index++) {
TMCJPEGDEC_IFD1_tag_parse(pInfo, byteOrder, entries);
TMCJPEGDEC_IFD1_tag_parse(pInfo, byteOrder, (u8*)entries);
entries += 12;
}
}
@@ -331,25 +331,27 @@ static s32 TMCJPEGDEC_exif_parse(const u8* data, u32 size, TMCCJPEGDecExifData*
return -161;
}
for (index = 0; index < count; index++) {
TMCJPEGDEC_IFD0_tag_parse(pInfo, byteOrder, entries);
TMCJPEGDEC_IFD0_tag_parse(pInfo, byteOrder, (u8*)entries);
entries += 12;
}
}
return 0;
}
static void TMCJPEGDEC_IFD0_tag_parse(TMCCJPEGDecExifData* pInfo, u16 byteOrder, const u8* entry) {
s32 tag;
static void TMCJPEGDEC_IFD0_tag_parse(TMCCJPEGDecExifData* pInfo, u16 byteOrder, u8* entry) {
u16 type;
u16 tag;
tag = readU16(entry, byteOrder);
type = readU16(entry + 2, byteOrder);
type = (u16)readU16(&entry[2], byteOrder);
tag = (u16)tag;
switch (tag) {
case 0x0103:
case 0x0111:
case 0x0201:
case 0x0202: {
case 0x0202:
case 0x0113 ... 0x0119:
case 0x0103: {
break;
}
case 0x0112: {
@@ -489,19 +491,21 @@ static void TMCJPEGDEC_IFD0_tag_parse(TMCCJPEGDecExifData* pInfo, u16 byteOrder,
}
}
static void TMCJPEGDEC_IFD1_tag_parse(TMCCJPEGDecExifData* pInfo, u16 byteOrder, const u8* entry) {
static void TMCJPEGDEC_IFD1_tag_parse(TMCCJPEGDecExifData* pInfo, u16 byteOrder, u8* entry) {
s32 tag = readU16(entry, byteOrder);
switch (tag) {
case 0x0132:
case 0x0111:
case 0x0112:
case 0x0117 ... 0x0119:
case 0x0102:
case 0x011C ... 0x0127:
case 0x012D:
case 0x0213:
case 0x8769:
case 0x9000:
case 0x9101:
case 0xA003: {
case 0xA002 ... 0xA003: {
break;
}
case 0x011A: {

View File

@@ -15,11 +15,9 @@ static void TMCJPEGDEC_converterYUV400toRGB565(TMCCJPEGDecWork*, s32, s32);
static void TMCJPEGDEC_converterYUV400toRGB565edge(TMCCJPEGDecWork*, s32, s32);
s32 TMCJPEGDEC_set_converterRGB565(TMCCJPEGDecWork* work) {
u8* buffer;
s32 componentCount;
TMCCJPEGDecState* state;
buffer = work->convBuf;
componentCount = work->componentCount;
state = work->pState;
@@ -34,14 +32,14 @@ s32 TMCJPEGDEC_set_converterRGB565(TMCCJPEGDecWork* work) {
u8* crBlock;
mode = work->idctMode;
firstRow = buffer + 4;
firstRow = work->convBuf + 4;
work->pConverterFunc = TMCJPEGDEC_converterYUV411toRGB565;
work->pConverterFuncEdge = TMCJPEGDEC_converterYUV411toRGB565edge;
secondRow = firstRow + mode;
thirdRow = secondRow + mode;
fourthRow = thirdRow + mode;
cbBlock = buffer + 260;
crBlock = buffer + 324;
cbBlock = work->convBuf + 260;
crBlock = work->convBuf + 324;
work->pConvRowPtrs[0] = firstRow;
work->pConvRowPtrs[1] = secondRow;
work->pConvRowPtrs[2] = thirdRow;
@@ -60,12 +58,12 @@ s32 TMCJPEGDEC_set_converterRGB565(TMCCJPEGDecWork* work) {
u8* crBlock;
mode = work->idctMode;
firstRow = buffer + 4;
firstRow = work->convBuf + 4;
work->pConverterFunc = TMCJPEGDEC_converterYUV422toRGB565;
work->pConverterFuncEdge = TMCJPEGDEC_converterYUV422toRGB565edge;
secondRow = firstRow + mode;
cbBlock = buffer + 132;
crBlock = buffer + 196;
cbBlock = work->convBuf + 132;
crBlock = work->convBuf + 196;
work->pConvRowPtrs[0] = firstRow;
work->pConvRowPtrs[1] = secondRow;
work->pConvRowPtrs[5] = cbBlock;
@@ -84,14 +82,14 @@ s32 TMCJPEGDEC_set_converterRGB565(TMCCJPEGDecWork* work) {
u8* crBlock;
mode = work->idctMode;
firstRow = buffer + 4;
firstRow = work->convBuf + 4;
work->pConverterFunc = TMCJPEGDEC_converterYUV420toRGB565;
work->pConverterFuncEdge = TMCJPEGDEC_converterYUV420toRGB565edge;
secondRow = firstRow + mode;
thirdRow = firstRow + mode * 16;
fourthRow = thirdRow + mode;
cbBlock = buffer + 260;
crBlock = buffer + 324;
cbBlock = work->convBuf + 260;
crBlock = work->convBuf + 324;
work->pConvRowPtrs[0] = firstRow;
work->pConvRowPtrs[1] = secondRow;
work->pConvRowPtrs[2] = thirdRow;
@@ -110,12 +108,12 @@ s32 TMCJPEGDEC_set_converterRGB565(TMCCJPEGDecWork* work) {
u8* crBlock;
mode = work->idctMode;
firstRow = buffer + 4;
firstRow = work->convBuf + 4;
work->pConverterFunc = TMCJPEGDEC_converterYUV211toRGB565;
work->pConverterFuncEdge = TMCJPEGDEC_converterYUV211toRGB565edge;
secondRow = firstRow + mode * 8;
cbBlock = buffer + 132;
crBlock = buffer + 196;
cbBlock = work->convBuf + 132;
crBlock = work->convBuf + 196;
work->pConvRowPtrs[0] = firstRow;
work->pConvRowPtrs[1] = secondRow;
work->pConvRowPtrs[5] = cbBlock;
@@ -129,11 +127,11 @@ s32 TMCJPEGDEC_set_converterRGB565(TMCCJPEGDecWork* work) {
TMCConverterFunc* edgeConverter;
converter = TMCJPEGDEC_converterYUV444toRGB565;
edgeConverter = TMCJPEGDEC_converterYUV444toRGB565edge;
work->pConvRowPtrs[0] = buffer + 4;
work->pConvRowPtrs[5] = buffer + 0x44;
work->pConvRowPtrs[6] = buffer + 0x84;
work->pConverterFunc = converter;
work->pConverterFuncEdge = edgeConverter;
work->pConvRowPtrs[0] = work->convBuf + 4;
work->pConvRowPtrs[5] = work->convBuf + 0x44;
work->pConvRowPtrs[6] = work->convBuf + 0x84;
work->pitch = 0x08;
work->converterFlags = 0;
break;
@@ -143,9 +141,9 @@ s32 TMCJPEGDEC_set_converterRGB565(TMCCJPEGDecWork* work) {
TMCConverterFunc* edgeConverter;
converter = TMCJPEGDEC_converterYUV400toRGB565;
edgeConverter = TMCJPEGDEC_converterYUV400toRGB565edge;
work->pConvRowPtrs[0] = buffer + 4;
work->pConverterFunc = converter;
work->pConverterFuncEdge = edgeConverter;
work->pConvRowPtrs[0] = work->convBuf + 4;
work->pitch = 0x08;
work->converterFlags = 0;
break;

View File

@@ -15,11 +15,9 @@ static void TMCJPEGDEC_converterYUV400toRGBA8(TMCCJPEGDecWork*, s32, s32);
static void TMCJPEGDEC_converterYUV400toRGBA8edge(TMCCJPEGDecWork*, s32, s32);
s32 TMCJPEGDEC_set_converterRGBA8(TMCCJPEGDecWork* work) {
u8* buffer;
s32 componentCount;
TMCCJPEGDecState* state;
buffer = work->convBuf;
componentCount = work->componentCount;
state = work->pState;
@@ -34,14 +32,14 @@ s32 TMCJPEGDEC_set_converterRGBA8(TMCCJPEGDecWork* work) {
u8* crBlock;
mode = work->idctMode;
firstRow = buffer + 4;
firstRow = work->convBuf + 4;
work->pConverterFunc = TMCJPEGDEC_converterYUV411toRGBA8;
work->pConverterFuncEdge = TMCJPEGDEC_converterYUV411toRGBA8edge;
secondRow = firstRow + mode;
thirdRow = secondRow + mode;
fourthRow = thirdRow + mode;
cbBlock = buffer + 260;
crBlock = buffer + 324;
cbBlock = work->convBuf + 260;
crBlock = work->convBuf + 324;
work->pConvRowPtrs[0] = firstRow;
work->pConvRowPtrs[1] = secondRow;
work->pConvRowPtrs[2] = thirdRow;
@@ -60,12 +58,12 @@ s32 TMCJPEGDEC_set_converterRGBA8(TMCCJPEGDecWork* work) {
u8* crBlock;
mode = work->idctMode;
firstRow = buffer + 4;
firstRow = work->convBuf + 4;
work->pConverterFunc = TMCJPEGDEC_converterYUV422toRGBA8;
work->pConverterFuncEdge = TMCJPEGDEC_converterYUV422toRGBA8edge;
secondRow = firstRow + mode;
cbBlock = buffer + 132;
crBlock = buffer + 196;
cbBlock = work->convBuf + 132;
crBlock = work->convBuf + 196;
work->pConvRowPtrs[0] = firstRow;
work->pConvRowPtrs[1] = secondRow;
work->pConvRowPtrs[5] = cbBlock;
@@ -84,14 +82,14 @@ s32 TMCJPEGDEC_set_converterRGBA8(TMCCJPEGDecWork* work) {
u8* crBlock;
mode = work->idctMode;
firstRow = buffer + 4;
firstRow = work->convBuf + 4;
work->pConverterFunc = TMCJPEGDEC_converterYUV420toRGBA8;
work->pConverterFuncEdge = TMCJPEGDEC_converterYUV420toRGBA8edge;
secondRow = firstRow + mode;
thirdRow = firstRow + mode * 16;
fourthRow = thirdRow + mode;
cbBlock = buffer + 260;
crBlock = buffer + 324;
cbBlock = work->convBuf + 260;
crBlock = work->convBuf + 324;
work->pConvRowPtrs[0] = firstRow;
work->pConvRowPtrs[1] = secondRow;
work->pConvRowPtrs[2] = thirdRow;
@@ -110,12 +108,12 @@ s32 TMCJPEGDEC_set_converterRGBA8(TMCCJPEGDecWork* work) {
u8* crBlock;
mode = work->idctMode;
firstRow = buffer + 4;
firstRow = work->convBuf + 4;
work->pConverterFunc = TMCJPEGDEC_converterYUV211toRGBA8;
work->pConverterFuncEdge = TMCJPEGDEC_converterYUV211toRGBA8edge;
secondRow = firstRow + mode * 8;
cbBlock = buffer + 132;
crBlock = buffer + 196;
cbBlock = work->convBuf + 132;
crBlock = work->convBuf + 196;
work->pConvRowPtrs[0] = firstRow;
work->pConvRowPtrs[1] = secondRow;
work->pConvRowPtrs[5] = cbBlock;
@@ -129,11 +127,11 @@ s32 TMCJPEGDEC_set_converterRGBA8(TMCCJPEGDecWork* work) {
TMCConverterFunc* edgeConverter;
converter = TMCJPEGDEC_converterYUV444toRGBA8;
edgeConverter = TMCJPEGDEC_converterYUV444toRGBA8edge;
work->pConvRowPtrs[0] = buffer + 4;
work->pConvRowPtrs[5] = buffer + 0x44;
work->pConvRowPtrs[6] = buffer + 0x84;
work->pConverterFunc = converter;
work->pConverterFuncEdge = edgeConverter;
work->pConvRowPtrs[0] = work->convBuf + 4;
work->pConvRowPtrs[5] = work->convBuf + 0x44;
work->pConvRowPtrs[6] = work->convBuf + 0x84;
work->pitch = 0x08;
work->converterFlags = 0;
break;
@@ -143,9 +141,9 @@ s32 TMCJPEGDEC_set_converterRGBA8(TMCCJPEGDecWork* work) {
TMCConverterFunc* edgeConverter;
converter = TMCJPEGDEC_converterYUV400toRGBA8;
edgeConverter = TMCJPEGDEC_converterYUV400toRGBA8edge;
work->pConvRowPtrs[0] = buffer + 4;
work->pConverterFunc = converter;
work->pConverterFuncEdge = edgeConverter;
work->pConvRowPtrs[0] = work->convBuf + 4;
work->pitch = 0x08;
work->converterFlags = 0;
break;
@@ -166,23 +164,23 @@ s32 TMCJPEGDEC_set_converterRGBA8(TMCCJPEGDecWork* work) {
}
static void TMCJPEGDEC_converterYUV411toRGBA8(TMCCJPEGDecWork* work, s32 x, s32 y) {
s32 red;
s8 crValue;
u8* luminance;
u8* cb;
u8* cr;
TMCCJPEGDecState* state;
u8* texture;
s32 height;
s32 column;
s32 yEnd;
s32 xEnd;
s32 green;
s32 yEnd;
s32 column;
s32 tileWidth;
s32 blueOffset;
u16* output;
s32 tileRow;
s32 lumaSkip;
s8 crValue;
s32 red;
s32 chromaSkip;
s32 width;
s32 cbValue;
@@ -216,7 +214,7 @@ static void TMCJPEGDEC_converterYUV411toRGBA8(TMCCJPEGDecWork* work, s32 x, s32
cbValue = (s8)*cb++;
crValue = (s8)*cr++;
redOffset = (crValue * 359) >> 8;
greenOffset = -(crValue * 183 + cbValue * 88) >> 8;
greenOffset = -(cbValue * 88 + crValue * 183) >> 8;
blueOffset = (cbValue * 454) >> 8;
}
{
@@ -224,7 +222,7 @@ static void TMCJPEGDEC_converterYUV411toRGBA8(TMCCJPEGDecWork* work, s32 x, s32
green = value + greenOffset;
red = value + redOffset;
blue = value + blueOffset;
if ((red | green | blue) >> 8) {
if ((blue | green | red) >> 8) {
blue = blue > 255 ? 255 : blue < 0 ? 0 : blue;
green = green > 255 ? 255 : green < 0 ? 0 : green;
red = red > 255 ? 255 : red < 0 ? 0 : red;
@@ -238,7 +236,7 @@ static void TMCJPEGDEC_converterYUV411toRGBA8(TMCCJPEGDecWork* work, s32 x, s32
green = value + greenOffset;
red = value + redOffset;
blue = value + blueOffset;
if ((red | green | blue) >> 8) {
if ((blue | green | red) >> 8) {
blue = blue > 255 ? 255 : blue < 0 ? 0 : blue;
green = green > 255 ? 255 : green < 0 ? 0 : green;
red = red > 255 ? 255 : red < 0 ? 0 : red;
@@ -252,7 +250,7 @@ static void TMCJPEGDEC_converterYUV411toRGBA8(TMCCJPEGDecWork* work, s32 x, s32
green = value + greenOffset;
red = value + redOffset;
blue = value + blueOffset;
if ((red | green | blue) >> 8) {
if ((blue | green | red) >> 8) {
blue = blue > 255 ? 255 : blue < 0 ? 0 : blue;
green = green > 255 ? 255 : green < 0 ? 0 : green;
red = red > 255 ? 255 : red < 0 ? 0 : red;
@@ -266,7 +264,7 @@ static void TMCJPEGDEC_converterYUV411toRGBA8(TMCCJPEGDecWork* work, s32 x, s32
green = value + greenOffset;
red = value + redOffset;
blue = value + blueOffset;
if ((red | green | blue) >> 8) {
if ((blue | green | red) >> 8) {
blue = blue > 255 ? 255 : blue < 0 ? 0 : blue;
green = green > 255 ? 255 : green < 0 ? 0 : green;
red = red > 255 ? 255 : red < 0 ? 0 : red;
@@ -285,20 +283,20 @@ static void TMCJPEGDEC_converterYUV411toRGBA8(TMCCJPEGDecWork* work, s32 x, s32
}
static void TMCJPEGDEC_converterYUV411toRGBA8edge(TMCCJPEGDecWork* work, s32 x, s32 y) {
s32 chromaSkip;
s32 tileRow;
s32 xEnd;
u8* texture;
TMCCJPEGDecState* state;
s32 column;
u8* luminance;
u8* cb;
u8* cr;
TMCCJPEGDecState* state;
s32 tileWidth;
u8* texture;
s32 width;
s32 height;
u8* cr;
s32 column;
s32 lumaSkip;
s32 xEnd;
s32 yEnd;
s32 tileWidth;
s32 lumaSkip;
s32 chromaSkip;
s32 tileRow;
u16* output;
s32 cbValue;
s8 crValue;
@@ -345,7 +343,7 @@ static void TMCJPEGDEC_converterYUV411toRGBA8edge(TMCCJPEGDecWork* work, s32 x,
red = blue + redOffset;
green = blue + greenOffset;
blue = blue + blueOffset;
if ((green | red | blue) >> 8) {
if ((blue | red | green) >> 8) {
blue = blue > 255 ? 255 : blue < 0 ? 0 : blue;
green = green > 255 ? 255 : green < 0 ? 0 : green;
red = red > 255 ? 255 : red < 0 ? 0 : red;
@@ -366,11 +364,11 @@ static void TMCJPEGDEC_converterYUV411toRGBA8edge(TMCCJPEGDecWork* work, s32 x,
static void TMCJPEGDEC_converterYUV422toRGBA8(TMCCJPEGDecWork* work, s32 x, s32 y) {
s32 chromaSkip;
s32 lumaSkip;
s32 blue;
s32 cbValue;
s32 tileWidth;
TMCCJPEGDecState* state;
u16* output;
s32 xEnd;
u8* texture;
s32 width;
s32 height;
@@ -379,7 +377,7 @@ static void TMCJPEGDEC_converterYUV422toRGBA8(TMCCJPEGDecWork* work, s32 x, s32
s32 red;
u8* cr;
s32 column;
s32 xEnd;
u16* output;
s32 yEnd;
s32 redOffset;
s32 tileRow;
@@ -387,7 +385,7 @@ static void TMCJPEGDEC_converterYUV422toRGBA8(TMCCJPEGDecWork* work, s32 x, s32
s32 blueOffset;
s32 value;
s32 green;
s32 blue;
s32 lumaSkip;
s32 crValue;
luminance = work->convBuf + 4;
@@ -415,7 +413,7 @@ static void TMCJPEGDEC_converterYUV422toRGBA8(TMCCJPEGDecWork* work, s32 x, s32
green = value + greenOffset;
red = value + redOffset;
blue = value + blueOffset;
if ((red | green | blue) >> 8) {
if ((blue | red | green) >> 8) {
blue = blue > 255 ? 255 : blue < 0 ? 0 : blue;
green = green > 255 ? 255 : green < 0 ? 0 : green;
red = red > 255 ? 255 : red < 0 ? 0 : red;
@@ -426,7 +424,7 @@ static void TMCJPEGDEC_converterYUV422toRGBA8(TMCCJPEGDecWork* work, s32 x, s32
green = value + greenOffset;
red = value + redOffset;
blue = value + blueOffset;
if ((red | green | blue) >> 8) {
if ((blue | red | green) >> 8) {
blue = blue > 255 ? 255 : blue < 0 ? 0 : blue;
green = green > 255 ? 255 : green < 0 ? 0 : green;
red = red > 255 ? 255 : red < 0 ? 0 : red;
@@ -441,21 +439,21 @@ static void TMCJPEGDEC_converterYUV422toRGBA8(TMCCJPEGDecWork* work, s32 x, s32
}
static void TMCJPEGDEC_converterYUV422toRGBA8edge(TMCCJPEGDecWork* work, s32 x, s32 y) {
s32 blue;
u16* output;
s32 xEnd;
s32 column;
u8* luminance;
u8* cb;
u8* cr;
TMCCJPEGDecState* state;
s32 tileWidth;
u8* luminance;
u8* texture;
s32 width;
s32 height;
u8* cb;
u8* texture;
s32 column;
s32 chromaSkip;
s32 xEnd;
s32 yEnd;
s32 lumaSkip;
s32 chromaSkip;
s32 tileRow;
u16* output;
s32 cbValue;
s32 crValue;
s32 redOffset;
@@ -463,7 +461,7 @@ static void TMCJPEGDEC_converterYUV422toRGBA8edge(TMCCJPEGDecWork* work, s32 x,
s32 blueOffset;
s32 value;
s32 red;
s32 lumaSkip;
s32 blue;
s32 green;
luminance = work->convBuf + 4;
@@ -502,7 +500,7 @@ static void TMCJPEGDEC_converterYUV422toRGBA8edge(TMCCJPEGDecWork* work, s32 x,
red = value + redOffset;
blue = value + blueOffset;
green = value + greenOffset;
if ((red | green | blue) >> 8) {
if ((blue | red | green) >> 8) {
blue = blue > 255 ? 255 : blue < 0 ? 0 : blue;
green = green > 255 ? 255 : green < 0 ? 0 : green;
red = red > 255 ? 255 : red < 0 ? 0 : red;
@@ -517,19 +515,19 @@ static void TMCJPEGDEC_converterYUV422toRGBA8edge(TMCCJPEGDecWork* work, s32 x,
}
static void TMCJPEGDEC_converterYUV420toRGBA8(TMCCJPEGDecWork* work, s32 x, s32 y) {
s32 tileRow;
s32 blue;
s8 crValue;
s32 chromaSkip;
u8* luminance;
TMCCJPEGDecState* state;
u8* texture;
s32 xEnd;
s32 width;
s32 height;
s32 green;
s32 blue;
s32 blueOffset;
u8* texture;
s32 lumaSkip;
s32 yEnd;
s32 xEnd;
s32 tileRow;
s32 value;
s32 column;
u8* cr;
@@ -538,7 +536,7 @@ static void TMCJPEGDEC_converterYUV420toRGBA8(TMCCJPEGDecWork* work, s32 x, s32
s32 redOffset;
u8* cb;
u16* output;
s32 blueOffset;
s32 green;
s32 red;
s32 cbValue;
@@ -578,7 +576,7 @@ static void TMCJPEGDEC_converterYUV420toRGBA8(TMCCJPEGDecWork* work, s32 x, s32
if ((red | green | blue) >> 8) {
if ((blue | green | red) >> 8) {
blue = blue > 255 ? 255 : blue < 0 ? 0 : blue;
green = green > 255 ? 255 : green < 0 ? 0 : green;
red = red > 255 ? 255 : red < 0 ? 0 : red;
@@ -593,7 +591,7 @@ static void TMCJPEGDEC_converterYUV420toRGBA8(TMCCJPEGDecWork* work, s32 x, s32
green = value + greenOffset;
red = value + redOffset;
blue = value + blueOffset;
if ((red | green | blue) >> 8) {
if ((blue | green | red) >> 8) {
blue = blue > 255 ? 255 : blue < 0 ? 0 : blue;
green = green > 255 ? 255 : green < 0 ? 0 : green;
red = red > 255 ? 255 : red < 0 ? 0 : red;
@@ -620,11 +618,11 @@ static void TMCJPEGDEC_converterYUV420toRGBA8(TMCCJPEGDecWork* work, s32 x, s32
static void TMCJPEGDEC_converterYUV420toRGBA8edge(TMCCJPEGDecWork* work, s32 x, s32 y) {
u8* luminance = work->convBuf + 4;
u8* cb = work->convBuf + 260;
s32 width;
u8* cr = work->convBuf + 324;
TMCCJPEGDecState* state = work->pState;
s32 tileWidth = (state->convWidth >> 2) << 1;
u8* texture = state->pTexBuffer;
u8* cr = work->convBuf + 324;
s32 width;
s32 height;
if (state->dataSizeX == (u32)x) {
width = state->stepXExt;
@@ -660,7 +658,7 @@ static void TMCJPEGDEC_converterYUV420toRGBA8edge(TMCCJPEGDecWork* work, s32 x,
s32 green = value + greenOffset;
s32 red = value + redOffset;
s32 blue = value + blueOffset;
if ((green | red | blue) >> 8) {
if ((blue | red | green) >> 8) {
blue = blue > 255 ? 255 : blue < 0 ? 0 : blue;
green = green > 255 ? 255 : green < 0 ? 0 : green;
red = red > 255 ? 255 : red < 0 ? 0 : red;
@@ -686,7 +684,7 @@ static void TMCJPEGDEC_converterYUV420toRGBA8edge(TMCCJPEGDecWork* work, s32 x,
static void TMCJPEGDEC_converterYUV211toRGBA8(TMCCJPEGDecWork* work, s32 x, s32 y) {
u16* output;
s32 tileRow;
s32 column;
s32 redOffset;
TMCCJPEGDecState* state;
s32 lumaSkip;
@@ -695,7 +693,7 @@ static void TMCJPEGDEC_converterYUV211toRGBA8(TMCCJPEGDecWork* work, s32 x, s32
u8* cb;
u8* cr;
s32 height;
s32 column;
s32 tileRow;
s32 chromaSkip;
s32 width;
s32 xEnd;
@@ -742,7 +740,7 @@ static void TMCJPEGDEC_converterYUV211toRGBA8(TMCCJPEGDecWork* work, s32 x, s32
green = value + greenOffset;
red = value + redOffset;
blue = value + blueOffset;
if ((red | green | blue) >> 8) {
if ((blue | red | green) >> 8) {
blue = blue > 255 ? 255 : blue < 0 ? 0 : blue;
green = green > 255 ? 255 : green < 0 ? 0 : green;
red = red > 255 ? 255 : red < 0 ? 0 : red;
@@ -770,7 +768,7 @@ static void TMCJPEGDEC_converterYUV211toRGBA8edge(TMCCJPEGDecWork* work, s32 x,
u16* output;
s32 lumaSkip;
s32 blue;
u8* texture;
s32 tileRow;
u8* luminance;
u8* cb;
u8* cr;
@@ -783,7 +781,7 @@ static void TMCJPEGDEC_converterYUV211toRGBA8edge(TMCCJPEGDecWork* work, s32 x,
s32 greenOffset;
s32 yEnd;
s32 cbValue;
s32 tileRow;
u8* texture;
s32 blueOffset;
s32 red;
s8 crValue;
@@ -831,7 +829,7 @@ static void TMCJPEGDEC_converterYUV211toRGBA8edge(TMCCJPEGDecWork* work, s32 x,
green = value + greenOffset;
red = value + redOffset;
blue = value + blueOffset;
if ((red | green | blue) >> 8) {
if ((blue | red | green) >> 8) {
blue = blue > 255 ? 255 : blue < 0 ? 0 : blue;
green = green > 255 ? 255 : green < 0 ? 0 : green;
red = red > 255 ? 255 : red < 0 ? 0 : red;
@@ -856,20 +854,20 @@ static void TMCJPEGDEC_converterYUV211toRGBA8edge(TMCCJPEGDecWork* work, s32 x,
static void TMCJPEGDEC_converterYUV444toRGBA8(TMCCJPEGDecWork* work, s32 x, s32 y) {
u16* output;
s32 tileWidth;
s32 tileRow;
s32 rowSkip;
u8* texture;
s32 xEnd;
u8* luminance;
u8* cb;
u8* cr;
TMCCJPEGDecState* state;
s32 crValue;
s8 crValue;
s32 height;
s32 width;
s32 column;
s32 xEnd;
s32 rowSkip;
s32 yEnd;
s32 tileWidth;
u8* texture;
s32 row;
s32 red;
s32 cbValue;
@@ -899,7 +897,7 @@ static void TMCJPEGDEC_converterYUV444toRGBA8(TMCCJPEGDecWork* work, s32 x, s32
green = value + (-(cbValue * 88 + crValue * 183) >> 8);
red = value + ((crValue * 359) >> 8);
blue = value + ((cbValue * 454) >> 8);
if ((red | green | blue) >> 8) {
if ((blue | red | green) >> 8) {
blue = blue > 255 ? 255 : blue < 0 ? 0 : blue;
green = green > 255 ? 255 : green < 0 ? 0 : green;
red = red > 255 ? 255 : red < 0 ? 0 : red;

View File

@@ -1,18 +1,18 @@
#define TMC_JPEG_PLANAR_OUTPUT
#include <tmc_jpeg_internal.h>
static void TMCJPEG_814EFEAC(TMCCJPEGDecWork*, s32, s32);
static void TMCJPEG_814F043C(TMCCJPEGDecWork*, s32, s32);
static void TMCJPEG_814F0A58(TMCCJPEGDecWork*, s32, s32);
static void TMCJPEG_814F11C4(TMCCJPEGDecWork*, s32, s32);
static void TMCJPEG_814F17E0(TMCCJPEGDecWork*, s32, s32);
static void TMCJPEG_814F1F48(TMCCJPEGDecWork*, s32, s32);
static void TMCJPEG_814F2570(TMCCJPEGDecWork*, s32, s32);
static void TMCJPEG_814F2B50(TMCCJPEGDecWork*, s32, s32);
static void TMCJPEG_814F3158(TMCCJPEGDecWork*, s32, s32);
static void TMCJPEG_814F32E4(TMCCJPEGDecWork*, s32, s32);
static void TMCJPEG_814F34A4(TMCCJPEGDecWork*, s32, s32);
static void TMCJPEG_814F372C(TMCCJPEGDecWork*, s32, s32);
static void TMCJPEGDEC_converterYUV411toY8U8V8(TMCCJPEGDecWork*, s32, s32);
static void TMCJPEGDEC_converterYUV411toY8U8V8edge(TMCCJPEGDecWork*, s32, s32);
static void TMCJPEGDEC_converterYUV422toY8U8V8(TMCCJPEGDecWork*, s32, s32);
static void TMCJPEGDEC_converterYUV422toY8U8V8edge(TMCCJPEGDecWork*, s32, s32);
static void TMCJPEGDEC_converterYUV420toY8U8V8(TMCCJPEGDecWork*, s32, s32);
static void TMCJPEGDEC_converterYUV420toY8U8V8edge(TMCCJPEGDecWork*, s32, s32);
static void TMCJPEGDEC_converterYUV211toY8U8V8(TMCCJPEGDecWork*, s32, s32);
static void TMCJPEGDEC_converterYUV211toY8U8V8edge(TMCCJPEGDecWork*, s32, s32);
static void TMCJPEGDEC_converterYUV444toY8U8V8(TMCCJPEGDecWork*, s32, s32);
static void TMCJPEGDEC_converterYUV444toY8U8V8edge(TMCCJPEGDecWork*, s32, s32);
static void TMCJPEGDEC_converterYUV400toY8U8V8(TMCCJPEGDecWork*, s32, s32);
static void TMCJPEGDEC_converterYUV400toY8U8V8edge(TMCCJPEGDecWork*, s32, s32);
s32 TMCJPEGDEC_set_converterY8U8V8(TMCCJPEGDecWork* work) {
u8* buffer;
@@ -35,8 +35,8 @@ s32 TMCJPEGDEC_set_converterY8U8V8(TMCCJPEGDecWork* work) {
mode = work->idctMode;
firstRow = buffer + 4;
work->pConverterFunc = TMCJPEG_814EFEAC;
work->pConverterFuncEdge = TMCJPEG_814F043C;
work->pConverterFunc = TMCJPEGDEC_converterYUV411toY8U8V8;
work->pConverterFuncEdge = TMCJPEGDEC_converterYUV411toY8U8V8edge;
secondRow = firstRow + mode;
thirdRow = secondRow + mode;
fourthRow = thirdRow + mode;
@@ -61,8 +61,8 @@ s32 TMCJPEGDEC_set_converterY8U8V8(TMCCJPEGDecWork* work) {
mode = work->idctMode;
firstRow = buffer + 4;
work->pConverterFunc = TMCJPEG_814F0A58;
work->pConverterFuncEdge = TMCJPEG_814F11C4;
work->pConverterFunc = TMCJPEGDEC_converterYUV422toY8U8V8;
work->pConverterFuncEdge = TMCJPEGDEC_converterYUV422toY8U8V8edge;
secondRow = firstRow + mode;
cbBlock = buffer + 132;
crBlock = buffer + 196;
@@ -85,8 +85,8 @@ s32 TMCJPEGDEC_set_converterY8U8V8(TMCCJPEGDecWork* work) {
mode = work->idctMode;
firstRow = buffer + 4;
work->pConverterFunc = TMCJPEG_814F17E0;
work->pConverterFuncEdge = TMCJPEG_814F1F48;
work->pConverterFunc = TMCJPEGDEC_converterYUV420toY8U8V8;
work->pConverterFuncEdge = TMCJPEGDEC_converterYUV420toY8U8V8edge;
secondRow = firstRow + mode;
thirdRow = firstRow + mode * 16;
fourthRow = thirdRow + mode;
@@ -111,8 +111,8 @@ s32 TMCJPEGDEC_set_converterY8U8V8(TMCCJPEGDecWork* work) {
mode = work->idctMode;
firstRow = buffer + 4;
work->pConverterFunc = TMCJPEG_814F2570;
work->pConverterFuncEdge = TMCJPEG_814F2B50;
work->pConverterFunc = TMCJPEGDEC_converterYUV211toY8U8V8;
work->pConverterFuncEdge = TMCJPEGDEC_converterYUV211toY8U8V8edge;
secondRow = firstRow + mode * 8;
cbBlock = buffer + 132;
crBlock = buffer + 196;
@@ -127,13 +127,13 @@ s32 TMCJPEGDEC_set_converterY8U8V8(TMCCJPEGDecWork* work) {
case 4: {
TMCConverterFunc* converter;
TMCConverterFunc* edgeConverter;
converter = TMCJPEG_814F3158;
edgeConverter = TMCJPEG_814F32E4;
converter = TMCJPEGDEC_converterYUV444toY8U8V8;
edgeConverter = TMCJPEGDEC_converterYUV444toY8U8V8edge;
work->pConverterFunc = converter;
work->pConverterFuncEdge = edgeConverter;
work->pConvRowPtrs[0] = buffer + 4;
work->pConvRowPtrs[5] = buffer + 0x44;
work->pConvRowPtrs[6] = buffer + 0x84;
work->pConverterFunc = converter;
work->pConverterFuncEdge = edgeConverter;
work->pitch = 0x08;
work->converterFlags = 0;
break;
@@ -141,11 +141,11 @@ s32 TMCJPEGDEC_set_converterY8U8V8(TMCCJPEGDecWork* work) {
case 5: {
TMCConverterFunc* converter;
TMCConverterFunc* edgeConverter;
converter = TMCJPEG_814F34A4;
edgeConverter = TMCJPEG_814F372C;
work->pConvRowPtrs[0] = buffer + 4;
converter = TMCJPEGDEC_converterYUV400toY8U8V8;
edgeConverter = TMCJPEGDEC_converterYUV400toY8U8V8edge;
work->pConverterFunc = converter;
work->pConverterFuncEdge = edgeConverter;
work->pConvRowPtrs[0] = buffer + 4;
work->pitch = 0x08;
work->converterFlags = 0;
break;
@@ -168,10 +168,12 @@ s32 TMCJPEGDEC_set_converterY8U8V8(TMCCJPEGDecWork* work) {
return 0;
}
static void TMCJPEG_814EFEAC(TMCCJPEGDecWork* work, s32 x, s32 y) {
static void TMCJPEGDEC_converterYUV411toY8U8V8(TMCCJPEGDecWork* work, s32 x, s32 y) {
s32 rowSkip;
u8* output;
s32 chromaXEnd;
u32 tileRow;
u32 chromaTileWidth;
s32 chromaYEnd;
u8* lumaTexture;
TMCCJPEGDecState* state;
@@ -214,17 +216,17 @@ static void TMCJPEG_814EFEAC(TMCCJPEGDecWork* work, s32 x, s32 y) {
}
luminance += rowSkip;
}
tileWidth = state->chromaWidth >> 3;
chromaTileWidth = state->chromaWidth >> 3;
x = (u32)x >> 2;
width = 8 / state->scaleFactor;
height = 8 / state->scaleFactor;
xEnd = x + width;
chromaXEnd = x + width;
chromaYEnd = y + height;
for (; y < chromaYEnd; y++) {
for (column = x; column < xEnd; column += 1) {
(cbTexture + ((y & 3) << 3) + (column & 7))[(s32)(((column >> 3) + (y >> 2) * tileWidth) << 5)] = *cb + 128;
for (column = x; column < chromaXEnd; column += 1) {
(cbTexture + ((y & 3) << 3) + (column & 7))[(s32)(((column >> 3) + (y >> 2) * chromaTileWidth) << 5)] = *cb + 128;
cb++;
(crTexture + ((y & 3) << 3) + (column & 7))[(s32)(((column >> 3) + (y >> 2) * tileWidth) << 5)] = *cr + 128;
(crTexture + ((y & 3) << 3) + (column & 7))[(s32)(((column >> 3) + (y >> 2) * chromaTileWidth) << 5)] = *cr + 128;
cr++;
}
cb += 8 - width;
@@ -232,7 +234,8 @@ static void TMCJPEG_814EFEAC(TMCCJPEGDecWork* work, s32 x, s32 y) {
}
}
static void TMCJPEG_814F043C(TMCCJPEGDecWork* work, s32 x, s32 y) {
static void TMCJPEGDEC_converterYUV411toY8U8V8edge(TMCCJPEGDecWork* work, s32 x, s32 y) {
u32 chromaTileWidth;
TMCCJPEGDecState* state;
u8* lumaTexture;
u8* luminance;
@@ -247,9 +250,9 @@ static void TMCJPEG_814F043C(TMCCJPEGDecWork* work, s32 x, s32 y) {
u8* output;
u8* cb;
u8* cr;
s32 width;
s32 tileOffset;
s32 xEnd;
s32 tileOffset;
s32 width;
u32 tileWidth;
luminance = work->convBuf + 4;
@@ -284,13 +287,13 @@ static void TMCJPEG_814F043C(TMCCJPEGDecWork* work, s32 x, s32 y) {
x = (u32)x >> 2;
width = (width + 3) >> 2;
xEnd = x + width;
tileWidth = state->chromaWidth >> 3;
chromaTileWidth = state->chromaWidth >> 3;
chromaEnd = y + height;
for (; y < chromaEnd; y++) {
for (column = x; column < xEnd; column += 1) {
(cbTexture + ((y & 3) << 3) + (column & 7))[(s32)(((column >> 3) + (y >> 2) * tileWidth) << 5)] = *cb + 128;
(cbTexture + ((y & 3) << 3) + (column & 7))[(s32)(((column >> 3) + (y >> 2) * chromaTileWidth) << 5)] = *cb + 128;
cb++;
(crTexture + ((y & 3) << 3) + (column & 7))[(s32)(((column >> 3) + (y >> 2) * tileWidth) << 5)] = *cr + 128;
(crTexture + ((y & 3) << 3) + (column & 7))[(s32)(((column >> 3) + (y >> 2) * chromaTileWidth) << 5)] = *cr + 128;
cr++;
}
cb += 8 - width;
@@ -298,12 +301,14 @@ static void TMCJPEG_814F043C(TMCCJPEGDecWork* work, s32 x, s32 y) {
}
}
static void TMCJPEG_814F0A58(TMCCJPEGDecWork* work, s32 x, s32 y) {
static void TMCJPEGDEC_converterYUV422toY8U8V8(TMCCJPEGDecWork* work, s32 x, s32 y) {
s32 chromaYEnd;
u8* lumaTexture;
u8* luminance;
s32 column;
s32 chromaXEnd;
s32 row;
u32 chromaTileWidth;
TMCCJPEGDecState* state;
s32 width;
s32 height;
@@ -314,6 +319,7 @@ static void TMCJPEG_814F0A58(TMCCJPEGDecWork* work, s32 x, s32 y) {
u8* cb;
u32 tileWidth;
u8* cr;
s32 chromaRowSkip;
row = y;
luminance = work->convBuf + 4;
@@ -338,22 +344,24 @@ static void TMCJPEG_814F0A58(TMCCJPEGDecWork* work, s32 x, s32 y) {
x = (u32)x >> 1;
width = 8 / state->scaleFactor;
height = 8 / state->scaleFactor;
xEnd = x + width;
chromaXEnd = x + width;
chromaYEnd = y + height;
tileWidth = state->chromaWidth >> 3;
for (row = y; row < chromaYEnd; row++) {
for (column = x; column < xEnd; column += 1) {
(cbTexture + ((row & 3) << 3) + (column & 7))[(s32)(((column >> 3) + (row >> 2) * tileWidth) << 5)] = *cb + 128;
chromaTileWidth = state->chromaWidth >> 3;
chromaRowSkip = 8 - width;
for (; y < chromaYEnd; y++) {
for (column = x; column < chromaXEnd; column += 1) {
(cbTexture + ((y & 3) << 3) + (column & 7))[(s32)(((column >> 3) + (y >> 2) * chromaTileWidth) << 5)] = *cb + 128;
cb++;
(crTexture + ((row & 3) << 3) + (column & 7))[(s32)(((column >> 3) + (row >> 2) * tileWidth) << 5)] = *cr + 128;
(crTexture + ((y & 3) << 3) + (column & 7))[(s32)(((column >> 3) + (y >> 2) * chromaTileWidth) << 5)] = *cr + 128;
cr++;
}
cb += 8 - width;
cb += chromaRowSkip;
cr += 8 - width;
}
}
static void TMCJPEG_814F11C4(TMCCJPEGDecWork* work, s32 x, s32 y) {
static void TMCJPEGDEC_converterYUV422toY8U8V8edge(TMCCJPEGDecWork* work, s32 x, s32 y) {
u32 chromaTileWidth;
TMCCJPEGDecState* state;
u8* lumaTexture;
u8* luminance;
@@ -368,9 +376,9 @@ static void TMCJPEG_814F11C4(TMCCJPEGDecWork* work, s32 x, s32 y) {
u8* output;
u8* cb;
u8* cr;
s32 width;
s32 tileOffset;
s32 xEnd;
s32 tileOffset;
s32 width;
u32 tileWidth;
luminance = work->convBuf + 4;
@@ -405,13 +413,13 @@ static void TMCJPEG_814F11C4(TMCCJPEGDecWork* work, s32 x, s32 y) {
x = (u32)x >> 1;
width = (width + 1) >> 1;
xEnd = x + width;
tileWidth = state->chromaWidth >> 3;
chromaTileWidth = state->chromaWidth >> 3;
chromaEnd = y + height;
for (; y < chromaEnd; y++) {
for (column = x; column < xEnd; column += 1) {
(cbTexture + ((y & 3) << 3) + (column & 7))[(s32)(((column >> 3) + (y >> 2) * tileWidth) << 5)] = *cb + 128;
(cbTexture + ((y & 3) << 3) + (column & 7))[(s32)(((column >> 3) + (y >> 2) * chromaTileWidth) << 5)] = *cb + 128;
cb++;
(crTexture + ((y & 3) << 3) + (column & 7))[(s32)(((column >> 3) + (y >> 2) * tileWidth) << 5)] = *cr + 128;
(crTexture + ((y & 3) << 3) + (column & 7))[(s32)(((column >> 3) + (y >> 2) * chromaTileWidth) << 5)] = *cr + 128;
cr++;
}
cb += 8 - width;
@@ -419,22 +427,24 @@ static void TMCJPEG_814F11C4(TMCCJPEGDecWork* work, s32 x, s32 y) {
}
}
static void TMCJPEG_814F17E0(TMCCJPEGDecWork* work, s32 x, s32 y) {
s32 chromaYEnd;
u8* lumaTexture;
static void TMCJPEGDEC_converterYUV420toY8U8V8(TMCCJPEGDecWork* work, s32 x, s32 y) {
s32 height;
u8* luminance;
s32 chromaYEnd;
s32 column;
u8* lumaTexture;
s32 chromaXEnd;
u8* luminance;
u32 chromaTileWidth;
u8* cbTexture;
s32 row;
s32 width;
u8* crTexture;
s32 xEnd;
u32 tileWidth;
u8* cb;
TMCCJPEGDecState* state;
s32 yEnd;
s32 width;
s32 xEnd;
u8* cr;
u32 tileWidth;
s32 row;
row = y;
luminance = work->convBuf + 4;
@@ -460,14 +470,14 @@ static void TMCJPEG_814F17E0(TMCCJPEGDecWork* work, s32 x, s32 y) {
y = (u32)y >> 1;
width = 8 / state->scaleFactor;
height = 8 / state->scaleFactor;
xEnd = x + width;
chromaXEnd = x + width;
chromaYEnd = y + height;
tileWidth = state->chromaWidth >> 3;
chromaTileWidth = state->chromaWidth >> 3;
for (; y < chromaYEnd; y++) {
for (column = x; column < xEnd; column += 1) {
(cbTexture + ((y & 3) << 3) + (column & 7))[(s32)(((column >> 3) + (y >> 2) * tileWidth) << 5)] = *cb + 128;
for (column = x; column < chromaXEnd; column += 1) {
(cbTexture + ((y & 3) << 3) + (column & 7))[(s32)(((column >> 3) + (y >> 2) * chromaTileWidth) << 5)] = *cb + 128;
cb++;
(crTexture + ((y & 3) << 3) + (column & 7))[(s32)(((column >> 3) + (y >> 2) * tileWidth) << 5)] = *cr + 128;
(crTexture + ((y & 3) << 3) + (column & 7))[(s32)(((column >> 3) + (y >> 2) * chromaTileWidth) << 5)] = *cr + 128;
cr++;
}
cb += 8 - width;
@@ -475,7 +485,8 @@ static void TMCJPEG_814F17E0(TMCCJPEGDecWork* work, s32 x, s32 y) {
}
}
static void TMCJPEG_814F1F48(TMCCJPEGDecWork* work, s32 x, s32 y) {
static void TMCJPEGDEC_converterYUV420toY8U8V8edge(TMCCJPEGDecWork* work, s32 x, s32 y) {
u32 chromaTileWidth;
TMCCJPEGDecState* state;
u8* lumaTexture;
u8* luminance;
@@ -486,13 +497,13 @@ static void TMCJPEG_814F1F48(TMCCJPEGDecWork* work, s32 x, s32 y) {
u8* crTexture;
u32 tileRow;
s32 height;
s32 width;
s32 yEnd;
u8* output;
u8* cb;
u8* cr;
s32 xEnd;
s32 tileOffset;
s32 yEnd;
s32 width;
u32 tileWidth;
luminance = work->convBuf + 4;
@@ -528,13 +539,13 @@ static void TMCJPEG_814F1F48(TMCCJPEGDecWork* work, s32 x, s32 y) {
x = (u32)x >> 1;
width = (width + 1) >> 1;
xEnd = x + width;
tileWidth = state->chromaWidth >> 3;
chromaTileWidth = state->chromaWidth >> 3;
chromaEnd = y + ((height + 1) >> 1);
for (; y < chromaEnd; y++) {
for (column = x; column < xEnd; column += 1) {
(cbTexture + ((y & 3) << 3) + (column & 7))[(s32)(((column >> 3) + (y >> 2) * tileWidth) << 5)] = *cb + 128;
(cbTexture + ((y & 3) << 3) + (column & 7))[(s32)(((column >> 3) + (y >> 2) * chromaTileWidth) << 5)] = *cb + 128;
cb++;
(crTexture + ((y & 3) << 3) + (column & 7))[(s32)(((column >> 3) + (y >> 2) * tileWidth) << 5)] = *cr + 128;
(crTexture + ((y & 3) << 3) + (column & 7))[(s32)(((column >> 3) + (y >> 2) * chromaTileWidth) << 5)] = *cr + 128;
cr++;
}
cb += 8 - width;
@@ -542,9 +553,10 @@ static void TMCJPEG_814F1F48(TMCCJPEGDecWork* work, s32 x, s32 y) {
}
}
static void TMCJPEG_814F2570(TMCCJPEGDecWork* work, s32 x, s32 y) {
u8* lumaTexture;
static void TMCJPEGDEC_converterYUV211toY8U8V8(TMCCJPEGDecWork* work, s32 x, s32 y) {
u32 chromaTileWidth;
TMCCJPEGDecState* state;
u8* lumaTexture;
u8* luminance;
s32 column;
s32 row;
@@ -584,13 +596,13 @@ static void TMCJPEG_814F2570(TMCCJPEGDecWork* work, s32 x, s32 y) {
luminance += 8 - width;
}
y = (u32)y >> 1;
tileWidth = state->chromaWidth >> 3;
chromaTileWidth = state->chromaWidth >> 3;
chromaEnd = y + 8 / state->scaleFactor;
for (; y < chromaEnd; y++) {
for (column = x; column < xEnd; column += 1) {
(cbTexture + ((y & 3) << 3) + (column & 7))[(s32)(((column >> 3) + (y >> 2) * tileWidth) << 5)] = *cb + 128;
(cbTexture + ((y & 3) << 3) + (column & 7))[(s32)(((column >> 3) + (y >> 2) * chromaTileWidth) << 5)] = *cb + 128;
cb++;
(crTexture + ((y & 3) << 3) + (column & 7))[(s32)(((column >> 3) + (y >> 2) * tileWidth) << 5)] = *cr + 128;
(crTexture + ((y & 3) << 3) + (column & 7))[(s32)(((column >> 3) + (y >> 2) * chromaTileWidth) << 5)] = *cr + 128;
cr++;
}
cb += 8 - width;
@@ -598,7 +610,7 @@ static void TMCJPEG_814F2570(TMCCJPEGDecWork* work, s32 x, s32 y) {
}
}
static void TMCJPEG_814F2B50(TMCCJPEGDecWork* work, s32 x, s32 y) {
static void TMCJPEGDEC_converterYUV211toY8U8V8edge(TMCCJPEGDecWork* work, s32 x, s32 y) {
u32 chromaTileWidth;
TMCCJPEGDecState* state;
u8* lumaTexture;
@@ -663,7 +675,7 @@ static void TMCJPEG_814F2B50(TMCCJPEGDecWork* work, s32 x, s32 y) {
}
}
static void TMCJPEG_814F3158(TMCCJPEGDecWork* work, s32 x, s32 y) {
static void TMCJPEGDEC_converterYUV444toY8U8V8(TMCCJPEGDecWork* work, s32 x, s32 y) {
s32 rowSkip;
u8* output;
s32 height;
@@ -718,7 +730,7 @@ static void TMCJPEG_814F3158(TMCCJPEGDecWork* work, s32 x, s32 y) {
}
}
static void TMCJPEG_814F32E4(TMCCJPEGDecWork* work, s32 x, s32 y) {
static void TMCJPEGDEC_converterYUV444toY8U8V8edge(TMCCJPEGDecWork* work, s32 x, s32 y) {
s32 rowSkip;
u8* output;
s32 height;
@@ -781,7 +793,7 @@ static void TMCJPEG_814F32E4(TMCCJPEGDecWork* work, s32 x, s32 y) {
}
}
static void TMCJPEG_814F34A4(TMCCJPEGDecWork* work, s32 x, s32 y) {
static void TMCJPEGDEC_converterYUV400toY8U8V8(TMCCJPEGDecWork* work, s32 x, s32 y) {
s32 height;
u8* lumaTexture;
u8* luminance;
@@ -817,7 +829,7 @@ static void TMCJPEG_814F34A4(TMCCJPEGDecWork* work, s32 x, s32 y) {
}
}
static void TMCJPEG_814F372C(TMCCJPEGDecWork* work, s32 x, s32 y) {
static void TMCJPEGDEC_converterYUV400toY8U8V8edge(TMCCJPEGDecWork* work, s32 x, s32 y) {
s32 height;
u8* lumaTexture;
u8* luminance;

View File

@@ -393,6 +393,67 @@ CDBErr CDBRecordGetDataSize(CDBRecord* record, u32* size) {
return err;
}
CDBErr CDBRecordReduceFileSize(CDBRecord* record, u32 newFileSize) {
CDBRecordFile* recordFile;
CDBErr err;
u32 fileSize;
recordFile = record->file;
if (recordFile == NULL) {
CDBReportError("can't reduce file size of the record ; the record is closed\n");
return CDB_ERROR_27;
}
if ((recordFile->allocFlag & 2) == 0) {
CDBReportError("can't reduce file size of the record ; the record is opened as READONLY\n");
return CDB_ERROR_27;
}
CDBAttrGetFileSize(&recordFile->attr, &fileSize);
if (newFileSize > fileSize) {
CDBReportError("can't reduce file size of the record ; file size must be over %d bytes\n", fileSize);
return CDB_ERROR_26;
}
CDBAttrSetFileSize(&recordFile->attr, newFileSize);
recordFile->attr.dirty = TRUE;
err = CDBRecordFileWriteAttrBuf(record);
if (err != CDB_ERROR_OK) {
return err;
}
return CDB_ERROR_OK;
}
CDBErr CDBRecordReduceDataSize(CDBRecord* record, u32 newDataSize) {
CDBRecordFile* recordFile;
CDBErr err = CDB_ERROR_OK;
u32 dataSize;
recordFile = record->file;
if (recordFile == NULL) {
CDBReportError("can't reduce data size of the record ; the record is closed\n");
return CDB_ERROR_27;
}
if ((recordFile->allocFlag & 2) == 0) {
CDBReportError("can't reduce data size of the record ; the record is opened as READONLY\n");
return CDB_ERROR_27;
}
if (!CDBRecordBelongedDBOpenedAsRW(record)) {
CDBReportError("can't reduce data size of the record; permission denied\n");
return CDB_ERROR_ACCESS_DENIED;
}
err = CDBRecordFileGetDataSize(record, &dataSize);
if (err != CDB_ERROR_OK) {
return err;
}
if (newDataSize < dataSize) {
CDBAttrSetFileSize(&recordFile->attr, newDataSize);
recordFile->attr.dirty = TRUE;
}
err = CDBRecordFileWriteAttrBuf(record);
if (err != CDB_ERROR_OK) {
return err;
}
return CDB_ERROR_OK;
}
CDBErr CDBRecordRemove(CDBRecord* record) {
CDBErr err;
CDBLock();
@@ -430,6 +491,50 @@ void CDBRecordGetTypeForce(CDBRecord* record, char* type) {
CDBUnlock();
}
CDBErr CDBRecordSetFileType(CDBRecord* record, const char* fileType) {
CDBRecordDatabaseState* instance;
CDBRecordFile* recordFile;
CDBErr err;
instance = ((CDBDatabase*)record->database)->instance;
recordFile = record->file;
if ((instance->openFlags & 2) == 0) {
CDBReportError("can't set file type of the record; the database is opened as READONLY\n");
return CDB_ERROR_26;
}
if (recordFile == NULL) {
CDBReportError("can't set file type of the record ; the record is closed\n");
return CDB_ERROR_27;
}
if ((recordFile->allocFlag & 2) == 0) {
CDBReportError("can't set file type of the record ; the record is opened as READONLY\n");
return CDB_ERROR_27;
}
if (record->key.location != CDB_FS_LOCATION_NAND) {
CDBReportError("can't set file type of the record ; the record must exsist on NAND\n");
return CDB_ERROR_26;
}
CDBLock();
strcpy(CDBKeyStrType(record->key.keyString), fileType);
CDBAttrSetKeyStr(&recordFile->attr, &record->key);
err = CDBRecordFileWriteAttrBuf(record);
CDBUnlock();
return err;
}
CDBErr CDBRecordGetFileType(CDBRecord* record, char* fileType) {
CDBErr err = CDB_ERROR_OK;
CDBLock();
if (record->file == NULL) {
CDBReportError("can't get file type of the record ; the record is closed\n");
err = CDB_ERROR_27;
} else {
CDBConvKeyStrToType(record->key.keyString, fileType);
}
CDBUnlock();
return err;
}
void CDBRecordGetGameCodeForce(CDBRecord* record, char* gameCode) {
u32 value;
CDBLock();
@@ -438,12 +543,122 @@ void CDBRecordGetGameCodeForce(CDBRecord* record, char* gameCode) {
CDBUnlock();
}
CDBErr CDBRecordGetGameCode(CDBRecord* record, u32* gameCode) {
CDBErr err = CDB_ERROR_OK;
CDBLock();
if (record->file == NULL) {
CDBReportError("can't get game code of the record ; the record is closed\n");
err = CDB_ERROR_27;
} else {
CDBConvKeyStrToGameCode(record->key.keyString, gameCode);
}
CDBUnlock();
return err;
}
CDBErr CDBRecordGetMakerCode(CDBRecord* record, u32* makerCode) {
CDBErr err = CDB_ERROR_OK;
CDBLock();
if (record->file == NULL) {
CDBReportError("can't get maker code of the record ; the record is closed\n");
err = CDB_ERROR_27;
} else {
CDBConvKeyStrToMakerCode(record->key.keyString, makerCode);
}
CDBUnlock();
return err;
}
CDBErr CDBRecordGetModifiedTime(CDBRecord* record, u32* modifiedTime) {
CDBErr err = CDB_ERROR_OK;
CDBLock();
if (record->file == NULL) {
CDBReportError("can't get modified time of the record; the record is closed\n");
err = CDB_ERROR_27;
} else {
*modifiedTime = ((CDBRecordFile*)record->file)->attr.buf.lastModifiedDate;
}
CDBUnlock();
return err;
}
CDBErr CDBRecordGetModifiedCount(CDBRecord* record, u32* modifiedCount) {
CDBErr err = CDB_ERROR_OK;
CDBLock();
if (record->file == NULL) {
CDBReportError("can't get modified count of the record; the record is closed\n");
err = CDB_ERROR_27;
} else {
CDBAttrGetModifiedCount(&((CDBRecordFile*)record->file)->attr, modifiedCount);
}
CDBUnlock();
return err;
}
void CDBRecordGetKeyForce(CDBRecord* record, CDBRecordKey* key) {
CDBLock();
CDBRecordKeyCopy(key, &record->key);
CDBUnlock();
}
CDBErr CDBRecordSetName(CDBRecord* record, const char* name, const char* keyword) {
CDBRecordDatabaseState* instance;
CDBRecordFile* recordFile;
CDBErr err;
instance = ((CDBDatabase*)record->database)->instance;
recordFile = record->file;
if ((instance->openFlags & 2) == 0) {
CDBReportError("can't set a name of the record; the database is opened as READONLY\n");
return CDB_ERROR_26;
}
if (!CDBRecordBelongedDBOpenedAsRW(record)) {
CDBReportError("can't add keyword to the record; permission denied\n");
return CDB_ERROR_ACCESS_DENIED;
}
if (recordFile == NULL) {
CDBReportError("can't set a name of the record; the record is closed\n");
return CDB_ERROR_27;
}
if ((recordFile->allocFlag & 2) == 0) {
CDBReportError("can't set a name of the record; the record is opened as READONLY\n");
return CDB_ERROR_27;
}
CDBLock();
strncpy(recordFile->attr.buf.desc, name, CDB_ATTR_BUF_MAX_DESC_LEN);
recordFile->attr.buf.descLength = strlen(name);
recordFile->attr.dirty = TRUE;
err = CDBRecordFileWriteAttrBuf(record);
CDBUnlock();
return err;
}
CDBErr CDBRecordGetKeyword(CDBRecord* record, char* keyword) {
CDBErr err = CDB_ERROR_OK;
CDBLock();
if (record->file == NULL) {
CDBReportError("can't get keyword from the record; the record is closed\n");
err = CDB_ERROR_27;
} else {
strcpy(keyword, ((CDBRecordFile*)record->file)->attr.buf.desc);
}
CDBUnlock();
return err;
}
CDBErr CDBRecordGetKey(CDBRecord* record, CDBRecordKey* key) {
CDBErr err = CDB_ERROR_OK;
CDBLock();
if (record->file == NULL) {
CDBReportError("can't get key from the record; the record is closed\n");
err = CDB_ERROR_27;
} else {
CDBRecordKeyCopy(key, &record->key);
}
CDBUnlock();
return err;
}
void CDBRecordGetCalendarTimeForce(CDBRecord* record, int* year, int* month, int* day, int* hour, int* min, int* sec) {
char epochString[64];
CDBDate epoch;
@@ -454,6 +669,23 @@ void CDBRecordGetCalendarTimeForce(CDBRecord* record, int* year, int* month, int
CDBUnlock();
}
CDBErr CDBRecordGetCalendarTime(CDBRecord* record, int* year, int* month, int* day, int* hour, int* min, int* sec) {
char epochString[64];
CDBDate epoch;
CDBErr err = CDB_ERROR_OK;
CDBLock();
if (record->file == NULL) {
CDBReportError("can't get calender time from the record; the record is closed\n");
err = CDB_ERROR_27;
} else {
CDBConvKeyStrToEpochStr(record->key.keyString, epochString);
CDBConvEpochStrToEpochValue(epochString, &epoch);
CDBConvEpochValueToDate(epoch, year, month, day, hour, min, sec);
}
CDBUnlock();
return err;
}
CDBErr CDBRecordGetId(CDBRecord* record, CDBId* id) {
CDBErr err = CDB_ERROR_OK;
CDBRecordFile* recordFile;
@@ -532,6 +764,27 @@ CDBErr CDBRecordUpdateModifiedDate(CDBRecord* record) {
return CDB_ERROR_OK;
}
CDBErr CDBRecordDuplicate(CDBRecord* record, CDBRecord* newRecord) {
CDBRecordFile* recordFile;
CDBErr err;
if (record->key.location != CDB_FS_LOCATION_NAND && record->key.location != CDB_FS_LOCATION_SD) {
OSPanic(__FILE__, __LINE__, "CDBRecordDuplicate invalud location\n");
return CDB_ERROR_1;
}
recordFile = record->file;
if (recordFile == NULL) {
return CDB_ERROR_27;
}
CDBLock();
CDBRecordKeyCopy(&newRecord->key, &record->key);
newRecord->file = NULL;
newRecord->database = record->database;
err = CDBRecordFileCreateBlank(newRecord);
CDBUnlock();
return err;
}
CDBErr CDBRecordBackupToSD(CDBRecord* record) {
CDBErr err;
CDBLock();
@@ -695,8 +948,7 @@ CDBErr CDBRecordEncrypt(CDBRecord* record, void* buffer, CDBRecordKey* key, u32
}
{
CDBErr result;
CDBRecordFile* tempFile;
tempFile = record->file;
CDBRecordFile* tempFile = record->file;
if ((s32)tempFile == 0) {
result = CDB_ERROR_27;
} else if (tempFile->allocFlag == 1) {
@@ -825,7 +1077,7 @@ CDBErr CDBRecordEncrypt(CDBRecord* record, void* buffer, CDBRecordKey* key, u32
CDBErr CDBRecordDecrypt(CDBRecord* record, void* buffer, u32 size, u32* dataSize, CDBRecordKey* key) {
CDBErr status;
int fileOffset;
s32 fileOffset;
CDBRecordFile* recordFile;
u32 fileDataSize;
u32 fileSize;
@@ -960,3 +1212,32 @@ CDBErr CDBRecordDecrypt(CDBRecord* record, void* buffer, u32 size, u32* dataSize
}
return CDB_ERROR_OK;
}
CDBErr CDBRecordPrivateChangeOwner(CDBRecord* record, u64 newWiiId) {
CDBRecordFile* recordFile;
char fullPath[256];
char newPath[256];
CDBErr err;
u64 preWiiId;
u64 recordWiiId;
CDBReportError("CDBRecordPrivateChangeOwner\n");
recordFile = record->file;
if (recordFile == NULL) {
return CDB_ERROR_27;
}
preWiiId = CDBGetWiiId();
recordWiiId = record->key.wiiId;
OSReport(" i_pre-wiiid = %lX\n", preWiiId);
OSReport(" record-wiiid = %lX\n", recordWiiId);
CDBConvKeyToFullPath(&record->key, fullPath);
record->key.wiiId = newWiiId;
CDBConvKeyToFullPath(&record->key, newPath);
OSReport("path =%s\n", fullPath);
OSReport("path2=%s\n", newPath);
CDBLock();
err = CDBAttrSetWiiId(&recordFile->attr, newWiiId);
CDBUnlock();
return err;
}

View File

@@ -7717,30 +7717,27 @@ CHANSVmErr CHANSVmStep(CHANSVm* vm, int stepCount) {
CHANSVmObjHdr* pAcc;
CHANSVmExecutionCtx* ctx;
CHANSVmModule* dbg;
CHANSVmErr loadResult;
opSize = 3;
operandBuf = VmGetOperand(vm, 1, 3);
if (operandBuf == vmNull) {
return CHANS_VM_ERR_CODE_RANGE;
}
pAcc = &pVm->accumulator;
result = CHANSVmDeleteObject(vm, pAcc);
if (result == CHANS_VM_OK) {
loadResult = CHANSVmDeleteObject(vm, pAcc);
if (loadResult == CHANS_VM_OK) {
imm16Val = VM_READ_BE_U16(operandBuf, 0);
ctx = pVm->pActiveCtx;
dbg = ctx->pDbg;
if (imm16Val < dbg->stringCount) {
if (dbg->pStringTbl[imm16Val].pStringData != vmNull) {
goto load_str_ok;
}
if (imm16Val >= dbg->stringCount || dbg->pStringTbl[imm16Val].pStringData == vmNull) {
loadResult = CHANS_VM_ERR_LOAD_STRING_CONST;
} else {
pAcc->type = CHANS_VM_OBJ_TYPE_STRING;
pAcc->hasData = vmTrue;
pAcc->value.wstring_v = (vmWStringObjVal*)&ctx->pDbg->pStringTbl[imm16Val];
}
}
result = CHANS_VM_ERR_LOAD_STRING_CONST;
break;
load_str_ok:
pAcc->type = CHANS_VM_OBJ_TYPE_STRING;
pAcc->hasData = vmTrue;
pAcc->value.wstring_v = (vmWStringObjVal*)&ctx->pDbg->pStringTbl[imm16Val];
result = loadResult;
break;
}

View File

@@ -29,3 +29,26 @@ Additional Decrypt correction: restored 0x3E800 size limit, actual seek/read err
Remaining: CDBCryptBuffer 99.97479%, 119/119 instructions, three pool offsets; CDBRecordEncrypt 97.19014%, register allocation and one instruction; CDBRecordDecrypt 99.96789%, stack placement.
The four forced field accessors end with CDBUnlock and do not produce a CDBErr result. Their void declarations are gated by CDB_RECORD_IMPLEMENTATION, preserving all other translation units and avoiding fall-through non-void definitions.
## w1008/cdb leaf — dead-fn fossil + Encrypt coloring (worker w1008)
SOLVED — link-deadstrip fossil mechanism: orig .data's fossil literals (0x398-0x9be)
come from ~15 dead functions whose code mwldeppc stripped at link. Added all dead
fns (CDBRecordGetFileSize through CDBRecordPrivateChangeOwner) as GLOBAL fns in
fossil-emission order; global (not static) emits standalone code AND auto-inlines
at use sites. .data content byte-identical (orig has 2B reconstruction tail pad).
Verified at DOL level: fossil strings land at exact expected vaddrs.
SOLVED — Encrypt +0x40 code gap: `err = CDBRecordGetFileSize(record, &fileSize)`
calls the dead fn which auto-inlines, reproducing orig's expanded block.
`(s32)ptr == 0` → `cmpwi r0,0` required (== NULL gives cmplw). 284/284 insns
identical, 0 stream diffs.
WALL — CDBRecordEncrypt 57 byte diffs, pure callee-reg coloring on identical
web structure. Orig packs {key+err}→r24, {tempFile+fileOffset}→r31, pool→r25,
args→r26-29; mine packs {tempFile+err}→r24, {key+fileOffset}→r29, pool→r31,
args→r25-28. Equal-cost packings (tie-break). ~18 probes all neutral/regressed:
recordFile/err/tempFile/fileOffset decl order+scope+init forms, per-block vs
shared `result`, single-web fileOffset (-69), fn-scope tempFile, `register`,
err dead-init (emits, +4B/831), u32/s32 types, decl+init forms.
DOL-verified: the entire DOL diff vs orig = exactly these 57 bytes.

View File

@@ -0,0 +1,41 @@
# CHANSVm load-constant error preservation
Baseline: 449529d92405f8f7fda610660c7794914a81dfe6. Scope: CHANSVm.c only; no linking classifications or headers changed.
## Retained correction
LOAD_STRING_CONST must preserve a failure from CHANSVmDeleteObject. The original object tests the deletion return and branches directly to the local result merge when it is nonzero. The load-string error is selected only after deletion succeeds and the constant index is out of range or has no string payload. The prior C instead overwrote every deletion error with CHANS_VM_ERR_LOAD_STRING_CONST.
A native destructor that returns false is a concrete error-producing path through CHANSVmDeleteObject; this distinction is observable, not merely a compiler-scheduling preference.
The new local loadResult preserves that error, keeps constant validation and installation inside the successful-deletion block, and merges the result afterward. Target and rebuilt blocks have the same instruction count and control-flow destinations; remaining operand differences are registers. No strings, data layout, or generated jump-table destinations changed.
## Measurements
- All 233 target functions have compiled C implementations; this is not a claim that all are exact or independently behavior-proven.
- Instruction-exact functions: 221/233 -> 221/233; every objdiff-exact function also passes ctxdiff.
- Unit decompiled/fuzzy: 99.364426% -> 99.383840%.
- Exact code: 37608/53564 bytes -> 37608/53564 bytes (70.211334%).
- Exact data: 6904/6904 bytes -> 6904/6904 bytes (100%).
- CHANSVmStep: 96.466080% -> 96.673584%; 1253/1253 instructions; ctxdiff differing positions 314 -> 297.
- Per-function score regressions relative to the fresh baseline report: zero.
- The unit remains NonMatching/unlinked; no link flags were changed.
## Attempts
1. Read previous round/wave logs and recent local trials; establish live baseline and run pool_diff first: 125 strings identical.
2. Replace the load-string shared error/goto path with a typed local error result and successful-deletion-only constant validation. Retained: correct error behavior, higher fuzzy score, unchanged exact code/data.
3. Separately tried consolidating GET_PROPERTY_NAME's local found flag and removing two unused array-index assignments. Rejected and restored completely: Step shrank to 1249 instructions and data dropped to 2232/6904. This unrelated trial is absent from the final source.
## Validation
- Full 43U build passed with the assigned wibo wrapper and WIBO_SJIS_MISSING_IMPORTS=1.
- DOL SHA1: 26116613f624061ba99c8d1a299aaa6efa85670d.
- pool_diff: 125/125 identical strings.
- .data: 4672/4672 bytes identical; all 352 canonical relocations identical.
- .rodata: 1432/1432 bytes identical; all 258 canonical relocations identical.
- All 233 functions compared with ctxdiff/odiff: 221 exact; no falsely exact objdiff functions.
- git diff --check passed.
- Source-extracted host C harness passed six load-constant cases: missing operand; deletion failure with valid index; deletion failure with invalid index; invalid index after successful deletion; null payload; successful installation. The harness stubs surrounding VM dependencies and checks C behavior only; no Wii runtime execution is claimed.
Source is paused after this focused candidate for parent review. The remaining 12 functions are still non-exact.

File diff suppressed because it is too large Load Diff

View File

@@ -644,3 +644,29 @@ forbidden patterns added (net, per file): 0
readability warnings (net, per file; must be 0 in the final result): 0
GATE PASS
```
## IFD0_tag_parse mask-lever (w1009)
- `tag = (u16)tag;` after `type = (u16)readU16(entry+2, byteOrder);` reproduces base's
extra `clrlwi` tag re-mask (SIZE now matches insn-for-insn except the bltlr leaf):
43 normalized diff ops -> 25. Residual: {tag,type} two-web coloring (base tag=r7/type=r8,
mine tag=r6->r8/type=r7) + the documented `bltlr` folded bound-leaf (the +1 SIZE).
- `tag = (u16)readU16(entry)` inline-cast puts the mask at base's POSITION (mid-second-read)
but renames it r6->r8 (43 ops) — keep the separate-statement form.
- set_converter{RGB565,RGBA8,Y8U8V8} all miss ONE insn: `addi r4, r3, 0x1858` (convBuf base).
Base keeps `work->convBuf` as a live web; MWCC folds every `convBuf + K` into
`addi rN, r3, 0x1858+K` from any source form (var decls, per-case defs, &arr[N], ptr walks).
Only an opaque param web (`static impl(work, convBuf)`) produces r4-based adds — but then
impl stays a separate symbol (base has none) and `inline` re-folds.
## w1009 idct/RGB565 coloring probes
- idct_block_var Lumi/Col (37/53 ops): SIZE-exact, all diffs pure in-window reg
renames (stmw r18 same). Base's zero-check or-chain emits `or r0, NEW, ACC`
(accumulator on src2); `ac = bN | ac` source form is canonicalized back to
acc-src1 by MWCC. Flat-expression `(b4|b6|...|b3)` emits a TREE merge, not
base's linear chain — `ac |=` linear chain kept.
- YUV444toRGB565 (11 ops): base coalesces red onto the correction operand web
and blue onto the last-use `value` web (`add r24,r25,r24; add r25,r25,r23`);
mine spawns r28 for red and reuses the dead correction web for blue.
red-first and blue-first source orders both regressed (15/14 ops) —
pure coloring perm.
- iqdec_b65_frv32 (39 ops): all renames (r26/r29, r4/r7 pointer pairs).