f
This commit is contained in:
parent
8036516c7d
commit
e4e94b84f9
1 changed files with 5 additions and 8 deletions
|
@ -801,16 +801,14 @@ proc quantizationAndIDCTPass(state: var DecoderState) =
|
||||||
let
|
let
|
||||||
w = (state.components[comp].width + 7) shr 3
|
w = (state.components[comp].width + 7) shr 3
|
||||||
h = (state.components[comp].height + 7) shr 3
|
h = (state.components[comp].height + 7) shr 3
|
||||||
|
qTableId = state.components[comp].quantizationTableId
|
||||||
|
if qTableId.int notin 0 ..< state.quantizationTables.len:
|
||||||
|
failInvalid()
|
||||||
for column in 0 ..< h:
|
for column in 0 ..< h:
|
||||||
for row in 0 ..< w:
|
for row in 0 ..< w:
|
||||||
var data = state.components[comp].blocks[row][column]
|
var data {.byaddr.} = state.components[comp].blocks[row][column]
|
||||||
|
|
||||||
for i in 0 ..< 64:
|
for i in 0 ..< 64:
|
||||||
let qTableId = state.components[comp].quantizationTableId
|
|
||||||
if qTableId.int notin 0 ..< state.quantizationTables.len:
|
|
||||||
failInvalid()
|
|
||||||
data[i] = cast[int16](data[i] * state.quantizationTables[qTableId][i].int32)
|
data[i] = cast[int16](data[i] * state.quantizationTables[qTableId][i].int32)
|
||||||
|
|
||||||
state.components[comp].idctBlock(
|
state.components[comp].idctBlock(
|
||||||
state.components[comp].widthStride * column * 8 + row * 8,
|
state.components[comp].widthStride * column * 8 + row * 8,
|
||||||
data
|
data
|
||||||
|
@ -900,8 +898,7 @@ proc buildImage(state: var DecoderState): Image =
|
||||||
cr.unsafe[x, y],
|
cr.unsafe[x, y],
|
||||||
)
|
)
|
||||||
elif state.components.len == 1:
|
elif state.components.len == 1:
|
||||||
let
|
let cy = state.components[0].channel
|
||||||
cy = state.components[0].channel
|
|
||||||
for y in 0 ..< state.imageHeight:
|
for y in 0 ..< state.imageHeight:
|
||||||
for x in 0 ..< state.imageWidth:
|
for x in 0 ..< state.imageWidth:
|
||||||
result.unsafe[x, y] = grayScaleToRgbx(cy.unsafe[x, y])
|
result.unsafe[x, y] = grayScaleToRgbx(cy.unsafe[x, y])
|
||||||
|
|
Loading…
Reference in a new issue