diff options
Diffstat (limited to 'runtime/opus_decoder/leonida_opus_decoder.h')
| -rw-r--r-- | runtime/opus_decoder/leonida_opus_decoder.h | 44 |
1 files changed, 44 insertions, 0 deletions
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 @@ | |||
| 1 | #ifndef LEONIDA_OPUS_DECODER_H | ||
| 2 | #define LEONIDA_OPUS_DECODER_H | ||
| 3 | |||
| 4 | #include <stddef.h> | ||
| 5 | #include <stdint.h> | ||
| 6 | |||
| 7 | #ifdef __cplusplus | ||
| 8 | extern "C" { | ||
| 9 | #endif | ||
| 10 | |||
| 11 | /* 120 ms at 48 kHz: the longest Opus packet, in samples per channel. */ | ||
| 12 | #define LEONIDA_OPUS_MAX_FRAMES 5760u | ||
| 13 | |||
| 14 | typedef struct LeonidaOpusDecoder LeonidaOpusDecoder; | ||
| 15 | |||
| 16 | enum LeonidaOpusStatus { | ||
| 17 | LEONIDA_OPUS_OK = 0, | ||
| 18 | LEONIDA_OPUS_INVALID_ARGUMENT = 1, | ||
| 19 | LEONIDA_OPUS_INVALID_FORMAT = 2, | ||
| 20 | LEONIDA_OPUS_DECODER_FAILURE = 3, | ||
| 21 | LEONIDA_OPUS_OUT_OF_MEMORY = 4, | ||
| 22 | LEONIDA_OPUS_PANIC = 5, | ||
| 23 | LEONIDA_OPUS_BUFFER_TOO_SMALL = 6, | ||
| 24 | }; | ||
| 25 | |||
| 26 | int32_t leonida_opus_decoder_create(uint32_t sample_rate, uint32_t channels, | ||
| 27 | LeonidaOpusDecoder **out_decoder); | ||
| 28 | uint32_t leonida_opus_decoder_channels(const LeonidaOpusDecoder *decoder); | ||
| 29 | int32_t leonida_opus_decode_packet(LeonidaOpusDecoder *decoder, | ||
| 30 | const uint8_t *input, size_t input_len, | ||
| 31 | float *out, size_t out_capacity_frames, | ||
| 32 | uint32_t *out_frames); | ||
| 33 | int32_t leonida_opus_decoder_reset(LeonidaOpusDecoder *decoder); | ||
| 34 | void leonida_opus_decoder_destroy(LeonidaOpusDecoder *decoder); | ||
| 35 | /* Test helper: encodes frame_count interleaved f32 frames to one packet at 48 kHz. */ | ||
| 36 | int32_t leonida_opus_encode_test(const float *input, uint32_t frame_count, | ||
| 37 | uint32_t channels, uint8_t *out, | ||
| 38 | size_t out_capacity, size_t *out_len); | ||
| 39 | |||
| 40 | #ifdef __cplusplus | ||
| 41 | } | ||
| 42 | #endif | ||
| 43 | |||
| 44 | #endif | ||