Replace MathUtil::Clamp with its std counterpart
This commit is contained in:
parent
14878a17d9
commit
7a3e126a4f
17 changed files with 49 additions and 72 deletions
|
@ -9,7 +9,6 @@
|
|||
#include "audio_core/codec.h"
|
||||
#include "common/assert.h"
|
||||
#include "common/common_types.h"
|
||||
#include "common/math_util.h"
|
||||
|
||||
namespace AudioCore {
|
||||
namespace Codec {
|
||||
|
@ -51,7 +50,7 @@ StereoBuffer16 DecodeADPCM(const u8* const data, const size_t sample_count,
|
|||
// Filter: y[n] = x[n] + 0.5 + c1 * y[n-1] + c2 * y[n-2]
|
||||
int val = ((xn << 11) + 0x400 + coef1 * yn1 + coef2 * yn2) >> 11;
|
||||
// Clamp to output range.
|
||||
val = MathUtil::Clamp(val, -32768, 32767);
|
||||
val = std::clamp(val, -32768, 32767);
|
||||
// Advance output feedback.
|
||||
yn2 = yn1;
|
||||
yn1 = val;
|
||||
|
|
|
@ -8,7 +8,6 @@
|
|||
#include "audio_core/hle/filter.h"
|
||||
#include "audio_core/hle/shared_memory.h"
|
||||
#include "common/common_types.h"
|
||||
#include "common/math_util.h"
|
||||
|
||||
namespace AudioCore {
|
||||
namespace HLE {
|
||||
|
@ -68,7 +67,7 @@ std::array<s16, 2> SourceFilters::SimpleFilter::ProcessSample(const std::array<s
|
|||
std::array<s16, 2> y0;
|
||||
for (size_t i = 0; i < 2; i++) {
|
||||
const s32 tmp = (b0 * x0[i] + a1 * y1[i]) >> 15;
|
||||
y0[i] = MathUtil::Clamp(tmp, -32768, 32767);
|
||||
y0[i] = std::clamp(tmp, -32768, 32767);
|
||||
}
|
||||
|
||||
y1 = y0;
|
||||
|
@ -102,7 +101,7 @@ std::array<s16, 2> SourceFilters::BiquadFilter::ProcessSample(const std::array<s
|
|||
std::array<s16, 2> y0;
|
||||
for (size_t i = 0; i < 2; i++) {
|
||||
const s32 tmp = (b0 * x0[i] + b1 * x1[i] + b2 * x2[i] + a1 * y1[i] + a2 * y2[i]) >> 14;
|
||||
y0[i] = MathUtil::Clamp(tmp, -32768, 32767);
|
||||
y0[i] = std::clamp(tmp, -32768, 32767);
|
||||
}
|
||||
|
||||
x2 = x1;
|
||||
|
|
|
@ -7,7 +7,6 @@
|
|||
#include "audio_core/hle/mixers.h"
|
||||
#include "common/assert.h"
|
||||
#include "common/logging/log.h"
|
||||
#include "common/math_util.h"
|
||||
|
||||
namespace AudioCore {
|
||||
namespace HLE {
|
||||
|
@ -87,7 +86,7 @@ void Mixers::ParseConfig(DspConfiguration& config) {
|
|||
}
|
||||
|
||||
static s16 ClampToS16(s32 value) {
|
||||
return static_cast<s16>(MathUtil::Clamp(value, -32768, 32767));
|
||||
return static_cast<s16>(std::clamp(value, -32768, 32767));
|
||||
}
|
||||
|
||||
static std::array<s16, 2> AddAndClampToS16(const std::array<s16, 2>& a,
|
||||
|
|
|
@ -4,7 +4,6 @@
|
|||
|
||||
#include "audio_core/interpolate.h"
|
||||
#include "common/assert.h"
|
||||
#include "common/math_util.h"
|
||||
|
||||
namespace AudioCore {
|
||||
namespace AudioInterp {
|
||||
|
@ -63,8 +62,8 @@ void Linear(State& state, StereoBuffer16& input, float rate, StereoFrame16& outp
|
|||
StepOverSamples(state, input, rate, output, outputi,
|
||||
[](u64 fraction, const auto& x0, const auto& x1, const auto& x2) {
|
||||
// This is a saturated subtraction. (Verified by black-box fuzzing.)
|
||||
s64 delta0 = MathUtil::Clamp<s64>(x1[0] - x0[0], -32768, 32767);
|
||||
s64 delta1 = MathUtil::Clamp<s64>(x1[1] - x0[1], -32768, 32767);
|
||||
s64 delta0 = std::clamp<s64>(x1[0] - x0[0], -32768, 32767);
|
||||
s64 delta1 = std::clamp<s64>(x1[1] - x0[1], -32768, 32767);
|
||||
|
||||
return std::array<s16, 2>{
|
||||
static_cast<s16>(x0[0] + fraction * delta0 / scale_factor),
|
||||
|
|
|
@ -10,7 +10,6 @@
|
|||
#include "audio_core/time_stretch.h"
|
||||
#include "common/common_types.h"
|
||||
#include "common/logging/log.h"
|
||||
#include "common/math_util.h"
|
||||
|
||||
using steady_clock = std::chrono::steady_clock;
|
||||
|
||||
|
@ -20,7 +19,7 @@ constexpr double MIN_RATIO = 0.1;
|
|||
constexpr double MAX_RATIO = 100.0;
|
||||
|
||||
static double ClampRatio(double ratio) {
|
||||
return MathUtil::Clamp(ratio, MIN_RATIO, MAX_RATIO);
|
||||
return std::clamp(ratio, MIN_RATIO, MAX_RATIO);
|
||||
}
|
||||
|
||||
constexpr double MIN_DELAY_TIME = 0.05; // Units: seconds
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue