Git init
[external/opencore-amr.git] / opencore / codecs_v2 / audio / gsm_amr / amr_nb / dec / src / c_g_aver.h
1 /* ------------------------------------------------------------------
2  * Copyright (C) 1998-2009 PacketVideo
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *      http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
13  * express or implied.
14  * See the License for the specific language governing permissions
15  * and limitations under the License.
16  * -------------------------------------------------------------------
17  */
18 /****************************************************************************************
19 Portions of this file are derived from the following 3GPP standard:
20
21     3GPP TS 26.073
22     ANSI-C code for the Adaptive Multi-Rate (AMR) speech codec
23     Available from http://www.3gpp.org
24
25 (C) 2004, 3GPP Organizational Partners (ARIB, ATIS, CCSA, ETSI, TTA, TTC)
26 Permission to distribute, modify and use this file under the standard license
27 terms listed above has been obtained from the copyright holder.
28 ****************************************************************************************/
29 /*
30 ------------------------------------------------------------------------------
31
32
33
34  Filename: c_g_aver.h
35
36 ------------------------------------------------------------------------------
37  INCLUDE DESCRIPTION
38
39       File             : c_g_aver.h
40       Purpose          : Background noise source charateristic detector (SCD)
41
42 ------------------------------------------------------------------------------
43 */
44
45 #ifndef _C_G_AVER_H_
46 #define _C_G_AVER_H_
47
48 /*----------------------------------------------------------------------------
49 ; INCLUDES
50 ----------------------------------------------------------------------------*/
51 #include "typedef.h"
52 #include "mode.h"
53 #include "cnst.h"
54
55 /*--------------------------------------------------------------------------*/
56 #ifdef __cplusplus
57 extern "C"
58 {
59 #endif
60
61     /*----------------------------------------------------------------------------
62     ; MACROS
63     ; [Define module specific macros here]
64     ----------------------------------------------------------------------------*/
65
66     /*----------------------------------------------------------------------------
67     ; DEFINES
68     ; [Include all pre-processor statements here.]
69     ----------------------------------------------------------------------------*/
70 #define L_CBGAINHIST 7
71
72     /*----------------------------------------------------------------------------
73     ; EXTERNAL VARIABLES REFERENCES
74     ; [Declare variables used in this module but defined elsewhere]
75     ----------------------------------------------------------------------------*/
76
77     /*----------------------------------------------------------------------------
78     ; SIMPLE TYPEDEF'S
79     ----------------------------------------------------------------------------*/
80
81     /*----------------------------------------------------------------------------
82     ; ENUMERATED TYPEDEF'S
83     ----------------------------------------------------------------------------*/
84
85     /*----------------------------------------------------------------------------
86     ; STRUCTURES TYPEDEF'S
87     ----------------------------------------------------------------------------*/
88     typedef struct
89     {
90         /* history vector of past synthesis speech energy */
91         Word16 cbGainHistory[L_CBGAINHIST];
92
93         /* state flags */
94         Word16 hangVar;       /* counter; */
95         Word16 hangCount;     /* counter; */
96
97     } Cb_gain_averageState;
98
99     /*----------------------------------------------------------------------------
100     ; GLOBAL FUNCTION DEFINITIONS
101     ; [List function prototypes here]
102     ----------------------------------------------------------------------------*/
103     /*
104      *  Function    : Cb_gain_average_init
105      *  Purpose     : Allocates initializes state memory
106      *  Description : Stores pointer to filter status struct in *st. This
107      *                pointer has to be passed to Cb_gain_average in each call.
108      *  Returns     : 0 on success
109      */
110     Word16 Cb_gain_average_init(Cb_gain_averageState **st);
111
112     /*
113      *  Function    : Cb_gain_average_reset
114      *  Purpose     : Resets state memory
115      *  Returns     : 0 on success
116      */
117     Word16 Cb_gain_average_reset(Cb_gain_averageState *st);
118
119     /*
120      *  Function    : Cb_gain_average_exit
121      *  Purpose     : The memory used for state memory is freed
122      *  Description : Stores NULL in *s
123      *  Returns     : void
124      */
125     void Cb_gain_average_exit(Cb_gain_averageState **st);
126
127     /*
128      *  Function    : Cb_gain_average
129      *  Purpose     : Charaterice synthesis speech and detect background noise
130      *  Returns     : background noise decision; 0 = bgn, 1 = no bgn
131      */
132     Word16 Cb_gain_average(
133         Cb_gain_averageState *st, /* i/o : State variables for CB gain avergeing   */
134         enum Mode mode,           /* i   : AMR mode                                */
135         Word16 gain_code,         /* i   : CB gain                              Q1 */
136         Word16 lsp[],             /* i   : The LSP for the current frame       Q15 */
137         Word16 lspAver[],         /* i   : The average of LSP for 8 frames     Q15 */
138         Word16 bfi,               /* i   : bad frame indication flag               */
139         Word16 prev_bf,           /* i   : previous bad frame indication flag      */
140         Word16 pdfi,              /* i   : potential degraded bad frame ind flag   */
141         Word16 prev_pdf,          /* i   : prev pot. degraded bad frame ind flag   */
142         Word16 inBackgroundNoise, /* i   : background noise decision               */
143         Word16 voicedHangover,    /* i   : # of frames after last voiced frame     */
144         Flag   *pOverflow
145     );
146
147
148 #ifdef __cplusplus
149 }
150 #endif
151
152 #endif  /* _C_G_AVER_H_ */
153
154