On Tue Mar 3 10:34:46 2026 +0000, Anton Baskanov wrote:
I was thinking of `rem` in terms of calculating the value of a continuous FIR function `f(x)`: we split `x` like this: `x = x * fir_step / fir_step = (floor(x * fir_step) + fmod(x * fir_step), 1.0)) / fir_step` so `idx = floor(x * fir_step)` and `rem = fmod(x * fir_step, 1.0)`. Note that the filter coefficients are accessed in reverse order compared to what a convolution would give. This is where `fir_step - 1 - ...` and `1.0 - ...` come from. It doesn't affect the resulting value because the FIR is symmetric, and it allows the FIR and the input array indices to advance in the same direction, which will be very useful for SIMD. It was already like this in the original code. Right, I did realize that the resampler goes through the filter coefficients in reverse (I already went through that particular confusion in the past :sweat_smile:). I can also agree that "rem" is technically correct. It's just that this isn't immediately obvious and variable naming doesn't seem to help necessarily. I feel like tweaking some variable names and possibly adding a comment or two would help to avoid retreading the same steps the next time someone needs to touch the resampler, in a few months or a few years.
Maybe I'll give it a shot at the end of this rework. -- https://gitlab.winehq.org/wine/wine/-/merge_requests/10217#note_131091