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 Pathname: ./audio/gsm-amr/c/src/weight_a.c 32 33 ------------------------------------------------------------------------------ 34 REVISION HISTORY 35 36 Description: Put file into template and first pass at optimization. 37 38 Description: Made changes based on comments from the review meeting. Used 39 pointers instead of index addressing in the arrays. 40 41 Description: Synchronized file with UMTS version 3.2.0. Updated coding 42 template. Removed unnecessary include files. 43 44 Description: Fixed typecasting issue with TI C compiler. 45 46 Description: Made the following changes per comments from Phase 2/3 review: 47 1. Modified FOR loop to count down. 48 2. Used address pre-increment instead of address offsets. 49 50 Description: Replaced "int" and/or "char" with OSCL defined types. 51 52 Description: Changed round function name to pv_round to avoid conflict with 53 round function in C standard library. 54 55 Who: Date: 56 Description: 57 58 ------------------------------------------------------------------------------ 59 */ 60 61 /*---------------------------------------------------------------------------- 62 ; INCLUDES 63 ----------------------------------------------------------------------------*/ 64 #include "weight_a.h" 65 #include "typedef.h" 66 #include "cnst.h" 67 68 /*---------------------------------------------------------------------------- 69 ; MACROS 70 ; Define module specific macros here 71 ----------------------------------------------------------------------------*/ 72 73 74 /*---------------------------------------------------------------------------- 75 ; DEFINES 76 ; Include all pre-processor statements here. Include conditional 77 ; compile variables also. 78 ----------------------------------------------------------------------------*/ 79 80 81 /*---------------------------------------------------------------------------- 82 ; LOCAL FUNCTION DEFINITIONS 83 ; Function Prototype declaration 84 ----------------------------------------------------------------------------*/ 85 86 87 /*---------------------------------------------------------------------------- 88 ; LOCAL STORE/BUFFER/POINTER DEFINITIONS 89 ; Variable declaration - defined here and used outside this module 90 ----------------------------------------------------------------------------*/ 91 92 93 /* 94 ------------------------------------------------------------------------------ 95 FUNCTION NAME: Weight_Ai 96 ------------------------------------------------------------------------------ 97 INPUT AND OUTPUT DEFINITIONS 98 99 Inputs: 100 a = LPC coefficients (Word16) 101 fac = Spectral expansion factors (Word16) 102 a_exp = Spectral expanded LPC coefficients (Word16) 103 104 Outputs: 105 a_exp points to the updated spectral expanded LPC coefficients 106 107 Returns: 108 None. 109 110 Global Variables Used: 111 None. 112 113 Local Variables Needed: 114 None. 115 116 ------------------------------------------------------------------------------ 117 FUNCTION DESCRIPTION 118 119 This function calculates the spectral expansion for the LP coefficients of 120 order M. 121 a_exp[i] = a[i] * fac[i-1] ; i=1..M 122 123 ------------------------------------------------------------------------------ 124 REQUIREMENTS 125 126 None. 127 128 ------------------------------------------------------------------------------ 129 REFERENCES 130 131 weight_a.c, UMTS GSM AMR speech codec, R99 - Version 3.2.0, March 2, 2001 132 133 ------------------------------------------------------------------------------ 134 PSEUDO-CODE 135 136 void Weight_Ai ( 137 Word16 a[], // (i) : a[M+1] LPC coefficients (M=10) 138 const Word16 fac[], // (i) : Spectral expansion factors. 139 Word16 a_exp[] // (o) : Spectral expanded LPC coefficients 140 ) 141 { 142 Word16 i; 143 a_exp[0] = a[0]; 144 145 for (i = 1; i <= M; i++) 146 { 147 a_exp[i] = pv_round (L_mult (a[i], fac[i - 1])); 148 } 149 return; 150 } 151 152 ------------------------------------------------------------------------------ 153 RESOURCES USED [optional] 154 155 When the code is written for a specific target processor the 156 the resources used should be documented below. 157 158 HEAP MEMORY USED: x bytes 159 160 STACK MEMORY USED: x bytes 161 162 CLOCK CYCLES: (cycle count equation for this function) + (variable 163 used to represent cycle count for each subroutine 164 called) 165 where: (cycle count variable) = cycle count for [subroutine 166 name] 167 168 ------------------------------------------------------------------------------ 169 CAUTION [optional] 170 [State any special notes, constraints or cautions for users of this function] 171 172 ------------------------------------------------------------------------------ 173 */ 174 175 void Weight_Ai( 176 Word16 a[], /* (i) : a[M+1] LPC coefficients (M=10) */ 177 const Word16 fac[], /* (i) : Spectral expansion factors. */ 178 Word16 a_exp[] /* (o) : Spectral expanded LPC coefficients */ 179 ) 180 { 181 Word16 i; 182 183 *(a_exp) = *(a); 184 185 for (i = M; i >= 1; i--) 186 { 187 a_exp += 1; 188 a += 1; 189 fac += 1; 190 *(a_exp) = (Word16)((((Word32) * (a)) * *(fac - 1) 191 + 0x00004000L) >> 15); 192 } 193 194 return; 195 } 196 197