Author: sagamusix
Date: Sat Mar 16 21:57:51 2024
New Revision: 20378
URL: https://source.openmpt.org/browse/openmpt/?op=revision&rev=20378
Log:
Merged revision(s) 20376 from trunk/OpenMPT:
[Fix] Distortion DMO: The UB fix in r15730 did not correspond to the actually observed behaviour, thus causing the Distortion plugin to sound different in some situations.
........
Modified:
branches/OpenMPT-1.30/ (props changed)
branches/OpenMPT-1.30/soundlib/plugins/dmo/DMOUtils.cpp
Modified: branches/OpenMPT-1.30/soundlib/plugins/dmo/DMOUtils.cpp
==============================================================================
--- branches/OpenMPT-1.30/soundlib/plugins/dmo/DMOUtils.cpp Sat Mar 16 21:57:34 2024 (r20377)
+++ branches/OpenMPT-1.30/soundlib/plugins/dmo/DMOUtils.cpp Sat Mar 16 21:57:51 2024 (r20378)
@@ -26,7 +26,12 @@
// Computes (log2(x) + 1) * 2 ^ (shiftL - shiftR) (x = -2^31...2^31)
float logGain(float x, int32 shiftL, int32 shiftR)
{
- uint32 intSample = static_cast<uint32>(static_cast<int64>(x));
+ uint32 intSample;
+ if(x <= static_cast<float>(int32_min) || x > static_cast<float>(int32_max))
+ intSample = static_cast<uint32>(int32_min);
+ else
+ intSample = static_cast<uint32>(static_cast<int32>(x));
+
const uint32 sign = intSample & 0x80000000;
if(sign)
intSample = (~intSample) + 1;
|