diff --git a/codec/h265/lex.go b/codec/h265/lex.go index cf65b3fe..06b7dcb2 100644 --- a/codec/h265/lex.go +++ b/codec/h265/lex.go @@ -147,24 +147,24 @@ func (l *Lexer) handleAggregation(d []byte) { // handleFragmentation parses NAL units from fragmentation packets and writes // them to the Lexer's buf. func (l *Lexer) handleFragmentation(d []byte) { - _d := d[3:] - if l.donl { - _d = d[5:] - } - // Get start and end indiciators from FU header. start := d[2]&0x80 != 0 end := d[2]&0x40 != 0 + d = d[3:] + if l.donl { + d = d[2:] + } + switch { case start && !end: l.frag = true - l.writeWithPrefix(_d) + l.writeWithPrefix(d) case !start && end: l.frag = false fallthrough case !start && !end: - l.writeNoPrefix(_d) + l.writeNoPrefix(d) default: panic("bad fragmentation packet") }