From 54825845e70de935f3adede4fbd4e01aad1a15b5 Mon Sep 17 00:00:00 2001 From: Cameron Gutman Date: Thu, 22 Sep 2022 21:51:11 -0500 Subject: [PATCH] Fix large frame header size for GFE 3.26 --- src/VideoDepacketizer.c | 25 ++++++++++++++++++------- 1 file changed, 18 insertions(+), 7 deletions(-) diff --git a/src/VideoDepacketizer.c b/src/VideoDepacketizer.c index 0dab632..d781deb 100644 --- a/src/VideoDepacketizer.c +++ b/src/VideoDepacketizer.c @@ -697,13 +697,24 @@ static void processRtpPayload(PNV_VIDEO_PACKET videoPacket, int length, // If this is the first packet, skip the frame header (if one exists) if (firstPacket) { - if (APP_VERSION_AT_LEAST(7, 1, 415)) { - // >= 7.1.415 - // The first IDR frame now has smaller headers than the rest. We seem to be able to tell - // them apart by looking at the first byte. It will be 0x81 for the long header and 0x01 - // for the short header. - // TODO: This algorithm seems to actually work on GFE 3.18 (first byte always 0x01), so - // maybe we could unify this codepath in the future. + if (APP_VERSION_AT_LEAST(7, 1, 446)) { + // >= 7.1.446 uses 2 different header lengths based on the first byte: + // 0x01 indicates an 8 byte header + // 0x81 indicates a 41 byte header + if (currentPos.data[0] == 0x01) { + currentPos.offset += 8; + currentPos.length -= 8; + } + else { + LC_ASSERT(currentPos.data[0] == (char)0x81); + currentPos.offset += 41; + currentPos.length -= 41; + } + } + else if (APP_VERSION_AT_LEAST(7, 1, 415)) { + // [7.1.415, 7.1.446) uses 2 different header lengths based on the first byte: + // 0x01 indicates an 8 byte header + // 0x81 indicates a 24 byte header if (currentPos.data[0] == 0x01) { currentPos.offset += 8; currentPos.length -= 8;