Exp.-Golomb codes of what order? If you need to analyze the H.264 bitstream (I mean the transport layer), you can write simple functions to access scecified bits in an infinite bitstream. Bits indexing from left to right.
inline u_dword get_bit(const u_byte * const base, u_dword offset)
{
return ((*(base + (offset >> 0x3))) >> (0x7 - (offset & 0x7))) & 0x1;
}
This function implements decoding of zero-range exp-Golomb codes (used in H.264).
u_dword DecodeUGolomb(const u_byte * const base, u_dword * const offset)
{
u_dword zeros = 0;
while (0 == get_bit(base, (*offset)++)) zeros++;
u_dword info = 1 << zeros;
for (s_dword i = zeros - 1; i >= 0; i--)
{
info |= get_bit(base, (*offset)++) << i;
}
return (info - 1);
}
u_dword means an unsigned integer of 4 bytes. u_byte means unsigned 1 byte integer.
Note that the first byte of each NAL block is a specified structure with a forbidden bit, a NAL reference, and a NAL type.
source
share