Skip to content

Commit

Permalink
qoa.h: Sync with upstream
Browse files Browse the repository at this point in the history
  • Loading branch information
DeeJayLSP committed Oct 9, 2024
1 parent 4c4e673 commit 4e85456
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 4 deletions.
2 changes: 1 addition & 1 deletion thirdparty/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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}`
Expand Down
4 changes: 2 additions & 2 deletions thirdparty/misc/patches/qoa-min-fix.patch
Original file line number Diff line number Diff line change
@@ -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 {
Expand Down Expand Up @@ -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;
Expand Down
4 changes: 3 additions & 1 deletion thirdparty/misc/qoa.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down

0 comments on commit 4e85456

Please sign in to comment.