1
Fork 0
mirror of https://github.com/jech/galene.git synced 2024-11-25 10:05:58 +01:00

Fix keyframe detection for VP8 and VP9.

This commit is contained in:
Juliusz Chroboczek 2024-04-14 15:35:53 +02:00
parent c0b755f82f
commit 26e0ac410f

View file

@ -266,10 +266,10 @@ func PacketFlags(codec string, buf []byte) (Flags, error) {
if err != nil {
return flags, err
}
flags.Start = vp8.S != 0 && vp8.PID == 0
flags.End = packet.Marker
flags.Keyframe = vp8.S != 0 && (vp8.Payload[0]&0x1) == 0
flags.Keyframe = vp8.S != 0 && vp8.PID == 0 &&
len(vp8.Payload) > 0 && (vp8.Payload[0]&0x1) == 0
flags.Pid = vp8.PictureID
flags.Tid = vp8.TID
flags.TidUpSync = flags.Keyframe || vp8.Y == 1
@ -289,7 +289,8 @@ func PacketFlags(codec string, buf []byte) (Flags, error) {
}
flags.Start = vp9.B
flags.End = vp9.E
if (vp9.Payload[0] & 0xc0) == 0x80 {
if vp9.B && len(vp9.Payload) > 0 &&
(vp9.Payload[0] & 0xc0) == 0x80 {
profile := (vp9.Payload[0] >> 4) & 0x3
if profile != 3 {
flags.Keyframe = (vp9.Payload[0] & 0xC) == 0