Documentation ¶
Overview ¶
Brotli compression library bindings for the encoder
Index ¶
- Variables
- func CompressBuffer(params *BrotliParams, inputBuffer []byte, encodedBuffer []byte) ([]byte, error)
- type BrotliCompressor
- type BrotliParams
- func (p *BrotliParams) Lgblock() int
- func (p *BrotliParams) Lgwin() int
- func (p *BrotliParams) MaxOutputSize(inputLength int) int
- func (p *BrotliParams) Mode() Mode
- func (p *BrotliParams) Quality() int
- func (p *BrotliParams) SetLgblock(value int)
- func (p *BrotliParams) SetLgwin(value int)
- func (p *BrotliParams) SetMode(value Mode)
- func (p *BrotliParams) SetQuality(value int)
- type BrotliWriter
- type Mode
Constants ¶
This section is empty.
Variables ¶
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