f
This commit is contained in:
parent
68b9d63ecd
commit
01fe732608
1 changed files with 3 additions and 4 deletions
|
@ -399,11 +399,10 @@ proc fillBitBuffer(state: var DecoderState) =
|
||||||
|
|
||||||
proc huffmanDecode(state: var DecoderState, tableCurrent, table: int): uint8 =
|
proc huffmanDecode(state: var DecoderState, tableCurrent, table: int): uint8 =
|
||||||
## Decode a uint8 from the huffman table.
|
## Decode a uint8 from the huffman table.
|
||||||
if state.bitsBuffered < 16:
|
|
||||||
state.fillBitBuffer()
|
|
||||||
|
|
||||||
var huffman {.byaddr.} = state.huffmanTables[tableCurrent][table]
|
var huffman {.byaddr.} = state.huffmanTables[tableCurrent][table]
|
||||||
|
|
||||||
|
state.fillBitBuffer()
|
||||||
|
|
||||||
let
|
let
|
||||||
fastId = (state.bitBuffer shr (32 - fastBits)) and ((1 shl fastBits) - 1)
|
fastId = (state.bitBuffer shr (32 - fastBits)) and ((1 shl fastBits) - 1)
|
||||||
fast = huffman.fast[fastId]
|
fast = huffman.fast[fastId]
|
||||||
|
@ -430,7 +429,7 @@ proc huffmanDecode(state: var DecoderState, tableCurrent, table: int): uint8 =
|
||||||
let symbolId = (state.bitBuffer shr (32 - i)).int + huffman.deltas[i]
|
let symbolId = (state.bitBuffer shr (32 - i)).int + huffman.deltas[i]
|
||||||
state.bitBuffer = state.bitBuffer shl i
|
state.bitBuffer = state.bitBuffer shl i
|
||||||
state.bitsBuffered -= i
|
state.bitsBuffered -= i
|
||||||
huffman.symbols[symbolId]
|
return huffman.symbols[symbolId]
|
||||||
|
|
||||||
template lrot(value: uint32, shift: int): uint32 =
|
template lrot(value: uint32, shift: int): uint32 =
|
||||||
## Left rotate - used for huffman decoding.
|
## Left rotate - used for huffman decoding.
|
||||||
|
|
Loading…
Reference in a new issue