none
Question Regarding parsing of Sequence Parameter set in H.264

    Question

  • Hi

    I started parsing a H.264 stream and got a Nal Unit type of 7 (Sequence parameter set).

    Now when i start parsing this (Sequence parameter set) i parsed profile_idc(8 bit), level_idc (8 bit), constraints flag (1 bit each) etc.

    When i come to  seq_parameter_set_id in specs it is given as ue(v) which indicates it is coded in

    ExGolomb fashion. To decipher this i don't know how much bits to read to

    decode  seq_parameter_set_id. It says that it can have a value in between 0 to 31. But how many
     
    bits does it take ?(like profile and level_idc take 8 bits each).

    Waiting for a reply...

    Thanks in advance

     

     

     

    Friday, March 27, 2009 9:28 AM

Answers

  • It's variable-length. Go back and read the spec again and it will become clear eventually. It's a scheme to ensure that smaller numbers take fewer bits (at the cost of ensuring that larger numbers take more bits). To decode it, you need something like this (where GetWord(n) returns the next n bits from the input stream).

    unsigned long  
    NALUnit::GetUE() 
        // Exp-Golomb entropy coding: leading zeros, then a one, then 
        // the data bits. The number of leading zeros is the number of 
        // data bits, counting up from that number of 1s as the base. 
        // That is, if you see 
        //      0001010 
        // You have three leading zeros, so there are three data bits (010) 
        // counting up from a base of 111: thus 111 + 010 = 1001 = 9 
        int cZeros = 0
        while (GetBit() == 0) 
        { 
            cZeros++; 
        } 
        return GetWord(cZeros) + ((1 <cZeros)-1); 
     

    • Marked as answer by gk00ei24 Friday, March 27, 2009 11:05 AM
    Friday, March 27, 2009 10:08 AM

All replies

  • It's variable-length. Go back and read the spec again and it will become clear eventually. It's a scheme to ensure that smaller numbers take fewer bits (at the cost of ensuring that larger numbers take more bits). To decode it, you need something like this (where GetWord(n) returns the next n bits from the input stream).

    unsigned long  
    NALUnit::GetUE() 
        // Exp-Golomb entropy coding: leading zeros, then a one, then 
        // the data bits. The number of leading zeros is the number of 
        // data bits, counting up from that number of 1s as the base. 
        // That is, if you see 
        //      0001010 
        // You have three leading zeros, so there are three data bits (010) 
        // counting up from a base of 111: thus 111 + 010 = 1001 = 9 
        int cZeros = 0
        while (GetBit() == 0) 
        { 
            cZeros++; 
        } 
        return GetWord(cZeros) + ((1 <cZeros)-1); 
     

    • Marked as answer by gk00ei24 Friday, March 27, 2009 11:05 AM
    Friday, March 27, 2009 10:08 AM
  • Thanx Geraint....
    Friday, March 27, 2009 11:01 AM