codec/h264/lex.go: merge logic for start end packet writing into first if

This commit is contained in:
Saxon 2019-05-24 10:38:06 +09:30
parent 04cd2e66ff
commit 5dfff61887
1 changed files with 4 additions and 8 deletions

View File

@ -266,24 +266,20 @@ func (l *RTPLexer) handleFUA(d []byte) {
// If start, form new header, skip FU indicator only and set first byte to
// new header. Otherwise, skip over both FU indicator and FU header.
if start {
if end {
panic("bad fragmentation packet")
}
const FUIndicatorIdx = 0
newHead := (d[FUIndicatorIdx] & 0xe0) | (d[FUHeadIdx] & 0x1f)
d = d[1:]
d[0] = newHead
} else {
d = d[2:]
}
if start {
if end {
panic("bad fragmentation packet")
}
l.frag = true
l.writeWithPrefix(d)
} else {
if end {
l.frag = false
}
d = d[2:]
l.writeNoPrefix(d)
}
}