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: dst8.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 8 33 34 35 ------------------------------------------------------------------------------ 36 FUNCTION DESCRIPTION 37 38 Implement discrete sine transform of lenght 8 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 "dst8.h" 62 63 #include "fxp_mul32.h" 64 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 #define Qfmt15(x) (Int16)(x*((Int32)1<<15) + (x>=0?0.5F:-0.5F)) 79 80 /*---------------------------------------------------------------------------- 81 ; LOCAL FUNCTION DEFINITIONS 82 ; Function Prototype declaration 83 ----------------------------------------------------------------------------*/ 84 85 /*---------------------------------------------------------------------------- 86 ; LOCAL STORE/BUFFER/POINTER DEFINITIONS 87 ; Variable declaration - defined here and used outside this module 88 ----------------------------------------------------------------------------*/ 89 90 /*---------------------------------------------------------------------------- 91 ; EXTERNAL FUNCTION REFERENCES 92 ; Declare functions defined elsewhere and referenced in this module 93 ----------------------------------------------------------------------------*/ 94 95 /*---------------------------------------------------------------------------- 96 ; EXTERNAL GLOBAL STORE/BUFFER/POINTER REFERENCES 97 ; Declare variables used in this module but defined elsewhere 98 ----------------------------------------------------------------------------*/ 99 100 /*---------------------------------------------------------------------------- 101 ; FUNCTION CODE 102 ----------------------------------------------------------------------------*/ 103 104 105 #define R_SHIFT 29 106 #define Qfmt(x) (Int32)(x*((Int32)1<<R_SHIFT) + (x>=0?0.5F:-0.5F)) 107 108 #define Qfmt31(x) (Int32)(x*0x7FFFFFFF + (x>=0?0.5F:-0.5F)) 109 110 111 void dst_8(Int32 vec[]) 112 { 113 114 Int32 temp1; 115 Int32 temp2; 116 Int32 temp3; 117 Int32 temp4; 118 Int32 temp5; 119 Int32 temp6; 120 Int32 temp7; 121 Int32 tmp_a; 122 Int32 tmp_aa; 123 Int32 tmp_b; 124 Int32 tmp_bb; 125 Int32 tmp_c; 126 Int32 tmp_cc; 127 Int32 tmp_d; 128 Int32 tmp_dd; 129 130 temp1 = fxp_mul32_by_16(vec[1], Qfmt15(0.50979557910416F)); /* (1/(2*cos( phi)));*/ 131 temp2 = fxp_mul32_by_16(vec[2], Qfmt15(0.54119610014620F)); /* (1/(2*cos(2*phi)));*/ 132 temp3 = fxp_mul32_by_16(vec[3], Qfmt15(0.60134488693505F)); /* (1/(2*cos(3*phi)));*/ 133 temp5 = fxp_mul32_by_16(vec[5], Qfmt15(0.89997622313642F)); /* (1/(2*cos(5*phi)));*/ 134 temp6 = fxp_mul32_by_16(vec[6] << 1, Qfmt15(0.65328148243819F)); /* (1/(2*cos(6*phi)));*/ 135 temp7 = vec[7] + fxp_mul32_Q31(vec[7], Qfmt31(0.56291544774152F)); /* (1/(2*cos(7*phi)));*/ 136 137 /* even */ 138 tmp_a = fxp_mul32_Q31((temp2 + temp6) << 1, Qfmt31(0.70710678118655F)); 139 tmp_b = (temp2 - temp6) + tmp_a; 140 141 temp4 = fxp_mul32_by_16(vec[4], Qfmt15(0.70710678118655F)); 142 vec[0] = tmp_a + temp4; 143 vec[1] = tmp_b + temp4; 144 vec[2] = tmp_b - temp4; 145 vec[3] = tmp_a - temp4; 146 147 148 /* odd */ 149 150 tmp_a = fxp_mul32_by_16((temp1 + temp7) << 1, Qfmt15(0.54119610014620F)); /* (1/(2*cos(2*phi))); */ 151 tmp_aa = (temp1 - temp7); 152 tmp_bb = (temp5 - temp3); 153 temp5 = fxp_mul32_Q29((temp5 + temp3), Qfmt(1.30656296487638F)); /* (1/(2*cos(6*phi))); */ 154 155 156 tmp_c = fxp_mul32_by_16((tmp_a + temp5) << 1, Qfmt15(0.70710678118655F)); 157 tmp_cc = tmp_a - temp5; 158 159 tmp_d = fxp_mac32_by_16((tmp_aa - tmp_bb) << 1, Qfmt15(0.70710678118655F), tmp_c); 160 tmp_dd = (tmp_aa + tmp_bb); 161 162 tmp_dd += tmp_c; 163 tmp_a = tmp_d + tmp_cc; 164 vec[5] = tmp_a - vec[2]; 165 vec[2] += tmp_a; 166 167 temp5 = tmp_dd + tmp_cc; 168 169 vec[4] = temp5 - vec[3]; 170 vec[3] += temp5; 171 vec[7] = tmp_c - vec[0]; 172 vec[0] += tmp_c; 173 vec[6] = tmp_d - vec[1]; 174 vec[1] += tmp_d; 175 176 } 177 178 179 #endif 180