1
Fork 0
mirror of https://github.com/jech/galene.git synced 2024-11-22 16:45:58 +01:00

Don't rewrite PID for VP9.

Rewriting is not useful for VP9, and even harmful, as it breaks the
offsets in the scalability structure.
This commit is contained in:
Juliusz Chroboczek 2021-08-03 22:51:14 +02:00
parent 48a9b10ce8
commit d96a48f805

View file

@ -234,7 +234,7 @@ type Flags struct {
Start bool Start bool
End bool End bool
Keyframe bool Keyframe bool
Pid uint16 Pid uint16 // only returned for VP8
Tid uint8 Tid uint8
Sid uint8 Sid uint8
TidUpSync bool TidUpSync bool
@ -295,7 +295,6 @@ func PacketFlags(codec string, buf []byte) (Flags, error) {
flags.Keyframe = (vp9.Payload[0] & 0x6) == 0 flags.Keyframe = (vp9.Payload[0] & 0x6) == 0
} }
} }
flags.Pid = vp9.PictureID
flags.Tid = vp9.TID flags.Tid = vp9.TID
flags.Sid = vp9.SID flags.Sid = vp9.SID
flags.TidUpSync = flags.Keyframe || vp9.U flags.TidUpSync = flags.Keyframe || vp9.U
@ -335,6 +334,7 @@ func RewritePacket(codec string, data []byte, setMarker bool, seqno uint16, delt
} }
} }
// only rewrite PID for VP8.
if strings.EqualFold(codec, "video/vp8") { if strings.EqualFold(codec, "video/vp8") {
x := (data[offset] & 0x80) != 0 x := (data[offset] & 0x80) != 0
if !x { if !x {
@ -355,22 +355,6 @@ func RewritePacket(codec string, data []byte, setMarker bool, seqno uint16, delt
data[offset+2] = (data[offset+2] + uint8(delta)) & 0x7F data[offset+2] = (data[offset+2] + uint8(delta)) & 0x7F
} }
return nil return nil
} else if strings.EqualFold(codec, "video/vp9") {
i := (data[offset] & 0x80) != 0
if !i {
return nil
}
m := (data[offset+1] & 0x80) != 0
if m {
pid := (uint16(data[offset+1]&0x7F) << 8) |
uint16(data[offset+2])
pid = (pid + delta) & 0x7FFF
data[offset+1] = 0x80 | byte((pid>>8)&0x7F)
data[offset+2] = byte(pid & 0xFF)
} else {
data[offset+1] = (data[offset+1] + uint8(delta)) & 0x7F
}
return nil
} }
return errUnsupportedCodec return errUnsupportedCodec