audio: Fix unsigned PCM conversion edge cases
Get series with b4
b4 am [email protected] change-id 20260423-audio-464e1e90304eVersions newest first
- v1 Latest3 patches 1 replyIn review
Patches in v1 No applies recorded yet
| # | Subject and files | Size | Replies | Applied |
|---|---|---|---|---|
| 1/3 | audio: Avoid unsigned sample wraparoundaudio/ | +2 | 0 replies | |
| 2/3 | audio: Clamp unsigned sample conversionaudio/ | +3 | 0 replies | |
| 3/3 | audio: Use unsigned PCM biasaudio/ | +7 | 0 replies |
Reviews trailers per patch
None of the 3 patches has a Reviewed-by or Acked-by of their own; the series has one for all of them.
| Patch | Marc-André Lureau |
|---|---|
| Series | A-b |
| 1/3 | |
| 2/3 | |
| 3/3 |
Trailers given in replies are filled; those carried in the patches from earlier versions are outlined with dashes.
Cover letter [PATCH 0/3] audio: Fix unsigned PCM conversion edge cases
Building QEMU with recent Clang from Xcode reports warnings in the unsigned 32-bit PCM clipping helper. The warning points at a real conversion issue: the current code mixes unsigned arithmetic, floating-point rounding, and the wrong midpoint for unsigned PCM samples.
Unsigned PCM uses a bias at the upper middle value of the sample range, such as 0x80, 0x8000, or 0x80000000. The existing HALF value names the lower middle value instead. Around that boundary, the conversion code can also wrap before promotion, and the uint32_t clipping helper can compute a value one past the representable range.
Fix the unsigned conversion paths by:
- converting before subtracting the bias, so samples below the midpoint do not wrap;
- clamping the floating-point clipping result to the integer endpoint;
- replacing HALF with an explicit BIAS value matching unsigned PCM.
---
Akihiko Odaki (3):
audio: Avoid unsigned sample wraparound
audio: Clamp unsigned sample conversion
audio: Use unsigned PCM bias
audio/mixeng_template.h | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-)
---
base-commit: 98b060da3a4f92b2a994ead5b16a87e783baf77c
change-id: 20260423-audio-464e1e90304e
Best regards,
Signature · 1 line
Akihiko Odaki <[email protected]>