下面介绍实际完成NAL解析工作的函数:
/**
* Parse an AVC AnnexB Bytestream bs to extract a single nalUnit
* while accumulating bytestream statistics into stats.
*
* If EOF occurs while trying to extract a NALunit, an exception
* of std::ios_base::failure is thrown. The contsnts of stats will
* be correct at this point.
*/
static void
_byteStreamNALUnit(
InputByteStream& bs,
vector<uint8_t>& nalUnit,
AnnexBStats& stats)
{
/* At the beginning of the decoding process, the decoder initialises its
* current position in the byte stream to the beginning of the byte stream.
* It then extracts and discards each leading_zero_8bits syntax element (if
* present), moving the current position in the byte stream forward one
* byte at a time, until the current position in the byte stream is such
* that the next four bytes in the bitstream form the four-byte sequence
* 0x00000001.
*/
while ((bs.e