Backed out changeset c079a5c658fb (bug 1930660) for causing Android build bustages in ycbcr_to_rgb565.cpp. CLOSED TREE

This commit is contained in:
Stanca Serban 2024-11-12 19:29:58 +02:00
parent e378558d37
commit b547f402cf
3 changed files with 26 additions and 3 deletions

View File

@ -122,8 +122,9 @@ void HRTFDatabase::getKernelsFromAzimuthElevation(
unsigned HRTFDatabase::indexFromElevationAngle(double elevationAngle) {
// Clamp to allowed range.
elevationAngle = std::clamp(elevationAngle, static_cast<double>(MinElevation),
static_cast<double>(MaxElevation));
elevationAngle =
mozilla::clamped(elevationAngle, static_cast<double>(MinElevation),
static_cast<double>(MaxElevation));
unsigned elevationIndex =
static_cast<int>(InterpolationFactor * (elevationAngle - MinElevation) /

View File

@ -90,7 +90,7 @@ nsReturnRef<HRTFKernel> HRTFKernel::createInterpolatedKernel(
if (!kernel1 || !kernel2) return nsReturnRef<HRTFKernel>();
MOZ_ASSERT(x >= 0.0 && x < 1.0);
x = std::clamp(x, 0.0f, 1.0f);
x = mozilla::clamped(x, 0.0f, 1.0f);
float sampleRate1 = kernel1->sampleRate();
float sampleRate2 = kernel2->sampleRate();

View File

@ -29,4 +29,26 @@ inline const T& XPCOM_MAX(const T& aA, const T& aB) {
return aA > aB ? aA : aB;
}
namespace mozilla {
template <class T>
inline const T& clamped(const T& aA, const T& aMin, const T& aMax) {
MOZ_ASSERT(aMax >= aMin,
"clamped(): aMax must be greater than or equal to aMin");
return XPCOM_MIN(XPCOM_MAX(aA, aMin), aMax);
}
} // namespace mozilla
template <class InputIterator, class T>
inline uint32_t NS_COUNT(InputIterator& aFirst, const InputIterator& aLast,
const T& aValue) {
uint32_t result = 0;
for (; aFirst != aLast; ++aFirst)
if (*aFirst == aValue) {
++result;
}
return result;
}
#endif // !defined(nsAlgorithm_h___)