lag_wind.cpp revision b841f14f8e51f2365945281fbfa54ef6a1b1b5a6
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/****************************************************************************************
19Portions 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)
26Permission to distribute, modify and use this file under the standard license
27terms listed above has been obtained from the copyright holder.
28****************************************************************************************/
29/*
30------------------------------------------------------------------------------
31
32
33
34 Pathname: ./audio/gsm-amr/c/src/lag_wind.c
35
36     Date: 01/31/2002
37
38------------------------------------------------------------------------------
39 REVISION HISTORY
40
41 Description:
42              1. Eliminated unused include files.
43              2. Replaced array addressing by pointers
44              3. Eliminated l_extract() function call
45
46 Description:  Added casting to eliminate warnings
47
48 Description:  Replaced "int" and/or "char" with OSCL defined types.
49
50 Description:
51
52------------------------------------------------------------------------------
53*/
54
55/*----------------------------------------------------------------------------
56; INCLUDES
57----------------------------------------------------------------------------*/
58#include "lag_wind.h"
59#include "lag_wind_tab.h"
60#include "basic_op.h"
61
62/*----------------------------------------------------------------------------
63; MACROS
64; Define module specific macros here
65----------------------------------------------------------------------------*/
66
67
68/*----------------------------------------------------------------------------
69; DEFINES
70; Include all pre-processor statements here. Include conditional
71; compile variables also.
72----------------------------------------------------------------------------*/
73
74
75/*----------------------------------------------------------------------------
76; LOCAL FUNCTION DEFINITIONS
77; Function Prototype declaration
78----------------------------------------------------------------------------*/
79
80
81/*----------------------------------------------------------------------------
82; LOCAL STORE/BUFFER/POINTER DEFINITIONS
83; Variable declaration - defined here and used outside this module
84----------------------------------------------------------------------------*/
85
86
87/*
88------------------------------------------------------------------------------
89 FUNCTION NAME: lag_wind
90------------------------------------------------------------------------------
91 INPUT AND OUTPUT DEFINITIONS
92
93 Inputs:
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
98
99 Outputs:
100    None
101
102 Returns:
103    None
104
105 Global Variables Used:
106    None.
107
108 Local Variables Needed:
109    None.
110
111------------------------------------------------------------------------------
112 FUNCTION DESCRIPTION
113
114      File             : lag_wind.c
115      Purpose          : Lag windowing of autocorrelations.
116
117    FUNCTION:  Lag_window()
118
119    PURPOSE:  Lag windowing of autocorrelations.
120
121    DESCRIPTION:
122          r[i] = r[i]*lag_wind[i],   i=1,...,10
123
124      r[i] and lag_wind[i] are in special double precision format.
125      See "oper_32b.c" for the format.
126
127------------------------------------------------------------------------------
128 REQUIREMENTS
129
130 None.
131
132------------------------------------------------------------------------------
133 REFERENCES
134
135 lag_wind.c, UMTS GSM AMR speech codec, R99 - Version 3.2.0, March 2, 2001
136
137------------------------------------------------------------------------------
138 PSEUDO-CODE
139
140    Word16 i;
141    Word32 x;
142
143    for (i = 1; i <= m; i++)
144    {
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);
147    }
148    return;
149
150------------------------------------------------------------------------------
151 RESOURCES USED [optional]
152
153 When the code is written for a specific target processor the
154 the resources used should be documented below.
155
156 HEAP MEMORY USED: x bytes
157
158 STACK MEMORY USED: x bytes
159
160 CLOCK CYCLES: (cycle count equation for this function) + (variable
161                used to represent cycle count for each subroutine
162                called)
163     where: (cycle count variable) = cycle count for [subroutine
164                                     name]
165
166------------------------------------------------------------------------------
167 CAUTION [optional]
168 [State any special notes, constraints or cautions for users of this function]
169
170------------------------------------------------------------------------------
171*/
172void Lag_window(
173    Word16 m,           /* (i)     : LPC order                        */
174    Word16 r_h[],       /* (i/o)   : Autocorrelations  (msb)          */
175    Word16 r_l[],       /* (i/o)   : Autocorrelations  (lsb)          */
176    Flag   *pOverflow
177)
178{
179    Word16 i;
180    Word32 x;
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];
185
186    for (i = m; i != 0 ; i--)
187    {
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);
191    }
192
193    return;
194}
195
196