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: idct32.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 inverse discrete cosine 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 #include "idct32.h" 61 #include "dst32.h" 62 #include "idct16.h" 63 64 #include "fxp_mul32.h" 65 66 67 /*---------------------------------------------------------------------------- 68 ; MACROS 69 ; Define module specific macros here 70 ----------------------------------------------------------------------------*/ 71 72 73 /*---------------------------------------------------------------------------- 74 ; DEFINES 75 ; Include all pre-processor statements here. Include conditional 76 ; compile variables also. 77 ----------------------------------------------------------------------------*/ 78 79 80 81 #define R_SHIFT1 29 82 #define Qfmt1(x) (Int32)(x*((Int32)1<<R_SHIFT1) + (x>=0?0.5F:-0.5F)) 83 84 #define Qfmt3(a) (Int32)(a*0x7FFFFFFF + (a>=0?0.5F:-0.5F)) 85 86 87 /*---------------------------------------------------------------------------- 88 ; LOCAL FUNCTION DEFINITIONS 89 ; Function Prototype declaration 90 ----------------------------------------------------------------------------*/ 91 92 /*---------------------------------------------------------------------------- 93 ; LOCAL STORE/BUFFER/POINTER DEFINITIONS 94 ; Variable declaration - defined here and used outside this module 95 ----------------------------------------------------------------------------*/ 96 97 /*---------------------------------------------------------------------------- 98 ; EXTERNAL FUNCTION REFERENCES 99 ; Declare functions defined elsewhere and referenced in this module 100 ----------------------------------------------------------------------------*/ 101 102 /*---------------------------------------------------------------------------- 103 ; EXTERNAL GLOBAL STORE/BUFFER/POINTER REFERENCES 104 ; Declare variables used in this module but defined elsewhere 105 ----------------------------------------------------------------------------*/ 106 107 /*---------------------------------------------------------------------------- 108 ; FUNCTION CODE 109 ----------------------------------------------------------------------------*/ 110 111 void idct_32(Int32 vec[], Int32 scratch_mem[]) /* scratch_mem size 32 */ 112 { 113 Int32 *temp_even = scratch_mem; 114 115 Int32 i; 116 const Int32 *pt_cos = CosTable_16; 117 Int32 tmp1, tmp2; 118 Int32 *pt_even = temp_even; 119 Int32 *pt_odd = vec; 120 Int32 *pt_vec = vec; 121 Int32 *pt_vecN_1; 122 Int32 tmp3; 123 124 125 *(pt_even++) = *(pt_vec++); 126 tmp1 = *(pt_vec++); 127 tmp2 = 0; 128 129 for (i = 7; i != 0; i--) 130 { 131 *(pt_odd++) = tmp2 + tmp1; 132 *(pt_even++) = *(pt_vec++); 133 tmp2 = *(pt_vec++); 134 *(pt_even++) = *(pt_vec++); 135 *(pt_odd++) = tmp2 + tmp1; 136 tmp1 = *(pt_vec++); 137 } 138 139 *(pt_odd++) = tmp2 + tmp1; 140 *(pt_even++) = *(pt_vec++); 141 tmp2 = *(pt_vec++); 142 *(pt_odd++) = tmp2 + tmp1; 143 144 145 idct_16(temp_even, &scratch_mem[16]); 146 idct_16(vec, &scratch_mem[24]); 147 148 149 pt_cos = &CosTable_16[13]; 150 151 pt_vec = &vec[15]; 152 153 pt_even = &temp_even[15]; 154 pt_vecN_1 = &vec[16]; 155 156 tmp1 = *(pt_even--); 157 158 159 tmp3 = fxp_mul32_Q31(*(pt_vec) << 3, Qfmt3(0.63687550772175F)) << 2; 160 tmp2 = *(pt_even--); 161 *(pt_vecN_1++) = tmp1 - tmp3; 162 *(pt_vec--) = tmp1 + tmp3; 163 tmp3 = fxp_mul32_Q31(*(pt_vec) << 3, Qfmt3(0.85190210461718F)); 164 165 tmp1 = *(pt_even--); 166 *(pt_vecN_1++) = tmp2 - tmp3; 167 *(pt_vec--) = tmp2 + tmp3; 168 169 for (i = 2; i != 0; i--) 170 { 171 tmp3 = fxp_mul32_Q29(*(pt_vec), *(pt_cos--)); 172 tmp2 = *(pt_even--); 173 *(pt_vecN_1++) = tmp1 - tmp3; 174 *(pt_vec--) = tmp1 + tmp3; 175 tmp3 = fxp_mul32_Q29(*(pt_vec), *(pt_cos--)); 176 tmp1 = *(pt_even--); 177 *(pt_vecN_1++) = tmp2 - tmp3; 178 *(pt_vec--) = tmp2 + tmp3; 179 } 180 181 for (i = 5; i != 0; i--) 182 { 183 tmp3 = fxp_mul32_Q31(*(pt_vec) << 1, *(pt_cos--)); 184 tmp2 = *(pt_even--); 185 *(pt_vecN_1++) = tmp1 - tmp3; 186 *(pt_vec--) = tmp1 + tmp3; 187 tmp3 = fxp_mul32_Q31(*(pt_vec) << 1, *(pt_cos--)); 188 tmp1 = *(pt_even--); 189 *(pt_vecN_1++) = tmp2 - tmp3; 190 *(pt_vec--) = tmp2 + tmp3; 191 } 192 } 193 194 195 196 #endif 197