00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024 #include "mpeg3audio.h"
00025 #include <string.h>
00026
00027
00028
00029 static short mpeg3_slowdec[] = { 0x0f, 0x11, 0x13, 0x15 };
00030 static short mpeg3_fastdec[] = { 0x3f, 0x53, 0x67, 0x7b };
00031 static short mpeg3_slowgain[] = { 0x540, 0x4d8, 0x478, 0x410 };
00032 static short mpeg3_dbpbtab[] = { 0x000, 0x700, 0x900, 0xb00 };
00033
00034 static unsigned short mpeg3_floortab[] = { 0x2f0, 0x2b0, 0x270, 0x230, 0x1f0, 0x170, 0x0f0, 0xf800 };
00035 static short mpeg3_fastgain[] = { 0x080, 0x100, 0x180, 0x200, 0x280, 0x300, 0x380, 0x400 };
00036
00037
00038 static short mpeg3_bndtab[] =
00039 {
00040 0, 1, 2, 3, 4, 5, 6, 7, 8, 9,
00041 10, 11, 12, 13, 14, 15, 16, 17, 18, 19,
00042 20, 21, 22, 23, 24, 25, 26, 27, 28, 31,
00043 34, 37, 40, 43, 46, 49, 55, 61, 67, 73,
00044 79, 85, 97, 109, 121, 133, 157, 181, 205, 229
00045 };
00046
00047 static short mpeg3_bndsz[] =
00048 {
00049 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
00050 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
00051 1, 1, 1, 1, 1, 1, 1, 1, 3, 3,
00052 3, 3, 3, 3, 3, 6, 6, 6, 6, 6,
00053 6, 12, 12, 12, 12, 24, 24, 24, 24, 24
00054 };
00055
00056 static short mpeg3_masktab[] =
00057 {
00058 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15,
00059 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 28, 28, 29,
00060 29, 29, 30, 30, 30, 31, 31, 31, 32, 32, 32, 33, 33, 33, 34, 34,
00061 34, 35, 35, 35, 35, 35, 35, 36, 36, 36, 36, 36, 36, 37, 37, 37,
00062 37, 37, 37, 38, 38, 38, 38, 38, 38, 39, 39, 39, 39, 39, 39, 40,
00063 40, 40, 40, 40, 40, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41,
00064 41, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 43, 43, 43,
00065 43, 43, 43, 43, 43, 43, 43, 43, 43, 44, 44, 44, 44, 44, 44, 44,
00066 44, 44, 44, 44, 44, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45,
00067 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 46, 46, 46,
00068 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46,
00069 46, 46, 46, 46, 46, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47,
00070 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 48, 48, 48,
00071 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48,
00072 48, 48, 48, 48, 48, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49,
00073 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 0, 0, 0
00074 };
00075
00076
00077 static short mpeg3_latab[] =
00078 {
00079 0x0040, 0x003f, 0x003e, 0x003d, 0x003c, 0x003b, 0x003a, 0x0039,
00080 0x0038, 0x0037, 0x0036, 0x0035, 0x0034, 0x0034, 0x0033, 0x0032,
00081 0x0031, 0x0030, 0x002f, 0x002f, 0x002e, 0x002d, 0x002c, 0x002c,
00082 0x002b, 0x002a, 0x0029, 0x0029, 0x0028, 0x0027, 0x0026, 0x0026,
00083 0x0025, 0x0024, 0x0024, 0x0023, 0x0023, 0x0022, 0x0021, 0x0021,
00084 0x0020, 0x0020, 0x001f, 0x001e, 0x001e, 0x001d, 0x001d, 0x001c,
00085 0x001c, 0x001b, 0x001b, 0x001a, 0x001a, 0x0019, 0x0019, 0x0018,
00086 0x0018, 0x0017, 0x0017, 0x0016, 0x0016, 0x0015, 0x0015, 0x0015,
00087 0x0014, 0x0014, 0x0013, 0x0013, 0x0013, 0x0012, 0x0012, 0x0012,
00088 0x0011, 0x0011, 0x0011, 0x0010, 0x0010, 0x0010, 0x000f, 0x000f,
00089 0x000f, 0x000e, 0x000e, 0x000e, 0x000d, 0x000d, 0x000d, 0x000d,
00090 0x000c, 0x000c, 0x000c, 0x000c, 0x000b, 0x000b, 0x000b, 0x000b,
00091 0x000a, 0x000a, 0x000a, 0x000a, 0x000a, 0x0009, 0x0009, 0x0009,
00092 0x0009, 0x0009, 0x0008, 0x0008, 0x0008, 0x0008, 0x0008, 0x0008,
00093 0x0007, 0x0007, 0x0007, 0x0007, 0x0007, 0x0007, 0x0006, 0x0006,
00094 0x0006, 0x0006, 0x0006, 0x0006, 0x0006, 0x0006, 0x0005, 0x0005,
00095 0x0005, 0x0005, 0x0005, 0x0005, 0x0005, 0x0005, 0x0004, 0x0004,
00096 0x0004, 0x0004, 0x0004, 0x0004, 0x0004, 0x0004, 0x0004, 0x0004,
00097 0x0004, 0x0003, 0x0003, 0x0003, 0x0003, 0x0003, 0x0003, 0x0003,
00098 0x0003, 0x0003, 0x0003, 0x0003, 0x0003, 0x0003, 0x0003, 0x0002,
00099 0x0002, 0x0002, 0x0002, 0x0002, 0x0002, 0x0002, 0x0002, 0x0002,
00100 0x0002, 0x0002, 0x0002, 0x0002, 0x0002, 0x0002, 0x0002, 0x0002,
00101 0x0002, 0x0002, 0x0001, 0x0001, 0x0001, 0x0001, 0x0001, 0x0001,
00102 0x0001, 0x0001, 0x0001, 0x0001, 0x0001, 0x0001, 0x0001, 0x0001,
00103 0x0001, 0x0001, 0x0001, 0x0001, 0x0001, 0x0001, 0x0001, 0x0001,
00104 0x0001, 0x0001, 0x0001, 0x0001, 0x0001, 0x0001, 0x0001, 0x0001,
00105 0x0001, 0x0001, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
00106 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
00107 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
00108 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
00109 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
00110 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
00111 0x0000, 0x0000, 0x0000, 0x0000
00112 };
00113
00114 static short mpeg3_hth[][50] =
00115 {
00116 {
00117 0x04d0, 0x04d0, 0x0440, 0x0400, 0x03e0, 0x03c0, 0x03b0, 0x03b0,
00118 0x03a0, 0x03a0, 0x03a0, 0x03a0, 0x03a0, 0x0390, 0x0390, 0x0390,
00119 0x0380, 0x0380, 0x0370, 0x0370, 0x0360, 0x0360, 0x0350, 0x0350,
00120 0x0340, 0x0340, 0x0330, 0x0320, 0x0310, 0x0300, 0x02f0, 0x02f0,
00121 0x02f0, 0x02f0, 0x0300, 0x0310, 0x0340, 0x0390, 0x03e0, 0x0420,
00122 0x0460, 0x0490, 0x04a0, 0x0460, 0x0440, 0x0440, 0x0520, 0x0800,
00123 0x0840, 0x0840
00124 },
00125
00126 {
00127 0x04f0, 0x04f0, 0x0460, 0x0410, 0x03e0, 0x03d0, 0x03c0, 0x03b0,
00128 0x03b0, 0x03a0, 0x03a0, 0x03a0, 0x03a0, 0x03a0, 0x0390, 0x0390,
00129 0x0390, 0x0380, 0x0380, 0x0380, 0x0370, 0x0370, 0x0360, 0x0360,
00130 0x0350, 0x0350, 0x0340, 0x0340, 0x0320, 0x0310, 0x0300, 0x02f0,
00131 0x02f0, 0x02f0, 0x02f0, 0x0300, 0x0320, 0x0350, 0x0390, 0x03e0,
00132 0x0420, 0x0450, 0x04a0, 0x0490, 0x0460, 0x0440, 0x0480, 0x0630,
00133 0x0840, 0x0840
00134 },
00135
00136 {
00137 0x0580, 0x0580, 0x04b0, 0x0450, 0x0420, 0x03f0, 0x03e0, 0x03d0,
00138 0x03c0, 0x03b0, 0x03b0, 0x03b0, 0x03a0, 0x03a0, 0x03a0, 0x03a0,
00139 0x03a0, 0x03a0, 0x03a0, 0x03a0, 0x0390, 0x0390, 0x0390, 0x0390,
00140 0x0380, 0x0380, 0x0380, 0x0370, 0x0360, 0x0350, 0x0340, 0x0330,
00141 0x0320, 0x0310, 0x0300, 0x02f0, 0x02f0, 0x02f0, 0x0300, 0x0310,
00142 0x0330, 0x0350, 0x03c0, 0x0410, 0x0470, 0x04a0, 0x0460, 0x0440,
00143 0x0450, 0x04e0
00144 }
00145 };
00146
00147
00148 static short mpeg3_baptab[] =
00149 {
00150 0, 1, 1, 1, 1, 1, 2, 2, 3, 3, 3, 4, 4, 5, 5, 6,
00151 6, 6, 6, 7, 7, 7, 7, 8, 8, 8, 8, 9, 9, 9, 9, 10,
00152 10, 10, 10, 11, 11, 11, 11, 12, 12, 12, 12, 13, 13, 13, 13, 14,
00153 14, 14, 14, 14, 14, 14, 14, 15, 15, 15, 15, 15, 15, 15, 15, 15
00154 };
00155
00156
00157 static int logadd(int a, int b)
00158 {
00159 int c;
00160 int address;
00161
00162 c = a - b;
00163 address = mpeg3_min((abs(c) >> 1), 255);
00164
00165 if(c >= 0)
00166 return(a + mpeg3_latab[address]);
00167 else
00168 return(b + mpeg3_latab[address]);
00169 }
00170
00171
00172 int mpeg3audio_ac3_calc_lowcomp(int a, int b0, int b1, int bin)
00173 {
00174 if(bin < 7)
00175 {
00176 if((b0 + 256) == b1)
00177 a = 384;
00178 else
00179 if(b0 > b1)
00180 a = mpeg3_max(0, a - 64);
00181 }
00182 else if(bin < 20)
00183 {
00184 if((b0 + 256) == b1)
00185 a = 320;
00186 else if(b0 > b1)
00187 a = mpeg3_max(0, a - 64) ;
00188 }
00189 else
00190 a = mpeg3_max(0, a - 128);
00191
00192 return(a);
00193 }
00194
00195 void mpeg3audio_ac3_ba_compute_psd(int start,
00196 int end,
00197 short exps[],
00198 short psd[],
00199 short bndpsd[])
00200 {
00201 int bin,i,j,k;
00202 int lastbin = 0;
00203
00204
00205 for (bin = start; bin < end; bin++)
00206 {
00207 psd[bin] = (3072 - (exps[bin] << 7));
00208 }
00209
00210
00211 j = start;
00212 k = mpeg3_masktab[start];
00213
00214 do
00215 {
00216 lastbin = mpeg3_min(mpeg3_bndtab[k] + mpeg3_bndsz[k], end);
00217 bndpsd[k] = psd[j];
00218 j++;
00219
00220 for(i = j; i < lastbin; i++)
00221 {
00222 bndpsd[k] = logadd(bndpsd[k], psd[j]);
00223 j++;
00224 }
00225
00226 k++;
00227 }while(end > lastbin);
00228 }
00229
00230 void mpeg3audio_ac3_ba_compute_excitation(mpeg3audio_t *audio,
00231 int start,
00232 int end,
00233 int fgain,
00234 int fastleak,
00235 int slowleak,
00236 int is_lfe,
00237 short bndpsd[],
00238 short excite[])
00239 {
00240 int bin;
00241 int bndstrt;
00242 int bndend;
00243 int lowcomp = 0;
00244 int begin = 0;
00245
00246
00247 bndstrt = mpeg3_masktab[start];
00248 bndend = mpeg3_masktab[end - 1] + 1;
00249
00250 if(bndstrt == 0)
00251 {
00252 lowcomp = mpeg3audio_ac3_calc_lowcomp(lowcomp, bndpsd[0], bndpsd[1], 0);
00253 excite[0] = bndpsd[0] - fgain - lowcomp;
00254 lowcomp = mpeg3audio_ac3_calc_lowcomp(lowcomp, bndpsd[1], bndpsd[2], 1);
00255 excite[1] = bndpsd[1] - fgain - lowcomp;
00256 begin = 7 ;
00257
00258
00259 for (bin = 2; bin < 7; bin++)
00260 {
00261 if(!(is_lfe && (bin == 6)))
00262 lowcomp = mpeg3audio_ac3_calc_lowcomp(lowcomp, bndpsd[bin], bndpsd[bin+1], bin);
00263 fastleak = bndpsd[bin] - fgain;
00264 slowleak = bndpsd[bin] - audio->ac3_bit_allocation.sgain;
00265 excite[bin] = fastleak - lowcomp;
00266
00267 if(!(is_lfe && (bin == 6)))
00268 {
00269 if(bndpsd[bin] <= bndpsd[bin+1])
00270 {
00271 begin = bin + 1 ;
00272 break;
00273 }
00274 }
00275 }
00276
00277 for (bin = begin; bin < mpeg3_min(bndend, 22); bin++)
00278 {
00279 if (!(is_lfe && (bin == 6)))
00280 lowcomp = mpeg3audio_ac3_calc_lowcomp(lowcomp, bndpsd[bin], bndpsd[bin+1], bin);
00281 fastleak -= audio->ac3_bit_allocation.fdecay;
00282 fastleak = mpeg3_max(fastleak, bndpsd[bin] - fgain);
00283 slowleak -= audio->ac3_bit_allocation.sdecay;
00284 slowleak = mpeg3_max(slowleak, bndpsd[bin] - audio->ac3_bit_allocation.sgain);
00285 excite[bin] = mpeg3_max(fastleak - lowcomp, slowleak);
00286 }
00287 begin = 22;
00288 }
00289 else
00290 {
00291 begin = bndstrt;
00292 }
00293
00294 for (bin = begin; bin < bndend; bin++)
00295 {
00296 fastleak -= audio->ac3_bit_allocation.fdecay;
00297 fastleak = mpeg3_max(fastleak, bndpsd[bin] - fgain);
00298 slowleak -= audio->ac3_bit_allocation.sdecay;
00299 slowleak = mpeg3_max(slowleak, bndpsd[bin] - audio->ac3_bit_allocation.sgain);
00300 excite[bin] = mpeg3_max(fastleak, slowleak) ;
00301 }
00302 }
00303
00304 void mpeg3audio_ac3_ba_compute_mask(mpeg3audio_t *audio,
00305 int start,
00306 int end,
00307 int fscod,
00308 int deltbae,
00309 int deltnseg,
00310 short deltoffst[],
00311 short deltba[],
00312 short deltlen[],
00313 short excite[],
00314 short mask[])
00315 {
00316 int bin, k;
00317 int bndstrt;
00318 int bndend;
00319 int delta;
00320
00321 bndstrt = mpeg3_masktab[start];
00322 bndend = mpeg3_masktab[end - 1] + 1;
00323
00324
00325
00326 for (bin = bndstrt; bin < bndend; bin++)
00327 {
00328 if (audio->ac3_bit_allocation.bndpsd[bin] < audio->ac3_bit_allocation.dbknee)
00329 {
00330 excite[bin] += ((audio->ac3_bit_allocation.dbknee - audio->ac3_bit_allocation.bndpsd[bin]) >> 2);
00331 }
00332 mask[bin] = mpeg3_max(excite[bin], mpeg3_hth[fscod][bin]);
00333 }
00334
00335
00336 if ((deltbae == DELTA_BIT_REUSE) || (deltbae == DELTA_BIT_NEW))
00337 {
00338 int band = 0;
00339 int seg = 0;
00340
00341 for (seg = 0; seg < deltnseg + 1; seg++)
00342 {
00343 band += deltoffst[seg];
00344 if (deltba[seg] >= 4)
00345 {
00346 delta = (deltba[seg] - 3) << 7;
00347 }
00348 else
00349 {
00350 delta = (deltba[seg] - 4) << 7;
00351 }
00352
00353 for (k = 0; k < deltlen[seg]; k++)
00354 {
00355 mask[band] += delta;
00356 band++;
00357 }
00358 }
00359 }
00360 }
00361
00362 void mpeg3audio_ac3_ba_compute_bap(mpeg3audio_t *audio,
00363 int start,
00364 int end,
00365 int snroffset,
00366 short psd[],
00367 short mask[],
00368 short bap[])
00369 {
00370 int i, j, k;
00371 short lastbin = 0;
00372 short address = 0;
00373
00374
00375 i = start;
00376 j = mpeg3_masktab[start];
00377
00378 do
00379 {
00380 lastbin = mpeg3_min(mpeg3_bndtab[j] + mpeg3_bndsz[j], end);
00381 mask[j] -= snroffset;
00382 mask[j] -= audio->ac3_bit_allocation.floor;
00383
00384 if(mask[j] < 0)
00385 mask[j] = 0;
00386
00387 mask[j] &= 0x1fe0;
00388 mask[j] += audio->ac3_bit_allocation.floor;
00389 for(k = i; k < lastbin; k++)
00390 {
00391 address = (psd[i] - mask[j]) >> 5;
00392 address = mpeg3_min(63, mpeg3_max(0, address));
00393 bap[i] = mpeg3_baptab[address];
00394 i++;
00395 }
00396 j++;
00397 }while (end > lastbin);
00398 }
00399
00400 int mpeg3audio_ac3_bit_allocate(mpeg3audio_t *audio,
00401 unsigned int fscod,
00402 mpeg3_ac3bsi_t *bsi,
00403 mpeg3_ac3audblk_t *audblk)
00404 {
00405 int result = 0;
00406 int i;
00407 int fgain;
00408 int snroffset;
00409 int start;
00410 int end;
00411 int fastleak;
00412 int slowleak;
00413
00414
00415
00416
00417 if(audblk->chexpstr[0] == 0 && audblk->chexpstr[1] == 0 &&
00418 audblk->chexpstr[2] == 0 && audblk->chexpstr[3] == 0 &&
00419 audblk->chexpstr[4] == 0 && audblk->cplexpstr == 0 &&
00420 audblk->lfeexpstr == 0 && audblk->baie == 0 &&
00421 audblk->snroffste == 0 && audblk->deltbaie == 0)
00422 return 0;
00423
00424
00425 audio->ac3_bit_allocation.sdecay = mpeg3_slowdec[audblk->sdcycod];
00426 audio->ac3_bit_allocation.fdecay = mpeg3_fastdec[audblk->fdcycod];
00427 audio->ac3_bit_allocation.sgain = mpeg3_slowgain[audblk->sgaincod];
00428 audio->ac3_bit_allocation.dbknee = mpeg3_dbpbtab[audblk->dbpbcod];
00429 audio->ac3_bit_allocation.floor = mpeg3_floortab[audblk->floorcod];
00430
00431
00432 if(!audblk->csnroffst && !audblk->fsnroffst[0] &&
00433 !audblk->fsnroffst[1] && !audblk->fsnroffst[2] &&
00434 !audblk->fsnroffst[3] && !audblk->fsnroffst[4] &&
00435 !audblk->cplfsnroffst && !audblk->lfefsnroffst)
00436 {
00437 memset(audblk->fbw_bap, 0, sizeof(short) * 256 * 5);
00438 memset(audblk->cpl_bap, 0, sizeof(short) * 256);
00439 memset(audblk->lfe_bap, 0, sizeof(short) * 7);
00440 return 0;
00441 }
00442
00443 for(i = 0; i < bsi->nfchans; i++)
00444 {
00445 start = 0;
00446 end = audblk->endmant[i];
00447 fgain = mpeg3_fastgain[audblk->fgaincod[i]];
00448 snroffset = (((audblk->csnroffst - 15) << 4) + audblk->fsnroffst[i]) << 2 ;
00449 fastleak = 0;
00450 slowleak = 0;
00451
00452 mpeg3audio_ac3_ba_compute_psd(start,
00453 end,
00454 (short*)audblk->fbw_exp[i],
00455 audio->ac3_bit_allocation.psd,
00456 audio->ac3_bit_allocation.bndpsd);
00457
00458 mpeg3audio_ac3_ba_compute_excitation(audio,
00459 start,
00460 end ,
00461 fgain,
00462 fastleak,
00463 slowleak,
00464 0,
00465 audio->ac3_bit_allocation.bndpsd,
00466 audio->ac3_bit_allocation.excite);
00467
00468 mpeg3audio_ac3_ba_compute_mask(audio,
00469 start,
00470 end,
00471 fscod,
00472 audblk->deltbae[i],
00473 audblk->deltnseg[i],
00474 (short*)audblk->deltoffst[i],
00475 (short*)audblk->deltba[i],
00476 (short*)audblk->deltlen[i],
00477 audio->ac3_bit_allocation.excite,
00478 audio->ac3_bit_allocation.mask);
00479
00480 mpeg3audio_ac3_ba_compute_bap(audio,
00481 start,
00482 end,
00483 snroffset,
00484 audio->ac3_bit_allocation.psd,
00485 audio->ac3_bit_allocation.mask,
00486 (short*)audblk->fbw_bap[i]);
00487 }
00488
00489 if(audblk->cplinu)
00490 {
00491 start = audblk->cplstrtmant;
00492 end = audblk->cplendmant;
00493 fgain = mpeg3_fastgain[audblk->cplfgaincod];
00494 snroffset = (((audblk->csnroffst - 15) << 4) + audblk->cplfsnroffst) << 2 ;
00495 fastleak = (audblk->cplfleak << 8) + 768;
00496 slowleak = (audblk->cplsleak << 8) + 768;
00497
00498 mpeg3audio_ac3_ba_compute_psd(start,
00499 end,
00500 (short*)audblk->cpl_exp,
00501 audio->ac3_bit_allocation.psd,
00502 audio->ac3_bit_allocation.bndpsd);
00503
00504 mpeg3audio_ac3_ba_compute_excitation(audio,
00505 start,
00506 end ,
00507 fgain,
00508 fastleak,
00509 slowleak,
00510 0,
00511 audio->ac3_bit_allocation.bndpsd,
00512 audio->ac3_bit_allocation.excite);
00513
00514 mpeg3audio_ac3_ba_compute_mask(audio,
00515 start,
00516 end,
00517 fscod,
00518 audblk->cpldeltbae,
00519 audblk->cpldeltnseg,
00520 (short*)audblk->cpldeltoffst,
00521 (short*)audblk->cpldeltba,
00522 (short*)audblk->cpldeltlen,
00523 audio->ac3_bit_allocation.excite,
00524 audio->ac3_bit_allocation.mask);
00525
00526 mpeg3audio_ac3_ba_compute_bap(audio,
00527 start,
00528 end,
00529 snroffset,
00530 audio->ac3_bit_allocation.psd,
00531 audio->ac3_bit_allocation.mask,
00532 (short*)audblk->cpl_bap);
00533 }
00534
00535 if(bsi->lfeon)
00536 {
00537 start = 0;
00538 end = 7;
00539 fgain = mpeg3_fastgain[audblk->lfefgaincod];
00540 snroffset = (((audblk->csnroffst - 15) << 4) + audblk->lfefsnroffst) << 2 ;
00541 fastleak = 0;
00542 slowleak = 0;
00543
00544 mpeg3audio_ac3_ba_compute_psd(start,
00545 end,
00546 (short*)audblk->lfe_exp,
00547 audio->ac3_bit_allocation.psd,
00548 audio->ac3_bit_allocation.bndpsd);
00549
00550 mpeg3audio_ac3_ba_compute_excitation(audio,
00551 start,
00552 end ,
00553 fgain,
00554 fastleak,
00555 slowleak,
00556 1,
00557 audio->ac3_bit_allocation.bndpsd,
00558 audio->ac3_bit_allocation.excite);
00559
00560
00561 mpeg3audio_ac3_ba_compute_mask(audio,
00562 start,
00563 end,
00564 fscod,
00565 2,
00566 0,
00567 0,
00568 0,
00569 0,
00570 audio->ac3_bit_allocation.excite,
00571 audio->ac3_bit_allocation.mask);
00572
00573 mpeg3audio_ac3_ba_compute_bap(audio,
00574 start,
00575 end,
00576 snroffset,
00577 audio->ac3_bit_allocation.psd,
00578 audio->ac3_bit_allocation.mask,
00579 (short*)audblk->lfe_bap);
00580 }
00581
00582 return result;
00583 }