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/****************************************************************************************
19Portions 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)
26Permission to distribute, modify and use this file under the standard license
27terms listed above has been obtained from the copyright holder.
28****************************************************************************************/
29/*
30------------------------------------------------------------------------------
31
32
33
34 Filename: /audio/gsm_amr/c/include/ph_disp.h
35
36
37     Date: 08/11/2000
38
39------------------------------------------------------------------------------
40 REVISION HISTORY
41
42 Description: Updated template. Updated function prototype declaration for
43              ph_disp(). Included extern declaration for ph_imp_low_MR795 and
44              ph_imp_mid_MR795
45
46 Description:  Replaced "int" and/or "char" with OSCL defined types.
47
48 Description: Moved _cplusplus #ifdef after Include section.
49
50 Description:
51
52
53------------------------------------------------------------------------------
54 INCLUDE DESCRIPTION
55
56 This file contains all the constant definitions and prototype definitions
57 needed by the Phase dispersion of excitation signal ph_disp() function.
58
59------------------------------------------------------------------------------
60*/
61
62#ifndef PH_DISP_H
63#define PH_DISP_H "$Id $"
64
65/*----------------------------------------------------------------------------
66; INCLUDES
67----------------------------------------------------------------------------*/
68#include    "typedef.h"
69#include    "mode.h"
70
71/*--------------------------------------------------------------------------*/
72#ifdef __cplusplus
73extern "C"
74{
75#endif
76
77    /*----------------------------------------------------------------------------
78    ; MACROS
79    ; Define module specific macros here
80    ----------------------------------------------------------------------------*/
81
82    /*----------------------------------------------------------------------------
83    ; DEFINES
84    ; Include all pre-processor statements here.
85    ----------------------------------------------------------------------------*/
86#define PHDGAINMEMSIZE 5
87#define PHDTHR1LTP     9830  /* 0.6 in Q14 */
88#define PHDTHR2LTP     14746 /* 0.9 in Q14 */
89#define ONFACTPLUS1    16384 /* 2.0 in Q13   */
90#define ONLENGTH 2
91
92    /*----------------------------------------------------------------------------
93    ; EXTERNAL VARIABLES REFERENCES
94    ; Declare variables used in this module but defined elsewhere
95    ----------------------------------------------------------------------------*/
96    extern Word16 ph_imp_low_MR795[];
97    extern Word16 ph_imp_mid_MR795[];
98    extern Word16 ph_imp_low[];
99    extern Word16 ph_imp_mid[];
100
101    /*----------------------------------------------------------------------------
102    ; SIMPLE TYPEDEF'S
103    ----------------------------------------------------------------------------*/
104
105    /*----------------------------------------------------------------------------
106    ; ENUMERATED TYPEDEF'S
107    ----------------------------------------------------------------------------*/
108
109    /*----------------------------------------------------------------------------
110    ; STRUCTURES TYPEDEF'S
111    ----------------------------------------------------------------------------*/
112    typedef struct
113    {
114        Word16 gainMem[PHDGAINMEMSIZE];
115        Word16 prevState;
116        Word16 prevCbGain;
117        Word16 lockFull;
118        Word16 onset;
119    } ph_dispState;
120
121    /*----------------------------------------------------------------------------
122    ; GLOBAL FUNCTION DEFINITIONS
123    ; Function Prototype declaration
124    ----------------------------------------------------------------------------*/
125
126    /*----------------------------------------------------------------------------
127    ;
128    ;  Function:   ph_disp_reset
129    ;  Purpose:    Initializes state memory
130    ;
131    ----------------------------------------------------------------------------*/
132    Word16 ph_disp_reset(ph_dispState *state);
133
134    /*----------------------------------------------------------------------------
135    ;
136    ;  Function:   ph_disp_exit
137    ;  Purpose:    The memory used for state memory is freed
138    ;
139    ----------------------------------------------------------------------------*/
140    void ph_disp_exit(ph_dispState **state);
141
142    /*----------------------------------------------------------------------------
143    ;
144    ;  Function:   ph_disp_lock
145    ;  Purpose:    mark phase dispersion as locked in state struct
146    ;
147    ----------------------------------------------------------------------------*/
148    void ph_disp_lock(ph_dispState *state);
149
150    /*----------------------------------------------------------------------------
151    ;
152    ;  Function:   ph_disp_release
153    ;  Purpose:    mark phase dispersion as unlocked in state struct
154    ;
155    ----------------------------------------------------------------------------*/
156
157    void ph_disp_release(ph_dispState *state);
158
159    /*----------------------------------------------------------------------------
160    ;
161    ;  Function:   ph_disp
162    ;  Purpose:    perform phase dispersion according to the specified codec
163    ;              mode and computes total excitation for synthesis part
164    ;              if decoder
165    ;
166    ----------------------------------------------------------------------------*/
167
168    void ph_disp(
169        ph_dispState *state,    /* i/o     : State struct                       */
170        enum Mode mode,         /* i       : codec mode                         */
171        Word16 x[],             /* i/o Q0  : in:  LTP excitation signal         */
172        /*           out: total excitation signal       */
173        Word16 cbGain,          /* i   Q1  : Codebook gain                      */
174        Word16 ltpGain,         /* i   Q14 : LTP gain                           */
175        Word16 inno[],          /* i/o Q13 : Innovation vector (Q12 for 12.2)   */
176        Word16 pitch_fac,       /* i   Q14 : pitch factor used to scale the
177                                         LTP excitation (Q13 for 12.2)      */
178        Word16 tmp_shift,       /* i   Q0  : shift factor applied to sum of
179                                         scaled LTP ex & innov. before
180                                         rounding                           */
181        Flag   *pOverflow       /* i/o     : oveflow indicator                  */
182    );
183
184    /*----------------------------------------------------------------------------
185    ; END
186    ----------------------------------------------------------------------------*/
187#ifdef __cplusplus
188}
189#endif
190
191#endif /* _PH_DISP_H_ */
192
193