Skip to content

Commit

Permalink
Improve perf when extracting slices
Browse files Browse the repository at this point in the history
If the residual is in the top bits, the compiler doesn't need to clear the higher bits during the loop.
  • Loading branch information
braheezy committed Jan 4, 2025
1 parent acbf524 commit 1bfbba6
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion decode.go
Original file line number Diff line number Diff line change
Expand Up @@ -89,12 +89,13 @@ func (q *QOA) decodeFrame(bytes []byte, size uint, sampleData []int16, frameLen
p += 8

scaleFactor := (slice >> 60) & 0xF
slice <<= 4
sliceStart := sampleIndex*channels + c
sliceEnd := uint32(clamp(int(sampleIndex)+QOASliceLen, 0, int(samples)))*channels + c

for si := sliceStart; si < sliceEnd; si += channels {
predicted := q.lms[c].predict()
quantized := int((slice >> 57) & 0x7)
quantized := int((slice >> 61) & 0x7)
dequantized := qoaDequantTable[scaleFactor][quantized]
reconstructed := clampS16(predicted + int(dequantized))

Expand Down

0 comments on commit 1bfbba6

Please sign in to comment.