annotate libtwamr/ton_stab.c @ 430:edbbbf1c4ab1

implement twamr-tseq-dec test program
author Mychaela Falconia <falcon@freecalypso.org>
date Tue, 07 May 2024 23:35:41 +0000
parents 8fff74ca83e8
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
405
8fff74ca83e8 libtwamr: integrate ton_stab.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1 /*
8fff74ca83e8 libtwamr: integrate ton_stab.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2 *****************************************************************************
8fff74ca83e8 libtwamr: integrate ton_stab.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
3 *
8fff74ca83e8 libtwamr: integrate ton_stab.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
4 * GSM AMR-NB speech codec R98 Version 7.6.0 December 12, 2001
8fff74ca83e8 libtwamr: integrate ton_stab.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
5 * R99 Version 3.3.0
8fff74ca83e8 libtwamr: integrate ton_stab.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
6 * REL-4 Version 4.1.0
8fff74ca83e8 libtwamr: integrate ton_stab.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
7 *
8fff74ca83e8 libtwamr: integrate ton_stab.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
8 *****************************************************************************
8fff74ca83e8 libtwamr: integrate ton_stab.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
9 *
8fff74ca83e8 libtwamr: integrate ton_stab.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
10 * File : ton_stab.c
8fff74ca83e8 libtwamr: integrate ton_stab.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
11 *
8fff74ca83e8 libtwamr: integrate ton_stab.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
12 *****************************************************************************
8fff74ca83e8 libtwamr: integrate ton_stab.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
13 */
8fff74ca83e8 libtwamr: integrate ton_stab.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
14
8fff74ca83e8 libtwamr: integrate ton_stab.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
15 /*
8fff74ca83e8 libtwamr: integrate ton_stab.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
16 *****************************************************************************
8fff74ca83e8 libtwamr: integrate ton_stab.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
17 * MODULE INCLUDE FILE AND VERSION ID
8fff74ca83e8 libtwamr: integrate ton_stab.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
18 *****************************************************************************
8fff74ca83e8 libtwamr: integrate ton_stab.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
19 */
8fff74ca83e8 libtwamr: integrate ton_stab.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
20 #include "namespace.h"
8fff74ca83e8 libtwamr: integrate ton_stab.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
21 #include "ton_stab.h"
8fff74ca83e8 libtwamr: integrate ton_stab.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
22
8fff74ca83e8 libtwamr: integrate ton_stab.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
23 /*
8fff74ca83e8 libtwamr: integrate ton_stab.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
24 *****************************************************************************
8fff74ca83e8 libtwamr: integrate ton_stab.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
25 * INCLUDE FILES
8fff74ca83e8 libtwamr: integrate ton_stab.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
26 *****************************************************************************
8fff74ca83e8 libtwamr: integrate ton_stab.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
27 */
8fff74ca83e8 libtwamr: integrate ton_stab.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
28 #include "typedef.h"
8fff74ca83e8 libtwamr: integrate ton_stab.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
29 #include "basic_op.h"
8fff74ca83e8 libtwamr: integrate ton_stab.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
30 #include "no_count.h"
8fff74ca83e8 libtwamr: integrate ton_stab.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
31 #include "oper_32b.h"
8fff74ca83e8 libtwamr: integrate ton_stab.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
32 #include "cnst.h"
8fff74ca83e8 libtwamr: integrate ton_stab.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
33 #include "memops.h"
8fff74ca83e8 libtwamr: integrate ton_stab.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
34
8fff74ca83e8 libtwamr: integrate ton_stab.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
35 /*
8fff74ca83e8 libtwamr: integrate ton_stab.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
36 *****************************************************************************
8fff74ca83e8 libtwamr: integrate ton_stab.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
37 * LOCAL VARIABLES AND TABLES
8fff74ca83e8 libtwamr: integrate ton_stab.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
38 *****************************************************************************
8fff74ca83e8 libtwamr: integrate ton_stab.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
39 */
8fff74ca83e8 libtwamr: integrate ton_stab.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
40
8fff74ca83e8 libtwamr: integrate ton_stab.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
41 /*
8fff74ca83e8 libtwamr: integrate ton_stab.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
42 *****************************************************************************
8fff74ca83e8 libtwamr: integrate ton_stab.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
43 * PUBLIC PROGRAM CODE
8fff74ca83e8 libtwamr: integrate ton_stab.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
44 *****************************************************************************
8fff74ca83e8 libtwamr: integrate ton_stab.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
45 */
8fff74ca83e8 libtwamr: integrate ton_stab.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
46
8fff74ca83e8 libtwamr: integrate ton_stab.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
47 /*************************************************************************
8fff74ca83e8 libtwamr: integrate ton_stab.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
48 *
8fff74ca83e8 libtwamr: integrate ton_stab.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
49 * Function: ton_stab_reset
8fff74ca83e8 libtwamr: integrate ton_stab.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
50 * Purpose: Initializes state memory to zero
8fff74ca83e8 libtwamr: integrate ton_stab.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
51 *
8fff74ca83e8 libtwamr: integrate ton_stab.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
52 **************************************************************************
8fff74ca83e8 libtwamr: integrate ton_stab.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
53 */
8fff74ca83e8 libtwamr: integrate ton_stab.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
54 void ton_stab_reset (tonStabState *st)
8fff74ca83e8 libtwamr: integrate ton_stab.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
55 {
8fff74ca83e8 libtwamr: integrate ton_stab.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
56 /* initialize tone stabilizer state */
8fff74ca83e8 libtwamr: integrate ton_stab.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
57 st->count = 0;
8fff74ca83e8 libtwamr: integrate ton_stab.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
58 Set_zero(st->gp, N_FRAME); /* Init Gp_Clipping */
8fff74ca83e8 libtwamr: integrate ton_stab.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
59 }
8fff74ca83e8 libtwamr: integrate ton_stab.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
60
8fff74ca83e8 libtwamr: integrate ton_stab.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
61 /***************************************************************************
8fff74ca83e8 libtwamr: integrate ton_stab.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
62 * *
8fff74ca83e8 libtwamr: integrate ton_stab.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
63 * Function: check_lsp() *
8fff74ca83e8 libtwamr: integrate ton_stab.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
64 * Purpose: Check the LSP's to detect resonances *
8fff74ca83e8 libtwamr: integrate ton_stab.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
65 * *
8fff74ca83e8 libtwamr: integrate ton_stab.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
66 ****************************************************************************
8fff74ca83e8 libtwamr: integrate ton_stab.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
67 */
8fff74ca83e8 libtwamr: integrate ton_stab.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
68 Word16 check_lsp(tonStabState *st, /* i/o : State struct */
8fff74ca83e8 libtwamr: integrate ton_stab.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
69 Word16 *lsp /* i : unquantized LSP's */
8fff74ca83e8 libtwamr: integrate ton_stab.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
70 )
8fff74ca83e8 libtwamr: integrate ton_stab.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
71 {
8fff74ca83e8 libtwamr: integrate ton_stab.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
72 Word16 i, dist, dist_min1, dist_min2, dist_th;
8fff74ca83e8 libtwamr: integrate ton_stab.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
73
8fff74ca83e8 libtwamr: integrate ton_stab.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
74 /* Check for a resonance: */
8fff74ca83e8 libtwamr: integrate ton_stab.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
75 /* Find minimum distance between lsp[i] and lsp[i+1] */
8fff74ca83e8 libtwamr: integrate ton_stab.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
76
8fff74ca83e8 libtwamr: integrate ton_stab.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
77 dist_min1 = MAX_16; move16 ();
8fff74ca83e8 libtwamr: integrate ton_stab.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
78 for (i = 3; i < M-2; i++)
8fff74ca83e8 libtwamr: integrate ton_stab.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
79 {
8fff74ca83e8 libtwamr: integrate ton_stab.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
80 dist = sub(lsp[i], lsp[i+1]);
8fff74ca83e8 libtwamr: integrate ton_stab.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
81
8fff74ca83e8 libtwamr: integrate ton_stab.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
82 test ();
8fff74ca83e8 libtwamr: integrate ton_stab.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
83 if (sub(dist, dist_min1) < 0)
8fff74ca83e8 libtwamr: integrate ton_stab.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
84 {
8fff74ca83e8 libtwamr: integrate ton_stab.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
85 dist_min1 = dist; move16 ();
8fff74ca83e8 libtwamr: integrate ton_stab.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
86 }
8fff74ca83e8 libtwamr: integrate ton_stab.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
87 }
8fff74ca83e8 libtwamr: integrate ton_stab.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
88
8fff74ca83e8 libtwamr: integrate ton_stab.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
89 dist_min2 = MAX_16; move16 ();
8fff74ca83e8 libtwamr: integrate ton_stab.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
90 for (i = 1; i < 3; i++)
8fff74ca83e8 libtwamr: integrate ton_stab.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
91 {
8fff74ca83e8 libtwamr: integrate ton_stab.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
92 dist = sub(lsp[i], lsp[i+1]);
8fff74ca83e8 libtwamr: integrate ton_stab.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
93
8fff74ca83e8 libtwamr: integrate ton_stab.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
94 test ();
8fff74ca83e8 libtwamr: integrate ton_stab.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
95 if (sub(dist, dist_min2) < 0)
8fff74ca83e8 libtwamr: integrate ton_stab.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
96 {
8fff74ca83e8 libtwamr: integrate ton_stab.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
97 dist_min2 = dist; move16 ();
8fff74ca83e8 libtwamr: integrate ton_stab.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
98 }
8fff74ca83e8 libtwamr: integrate ton_stab.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
99 }
8fff74ca83e8 libtwamr: integrate ton_stab.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
100
8fff74ca83e8 libtwamr: integrate ton_stab.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
101 if (test (), sub(lsp[1], 32000) > 0)
8fff74ca83e8 libtwamr: integrate ton_stab.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
102 {
8fff74ca83e8 libtwamr: integrate ton_stab.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
103 dist_th = 600; move16 ();
8fff74ca83e8 libtwamr: integrate ton_stab.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
104 }
8fff74ca83e8 libtwamr: integrate ton_stab.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
105 else if (test (), sub(lsp[1], 30500) > 0)
8fff74ca83e8 libtwamr: integrate ton_stab.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
106 {
8fff74ca83e8 libtwamr: integrate ton_stab.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
107 dist_th = 800; move16 ();
8fff74ca83e8 libtwamr: integrate ton_stab.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
108 }
8fff74ca83e8 libtwamr: integrate ton_stab.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
109 else
8fff74ca83e8 libtwamr: integrate ton_stab.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
110 {
8fff74ca83e8 libtwamr: integrate ton_stab.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
111 dist_th = 1100; move16 ();
8fff74ca83e8 libtwamr: integrate ton_stab.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
112 }
8fff74ca83e8 libtwamr: integrate ton_stab.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
113
8fff74ca83e8 libtwamr: integrate ton_stab.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
114 test (); test ();
8fff74ca83e8 libtwamr: integrate ton_stab.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
115 if (sub(dist_min1, 1500) < 0 ||
8fff74ca83e8 libtwamr: integrate ton_stab.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
116 sub(dist_min2, dist_th) < 0)
8fff74ca83e8 libtwamr: integrate ton_stab.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
117 {
8fff74ca83e8 libtwamr: integrate ton_stab.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
118 st->count = add(st->count, 1);
8fff74ca83e8 libtwamr: integrate ton_stab.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
119 }
8fff74ca83e8 libtwamr: integrate ton_stab.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
120 else
8fff74ca83e8 libtwamr: integrate ton_stab.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
121 {
8fff74ca83e8 libtwamr: integrate ton_stab.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
122 st->count = 0; move16 ();
8fff74ca83e8 libtwamr: integrate ton_stab.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
123 }
8fff74ca83e8 libtwamr: integrate ton_stab.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
124
8fff74ca83e8 libtwamr: integrate ton_stab.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
125 /* Need 12 consecutive frames to set the flag */
8fff74ca83e8 libtwamr: integrate ton_stab.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
126 test ();
8fff74ca83e8 libtwamr: integrate ton_stab.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
127 if (sub(st->count, 12) >= 0)
8fff74ca83e8 libtwamr: integrate ton_stab.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
128 {
8fff74ca83e8 libtwamr: integrate ton_stab.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
129 st->count = 12; move16 ();
8fff74ca83e8 libtwamr: integrate ton_stab.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
130 return 1;
8fff74ca83e8 libtwamr: integrate ton_stab.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
131 }
8fff74ca83e8 libtwamr: integrate ton_stab.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
132 else
8fff74ca83e8 libtwamr: integrate ton_stab.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
133 {
8fff74ca83e8 libtwamr: integrate ton_stab.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
134 return 0;
8fff74ca83e8 libtwamr: integrate ton_stab.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
135 }
8fff74ca83e8 libtwamr: integrate ton_stab.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
136 }
8fff74ca83e8 libtwamr: integrate ton_stab.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
137
8fff74ca83e8 libtwamr: integrate ton_stab.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
138 /***************************************************************************
8fff74ca83e8 libtwamr: integrate ton_stab.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
139 *
8fff74ca83e8 libtwamr: integrate ton_stab.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
140 * Function: Check_Gp_Clipping()
8fff74ca83e8 libtwamr: integrate ton_stab.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
141 * Purpose: Verify that the sum of the last (N_FRAME+1) pitch
8fff74ca83e8 libtwamr: integrate ton_stab.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
142 * gains is under a certain threshold.
8fff74ca83e8 libtwamr: integrate ton_stab.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
143 *
8fff74ca83e8 libtwamr: integrate ton_stab.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
144 ***************************************************************************
8fff74ca83e8 libtwamr: integrate ton_stab.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
145 */
8fff74ca83e8 libtwamr: integrate ton_stab.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
146 Word16 check_gp_clipping(tonStabState *st, /* i/o : State struct */
8fff74ca83e8 libtwamr: integrate ton_stab.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
147 Word16 g_pitch /* i : pitch gain */
8fff74ca83e8 libtwamr: integrate ton_stab.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
148 )
8fff74ca83e8 libtwamr: integrate ton_stab.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
149 {
8fff74ca83e8 libtwamr: integrate ton_stab.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
150 Word16 i, sum;
8fff74ca83e8 libtwamr: integrate ton_stab.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
151
8fff74ca83e8 libtwamr: integrate ton_stab.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
152 sum = shr(g_pitch, 3); /* Division by 8 */
8fff74ca83e8 libtwamr: integrate ton_stab.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
153 for (i = 0; i < N_FRAME; i++)
8fff74ca83e8 libtwamr: integrate ton_stab.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
154 {
8fff74ca83e8 libtwamr: integrate ton_stab.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
155 sum = add(sum, st->gp[i]);
8fff74ca83e8 libtwamr: integrate ton_stab.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
156 }
8fff74ca83e8 libtwamr: integrate ton_stab.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
157
8fff74ca83e8 libtwamr: integrate ton_stab.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
158 test ();
8fff74ca83e8 libtwamr: integrate ton_stab.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
159 if (sub(sum, GP_CLIP) > 0)
8fff74ca83e8 libtwamr: integrate ton_stab.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
160 {
8fff74ca83e8 libtwamr: integrate ton_stab.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
161 return 1;
8fff74ca83e8 libtwamr: integrate ton_stab.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
162 }
8fff74ca83e8 libtwamr: integrate ton_stab.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
163 else
8fff74ca83e8 libtwamr: integrate ton_stab.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
164 {
8fff74ca83e8 libtwamr: integrate ton_stab.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
165 return 0;
8fff74ca83e8 libtwamr: integrate ton_stab.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
166 }
8fff74ca83e8 libtwamr: integrate ton_stab.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
167 }
8fff74ca83e8 libtwamr: integrate ton_stab.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
168
8fff74ca83e8 libtwamr: integrate ton_stab.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
169 /***************************************************************************
8fff74ca83e8 libtwamr: integrate ton_stab.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
170 *
8fff74ca83e8 libtwamr: integrate ton_stab.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
171 * Function: Update_Gp_Clipping()
8fff74ca83e8 libtwamr: integrate ton_stab.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
172 * Purpose: Update past pitch gain memory
8fff74ca83e8 libtwamr: integrate ton_stab.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
173 *
8fff74ca83e8 libtwamr: integrate ton_stab.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
174 ***************************************************************************
8fff74ca83e8 libtwamr: integrate ton_stab.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
175 */
8fff74ca83e8 libtwamr: integrate ton_stab.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
176 void update_gp_clipping(tonStabState *st, /* i/o : State struct */
8fff74ca83e8 libtwamr: integrate ton_stab.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
177 Word16 g_pitch /* i : pitch gain */
8fff74ca83e8 libtwamr: integrate ton_stab.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
178 )
8fff74ca83e8 libtwamr: integrate ton_stab.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
179 {
8fff74ca83e8 libtwamr: integrate ton_stab.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
180 Copy(&st->gp[1], &st->gp[0], N_FRAME-1);
8fff74ca83e8 libtwamr: integrate ton_stab.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
181 st->gp[N_FRAME-1] = shr(g_pitch, 3);
8fff74ca83e8 libtwamr: integrate ton_stab.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
182 }