pub fn nal_units(stream: &[u8]) -> impl Iterator<Item = &[u8]>
Expand description
Splits a bitstream into NAL units.
This function is useful if you happen to have a H.264 bitstream and want to decode it frame by frame: You apply this function to the underlying stream and run your decoder on each returned slice, preferably ignoring isolated decoding errors.
In detail, given a bitstream like so (001
being the NAL start prefix code):
......001.........001......001.....
This function will return an iterator returning packets:
[001.......][001....][001.....]
In other words, any incomplete data at the beginning of the buffer is skipped, NAL units in the middle are split at their boundaries, the last packet is returned as-is.