short *samples = data;
int16_t *samples = data;
static int AC3_encode_frame(AVCodecContext *avctx,                            unsigned char *frame, int buf_size, void *data){    AC3EncodeContext *s = avctx->priv_data;    short *samples = data;    int i, j, k, v, ch;    int16_t input_samples[N];    int32_t mdct_coef[NB_BLOCKS][AC3_MAX_CHANNELS][N/2];    uint8_t exp[NB_BLOCKS][AC3_MAX_CHANNELS][N/2];    uint8_t exp_strategy[NB_BLOCKS][AC3_MAX_CHANNELS];    uint8_t encoded_exp[NB_BLOCKS][AC3_MAX_CHANNELS][N/2];    uint8_t bap[NB_BLOCKS][AC3_MAX_CHANNELS][N/2];    int8_t exp_samples[NB_BLOCKS][AC3_MAX_CHANNELS];    int frame_bits;    frame_bits = 0;    for(ch=0;ch<s->nb_all_channels;ch++) {        /* fixed mdct to the six sub blocks & exponent computation */        for(i=0;i<NB_BLOCKS;i++) {            int16_t *sptr;            int sinc;            /* compute input samples */            memcpy(input_samples, s->last_samples[ch], N/2 * sizeof(int16_t));            sinc = s->nb_all_channels;            sptr = samples + (sinc * (N/2) * i) + ch;            for(j=0;j<N/2;j++) {                v = *sptr;                input_samples[j + N/2] = v;                s->last_samples[ch][j] = v;                 sptr += sinc;            }            /* apply the MDCT window */            for(j=0;j<N/2;j++) {                input_samples[j] = MUL16(input_samples[j],                                          ac3_window[j]) >> 15;                input_samples[N-j-1] = MUL16(input_samples[N-j-1],                                              ac3_window[j]) >> 15;            }                    /* Normalize the samples to use the maximum available               precision */            v = 14 - log2_tab(input_samples, N);            if (v < 0)                v = 0;            exp_samples[i][ch] = v - 8;            lshift_tab(input_samples, N, v);            /* do the MDCT */            mdct512(mdct_coef[i][ch], input_samples);                        /* compute "exponents". We take into account the               normalization there */            for(j=0;j<N/2;j++) {                int e;                v = abs(mdct_coef[i][ch][j]);                if (v == 0)                    e = 24;                else {                    e = 23 - av_log2(v) + exp_samples[i][ch];                    if (e >= 24) {                        e = 24;                        mdct_coef[i][ch][j] = 0;                    }                }                exp[i][ch][j] = e;            }        }                compute_exp_strategy(exp_strategy, exp, ch, ch == s->lfe_channel);        /* compute the exponents as the decoder will see them. The           EXP_REUSE case must be handled carefully : we select the           min of the exponents */        i = 0;        while (i < NB_BLOCKS) {            j = i + 1;            while (j < NB_BLOCKS && exp_strategy[j][ch] == EXP_REUSE) {                exponent_min(exp[i][ch], exp[j][ch], s->nb_coefs[ch]);                j++;            }            frame_bits += encode_exp(encoded_exp[i][ch],                                     exp[i][ch], s->nb_coefs[ch],                                      exp_strategy[i][ch]);            /* copy encoded exponents for reuse case */            for(k=i+1;k<j;k++) {                memcpy(encoded_exp[k][ch], encoded_exp[i][ch],                        s->nb_coefs[ch] * sizeof(uint8_t));            }            i = j;        }    }    compute_bit_allocation(s, bap, encoded_exp, exp_strategy, frame_bits);    /* everything is known... let's output the frame */    output_frame_header(s, frame);            for(i=0;i<NB_BLOCKS;i++) {        output_audio_block(s, exp_strategy[i], encoded_exp[i],                            bap[i], mdct_coef[i], exp_samples[i], i);    }    return output_frame_end(s);}