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 21 PacketVideo Corp. 22 MP3 Decoder Library 23 24 Filename: pvmp3_dct_9.cpp 25 26 Date: 09/21/2007 27 28------------------------------------------------------------------------------ 29 REVISION HISTORY 30 31 32 Description: 33 34------------------------------------------------------------------------------ 35 INPUT AND OUTPUT DEFINITIONS 36 37Input 38 int32 vec[] vector of 9 32-bit integers 39Returns 40 int32 vec[] dct computation in-place 41 42 43------------------------------------------------------------------------------ 44 FUNCTION DESCRIPTION 45 46 Returns the dct of length 9 of the input vector 47 48------------------------------------------------------------------------------ 49 REQUIREMENTS 50 51 52------------------------------------------------------------------------------ 53 REFERENCES 54 55------------------------------------------------------------------------------ 56 PSEUDO-CODE 57 58------------------------------------------------------------------------------ 59*/ 60 61#if ( !defined(PV_ARM_GCC_V5) && !defined(PV_ARM_GCC_V4) && !defined(PV_ARM_V5) && !defined(PV_ARM_V4) ) 62/*---------------------------------------------------------------------------- 63; INCLUDES 64----------------------------------------------------------------------------*/ 65#include "pvmp3_audio_type_defs.h" 66#include "pv_mp3dec_fxd_op.h" 67#include "pvmp3_mdct_18.h" 68 69/*---------------------------------------------------------------------------- 70; MACROS 71; Define module specific macros here 72----------------------------------------------------------------------------*/ 73 74 75/*---------------------------------------------------------------------------- 76; DEFINES 77; Include all pre-processor statements here. Include conditional 78; compile variables also. 79----------------------------------------------------------------------------*/ 80#define Qfmt31(a) (int32)(a*(0x7FFFFFFF)) 81 82#define cos_pi_9 Qfmt31( 0.93969262078591f) 83#define cos_2pi_9 Qfmt31( 0.76604444311898f) 84#define cos_4pi_9 Qfmt31( 0.17364817766693f) 85#define cos_5pi_9 Qfmt31(-0.17364817766693f) 86#define cos_7pi_9 Qfmt31(-0.76604444311898f) 87#define cos_8pi_9 Qfmt31(-0.93969262078591f) 88#define cos_pi_6 Qfmt31( 0.86602540378444f) 89#define cos_5pi_6 Qfmt31(-0.86602540378444f) 90#define cos_5pi_18 Qfmt31( 0.64278760968654f) 91#define cos_7pi_18 Qfmt31( 0.34202014332567f) 92#define cos_11pi_18 Qfmt31(-0.34202014332567f) 93#define cos_13pi_18 Qfmt31(-0.64278760968654f) 94#define cos_17pi_18 Qfmt31(-0.98480775301221f) 95 96/*---------------------------------------------------------------------------- 97; LOCAL FUNCTION DEFINITIONS 98; Function Prototype declaration 99----------------------------------------------------------------------------*/ 100 101/*---------------------------------------------------------------------------- 102; LOCAL STORE/BUFFER/POINTER DEFINITIONS 103; Variable declaration - defined here and used outside this module 104----------------------------------------------------------------------------*/ 105 106/*---------------------------------------------------------------------------- 107; EXTERNAL FUNCTION REFERENCES 108; Declare functions defined elsewhere and referenced in this module 109----------------------------------------------------------------------------*/ 110 111/*---------------------------------------------------------------------------- 112; EXTERNAL GLOBAL STORE/BUFFER/POINTER REFERENCES 113; Declare variables used in this module but defined elsewhere 114----------------------------------------------------------------------------*/ 115 116/*---------------------------------------------------------------------------- 117; FUNCTION CODE 118----------------------------------------------------------------------------*/ 119 120void pvmp3_dct_9(int32 vec[]) 121{ 122 123 /* split input vector */ 124 125 int32 tmp0 = vec[8] + vec[0]; 126 int32 tmp8 = vec[8] - vec[0]; 127 int32 tmp1 = vec[7] + vec[1]; 128 int32 tmp7 = vec[7] - vec[1]; 129 int32 tmp2 = vec[6] + vec[2]; 130 int32 tmp6 = vec[6] - vec[2]; 131 int32 tmp3 = vec[5] + vec[3]; 132 int32 tmp5 = vec[5] - vec[3]; 133 134 vec[0] = (tmp0 + tmp2 + tmp3) + (tmp1 + vec[4]); 135 vec[6] = ((tmp0 + tmp2 + tmp3) >> 1) - (tmp1 + vec[4]); 136 vec[2] = (tmp1 >> 1) - vec[4]; 137 vec[4] = -vec[2]; 138 vec[8] = -vec[2]; 139 vec[4] = fxp_mac32_Q32(vec[4], tmp0 << 1, cos_2pi_9); 140 vec[8] = fxp_mac32_Q32(vec[8], tmp0 << 1, cos_4pi_9); 141 vec[2] = fxp_mac32_Q32(vec[2], tmp0 << 1, cos_pi_9); 142 vec[2] = fxp_mac32_Q32(vec[2], tmp2 << 1, cos_5pi_9); 143 vec[4] = fxp_mac32_Q32(vec[4], tmp2 << 1, cos_8pi_9); 144 vec[8] = fxp_mac32_Q32(vec[8], tmp2 << 1, cos_2pi_9); 145 vec[8] = fxp_mac32_Q32(vec[8], tmp3 << 1, cos_8pi_9); 146 vec[4] = fxp_mac32_Q32(vec[4], tmp3 << 1, cos_4pi_9); 147 vec[2] = fxp_mac32_Q32(vec[2], tmp3 << 1, cos_7pi_9); 148 149 vec[1] = fxp_mul32_Q32(tmp5 << 1, cos_11pi_18); 150 vec[1] = fxp_mac32_Q32(vec[1], tmp6 << 1, cos_13pi_18); 151 vec[1] = fxp_mac32_Q32(vec[1], tmp7 << 1, cos_5pi_6); 152 vec[1] = fxp_mac32_Q32(vec[1], tmp8 << 1, cos_17pi_18); 153 vec[3] = fxp_mul32_Q32((tmp5 + tmp6 - tmp8) << 1, cos_pi_6); 154 vec[5] = fxp_mul32_Q32(tmp5 << 1, cos_17pi_18); 155 vec[5] = fxp_mac32_Q32(vec[5], tmp6 << 1, cos_7pi_18); 156 vec[5] = fxp_mac32_Q32(vec[5], tmp7 << 1, cos_pi_6); 157 vec[5] = fxp_mac32_Q32(vec[5], tmp8 << 1, cos_13pi_18); 158 vec[7] = fxp_mul32_Q32(tmp5 << 1, cos_5pi_18); 159 vec[7] = fxp_mac32_Q32(vec[7], tmp6 << 1, cos_17pi_18); 160 vec[7] = fxp_mac32_Q32(vec[7], tmp7 << 1, cos_pi_6); 161 vec[7] = fxp_mac32_Q32(vec[7], tmp8 << 1, cos_11pi_18); 162 163} 164 165 166 167#endif // If not assembly 168