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 ------------------------------------------------------------------------------
34 Pathname: ./audio/gsm-amr/c/src/lag_wind.c
38 ------------------------------------------------------------------------------
42 1. Eliminated unused include files.
43 2. Replaced array addressing by pointers
44 3. Eliminated l_extract() function call
46 Description: Added casting to eliminate warnings
48 Description: Replaced "int" and/or "char" with OSCL defined types.
52 ------------------------------------------------------------------------------
55 /*----------------------------------------------------------------------------
57 ----------------------------------------------------------------------------*/
59 #include "lag_wind_tab.h"
62 /*----------------------------------------------------------------------------
64 ; Define module specific macros here
65 ----------------------------------------------------------------------------*/
68 /*----------------------------------------------------------------------------
70 ; Include all pre-processor statements here. Include conditional
71 ; compile variables also.
72 ----------------------------------------------------------------------------*/
75 /*----------------------------------------------------------------------------
76 ; LOCAL FUNCTION DEFINITIONS
77 ; Function Prototype declaration
78 ----------------------------------------------------------------------------*/
81 /*----------------------------------------------------------------------------
82 ; LOCAL STORE/BUFFER/POINTER DEFINITIONS
83 ; Variable declaration - defined here and used outside this module
84 ----------------------------------------------------------------------------*/
88 ------------------------------------------------------------------------------
89 FUNCTION NAME: lag_wind
90 ------------------------------------------------------------------------------
91 INPUT AND OUTPUT DEFINITIONS
94 m = LPC order of type Word16
95 r_h[] = pointer to autocorrelations (msb) of type Word16
96 r_l[] = pointer to autocorrelations (lsb) of type Word16
97 pOverflow = pointer to overflow flag
105 Global Variables Used:
108 Local Variables Needed:
111 ------------------------------------------------------------------------------
115 Purpose : Lag windowing of autocorrelations.
117 FUNCTION: Lag_window()
119 PURPOSE: Lag windowing of autocorrelations.
122 r[i] = r[i]*lag_wind[i], i=1,...,10
124 r[i] and lag_wind[i] are in special double precision format.
125 See "oper_32b.c" for the format.
127 ------------------------------------------------------------------------------
132 ------------------------------------------------------------------------------
135 lag_wind.c, UMTS GSM AMR speech codec, R99 - Version 3.2.0, March 2, 2001
137 ------------------------------------------------------------------------------
143 for (i = 1; i <= m; i++)
145 x = Mpy_32 (r_h[i], r_l[i], lag_h[i - 1], lag_l[i - 1], pOverflow);
146 L_Extract (x, &r_h[i], &r_l[i], pOverflow);
150 ------------------------------------------------------------------------------
151 RESOURCES USED [optional]
153 When the code is written for a specific target processor the
154 the resources used should be documented below.
156 HEAP MEMORY USED: x bytes
158 STACK MEMORY USED: x bytes
160 CLOCK CYCLES: (cycle count equation for this function) + (variable
161 used to represent cycle count for each subroutine
163 where: (cycle count variable) = cycle count for [subroutine
166 ------------------------------------------------------------------------------
168 [State any special notes, constraints or cautions for users of this function]
170 ------------------------------------------------------------------------------
173 Word16 m, /* (i) : LPC order */
174 Word16 r_h[], /* (i/o) : Autocorrelations (msb) */
175 Word16 r_l[], /* (i/o) : Autocorrelations (lsb) */
181 const Word16 *p_lag_h = &lag_h[0];
182 const Word16 *p_lag_l = &lag_l[0];
183 Word16 *p_r_h = &r_h[1];
184 Word16 *p_r_l = &r_l[1];
186 for (i = m; i != 0 ; i--)
188 x = Mpy_32(*(p_r_h), *(p_r_l), *(p_lag_h++), *(p_lag_l++), pOverflow);
189 *(p_r_h) = (Word16)(x >> 16);
190 *(p_r_l++) = (x >> 1) - (*(p_r_h++) << 15);