Commit Graph

358 Commits

Author SHA1 Message Date
Max Kellermann 914ad261ed pcm/meson.build: split libpcm into two
One basic library without dependencies, and one with heavy
dependencies like libsamplerate.
2020-01-18 20:08:23 +01:00
Max Kellermann 2817bf9e95 copyright year 2020 2020-01-18 19:23:49 +01:00
Max Kellermann a37d22de8a pcm/Convert: choose pcm2dsd float/integer according to dest_format 2020-01-17 19:15:44 +01:00
Max Kellermann 452e1c1a6f pcm/Convert: throw if !ENABLE_DSD 2020-01-17 19:15:28 +01:00
Max Kellermann 8db86e2820 Revert "pcm/Convert: add option to enable the integer-only dsd2pcm implementation"
This reverts commit c84bae739a.  A
configuration option is not necessary, because the PcmConvert
constructor knows already whether integer or floating point is needed.
2020-01-17 19:11:10 +01:00
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 release v0.21.17
-----BEGIN PGP SIGNATURE-----
 
 iQJEBAABCgAuFiEEA5IzWngIOJSkMBxDI26KWMbbRRIFAl34Bg0QHG1heEBtdXNp
 Y3BkLm9yZwAKCRAjbopYxttFEmOvD/4/gBb1kIOQduz+ZV79LHPGeqDoIJBm8VWg
 t9R1Mpt0flqC8+RcXFK/P0kUifBO5fu+a1DbHHijUvDNLYpUsCiXyxTpES9gGh54
 7djEeqi1suoLpMUt4zkUEHGTp2dGUTmyewE1TuF1sZi2xlPgOeWXEX7a0xWs4zdG
 WI4CojUSkQGVAI2XZ7xIKP1v368B9F6AbqTK4zkzjNbTCv5VfESGlxdde0NXqU2e
 /bjil1aT2kdcks3ddeT4llyGIUzn1PzOyA6LQvmVXLSAtz9Rr/hHA+qkR19a4CCt
 PXxE0xClhhmZglzPuES0sRqBbwG99dPzA1ajTOtielwMrlFx+OceRfUnfdgqpPqd
 HTkEzMGsQ2PMMbE8R9DF5GU8B9xAcnKMh2g3/9KGStbocGSFWahLRObkHEhC5uJu
 g5ncQio3o/AtlBirywn/lkd6CYRDvMheMVOTHtv4/ZN0hIONMXCb6u1SQfqnX7qb
 fRP2UP9VUpPI9MUfOn/0uqM8/zXb5SMRe78p9UIYCF+mEDST190VxsdMjiBp/Xug
 Pktlec72iyiNHCavp04nXkt2kBrfSIFFaAQ0Qlp4huRV1k3Ur672NHtwuPLv8ORH
 xLec8On6nWVuuu5kC0F+4KxTlu6u2CMwH+wVr7t/D4rrD1iVo39MtElTBawZZC6+
 8EapnNHyGg==
 =A+Dp
 -----END PGP SIGNATURE-----

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
Max Kellermann 96d74e77eb pcm/Dsd{16,32}: move the conversion loop to a separate function 2019-06-17 22:51:01 +02:00
Max Kellermann 28e07e900f pcm/Export: convert the DSD bools to an enum
These options are exclusive.
2019-06-17 22:35:00 +02:00
Max Kellermann 32380d1db0 pcm/Dop: stash odd frames away for the next call
First part of the "real" fix for
https://github.com/MusicPlayerDaemon/MPD/issues/469
2019-06-17 22:18:44 +02:00
Max Kellermann c9f1354e4d pcm/RestBuffer: new utility class 2019-06-17 22:18:41 +02:00
Max Kellermann e3f9e96eef pcm/Dop: convert public function to stateful class
Preparing to add more state.
2019-06-17 22:16:29 +02:00
Max Kellermann 8f9b3cbf0e pcm/Dop: add separate dsd_buffer for DSD_U16/32
The dop_buffer will be moved out soon.
2019-06-17 22:11:23 +02:00
Max Kellermann 458a1beed9 AudioFormat: move MAX_CHANNELS to pcm/ChannelDefs.hxx
Reduce header dependencies.
2019-06-17 22:11:08 +02:00
Max Kellermann 33f5e03e80 Merge branch 'v0.21.x' 2019-06-17 22:06:54 +02:00
Max Kellermann d478bdda8e pcm/Export: document that Export() may return an empty buffer 2019-06-17 21:07:29 +02:00
Max Kellermann e87f0ca771 pcm/Pcm*: drop more "Pcm" prefixes from source file names 2019-06-17 11:17:48 +02:00
Max Kellermann a139279575 Copyright year 2019 2019-06-17 11:17:30 +02:00
Max Kellermann 9fcd33cc8d pcm/Dop: move the conversion loop to separate function 2019-06-16 12:23:48 +02:00
Max Kellermann 96ff6b9b8b pcm/Dop: remove redundant `inline` keywords 2019-06-16 12:23:38 +02:00
Max Kellermann fd5e74dbd0 pcm/Pcm{Dop,Export}: drop "Pcm" prefix 2019-06-16 12:11:44 +02:00
Max Kellermann b64571f4a5 pcm/Export: update API documentation 2019-06-16 11:52:57 +02:00
Max Kellermann 6addc9d6e0 pcm/PcmConvert: remove unused attribute "dest_format" 2019-04-04 21:06:28 +02:00
Max Kellermann e78d825059 pcm/PcmConvert: eliminate Open() and Close()
Let the constructor and destructor do this.  This means that all users
have to be converted to allocate PcmConvert dynamically.
2019-04-04 21:01:08 +02:00
Max Kellermann f2cacaf6b6 AudioFormat, pcm/Dsd*: remove redundant `inline` keywords from `constexpr` functions 2019-03-08 10:29:03 +01:00
Max Kellermann c176d94598 system/ByteOrder: move to util/ 2019-03-08 10:21:10 +01:00
Max Kellermann ce49d99c2f check.h: remove obsolete header
Since we switched from autotools to Meson in commit
94592c1406, we don't need to include
`config.h` early to properly enable large file support.  Meson passes
the required macros on the compiler command line instead of defining
them in `config.h`.

This means we can include `config.h` at any time, whenever we want to
check its macros, and there are no ordering constraints.
2018-11-19 16:33:49 +01:00
Max Kellermann f5c9071494 *: copyright year 2018 2018-10-31 17:54:59 +01:00
Max Kellermann c97469283c pcm: build dsd2pcm only if -Dtest=true 2018-10-30 13:31:43 +01:00
Max Kellermann 804ccddf7e pcm/Clamp: convert to `constexpr` 2018-10-30 00:08:25 +01:00
Max Kellermann bb5918932b pcm/PcmUtils: rename to Clamp.hxx 2018-10-30 00:05:58 +01:00
Max Kellermann aa77bc323f pcm/FloatConvert: make IntegerToFloatSampleConvert::Convert() constexpr 2018-10-29 23:52:25 +01:00
Max Kellermann 9b6a2589e5 Merge branch 'v0.20.x' 2018-10-29 23:06:32 +01:00
Max Kellermann cc5fab28af pcm/FloatConvert: fix compile-time integer overflow for S32
The compile-time calculation for `factor` overflows because `1<<31`
cannot be represented by `int`.  By casting to `uintmax_t` first, we
can avoid this overflow.

Closes #380
2018-10-29 22:50:54 +01:00
Max Kellermann a3f7127e72 pcm/FloatConvert: use FloatToIntegerSampleConvert::factor for IntegerToFloatSampleConvert::factor 2018-10-29 22:50:06 +01:00
Max Kellermann b0a6a569df pcm/FloatConvert: add `static_assert` on the factor
This assertion currently fails for S32 due to integer overflow (#380).
2018-10-29 22:38:32 +01:00
Max Kellermann 94592c1406 build with Meson instead of autotools
So long, autotools!  This is my last MPD related project to migrate
away from it.  It has its strengths, but also very obvious weaknesses
and weirdnesses.  Today, many of its quirks are not needed anymore,
and are cumbersome and slow.  Now welcome our new Meson overlords!
2018-10-14 23:41:38 +02:00
Max Kellermann 863722545f player/CrossFade, ...: use lround() 2018-09-22 19:08:03 +02:00
Max Kellermann ec54754e22 Compiler.h: move to util/ 2018-08-20 16:19:17 +02:00
Max Kellermann 4d80419982 pcm/ConfiguredResampler: use struct ConfigData 2018-07-17 23:04:26 +02:00
Max Kellermann 5b192beaa5 config/Global: remove ConfigBlock::SetUsed() call, let caller do that
This fixes an old bug which caused the "unused" warnings to be
unreliable; only the first block in the list was marked as being
"used", no matter if it was really used, and the rest was never marked
as "used", suppressing all warnings for them.
2018-07-17 21:08:41 +02:00
Max Kellermann 816603fd9a config/Config*: rename files, drop "Config" prefix 2018-07-16 19:50:07 +02:00
Max Kellermann 86a37d0ed6 Main, pcm/SampleFormat, command/Error: remove obsolete GCC version checks 2018-07-16 11:04:05 +02:00
Max Kellermann 9a29d02e7e Merge branch 'v0.20.x' 2018-07-06 19:43:01 +02:00
Max Kellermann 6f3c0d0a60 AudioFormat: include cleanup 2018-07-06 19:35:31 +02:00
Max Kellermann b7dc3fae7c Merge branch 'v0.20.x' 2018-03-15 20:08:13 +01:00
Max Kellermann a2340c313f pcm/PcmDop: round down to the nearest multiple of 4 DSD bytes
There was a discrepancy between what was written to the buffer and the
size returned by pcm_dsd_to_dop(): the "for" loop uses num_frames/2,
rounding down, while the return value is num_samples which is
num_frames*channels, without rounding.  This could cause undefined
data at the end of the destination buffer if the source buffer size
was not aligned to multiples of 8 bytes (4 DSD bytes per channel).

The latter however can occur in the 0.21 branch after commit
a06bf388d9

Closes #233
2018-03-15 20:02:00 +01:00
Max Kellermann 37b07a5e7c pcm/PcmDop: use size_t 2018-03-15 20:00:14 +01:00
Max Kellermann 65bbb0e0aa release v0.20.17
-----BEGIN PGP SIGNATURE-----
 
 iQJEBAABCgAuFiEEA5IzWngIOJSkMBxDI26KWMbbRRIFAlqAMO0QHG1heEBtdXNp
 Y3BkLm9yZwAKCRAjbopYxttFEg8eD/49NlFvlNdkamgYvh7MI1Sn67yKAwQt+N51
 W0hVnmXwPoSg76gfWw8J9kVyQy/jEkaCxsPF/UuEbH5jzqAC0y8hwYVRkJaRc9wN
 ZfwHvLHeaUxQweoguEwRSREy4ZC4ImQOK+eAxI1R43mqxxyhko1Akc1NmRVWzYfv
 /FGmAjTi1U6FR/yDpdSFn1NdlPmIgZ4WDuRsDT2NrshX/Bb32FiyZBytvek2P8n/
 QNgXv18E4yWXSb+zBYhPy/eaKhGasyjI3cbht1F0hNW9Yo/BsFxDuwXrX1vNBaOS
 E3Dux4s/nfcJ4RMRjmrkFwXImCvxt7+AGfh8RYBXuwqMExXz2kZjIs4ZVvO7Nu9A
 pFDJQwRIojXMfk73LU/MEpmNNEXhvfQLYkrM7poSqYaOr8SWMszqSgNnnfq6+flB
 sJbstgAStI6lL0jy0HrtMTvPVEiAGh6wCvMy/r2G9XUAyw76ccOg7MaIldn0MHJv
 A51+GfRTi4ILH0ReL1BGAg9nG97uFmRAWGkfkhtyD540xGRk7x5R8/ml4zFogHN6
 SbrV0NPdwk+uFd0y2znQT2gWyjc0id4WEKEoHX+Gl6c5qtPIfrq+PQPyk9kR+u+i
 AxwqMoKQer6Ji5qnsvCiKSkaGGiVNivrZ11jDWNCZaKjmvlKlvj/P5GxbPpORorq
 v4ru/4vNXQ==
 =v4t8
 -----END PGP SIGNATURE-----

Merge tag 'v0.20.17'

release v0.20.17
2018-02-11 13:22:43 +01:00
Max Kellermann 6de92bb42b pcm/Order: fix size calculation with 8 channels
This was a buffer overflow bug which could cause MPD crahes when
playing back 8 channels with the ALSA output plugin.

Closes #216
2018-02-09 19:01:12 +01:00
Max Kellermann 4a120f8090 Merge branch 'v0.20.x' 2018-01-05 10:10:17 +01:00
Max Kellermann f6ec43b9ec pcm/Resampler: add virtual method Flush()
Wired to Filter::Flush().

Closes #153
2018-01-02 23:17:25 +01:00