1
0
Fork 0
mirror of https://github.com/zeldaret/oot.git synced 2025-07-04 06:54:33 +00:00

jpegdecoder OK (#574)

* new match

* and the .s

* merge

Co-authored-by: petrie911 <pmontag@DESKTOP-LG8A167.localdomain>
This commit is contained in:
petrie911 2020-12-29 21:45:01 -06:00 committed by GitHub
parent dd38520a9e
commit 1facd83c38
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 8 additions and 105 deletions

View file

@ -124,17 +124,11 @@ s32 JpegDecoder_ProcessMcu(JpegHuffmanTable* hTable0, JpegHuffmanTable* hTable1,
return 0;
}
#ifdef NON_MATCHING
// stack usage (coeffLength is stored as a u32 instead of a u8)
s32 JpegDecoder_ParseNextSymbol(JpegHuffmanTable* hTable, s16* outCoeff, u8* outZeroCount) {
u16 buff;
u8 codeIdx;
u8 sym;
u8 coeffLength; // 0x26
u16 codeOff; // 0x24
codeOff = 0;
buff = JpegDecoder_ReadBits(16);
u16 codeOff = 0;
u16 buff = JpegDecoder_ReadBits(16);
for (codeIdx = 0; codeIdx < 16; codeIdx++) {
if (hTable->codesB[codeIdx] == 0xFFFF) {
@ -153,23 +147,19 @@ s32 JpegDecoder_ParseNextSymbol(JpegHuffmanTable* hTable, s16* outCoeff, u8* out
sym = hTable->symbols[hTable->codeOffs[codeIdx] + codeOff - hTable->codesA[codeIdx]];
*outZeroCount = sym >> 4;
coeffLength = sym & 0xF; // not using a temp for "sym & 0xF" puts coeffLength on the stack
sym &= 0xF;
sJpegBitStreamBitIdx += codeIdx - 15;
*outCoeff = 0;
if (coeffLength) { // (cond != 0) instead of (cond) puts coeffLength on the stack
*outCoeff = JpegDecoder_ReadBits(coeffLength);
if (*outCoeff < (1 << (coeffLength - 1))) {
*outCoeff +=
(-1 << coeffLength) + 1; // (*outCoeff -= (1 << coeffLength)-1; makes more sense but doesn't match)
if (sym) {
*outCoeff = JpegDecoder_ReadBits(sym);
if (*outCoeff < (1 << (sym - 1))) {
*outCoeff += (-1 << sym) + 1;
}
}
return 0;
}
#else
#pragma GLOBAL_ASM("asm/non_matchings/code/jpegdecoder/JpegDecoder_ParseNextSymbol.s")
#endif
u16 JpegDecoder_ReadBits(u8 len) {
u8 byteCount;