From 3ae777f9736761a29df4869b1f48d93d24e2ffe6 Mon Sep 17 00:00:00 2001 From: Cameron Gutman Date: Sat, 24 Sep 2022 13:43:32 -0500 Subject: [PATCH] Try to recover if the frame header parsing fails --- src/VideoDepacketizer.c | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/src/VideoDepacketizer.c b/src/VideoDepacketizer.c index d781deb..579ae19 100644 --- a/src/VideoDepacketizer.c +++ b/src/VideoDepacketizer.c @@ -744,11 +744,15 @@ static void processRtpPayload(PNV_VIDEO_PACKET videoPacket, int length, // Other versions don't have a frame header at all } - // Assert that the 3 or 4 byte Annex B NALU prefix is next - LC_ASSERT(currentPos.data[currentPos.offset + 0] == 0); - LC_ASSERT(currentPos.data[currentPos.offset + 1] == 0); - LC_ASSERT(currentPos.data[currentPos.offset + 2] == 0 || currentPos.data[currentPos.offset + 2] == 1); - LC_ASSERT(currentPos.data[currentPos.offset + 3] == 1 || currentPos.data[currentPos.offset + 2] == 1); + // The Annex B NALU start prefix must be next + if (!getAnnexBStartSequence(¤tPos, NULL)) { + // If we aren't starting on a start prefix, something went wrong. + LC_ASSERT(false); + + // For release builds, we will try to recover by searching for one. + // This mimics the way most decoders handle this situation. + skipToNextNal(¤tPos); + } // If an AUD NAL is prepended to this frame data, remove it. // Other parts of this code are not prepared to deal with a