Bug 1027875 - Remove Annex B assertion; r=cpearce
authorAnthony Jones <ajones@mozilla.com>
Fri, 04 Jul 2014 20:31:19 +1200
changeset 192393 5c1a090ccc63e19bfb42b8425031a12ec1dec24b
parent 192392 8be7f28c5dddbc244f2deed033a0afa3b5b806a8
child 192394 00b90bfadaa25b12097f87c12cf90dcedca7e528
push id27086
push userttaubert@mozilla.com
push dateSun, 06 Jul 2014 16:11:25 +0000
treeherdermozilla-central@9f59e39f70a5 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerscpearce
bugs1027875
milestone33.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 1027875 - Remove Annex B assertion; r=cpearce
media/libstagefright/binding/AnnexB.cpp
media/libstagefright/binding/include/mp4_demuxer/ByteReader.h
--- a/media/libstagefright/binding/AnnexB.cpp
+++ b/media/libstagefright/binding/AnnexB.cpp
@@ -61,18 +61,19 @@ AnnexB::ConvertExtraDataToAnnexB(mozilla
 
   ByteReader reader(aExtraData);
   const uint8_t* ptr = reader.Read(5);
   if (ptr && ptr[0] == 1) {
     // Append SPS then PPS
     ConvertSPSOrPPS(reader, reader.ReadU8() & 31, &annexB);
     ConvertSPSOrPPS(reader, reader.ReadU8(), &annexB);
 
-    MOZ_ASSERT(!reader.Remaining());
+    // MP4Box adds extra bytes that we ignore. I don't know what they do.
   }
+  reader.DiscardRemaining();
 
   return annexB;
 }
 
 void
 AnnexB::ConvertSPSOrPPS(ByteReader& aReader, uint8_t aCount,
                         Vector<uint8_t>* aAnnexB)
 {
--- a/media/libstagefright/binding/include/mp4_demuxer/ByteReader.h
+++ b/media/libstagefright/binding/include/mp4_demuxer/ByteReader.h
@@ -17,16 +17,26 @@ public:
     : mPtr(&aData[0]), mRemaining(aData.length())
   {
   }
   ByteReader(const uint8_t* aData, size_t aSize)
     : mPtr(aData), mRemaining(aSize)
   {
   }
 
+  ~ByteReader()
+  {
+    MOZ_ASSERT(!mRemaining);
+  }
+
+  // Make it explicit if we're not using the extra bytes.
+  void DiscardRemaining() {
+    mRemaining = 0;
+  }
+
   size_t Remaining() const { return mRemaining; }
 
   bool CanRead8() { return mRemaining >= 1; }
 
   uint8_t ReadU8()
   {
     auto ptr = Read(1);
     if (!ptr) {