Revision f1efbca5 libavcodec/ac3enc_fixed.c

View differences:

libavcodec/ac3enc_fixed.c
278 278

  
279 279

  
280 280
/**
281
 * Left-shift each value in an array by a specified amount.
282
 * @param tab    input array
283
 * @param n      number of values in the array
284
 * @param lshift left shift amount
285
 */
286
static void lshift_tab(int16_t *tab, int n, unsigned int lshift)
287
{
288
    int i;
289

  
290
    if (lshift > 0) {
291
        for (i = 0; i < n; i++)
292
            tab[i] <<= lshift;
293
    }
294
}
295

  
296

  
297
/**
298
 * Right-shift each value in an array of int32_t by a specified amount.
299
 * @param src    input array
300
 * @param len    number of values in the array
301
 * @param shift  right shift amount
302
 */
303
static void ac3_rshift_int32_c(int32_t *src, unsigned int len, unsigned int shift)
304
{
305
    int i;
306

  
307
    if (shift > 0) {
308
        for (i = 0; i < len; i++)
309
            src[i] >>= shift;
310
    }
311
}
312

  
313

  
314
/**
315 281
 * Normalize the input samples to use the maximum available precision.
316 282
 * This assumes signed 16-bit input samples.
317 283
 *
......
320 286
static int normalize_samples(AC3EncodeContext *s)
321 287
{
322 288
    int v = 14 - log2_tab(s, s->windowed_samples, AC3_WINDOW_SIZE);
323
    lshift_tab(s->windowed_samples, AC3_WINDOW_SIZE, v);
289
    if (v > 0)
290
        s->ac3dsp.ac3_lshift_int16(s->windowed_samples, AC3_WINDOW_SIZE, v);
324 291
    /* +6 to right-shift from 31-bit to 25-bit */
325 292
    return v + 6;
326 293
}
......
336 303
    for (blk = 0; blk < AC3_MAX_BLOCKS; blk++) {
337 304
        AC3Block *block = &s->blocks[blk];
338 305
        for (ch = 0; ch < s->channels; ch++) {
339
            ac3_rshift_int32_c(block->mdct_coef[ch], AC3_MAX_COEFS,
340
                               block->coeff_shift[ch]);
306
            s->ac3dsp.ac3_rshift_int32(block->mdct_coef[ch], AC3_MAX_COEFS,
307
                                       block->coeff_shift[ch]);
341 308
        }
342 309
    }
343 310
}

Also available in: Unified diff