qoa

package
v0.0.3 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 26, 2026 License: MIT Imports: 4 Imported by: 0

Documentation

Overview

Package qoa provides a bounded adapter around Karty's pinned QOA codec. It validates the complete file before handing bytes to the dependency.

Index

Constants

View Source
const (
	MaxEncodedBytes = 8 * 1024 * 1024
)

Variables

View Source
var ErrInvalid = errors.New("QOA data is invalid")

Functions

This section is empty.

Types

type Metadata

type Metadata struct {
	Channels     uint8
	SampleRate   uint32
	Frames       uint32
	DecodedBytes uint64
}

Metadata describes bounded, static QOA content. Frames is the number of samples per channel; DecodedBytes is interleaved signed PCM16 storage.

func Decode

func Decode(encoded []byte) (metadata Metadata, samples []int16, err error)

Decode returns interleaved signed PCM16 only after Inspect has established safe allocation and frame bounds.

func Encode

func Encode(samples []int16, channels uint8, sampleRate uint32) (encoded []byte, metadata Metadata, err error)

Encode converts complete interleaved signed PCM16 into deterministic static QOA after validating lengths and Karty's runtime budgets.

func Inspect

func Inspect(encoded []byte) (Metadata, error)

Inspect validates a complete static QOA file using uint64 arithmetic. It rejects streaming files, noncanonical frames, trailing data, and content outside Karty's one-shot sound budgets.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL