NALU
H.264碼流在網(wǎng)絡(luò)中傳輸時(shí)實(shí)際是以NALU的形式進(jìn)行傳輸?shù)?
每個(gè)NALU
由一個(gè)字節(jié)的Header
和RBSP
組成.
NAL Header
- forbidden_zero_bit
forbidden_zero_bit shall be equal to 0.
-
nal_ref_idc
用于表示當(dāng)前NALU的重要性,值越大,越重要.
解碼器在解碼處理不過(guò)來(lái)的時(shí)候洁桌,可以丟掉重要性為0的NALU.
nal_ref_idc不等于0時(shí), NAL unit的內(nèi)容可能是SPS/PPS/參考圖像的片等.
nal_ref_idc等于0時(shí)呜师,NAL unit的內(nèi)容可能是非參考圖像的片等.
nal_ref_idc shall not be equal to 0 for sequence parameter set or picture parameter set NAL units.
When nal_ref_idc is equal to 0 for one slice or slice data partition NAL unit of a particular picture, it shall be equal to 0 for all slice and slice data partition NAL units of the picture.
SPS/PPS時(shí),nal_ref_idc不可為0.
當(dāng)某個(gè)圖像的片的nal_ref_id等于0時(shí)箫措,該圖像的所有片均應(yīng)等于0.
nal_ref_idc shall not be equal to 0 for IDR NAL units, i.e., NAL units with nal_unit_type equal to 5.
nal_ref_idc shall be equal to 0 for all NAL units having nal_unit_type equal to 6, 9, 10, 11, or 12.
- nal_unit_type
nal_unit_type specifies the type of RBSP data structure contained in the NAL unit as specified in Table 7-1.
nal_unit_type從是否包含VCL
層編碼數(shù)據(jù)分為VCL NAL units
和 non-VCL NAL units
.
VCL NAL units
中包含VCL
層編碼輸出的數(shù)據(jù), 而non-VCL NAL units
不包括.
VCL NAL units
常用的是nal_unit_type=5
和nal_unit_type=1
.
nal_unit_type=5
表明該NALU的類型是IDR的slice, 也表明該NALU所在圖像也屬于IDR幀.
nal_unit_type=1
時(shí)一般表示該NALU所在的幀是P幀.
RBSP(Raw Byte Sequence Payload)
A syntax structure containing an integer number of bytes that is
encapsulated in a NAL unit.
An RBSP is either empty or has the form of a string of data bits containing syntax
elements followed by an RBSP stop bit and followed by zero or more subsequent bits equal to 0.
- (RBSP) stop bit
A bit equal to 1 present within a raw byte sequence payload
(RBSP) after a string of data bits. The location of the end of the string of data bits within an RBSP can be identified by searching from the end of the RBSP for the RBSP stop bit, which is the last non-zero bit in the
RBSP.
stop bit用于標(biāo)示RBSP中數(shù)據(jù)部分的結(jié)束. 其后會(huì)填充0.
An RBSP is specified as an ordered sequence of bytes as follows.
The RBSP contains an SODB as follows.
- If the SODB is empty (i.e., zero bits in length), the RBSP is also empty.
- Otherwise, the RBSP contains the SODB as follows.
- The first byte of the RBSP contains the (most significant, left-most) eight bits of the SODB; the next byte of the RBSP shall contain the next eight bits of the SODB, etc., until fewer than eight bits of the SODB remain.
-
rbsp_trailing_bits( ) are present after the SODB as follows:
i) The first (most significant, left-most) bits of the final RBSP byte contains the remaining bits of the SODB, (if any)
ii) The next bit consists of a single rbsp_stop_one_bit equal to 1, and
iii) When the rbsp_stop_one_bit is not the last bit of a byte-aligned byte, one or more rbsp_alignment_zero_bit is present to result in byte alignment. - One or more cabac_zero_word 16-bit syntax elements equal to 0x0000 may be present in some RBSPs after the rbsp_trailing_bits( ) at the end of the RBSP.
SODB(String Of Data Bits):
最原始的編碼數(shù)據(jù)RBSP, 長(zhǎng)度不一定是8的倍數(shù),此時(shí)需要對(duì)齊.
RBSP: 在SODB的后面填加了結(jié)尾比特(RBSP trailing bits 一個(gè)bit“1”)若干比特“0”,以便字節(jié)對(duì)齊.
References:
14496-10.pdf
14496-15.pdf
http://blog.csdn.net/newthinker_wei/article/details/8748442
http://www.360doc.com/content/14/0520/17/17532616_379388909.shtml
http://www.samirchen.com/video-concept/