Bug 911050 - Use mfbt/Endian.h rather than a local version in WaveReader. r=doublec
authorMatthew Gregan <kinetik@flim.org>
Fri, 06 Sep 2013 18:31:50 +1200
changeset 145827 9c2f3fa9cd5c3bf060db90fde950efd9b35d333c
parent 145826 c9985bea4d215c7acbac2e1e7ec34f2e2b75d878
child 145828 906d05d7d8e0d62f282d6e645090a302a1b2b63a
push id25225
push useremorley@mozilla.com
push dateFri, 06 Sep 2013 14:32:11 +0000
treeherdermozilla-central@fff320870b20 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersdoublec
bugs911050
milestone26.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 911050 - Use mfbt/Endian.h rather than a local version in WaveReader. r=doublec
content/media/wave/WaveReader.cpp
--- a/content/media/wave/WaveReader.cpp
+++ b/content/media/wave/WaveReader.cpp
@@ -10,16 +10,17 @@
 #include "mozilla/dom/TimeRanges.h"
 #include "MediaDecoderStateMachine.h"
 #include "VideoUtils.h"
 #include "nsISeekableStream.h"
 
 #include <stdint.h>
 #include "mozilla/Util.h"
 #include "mozilla/CheckedInt.h"
+#include "mozilla/Endian.h"
 #include <algorithm>
 
 namespace mozilla {
 
 // Un-comment to enable logging of seek bisections.
 //#define SEEK_LOGGING
 
 #ifdef PR_LOGGING
@@ -65,51 +66,43 @@ static const uint16_t WAVE_FORMAT_ENCODI
 // We reject files with more than this number of channels if we're decoding for
 // playback.
 static const uint8_t MAX_CHANNELS = 2;
 
 namespace {
   uint32_t
   ReadUint32BE(const char** aBuffer)
   {
-    uint32_t result =
-      uint8_t((*aBuffer)[0]) << 24 |
-      uint8_t((*aBuffer)[1]) << 16 |
-      uint8_t((*aBuffer)[2]) << 8 |
-      uint8_t((*aBuffer)[3]);
+    uint32_t result = BigEndian::readUint32(*aBuffer);
     *aBuffer += sizeof(uint32_t);
     return result;
   }
 
   uint32_t
   ReadUint32LE(const char** aBuffer)
   {
-    uint32_t result =
-      uint8_t((*aBuffer)[3]) << 24 |
-      uint8_t((*aBuffer)[2]) << 16 |
-      uint8_t((*aBuffer)[1]) << 8 |
-      uint8_t((*aBuffer)[0]);
+    uint32_t result = LittleEndian::readUint32(*aBuffer);
     *aBuffer += sizeof(uint32_t);
     return result;
   }
 
   uint16_t
   ReadUint16LE(const char** aBuffer)
   {
-    uint16_t result =
-      uint8_t((*aBuffer)[1]) << 8 |
-      uint8_t((*aBuffer)[0]) << 0;
+    uint16_t result = LittleEndian::readUint16(*aBuffer);
     *aBuffer += sizeof(uint16_t);
     return result;
   }
 
   int16_t
   ReadInt16LE(const char** aBuffer)
   {
-    return static_cast<int16_t>(ReadUint16LE(aBuffer));
+    uint16_t result = LittleEndian::readInt16(*aBuffer);
+    *aBuffer += sizeof(int16_t);
+    return result;
   }
 
   uint8_t
   ReadUint8(const char** aBuffer)
   {
     uint8_t result = uint8_t((*aBuffer)[0]);
     *aBuffer += sizeof(uint8_t);
     return result;