mirror of
https://github.com/containers/skopeo.git
synced 2025-07-13 14:34:44 +00:00
Bump github.com/containers/storage from 1.32.0 to 1.32.1
Bumps [github.com/containers/storage](https://github.com/containers/storage) from 1.32.0 to 1.32.1. - [Release notes](https://github.com/containers/storage/releases) - [Changelog](https://github.com/containers/storage/blob/master/docs/containers-storage-changes.md) - [Commits](https://github.com/containers/storage/compare/v1.32.0...v1.32.1) Signed-off-by: dependabot[bot] <support@github.com>
This commit is contained in:
parent
714ffe1b60
commit
c806083830
2
go.mod
2
go.mod
@ -6,7 +6,7 @@ require (
|
|||||||
github.com/containers/common v0.39.0
|
github.com/containers/common v0.39.0
|
||||||
github.com/containers/image/v5 v5.12.0
|
github.com/containers/image/v5 v5.12.0
|
||||||
github.com/containers/ocicrypt v1.1.1
|
github.com/containers/ocicrypt v1.1.1
|
||||||
github.com/containers/storage v1.32.0
|
github.com/containers/storage v1.32.1
|
||||||
github.com/docker/docker v20.10.6+incompatible
|
github.com/docker/docker v20.10.6+incompatible
|
||||||
github.com/dsnet/compress v0.0.2-0.20210315054119-f66993602bf5 // indirect
|
github.com/dsnet/compress v0.0.2-0.20210315054119-f66993602bf5 // indirect
|
||||||
github.com/go-check/check v0.0.0-20180628173108-788fd7840127
|
github.com/go-check/check v0.0.0-20180628173108-788fd7840127
|
||||||
|
6
go.sum
6
go.sum
@ -207,8 +207,9 @@ github.com/containers/ocicrypt v1.1.0/go.mod h1:b8AOe0YR67uU8OqfVNcznfFpAzu3rdgU
|
|||||||
github.com/containers/ocicrypt v1.1.1 h1:prL8l9w3ntVqXvNH1CiNn5ENjcCnr38JqpSyvKKB4GI=
|
github.com/containers/ocicrypt v1.1.1 h1:prL8l9w3ntVqXvNH1CiNn5ENjcCnr38JqpSyvKKB4GI=
|
||||||
github.com/containers/ocicrypt v1.1.1/go.mod h1:Dm55fwWm1YZAjYRaJ94z2mfZikIyIN4B0oB3dj3jFxY=
|
github.com/containers/ocicrypt v1.1.1/go.mod h1:Dm55fwWm1YZAjYRaJ94z2mfZikIyIN4B0oB3dj3jFxY=
|
||||||
github.com/containers/storage v1.30.1/go.mod h1:NDJkiwxnSHD1Is+4DGcyR3SIEYSDOa0xnAW+uGQFx9E=
|
github.com/containers/storage v1.30.1/go.mod h1:NDJkiwxnSHD1Is+4DGcyR3SIEYSDOa0xnAW+uGQFx9E=
|
||||||
github.com/containers/storage v1.32.0 h1:l2O+EybfGVkisqDkRysKG1VAO6jPPIYOV5Q4/sau86c=
|
|
||||||
github.com/containers/storage v1.32.0/go.mod h1:J3q772EVbN9vgqoN/dkvInKnp4xK9ZXm7wHNfuiIDgE=
|
github.com/containers/storage v1.32.0/go.mod h1:J3q772EVbN9vgqoN/dkvInKnp4xK9ZXm7wHNfuiIDgE=
|
||||||
|
github.com/containers/storage v1.32.1 h1:JgvHY5dokiff+Ee4TdvPYO++Oq2BAave5DmyPetH2iU=
|
||||||
|
github.com/containers/storage v1.32.1/go.mod h1:do6oIF71kfkVS3CPUZr+6He94fIaj6pzF8ywevPuuOw=
|
||||||
github.com/coreos/bbolt v1.3.2/go.mod h1:iRUV2dpdMOn7Bo10OQBFzIJO9kkE559Wcmn+qkEiiKk=
|
github.com/coreos/bbolt v1.3.2/go.mod h1:iRUV2dpdMOn7Bo10OQBFzIJO9kkE559Wcmn+qkEiiKk=
|
||||||
github.com/coreos/etcd v3.3.10+incompatible/go.mod h1:uF7uidLiAD3TWHmW31ZFd/JWoc32PjwdhPthX9715RE=
|
github.com/coreos/etcd v3.3.10+incompatible/go.mod h1:uF7uidLiAD3TWHmW31ZFd/JWoc32PjwdhPthX9715RE=
|
||||||
github.com/coreos/etcd v3.3.13+incompatible/go.mod h1:uF7uidLiAD3TWHmW31ZFd/JWoc32PjwdhPthX9715RE=
|
github.com/coreos/etcd v3.3.13+incompatible/go.mod h1:uF7uidLiAD3TWHmW31ZFd/JWoc32PjwdhPthX9715RE=
|
||||||
@ -459,8 +460,9 @@ github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+o
|
|||||||
github.com/klauspost/compress v1.4.1/go.mod h1:RyIbtBH6LamlWaDj8nUwkbUhJ87Yi3uG0guNDohfE1A=
|
github.com/klauspost/compress v1.4.1/go.mod h1:RyIbtBH6LamlWaDj8nUwkbUhJ87Yi3uG0guNDohfE1A=
|
||||||
github.com/klauspost/compress v1.11.3/go.mod h1:aoV0uJVorq1K+umq18yTdKaF57EivdYsUV+/s2qKfXs=
|
github.com/klauspost/compress v1.11.3/go.mod h1:aoV0uJVorq1K+umq18yTdKaF57EivdYsUV+/s2qKfXs=
|
||||||
github.com/klauspost/compress v1.11.13/go.mod h1:aoV0uJVorq1K+umq18yTdKaF57EivdYsUV+/s2qKfXs=
|
github.com/klauspost/compress v1.11.13/go.mod h1:aoV0uJVorq1K+umq18yTdKaF57EivdYsUV+/s2qKfXs=
|
||||||
github.com/klauspost/compress v1.12.2 h1:2KCfW3I9M7nSc5wOqXAlW2v2U6v+w6cbjvbfp+OykW8=
|
|
||||||
github.com/klauspost/compress v1.12.2/go.mod h1:8dP1Hq4DHOhN9w426knH3Rhby4rFm6D8eO+e+Dq5Gzg=
|
github.com/klauspost/compress v1.12.2/go.mod h1:8dP1Hq4DHOhN9w426knH3Rhby4rFm6D8eO+e+Dq5Gzg=
|
||||||
|
github.com/klauspost/compress v1.12.3 h1:G5AfA94pHPysR56qqrkO2pxEexdDzrpFJ6yt/VqWxVU=
|
||||||
|
github.com/klauspost/compress v1.12.3/go.mod h1:8dP1Hq4DHOhN9w426knH3Rhby4rFm6D8eO+e+Dq5Gzg=
|
||||||
github.com/klauspost/cpuid v1.2.0/go.mod h1:Pj4uuM528wm8OyEC2QMXAi2YiTZ96dNQPGgoMS4s3ek=
|
github.com/klauspost/cpuid v1.2.0/go.mod h1:Pj4uuM528wm8OyEC2QMXAi2YiTZ96dNQPGgoMS4s3ek=
|
||||||
github.com/klauspost/pgzip v1.2.5 h1:qnWYvvKqedOF2ulHpMG72XQol4ILEJ8k2wwRl/Km8oE=
|
github.com/klauspost/pgzip v1.2.5 h1:qnWYvvKqedOF2ulHpMG72XQol4ILEJ8k2wwRl/Km8oE=
|
||||||
github.com/klauspost/pgzip v1.2.5/go.mod h1:Ch1tH69qFZu15pkjo5kYi6mth2Zzwzt50oCQKQE9RUs=
|
github.com/klauspost/pgzip v1.2.5/go.mod h1:Ch1tH69qFZu15pkjo5kYi6mth2Zzwzt50oCQKQE9RUs=
|
||||||
|
2
vendor/github.com/containers/storage/VERSION
generated
vendored
2
vendor/github.com/containers/storage/VERSION
generated
vendored
@ -1 +1 @@
|
|||||||
1.32.0
|
1.32.1
|
||||||
|
2
vendor/github.com/containers/storage/containers.go
generated
vendored
2
vendor/github.com/containers/storage/containers.go
generated
vendored
@ -626,5 +626,5 @@ func (r *containerStore) ReloadIfChanged() error {
|
|||||||
if err == nil && modified {
|
if err == nil && modified {
|
||||||
return r.Load()
|
return r.Load()
|
||||||
}
|
}
|
||||||
return nil
|
return err
|
||||||
}
|
}
|
||||||
|
2
vendor/github.com/containers/storage/go.mod
generated
vendored
2
vendor/github.com/containers/storage/go.mod
generated
vendored
@ -10,7 +10,7 @@ require (
|
|||||||
github.com/google/go-intervals v0.0.2
|
github.com/google/go-intervals v0.0.2
|
||||||
github.com/hashicorp/go-multierror v1.1.1
|
github.com/hashicorp/go-multierror v1.1.1
|
||||||
github.com/json-iterator/go v1.1.11
|
github.com/json-iterator/go v1.1.11
|
||||||
github.com/klauspost/compress v1.12.2
|
github.com/klauspost/compress v1.12.3
|
||||||
github.com/klauspost/pgzip v1.2.5
|
github.com/klauspost/pgzip v1.2.5
|
||||||
github.com/mattn/go-shellwords v1.0.11
|
github.com/mattn/go-shellwords v1.0.11
|
||||||
github.com/mistifyio/go-zfs v2.1.2-0.20190413222219-f784269be439+incompatible
|
github.com/mistifyio/go-zfs v2.1.2-0.20190413222219-f784269be439+incompatible
|
||||||
|
4
vendor/github.com/containers/storage/go.sum
generated
vendored
4
vendor/github.com/containers/storage/go.sum
generated
vendored
@ -383,8 +383,8 @@ github.com/kisielk/errcheck v1.5.0/go.mod h1:pFxgyoBC7bSaBwPgfKdkLd5X25qrDl4LWUI
|
|||||||
github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck=
|
github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck=
|
||||||
github.com/klauspost/compress v1.11.3/go.mod h1:aoV0uJVorq1K+umq18yTdKaF57EivdYsUV+/s2qKfXs=
|
github.com/klauspost/compress v1.11.3/go.mod h1:aoV0uJVorq1K+umq18yTdKaF57EivdYsUV+/s2qKfXs=
|
||||||
github.com/klauspost/compress v1.11.13/go.mod h1:aoV0uJVorq1K+umq18yTdKaF57EivdYsUV+/s2qKfXs=
|
github.com/klauspost/compress v1.11.13/go.mod h1:aoV0uJVorq1K+umq18yTdKaF57EivdYsUV+/s2qKfXs=
|
||||||
github.com/klauspost/compress v1.12.2 h1:2KCfW3I9M7nSc5wOqXAlW2v2U6v+w6cbjvbfp+OykW8=
|
github.com/klauspost/compress v1.12.3 h1:G5AfA94pHPysR56qqrkO2pxEexdDzrpFJ6yt/VqWxVU=
|
||||||
github.com/klauspost/compress v1.12.2/go.mod h1:8dP1Hq4DHOhN9w426knH3Rhby4rFm6D8eO+e+Dq5Gzg=
|
github.com/klauspost/compress v1.12.3/go.mod h1:8dP1Hq4DHOhN9w426knH3Rhby4rFm6D8eO+e+Dq5Gzg=
|
||||||
github.com/klauspost/pgzip v1.2.5 h1:qnWYvvKqedOF2ulHpMG72XQol4ILEJ8k2wwRl/Km8oE=
|
github.com/klauspost/pgzip v1.2.5 h1:qnWYvvKqedOF2ulHpMG72XQol4ILEJ8k2wwRl/Km8oE=
|
||||||
github.com/klauspost/pgzip v1.2.5/go.mod h1:Ch1tH69qFZu15pkjo5kYi6mth2Zzwzt50oCQKQE9RUs=
|
github.com/klauspost/pgzip v1.2.5/go.mod h1:Ch1tH69qFZu15pkjo5kYi6mth2Zzwzt50oCQKQE9RUs=
|
||||||
github.com/konsorten/go-windows-terminal-sequences v1.0.1/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ=
|
github.com/konsorten/go-windows-terminal-sequences v1.0.1/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ=
|
||||||
|
2
vendor/github.com/containers/storage/images.go
generated
vendored
2
vendor/github.com/containers/storage/images.go
generated
vendored
@ -810,5 +810,5 @@ func (r *imageStore) ReloadIfChanged() error {
|
|||||||
if err == nil && modified {
|
if err == nil && modified {
|
||||||
return r.Load()
|
return r.Load()
|
||||||
}
|
}
|
||||||
return nil
|
return err
|
||||||
}
|
}
|
||||||
|
11
vendor/github.com/containers/storage/layers.go
generated
vendored
11
vendor/github.com/containers/storage/layers.go
generated
vendored
@ -1156,7 +1156,10 @@ func (r *layerStore) deleteInternal(id string) error {
|
|||||||
}
|
}
|
||||||
id = layer.ID
|
id = layer.ID
|
||||||
err := r.driver.Remove(id)
|
err := r.driver.Remove(id)
|
||||||
if err == nil {
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
os.Remove(r.tspath(id))
|
os.Remove(r.tspath(id))
|
||||||
os.RemoveAll(r.datadir(id))
|
os.RemoveAll(r.datadir(id))
|
||||||
delete(r.byid, id)
|
delete(r.byid, id)
|
||||||
@ -1196,8 +1199,8 @@ func (r *layerStore) deleteInternal(id string) error {
|
|||||||
label.ReleaseLabel(mountLabel)
|
label.ReleaseLabel(mountLabel)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
return err
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (r *layerStore) deleteInDigestMap(id string) {
|
func (r *layerStore) deleteInDigestMap(id string) {
|
||||||
@ -1777,7 +1780,7 @@ func (r *layerStore) ReloadIfChanged() error {
|
|||||||
if err == nil && modified {
|
if err == nil && modified {
|
||||||
return r.Load()
|
return r.Load()
|
||||||
}
|
}
|
||||||
return nil
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
func closeAll(closes ...func() error) (rErr error) {
|
func closeAll(closes ...func() error) (rErr error) {
|
||||||
|
34
vendor/github.com/containers/storage/store.go
generated
vendored
34
vendor/github.com/containers/storage/store.go
generated
vendored
@ -788,6 +788,15 @@ func (s *store) load() error {
|
|||||||
}
|
}
|
||||||
s.containerStore = rcs
|
s.containerStore = rcs
|
||||||
|
|
||||||
|
for _, store := range driver.AdditionalImageStores() {
|
||||||
|
gipath := filepath.Join(store, driverPrefix+"images")
|
||||||
|
ris, err := newROImageStore(gipath)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
s.roImageStores = append(s.roImageStores, ris)
|
||||||
|
}
|
||||||
|
|
||||||
s.digestLockRoot = filepath.Join(s.runRoot, driverPrefix+"locks")
|
s.digestLockRoot = filepath.Join(s.runRoot, driverPrefix+"locks")
|
||||||
if err := os.MkdirAll(s.digestLockRoot, 0700); err != nil {
|
if err := os.MkdirAll(s.digestLockRoot, 0700); err != nil {
|
||||||
return err
|
return err
|
||||||
@ -910,22 +919,10 @@ func (s *store) ImageStore() (ImageStore, error) {
|
|||||||
// Store. Accessing these stores directly will bypass locking and
|
// Store. Accessing these stores directly will bypass locking and
|
||||||
// synchronization, so it is not a part of the exported Store interface.
|
// synchronization, so it is not a part of the exported Store interface.
|
||||||
func (s *store) ROImageStores() ([]ROImageStore, error) {
|
func (s *store) ROImageStores() ([]ROImageStore, error) {
|
||||||
if len(s.roImageStores) != 0 {
|
if s.imageStore == nil {
|
||||||
return s.roImageStores, nil
|
return nil, ErrLoadError
|
||||||
}
|
|
||||||
driver, err := s.getGraphDriver()
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
driverPrefix := s.graphDriverName + "-"
|
|
||||||
for _, store := range driver.AdditionalImageStores() {
|
|
||||||
gipath := filepath.Join(store, driverPrefix+"images")
|
|
||||||
ris, err := newROImageStore(gipath)
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
s.roImageStores = append(s.roImageStores, ris)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return s.roImageStores, nil
|
return s.roImageStores, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2655,8 +2652,13 @@ func (s *store) mount(id string, options drivers.MountOpts) (string, error) {
|
|||||||
return "", err
|
return "", err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
modified, err := s.graphLock.Modified()
|
||||||
|
if err != nil {
|
||||||
|
return "", err
|
||||||
|
}
|
||||||
|
|
||||||
/* We need to make sure the home mount is present when the Mount is done. */
|
/* We need to make sure the home mount is present when the Mount is done. */
|
||||||
if s.graphLock.TouchedSince(s.lastLoaded) {
|
if modified {
|
||||||
s.graphDriver = nil
|
s.graphDriver = nil
|
||||||
s.layerStore = nil
|
s.layerStore = nil
|
||||||
s.graphDriver, err = s.getGraphDriver()
|
s.graphDriver, err = s.getGraphDriver()
|
||||||
|
2
vendor/github.com/klauspost/compress/flate/deflate.go
generated
vendored
2
vendor/github.com/klauspost/compress/flate/deflate.go
generated
vendored
@ -644,7 +644,7 @@ func (d *compressor) init(w io.Writer, level int) (err error) {
|
|||||||
d.fill = (*compressor).fillBlock
|
d.fill = (*compressor).fillBlock
|
||||||
d.step = (*compressor).store
|
d.step = (*compressor).store
|
||||||
case level == ConstantCompression:
|
case level == ConstantCompression:
|
||||||
d.w.logNewTablePenalty = 8
|
d.w.logNewTablePenalty = 10
|
||||||
d.window = make([]byte, 32<<10)
|
d.window = make([]byte, 32<<10)
|
||||||
d.fill = (*compressor).fillBlock
|
d.fill = (*compressor).fillBlock
|
||||||
d.step = (*compressor).storeHuff
|
d.step = (*compressor).storeHuff
|
||||||
|
2
vendor/github.com/klauspost/compress/flate/fast_encoder.go
generated
vendored
2
vendor/github.com/klauspost/compress/flate/fast_encoder.go
generated
vendored
@ -45,7 +45,7 @@ const (
|
|||||||
|
|
||||||
bTableBits = 17 // Bits used in the big tables
|
bTableBits = 17 // Bits used in the big tables
|
||||||
bTableSize = 1 << bTableBits // Size of the table
|
bTableSize = 1 << bTableBits // Size of the table
|
||||||
allocHistory = maxStoreBlockSize * 10 // Size to preallocate for history.
|
allocHistory = maxStoreBlockSize * 5 // Size to preallocate for history.
|
||||||
bufferReset = (1 << 31) - allocHistory - maxStoreBlockSize - 1 // Reset the buffer offset when reaching this.
|
bufferReset = (1 << 31) - allocHistory - maxStoreBlockSize - 1 // Reset the buffer offset when reaching this.
|
||||||
)
|
)
|
||||||
|
|
||||||
|
224
vendor/github.com/klauspost/compress/flate/huffman_bit_writer.go
generated
vendored
224
vendor/github.com/klauspost/compress/flate/huffman_bit_writer.go
generated
vendored
@ -6,6 +6,7 @@ package flate
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"encoding/binary"
|
"encoding/binary"
|
||||||
|
"fmt"
|
||||||
"io"
|
"io"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -27,7 +28,7 @@ const (
|
|||||||
// after which bytes are flushed to the writer.
|
// after which bytes are flushed to the writer.
|
||||||
// Should preferably be a multiple of 6, since
|
// Should preferably be a multiple of 6, since
|
||||||
// we accumulate 6 bytes between writes to the buffer.
|
// we accumulate 6 bytes between writes to the buffer.
|
||||||
bufferFlushSize = 240
|
bufferFlushSize = 246
|
||||||
|
|
||||||
// bufferSize is the actual output byte buffer size.
|
// bufferSize is the actual output byte buffer size.
|
||||||
// It must have additional headroom for a flush
|
// It must have additional headroom for a flush
|
||||||
@ -59,7 +60,10 @@ var offsetExtraBits = [64]int8{
|
|||||||
14, 14, 15, 15, 16, 16, 17, 17, 18, 18, 19, 19, 20, 20,
|
14, 14, 15, 15, 16, 16, 17, 17, 18, 18, 19, 19, 20, 20,
|
||||||
}
|
}
|
||||||
|
|
||||||
var offsetBase = [64]uint32{
|
var offsetCombined = [32]uint32{}
|
||||||
|
|
||||||
|
func init() {
|
||||||
|
var offsetBase = [64]uint32{
|
||||||
/* normal deflate */
|
/* normal deflate */
|
||||||
0x000000, 0x000001, 0x000002, 0x000003, 0x000004,
|
0x000000, 0x000001, 0x000002, 0x000003, 0x000004,
|
||||||
0x000006, 0x000008, 0x00000c, 0x000010, 0x000018,
|
0x000006, 0x000008, 0x00000c, 0x000010, 0x000018,
|
||||||
@ -72,6 +76,15 @@ var offsetBase = [64]uint32{
|
|||||||
0x008000, 0x00c000, 0x010000, 0x018000, 0x020000,
|
0x008000, 0x00c000, 0x010000, 0x018000, 0x020000,
|
||||||
0x030000, 0x040000, 0x060000, 0x080000, 0x0c0000,
|
0x030000, 0x040000, 0x060000, 0x080000, 0x0c0000,
|
||||||
0x100000, 0x180000, 0x200000, 0x300000,
|
0x100000, 0x180000, 0x200000, 0x300000,
|
||||||
|
}
|
||||||
|
|
||||||
|
for i := range offsetCombined[:] {
|
||||||
|
// Don't use extended window values...
|
||||||
|
if offsetBase[i] > 0x006000 {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
offsetCombined[i] = uint32(offsetExtraBits[i])<<16 | (offsetBase[i])
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// The odd order in which the codegen code sizes are written.
|
// The odd order in which the codegen code sizes are written.
|
||||||
@ -88,15 +101,16 @@ type huffmanBitWriter struct {
|
|||||||
bits uint64
|
bits uint64
|
||||||
nbits uint16
|
nbits uint16
|
||||||
nbytes uint8
|
nbytes uint8
|
||||||
|
lastHuffMan bool
|
||||||
literalEncoding *huffmanEncoder
|
literalEncoding *huffmanEncoder
|
||||||
|
tmpLitEncoding *huffmanEncoder
|
||||||
offsetEncoding *huffmanEncoder
|
offsetEncoding *huffmanEncoder
|
||||||
codegenEncoding *huffmanEncoder
|
codegenEncoding *huffmanEncoder
|
||||||
err error
|
err error
|
||||||
lastHeader int
|
lastHeader int
|
||||||
// Set between 0 (reused block can be up to 2x the size)
|
// Set between 0 (reused block can be up to 2x the size)
|
||||||
logNewTablePenalty uint
|
logNewTablePenalty uint
|
||||||
lastHuffMan bool
|
bytes [256 + 8]byte
|
||||||
bytes [256]byte
|
|
||||||
literalFreq [lengthCodesStart + 32]uint16
|
literalFreq [lengthCodesStart + 32]uint16
|
||||||
offsetFreq [32]uint16
|
offsetFreq [32]uint16
|
||||||
codegenFreq [codegenCodeCount]uint16
|
codegenFreq [codegenCodeCount]uint16
|
||||||
@ -128,6 +142,7 @@ func newHuffmanBitWriter(w io.Writer) *huffmanBitWriter {
|
|||||||
return &huffmanBitWriter{
|
return &huffmanBitWriter{
|
||||||
writer: w,
|
writer: w,
|
||||||
literalEncoding: newHuffmanEncoder(literalCount),
|
literalEncoding: newHuffmanEncoder(literalCount),
|
||||||
|
tmpLitEncoding: newHuffmanEncoder(literalCount),
|
||||||
codegenEncoding: newHuffmanEncoder(codegenCodeCount),
|
codegenEncoding: newHuffmanEncoder(codegenCodeCount),
|
||||||
offsetEncoding: newHuffmanEncoder(offsetCodeCount),
|
offsetEncoding: newHuffmanEncoder(offsetCodeCount),
|
||||||
}
|
}
|
||||||
@ -745,9 +760,31 @@ func (w *huffmanBitWriter) writeTokens(tokens []token, leCodes, oeCodes []hcode)
|
|||||||
offs := oeCodes[:32]
|
offs := oeCodes[:32]
|
||||||
lengths := leCodes[lengthCodesStart:]
|
lengths := leCodes[lengthCodesStart:]
|
||||||
lengths = lengths[:32]
|
lengths = lengths[:32]
|
||||||
|
|
||||||
|
// Go 1.16 LOVES having these on stack.
|
||||||
|
bits, nbits, nbytes := w.bits, w.nbits, w.nbytes
|
||||||
|
|
||||||
for _, t := range tokens {
|
for _, t := range tokens {
|
||||||
if t < matchType {
|
if t < matchType {
|
||||||
w.writeCode(lits[t.literal()])
|
//w.writeCode(lits[t.literal()])
|
||||||
|
c := lits[t.literal()]
|
||||||
|
bits |= uint64(c.code) << nbits
|
||||||
|
nbits += c.len
|
||||||
|
if nbits >= 48 {
|
||||||
|
binary.LittleEndian.PutUint64(w.bytes[nbytes:], bits)
|
||||||
|
//*(*uint64)(unsafe.Pointer(&w.bytes[nbytes])) = bits
|
||||||
|
bits >>= 48
|
||||||
|
nbits -= 48
|
||||||
|
nbytes += 6
|
||||||
|
if nbytes >= bufferFlushSize {
|
||||||
|
if w.err != nil {
|
||||||
|
nbytes = 0
|
||||||
|
return
|
||||||
|
}
|
||||||
|
_, w.err = w.writer.Write(w.bytes[:nbytes])
|
||||||
|
nbytes = 0
|
||||||
|
}
|
||||||
|
}
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -759,38 +796,99 @@ func (w *huffmanBitWriter) writeTokens(tokens []token, leCodes, oeCodes []hcode)
|
|||||||
} else {
|
} else {
|
||||||
// inlined
|
// inlined
|
||||||
c := lengths[lengthCode&31]
|
c := lengths[lengthCode&31]
|
||||||
w.bits |= uint64(c.code) << w.nbits
|
bits |= uint64(c.code) << nbits
|
||||||
w.nbits += c.len
|
nbits += c.len
|
||||||
if w.nbits >= 48 {
|
if nbits >= 48 {
|
||||||
w.writeOutBits()
|
binary.LittleEndian.PutUint64(w.bytes[nbytes:], bits)
|
||||||
|
//*(*uint64)(unsafe.Pointer(&w.bytes[nbytes])) = bits
|
||||||
|
bits >>= 48
|
||||||
|
nbits -= 48
|
||||||
|
nbytes += 6
|
||||||
|
if nbytes >= bufferFlushSize {
|
||||||
|
if w.err != nil {
|
||||||
|
nbytes = 0
|
||||||
|
return
|
||||||
|
}
|
||||||
|
_, w.err = w.writer.Write(w.bytes[:nbytes])
|
||||||
|
nbytes = 0
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
extraLengthBits := uint16(lengthExtraBits[lengthCode&31])
|
extraLengthBits := uint16(lengthExtraBits[lengthCode&31])
|
||||||
if extraLengthBits > 0 {
|
if extraLengthBits > 0 {
|
||||||
|
//w.writeBits(extraLength, extraLengthBits)
|
||||||
extraLength := int32(length - lengthBase[lengthCode&31])
|
extraLength := int32(length - lengthBase[lengthCode&31])
|
||||||
w.writeBits(extraLength, extraLengthBits)
|
bits |= uint64(extraLength) << nbits
|
||||||
|
nbits += extraLengthBits
|
||||||
|
if nbits >= 48 {
|
||||||
|
binary.LittleEndian.PutUint64(w.bytes[nbytes:], bits)
|
||||||
|
//*(*uint64)(unsafe.Pointer(&w.bytes[nbytes])) = bits
|
||||||
|
bits >>= 48
|
||||||
|
nbits -= 48
|
||||||
|
nbytes += 6
|
||||||
|
if nbytes >= bufferFlushSize {
|
||||||
|
if w.err != nil {
|
||||||
|
nbytes = 0
|
||||||
|
return
|
||||||
|
}
|
||||||
|
_, w.err = w.writer.Write(w.bytes[:nbytes])
|
||||||
|
nbytes = 0
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
// Write the offset
|
// Write the offset
|
||||||
offset := t.offset()
|
offset := t.offset()
|
||||||
offsetCode := offsetCode(offset)
|
offsetCode := offset >> 16
|
||||||
|
offset &= matchOffsetOnlyMask
|
||||||
if false {
|
if false {
|
||||||
w.writeCode(offs[offsetCode&31])
|
w.writeCode(offs[offsetCode&31])
|
||||||
} else {
|
} else {
|
||||||
// inlined
|
// inlined
|
||||||
c := offs[offsetCode&31]
|
c := offs[offsetCode]
|
||||||
w.bits |= uint64(c.code) << w.nbits
|
bits |= uint64(c.code) << nbits
|
||||||
w.nbits += c.len
|
nbits += c.len
|
||||||
if w.nbits >= 48 {
|
if nbits >= 48 {
|
||||||
w.writeOutBits()
|
binary.LittleEndian.PutUint64(w.bytes[nbytes:], bits)
|
||||||
|
//*(*uint64)(unsafe.Pointer(&w.bytes[nbytes])) = bits
|
||||||
|
bits >>= 48
|
||||||
|
nbits -= 48
|
||||||
|
nbytes += 6
|
||||||
|
if nbytes >= bufferFlushSize {
|
||||||
|
if w.err != nil {
|
||||||
|
nbytes = 0
|
||||||
|
return
|
||||||
|
}
|
||||||
|
_, w.err = w.writer.Write(w.bytes[:nbytes])
|
||||||
|
nbytes = 0
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
extraOffsetBits := uint16(offsetExtraBits[offsetCode&63])
|
}
|
||||||
if extraOffsetBits > 0 {
|
offsetComb := offsetCombined[offsetCode]
|
||||||
extraOffset := int32(offset - offsetBase[offsetCode&63])
|
if offsetComb > 1<<16 {
|
||||||
w.writeBits(extraOffset, extraOffsetBits)
|
//w.writeBits(extraOffset, extraOffsetBits)
|
||||||
|
bits |= uint64(offset&matchOffsetOnlyMask-(offsetComb&0xffff)) << nbits
|
||||||
|
nbits += uint16(offsetComb >> 16)
|
||||||
|
if nbits >= 48 {
|
||||||
|
binary.LittleEndian.PutUint64(w.bytes[nbytes:], bits)
|
||||||
|
//*(*uint64)(unsafe.Pointer(&w.bytes[nbytes])) = bits
|
||||||
|
bits >>= 48
|
||||||
|
nbits -= 48
|
||||||
|
nbytes += 6
|
||||||
|
if nbytes >= bufferFlushSize {
|
||||||
|
if w.err != nil {
|
||||||
|
nbytes = 0
|
||||||
|
return
|
||||||
|
}
|
||||||
|
_, w.err = w.writer.Write(w.bytes[:nbytes])
|
||||||
|
nbytes = 0
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// Restore...
|
||||||
|
w.bits, w.nbits, w.nbytes = bits, nbits, nbytes
|
||||||
|
|
||||||
if deferEOB {
|
if deferEOB {
|
||||||
w.writeCode(leCodes[endBlockMarker])
|
w.writeCode(leCodes[endBlockMarker])
|
||||||
}
|
}
|
||||||
@ -825,13 +923,28 @@ func (w *huffmanBitWriter) writeBlockHuff(eof bool, input []byte, sync bool) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Fill is rarely better...
|
||||||
|
const fill = false
|
||||||
|
const numLiterals = endBlockMarker + 1
|
||||||
|
const numOffsets = 1
|
||||||
|
|
||||||
// Add everything as literals
|
// Add everything as literals
|
||||||
// We have to estimate the header size.
|
// We have to estimate the header size.
|
||||||
// Assume header is around 70 bytes:
|
// Assume header is around 70 bytes:
|
||||||
// https://stackoverflow.com/a/25454430
|
// https://stackoverflow.com/a/25454430
|
||||||
const guessHeaderSizeBits = 70 * 8
|
const guessHeaderSizeBits = 70 * 8
|
||||||
estBits := histogramSize(input, w.literalFreq[:], !eof && !sync)
|
histogram(input, w.literalFreq[:numLiterals], fill)
|
||||||
estBits += w.lastHeader + len(input)/32
|
w.literalFreq[endBlockMarker] = 1
|
||||||
|
w.tmpLitEncoding.generate(w.literalFreq[:numLiterals], 15)
|
||||||
|
if fill {
|
||||||
|
// Clear fill...
|
||||||
|
for i := range w.literalFreq[:numLiterals] {
|
||||||
|
w.literalFreq[i] = 0
|
||||||
|
}
|
||||||
|
histogram(input, w.literalFreq[:numLiterals], false)
|
||||||
|
}
|
||||||
|
estBits := w.tmpLitEncoding.canReuseBits(w.literalFreq[:numLiterals])
|
||||||
|
estBits += w.lastHeader
|
||||||
if w.lastHeader == 0 {
|
if w.lastHeader == 0 {
|
||||||
estBits += guessHeaderSizeBits
|
estBits += guessHeaderSizeBits
|
||||||
}
|
}
|
||||||
@ -839,33 +952,31 @@ func (w *huffmanBitWriter) writeBlockHuff(eof bool, input []byte, sync bool) {
|
|||||||
|
|
||||||
// Store bytes, if we don't get a reasonable improvement.
|
// Store bytes, if we don't get a reasonable improvement.
|
||||||
ssize, storable := w.storedSize(input)
|
ssize, storable := w.storedSize(input)
|
||||||
if storable && ssize < estBits {
|
if storable && ssize <= estBits {
|
||||||
w.writeStoredHeader(len(input), eof)
|
w.writeStoredHeader(len(input), eof)
|
||||||
w.writeBytes(input)
|
w.writeBytes(input)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
reuseSize := 0
|
|
||||||
if w.lastHeader > 0 {
|
if w.lastHeader > 0 {
|
||||||
reuseSize = w.literalEncoding.bitLength(w.literalFreq[:256])
|
reuseSize := w.literalEncoding.canReuseBits(w.literalFreq[:256])
|
||||||
|
|
||||||
if estBits < reuseSize {
|
if estBits < reuseSize {
|
||||||
|
if debugDeflate {
|
||||||
|
//fmt.Println("not reusing, reuse:", reuseSize/8, "> new:", estBits/8, "- header est:", w.lastHeader/8)
|
||||||
|
}
|
||||||
// We owe an EOB
|
// We owe an EOB
|
||||||
w.writeCode(w.literalEncoding.codes[endBlockMarker])
|
w.writeCode(w.literalEncoding.codes[endBlockMarker])
|
||||||
w.lastHeader = 0
|
w.lastHeader = 0
|
||||||
|
} else if debugDeflate {
|
||||||
|
fmt.Println("reusing, reuse:", reuseSize/8, "> new:", estBits/8, "- header est:", w.lastHeader/8)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const numLiterals = endBlockMarker + 1
|
count := 0
|
||||||
const numOffsets = 1
|
|
||||||
if w.lastHeader == 0 {
|
if w.lastHeader == 0 {
|
||||||
if !eof && !sync {
|
// Use the temp encoding, so swap.
|
||||||
// Generate a slightly suboptimal tree that can be used for all.
|
w.literalEncoding, w.tmpLitEncoding = w.tmpLitEncoding, w.literalEncoding
|
||||||
fillHist(w.literalFreq[:numLiterals])
|
|
||||||
}
|
|
||||||
w.literalFreq[endBlockMarker] = 1
|
|
||||||
w.literalEncoding.generate(w.literalFreq[:numLiterals], 15)
|
|
||||||
|
|
||||||
// Generate codegen and codegenFrequencies, which indicates how to encode
|
// Generate codegen and codegenFrequencies, which indicates how to encode
|
||||||
// the literalEncoding and the offsetEncoding.
|
// the literalEncoding and the offsetEncoding.
|
||||||
w.generateCodegen(numLiterals, numOffsets, w.literalEncoding, huffOffset)
|
w.generateCodegen(numLiterals, numOffsets, w.literalEncoding, huffOffset)
|
||||||
@ -876,34 +987,47 @@ func (w *huffmanBitWriter) writeBlockHuff(eof bool, input []byte, sync bool) {
|
|||||||
w.writeDynamicHeader(numLiterals, numOffsets, numCodegens, eof)
|
w.writeDynamicHeader(numLiterals, numOffsets, numCodegens, eof)
|
||||||
w.lastHuffMan = true
|
w.lastHuffMan = true
|
||||||
w.lastHeader, _ = w.headerSize()
|
w.lastHeader, _ = w.headerSize()
|
||||||
|
if debugDeflate {
|
||||||
|
count += w.lastHeader
|
||||||
|
fmt.Println("header:", count/8)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
encoding := w.literalEncoding.codes[:257]
|
encoding := w.literalEncoding.codes[:256]
|
||||||
|
// Go 1.16 LOVES having these on stack. At least 1.5x the speed.
|
||||||
|
bits, nbits, nbytes := w.bits, w.nbits, w.nbytes
|
||||||
for _, t := range input {
|
for _, t := range input {
|
||||||
// Bitwriting inlined, ~30% speedup
|
// Bitwriting inlined, ~30% speedup
|
||||||
c := encoding[t]
|
c := encoding[t]
|
||||||
w.bits |= uint64(c.code) << w.nbits
|
bits |= uint64(c.code) << nbits
|
||||||
w.nbits += c.len
|
nbits += c.len
|
||||||
if w.nbits >= 48 {
|
if debugDeflate {
|
||||||
bits := w.bits
|
count += int(c.len)
|
||||||
w.bits >>= 48
|
}
|
||||||
w.nbits -= 48
|
if nbits >= 48 {
|
||||||
n := w.nbytes
|
binary.LittleEndian.PutUint64(w.bytes[nbytes:], bits)
|
||||||
binary.LittleEndian.PutUint64(w.bytes[n:], bits)
|
//*(*uint64)(unsafe.Pointer(&w.bytes[nbytes])) = bits
|
||||||
n += 6
|
bits >>= 48
|
||||||
if n >= bufferFlushSize {
|
nbits -= 48
|
||||||
|
nbytes += 6
|
||||||
|
if nbytes >= bufferFlushSize {
|
||||||
if w.err != nil {
|
if w.err != nil {
|
||||||
n = 0
|
nbytes = 0
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
w.write(w.bytes[:n])
|
_, w.err = w.writer.Write(w.bytes[:nbytes])
|
||||||
n = 0
|
nbytes = 0
|
||||||
}
|
}
|
||||||
w.nbytes = n
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
// Restore...
|
||||||
|
w.bits, w.nbits, w.nbytes = bits, nbits, nbytes
|
||||||
|
|
||||||
|
if debugDeflate {
|
||||||
|
fmt.Println("wrote", count/8, "bytes")
|
||||||
|
}
|
||||||
if eof || sync {
|
if eof || sync {
|
||||||
w.writeCode(encoding[endBlockMarker])
|
w.writeCode(w.literalEncoding.codes[endBlockMarker])
|
||||||
w.lastHeader = 0
|
w.lastHeader = 0
|
||||||
w.lastHuffMan = false
|
w.lastHuffMan = false
|
||||||
}
|
}
|
||||||
|
54
vendor/github.com/klauspost/compress/flate/huffman_code.go
generated
vendored
54
vendor/github.com/klauspost/compress/flate/huffman_code.go
generated
vendored
@ -22,8 +22,12 @@ type hcode struct {
|
|||||||
|
|
||||||
type huffmanEncoder struct {
|
type huffmanEncoder struct {
|
||||||
codes []hcode
|
codes []hcode
|
||||||
freqcache []literalNode
|
|
||||||
bitCount [17]int32
|
bitCount [17]int32
|
||||||
|
|
||||||
|
// Allocate a reusable buffer with the longest possible frequency table.
|
||||||
|
// Possible lengths are codegenCodeCount, offsetCodeCount and literalCount.
|
||||||
|
// The largest of these is literalCount, so we allocate for that case.
|
||||||
|
freqcache [literalCount + 1]literalNode
|
||||||
}
|
}
|
||||||
|
|
||||||
type literalNode struct {
|
type literalNode struct {
|
||||||
@ -132,6 +136,21 @@ func (h *huffmanEncoder) bitLengthRaw(b []byte) int {
|
|||||||
return total
|
return total
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// canReuseBits returns the number of bits or math.MaxInt32 if the encoder cannot be reused.
|
||||||
|
func (h *huffmanEncoder) canReuseBits(freq []uint16) int {
|
||||||
|
var total int
|
||||||
|
for i, f := range freq {
|
||||||
|
if f != 0 {
|
||||||
|
code := h.codes[i]
|
||||||
|
if code.len == 0 {
|
||||||
|
return math.MaxInt32
|
||||||
|
}
|
||||||
|
total += int(f) * int(code.len)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return total
|
||||||
|
}
|
||||||
|
|
||||||
// Return the number of literals assigned to each bit size in the Huffman encoding
|
// Return the number of literals assigned to each bit size in the Huffman encoding
|
||||||
//
|
//
|
||||||
// This method is only called when list.length >= 3
|
// This method is only called when list.length >= 3
|
||||||
@ -291,12 +310,6 @@ func (h *huffmanEncoder) assignEncodingAndSize(bitCount []int32, list []literalN
|
|||||||
// freq An array of frequencies, in which frequency[i] gives the frequency of literal i.
|
// freq An array of frequencies, in which frequency[i] gives the frequency of literal i.
|
||||||
// maxBits The maximum number of bits to use for any literal.
|
// maxBits The maximum number of bits to use for any literal.
|
||||||
func (h *huffmanEncoder) generate(freq []uint16, maxBits int32) {
|
func (h *huffmanEncoder) generate(freq []uint16, maxBits int32) {
|
||||||
if h.freqcache == nil {
|
|
||||||
// Allocate a reusable buffer with the longest possible frequency table.
|
|
||||||
// Possible lengths are codegenCodeCount, offsetCodeCount and literalCount.
|
|
||||||
// The largest of these is literalCount, so we allocate for that case.
|
|
||||||
h.freqcache = make([]literalNode, literalCount+1)
|
|
||||||
}
|
|
||||||
list := h.freqcache[:len(freq)+1]
|
list := h.freqcache[:len(freq)+1]
|
||||||
// Number of non-zero literals
|
// Number of non-zero literals
|
||||||
count := 0
|
count := 0
|
||||||
@ -330,10 +343,14 @@ func (h *huffmanEncoder) generate(freq []uint16, maxBits int32) {
|
|||||||
h.assignEncodingAndSize(bitCount, list)
|
h.assignEncodingAndSize(bitCount, list)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// atLeastOne clamps the result between 1 and 15.
|
||||||
func atLeastOne(v float32) float32 {
|
func atLeastOne(v float32) float32 {
|
||||||
if v < 1 {
|
if v < 1 {
|
||||||
return 1
|
return 1
|
||||||
}
|
}
|
||||||
|
if v > 15 {
|
||||||
|
return 15
|
||||||
|
}
|
||||||
return v
|
return v
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -346,31 +363,12 @@ func fillHist(b []uint16) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// histogramSize accumulates a histogram of b in h.
|
func histogram(b []byte, h []uint16, fill bool) {
|
||||||
// An estimated size in bits is returned.
|
|
||||||
// len(h) must be >= 256, and h's elements must be all zeroes.
|
|
||||||
func histogramSize(b []byte, h []uint16, fill bool) (bits int) {
|
|
||||||
h = h[:256]
|
h = h[:256]
|
||||||
for _, t := range b {
|
for _, t := range b {
|
||||||
h[t]++
|
h[t]++
|
||||||
}
|
}
|
||||||
total := len(b)
|
|
||||||
if fill {
|
if fill {
|
||||||
for _, v := range h {
|
fillHist(h)
|
||||||
if v == 0 {
|
|
||||||
total++
|
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
invTotal := 1.0 / float32(total)
|
|
||||||
shannon := float32(0.0)
|
|
||||||
for _, v := range h {
|
|
||||||
if v > 0 {
|
|
||||||
n := float32(v)
|
|
||||||
shannon += atLeastOne(-mFastLog2(n*invTotal)) * n
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return int(shannon + 0.99)
|
|
||||||
}
|
}
|
||||||
|
31
vendor/github.com/klauspost/compress/flate/token.go
generated
vendored
31
vendor/github.com/klauspost/compress/flate/token.go
generated
vendored
@ -13,14 +13,17 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
|
// From top
|
||||||
// 2 bits: type 0 = literal 1=EOF 2=Match 3=Unused
|
// 2 bits: type 0 = literal 1=EOF 2=Match 3=Unused
|
||||||
// 8 bits: xlength = length - MIN_MATCH_LENGTH
|
// 8 bits: xlength = length - MIN_MATCH_LENGTH
|
||||||
// 22 bits xoffset = offset - MIN_OFFSET_SIZE, or literal
|
// 5 bits offsetcode
|
||||||
|
// 16 bits xoffset = offset - MIN_OFFSET_SIZE, or literal
|
||||||
lengthShift = 22
|
lengthShift = 22
|
||||||
offsetMask = 1<<lengthShift - 1
|
offsetMask = 1<<lengthShift - 1
|
||||||
typeMask = 3 << 30
|
typeMask = 3 << 30
|
||||||
literalType = 0 << 30
|
literalType = 0 << 30
|
||||||
matchType = 1 << 30
|
matchType = 1 << 30
|
||||||
|
matchOffsetOnlyMask = 0xffff
|
||||||
)
|
)
|
||||||
|
|
||||||
// The length code for length X (MIN_MATCH_LENGTH <= X <= MAX_MATCH_LENGTH)
|
// The length code for length X (MIN_MATCH_LENGTH <= X <= MAX_MATCH_LENGTH)
|
||||||
@ -187,7 +190,7 @@ func (t *tokens) indexTokens(in []token) {
|
|||||||
t.AddLiteral(tok.literal())
|
t.AddLiteral(tok.literal())
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
t.AddMatch(uint32(tok.length()), tok.offset())
|
t.AddMatch(uint32(tok.length()), tok.offset()&matchOffsetOnlyMask)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -232,7 +235,7 @@ func (t *tokens) EstimatedBits() int {
|
|||||||
for _, v := range t.litHist[:] {
|
for _, v := range t.litHist[:] {
|
||||||
if v > 0 {
|
if v > 0 {
|
||||||
n := float32(v)
|
n := float32(v)
|
||||||
shannon += -mFastLog2(n*invTotal) * n
|
shannon += atLeastOne(-mFastLog2(n*invTotal)) * n
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// Just add 15 for EOB
|
// Just add 15 for EOB
|
||||||
@ -240,7 +243,7 @@ func (t *tokens) EstimatedBits() int {
|
|||||||
for i, v := range t.extraHist[1 : literalCount-256] {
|
for i, v := range t.extraHist[1 : literalCount-256] {
|
||||||
if v > 0 {
|
if v > 0 {
|
||||||
n := float32(v)
|
n := float32(v)
|
||||||
shannon += -mFastLog2(n*invTotal) * n
|
shannon += atLeastOne(-mFastLog2(n*invTotal)) * n
|
||||||
bits += int(lengthExtraBits[i&31]) * int(v)
|
bits += int(lengthExtraBits[i&31]) * int(v)
|
||||||
nMatches += int(v)
|
nMatches += int(v)
|
||||||
}
|
}
|
||||||
@ -251,7 +254,7 @@ func (t *tokens) EstimatedBits() int {
|
|||||||
for i, v := range t.offHist[:offsetCodeCount] {
|
for i, v := range t.offHist[:offsetCodeCount] {
|
||||||
if v > 0 {
|
if v > 0 {
|
||||||
n := float32(v)
|
n := float32(v)
|
||||||
shannon += -mFastLog2(n*invTotal) * n
|
shannon += atLeastOne(-mFastLog2(n*invTotal)) * n
|
||||||
bits += int(offsetExtraBits[i&31]) * int(v)
|
bits += int(offsetExtraBits[i&31]) * int(v)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -270,11 +273,13 @@ func (t *tokens) AddMatch(xlength uint32, xoffset uint32) {
|
|||||||
panic(fmt.Errorf("invalid offset: %v", xoffset))
|
panic(fmt.Errorf("invalid offset: %v", xoffset))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
oCode := offsetCode(xoffset)
|
||||||
|
xoffset |= oCode << 16
|
||||||
t.nLits++
|
t.nLits++
|
||||||
lengthCode := lengthCodes1[uint8(xlength)] & 31
|
|
||||||
|
t.extraHist[lengthCodes1[uint8(xlength)]]++
|
||||||
|
t.offHist[oCode]++
|
||||||
t.tokens[t.n] = token(matchType | xlength<<lengthShift | xoffset)
|
t.tokens[t.n] = token(matchType | xlength<<lengthShift | xoffset)
|
||||||
t.extraHist[lengthCode]++
|
|
||||||
t.offHist[offsetCode(xoffset)&31]++
|
|
||||||
t.n++
|
t.n++
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -286,7 +291,8 @@ func (t *tokens) AddMatchLong(xlength int32, xoffset uint32) {
|
|||||||
panic(fmt.Errorf("invalid offset: %v", xoffset))
|
panic(fmt.Errorf("invalid offset: %v", xoffset))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
oc := offsetCode(xoffset) & 31
|
oc := offsetCode(xoffset)
|
||||||
|
xoffset |= oc << 16
|
||||||
for xlength > 0 {
|
for xlength > 0 {
|
||||||
xl := xlength
|
xl := xlength
|
||||||
if xl > 258 {
|
if xl > 258 {
|
||||||
@ -294,12 +300,11 @@ func (t *tokens) AddMatchLong(xlength int32, xoffset uint32) {
|
|||||||
xl = 258 - baseMatchLength
|
xl = 258 - baseMatchLength
|
||||||
}
|
}
|
||||||
xlength -= xl
|
xlength -= xl
|
||||||
xl -= 3
|
xl -= baseMatchLength
|
||||||
t.nLits++
|
t.nLits++
|
||||||
lengthCode := lengthCodes1[uint8(xl)] & 31
|
t.extraHist[lengthCodes1[uint8(xl)]]++
|
||||||
t.tokens[t.n] = token(matchType | uint32(xl)<<lengthShift | xoffset)
|
|
||||||
t.extraHist[lengthCode]++
|
|
||||||
t.offHist[oc]++
|
t.offHist[oc]++
|
||||||
|
t.tokens[t.n] = token(matchType | uint32(xl)<<lengthShift | xoffset)
|
||||||
t.n++
|
t.n++
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
22
vendor/github.com/klauspost/compress/zstd/README.md
generated
vendored
22
vendor/github.com/klauspost/compress/zstd/README.md
generated
vendored
@ -16,8 +16,7 @@ Currently the package is heavily optimized for 64 bit processors and will be sig
|
|||||||
|
|
||||||
Install using `go get -u github.com/klauspost/compress`. The package is located in `github.com/klauspost/compress/zstd`.
|
Install using `go get -u github.com/klauspost/compress`. The package is located in `github.com/klauspost/compress/zstd`.
|
||||||
|
|
||||||
Godoc Documentation: https://godoc.org/github.com/klauspost/compress/zstd
|
[](https://pkg.go.dev/github.com/klauspost/compress/zstd)
|
||||||
|
|
||||||
|
|
||||||
## Compressor
|
## Compressor
|
||||||
|
|
||||||
@ -405,13 +404,28 @@ BenchmarkDecoder_DecodeAllParallelCgo/comp-data.bin.zst-16 749938
|
|||||||
|
|
||||||
This reflects the performance around May 2020, but this may be out of date.
|
This reflects the performance around May 2020, but this may be out of date.
|
||||||
|
|
||||||
|
## Zstd inside ZIP files
|
||||||
|
|
||||||
|
It is possible to use zstandard to compress individual files inside zip archives.
|
||||||
|
While this isn't widely supported it can be useful for internal files.
|
||||||
|
|
||||||
|
To support the compression and decompression of these files you must register a compressor and decompressor.
|
||||||
|
|
||||||
|
It is highly recommended registering the (de)compressors on individual zip Reader/Writer and NOT
|
||||||
|
use the global registration functions. The main reason for this is that 2 registrations from
|
||||||
|
different packages will result in a panic.
|
||||||
|
|
||||||
|
It is a good idea to only have a single compressor and decompressor, since they can be used for multiple zip
|
||||||
|
files concurrently, and using a single instance will allow reusing some resources.
|
||||||
|
|
||||||
|
See [this example](https://pkg.go.dev/github.com/klauspost/compress/zstd#example-ZipCompressor) for
|
||||||
|
how to compress and decompress files inside zip archives.
|
||||||
|
|
||||||
# Contributions
|
# Contributions
|
||||||
|
|
||||||
Contributions are always welcome.
|
Contributions are always welcome.
|
||||||
For new features/fixes, remember to add tests and for performance enhancements include benchmarks.
|
For new features/fixes, remember to add tests and for performance enhancements include benchmarks.
|
||||||
|
|
||||||
For sending files for reproducing errors use a service like [goobox](https://goobox.io/#/upload) or similar to share your files.
|
|
||||||
|
|
||||||
For general feedback and experience reports, feel free to open an issue or write me on [Twitter](https://twitter.com/sh0dan).
|
For general feedback and experience reports, feel free to open an issue or write me on [Twitter](https://twitter.com/sh0dan).
|
||||||
|
|
||||||
This package includes the excellent [`github.com/cespare/xxhash`](https://github.com/cespare/xxhash) package Copyright (c) 2016 Caleb Spare.
|
This package includes the excellent [`github.com/cespare/xxhash`](https://github.com/cespare/xxhash) package Copyright (c) 2016 Caleb Spare.
|
||||||
|
11
vendor/github.com/klauspost/compress/zstd/blockdec.go
generated
vendored
11
vendor/github.com/klauspost/compress/zstd/blockdec.go
generated
vendored
@ -123,12 +123,10 @@ func newBlockDec(lowMem bool) *blockDec {
|
|||||||
// Input must be a start of a block and will be at the end of the block when returned.
|
// Input must be a start of a block and will be at the end of the block when returned.
|
||||||
func (b *blockDec) reset(br byteBuffer, windowSize uint64) error {
|
func (b *blockDec) reset(br byteBuffer, windowSize uint64) error {
|
||||||
b.WindowSize = windowSize
|
b.WindowSize = windowSize
|
||||||
tmp := br.readSmall(3)
|
tmp, err := br.readSmall(3)
|
||||||
if tmp == nil {
|
if err != nil {
|
||||||
if debug {
|
println("Reading block header:", err)
|
||||||
println("Reading block header:", io.ErrUnexpectedEOF)
|
return err
|
||||||
}
|
|
||||||
return io.ErrUnexpectedEOF
|
|
||||||
}
|
}
|
||||||
bh := uint32(tmp[0]) | (uint32(tmp[1]) << 8) | (uint32(tmp[2]) << 16)
|
bh := uint32(tmp[0]) | (uint32(tmp[1]) << 8) | (uint32(tmp[2]) << 16)
|
||||||
b.Last = bh&1 != 0
|
b.Last = bh&1 != 0
|
||||||
@ -179,7 +177,6 @@ func (b *blockDec) reset(br byteBuffer, windowSize uint64) error {
|
|||||||
if cap(b.dst) <= maxSize {
|
if cap(b.dst) <= maxSize {
|
||||||
b.dst = make([]byte, 0, maxSize+1)
|
b.dst = make([]byte, 0, maxSize+1)
|
||||||
}
|
}
|
||||||
var err error
|
|
||||||
b.data, err = br.readBig(cSize, b.dataStorage)
|
b.data, err = br.readBig(cSize, b.dataStorage)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
if debug {
|
if debug {
|
||||||
|
21
vendor/github.com/klauspost/compress/zstd/bytebuf.go
generated
vendored
21
vendor/github.com/klauspost/compress/zstd/bytebuf.go
generated
vendored
@ -12,8 +12,8 @@ import (
|
|||||||
|
|
||||||
type byteBuffer interface {
|
type byteBuffer interface {
|
||||||
// Read up to 8 bytes.
|
// Read up to 8 bytes.
|
||||||
// Returns nil if no more input is available.
|
// Returns io.ErrUnexpectedEOF if this cannot be satisfied.
|
||||||
readSmall(n int) []byte
|
readSmall(n int) ([]byte, error)
|
||||||
|
|
||||||
// Read >8 bytes.
|
// Read >8 bytes.
|
||||||
// MAY use the destination slice.
|
// MAY use the destination slice.
|
||||||
@ -29,17 +29,17 @@ type byteBuffer interface {
|
|||||||
// in-memory buffer
|
// in-memory buffer
|
||||||
type byteBuf []byte
|
type byteBuf []byte
|
||||||
|
|
||||||
func (b *byteBuf) readSmall(n int) []byte {
|
func (b *byteBuf) readSmall(n int) ([]byte, error) {
|
||||||
if debugAsserts && n > 8 {
|
if debugAsserts && n > 8 {
|
||||||
panic(fmt.Errorf("small read > 8 (%d). use readBig", n))
|
panic(fmt.Errorf("small read > 8 (%d). use readBig", n))
|
||||||
}
|
}
|
||||||
bb := *b
|
bb := *b
|
||||||
if len(bb) < n {
|
if len(bb) < n {
|
||||||
return nil
|
return nil, io.ErrUnexpectedEOF
|
||||||
}
|
}
|
||||||
r := bb[:n]
|
r := bb[:n]
|
||||||
*b = bb[n:]
|
*b = bb[n:]
|
||||||
return r
|
return r, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (b *byteBuf) readBig(n int, dst []byte) ([]byte, error) {
|
func (b *byteBuf) readBig(n int, dst []byte) ([]byte, error) {
|
||||||
@ -81,19 +81,22 @@ type readerWrapper struct {
|
|||||||
tmp [8]byte
|
tmp [8]byte
|
||||||
}
|
}
|
||||||
|
|
||||||
func (r *readerWrapper) readSmall(n int) []byte {
|
func (r *readerWrapper) readSmall(n int) ([]byte, error) {
|
||||||
if debugAsserts && n > 8 {
|
if debugAsserts && n > 8 {
|
||||||
panic(fmt.Errorf("small read > 8 (%d). use readBig", n))
|
panic(fmt.Errorf("small read > 8 (%d). use readBig", n))
|
||||||
}
|
}
|
||||||
n2, err := io.ReadFull(r.r, r.tmp[:n])
|
n2, err := io.ReadFull(r.r, r.tmp[:n])
|
||||||
// We only really care about the actual bytes read.
|
// We only really care about the actual bytes read.
|
||||||
if n2 != n {
|
if err != nil {
|
||||||
|
if err == io.EOF {
|
||||||
|
return nil, io.ErrUnexpectedEOF
|
||||||
|
}
|
||||||
if debug {
|
if debug {
|
||||||
println("readSmall: got", n2, "want", n, "err", err)
|
println("readSmall: got", n2, "want", n, "err", err)
|
||||||
}
|
}
|
||||||
return nil
|
return nil, err
|
||||||
}
|
}
|
||||||
return r.tmp[:n]
|
return r.tmp[:n], nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (r *readerWrapper) readBig(n int, dst []byte) ([]byte, error) {
|
func (r *readerWrapper) readBig(n int, dst []byte) ([]byte, error) {
|
||||||
|
46
vendor/github.com/klauspost/compress/zstd/framedec.go
generated
vendored
46
vendor/github.com/klauspost/compress/zstd/framedec.go
generated
vendored
@ -80,9 +80,14 @@ func (d *frameDec) reset(br byteBuffer) error {
|
|||||||
d.WindowSize = 0
|
d.WindowSize = 0
|
||||||
var b []byte
|
var b []byte
|
||||||
for {
|
for {
|
||||||
b = br.readSmall(4)
|
var err error
|
||||||
if b == nil {
|
b, err = br.readSmall(4)
|
||||||
|
switch err {
|
||||||
|
case io.EOF, io.ErrUnexpectedEOF:
|
||||||
return io.EOF
|
return io.EOF
|
||||||
|
default:
|
||||||
|
return err
|
||||||
|
case nil:
|
||||||
}
|
}
|
||||||
if !bytes.Equal(b[1:4], skippableFrameMagic) || b[0]&0xf0 != 0x50 {
|
if !bytes.Equal(b[1:4], skippableFrameMagic) || b[0]&0xf0 != 0x50 {
|
||||||
if debug {
|
if debug {
|
||||||
@ -92,14 +97,14 @@ func (d *frameDec) reset(br byteBuffer) error {
|
|||||||
break
|
break
|
||||||
}
|
}
|
||||||
// Read size to skip
|
// Read size to skip
|
||||||
b = br.readSmall(4)
|
b, err = br.readSmall(4)
|
||||||
if b == nil {
|
if err != nil {
|
||||||
println("Reading Frame Size EOF")
|
println("Reading Frame Size", err)
|
||||||
return io.ErrUnexpectedEOF
|
return err
|
||||||
}
|
}
|
||||||
n := uint32(b[0]) | (uint32(b[1]) << 8) | (uint32(b[2]) << 16) | (uint32(b[3]) << 24)
|
n := uint32(b[0]) | (uint32(b[1]) << 8) | (uint32(b[2]) << 16) | (uint32(b[3]) << 24)
|
||||||
println("Skipping frame with", n, "bytes.")
|
println("Skipping frame with", n, "bytes.")
|
||||||
err := br.skipN(int(n))
|
err = br.skipN(int(n))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
if debug {
|
if debug {
|
||||||
println("Reading discarded frame", err)
|
println("Reading discarded frame", err)
|
||||||
@ -147,12 +152,11 @@ func (d *frameDec) reset(br byteBuffer) error {
|
|||||||
if size == 3 {
|
if size == 3 {
|
||||||
size = 4
|
size = 4
|
||||||
}
|
}
|
||||||
b = br.readSmall(int(size))
|
|
||||||
if b == nil {
|
b, err = br.readSmall(int(size))
|
||||||
if debug {
|
if err != nil {
|
||||||
println("Reading Dictionary_ID", io.ErrUnexpectedEOF)
|
println("Reading Dictionary_ID", err)
|
||||||
}
|
return err
|
||||||
return io.ErrUnexpectedEOF
|
|
||||||
}
|
}
|
||||||
var id uint32
|
var id uint32
|
||||||
switch size {
|
switch size {
|
||||||
@ -187,10 +191,10 @@ func (d *frameDec) reset(br byteBuffer) error {
|
|||||||
}
|
}
|
||||||
d.FrameContentSize = 0
|
d.FrameContentSize = 0
|
||||||
if fcsSize > 0 {
|
if fcsSize > 0 {
|
||||||
b := br.readSmall(fcsSize)
|
b, err = br.readSmall(fcsSize)
|
||||||
if b == nil {
|
if err != nil {
|
||||||
println("Reading Frame content", io.ErrUnexpectedEOF)
|
println("Reading Frame content", err)
|
||||||
return io.ErrUnexpectedEOF
|
return err
|
||||||
}
|
}
|
||||||
switch fcsSize {
|
switch fcsSize {
|
||||||
case 1:
|
case 1:
|
||||||
@ -307,10 +311,10 @@ func (d *frameDec) checkCRC() error {
|
|||||||
tmp[3] = byte(got >> 24)
|
tmp[3] = byte(got >> 24)
|
||||||
|
|
||||||
// We can overwrite upper tmp now
|
// We can overwrite upper tmp now
|
||||||
want := d.rawInput.readSmall(4)
|
want, err := d.rawInput.readSmall(4)
|
||||||
if want == nil {
|
if err != nil {
|
||||||
println("CRC missing?")
|
println("CRC missing?", err)
|
||||||
return io.ErrUnexpectedEOF
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
if !bytes.Equal(tmp[:], want) {
|
if !bytes.Equal(tmp[:], want) {
|
||||||
|
5
vendor/github.com/klauspost/compress/zstd/zip.go
generated
vendored
5
vendor/github.com/klauspost/compress/zstd/zip.go
generated
vendored
@ -13,8 +13,9 @@ import (
|
|||||||
// See https://www.winzip.com/win/en/comp_info.html
|
// See https://www.winzip.com/win/en/comp_info.html
|
||||||
const ZipMethodWinZip = 93
|
const ZipMethodWinZip = 93
|
||||||
|
|
||||||
// ZipMethodPKWare is the method number used by PKWARE to indicate Zstandard compression.
|
// ZipMethodPKWare is the original method number used by PKWARE to indicate Zstandard compression.
|
||||||
// See https://pkware.cachefly.net/webdocs/APPNOTE/APPNOTE-6.3.7.TXT
|
// Deprecated: This has been deprecated by PKWARE, use ZipMethodWinZip instead for compression.
|
||||||
|
// See https://pkware.cachefly.net/webdocs/APPNOTE/APPNOTE-6.3.9.TXT
|
||||||
const ZipMethodPKWare = 20
|
const ZipMethodPKWare = 20
|
||||||
|
|
||||||
var zipReaderPool sync.Pool
|
var zipReaderPool sync.Pool
|
||||||
|
4
vendor/modules.txt
vendored
4
vendor/modules.txt
vendored
@ -111,7 +111,7 @@ github.com/containers/ocicrypt/keywrap/pkcs7
|
|||||||
github.com/containers/ocicrypt/spec
|
github.com/containers/ocicrypt/spec
|
||||||
github.com/containers/ocicrypt/utils
|
github.com/containers/ocicrypt/utils
|
||||||
github.com/containers/ocicrypt/utils/keyprovider
|
github.com/containers/ocicrypt/utils/keyprovider
|
||||||
# github.com/containers/storage v1.32.0
|
# github.com/containers/storage v1.32.1
|
||||||
github.com/containers/storage
|
github.com/containers/storage
|
||||||
github.com/containers/storage/drivers
|
github.com/containers/storage/drivers
|
||||||
github.com/containers/storage/drivers/aufs
|
github.com/containers/storage/drivers/aufs
|
||||||
@ -232,7 +232,7 @@ github.com/imdario/mergo
|
|||||||
github.com/inconshreveable/mousetrap
|
github.com/inconshreveable/mousetrap
|
||||||
# github.com/json-iterator/go v1.1.11
|
# github.com/json-iterator/go v1.1.11
|
||||||
github.com/json-iterator/go
|
github.com/json-iterator/go
|
||||||
# github.com/klauspost/compress v1.12.2
|
# github.com/klauspost/compress v1.12.3
|
||||||
github.com/klauspost/compress/flate
|
github.com/klauspost/compress/flate
|
||||||
github.com/klauspost/compress/fse
|
github.com/klauspost/compress/fse
|
||||||
github.com/klauspost/compress/huff0
|
github.com/klauspost/compress/huff0
|
||||||
|
Loading…
Reference in New Issue
Block a user