Commit 45d27a52 authored by Max Kellermann's avatar Max Kellermann

PcmUtils: add function PcmClampN()

parent d22acc59
...@@ -63,4 +63,16 @@ PcmClamp(U x) ...@@ -63,4 +63,16 @@ PcmClamp(U x)
return T(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 #endif
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment