comparison libtwamr/agc.h @ 253:54f6bc41ed10

libtwamr: integrate a* modules
author Mychaela Falconia <falcon@freecalypso.org>
date Fri, 05 Apr 2024 06:08:15 +0000
parents
children 6b33f3ba4289
comparison
equal deleted inserted replaced
252:57b4053559ff 253:54f6bc41ed10
1 /*
2 *****************************************************************************
3 *
4 * GSM AMR-NB speech codec R98 Version 7.6.0 December 12, 2001
5 * R99 Version 3.3.0
6 * REL-4 Version 4.1.0
7 *
8 *****************************************************************************
9 *
10 * File : agc.h
11 * Purpose : Scales the postfilter output on a subframe basis
12 * : by automatic control of the subframe gain.
13 *
14 *****************************************************************************
15 */
16 #ifndef agc_h
17 #define agc_h "$Id $"
18
19 /*
20 *****************************************************************************
21 * INCLUDE FILES
22 *****************************************************************************
23 */
24 #include "typedef.h"
25
26 /*
27 *****************************************************************************
28 * DEFINITION OF DATA TYPES
29 *****************************************************************************
30 */
31 typedef struct {
32 Word16 past_gain;
33 } agcState;
34
35 /*
36 *****************************************************************************
37 * DECLARATION OF PROTOTYPES
38 *****************************************************************************
39 */
40 /*
41 **************************************************************************
42 *
43 * Function : agc_init
44 * Purpose : Allocates memory for agc state and initializes
45 * state memory
46 * Description : Stores pointer to agc status struct in *st. This pointer
47 * has to be passed to agc in each call.
48 * Returns : 0 on success
49 *
50 **************************************************************************
51 */
52 int agc_init(agcState **st);
53
54 /*
55 **************************************************************************
56 *
57 * Function : agc_reset
58 * Purpose : Reset of agc (i.e. set state memory to 1.0)
59 * Returns : 0 on success
60 *
61 **************************************************************************
62 */
63 int agc_reset (agcState *st);
64
65 /*
66 **************************************************************************
67 *
68 * Function : agc_exit
69 * Purpose : The memory used for state memory is freed,
70 * de-initialize agc
71 *
72 **************************************************************************
73 */
74 void agc_exit (agcState **st);
75
76 /*
77 **************************************************************************
78 *
79 * Function : agc
80 * Purpose : Scales the postfilter output on a subframe basis
81 * Description : sig_out[n] = sig_out[n] * gain[n];
82 * where gain[n] is the gain at the nth sample given by
83 * gain[n] = agc_fac * gain[n-1] + (1 - agc_fac) g_in/g_out
84 * g_in/g_out is the square root of the ratio of energy at
85 * the input and output of the postfilter.
86 *
87 **************************************************************************
88 */
89 int agc (
90 agcState *st, /* i/o : agc state */
91 Word16 *sig_in, /* i : postfilter input signal, (l_trm) */
92 Word16 *sig_out, /* i/o : postfilter output signal, (l_trm) */
93 Word16 agc_fac, /* i : AGC factor */
94 Word16 l_trm /* i : subframe size */
95 );
96
97 /*
98 **************************************************************************
99 *
100 * Function: agc2
101 * Purpose: Scales the excitation on a subframe basis
102 *
103 **************************************************************************
104 */
105 void agc2 (
106 Word16 *sig_in, /* i : postfilter input signal */
107 Word16 *sig_out, /* i/o : postfilter output signal */
108 Word16 l_trm /* i : subframe size */
109 );
110
111 #endif