[FFmpeg-devel] [PATCH] Arithmetic decoding in ALS

Reimar Döffinger Reimar.Doeffinger
Sat Feb 6 10:03:25 CET 2010


On Tue, Jan 26, 2010 at 01:44:46AM +0100, Thilo Borgmann wrote:
> +//#define DEBUG

That's not used anywhere.

> +static const unsigned int cf_tables_1[3][129] = {

All tables seem to fit in 16 bit?

> +static const unsigned int *cf_table[16] = {

one const too few.

> +int bgmc_init(AVCodecContext *avctx, uint8_t **cf_lut, unsigned int **cf_lut_status);

global symbols all need either a ff_ or av_ prefix, ff_ is appropriate I guess.

> +static const unsigned int tail_code[16][6] = {

Fits in 8 bits?

> +        unsigned int B = av_clip((av_ceil_log2(bd->block_length) - 3) >> 1, 0, 5);

B is not a good name, not only looks it a lot like 8 with some fonts, uppercase is also
for macros.

> +            k    [sb] = s[sb] > B ? s[sb] - B : 0;

FFMAX(s[sb] - B, 0)
might be faster for some architectures at least.

> +                    if (res & 1)
> +                        res = -res - 1;
> +
> +                    res >>= 1;

Isn't that the usually "level + sign" coding? In that case there should be an
optimized function for MPEG coding, one of these days I have to search for it
and write it down...
Either way, if res has the lowest bit set, so does -res, so your -1 is just
unsetting the bit you shift away in the next step anyway.
Also, -res - 1 is equivalent to ~res, which might be faster than -res anyway.



More information about the ffmpeg-devel mailing list