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 Filename: mdct_18.cpp 24 25 Date: 09/21/2007 26 27 ------------------------------------------------------------------------------ 28 REVISION HISTORY 29 30 31 Description: 32 33 ------------------------------------------------------------------------------ 34 INPUT AND OUTPUT DEFINITIONS 35 36 Input 37 int32 vec[], input vector of length 6 38 int32 *history input for overlap and add, vector updated with 39 next overlap and add values 40 Returns 41 none mdct computation in-place 42 43 44 ------------------------------------------------------------------------------ 45 FUNCTION DESCRIPTION 46 47 Returns the mdct of length 6 of the input vector, as well as the overlap 48 vector for next iteration ( on history[]) 49 50 ------------------------------------------------------------------------------ 51 REQUIREMENTS 52 53 54 ------------------------------------------------------------------------------ 55 REFERENCES 56 57 ------------------------------------------------------------------------------ 58 PSEUDO-CODE 59 60 ------------------------------------------------------------------------------ 61 */ 62 63 64 /*---------------------------------------------------------------------------- 65 ; INCLUDES 66 ----------------------------------------------------------------------------*/ 67 68 #include "pv_mp3dec_fxd_op.h" 69 #include "pvmp3_mdct_6.h" 70 71 72 /*---------------------------------------------------------------------------- 73 ; MACROS 74 ; Define module specific macros here 75 ----------------------------------------------------------------------------*/ 76 77 78 /*---------------------------------------------------------------------------- 79 ; DEFINES 80 ; Include all pre-processor statements here. Include conditional 81 ; compile variables also. 82 ----------------------------------------------------------------------------*/ 83 #define QFORMAT 29 84 #define Qfmt29(a) (int32)((a)*((int32)1<<QFORMAT) + ((a)>=0?0.5F:-0.5F)) 85 86 /*---------------------------------------------------------------------------- 87 ; LOCAL FUNCTION DEFINITIONS 88 ; Function Prototype declaration 89 ----------------------------------------------------------------------------*/ 90 91 /*---------------------------------------------------------------------------- 92 ; LOCAL STORE/BUFFER/POINTER DEFINITIONS 93 ; Variable declaration - defined here and used outside this module 94 ----------------------------------------------------------------------------*/ 95 /* 96 * (1./(2*cos((pi/(2*N))*(2*i+1)))), N = 12, i = [0:N/2-1] 97 */ 98 99 const int32 cosTerms_1_ov_cos_phi_N6[6] = 100 { 101 102 Qfmt29(0.50431448029008f), Qfmt29(0.54119610014620f), 103 Qfmt29(0.63023620700513f), Qfmt29(0.82133981585229f), 104 Qfmt29(1.30656296487638f), Qfmt29(3.83064878777019f) 105 }; 106 107 /*---------------------------------------------------------------------------- 108 ; EXTERNAL FUNCTION REFERENCES 109 ; Declare functions defined elsewhere and referenced in this module 110 ----------------------------------------------------------------------------*/ 111 112 /*---------------------------------------------------------------------------- 113 ; EXTERNAL GLOBAL STORE/BUFFER/POINTER REFERENCES 114 ; Declare variables used in this module but defined elsewhere 115 ----------------------------------------------------------------------------*/ 116 117 /*---------------------------------------------------------------------------- 118 ; FUNCTION CODE 119 ----------------------------------------------------------------------------*/ 120 121 122 void pvmp3_mdct_6(int32 vec[], int32 *history) 123 { 124 int32 i; 125 int32 tmp; 126 int32 tmp1; 127 int32 tmp2; 128 129 int32 *pt_vec = vec; 130 int32 *pt_vec_o = vec; 131 const int32 *pt_cos = cosTerms_1_ov_cos_phi_N6; 132 133 for (i = 2; i != 0; i--) 134 { 135 tmp = *(pt_vec++); 136 tmp1 = *(pt_vec++); 137 tmp2 = *(pt_vec++); 138 *(pt_vec_o++) = fxp_mul32_Q29(tmp, *(pt_cos++)); 139 *(pt_vec_o++) = fxp_mul32_Q29(tmp1, *(pt_cos++)); 140 *(pt_vec_o++) = fxp_mul32_Q29(tmp2, *(pt_cos++)); 141 } 142 143 144 pvmp3_dct_6(vec); // Even terms 145 146 147 tmp = -(vec[0] + vec[1]); 148 history[3] = tmp; 149 history[2] = tmp; 150 tmp = -(vec[1] + vec[2]); 151 vec[0] = vec[3] + vec[4]; 152 vec[1] = vec[4] + vec[5]; 153 history[4] = tmp; 154 history[1] = tmp; 155 tmp = -(vec[2] + vec[3]); 156 vec[4] = -vec[1]; 157 history[5] = tmp; 158 history[0] = tmp; 159 160 vec[2] = vec[5]; 161 vec[3] = -vec[5]; 162 vec[5] = -vec[0]; 163 164 } 165 166