mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 1231793: Part 2 - Added conversions to AudioSampleFormat.h. r=jya
This commit is contained in:
parent
0574df2777
commit
82110de2d4
@ -96,6 +96,19 @@ FloatToAudioSample<int16_t>(float aValue)
|
||||
return int16_t(clamped);
|
||||
}
|
||||
|
||||
template <typename T> T UInt8bitToAudioSample(uint8_t aValue);
|
||||
|
||||
template <> inline float
|
||||
UInt8bitToAudioSample<float>(uint8_t aValue)
|
||||
{
|
||||
return aValue * (static_cast<float>(2) / UINT8_MAX) - static_cast<float>(1);
|
||||
}
|
||||
template <> inline int16_t
|
||||
UInt8bitToAudioSample<int16_t>(uint8_t aValue)
|
||||
{
|
||||
return (int16_t(aValue) << 8) + aValue + INT16_MIN;
|
||||
}
|
||||
|
||||
template <typename T> T IntegerToAudioSample(int16_t aValue);
|
||||
|
||||
template <> inline float
|
||||
@ -109,6 +122,19 @@ IntegerToAudioSample<int16_t>(int16_t aValue)
|
||||
return aValue;
|
||||
}
|
||||
|
||||
template <typename T> T Int24bitToAudioSample(int32_t aValue);
|
||||
|
||||
template <> inline float
|
||||
Int24bitToAudioSample<float>(int32_t aValue)
|
||||
{
|
||||
return aValue / static_cast<float>(1 << 23);
|
||||
}
|
||||
template <> inline int16_t
|
||||
Int24bitToAudioSample<int16_t>(int32_t aValue)
|
||||
{
|
||||
return aValue / 256;
|
||||
}
|
||||
|
||||
template<typename SrcT, typename DstT>
|
||||
inline void
|
||||
ConvertAudioSample(SrcT aIn, DstT& aOut);
|
||||
|
Loading…
Reference in New Issue
Block a user