Fixed initialisation of tf in file_open(). Without setting the memory to 0,
[cinelerra_cv/mob.git] / libmpeg3 / audio / bit_allocation.c
blob86f3a7a3ac72c7143f3d2a4dc018dc3751eef020
1 /*
3 * Copyright (C) Aaron Holtzman - May 1999
6 * This file is part of libmpeg3
7 *
8 * libmpeg3 is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 2, or (at your option)
11 * any later version.
13 * libmpeg3 is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
18 * You should have received a copy of the GNU General Public License
19 * along with GNU Make; see the file COPYING. If not, write to
20 * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
24 #include "mpeg3audio.h"
25 #include <string.h>
27 /* Bit allocation tables */
29 static short mpeg3_slowdec[] = { 0x0f, 0x11, 0x13, 0x15 };
30 static short mpeg3_fastdec[] = { 0x3f, 0x53, 0x67, 0x7b };
31 static short mpeg3_slowgain[] = { 0x540, 0x4d8, 0x478, 0x410 };
32 static short mpeg3_dbpbtab[] = { 0x000, 0x700, 0x900, 0xb00 };
34 static unsigned short mpeg3_floortab[] = { 0x2f0, 0x2b0, 0x270, 0x230, 0x1f0, 0x170, 0x0f0, 0xf800 };
35 static short mpeg3_fastgain[] = { 0x080, 0x100, 0x180, 0x200, 0x280, 0x300, 0x380, 0x400 };
38 static short mpeg3_bndtab[] =
40 0, 1, 2, 3, 4, 5, 6, 7, 8, 9,
41 10, 11, 12, 13, 14, 15, 16, 17, 18, 19,
42 20, 21, 22, 23, 24, 25, 26, 27, 28, 31,
43 34, 37, 40, 43, 46, 49, 55, 61, 67, 73,
44 79, 85, 97, 109, 121, 133, 157, 181, 205, 229
47 static short mpeg3_bndsz[] =
49 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
50 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
51 1, 1, 1, 1, 1, 1, 1, 1, 3, 3,
52 3, 3, 3, 3, 3, 6, 6, 6, 6, 6,
53 6, 12, 12, 12, 12, 24, 24, 24, 24, 24
56 static short mpeg3_masktab[] =
58 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15,
59 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 28, 28, 29,
60 29, 29, 30, 30, 30, 31, 31, 31, 32, 32, 32, 33, 33, 33, 34, 34,
61 34, 35, 35, 35, 35, 35, 35, 36, 36, 36, 36, 36, 36, 37, 37, 37,
62 37, 37, 37, 38, 38, 38, 38, 38, 38, 39, 39, 39, 39, 39, 39, 40,
63 40, 40, 40, 40, 40, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41,
64 41, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 43, 43, 43,
65 43, 43, 43, 43, 43, 43, 43, 43, 43, 44, 44, 44, 44, 44, 44, 44,
66 44, 44, 44, 44, 44, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45,
67 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 46, 46, 46,
68 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46,
69 46, 46, 46, 46, 46, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47,
70 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 48, 48, 48,
71 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48,
72 48, 48, 48, 48, 48, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49,
73 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 0, 0, 0
77 static short mpeg3_latab[] =
79 0x0040, 0x003f, 0x003e, 0x003d, 0x003c, 0x003b, 0x003a, 0x0039,
80 0x0038, 0x0037, 0x0036, 0x0035, 0x0034, 0x0034, 0x0033, 0x0032,
81 0x0031, 0x0030, 0x002f, 0x002f, 0x002e, 0x002d, 0x002c, 0x002c,
82 0x002b, 0x002a, 0x0029, 0x0029, 0x0028, 0x0027, 0x0026, 0x0026,
83 0x0025, 0x0024, 0x0024, 0x0023, 0x0023, 0x0022, 0x0021, 0x0021,
84 0x0020, 0x0020, 0x001f, 0x001e, 0x001e, 0x001d, 0x001d, 0x001c,
85 0x001c, 0x001b, 0x001b, 0x001a, 0x001a, 0x0019, 0x0019, 0x0018,
86 0x0018, 0x0017, 0x0017, 0x0016, 0x0016, 0x0015, 0x0015, 0x0015,
87 0x0014, 0x0014, 0x0013, 0x0013, 0x0013, 0x0012, 0x0012, 0x0012,
88 0x0011, 0x0011, 0x0011, 0x0010, 0x0010, 0x0010, 0x000f, 0x000f,
89 0x000f, 0x000e, 0x000e, 0x000e, 0x000d, 0x000d, 0x000d, 0x000d,
90 0x000c, 0x000c, 0x000c, 0x000c, 0x000b, 0x000b, 0x000b, 0x000b,
91 0x000a, 0x000a, 0x000a, 0x000a, 0x000a, 0x0009, 0x0009, 0x0009,
92 0x0009, 0x0009, 0x0008, 0x0008, 0x0008, 0x0008, 0x0008, 0x0008,
93 0x0007, 0x0007, 0x0007, 0x0007, 0x0007, 0x0007, 0x0006, 0x0006,
94 0x0006, 0x0006, 0x0006, 0x0006, 0x0006, 0x0006, 0x0005, 0x0005,
95 0x0005, 0x0005, 0x0005, 0x0005, 0x0005, 0x0005, 0x0004, 0x0004,
96 0x0004, 0x0004, 0x0004, 0x0004, 0x0004, 0x0004, 0x0004, 0x0004,
97 0x0004, 0x0003, 0x0003, 0x0003, 0x0003, 0x0003, 0x0003, 0x0003,
98 0x0003, 0x0003, 0x0003, 0x0003, 0x0003, 0x0003, 0x0003, 0x0002,
99 0x0002, 0x0002, 0x0002, 0x0002, 0x0002, 0x0002, 0x0002, 0x0002,
100 0x0002, 0x0002, 0x0002, 0x0002, 0x0002, 0x0002, 0x0002, 0x0002,
101 0x0002, 0x0002, 0x0001, 0x0001, 0x0001, 0x0001, 0x0001, 0x0001,
102 0x0001, 0x0001, 0x0001, 0x0001, 0x0001, 0x0001, 0x0001, 0x0001,
103 0x0001, 0x0001, 0x0001, 0x0001, 0x0001, 0x0001, 0x0001, 0x0001,
104 0x0001, 0x0001, 0x0001, 0x0001, 0x0001, 0x0001, 0x0001, 0x0001,
105 0x0001, 0x0001, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
106 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
107 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
108 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
109 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
110 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
111 0x0000, 0x0000, 0x0000, 0x0000
114 static short mpeg3_hth[][50] =
117 0x04d0, 0x04d0, 0x0440, 0x0400, 0x03e0, 0x03c0, 0x03b0, 0x03b0,
118 0x03a0, 0x03a0, 0x03a0, 0x03a0, 0x03a0, 0x0390, 0x0390, 0x0390,
119 0x0380, 0x0380, 0x0370, 0x0370, 0x0360, 0x0360, 0x0350, 0x0350,
120 0x0340, 0x0340, 0x0330, 0x0320, 0x0310, 0x0300, 0x02f0, 0x02f0,
121 0x02f0, 0x02f0, 0x0300, 0x0310, 0x0340, 0x0390, 0x03e0, 0x0420,
122 0x0460, 0x0490, 0x04a0, 0x0460, 0x0440, 0x0440, 0x0520, 0x0800,
123 0x0840, 0x0840
127 0x04f0, 0x04f0, 0x0460, 0x0410, 0x03e0, 0x03d0, 0x03c0, 0x03b0,
128 0x03b0, 0x03a0, 0x03a0, 0x03a0, 0x03a0, 0x03a0, 0x0390, 0x0390,
129 0x0390, 0x0380, 0x0380, 0x0380, 0x0370, 0x0370, 0x0360, 0x0360,
130 0x0350, 0x0350, 0x0340, 0x0340, 0x0320, 0x0310, 0x0300, 0x02f0,
131 0x02f0, 0x02f0, 0x02f0, 0x0300, 0x0320, 0x0350, 0x0390, 0x03e0,
132 0x0420, 0x0450, 0x04a0, 0x0490, 0x0460, 0x0440, 0x0480, 0x0630,
133 0x0840, 0x0840
137 0x0580, 0x0580, 0x04b0, 0x0450, 0x0420, 0x03f0, 0x03e0, 0x03d0,
138 0x03c0, 0x03b0, 0x03b0, 0x03b0, 0x03a0, 0x03a0, 0x03a0, 0x03a0,
139 0x03a0, 0x03a0, 0x03a0, 0x03a0, 0x0390, 0x0390, 0x0390, 0x0390,
140 0x0380, 0x0380, 0x0380, 0x0370, 0x0360, 0x0350, 0x0340, 0x0330,
141 0x0320, 0x0310, 0x0300, 0x02f0, 0x02f0, 0x02f0, 0x0300, 0x0310,
142 0x0330, 0x0350, 0x03c0, 0x0410, 0x0470, 0x04a0, 0x0460, 0x0440,
143 0x0450, 0x04e0
148 static short mpeg3_baptab[] =
150 0, 1, 1, 1, 1, 1, 2, 2, 3, 3, 3, 4, 4, 5, 5, 6,
151 6, 6, 6, 7, 7, 7, 7, 8, 8, 8, 8, 9, 9, 9, 9, 10,
152 10, 10, 10, 11, 11, 11, 11, 12, 12, 12, 12, 13, 13, 13, 13, 14,
153 14, 14, 14, 14, 14, 14, 14, 15, 15, 15, 15, 15, 15, 15, 15, 15
157 static int logadd(int a, int b)
159 int c;
160 int address;
162 c = a - b;
163 address = mpeg3_min((abs(c) >> 1), 255);
165 if(c >= 0)
166 return(a + mpeg3_latab[address]);
167 else
168 return(b + mpeg3_latab[address]);
172 int mpeg3audio_ac3_calc_lowcomp(int a, int b0, int b1, int bin)
174 if(bin < 7)
176 if((b0 + 256) == b1)
177 a = 384;
178 else
179 if(b0 > b1)
180 a = mpeg3_max(0, a - 64);
182 else if(bin < 20)
184 if((b0 + 256) == b1)
185 a = 320;
186 else if(b0 > b1)
187 a = mpeg3_max(0, a - 64) ;
189 else
190 a = mpeg3_max(0, a - 128);
192 return(a);
195 void mpeg3audio_ac3_ba_compute_psd(int start,
196 int end,
197 short exps[],
198 short psd[],
199 short bndpsd[])
201 int bin,i,j,k;
202 int lastbin = 0;
204 /* Map the exponents into dBs */
205 for (bin = start; bin < end; bin++)
207 psd[bin] = (3072 - (exps[bin] << 7));
210 /* Integrate the psd function over each bit allocation band */
211 j = start;
212 k = mpeg3_masktab[start];
216 lastbin = mpeg3_min(mpeg3_bndtab[k] + mpeg3_bndsz[k], end);
217 bndpsd[k] = psd[j];
218 j++;
220 for(i = j; i < lastbin; i++)
222 bndpsd[k] = logadd(bndpsd[k], psd[j]);
223 j++;
226 k++;
227 }while(end > lastbin);
230 void mpeg3audio_ac3_ba_compute_excitation(mpeg3audio_t *audio,
231 int start,
232 int end,
233 int fgain,
234 int fastleak,
235 int slowleak,
236 int is_lfe,
237 short bndpsd[],
238 short excite[])
240 int bin;
241 int bndstrt;
242 int bndend;
243 int lowcomp = 0;
244 int begin = 0;
246 /* Compute excitation function */
247 bndstrt = mpeg3_masktab[start];
248 bndend = mpeg3_masktab[end - 1] + 1;
250 if(bndstrt == 0) /* For fbw and lfe channels */
252 lowcomp = mpeg3audio_ac3_calc_lowcomp(lowcomp, bndpsd[0], bndpsd[1], 0);
253 excite[0] = bndpsd[0] - fgain - lowcomp;
254 lowcomp = mpeg3audio_ac3_calc_lowcomp(lowcomp, bndpsd[1], bndpsd[2], 1);
255 excite[1] = bndpsd[1] - fgain - lowcomp;
256 begin = 7 ;
258 /* Note: Do not call mpeg3audio_ac3_calc_lowcomp() for the last band of the lfe channel, (bin = 6) */
259 for (bin = 2; bin < 7; bin++)
261 if(!(is_lfe && (bin == 6)))
262 lowcomp = mpeg3audio_ac3_calc_lowcomp(lowcomp, bndpsd[bin], bndpsd[bin+1], bin);
263 fastleak = bndpsd[bin] - fgain;
264 slowleak = bndpsd[bin] - audio->ac3_bit_allocation.sgain;
265 excite[bin] = fastleak - lowcomp;
267 if(!(is_lfe && (bin == 6)))
269 if(bndpsd[bin] <= bndpsd[bin+1])
271 begin = bin + 1 ;
272 break;
277 for (bin = begin; bin < mpeg3_min(bndend, 22); bin++)
279 if (!(is_lfe && (bin == 6)))
280 lowcomp = mpeg3audio_ac3_calc_lowcomp(lowcomp, bndpsd[bin], bndpsd[bin+1], bin);
281 fastleak -= audio->ac3_bit_allocation.fdecay;
282 fastleak = mpeg3_max(fastleak, bndpsd[bin] - fgain);
283 slowleak -= audio->ac3_bit_allocation.sdecay;
284 slowleak = mpeg3_max(slowleak, bndpsd[bin] - audio->ac3_bit_allocation.sgain);
285 excite[bin] = mpeg3_max(fastleak - lowcomp, slowleak);
287 begin = 22;
289 else /* For coupling channel */
291 begin = bndstrt;
294 for (bin = begin; bin < bndend; bin++)
296 fastleak -= audio->ac3_bit_allocation.fdecay;
297 fastleak = mpeg3_max(fastleak, bndpsd[bin] - fgain);
298 slowleak -= audio->ac3_bit_allocation.sdecay;
299 slowleak = mpeg3_max(slowleak, bndpsd[bin] - audio->ac3_bit_allocation.sgain);
300 excite[bin] = mpeg3_max(fastleak, slowleak) ;
304 void mpeg3audio_ac3_ba_compute_mask(mpeg3audio_t *audio,
305 int start,
306 int end,
307 int fscod,
308 int deltbae,
309 int deltnseg,
310 short deltoffst[],
311 short deltba[],
312 short deltlen[],
313 short excite[],
314 short mask[])
316 int bin, k;
317 int bndstrt;
318 int bndend;
319 int delta;
321 bndstrt = mpeg3_masktab[start];
322 bndend = mpeg3_masktab[end - 1] + 1;
324 /* Compute the masking curve */
326 for (bin = bndstrt; bin < bndend; bin++)
328 if (audio->ac3_bit_allocation.bndpsd[bin] < audio->ac3_bit_allocation.dbknee)
330 excite[bin] += ((audio->ac3_bit_allocation.dbknee - audio->ac3_bit_allocation.bndpsd[bin]) >> 2);
332 mask[bin] = mpeg3_max(excite[bin], mpeg3_hth[fscod][bin]);
335 /* Perform delta bit modulation if necessary */
336 if ((deltbae == DELTA_BIT_REUSE) || (deltbae == DELTA_BIT_NEW))
338 int band = 0;
339 int seg = 0;
341 for (seg = 0; seg < deltnseg + 1; seg++)
343 band += deltoffst[seg];
344 if (deltba[seg] >= 4)
346 delta = (deltba[seg] - 3) << 7;
348 else
350 delta = (deltba[seg] - 4) << 7;
353 for (k = 0; k < deltlen[seg]; k++)
355 mask[band] += delta;
356 band++;
362 void mpeg3audio_ac3_ba_compute_bap(mpeg3audio_t *audio,
363 int start,
364 int end,
365 int snroffset,
366 short psd[],
367 short mask[],
368 short bap[])
370 int i, j, k;
371 short lastbin = 0;
372 short address = 0;
374 /* Compute the bit allocation pointer for each bin */
375 i = start;
376 j = mpeg3_masktab[start];
380 lastbin = mpeg3_min(mpeg3_bndtab[j] + mpeg3_bndsz[j], end);
381 mask[j] -= snroffset;
382 mask[j] -= audio->ac3_bit_allocation.floor;
384 if(mask[j] < 0)
385 mask[j] = 0;
387 mask[j] &= 0x1fe0;
388 mask[j] += audio->ac3_bit_allocation.floor;
389 for(k = i; k < lastbin; k++)
391 address = (psd[i] - mask[j]) >> 5;
392 address = mpeg3_min(63, mpeg3_max(0, address));
393 bap[i] = mpeg3_baptab[address];
394 i++;
396 j++;
397 }while (end > lastbin);
400 int mpeg3audio_ac3_bit_allocate(mpeg3audio_t *audio,
401 unsigned int fscod,
402 mpeg3_ac3bsi_t *bsi,
403 mpeg3_ac3audblk_t *audblk)
405 int result = 0;
406 int i;
407 int fgain;
408 int snroffset;
409 int start;
410 int end;
411 int fastleak;
412 int slowleak;
414 /*printf("mpeg3audio_ac3_bit_allocate %d %d %d %d %d\n", audblk->sdcycod, audblk->fdcycod, audblk->sgaincod, audblk->dbpbcod, audblk->floorcod); */
415 /* Only perform bit_allocation if the exponents have changed or we
416 * have new sideband information */
417 if(audblk->chexpstr[0] == 0 && audblk->chexpstr[1] == 0 &&
418 audblk->chexpstr[2] == 0 && audblk->chexpstr[3] == 0 &&
419 audblk->chexpstr[4] == 0 && audblk->cplexpstr == 0 &&
420 audblk->lfeexpstr == 0 && audblk->baie == 0 &&
421 audblk->snroffste == 0 && audblk->deltbaie == 0)
422 return 0;
424 /* Do some setup before we do the bit alloc */
425 audio->ac3_bit_allocation.sdecay = mpeg3_slowdec[audblk->sdcycod];
426 audio->ac3_bit_allocation.fdecay = mpeg3_fastdec[audblk->fdcycod];
427 audio->ac3_bit_allocation.sgain = mpeg3_slowgain[audblk->sgaincod];
428 audio->ac3_bit_allocation.dbknee = mpeg3_dbpbtab[audblk->dbpbcod];
429 audio->ac3_bit_allocation.floor = mpeg3_floortab[audblk->floorcod];
431 /* if all the SNR offset constants are zero then the whole block is zero */
432 if(!audblk->csnroffst && !audblk->fsnroffst[0] &&
433 !audblk->fsnroffst[1] && !audblk->fsnroffst[2] &&
434 !audblk->fsnroffst[3] && !audblk->fsnroffst[4] &&
435 !audblk->cplfsnroffst && !audblk->lfefsnroffst)
437 memset(audblk->fbw_bap, 0, sizeof(short) * 256 * 5);
438 memset(audblk->cpl_bap, 0, sizeof(short) * 256);
439 memset(audblk->lfe_bap, 0, sizeof(short) * 7);
440 return 0;
443 for(i = 0; i < bsi->nfchans; i++)
445 start = 0;
446 end = audblk->endmant[i];
447 fgain = mpeg3_fastgain[audblk->fgaincod[i]];
448 snroffset = (((audblk->csnroffst - 15) << 4) + audblk->fsnroffst[i]) << 2 ;
449 fastleak = 0;
450 slowleak = 0;
452 mpeg3audio_ac3_ba_compute_psd(start,
453 end,
454 (short*)audblk->fbw_exp[i],
455 audio->ac3_bit_allocation.psd,
456 audio->ac3_bit_allocation.bndpsd);
458 mpeg3audio_ac3_ba_compute_excitation(audio,
459 start,
460 end ,
461 fgain,
462 fastleak,
463 slowleak,
465 audio->ac3_bit_allocation.bndpsd,
466 audio->ac3_bit_allocation.excite);
468 mpeg3audio_ac3_ba_compute_mask(audio,
469 start,
470 end,
471 fscod,
472 audblk->deltbae[i],
473 audblk->deltnseg[i],
474 (short*)audblk->deltoffst[i],
475 (short*)audblk->deltba[i],
476 (short*)audblk->deltlen[i],
477 audio->ac3_bit_allocation.excite,
478 audio->ac3_bit_allocation.mask);
480 mpeg3audio_ac3_ba_compute_bap(audio,
481 start,
482 end,
483 snroffset,
484 audio->ac3_bit_allocation.psd,
485 audio->ac3_bit_allocation.mask,
486 (short*)audblk->fbw_bap[i]);
489 if(audblk->cplinu)
491 start = audblk->cplstrtmant;
492 end = audblk->cplendmant;
493 fgain = mpeg3_fastgain[audblk->cplfgaincod];
494 snroffset = (((audblk->csnroffst - 15) << 4) + audblk->cplfsnroffst) << 2 ;
495 fastleak = (audblk->cplfleak << 8) + 768;
496 slowleak = (audblk->cplsleak << 8) + 768;
498 mpeg3audio_ac3_ba_compute_psd(start,
499 end,
500 (short*)audblk->cpl_exp,
501 audio->ac3_bit_allocation.psd,
502 audio->ac3_bit_allocation.bndpsd);
504 mpeg3audio_ac3_ba_compute_excitation(audio,
505 start,
506 end ,
507 fgain,
508 fastleak,
509 slowleak,
511 audio->ac3_bit_allocation.bndpsd,
512 audio->ac3_bit_allocation.excite);
514 mpeg3audio_ac3_ba_compute_mask(audio,
515 start,
516 end,
517 fscod,
518 audblk->cpldeltbae,
519 audblk->cpldeltnseg,
520 (short*)audblk->cpldeltoffst,
521 (short*)audblk->cpldeltba,
522 (short*)audblk->cpldeltlen,
523 audio->ac3_bit_allocation.excite,
524 audio->ac3_bit_allocation.mask);
526 mpeg3audio_ac3_ba_compute_bap(audio,
527 start,
528 end,
529 snroffset,
530 audio->ac3_bit_allocation.psd,
531 audio->ac3_bit_allocation.mask,
532 (short*)audblk->cpl_bap);
535 if(bsi->lfeon)
537 start = 0;
538 end = 7;
539 fgain = mpeg3_fastgain[audblk->lfefgaincod];
540 snroffset = (((audblk->csnroffst - 15) << 4) + audblk->lfefsnroffst) << 2 ;
541 fastleak = 0;
542 slowleak = 0;
544 mpeg3audio_ac3_ba_compute_psd(start,
545 end,
546 (short*)audblk->lfe_exp,
547 audio->ac3_bit_allocation.psd,
548 audio->ac3_bit_allocation.bndpsd);
550 mpeg3audio_ac3_ba_compute_excitation(audio,
551 start,
552 end ,
553 fgain,
554 fastleak,
555 slowleak,
557 audio->ac3_bit_allocation.bndpsd,
558 audio->ac3_bit_allocation.excite);
560 /* Perform no delta bit allocation for lfe */
561 mpeg3audio_ac3_ba_compute_mask(audio,
562 start,
563 end,
564 fscod,
570 audio->ac3_bit_allocation.excite,
571 audio->ac3_bit_allocation.mask);
573 mpeg3audio_ac3_ba_compute_bap(audio,
574 start,
575 end,
576 snroffset,
577 audio->ac3_bit_allocation.psd,
578 audio->ac3_bit_allocation.mask,
579 (short*)audblk->lfe_bap);
582 return result;