Documentation
¶
Overview ¶
Package qoa provides bounded one-shot and incremental adapters around Karty's pinned QOA codec.
Index ¶
- Constants
- Variables
- type Metadata
- func Decode(encoded []byte) (metadata Metadata, samples []int16, err error)
- func Encode(samples []int16, channels uint8, sampleRate uint32) (encoded []byte, metadata Metadata, err error)
- func EncodeStream(samples []int16, channels uint8, sampleRate uint32) (encoded []byte, metadata Metadata, err error)
- func Inspect(encoded []byte) (Metadata, error)
- func InspectStream(encoded []byte) (Metadata, error)
- type StreamDecoder
Constants ¶
const (
MaxEncodedBytes = 8 * 1024 * 1024
)
const MaxStreamDurationSeconds = asset.MaxAudioStreamDurationSeconds
MaxStreamDurationSeconds bounds long-form QOA metadata without requiring the complete decoded PCM to fit in memory.
const MaxStreamEncodedBytes = asset.MaxEncodedAudioStreamBytes
MaxStreamEncodedBytes bounds complete long-form QOA files processed by the packaging APIs. Runtime playback should use StreamDecoder instead.
Variables ¶
var ErrInvalid = errors.New("QOA data is invalid")
Functions ¶
This section is empty.
Types ¶
type Metadata ¶
Metadata describes bounded, static QOA content. Frames is the number of samples per channel; DecodedBytes is interleaved signed PCM16 storage.
func Decode ¶
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 EncodeStream ¶ added in v0.0.4
func EncodeStream(samples []int16, channels uint8, sampleRate uint32) (encoded []byte, metadata Metadata, err error)
EncodeStream converts complete interleaved signed PCM16 into deterministic static QOA using the long-form streaming-audio bounds. The resulting file is suitable for separate staging and incremental playback with StreamDecoder.
func Inspect ¶
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.
func InspectStream ¶ added in v0.0.4
InspectStream validates a complete, static long-form QOA file. It applies streaming-audio duration and encoded-size bounds without requiring decoded PCM to fit in the one-shot sound budget.
type StreamDecoder ¶ added in v0.0.4
type StreamDecoder struct {
// contains filtered or unexported fields
}
StreamDecoder incrementally validates QOA frames and exposes interleaved little-endian PCM16. It retains at most one encoded and one decoded frame.
func NewStreamDecoder ¶ added in v0.0.4
func NewStreamDecoder(source io.Reader) (*StreamDecoder, error)
NewStreamDecoder reads the file header and first frame. Static QOA with a known sample count is required so allocation and duration bounds are known.
func (*StreamDecoder) Metadata ¶ added in v0.0.4
func (decoder *StreamDecoder) Metadata() Metadata