Fix compatibility with nimskull

This commit is contained in:
Alberto Torres 2024-08-17 17:28:15 +02:00
parent 3b65ca5605
commit 89ac8dfbe6
3 changed files with 9 additions and 12 deletions

View file

@ -1,5 +1,5 @@
import chroma, flatty/binny, ../common, ../images, ../internal, import chroma, flatty/binny, ../common, ../images, ../internal,
../simd, std/decls, std/sequtils, std/strutils ../simd, std/sequtils, std/strutils
# This JPEG decoder is loosely based on stb_image which is public domain. # This JPEG decoder is loosely based on stb_image which is public domain.
@ -547,7 +547,7 @@ 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.
var huffman {.byaddr.} = state.huffmanTables[tableCurrent][table] var huffman = state.huffmanTables[tableCurrent][table].addr
state.fillBitBuffer() state.fillBitBuffer()
@ -884,14 +884,15 @@ proc idctBlock(component: var Component, offset: int, data: array[64, int16]) =
proc decodeBlock(state: var DecoderState, comp, row, column: int) = proc decodeBlock(state: var DecoderState, comp, row, column: int) =
## Decodes a block. ## Decodes a block.
var data {.byaddr.} = state.components[comp].blocks[row][column] var data = state.components[comp].blocks[row][column].addr
if state.progressive: if state.progressive:
if state.spectralStart == 0: if state.spectralStart == 0:
state.decodeProgressiveBlock(comp, data) state.decodeProgressiveBlock(comp, data[])
else: else:
state.decodeProgressiveContinuationBlock(comp, data) state.decodeProgressiveContinuationBlock(comp, data[])
else: else:
state.decodeRegularBlock(comp, data) state.decodeRegularBlock(comp, data[])
proc checkRestart(state: var DecoderState) = proc checkRestart(state: var DecoderState) =
## Check if we might have run into a restart marker, then deal with it. ## Check if we might have run into a restart marker, then deal with it.
@ -941,7 +942,7 @@ proc quantizationAndIDCTPass(state: var DecoderState) =
failInvalid() failInvalid()
for column in 0 ..< h: for column in 0 ..< h:
for row in 0 ..< w: for row in 0 ..< w:
var data {.byaddr.} = state.components[comp].blocks[row][column] var data = state.components[comp].blocks[row][column].addr
when defined(amd64) and allowSimd: when defined(amd64) and allowSimd:
for i in 0 ..< 8: # 8 per pass for i in 0 ..< 8: # 8 per pass
@ -957,7 +958,7 @@ proc quantizationAndIDCTPass(state: var DecoderState) =
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[]
) )
proc magnifyXBy2(mask: Mask): Mask = proc magnifyXBy2(mask: Mask): Mask =

View file

@ -497,7 +497,6 @@ proc blendRect(a, b: Image, pos: Ivec2, blendMode: BlendMode) =
xEnd - xStart xEnd - xStart
) )
of MaskBlend: of MaskBlend:
{.linearScanEnd.}
if yStart + py > 0: if yStart + py > 0:
zeroMem(a.data[0].addr, (yStart + py) * a.width * 4) zeroMem(a.data[0].addr, (yStart + py) * a.width * 4)
for y in yStart ..< yEnd: for y in yStart ..< yEnd:
@ -607,7 +606,6 @@ proc drawSmooth(a, b: Image, transform: Mat3, blendMode: BlendMode) =
) )
of MaskBlend: of MaskBlend:
{.linearScanEnd.}
if blendMode == MaskBlend and xStart > 0: if blendMode == MaskBlend and xStart > 0:
zeroMem(a.data[a.dataIndex(0, y)].addr, xStart * 4) zeroMem(a.data[a.dataIndex(0, y)].addr, xStart * 4)

View file

@ -1505,7 +1505,6 @@ proc fillCoverage(
) )
of MaskBlend: of MaskBlend:
{.linearScanEnd.}
blendLineCoverageMask( blendLineCoverageMask(
image.getUncheckedArray(startX, y), image.getUncheckedArray(startX, y),
cast[ptr UncheckedArray[uint8]](coverages[0].unsafeAddr), cast[ptr UncheckedArray[uint8]](coverages[0].unsafeAddr),
@ -1560,7 +1559,6 @@ proc fillHits(
blendLineNormal(image.getUncheckedArray(start, y), rgbx, len) blendLineNormal(image.getUncheckedArray(start, y), rgbx, len)
of MaskBlend: of MaskBlend:
{.linearScanEnd.}
var filledTo = startX var filledTo = startX
for (start, len) in hits.walkInteger(numHits, windingRule, y, image.width): for (start, len) in hits.walkInteger(numHits, windingRule, y, image.width):
if maskClears: # Clear any gap between this fill and the previous fill if maskClears: # Clear any gap between this fill and the previous fill