1
Fork 0
mirror of https://github.com/jech/galene.git synced 2024-11-13 20:25:57 +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 8bbf9d16d0
commit 42748d4ad8

View file

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