Mercurial > audlegacy
diff Plugins/Input/aac/libfaad2/sbr_fbt.c @ 1010:29feaace84d0 trunk
[svn] - synchronize audacious-faad with FAAD2 CVS.
author | nenolod |
---|---|
date | Mon, 08 May 2006 06:56:47 -0700 |
parents | 0a2ad94e8607 |
children | 1e6c0a3f2d15 |
line wrap: on
line diff
--- a/Plugins/Input/aac/libfaad2/sbr_fbt.c Mon May 08 06:00:19 2006 -0700 +++ b/Plugins/Input/aac/libfaad2/sbr_fbt.c Mon May 08 06:56:47 2006 -0700 @@ -22,7 +22,7 @@ ** Commercial non-GPL licensing of this software is possible. ** For more info contact Ahead Software through Mpeg4AAClicense@nero.com. ** -** $Id: sbr_fbt.c,v 1.17 2004/09/08 09:43:11 gcp Exp $ +** $Id: sbr_fbt.c,v 1.10 2004/01/16 20:20:32 menno Exp $ **/ /* Calculate frequency band tables */ @@ -197,7 +197,7 @@ if (k2 <= k0) { sbr->N_master = 0; - return 1; + return 0; } dk = bs_alter_scale ? 2 : 1; @@ -224,7 +224,7 @@ if (k2Diff) { incr = (k2Diff > 0) ? -1 : 1; - k = (uint8_t) ((k2Diff > 0) ? (nrBands-1) : 0); + k = (k2Diff > 0) ? (nrBands-1) : 0; while (k2Diff != 0) { @@ -236,10 +236,10 @@ sbr->f_master[0] = k0; for (k = 1; k <= nrBands; k++) - sbr->f_master[k] = (uint8_t)(sbr->f_master[k-1] + vDk[k-1]); + sbr->f_master[k] = sbr->f_master[k-1] + vDk[k-1]; - sbr->N_master = (uint8_t)nrBands; - sbr->N_master = (min(sbr->N_master, 64)); + sbr->N_master = nrBands; + sbr->N_master = min(sbr->N_master, 64); #if 0 printf("f_master[%d]: ", nrBands); @@ -355,23 +355,18 @@ uint8_t temp1[] = { 6, 5, 4 }; real_t q, qk; int32_t A_1; -#ifdef FIXED_POINT - real_t rk2, rk0; -#endif /* mft only defined for k2 > k0 */ if (k2 <= k0) { sbr->N_master = 0; - return 1; + return 0; } bands = temp1[bs_freq_scale-1]; #ifdef FIXED_POINT - rk0 = (real_t)k0 << REAL_BITS; - rk2 = (real_t)k2 << REAL_BITS; - if (rk2 > MUL_C(rk0, COEF_CONST(2.2449))) + if (REAL_CONST(k2) > MUL_R(REAL_CONST(k0),REAL_CONST(2.2449))) #else if ((float)k2/(float)k0 > 2.2449) #endif @@ -383,18 +378,16 @@ k1 = k2; } - nrBand0 = (uint8_t)(2 * find_bands(0, bands, k0, k1)); + nrBand0 = 2 * find_bands(0, bands, k0, k1); nrBand0 = min(nrBand0, 63); if (nrBand0 <= 0) return 1; q = find_initial_power(nrBand0, k0, k1); + qk = REAL_CONST(k0); #ifdef FIXED_POINT - qk = (real_t)k0 << REAL_BITS; - //A_1 = (int32_t)((qk + REAL_CONST(0.5)) >> REAL_BITS); - A_1 = k0; + A_1 = (int32_t)((qk + REAL_CONST(0.5)) >> REAL_BITS); #else - qk = REAL_CONST(k0); A_1 = (int32_t)(qk + .5); #endif for (k = 0; k <= nrBand0; k++) @@ -424,23 +417,21 @@ if (!twoRegions) { for (k = 0; k <= nrBand0; k++) - sbr->f_master[k] = (uint8_t) vk0[k]; + sbr->f_master[k] = vk0[k]; sbr->N_master = nrBand0; sbr->N_master = min(sbr->N_master, 64); return 0; } - nrBand1 = (uint8_t)(2 * find_bands(1 /* warped */, bands, k1, k2)); + nrBand1 = 2 * find_bands(1 /* warped */, bands, k1, k2); nrBand1 = min(nrBand1, 63); q = find_initial_power(nrBand1, k1, k2); + qk = REAL_CONST(k1); #ifdef FIXED_POINT - qk = (real_t)k1 << REAL_BITS; - //A_1 = (int32_t)((qk + REAL_CONST(0.5)) >> REAL_BITS); - A_1 = k1; + A_1 = (int32_t)((qk + REAL_CONST(0.5)) >> REAL_BITS); #else - qk = REAL_CONST(k1); A_1 = (int32_t)(qk + .5); #endif for (k = 0; k <= nrBand1 - 1; k++) @@ -481,11 +472,11 @@ sbr->N_master = min(sbr->N_master, 64); for (k = 0; k <= nrBand0; k++) { - sbr->f_master[k] = (uint8_t) vk0[k]; + sbr->f_master[k] = vk0[k]; } for (k = nrBand0 + 1; k <= sbr->N_master; k++) { - sbr->f_master[k] = (uint8_t) vk1[k - nrBand0]; + sbr->f_master[k] = vk1[k - nrBand0]; } #if 0 @@ -536,13 +527,11 @@ if (k == 0) i = 0; else - i = (uint8_t)(2*k - minus); + i = 2*k - minus; sbr->f_table_res[LO_RES][k] = sbr->f_table_res[HI_RES][i]; } #if 0 - printf("bs_freq_scale: %d\n", sbr->bs_freq_scale); - printf("bs_limiter_bands: %d\n", sbr->bs_limiter_bands); printf("f_table_res[HI_RES][%d]: ", sbr->N_high); for (k = 0; k <= sbr->N_high; k++) { @@ -567,7 +556,7 @@ #if 0 sbr->N_Q = max(1, (int32_t)(sbr->bs_noise_bands*(log(k2/(float)sbr->kx)/log(2.0)) + 0.5)); #else - sbr->N_Q = (uint8_t)(max(1, find_bands(0, sbr->bs_noise_bands, sbr->kx, k2))); + sbr->N_Q = max(1, find_bands(0, sbr->bs_noise_bands, sbr->kx, k2)); #endif sbr->N_Q = min(5, sbr->N_Q); } @@ -603,7 +592,7 @@ printf("f_table_noise[%d]: ", sbr->N_Q); for (k = 0; k <= sbr->N_Q; k++) { - printf("%d ", sbr->f_table_noise[k] - sbr->kx); + printf("%d ", sbr->f_table_noise[k]); } printf("\n"); #endif @@ -622,8 +611,8 @@ static const real_t limiterBandsPerOctave[] = { REAL_CONST(1.2), REAL_CONST(2), REAL_CONST(3) }; #else - static const real_t limiterBandsCompare[] = { REAL_CONST(1.327152), - REAL_CONST(1.185093), REAL_CONST(1.119872) }; + static const real_t limiterBandsCompare[] = { REAL_CONST(1.328125), + REAL_CONST(1.1875), REAL_CONST(1.125) }; #endif uint8_t k, s; int8_t nrLim; @@ -635,15 +624,6 @@ sbr->f_table_lim[0][1] = sbr->f_table_res[LO_RES][sbr->N_low] - sbr->kx; sbr->N_L[0] = 1; -#if 0 - printf("f_table_lim[%d][%d]: ", 0, sbr->N_L[0]); - for (k = 0; k <= sbr->N_L[0]; k++) - { - printf("%d ", sbr->f_table_lim[0][k]); - } - printf("\n"); -#endif - for (s = 1; s < 4; s++) { int32_t limTable[100 /*TODO*/] = {0}; @@ -684,18 +664,17 @@ if (limTable[k-1] != 0) #if 0 nOctaves = REAL_CONST(log((float)limTable[k]/(float)limTable[k-1])/log(2.0)); -#else +#endif #ifdef FIXED_POINT - nOctaves = DIV_R((limTable[k]<<REAL_BITS),REAL_CONST(limTable[k-1])); + nOctaves = SBR_DIV(REAL_CONST(limTable[k]),REAL_CONST(limTable[k-1])); #else nOctaves = (real_t)limTable[k]/(real_t)limTable[k-1]; #endif -#endif else nOctaves = 0; #if 0 - if ((MUL_R(nOctaves,limBands)) < REAL_CONST(0.49)) + if ((MUL(nOctaves,limBands)) < REAL_CONST(0.49)) #else if (nOctaves < limiterBandsCompare[s - 1]) #endif