MCPcopy
hub / github.com/q191201771/lal / Annexb2Avcc

Function Annexb2Avcc

pkg/avc/avc.go:556–566  ·  view source on GitHub ↗
(nals []byte)

Source from the content-addressed store, hash-verified

554}
555
556func Annexb2Avcc(nals []byte) ([]byte, error) {
557 // TODO(chef): 增加原地转换,不申请内存的方式。考虑原地内存不够大的情况 202206
558 var buf nazabytes.Buffer
559 buf.Grow(len(nals) + 16) // perf: start code是三字节0 0 1时,转换时每个nal会多需要一个字节,预先申请16个字节,减少后续扩容的可能性
560 err := IterateNaluAnnexb(nals, func(nal []byte) {
561 bele.BePutUint32(buf.ReserveBytes(4), uint32(len(nal)))
562 buf.Flush(4)
563 _, _ = buf.Write(nal)
564 })
565 return buf.Bytes(), err
566}
567
568// ---------------------------------------------------------------------------------------------------------------------
569

Callers

nothing calls this directly

Calls 5

WriteMethod · 0.95
BytesMethod · 0.95
IterateNaluAnnexbFunction · 0.85
GrowMethod · 0.80
FlushMethod · 0.45

Tested by

no test coverage detected