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: analysis_sub_band.c 21 22 ------------------------------------------------------------------------------ 23 REVISION HISTORY 24 25 26 Who: Date: MM/DD/YYYY 27 Description: 28 29 ------------------------------------------------------------------------------ 30 INPUT AND OUTPUT DEFINITIONS 31 32 Int32 vec[], Input vector, 32-bit 33 const Int32 *cosTerms, Cosine Terms 34 Int maxbands number of bands used 35 Int32 *scratch_mem Scratch memory 36 37 38 ------------------------------------------------------------------------------ 39 FUNCTION DESCRIPTION 40 41 Implement root squared of a number 42 43 ------------------------------------------------------------------------------ 44 REQUIREMENTS 45 46 47 ------------------------------------------------------------------------------ 48 REFERENCES 49 50 ------------------------------------------------------------------------------ 51 PSEUDO-CODE 52 53 ------------------------------------------------------------------------------ 54 */ 55 56 57 /*---------------------------------------------------------------------------- 58 ; INCLUDES 59 ----------------------------------------------------------------------------*/ 60 61 #ifdef AAC_PLUS 62 63 64 #include "analysis_sub_band.h" 65 #include "dst32.h" 66 #include "idct32.h" 67 #include "mdst.h" 68 69 #include "aac_mem_funcs.h" 70 #include "pv_audio_type_defs.h" 71 #include "fxp_mul32.h" 72 73 74 /*---------------------------------------------------------------------------- 75 ; MACROS 76 ; Define module specific macros here 77 ----------------------------------------------------------------------------*/ 78 79 80 /*---------------------------------------------------------------------------- 81 ; DEFINES 82 ; Include all pre-processor statements here. Include conditional 83 ; compile variables also. 84 ----------------------------------------------------------------------------*/ 85 86 /*---------------------------------------------------------------------------- 87 ; LOCAL FUNCTION DEFINITIONS 88 ; Function Prototype declaration 89 ----------------------------------------------------------------------------*/ 90 91 /*---------------------------------------------------------------------------- 92 ; LOCAL STORE/BUFFER/POINTER DEFINITIONS 93 ; Variable declaration - defined here and used outside this module 94 ----------------------------------------------------------------------------*/ 95 96 97 #ifdef HQ_SBR 98 99 100 const Int32 exp_1_5_phi[32] = 101 { 102 103 0x7FEA04B6, 0x7F380E1C, 0x7DD6176E, 0x7BC6209F, 104 0x790A29A4, 0x75A6326E, 0x719E3AF3, 0x6CF94326, 105 0x67BD4AFB, 0x61F15269, 0x5B9D5964, 0x54CA5FE4, 106 0x4D8165DE, 0x45CD6B4B, 0x3DB87023, 0x354E7460, 107 0x2C9977FB, 0x23A77AEF, 0x1A837D3A, 0x113A7ED6, 108 0x07D97FC2, 0xFE6E7FFE, 0xF5057F87, 0xEBAB7E60, 109 0xE26D7C89, 0xD9587A06, 0xD07976D9, 0xC7DB7308, 110 0xBF8C6E97, 0xB796698C, 0xB00563EF, 0xA8E25DC8, 111 112 }; 113 114 #endif 115 116 117 /*---------------------------------------------------------------------------- 118 ; EXTERNAL FUNCTION REFERENCES 119 ; Declare functions defined elsewhere and referenced in this module 120 ----------------------------------------------------------------------------*/ 121 122 /*---------------------------------------------------------------------------- 123 ; EXTERNAL GLOBAL STORE/BUFFER/POINTER REFERENCES 124 ; Declare variables used in this module but defined elsewhere 125 ----------------------------------------------------------------------------*/ 126 127 /*---------------------------------------------------------------------------- 128 ; FUNCTION CODE 129 ----------------------------------------------------------------------------*/ 130 131 132 void analysis_sub_band_LC(Int32 vec[64], 133 Int32 cosine_total[], 134 Int32 maxBand, 135 Int32 scratch_mem[][64]) 136 { 137 Int32 i; 138 Int32 *cosine_term = &scratch_mem[0][0]; 139 Int32 *sine_term = &scratch_mem[0][32]; 140 141 Int32 *pt_cos_t; 142 143 144 Int32 *pt_vec = &vec[0]; 145 Int32 *pt_vec_32 = &vec[32]; 146 147 Int32 *pt_cos = cosine_term; 148 Int32 *pt_sin = sine_term; 149 150 for (i = 8; i != 0; i--) 151 { 152 Int32 tmp1 = *(pt_vec_32++); 153 Int32 tmp3 = *(pt_vec_32++); 154 Int32 tmp2 = *(pt_vec++); 155 Int32 tmp4 = *(pt_vec++); 156 *(pt_cos++) = (tmp1 - tmp2) >> 1; 157 *(pt_cos++) = (tmp3 - tmp4) >> 1; 158 *(pt_sin++) = (tmp1 + tmp2); 159 *(pt_sin++) = (tmp3 + tmp4); 160 tmp1 = *(pt_vec_32++); 161 tmp3 = *(pt_vec_32++); 162 tmp2 = *(pt_vec++); 163 tmp4 = *(pt_vec++); 164 *(pt_cos++) = (tmp1 - tmp2) >> 1; 165 *(pt_cos++) = (tmp3 - tmp4) >> 1; 166 *(pt_sin++) = (tmp1 + tmp2); 167 *(pt_sin++) = (tmp3 + tmp4); 168 } 169 170 171 idct_32(cosine_term, scratch_mem[1]); 172 173 dst_32(sine_term, scratch_mem[1]); 174 175 pt_cos = cosine_term; 176 pt_sin = sine_term; 177 178 pt_cos_t = cosine_total; 179 180 for (i = 0; i < maxBand; i += 4) 181 { 182 *(pt_cos_t++) = (*(pt_cos++) + *(pt_sin++)); 183 *(pt_cos_t++) = (-*(pt_cos++) + *(pt_sin++)); 184 *(pt_cos_t++) = (-*(pt_cos++) - *(pt_sin++)); 185 *(pt_cos_t++) = (*(pt_cos++) - *(pt_sin++)); 186 } 187 188 pt_cos_t = &cosine_total[maxBand]; 189 190 for (i = (32 - maxBand); i != 0; i--) 191 { 192 *(pt_cos_t++) = 0; 193 } 194 } 195 196 197 #ifdef HQ_SBR 198 199 200 void analysis_sub_band(Int32 vec[64], 201 Int32 cosine_total[], 202 Int32 sine_total[], 203 Int32 maxBand, 204 Int32 scratch_mem[][64]) 205 { 206 Int32 i; 207 Int32 *sine_term1 = &scratch_mem[0][0]; 208 Int32 *sine_term2 = &scratch_mem[0][32]; 209 210 Int32 temp1; 211 Int32 temp2; 212 Int32 temp3; 213 Int32 temp4; 214 215 const Int32 *pt_exp; 216 Int32 exp_1_5; 217 218 Int32 *pt_vec = &vec[0]; 219 Int32 *pt_vec_32 = &vec[32]; 220 221 Int32 *pt_cos1 = pt_vec; 222 Int32 *pt_sin1 = sine_term1; 223 Int32 *pt_cos2 = pt_vec_32; 224 Int32 *pt_sin2 = sine_term2; 225 226 227 pv_memcpy(sine_term1, vec, 64*sizeof(*vec)); 228 229 mdst_32(sine_term1, scratch_mem[1]); 230 mdst_32(sine_term2, scratch_mem[1]); 231 232 mdct_32(&vec[ 0]); 233 mdct_32(&vec[32]); 234 235 pt_cos1 = &vec[ 0]; 236 pt_cos2 = &vec[32]; 237 238 239 pt_sin1 = sine_term1; 240 pt_sin2 = sine_term2; 241 242 pt_vec = cosine_total; 243 pt_vec_32 = sine_total; 244 pt_exp = exp_1_5_phi; 245 246 temp3 = (*(pt_cos1++) - *(pt_sin2++)); 247 temp4 = (*(pt_sin1++) + *(pt_cos2++)); 248 249 for (i = 0; i < maxBand; i += 2) 250 { 251 252 exp_1_5 = *(pt_exp++); 253 temp1 = cmplx_mul32_by_16(temp3, temp4, exp_1_5); 254 temp2 = cmplx_mul32_by_16(temp4, -temp3, exp_1_5); 255 256 *(pt_vec++) = shft_lft_1(temp1); 257 *(pt_vec_32++) = shft_lft_1(temp2); 258 259 temp3 = (*(pt_cos1++) + *(pt_sin2++)); 260 temp4 = (*(pt_sin1++) - *(pt_cos2++)); 261 262 exp_1_5 = *(pt_exp++); 263 temp1 = cmplx_mul32_by_16(temp3, temp4, exp_1_5); 264 temp2 = cmplx_mul32_by_16(temp4, -temp3, exp_1_5); 265 266 *(pt_vec++) = shft_lft_1(temp1); 267 *(pt_vec_32++) = shft_lft_1(temp2); 268 269 temp3 = (*(pt_cos1++) - *(pt_sin2++)); 270 temp4 = (*(pt_sin1++) + *(pt_cos2++)); 271 } 272 273 274 pt_cos1 = &cosine_total[maxBand]; /* in the chance that maxband is not even */ 275 pt_sin1 = &sine_total[maxBand]; 276 277 for (i = (32 - maxBand); i != 0; i--) 278 { 279 *(pt_cos1++) = 0; 280 *(pt_sin1++) = 0; 281 } 282 283 } 284 285 286 #endif 287 288 #endif 289 290