1 /* 2 ** Copyright 2003-2010, VisualOn, Inc. 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 express or implied. 13 ** See the License for the specific language governing permissions and 14 ** limitations under the License. 15 */ 16 /******************************************************************************* 17 File: oper_32b.h 18 19 Content: Double precision operations 20 21 *******************************************************************************/ 22 23 #ifndef __OPER_32b_H 24 #define __OPER_32b_H 25 26 #include "typedef.h" 27 28 #ifdef __cplusplus 29 extern "C" { 30 #endif 31 32 #define POW2_TABLE_BITS 8 33 #define POW2_TABLE_SIZE (1<<POW2_TABLE_BITS) 34 35 void L_Extract (Word32 L_32, Word16 *hi, Word16 *lo); 36 Word32 L_Comp (Word16 hi, Word16 lo); 37 Word32 Mpy_32 (Word16 hi1, Word16 lo1, Word16 hi2, Word16 lo2); 38 Word32 Mpy_32_16 (Word16 hi, Word16 lo, Word16 n); 39 Word32 Div_32 (Word32 L_num, Word32 denom); 40 Word16 iLog4(Word32 value); 41 Word32 rsqrt(Word32 value, Word32 accuracy); 42 Word32 pow2_xy(Word32 x, Word32 y); 43 44 __inline Word32 L_mpy_ls(Word32 L_var2, Word16 var1) 45 { 46 unsigned short swLow1; 47 Word16 swHigh1; 48 Word32 l_var_out; 49 50 swLow1 = (unsigned short)(L_var2); 51 swHigh1 = (Word16)(L_var2 >> 16); 52 53 l_var_out = (long)swLow1 * (long)var1 >> 15; 54 55 l_var_out += swHigh1 * var1 << 1; 56 57 return(l_var_out); 58 } 59 60 __inline Word32 L_mpy_wx(Word32 L_var2, Word16 var1) 61 { 62 #if ARMV5TE_L_MPY_LS 63 Word32 result; 64 asm volatile( 65 "SMULWB %[result], %[L_var2], %[var1] \n" 66 :[result]"=r"(result) 67 :[L_var2]"r"(L_var2), [var1]"r"(var1) 68 ); 69 return result; 70 #else 71 unsigned short swLow1; 72 Word16 swHigh1; 73 Word32 l_var_out; 74 75 swLow1 = (unsigned short)(L_var2); 76 swHigh1 = (Word16)(L_var2 >> 16); 77 78 l_var_out = (long)swLow1 * (long)var1 >> 16; 79 l_var_out += swHigh1 * var1; 80 81 return(l_var_out); 82 #endif 83 } 84 85 #ifdef __cplusplus 86 } 87 #endif 88 89 #endif 90