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: ps_hybrid_analysis.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 33 34------------------------------------------------------------------------------ 35 FUNCTION DESCRIPTION 36 37 Does Hybrid analysis 38 39------------------------------------------------------------------------------ 40 REQUIREMENTS 41 42 43------------------------------------------------------------------------------ 44 REFERENCES 45 46SC 29 Software Copyright Licencing Disclaimer: 47 48This software module was originally developed by 49 Coding Technologies 50 51and edited by 52 - 53 54in the course of development of the ISO/IEC 13818-7 and ISO/IEC 14496-3 55standards for reference purposes and its performance may not have been 56optimized. This software module is an implementation of one or more tools as 57specified by the ISO/IEC 13818-7 and ISO/IEC 14496-3 standards. 58ISO/IEC gives users free license to this software module or modifications 59thereof for use in products claiming conformance to audiovisual and 60image-coding related ITU Recommendations and/or ISO/IEC International 61Standards. ISO/IEC gives users the same free license to this software module or 62modifications thereof for research purposes and further ISO/IEC standardisation. 63Those intending to use this software module in products are advised that its 64use may infringe existing patents. ISO/IEC have no liability for use of this 65software module or modifications thereof. Copyright is not released for 66products that do not conform to audiovisual and image-coding related ITU 67Recommendations and/or ISO/IEC International Standards. 68The original developer retains full right to modify and use the code for its 69own purpose, assign or donate the code to a third party and to inhibit third 70parties from using the code for products that do not conform to audiovisual and 71image-coding related ITU Recommendations and/or ISO/IEC International Standards. 72This copyright notice must be included in all copies or derivative works. 73Copyright (c) ISO/IEC 2003. 74 75------------------------------------------------------------------------------ 76 PSEUDO-CODE 77 78------------------------------------------------------------------------------ 79*/ 80 81 82/*---------------------------------------------------------------------------- 83; INCLUDES 84----------------------------------------------------------------------------*/ 85 86#ifdef AAC_PLUS 87 88#ifdef PARAMETRICSTEREO 89 90#include "s_hybrid.h" 91#include "aac_mem_funcs.h" 92#include "ps_fft_rx8.h" 93#include "ps_channel_filtering.h" 94#include "pv_audio_type_defs.h" 95#include "fxp_mul32.h" 96/*---------------------------------------------------------------------------- 97; MACROS 98; Define module specific macros here 99----------------------------------------------------------------------------*/ 100 101 102/*---------------------------------------------------------------------------- 103; DEFINES 104; Include all pre-processor statements here. Include conditional 105; compile variables also. 106----------------------------------------------------------------------------*/ 107#define R_SHIFT 29 108#define Q29_fmt(x) (Int32)(x*((Int32)1<<R_SHIFT) + (x>=0?0.5F:-0.5F)) 109 110#define Qfmt31(a) (Int32)(-a*((Int32)1<<31) + (a>=0?0.5F:-0.5F)) 111 112/*---------------------------------------------------------------------------- 113; LOCAL FUNCTION DEFINITIONS 114; Function Prototype declaration 115----------------------------------------------------------------------------*/ 116 117/*---------------------------------------------------------------------------- 118; LOCAL STORE/BUFFER/POINTER DEFINITIONS 119; Variable declaration - defined here and used outside this module 120----------------------------------------------------------------------------*/ 121 122 123/*---------------------------------------------------------------------------- 124; EXTERNAL FUNCTION REFERENCES 125; Declare functions defined elsewhere and referenced in this module 126----------------------------------------------------------------------------*/ 127 128/*---------------------------------------------------------------------------- 129; EXTERNAL GLOBAL STORE/BUFFER/POINTER REFERENCES 130; Declare variables used in this module but defined elsewhere 131----------------------------------------------------------------------------*/ 132 133 134/*---------------------------------------------------------------------------- 135; FUNCTION CODE 136----------------------------------------------------------------------------*/ 137 138 139void two_ch_filtering(const Int32 *pQmf_r, 140 const Int32 *pQmf_i, 141 Int32 *mHybrid_r, 142 Int32 *mHybrid_i) 143{ 144 145 Int32 cum0; 146 Int32 cum1; 147 Int32 cum2; 148 Int32 tmp1; 149 Int32 tmp2; 150 151 tmp1 = pQmf_r[ 1] + pQmf_r[11]; 152 tmp2 = pQmf_i[ 1] + pQmf_i[11]; 153 cum1 = fxp_mul32_Q31(Qfmt31(0.03798975052098f), tmp1); 154 cum2 = fxp_mul32_Q31(Qfmt31(0.03798975052098f), tmp2); 155 tmp1 = pQmf_r[ 3] + pQmf_r[ 9]; 156 tmp2 = pQmf_i[ 3] + pQmf_i[ 9]; 157 cum1 = fxp_msu32_Q31(cum1, Qfmt31(0.14586278335076f), tmp1); 158 cum2 = fxp_msu32_Q31(cum2, Qfmt31(0.14586278335076f), tmp2); 159 tmp1 = pQmf_r[ 5] + pQmf_r[ 7]; 160 tmp2 = pQmf_i[ 5] + pQmf_i[ 7]; 161 cum1 = fxp_mac32_Q31(cum1, Qfmt31(0.61193261090336f), tmp1); 162 cum2 = fxp_mac32_Q31(cum2, Qfmt31(0.61193261090336f), tmp2); 163 164 cum0 = pQmf_r[HYBRID_FILTER_DELAY] >> 1; /* HYBRID_FILTER_DELAY == 6 */ 165 166 mHybrid_r[0] = (cum0 + cum1); 167 mHybrid_r[1] = (cum0 - cum1); 168 169 cum0 = pQmf_i[HYBRID_FILTER_DELAY] >> 1; /* HYBRID_FILTER_DELAY == 6 */ 170 171 mHybrid_i[0] = (cum0 + cum2); 172 mHybrid_i[1] = (cum0 - cum2); 173 174} 175 176 177 178 179 180/*---------------------------------------------------------------------------- 181; FUNCTION CODE 182----------------------------------------------------------------------------*/ 183 184 185void eight_ch_filtering(const Int32 *pQmfReal, 186 const Int32 *pQmfImag, 187 Int32 *mHybridReal, 188 Int32 *mHybridImag, 189 Int32 scratch_mem[]) 190 191{ 192 193 Int32 real; 194 Int32 imag; 195 Int32 tmp1; 196 Int32 tmp2; 197 198 real = fxp_mul32_Q29(Q29_fmt(-0.06989827306334f), pQmfReal[ 4]); 199 200 real = fxp_mac32_Q31(real, Qfmt31(0.01055120626280f), pQmfReal[12]); 201 imag = fxp_mul32_Q29(Q29_fmt(-0.06989827306334f), pQmfImag[ 4]); 202 203 imag = fxp_mac32_Q31(imag, Qfmt31(0.01055120626280f), pQmfImag[12]); 204 205 mHybridReal[2] = (imag - real); 206 mHybridImag[2] = -(imag + real); 207 208 real = fxp_mul32_Q29(Q29_fmt(-0.07266113929591f), pQmfReal[ 3]); 209 210 real = fxp_mac32_Q31(real, Qfmt31(0.04540841899650f), pQmfReal[11]); 211 imag = fxp_mul32_Q29(Q29_fmt(-0.07266113929591f), pQmfImag[ 3]); 212 213 imag = fxp_mac32_Q31(imag, Qfmt31(0.04540841899650f), pQmfImag[11]); 214 215 tmp1 = fxp_mul32_Q29(Q29_fmt(-0.38268343236509f), real); 216 mHybridReal[3] = fxp_mac32_Q29(Q29_fmt(0.92387953251129f), imag, tmp1); 217 tmp2 = fxp_mul32_Q29(Q29_fmt(-0.92387953251129f), real); 218 mHybridImag[3] = fxp_mac32_Q29(Q29_fmt(-0.38268343236509f), imag, tmp2); 219 220 221 mHybridImag[4] = fxp_mul32_Q31(Qfmt31(0.09093731860946f), (pQmfReal[ 2] - pQmfReal[10])); 222 mHybridReal[4] = fxp_mul32_Q31(Qfmt31(0.09093731860946f), (pQmfImag[10] - pQmfImag[ 2])); 223 224 225 real = fxp_mul32_Q29(Q29_fmt(-0.02270420949825f), pQmfReal[ 1]); 226 227 real = fxp_mac32_Q31(real, Qfmt31(0.14532227859182f), pQmfReal[ 9]); 228 imag = fxp_mul32_Q29(Q29_fmt(-0.02270420949825f), pQmfImag[ 1]); 229 230 imag = fxp_mac32_Q31(imag, Qfmt31(0.14532227859182f), pQmfImag[ 9]); 231 232 tmp1 = fxp_mul32_Q29(Q29_fmt(0.92387953251129f), imag); 233 234 mHybridReal[5] = fxp_mac32_Q31(tmp1, Qfmt31(0.76536686473018f), real); 235 tmp2 = fxp_mul32_Q29(Q29_fmt(-0.92387953251129f), real); 236 237 mHybridImag[5] = fxp_mac32_Q31(tmp2, Qfmt31(0.76536686473018f), imag); 238 239 real = fxp_mul32_Q29(Q29_fmt(-0.00527560313140f), pQmfReal[ 0]); 240 241 real = fxp_mac32_Q31(real, Qfmt31(0.13979654612668f), pQmfReal[ 8]); 242 imag = fxp_mul32_Q29(Q29_fmt(-0.00527560313140f), pQmfImag[ 0]); 243 244 imag = fxp_mac32_Q31(imag, Qfmt31(0.13979654612668f), pQmfImag[ 8]); 245 246 mHybridReal[6] = (imag + real); 247 mHybridImag[6] = (imag - real); 248 249 250 tmp1 = fxp_mul32_Q31(Qfmt31(0.21791935610828f), pQmfReal[ 7]); 251 mHybridReal[7] = fxp_mac32_Q31(tmp1, Qfmt31(0.09026515280366f), pQmfImag[ 7]); 252 253 tmp2 = fxp_mul32_Q29(Q29_fmt(-0.04513257640183f), pQmfReal[ 7]); 254 255 mHybridImag[7] = fxp_mac32_Q31(tmp2, Qfmt31(0.21791935610828f), pQmfImag[ 7]); 256 257 mHybridReal[0] = pQmfReal[HYBRID_FILTER_DELAY] >> 3; 258 mHybridImag[0] = pQmfImag[HYBRID_FILTER_DELAY] >> 3; 259 260 tmp1 = fxp_mul32_Q29(Q29_fmt(-0.04513257640183f), pQmfImag[ 5]); 261 262 mHybridReal[1] = fxp_mac32_Q31(tmp1, Qfmt31(0.21791935610828f), pQmfReal[ 5]); 263 264 265 tmp2 = fxp_mul32_Q31(Qfmt31(0.21791935610828f), pQmfImag[ 5]); 266 mHybridImag[1] = fxp_mac32_Q31(tmp2, Qfmt31(0.09026515280366f), pQmfReal[ 5]); 267 268 /* 269 * 8*ifft 270 */ 271 272 ps_fft_rx8(mHybridReal, mHybridImag, scratch_mem); 273 274} 275 276 277#endif 278 279 280#endif 281 282