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 Filename: lag_wind.cpp
36 ------------------------------------------------------------------------------
39 /*----------------------------------------------------------------------------
41 ----------------------------------------------------------------------------*/
43 #include "lag_wind_tab.h"
46 /*----------------------------------------------------------------------------
48 ; Define module specific macros here
49 ----------------------------------------------------------------------------*/
52 /*----------------------------------------------------------------------------
54 ; Include all pre-processor statements here. Include conditional
55 ; compile variables also.
56 ----------------------------------------------------------------------------*/
59 /*----------------------------------------------------------------------------
60 ; LOCAL FUNCTION DEFINITIONS
61 ; Function Prototype declaration
62 ----------------------------------------------------------------------------*/
65 /*----------------------------------------------------------------------------
66 ; LOCAL STORE/BUFFER/POINTER DEFINITIONS
67 ; Variable declaration - defined here and used outside this module
68 ----------------------------------------------------------------------------*/
72 ------------------------------------------------------------------------------
73 FUNCTION NAME: lag_wind
74 ------------------------------------------------------------------------------
75 INPUT AND OUTPUT DEFINITIONS
78 m = LPC order of type Word16
79 r_h[] = pointer to autocorrelations (msb) of type Word16
80 r_l[] = pointer to autocorrelations (lsb) of type Word16
81 pOverflow = pointer to overflow flag
89 Global Variables Used:
92 Local Variables Needed:
95 ------------------------------------------------------------------------------
99 Purpose : Lag windowing of autocorrelations.
101 FUNCTION: Lag_window()
103 PURPOSE: Lag windowing of autocorrelations.
106 r[i] = r[i]*lag_wind[i], i=1,...,10
108 r[i] and lag_wind[i] are in special double precision format.
109 See "oper_32b.c" for the format.
111 ------------------------------------------------------------------------------
116 ------------------------------------------------------------------------------
119 lag_wind.c, UMTS GSM AMR speech codec, R99 - Version 3.2.0, March 2, 2001
121 ------------------------------------------------------------------------------
127 for (i = 1; i <= m; i++)
129 x = Mpy_32 (r_h[i], r_l[i], lag_h[i - 1], lag_l[i - 1], pOverflow);
130 L_Extract (x, &r_h[i], &r_l[i], pOverflow);
134 ------------------------------------------------------------------------------
136 [State any special notes, constraints or cautions for users of this function]
138 ------------------------------------------------------------------------------
141 Word16 m, /* (i) : LPC order */
142 Word16 r_h[], /* (i/o) : Autocorrelations (msb) */
143 Word16 r_l[], /* (i/o) : Autocorrelations (lsb) */
149 const Word16 *p_lag_h = &lag_h[0];
150 const Word16 *p_lag_l = &lag_l[0];
151 Word16 *p_r_h = &r_h[1];
152 Word16 *p_r_l = &r_l[1];
154 for (i = m; i != 0 ; i--)
156 x = Mpy_32(*(p_r_h), *(p_r_l), *(p_lag_h++), *(p_lag_l++), pOverflow);
157 *(p_r_h) = (Word16)(x >> 16);
158 *(p_r_l++) = (x >> 1) - (*(p_r_h++) << 15);