Skip to content

Commit

Permalink
Complete the VP8 unmarshaller
Browse files Browse the repository at this point in the history
The unmarshaller was ignoring the scalability data.
  • Loading branch information
jech authored and zyxar committed May 12, 2021
1 parent 4997f55 commit 4e87540
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 7 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ Check out the **[contributing wiki](https://github.com/pion/webrtc/wiki/Contribu
* [lxb](https://github.com/lxb531)
* [Robin Raymond](https://github.com/robin-raymond)
* [debiandebiandebian](https://github.com/debiandebiandebian)
* [Juliusz Chroboczek](https://github.com/jech)

### License
MIT License - see [LICENSE](LICENSE) for full text
35 changes: 28 additions & 7 deletions codecs/vp8_packet.go
Original file line number Diff line number Diff line change
Expand Up @@ -91,18 +91,23 @@ func (p *VP8Payloader) Payload(mtu int, payload []byte) [][]byte {
// VP8Packet represents the VP8 header that is stored in the payload of an RTP Packet
type VP8Packet struct {
// Required Header
X uint8 /* extended controlbits present */
N uint8 /* (non-reference frame) when set to 1 this frame can be discarded */
X uint8 /* extended control bits present */
N uint8 /* when set to 1 this frame can be discarded */
S uint8 /* start of VP8 partition */
PID uint8 /* partition index */

// Optional Header
I uint8 /* 1 if PictureID is present */
L uint8 /* 1 if TL0PICIDX is present */
T uint8 /* 1 if TID is present */
K uint8 /* 1 if KEYIDX is present */
// Extended control bits
I uint8 /* 1 if PictureID is present */
L uint8 /* 1 if TL0PICIDX is present */
T uint8 /* 1 if TID is present */
K uint8 /* 1 if KEYIDX is present */

// Optional extension
PictureID uint16 /* 8 or 16 bits, picture ID */
TL0PICIDX uint8 /* 8 bits temporal level zero index */
TID uint8 /* 2 bits temporal layer index */
Y uint8 /* 1 bit layer sync bit */
KEYIDX uint8 /* 5 bits temporal key frame index */

Payload []byte
}
Expand Down Expand Up @@ -152,11 +157,27 @@ func (p *VP8Packet) Unmarshal(payload []byte) ([]byte, error) {
}
}

if payloadIndex >= payloadLen {
return nil, errShortPacket
}

if p.L == 1 {
p.TL0PICIDX = payload[payloadIndex]
payloadIndex++
}

if payloadIndex >= payloadLen {
return nil, errShortPacket
}

if p.T == 1 || p.K == 1 {
if p.T == 1 {
p.TID = payload[payloadIndex] >> 6
p.Y = (payload[payloadIndex] >> 5) & 0x1
}
if p.K == 1 {
p.KEYIDX = payload[payloadIndex] & 0x1F
}
payloadIndex++
}

Expand Down

0 comments on commit 4e87540

Please sign in to comment.