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: idct8.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 inverse discrete cosine transform of lenght 8 39 40 ------------------------------------------------------------------------------ 41 REQUIREMENTS 42 43 44 ------------------------------------------------------------------------------ 45 REFERENCES 46 47 ------------------------------------------------------------------------------ 48 PSEUDO-CODE 49 50 ------------------------------------------------------------------------------ 51 */ 52 53 #ifdef AAC_PLUS 54 55 /*---------------------------------------------------------------------------- 56 ; INCLUDES 57 ----------------------------------------------------------------------------*/ 58 #include "idct8.h" 59 60 #include "fxp_mul32.h" 61 62 /*---------------------------------------------------------------------------- 63 ; MACROS 64 ; Define module specific macros here 65 ----------------------------------------------------------------------------*/ 66 67 68 /*---------------------------------------------------------------------------- 69 ; DEFINES 70 ; Include all pre-processor statements here. Include conditional 71 ; compile variables also. 72 ----------------------------------------------------------------------------*/ 73 74 75 #define R_SHIFT 29 76 #define Qfmt(x) (Int32)(x*((Int32)1<<R_SHIFT) + (x>=0?0.5F:-0.5F)) 77 78 #define Qfmt15(x) (Int16)(x*((Int32)1<<15) + (x>=0?0.5F:-0.5F)) 79 80 81 /*---------------------------------------------------------------------------- 82 ; LOCAL FUNCTION DEFINITIONS 83 ; Function Prototype declaration 84 ----------------------------------------------------------------------------*/ 85 86 /*---------------------------------------------------------------------------- 87 ; LOCAL STORE/BUFFER/POINTER DEFINITIONS 88 ; Variable declaration - defined here and used outside this module 89 ----------------------------------------------------------------------------*/ 90 91 /*---------------------------------------------------------------------------- 92 ; EXTERNAL FUNCTION REFERENCES 93 ; Declare functions defined elsewhere and referenced in this module 94 ----------------------------------------------------------------------------*/ 95 96 /*---------------------------------------------------------------------------- 97 ; EXTERNAL GLOBAL STORE/BUFFER/POINTER REFERENCES 98 ; Declare variables used in this module but defined elsewhere 99 ----------------------------------------------------------------------------*/ 100 101 /*---------------------------------------------------------------------------- 102 ; FUNCTION CODE 103 ----------------------------------------------------------------------------*/ 104 105 void idct_8(Int32 vec[]) 106 { 107 108 Int32 tmp0; 109 Int32 tmp1; 110 Int32 tmp2; 111 Int32 tmp3; 112 Int32 tmp4; 113 Int32 tmp5; 114 Int32 tmp6; 115 Int32 tmp7; 116 Int32 tmp8; 117 118 119 tmp5 = fxp_mul32_by_16(vec[4] << 1, Qfmt15(0.70710678118655F)); 120 121 tmp1 = vec[0] + tmp5; 122 tmp5 = vec[0] - tmp5; 123 124 tmp3 = fxp_mul32_by_16(vec[2] << 1, Qfmt15(0.54119610014620F)); /* (1/(2*cos(2*phi)));*/ 125 tmp7 = fxp_mul32_Q29(vec[6], Qfmt(1.30656296487638F)); /* (1/(2*cos(6*phi)));*/ 126 127 tmp0 = fxp_mul32_by_16((tmp3 - tmp7) << 1, Qfmt15(0.70710678118655F)); /* (1/(2*cos(2*phi))); */ 128 tmp7 = (tmp3 + tmp7) + tmp0; 129 130 vec[0] = tmp1 + tmp7; 131 tmp2 = fxp_mul32_by_16(vec[1] << 1, Qfmt15(0.50979557910416F)); /* (1/(2*cos( phi)));*/ 132 vec[1] = tmp5 + tmp0; 133 vec[2] = tmp5 - tmp0; 134 tmp4 = fxp_mul32_by_16(vec[3] << 1, Qfmt15(0.60134488693505F)); /* (1/(2*cos(3*phi)));*/ 135 vec[3] = tmp1 - tmp7; 136 137 tmp6 = fxp_mul32_by_16(vec[5] << 1, Qfmt15(0.89997622313642F)); /* (1/(2*cos(5*phi)));*/ 138 tmp8 = fxp_mul32_Q29(vec[7], Qfmt(2.56291544774151F)); /* (1/(2*cos(7*phi)));*/ 139 140 tmp7 = tmp2 + tmp8; 141 tmp5 = fxp_mul32_by_16((tmp2 - tmp8) << 1, Qfmt15(0.54119610014620F)); 142 tmp8 = tmp4 + tmp6; 143 tmp6 = fxp_mul32_Q29((tmp4 - tmp6), Qfmt(1.30656296487638F)); 144 145 tmp0 = tmp7 + tmp8; 146 tmp2 = fxp_mul32_by_16((tmp7 - tmp8) << 1, Qfmt15(0.70710678118655F)); 147 148 tmp3 = fxp_mul32_by_16((tmp5 - tmp6) << 1, Qfmt15(0.70710678118655F)); 149 tmp1 = (tmp5 + tmp6) + tmp3; 150 151 tmp5 = tmp0 + tmp1; 152 tmp6 = tmp1 + tmp2; 153 tmp7 = tmp2 + tmp3; 154 155 vec[7] = vec[0] - tmp5; 156 vec[0] += tmp5; 157 vec[6] = vec[1] - tmp6; 158 vec[1] += tmp6; 159 vec[5] = vec[2] - tmp7; 160 vec[2] += tmp7; 161 vec[4] = vec[3] - tmp3; 162 vec[3] += tmp3; 163 164 } 165 166 167 #endif 168 169