upleb.uk

Public git repos — served from a NIP-34 GRASP relay at git.upleb.uk

summaryrefslogtreecommitdiff
path: root/runtime/xma_decoder/leonida_xma2_decoder.h
blob: a4c5b45344af2c4993afb3ee9d8dd25062bcf069 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
#ifndef LEONIDA_XMA2_DECODER_H
#define LEONIDA_XMA2_DECODER_H

#include <stddef.h>
#include <stdint.h>

#ifdef __cplusplus
extern "C" {
#endif

#define LEONIDA_XMA2_PACKET_BYTES 2048u

typedef struct LeonidaXma2Decoder LeonidaXma2Decoder;
typedef struct LeonidaXma2PcmBlock LeonidaXma2PcmBlock;

enum LeonidaXma2Status {
  LEONIDA_XMA2_OK = 0,
  LEONIDA_XMA2_INVALID_ARGUMENT = 1,
  LEONIDA_XMA2_INVALID_FORMAT = 2,
  LEONIDA_XMA2_BAD_PACKET_SIZE = 3,
  LEONIDA_XMA2_OUT_OF_MEMORY = 4,
  LEONIDA_XMA2_DECODER_FAILURE = 5,
  LEONIDA_XMA2_PANIC = 6,
};

int32_t leonida_xma2_decoder_create(uint32_t sample_rate, uint32_t channels,
                                    LeonidaXma2Decoder **out_decoder);
/* Like leonida_xma2_decoder_create, but decodes like the console's XMA hardware: the first
   frame is kept and there is no 64-sample start skip; the caller applies the context's skip. */
int32_t leonida_xma2_decoder_create_hardware(uint32_t sample_rate, uint32_t channels,
                                             LeonidaXma2Decoder **out_decoder);
int32_t leonida_xma2_decode_buffer(LeonidaXma2Decoder *decoder,
                                   const uint8_t *input, size_t input_len,
                                   LeonidaXma2PcmBlock **out_block);
void leonida_xma2_decoder_destroy(LeonidaXma2Decoder *decoder);
const int16_t *leonida_xma2_pcm_data(const LeonidaXma2PcmBlock *block);
size_t leonida_xma2_pcm_sample_count(const LeonidaXma2PcmBlock *block);
void leonida_xma2_pcm_destroy(LeonidaXma2PcmBlock *block);

#ifdef __cplusplus
}
#endif

#endif