Author: sagamusix
Date: Sat Mar 16 22:06:39 2024
New Revision: 20380
URL: https://source.openmpt.org/browse/openmpt/?op=revision&rev=20380
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.28/ (props changed)
branches/OpenMPT-1.28/soundlib/plugins/dmo/Distortion.cpp
Modified: branches/OpenMPT-1.28/soundlib/plugins/dmo/Distortion.cpp
==============================================================================
--- branches/OpenMPT-1.28/soundlib/plugins/dmo/Distortion.cpp Sat Mar 16 22:05:58 2024 (r20379)
+++ branches/OpenMPT-1.28/soundlib/plugins/dmo/Distortion.cpp Sat Mar 16 22:06:39 2024 (r20380)
@@ -27,7 +27,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;
|