Merge pull request #3994 from FearlessTobi/replace-clamp-functions

Remove MathUtil::Clamp and replace it with its std:: counterpart
This commit is contained in:
James Rowe
2018-08-02 11:08:07 -06:00
committed by GitHub
17 changed files with 69 additions and 82 deletions

View File

@@ -2,13 +2,13 @@
// Licensed under GPLv2 or any later version
// Refer to the license.txt file included.
#include <algorithm>
#include <array>
#include <cstddef>
#include "audio_core/hle/common.h"
#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 +68,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 +102,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;

View File

@@ -2,12 +2,11 @@
// Licensed under GPLv2 or any later version
// Refer to the license.txt file included.
#include <algorithm>
#include <cstddef>
#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,