|
From: <sv...@op...> - 2026-05-20 15:12:54
|
Author: manx Date: Wed May 20 17:12:41 2026 New Revision: 25330 URL: https://source.openmpt.org/browse/openmpt/?op=revision&rev=25330 Log: Merged revision(s) 25329 from trunk/OpenMPT: [Fix] openmpt/soundbase/SampleConvert.hpp: Use mpt::safe_clamp instead of std::clamp also for double, and not only for float. ........ Modified: branches/OpenMPT-1.32/ (props changed) branches/OpenMPT-1.32/src/openmpt/soundbase/SampleConvert.hpp Modified: branches/OpenMPT-1.32/src/openmpt/soundbase/SampleConvert.hpp ============================================================================== --- branches/OpenMPT-1.32/src/openmpt/soundbase/SampleConvert.hpp Wed May 20 17:12:01 2026 (r25329) +++ branches/OpenMPT-1.32/src/openmpt/soundbase/SampleConvert.hpp Wed May 20 17:12:41 2026 (r25330) @@ -172,7 +172,7 @@ using output_t = uint8; MPT_FORCEINLINE output_t operator()(input_t val) { - val = std::clamp(val, -1.0, 1.0); + val = mpt::safe_clamp(val, -1.0, 1.0); val *= 128.0; return static_cast<uint8>(mpt::saturate_cast<int8>(static_cast<int>(SC::fastround(val))) + 0x80); } @@ -253,7 +253,7 @@ using output_t = int8; MPT_FORCEINLINE output_t operator()(input_t val) { - val = std::clamp(val, -1.0, 1.0); + val = mpt::safe_clamp(val, -1.0, 1.0); val *= 128.0; return mpt::saturate_cast<int8>(static_cast<int>(SC::fastround(val))); } @@ -334,7 +334,7 @@ using output_t = int16; MPT_FORCEINLINE output_t operator()(input_t val) { - val = std::clamp(val, -1.0, 1.0); + val = mpt::safe_clamp(val, -1.0, 1.0); val *= 32768.0; return mpt::saturate_cast<int16>(static_cast<int>(SC::fastround(val))); } @@ -415,7 +415,7 @@ using output_t = int24; MPT_FORCEINLINE output_t operator()(input_t val) { - val = std::clamp(val, -1.0, 1.0); + val = mpt::safe_clamp(val, -1.0, 1.0); val *= 2147483648.0; return static_cast<int24>(mpt::rshift_signed(mpt::saturate_cast<int32>(static_cast<int64>(SC::fastround(val))), 8)); } @@ -496,7 +496,7 @@ using output_t = int32; MPT_FORCEINLINE output_t operator()(input_t val) { - val = std::clamp(val, -1.0, 1.0); + val = mpt::safe_clamp(val, -1.0, 1.0); val *= 2147483648.0; return mpt::saturate_cast<int32>(static_cast<int64>(SC::fastround(val))); } @@ -577,7 +577,7 @@ using output_t = int64; MPT_FORCEINLINE output_t operator()(input_t val) { - val = std::clamp(val, -1.0, 1.0); + val = mpt::safe_clamp(val, -1.0, 1.0); val *= static_cast<double>(uint64(1) << 63); return mpt::saturate_trunc<int64>(SC::fastround(val)); } |