-
Notifications
You must be signed in to change notification settings - Fork 1
/
decode_amd64.go
43 lines (37 loc) · 1.15 KB
/
decode_amd64.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
// Copyright (c) 2024, Intel Corporation.
// SPDX-License-Identifier: BSD-3-Clause
//go:build amd64 && !noasmtest
package flate
import "github.com/intel/fastgo/internal/cpu"
func decodeHuffmanAsmArchV3(state *inflate, output []byte, offset int) (written int, errno int)
func decodeHuffman(state *inflate, output []byte, written int) (w int, err error) {
if cpu.ArchLevel < 3 {
return decodeHuffmanLargeLoop(state, output, written)
}
if len(output)-written > outBufferSlop && len(state.input) > inBufferSlop {
var errno int
written, errno = decodeHuffmanAsmArchV3(state, output[:len(output)-outBufferSlop], written)
if errno != 0 && errno != errorNoEndInput {
switch errno {
case errorNoInvalidBlock:
err = errInvalidBlock
case errorNoInvalidSymbol:
err = errInvalidSymbol
case errorNoInvalidLookback:
err = errInvalidLookBack
case errorNoOutOverflow:
err = errOutputOverflow
}
return written, err
}
if errno == 0 {
state.phase = phaseNewBlock
if state.bfinal == 1 {
state.phase = phaseStreamEnd
}
return written, nil
}
}
// fallback to slow path
return decodeHuffmanLargeLoop(state, output, written)
}