[alsa-devel] Conversion to int16_t and resolution loss with rate converter plugins
Pavel Hofman
pavel.hofman at ivitera.com
Thu Apr 5 08:17:21 CEST 2018
Dne 5.4.2018 v 05:05 Flavio Protasio Ribeiro napsal(a):
> Hi Folks,
>
>
>
> The libsamplerate and speex rate converter plugins only implement the
> convert_s16 callback from snd_pcm_rate_ops_t. This has ALSA convert
> the buffer to int16_t before handing it over to the plugin for
> resampling. On devices with more than 16 effective bits, this implies
> words gets truncated and bits are lost.
>
>
>
> Specifically for libsamplerate, the resampling is internally
> implemented with floats, so truncating to 16 bits does not offer a
> computational benefit.
>
>
>
> I get why only convert_s16 is implemented for plugins that aren't
> part of the main alsa-lib package. The more generic convert callback
> comes with the burden having the plugin support conversion from/to
> any of the ALSA data types (or alternatively, having the plugin
> source include plugin_ops.h and its dependencies). So here's what I
> propose: replace convert_s16 with a convert_s32 callback which uses
> int32_t instead of int16_t. This would preserve all bits from the
> device and keep the plugin interface simple. Of course this means
> plugins have to be updated to use convert_s32 and rebuilt.
>
>
Hi,
Many years ago I tried to extend the rate API to float, the native
formats of libsamplerate and speex.
I go stuck on float support of all platforms, perhaps you can get
something from the discussion and patches.
http://mailman.alsa-project.org/pipermail/alsa-devel/2011-June/041059.html
http://mailman.alsa-project.org/pipermail/alsa-devel/2011-July/041503.html
If we succeed in adding >16 bit API to the rate plugin, perhaps
supporting libsoxr would be the next step which would bring great value
(performance vs. CPU load) to alsa-lib. Unfortunately that is not just
about conversion, there are other quirks to iron out...
Anyway, thanks a lot and good luck to your very useful endeavour.
Best regards,
Pavel.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0001-Support-for-float-samples-in-rate-converters.patch
Type: text/x-patch
Size: 7073 bytes
Desc: not available
URL: <http://mailman.alsa-project.org/pipermail/alsa-devel/attachments/20180405/fb4debb1/attachment-0002.bin>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0001-Using-float-instead-of-s16-for-libsamplerate.patch
Type: text/x-patch
Size: 3221 bytes
Desc: not available
URL: <http://mailman.alsa-project.org/pipermail/alsa-devel/attachments/20180405/fb4debb1/attachment-0003.bin>
More information about the Alsa-devel
mailing list