You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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?
The text was updated successfully, but these errors were encountered:
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?
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?
The text was updated successfully, but these errors were encountered: