diff options
Diffstat (limited to 'src/code/jpegdecoder.c')
| -rw-r--r-- | src/code/jpegdecoder.c | 24 |
1 files changed, 7 insertions, 17 deletions
diff --git a/src/code/jpegdecoder.c b/src/code/jpegdecoder.c index cde91207c..238ca2439 100644 --- a/src/code/jpegdecoder.c +++ b/src/code/jpegdecoder.c @@ -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; |
