diff options
| author | petrie911 <69443847+petrie911@users.noreply.github.com> | 2020-12-29 21:45:01 -0600 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2020-12-29 22:45:01 -0500 |
| commit | 1facd83c3866041b4b66f583773455bc87fb62b9 (patch) | |
| tree | cb3616abec1605c044deb092f865cf692f6ba381 /src/code/jpegdecoder.c | |
| parent | dd38520a9e2f00583112db4c5f0562410cd03a4f (diff) | |
jpegdecoder OK (#574)
* new match
* and the .s
* merge
Co-authored-by: petrie911 <pmontag@DESKTOP-LG8A167.localdomain>
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; |
