ez perf
This commit is contained in:
parent
3f2fefb43d
commit
3e204e829f
1 changed files with 8 additions and 4 deletions
|
@ -895,17 +895,21 @@ proc buildImage(state: var DecoderState): Image =
|
||||||
cb = state.components[1].channel
|
cb = state.components[1].channel
|
||||||
cr = state.components[2].channel
|
cr = state.components[2].channel
|
||||||
for y in 0 ..< state.imageHeight:
|
for y in 0 ..< state.imageHeight:
|
||||||
|
var channelIndex = cy.dataIndex(0, y)
|
||||||
for x in 0 ..< state.imageWidth:
|
for x in 0 ..< state.imageWidth:
|
||||||
result.unsafe[x, y] = yCbCrToRgbx(
|
result.unsafe[x, y] = yCbCrToRgbx(
|
||||||
cy.unsafe[x, y],
|
cy.data[channelIndex],
|
||||||
cb.unsafe[x, y],
|
cb.data[channelIndex],
|
||||||
cr.unsafe[x, y],
|
cr.data[channelIndex],
|
||||||
)
|
)
|
||||||
|
inc channelIndex
|
||||||
elif state.components.len == 1:
|
elif state.components.len == 1:
|
||||||
let cy = state.components[0].channel
|
let cy = state.components[0].channel
|
||||||
for y in 0 ..< state.imageHeight:
|
for y in 0 ..< state.imageHeight:
|
||||||
|
var channelIndex = cy.dataIndex(0, y)
|
||||||
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.data[channelIndex])
|
||||||
|
inc channelIndex
|
||||||
else:
|
else:
|
||||||
failInvalid()
|
failInvalid()
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue