summaryrefslogtreecommitdiffstats
path: root/thirdparty/misc/qoa.h
diff options
context:
space:
mode:
authorDeeJayLSP <djlsplays@gmail.com>2024-06-08 10:27:03 -0300
committerDeeJayLSP <djlsplays@gmail.com>2024-06-08 11:57:40 -0300
commit63bb754fc89eb34c49eb3883f93b8363ddd78c3c (patch)
tree9145677e02c472abc5fd4c4253d0c03c6faa90f4 /thirdparty/misc/qoa.h
parent5833f597865c773fae3ee09fc4e31d4a243f812d (diff)
downloadredot-engine-63bb754fc89eb34c49eb3883f93b8363ddd78c3c.tar.gz
qoa: Apply upstream patches
Diffstat (limited to 'thirdparty/misc/qoa.h')
-rw-r--r--thirdparty/misc/qoa.h16
1 files changed, 14 insertions, 2 deletions
diff --git a/thirdparty/misc/qoa.h b/thirdparty/misc/qoa.h
index 2dde8df098..c890b88bd6 100644
--- a/thirdparty/misc/qoa.h
+++ b/thirdparty/misc/qoa.h
@@ -391,6 +391,9 @@ unsigned int qoa_encode_frame(const short *sample_data, qoa_desc *qoa, unsigned
16 scalefactors, encode all samples for the current slice and
meassure the total squared error. */
qoa_uint64_t best_rank = -1;
+ #ifdef QOA_RECORD_TOTAL_ERROR
+ qoa_uint64_t best_error = -1;
+ #endif
qoa_uint64_t best_slice = -1;
qoa_lms_t best_lms = {{-1, -1, -1, -1}, {-1, -1, -1, -1}};
int best_scalefactor = -1;
@@ -407,6 +410,9 @@ unsigned int qoa_encode_frame(const short *sample_data, qoa_desc *qoa, unsigned
qoa_lms_t lms = qoa->lms[c];
qoa_uint64_t slice = scalefactor;
qoa_uint64_t current_rank = 0;
+ #ifdef QOA_RECORD_TOTAL_ERROR
+ qoa_uint64_t current_error = 0;
+ #endif
for (int si = slice_start; si < slice_end; si += channels) {
int sample = sample_data[si];
@@ -436,6 +442,9 @@ unsigned int qoa_encode_frame(const short *sample_data, qoa_desc *qoa, unsigned
qoa_uint64_t error_sq = error * error;
current_rank += error_sq + weights_penalty * weights_penalty;
+ #ifdef QOA_RECORD_TOTAL_ERROR
+ current_error += error_sq;
+ #endif
if (current_rank > best_rank) {
break;
}
@@ -446,6 +455,9 @@ unsigned int qoa_encode_frame(const short *sample_data, qoa_desc *qoa, unsigned
if (current_rank < best_rank) {
best_rank = current_rank;
+ #ifdef QOA_RECORD_TOTAL_ERROR
+ best_error = current_error;
+ #endif
best_slice = slice;
best_lms = lms;
best_scalefactor = scalefactor;
@@ -581,8 +593,8 @@ unsigned int qoa_decode_frame(const unsigned char *bytes, unsigned int size, qoa
unsigned int samples = (frame_header >> 16) & 0x00ffff;
unsigned int frame_size = (frame_header ) & 0x00ffff;
- int data_size = frame_size - 8 - QOA_LMS_LEN * 4 * channels;
- int num_slices = data_size / 8;
+ unsigned int data_size = frame_size - 8 - QOA_LMS_LEN * 4 * channels;
+ unsigned int num_slices = data_size / 8;
unsigned int max_total_samples = num_slices * QOA_SLICE_LEN;
if (