Versions in this module Expand all Collapse all v1 v1.0.1 Jun 30, 2026 v1.0.0 Jun 30, 2026 Changes in this version + const ACContextMag + const ACContextS0 + const ACContextSE + const ACContextSN + const ACContextSP + const ACContextX1 + const ACContextX2 + const DCContextMag + const DCContextS0 + const DCContextSP + const DCContextSS + const DCContextX1 + const DCContextX2 + const DCContextsPerComponent + const InitialA + const MarkerDAC + const MarkerSOF10 + const MarkerSOF11 + const MarkerSOF9 + const MarkerSOS + const MaxContexts + const MaxIterationsPerBlock + const MaxRenormIterations + const MaxStates + const MinA + var ErrInvalidContext = fmt.Errorf("invalid context index") + var ErrInvalidMarker = fmt.Errorf("invalid marker") + var ErrInvalidState = fmt.Errorf("invalid QM-coder state") + var ErrMaxIterations = fmt.Errorf("maximum iterations exceeded") + func DefaultConditioningTables() map[int]*ConditioningTable + func FrameTypeName(marker byte) string + type ACContextSelector struct + Kx int + func NewACContextSelector(kx int) *ACContextSelector + func (a *ACContextSelector) GetBandSum() int + func (a *ACContextSelector) GetMagnitudeContext(baseContext int) int + func (a *ACContextSelector) GetS0Context(baseContext, k int) int + func (a *ACContextSelector) GetSEContext(baseContext, k int) int + func (a *ACContextSelector) GetSignContext(baseContext int, negative bool) int + func (a *ACContextSelector) GetX1Context(baseContext, k int) int + func (a *ACContextSelector) GetX2Context(baseContext, k int) int + func (a *ACContextSelector) ResetBandSum() + func (a *ACContextSelector) UpdateBandSum(coeff int) + type CoefficientDecoder struct + func NewCoefficientDecoder(data []byte, numComponents int, conditioning map[int]*ConditioningTable, ...) (*CoefficientDecoder, error) + func (d *CoefficientDecoder) DecodeAC(component, spectralStart, spectralEnd int) ([]int, error) + func (d *CoefficientDecoder) DecodeBlock(component int) ([]int, error) + func (d *CoefficientDecoder) DecodeDC(component int) (int, error) + func (d *CoefficientDecoder) ResetAllDC() + func (d *CoefficientDecoder) ResetBlock(component int) + func (d *CoefficientDecoder) ResetDC(component int) + func (d *CoefficientDecoder) SetLossless(lossless bool) + func (d *CoefficientDecoder) SetProgressive(progressive bool) + type CoefficientEncoder struct + func NewCoefficientEncoder(numComponents int, conditioning map[int]*ConditioningTable, ...) (*CoefficientEncoder, error) + func (e *CoefficientEncoder) EncodeAC(component int, coefficients []int, spectralStart, spectralEnd int) error + func (e *CoefficientEncoder) EncodeBlock(component int, block []int) error + func (e *CoefficientEncoder) EncodeDC(component, diff int) error + func (e *CoefficientEncoder) Flush() error + func (e *CoefficientEncoder) GetBytes() []byte + func (e *CoefficientEncoder) ResetAllDC() + func (e *CoefficientEncoder) ResetBlock(component int) + func (e *CoefficientEncoder) ResetDC(component int) + func (e *CoefficientEncoder) SetLossless(lossless bool) + func (e *CoefficientEncoder) SetProgressive(progressive bool) + type Component struct + HorizontalSampling int + ID int + QuantTableID int + VerticalSampling int + type ConditioningTable struct + Kx uint8 + L uint8 + U uint8 + type Context struct + MPS uint8 + State uint8 + type ContextManager struct + func NewContextManager(numComponents int, conditioning map[int]*ConditioningTable) *ContextManager + func (cm *ContextManager) GetACSelector(component int) *ACContextSelector + func (cm *ContextManager) GetDCSelector(component int) *DCContextSelector + func (cm *ContextManager) ResetAll() + func (cm *ContextManager) ResetBlock(component int) + func (cm *ContextManager) TotalContexts() int + type DACParser struct + func NewDACParser(validator Validator) *DACParser + func (p *DACParser) ParseDAC(r io.Reader) (map[int]*ConditioningTable, error) + type DCContextSelector struct + L int + U int + func NewDCContextSelector(l, u int) *DCContextSelector + func (d *DCContextSelector) Classify() int + func (d *DCContextSelector) GetMagnitudeContext(baseContext int) int + func (d *DCContextSelector) GetS0Context(baseContext int) int + func (d *DCContextSelector) GetSPContext(baseContext int) int + func (d *DCContextSelector) GetSSContext(baseContext int) int + func (d *DCContextSelector) GetXContext(baseContext int, xIndex int) int + func (d *DCContextSelector) Reset() + func (d *DCContextSelector) UpdatePreviousDifference(diff int) + type DefaultValidator struct + func NewValidator() *DefaultValidator + func (*DefaultValidator) SafeAdd(a, b int) (int, error) + func (*DefaultValidator) SafeMultiply(a, b int) (int, error) + func (*DefaultValidator) SafeSubtract(a, b int) (int, error) + func (*DefaultValidator) ValidateContextIndex(index int) error + func (*DefaultValidator) ValidateDimensions(width, height int) error + func (*DefaultValidator) ValidatePrecision(precision int) error + func (*DefaultValidator) ValidateSpectralSelection(ss, se int) error + func (*DefaultValidator) ValidateStateIndex(state int) error + func (*DefaultValidator) ValidateSuccessiveApprox(ah, al int) error + type Frame struct + Components []Component + Height int + IsLossless bool + IsProgressive bool + Precision int + Width int + type FrameParser struct + func NewFrameParser(validator Validator) *FrameParser + func (p *FrameParser) ParseSOF(r io.Reader, expectedMarker byte) (*Frame, error) + func (p *FrameParser) ParseSOF10(r io.Reader) (*Frame, error) + func (p *FrameParser) ParseSOF11(r io.Reader) (*Frame, error) + func (p *FrameParser) ParseSOF9(r io.Reader) (*Frame, error) + type LosslessDecoder struct + func NewLosslessDecoder(data []byte, numComponents int, conditioning map[int]*ConditioningTable, ...) (*LosslessDecoder, error) + func (d *LosslessDecoder) DecodeDifference(component int) (int, error) + func (d *LosslessDecoder) DecodeRow(component, width int) ([]int, error) + func (d *LosslessDecoder) GetPrecision() int + type LosslessEncoder struct + func NewLosslessEncoder(numComponents int, conditioning map[int]*ConditioningTable, precision int, ...) (*LosslessEncoder, error) + func (e *LosslessEncoder) EncodeDifference(component, diff int) error + func (e *LosslessEncoder) EncodeRow(component int, diffs []int) error + type ProgressiveDecoder struct + func NewProgressiveDecoder(numComponents, blocksPerComponent int, _ map[int]*ConditioningTable, ...) *ProgressiveDecoder + func (d *ProgressiveDecoder) DecodeACScan(component, spectralStart, spectralEnd, al int) error + func (d *ProgressiveDecoder) DecodeDCScan(components []int, al int) error + func (d *ProgressiveDecoder) GetCoefficients(component int) [][]int + func (d *ProgressiveDecoder) InitScan(data []byte, numComponents int, conditioning map[int]*ConditioningTable, ...) error + type QMDecoder struct + A uint32 + C uint32 + CT int + func NewQMDecoder(data []byte, numContexts int, validator Validator) (*QMDecoder, error) + func (d *QMDecoder) BytesRemaining() int + func (d *QMDecoder) DecodeBit(contextIndex int) (int, error) + func (d *QMDecoder) DecodeValue(contextIndex, numBits int) (int, error) + func (d *QMDecoder) GetContext(index int) (*Context, error) + func (d *QMDecoder) Position() int + func (d *QMDecoder) ResetAllContexts() + func (d *QMDecoder) ResetContext(contextIndex int) error + func (d *QMDecoder) ResetIterationCount() + type QMEncoder struct + A uint32 + BP int + C uint32 + CT int + SC int + func NewQMEncoder(numContexts int, validator Validator) (*QMEncoder, error) + func (e *QMEncoder) BytesWritten() int + func (e *QMEncoder) EncodeBit(contextIndex int, bit int) error + func (e *QMEncoder) EncodeValue(contextIndex, value, numBits int) error + func (e *QMEncoder) Flush() error + func (e *QMEncoder) GetBytes() []byte + func (e *QMEncoder) GetContext(index int) (*Context, error) + func (e *QMEncoder) Reset() + func (e *QMEncoder) ResetAllContexts() + func (e *QMEncoder) ResetContext(contextIndex int) error + func (e *QMEncoder) WriteTo(w io.Writer) (int64, error) + type QMState struct + NLPS uint8 + NMPS uint8 + Qe uint16 + SwitchMPS bool + func GetState(index int) (*QMState, error) + type Scan struct + Components []ScanComponent + SpectralEnd int + SpectralStart int + SuccApproxHigh int + SuccApproxLow int + type ScanComponent struct + ACConditioningTable int + ComponentSelector int + DCConditioningTable int + type ScanParser struct + func NewScanParser(validator Validator) *ScanParser + func (p *ScanParser) ParseSOS(r io.Reader) (*Scan, error) + type SequentialDecoder struct + func NewSequentialDecoder(data []byte, numComponents int, conditioning map[int]*ConditioningTable, ...) (*SequentialDecoder, error) + func (d *SequentialDecoder) DecodeImage(width, height int, components []int) ([][][]int, error) + type SequentialEncoder struct + func NewSequentialEncoder(numComponents int, conditioning map[int]*ConditioningTable, ...) (*SequentialEncoder, error) + func (e *SequentialEncoder) EncodeImage(blocks [][][]int) error + type Validator interface + SafeAdd func(a, b int) (int, error) + SafeMultiply func(a, b int) (int, error) + SafeSubtract func(a, b int) (int, error) + ValidateContextIndex func(index int) error + ValidateDimensions func(width, height int) error + ValidatePrecision func(precision int) error + ValidateSpectralSelection func(ss, se int) error + ValidateStateIndex func(state int) error + ValidateSuccessiveApprox func(ah, al int) error