From 80cb0a2f3024b0deb1c18cb34a82377f3f7728d5 Mon Sep 17 00:00:00 2001 From: Juliusz Chroboczek Date: Sun, 3 Jan 2021 20:55:35 +0100 Subject: [PATCH] Simplify VP9 keyframe detection. --- rtpconn/rtpreader.go | 11 ++--------- 1 file changed, 2 insertions(+), 9 deletions(-) diff --git a/rtpconn/rtpreader.go b/rtpconn/rtpreader.go index 24fe72a..d405d9b 100644 --- a/rtpconn/rtpreader.go +++ b/rtpconn/rtpreader.go @@ -46,16 +46,9 @@ func isKeyframe(codec string, packet *rtp.Packet) (bool, bool) { profile := (vp9.Payload[0] >> 4) & 0x3 if profile != 3 { - if (vp9.Payload[0] & 0x8) != 0 { - return false, true - } - return (vp9.Payload[0] & 0x4) == 0, true - } else { - if (vp9.Payload[0] & 0x4) != 0 { - return false, true - } - return (vp9.Payload[0] & 0x2) == 0, true + return (vp9.Payload[0] & 0xC) == 0, true } + return (vp9.Payload[0] & 0x6) == 0, true case "video/h264": if len(packet.Payload) < 1 { return false, false