Revision cc4d3dd3 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
 * Shift each value in an array by a specified amount.
299
 * @param src    input array
300
 * @param n      number of values in the array
301
 * @param shift  shift amount (negative=right, positive=left)
302
 */
303
static void shift_int32(int32_t *src, int n, int shift)
304
{
305
    int i;
306

  
307
    if (shift > 0) {
308
        for (i = 0; i < n; i++)
309
            src[i] <<= shift;
310
    } else if (shift < 0) {
311
        shift = -shift;
312
        for (i = 0; i < n; i++)
313
            src[i] >>= shift;
314
    }
315
}
316

  
317

  
318
/**
319 281
 * Normalize the input samples to use the maximum available precision.
320 282
 * This assumes signed 16-bit input samples.
321 283
 *
......
324 286
static int normalize_samples(AC3EncodeContext *s)
325 287
{
326 288
    int v = 14 - log2_tab(s, s->windowed_samples, AC3_WINDOW_SIZE);
327
    lshift_tab(s->windowed_samples, AC3_WINDOW_SIZE, v);
289
    s->ac3dsp.ac3_lshift_int16(s->windowed_samples, AC3_WINDOW_SIZE, v);
328 290
    return 9 - v;
329 291
}
330 292

  
......
339 301
    for (blk = 0; blk < AC3_MAX_BLOCKS; blk++) {
340 302
        AC3Block *block = &s->blocks[blk];
341 303
        for (ch = 0; ch < s->channels; ch++) {
342
            shift_int32(block->mdct_coef[ch], AC3_MAX_COEFS,
343
                        block->coeff_shift[ch]);
304
            s->ac3dsp.ac3_shift_int32(block->mdct_coef[ch], AC3_MAX_COEFS,
305
                                      block->coeff_shift[ch]);
344 306
        }
345 307
    }
346 308
}

Also available in: Unified diff