Commit graph

60 commits

Author SHA1 Message Date
Wim Taymans
68f883ff77 audioconvert: fix dither scale
Rectangular dither should be [-0.5, 0.5]
Triangular dither should be [-1.0, 1.0]
Noise should add extra bits.
2022-07-11 17:19:28 +02:00
Wim Taymans
dd1d5960b4 audioconvert: implement f64s
Add swapping functions for f64s.
Fix the awkward interleave/deinterleave names for 32s.
2022-07-11 10:58:51 +02:00
Wim Taymans
06b1cf8663 audioconvert: implement (de)interleave with existing functions 2022-06-30 18:24:05 +02:00
Wim Taymans
9b37142ef6 audioconvert: implement noise shaping
To compare the results:

  pw-cat -r test.wav --format=u8 -P '{ dither.method=none }'

vs:

  pw-cat -r test.wav --format=u8 -P '{ dither.method=shaped5 }'
2022-06-29 17:33:37 +02:00
Wim Taymans
938f2b123e audioconvert: improve format conversion
Make dither noise as a value between -0.5 and 0.5 and add this
to the scaled samples.
For this, we first need to do the scaling and then the CLAMP to
the target depth. This optimizes to the same code but allows us
to avoid under and overflows when we add the dither noise.

Add more dithering methods.

Expose a dither.method property on audioconvert. Disable dither when
the target depth > 16.
2022-06-29 14:10:15 +02:00
Wim Taymans
22d02a7891 audioconvert: dither in 24 bits
This saves some shifts.
2022-06-28 17:15:27 +02:00
Wim Taymans
7a0f201dc7 audioconvert: set right flags for functions 2022-06-28 17:02:15 +02:00
Wim Taymans
6b49bded3a audioconvert: move dither and noise to fmt-ops
We need to do dithering and noise when converting f32 to the
target format. This is more natural because we can work in 32 bits
integers instead of floats.

This will also make it possible to actually calculate the error between
source and target values and implement some sort of feedback and
noise shaping later.
2022-06-28 16:55:50 +02:00
Wim Taymans
734470f0cd audioconvert: add SSE (de)interleave_32(s) versions 2022-03-11 15:02:02 +01:00
Wim Taymans
9f5caa6358 audioconvert: add f64 conversion
See #1990
2022-01-10 13:04:31 +01:00
Wim Taymans
0ace131d72 audioconvert: add stereo deinterleave neon asm
This can take some shortcuts and convert twice as many samples in one
iteration as the strided stereo deinterleave one.
2021-10-28 11:30:04 +02:00
Julian Bouzas
20e64b39da fmtconvert: add support for U16, U24, U32 and U24_32 formats 2021-09-08 14:24:26 -04:00
Wim Taymans
df9f79d869 audioconvert: add converstion to and from alaw/ulaw 2021-08-17 17:32:25 +02:00
Wim Taymans
a5e2e955d2 audioconvert: add more conversions
Add the other endian conversions.
2021-08-17 14:45:00 +02:00
George Kiagiadakis
bc1f9d304f audioconvert: handle S8/S8P raw audio formats 2021-05-05 08:56:59 +03:00
Wim Taymans
a8faad9f17 fmt: support f32p -> s24s conversion
As used by MAudio Fasttrack Pro

See rhbz#916017
2021-01-14 17:58:54 +01:00
Wim Taymans
a520335581 fmt-ops: add sse2 version of f32 to s16 planar/interleaved 2020-07-03 11:05:26 +02:00
Wim Taymans
1b3aaba206 fmt-ops: set the right flags on optimized functions
Or else we could select an avx2 version on a non-capable CPU.

Fixes #227
2020-04-02 17:34:47 +02:00
Wim Taymans
527dc89365 fmt-ops: add neon optimizations for format conversion 2020-03-30 10:59:21 -04:00
Wim Taymans
949dba7bfc fmt-ops: flesh out avx optimizations 2020-03-17 17:27:47 +01:00
Wim Taymans
3a911dfe3b fmt-ops: add avx2 optimized version
Only one optimized version but the sse2 version are compiled with
the avx2 flags so that they get optimized better.
2020-03-16 16:11:29 +01:00
Wim Taymans
fd3dd14ebe fmt-ops: add optimized f32 to s16 stereo conversion 2020-03-16 13:04:21 +01:00
Wim Taymans
f4387e0568 fmt-ops: add support for s24 with endian conversion 2020-01-27 15:46:25 +01:00
Wim Taymans
3c9aa2e96c fmt: add sse2 optimized s32->f32d 2019-10-24 11:06:04 +02:00
Wim Taymans
d8e399dee9 audioconvert: pass state to functions
Pass some state to convert and channelmix functions. This makes it
possible to select per channel optimized convert functions but
also makes it possible to implement noise shaping later.
Pass the channelmix matrix and volume in the state.
Handle specialized 2 channel s16 -> f32 conversion
2019-03-29 17:39:59 +01:00
Wim Taymans
d260cb19be audioconvert: compile c version separately
Also compile the c versions in a separate module with their own
flags.
2019-03-28 21:07:53 +01:00
Wim Taymans
c8d3d475bb audioconvert: handle more optimizations
Compile an optimized library for the given CPU with the right flags,
then link it with the main library.
2019-03-27 17:58:48 +01:00
Wim Taymans
ecc3e78ad4 fmt-ops: use faster f32 -> s32 conversion 2019-03-26 17:24:14 +01:00
Wim Taymans
0505f2dc98 audioconvert: implement passthrough
Add some const and SPA_RESTRICT to methods
When the input and output is the same, work in passthrough mode
where we simply copy place the input pointer onto the output buffer
without doing a memcpy.
Do memcpy when the resampler is not active.
2019-03-20 19:29:14 +01:00
Wim Taymans
74cf412f47 utils: add debugable spa_memcpy 2019-03-20 19:27:46 +01:00
Wim Taymans
fa3bcabbca audioconvert: some more optimizations 2019-03-20 13:04:44 +01:00
George Kiagiadakis
d9c2f77cfe spa/audioconvert: don't include xmmintrin.h in the non-sse fmt-ops
Fixes compilation for arm
2019-02-13 11:22:57 +01:00
Wim Taymans
13bf70a8dd mem: align memory to requested alignment
Improve the allocators to always align the buffer memory to the
requested alignment
Use aligned read and writes for sse functions and check alignment,
optionally falling back to unaligned path.
Add more tests and benchmark cases
Check and warn for misaligned memory in plugins.
2019-01-24 18:28:52 +01:00
Wim Taymans
6f586602af audioconvert: add unit test for format conversion
Add unit test for fmt conversion and fix some bugs
Add empty fmt-ops benchmark
2019-01-23 15:59:54 +01:00
Wim Taymans
e918f9f77c fix sign confusion 2019-01-07 15:52:42 +01:00
Wim Taymans
2c4bffec74 fmt-ops: small optimizations 2019-01-07 13:49:52 +01:00
Wim Taymans
0e91276a03 fmt-ops: SSE functions were really SSE2
The SSE functions used integer operations and were really SSE2 so
rename.
Optimize some more.
2018-12-20 16:11:25 +01:00
Wim Taymans
4dfe1011a6 audioconvert: use cpu detection interface 2018-12-17 13:26:54 +01:00
Wim Taymans
5025aa97e6 audioconvert: fix x86 feature defines 2018-12-17 10:20:18 +01:00
Wim Taymans
08a63ded5d audioconvert: pass samples to convert functions
Pass the number of samples to convert functions instead of number of
bytes because it is much more useful.
2018-12-13 12:02:47 +01:00
Wim Taymans
13010d5d2e fmt: use faster s24 to f32 conversion 2018-11-21 15:51:03 +01:00
Wim Taymans
3267667d94 fmt: improve s24 to float conversion 2018-11-08 09:56:58 +01:00
Wim Taymans
2b88dde567 fmtconvert: add conversions for planar to planar 2018-11-07 11:56:19 +01:00
Wim Taymans
85f2e93c54 Relicense as MIT/X11
Remove some obsolete files
2018-11-05 17:48:52 +01:00
Wim Taymans
ef7a111611 fmt: fix and enable f32 -> s16 conversion 2018-10-30 08:37:07 +00:00
Wim Taymans
ae9843aca2 disable s16 sse until fixed 2018-10-29 14:07:19 +00:00
Wim Taymans
9f61ef96ff fmt-ops: add f32 -> s16 see optimisations 2018-10-29 09:21:33 +00:00
Wim Taymans
5196f7f053 audio: remove layout from audio
Make special format types for planar and interleaved instead of
having a field.
Add enum for audio channel positions
Add some default audio channel layouts
Place the channel layout in the audio format when possible
alsa: place audio channel positions in format
Add sse optimized channel mixing for some common cases
Remove name from port info, it's not mandatory and in the properties
Add direction to port info
2018-09-13 17:03:56 +02:00
Wim Taymans
fca3e1d85d Remove dynamic types
Do not use dynamic types anymore. The reason is that it's difficult:

- to maintain a shared type database over a network.
- the extra overhead when translating between processes and for
  maintaining the translation tables.
- race conditions in translating in RT-threads, this is a problem
  because we want to make event streams.

We now have simple enums with types and extension points for all
types. This is also nicer to use in general.
We don't need the mapper anymore or pass strings around as types.
There is a parallel type info system to get more info about ids and
enums and their hierarchy. It can also be used for debugging.
2018-08-23 17:47:57 +02:00
Wim Taymans
a72e3cefd7 fmt: fix 24 bits audio 2018-08-01 18:15:17 +02:00