Line data Source code
1 : /******************************************************************************************************
2 :
3 : (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
4 : Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD.,
5 : Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange,
6 : Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other
7 : contributors to this repository. All Rights Reserved.
8 :
9 : This software is protected by copyright law and by international treaties.
10 : The IVAS codec Public Collaboration consisting of Dolby International AB, Ericsson AB,
11 : Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD.,
12 : Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange,
13 : Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other
14 : contributors to this repository retain full ownership rights in their respective contributions in
15 : the software. This notice grants no license of any kind, including but not limited to patent
16 : license, nor is any license granted by implication, estoppel or otherwise.
17 :
18 : Contributors are required to enter into the IVAS codec Public Collaboration agreement before making
19 : contributions.
20 :
21 : This software is provided "AS IS", without any express or implied warranties. The software is in the
22 : development stage. It is intended exclusively for experts who have experience with such software and
23 : solely for the purpose of inspection. All implied warranties of non-infringement, merchantability
24 : and fitness for a particular purpose are hereby disclaimed and excluded.
25 :
26 : Any dispute, controversy or claim arising under or in relation to providing this software shall be
27 : submitted to and settled by the final, binding jurisdiction of the courts of Munich, Germany in
28 : accordance with the laws of the Federal Republic of Germany excluding its conflict of law rules and
29 : the United Nations Convention on Contracts on the International Sales of Goods.
30 :
31 : *******************************************************************************************************/
32 :
33 : /*====================================================================================
34 : EVS Codec 3GPP TS26.443 Nov 04, 2021. Version 12.14.0 / 13.10.0 / 14.6.0 / 15.4.0 / 16.3.0
35 : ====================================================================================*/
36 :
37 : #include <stdint.h>
38 : #include "options.h"
39 : #ifdef DEBUGGING
40 : #include "debug.h"
41 : #endif
42 : #include <math.h>
43 : #include "cnst.h"
44 : #include "prot.h"
45 : #include "rom_com.h"
46 : #include "wmc_auto.h"
47 :
48 : /*-----------------------------------------------------------------*
49 : * Local constants
50 : *-----------------------------------------------------------------*/
51 :
52 : #define SHARP_DIST_THRES 22.2f
53 : #define HALF_WIN_LENGTH 10
54 : #define L_SPEC_HB 320
55 : #define PEAK_THRESHOLD 0.1f
56 : #define LOW_COUNT_THRESHOLD 220
57 :
58 :
59 : /*-----------------------------------------------------------------*
60 : * Local function prototypes
61 : *-----------------------------------------------------------------*/
62 :
63 : static void hvq_classifier( const float *input, int16_t *prev_Npeaks, int16_t *prev_peaks, int16_t *hqswb_clas, int16_t *Npeaks, int16_t *peaks, const int32_t core_brate, const int16_t last_core, float *nf_gains, int16_t *hvq_hangover, float *pe_gains );
64 : static int16_t hf_spectrum_sparseness( Encoder_State *st, const float *coefs );
65 :
66 : /*--------------------------------------------------------------------------*
67 : * hq_classifier_enc()
68 : *
69 : * HQ mode selector (decision_matrix)
70 : *--------------------------------------------------------------------------*/
71 :
72 : /*! r: Consumed bits */
73 8423 : int16_t hq_classifier_enc(
74 : Encoder_State *st, /* i/o: encoder state structure */
75 : const int16_t length, /* i : Frame length */
76 : const float *coefs, /* i : Spectral coefficients */
77 : const int16_t is_transient, /* i : Transient flag */
78 : int16_t *Npeaks, /* o : Number of identified peaks */
79 : int16_t *peaks, /* o : Peak indices */
80 : float *pe_gains, /* o : Peak gains */
81 : float *nf_gains, /* o : Noise-fill gains */
82 : int16_t *hqswb_clas /* o : HQ class */
83 : )
84 : {
85 : int16_t bits;
86 : int32_t max_brate;
87 : int16_t harmonic_decision;
88 :
89 8423 : HQ_ENC_HANDLE hHQ_core = st->hHQ_core;
90 :
91 8423 : max_brate = HQ_32k;
92 8423 : if ( st->element_mode > EVS_MONO )
93 : {
94 8017 : max_brate = HQ_48k;
95 : }
96 :
97 8423 : *hqswb_clas = HQ_NORMAL;
98 8423 : bits = 1;
99 8423 : if ( is_transient )
100 : {
101 562 : *hqswb_clas = HQ_TRANSIENT;
102 : }
103 :
104 8423 : if ( length == L_SPEC32k || length == L_SPEC48k )
105 : {
106 7682 : if ( st->core_brate <= max_brate )
107 : {
108 :
109 7351 : if ( !is_transient && st->bwidth == st->last_bwidth )
110 : {
111 : /* Detect HQ_HARMONIC mode */
112 6825 : *hqswb_clas = peak_avrg_ratio( st->total_brate, coefs, NUMC_N + 96, &hHQ_core->mode_count, &hHQ_core->mode_count1 );
113 :
114 6825 : harmonic_decision = hf_spectrum_sparseness( st, coefs );
115 :
116 6825 : if ( *hqswb_clas == HQ_HARMONIC && !harmonic_decision )
117 : {
118 1 : *hqswb_clas = HQ_NORMAL;
119 : }
120 : else
121 : {
122 : /* Detect HQ_HVQ mode */
123 6824 : hvq_classifier( coefs, &hHQ_core->prev_Npeaks, hHQ_core->prev_peaks, hqswb_clas, Npeaks, peaks, st->core_brate, st->last_core, nf_gains, &hHQ_core->hvq_hangover, pe_gains );
124 : }
125 : }
126 7351 : bits = 2;
127 : }
128 : }
129 741 : else if ( length == L_SPEC16k_EXT || length == L_SPEC48k_EXT )
130 : {
131 135 : bits = 0; /* HQ_NORMAL only -- no signaling needed */
132 : }
133 :
134 : /* write signaling info to the bitstream */
135 8423 : push_indice( st->hBstr, IND_HQ_SWB_CLAS, *hqswb_clas, bits );
136 :
137 8423 : if ( st->core_brate <= HQ_32k && *hqswb_clas == HQ_NORMAL )
138 : {
139 3645 : if ( length == L_SPEC32k )
140 : {
141 760 : *hqswb_clas = HQ_GEN_SWB;
142 : }
143 2885 : else if ( length == L_SPEC48k )
144 : {
145 2309 : *hqswb_clas = HQ_GEN_FB;
146 : }
147 : }
148 :
149 8423 : return bits;
150 : }
151 :
152 : /*--------------------------------------------------------------------------*
153 : * peak_avrg_ratio()
154 : *
155 : * Classify the input signal and decide if it has a harmonic structure
156 : *--------------------------------------------------------------------------*/
157 :
158 : /*! r: hqswb_clas */
159 6856 : int16_t peak_avrg_ratio(
160 : const int32_t total_brate, /* i : total bitrate */
161 : const float *input_hi, /* i : input signal */
162 : const int16_t N, /* i : number of coefficients */
163 : int16_t *mode_count, /* i/o: HQ_HARMONIC mode count */
164 : int16_t *mode_count1 /* i/o: HQ_NORMAL mode count */
165 : )
166 : {
167 : float mean, peak, sharp;
168 : int16_t i, j, q, k, k1, hqswb_clas;
169 : float input_abs[L_FRAME32k];
170 :
171 3733544 : for ( i = 96; i < N; i++ )
172 : {
173 3726688 : input_abs[i] = (float) fabs( input_hi[i] );
174 : }
175 :
176 6856 : hqswb_clas = HQ_NORMAL;
177 :
178 6856 : k = 0;
179 6856 : k1 = 0;
180 6856 : q = 96;
181 102840 : for ( i = 3; i < 17; i++ )
182 : {
183 95984 : peak = 0.0f;
184 95984 : mean = EPSILON;
185 3167472 : for ( j = 0; j < 32; j++, q++ )
186 : {
187 3071488 : mean += input_abs[q];
188 :
189 3071488 : if ( input_abs[q] > peak )
190 : {
191 423378 : peak = input_abs[q];
192 : }
193 : }
194 :
195 95984 : sharp = 32 * peak / mean;
196 :
197 95984 : if ( i < 8 )
198 : {
199 34280 : if ( sharp > 4.5 )
200 : {
201 21909 : k += 1;
202 : }
203 : }
204 : else
205 : {
206 61704 : if ( sharp > 3.6 && peak > 10 )
207 : {
208 21425 : k1 += 1;
209 : }
210 : }
211 : }
212 :
213 6856 : if ( k + k1 >= 10 && k1 > 5 )
214 : {
215 1570 : if ( *mode_count < 8 )
216 : {
217 1570 : ( *mode_count )++;
218 : }
219 :
220 1570 : if ( *mode_count1 > 0 )
221 : {
222 0 : ( *mode_count1 )--;
223 : }
224 : }
225 : else
226 : {
227 5286 : if ( *mode_count > 0 )
228 : {
229 0 : ( *mode_count )--;
230 : }
231 :
232 5286 : if ( *mode_count1 < 8 )
233 : {
234 5270 : ( *mode_count1 )++;
235 : }
236 : }
237 6856 : if ( ( k + k1 >= 5 && k1 > 2 && total_brate < HQ_BWE_CROSSOVER_BRATE && total_brate > HQ_16k40 ) || ( ( ( k + k1 >= 10 && k1 > 5 ) || *mode_count >= 5 ) && *mode_count1 < 5 ) )
238 : {
239 2134 : hqswb_clas = HQ_HARMONIC;
240 : }
241 :
242 6856 : return hqswb_clas;
243 : }
244 :
245 :
246 : /*--------------------------------------------------------------------------*
247 : * hvq_classifier()
248 : *
249 : * Classification of spectral content for HQ_HVQ mode
250 : *--------------------------------------------------------------------------*/
251 :
252 6824 : static void hvq_classifier(
253 : const float *input, /* i : input signal */
254 : int16_t *prev_Npeaks, /* i/o: Peak number memory */
255 : int16_t *prev_peaks, /* i/o: Peak indices memory */
256 : int16_t *hqswb_clas, /* i/o: HQ class */
257 : int16_t *Npeaks, /* o : Number of peaks */
258 : int16_t *peaks, /* o : Peak indices */
259 : const int32_t core_brate, /* i : Core bitrate */
260 : const int16_t last_core, /* i : Last core used */
261 : float *nf_gains, /* o : Noisefloor gains */
262 : int16_t *hvq_hangover, /* i/o: Mode-switch hangover */
263 : float *pe_gains /* o : peak gains */
264 : )
265 : {
266 : const float *p_adj;
267 : float sharp_dist;
268 : float nf, pe, d, peak, thr_tmp, m;
269 : float input_abs[L_FRAME32k], thr[L_FRAME16k];
270 : float pe_mean[HVQ_NSUB_32k], nf_mean[HVQ_NSUB_32k];
271 : float sharp[HVQ_NSUB_32k];
272 :
273 : int16_t num_sharp_bands, i, j, k, q, peak_th, nsub, pindx, N, offset;
274 : int16_t num_peak_cands, high, low;
275 : int16_t peak_cand_idx[HVQ_THRES_BIN_32k], avail_peaks[HVQ_NSUB_32k];
276 :
277 6824 : if ( *hqswb_clas == HQ_HARMONIC && last_core != ACELP_CORE && last_core != AMR_WB_CORE )
278 : {
279 2107 : set_f( thr, 0.0f, L_FRAME16k );
280 :
281 2107 : if ( core_brate < HQ_BWE_CROSSOVER_BRATE )
282 : {
283 1160 : nsub = HVQ_NSUB_24k;
284 : }
285 : else
286 : {
287 947 : nsub = HVQ_NSUB_32k;
288 : }
289 :
290 2107 : N = nsub * HVQ_BW;
291 :
292 564987 : for ( i = 0; i < N; i++ )
293 : {
294 562880 : input_abs[i] = (float) fabs( input[i] );
295 : }
296 :
297 2107 : *Npeaks = 0;
298 2107 : nf = 800;
299 2107 : pe = 800;
300 2107 : num_sharp_bands = 0;
301 2107 : k = 0;
302 2107 : q = 0;
303 2107 : sharp_dist = 0;
304 :
305 : /* Find peak threshold */
306 19697 : for ( i = 0; i < nsub; i++ )
307 : {
308 17590 : peak = 0.0f;
309 17590 : nf_mean[i] = EPSILON;
310 17590 : pe_mean[i] = EPSILON;
311 580470 : for ( j = 0; j < HVQ_BW; j++, q++ )
312 : {
313 562880 : d = input_abs[q];
314 :
315 562880 : if ( d > nf )
316 : {
317 303501 : nf = HVQ_NF_WEIGHT1 * nf + ( 1 - HVQ_NF_WEIGHT1 ) * d;
318 : }
319 : else
320 : {
321 259379 : nf = HVQ_NF_WEIGHT2 * nf + ( 1 - HVQ_NF_WEIGHT2 ) * d;
322 : }
323 :
324 562880 : if ( d > pe )
325 : {
326 113712 : pe = HVQ_PE_WEIGHT1 * pe + ( 1 - HVQ_PE_WEIGHT1 ) * d;
327 : }
328 : else
329 : {
330 449168 : pe = HVQ_PE_WEIGHT2 * pe + ( 1 - HVQ_PE_WEIGHT2 ) * d;
331 : }
332 :
333 562880 : nf_mean[i] += nf;
334 562880 : pe_mean[i] += pe;
335 :
336 562880 : if ( d > peak )
337 : {
338 84189 : peak = d;
339 : }
340 : }
341 :
342 17590 : nf_mean[i] /= HVQ_BW;
343 17590 : pe_mean[i] /= HVQ_BW;
344 :
345 :
346 17590 : thr_tmp = (float) pow( pe_mean[i] / nf_mean[i], HVQ_THR_POW ) * nf_mean[i];
347 17590 : set_f( &thr[k], thr_tmp, HVQ_BW );
348 17590 : k += HVQ_BW;
349 :
350 17590 : sharp[i] = peak / nf_mean[i];
351 17590 : sharp_dist += sharp[i] - HVQ_SHARP_THRES;
352 :
353 17590 : if ( sharp[i] > HVQ_SHARP_THRES )
354 : {
355 15028 : num_sharp_bands++;
356 : }
357 : }
358 :
359 : /* Estimate noise floor gains */
360 2107 : offset = nsub % 2;
361 18537 : for ( i = 0; i < 2 * ( nsub / 2 ); i++ )
362 : {
363 16430 : nf_gains[( 2 * i + 1 ) / nsub] += nf_mean[i + offset];
364 16430 : pe_gains[( 2 * i + 1 ) / nsub] += pe_mean[i + offset];
365 : }
366 :
367 6321 : for ( i = 0; i < HVQ_NF_GROUPS; i++ )
368 : {
369 4214 : nf_gains[i] /= nsub / HVQ_NF_GROUPS;
370 4214 : pe_gains[i] /= nsub / HVQ_NF_GROUPS;
371 : }
372 :
373 : /* Allocate available peaks */
374 19697 : for ( i = 0; i < nsub; i++ )
375 : {
376 17590 : avail_peaks[i] = HVQ_PA_PEAKS_SHARP1;
377 17590 : if ( nf_mean[i] < nf_gains[( 2 * i + 1 ) / nsub] * HVQ_PA_FAC )
378 : {
379 6378 : if ( sharp[i] < HVQ_PA_SHARP_THRES3 )
380 : {
381 1500 : avail_peaks[i] = HVQ_PA_PEAKS_SHARP3;
382 : }
383 4878 : else if ( sharp[i] < HVQ_PA_SHARP_THRES2 )
384 : {
385 658 : avail_peaks[i] = HVQ_PA_PEAKS_SHARP2;
386 : }
387 : }
388 : }
389 :
390 : /* Adjust threshold around previous peaks */
391 24818 : for ( i = 0; i < *prev_Npeaks; i++ )
392 : {
393 22711 : j = prev_peaks[i] - 2;
394 22711 : k = prev_peaks[i] + 2;
395 22711 : p_adj = hvq_thr_adj;
396 :
397 113555 : for ( q = j; q < k; q++ )
398 : {
399 90844 : thr[q] *= *p_adj++;
400 : }
401 : }
402 :
403 2107 : num_peak_cands = 0;
404 :
405 : /* Remove everything below threshold for peak search */
406 2107 : input_abs[0] = 0;
407 2107 : input_abs[1] = 0;
408 2107 : input_abs[N - 2] = 0;
409 2107 : input_abs[N - 1] = 0;
410 560773 : for ( i = 0; i < N - 2; i++ )
411 : {
412 558666 : if ( input_abs[i] < thr[i] )
413 : {
414 455154 : input_abs[i] = 0;
415 : }
416 : else
417 : {
418 103512 : input_abs[num_peak_cands] = input_abs[i];
419 103512 : peak_cand_idx[num_peak_cands] = i;
420 103512 : num_peak_cands++;
421 : }
422 : }
423 :
424 : /* maximum 27 (5+9+13) bits for additional peak */
425 2107 : peak_th = (int16_t) ( ( core_brate * HVQ_PEAKS_PER_DELTA_THR + HVQ_PEAKS_PER_DELTA_THR_OFFS ) / HVQ_PEAKS_BPS_DELTA );
426 :
427 : /* Find peaks */
428 2107 : pindx = maximum( input_abs, num_peak_cands, &m );
429 2107 : i = 0;
430 :
431 44490 : while ( m > 0 && i < peak_th + 1 )
432 : {
433 42383 : if ( avail_peaks[peak_cand_idx[pindx] / HVQ_BW] > 0 )
434 : {
435 41349 : peaks[i++] = peak_cand_idx[pindx];
436 41349 : avail_peaks[peak_cand_idx[pindx] / HVQ_BW]--;
437 : }
438 :
439 42383 : j = pindx - 2;
440 42383 : k = pindx + 2;
441 :
442 42383 : if ( j < 0 )
443 : {
444 2059 : j = 0;
445 : }
446 :
447 42383 : if ( k > num_peak_cands - 1 )
448 : {
449 1424 : k = num_peak_cands - 1;
450 : }
451 :
452 42383 : low = peak_cand_idx[pindx] - 2;
453 42383 : high = peak_cand_idx[pindx] + 2;
454 :
455 42383 : if ( low < 0 )
456 : {
457 0 : low = 0;
458 : }
459 :
460 42383 : if ( high > N - 1 )
461 : {
462 0 : high = N - 1;
463 : }
464 :
465 166242 : for ( q = j; q <= pindx; q++ )
466 : {
467 123859 : if ( peak_cand_idx[q] >= low )
468 : {
469 69614 : peak_cand_idx[q] = 0;
470 69614 : input_abs[q] = 0;
471 : }
472 : }
473 :
474 125002 : for ( q = pindx + 1; q <= k; q++ )
475 : {
476 82619 : if ( peak_cand_idx[q] <= high )
477 : {
478 56372 : peak_cand_idx[q] = 0;
479 56372 : input_abs[q] = 0;
480 : }
481 : }
482 :
483 42383 : pindx = maximum( input_abs, num_peak_cands, &m );
484 : }
485 :
486 2107 : *Npeaks = i;
487 :
488 : /* decision about HQ_HVQ mode */
489 2107 : if ( *Npeaks > HVQ_MIN_PEAKS )
490 : {
491 2107 : if ( num_sharp_bands > nsub - 3 && *Npeaks <= peak_th )
492 : {
493 1117 : sharp_dist /= nsub;
494 1117 : if ( sharp_dist <= SHARP_DIST_THRES && *hvq_hangover < 0 )
495 : {
496 40 : ( *hvq_hangover )++;
497 : }
498 : else
499 : {
500 1077 : *hqswb_clas = HQ_HVQ;
501 1077 : *hvq_hangover = 2;
502 : }
503 :
504 : /* update memory */
505 1117 : *prev_Npeaks = *Npeaks;
506 1117 : mvs2s( peaks, prev_peaks, *Npeaks );
507 : }
508 : else
509 : {
510 990 : if ( *hvq_hangover > 0 )
511 : {
512 250 : *hqswb_clas = HQ_HVQ;
513 250 : ( *hvq_hangover )--;
514 : }
515 : else
516 : {
517 740 : *hvq_hangover = -1;
518 : }
519 : }
520 : }
521 : else
522 : {
523 0 : *hvq_hangover = -1;
524 : }
525 :
526 2107 : *Npeaks = (int16_t) ( min( ( core_brate * HVQ_PEAKS_PER_DELTA + HVQ_PEAKS_PER_DELTA_OFFS ) / HVQ_PEAKS_BPS_DELTA, *Npeaks ) );
527 : }
528 : else
529 : {
530 4717 : *prev_Npeaks = 0;
531 4717 : *hvq_hangover = 0;
532 : }
533 :
534 6824 : return;
535 : }
536 : /*--------------------------------------------------------------------------*
537 : * hf_spectrum_sparseness()
538 : *
539 : * Detection of sparse spectrum in high band for activation of harmonic
540 : * modes HQ_HARMONIC and HQ_HVQ
541 : *--------------------------------------------------------------------------*/
542 : /*! r: Harmonic decision for high band */
543 6825 : static int16_t hf_spectrum_sparseness(
544 : Encoder_State *st, /* i/o: encoder state structure */
545 : const float *coefs /* i : MDCT spectrum */
546 : )
547 : {
548 : int16_t i;
549 : float thr;
550 : int16_t low_count;
551 : float A[L_SPEC_HB];
552 : float Amax;
553 : float movmean;
554 : float inv_rms;
555 : float crest;
556 : float crest_mod;
557 : const float *p_num;
558 : float *crest_lp;
559 : float *crest_mod_lp;
560 : int16_t result;
561 :
562 6825 : crest_lp = &st->hHQ_core->crest_lp;
563 6825 : crest_mod_lp = &st->hHQ_core->crest_mod_lp;
564 :
565 6825 : result = TRUE;
566 6825 : if ( st->element_mode != EVS_MONO )
567 : {
568 2166750 : for ( i = 0; i < L_SPEC_HB; i++ )
569 : {
570 2160000 : A[i] = (float) fabsf( coefs[i + L_SPEC_HB] );
571 : }
572 6750 : low_count = 0;
573 6750 : inv_rms = 0.0f;
574 6750 : crest_mod = 0.0f;
575 6750 : maximum( A, L_SPEC_HB, &Amax );
576 6750 : if ( Amax == 0 )
577 : {
578 : /* For all-zero input the crest is 1.0 */
579 0 : crest = 1.0f;
580 0 : crest_mod = 1.0f;
581 0 : low_count = 0;
582 : }
583 : else
584 : {
585 6750 : thr = Amax * PEAK_THRESHOLD;
586 6750 : movmean = 0.0f; /* avoid uninitialized warning */
587 6750 : p_num = &inv_tbl[HALF_WIN_LENGTH + 1]; /* Table for division 1./(11:21) */
588 2166750 : for ( i = 0; i < L_SPEC_HB; i++ )
589 : {
590 2160000 : inv_rms += A[i] * A[i];
591 2160000 : if ( A[i] < thr )
592 : {
593 1342319 : low_count += 1;
594 : }
595 2160000 : if ( i <= HALF_WIN_LENGTH )
596 : {
597 74250 : if ( i == 0 )
598 : {
599 6750 : movmean = sum_f( &A[0], i + HALF_WIN_LENGTH + 1 ) * ( *p_num );
600 : }
601 : else
602 : {
603 67500 : p_num++;
604 67500 : movmean = movmean + ( A[i + HALF_WIN_LENGTH] - movmean ) * ( *p_num );
605 : }
606 : }
607 : else
608 : {
609 2085750 : if ( L_SPEC_HB <= i + HALF_WIN_LENGTH )
610 : {
611 67500 : p_num--;
612 67500 : movmean = movmean + ( movmean - A[i - HALF_WIN_LENGTH - 1] ) * ( *p_num );
613 : }
614 : else
615 : {
616 2018250 : movmean = movmean + ( A[i + HALF_WIN_LENGTH] - A[i - HALF_WIN_LENGTH - 1] ) * ( *p_num );
617 : }
618 : }
619 2160000 : if ( crest_mod < movmean )
620 : {
621 89357 : crest_mod = movmean;
622 : }
623 : }
624 6750 : inv_rms = 1.0f / (float) sqrtf( inv_rms / L_SPEC_HB );
625 6750 : crest = Amax * inv_rms;
626 6750 : crest_mod = crest_mod * inv_rms;
627 : }
628 6750 : *crest_lp = HQ_CREST_FAC_SM * ( *crest_lp ) + ( 1.0f - HQ_CREST_FAC_SM ) * crest;
629 6750 : *crest_mod_lp = HQ_CREST_FAC_SM * ( *crest_mod_lp ) + ( 1.0f - HQ_CREST_FAC_SM ) * crest_mod;
630 :
631 6750 : if ( ( ( *crest_lp ) > HQ_CREST_THRESHOLD ) && ( ( *crest_mod_lp ) > HQ_CREST_MOD_THRESHOLD ) && ( low_count > LOW_COUNT_THRESHOLD ) )
632 : {
633 40 : result = FALSE;
634 : }
635 : }
636 :
637 6825 : return result;
638 : }
|