Documentation
¶
Overview ¶
Package dnnblob parses the USE_WEIGHTS_FILE format read by libopus `dnn/parse_lpcnet_weights.c`. A blob contains named records with a type tag, payload byte size, and weight data. Clone validates the record framing and retains a copy of the input; each record's data view refers to that copy.
The package checks required record names for known DRED, OSCE, and LPCNet model families and exposes typed float32, int32, and int8 views. Model loaders bind those views to layers and validate layer dimensions; this package does not execute the networks.
Index ¶
- Constants
- func RequiredDREDDecoderRecordNames() []string
- func RequiredDecoderControlRecordNames(requireOSCEBWE bool) []string
- func RequiredEncoderControlRecordNames() []string
- type Blob
- func (b *Blob) DecoderModels() DecoderModelState
- func (b *Blob) HasRecord(name string) bool
- func (b *Blob) Record(name string) (Record, bool)
- func (b *Blob) SupportsDREDDecoder() bool
- func (b *Blob) SupportsDREDEncoder() bool
- func (b *Blob) SupportsFARGAN() bool
- func (b *Blob) SupportsOSCE() bool
- func (b *Blob) SupportsOSCEBWE() bool
- func (b *Blob) SupportsOSCELACE() bool
- func (b *Blob) SupportsOSCENoLACE() bool
- func (b *Blob) SupportsPLC() bool
- func (b *Blob) SupportsPitchDNN() bool
- func (b *Blob) ValidateDREDDecoderControl() error
- func (b *Blob) ValidateDecoderControl(requireOSCEBWE bool) error
- func (b *Blob) ValidateEncoderControl() error
- type DecoderModelState
- type Float32View
- type Int8View
- type Int32View
- type Record
Constants ¶
const ( TypeFloat int32 = 0 TypeInt int32 = 1 TypeQWeight int32 = 2 TypeInt8 int32 = 3 )
Record type tags, matching the libopus WeightArray type field (dnn/nnet.h WEIGHT_TYPE_*): float32, int32, quantized weights and int8.
Variables ¶
This section is empty.
Functions ¶
func RequiredDREDDecoderRecordNames ¶
func RequiredDREDDecoderRecordNames() []string
RequiredDREDDecoderRecordNames returns the shared loader-derived record names for the standalone libopus DRED decoder model family. Callers must treat the returned slice as read-only.
func RequiredDecoderControlRecordNames ¶
RequiredDecoderControlRecordNames returns the shared loader-derived record names expected by the default-build libopus main decoder path for OPUS_SET_DNN_BLOB. When requireOSCEBWE is true, it includes the optional OSCE and OSCE_BWE families. Callers must treat the returned slice as read-only.
func RequiredEncoderControlRecordNames ¶
func RequiredEncoderControlRecordNames() []string
RequiredEncoderControlRecordNames returns the shared loader-derived record names the libopus encoder path expects from OPUS_SET_DNN_BLOB. Callers must treat the returned slice as read-only.
Types ¶
type Blob ¶
Blob stores a framing-validated copy of a libopus-style weights blob and its records. Raw, Records, and Record.Data are mutable; each Record.Data payload aliases Raw. Leave them unchanged while model views use the blob.
func Clone ¶
Clone validates data using libopus parse_weights-style framing rules and returns a persistent copy whose record slices point into the copied buffer.
func (*Blob) DecoderModels ¶
func (b *Blob) DecoderModels() DecoderModelState
DecoderModels reports which decoder-side model families have all required record names in the retained blob. Model loaders validate layer dimensions.
func (*Blob) HasRecord ¶
HasRecord reports whether the parsed blob contains a record with the given name.
func (*Blob) Record ¶
Record returns the first record with the given name, mirroring libopus find_array_entry() first-match behavior.
func (*Blob) SupportsDREDDecoder ¶
SupportsDREDDecoder reports whether the required DRED decoder record names are present.
func (*Blob) SupportsDREDEncoder ¶
SupportsDREDEncoder reports whether the required DRED encoder record names are present.
func (*Blob) SupportsFARGAN ¶
SupportsFARGAN reports whether the required FARGAN model record names are present.
func (*Blob) SupportsOSCE ¶
SupportsOSCE reports whether the required LACE and NoLACE record names are present.
func (*Blob) SupportsOSCEBWE ¶
SupportsOSCEBWE reports whether the required OSCE_BWE record names are present.
func (*Blob) SupportsOSCELACE ¶
SupportsOSCELACE reports whether all required LACE record names are present.
func (*Blob) SupportsOSCENoLACE ¶
SupportsOSCENoLACE reports whether all required NoLACE record names are present.
func (*Blob) SupportsPLC ¶
SupportsPLC reports whether the required PLC model record names are present.
func (*Blob) SupportsPitchDNN ¶
SupportsPitchDNN reports whether the required pitch-model record names are present for the libopus DRED and PLC/FARGAN control loaders.
func (*Blob) ValidateDREDDecoderControl ¶
ValidateDREDDecoderControl checks for the record names required by the standalone libopus DRED decoder loader. Model loaders validate dimensions.
func (*Blob) ValidateDecoderControl ¶
ValidateDecoderControl checks for the record names required by the default libopus decoder DNN-blob control and, when requested, OSCE and OSCE_BWE. Model loaders validate layer dimensions.
func (*Blob) ValidateEncoderControl ¶
ValidateEncoderControl checks for the record names required by the libopus encoder DNN-blob control. The model loader validates layer dimensions.
type DecoderModelState ¶
type DecoderModelState struct {
PitchDNN bool
PLC bool
FARGAN bool
DRED bool
OSCE bool
OSCEBWE bool
}
DecoderModelState summarizes which decoder-side model families are present in a validated weights blob.
type Float32View ¶
type Float32View struct {
// contains filtered or unexported fields
}
Float32View is a zero-copy typed view over a validated float32 record payload.
func Float32ViewFromBytes ¶
func Float32ViewFromBytes(data []byte, size int32) (Float32View, error)
Float32ViewFromBytes returns a zero-copy float32 view over raw record bytes, validating that the byte count matches size and contains whole elements. This matches libopus's size-driven layer binding behavior.
func (Float32View) At ¶
func (v Float32View) At(i int) float32
At returns the i-th float32 value. It panics if i is outside [0, Len()).
func (Float32View) Bytes ¶ added in v0.2.0
func (v Float32View) Bytes() []byte
Bytes returns the view's little-endian payload without copying.
func (Float32View) Empty ¶
func (v Float32View) Empty() bool
Empty reports whether the view is empty.
func (Float32View) Fill ¶
func (v Float32View) Fill(dst []float32) int
Fill copies the view into dst and returns the number of values written.
func (Float32View) Len ¶
func (v Float32View) Len() int
Len reports the number of float32 values in the view.
type Int8View ¶
type Int8View struct {
// contains filtered or unexported fields
}
Int8View is a zero-copy typed view over a validated int8 record payload.
func Int8ViewFromBytes ¶
Int8ViewFromBytes returns a zero-copy int8 view over raw record bytes, validating only the byte size.
type Int32View ¶
type Int32View struct {
// contains filtered or unexported fields
}
Int32View is a zero-copy typed view over a validated int32 record payload.
func Int32ViewFromBytes ¶
Int32ViewFromBytes returns a zero-copy int32 view over raw record bytes, validating that the byte count matches size and contains whole elements.
type Record ¶
Record mirrors one libopus WeightArray entry parsed from a weights blob.
func (Record) Float32View ¶
func (r Record) Float32View() (Float32View, error)
Float32View returns a zero-copy float32 view over the record payload.