Git init
[external/opencore-amr.git] / opencore / codecs_v2 / audio / gsm_amr / amr_nb / dec / src / d_plsf.cpp
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: d_plsf.cpp
35
36 ------------------------------------------------------------------------------
37  MODULE DESCRIPTION
38
39  common part (reset) of LSF decoder
40  module (rest in d_plsf_3.c and d_plsf_5.c)
41 ------------------------------------------------------------------------------
42 */
43
44 /*----------------------------------------------------------------------------
45 ; INCLUDES
46 ----------------------------------------------------------------------------*/
47 #include "typedef.h"
48 #include "basic_op.h"
49 #include "cnst.h"
50 #include "oscl_mem.h"
51 #include "d_plsf.h"
52 #include "q_plsf_5_tbl.h"
53
54
55 /*----------------------------------------------------------------------------
56 ; MACROS
57 ; Define module specific macros here
58 ----------------------------------------------------------------------------*/
59
60 /*----------------------------------------------------------------------------
61 ; DEFINES
62 ; Include all pre-processor statements here. Include conditional
63 ; compile variables also.
64 ----------------------------------------------------------------------------*/
65
66 /*----------------------------------------------------------------------------
67 ; LOCAL FUNCTION DEFINITIONS
68 ; Function Prototype declaration
69 ----------------------------------------------------------------------------*/
70
71 /*----------------------------------------------------------------------------
72 ; LOCAL VARIABLE DEFINITIONS
73 ; Variable declaration - defined here and used outside this module
74 ----------------------------------------------------------------------------*/
75
76 /*----------------------------------------------------------------------------
77 ; EXTERNAL FUNCTION REFERENCES
78 ; Declare functions defined elsewhere and referenced in this module
79 ----------------------------------------------------------------------------*/
80
81 /*----------------------------------------------------------------------------
82 ; EXTERNAL VARIABLES REFERENCES
83 ; Declare variables used in this module but defined elsewhere
84 ----------------------------------------------------------------------------*/
85
86 /*
87 ------------------------------------------------------------------------------
88  FUNCTION NAME: D_plsf_reset
89 ------------------------------------------------------------------------------
90  INPUT AND OUTPUT DEFINITIONS
91
92  Inputs:
93     state = pointer to structure of type D_plsf_reset
94
95  Outputs:
96     fields of the structure pointed to by state is initialized to zero
97
98  Returns:
99     return_value = 0, if reset was successful; -1, otherwise (int)
100
101  Global Variables Used:
102     None
103
104  Local Variables Needed:
105     None
106
107 ------------------------------------------------------------------------------
108  FUNCTION DESCRIPTION
109
110  Resets state memory
111
112 ------------------------------------------------------------------------------
113  REQUIREMENTS
114
115  None
116
117 ------------------------------------------------------------------------------
118  REFERENCES
119
120  d_plsf.c, UMTS GSM AMR speech codec, R99 - Version 3.2.0, March 2, 2001
121
122 ------------------------------------------------------------------------------
123  PSEUDO-CODE
124
125 int D_plsf_reset (D_plsfState *state)
126 {
127   Word16 i;
128
129   if (state == (D_plsfState *) NULL){
130       // fprintf(stderr, "D_plsf_reset: invalid parameter\n");
131       return -1;
132   }
133
134   for (i = 0; i < M; i++){
135       state->past_r_q[i] = 0;             // Past quantized prediction error
136   }
137
138   // Past dequantized lsfs
139   Copy(mean_lsf, &state->past_lsf_q[0], M);
140
141   return 0;
142 }
143 ------------------------------------------------------------------------------
144  CAUTION [optional]
145  [State any special notes, constraints or cautions for users of this function]
146
147 ------------------------------------------------------------------------------
148 */
149
150 Word16 D_plsf_reset(D_plsfState *state, const Word16* mean_lsf_5_ptr)
151 {
152     Word16 i;
153
154     if (state == (D_plsfState *) NULL)
155     {
156         /* fprintf(stderr, "D_plsf_reset: invalid parameter\n"); */
157         return -1;
158     }
159
160     for (i = 0; i < M; i++)
161     {
162         state->past_r_q[i] = 0;             /* Past quantized prediction error */
163     }
164
165     /* Past dequantized lsfs */
166     oscl_memmove((void *)&state->past_lsf_q[0], mean_lsf_5_ptr, M*sizeof(*mean_lsf_5_ptr));
167
168     return 0;
169
170 }