enc

package
v0.0.0-...-9993916 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 19, 2015 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Overview

Brotli compression library bindings for the encoder

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrInputLargerThanBlockSize error = errors.New("data copied to ring buffer larger than brotli compressor block size")
	ErrBrotliCompression        error = errors.New("brotli compression error")
)

Functions

func CompressBuffer

func CompressBuffer(params *BrotliParams, inputBuffer []byte, encodedBuffer []byte) ([]byte, error)

Compress a buffer. Uses encodedBuffer as the destination buffer unless it is too small, in which case a new buffer is allocated. Default parameters are used if params is nil. Returns the slice of the encodedBuffer containing the output, or an error.

Types

type BrotliCompressor

type BrotliCompressor struct {
	// contains filtered or unexported fields
}

func NewBrotliCompressor

func NewBrotliCompressor(params *BrotliParams) *BrotliCompressor

An instance can not be reused for multiple brotli streams.

func (*BrotliCompressor) CopyInputToRingBuffer

func (bp *BrotliCompressor) CopyInputToRingBuffer(input []byte)

Copies the given input data to the internal ring buffer of the compressor. No processing of the data occurs at this time and this function can be called multiple times before calling WriteBrotliData() to process the accumulated input. At most GetInputBlockSize() bytes of input data can be copied to the ring buffer, otherwise the next WriteBrotliData() will fail.

func (*BrotliCompressor) Free

func (bp *BrotliCompressor) Free()

func (*BrotliCompressor) GetInputBlockSize

func (bp *BrotliCompressor) GetInputBlockSize() int

The maximum input size that can be processed at once.

func (*BrotliCompressor) WriteBrotliData

func (bp *BrotliCompressor) WriteBrotliData(isLast bool, forceFlush bool) ([]byte, error)

Processes the accumulated input data and returns the new output meta-block, or zero if no new output meta-block was created (in this case the processed input data is buffered internally). Returns ErrInputLargerThanBlockSize if more data was copied to the ring buffer than the block sized. If isLast or forceFlush is true, an output meta-block is always created

type BrotliParams

type BrotliParams struct {
	// contains filtered or unexported fields
}

func NewBrotliParams

func NewBrotliParams() *BrotliParams

Instantiates the compressor parameters with the default settings

func (*BrotliParams) Lgblock

func (p *BrotliParams) Lgblock() int

Base 2 logarithm of the maximum input block size. Range is 16 to 24. If set to 0 (default), the value will be set based on the quality.

func (*BrotliParams) Lgwin

func (p *BrotliParams) Lgwin() int

Base 2 logarithm of the sliding window size. Range is 10 to 24. Default is 22.

func (*BrotliParams) MaxOutputSize

func (p *BrotliParams) MaxOutputSize(inputLength int) int

Maximum output size based on https://github.com/google/brotli/blob/24469b81d604ddf1976c3e4b633523bd8f6f631c/enc/encode_parallel.cc#L233 There doesn't appear to be any documentation of what this calculation is based on.

func (*BrotliParams) Mode

func (p *BrotliParams) Mode() Mode

func (*BrotliParams) Quality

func (p *BrotliParams) Quality() int

Controls the compression-speed vs compression-density tradeoffs. The higher the quality, the slower the compression. Range is 0 to 11. Default is 11.

func (*BrotliParams) SetLgblock

func (p *BrotliParams) SetLgblock(value int)

func (*BrotliParams) SetLgwin

func (p *BrotliParams) SetLgwin(value int)

func (*BrotliParams) SetMode

func (p *BrotliParams) SetMode(value Mode)

func (*BrotliParams) SetQuality

func (p *BrotliParams) SetQuality(value int)

type BrotliWriter

type BrotliWriter struct {
	// contains filtered or unexported fields
}

func NewBrotliWriter

func NewBrotliWriter(params *BrotliParams, writer io.Writer) *BrotliWriter

func (*BrotliWriter) Close

func (w *BrotliWriter) Close() error

func (*BrotliWriter) Write

func (w *BrotliWriter) Write(buffer []byte) (int, error)

type Mode

type Mode int
const (
	// Default compression mode. The compressor does not know anything in
	// advance about the properties of the input.
	GENERIC Mode = iota
	// Compression mode for UTF-8 format text input.
	TEXT
	// Compression mode used in WOFF 2.0.
	FONT
)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL