encoder returns an encoder with the selected options.
()
| 49 | |
| 50 | // encoder returns an encoder with the selected options. |
| 51 | func (o encoderOptions) encoder() encoder { |
| 52 | switch o.level { |
| 53 | case SpeedFastest: |
| 54 | if o.dict != nil { |
| 55 | return &fastEncoderDict{fastEncoder: fastEncoder{fastBase: fastBase{maxMatchOff: int32(o.windowSize), bufferReset: math.MaxInt32 - int32(o.windowSize*2), lowMem: o.lowMem}}} |
| 56 | } |
| 57 | return &fastEncoder{fastBase: fastBase{maxMatchOff: int32(o.windowSize), bufferReset: math.MaxInt32 - int32(o.windowSize*2), lowMem: o.lowMem}} |
| 58 | |
| 59 | case SpeedDefault: |
| 60 | if o.dict != nil { |
| 61 | return &doubleFastEncoderDict{fastEncoderDict: fastEncoderDict{fastEncoder: fastEncoder{fastBase: fastBase{maxMatchOff: int32(o.windowSize), bufferReset: math.MaxInt32 - int32(o.windowSize*2), lowMem: o.lowMem}}}} |
| 62 | } |
| 63 | return &doubleFastEncoder{fastEncoder: fastEncoder{fastBase: fastBase{maxMatchOff: int32(o.windowSize), bufferReset: math.MaxInt32 - int32(o.windowSize*2), lowMem: o.lowMem}}} |
| 64 | case SpeedBetterCompression: |
| 65 | if o.dict != nil { |
| 66 | return &betterFastEncoderDict{betterFastEncoder: betterFastEncoder{fastBase: fastBase{maxMatchOff: int32(o.windowSize), bufferReset: math.MaxInt32 - int32(o.windowSize*2), lowMem: o.lowMem}}} |
| 67 | } |
| 68 | return &betterFastEncoder{fastBase: fastBase{maxMatchOff: int32(o.windowSize), bufferReset: math.MaxInt32 - int32(o.windowSize*2), lowMem: o.lowMem}} |
| 69 | case SpeedBestCompression: |
| 70 | return &bestFastEncoder{fastBase: fastBase{maxMatchOff: int32(o.windowSize), bufferReset: math.MaxInt32 - int32(o.windowSize*2), lowMem: o.lowMem}} |
| 71 | } |
| 72 | panic("unknown compression level") |
| 73 | } |
| 74 | |
| 75 | // WithEncoderCRC will add CRC value to output. |
| 76 | // Output will be 4 bytes larger. |
no outgoing calls
no test coverage detected