amrwb

package module
v0.0.0-...-b3200ec Latest Latest
Warning

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

Go to latest
Published: Oct 15, 2026 License: Apache-2.0 Imports: 3 Imported by: 1 module, 1 package

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

README

AMR-WB encoder and decoder for Go

This package provides CGo bindings for AMR-WB encoder and decoder. All C source is bundled into the package, so no external dependencies are required.

Decoder is based on opencore-amr and encoder is based on vo-amrwbenc.

License

Apache License 2.0 (see license headers)

Documentation

Overview

Package amrwb implements AMR-WB audio codec encoding and decoding.

Index

Constants

View Source
const (
	Magic        = "#!AMR-WB\n" // File magic for AMR-WB, as described in RFC 4867 #5.1.
	PCMFrameSize = 320          // PCM frame size at 16kHz
	FrameSizeMax = 61           // max encoded AMR-WB block size
)
View Source
const (
	// Storage format for AMR-WB. See RFC 4867 #5
	Storage = Format(iota)
	// RTPBandwidthEfficient is a bandwidth-efficient AMR-WB format for RTP payloads. See RFC 4867 #4.3
	RTPBandwidthEfficient
	// RTPOctetAligned is an octet-aligned AMR-WB format for RTP payloads (without interleaving). See RFC 4867 #4.4
	RTPOctetAligned
)
View Source
const (
	Mode6Kb  = amrenc.Mode6Kb  // 6.60kbps
	Mode8Kb  = amrenc.Mode8Kb  // 8.85kbps
	Mode12Kb = amrenc.Mode12Kb // 12.65kbps
	Mode14Kb = amrenc.Mode14Kb // 14.25kbps
	Mode16Kb = amrenc.Mode16Kb // 15.85bps
	Mode18Kb = amrenc.Mode18Kb // 18.25bps
	Mode20Kb = amrenc.Mode20Kb // 19.85kbps
	Mode23Kb = amrenc.Mode23Kb // 23.05kbps
	Mode24Kb = amrenc.Mode24Kb // 23.85kbps

	Fastest = Mode6Kb  // fastest encoding
	Best    = Mode24Kb // best encoding
)

Variables

View Source
var (
	ErrInvalidBlock = errors.New("amrwb: invalid block")
)

Functions

func BlockSize

func BlockSize(data []byte) int

BlockSize returns size of the first AMR-WB block in file data, as described in RFC 4867 #5.3. This function is not suitable for use in parsing of AMR-WB RTP payload, as it uses a different format.

func Blocks

func Blocks(data []byte) (sz, cnt int)

Blocks counts the number of AMR-WB blocks in file data, as described in RFC 4867 #5.3. See BlockSize for details.

Types

type Decoder

type Decoder struct {
	*amrdec.Decoder
	// contains filtered or unexported fields
}

Decoder for AMR-WB audio codec.

func NewDecoder

func NewDecoder(format Format) *Decoder

NewDecoder creates a new Decoder. Caller must call Close to avoid resource leak.

func (*Decoder) Decode

func (d *Decoder) Decode(dst *PCMFrame, src []byte) (int, error)

Decode PCM16 audio frame from src and return a number of bytes read. It returns ErrInvalidBlock if the block is empty or malformed.

type Encoder

type Encoder struct {
	*amrenc.Encoder
	// contains filtered or unexported fields
}

Encoder for AMR-WB audio codec.

func NewEncoder

func NewEncoder(format Format, mode Mode) *Encoder

NewEncoder creates a new Encoder. Caller must call Close to avoid resource leak.

func (*Encoder) Encode

func (e *Encoder) Encode(dst []byte, src *PCMFrame) []byte

Encode PCM16 audio frame and append it to dst.

type Format

type Format int

Format represent the variation of the encoding/decoding format for AMR-WB.

type Mode

type Mode = amrenc.Mode

Mode specifies the bit rate the codec supports.

type PCMFrame

type PCMFrame = [PCMFrameSize]int16

Directories

Path Synopsis
Package amrdec implements AMR-WB decoding.
Package amrdec implements AMR-WB decoding.
Package amrenc implements AMR-WB encoding.
Package amrenc implements AMR-WB encoding.

Jump to

Keyboard shortcuts

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