Methods for Exp-Golomb CodeWord Construction and Parsing

1.2k Views Asked by At

I am working with OpenH264 Codec. OpenH264 is using Exp-Golomb Coding for header related information. I have studied several websites and gathered a little information about Exp-Golomb Coding. OpenH264 uses 4 types of Exp-Golomb coding methods. They are:

  • Ue [When values are only Non-Negative quantity]
  • Te [when values are only 1 or 0]
  • Se [when values are both negative and positive quantity]
  • Me [when values a standard code map is defined for values]

I have learnt how to Construct or Parse by Method Ue.

Syntax Format for Exp-Golomb(Ue) = [M-Zeros][1][INFO].

Construction: Suppose We have a Code_Num = 226.
Now,
M = floor(log2(Code_Num)) = floor(log2(226)) = 7
INFO = Code_Num + 1 - pow(2,M) = 226 + 1 - 128 = 99 = (1100011) in Binary
So,
CodeWord = 0000000 1 1100011 [M-zeros, 1 ignoring bit, INFO]

Parsing: Suppose We have a CodeWord = 000000011100011
Code_Num = pow(2,M) + INFO - 1 = 128 + 99 - 1 = 226

Now I can calculate Exp-Golomb(Ue). But I want to learn all the theories related Se, Te and Me. But I am unable to find any resources for other methods. Please help me.

1

There are 1 best solutions below

0
On

OpenH264 is an implementation of the H.264/AVC video codec.

AVC uses Exp-Golomb coding in it's various headers, all compatible encoders have to as well.

Also, te(v) stands for Truncated Exponential-golomb encoding.

Anyway, you can find information about reading signed Exponential-Golomb codes on the wiki page:

but a real quick tl;dr is the 0 = 1, 1 = 010, -1 = 011, etc.

as for this mess:

M = floor(log2(Code_Num)) = floor(log2(226)) = 7 INFO = Code_Num + 1 - pow(2,M) = 226 + 1 - 128 = 99 = (1100011) in Binary So, CodeWord = 0000000 1 1100011 [M-zeros, 1 ignoring bit, INFO]

That's not at all accurate, you're supposed to add 1 during encoding, and subtract 1 during decoding (for unsigned Exp-Golomb only), Signed Exp-Golomb uses a completely different system.

Edit:

Mapped Exp-Golomb is exactly the same as Unsigned Exp-Golomb, plus a table lookup.

Truncated Exp-Golomb is the same as standard RICE aka Unary coding, except the stop bit is 0.

If you don't feel like creating your own decoders/encoders, take a look at my project BitIO, because I've already written them, especially ReadRICE/WriteRICE, and ReadExpGolomb/WriteExpGolomb functions, BitIO on Github