Bug 1365227 - Enforce that ExtractExtra data works on AVCC only. r=JamesCheng, a=gchang
authorJean-Yves Avenard <jyavenard@mozilla.com>
Tue, 16 May 2017 14:51:24 +0200
changeset 394042 93e66a0ce8102ee500389ab819869b3ddfbaf1d6
parent 394041 dbb2acc72839c7bda047fd2be29182d3ced0b86b
child 394043 eac1fd1b0c992cb1124d438fe1be37972ccabc4d
push id7339
push userryanvm@gmail.com
push dateMon, 22 May 2017 18:17:11 +0000
treeherdermozilla-beta@5de3b1528ca0 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersJamesCheng, gchang
bugs1365227
milestone54.0
Bug 1365227 - Enforce that ExtractExtra data works on AVCC only. r=JamesCheng, a=gchang MozReview-Commit-ID: ox5oaDvdfx
media/libstagefright/binding/AnnexB.cpp
--- a/media/libstagefright/binding/AnnexB.cpp
+++ b/media/libstagefright/binding/AnnexB.cpp
@@ -251,45 +251,35 @@ AnnexB::ConvertSampleToAVCC(mozilla::Med
   }
   nsAutoPtr<MediaRawDataWriter> samplewriter(aSample->CreateWriter());
   return samplewriter->Replace(nalu.begin(), nalu.length());
 }
 
 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;