FreeCalypso > hg > gsm-codec-lib
annotate libtwamr/c_g_aver.c @ 468:4104b0390fab
efrtest: new program gsmefr-dlcap-sync
author | Mychaela Falconia <falcon@freecalypso.org> |
---|---|
date | Mon, 13 May 2024 07:21:09 +0000 |
parents | dc3b7caa59c4 |
children |
rev | line source |
---|---|
324
dc3b7caa59c4
libtwamr: integrate c_g_aver.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1 /************************************************************************* |
dc3b7caa59c4
libtwamr: integrate c_g_aver.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2 * |
dc3b7caa59c4
libtwamr: integrate c_g_aver.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
3 * GSM AMR-NB speech codec R98 Version 7.6.0 December 12, 2001 |
dc3b7caa59c4
libtwamr: integrate c_g_aver.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
4 * R99 Version 3.3.0 |
dc3b7caa59c4
libtwamr: integrate c_g_aver.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
5 * REL-4 Version 4.1.0 |
dc3b7caa59c4
libtwamr: integrate c_g_aver.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
6 * |
dc3b7caa59c4
libtwamr: integrate c_g_aver.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
7 ******************************************************************************** |
dc3b7caa59c4
libtwamr: integrate c_g_aver.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
8 * |
dc3b7caa59c4
libtwamr: integrate c_g_aver.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
9 * File : c_g_aver.c |
dc3b7caa59c4
libtwamr: integrate c_g_aver.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
10 * Purpose : |
dc3b7caa59c4
libtwamr: integrate c_g_aver.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
11 * |
dc3b7caa59c4
libtwamr: integrate c_g_aver.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
12 ******************************************************************************** |
dc3b7caa59c4
libtwamr: integrate c_g_aver.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
13 */ |
dc3b7caa59c4
libtwamr: integrate c_g_aver.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
14 |
dc3b7caa59c4
libtwamr: integrate c_g_aver.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
15 /* |
dc3b7caa59c4
libtwamr: integrate c_g_aver.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
16 ******************************************************************************** |
dc3b7caa59c4
libtwamr: integrate c_g_aver.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
17 * MODULE INCLUDE FILE AND VERSION ID |
dc3b7caa59c4
libtwamr: integrate c_g_aver.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
18 ******************************************************************************** |
dc3b7caa59c4
libtwamr: integrate c_g_aver.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
19 */ |
dc3b7caa59c4
libtwamr: integrate c_g_aver.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
20 #include "namespace.h" |
dc3b7caa59c4
libtwamr: integrate c_g_aver.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
21 #include "c_g_aver.h" |
dc3b7caa59c4
libtwamr: integrate c_g_aver.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
22 |
dc3b7caa59c4
libtwamr: integrate c_g_aver.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
23 #include "tw_amr.h" |
dc3b7caa59c4
libtwamr: integrate c_g_aver.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
24 #include "typedef.h" |
dc3b7caa59c4
libtwamr: integrate c_g_aver.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
25 #include "basic_op.h" |
dc3b7caa59c4
libtwamr: integrate c_g_aver.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
26 #include "no_count.h" |
dc3b7caa59c4
libtwamr: integrate c_g_aver.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
27 #include "cnst.h" |
dc3b7caa59c4
libtwamr: integrate c_g_aver.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
28 #include "memops.h" |
dc3b7caa59c4
libtwamr: integrate c_g_aver.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
29 |
dc3b7caa59c4
libtwamr: integrate c_g_aver.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
30 /* |
dc3b7caa59c4
libtwamr: integrate c_g_aver.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
31 ******************************************************************************** |
dc3b7caa59c4
libtwamr: integrate c_g_aver.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
32 * LOCAL VARIABLES AND TABLES |
dc3b7caa59c4
libtwamr: integrate c_g_aver.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
33 ******************************************************************************** |
dc3b7caa59c4
libtwamr: integrate c_g_aver.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
34 */ |
dc3b7caa59c4
libtwamr: integrate c_g_aver.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
35 /*-----------------------------------------------------------------* |
dc3b7caa59c4
libtwamr: integrate c_g_aver.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
36 * Decoder constant parameters (defined in "cnst.h") * |
dc3b7caa59c4
libtwamr: integrate c_g_aver.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
37 *-----------------------------------------------------------------* |
dc3b7caa59c4
libtwamr: integrate c_g_aver.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
38 * L_FRAME : Frame size. * |
dc3b7caa59c4
libtwamr: integrate c_g_aver.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
39 * L_SUBFR : Sub-frame size. * |
dc3b7caa59c4
libtwamr: integrate c_g_aver.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
40 *-----------------------------------------------------------------*/ |
dc3b7caa59c4
libtwamr: integrate c_g_aver.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
41 |
dc3b7caa59c4
libtwamr: integrate c_g_aver.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
42 /* |
dc3b7caa59c4
libtwamr: integrate c_g_aver.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
43 ******************************************************************************** |
dc3b7caa59c4
libtwamr: integrate c_g_aver.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
44 * PUBLIC PROGRAM CODE |
dc3b7caa59c4
libtwamr: integrate c_g_aver.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
45 ******************************************************************************** |
dc3b7caa59c4
libtwamr: integrate c_g_aver.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
46 */ |
dc3b7caa59c4
libtwamr: integrate c_g_aver.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
47 /* |
dc3b7caa59c4
libtwamr: integrate c_g_aver.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
48 ************************************************************************** |
dc3b7caa59c4
libtwamr: integrate c_g_aver.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
49 * |
dc3b7caa59c4
libtwamr: integrate c_g_aver.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
50 * Function : Cb_gain_average_reset |
dc3b7caa59c4
libtwamr: integrate c_g_aver.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
51 * Purpose : Resets state memory |
dc3b7caa59c4
libtwamr: integrate c_g_aver.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
52 * |
dc3b7caa59c4
libtwamr: integrate c_g_aver.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
53 ************************************************************************** |
dc3b7caa59c4
libtwamr: integrate c_g_aver.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
54 */ |
dc3b7caa59c4
libtwamr: integrate c_g_aver.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
55 void Cb_gain_average_reset (Cb_gain_averageState *state) |
dc3b7caa59c4
libtwamr: integrate c_g_aver.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
56 { |
dc3b7caa59c4
libtwamr: integrate c_g_aver.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
57 /* Static vectors to zero */ |
dc3b7caa59c4
libtwamr: integrate c_g_aver.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
58 Set_zero (state->cbGainHistory, L_CBGAINHIST); |
dc3b7caa59c4
libtwamr: integrate c_g_aver.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
59 |
dc3b7caa59c4
libtwamr: integrate c_g_aver.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
60 /* Initialize hangover handling */ |
dc3b7caa59c4
libtwamr: integrate c_g_aver.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
61 state->hangVar = 0; |
dc3b7caa59c4
libtwamr: integrate c_g_aver.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
62 state->hangCount= 0; |
dc3b7caa59c4
libtwamr: integrate c_g_aver.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
63 } |
dc3b7caa59c4
libtwamr: integrate c_g_aver.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
64 |
dc3b7caa59c4
libtwamr: integrate c_g_aver.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
65 /* |
dc3b7caa59c4
libtwamr: integrate c_g_aver.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
66 ************************************************************************** |
dc3b7caa59c4
libtwamr: integrate c_g_aver.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
67 * |
dc3b7caa59c4
libtwamr: integrate c_g_aver.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
68 * Function : Cb_gain_average |
dc3b7caa59c4
libtwamr: integrate c_g_aver.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
69 * Purpose : |
dc3b7caa59c4
libtwamr: integrate c_g_aver.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
70 * Returns : The mix cb gains for MR475, MR515, MR59, MR67, MR102; gain_code other modes |
dc3b7caa59c4
libtwamr: integrate c_g_aver.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
71 * |
dc3b7caa59c4
libtwamr: integrate c_g_aver.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
72 ************************************************************************** |
dc3b7caa59c4
libtwamr: integrate c_g_aver.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
73 */ |
dc3b7caa59c4
libtwamr: integrate c_g_aver.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
74 Word16 Cb_gain_average ( |
dc3b7caa59c4
libtwamr: integrate c_g_aver.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
75 Cb_gain_averageState *st, /* i/o : State variables for CB gain avergeing */ |
dc3b7caa59c4
libtwamr: integrate c_g_aver.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
76 enum Mode mode, /* i : AMR mode */ |
dc3b7caa59c4
libtwamr: integrate c_g_aver.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
77 Word16 gain_code, /* i : CB gain Q1 */ |
dc3b7caa59c4
libtwamr: integrate c_g_aver.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
78 Word16 lsp[], /* i : The LSP for the current frame Q15 */ |
dc3b7caa59c4
libtwamr: integrate c_g_aver.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
79 Word16 lspAver[], /* i : The average of LSP for 8 frames Q15 */ |
dc3b7caa59c4
libtwamr: integrate c_g_aver.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
80 Word16 bfi, /* i : bad frame indication flag */ |
dc3b7caa59c4
libtwamr: integrate c_g_aver.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
81 Word16 prev_bf, /* i : previous bad frame indication flag */ |
dc3b7caa59c4
libtwamr: integrate c_g_aver.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
82 Word16 pdfi, /* i : potential degraded bad frame ind flag */ |
dc3b7caa59c4
libtwamr: integrate c_g_aver.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
83 Word16 prev_pdf, /* i : prev pot. degraded bad frame ind flag */ |
dc3b7caa59c4
libtwamr: integrate c_g_aver.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
84 Word16 inBackgroundNoise, /* i : background noise decision */ |
dc3b7caa59c4
libtwamr: integrate c_g_aver.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
85 Word16 voicedHangover /* i : # of frames after last voiced frame */ |
dc3b7caa59c4
libtwamr: integrate c_g_aver.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
86 ) |
dc3b7caa59c4
libtwamr: integrate c_g_aver.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
87 { |
dc3b7caa59c4
libtwamr: integrate c_g_aver.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
88 /*---------------------------------------------------------* |
dc3b7caa59c4
libtwamr: integrate c_g_aver.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
89 * Compute mixed cb gain, used to make cb gain more * |
dc3b7caa59c4
libtwamr: integrate c_g_aver.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
90 * smooth in background noise for modes 5.15, 5.9 and 6.7 * |
dc3b7caa59c4
libtwamr: integrate c_g_aver.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
91 * states that needs to be updated by all * |
dc3b7caa59c4
libtwamr: integrate c_g_aver.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
92 *---------------------------------------------------------*/ |
dc3b7caa59c4
libtwamr: integrate c_g_aver.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
93 Word16 i; |
dc3b7caa59c4
libtwamr: integrate c_g_aver.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
94 Word16 cbGainMix, diff, tmp_diff, bgMix, cbGainMean; |
dc3b7caa59c4
libtwamr: integrate c_g_aver.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
95 Word32 L_sum; |
dc3b7caa59c4
libtwamr: integrate c_g_aver.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
96 Word16 tmp[M], tmp1, tmp2, shift1, shift2, shift; |
dc3b7caa59c4
libtwamr: integrate c_g_aver.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
97 |
dc3b7caa59c4
libtwamr: integrate c_g_aver.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
98 /* set correct cbGainMix for MR74, MR795, MR122 */ |
dc3b7caa59c4
libtwamr: integrate c_g_aver.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
99 cbGainMix = gain_code; move16 (); |
dc3b7caa59c4
libtwamr: integrate c_g_aver.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
100 |
dc3b7caa59c4
libtwamr: integrate c_g_aver.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
101 /*-------------------------------------------------------* |
dc3b7caa59c4
libtwamr: integrate c_g_aver.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
102 * Store list of CB gain needed in the CB gain * |
dc3b7caa59c4
libtwamr: integrate c_g_aver.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
103 * averaging * |
dc3b7caa59c4
libtwamr: integrate c_g_aver.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
104 *-------------------------------------------------------*/ |
dc3b7caa59c4
libtwamr: integrate c_g_aver.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
105 for (i = 0; i < (L_CBGAINHIST-1); i++) |
dc3b7caa59c4
libtwamr: integrate c_g_aver.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
106 { |
dc3b7caa59c4
libtwamr: integrate c_g_aver.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
107 st->cbGainHistory[i] = st->cbGainHistory[i+1]; move16 (); |
dc3b7caa59c4
libtwamr: integrate c_g_aver.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
108 } |
dc3b7caa59c4
libtwamr: integrate c_g_aver.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
109 st->cbGainHistory[L_CBGAINHIST-1] = gain_code; move16 (); |
dc3b7caa59c4
libtwamr: integrate c_g_aver.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
110 |
dc3b7caa59c4
libtwamr: integrate c_g_aver.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
111 /* compute lsp difference */ |
dc3b7caa59c4
libtwamr: integrate c_g_aver.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
112 for (i = 0; i < M; i++) { |
dc3b7caa59c4
libtwamr: integrate c_g_aver.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
113 tmp1 = abs_s(sub(lspAver[i], lsp[i])); /* Q15 */ |
dc3b7caa59c4
libtwamr: integrate c_g_aver.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
114 shift1 = sub(norm_s(tmp1), 1); /* Qn */ |
dc3b7caa59c4
libtwamr: integrate c_g_aver.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
115 tmp1 = shl(tmp1, shift1); /* Q15+Qn */ |
dc3b7caa59c4
libtwamr: integrate c_g_aver.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
116 shift2 = norm_s(lspAver[i]); /* Qm */ |
dc3b7caa59c4
libtwamr: integrate c_g_aver.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
117 tmp2 = shl(lspAver[i], shift2); /* Q15+Qm */ |
dc3b7caa59c4
libtwamr: integrate c_g_aver.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
118 tmp[i] = div_s(tmp1, tmp2); /* Q15+(Q15+Qn)-(Q15+Qm) */ |
dc3b7caa59c4
libtwamr: integrate c_g_aver.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
119 move16 (); |
dc3b7caa59c4
libtwamr: integrate c_g_aver.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
120 shift = sub(add(2, shift1), shift2); |
dc3b7caa59c4
libtwamr: integrate c_g_aver.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
121 test (); |
dc3b7caa59c4
libtwamr: integrate c_g_aver.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
122 if (shift >= 0) |
dc3b7caa59c4
libtwamr: integrate c_g_aver.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
123 { |
dc3b7caa59c4
libtwamr: integrate c_g_aver.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
124 tmp[i] = shr(tmp[i], shift); move16 (); /* Q15+Qn-Qm-Qx=Q13 */ |
dc3b7caa59c4
libtwamr: integrate c_g_aver.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
125 } |
dc3b7caa59c4
libtwamr: integrate c_g_aver.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
126 else |
dc3b7caa59c4
libtwamr: integrate c_g_aver.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
127 { |
dc3b7caa59c4
libtwamr: integrate c_g_aver.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
128 tmp[i] = shl(tmp[i], negate(shift)); move16 (); /* Q15+Qn-Qm-Qx=Q13 */ |
dc3b7caa59c4
libtwamr: integrate c_g_aver.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
129 } |
dc3b7caa59c4
libtwamr: integrate c_g_aver.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
130 } |
dc3b7caa59c4
libtwamr: integrate c_g_aver.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
131 |
dc3b7caa59c4
libtwamr: integrate c_g_aver.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
132 diff = tmp[0]; move16 (); |
dc3b7caa59c4
libtwamr: integrate c_g_aver.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
133 for (i = 1; i < M; i++) { |
dc3b7caa59c4
libtwamr: integrate c_g_aver.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
134 diff = add(diff, tmp[i]); /* Q13 */ |
dc3b7caa59c4
libtwamr: integrate c_g_aver.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
135 } |
dc3b7caa59c4
libtwamr: integrate c_g_aver.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
136 |
dc3b7caa59c4
libtwamr: integrate c_g_aver.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
137 /* Compute hangover */ |
dc3b7caa59c4
libtwamr: integrate c_g_aver.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
138 test (); |
dc3b7caa59c4
libtwamr: integrate c_g_aver.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
139 if (sub(diff, 5325) > 0) /* 0.65 in Q11 */ |
dc3b7caa59c4
libtwamr: integrate c_g_aver.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
140 { |
dc3b7caa59c4
libtwamr: integrate c_g_aver.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
141 st->hangVar = add(st->hangVar, 1); |
dc3b7caa59c4
libtwamr: integrate c_g_aver.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
142 } |
dc3b7caa59c4
libtwamr: integrate c_g_aver.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
143 else |
dc3b7caa59c4
libtwamr: integrate c_g_aver.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
144 { |
dc3b7caa59c4
libtwamr: integrate c_g_aver.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
145 st->hangVar = 0; move16 (); |
dc3b7caa59c4
libtwamr: integrate c_g_aver.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
146 } |
dc3b7caa59c4
libtwamr: integrate c_g_aver.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
147 |
dc3b7caa59c4
libtwamr: integrate c_g_aver.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
148 test (); |
dc3b7caa59c4
libtwamr: integrate c_g_aver.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
149 if (sub(st->hangVar, 10) > 0) |
dc3b7caa59c4
libtwamr: integrate c_g_aver.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
150 { |
dc3b7caa59c4
libtwamr: integrate c_g_aver.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
151 st->hangCount = 0; /* Speech period, reset hangover variable */ move16 (); |
dc3b7caa59c4
libtwamr: integrate c_g_aver.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
152 } |
dc3b7caa59c4
libtwamr: integrate c_g_aver.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
153 |
dc3b7caa59c4
libtwamr: integrate c_g_aver.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
154 /* Compute mix constant (bgMix) */ |
dc3b7caa59c4
libtwamr: integrate c_g_aver.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
155 bgMix = 8192; /* 1 in Q13 */ move16 (); |
dc3b7caa59c4
libtwamr: integrate c_g_aver.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
156 test (); |
dc3b7caa59c4
libtwamr: integrate c_g_aver.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
157 if ((sub(mode, MR67) <= 0) || (sub(mode, MR102) == 0)) |
dc3b7caa59c4
libtwamr: integrate c_g_aver.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
158 /* MR475, MR515, MR59, MR67, MR102 */ |
dc3b7caa59c4
libtwamr: integrate c_g_aver.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
159 { |
dc3b7caa59c4
libtwamr: integrate c_g_aver.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
160 /* if errors and presumed noise make smoothing probability stronger */ |
dc3b7caa59c4
libtwamr: integrate c_g_aver.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
161 test (); test (); test (); test (); test (); test(); test (); test (); test (); |
dc3b7caa59c4
libtwamr: integrate c_g_aver.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
162 if (((((pdfi != 0) && (prev_pdf != 0)) || (bfi != 0) || (prev_bf != 0)) && |
dc3b7caa59c4
libtwamr: integrate c_g_aver.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
163 (sub(voicedHangover, 1) > 0) && (inBackgroundNoise != 0) && |
dc3b7caa59c4
libtwamr: integrate c_g_aver.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
164 ((sub(mode, MR475) == 0) || |
dc3b7caa59c4
libtwamr: integrate c_g_aver.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
165 (sub(mode, MR515) == 0) || |
dc3b7caa59c4
libtwamr: integrate c_g_aver.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
166 (sub(mode, MR59) == 0)) )) |
dc3b7caa59c4
libtwamr: integrate c_g_aver.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
167 { |
dc3b7caa59c4
libtwamr: integrate c_g_aver.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
168 /* bgMix = min(0.25, max(0.0, diff-0.55)) / 0.25; */ |
dc3b7caa59c4
libtwamr: integrate c_g_aver.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
169 tmp_diff = sub(diff, 4506); /* 0.55 in Q13 */ |
dc3b7caa59c4
libtwamr: integrate c_g_aver.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
170 |
dc3b7caa59c4
libtwamr: integrate c_g_aver.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
171 /* max(0.0, diff-0.55) */ |
dc3b7caa59c4
libtwamr: integrate c_g_aver.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
172 test (); |
dc3b7caa59c4
libtwamr: integrate c_g_aver.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
173 if (tmp_diff > 0) |
dc3b7caa59c4
libtwamr: integrate c_g_aver.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
174 { |
dc3b7caa59c4
libtwamr: integrate c_g_aver.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
175 tmp1 = tmp_diff; move16 (); |
dc3b7caa59c4
libtwamr: integrate c_g_aver.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
176 } |
dc3b7caa59c4
libtwamr: integrate c_g_aver.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
177 else |
dc3b7caa59c4
libtwamr: integrate c_g_aver.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
178 { |
dc3b7caa59c4
libtwamr: integrate c_g_aver.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
179 tmp1 = 0; move16 (); |
dc3b7caa59c4
libtwamr: integrate c_g_aver.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
180 } |
dc3b7caa59c4
libtwamr: integrate c_g_aver.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
181 |
dc3b7caa59c4
libtwamr: integrate c_g_aver.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
182 /* min(0.25, tmp1) */ |
dc3b7caa59c4
libtwamr: integrate c_g_aver.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
183 test (); |
dc3b7caa59c4
libtwamr: integrate c_g_aver.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
184 if (sub(2048, tmp1) < 0) |
dc3b7caa59c4
libtwamr: integrate c_g_aver.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
185 { |
dc3b7caa59c4
libtwamr: integrate c_g_aver.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
186 bgMix = 8192; move16 (); |
dc3b7caa59c4
libtwamr: integrate c_g_aver.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
187 } |
dc3b7caa59c4
libtwamr: integrate c_g_aver.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
188 else |
dc3b7caa59c4
libtwamr: integrate c_g_aver.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
189 { |
dc3b7caa59c4
libtwamr: integrate c_g_aver.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
190 bgMix = shl(tmp1, 2); |
dc3b7caa59c4
libtwamr: integrate c_g_aver.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
191 } |
dc3b7caa59c4
libtwamr: integrate c_g_aver.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
192 } |
dc3b7caa59c4
libtwamr: integrate c_g_aver.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
193 else |
dc3b7caa59c4
libtwamr: integrate c_g_aver.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
194 { |
dc3b7caa59c4
libtwamr: integrate c_g_aver.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
195 /* bgMix = min(0.25, max(0.0, diff-0.40)) / 0.25; */ |
dc3b7caa59c4
libtwamr: integrate c_g_aver.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
196 tmp_diff = sub(diff, 3277); /* 0.4 in Q13 */ |
dc3b7caa59c4
libtwamr: integrate c_g_aver.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
197 |
dc3b7caa59c4
libtwamr: integrate c_g_aver.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
198 /* max(0.0, diff-0.40) */ |
dc3b7caa59c4
libtwamr: integrate c_g_aver.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
199 test (); |
dc3b7caa59c4
libtwamr: integrate c_g_aver.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
200 if (tmp_diff > 0) |
dc3b7caa59c4
libtwamr: integrate c_g_aver.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
201 { |
dc3b7caa59c4
libtwamr: integrate c_g_aver.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
202 tmp1 = tmp_diff; move16 (); |
dc3b7caa59c4
libtwamr: integrate c_g_aver.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
203 } |
dc3b7caa59c4
libtwamr: integrate c_g_aver.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
204 else |
dc3b7caa59c4
libtwamr: integrate c_g_aver.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
205 { |
dc3b7caa59c4
libtwamr: integrate c_g_aver.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
206 tmp1 = 0; move16 (); |
dc3b7caa59c4
libtwamr: integrate c_g_aver.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
207 } |
dc3b7caa59c4
libtwamr: integrate c_g_aver.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
208 |
dc3b7caa59c4
libtwamr: integrate c_g_aver.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
209 /* min(0.25, tmp1) */ |
dc3b7caa59c4
libtwamr: integrate c_g_aver.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
210 test (); |
dc3b7caa59c4
libtwamr: integrate c_g_aver.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
211 if (sub(2048, tmp1) < 0) |
dc3b7caa59c4
libtwamr: integrate c_g_aver.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
212 { |
dc3b7caa59c4
libtwamr: integrate c_g_aver.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
213 bgMix = 8192; move16 (); |
dc3b7caa59c4
libtwamr: integrate c_g_aver.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
214 } |
dc3b7caa59c4
libtwamr: integrate c_g_aver.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
215 else |
dc3b7caa59c4
libtwamr: integrate c_g_aver.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
216 { |
dc3b7caa59c4
libtwamr: integrate c_g_aver.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
217 bgMix = shl(tmp1, 2); |
dc3b7caa59c4
libtwamr: integrate c_g_aver.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
218 } |
dc3b7caa59c4
libtwamr: integrate c_g_aver.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
219 } |
dc3b7caa59c4
libtwamr: integrate c_g_aver.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
220 |
dc3b7caa59c4
libtwamr: integrate c_g_aver.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
221 test (); test (); |
dc3b7caa59c4
libtwamr: integrate c_g_aver.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
222 if ((sub(st->hangCount, 40) < 0) || (sub(diff, 5325) > 0)) /* 0.65 in Q13 */ |
dc3b7caa59c4
libtwamr: integrate c_g_aver.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
223 { |
dc3b7caa59c4
libtwamr: integrate c_g_aver.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
224 bgMix = 8192; /* disable mix if too short time since */ move16 (); |
dc3b7caa59c4
libtwamr: integrate c_g_aver.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
225 } |
dc3b7caa59c4
libtwamr: integrate c_g_aver.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
226 |
dc3b7caa59c4
libtwamr: integrate c_g_aver.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
227 /* Smoothen the cb gain trajectory */ |
dc3b7caa59c4
libtwamr: integrate c_g_aver.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
228 /* smoothing depends on mix constant bgMix */ |
dc3b7caa59c4
libtwamr: integrate c_g_aver.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
229 L_sum = L_mult(6554, st->cbGainHistory[2]); /* 0.2 in Q15; L_sum in Q17 */ |
dc3b7caa59c4
libtwamr: integrate c_g_aver.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
230 for (i = 3; i < L_CBGAINHIST; i++) |
dc3b7caa59c4
libtwamr: integrate c_g_aver.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
231 { |
dc3b7caa59c4
libtwamr: integrate c_g_aver.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
232 L_sum = L_mac(L_sum, 6554, st->cbGainHistory[i]); |
dc3b7caa59c4
libtwamr: integrate c_g_aver.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
233 } |
dc3b7caa59c4
libtwamr: integrate c_g_aver.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
234 cbGainMean = round(L_sum); /* Q1 */ |
dc3b7caa59c4
libtwamr: integrate c_g_aver.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
235 |
dc3b7caa59c4
libtwamr: integrate c_g_aver.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
236 /* more smoothing in error and bg noise (NB no DFI used here) */ |
dc3b7caa59c4
libtwamr: integrate c_g_aver.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
237 test (); test (); test (); test (); test(); test(); |
dc3b7caa59c4
libtwamr: integrate c_g_aver.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
238 if (((bfi != 0) || (prev_bf != 0)) && (inBackgroundNoise != 0) && |
dc3b7caa59c4
libtwamr: integrate c_g_aver.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
239 ((sub(mode, MR475) == 0) || |
dc3b7caa59c4
libtwamr: integrate c_g_aver.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
240 (sub(mode, MR515) == 0) || |
dc3b7caa59c4
libtwamr: integrate c_g_aver.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
241 (sub(mode, MR59) == 0)) ) |
dc3b7caa59c4
libtwamr: integrate c_g_aver.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
242 { |
dc3b7caa59c4
libtwamr: integrate c_g_aver.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
243 L_sum = L_mult(4681, st->cbGainHistory[0]); /* 0.143 in Q15; L_sum in Q17 */ |
dc3b7caa59c4
libtwamr: integrate c_g_aver.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
244 for (i = 1; i < L_CBGAINHIST; i++) |
dc3b7caa59c4
libtwamr: integrate c_g_aver.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
245 { |
dc3b7caa59c4
libtwamr: integrate c_g_aver.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
246 L_sum = L_mac(L_sum, 4681, st->cbGainHistory[i]); |
dc3b7caa59c4
libtwamr: integrate c_g_aver.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
247 } |
dc3b7caa59c4
libtwamr: integrate c_g_aver.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
248 cbGainMean = round(L_sum); /* Q1 */ |
dc3b7caa59c4
libtwamr: integrate c_g_aver.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
249 } |
dc3b7caa59c4
libtwamr: integrate c_g_aver.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
250 |
dc3b7caa59c4
libtwamr: integrate c_g_aver.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
251 /* cbGainMix = bgMix*cbGainMix + (1-bgMix)*cbGainMean; */ |
dc3b7caa59c4
libtwamr: integrate c_g_aver.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
252 L_sum = L_mult(bgMix, cbGainMix); /* L_sum in Q15 */ |
dc3b7caa59c4
libtwamr: integrate c_g_aver.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
253 L_sum = L_mac(L_sum, 8192, cbGainMean); |
dc3b7caa59c4
libtwamr: integrate c_g_aver.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
254 L_sum = L_msu(L_sum, bgMix, cbGainMean); |
dc3b7caa59c4
libtwamr: integrate c_g_aver.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
255 cbGainMix = round(L_shl(L_sum, 2)); /* Q1 */ |
dc3b7caa59c4
libtwamr: integrate c_g_aver.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
256 } |
dc3b7caa59c4
libtwamr: integrate c_g_aver.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
257 |
dc3b7caa59c4
libtwamr: integrate c_g_aver.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
258 st->hangCount = add(st->hangCount, 1); |
dc3b7caa59c4
libtwamr: integrate c_g_aver.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
259 return cbGainMix; |
dc3b7caa59c4
libtwamr: integrate c_g_aver.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
260 } |