1 /* ------------------------------------------------------------------
2 * Copyright (C) 1998-2009 PacketVideo
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
8 * http://www.apache.org/licenses/LICENSE-2.0
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
14 * See the License for the specific language governing permissions
15 * and limitations under the License.
16 * -------------------------------------------------------------------
18 /****************************************************************************************
19 Portions of this file are derived from the following 3GPP standard:
22 ANSI-C code for the Adaptive Multi-Rate (AMR) speech codec
23 Available from http://www.3gpp.org
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 ****************************************************************************************/
30 ------------------------------------------------------------------------------
37 ------------------------------------------------------------------------------
40 Purpose : Preemphasis filtering
41 Description : Filtering through 1 - g z^-1
43 ------------------------------------------------------------------------------
46 /*----------------------------------------------------------------------------
48 ----------------------------------------------------------------------------*/
53 /*----------------------------------------------------------------------------
55 ; Define module specific macros here
56 ----------------------------------------------------------------------------*/
58 /*----------------------------------------------------------------------------
60 ; Include all pre-processor statements here. Include conditional
61 ; compile variables also.
62 ----------------------------------------------------------------------------*/
64 /*----------------------------------------------------------------------------
65 ; LOCAL FUNCTION DEFINITIONS
66 ; Function Prototype declaration
67 ----------------------------------------------------------------------------*/
69 /*----------------------------------------------------------------------------
70 ; LOCAL VARIABLE DEFINITIONS
71 ; Variable declaration - defined here and used outside this module
72 ----------------------------------------------------------------------------*/
76 ------------------------------------------------------------------------------
77 FUNCTION NAME: preemphasis_reset
78 ------------------------------------------------------------------------------
79 INPUT AND OUTPUT DEFINITIONS
82 st -- double pointer to preemphasisState
85 st -- double ponter to preemphasisState
91 Global Variables Used:
94 Local Variables Needed:
97 ------------------------------------------------------------------------------
100 Initializes state memory to zero
101 ------------------------------------------------------------------------------
106 ------------------------------------------------------------------------------
109 preemph.c, UMTS GSM AMR speech codec, R99 - Version 3.2.0, March 2, 2001
111 ------------------------------------------------------------------------------
115 ------------------------------------------------------------------------------
117 [State any special notes, constraints or cautions for users of this function]
119 ------------------------------------------------------------------------------
122 Word16 preemphasis_reset(preemphasisState *state)
124 if (state == (preemphasisState *) NULL)
126 /* fprintf(stderr, "preemphasis_reset: invalid parameter\n"); */
136 ------------------------------------------------------------------------------
137 FUNCTION NAME: preemphasis
138 ------------------------------------------------------------------------------
139 INPUT AND OUTPUT DEFINITIONS
142 st -- Pointer to preemphasisState -- preemphasis filter state
143 signal -- array of type Word16 -- input signal overwritten by the output
144 g -- Word16 -- preemphasis coefficient
145 L -- Word16 -- size of filtering
148 st -- Pointer to preemphasisState -- preemphasis filter state
149 signal -- array of type Word16 -- input signal overwritten by the output
150 pOverflow -- pointer to type Flag -- overflow indicator
154 Global Variables Used:
157 Local Variables Needed:
160 ------------------------------------------------------------------------------
163 Filtering through 1 - g z^-1
164 ------------------------------------------------------------------------------
169 ------------------------------------------------------------------------------
172 preemph.c, UMTS GSM AMR speech codec, R99 - Version 3.2.0, March 2, 2001
174 ------------------------------------------------------------------------------
178 ------------------------------------------------------------------------------
180 [State any special notes, constraints or cautions for users of this function]
182 ------------------------------------------------------------------------------
187 preemphasisState *st, /* (i/o) : preemphasis filter state */
188 Word16 *signal, /* (i/o) : input signal overwritten by the output */
189 Word16 g, /* (i) : preemphasis coefficient */
190 Word16 L, /* (i) : size of filtering */
191 Flag *pOverflow /* (o) : overflow indicator */
204 for (i = 0; i <= L - 2; i++)
206 temp2 = mult(g, *(p2--), pOverflow);
207 *p1 = sub(*p1, temp2, pOverflow);
212 temp2 = mult(g, st->mem_pre, pOverflow);
214 *p1 = sub(*p1, temp2, pOverflow);