This commit is contained in:
Ryan Oldenburg 2022-05-25 19:20:45 -05:00
parent 3b67e809c5
commit 07d16c7c87

View file

@ -69,12 +69,14 @@ type
len, pos: int len, pos: int
bitsBuffered: int bitsBuffered: int
bitBuffer: uint32 bitBuffer: uint32
imageHeight, imageWidth: int imageHeight, imageWidth: int
quantizationTables: array[4, array[64, uint8]] quantizationTables: array[4, array[64, uint8]]
huffmanTables: array[2, array[4, Huffman]] # 0 = DC, 1 = AC huffmanTables: array[2, array[4, Huffman]] # 0 = DC, 1 = AC
components: seq[Component] components: seq[Component]
maxYScale, maxXScale: int maxYScale, maxXScale: int
mcuWidth, mcuHeight, numMcuWide, numMcuHigh: int mcuWidth, mcuHeight, numMcuWide, numMcuHigh: int
scanComponents: int scanComponents: int
spectralStart, spectralEnd: int spectralStart, spectralEnd: int
successiveApproxLow, successiveApproxHigh: int successiveApproxLow, successiveApproxHigh: int
@ -857,8 +859,8 @@ proc decodeBlocks(state: var DecoderState) =
# Single component pass. # Single component pass.
let let
comp = state.componentOrder[0] comp = state.componentOrder[0]
w = (state.components[comp].width + 7) shr 3 w = (state.components[comp].width + 7) div 8
h = (state.components[comp].height + 7) shr 3 h = (state.components[comp].height + 7) div 8
for column in 0 ..< h: for column in 0 ..< h:
for row in 0 ..< w: for row in 0 ..< w:
state.decodeBlock(comp, row, column) state.decodeBlock(comp, row, column)
@ -880,8 +882,8 @@ proc quantizationAndIDCTPass(state: var DecoderState) =
## Does quantization and IDCT. ## Does quantization and IDCT.
for comp in 0 ..< state.components.len: for comp in 0 ..< state.components.len:
let let
w = (state.components[comp].width + 7) shr 3 w = (state.components[comp].width + 7) div 8
h = (state.components[comp].height + 7) shr 3 h = (state.components[comp].height + 7) div 8
qTableId = state.components[comp].quantizationTableId qTableId = state.components[comp].quantizationTableId
if qTableId.int notin 0 ..< state.quantizationTables.len: if qTableId.int notin 0 ..< state.quantizationTables.len:
failInvalid() failInvalid()