[FFmpeg-devel] [PATCH] AAC decoder

Robert Swain robert.swain
Mon Jun 2 13:33:57 CEST 2008


2008/4/2 Michael Niedermayer <michaelni at gmx.at>:
> On Tue, Apr 01, 2008 at 04:56:48PM +0200, Andreas ?man wrote:
>> +
>> +/**
>> + * Decode spectral data
>> + * reference: Table 4.50
>> + */
>> +static int spectral_data(AACContext * ac, GetBitContext * gb, const ics_struct * ics, const int cb[][64], int * icoef) {
>
>> +    static const int unsigned_cb[] = { 0, 0, 1, 1, 0, 0, 1, 1, 1, 1, 1 };
>
> unsigned_cb[x] == x&10
>
>
>> +    int i, k, g;
>> +    const uint16_t * offsets = ics->swb_offset;
>> +
>> +    for (g = 0; g < ics->num_window_groups; g++) {
>> +        for (i = 0; i < ics->max_sfb; i++) {
>> +            const int cur_cb = cb[g][i];
>> +            const int dim = cur_cb >= FIRST_PAIR_HCB ? 2 : 4;
>> +            int group;
>> +            if (cur_cb == INTENSITY_HCB2 || cur_cb == INTENSITY_HCB) {
>> +                continue;
>> +            }
>> +            if (cur_cb == NOISE_HCB) {
>> +                for (group = 0; group < ics->group_len[g]; group++) {
>> +                    for (k = offsets[i]; k < offsets[i+1]; k++)
>> +                        icoef[group*128+k] = av_random(&ac->random_state) & 0x0000FFFF;
>> +                }
>> +                continue;
>> +            }
>> +            if (cur_cb == ZERO_HCB) {
>> +                for (group = 0; group < ics->group_len[g]; group++) {
>> +                    memset(icoef + group * 128 + offsets[i], 0, (offsets[i+1] - offsets[i])*sizeof(int));
>> +                }
>> +                continue;
>> +            }
> [...]
>
>> +                                while (get_bits1(gb)) n++;
>> +                                ptr[j] = (1<<n) + get_bits(gb, n);
>> +                            }
>> +                        }
>> +                    }
>> +                    for (j = 0; j < dim; j++)
>> +                        icoef[group*128+k+j] = sign[j] * ptr[j];
>
> This is really ugly, so much unneeded code, reading signs in a temporary array
> copying values and then multplying and throwig the intermediate arrays away.

How about the attached patch? Any further suggestions?

Rob
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 20080602-1110-simplify_decode_spectral_data.diff
Type: text/x-diff
Size: 2796 bytes
Desc: not available
URL: <http://lists.mplayerhq.hu/pipermail/ffmpeg-devel/attachments/20080602/89a4864c/attachment.diff>



More information about the ffmpeg-devel mailing list