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 6637 : 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 6637 : HQ_ENC_HANDLE hHQ_core = st->hHQ_core;
90 :
91 6637 : max_brate = HQ_32k;
92 6637 : if ( st->element_mode > EVS_MONO )
93 : {
94 6231 : max_brate = HQ_48k;
95 : }
96 :
97 6637 : *hqswb_clas = HQ_NORMAL;
98 6637 : bits = 1;
99 6637 : if ( is_transient )
100 : {
101 421 : *hqswb_clas = HQ_TRANSIENT;
102 : }
103 :
104 6637 : if ( length == L_SPEC32k || length == L_SPEC48k )
105 : {
106 6019 : if ( st->core_brate <= max_brate )
107 : {
108 :
109 5688 : if ( !is_transient && st->bwidth == st->last_bwidth )
110 : {
111 : /* Detect HQ_HARMONIC mode */
112 5303 : *hqswb_clas = peak_avrg_ratio( st->total_brate, coefs, NUMC_N + 96, &hHQ_core->mode_count, &hHQ_core->mode_count1 );
113 :
114 5303 : harmonic_decision = hf_spectrum_sparseness( st, coefs );
115 :
116 5303 : if ( *hqswb_clas == HQ_HARMONIC && !harmonic_decision )
117 : {
118 1 : *hqswb_clas = HQ_NORMAL;
119 : }
120 : else
121 : {
122 : /* Detect HQ_HVQ mode */
123 5302 : 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 5688 : bits = 2;
127 : }
128 : }
129 618 : else if ( length == L_SPEC16k_EXT || length == L_SPEC48k_EXT )
130 : {
131 107 : bits = 0; /* HQ_NORMAL only -- no signaling needed */
132 : }
133 :
134 : /* write signaling info to the bitstream */
135 6637 : push_indice( st->hBstr, IND_HQ_SWB_CLAS, *hqswb_clas, bits );
136 :
137 6637 : if ( st->core_brate <= HQ_32k && *hqswb_clas == HQ_NORMAL )
138 : {
139 2501 : if ( length == L_SPEC32k )
140 : {
141 342 : *hqswb_clas = HQ_GEN_SWB;
142 : }
143 2159 : else if ( length == L_SPEC48k )
144 : {
145 1706 : *hqswb_clas = HQ_GEN_FB;
146 : }
147 : }
148 :
149 6637 : 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 5334 : 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 2904054 : for ( i = 96; i < N; i++ )
172 : {
173 2898720 : input_abs[i] = (float) fabs( input_hi[i] );
174 : }
175 :
176 5334 : hqswb_clas = HQ_NORMAL;
177 :
178 5334 : k = 0;
179 5334 : k1 = 0;
180 5334 : q = 96;
181 80010 : for ( i = 3; i < 17; i++ )
182 : {
183 74676 : peak = 0.0f;
184 74676 : mean = EPSILON;
185 2464308 : for ( j = 0; j < 32; j++, q++ )
186 : {
187 2389632 : mean += input_abs[q];
188 :
189 2389632 : if ( input_abs[q] > peak )
190 : {
191 330893 : peak = input_abs[q];
192 : }
193 : }
194 :
195 74676 : sharp = 32 * peak / mean;
196 :
197 74676 : if ( i < 8 )
198 : {
199 26670 : if ( sharp > 4.5 )
200 : {
201 17220 : k += 1;
202 : }
203 : }
204 : else
205 : {
206 48006 : if ( sharp > 3.6 && peak > 10 )
207 : {
208 17290 : k1 += 1;
209 : }
210 : }
211 : }
212 :
213 5334 : if ( k + k1 >= 10 && k1 > 5 )
214 : {
215 1292 : if ( *mode_count < 8 )
216 : {
217 1292 : ( *mode_count )++;
218 : }
219 :
220 1292 : if ( *mode_count1 > 0 )
221 : {
222 0 : ( *mode_count1 )--;
223 : }
224 : }
225 : else
226 : {
227 4042 : if ( *mode_count > 0 )
228 : {
229 0 : ( *mode_count )--;
230 : }
231 :
232 4042 : if ( *mode_count1 < 8 )
233 : {
234 4026 : ( *mode_count1 )++;
235 : }
236 : }
237 5334 : 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 1683 : hqswb_clas = HQ_HARMONIC;
240 : }
241 :
242 5334 : return hqswb_clas;
243 : }
244 :
245 :
246 : /*--------------------------------------------------------------------------*
247 : * hvq_classifier()
248 : *
249 : * Classification of spectral content for HQ_HVQ mode
250 : *--------------------------------------------------------------------------*/
251 :
252 5302 : 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 5302 : if ( *hqswb_clas == HQ_HARMONIC && last_core != ACELP_CORE && last_core != AMR_WB_CORE )
278 : {
279 1670 : set_f( thr, 0.0f, L_FRAME16k );
280 :
281 1670 : if ( core_brate < HQ_BWE_CROSSOVER_BRATE )
282 : {
283 808 : nsub = HVQ_NSUB_24k;
284 : }
285 : else
286 : {
287 862 : nsub = HVQ_NSUB_32k;
288 : }
289 :
290 1670 : N = nsub * HVQ_BW;
291 :
292 458502 : for ( i = 0; i < N; i++ )
293 : {
294 456832 : input_abs[i] = (float) fabs( input[i] );
295 : }
296 :
297 1670 : *Npeaks = 0;
298 1670 : nf = 800;
299 1670 : pe = 800;
300 1670 : num_sharp_bands = 0;
301 1670 : k = 0;
302 1670 : q = 0;
303 1670 : sharp_dist = 0;
304 :
305 : /* Find peak threshold */
306 15946 : for ( i = 0; i < nsub; i++ )
307 : {
308 14276 : peak = 0.0f;
309 14276 : nf_mean[i] = EPSILON;
310 14276 : pe_mean[i] = EPSILON;
311 471108 : for ( j = 0; j < HVQ_BW; j++, q++ )
312 : {
313 456832 : d = input_abs[q];
314 :
315 456832 : if ( d > nf )
316 : {
317 247019 : nf = HVQ_NF_WEIGHT1 * nf + ( 1 - HVQ_NF_WEIGHT1 ) * d;
318 : }
319 : else
320 : {
321 209813 : nf = HVQ_NF_WEIGHT2 * nf + ( 1 - HVQ_NF_WEIGHT2 ) * d;
322 : }
323 :
324 456832 : if ( d > pe )
325 : {
326 92621 : pe = HVQ_PE_WEIGHT1 * pe + ( 1 - HVQ_PE_WEIGHT1 ) * d;
327 : }
328 : else
329 : {
330 364211 : pe = HVQ_PE_WEIGHT2 * pe + ( 1 - HVQ_PE_WEIGHT2 ) * d;
331 : }
332 :
333 456832 : nf_mean[i] += nf;
334 456832 : pe_mean[i] += pe;
335 :
336 456832 : if ( d > peak )
337 : {
338 68835 : peak = d;
339 : }
340 : }
341 :
342 14276 : nf_mean[i] /= HVQ_BW;
343 14276 : pe_mean[i] /= HVQ_BW;
344 :
345 :
346 14276 : thr_tmp = (float) pow( pe_mean[i] / nf_mean[i], HVQ_THR_POW ) * nf_mean[i];
347 14276 : set_f( &thr[k], thr_tmp, HVQ_BW );
348 14276 : k += HVQ_BW;
349 :
350 14276 : sharp[i] = peak / nf_mean[i];
351 14276 : sharp_dist += sharp[i] - HVQ_SHARP_THRES;
352 :
353 14276 : if ( sharp[i] > HVQ_SHARP_THRES )
354 : {
355 12245 : num_sharp_bands++;
356 : }
357 : }
358 :
359 : /* Estimate noise floor gains */
360 1670 : offset = nsub % 2;
361 15138 : for ( i = 0; i < 2 * ( nsub / 2 ); i++ )
362 : {
363 13468 : nf_gains[( 2 * i + 1 ) / nsub] += nf_mean[i + offset];
364 13468 : pe_gains[( 2 * i + 1 ) / nsub] += pe_mean[i + offset];
365 : }
366 :
367 5010 : for ( i = 0; i < HVQ_NF_GROUPS; i++ )
368 : {
369 3340 : nf_gains[i] /= nsub / HVQ_NF_GROUPS;
370 3340 : pe_gains[i] /= nsub / HVQ_NF_GROUPS;
371 : }
372 :
373 : /* Allocate available peaks */
374 15946 : for ( i = 0; i < nsub; i++ )
375 : {
376 14276 : avail_peaks[i] = HVQ_PA_PEAKS_SHARP1;
377 14276 : if ( nf_mean[i] < nf_gains[( 2 * i + 1 ) / nsub] * HVQ_PA_FAC )
378 : {
379 5393 : if ( sharp[i] < HVQ_PA_SHARP_THRES3 )
380 : {
381 1227 : avail_peaks[i] = HVQ_PA_PEAKS_SHARP3;
382 : }
383 4166 : else if ( sharp[i] < HVQ_PA_SHARP_THRES2 )
384 : {
385 550 : avail_peaks[i] = HVQ_PA_PEAKS_SHARP2;
386 : }
387 : }
388 : }
389 :
390 : /* Adjust threshold around previous peaks */
391 20228 : for ( i = 0; i < *prev_Npeaks; i++ )
392 : {
393 18558 : j = prev_peaks[i] - 2;
394 18558 : k = prev_peaks[i] + 2;
395 18558 : p_adj = hvq_thr_adj;
396 :
397 92790 : for ( q = j; q < k; q++ )
398 : {
399 74232 : thr[q] *= *p_adj++;
400 : }
401 : }
402 :
403 1670 : num_peak_cands = 0;
404 :
405 : /* Remove everything below threshold for peak search */
406 1670 : input_abs[0] = 0;
407 1670 : input_abs[1] = 0;
408 1670 : input_abs[N - 2] = 0;
409 1670 : input_abs[N - 1] = 0;
410 455162 : for ( i = 0; i < N - 2; i++ )
411 : {
412 453492 : if ( input_abs[i] < thr[i] )
413 : {
414 369777 : input_abs[i] = 0;
415 : }
416 : else
417 : {
418 83715 : input_abs[num_peak_cands] = input_abs[i];
419 83715 : peak_cand_idx[num_peak_cands] = i;
420 83715 : num_peak_cands++;
421 : }
422 : }
423 :
424 : /* maximum 27 (5+9+13) bits for additional peak */
425 1670 : 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 1670 : pindx = maximum( input_abs, num_peak_cands, &m );
429 1670 : i = 0;
430 :
431 35924 : while ( m > 0 && i < peak_th + 1 )
432 : {
433 34254 : if ( avail_peaks[peak_cand_idx[pindx] / HVQ_BW] > 0 )
434 : {
435 33406 : peaks[i++] = peak_cand_idx[pindx];
436 33406 : avail_peaks[peak_cand_idx[pindx] / HVQ_BW]--;
437 : }
438 :
439 34254 : j = pindx - 2;
440 34254 : k = pindx + 2;
441 :
442 34254 : if ( j < 0 )
443 : {
444 1579 : j = 0;
445 : }
446 :
447 34254 : if ( k > num_peak_cands - 1 )
448 : {
449 1136 : k = num_peak_cands - 1;
450 : }
451 :
452 34254 : low = peak_cand_idx[pindx] - 2;
453 34254 : high = peak_cand_idx[pindx] + 2;
454 :
455 34254 : if ( low < 0 )
456 : {
457 0 : low = 0;
458 : }
459 :
460 34254 : if ( high > N - 1 )
461 : {
462 0 : high = N - 1;
463 : }
464 :
465 134492 : for ( q = j; q <= pindx; q++ )
466 : {
467 100238 : if ( peak_cand_idx[q] >= low )
468 : {
469 56484 : peak_cand_idx[q] = 0;
470 56484 : input_abs[q] = 0;
471 : }
472 : }
473 :
474 101047 : for ( q = pindx + 1; q <= k; q++ )
475 : {
476 66793 : if ( peak_cand_idx[q] <= high )
477 : {
478 45669 : peak_cand_idx[q] = 0;
479 45669 : input_abs[q] = 0;
480 : }
481 : }
482 :
483 34254 : pindx = maximum( input_abs, num_peak_cands, &m );
484 : }
485 :
486 1670 : *Npeaks = i;
487 :
488 : /* decision about HQ_HVQ mode */
489 1670 : if ( *Npeaks > HVQ_MIN_PEAKS )
490 : {
491 1670 : if ( num_sharp_bands > nsub - 3 && *Npeaks <= peak_th )
492 : {
493 883 : sharp_dist /= nsub;
494 883 : if ( sharp_dist <= SHARP_DIST_THRES && *hvq_hangover < 0 )
495 : {
496 35 : ( *hvq_hangover )++;
497 : }
498 : else
499 : {
500 848 : *hqswb_clas = HQ_HVQ;
501 848 : *hvq_hangover = 2;
502 : }
503 :
504 : /* update memory */
505 883 : *prev_Npeaks = *Npeaks;
506 883 : mvs2s( peaks, prev_peaks, *Npeaks );
507 : }
508 : else
509 : {
510 787 : if ( *hvq_hangover > 0 )
511 : {
512 199 : *hqswb_clas = HQ_HVQ;
513 199 : ( *hvq_hangover )--;
514 : }
515 : else
516 : {
517 588 : *hvq_hangover = -1;
518 : }
519 : }
520 : }
521 : else
522 : {
523 0 : *hvq_hangover = -1;
524 : }
525 :
526 1670 : *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 3632 : *prev_Npeaks = 0;
531 3632 : *hvq_hangover = 0;
532 : }
533 :
534 5302 : 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 5303 : 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 5303 : crest_lp = &st->hHQ_core->crest_lp;
563 5303 : crest_mod_lp = &st->hHQ_core->crest_mod_lp;
564 :
565 5303 : result = TRUE;
566 5303 : if ( st->element_mode != EVS_MONO )
567 : {
568 1678188 : for ( i = 0; i < L_SPEC_HB; i++ )
569 : {
570 1672960 : A[i] = (float) fabsf( coefs[i + L_SPEC_HB] );
571 : }
572 5228 : low_count = 0;
573 5228 : inv_rms = 0.0f;
574 5228 : crest_mod = 0.0f;
575 5228 : maximum( A, L_SPEC_HB, &Amax );
576 5228 : 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 5228 : thr = Amax * PEAK_THRESHOLD;
586 5228 : movmean = 0.0f; /* avoid uninitialized warning */
587 5228 : p_num = &inv_tbl[HALF_WIN_LENGTH + 1]; /* Table for division 1./(11:21) */
588 1678188 : for ( i = 0; i < L_SPEC_HB; i++ )
589 : {
590 1672960 : inv_rms += A[i] * A[i];
591 1672960 : if ( A[i] < thr )
592 : {
593 1048449 : low_count += 1;
594 : }
595 1672960 : if ( i <= HALF_WIN_LENGTH )
596 : {
597 57508 : if ( i == 0 )
598 : {
599 5228 : movmean = sum_f( &A[0], i + HALF_WIN_LENGTH + 1 ) * ( *p_num );
600 : }
601 : else
602 : {
603 52280 : p_num++;
604 52280 : movmean = movmean + ( A[i + HALF_WIN_LENGTH] - movmean ) * ( *p_num );
605 : }
606 : }
607 : else
608 : {
609 1615452 : if ( L_SPEC_HB <= i + HALF_WIN_LENGTH )
610 : {
611 52280 : p_num--;
612 52280 : movmean = movmean + ( movmean - A[i - HALF_WIN_LENGTH - 1] ) * ( *p_num );
613 : }
614 : else
615 : {
616 1563172 : movmean = movmean + ( A[i + HALF_WIN_LENGTH] - A[i - HALF_WIN_LENGTH - 1] ) * ( *p_num );
617 : }
618 : }
619 1672960 : if ( crest_mod < movmean )
620 : {
621 69853 : crest_mod = movmean;
622 : }
623 : }
624 5228 : inv_rms = 1.0f / (float) sqrtf( inv_rms / L_SPEC_HB );
625 5228 : crest = Amax * inv_rms;
626 5228 : crest_mod = crest_mod * inv_rms;
627 : }
628 5228 : *crest_lp = HQ_CREST_FAC_SM * ( *crest_lp ) + ( 1.0f - HQ_CREST_FAC_SM ) * crest;
629 5228 : *crest_mod_lp = HQ_CREST_FAC_SM * ( *crest_mod_lp ) + ( 1.0f - HQ_CREST_FAC_SM ) * crest_mod;
630 :
631 5228 : if ( ( ( *crest_lp ) > HQ_CREST_THRESHOLD ) && ( ( *crest_mod_lp ) > HQ_CREST_MOD_THRESHOLD ) && ( low_count > LOW_COUNT_THRESHOLD ) )
632 : {
633 36 : result = FALSE;
634 : }
635 : }
636 :
637 5303 : return result;
638 : }
|