[FFmpeg-devel] [PATCH] Function to parse Dirac sequence header

Kostya kostya.shishkov
Thu Nov 6 13:42:13 CET 2008


On Thu, Nov 06, 2008 at 11:15:47AM +0100, Diego Biurrun wrote:
> On Wed, Nov 05, 2008 at 11:22:01PM -0500, David Conrad wrote:
> >
> > This will be useful for both the dirac parser and ogg demuxer (and  
> > future native dirac decoder of course.)
> > Adapted from the soc repository.
> >
> > --- /dev/null
> > +++ b/libavcodec/dirac.c
> > @@ -0,0 +1,259 @@
> > +    /* framerate */
> > +    if (get_bits1(gb)) {
> > +        source->frame_rate_index = svq3_get_ue_golomb(gb);
> 
> This function is used in svq3.c, rv30.c, rv40.c and now dirac.c.
> Clearly, the svq3_ prefix is misleading and it should be renamed.
> 
> Does anybody have a suggestion for a better name?

Oh, I used one in RV* code.

I find those names misleading.
In reality it's called Elias Gamma code - read any good book on
data compression or excellent report by Peter Fenwick
(http://www.cs.auckland.ac.nz/~peter-f/FTPfiles/TechRep137.ps)

It's idea is to prefix each bit with another bit that signals
that this is the last bit of codeword, i.e.
(those examples are for illustrative purposes only, the real
 coding differs a bit - no leading zeroes coding, zero is not
 coded too).

 0 -> 0 0
01 -> 1 0 0 1
10 -> 1 1 0 0
11 -> 1 1 0 1

When signal and payload bits are separated into two groups like
 0 ->  0 0
01 -> 10 01
10 -> 10 10
11 -> 10 11
we get Gamma' (wider-known version of Elias code).

In original paper Golomb (which is funny to read), he describes
more sophisticated codes where prefix length may differ from
payload length (that's just a rule for recognizing them).

Why those committees call every variable-length code for integers
Golomb codes is a great mystery.
 
P.S. Rice codes is a special case of Golomb codes,
Rice(n) = Golomb(2^n).
 
> Diego




More information about the ffmpeg-devel mailing list