|
From: <sv...@op...> - 2026-05-20 15:28:14
|
Author: manx Date: Wed May 20 17:28:03 2026 New Revision: 25332 URL: https://source.openmpt.org/browse/openmpt/?op=revision&rev=25332 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.30/ (props changed) branches/OpenMPT-1.30/src/openmpt/soundbase/SampleConvert.hpp Modified: branches/OpenMPT-1.30/src/openmpt/soundbase/SampleConvert.hpp ============================================================================== --- branches/OpenMPT-1.30/src/openmpt/soundbase/SampleConvert.hpp Wed May 20 17:13:20 2026 (r25331) +++ branches/OpenMPT-1.30/src/openmpt/soundbase/SampleConvert.hpp Wed May 20 17:28:03 2026 (r25332) @@ -171,7 +171,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); } @@ -252,7 +252,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))); } @@ -333,7 +333,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))); } @@ -414,7 +414,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)); } @@ -495,7 +495,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))); } @@ -576,7 +576,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_cast<int64>(SC::fastround(val)); } |