Bug 1231793: Part 2 - Added conversions to AudioSampleFormat.h. r=jya
☠☠ backed out by 52d290be7c7d ☠ ☠
authorLouis Christie <lchristie@mozilla.com>
Fri, 12 Feb 2016 14:40:13 +1300
changeset 320562 33d6f22d9b1f388219791679203bd9c63c630d1d
parent 320561 cd4fc7f2c80a3c54482e3c8d59245a861a033cd6
child 320563 a5a15d50a8e4f1c49bcc27ecab5ca9e5fa69392d
push id5913
push userjlund@mozilla.com
push dateMon, 25 Apr 2016 16:57:49 +0000
treeherdermozilla-beta@dcaf0a6fa115 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjya
bugs1231793
milestone47.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1231793: Part 2 - Added conversions to AudioSampleFormat.h. r=jya
dom/media/AudioSampleFormat.h
--- a/dom/media/AudioSampleFormat.h
+++ b/dom/media/AudioSampleFormat.h
@@ -91,29 +91,55 @@ FloatToAudioSample<float>(float aValue)
 template <> inline int16_t
 FloatToAudioSample<int16_t>(float aValue)
 {
   float v = aValue*32768.0f;
   float clamped = std::max(-32768.0f, std::min(32767.0f, v));
   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
 IntegerToAudioSample<float>(int16_t aValue)
 {
   return aValue / 32768.0f;
 }
 template <> inline int16_t
 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);
 
 template<>
 inline void
 ConvertAudioSample(int16_t aIn, int16_t & aOut)
 {