## Revision 323e6fea libavcodec/ac3enc_fixed.c

View differences:

libavcodec/ac3enc_fixed.c
131 131

132 132

133 133
```/** Complex multiply */
```
134
```#define CMUL(pre, pim, are, aim, bre, bim)              \
```
134
```#define CMUL(pre, pim, are, aim, bre, bim, rshift)      \
```
135 135
```{                                                       \
```
136
```   pre = (MUL16(are, bre) - MUL16(aim, bim)) >> 15;     \
```
137
```   pim = (MUL16(are, bim) + MUL16(bre, aim)) >> 15;     \
```
136
```   pre = (MUL16(are, bre) - MUL16(aim, bim)) >> rshift; \
```
137
```   pim = (MUL16(are, bim) + MUL16(bre, aim)) >> rshift; \
```
138 138
```}
```
139 139

140 140

......
195 195
```            p++;
```
196 196
```            q++;
```
197 197
```            for(l = nblocks; l < np2; l += nblocks) {
```
198
```                CMUL(tmp_re, tmp_im, mdct->costab[l], -mdct->sintab[l], q->re, q->im);
```
198
```                CMUL(tmp_re, tmp_im, mdct->costab[l], -mdct->sintab[l], q->re, q->im, 15);
```
199 199
```                BF(p->re, p->im, q->re,  q->im,
```
200 200
```                   p->re, p->im, tmp_re, tmp_im);
```
201 201
```                p++;
```
......
234 234
```    for (i = 0; i < n4; i++) {
```
235 235
```        re =  ((int)rot[   2*i] - (int)rot[ n-1-2*i]) >> 1;
```
236 236
```        im = -((int)rot[n2+2*i] - (int)rot[n2-1-2*i]) >> 1;
```
237
```        CMUL(x[i].re, x[i].im, re, im, -mdct->xcos1[i], mdct->xsin1[i]);
```
237
```        CMUL(x[i].re, x[i].im, re, im, -mdct->xcos1[i], mdct->xsin1[i], 15);
```
238 238
```    }
```
239 239

240 240
```    fft(mdct, x, mdct->nbits - 2);
```
......
243 243
```    for (i = 0; i < n4; i++) {
```
244 244
```        re = x[i].re;
```
245 245
```        im = x[i].im;
```
246
```        CMUL(out[n2-1-2*i], out[2*i], re, im, mdct->xsin1[i], mdct->xcos1[i]);
```
246
```        CMUL(out[n2-1-2*i], out[2*i], re, im, mdct->xsin1[i], mdct->xcos1[i], 0);
```
247 247
```    }
```
248 248
```}
```
249 249

......
295 295

296 296

297 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
```/**
```
298 315
``` * Normalize the input samples to use the maximum available precision.
```
299
``` * This assumes signed 16-bit input samples. Exponents are reduced by 9 to
```
300
``` * match the 24-bit internal precision for MDCT coefficients.
```
316
``` * This assumes signed 16-bit input samples.
```
301 317
``` *
```
302 318
``` * @return exponent shift
```
303 319
``` */
```
......
305 321
```{
```
306 322
```    int v = 14 - log2_tab(s, s->windowed_samples, AC3_WINDOW_SIZE);
```
307 323
```    lshift_tab(s->windowed_samples, AC3_WINDOW_SIZE, v);
```
308
```    return v - 9;
```
324
```    /* +6 to right-shift from 31-bit to 25-bit */
```
325
```    return v + 6;
```
309 326
```}
```
310 327

311 328

312 329
```/**
```
313
``` * Scale MDCT coefficients from float to fixed-point.
```
330
``` * Scale MDCT coefficients to 25-bit signed fixed-point.
```
314 331
``` */
```
315 332
```static void scale_coefficients(AC3EncodeContext *s)
```
316 333
```{
```
317
```    /* scaling/conversion is obviously not needed for the fixed-point encoder
```
318
```       since the coefficients are already fixed-point. */
```
319
```    return;
```
334
```    int blk, ch;
```
335

336
```    for (blk = 0; blk < AC3_MAX_BLOCKS; blk++) {
```
337
```        AC3Block *block = &s->blocks[blk];
```
338
```        for (ch = 0; ch < s->channels; ch++) {
```
339
```            ac3_rshift_int32_c(block->mdct_coef[ch], AC3_MAX_COEFS,
```
340
```                               block->coeff_shift[ch]);
```
341
```        }
```
342
```    }
```
320 343
```}
```
321 344

322 345

Also available in: Unified diff