• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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  Pathname: ./audio/gsm-amr/c/src/pre_big.c
35  Functions:
36 
37      Date: 02/04/2002
38 
39 ------------------------------------------------------------------------------
40  REVISION HISTORY
41 
42  Description: Updated template used to PV coding template.
43  Changed to accept the pOverflow flag for EPOC compatibility.
44 
45  Description:  Replaced "int" and/or "char" with OSCL defined types.
46 
47  Description:
48 
49 ------------------------------------------------------------------------------
50  MODULE DESCRIPTION
51 
52     Big subframe (2 subframes) preprocessing
53 ------------------------------------------------------------------------------
54 */
55 
56 /*----------------------------------------------------------------------------
57 ; INCLUDES
58 ----------------------------------------------------------------------------*/
59 #include "pre_big.h"
60 #include "typedef.h"
61 #include "basic_op.h"
62 #include "syn_filt.h"
63 #include "weight_a.h"
64 #include "residu.h"
65 #include "cnst.h"
66 
67 /*----------------------------------------------------------------------------
68 ; MACROS
69 ; Define module specific macros here
70 ----------------------------------------------------------------------------*/
71 
72 /*----------------------------------------------------------------------------
73 ; DEFINES
74 ; Include all pre-processor statements here. Include conditional
75 ; compile variables also.
76 ----------------------------------------------------------------------------*/
77 
78 /*----------------------------------------------------------------------------
79 ; LOCAL FUNCTION DEFINITIONS
80 ; Function Prototype declaration
81 ----------------------------------------------------------------------------*/
82 
83 /*----------------------------------------------------------------------------
84 ; LOCAL VARIABLE DEFINITIONS
85 ; Variable declaration - defined here and used outside this module
86 ----------------------------------------------------------------------------*/
87 
88 /*
89 ------------------------------------------------------------------------------
90  FUNCTION NAME: pre_big
91 ------------------------------------------------------------------------------
92  INPUT AND OUTPUT DEFINITIONS
93 
94  Inputs:
95     mode = enum Mode -- coder mode
96     gamma1 = array of type const Word16 -- spectral exp. factor 1
97     gamma1_12k2 = array of type const Word16 -- spectral exp. factor 1 for EFR
98     gamma2 = array of type const Word16 -- spectral exp. factor 2
99     A_t = array of type Word16 -- A(z) unquantized, for 4 subframes, Q12
100     frameOffset = Word16 -- Start position in speech vector,   Q0
101     speech[] = array of type Word16 -- speech,                            Q0
102 
103  Outputs:
104     mem_w = array of type Word16 -- synthesis filter memory state,     Q0
105     wsp   = array of type Word16 -- weighted speech                    Q0
106     pOverflow = pointer of type Flag -- overflow indicator
107 
108  Returns:
109     None
110 
111  Global Variables Used:
112     None
113 
114  Local Variables Needed:
115     None
116 
117 ------------------------------------------------------------------------------
118  FUNCTION DESCRIPTION
119 
120 
121 ------------------------------------------------------------------------------
122  REQUIREMENTS
123 
124  None
125 
126 ------------------------------------------------------------------------------
127  REFERENCES
128 
129  pre_big.c, UMTS GSM AMR speech codec, R99 - Version 3.2.0, March 2, 2001
130 
131 ------------------------------------------------------------------------------
132  PSEUDO-CODE
133 
134 
135 ------------------------------------------------------------------------------
136  RESOURCES USED [optional]
137 
138  When the code is written for a specific target processor the
139  the resources used should be documented below.
140 
141  HEAP MEMORY USED: x bytes
142 
143  STACK MEMORY USED: x bytes
144 
145  CLOCK CYCLES: (cycle count equation for this function) + (variable
146                 used to represent cycle count for each subroutine
147                 called)
148      where: (cycle count variable) = cycle count for [subroutine
149                                      name]
150 
151 ------------------------------------------------------------------------------
152  CAUTION [optional]
153  [State any special notes, constraints or cautions for users of this function]
154 
155 ------------------------------------------------------------------------------
156 */
157 
pre_big(enum Mode mode,const Word16 gamma1[],const Word16 gamma1_12k2[],const Word16 gamma2[],Word16 A_t[],Word16 frameOffset,Word16 speech[],Word16 mem_w[],Word16 wsp[],Flag * pOverflow)158 void pre_big(
159     enum Mode mode,            /* i  : coder mode                             */
160     const Word16 gamma1[],     /* i  : spectral exp. factor 1                 */
161     const Word16 gamma1_12k2[],/* i  : spectral exp. factor 1 for EFR         */
162     const Word16 gamma2[],     /* i  : spectral exp. factor 2                 */
163     Word16 A_t[],              /* i  : A(z) unquantized, for 4 subframes, Q12 */
164     Word16 frameOffset,        /* i  : Start position in speech vector,   Q0  */
165     Word16 speech[],           /* i  : speech,                            Q0  */
166     Word16 mem_w[],            /* i/o: synthesis filter memory state,     Q0  */
167     Word16 wsp[],              /* o  : weighted speech                    Q0  */
168     Flag   *pOverflow          /* o  : overflow indicator                     */
169 )
170 {
171     Word16 Ap1[MP1];            /* A(z) with spectral expansion         */
172     Word16 Ap2[MP1];            /* A(z) with spectral expansion         */
173     const Word16 *g1;           /* Pointer to correct gammma1 vector    */
174     Word16 aOffset;
175     Word16 i;
176 
177     if (mode <= MR795)
178     {
179         g1 = gamma1;
180     }
181     else
182     {
183         g1 = gamma1_12k2;
184     }
185 
186     if (frameOffset > 0)
187     {
188         aOffset = 2 * MP1;
189     }
190     else
191     {
192         aOffset = 0;
193     }
194 
195     /* process two subframes (which form the "big" subframe) */
196     for (i = 0; i < 2; i++)
197     {
198         Weight_Ai(&A_t[aOffset], g1, Ap1);
199         Weight_Ai(&A_t[aOffset], gamma2, Ap2);
200         Residu(Ap1, &speech[frameOffset], &wsp[frameOffset], L_SUBFR);
201 
202         Syn_filt(Ap2, &wsp[frameOffset], &wsp[frameOffset], L_SUBFR, mem_w, 1);
203 
204         aOffset = add(aOffset, MP1, pOverflow);
205 
206         frameOffset = add(frameOffset, L_SUBFR, pOverflow);
207     }
208 
209     return;
210 }
211