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: dst32.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 x 32-bit integer input length 32 33 34 35------------------------------------------------------------------------------ 36 FUNCTION DESCRIPTION 37 38 Implement discrete sine transform of lenght 32 39 40------------------------------------------------------------------------------ 41 REQUIREMENTS 42 43 44------------------------------------------------------------------------------ 45 REFERENCES 46 47------------------------------------------------------------------------------ 48 PSEUDO-CODE 49 50------------------------------------------------------------------------------ 51*/ 52 53 54/*---------------------------------------------------------------------------- 55; INCLUDES 56----------------------------------------------------------------------------*/ 57 58#ifdef AAC_PLUS 59 60 61#include "dst32.h" 62#include "dst16.h" 63 64#include "fxp_mul32.h" 65 66/*---------------------------------------------------------------------------- 67; MACROS 68; Define module specific macros here 69----------------------------------------------------------------------------*/ 70 71 72/*---------------------------------------------------------------------------- 73; DEFINES 74; Include all pre-processor statements here. Include conditional 75; compile variables also. 76----------------------------------------------------------------------------*/ 77 78 79#define R_SHIFT1 29 80#define Qfmt29(x) (Int32)(x*((Int32)1<<R_SHIFT1) + (x>=0?0.5F:-0.5F)) 81#define Qfmt31(a) (Int32)(a*0x7FFFFFFF + (a>=0?0.5F:-0.5F)) 82 83const Int32 CosTable_16[14] = 84{ 85 Qfmt31(0.50060299823520F), Qfmt31(0.50547095989754F), 86 Qfmt31(0.51544730992262F), Qfmt31(0.53104259108978F), 87 Qfmt31(0.55310389603444F), Qfmt31(0.58293496820613F), 88 Qfmt31(0.62250412303566F), Qfmt31(0.67480834145501F), 89 Qfmt31(0.74453627100230F), Qfmt31(0.83934964541553F), 90 Qfmt29(0.97256823786196F), Qfmt29(1.16943993343288F), 91 Qfmt29(1.48416461631417F), Qfmt29(2.05778100995341F) 92}; 93 94/*---------------------------------------------------------------------------- 95; LOCAL FUNCTION DEFINITIONS 96; Function Prototype declaration 97----------------------------------------------------------------------------*/ 98 99/*---------------------------------------------------------------------------- 100; LOCAL STORE/BUFFER/POINTER DEFINITIONS 101; Variable declaration - defined here and used outside this module 102----------------------------------------------------------------------------*/ 103 104/*---------------------------------------------------------------------------- 105; EXTERNAL FUNCTION REFERENCES 106; Declare functions defined elsewhere and referenced in this module 107----------------------------------------------------------------------------*/ 108 109/*---------------------------------------------------------------------------- 110; EXTERNAL GLOBAL STORE/BUFFER/POINTER REFERENCES 111; Declare variables used in this module but defined elsewhere 112----------------------------------------------------------------------------*/ 113 114/*---------------------------------------------------------------------------- 115; FUNCTION CODE 116----------------------------------------------------------------------------*/ 117 118 119void dst_32(Int32 vec[], Int32 scratch_mem[]) /* scratch_mem size 32 */ 120{ 121 Int32 *temp_even = scratch_mem; 122 123 Int32 i; 124 const Int32 *pt_cos = &CosTable_16[13]; 125 Int32 tmp0 = vec[31] >> 1; 126 Int32 tmp1, tmp2; 127 Int32 *pt_even = temp_even; 128 Int32 *pt_odd = vec; 129 Int32 *pt_vec = vec; 130 Int32 *pt_vecN_1 = vec; 131 Int32 tmp3; 132 133 134 tmp1 = 0; 135 136 for (i = 5; i != 0; i--) 137 { 138 *(pt_even++) = *(pt_vec++); 139 tmp2 = *(pt_vec++); 140 *(pt_even++) = *(pt_vec++); 141 tmp3 = *(pt_vec++); 142 *(pt_even++) = *(pt_vec++); 143 *(pt_odd++) = tmp2 + tmp1; 144 *(pt_odd++) = tmp3 + tmp2; 145 tmp1 = *(pt_vec++); 146 *(pt_odd++) = tmp1 + tmp3; 147 } 148 149 *(pt_even) = *(pt_vec++); 150 *(pt_odd) = *(pt_vec) + tmp1; 151 152 153 dst_16(temp_even, &scratch_mem[16]); 154 dst_16(vec, &scratch_mem[24]); 155 156 157 pt_vecN_1 = &vec[16]; 158 159 tmp1 = temp_even[15]; 160 161 tmp3 = fxp_mul32_Q31((vec[15] - tmp0) << 3, Qfmt31(0.63687550772175F)) << 2; 162 tmp2 = temp_even[14]; 163 *(pt_vecN_1++) = tmp3 - tmp1; 164 vec[15] = tmp3 + tmp1; 165 tmp1 = temp_even[13]; 166 tmp3 = fxp_mul32_Q31((vec[14] + tmp0) << 3, Qfmt31(0.85190210461718F)); 167 *(pt_vecN_1++) = tmp3 - tmp2; 168 vec[14] = tmp3 + tmp2; 169 170 pt_even = &temp_even[12]; 171 pt_vec = &vec[13]; 172 173 for (i = 2; i != 0; i--) 174 { 175 tmp3 = fxp_mul32_Q29((*(pt_vec) - tmp0), *(pt_cos--)); 176 tmp2 = *(pt_even--); 177 *(pt_vec--) = tmp3 + tmp1; 178 *(pt_vecN_1++) = tmp3 - tmp1; 179 tmp3 = fxp_mul32_Q29((*(pt_vec) + tmp0), *(pt_cos--)); 180 tmp1 = *(pt_even--); 181 *(pt_vec--) = tmp3 + tmp2; 182 *(pt_vecN_1++) = tmp3 - tmp2; 183 } 184 185 for (i = 5; i != 0; i--) 186 { 187 tmp3 = fxp_mul32_Q31((*(pt_vec) - tmp0) << 1, *(pt_cos--)); 188 tmp2 = *(pt_even--); 189 *(pt_vec--) = tmp3 + tmp1; 190 *(pt_vecN_1++) = tmp3 - tmp1; 191 tmp3 = fxp_mul32_Q31((*(pt_vec) + tmp0) << 1, *(pt_cos--)); 192 tmp1 = *(pt_even--); 193 *(pt_vec--) = tmp3 + tmp2; 194 *(pt_vecN_1++) = tmp3 - tmp2; 195 } 196 197 198} 199 200#endif 201