H264 bitstream analysis
Posted: Mon May 19, 2014 12:41 am
[---------Access Unit--------------]
[nal][nal][nal][nal][nal][nal][nal]
[-----I Slice-----------------------]
header= 0x00 0x00 0x01
NAL=XY .. .. .. .. ..
XY= [0._._._|_._._._]
0 = forbidden bit
[_._]= 2 bits, NRI (nal_ref_idc)
whether this NAL is referenced by another NAL. [0][0] can be discarded as the data it' not part of the picure
_|_._._._= 5 bits unit_type
Unit Type :
0 reserved
1-23 NAL unit Single NAL unit packet:
1 NAL_SLICE
2 NAL_SLICE_DPA
3 NAL_SLICE_DPB
4 NAL_SLICE_DPC
5 H264_NAL_SLICE_IDR
6 NAL_SEI
7 NAL_SPS
8 NAL_PPS
9 NAL_AU_DELIMITER ,
10 NAL_SEQ_END
11 NAL_STREAM_END
12 NAL_FILLER_DATA
24 STAP-A Single-time aggregation packet 5.7.1
25 STAP-B Single-time aggregation packet 5.7.1
26 MTAP16 Multi-time aggregation packet 5.7.2
27 MTAP24 Multi-time aggregation packet 5.7.2
28 FU-A Fragmentation unit 5.8
29 FU-B Fragmentation unit 5.8
30-31 reserved
In particular, the H.264 specification requires that the value of NRI SHALL be equal to 0 for all NAL units having nal_unit_type equal to 6, 9, 10, 11, or 12.
if type is 5, the data belongs to an Iframe !!!
For NAL units having nal_unit_type equal to 7 or 8 (indicating a sequence parameter set or a picture parameter set, respectively), an H.264 encoder SHOULD set the value of NRI to 11 (in binary format).
For coded slice NAL units of a primary coded picture having nal_unit_type equal to 5 (indicating a coded slice belonging to an IDR picture), an H.264 encoder SHOULD set the value of NRI to 11 (in binary format).
NAL_AU_DELIMITER = 9 is the Access Unit delimiter
The next byte after 00 00 001 09 XY
X = [D.C.B.A]
A=1
CB:
.......00 => start of I frame !
.......01 => start of P frame
.......10 => start of B frame
[nal][nal][nal][nal][nal][nal][nal]
[-----I Slice-----------------------]
header= 0x00 0x00 0x01
NAL=XY .. .. .. .. ..
XY= [0._._._|_._._._]
0 = forbidden bit
[_._]= 2 bits, NRI (nal_ref_idc)
whether this NAL is referenced by another NAL. [0][0] can be discarded as the data it' not part of the picure
_|_._._._= 5 bits unit_type
Unit Type :
0 reserved
1-23 NAL unit Single NAL unit packet:
1 NAL_SLICE
2 NAL_SLICE_DPA
3 NAL_SLICE_DPB
4 NAL_SLICE_DPC
5 H264_NAL_SLICE_IDR
6 NAL_SEI
7 NAL_SPS
8 NAL_PPS
9 NAL_AU_DELIMITER ,
10 NAL_SEQ_END
11 NAL_STREAM_END
12 NAL_FILLER_DATA
24 STAP-A Single-time aggregation packet 5.7.1
25 STAP-B Single-time aggregation packet 5.7.1
26 MTAP16 Multi-time aggregation packet 5.7.2
27 MTAP24 Multi-time aggregation packet 5.7.2
28 FU-A Fragmentation unit 5.8
29 FU-B Fragmentation unit 5.8
30-31 reserved
In particular, the H.264 specification requires that the value of NRI SHALL be equal to 0 for all NAL units having nal_unit_type equal to 6, 9, 10, 11, or 12.
if type is 5, the data belongs to an Iframe !!!
For NAL units having nal_unit_type equal to 7 or 8 (indicating a sequence parameter set or a picture parameter set, respectively), an H.264 encoder SHOULD set the value of NRI to 11 (in binary format).
For coded slice NAL units of a primary coded picture having nal_unit_type equal to 5 (indicating a coded slice belonging to an IDR picture), an H.264 encoder SHOULD set the value of NRI to 11 (in binary format).
NAL_AU_DELIMITER = 9 is the Access Unit delimiter
The next byte after 00 00 001 09 XY
X = [D.C.B.A]
A=1
CB:
.......00 => start of I frame !
.......01 => start of P frame
.......10 => start of B frame