@@ -297,8 +297,9 @@ proc decodeSOF0(state: var DecoderState) =
297297 if state.imageWidth == 0 :
298298 failInvalid (" image invalid 0 width" )
299299
300- let numComponents = state.readUint8 ().int
301- if numComponents notin {1 , 3 }:
300+ let numComponentsU8 = state.readUint8 ()
301+ let numComponents = numComponentsU8.int
302+ if numComponentsU8 notin {1 'u8 , 3 }:
302303 failInvalid (" unsupported component count, must be 1 or 3" )
303304
304305 len -= 6
@@ -315,7 +316,7 @@ proc decodeSOF0(state: var DecoderState) =
315316 if quantizationTableId > 3 :
316317 failInvalid (" invalid quantization table id" )
317318
318- if vertical notin {1 , 2 , 4 } or horizontal notin {1 , 2 , 4 }:
319+ if vertical notin {1 'u8 , 2 , 4 } or horizontal notin {1 'u8 , 2 , 4 }:
319320 failInvalid (" invalid component scaling factor" )
320321
321322 component.xScale = vertical.int
@@ -443,13 +444,13 @@ proc reset(state: var DecoderState) =
443444proc decodeSOS (state: var DecoderState ) =
444445 # # Decode Start of Scan - header before the block data.
445446 var len = state.readUint16be () - 2
446-
447- state.scanComponents = state. readUint8 () .int
447+ let scanComponentsU8 = state. readUint8 ()
448+ state.scanComponents = scanComponentsU8 .int
448449
449450 if state.scanComponents > state.components.len:
450451 failInvalid (" extra components" )
451452
452- if state.scanComponents notin {1 , 3 }:
453+ if scanComponentsU8 notin {1 'u8 , 3 }:
453454 failInvalid (" unsupported scan component count" )
454455
455456 state.componentOrder.setLen (0 )
@@ -878,7 +879,7 @@ proc checkRestart(state: var DecoderState) =
878879 if state.pos + 1 > state.len:
879880 failInvalid ()
880881 if state.buffer[state.pos] != 0x FF or
881- state.buffer[state.pos + 1 ] notin { 0x D0 .. 0x D7 } :
882+ state.buffer[state.pos + 1 ] notin 0x D0 'u8 .. 0x D7 'u8 :
882883 failInvalid (" did not get expected restart marker" )
883884 state.pos += 2
884885 state.reset ()
0 commit comments