On Sun, Jun 17, 2012 at 04:54:36PM +0200, Kostya Shishkov wrote:
> On Sun, Jun 17, 2012 at 03:01:40PM +0200, Diego Biurrun wrote:
> > On Sat, Jun 16, 2012 at 12:36:16PM +0200, Kostya Shishkov wrote:
> > > +static int arith_get_bit(ArithCoder *c)
> > > +{
> > > +    int range = c->high - c->low + 1;
> > > +    int bit   = (((c->value - c->low) << 1) + 1) / range;
> > > +
> > > +    if (bit)
> > > +        c->low += range >> 1;
> > > +    else
> > > +        c->high = c->low + (range >> 1) - 1;
> > > +
> > > +    arith_normalise(c);
> > > +
> > > +    return bit;
> > > +}
> > > +
> > > +static int arith_get_bits(ArithCoder *c, int bits)
> > > +{
> > > +    int range = c->high - c->low + 1;
> > > +    int val   = (((c->value - c->low + 1) << bits) - 1) / range;
> > > +    int prob  = range * val;
> > > +
> > > +    c->high   = ((prob + range) >> bits) + c->low - 1;
> > > +    c->low   += prob >> bits;
> > > +
> > > +    arith_normalise(c);
> > > +
> > > +    return val;
> > > +}
> > > +
> > > +static int arith_get_number(ArithCoder *c, int mod_val)
> > > +{
> > > +    int range = c->high - c->low + 1;
> > > +    int val   = ((c->value - c->low + 1) * mod_val - 1) / range;
> > > +    int prob  = range * val;
> > > +
> > > +    c->high   = (prob + range) / mod_val + c->low - 1;
> > > +    c->low   += prob / mod_val;
> > > +
> > > +    arith_normalise(c);
> > > +
> > > +    return val;
> > > +}
> > 
> > This would be easy to refactor in Haskell ;)
> 
> The question is why one should do that.

For fun of course :)

> > > +static av_cold int decode_end(AVCodecContext *avctx)
> > 
> > av_cold
> 
> ?
> 
> static av_colder int decode_end()
> or
> static av_frozen int decode_end()

lol, I'm blind - but if in doubt, I'd go for "colder", no need to
freeze it just yet ;)

> > I thought generic function names like decode_init/decode_end/decode_frame
> > should be avoided in modern code.  Should I make this an entry in the dev
> > docs?
> 
> As you like, I'll prefix them meanwhile.

Please harass me if I don't produce a patch soon...

Diego
_______________________________________________
libav-devel mailing list
[email protected]
https://lists.libav.org/mailman/listinfo/libav-devel

Reply via email to