Bug 1194708 - Properly find SPS NAL in some H264 streams. r=kentuckyfriedtakahe, a=sledru
authorJean-Yves Avenard <jyavenard@mozilla.com>
Mon, 17 Aug 2015 10:28:12 +1000
changeset 288751 6b8ab5760fa7b92af3ca44a6bbc99da5d4e1ecd8
parent 288750 66976c6ac88a75acb18bd1055267013a4ba973fc
child 288752 881a6fc93a030135780e7c62421afa25dcf08c78
push id5067
push userraliiev@mozilla.com
push dateMon, 21 Sep 2015 14:04:52 +0000
treeherdermozilla-beta@14221ffe5b2f [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerskentuckyfriedtakahe, sledru
bugs1194708
milestone42.0a2
Bug 1194708 - Properly find SPS NAL in some H264 streams. r=kentuckyfriedtakahe, a=sledru 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