Commit Graph

303 Commits

Author SHA1 Message Date
Max Kellermann c84bae739a pcm/Convert: add option to enable the integer-only dsd2pcm implementation 2020-01-17 16:37:09 +01:00
Max Kellermann 925b5954c3 pcm/Dsd2Pcm: add integer-only implementation 2020-01-17 16:17:32 +01:00
Max Kellermann 235b6980b8 pcm/Dsd2Pcm: add optimized stereo version
This code path is 2% faster.
2020-01-14 23:38:46 +01:00
Max Kellermann ee46150329 pcm/Dsd2Pcm: add class MultiDsd2Pcm 2020-01-14 23:29:03 +01:00
Max Kellermann 79c585bf03 pcm/PcmDsd: use size_t 2020-01-14 23:28:34 +01:00
Max Kellermann becd81f771 pcm/PcmDsd: manage Dsd2Pcm instances, not pointers 2020-01-14 23:26:34 +01:00
Max Kellermann 2073a2c1b0 pcm/Dsd2Pcm: remove unused "lsbf" flag 2020-01-14 23:20:45 +01:00
Max Kellermann 3f3104348e pcm/Dsd2Pcm: add "restrict" attribute 2020-01-14 23:20:36 +01:00
Max Kellermann 4038d8527f pcm/Dsd2Pcm: eliminate "& 0xff" 2020-01-14 22:56:28 +01:00
Max Kellermann 3565f0c8ce pcm/Dsd2Pcm: move code to TranslateSample()
10% speedup.  Strange, huh?
2020-01-14 22:51:20 +01:00
Max Kellermann 9647b2cb01 pcm/Dsd2Pcm: move code to ApplySample()
For some reason, this speeds up the library by 2%.
2020-01-14 22:43:11 +01:00
Max Kellermann 2d5bf53240 pcm/Dsd2Pcm: use sizet_t instead of int 2020-01-14 22:40:54 +01:00
Max Kellermann a65f7b1006 pcm/Dsd2Pcm: use std::fill_n() 2020-01-14 22:39:54 +01:00
Max Kellermann bc5b647053 pcm/Dsd2Pcm: use sizet_t instead of unsigned 2020-01-14 22:37:30 +01:00
Max Kellermann 1708ae3e3c pcm/Dsd2Pcm: use uint8_t instead of unsigned char 2020-01-14 22:36:50 +01:00
Max Kellermann 6bfbc5d320 pcm/Dsd2Pcm: move code to CalcOutputSample() 2020-01-14 22:25:54 +01:00
Max Kellermann e7483bc5bc pcm/Dsd2Pcm: make variables more local 2020-01-14 22:21:32 +01:00
Max Kellermann b911ec1a29 pcm/Dsd2Pcm: convert to class 2020-01-14 22:16:02 +01:00
Max Kellermann ca2633bf26 pcm/Dsd2Pcm: remove unused function dsd2pcm_clone() 2020-01-14 22:15:05 +01:00
Max Kellermann 566ac171f5 pcm/Dsd2Pcm: generate ctables at compile time 2020-01-14 22:11:12 +01:00
Max Kellermann 4d95402e4e pcm/Dsd2Pcm: move formula to CalculateCtableValue() 2020-01-14 22:11:12 +01:00
Max Kellermann 4d102c4770 pcm/Dsd2Pcm: convert parameter to bool 2020-01-14 22:11:12 +01:00
Max Kellermann 91bc41ea20 pcm/Dsd2Pcm: add noexcept and remove extern 2020-01-14 22:11:12 +01:00
Max Kellermann e565dcf18c pcm/dsd2pcm: convert to C++ 2020-01-14 22:05:58 +01:00
Max Kellermann 5a87fc7c26 pcm/dsd2pcm: remove unused sources 2020-01-14 22:05:27 +01:00
Max Kellermann 44d7a1d8d2 pcm/Traits: drop "_type" from type names 2020-01-03 16:01:44 +01:00
Max Kellermann 683d5848f4 Merge tag 'v0.21.17'
release v0.21.17
2019-12-16 23:44:20 +01:00
Max Kellermann dc3c0c8866 pcm/Convert, ...: add missing include for std::runtime_error 2019-12-16 22:52:50 +01:00
Max Kellermann f357f743a3 pcm/Volume: use transform_n() 2019-08-10 12:05:37 +02:00
Max Kellermann 91e565d92e pcm/PcmFormat: use transform_n() 2019-08-10 12:05:35 +02:00
Max Kellermann af99f9fc90 pcm/Volume: convert S16 to S24 to preserve quality and reduce noise
Applying software volume to S16 samples means several bits of
precision are lost; at 25% volume, two bits are lost.  Additionally,
dithering adds some noise.

The problem gets worse when you apply the software volume code twice:
for the software mixer volume, and again for the replay gain.  This
loses some more precision and adds even more dithering noise, which
can become audible (see
https://github.com/MusicPlayerDaemon/MPD/issues/542).

By converting everything to 24 bit, we need to shift only two bits to
the right instead of ten, losing nearly no precision, and dithering is
not needed.  Even if the output device is unable to play S24 directly,
we can convert back to S16 with only one stage of dithering.

Closes https://github.com/MusicPlayerDaemon/MPD/issues/542
2019-07-30 20:03:37 +02:00
Max Kellermann 326c6ae615 pcm/Volume: add variable "dest_size" 2019-07-05 21:01:09 +02:00
Max Kellermann 5fa7610264 pcm/Volume: Open() returns output sample format
Prepare for a new mode which may convert to a different sample format
when applying volume, to reduce dithering.
2019-07-05 19:03:00 +02:00
Max Kellermann 1c757f8c1c pcm/Volume: allow any exception 2019-07-05 19:01:46 +02:00
Max Kellermann 06fbbe2d7b pcm/Volume: calculate PCM_VOLUME_1 2019-07-05 18:26:26 +02:00
Max Kellermann 21d91cb1d1 pcm/Volume: fix API documentation 2019-07-05 18:26:14 +02:00
Max Kellermann d663f81420 include cleanups (powered by iwyu) 2019-07-05 09:59:58 +02:00
Max Kellermann beed004b10 pcm/Export: add GetSilence() 2019-06-26 16:04:46 +02:00
Max Kellermann 34c6337887 pcm/Export: add GetInputBlockSize(), GetOutputBlockSize() 2019-06-26 15:49:08 +02:00
Max Kellermann 2093e53641 pcm/Export: add GetInputFrameSize() 2019-06-26 15:48:18 +02:00
Max Kellermann 2f243f2295 pcm/Export: rename GetFrameSize() to GetOutputFrameSize() 2019-06-26 15:46:49 +02:00
Max Kellermann e69fd0300a pcm/Export: rename CalcSourceSize() to CalcInputSize() 2019-06-26 15:46:05 +02:00
Max Kellermann f43cafbf7d pcm/Export: eliminate the AudioFormat parameter from GetFrameSize() 2019-06-26 15:42:47 +02:00
Max Kellermann 53faf77d20 pcm/Export: use the "channels" attribute in GetFrameSize() 2019-06-26 15:41:07 +02:00
Max Kellermann bf574dcb0a pcm/RestBuffer: make internal methods private 2019-06-26 14:44:20 +02:00
Max Kellermann 72b8f33272 pcm/Export: split src_sample_format from alsa_channel_order
Combining these two in one single value saves some memory, but is
complicated and we may need the src_sample_format for new features
later.
2019-06-18 12:19:40 +02:00
Max Kellermann a17f420d6b pcm/Export: update API documentation 2019-06-18 12:19:40 +02:00
Max Kellermann bf26adf555 pcm/Dsd{16,32}: stash odd frames away for the next call
Similar to commit 32380d1db0, these are
the final parts for really fixing
https://github.com/MusicPlayerDaemon/MPD/issues/469
2019-06-18 11:19:27 +02:00
Max Kellermann 0cc94fe30c pcm/Dsd{16,32}: convert public function to stateful class 2019-06-18 10:58:55 +02:00
Max Kellermann d5d5705213 pcm/Export: update API documentation 2019-06-18 10:58:26 +02:00