(nals []byte)
| 554 | } |
| 555 | |
| 556 | func 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 |
nothing calls this directly
no test coverage detected