pcm_volume: implemented 32 bit support

Support 32 bit samples with software mixer.
This commit is contained in:
Max Kellermann
2009-11-19 21:00:50 +01:00
parent 5a480137d2
commit 1358428031
3 changed files with 43 additions and 0 deletions

View File

@@ -38,4 +38,18 @@ pcm_range(int32_t sample, unsigned bits)
return sample;
}
/**
* Check if the value is within the range of the provided bit size,
* and caps it if necessary.
*/
static inline int64_t
pcm_range_64(int64_t sample, unsigned bits)
{
if (G_UNLIKELY(sample < ((int64_t)-1 << (bits - 1))))
return (int64_t)-1 << (bits - 1);
if (G_UNLIKELY(sample >= ((int64_t)1 << (bits - 1))))
return ((int64_t)1 << (bits - 1)) - 1;
return sample;
}
#endif