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: spreproc.cpp
35 Functions: subframePreProc
37 ------------------------------------------------------------------------------
41 ------------------------------------------------------------------------------
44 /*----------------------------------------------------------------------------
46 ----------------------------------------------------------------------------*/
54 /*----------------------------------------------------------------------------
56 ; Define module specific macros here
57 ----------------------------------------------------------------------------*/
59 /*----------------------------------------------------------------------------
61 ; Include all pre-processor statements here. Include conditional
62 ; compile variables also.
63 ----------------------------------------------------------------------------*/
65 /*----------------------------------------------------------------------------
66 ; LOCAL FUNCTION DEFINITIONS
67 ; Function Prototype declaration
68 ----------------------------------------------------------------------------*/
70 /*----------------------------------------------------------------------------
71 ; LOCAL VARIABLE DEFINITIONS
72 ; Variable declaration - defined here and used outside this module
73 ----------------------------------------------------------------------------*/
76 ------------------------------------------------------------------------------
77 FUNCTION NAME: subframePreProc
78 ------------------------------------------------------------------------------
79 INPUT AND OUTPUT DEFINITIONS
82 mode -- enum Mode -- coder mode
83 gamma1 -- const Word16 array -- spectral exp. factor 1
84 gamma1_12k2 -- const Word16 array -- spectral exp. factor 1 for EFR
85 gamma2 -- const Word16 array -- spectral exp. factor 2
86 A -- Pointer to Word16 -- A(z) unquantized for the 4 subframes
87 Aq -- Pointer to Word16 -- A(z) quantized for the 4 subframes
88 speech -- Pointer to Word16 -- speech segment
89 mem_err -- Pointer to Word16 -- pointer to error signal
90 mem_w0 -- Pointer to Word16 -- memory of weighting filter
91 zero -- Pointer to Word16 -- pointer to zero vector
94 ai_zero -- Word16 array -- history of weighted synth. filter
95 exc -- Word16 array -- long term prediction residual
96 h1 -- Word16 array -- impulse response
97 xn -- Word16 array -- target vector for pitch search
98 res2 -- Word16 array -- long term prediction residual
99 error -- Word16 array -- error of LPC synthesis filter
104 Global Variables Used:
107 Local Variables Needed:
110 ------------------------------------------------------------------------------
114 ------------------------------------------------------------------------------
119 ------------------------------------------------------------------------------
122 spreproc.c, UMTS GSM AMR speech codec, R99 - Version 3.2.0, March 2, 2001
124 ------------------------------------------------------------------------------
128 ------------------------------------------------------------------------------
130 [State any special notes, constraints or cautions for users of this function]
132 ------------------------------------------------------------------------------
135 void subframePreProc(
136 enum Mode mode, /* i : coder mode */
137 const Word16 gamma1[], /* i : spectral exp. factor 1 */
138 const Word16 gamma1_12k2[],/* i : spectral exp. factor 1 for EFR */
139 const Word16 gamma2[], /* i : spectral exp. factor 2 */
140 Word16 *A, /* i : A(z) unquantized for the 4 subframes */
141 Word16 *Aq, /* i : A(z) quantized for the 4 subframes */
142 Word16 *speech, /* i : speech segment */
143 Word16 *mem_err, /* i : pointer to error signal */
144 Word16 *mem_w0, /* i : memory of weighting filter */
145 Word16 *zero, /* i : pointer to zero vector */
146 Word16 ai_zero[], /* o : history of weighted synth. filter */
147 Word16 exc[], /* o : long term prediction residual */
148 Word16 h1[], /* o : impulse response */
149 Word16 xn[], /* o : target vector for pitch search */
150 Word16 res2[], /* o : long term prediction residual */
151 Word16 error[] /* o : error of LPC synthesis filter */
154 Word16 Ap1[MP1]; /* A(z) with spectral expansion */
155 Word16 Ap2[MP1]; /* A(z) with spectral expansion */
156 const Word16 *g1; /* Pointer to correct gammma1 vector */
158 /* mode specific pointer to gamma1 values */
159 if (mode == MR122 || mode == MR102)
168 /* Find the weighted LPC coefficients for the weighting filter. */
169 Weight_Ai(A, g1, Ap1);
170 Weight_Ai(A, gamma2, Ap2);
172 oscl_memcpy(ai_zero, Ap1, (M + 1)*sizeof(Word16));
175 Syn_filt(Aq, ai_zero, h1, L_SUBFR, zero, 0);
176 Syn_filt(Ap2, h1, h1, L_SUBFR, zero, 0);
180 * Find the target vector for pitch search:
185 Residu(Aq, speech, res2, L_SUBFR);
187 oscl_memcpy(exc, res2, L_SUBFR*sizeof(Word16));
189 Syn_filt(Aq, exc, error, L_SUBFR, mem_err, 0);
191 Residu(Ap1, error, xn, L_SUBFR);
193 /* target signal xn[]*/
194 Syn_filt(Ap2, xn, xn, L_SUBFR, mem_w0, 0);