2022-05-19 01:51:26 -07:00
|
|
|
#ifndef SOUND_DECODER_H
|
|
|
|
#define SOUND_DECODER_H
|
|
|
|
|
|
|
|
#include <stddef.h>
|
|
|
|
|
2022-09-23 05:43:44 -07:00
|
|
|
namespace fallout {
|
|
|
|
|
2023-02-13 00:02:17 -08:00
|
|
|
typedef int(SoundDecoderReadProc)(void* data, void* buffer, unsigned int size);
|
2022-05-19 01:51:26 -07:00
|
|
|
|
|
|
|
typedef struct SoundDecoder {
|
|
|
|
SoundDecoderReadProc* readProc;
|
2023-02-13 00:02:17 -08:00
|
|
|
void* data;
|
2022-05-19 01:51:26 -07:00
|
|
|
unsigned char* bufferIn;
|
|
|
|
size_t bufferInSize;
|
|
|
|
|
|
|
|
// Next input byte.
|
|
|
|
unsigned char* nextIn;
|
|
|
|
|
|
|
|
// Number of bytes remaining in the input buffer.
|
|
|
|
int remainingInSize;
|
|
|
|
|
|
|
|
// Bit accumulator.
|
|
|
|
int hold;
|
|
|
|
|
|
|
|
// Number of bits in bit accumulator.
|
|
|
|
int bits;
|
2022-12-25 11:30:31 -08:00
|
|
|
int levels;
|
|
|
|
int subbands;
|
|
|
|
int samples_per_subband;
|
|
|
|
int total_samples;
|
|
|
|
unsigned char* prev_samples;
|
|
|
|
unsigned char* samples;
|
|
|
|
int block_samples_per_subband;
|
|
|
|
int block_total_samples;
|
|
|
|
int channels;
|
|
|
|
int rate;
|
|
|
|
int file_cnt;
|
|
|
|
unsigned char* samp_ptr;
|
|
|
|
int samp_cnt;
|
2022-05-19 01:51:26 -07:00
|
|
|
} SoundDecoder;
|
|
|
|
|
|
|
|
size_t soundDecoderDecode(SoundDecoder* soundDecoder, void* buffer, size_t size);
|
|
|
|
void soundDecoderFree(SoundDecoder* soundDecoder);
|
2023-02-13 00:02:17 -08:00
|
|
|
SoundDecoder* soundDecoderInit(SoundDecoderReadProc* readProc, void* data, int* channelsPtr, int* sampleRatePtr, int* sampleCountPtr);
|
2022-05-19 01:51:26 -07:00
|
|
|
|
2022-09-23 05:43:44 -07:00
|
|
|
} // namespace fallout
|
|
|
|
|
2022-05-19 01:51:26 -07:00
|
|
|
#endif /* SOUND_DECODER_H */
|