libdragon
Loading...
Searching...
No Matches
Data Structures | Functions
wav64_opus.c File Reference

Support for opus-compressed WAV64 files. More...

Data Structures

struct  wav64_opus_header_ext
 Wav64 Opus header extension. More...
 
struct  wav64_opus_state
 Wav64 Opus state. More...
 

Functions

void wav64_opus_init (wav64_t *wav)
 Initialize opus decompression on a wav64 file.
 
void wav64_opus_close (wav64_t *wav)
 Shut down opus decompression on a wav64 file.
 
int wav64_opus_get_bitrate (wav64_t *wav)
 Return the bitrate for a wav64 file.
 

Detailed Description

Support for opus-compressed WAV64 files.

Author
Giovanni Bajo (giova.nosp@m.nnib.nosp@m.ajo@g.nosp@m.mail.nosp@m..com)

Opus notes

This section details how the Opus format is used in wav64. Opus is made by a mix of two different coders: CELT and SILK. CELT is used for larger frames and is more apt for music, while SILK is used for smaller frames and is more apt for speech. Our N64 implementation only uses CELT. In fact, the whole Opus layer (which is a framing layer) is not used at all.

A WAV64 file compressed with Opus contains a sequence of raw CELT frames. Since CELT requires framing (that is, the length of the compressed frame must be known in advance), a very simple framing is used: each frame is preceded by a 16-bit integer that contains the compressed length of the frame itself. Moreover, frames are forced to be 2-byte aligned, so that they're easier to read them via DMA.

At the API level, we use the opus_custom API which is a CELT-only API that allows to implement custom "modes". A "mode" is the configuration of the codec, in terms of sample rate and frame size. Standard CELT only supports 48kHz with frames of some specific length (from 2.5ms to 60ms in various steps). For N64, we want to flexibility of experimenting with different sample rates and frame sizes. For instance, currently the implementation defaults to 32 Khz and 20ms frames (640 samples per frame), which seems a good compromise between quality and performance.


Data Structure Documentation

◆ wav64_opus_header_ext

struct wav64_opus_header_ext

Wav64 Opus header extension.

Data Fields
uint32_t frame_size Size of an audioframe in samples.
uint32_t max_cmp_frame_size Maximum compressed frame size in bytes.
uint32_t bitrate_bps Bitrate in bits per second.

◆ wav64_opus_state

struct wav64_opus_state

Wav64 Opus state.

Data Fields
wav64_opus_header_ext xhead Opus header extension.
OpusCustomMode * mode Opus custom mode for this file.
OpusCustomDecoder * dec Opus decoder for this file.