Git init
[external/opencore-amr.git] / opencore / codecs_v2 / audio / gsm_amr / amr_nb / enc / src / gain_q.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: gain_q.h
35
36 ------------------------------------------------------------------------------
37  INCLUDE DESCRIPTION
38
39  This file contains all the constant definitions and prototype definitions
40  needed by the file, gain_q.c
41
42 ------------------------------------------------------------------------------
43 */
44
45 /*----------------------------------------------------------------------------
46 ; CONTINUE ONLY IF NOT ALREADY DEFINED
47 ----------------------------------------------------------------------------*/
48 #ifndef gain_q_h
49 #define gain_q_h "$Id $"
50
51 /*----------------------------------------------------------------------------
52 ; INCLUDES
53 ----------------------------------------------------------------------------*/
54 #include "typedef.h"
55 #include "mode.h"
56 #include "gc_pred.h"
57 #include "g_adapt.h"
58 #include "get_const_tbls.h"
59
60 /*--------------------------------------------------------------------------*/
61 #ifdef __cplusplus
62 extern "C"
63 {
64 #endif
65
66     /*----------------------------------------------------------------------------
67     ; MACROS
68     ; Define module specific macros here
69     ----------------------------------------------------------------------------*/
70
71     /*----------------------------------------------------------------------------
72     ; DEFINES
73     ; Include all pre-processor statements here.
74     ----------------------------------------------------------------------------*/
75
76     /*----------------------------------------------------------------------------
77     ; EXTERNAL VARIABLES REFERENCES
78     ; Declare variables used in this module but defined elsewhere
79     ----------------------------------------------------------------------------*/
80
81     /*----------------------------------------------------------------------------
82     ; SIMPLE TYPEDEF'S
83     ----------------------------------------------------------------------------*/
84
85     /*----------------------------------------------------------------------------
86     ; ENUMERATED TYPEDEF'S
87     ----------------------------------------------------------------------------*/
88
89     /*----------------------------------------------------------------------------
90     ; STRUCTURES TYPEDEF'S
91     ----------------------------------------------------------------------------*/
92     typedef struct
93     {
94         Word16 sf0_exp_gcode0;
95         Word16 sf0_frac_gcode0;
96         Word16 sf0_exp_target_en;
97         Word16 sf0_frac_target_en;
98         Word16 sf0_exp_coeff[5];
99         Word16 sf0_frac_coeff[5];
100         Word16 *gain_idx_ptr;
101
102         gc_predState     gc_predSt;
103         gc_predState     gc_predUnqSt;
104         GainAdaptState   *adaptSt;
105     } gainQuantState;
106
107     /*----------------------------------------------------------------------------
108     ; GLOBAL FUNCTION DEFINITIONS
109     ; Function Prototype declaration
110     ----------------------------------------------------------------------------*/
111     Word16 gainQuant_init(gainQuantState **st);
112     /* initialize one instance of the pre processing state.
113        Stores pointer to filter status struct in *st. This pointer has to
114        be passed to gainQuant in each call.
115        returns 0 on success
116      */
117     Word16 gainQuant_reset(gainQuantState *st);
118     /* reset of pre processing state (i.e. set state memory to zero)
119        returns 0 on success
120      */
121     void gainQuant_exit(gainQuantState **st);
122     /* de-initialize pre processing state (i.e. free status struct)
123        stores NULL in *st
124      */
125
126     void gainQuant(
127         gainQuantState *st,   /* i/o : State struct                      */
128         enum Mode mode,       /* i   : coder mode                        */
129         Word16 res[],         /* i   : LP residual,                 Q0   */
130         Word16 exc[],         /* i   : LTP excitation (unfiltered), Q0   */
131         Word16 code[],        /* i   : CB innovation (unfiltered),  Q13  */
132         /*       (unsharpened for MR475)           */
133         Word16 xn[],          /* i   : Target vector.                    */
134         Word16 xn2[],         /* i   : Target vector.                    */
135         Word16 y1[],          /* i   : Adaptive codebook.                */
136         Word16 Y2[],          /* i   : Filtered innovative vector.       */
137         Word16 g_coeff[],     /* i   : Correlations <xn y1> <y1 y1>      */
138         /*       Compute in G_pitch().             */
139         Word16 even_subframe, /* i   : even subframe indicator flag      */
140         Word16 gp_limit,      /* i   : pitch gain limit                  */
141         Word16 *sf0_gain_pit, /* o   : Pitch gain sf 0.   MR475          */
142         Word16 *sf0_gain_cod, /* o   : Code gain sf 0.    MR475          */
143         Word16 *gain_pit,     /* i/o : Pitch gain.                       */
144         Word16 *gain_cod,     /* o   : Code gain.                        */
145         /*       MR475: gain_* unquantized in even */
146         /*       subframes, quantized otherwise    */
147         Word16 **anap,        /* o   : Index of quantization             */
148         CommonAmrTbls* common_amr_tbls, /* i : ptr to struct of tbl ptrs */
149         Flag   *pOverflow     /* o   : overflow indicator                */
150     );
151
152     /*----------------------------------------------------------------------------
153     ; END
154     ----------------------------------------------------------------------------*/
155 #ifdef __cplusplus
156 }
157 #endif
158
159 #endif /* gain_q_h */
160
161