pipewire/spa/plugins
Roman Lebedev 7c40cafa7c
audioconvert: avoid even more precision loss in F32 to S32 conversion
This is somewhat similar to the S32->F32 conversion improvements,
but here things a bit more tricky...

The main consideration is that the limits to which we clamp
must be valid 32-bit signed integers, but not all such integers
are exactly losslessly representable in `float32_t`.

For example it we'd clamp to `2147483647`,
that is actually a `2147483648.0f`,
and `2147483648` is not a valid 32-bit signed integer,
so the post-clamp conversion would basically be UB.
We don't have this problem for negative bound, though.

But as we know, any 25-bit signed integer is losslessly
round-trippable through float32_t, and since multiplying by 2
only changes the float's exponent, we can clamp to `2147483520`!
The algorithm of selection of the pre-clamping scale is unaffected.

This additionally avoids right-shift, and thus is even faster.

As `test_lossless_s32_lossless_subset` shows,
if the integer is in the form of s25+shift,
the maximal absolute error is finally zero.

Without going through `float`->`double`->`int`,
i'm not sure if the `float`->`int` conversion
can be improved further.
2024-06-27 19:41:20 +03:00
..
aec spa: aec: webrtc: Fix multichannel processing 2024-06-25 15:34:30 -04:00
alsa impl-port: add port.group property 2024-06-24 13:38:09 +02:00
audioconvert audioconvert: avoid even more precision loss in F32 to S32 conversion 2024-06-27 19:41:20 +03:00
audiomixer spa: revert peer_enum_params node event again 2024-06-20 10:22:45 +02:00
audiotestsrc fix compilation some more 2024-06-18 15:41:12 +02:00
avb spa: small cleanups 2024-01-10 15:51:01 +01:00
bluez5 impl-port: add port.group property 2024-06-24 13:38:09 +02:00
control spa: revert peer_enum_params node event again 2024-06-20 10:22:45 +02:00
ffmpeg spa: use log topics everywhere 2024-03-11 18:45:21 +02:00
jack spa: use log topics everywhere 2024-03-11 18:45:21 +02:00
libcamera impl-port: add port.group property 2024-06-24 13:38:09 +02:00
support Fix compilation with -Werror=float-conversion 2024-06-18 12:17:56 +02:00
test spa: use log topics everywhere 2024-03-11 18:45:21 +02:00
v4l2 impl-port: add port.group property 2024-06-24 13:38:09 +02:00
videoconvert videoconvert: Enable loading external converter plugins 2024-01-22 13:59:16 +00:00
videotestsrc spa: use log topics everywhere 2024-03-11 18:45:21 +02:00
volume spa: fix volume plugin compilation 2024-06-18 15:44:26 +02:00
vulkan vulkan: fix compilation 2024-06-18 15:16:06 +02:00
meson.build meson: fix build with missing libudev-devel 2024-02-06 11:49:40 +01:00