Initialize Tizen 2.3
[external/opencore-amr.git] / opencore / codecs_v2 / audio / gsm_amr / amr_nb / dec / src / ph_disp.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: ph_disp.h
35
36 ------------------------------------------------------------------------------
37  INCLUDE DESCRIPTION
38
39  This file contains all the constant definitions and prototype definitions
40  needed by the Phase dispersion of excitation signal ph_disp() function.
41
42 ------------------------------------------------------------------------------
43 */
44
45 #ifndef PH_DISP_H
46 #define PH_DISP_H "$Id $"
47
48 /*----------------------------------------------------------------------------
49 ; INCLUDES
50 ----------------------------------------------------------------------------*/
51 #include    "typedef.h"
52 #include    "mode.h"
53 #include "get_const_tbls.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 PHDGAINMEMSIZE 5
71 #define PHDTHR1LTP     9830  /* 0.6 in Q14 */
72 #define PHDTHR2LTP     14746 /* 0.9 in Q14 */
73 #define ONFACTPLUS1    16384 /* 2.0 in Q13   */
74 #define ONLENGTH 2
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 gainMem[PHDGAINMEMSIZE];
95         Word16 prevState;
96         Word16 prevCbGain;
97         Word16 lockFull;
98         Word16 onset;
99     } ph_dispState;
100
101     /*----------------------------------------------------------------------------
102     ; GLOBAL FUNCTION DEFINITIONS
103     ; Function Prototype declaration
104     ----------------------------------------------------------------------------*/
105
106     /*----------------------------------------------------------------------------
107     ;
108     ;  Function:   ph_disp_reset
109     ;  Purpose:    Initializes state memory
110     ;
111     ----------------------------------------------------------------------------*/
112     Word16 ph_disp_reset(ph_dispState *state);
113
114     /*----------------------------------------------------------------------------
115     ;
116     ;  Function:   ph_disp_exit
117     ;  Purpose:    The memory used for state memory is freed
118     ;
119     ----------------------------------------------------------------------------*/
120     void ph_disp_exit(ph_dispState **state);
121
122     /*----------------------------------------------------------------------------
123     ;
124     ;  Function:   ph_disp_lock
125     ;  Purpose:    mark phase dispersion as locked in state struct
126     ;
127     ----------------------------------------------------------------------------*/
128     void ph_disp_lock(ph_dispState *state);
129
130     /*----------------------------------------------------------------------------
131     ;
132     ;  Function:   ph_disp_release
133     ;  Purpose:    mark phase dispersion as unlocked in state struct
134     ;
135     ----------------------------------------------------------------------------*/
136
137     void ph_disp_release(ph_dispState *state);
138
139     /*----------------------------------------------------------------------------
140     ;
141     ;  Function:   ph_disp
142     ;  Purpose:    perform phase dispersion according to the specified codec
143     ;              mode and computes total excitation for synthesis part
144     ;              if decoder
145     ;
146     ----------------------------------------------------------------------------*/
147
148     void ph_disp(
149         ph_dispState *state,    /* i/o     : State struct                       */
150         enum Mode mode,         /* i       : codec mode                         */
151         Word16 x[],             /* i/o Q0  : in:  LTP excitation signal         */
152         /*           out: total excitation signal       */
153         Word16 cbGain,          /* i   Q1  : Codebook gain                      */
154         Word16 ltpGain,         /* i   Q14 : LTP gain                           */
155         Word16 inno[],          /* i/o Q13 : Innovation vector (Q12 for 12.2)   */
156         Word16 pitch_fac,       /* i   Q14 : pitch factor used to scale the
157                                          LTP excitation (Q13 for 12.2)      */
158         Word16 tmp_shift,       /* i   Q0  : shift factor applied to sum of
159                                          scaled LTP ex & innov. before
160                                          rounding                           */
161         CommonAmrTbls* common_amr_tbls, /* i : ptr to struct of table ptrs      */
162         Flag   *pOverflow       /* i/o     : oveflow indicator                  */
163     );
164
165     /*----------------------------------------------------------------------------
166     ; END
167     ----------------------------------------------------------------------------*/
168 #ifdef __cplusplus
169 }
170 #endif
171
172 #endif /* _PH_DISP_H_ */
173