From 4e85456f4c7d4ebb855ab9a4d0c422f0637d37d1 Mon Sep 17 00:00:00 2001 From: DeeJayLSP Date: Wed, 9 Oct 2024 12:14:59 -0300 Subject: [PATCH] qoa.h: Sync with upstream --- thirdparty/README.md | 2 +- thirdparty/misc/patches/qoa-min-fix.patch | 4 ++-- thirdparty/misc/qoa.h | 4 +++- 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/thirdparty/README.md b/thirdparty/README.md index 58226261f4b5..668375823d71 100644 --- a/thirdparty/README.md +++ b/thirdparty/README.md @@ -694,7 +694,7 @@ Collection of single-file libraries used in Godot components. * License: MIT - `qoa.h` * Upstream: https://github.com/phoboslab/qoa - * Version: git (e0c69447d4d3945c3c92ac1751e4cdc9803a8303, 2024) + * Version: git (a2d927f8ce78a85e903676a33e0f956e53b89f7d, 2024) * Modifications: Added a few modifiers to comply with C++ nature. * License: MIT - `r128.{c,h}` diff --git a/thirdparty/misc/patches/qoa-min-fix.patch b/thirdparty/misc/patches/qoa-min-fix.patch index 6008b5f8bcdc..a86dee5774fb 100644 --- a/thirdparty/misc/patches/qoa-min-fix.patch +++ b/thirdparty/misc/patches/qoa-min-fix.patch @@ -1,5 +1,5 @@ diff --git a/qoa.h b/qoa.h -index cfed266bef..23612bb0bf 100644 +index f0f44214d8..9fa5465f08 100644 --- a/qoa.h +++ b/qoa.h @@ -140,14 +140,14 @@ typedef struct { @@ -42,7 +42,7 @@ index cfed266bef..23612bb0bf 100644 for (unsigned int c = 0; c < qoa->channels; c++) { /* Set the initial LMS weights to {0, 0, -1, 2}. This helps with the -@@ -655,7 +655,7 @@ short *qoa_decode(const unsigned char *bytes, int size, qoa_desc *qoa) { +@@ -657,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; diff --git a/thirdparty/misc/qoa.h b/thirdparty/misc/qoa.h index 23612bb0bfb4..9fa5465f08c9 100644 --- a/thirdparty/misc/qoa.h +++ b/thirdparty/misc/qoa.h @@ -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);