From 866b4633425a8684f8155625491a60af09d0ebec Mon Sep 17 00:00:00 2001 From: cptpcrd <31829097+cptpcrd@users.noreply.github.com> Date: Tue, 27 Sep 2022 11:53:24 -0400 Subject: [PATCH] Fix parsing of G bit in VP9 scalability structure Previously it would erroneously look at some of the reserved fields. --- codecs/vp9_packet.go | 2 +- codecs/vp9_packet_test.go | 19 +++++++++++++++++++ 2 files changed, 20 insertions(+), 1 deletion(-) diff --git a/codecs/vp9_packet.go b/codecs/vp9_packet.go index e2ffab79..63f05e12 100644 --- a/codecs/vp9_packet.go +++ b/codecs/vp9_packet.go @@ -435,7 +435,7 @@ func (p *VP9Packet) parseSSData(packet []byte, pos int) (int, error) { p.NS = packet[pos] >> 5 p.Y = packet[pos]&0x10 != 0 - p.G = (packet[pos]>>1)&0x7 != 0 + p.G = packet[pos]&0x8 != 0 pos++ NS := p.NS + 1 diff --git a/codecs/vp9_packet_test.go b/codecs/vp9_packet_test.go index 9591f22c..15205ef1 100644 --- a/codecs/vp9_packet_test.go +++ b/codecs/vp9_packet_test.go @@ -169,6 +169,25 @@ func TestVP9Packet_Unmarshal(t *testing.T) { Payload: []byte{}, }, }, + "ScalabilityStructureReserved": { + b: []byte{ + 0x0A, + (1 << 5) | (0 << 4) | (0 << 3) | (1 << 2) | (1 << 1) | 1, // NS:1 Y:0 G:0, reserved fields set to 1 + }, + pkt: VP9Packet{ + B: true, + V: true, + NS: 1, + Y: false, + G: false, + NG: 0, + Payload: []byte{}, + }, + }, + "ScalabilityStructure_ShortPacket0": { + b: []byte{0x0A, 0x10}, + err: errShortPacket, + }, "ScalabilityMissingWidth": { b: []byte("200"), err: errShortPacket,