|
@@ -140,14 +140,14 @@ typedef struct {
|
|
|
#endif
|
|
|
} qoa_desc;
|
|
|
|
|
|
-inline unsigned int qoa_encode_header(qoa_desc *qoa, unsigned char *bytes);
|
|
|
-inline unsigned int qoa_encode_frame(const short *sample_data, qoa_desc *qoa, unsigned int frame_len, unsigned char *bytes);
|
|
|
-inline void *qoa_encode(const short *sample_data, qoa_desc *qoa, unsigned int *out_len);
|
|
|
+unsigned int qoa_encode_header(qoa_desc *qoa, unsigned char *bytes);
|
|
|
+unsigned int qoa_encode_frame(const short *sample_data, qoa_desc *qoa, unsigned int frame_len, unsigned char *bytes);
|
|
|
+void *qoa_encode(const short *sample_data, qoa_desc *qoa, unsigned int *out_len);
|
|
|
|
|
|
-inline unsigned int qoa_max_frame_size(qoa_desc *qoa);
|
|
|
-inline unsigned int qoa_decode_header(const unsigned char *bytes, int size, qoa_desc *qoa);
|
|
|
-inline unsigned int qoa_decode_frame(const unsigned char *bytes, unsigned int size, qoa_desc *qoa, short *sample_data, unsigned int *frame_len);
|
|
|
-inline short *qoa_decode(const unsigned char *bytes, int size, qoa_desc *file);
|
|
|
+unsigned int qoa_max_frame_size(qoa_desc *qoa);
|
|
|
+unsigned int qoa_decode_header(const unsigned char *bytes, int size, qoa_desc *qoa);
|
|
|
+unsigned int qoa_decode_frame(const unsigned char *bytes, unsigned int size, qoa_desc *qoa, short *sample_data, unsigned int *frame_len);
|
|
|
+short *qoa_decode(const unsigned char *bytes, int size, qoa_desc *file);
|
|
|
|
|
|
#ifndef QOA_NO_STDIO
|
|
|
|
|
@@ -395,7 +395,7 @@ unsigned int qoa_encode_frame(const short *sample_data, qoa_desc *qoa, unsigned
|
|
|
qoa_uint64_t best_error = -1;
|
|
|
#endif
|
|
|
qoa_uint64_t best_slice = 0;
|
|
|
- qoa_lms_t best_lms = {};
|
|
|
+ qoa_lms_t best_lms;
|
|
|
int best_scalefactor = 0;
|
|
|
|
|
|
for (int sfi = 0; sfi < 16; sfi++) {
|
|
@@ -500,7 +500,7 @@ void *qoa_encode(const short *sample_data, qoa_desc *qoa, unsigned int *out_len)
|
|
|
num_frames * QOA_LMS_LEN * 4 * qoa->channels + /* 4 * 4 bytes lms state per channel */
|
|
|
num_slices * 8 * qoa->channels; /* 8 byte slices */
|
|
|
|
|
|
- unsigned char *bytes = (unsigned char *)QOA_MALLOC(encoded_size);
|
|
|
+ unsigned char *bytes = QOA_MALLOC(encoded_size);
|
|
|
|
|
|
for (unsigned int c = 0; c < qoa->channels; c++) {
|
|
|
/* Set the initial LMS weights to {0, 0, -1, 2}. This helps with the
|
|
@@ -626,12 +626,14 @@ unsigned int qoa_decode_frame(const unsigned char *bytes, unsigned int size, qoa
|
|
|
qoa_uint64_t slice = qoa_read_u64(bytes, &p);
|
|
|
|
|
|
int scalefactor = (slice >> 60) & 0xf;
|
|
|
+ slice <<= 4;
|
|
|
+
|
|
|
int slice_start = sample_index * channels + c;
|
|
|
int slice_end = qoa_clamp(sample_index + QOA_SLICE_LEN, 0, samples) * channels + c;
|
|
|
|
|
|
for (int si = slice_start; si < slice_end; si += channels) {
|
|
|
int predicted = qoa_lms_predict(&qoa->lms[c]);
|
|
|
- int quantized = (slice >> 57) & 0x7;
|
|
|
+ int quantized = (slice >> 61) & 0x7;
|
|
|
int dequantized = qoa_dequant_tab[scalefactor][quantized];
|
|
|
int reconstructed = qoa_clamp_s16(predicted + dequantized);
|
|
|
|
|
@@ -655,7 +657,7 @@ short *qoa_decode(const unsigned char *bytes, int size, qoa_desc *qoa) {
|
|
|
|
|
|
/* Calculate the required size of the sample buffer and allocate */
|
|
|
int total_samples = qoa->samples * qoa->channels;
|
|
|
- short *sample_data = (short *)QOA_MALLOC(total_samples * sizeof(short));
|
|
|
+ short *sample_data = QOA_MALLOC(total_samples * sizeof(short));
|
|
|
|
|
|
unsigned int sample_index = 0;
|
|
|
unsigned int frame_len;
|