comparison libfaad2/sbr_fbt.c @ 12527:4a370c80fe5c

update to the 2.0 release of faad, patch by adland
author diego
date Wed, 02 Jun 2004 22:59:04 +0000
parents 3185f64f6350
children d81145997036
comparison
equal deleted inserted replaced
12526:e183ad37d24c 12527:4a370c80fe5c
1 /* 1 /*
2 ** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding 2 ** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding
3 ** Copyright (C) 2003 M. Bakker, Ahead Software AG, http://www.nero.com 3 ** Copyright (C) 2003-2004 M. Bakker, Ahead Software AG, http://www.nero.com
4 ** 4 **
5 ** This program is free software; you can redistribute it and/or modify 5 ** This program is free software; you can redistribute it and/or modify
6 ** it under the terms of the GNU General Public License as published by 6 ** it under the terms of the GNU General Public License as published by
7 ** the Free Software Foundation; either version 2 of the License, or 7 ** the Free Software Foundation; either version 2 of the License, or
8 ** (at your option) any later version. 8 ** (at your option) any later version.
20 ** forbidden. 20 ** forbidden.
21 ** 21 **
22 ** Commercial non-GPL licensing of this software is possible. 22 ** Commercial non-GPL licensing of this software is possible.
23 ** For more info contact Ahead Software through Mpeg4AAClicense@nero.com. 23 ** For more info contact Ahead Software through Mpeg4AAClicense@nero.com.
24 ** 24 **
25 ** $Id: sbr_fbt.c,v 1.3 2003/09/09 18:37:32 menno Exp $ 25 ** $Id: sbr_fbt.c,v 1.2 2003/10/03 22:22:27 alex Exp $
26 **/ 26 **/
27 27
28 /* Calculate frequency band tables */ 28 /* Calculate frequency band tables */
29 29
30 #include "common.h" 30 #include "common.h"
34 34
35 #include <stdlib.h> 35 #include <stdlib.h>
36 36
37 #include "sbr_syntax.h" 37 #include "sbr_syntax.h"
38 #include "sbr_fbt.h" 38 #include "sbr_fbt.h"
39
40 /* static function declarations */
41 static int32_t find_bands(uint8_t warp, uint8_t bands, uint8_t a0, uint8_t a1);
42
39 43
40 /* calculate the start QMF channel for the master frequency band table */ 44 /* calculate the start QMF channel for the master frequency band table */
41 /* parameter is also called k0 */ 45 /* parameter is also called k0 */
42 uint8_t qmf_start_channel(uint8_t bs_start_freq, uint8_t bs_samplerate_mode, 46 uint8_t qmf_start_channel(uint8_t bs_start_freq, uint8_t bs_samplerate_mode,
43 uint32_t sample_rate) 47 uint32_t sample_rate)
96 } else { 100 } else {
97 return startMin + offset[6][bs_start_freq]; 101 return startMin + offset[6][bs_start_freq];
98 } 102 }
99 } 103 }
100 104
101 static int32_t longcmp(const void *a, const void *b) 105 static int longcmp(const void *a, const void *b)
102 { 106 {
103 return ((int32_t)(*(int32_t*)a - *(int32_t*)b)); 107 return ((int)(*(int32_t*)a - *(int32_t*)b));
104 } 108 }
105 109
106 /* calculate the stop QMF channel for the master frequency band table */ 110 /* calculate the stop QMF channel for the master frequency band table */
107 /* parameter is also called k2 */ 111 /* parameter is also called k2 */
108 uint8_t qmf_stop_channel(uint8_t bs_stop_freq, uint32_t sample_rate, 112 uint8_t qmf_stop_channel(uint8_t bs_stop_freq, uint32_t sample_rate,
178 /* calculate the master frequency table from k0, k2, bs_freq_scale 182 /* calculate the master frequency table from k0, k2, bs_freq_scale
179 and bs_alter_scale 183 and bs_alter_scale
180 184
181 version for bs_freq_scale = 0 185 version for bs_freq_scale = 0
182 */ 186 */
183 void master_frequency_table_fs0(sbr_info *sbr, uint8_t k0, uint8_t k2, 187 uint8_t master_frequency_table_fs0(sbr_info *sbr, uint8_t k0, uint8_t k2,
184 uint8_t bs_alter_scale) 188 uint8_t bs_alter_scale)
185 { 189 {
186 int8_t incr; 190 int8_t incr;
187 uint8_t k; 191 uint8_t k;
188 uint8_t dk; 192 uint8_t dk;
189 uint32_t nrBands, k2Achieved; 193 uint32_t nrBands, k2Achieved;
190 int32_t k2Diff, vDk[64]; 194 int32_t k2Diff, vDk[64] = {0};
191
192 memset(vDk, 0, 64*sizeof(int32_t));
193 195
194 /* mft only defined for k2 > k0 */ 196 /* mft only defined for k2 > k0 */
195 if (k2 <= k0) 197 if (k2 <= k0)
196 { 198 {
197 sbr->N_master = 0; 199 sbr->N_master = 0;
198 return; 200 return 0;
199 } 201 }
200 202
201 dk = bs_alter_scale ? 2 : 1; 203 dk = bs_alter_scale ? 2 : 1;
202 204
203 #if 0 /* replaced by float-less design */ 205 #if 0 /* replaced by float-less design */
209 } else { 211 } else {
210 nrBands = (((k2-k0)>>1)<<1); 212 nrBands = (((k2-k0)>>1)<<1);
211 } 213 }
212 #endif 214 #endif
213 nrBands = min(nrBands, 63); 215 nrBands = min(nrBands, 63);
216 if (nrBands <= 0)
217 return 1;
214 218
215 k2Achieved = k0 + nrBands * dk; 219 k2Achieved = k0 + nrBands * dk;
216 k2Diff = k2 - k2Achieved; 220 k2Diff = k2 - k2Achieved;
217 for (k = 0; k < nrBands; k++) 221 for (k = 0; k < nrBands; k++)
218 vDk[k] = dk; 222 vDk[k] = dk;
243 { 247 {
244 printf("%d ", sbr->f_master[k]); 248 printf("%d ", sbr->f_master[k]);
245 } 249 }
246 printf("\n"); 250 printf("\n");
247 #endif 251 #endif
248 } 252
249 253 return 0;
254 }
250 255
251 /* 256 /*
252 This function finds the number of bands using this formula: 257 This function finds the number of bands using this formula:
253 bands * log(a1/a0)/log(2.0) + 0.5 258 bands * log(a1/a0)/log(2.0) + 0.5
254 */ 259 */
255 static int32_t find_bands(uint8_t warp, uint8_t bands, uint8_t a0, uint8_t a1) 260 static int32_t find_bands(uint8_t warp, uint8_t bands, uint8_t a0, uint8_t a1)
256 { 261 {
262 #ifdef FIXED_POINT
263 /* table with log2() values */
264 static const real_t log2Table[65] = {
265 COEF_CONST(0.0), COEF_CONST(0.0), COEF_CONST(1.0000000000), COEF_CONST(1.5849625007),
266 COEF_CONST(2.0000000000), COEF_CONST(2.3219280949), COEF_CONST(2.5849625007), COEF_CONST(2.8073549221),
267 COEF_CONST(3.0000000000), COEF_CONST(3.1699250014), COEF_CONST(3.3219280949), COEF_CONST(3.4594316186),
268 COEF_CONST(3.5849625007), COEF_CONST(3.7004397181), COEF_CONST(3.8073549221), COEF_CONST(3.9068905956),
269 COEF_CONST(4.0000000000), COEF_CONST(4.0874628413), COEF_CONST(4.1699250014), COEF_CONST(4.2479275134),
270 COEF_CONST(4.3219280949), COEF_CONST(4.3923174228), COEF_CONST(4.4594316186), COEF_CONST(4.5235619561),
271 COEF_CONST(4.5849625007), COEF_CONST(4.6438561898), COEF_CONST(4.7004397181), COEF_CONST(4.7548875022),
272 COEF_CONST(4.8073549221), COEF_CONST(4.8579809951), COEF_CONST(4.9068905956), COEF_CONST(4.9541963104),
273 COEF_CONST(5.0000000000), COEF_CONST(5.0443941194), COEF_CONST(5.0874628413), COEF_CONST(5.1292830169),
274 COEF_CONST(5.1699250014), COEF_CONST(5.2094533656), COEF_CONST(5.2479275134), COEF_CONST(5.2854022189),
275 COEF_CONST(5.3219280949), COEF_CONST(5.3575520046), COEF_CONST(5.3923174228), COEF_CONST(5.4262647547),
276 COEF_CONST(5.4594316186), COEF_CONST(5.4918530963), COEF_CONST(5.5235619561), COEF_CONST(5.5545888517),
277 COEF_CONST(5.5849625007), COEF_CONST(5.6147098441), COEF_CONST(5.6438561898), COEF_CONST(5.6724253420),
278 COEF_CONST(5.7004397181), COEF_CONST(5.7279204546), COEF_CONST(5.7548875022), COEF_CONST(5.7813597135),
279 COEF_CONST(5.8073549221), COEF_CONST(5.8328900142), COEF_CONST(5.8579809951), COEF_CONST(5.8826430494),
280 COEF_CONST(5.9068905956), COEF_CONST(5.9307373376), COEF_CONST(5.9541963104), COEF_CONST(5.9772799235),
281 COEF_CONST(6.0)
282 };
283 real_t r0 = log2Table[a0]; /* coef */
284 real_t r1 = log2Table[a1]; /* coef */
285 real_t r2 = (r1 - r0); /* coef */
286
287 if (warp)
288 r2 = MUL_C(r2, COEF_CONST(1.0/1.3));
289
290 /* convert r2 to real and then multiply and round */
291 r2 = (r2 >> (COEF_BITS-REAL_BITS)) * bands + (1<<(REAL_BITS-1));
292
293 return (r2 >> REAL_BITS);
294 #else
257 real_t div = (real_t)log(2.0); 295 real_t div = (real_t)log(2.0);
258 if (warp) div *= (real_t)1.3; 296 if (warp) div *= (real_t)1.3;
259 297
260 return (int32_t)(bands * log((float)a1/(float)a0)/div + 0.5); 298 return (int32_t)(bands * log((float)a1/(float)a0)/div + 0.5);
261 } 299 #endif
262 300 }
301
302 static real_t find_initial_power(uint8_t bands, uint8_t a0, uint8_t a1)
303 {
304 #ifdef FIXED_POINT
305 /* table with log() values */
306 static const real_t logTable[65] = {
307 COEF_CONST(0.0), COEF_CONST(0.0), COEF_CONST(0.6931471806), COEF_CONST(1.0986122887),
308 COEF_CONST(1.3862943611), COEF_CONST(1.6094379124), COEF_CONST(1.7917594692), COEF_CONST(1.9459101491),
309 COEF_CONST(2.0794415417), COEF_CONST(2.1972245773), COEF_CONST(2.3025850930), COEF_CONST(2.3978952728),
310 COEF_CONST(2.4849066498), COEF_CONST(2.5649493575), COEF_CONST(2.6390573296), COEF_CONST(2.7080502011),
311 COEF_CONST(2.7725887222), COEF_CONST(2.8332133441), COEF_CONST(2.8903717579), COEF_CONST(2.9444389792),
312 COEF_CONST(2.9957322736), COEF_CONST(3.0445224377), COEF_CONST(3.0910424534), COEF_CONST(3.1354942159),
313 COEF_CONST(3.1780538303), COEF_CONST(3.2188758249), COEF_CONST(3.2580965380), COEF_CONST(3.2958368660),
314 COEF_CONST(3.3322045102), COEF_CONST(3.3672958300), COEF_CONST(3.4011973817), COEF_CONST(3.4339872045),
315 COEF_CONST(3.4657359028), COEF_CONST(3.4965075615), COEF_CONST(3.5263605246), COEF_CONST(3.5553480615),
316 COEF_CONST(3.5835189385), COEF_CONST(3.6109179126), COEF_CONST(3.6375861597), COEF_CONST(3.6635616461),
317 COEF_CONST(3.6888794541), COEF_CONST(3.7135720667), COEF_CONST(3.7376696183), COEF_CONST(3.7612001157),
318 COEF_CONST(3.7841896339), COEF_CONST(3.8066624898), COEF_CONST(3.8286413965), COEF_CONST(3.8501476017),
319 COEF_CONST(3.8712010109), COEF_CONST(3.8918202981), COEF_CONST(3.9120230054), COEF_CONST(3.9318256327),
320 COEF_CONST(3.9512437186), COEF_CONST(3.9702919136), COEF_CONST(3.9889840466), COEF_CONST(4.0073331852),
321 COEF_CONST(4.0253516907), COEF_CONST(4.0430512678), COEF_CONST(4.0604430105), COEF_CONST(4.0775374439),
322 COEF_CONST(4.0943445622), COEF_CONST(4.1108738642), COEF_CONST(4.1271343850), COEF_CONST(4.1431347264),
323 COEF_CONST(4.158883083)
324 };
325 /* standard Taylor polynomial coefficients for exp(x) around 0 */
326 /* a polynomial around x=1 is more precise, as most values are around 1.07,
327 but this is just fine already */
328 static const real_t c1 = COEF_CONST(1.0);
329 static const real_t c2 = COEF_CONST(1.0/2.0);
330 static const real_t c3 = COEF_CONST(1.0/6.0);
331 static const real_t c4 = COEF_CONST(1.0/24.0);
332
333 real_t r0 = logTable[a0]; /* coef */
334 real_t r1 = logTable[a1]; /* coef */
335 real_t r2 = (r1 - r0) / bands; /* coef */
336 real_t rexp = c1 + MUL_C((c1 + MUL_C((c2 + MUL_C((c3 + MUL_C(c4,r2)), r2)), r2)), r2);
337
338 return (rexp >> (COEF_BITS-REAL_BITS)); /* real */
339 #else
340 return (real_t)pow((real_t)a1/(real_t)a0, 1.0/(real_t)bands);
341 #endif
342 }
263 343
264 /* 344 /*
265 version for bs_freq_scale > 0 345 version for bs_freq_scale > 0
266 */ 346 */
267 void master_frequency_table(sbr_info *sbr, uint8_t k0, uint8_t k2, 347 uint8_t master_frequency_table(sbr_info *sbr, uint8_t k0, uint8_t k2,
268 uint8_t bs_freq_scale, uint8_t bs_alter_scale) 348 uint8_t bs_freq_scale, uint8_t bs_alter_scale)
269 { 349 {
270 uint8_t k, bands, twoRegions; 350 uint8_t k, bands, twoRegions;
271 uint8_t k1; 351 uint8_t k1;
272 uint32_t nrBand0, nrBand1; 352 uint8_t nrBand0, nrBand1;
273 int32_t vDk0[64], vDk1[64]; 353 int32_t vDk0[64] = {0}, vDk1[64] = {0};
274 int32_t vk0[64], vk1[64]; 354 int32_t vk0[64] = {0}, vk1[64] = {0};
275 uint8_t temp1[] = { 6, 5, 4 }; 355 uint8_t temp1[] = { 6, 5, 4 };
276 356 real_t q, qk;
277 /* without memset code enters infinite loop, 357 int32_t A_1;
278 so there must be some wrong table access */
279 memset(vDk0, 0, 64*sizeof(int32_t));
280 memset(vDk1, 0, 64*sizeof(int32_t));
281 memset(vk0, 0, 64*sizeof(int32_t));
282 memset(vk1, 0, 64*sizeof(int32_t));
283 358
284 /* mft only defined for k2 > k0 */ 359 /* mft only defined for k2 > k0 */
285 if (k2 <= k0) 360 if (k2 <= k0)
286 { 361 {
287 sbr->N_master = 0; 362 sbr->N_master = 0;
288 return; 363 return 0;
289 } 364 }
290 365
291 bands = temp1[bs_freq_scale-1]; 366 bands = temp1[bs_freq_scale-1];
292 367
368 #ifdef FIXED_POINT
369 if (REAL_CONST(k2) > MUL_R(REAL_CONST(k0),REAL_CONST(2.2449)))
370 #else
293 if ((float)k2/(float)k0 > 2.2449) 371 if ((float)k2/(float)k0 > 2.2449)
372 #endif
294 { 373 {
295 twoRegions = 1; 374 twoRegions = 1;
296 k1 = k0 << 1; 375 k1 = k0 << 1;
297 } else { 376 } else {
298 twoRegions = 0; 377 twoRegions = 0;
299 k1 = k2; 378 k1 = k2;
300 } 379 }
301 380
302 nrBand0 = 2 * find_bands(0, bands, k0, k1); 381 nrBand0 = 2 * find_bands(0, bands, k0, k1);
303 nrBand0 = min(nrBand0, 63); 382 nrBand0 = min(nrBand0, 63);
304 383 if (nrBand0 <= 0)
384 return 1;
385
386 q = find_initial_power(nrBand0, k0, k1);
387 qk = REAL_CONST(k0);
388 #ifdef FIXED_POINT
389 A_1 = (int32_t)((qk + REAL_CONST(0.5)) >> REAL_BITS);
390 #else
391 A_1 = (int32_t)(qk + .5);
392 #endif
305 for (k = 0; k <= nrBand0; k++) 393 for (k = 0; k <= nrBand0; k++)
306 { 394 {
307 /* diverging power series */ 395 int32_t A_0 = A_1;
308 vDk0[k] = (int32_t)(k0 * pow((float)k1/(float)k0, (k+1)/(float)nrBand0)+0.5) - 396 #ifdef FIXED_POINT
309 (int32_t)(k0 * pow((float)k1/(float)k0, k/(float)nrBand0)+0.5); 397 qk = MUL_R(qk,q);
398 A_1 = (int32_t)((qk + REAL_CONST(0.5)) >> REAL_BITS);
399 #else
400 qk *= q;
401 A_1 = (int32_t)(qk + 0.5);
402 #endif
403 vDk0[k] = A_1 - A_0;
310 } 404 }
311 405
312 /* needed? */ 406 /* needed? */
313 qsort(vDk0, nrBand0, sizeof(vDk0[0]), longcmp); 407 qsort(vDk0, nrBand0, sizeof(vDk0[0]), longcmp);
314 408
315 vk0[0] = k0; 409 vk0[0] = k0;
316 for (k = 1; k <= nrBand0; k++) 410 for (k = 1; k <= nrBand0; k++)
317 { 411 {
318 vk0[k] = vk0[k-1] + vDk0[k-1]; 412 vk0[k] = vk0[k-1] + vDk0[k-1];
413 if (vDk0[k-1] == 0)
414 return 1;
319 } 415 }
320 416
321 if (!twoRegions) 417 if (!twoRegions)
322 { 418 {
323 for (k = 0; k <= nrBand0; k++) 419 for (k = 0; k <= nrBand0; k++)
324 sbr->f_master[k] = vk0[k]; 420 sbr->f_master[k] = vk0[k];
325 421
326 sbr->N_master = nrBand0; 422 sbr->N_master = nrBand0;
327 sbr->N_master = min(sbr->N_master, 64); 423 sbr->N_master = min(sbr->N_master, 64);
328 return; 424 return 0;
329 } 425 }
330 426
331 nrBand1 = 2 * find_bands(1 /* warped */, bands, k1, k2); 427 nrBand1 = 2 * find_bands(1 /* warped */, bands, k1, k2);
332 nrBand1 = min(nrBand1, 63); 428 nrBand1 = min(nrBand1, 63);
333 429
430 q = find_initial_power(nrBand1, k1, k2);
431 qk = REAL_CONST(k1);
432 #ifdef FIXED_POINT
433 A_1 = (int32_t)((qk + REAL_CONST(0.5)) >> REAL_BITS);
434 #else
435 A_1 = (int32_t)(qk + .5);
436 #endif
334 for (k = 0; k <= nrBand1 - 1; k++) 437 for (k = 0; k <= nrBand1 - 1; k++)
335 { 438 {
336 vDk1[k] = (int32_t)(k1 * pow((float)k2/(float)k1, (k+1)/(float)nrBand1)+0.5) - 439 int32_t A_0 = A_1;
337 (int32_t)(k1 * pow((float)k2/(float)k1, k/(float)nrBand1)+0.5); 440 #ifdef FIXED_POINT
441 qk = MUL_R(qk,q);
442 A_1 = (int32_t)((qk + REAL_CONST(0.5)) >> REAL_BITS);
443 #else
444 qk *= q;
445 A_1 = (int32_t)(qk + 0.5);
446 #endif
447 vDk1[k] = A_1 - A_0;
338 } 448 }
339 449
340 if (vDk1[0] < vDk0[nrBand0 - 1]) 450 if (vDk1[0] < vDk0[nrBand0 - 1])
341 { 451 {
342 int32_t change; 452 int32_t change;
352 qsort(vDk1, nrBand1, sizeof(vDk1[0]), longcmp); 462 qsort(vDk1, nrBand1, sizeof(vDk1[0]), longcmp);
353 vk1[0] = k1; 463 vk1[0] = k1;
354 for (k = 1; k <= nrBand1; k++) 464 for (k = 1; k <= nrBand1; k++)
355 { 465 {
356 vk1[k] = vk1[k-1] + vDk1[k-1]; 466 vk1[k] = vk1[k-1] + vDk1[k-1];
467 if (vDk1[k-1] == 0)
468 return 1;
357 } 469 }
358 470
359 sbr->N_master = nrBand0 + nrBand1; 471 sbr->N_master = nrBand0 + nrBand1;
360 sbr->N_master = min(sbr->N_master, 64); 472 sbr->N_master = min(sbr->N_master, 64);
361 for (k = 0; k <= nrBand0; k++) 473 for (k = 0; k <= nrBand0; k++)
373 { 485 {
374 printf("%d ", sbr->f_master[k]); 486 printf("%d ", sbr->f_master[k]);
375 } 487 }
376 printf("\n"); 488 printf("\n");
377 #endif 489 #endif
490
491 return 0;
378 } 492 }
379 493
380 /* calculate the derived frequency border tables from f_master */ 494 /* calculate the derived frequency border tables from f_master */
381 uint8_t derived_frequency_table(sbr_info *sbr, uint8_t bs_xover_band, 495 uint8_t derived_frequency_table(sbr_info *sbr, uint8_t bs_xover_band,
382 uint8_t k2) 496 uint8_t k2)
399 sbr->f_table_res[HI_RES][k] = sbr->f_master[k + bs_xover_band]; 513 sbr->f_table_res[HI_RES][k] = sbr->f_master[k + bs_xover_band];
400 } 514 }
401 515
402 sbr->M = sbr->f_table_res[HI_RES][sbr->N_high] - sbr->f_table_res[HI_RES][0]; 516 sbr->M = sbr->f_table_res[HI_RES][sbr->N_high] - sbr->f_table_res[HI_RES][0];
403 sbr->kx = sbr->f_table_res[HI_RES][0]; 517 sbr->kx = sbr->f_table_res[HI_RES][0];
518 if (sbr->kx > 32)
519 return 1;
520 if (sbr->kx + sbr->M > 64)
521 return 1;
404 522
405 minus = (sbr->N_high & 1) ? 1 : 0; 523 minus = (sbr->N_high & 1) ? 1 : 0;
406 524
407 for (k = 0; k <= sbr->N_low; k++) 525 for (k = 0; k <= sbr->N_low; k++)
408 { 526 {
438 #if 0 556 #if 0
439 sbr->N_Q = max(1, (int32_t)(sbr->bs_noise_bands*(log(k2/(float)sbr->kx)/log(2.0)) + 0.5)); 557 sbr->N_Q = max(1, (int32_t)(sbr->bs_noise_bands*(log(k2/(float)sbr->kx)/log(2.0)) + 0.5));
440 #else 558 #else
441 sbr->N_Q = max(1, find_bands(0, sbr->bs_noise_bands, sbr->kx, k2)); 559 sbr->N_Q = max(1, find_bands(0, sbr->bs_noise_bands, sbr->kx, k2));
442 #endif 560 #endif
443 sbr->N_Q = min(5, sbr->N_Q); 561 sbr->N_Q = min(5, sbr->N_Q);
444 } 562 }
445 563
446 for (k = 0; k <= sbr->N_Q; k++) 564 for (k = 0; k <= sbr->N_Q; k++)
447 { 565 {
448 if (k == 0) 566 if (k == 0)
449 { 567 {
450 i = 0; 568 i = 0;
451 } else { /* is this accurate? */ 569 } else {
452 //i = i + (int32_t)((sbr->N_low - i)/(sbr->N_Q + 1 - k)); 570 /* i = i + (int32_t)((sbr->N_low - i)/(sbr->N_Q + 1 - k)); */
453 i = i + (sbr->N_low - i)/(sbr->N_Q + 1 - k); 571 i = i + (sbr->N_low - i)/(sbr->N_Q + 1 - k);
454 } 572 }
455 sbr->f_table_noise[k] = sbr->f_table_res[LO_RES][i]; 573 sbr->f_table_noise[k] = sbr->f_table_res[LO_RES][i];
456 } 574 }
457 575
496 static const real_t limiterBandsCompare[] = { REAL_CONST(1.328125), 614 static const real_t limiterBandsCompare[] = { REAL_CONST(1.328125),
497 REAL_CONST(1.1875), REAL_CONST(1.125) }; 615 REAL_CONST(1.1875), REAL_CONST(1.125) };
498 #endif 616 #endif
499 uint8_t k, s; 617 uint8_t k, s;
500 int8_t nrLim; 618 int8_t nrLim;
501 int32_t limTable[100 /*TODO*/];
502 uint8_t patchBorders[64/*??*/];
503 #if 0 619 #if 0
504 real_t limBands; 620 real_t limBands;
505 #endif 621 #endif
506 622
507 sbr->f_table_lim[0][0] = sbr->f_table_res[LO_RES][0] - sbr->kx; 623 sbr->f_table_lim[0][0] = sbr->f_table_res[LO_RES][0] - sbr->kx;
508 sbr->f_table_lim[0][1] = sbr->f_table_res[LO_RES][sbr->N_low] - sbr->kx; 624 sbr->f_table_lim[0][1] = sbr->f_table_res[LO_RES][sbr->N_low] - sbr->kx;
509 sbr->N_L[0] = 1; 625 sbr->N_L[0] = 1;
510 626
511 for (s = 1; s < 4; s++) 627 for (s = 1; s < 4; s++)
512 { 628 {
513 memset(limTable, 0, 100*sizeof(int32_t)); 629 int32_t limTable[100 /*TODO*/] = {0};
630 uint8_t patchBorders[64/*??*/] = {0};
514 631
515 #if 0 632 #if 0
516 limBands = limiterBandsPerOctave[s - 1]; 633 limBands = limiterBandsPerOctave[s - 1];
517 #endif 634 #endif
518 635
546 663
547 if (limTable[k-1] != 0) 664 if (limTable[k-1] != 0)
548 #if 0 665 #if 0
549 nOctaves = REAL_CONST(log((float)limTable[k]/(float)limTable[k-1])/log(2.0)); 666 nOctaves = REAL_CONST(log((float)limTable[k]/(float)limTable[k-1])/log(2.0));
550 #endif 667 #endif
668 #ifdef FIXED_POINT
669 nOctaves = SBR_DIV(REAL_CONST(limTable[k]),REAL_CONST(limTable[k-1]));
670 #else
551 nOctaves = (real_t)limTable[k]/(real_t)limTable[k-1]; 671 nOctaves = (real_t)limTable[k]/(real_t)limTable[k-1];
672 #endif
552 else 673 else
553 nOctaves = 0; 674 nOctaves = 0;
554 675
555 #if 0 676 #if 0
556 if ((MUL(nOctaves,limBands)) < REAL_CONST(0.49)) 677 if ((MUL(nOctaves,limBands)) < REAL_CONST(0.49))