Breif Description of nal_ref_idc Value in H.246 NALU

I am so sorry for my late update because of my study!

A quick update from me: I have actually stopped working on H.264 and MP4 for some time but I hope my articles can help some of the beginners.

As in the article Introduction to H.264: (1) NAL Unit, Suji Mani asked what is the exact meaning of different values in nal_ref_idc. In fact, nal_ref_idc is base on “Start Code Value” and represents the priority of the current frame (i.e. how important of the frame – the higher the value, the more important the frame). Here is a list of nal_ref_idc values with the corresponding Start Code Type:

Start Code Type nal_ref_idc values (in binary) nal_ref_idc values (in decimal)
 Sequence header 11 3
 Picture header of I-frame 11 3
 Slice data of I-frame 11 3
 Picture header of P-frame 10 2
 Slice data of P-frame 10 2
 Picture header of B-frame 01 1
 Slice data of B-frame 01 1
 Video extension start code 00 0
 User data start code 00 0
 Video edit start code 00 0

Let me clarify a bit. nal_ref_idc is actually telling you what is the type of the current frame, which implies that what information you could get in this frame.

The example in Introduction to H.264: (1) NAL Unit is the beginning of a H.246 raw data. Let’s check the example again.

An excerpt of a h.264 stream
Figure 1: A sample of raw H.264 in byte stream format
HexBinary
0x670110 0111

forbidden_zero_bit = 0,

nal_ref_idc = 3,

nal_unit_type = 7 (Sequence Parameter Set, SPS)

As this is the beginning of a h.264 raw data, it is reasonable to say the first frame is a SPS (i.e. Start Code Type is Sequence Header). Hence, we have nal_ref_idc = 3.

I hope this helps.

15 thoughts on “Breif Description of nal_ref_idc Value in H.246 NALU”

  1. Hi Yumi,

    I am new in H.264 so actually I’m studying the structure of the H.264 NALUs.
    I took a lot of samples of transport streams coming from satellite and terrestrial platforms. Full many a time there are no IDR pictures in the streams at all (NALU=0x65)!
    Why is it? In this case how can the decoders find the entry point?

    Thanks,
    Peter

      1. Hi Yumi,
        Do you mean that 0x65, 0x45, 0x25 are all IDR frames? Ok, but what is the difference between them? And what about the statement that nal_ref_idc represents the current priority of the frame? What is the difference between these IDR frames from the decoding aspect?
        Regards,
        Peter

        1. Do you mean that 0x65, 0x45, 0x25 are all IDR frames?
          -> Yes, or No.
          If you just check the last 5 bits, then Yes.

          However, from my understanding, 0x45 & 0x25 should never exist because I-frame should always have nal_ref_idc = 3. And since I-frame is a key frame, it makes sense to have nal_ref_idc = 3.

          Have you ever seen 0x45 & 0x25 so you have such doubt?

          1. I took a sample of the Hungarian terrestrial transmission MUX and in some services I found only 00 00 01 45 …. sequence but never 00 00 01 65 …. (H.264 1440 x 1080 HD video).

            1. I read the standard again. For the whole doc, it seems that it only cares about whether nal_ref_idc is 0. So, I guess a slice can be successfully decoded, no matter it is 1 or 3. It may just give extra information to the decoder saying that some reference frame is more important than the others, but does not affect the decoding process.

              I haven’t encounter such problem yet so I can’t tell.

              I wonder if you can find any slice with nal_ref_idc = 3, says 0x6X / 0x7X?

  2. For interpretation of SEI messages, the values of the parameters of the picture parameter set and sequence parameter set that are active for the operation of the decoding process for the VCL NAL units of the primary coded picture in the same access unit shall be considered in effect unless otherwise specified in the SEI message semantics.

  3. Hey what i was trying to do is try to differ the non reference frames from the reference frames . I wanted to take all the data required for the non reference frames . Store them in a defenite structures and then use this data later for decoding these frames. Any guidance on how I should go about this whole situation . What data should i be storing so that it can be reused for decoding of these non reference pictures. I am new to the h264 decoder and have worked only on the VP9 codec so if you could tell me where and what to look for would save me a lot of research time.

  4. Hi yumi.
    I am totally newbie for H.264.

    Can you please tell me how to decode this SPS data. I am not able to decode SPS data after level_idc(1f).
    6742c01f8c8d40501e900f08846a

Leave a Reply

Your email address will not be published. Required fields are marked *