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.173
22    ANSI-C code for the Adaptive Multi-Rate - Wideband (AMR-WB) speech codec
23    Available from http://www.3gpp.org
24
25(C) 2007, 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 Filename: weight_amrwb_lpc.cpp
35
36     Date: 05/08/2007
37
38------------------------------------------------------------------------------
39 REVISION HISTORY
40
41
42 Description:
43
44------------------------------------------------------------------------------
45 INPUT AND OUTPUT DEFINITIONS
46
47     int16 a[],            (i) Q12 : a[m+1]  LPC coefficients
48     int16 ap[],           (o) Q12 : Spectral expanded LPC coefficients
49     int16 gamma,          (i) Q15 : Spectral expansion factor.
50     int16 m               (i)     : LPC order.
51
52------------------------------------------------------------------------------
53 FUNCTION DESCRIPTION
54
55   Weighting of LPC coefficients.
56     ap[i]  =  a[i]   (gamma    i)
57
58------------------------------------------------------------------------------
59 REQUIREMENTS
60
61
62------------------------------------------------------------------------------
63 REFERENCES
64
65------------------------------------------------------------------------------
66 PSEUDO-CODE
67
68------------------------------------------------------------------------------
69*/
70
71
72/*----------------------------------------------------------------------------
73; INCLUDES
74----------------------------------------------------------------------------*/
75
76#include "pv_amr_wb_type_defs.h"
77#include "pvamrwbdecoder_basic_op.h"
78#include "pvamrwbdecoder_acelp.h"
79
80/*----------------------------------------------------------------------------
81; MACROS
82; Define module specific macros here
83----------------------------------------------------------------------------*/
84
85
86/*----------------------------------------------------------------------------
87; DEFINES
88; Include all pre-processor statements here. Include conditional
89; compile variables also.
90----------------------------------------------------------------------------*/
91
92/*----------------------------------------------------------------------------
93; LOCAL FUNCTION DEFINITIONS
94; Function Prototype declaration
95----------------------------------------------------------------------------*/
96
97/*----------------------------------------------------------------------------
98; LOCAL STORE/BUFFER/POINTER DEFINITIONS
99; Variable declaration - defined here and used outside this module
100----------------------------------------------------------------------------*/
101
102/*----------------------------------------------------------------------------
103; EXTERNAL FUNCTION REFERENCES
104; Declare functions defined elsewhere and referenced in this module
105----------------------------------------------------------------------------*/
106
107/*----------------------------------------------------------------------------
108; EXTERNAL GLOBAL STORE/BUFFER/POINTER REFERENCES
109; Declare variables used in this module but defined elsewhere
110----------------------------------------------------------------------------*/
111
112/*----------------------------------------------------------------------------
113; FUNCTION CODE
114----------------------------------------------------------------------------*/
115
116void weight_amrwb_lpc(
117    int16 a[],          /* (i) Q12 : a[m+1]  LPC coefficients             */
118    int16 ap[],         /* (o) Q12 : Spectral expanded LPC coefficients   */
119    int16 gamma,        /* (i) Q15 : Spectral expansion factor.           */
120    int16 m             /* (i)     : LPC order.                           */
121)
122{
123    int16 i, fac;
124    int32 roundFactor = 0x00004000L;
125    ap[0] = a[0];
126    fac = gamma;
127    for (i = 1; i < m; i++)
128    {
129        ap[i] = (int16)(fxp_mac_16by16(a[i], fac, roundFactor) >> 15);
130        fac   = (int16)(fxp_mac_16by16(fac, gamma, roundFactor) >> 15);
131    }
132    ap[i] = (int16)(fxp_mac_16by16(a[i], fac, roundFactor) >> 15);
133
134    return;
135}
136