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 20 Filename: calc_sbr_anafilterbank.c 21 22 23 ------------------------------------------------------------------------------ 24 REVISION HISTORY 25 26 27 Who: Date: MM/DD/YYYY 28 Description: 29 30 ------------------------------------------------------------------------------ 31 INPUT AND OUTPUT DEFINITIONS 32 33 34 35 ------------------------------------------------------------------------------ 36 FUNCTION DESCRIPTION 37 38 39 ------------------------------------------------------------------------------ 40 REQUIREMENTS 41 42 43 ------------------------------------------------------------------------------ 44 REFERENCES 45 46 SC 29 Software Copyright Licencing Disclaimer: 47 48 This software module was originally developed by 49 Coding Technologies 50 51 and edited by 52 - 53 54 in the course of development of the ISO/IEC 13818-7 and ISO/IEC 14496-3 55 standards for reference purposes and its performance may not have been 56 optimized. This software module is an implementation of one or more tools as 57 specified by the ISO/IEC 13818-7 and ISO/IEC 14496-3 standards. 58 ISO/IEC gives users free license to this software module or modifications 59 thereof for use in products claiming conformance to audiovisual and 60 image-coding related ITU Recommendations and/or ISO/IEC International 61 Standards. ISO/IEC gives users the same free license to this software module or 62 modifications thereof for research purposes and further ISO/IEC standardisation. 63 Those intending to use this software module in products are advised that its 64 use may infringe existing patents. ISO/IEC have no liability for use of this 65 software module or modifications thereof. Copyright is not released for 66 products that do not conform to audiovisual and image-coding related ITU 67 Recommendations and/or ISO/IEC International Standards. 68 The original developer retains full right to modify and use the code for its 69 own purpose, assign or donate the code to a third party and to inhibit third 70 parties from using the code for products that do not conform to audiovisual and 71 image-coding related ITU Recommendations and/or ISO/IEC International Standards. 72 This copyright notice must be included in all copies or derivative works. 73 Copyright (c) ISO/IEC 2002. 74 75 ------------------------------------------------------------------------------ 76 PSEUDO-CODE 77 78 ------------------------------------------------------------------------------ 79 */ 80 81 82 /*---------------------------------------------------------------------------- 83 ; INCLUDES 84 ----------------------------------------------------------------------------*/ 85 86 #ifdef AAC_PLUS 87 88 89 #include "calc_sbr_anafilterbank.h" 90 #include "qmf_filterbank_coeff.h" 91 #include "analysis_sub_band.h" 92 93 #include "aac_mem_funcs.h" 94 #include "fxp_mul32.h" 95 96 97 98 /*---------------------------------------------------------------------------- 99 ; MACROS 100 ; Define module specific macros here 101 ----------------------------------------------------------------------------*/ 102 103 104 /*---------------------------------------------------------------------------- 105 ; DEFINES 106 ; Include all pre-processor statements here. Include conditional 107 ; compile variables also. 108 ----------------------------------------------------------------------------*/ 109 110 /*---------------------------------------------------------------------------- 111 ; LOCAL FUNCTION DEFINITIONS 112 ; Function Prototype declaration 113 ----------------------------------------------------------------------------*/ 114 115 /*---------------------------------------------------------------------------- 116 ; LOCAL STORE/BUFFER/POINTER DEFINITIONS 117 ; Variable declaration - defined here and used outside this module 118 ----------------------------------------------------------------------------*/ 119 120 /*---------------------------------------------------------------------------- 121 ; EXTERNAL FUNCTION REFERENCES 122 ; Declare functions defined elsewhere and referenced in this module 123 ----------------------------------------------------------------------------*/ 124 125 /*---------------------------------------------------------------------------- 126 ; EXTERNAL GLOBAL STORE/BUFFER/POINTER REFERENCES 127 ; Declare variables used in this module but defined elsewhere 128 ----------------------------------------------------------------------------*/ 129 130 /*---------------------------------------------------------------------------- 131 ; FUNCTION CODE 132 ----------------------------------------------------------------------------*/ 133 134 void calc_sbr_anafilterbank_LC(Int32 * Sr, 135 Int16 * X, 136 Int32 scratch_mem[][64], 137 Int32 maxBand) 138 { 139 140 Int i; 141 Int32 *p_Y_1; 142 Int32 *p_Y_2; 143 144 Int16 * pt_X_1; 145 Int16 * pt_X_2; 146 Int32 realAccu1; 147 Int32 realAccu2; 148 149 Int32 tmp1; 150 Int32 tmp2; 151 152 153 const Int32 * pt_C; 154 155 p_Y_1 = scratch_mem[0]; 156 157 158 p_Y_2 = p_Y_1 + 63; 159 pt_C = &sbrDecoderFilterbankCoefficients_an_filt_LC[0]; 160 161 pt_X_1 = X; 162 163 164 realAccu1 = fxp_mul32_by_16(Qfmt27(-0.51075594183097F), pt_X_1[-192]); 165 166 realAccu1 = fxp_mac32_by_16(Qfmt27(-0.51075594183097F), -pt_X_1[-128], realAccu1); 167 realAccu1 = fxp_mac32_by_16(Qfmt27(-0.01876919066980F), pt_X_1[-256], realAccu1); 168 *(p_Y_1++) = fxp_mac32_by_16(Qfmt27(-0.01876919066980F), -pt_X_1[ -64], realAccu1); 169 170 171 /* create array Y */ 172 173 pt_X_1 = &X[-1]; 174 pt_X_2 = &X[-319]; 175 176 177 for (i = 15; i != 0; i--) 178 { 179 tmp1 = *(pt_X_1--); 180 tmp2 = *(pt_X_2++); 181 182 realAccu1 = fxp_mul32_by_16(*(pt_C), tmp1); 183 realAccu2 = fxp_mul32_by_16(*(pt_C++), tmp2); 184 tmp1 = pt_X_1[ -63]; 185 tmp2 = pt_X_2[ +63]; 186 realAccu1 = fxp_mac32_by_16(*(pt_C), tmp1, realAccu1); 187 realAccu2 = fxp_mac32_by_16(*(pt_C++), tmp2, realAccu2); 188 tmp1 = pt_X_1[ -127]; 189 tmp2 = pt_X_2[ +127]; 190 realAccu1 = fxp_mac32_by_16(*(pt_C), tmp1, realAccu1); 191 realAccu2 = fxp_mac32_by_16(*(pt_C++), tmp2, realAccu2); 192 tmp1 = pt_X_1[ -191]; 193 tmp2 = pt_X_2[ +191]; 194 realAccu1 = fxp_mac32_by_16(*(pt_C), tmp1, realAccu1); 195 realAccu2 = fxp_mac32_by_16(*(pt_C++), tmp2, realAccu2); 196 tmp1 = pt_X_1[ -255]; 197 tmp2 = pt_X_2[ +255]; 198 *(p_Y_1++) = fxp_mac32_by_16(*(pt_C), tmp1, realAccu1); 199 *(p_Y_2--) = fxp_mac32_by_16(*(pt_C++), tmp2, realAccu2); 200 201 tmp1 = *(pt_X_1--); 202 tmp2 = *(pt_X_2++); 203 realAccu1 = fxp_mul32_by_16(*(pt_C), tmp1); 204 realAccu2 = fxp_mul32_by_16(*(pt_C++), tmp2); 205 206 tmp1 = pt_X_1[ -63]; 207 tmp2 = pt_X_2[ +63]; 208 realAccu1 = fxp_mac32_by_16(*(pt_C), tmp1, realAccu1); 209 realAccu2 = fxp_mac32_by_16(*(pt_C++), tmp2, realAccu2); 210 tmp1 = pt_X_1[ -127]; 211 tmp2 = pt_X_2[ +127]; 212 realAccu1 = fxp_mac32_by_16(*(pt_C), tmp1, realAccu1); 213 realAccu2 = fxp_mac32_by_16(*(pt_C++), tmp2, realAccu2); 214 tmp1 = pt_X_1[ -191]; 215 tmp2 = pt_X_2[ +191]; 216 realAccu1 = fxp_mac32_by_16(*(pt_C), tmp1, realAccu1); 217 realAccu2 = fxp_mac32_by_16(*(pt_C++), tmp2, realAccu2); 218 tmp1 = pt_X_1[ -255]; 219 tmp2 = pt_X_2[ +255]; 220 *(p_Y_1++) = fxp_mac32_by_16(*(pt_C), tmp1, realAccu1); 221 *(p_Y_2--) = fxp_mac32_by_16(*(pt_C++), tmp2, realAccu2); 222 223 } 224 225 226 tmp1 = *(pt_X_1--); 227 tmp2 = *(pt_X_2++); 228 realAccu1 = fxp_mul32_by_16(*(pt_C), tmp1); 229 realAccu2 = fxp_mul32_by_16(*(pt_C++), tmp2); 230 231 tmp1 = pt_X_1[ -63]; 232 tmp2 = pt_X_2[ +63]; 233 realAccu1 = fxp_mac32_by_16(*(pt_C), tmp1, realAccu1); 234 realAccu2 = fxp_mac32_by_16(*(pt_C++), tmp2, realAccu2); 235 tmp1 = pt_X_1[ -127]; 236 tmp2 = pt_X_2[ +127]; 237 realAccu1 = fxp_mac32_by_16(*(pt_C), tmp1, realAccu1); 238 realAccu2 = fxp_mac32_by_16(*(pt_C++), tmp2, realAccu2); 239 tmp1 = pt_X_1[ -191]; 240 tmp2 = pt_X_2[ +191]; 241 realAccu1 = fxp_mac32_by_16(*(pt_C), tmp1, realAccu1); 242 realAccu2 = fxp_mac32_by_16(*(pt_C++), tmp2, realAccu2); 243 tmp1 = pt_X_1[ -255]; 244 tmp2 = pt_X_2[ +255]; 245 *(p_Y_1++) = fxp_mac32_by_16(*(pt_C), tmp1, realAccu1); 246 *(p_Y_2--) = fxp_mac32_by_16(*(pt_C++), tmp2, realAccu2); 247 248 249 pt_X_1 = X; 250 251 realAccu2 = fxp_mul32_by_16(Qfmt27(0.00370548843500F), X[ -32]); 252 253 realAccu2 = fxp_mac32_by_16(Qfmt27(0.00370548843500F), pt_X_1[-288], realAccu2); 254 realAccu2 = fxp_mac32_by_16(Qfmt27(0.09949460091720F), pt_X_1[ -96], realAccu2); 255 realAccu2 = fxp_mac32_by_16(Qfmt27(0.09949460091720F), pt_X_1[-224], realAccu2); 256 *(p_Y_1++) = fxp_mac32_by_16(Qfmt27(1.20736865027288F), pt_X_1[-160], realAccu2); 257 258 259 analysis_sub_band_LC(scratch_mem[0], 260 Sr, 261 maxBand, 262 (Int32(*)[64])scratch_mem[1]); 263 264 } 265 266 267 268 #ifdef HQ_SBR 269 270 void calc_sbr_anafilterbank(Int32 * Sr, 271 Int32 * Si, 272 Int16 * X, 273 Int32 scratch_mem[][64], 274 Int32 maxBand) 275 { 276 Int i; 277 Int32 *p_Y_1; 278 Int32 *p_Y_2; 279 280 281 282 283 const Int32 * pt_C; 284 Int16 * pt_X_1; 285 Int16 * pt_X_2; 286 Int32 realAccu1; 287 Int32 realAccu2; 288 289 Int32 tmp1; 290 Int32 tmp2; 291 292 293 p_Y_1 = scratch_mem[0]; 294 295 296 p_Y_2 = p_Y_1 + 63; 297 pt_C = &sbrDecoderFilterbankCoefficients_an_filt[0]; 298 299 realAccu1 = fxp_mul32_by_16(Qfmt27(-0.36115899F), X[-192]); 300 301 302 realAccu1 = fxp_mac32_by_16(Qfmt27(-0.36115899F), -X[-128], realAccu1); 303 realAccu1 = fxp_mac32_by_16(Qfmt27(-0.013271822F), X[-256], realAccu1); 304 *(p_Y_1++) = fxp_mac32_by_16(Qfmt27(-0.013271822F), -X[ -64], realAccu1); 305 306 /* create array Y */ 307 308 pt_X_1 = &X[-1]; 309 pt_X_2 = &X[-319]; 310 311 312 for (i = 31; i != 0; i--) 313 { 314 tmp1 = *(pt_X_1--); 315 tmp2 = *(pt_X_2++); 316 realAccu1 = fxp_mul32_by_16(*(pt_C), tmp1); 317 realAccu2 = fxp_mul32_by_16(*(pt_C++), tmp2); 318 tmp1 = pt_X_1[ -63]; 319 tmp2 = pt_X_2[ 63]; 320 realAccu1 = fxp_mac32_by_16(*(pt_C), tmp1, realAccu1); 321 realAccu2 = fxp_mac32_by_16(*(pt_C++), tmp2, realAccu2); 322 tmp1 = pt_X_1[ -127]; 323 tmp2 = pt_X_2[ 127]; 324 realAccu1 = fxp_mac32_by_16(*(pt_C), tmp1, realAccu1); 325 realAccu2 = fxp_mac32_by_16(*(pt_C++), tmp2, realAccu2); 326 tmp1 = pt_X_1[ -191]; 327 tmp2 = pt_X_2[ 191]; 328 realAccu1 = fxp_mac32_by_16(*(pt_C), tmp1, realAccu1); 329 realAccu2 = fxp_mac32_by_16(*(pt_C++), tmp2, realAccu2); 330 tmp1 = pt_X_1[ -255]; 331 tmp2 = pt_X_2[ 255]; 332 *(p_Y_1++) = fxp_mac32_by_16(*(pt_C), tmp1, realAccu1); 333 *(p_Y_2--) = fxp_mac32_by_16(*(pt_C++), tmp2, realAccu2); 334 } 335 336 337 realAccu2 = fxp_mul32_by_16(Qfmt27(0.002620176F), X[ -32]); 338 realAccu2 = fxp_mac32_by_16(Qfmt27(0.002620176F), X[-288], realAccu2); 339 realAccu2 = fxp_mac32_by_16(Qfmt27(0.070353307F), X[ -96], realAccu2); 340 realAccu2 = fxp_mac32_by_16(Qfmt27(0.070353307F), X[-224], realAccu2); 341 342 343 *(p_Y_1++) = fxp_mac32_by_16(Qfmt27(0.85373856F), (X[-160]), realAccu2); 344 345 346 analysis_sub_band(scratch_mem[0], 347 Sr, 348 Si, 349 maxBand, 350 (Int32(*)[64])scratch_mem[1]); 351 352 } 353 354 355 #endif 356 357 358 359 #endif /* AAC_PLUS */ 360 361