Bug 1365227: P2. Enforce that ExtractExtra data works on AVCC only. r=JamesCheng
authorJean-Yves Avenard <jyavenard@mozilla.com>
Tue, 16 May 2017 14:51:24 +0200
changeset 358755 26cf15cc538922429751eb1171254bf2e4f5c4d3
parent 358754 02ce5318570c9a2fb28700b431a55305886cd0fa
child 358756 e8c5ff8e2c50223cd82977b7501c59ff2107ddb3
push id31838
push userkwierso@gmail.com
push dateWed, 17 May 2017 20:32:10 +0000
treeherdermozilla-central@b133ec74e3d0 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersJamesCheng
bugs1365227
milestone55.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 1365227: P2. Enforce that ExtractExtra data works on AVCC only. r=JamesCheng MozReview-Commit-ID: ox5oaDvdfx
media/libstagefright/binding/AnnexB.cpp
--- a/media/libstagefright/binding/AnnexB.cpp
+++ b/media/libstagefright/binding/AnnexB.cpp
@@ -269,45 +269,35 @@ AnnexB::ConvertSampleToAVCC(mozilla::Med
   }
   aSample->mExtraData = extradata;
   return true;
 }
 
 already_AddRefed<mozilla::MediaByteBuffer>
 AnnexB::ExtractExtraData(const mozilla::MediaRawData* aSample)
 {
+  MOZ_ASSERT(IsAVCC(aSample));
+
   RefPtr<mozilla::MediaByteBuffer> extradata = new mozilla::MediaByteBuffer;
   if (HasSPS(aSample->mExtraData)) {
     // We already have an explicit extradata, re-use it.
     extradata = aSample->mExtraData;
     return extradata.forget();
   }
 
-  if (IsAnnexB(aSample)) {
-    // We can't extract data from AnnexB.
-    return extradata.forget();
-  }
-
   // SPS content
   mozilla::Vector<uint8_t> sps;
   ByteWriter spsw(sps);
   int numSps = 0;
   // PPS content
   mozilla::Vector<uint8_t> pps;
   ByteWriter ppsw(pps);
   int numPps = 0;
 
-  int nalLenSize;
-  if (IsAVCC(aSample)) {
-    nalLenSize = ((*aSample->mExtraData)[4] & 3) + 1;
-  } else {
-    // We do not have an extradata, assume it's AnnexB converted to AVCC via
-    // ConvertSampleToAVCC.
-    nalLenSize = 4;
-  }
+  int nalLenSize = ((*aSample->mExtraData)[4] & 3) + 1;
   ByteReader reader(aSample->Data(), aSample->Size());
 
   // Find SPS and PPS NALUs in AVCC data
   while (reader.Remaining() > nalLenSize) {
     uint32_t nalLen;
     switch (nalLenSize) {
       case 1: nalLen = reader.ReadU8();  break;
       case 2: nalLen = reader.ReadU16(); break;