Compare commits

...

1 Commits

Author SHA1 Message Date
coah
c652da19c3 fix(odh): preserve unsigned refills and defer planar addressing 2026-10-08 21:44:34 -05:00
2 changed files with 53 additions and 7 deletions

View File

@@ -891,8 +891,7 @@ s32 CArGBAOdh::cdj_c_colorConv(SArCDJ_OdhMaster* master, u8* sourceData, int for
void CArGBAOdh::LineConv11(u8* source, u8* lumaOutput, u8* cbOutput, u8* crOutput, u16 width, u16 height,
const long* conversionTable, int format) {
u8* cbSource = source + width * height;
u8* crSource = source + width * height * 2;
u32 planeSize = (u32)width * (u32)height;
for (int i = 0; i < width; i++) {
s32 red;
s32 green;
@@ -916,8 +915,8 @@ void CArGBAOdh::LineConv11(u8* source, u8* lumaOutput, u8* cbOutput, u8* crOutpu
} else {
int offset = (i & 7) + (i & ~7) * 4;
float y = source[offset] - colorConvert16;
float cb = cbSource[offset] - colorConvert128;
float cr = crSource[offset] - colorConvert128;
float cb = source[planeSize + offset] - colorConvert128;
float cr = source[planeSize * 2 + offset] - colorConvert128;
red = colorConvertY * y + colorConvertR * cr;
green = colorConvertY * y - colorConvertG1 * cb - colorConvertG2 * cr;
blue = colorConvertY * y + colorConvertB * cb;
@@ -2025,7 +2024,7 @@ s32 CArGBAOdh::huffmanDecoder(u32* coefficientOutput, SArCDJ_HuffmanRequest* req
return ODH_ERROR_INVALID_BITSTREAM;
}
bitBuffer = (sourceCursor[0] << 24 | sourceCursor[1] << 16 | sourceCursor[2] << 8 | sourceCursor[3]) << bitOffset;
bitBuffer = ((u32)sourceCursor[0] << 24 | (u32)sourceCursor[1] << 16 | (u32)sourceCursor[2] << 8 | sourceCursor[3]) << bitOffset;
maxLength = component == 0 ? 9 : 11;
length = 1;
@@ -2081,7 +2080,7 @@ s32 CArGBAOdh::huffmanDecoder(u32* coefficientOutput, SArCDJ_HuffmanRequest* req
return ODH_ERROR_INVALID_BITSTREAM;
}
bitBuffer = (sourceCursor[0] << 24 | sourceCursor[1] << 16 | sourceCursor[2] << 8 | sourceCursor[3]) << bitOffset;
bitBuffer = ((u32)sourceCursor[0] << 24 | (u32)sourceCursor[1] << 16 | (u32)sourceCursor[2] << 8 | sourceCursor[3]) << bitOffset;
length = 1;
tableIndex = 0;
for (; length <= 6; length++) {
@@ -2144,7 +2143,7 @@ s32 CArGBAOdh::huffmanDecoder(u32* coefficientOutput, SArCDJ_HuffmanRequest* req
return ODH_ERROR_INVALID_BITSTREAM;
}
bitBuffer = (sourceCursor[0] << 24 | sourceCursor[1] << 16 | sourceCursor[2] << 8 | sourceCursor[3]) << bitOffset;
bitBuffer = ((u32)sourceCursor[0] << 24 | (u32)sourceCursor[1] << 16 | (u32)sourceCursor[2] << 8 | sourceCursor[3]) << bitOffset;
maxLength = component == 0 ? 9 : 11;
length = 1;

View File

@@ -0,0 +1,47 @@
# ODH source-integrity checks
Base: 3d7e767cf729de96ac1cd88ddbf5c18eaa08187d (43U only).
- Restored unsigned arithmetic in all three huffmanDecoder word refills by
casting the shifted bytes to u32. The combined word and its bitOffset shift
now remain unsigned, including input words with the high bit set.
- Restored unsigned planeSize indexing in LineConv11. Chroma source pointers
are only formed by accesses in the planar-format branch. The RGB565 caller
passes a row-offset pointer into Capture's GXGetTexBufferSize allocation;
for tile-aligned dimensions that allocation is exactly width*height*2 bytes.
Unconditionally adding two planes to a nonzero row pointer could therefore
form an out-of-bounds pointer even though RGB565 never dereferences it.
- Reviewed the full huffmanDecoder rewrite against its preceding source.
Other category shifts and caller/table preconditions were already present;
no additional newly introduced arithmetic issue was identified in this pass.
One candidate, no compiler flags or other source changes. No debugger, compiler
memory access, forced registers, assembly, uninitialized values, or online source
references were used. Retail objects and disassembly remained local.
Validation:
- All allocated source-object sections, function spans, and resolved relocations
are identical to the unmodified base object (debug metadata differs).
- All 28 retail function spans are raw-byte exact: 14,684 bytes, with all 203
relocations identical after resolving local symbols to actual section offsets
and code symbols to function-relative targets.
- Data matches: .rodata 5,856, .data 464, .sdata2 40 bytes. The source .data is
459 bytes plus five zero alignment bytes in the split/link target.
- Pool identical, 10/10 strings. huffmanDecoder ctxdiff: 306/306, zero diffs.
LineConv11: 146/146; the strict-name local helper prints eight pre-existing
label-name differences. Exact bytes, resolved relocation destinations, and
referenced data independently match; none were ignored without resolution.
- Official objdiff: ODH 28/28 functions; code, data, fuzzy and link all 100%.
- Every measure, function and section in all 1,028 report units, plus all global
measures, is unchanged from the base report.
- Full 43U build and build/43U/ok pass. DOL SHA1:
26116613f624061ba99c8d1a299aaa6efa85670d.
- All 22 workflow-guard tests pass. A host UBSan refill test passes 524,288
cases against a 64-bit oracle (every high byte, offsets 0..7).
- The global completion checker still fails on pre-existing incomplete units;
this change does not claim repository-wide completion.
Local reproducible evidence: ../odh-unsigned-refills-evidence/verify.py,
verification.log, full-build.log, pool.log, guards.log, refill-test.cpp/log,
completion.log, status.json and dol.sha1. No publication or merge performed.