Revision 7e0a284b libavcodec/ac3enc.c

View differences:

libavcodec/ac3enc.c
78 78
    int16_t  **band_psd;                        ///< psd per critical band
79 79
    int16_t  **mask;                            ///< masking curve
80 80
    uint16_t **qmant;                           ///< quantized mantissas
81
    int8_t   exp_shift[AC3_MAX_CHANNELS];       ///< exponent shift values
81
    int8_t   coeff_shift[AC3_MAX_CHANNELS];     ///< fixed-point coefficient shift values
82 82
    uint8_t  new_rematrixing_strategy;          ///< send new rematrixing flags in this block
83 83
    uint8_t  rematrixing_flags[4];              ///< rematrixing flags
84 84
} AC3Block;
......
269 269

  
270 270
            apply_window(&s->dsp, s->windowed_samples, input_samples, s->mdct.window, AC3_WINDOW_SIZE);
271 271

  
272
            block->exp_shift[ch] = normalize_samples(s);
272
            block->coeff_shift[ch] = normalize_samples(s);
273 273

  
274 274
            mdct512(&s->mdct, block->mdct_coef[ch], s->windowed_samples);
275 275
        }
......
416 416
            AC3Block *block = &s->blocks[blk];
417 417
            uint8_t *exp   = block->exp[ch];
418 418
            int32_t *coef = block->fixed_coef[ch];
419
            int exp_shift  = block->exp_shift[ch];
420 419
            for (i = 0; i < AC3_MAX_COEFS; i++) {
421 420
                int e;
422 421
                int v = abs(coef[i]);
423 422
                if (v == 0)
424 423
                    e = 24;
425 424
                else {
426
                    e = 23 - av_log2(v) + exp_shift;
425
                    e = 23 - av_log2(v);
427 426
                    if (e >= 24) {
428 427
                        e = 24;
429 428
                        coef[i] = 0;
......
1139 1138
 * Quantize a set of mantissas for a single channel in a single block.
1140 1139
 */
1141 1140
static void quantize_mantissas_blk_ch(AC3EncodeContext *s, int32_t *fixed_coef,
1142
                                      int8_t exp_shift, uint8_t *exp,
1141
                                      uint8_t *exp,
1143 1142
                                      uint8_t *bap, uint16_t *qmant, int n)
1144 1143
{
1145 1144
    int i;
......
1147 1146
    for (i = 0; i < n; i++) {
1148 1147
        int v;
1149 1148
        int c = fixed_coef[i];
1150
        int e = exp[i] - exp_shift;
1149
        int e = exp[i];
1151 1150
        int b = bap[i];
1152 1151
        switch (b) {
1153 1152
        case 0:
......
1243 1242
        s->qmant1_ptr = s->qmant2_ptr = s->qmant4_ptr = NULL;
1244 1243

  
1245 1244
        for (ch = 0; ch < s->channels; ch++) {
1246
            quantize_mantissas_blk_ch(s, block->fixed_coef[ch], block->exp_shift[ch],
1245
            quantize_mantissas_blk_ch(s, block->fixed_coef[ch],
1247 1246
                                      block->exp[ch], block->bap[ch],
1248 1247
                                      block->qmant[ch], s->nb_coefs[ch]);
1249 1248
        }

Also available in: Unified diff