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 CurrentVersion + const MarkerEndOfBitstream + const MarkerHyperprior + const MarkerLatentCodestream + const MarkerSideInfo + const MaxChannels + const MaxLatentDimension + const MinHeaderSize + const SignatureSize + var AllowPlaceholderSignature = false + var ErrChecksumMismatch = errors.New("jpegai: checksum mismatch") + var ErrHyperpriorDecodeFailed = errors.New("jpegai: hyperprior decoding failed") + var ErrInferenceFailed = errors.New("jpegai: inference failed") + var ErrInvalidDimensions = errors.New("jpegai: invalid image dimensions") + var ErrInvalidEntropyData = errors.New("jpegai: invalid entropy coded data") + var ErrInvalidHeader = errors.New("jpegai: invalid header structure") + var ErrInvalidLatentShape = errors.New("jpegai: invalid latent tensor shape") + var ErrInvalidModelID = errors.New("jpegai: invalid model identifier") + var ErrInvalidQuality = errors.New("jpegai: invalid quality parameter") + var ErrInvalidSignature = errors.New("jpegai: invalid JPEG AI signature") + var ErrIterationLimitExceeded = errors.New("jpegai: iteration limit exceeded") + var ErrLatentDecodeFailed = errors.New("jpegai: latent decoding failed") + var ErrModelLoadFailed = errors.New("jpegai: model loading failed") + var ErrModelNotLoaded = errors.New("jpegai: model not loaded") + var ErrModelTooLarge = errors.New("jpegai: model size exceeds maximum limit") + var ErrNoInferenceEngine = errors.New("jpegai: no inference engine configured") + var ErrOutputSizeTooLarge = errors.New("jpegai: output size exceeds maximum limit") + var ErrPlaceholderSignatureDisabled = errors.New("jpegai: placeholder JAI signature disabled; set AllowPlaceholderSignature") + var ErrTensorDimensionMismatch = errors.New("jpegai: tensor dimension mismatch") + var ErrTruncatedBitstream = errors.New("jpegai: truncated bitstream") + var ErrUnsupportedProfile = errors.New("jpegai: unsupported coding profile") + var ErrUnsupportedVersion = errors.New("jpegai: unsupported bitstream version") + var Signature = [4]byte + type ColorSpace uint8 + const ColorSpaceGrayscale + const ColorSpaceRGB + const ColorSpaceRGBA + const ColorSpaceYCbCr + func (c ColorSpace) String() string + type DecodeInfo struct + BitDepth int + ColorSpace ColorSpace + HasHyperprior bool + Height int + LatentShape *LatentShape + ModelID string + Quality int + Width int + type Decoder struct + func NewDecoder(data []byte) *Decoder + func (d *Decoder) Decode() ([]float32, error) + func (d *Decoder) GetDecodeInfo() (*DecodeInfo, error) + func (d *Decoder) GetHeader() *JPEGAIHeader + func (d *Decoder) Infer(latentData []float32) ([]float32, error) + func (d *Decoder) IsModelLoaded() bool + func (d *Decoder) LoadModel(path string) (*ModelMetadata, error) + func (d *Decoder) ParseHeader() (*JPEGAIHeader, error) + func (d *Decoder) SetInferenceEngine(engine InferenceEngine) + func (d *Decoder) SetModelLoader(loader ModelLoader) + func (d *Decoder) UnloadModel() error + type DecoderNetwork interface + Decode func(latents []float32, shape *LatentShape) ([]float32, error) + GetModelInfo func() (*ModelMetadata, error) + type DecodingContext struct + Header *JPEGAIHeader + Hyperprior *HyperpriorData + Iterations int + Latents *LatentRepresentation + Position int + type EncoderNetwork interface + Encode func(input []float32, width, height, channels int) ([]float32, *LatentShape, error) + GetModelInfo func() (*ModelMetadata, error) + type EntropyMode uint8 + const EntropyModeArithmetic + const EntropyModeHybrid + const EntropyModeRange + func (m EntropyMode) String() string + type HyperpriorData struct + Data []byte + MeanParams []float32 + ScaleParams []float32 + Shape *LatentShape + type InferenceEngine interface + GetModelInfo func() (*ModelMetadata, error) + Infer func(latentData []float32) ([]float32, error) + type JPEGAIHeader struct + BitDepth int + Checksum uint32 + ColorSpace ColorSpace + HasHyperprior bool + HasSideInfo bool + Height int + LatentShape *LatentShape + ModelID string + Profile Profile + Quality int + Version uint16 + Width int + func ParseHeader(data []byte) (*JPEGAIHeader, error) + type LatentCodestream struct + Data []byte + DataOffset int + EntropyMode EntropyMode + Shape *LatentShape + TableOffset int + type LatentRepresentation struct + Data []int16 + Offset float32 + Scale float32 + Shape *LatentShape + func (l *LatentRepresentation) Dequantize() []float32 + type LatentShape struct + Batch int + Channels int + Height int + Width int + func (s *LatentShape) Size() int + func (s *LatentShape) Validate() error + type ModelLoader interface + IsModelLoaded func() bool + LoadModel func(path string) (*ModelMetadata, error) + UnloadModel func() error + type ModelMetadata struct + Architecture string + DownsampleFactor int + HyperLatentChannels int + InputChannels int + LatentChannels int + ModelID string + ModelSize int64 + ModelVersion uint16 + Precision string + type ParseError struct + Cause error + Message string + Offset int + func NewParseError(offset int, message string, cause error) *ParseError + func (e *ParseError) Error() string + func (e *ParseError) Unwrap() error + type Parser struct + func NewParser(data []byte) *Parser + func (p *Parser) DecodeLatents(codestream *LatentCodestream) (*LatentRepresentation, error) + func (p *Parser) ParseHyperprior() (*HyperpriorData, error) + func (p *Parser) ParseLatentCodestream(expectedShape *LatentShape) (*LatentCodestream, error) + func (p *Parser) Position() int + func (p *Parser) Remaining() int + func (p *Parser) SetPosition(pos int) + type Profile uint8 + const ProfileBase + const ProfileHigh + const ProfileLowLatency + const ProfileScalable + func (p Profile) String() string