-
Notifications
You must be signed in to change notification settings - Fork 7
/
FrameDecoderBuilder.go
41 lines (33 loc) · 1.29 KB
/
FrameDecoderBuilder.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
package compression
// 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.
type FrameDecoderBuilder struct {
width int
height int
colorer TileColorFunction
paletteLookupList []byte
controlWords []ControlWord
}
// NewFrameDecoderBuilder returns a new instance of a builder with given initial values.
func NewFrameDecoderBuilder(width, height int) *FrameDecoderBuilder {
return &FrameDecoderBuilder{
width: width,
height: height,
}
}
// Build creates a new instance of a decoder with the most recent parameters.
func (builder *FrameDecoderBuilder) Build() *FrameDecoder {
return newFrameDecoder(builder)
}
// ForStandardFrame registers the frame buffer and sets the standard coloring method.
func (builder *FrameDecoderBuilder) ForStandardFrame(frame []byte, stride int) {
builder.colorer = StandardTileColorer(frame, stride)
}
// WithPaletteLookupList registers the new list.
func (builder *FrameDecoderBuilder) WithPaletteLookupList(list []byte) {
builder.paletteLookupList = list
}
// WithControlWords registers the new word dictionary.
func (builder *FrameDecoderBuilder) WithControlWords(words []ControlWord) {
builder.controlWords = words
}