Documentation ¶
Index ¶
Constants ¶
const ( // TileSideLength is the number of pixel per side of a square frame tile TileSideLength = 4 // PixelPerTile is the number of pixel within one frame tile PixelPerTile = TileSideLength * TileSideLength )
const ( CtrlColorTile2ColorsStatic = ControlType(0) CtrlColorTile2ColorsMasked = ControlType(1) CtrlColorTile4ColorsMasked = ControlType(2) CtrlColorTile8ColorsMasked = ControlType(3) CtrlColorTile16ColorsMasked = ControlType(4) CtrlSkip = ControlType(5) CtrlRepeatPrevious = ControlType(6) CtrlUnknown = ControlType(7) )
Control type constants
Variables ¶
var ErrFormat = fmt.Errorf("format Error")
ErrFormat indicates errors in the compression format.
Functions ¶
func PackControlWords ¶
func PackControlWords(words []ControlWord) []byte
PackControlWords packs and encodes the given words into a byte stream.
Types ¶
type BitstreamReader ¶
type BitstreamReader struct {
// contains filtered or unexported fields
}
BitstreamReader is a utility to read big-endian integer values of arbitrary bit size from a bitstream.
func NewBitstreamReader ¶
func NewBitstreamReader(data []byte) *BitstreamReader
NewBitstreamReader returns a new instance of a bistream reader using the provided byte slice as source.
func (*BitstreamReader) Advance ¶
func (reader *BitstreamReader) Advance(bits int)
Advance skips the provided amount of bits and puts the current position there. Successive read operations will return values from the new position. It is possible to advance beyond the available length.
This function panics when advancing with negative values.
func (*BitstreamReader) Exhausted ¶
func (reader *BitstreamReader) Exhausted() bool
Exhausted returns true if the current position is at or beyond the possible length. Reading an exhausted stream yields only zeroes.
func (*BitstreamReader) Read ¶
func (reader *BitstreamReader) Read(bits int) (result uint32)
Read returns a value with the requested bit size, right aligned, as a uint32. Reading does not advance the current position. A successful read of a certain size will return the same value when called repeatedly with the same parameter. Reading is possible beyond the available size. For the missing bits, a value of 0 is provided.
The function panics when reading more than 32 bits.
type ControlWord ¶
type ControlWord uint32
ControlWord describes the current compression action.
func UnpackControlWords ¶
func UnpackControlWords(data []byte) (words []ControlWord, err error)
UnpackControlWords reads from an encoded string of bytes a series of packed control words. If all is OK, the control words are returned. If the function returns an error, something could not be read/decoded properly.
func (ControlWord) Count ¶
func (word ControlWord) Count() int
Count returns the count value of the control
func (ControlWord) IsLongOffset ¶
func (word ControlWord) IsLongOffset() bool
IsLongOffset returns true if Count() returns 0.
func (ControlWord) LongOffset ¶
func (word ControlWord) LongOffset() uint32
LongOffset returns the long offset value. Only relevant if IsLongOffset() returns true.
func (ControlWord) Packed ¶
func (word ControlWord) Packed(times int) PackedControlWord
Packed returns the control word packed in a PackedControlWord with the given number of times.
func (ControlWord) Parameter ¶
func (word ControlWord) Parameter() uint32
Parameter returns the type specific parameter value.
func (ControlWord) Type ¶
func (word ControlWord) Type() ControlType
Type returns the type of the control. Only relevant if IsLongOffset() returns false.
type FrameDecoder ¶
type FrameDecoder struct {
// contains filtered or unexported fields
}
FrameDecoder is for decoding compressed frames with the help of data streams. A new instance of a decoder is created with a FrameDecoderBuilder.
func (*FrameDecoder) Decode ¶
func (decoder *FrameDecoder) Decode(bitstreamData []byte, maskstreamData []byte)
Decode reads the provided streams to paint a frame.
type FrameDecoderBuilder ¶
type FrameDecoderBuilder struct {
// contains filtered or unexported fields
}
FrameDecoderBuilder implements the builder pattern for creating new instances of FrameDecoder. This builder can be reused during the processing of a movie. Every Build() call creates a new instance.
func NewFrameDecoderBuilder ¶
func NewFrameDecoderBuilder(width, height int) *FrameDecoderBuilder
NewFrameDecoderBuilder returns a new instance of a builder with given initial values.
func (*FrameDecoderBuilder) Build ¶
func (builder *FrameDecoderBuilder) Build() *FrameDecoder
Build creates a new instance of a decoder with the most recent parameters.
func (*FrameDecoderBuilder) ForStandardFrame ¶
func (builder *FrameDecoderBuilder) ForStandardFrame(frame []byte, stride int)
ForStandardFrame registers the frame buffer and sets the standard coloring method.
func (*FrameDecoderBuilder) WithControlWords ¶
func (builder *FrameDecoderBuilder) WithControlWords(words []ControlWord)
WithControlWords registers the new word dictionary.
func (*FrameDecoderBuilder) WithPaletteLookupList ¶
func (builder *FrameDecoderBuilder) WithPaletteLookupList(list []byte)
WithPaletteLookupList registers the new list.
type MaskstreamReader ¶
type MaskstreamReader struct {
// contains filtered or unexported fields
}
MaskstreamReader reads mask integers from a byte array.
func NewMaskstreamReader ¶
func NewMaskstreamReader(source []byte) *MaskstreamReader
NewMaskstreamReader returns a new reader instance for given source.
func (*MaskstreamReader) Read ¶
func (reader *MaskstreamReader) Read(bytes int) (value uint64)
Read returns a mask integer of given byte length from the current position. If the current position is at or beyond the available size, 0x00 is assumed for the missing bytes.
Reading more than 8, or less than 0, bytes panics.
type PackedControlWord ¶
type PackedControlWord uint32
PackedControlWord contains a ControlWord together with a count value of occurrences.
func (PackedControlWord) Times ¶
func (packed PackedControlWord) Times() int
Times returns the amount of occurrences of the contained control word.
func (PackedControlWord) Value ¶
func (packed PackedControlWord) Value() ControlWord
Value returns the control word value.
type TileColorFunction ¶
type TileColorFunction func(hTile int, vTile int, lookupArray []byte, mask uint64, indexBitSize uint64)
TileColorFunction is one which shall color the pixel of a video frame tile using the provided values. mask is a packed field of 16 indices, each with a length of indexBitSize. These indices point into a value of lookupArray.
func StandardTileColorer ¶
func StandardTileColorer(frame []byte, stride int) TileColorFunction
StandardTileColorer returns a TileColorFunction for given frame buffer.
This colorer iterates over all pixel of a tile. It sets the pixel value if the corresponding palette value is > 0x00.