开发者

What does this H264 NAL Header Mean?

0000 0109 开发者_JAVA技巧1000 0001 6742 0020 e900 800c
3200 0001 68ce 3c80 0000 0001 6588 801a

As far as I know, 0000 01 is the start prefix code to identify a NAL Unit. What does "09 .... " mean? Is it the header type byte?


0x000001 is the NAL start prefix code (it can also be 0x00000001, depends on the encoder implementation). 0x09 is 0b00001001, which means F=0, NRI = 0, and type is 0b01001. That particular type is an access unit delimiter. Notice that it is immediately followed by another NAL unit defined by 0x67, which is a NAL type of 7, which is the sequence parameter set.

There's also the picture parameter set:

00 0001 68...

...and the start of a keyframe:

0000 0001 65...


The key reference to figuring out what kind of NAL you are looking at is http://www.itu.int/rec/T-REC-H.264-201304-S . Specifically, the table on page 63 (as of Jan 2014) lists all valid NAL types.

To figure out what you are looking out look at the first 4 bytes. If the NAL is in "Annex B" framing they will either be 00 00 01 or 00 00 00 01. This sequence is forbidden/suppressed within the H.264 bitstream so if you see it you know for certain that you are looking at the start of a NAL. The NAL type is the 5 low order bits after the 1. In code:

int nalType = p[2] == 1 ? (p[3] & 0x1f) : (p[4] & 0x1f);

Also in H.264 jargon IDR means I-frame and non-IDR means P or B frames.

With the above information we can look at the above stream and see an access unit delimiter, followed by an SPS, PPS, and first I-Frame.


    0000 0109 1000 0001 6742 0020 e900 800c
    3200 0001 68ce 3c80 0000 0001 6588 801a

-> 000001| 09 (AUD)| 10 | 000001 | 67(SPS) | xxxx (SPS data)
   xx | 000001 | 68 (PPS)| xxxx (PPS data)

AUD, SPS, PPS is type of NALU (Network Abstraction Layer Units) NALU have about 31 types.

09 AUD mean Access Unit Delimiter.

Access Unit Delimiter (AUD). An AUD is an optional NALU that can be use to delimit frames in an elementary stream. It is not required (unless otherwise stated by the container/protocol, like TS), and is often not included in order to save space, but it can be useful to finds the start of a frame without having to fully parse each NALU.

Check this answer for more information.

I also have a question about how to decode h264 stream (in iOS).


That defines the packet type. The format is:

+---------------+
|0|1|2|3|4|5|6|7|
+-+-+-+-+-+-+-+-+
|F|NRI|  Type   |
+---------------+

Are you sure this is an h.264 NAL header? From what you provided, this doesn't appear to be the header with the context you provided.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜