Bug 1365227: P1. Create AVCC header for converted annexB. r=JamesCheng
authorJean-Yves Avenard <jyavenard@mozilla.com>
Tue, 16 May 2017 14:22:43 +0200
changeset 358711 02ce5318570c9a2fb28700b431a55305886cd0fa
parent 358710 9a0a00d865f40eec2da832356fa62bb45c271b87
child 358712 26cf15cc538922429751eb1171254bf2e4f5c4d3
push id42821
push userjyavenard@mozilla.com
push dateWed, 17 May 2017 09:56:39 +0000
treeherderautoland@26cf15cc5389 [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: P1. Create AVCC header for converted annexB. r=JamesCheng Otherwise AnnexB::IsAVCC will return false on those converted samples. MozReview-Commit-ID: 6OBV6L49InL
media/libstagefright/binding/AnnexB.cpp
--- a/media/libstagefright/binding/AnnexB.cpp
+++ b/media/libstagefright/binding/AnnexB.cpp
@@ -245,17 +245,35 @@ AnnexB::ConvertSampleToAVCC(mozilla::Med
   mozilla::Vector<uint8_t> nalu;
   ByteWriter writer(nalu);
   ByteReader reader(aSample->Data(), aSample->Size());
 
   if (!ParseNALUnits(writer, reader)) {
     return false;
   }
   nsAutoPtr<MediaRawDataWriter> samplewriter(aSample->CreateWriter());
-  return samplewriter->Replace(nalu.begin(), nalu.length());
+  if (!samplewriter->Replace(nalu.begin(), nalu.length())) {
+    return false;
+  }
+  // Create the AVCC header.
+  RefPtr<mozilla::MediaByteBuffer> extradata = new mozilla::MediaByteBuffer;
+  static const uint8_t kFakeExtraData[] = {
+    1 /* version */,
+    0x64 /* profile (High) */,
+    0 /* profile compat (0) */,
+    40 /* level (40) */,
+    0xfc | 3 /* nal size - 1 */,
+    0xe0 /* num SPS (0) */,
+    0 /* num PPS (0) */
+  };
+  if (!extradata->AppendElements(kFakeExtraData, ArrayLength(kFakeExtraData))) {
+    return false;
+  }
+  aSample->mExtraData = extradata;
+  return true;
 }
 
 already_AddRefed<mozilla::MediaByteBuffer>
 AnnexB::ExtractExtraData(const mozilla::MediaRawData* aSample)
 {
   RefPtr<mozilla::MediaByteBuffer> extradata = new mozilla::MediaByteBuffer;
   if (HasSPS(aSample->mExtraData)) {
     // We already have an explicit extradata, re-use it.