Bug 1231793: Part 1 - Added read functions for Little Endian integers to ByteReader.h. r=jya
☠☠ backed out by 52d290be7c7d ☠ ☠
authorLouis Christie <lchristie@mozilla.com>
Fri, 12 Feb 2016 14:40:08 +1300
changeset 320561 cd4fc7f2c80a3c54482e3c8d59245a861a033cd6
parent 320560 fb1b8c571e954c651918fa22172ec69af05469fa
child 320562 33d6f22d9b1f388219791679203bd9c63c630d1d
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 1 - Added read functions for Little Endian integers to ByteReader.h. r=jya
media/libstagefright/binding/include/mp4_demuxer/ByteReader.h
--- a/media/libstagefright/binding/include/mp4_demuxer/ByteReader.h
+++ b/media/libstagefright/binding/include/mp4_demuxer/ByteReader.h
@@ -82,31 +82,55 @@ public:
     auto ptr = Read(2);
     if (!ptr) {
       MOZ_ASSERT(false);
       return 0;
     }
     return mozilla::BigEndian::readUint16(ptr);
   }
 
+  int16_t ReadLE16()
+  {
+    auto ptr = Read(2);
+    if (!ptr) {
+      MOZ_ASSERT(false);
+      return 0;
+    }
+    return mozilla::LittleEndian::readInt16(ptr);
+  }
+
   uint32_t ReadU24()
   {
     auto ptr = Read(3);
     if (!ptr) {
       MOZ_ASSERT(false);
       return 0;
     }
     return ptr[0] << 16 | ptr[1] << 8 | ptr[2];
   }
 
   uint32_t Read24()
   {
     return (uint32_t)ReadU24();
   }
 
+  int32_t ReadLE24()
+  {
+    auto ptr = Read(3);
+    if (!ptr) {
+      MOZ_ASSERT(false);
+      return 0;
+    }
+    int32_t result = int32_t(ptr[2] << 16 | ptr[1] << 8 | ptr[0]);
+    if (result & 0x00800000u) {
+      result -= 0x1000000;
+    }
+    return result;
+  }
+
   bool CanRead32() { return mRemaining >= 4; }
 
   uint32_t ReadU32()
   {
     auto ptr = Read(4);
     if (!ptr) {
       MOZ_ASSERT(false);
       return 0;