From a5dd540bccc6ce20971a6680f076beedc13f2a95 Mon Sep 17 00:00:00 2001 From: BubsMcgee Date: Wed, 25 Nov 2026 14:11:53 -0500 Subject: xapu: decode Opus packets through runtime/opus_decoder (RT-XAPU-OPUS-DECODE) Builds on #1144 (RT-XAPU-CONNECT-LAYOUTS): the queue and layouts stay there; fill() decodes each process packet through a Rust C-ABI crate over BSD-3 opus-pure when cargo builds it, and keeps the table-of-contents silence path otherwise. Adds xapu_opus_test (a generated 440 Hz stereo packet decoded to 960 frames) and the CMake wiring; xapu_chad_test keeps covering the layouts and the silent path. No game data. --- runtime/opus_decoder/leonida_opus_decoder.h | 44 +++++++++++++++++++++++++++++ 1 file changed, 44 insertions(+) create mode 100644 runtime/opus_decoder/leonida_opus_decoder.h (limited to 'runtime/opus_decoder/leonida_opus_decoder.h') diff --git a/runtime/opus_decoder/leonida_opus_decoder.h b/runtime/opus_decoder/leonida_opus_decoder.h new file mode 100644 index 000000000..d5473510d --- /dev/null +++ b/runtime/opus_decoder/leonida_opus_decoder.h @@ -0,0 +1,44 @@ +#ifndef LEONIDA_OPUS_DECODER_H +#define LEONIDA_OPUS_DECODER_H + +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/* 120 ms at 48 kHz: the longest Opus packet, in samples per channel. */ +#define LEONIDA_OPUS_MAX_FRAMES 5760u + +typedef struct LeonidaOpusDecoder LeonidaOpusDecoder; + +enum LeonidaOpusStatus { + LEONIDA_OPUS_OK = 0, + LEONIDA_OPUS_INVALID_ARGUMENT = 1, + LEONIDA_OPUS_INVALID_FORMAT = 2, + LEONIDA_OPUS_DECODER_FAILURE = 3, + LEONIDA_OPUS_OUT_OF_MEMORY = 4, + LEONIDA_OPUS_PANIC = 5, + LEONIDA_OPUS_BUFFER_TOO_SMALL = 6, +}; + +int32_t leonida_opus_decoder_create(uint32_t sample_rate, uint32_t channels, + LeonidaOpusDecoder **out_decoder); +uint32_t leonida_opus_decoder_channels(const LeonidaOpusDecoder *decoder); +int32_t leonida_opus_decode_packet(LeonidaOpusDecoder *decoder, + const uint8_t *input, size_t input_len, + float *out, size_t out_capacity_frames, + uint32_t *out_frames); +int32_t leonida_opus_decoder_reset(LeonidaOpusDecoder *decoder); +void leonida_opus_decoder_destroy(LeonidaOpusDecoder *decoder); +/* Test helper: encodes frame_count interleaved f32 frames to one packet at 48 kHz. */ +int32_t leonida_opus_encode_test(const float *input, uint32_t frame_count, + uint32_t channels, uint8_t *out, + size_t out_capacity, size_t *out_len); + +#ifdef __cplusplus +} +#endif + +#endif -- cgit v1.2.3