MathUtil: Convert Clamp into a constexpr function

This commit is contained in:
Lioncash
2015-09-11 23:43:17 -04:00
parent c5685ba53a
commit b9e360df7b
13 changed files with 43 additions and 70 deletions

View File

@@ -31,8 +31,7 @@ static s16 ADPDecodeSample(s32 bits, s32 q, s32& hist1, s32& hist2)
hist = (hist1 * 0x62) - (hist2 * 0x37);
break;
}
hist = (hist + 0x20) >> 6;
MathUtil::Clamp(&hist, -0x200000, 0x1fffff);
hist = MathUtil::Clamp((hist + 0x20) >> 6, -0x200000, 0x1fffff);
s32 cur = (((s16)(bits << 12) >> (q & 0xf)) << 6) + hist;
@@ -40,7 +39,7 @@ static s16 ADPDecodeSample(s32 bits, s32 q, s32& hist1, s32& hist2)
hist1 = cur;
cur >>= 6;
MathUtil::Clamp(&cur, -0x8000, 0x7fff);
cur = MathUtil::Clamp(cur, -0x8000, 0x7fff);
return (s16)cur;
}