Skip to content

Commit

Permalink
Avoid usage of OBUElements in av1_packet_test
Browse files Browse the repository at this point in the history
It's deprecated.
  • Loading branch information
jech committed Apr 15, 2024
1 parent 38c65dc commit 437c45c
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 6 deletions.
2 changes: 2 additions & 0 deletions codecs/av1_packet.go
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,8 @@ func (p *AV1Packet) Unmarshal(payload []byte) ([]byte, error) {
return nil, err
}
p.OBUElements = elts
} else {
p.OBUElements = nil
}

return payload[1:], nil
Expand Down
24 changes: 18 additions & 6 deletions codecs/av1_packet_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -275,20 +275,32 @@ func TestAV1_Unmarshal(t *testing.T) {
}

av1Pkt := &AV1Packet{}
if _, err := av1Pkt.Unmarshal(av1Payload); err != nil {
av1Pkt.DontParseOBUElements = true
payload, err := av1Pkt.Unmarshal(av1Payload)
if err != nil {
t.Fatal(err)
}

t.Log(*av1Pkt)
if !reflect.DeepEqual(av1Pkt, &AV1Packet{
Z: false,
Y: true,
W: 2,
N: true,
OBUElements: [][]byte{
av1Payload[2:14],
av1Payload[14:],
},
DontParseOBUElements: true,
}) {
t.Fatal("AV1 Unmarshal didn't store the expected results in the packet")
t.Error("AV1 Unmarshal didn't store the expected results in the packet")
}

obus, err := av1Pkt.ParseOBUElements(payload)
if err != nil {
t.Fatal("ParseOBUElements: ", err)
}

if !reflect.DeepEqual(obus, [][]byte{
av1Payload[2:14],
av1Payload[14:],
}) {
t.Fatal("Unexpected value ParseOBUElements")
}
}

0 comments on commit 437c45c

Please sign in to comment.