PcmUtils: add function PcmClampN()

This commit is contained in:
Max Kellermann 2013-11-22 23:00:39 +01:00
parent d22acc59c9
commit 45d27a52f1

View File

@ -63,4 +63,16 @@ PcmClamp(U x)
return T(x);
}
/**
* Check if the values in this buffer are within the range of the
* provided bit size, and clamps them whenever necessary.
*/
template<typename T, typename U, unsigned bits>
static inline void
PcmClampN(T *dest, const U *src, unsigned n)
{
while (n-- > 0)
*dest++ = PcmClamp<T, U, bits>(*src++);
}
#endif