Bug 1194708: Properly find SPS NAL in some H264 streams. r=kentuckyfriedtakahe
authorJean-Yves Avenard <jyavenard@mozilla.com>
Mon, 17 Aug 2015 10:28:12 +1000
changeset 257959 13b813170d8e2cf550518b0be8306d8db1ca62e5
parent 257958 a30421f03bc51317050c3970e5120ee063532436
child 257960 6fc3ec170fb24e211b579428edb255c67d1d363a
push id63781
push userjyavenard@mozilla.com
push dateMon, 17 Aug 2015 00:30:45 +0000
treeherdermozilla-inbound@6fc3ec170fb2 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerskentuckyfriedtakahe
bugs1194708
milestone43.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 1194708: Properly find SPS NAL in some H264 streams. r=kentuckyfriedtakahe With some encoding, we didn't detect the SPS. With AVC3 stream it would cause playback to never start on mac or linux (ffmpeg)
media/libstagefright/binding/AnnexB.cpp
--- a/media/libstagefright/binding/AnnexB.cpp
+++ b/media/libstagefright/binding/AnnexB.cpp
@@ -269,27 +269,27 @@ AnnexB::ExtractExtraData(const mozilla::
   while (reader.Remaining() > nalLenSize) {
     uint32_t nalLen;
     switch (nalLenSize) {
       case 1: nalLen = reader.ReadU8();  break;
       case 2: nalLen = reader.ReadU16(); break;
       case 3: nalLen = reader.ReadU24(); break;
       case 4: nalLen = reader.ReadU32(); break;
     }
-    uint8_t nalType = reader.PeekU8();
+    uint8_t nalType = reader.PeekU8() & 0x1f;
     const uint8_t* p = reader.Read(nalLen);
     if (!p) {
       return extradata.forget();
     }
 
-    if (nalType == 0x67) { /* SPS */
+    if (nalType == 0x7) { /* SPS */
       numSps++;
       spsw.WriteU16(nalLen);
       spsw.Write(p, nalLen);
-    } else if (nalType == 0x68) { /* PPS */
+    } else if (nalType == 0x8) { /* PPS */
       numPps++;
       ppsw.WriteU16(nalLen);
       ppsw.Write(p, nalLen);
     }
   }
 
   if (numSps && sps.length() > 5) {
     extradata->AppendElement(1);        // version