Bug 1540251 - Workaround unset NAL size in WebrtcGmpVideoEncoder::Encoded; r=pehrsons a=pascalc
authorDan Minor <dminor@mozilla.com>
Mon, 01 Apr 2019 13:47:29 +0000
changeset 526369 85db0015c02fafc0f57db709783898361b5201ec
parent 526368 c18c758f3e31c4a0b4a535fab4006a114c13acaa
child 526370 ded211603671be4210c80f5c2f17c0a4a5f9ceb7
push id2032
push userffxbld-merge
push dateMon, 13 May 2019 09:36:57 +0000
treeherdermozilla-release@455c1065dcbe [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerspehrsons, pascalc
bugs1540251
milestone67.0
Bug 1540251 - Workaround unset NAL size in WebrtcGmpVideoEncoder::Encoded; r=pehrsons a=pascalc OpenH264 1.8.1 occasionally generates a size of 0x01000000. This is a magic value in the NAL which should be replaced with a valid size, but for some reason this is not always happening. If we return early here, encoding will continue to work as expected. This workaround can be removed once this issue is addressed upstream, although that may require a new release of OpenH264. Differential Revision: https://phabricator.services.mozilla.com/D25468
media/webrtc/signaling/src/media-conduit/WebrtcGmpVideoCodec.cpp
--- a/media/webrtc/signaling/src/media-conduit/WebrtcGmpVideoCodec.cpp
+++ b/media/webrtc/signaling/src/media-conduit/WebrtcGmpVideoCodec.cpp
@@ -585,16 +585,26 @@ void WebrtcGmpVideoEncoder::Encoded(
 #else
           size = BigEndian::readUint32(buffer);
 #endif
           buffer += 4;
           break;
         default:
           MOZ_CRASH("GMP_BufferType already handled in switch above");
       }
+
+      // OpenH264 1.8.1 occasionally generates a size of 0x01000000.
+      // This is a magic value in the NAL which should be replaced with a
+      // valid size, but for some reason this is not always happening.
+      // If we return early here, encoding will continue to work as expected.
+      // See Bug 1533001.
+      if (size == 0x01000000) {
+        return;
+      }
+
       MOZ_ASSERT(size != 0 &&
                  buffer + size <=
                      end);  // in non-debug code, don't crash in this case
       if (size == 0 || buffer + size > end) {
         // XXX see above - should we kill the plugin for returning extra bytes?
         // Probably
         LOG(LogLevel::Error, ("GMP plugin returned badly formatted encoded "
                               "data: buffer=%p, size=%d, end=%p",