2 ** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding
3 ** Copyright (C) 2003-2005 M. Bakker, Nero AG, http://www.nero.com
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
7 ** the Free Software Foundation; either version 2 of the License, or
8 ** (at your option) any later version.
10 ** This program is distributed in the hope that it will be useful,
11 ** but WITHOUT ANY WARRANTY; without even the implied warranty of
12 ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 ** GNU General Public License for more details.
15 ** You should have received a copy of the GNU General Public License
16 ** along with this program; if not, write to the Free Software
17 ** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
19 ** Any non-GPL usage of this software or parts of this software is strictly
22 ** The "appropriate copyright message" mentioned in section 2c of the GPLv2
23 ** must read: "Code from FAAD2 is copyright (c) Nero AG, www.nero.com"
25 ** Commercial non-GPL licensing of this software is possible.
26 ** For more info contact Nero AG through Mpeg4AAClicense@nero.com.
28 ** $Id: sbr_hfgen.c,v 1.26 2007/11/01 12:33:35 menno Exp $
31 /* High Frequency generation */
42 /* static function declarations */
44 static void calc_prediction_coef_lp(sbr_info *sbr, qmf_t Xlow[MAX_NTSRHFG][64],
45 complex_t *alpha_0, complex_t *alpha_1, real_t *rxx);
46 static void calc_aliasing_degree(sbr_info *sbr, real_t *rxx, real_t *deg);
48 static void calc_prediction_coef(sbr_info *sbr, qmf_t Xlow[MAX_NTSRHFG][64],
49 complex_t *alpha_0, complex_t *alpha_1, uint8_t k);
51 static void calc_chirp_factors(sbr_info *sbr, uint8_t ch);
52 static void patch_construction(sbr_info *sbr);
55 void hf_generation(sbr_info *sbr, qmf_t Xlow[MAX_NTSRHFG][64],
56 qmf_t Xhigh[MAX_NTSRHFG][64]
63 ALIGN complex_t alpha_0[64], alpha_1[64];
68 uint8_t offset = sbr->tHFAdj;
69 uint8_t first = sbr->t_E[ch][0];
70 uint8_t last = sbr->t_E[ch][sbr->L_E[ch]];
72 calc_chirp_factors(sbr, ch);
75 memset(deg, 0, 64*sizeof(real_t));
78 if ((ch == 0) && (sbr->Reset))
79 patch_construction(sbr);
81 /* calculate the prediction coefficients */
83 calc_prediction_coef_lp(sbr, Xlow, alpha_0, alpha_1, rxx);
84 calc_aliasing_degree(sbr, rxx, deg);
87 /* actual HF generation */
88 for (i = 0; i < sbr->noPatches; i++)
90 for (x = 0; x < sbr->patchNoSubbands[i]; x++)
92 real_t a0_r, a0_i, a1_r, a1_i;
96 /* find the low and high band for patching */
98 for (q = 0; q < i; q++)
100 k += sbr->patchNoSubbands[q];
102 p = sbr->patchStartSubband[i] + x;
105 if (x != 0 /*x < sbr->patchNoSubbands[i]-1*/)
111 g = sbr->table_map_k_to_g[k];
113 bw = sbr->bwArray[ch][g];
116 /* do the patching */
117 /* with or without filtering */
120 real_t temp1_r, temp2_r, temp3_r;
121 #ifndef SBR_LOW_POWER
122 real_t temp1_i, temp2_i, temp3_i;
123 calc_prediction_coef(sbr, Xlow, alpha_0, alpha_1, p);
126 a0_r = MUL_C(RE(alpha_0[p]), bw);
127 a1_r = MUL_C(RE(alpha_1[p]), bw2);
128 #ifndef SBR_LOW_POWER
129 a0_i = MUL_C(IM(alpha_0[p]), bw);
130 a1_i = MUL_C(IM(alpha_1[p]), bw2);
133 temp2_r = QMF_RE(Xlow[first - 2 + offset][p]);
134 temp3_r = QMF_RE(Xlow[first - 1 + offset][p]);
135 #ifndef SBR_LOW_POWER
136 temp2_i = QMF_IM(Xlow[first - 2 + offset][p]);
137 temp3_i = QMF_IM(Xlow[first - 1 + offset][p]);
139 for (l = first; l < last; l++)
143 temp3_r = QMF_RE(Xlow[l + offset][p]);
144 #ifndef SBR_LOW_POWER
147 temp3_i = QMF_IM(Xlow[l + offset][p]);
151 QMF_RE(Xhigh[l + offset][k]) =
153 +(MUL_R(a0_r, temp2_r) +
154 MUL_R(a1_r, temp1_r));
156 QMF_RE(Xhigh[l + offset][k]) =
158 +(MUL_R(a0_r, temp2_r) -
159 MUL_R(a0_i, temp2_i) +
160 MUL_R(a1_r, temp1_r) -
161 MUL_R(a1_i, temp1_i));
162 QMF_IM(Xhigh[l + offset][k]) =
164 +(MUL_R(a0_i, temp2_r) +
165 MUL_R(a0_r, temp2_i) +
166 MUL_R(a1_i, temp1_r) +
167 MUL_R(a1_r, temp1_i));
171 for (l = first; l < last; l++)
173 QMF_RE(Xhigh[l + offset][k]) = QMF_RE(Xlow[l + offset][p]);
174 #ifndef SBR_LOW_POWER
175 QMF_IM(Xhigh[l + offset][k]) = QMF_IM(Xlow[l + offset][p]);
184 limiter_frequency_table(sbr);
199 static void auto_correlation(sbr_info *sbr, acorr_coef *ac,
200 qmf_t buffer[MAX_NTSRHFG][64],
201 uint8_t bd, uint8_t len)
203 real_t r01 = 0, r02 = 0, r11 = 0;
205 uint8_t offset = sbr->tHFAdj;
207 const real_t rel = FRAC_CONST(0.999999); // 1 / (1 + 1e-6f);
211 const real_t rel = 1 / (1 + 1e-6f);
218 for (j = (offset-2); j < (len + offset); j++)
221 x = QMF_RE(buffer[j][bd])>>REAL_BITS;
222 mask |= x ^ (x >> 31);
225 exp = wl_min_lzc(mask);
227 /* improves accuracy */
231 for (j = offset; j < len + offset; j++)
233 real_t buf_j = ((QMF_RE(buffer[j][bd])+(1<<(exp-1)))>>exp);
234 real_t buf_j_1 = ((QMF_RE(buffer[j-1][bd])+(1<<(exp-1)))>>exp);
235 real_t buf_j_2 = ((QMF_RE(buffer[j-2][bd])+(1<<(exp-1)))>>exp);
237 /* normalisation with rounding */
238 r01 += MUL_R(buf_j, buf_j_1);
239 r02 += MUL_R(buf_j, buf_j_2);
240 r11 += MUL_R(buf_j_1, buf_j_1);
243 MUL_R(((QMF_RE(buffer[len+offset-1][bd])+(1<<(exp-1)))>>exp), ((QMF_RE(buffer[len+offset-2][bd])+(1<<(exp-1)))>>exp)) +
244 MUL_R(((QMF_RE(buffer[offset-1][bd])+(1<<(exp-1)))>>exp), ((QMF_RE(buffer[offset-2][bd])+(1<<(exp-1)))>>exp));
246 MUL_R(((QMF_RE(buffer[len+offset-2][bd])+(1<<(exp-1)))>>exp), ((QMF_RE(buffer[len+offset-2][bd])+(1<<(exp-1)))>>exp)) +
247 MUL_R(((QMF_RE(buffer[offset-2][bd])+(1<<(exp-1)))>>exp), ((QMF_RE(buffer[offset-2][bd])+(1<<(exp-1)))>>exp));
249 for (j = offset; j < len + offset; j++)
251 r01 += QMF_RE(buffer[j][bd]) * QMF_RE(buffer[j-1][bd]);
252 r02 += QMF_RE(buffer[j][bd]) * QMF_RE(buffer[j-2][bd]);
253 r11 += QMF_RE(buffer[j-1][bd]) * QMF_RE(buffer[j-1][bd]);
256 QMF_RE(buffer[len+offset-1][bd]) * QMF_RE(buffer[len+offset-2][bd]) +
257 QMF_RE(buffer[offset-1][bd]) * QMF_RE(buffer[offset-2][bd]);
259 QMF_RE(buffer[len+offset-2][bd]) * QMF_RE(buffer[len+offset-2][bd]) +
260 QMF_RE(buffer[offset-2][bd]) * QMF_RE(buffer[offset-2][bd]);
266 ac->det = MUL_R(RE(ac->r11), RE(ac->r22)) - MUL_F(MUL_R(RE(ac->r12), RE(ac->r12)), rel);
269 static void auto_correlation(sbr_info *sbr, acorr_coef *ac, qmf_t buffer[MAX_NTSRHFG][64],
270 uint8_t bd, uint8_t len)
272 real_t r01r = 0, r01i = 0, r02r = 0, r02i = 0, r11r = 0;
273 real_t temp1_r, temp1_i, temp2_r, temp2_i, temp3_r, temp3_i, temp4_r, temp4_i, temp5_r, temp5_i;
275 const real_t rel = FRAC_CONST(0.999999); // 1 / (1 + 1e-6f);
279 const real_t rel = 1 / (1 + 1e-6f);
282 uint8_t offset = sbr->tHFAdj;
287 for (j = (offset-2); j < (len + offset); j++)
290 x = QMF_RE(buffer[j][bd])>>REAL_BITS;
291 mask |= x ^ (x >> 31);
292 x = QMF_IM(buffer[j][bd])>>REAL_BITS;
293 mask |= x ^ (x >> 31);
296 exp = wl_min_lzc(mask);
298 /* improves accuracy */
302 pow2_to_exp = 1<<(exp-1);
304 temp2_r = (QMF_RE(buffer[offset-2][bd]) + pow2_to_exp) >> exp;
305 temp2_i = (QMF_IM(buffer[offset-2][bd]) + pow2_to_exp) >> exp;
306 temp3_r = (QMF_RE(buffer[offset-1][bd]) + pow2_to_exp) >> exp;
307 temp3_i = (QMF_IM(buffer[offset-1][bd]) + pow2_to_exp) >> exp;
308 // Save these because they are needed after loop
314 for (j = offset; j < len + offset; j++)
316 temp1_r = temp2_r; // temp1_r = (QMF_RE(buffer[offset-2][bd] + (1<<(exp-1))) >> exp;
317 temp1_i = temp2_i; // temp1_i = (QMF_IM(buffer[offset-2][bd] + (1<<(exp-1))) >> exp;
318 temp2_r = temp3_r; // temp2_r = (QMF_RE(buffer[offset-1][bd] + (1<<(exp-1))) >> exp;
319 temp2_i = temp3_i; // temp2_i = (QMF_IM(buffer[offset-1][bd] + (1<<(exp-1))) >> exp;
320 temp3_r = (QMF_RE(buffer[j][bd]) + pow2_to_exp) >> exp;
321 temp3_i = (QMF_IM(buffer[j][bd]) + pow2_to_exp) >> exp;
322 r01r += MUL_R(temp3_r, temp2_r) + MUL_R(temp3_i, temp2_i);
323 r01i += MUL_R(temp3_i, temp2_r) - MUL_R(temp3_r, temp2_i);
324 r02r += MUL_R(temp3_r, temp1_r) + MUL_R(temp3_i, temp1_i);
325 r02i += MUL_R(temp3_i, temp1_r) - MUL_R(temp3_r, temp1_i);
326 r11r += MUL_R(temp2_r, temp2_r) + MUL_R(temp2_i, temp2_i);
329 // These are actual values in temporary variable at this point
330 // temp1_r = (QMF_RE(buffer[len+offset-1-2][bd] + (1<<(exp-1))) >> exp;
331 // temp1_i = (QMF_IM(buffer[len+offset-1-2][bd] + (1<<(exp-1))) >> exp;
332 // temp2_r = (QMF_RE(buffer[len+offset-1-1][bd] + (1<<(exp-1))) >> exp;
333 // temp2_i = (QMF_IM(buffer[len+offset-1-1][bd] + (1<<(exp-1))) >> exp;
334 // temp3_r = (QMF_RE(buffer[len+offset-1][bd]) + (1<<(exp-1))) >> exp;
335 // temp3_i = (QMF_IM(buffer[len+offset-1][bd]) + (1<<(exp-1))) >> exp;
336 // temp4_r = (QMF_RE(buffer[offset-2][bd]) + (1<<(exp-1))) >> exp;
337 // temp4_i = (QMF_IM(buffer[offset-2][bd]) + (1<<(exp-1))) >> exp;
338 // temp5_r = (QMF_RE(buffer[offset-1][bd]) + (1<<(exp-1))) >> exp;
339 // temp5_i = (QMF_IM(buffer[offset-1][bd]) + (1<<(exp-1))) >> exp;
342 (MUL_R(temp3_r, temp2_r) + MUL_R(temp3_i, temp2_i)) +
343 (MUL_R(temp5_r, temp4_r) + MUL_R(temp5_i, temp4_i));
345 (MUL_R(temp3_i, temp2_r) - MUL_R(temp3_r, temp2_i)) +
346 (MUL_R(temp5_i, temp4_r) - MUL_R(temp5_r, temp4_i));
348 (MUL_R(temp2_r, temp2_r) + MUL_R(temp2_i, temp2_i)) +
349 (MUL_R(temp4_r, temp4_r) + MUL_R(temp4_i, temp4_i));
353 temp2_r = QMF_RE(buffer[offset-2][bd]);
354 temp2_i = QMF_IM(buffer[offset-2][bd]);
355 temp3_r = QMF_RE(buffer[offset-1][bd]);
356 temp3_i = QMF_IM(buffer[offset-1][bd]);
357 // Save these because they are needed after loop
363 for (j = offset; j < len + offset; j++)
365 temp1_r = temp2_r; // temp1_r = QMF_RE(buffer[j-2][bd];
366 temp1_i = temp2_i; // temp1_i = QMF_IM(buffer[j-2][bd];
367 temp2_r = temp3_r; // temp2_r = QMF_RE(buffer[j-1][bd];
368 temp2_i = temp3_i; // temp2_i = QMF_IM(buffer[j-1][bd];
369 temp3_r = QMF_RE(buffer[j][bd]);
370 temp3_i = QMF_IM(buffer[j][bd]);
371 r01r += temp3_r * temp2_r + temp3_i * temp2_i;
372 r01i += temp3_i * temp2_r - temp3_r * temp2_i;
373 r02r += temp3_r * temp1_r + temp3_i * temp1_i;
374 r02i += temp3_i * temp1_r - temp3_r * temp1_i;
375 r11r += temp2_r * temp2_r + temp2_i * temp2_i;
378 // These are actual values in temporary variable at this point
379 // temp1_r = QMF_RE(buffer[len+offset-1-2][bd];
380 // temp1_i = QMF_IM(buffer[len+offset-1-2][bd];
381 // temp2_r = QMF_RE(buffer[len+offset-1-1][bd];
382 // temp2_i = QMF_IM(buffer[len+offset-1-1][bd];
383 // temp3_r = QMF_RE(buffer[len+offset-1][bd]);
384 // temp3_i = QMF_IM(buffer[len+offset-1][bd]);
385 // temp4_r = QMF_RE(buffer[offset-2][bd]);
386 // temp4_i = QMF_IM(buffer[offset-2][bd]);
387 // temp5_r = QMF_RE(buffer[offset-1][bd]);
388 // temp5_i = QMF_IM(buffer[offset-1][bd]);
391 (temp3_r * temp2_r + temp3_i * temp2_i) +
392 (temp5_r * temp4_r + temp5_i * temp4_i);
394 (temp3_i * temp2_r - temp3_r * temp2_i) +
395 (temp5_i * temp4_r - temp5_r * temp4_i);
397 (temp2_r * temp2_r + temp2_i * temp2_i) +
398 (temp4_r * temp4_r + temp4_i * temp4_i);
408 ac->det = MUL_R(RE(ac->r11), RE(ac->r22)) - MUL_F(rel, (MUL_R(RE(ac->r12), RE(ac->r12)) + MUL_R(IM(ac->r12), IM(ac->r12))));
412 /* calculate linear prediction coefficients using the covariance method */
413 #ifndef SBR_LOW_POWER
414 static void calc_prediction_coef(sbr_info *sbr, qmf_t Xlow[MAX_NTSRHFG][64],
415 complex_t *alpha_0, complex_t *alpha_1, uint8_t k)
420 auto_correlation(sbr, &ac, Xlow, k, sbr->numTimeSlotsRate + 6);
428 tmp = (MUL_R(RE(ac.r01), RE(ac.r12)) - MUL_R(IM(ac.r01), IM(ac.r12)) - MUL_R(RE(ac.r02), RE(ac.r11)));
429 RE(alpha_1[k]) = DIV_R(tmp, ac.det);
430 tmp = (MUL_R(IM(ac.r01), RE(ac.r12)) + MUL_R(RE(ac.r01), IM(ac.r12)) - MUL_R(IM(ac.r02), RE(ac.r11)));
431 IM(alpha_1[k]) = DIV_R(tmp, ac.det);
433 tmp = REAL_CONST(1.0) / ac.det;
434 RE(alpha_1[k]) = (MUL_R(RE(ac.r01), RE(ac.r12)) - MUL_R(IM(ac.r01), IM(ac.r12)) - MUL_R(RE(ac.r02), RE(ac.r11))) * tmp;
435 IM(alpha_1[k]) = (MUL_R(IM(ac.r01), RE(ac.r12)) + MUL_R(RE(ac.r01), IM(ac.r12)) - MUL_R(IM(ac.r02), RE(ac.r11))) * tmp;
445 tmp = -(RE(ac.r01) + MUL_R(RE(alpha_1[k]), RE(ac.r12)) + MUL_R(IM(alpha_1[k]), IM(ac.r12)));
446 RE(alpha_0[k]) = DIV_R(tmp, RE(ac.r11));
447 tmp = -(IM(ac.r01) + MUL_R(IM(alpha_1[k]), RE(ac.r12)) - MUL_R(RE(alpha_1[k]), IM(ac.r12)));
448 IM(alpha_0[k]) = DIV_R(tmp, RE(ac.r11));
450 tmp = 1.0f / RE(ac.r11);
451 RE(alpha_0[k]) = -(RE(ac.r01) + MUL_R(RE(alpha_1[k]), RE(ac.r12)) + MUL_R(IM(alpha_1[k]), IM(ac.r12))) * tmp;
452 IM(alpha_0[k]) = -(IM(ac.r01) + MUL_R(IM(alpha_1[k]), RE(ac.r12)) - MUL_R(RE(alpha_1[k]), IM(ac.r12))) * tmp;
456 if ((MUL_R(RE(alpha_0[k]),RE(alpha_0[k])) + MUL_R(IM(alpha_0[k]),IM(alpha_0[k])) >= REAL_CONST(16)) ||
457 (MUL_R(RE(alpha_1[k]),RE(alpha_1[k])) + MUL_R(IM(alpha_1[k]),IM(alpha_1[k])) >= REAL_CONST(16)))
466 static void calc_prediction_coef_lp(sbr_info *sbr, qmf_t Xlow[MAX_NTSRHFG][64],
467 complex_t *alpha_0, complex_t *alpha_1, real_t *rxx)
473 for (k = 1; k < sbr->f_master[0]; k++)
475 auto_correlation(sbr, &ac, Xlow, k, sbr->numTimeSlotsRate + 6);
482 tmp = MUL_R(RE(ac.r01), RE(ac.r22)) - MUL_R(RE(ac.r12), RE(ac.r02));
483 RE(alpha_0[k]) = DIV_R(tmp, (-ac.det));
485 tmp = MUL_R(RE(ac.r01), RE(ac.r12)) - MUL_R(RE(ac.r02), RE(ac.r11));
486 RE(alpha_1[k]) = DIV_R(tmp, ac.det);
489 if ((RE(alpha_0[k]) >= REAL_CONST(4)) || (RE(alpha_1[k]) >= REAL_CONST(4)))
491 RE(alpha_0[k]) = REAL_CONST(0);
492 RE(alpha_1[k]) = REAL_CONST(0);
495 /* reflection coefficient */
498 rxx[k] = COEF_CONST(0.0);
500 rxx[k] = DIV_C(RE(ac.r01), RE(ac.r11));
502 if (rxx[k] > COEF_CONST(1.0)) rxx[k] = COEF_CONST(1.0);
503 if (rxx[k] < COEF_CONST(-1.0)) rxx[k] = COEF_CONST(-1.0);
508 static void calc_aliasing_degree(sbr_info *sbr, real_t *rxx, real_t *deg)
512 rxx[0] = COEF_CONST(0.0);
513 deg[1] = COEF_CONST(0.0);
515 for (k = 2; k < sbr->k0; k++)
519 if ((k % 2 == 0) && (rxx[k] < COEF_CONST(0.0)))
523 deg[k] = COEF_CONST(1.0);
525 if (rxx[k-2] > COEF_CONST(0.0))
527 deg[k-1] = COEF_CONST(1.0) - MUL_C(rxx[k-1], rxx[k-1]);
529 } else if (rxx[k-2] > COEF_CONST(0.0)) {
530 deg[k] = COEF_CONST(1.0) - MUL_C(rxx[k-1], rxx[k-1]);
534 if ((k % 2 == 1) && (rxx[k] > COEF_CONST(0.0)))
536 if (rxx[k-1] > COEF_CONST(0.0))
538 deg[k] = COEF_CONST(1.0);
540 if (rxx[k-2] < COEF_CONST(0.0))
542 deg[k-1] = COEF_CONST(1.0) - MUL_C(rxx[k-1], rxx[k-1]);
544 } else if (rxx[k-2] < COEF_CONST(0.0)) {
545 deg[k] = COEF_CONST(1.0) - MUL_C(rxx[k-1], rxx[k-1]);
552 /* FIXED POINT: bwArray = COEF */
553 static real_t mapNewBw(uint8_t invf_mode, uint8_t invf_mode_prev)
558 if (invf_mode_prev == 0) /* NONE */
559 return COEF_CONST(0.6);
561 return COEF_CONST(0.75);
564 return COEF_CONST(0.9);
567 return COEF_CONST(0.98);
570 if (invf_mode_prev == 1) /* LOW */
571 return COEF_CONST(0.6);
573 return COEF_CONST(0.0);
577 /* FIXED POINT: bwArray = COEF */
578 static void calc_chirp_factors(sbr_info *sbr, uint8_t ch)
582 for (i = 0; i < sbr->N_Q; i++)
584 sbr->bwArray[ch][i] = mapNewBw(sbr->bs_invf_mode[ch][i], sbr->bs_invf_mode_prev[ch][i]);
586 if (sbr->bwArray[ch][i] < sbr->bwArray_prev[ch][i])
587 sbr->bwArray[ch][i] = MUL_F(sbr->bwArray[ch][i], FRAC_CONST(0.75)) + MUL_F(sbr->bwArray_prev[ch][i], FRAC_CONST(0.25));
589 sbr->bwArray[ch][i] = MUL_F(sbr->bwArray[ch][i], FRAC_CONST(0.90625)) + MUL_F(sbr->bwArray_prev[ch][i], FRAC_CONST(0.09375));
591 if (sbr->bwArray[ch][i] < COEF_CONST(0.015625))
592 sbr->bwArray[ch][i] = COEF_CONST(0.0);
594 if (sbr->bwArray[ch][i] >= COEF_CONST(0.99609375))
595 sbr->bwArray[ch][i] = COEF_CONST(0.99609375);
597 sbr->bwArray_prev[ch][i] = sbr->bwArray[ch][i];
598 sbr->bs_invf_mode_prev[ch][i] = sbr->bs_invf_mode[ch][i];
602 static void patch_construction(sbr_info *sbr)
606 uint8_t msb = sbr->k0;
607 uint8_t usb = sbr->kx;
608 uint8_t goalSbTab[] = { 21, 23, 32, 43, 46, 64, 85, 93, 128, 0, 0, 0 };
609 /* (uint8_t)(2.048e6/sbr->sample_rate + 0.5); */
610 uint8_t goalSb = goalSbTab[get_sr_index(sbr->sample_rate)];
614 if (goalSb < (sbr->kx + sbr->M))
616 for (i = 0, k = 0; sbr->f_master[i] < goalSb; i++)
622 if (sbr->N_master == 0)
625 sbr->patchNoSubbands[0] = 0;
626 sbr->patchStartSubband[0] = 0;
639 sb = sbr->f_master[j];
640 odd = (sb - 2 + sbr->k0) % 2;
641 } while (sb > (sbr->k0 - 1 + msb - odd));
643 sbr->patchNoSubbands[sbr->noPatches] = max(sb - usb, 0);
644 sbr->patchStartSubband[sbr->noPatches] = sbr->k0 - odd -
645 sbr->patchNoSubbands[sbr->noPatches];
647 if (sbr->patchNoSubbands[sbr->noPatches] > 0)
656 if (sbr->f_master[k] - sb < 3)
658 } while (sb != (sbr->kx + sbr->M));
660 if ((sbr->patchNoSubbands[sbr->noPatches-1] < 3) && (sbr->noPatches > 1))
665 sbr->noPatches = min(sbr->noPatches, 5);