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 82747 : 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 82747 : HQ_ENC_HANDLE hHQ_core = st->hHQ_core;
90 :
91 82747 : max_brate = HQ_32k;
92 82747 : if ( st->element_mode > EVS_MONO )
93 : {
94 74800 : max_brate = HQ_48k;
95 : }
96 :
97 82747 : *hqswb_clas = HQ_NORMAL;
98 82747 : bits = 1;
99 82747 : if ( is_transient )
100 : {
101 3614 : *hqswb_clas = HQ_TRANSIENT;
102 : }
103 :
104 82747 : if ( length == L_SPEC32k || length == L_SPEC48k )
105 : {
106 68173 : if ( st->core_brate <= max_brate )
107 : {
108 :
109 63586 : if ( !is_transient && st->bwidth == st->last_bwidth )
110 : {
111 : /* Detect HQ_HARMONIC mode */
112 60559 : *hqswb_clas = peak_avrg_ratio( st->total_brate, coefs, NUMC_N + 96, &hHQ_core->mode_count, &hHQ_core->mode_count1 );
113 :
114 60559 : harmonic_decision = hf_spectrum_sparseness( st, coefs );
115 :
116 60559 : if ( *hqswb_clas == HQ_HARMONIC && !harmonic_decision )
117 : {
118 89 : *hqswb_clas = HQ_NORMAL;
119 : }
120 : else
121 : {
122 : /* Detect HQ_HVQ mode */
123 60470 : 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 63586 : bits = 2;
127 : }
128 : }
129 14574 : else if ( length == L_SPEC16k_EXT || length == L_SPEC48k_EXT )
130 : {
131 917 : bits = 0; /* HQ_NORMAL only -- no signaling needed */
132 : }
133 :
134 : /* write signaling info to the bitstream */
135 82747 : push_indice( st->hBstr, IND_HQ_SWB_CLAS, *hqswb_clas, bits );
136 :
137 82747 : if ( st->core_brate <= HQ_32k && *hqswb_clas == HQ_NORMAL )
138 : {
139 37107 : if ( length == L_SPEC32k )
140 : {
141 12481 : *hqswb_clas = HQ_GEN_SWB;
142 : }
143 24626 : else if ( length == L_SPEC48k )
144 : {
145 13055 : *hqswb_clas = HQ_GEN_FB;
146 : }
147 : }
148 :
149 82747 : 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 62057 : 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 33677257 : for ( i = 96; i < N; i++ )
172 : {
173 33615200 : input_abs[i] = (float) fabs( input_hi[i] );
174 : }
175 :
176 62057 : hqswb_clas = HQ_NORMAL;
177 :
178 62057 : k = 0;
179 62057 : k1 = 0;
180 62057 : q = 96;
181 930855 : for ( i = 3; i < 17; i++ )
182 : {
183 868798 : peak = 0.0f;
184 868798 : mean = EPSILON;
185 28670334 : for ( j = 0; j < 32; j++, q++ )
186 : {
187 27801536 : mean += input_abs[q];
188 :
189 27801536 : if ( input_abs[q] > peak )
190 : {
191 3786559 : peak = input_abs[q];
192 : }
193 : }
194 :
195 868798 : sharp = 32 * peak / mean;
196 :
197 868798 : if ( i < 8 )
198 : {
199 310285 : if ( sharp > 4.5 )
200 : {
201 156156 : k += 1;
202 : }
203 : }
204 : else
205 : {
206 558513 : if ( sharp > 3.6 && peak > 10 )
207 : {
208 175537 : k1 += 1;
209 : }
210 : }
211 : }
212 :
213 62057 : if ( k + k1 >= 10 && k1 > 5 )
214 : {
215 11908 : if ( *mode_count < 8 )
216 : {
217 11814 : ( *mode_count )++;
218 : }
219 :
220 11908 : if ( *mode_count1 > 0 )
221 : {
222 165 : ( *mode_count1 )--;
223 : }
224 : }
225 : else
226 : {
227 50149 : if ( *mode_count > 0 )
228 : {
229 111 : ( *mode_count )--;
230 : }
231 :
232 50149 : if ( *mode_count1 < 8 )
233 : {
234 48611 : ( *mode_count1 )++;
235 : }
236 : }
237 62057 : 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 20265 : hqswb_clas = HQ_HARMONIC;
240 : }
241 :
242 62057 : return hqswb_clas;
243 : }
244 :
245 :
246 : /*--------------------------------------------------------------------------*
247 : * hvq_classifier()
248 : *
249 : * Classification of spectral content for HQ_HVQ mode
250 : *--------------------------------------------------------------------------*/
251 :
252 60470 : 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 60470 : if ( *hqswb_clas == HQ_HARMONIC && last_core != ACELP_CORE && last_core != AMR_WB_CORE )
278 : {
279 19825 : set_f( thr, 0.0f, L_FRAME16k );
280 :
281 19825 : if ( core_brate < HQ_BWE_CROSSOVER_BRATE )
282 : {
283 15537 : nsub = HVQ_NSUB_24k;
284 : }
285 : else
286 : {
287 4288 : nsub = HVQ_NSUB_32k;
288 : }
289 :
290 19825 : N = nsub * HVQ_BW;
291 :
292 4872273 : for ( i = 0; i < N; i++ )
293 : {
294 4852448 : input_abs[i] = (float) fabs( input[i] );
295 : }
296 :
297 19825 : *Npeaks = 0;
298 19825 : nf = 800;
299 19825 : pe = 800;
300 19825 : num_sharp_bands = 0;
301 19825 : k = 0;
302 19825 : q = 0;
303 19825 : sharp_dist = 0;
304 :
305 : /* Find peak threshold */
306 171464 : for ( i = 0; i < nsub; i++ )
307 : {
308 151639 : peak = 0.0f;
309 151639 : nf_mean[i] = EPSILON;
310 151639 : pe_mean[i] = EPSILON;
311 5004087 : for ( j = 0; j < HVQ_BW; j++, q++ )
312 : {
313 4852448 : d = input_abs[q];
314 :
315 4852448 : if ( d > nf )
316 : {
317 2661013 : nf = HVQ_NF_WEIGHT1 * nf + ( 1 - HVQ_NF_WEIGHT1 ) * d;
318 : }
319 : else
320 : {
321 2191435 : nf = HVQ_NF_WEIGHT2 * nf + ( 1 - HVQ_NF_WEIGHT2 ) * d;
322 : }
323 :
324 4852448 : if ( d > pe )
325 : {
326 1001051 : pe = HVQ_PE_WEIGHT1 * pe + ( 1 - HVQ_PE_WEIGHT1 ) * d;
327 : }
328 : else
329 : {
330 3851397 : pe = HVQ_PE_WEIGHT2 * pe + ( 1 - HVQ_PE_WEIGHT2 ) * d;
331 : }
332 :
333 4852448 : nf_mean[i] += nf;
334 4852448 : pe_mean[i] += pe;
335 :
336 4852448 : if ( d > peak )
337 : {
338 711236 : peak = d;
339 : }
340 : }
341 :
342 151639 : nf_mean[i] /= HVQ_BW;
343 151639 : pe_mean[i] /= HVQ_BW;
344 :
345 :
346 151639 : thr_tmp = (float) pow( pe_mean[i] / nf_mean[i], HVQ_THR_POW ) * nf_mean[i];
347 151639 : set_f( &thr[k], thr_tmp, HVQ_BW );
348 151639 : k += HVQ_BW;
349 :
350 151639 : sharp[i] = peak / nf_mean[i];
351 151639 : sharp_dist += sharp[i] - HVQ_SHARP_THRES;
352 :
353 151639 : if ( sharp[i] > HVQ_SHARP_THRES )
354 : {
355 120518 : num_sharp_bands++;
356 : }
357 : }
358 :
359 : /* Estimate noise floor gains */
360 19825 : offset = nsub % 2;
361 155927 : for ( i = 0; i < 2 * ( nsub / 2 ); i++ )
362 : {
363 136102 : nf_gains[( 2 * i + 1 ) / nsub] += nf_mean[i + offset];
364 136102 : pe_gains[( 2 * i + 1 ) / nsub] += pe_mean[i + offset];
365 : }
366 :
367 59475 : for ( i = 0; i < HVQ_NF_GROUPS; i++ )
368 : {
369 39650 : nf_gains[i] /= nsub / HVQ_NF_GROUPS;
370 39650 : pe_gains[i] /= nsub / HVQ_NF_GROUPS;
371 : }
372 :
373 : /* Allocate available peaks */
374 171464 : for ( i = 0; i < nsub; i++ )
375 : {
376 151639 : avail_peaks[i] = HVQ_PA_PEAKS_SHARP1;
377 151639 : if ( nf_mean[i] < nf_gains[( 2 * i + 1 ) / nsub] * HVQ_PA_FAC )
378 : {
379 43753 : if ( sharp[i] < HVQ_PA_SHARP_THRES3 )
380 : {
381 15028 : avail_peaks[i] = HVQ_PA_PEAKS_SHARP3;
382 : }
383 28725 : else if ( sharp[i] < HVQ_PA_SHARP_THRES2 )
384 : {
385 4761 : avail_peaks[i] = HVQ_PA_PEAKS_SHARP2;
386 : }
387 : }
388 : }
389 :
390 : /* Adjust threshold around previous peaks */
391 211226 : for ( i = 0; i < *prev_Npeaks; i++ )
392 : {
393 191401 : j = prev_peaks[i] - 2;
394 191401 : k = prev_peaks[i] + 2;
395 191401 : p_adj = hvq_thr_adj;
396 :
397 957005 : for ( q = j; q < k; q++ )
398 : {
399 765604 : thr[q] *= *p_adj++;
400 : }
401 : }
402 :
403 19825 : num_peak_cands = 0;
404 :
405 : /* Remove everything below threshold for peak search */
406 19825 : input_abs[0] = 0;
407 19825 : input_abs[1] = 0;
408 19825 : input_abs[N - 2] = 0;
409 19825 : input_abs[N - 1] = 0;
410 4832623 : for ( i = 0; i < N - 2; i++ )
411 : {
412 4812798 : if ( input_abs[i] < thr[i] )
413 : {
414 3893587 : input_abs[i] = 0;
415 : }
416 : else
417 : {
418 919211 : input_abs[num_peak_cands] = input_abs[i];
419 919211 : peak_cand_idx[num_peak_cands] = i;
420 919211 : num_peak_cands++;
421 : }
422 : }
423 :
424 : /* maximum 27 (5+9+13) bits for additional peak */
425 19825 : 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 19825 : pindx = maximum( input_abs, num_peak_cands, &m );
429 19825 : i = 0;
430 :
431 392990 : while ( m > 0 && i < peak_th + 1 )
432 : {
433 373165 : if ( avail_peaks[peak_cand_idx[pindx] / HVQ_BW] > 0 )
434 : {
435 365397 : peaks[i++] = peak_cand_idx[pindx];
436 365397 : avail_peaks[peak_cand_idx[pindx] / HVQ_BW]--;
437 : }
438 :
439 373165 : j = pindx - 2;
440 373165 : k = pindx + 2;
441 :
442 373165 : if ( j < 0 )
443 : {
444 19315 : j = 0;
445 : }
446 :
447 373165 : if ( k > num_peak_cands - 1 )
448 : {
449 10890 : k = num_peak_cands - 1;
450 : }
451 :
452 373165 : low = peak_cand_idx[pindx] - 2;
453 373165 : high = peak_cand_idx[pindx] + 2;
454 :
455 373165 : if ( low < 0 )
456 : {
457 0 : low = 0;
458 : }
459 :
460 373165 : if ( high > N - 1 )
461 : {
462 0 : high = N - 1;
463 : }
464 :
465 1461994 : for ( q = j; q <= pindx; q++ )
466 : {
467 1088829 : if ( peak_cand_idx[q] >= low )
468 : {
469 604319 : peak_cand_idx[q] = 0;
470 604319 : input_abs[q] = 0;
471 : }
472 : }
473 :
474 1103427 : for ( q = pindx + 1; q <= k; q++ )
475 : {
476 730262 : if ( peak_cand_idx[q] <= high )
477 : {
478 477378 : peak_cand_idx[q] = 0;
479 477378 : input_abs[q] = 0;
480 : }
481 : }
482 :
483 373165 : pindx = maximum( input_abs, num_peak_cands, &m );
484 : }
485 :
486 19825 : *Npeaks = i;
487 :
488 : /* decision about HQ_HVQ mode */
489 19825 : if ( *Npeaks > HVQ_MIN_PEAKS )
490 : {
491 19825 : if ( num_sharp_bands > nsub - 3 && *Npeaks <= peak_th )
492 : {
493 9952 : sharp_dist /= nsub;
494 9952 : if ( sharp_dist <= SHARP_DIST_THRES && *hvq_hangover < 0 )
495 : {
496 319 : ( *hvq_hangover )++;
497 : }
498 : else
499 : {
500 9633 : *hqswb_clas = HQ_HVQ;
501 9633 : *hvq_hangover = 2;
502 : }
503 :
504 : /* update memory */
505 9952 : *prev_Npeaks = *Npeaks;
506 9952 : mvs2s( peaks, prev_peaks, *Npeaks );
507 : }
508 : else
509 : {
510 9873 : if ( *hvq_hangover > 0 )
511 : {
512 1774 : *hqswb_clas = HQ_HVQ;
513 1774 : ( *hvq_hangover )--;
514 : }
515 : else
516 : {
517 8099 : *hvq_hangover = -1;
518 : }
519 : }
520 : }
521 : else
522 : {
523 0 : *hvq_hangover = -1;
524 : }
525 :
526 19825 : *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 40645 : *prev_Npeaks = 0;
531 40645 : *hvq_hangover = 0;
532 : }
533 :
534 60470 : 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 60559 : 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 60559 : crest_lp = &st->hHQ_core->crest_lp;
563 60559 : crest_mod_lp = &st->hHQ_core->crest_mod_lp;
564 :
565 60559 : result = TRUE;
566 60559 : if ( st->element_mode != EVS_MONO )
567 : {
568 18860034 : for ( i = 0; i < L_SPEC_HB; i++ )
569 : {
570 18801280 : A[i] = (float) fabsf( coefs[i + L_SPEC_HB] );
571 : }
572 58754 : low_count = 0;
573 58754 : inv_rms = 0.0f;
574 58754 : crest_mod = 0.0f;
575 58754 : maximum( A, L_SPEC_HB, &Amax );
576 58754 : 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 58754 : thr = Amax * PEAK_THRESHOLD;
586 58754 : movmean = 0.0f; /* avoid uninitialized warning */
587 58754 : p_num = &inv_tbl[HALF_WIN_LENGTH + 1]; /* Table for division 1./(11:21) */
588 18860034 : for ( i = 0; i < L_SPEC_HB; i++ )
589 : {
590 18801280 : inv_rms += A[i] * A[i];
591 18801280 : if ( A[i] < thr )
592 : {
593 11003394 : low_count += 1;
594 : }
595 18801280 : if ( i <= HALF_WIN_LENGTH )
596 : {
597 646294 : if ( i == 0 )
598 : {
599 58754 : movmean = sum_f( &A[0], i + HALF_WIN_LENGTH + 1 ) * ( *p_num );
600 : }
601 : else
602 : {
603 587540 : p_num++;
604 587540 : movmean = movmean + ( A[i + HALF_WIN_LENGTH] - movmean ) * ( *p_num );
605 : }
606 : }
607 : else
608 : {
609 18154986 : if ( L_SPEC_HB <= i + HALF_WIN_LENGTH )
610 : {
611 587540 : p_num--;
612 587540 : movmean = movmean + ( movmean - A[i - HALF_WIN_LENGTH - 1] ) * ( *p_num );
613 : }
614 : else
615 : {
616 17567446 : movmean = movmean + ( A[i + HALF_WIN_LENGTH] - A[i - HALF_WIN_LENGTH - 1] ) * ( *p_num );
617 : }
618 : }
619 18801280 : if ( crest_mod < movmean )
620 : {
621 815622 : crest_mod = movmean;
622 : }
623 : }
624 58754 : inv_rms = 1.0f / (float) sqrtf( inv_rms / L_SPEC_HB );
625 58754 : crest = Amax * inv_rms;
626 58754 : crest_mod = crest_mod * inv_rms;
627 : }
628 58754 : *crest_lp = HQ_CREST_FAC_SM * ( *crest_lp ) + ( 1.0f - HQ_CREST_FAC_SM ) * crest;
629 58754 : *crest_mod_lp = HQ_CREST_FAC_SM * ( *crest_mod_lp ) + ( 1.0f - HQ_CREST_FAC_SM ) * crest_mod;
630 :
631 58754 : if ( ( ( *crest_lp ) > HQ_CREST_THRESHOLD ) && ( ( *crest_mod_lp ) > HQ_CREST_MOD_THRESHOLD ) && ( low_count > LOW_COUNT_THRESHOLD ) )
632 : {
633 338 : result = FALSE;
634 : }
635 : }
636 :
637 60559 : return result;
638 : }
|