[FFmpeg-cvslog] r21799 - in trunk/libavcodec: Makefile alsdec.c bgmc.c bgmc.h

Alex Converse alex.converse
Thu Feb 18 06:31:40 CET 2010


On Sat, Feb 13, 2010 at 1:24 PM, thilo.borgmann <subversion at mplayerhq.hu>wrote:

> Author: thilo.borgmann
> Date: Sat Feb 13 19:24:13 2010
> New Revision: 21799
>
> Log:
> Support arithmetic decoding in ALS.
>

Just a few things I noticed that seemed off...


> Modified: trunk/libavcodec/alsdec.c
>
> ==============================================================================
> --- trunk/libavcodec/alsdec.c   Sat Feb 13 19:23:46 2010        (r21798)
> +++ trunk/libavcodec/alsdec.c   Sat Feb 13 19:24:13 2010        (r21799)
> @@ -591,9 +617,15 @@ static int read_var_block_data(ALSDecCon
>
>     sb_length = bd->block_length >> log2_sub_blocks;
>
> -
>     if (sconf->bgmc) {
> -        // TODO: BGMC mode
> +        s[0] = get_bits(gb, 8 + (sconf->resolution > 1));
> +        for (k = 1; k < sub_blocks; k++)
> +            s[k] = s[k - 1] + decode_rice(gb, 2);
> +
> +        for (k = 0; k < sub_blocks; k++) {
> +            sx[k]   = s[k] & 0x0F;
> +            s [k] >>= 4;
> +        }
>     } else {
>         s[0] = get_bits(gb, 4 + (sconf->resolution > 1));
>         for (k = 1; k < sub_blocks; k++)
> @@ -697,9 +729,76 @@ static int read_var_block_data(ALSDecCon
>
>     // read all residuals
>     if (sconf->bgmc) {
> -        // TODO: BGMC mode
> +        unsigned int delta[sub_blocks];
> +        unsigned int k    [sub_blocks];
>

Can these be made fixed length arrays. The max value of sub_blocks is 8, no?


> +        unsigned int b = av_clip((av_ceil_log2(bd->block_length) - 3) >>
> 1, 0, 5);
> +        unsigned int i = start;
>
What is the function of this initialization (i = start)

+
> +        // read most significant bits
> +        unsigned int high;
> +        unsigned int low;
> +        unsigned int value;
> +
> +        ff_bgmc_decode_init(gb, &high, &low, &value);
> +
> +        current_res = bd->raw_samples + start;
> +
> +        for (sb = 0; sb < sub_blocks; sb++, i = 0) {
>
and this assignment (i = 0)?

+            k    [sb] = s[sb] > b ? s[sb] - b : 0;
> +            delta[sb] = 5 - s[sb] + k[sb];
> +
> +            ff_bgmc_decode(gb, sb_length, current_res,
> +                        delta[sb], sx[sb], &high, &low, &value,
> ctx->bgmc_lut, ctx->bgmc_lut_status);
> +
> +            current_res += sb_length;
> +        }
> +
> +        ff_bgmc_decode_end(gb);
> +
> +
> +        // read least significant bits and tails
> +        i = start;
>
And this one?


> +        current_res = bd->raw_samples + start;
> +
> +        for (sb = 0; sb < sub_blocks; sb++, i = 0) {
> +            unsigned int cur_tail_code = tail_code[sx[sb]][delta[sb]];
> +            unsigned int cur_k         = k[sb];
> +            unsigned int cur_s         = s[sb];
> +
> +            for (; i < sb_length; i++) {
> +                int32_t res = *current_res;
> +
> +                if (res == cur_tail_code) {
> +                    unsigned int max_msb =   (2 + (sx[sb] > 2) + (sx[sb] >
> 10))
> +                                          << (5 - delta[sb]);
> +
> +                    res = decode_rice(gb, cur_s);
> +
> +                    if (res >= 0) {
> +                        res += (max_msb    ) << cur_k;
> +                    } else {
> +                        res -= (max_msb - 1) << cur_k;
> +                    }
> +                } else {
> +                    if (res > cur_tail_code)
> +                        res--;
> +
> +                    if (res & 1)
> +                        res = -res;
> +
> +                    res >>= 1;
> +
> +                    if (cur_k) {
> +                        res <<= cur_k;
> +                        res  |= get_bits_long(gb, cur_k);
> +                    }
> +                }
> +
> +            *current_res++ = res;
> +            }
> +        }
>     } else {
> -        int32_t *current_res = bd->raw_samples + start;
> +        current_res = bd->raw_samples + start;
>
>         for (sb = 0; sb < sub_blocks; sb++, start = 0)
>             for (; start < sb_length; start++)
>
>
--Alex



More information about the ffmpeg-cvslog mailing list