Git init
[external/opencore-amr.git] / opencore / codecs_v2 / audio / gsm_amr / amr_nb / common / include / d_plsf.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  Filename: d_plsf.h
32
33 ------------------------------------------------------------------------------
34  INCLUDE DESCRIPTION
35
36  This file contains all the constant definitions and prototype definitions
37  needed by the d_plsf_3.c and d_plsf_5.c
38
39 ------------------------------------------------------------------------------
40 */
41
42 /*----------------------------------------------------------------------------
43 ; CONTINUE ONLY IF NOT ALREADY DEFINED
44 ----------------------------------------------------------------------------*/
45 #ifndef d_plsf_h
46 #define d_plsf_h "$Id $"
47
48 /*----------------------------------------------------------------------------
49 ; INCLUDES
50 ----------------------------------------------------------------------------*/
51 #include "typedef.h"
52 #include "cnst.h"
53 #include "mode.h"
54 #include "get_const_tbls.h"
55
56 /*--------------------------------------------------------------------------*/
57 #ifdef __cplusplus
58 extern "C"
59 {
60 #endif
61
62     /*----------------------------------------------------------------------------
63     ; MACROS
64     ; Define module specific macros here
65     ----------------------------------------------------------------------------*/
66
67     /*----------------------------------------------------------------------------
68     ; DEFINES
69     ; Include all pre-processor statements here.
70     ----------------------------------------------------------------------------*/
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         Word16 past_r_q[M];   /* Past quantized prediction error, Q15 */
91         Word16 past_lsf_q[M]; /* Past dequantized lsfs,           Q15 */
92     } D_plsfState;
93
94     /*----------------------------------------------------------------------------
95     ; GLOBAL FUNCTION DEFINITIONS
96     ; Function Prototype declaration
97     ----------------------------------------------------------------------------*/
98
99     /*
100     **************************************************************************
101     *
102     *  Function    : D_plsf_reset
103     *  Purpose     : Resets state memory
104     *  Returns     : 0 on success
105     *
106     **************************************************************************
107     */
108     Word16 D_plsf_reset(D_plsfState *st, const Word16* mean_lsf_5_ptr);
109
110     /*
111     **************************************************************************
112     *
113     *  Function    : D_plsf_exit
114     *  Purpose     : The memory used for state memory is freed
115     *  Description : Stores NULL in *st
116     *  Returns     : void
117     *
118     **************************************************************************
119     */
120     void D_plsf_exit(D_plsfState **st);
121
122     /*
123     **************************************************************************
124     *
125     *  Function    : D_plsf_5
126     *  Purpose     : Decodes the 2 sets of LSP parameters in a frame
127     *                using the received quantization indices.
128     *  Description : The two sets of LSFs are quantized using split by
129     *                5 matrix quantization (split-MQ) with 1st order MA
130     *                prediction.
131     *                See "q_plsf_5.c" for more details about the
132     *                quantization procedure
133     *  Returns     : 0
134     *
135     **************************************************************************
136     */
137     void D_plsf_5(
138         D_plsfState *st,  /* i/o: State variables                            */
139         Word16 bfi,       /* i  : bad frame indicator (set to 1 if a bad
140                               frame is received)                         */
141         Word16 *indice,   /* i  : quantization indices of 5 submatrices, Q0  */
142         CommonAmrTbls* common_amr_tbls, /* i : structure containing ptrs to read-only tables */
143         Word16 *lsp1_q,   /* o  : quantized 1st LSP vector (M)           Q15 */
144         Word16 *lsp2_q,   /* o  : quantized 2nd LSP vector (M)           Q15 */
145         Flag  *pOverflow  /* o : Flag set when overflow occurs               */
146     );
147
148     /*************************************************************************
149      *
150      *  FUNCTION:   D_plsf_3()
151      *
152      *  PURPOSE: Decodes the LSP parameters using the received quantization
153      *           indices.1st order MA prediction and split by 3 matrix
154      *           quantization (split-MQ)
155      *
156      *************************************************************************/
157
158     void D_plsf_3(
159         D_plsfState *st,  /* i/o: State struct                               */
160         enum Mode mode,   /* i  : coder mode                                 */
161         Word16 bfi,       /* i  : bad frame indicator (set to 1 if a         */
162         /*      bad frame is received)                     */
163         Word16 * indice,  /* i  : quantization indices of 3 submatrices, Q0  */
164         CommonAmrTbls* common_amr_tbls, /* i : structure containing ptrs to read-only tables */
165         Word16 * lsp1_q,  /* o  : quantized 1st LSP vector,              Q15 */
166         Flag  *pOverflow  /* o : Flag set when overflow occurs               */
167     );
168
169     /*************************************************************************
170      *
171      *  FUNCTION:   Init_D_plsf_3()
172      *
173      *  PURPOSE: Set the past_r_q[M] vector to one of the eight
174      *           past_rq_init vectors.
175      *
176      *************************************************************************/
177     void Init_D_plsf_3(D_plsfState *st,  /* i/o: State struct                */
178                        Word16 index,     /* i  : past_rq_init[] index [0, 7] */
179                        const Word16* past_rq_init_ptr /* ptr to read-only table */
180                       );
181
182     /*----------------------------------------------------------------------------
183     ; END
184     ----------------------------------------------------------------------------*/
185 #ifdef __cplusplus
186 }
187 #endif
188
189 #endif /* _Q_PLSF_H_ */
190