From 2c8e5cab3faa6d360e222b7a6c40a80083d021ac Mon Sep 17 00:00:00 2001 From: Eric Laurent Date: Fri, 9 Jul 2010 12:28:50 -0700 Subject: First submission of audio effect library from NXP software. This CL contains the first open sourceable version of the audio effect library from NXP software. The effects implemented are: - Bass boost - Virtualizer (stereo widening) - Equalizer - Spectrum analyzer Source file for the effect engines are located under libeffects/lvm/lib The wrapper implementing the interface with the audio effect framework in under libeffects/lvm/wrapper The code of other effect libraries has also been reorganized fo clarity: - the effect factory is now under libeffects/factory - the test equalizer and reverb effects are under libeffect/testlibs - the visualizer is under libeffects/virtualizer Change-Id: I8d91e2181f81b89f8fc0c1e1e6bf552c5809b2eb --- media/libeffects/lvm/lib/Common/lib/LVM_Macros.h | 130 +++++++++++++++++++++++ 1 file changed, 130 insertions(+) create mode 100755 media/libeffects/lvm/lib/Common/lib/LVM_Macros.h (limited to 'media/libeffects/lvm/lib/Common/lib/LVM_Macros.h') diff --git a/media/libeffects/lvm/lib/Common/lib/LVM_Macros.h b/media/libeffects/lvm/lib/Common/lib/LVM_Macros.h new file mode 100755 index 0000000..8bd363d --- /dev/null +++ b/media/libeffects/lvm/lib/Common/lib/LVM_Macros.h @@ -0,0 +1,130 @@ +/* + * Copyright (C) 2004-2010 NXP Software + * Copyright (C) 2010 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/********************************************************************************** + + $Author: beq07716 $ + $Revision: 1000 $ + $Date: 2010-06-28 13:08:20 +0200 (Mon, 28 Jun 2010) $ + +***********************************************************************************/ + +#ifndef _LVM_MACROS_H_ +#define _LVM_MACROS_H_ + +#ifdef __cplusplus +extern "C" { +#endif /* __cplusplus */ + +/********************************************************************************** + MUL32x32INTO32(A,B,C,ShiftR) + C = (A * B) >> ShiftR + + A, B and C are all 32 bit SIGNED numbers and ShiftR can vary from 0 to 64 + + The user has to take care that C does not overflow. The result in case + of overflow is undefined. + +***********************************************************************************/ +#ifndef MUL32x32INTO32 +#define MUL32x32INTO32(A,B,C,ShiftR) \ + {LVM_INT32 MUL32x32INTO32_temp,MUL32x32INTO32_temp2,MUL32x32INTO32_mask,MUL32x32INTO32_HH,MUL32x32INTO32_HL,MUL32x32INTO32_LH,MUL32x32INTO32_LL;\ + LVM_INT32 shiftValue;\ + shiftValue = (ShiftR);\ + MUL32x32INTO32_mask=0x0000FFFF;\ + MUL32x32INTO32_HH= ((LVM_INT32)((LVM_INT16)((A)>>16))*((LVM_INT16)((B)>>16)) );\ + MUL32x32INTO32_HL= ((LVM_INT32)((B)&MUL32x32INTO32_mask)*((LVM_INT16)((A)>>16))) ;\ + MUL32x32INTO32_LH= ((LVM_INT32)((A)&MUL32x32INTO32_mask)*((LVM_INT16)((B)>>16)));\ + MUL32x32INTO32_LL= (LVM_INT32)((A)&MUL32x32INTO32_mask)*(LVM_INT32)((B)&MUL32x32INTO32_mask);\ + MUL32x32INTO32_temp= (LVM_INT32)(MUL32x32INTO32_HL&MUL32x32INTO32_mask)+(LVM_INT32)(MUL32x32INTO32_LH&MUL32x32INTO32_mask)+(LVM_INT32)((MUL32x32INTO32_LL>>16)&MUL32x32INTO32_mask);\ + MUL32x32INTO32_HH= MUL32x32INTO32_HH+(LVM_INT32)(MUL32x32INTO32_HL>>16)+(LVM_INT32)(MUL32x32INTO32_LH>>16)+(LVM_INT32)(MUL32x32INTO32_temp>>16);\ + MUL32x32INTO32_LL=MUL32x32INTO32_LL+(LVM_INT32)(MUL32x32INTO32_HL<<16)+(LVM_INT32)(MUL32x32INTO32_LH<<16);\ + if(shiftValue<32)\ + {\ + MUL32x32INTO32_HH=MUL32x32INTO32_HH<<(32-shiftValue);\ + MUL32x32INTO32_mask=((LVM_INT32)1<<(32-shiftValue))-1;\ + MUL32x32INTO32_LL=(MUL32x32INTO32_LL>>shiftValue)&MUL32x32INTO32_mask;\ + MUL32x32INTO32_temp2=MUL32x32INTO32_HH|MUL32x32INTO32_LL;\ + }\ + else\ + {\ + MUL32x32INTO32_temp2=(LVM_INT32)MUL32x32INTO32_HH>>(shiftValue-32);\ + }\ + (C) = MUL32x32INTO32_temp2;\ + } +#endif + +/********************************************************************************** + MUL32x16INTO32(A,B,C,ShiftR) + C = (A * B) >> ShiftR + + A and C are 32 bit SIGNED numbers. B is a 16 bit SIGNED number. + ShiftR can vary from 0 to 48 + + The user has to take care that C does not overflow. The result in case + of overflow is undefined. + +***********************************************************************************/ +#ifndef MUL32x16INTO32 +#define MUL32x16INTO32(A,B,C,ShiftR) \ + {LVM_INT32 MUL32x16INTO32_mask,MUL32x16INTO32_HH,MUL32x16INTO32_LL;\ + LVM_INT32 shiftValue;\ + shiftValue = (ShiftR);\ + MUL32x16INTO32_mask=0x0000FFFF;\ + MUL32x16INTO32_HH= ((LVM_INT32)(B)*((LVM_INT16)((A)>>16)));\ + MUL32x16INTO32_LL= ((LVM_INT32)((A)&MUL32x16INTO32_mask)*(B));\ + if(shiftValue<16)\ + {\ + MUL32x16INTO32_HH=(LVM_INT32)((LVM_UINT32)MUL32x16INTO32_HH<<(16-shiftValue));\ + (C)=MUL32x16INTO32_HH+(LVM_INT32)(MUL32x16INTO32_LL>>shiftValue);\ + }\ + else if(shiftValue<32) {\ + MUL32x16INTO32_HH=(LVM_INT32)(MUL32x16INTO32_HH>>(shiftValue-16));\ + (C)=MUL32x16INTO32_HH+(LVM_INT32)(MUL32x16INTO32_LL>>shiftValue);\ + }\ + else {\ + (C)=MUL32x16INTO32_HH>>(shiftValue-16);}\ + } +#endif + +/********************************************************************************** + ADD2_SAT_32x32(A,B,C) + C = SAT(A + B) + + A,B and C are 32 bit SIGNED numbers. +***********************************************************************************/ +#ifndef ADD2_SAT_32x32 +#define ADD2_SAT_32x32(A,B,C) \ + {(C)=(A)+(B);\ + if ((((C) ^ (A)) & ((C) ^ (B))) >> 31)\ + {\ + if((A)<0)\ + (C)=0x80000000l;\ + else\ + (C)=0x7FFFFFFFl;\ + }\ + } +#endif + + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + +#endif /* _LVM_MACROS_H_ */ + +/*** End of file ******************************************************************/ -- cgit v1.1