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 ****************************************************************************************/
33 ------------------------------------------------------------------------------
37 ------------------------------------------------------------------------------
40 /*----------------------------------------------------------------------------
42 ----------------------------------------------------------------------------*/
49 /*----------------------------------------------------------------------------
51 ; Define module specific macros here
52 ----------------------------------------------------------------------------*/
54 /*----------------------------------------------------------------------------
56 ; Include all pre-processor statements here. Include conditional
57 ; compile variables also.
58 ----------------------------------------------------------------------------*/
60 /*----------------------------------------------------------------------------
61 ; LOCAL FUNCTION DEFINITIONS
62 ; Function Prototype declaration
63 ----------------------------------------------------------------------------*/
65 /*----------------------------------------------------------------------------
66 ; LOCAL VARIABLE DEFINITIONS
67 ; Variable declaration - defined here and used outside this module
68 ----------------------------------------------------------------------------*/
72 ------------------------------------------------------------------------------
73 FUNCTION NAME: Int_lpc_1and3
74 ------------------------------------------------------------------------------
75 INPUT AND OUTPUT DEFINITIONS
78 lsp_old -- array of type Word16 -- LSP vector at the
79 4th subfr. of past frame (M)
80 lsp_mid -- array of type Word16 -- LSP vector at the 2nd subfr. of
82 lsp_new -- array of type Word16 -- LSP vector at the 4th subfr. of
86 Az -- array of type Word16 -- interpolated LP parameters in all subfr.
88 pOverflow -- pointer to type Flag -- Overflow indicator
93 Global Variables Used:
96 Local Variables Needed:
99 ------------------------------------------------------------------------------
102 Purpose : Interpolates the LSPs and converts to LPC parameters
103 to get a different LP filter in each subframe.
104 Description : The 20 ms speech frame is divided into 4 subframes.
105 The LSPs are quantized and transmitted at the 2nd and
106 4th subframes (twice per frame) and interpolated at the
107 1st and 3rd subframe.
109 |------|------|------|------|
113 sf1: 1/2 Fm + 1/2 F0 sf3: 1/2 F1 + 1/2 Fm
116 ------------------------------------------------------------------------------
121 ------------------------------------------------------------------------------
124 int_lpc.c, UMTS GSM AMR speech codec, R99 - Version 3.2.0, March 2, 2001
126 ------------------------------------------------------------------------------
130 ------------------------------------------------------------------------------
132 [State any special notes, constraints or cautions for users of this function]
134 ------------------------------------------------------------------------------
137 OSCL_EXPORT_REF void Int_lpc_1and3(
138 Word16 lsp_old[], /* i : LSP vector at the 4th subfr. of past frame (M) */
139 Word16 lsp_mid[], /* i : LSP vector at the 2nd subfr. of
141 Word16 lsp_new[], /* i : LSP vector at the 4th subfr. of
143 Word16 Az[], /* o : interpolated LP parameters in all subfr.
150 Word16 *p_lsp_old = &lsp_old[0];
151 Word16 *p_lsp_mid = &lsp_mid[0];
152 Word16 *p_lsp_new = &lsp_new[0];
153 Word16 *p_lsp = &lsp[0];
155 /* lsp[i] = lsp_mid[i] * 0.5 + lsp_old[i] * 0.5 */
157 for (i = M >> 1; i != 0; i--)
159 *(p_lsp++) = (*(p_lsp_old++) >> 1) + (*(p_lsp_mid++) >> 1);
160 *(p_lsp++) = (*(p_lsp_old++) >> 1) + (*(p_lsp_mid++) >> 1);
166 pOverflow); /* Subframe 1 */
173 pOverflow); /* Subframe 2 */
177 p_lsp_mid = &lsp_mid[0];
180 for (i = M >> 1; i != 0; i--)
182 *(p_lsp++) = (*(p_lsp_mid++) >> 1) + (*(p_lsp_new++) >> 1);
183 *(p_lsp++) = (*(p_lsp_mid++) >> 1) + (*(p_lsp_new++) >> 1);
189 pOverflow); /* Subframe 3 */
196 pOverflow); /* Subframe 4 */
203 ------------------------------------------------------------------------------
204 FUNCTION NAME: Int_lpc_1and3_2
205 ------------------------------------------------------------------------------
206 INPUT AND OUTPUT DEFINITIONS
209 lsp_old -- array of type Word16 -- LSP vector at the
210 4th subfr. of past frame (M)
211 lsp_mid -- array of type Word16 -- LSP vector at the 2nd subfr. of
213 lsp_new -- array of type Word16 -- LSP vector at the 4th subfr. of
217 Az -- array of type Word16 -- interpolated LP parameters in.
219 pOverflow -- pointer to type Flag -- Overflow indicator
224 Global Variables Used:
227 Local Variables Needed:
230 ------------------------------------------------------------------------------
233 Purpose : Interpolation of the LPC parameters. Same as the Int_lpc
234 function but we do not recompute Az() for subframe 2 and
235 4 because it is already available.
237 ------------------------------------------------------------------------------
242 ------------------------------------------------------------------------------
245 int_lpc.c, UMTS GSM AMR speech codec, R99 - Version 3.2.0, March 2, 2001
247 ------------------------------------------------------------------------------
251 ------------------------------------------------------------------------------
253 [State any special notes, constraints or cautions for users of this function]
255 ------------------------------------------------------------------------------
258 void Int_lpc_1and3_2(
259 Word16 lsp_old[], /* i : LSP vector at the 4th subfr. of past frame (M) */
260 Word16 lsp_mid[], /* i : LSP vector at the 2nd subframe of
262 Word16 lsp_new[], /* i : LSP vector at the 4th subframe of
264 Word16 Az[], /* o :interpolated LP parameters
265 in subframes 1 and 3 (AZ_SIZE) */
271 Word16 *p_lsp_old = &lsp_old[0];
272 Word16 *p_lsp_mid = &lsp_mid[0];
273 Word16 *p_lsp_new = &lsp_new[0];
274 Word16 *p_lsp = &lsp[0];
276 /* lsp[i] = lsp_mid[i] * 0.5 + lsp_old[i] * 0.5 */
278 for (i = M >> 1; i != 0; i--)
280 *(p_lsp++) = (*(p_lsp_old++) >> 1) + (*(p_lsp_mid++) >> 1);
281 *(p_lsp++) = (*(p_lsp_old++) >> 1) + (*(p_lsp_mid++) >> 1);
283 Lsp_Az(lsp, Az, pOverflow); /* Subframe 1 */
286 p_lsp_mid = &lsp_mid[0];
289 for (i = M >> 1; i != 0; i--)
291 *(p_lsp++) = (*(p_lsp_mid++) >> 1) + (*(p_lsp_new++) >> 1);
292 *(p_lsp++) = (*(p_lsp_mid++) >> 1) + (*(p_lsp_new++) >> 1);
295 Lsp_Az(lsp, Az, pOverflow); /* Subframe 3 */
302 ------------------------------------------------------------------------------
304 ------------------------------------------------------------------------------
305 INPUT AND OUTPUT DEFINITIONS
308 lsp_old -- array of type Word16 -- LSP vector at the
309 4th subfr. of past frame (M)
310 lsp_new -- array of type Word16 -- LSP vector at the 4th subfr. of
314 Az -- array of type Word16 -- interpolated LP parameters in.
316 pOverflow -- pointer to type Flag -- Overflow indicator
321 Global Variables Used:
324 Local Variables Needed:
327 ------------------------------------------------------------------------------
330 PURPOSE: Interpolates the LSPs and convert to LP parameters to get
331 a different LP filter in each subframe.
334 The 20 ms speech frame is divided into 4 subframes.
335 The LSPs are quantized and transmitted at the 4th subframe
336 (once per frame) and interpolated at the 1st, 2nd and 3rd subframe.
338 |------|------|------|------|
342 sf1: 3/4 F0 + 1/4 F1 sf3: 1/4 F0 + 3/4 F1
343 sf2: 1/2 F0 + 1/2 F1 sf4: F1
345 ------------------------------------------------------------------------------
350 ------------------------------------------------------------------------------
353 int_lpc.c, UMTS GSM AMR speech codec, R99 - Version 3.2.0, March 2, 2001
355 ------------------------------------------------------------------------------
359 ------------------------------------------------------------------------------
361 [State any special notes, constraints or cautions for users of this function]
363 ------------------------------------------------------------------------------
366 OSCL_EXPORT_REF void Int_lpc_1to3(
367 Word16 lsp_old[], /* input : LSP vector at the 4th SF of past frame */
368 Word16 lsp_new[], /* input : LSP vector at the 4th SF of present frame */
369 Word16 Az[], /* output: interpolated LP parameters in all SFs */
378 for (i = 0; i < M; i++)
380 temp = lsp_old[i] - (lsp_old[i] >> 2);
381 lsp[i] = temp + (lsp_new[i] >> 2);
387 pOverflow); /* Subframe 1 */
392 for (i = 0; i < M; i++)
394 lsp[i] = (lsp_new[i] >> 1) + (lsp_old[i] >> 1);
398 Lsp_Az(lsp, Az, pOverflow); /* Subframe 2 */
402 for (i = 0; i < M; i++)
405 temp = lsp_new[i] - (lsp_new[i] >> 2);
406 lsp[i] = temp + (lsp_old[i] >> 2);
410 Lsp_Az(lsp, Az, pOverflow); /* Subframe 3 */
414 Lsp_Az(lsp_new, Az, pOverflow); /* Subframe 4 */
419 ------------------------------------------------------------------------------
420 FUNCTION NAME: Int_lpc_1to3_2
421 ------------------------------------------------------------------------------
422 INPUT AND OUTPUT DEFINITIONS
425 lsp_old -- array of type Word16 -- LSP vector at the
426 4th subfr. of past frame (M)
427 lsp_new -- array of type Word16 -- LSP vector at the 4th subfr. of
431 Az -- array of type Word16 -- interpolated LP parameters in.
433 pOverflow -- pointer to type Flag -- Overflow indicator
438 Global Variables Used:
441 Local Variables Needed:
444 ------------------------------------------------------------------------------
447 Interpolation of the LPC parameters.
448 Same as the previous function but we do not recompute Az() for
449 subframe 4 because it is already available.
451 ------------------------------------------------------------------------------
456 ------------------------------------------------------------------------------
459 int_lpc.c, UMTS GSM AMR speech codec, R99 - Version 3.2.0, March 2, 2001
461 ------------------------------------------------------------------------------
465 ------------------------------------------------------------------------------
467 [State any special notes, constraints or cautions for users of this function]
469 ------------------------------------------------------------------------------
473 Word16 lsp_old[], /* input : LSP vector at the 4th SF of past frame */
474 Word16 lsp_new[], /* input : LSP vector at the 4th SF of present frame */
475 Word16 Az[], /* output: interpolated LP parameters in SFs 1,2,3 */
483 for (i = 0; i < M; i++)
485 temp = lsp_old[i] - (lsp_old[i] >> 2);
486 lsp[i] = temp + (lsp_new[i] >> 2);
490 Lsp_Az(lsp, Az, pOverflow); /* Subframe 1 */
494 for (i = 0; i < M; i++)
496 lsp[i] = (lsp_new[i] >> 1) + (lsp_old[i] >> 1);
500 Lsp_Az(lsp, Az, pOverflow); /* Subframe 2 */
504 for (i = 0; i < M; i++)
506 temp = lsp_new[i] - (lsp_new[i] >> 2);
507 lsp[i] = temp + (lsp_old[i] >> 2);
511 Lsp_Az(lsp, Az, pOverflow); /* Subframe 3 */