Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improvements for people who want to port the code to another language #63

Open
mcraiha opened this issue Jan 2, 2025 · 0 comments
Open

Comments

@mcraiha
Copy link
Contributor

mcraiha commented Jan 2, 2025

Hi,

I just completed my first port of the QOA to C#, and I noticed couple of things that could be improved in original code, to make the porting process a bit easier.

((v > 0) - (v < 0)) - ((n > 0) - (n < 0))
Many languages do not return 1 or 0 values for comparisons so this part requires some extra unfolding

qoa_uint64_t best_rank = -1;
-1 is not a valid value for unsigned integers in many languages. Maybe ULONG_MAX would be more suitable?

int slice_len = qoa_clamp(QOA_SLICE_LEN, 0, frame_len - sample_index);
int slice_start = sample_index * channels + c;
int slice_end = (sample_index + slice_len) * channels + c;

sample_index, channels, c and slice_len are always 0 or larger (and e.g. sample_index is unsigned), so using int type does not work without casting. Maybe size_t might be more suitable for indexing purposes?

qoa->lms[c].history[i] = ((signed short)(history >> 48));
and
qoa->lms[c].weights[i] = ((signed short)(weights >> 48));
should short be used instead of signed short?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant