1e2e838afcf03e603a41a0455846eaf9614537c16Mans Rullgard/* 2e2e838afcf03e603a41a0455846eaf9614537c16Mans Rullgard ** Copyright 2003-2010, VisualOn, Inc. 3e2e838afcf03e603a41a0455846eaf9614537c16Mans Rullgard ** 4e2e838afcf03e603a41a0455846eaf9614537c16Mans Rullgard ** Licensed under the Apache License, Version 2.0 (the "License"); 5e2e838afcf03e603a41a0455846eaf9614537c16Mans Rullgard ** you may not use this file except in compliance with the License. 6e2e838afcf03e603a41a0455846eaf9614537c16Mans Rullgard ** You may obtain a copy of the License at 7e2e838afcf03e603a41a0455846eaf9614537c16Mans Rullgard ** 8e2e838afcf03e603a41a0455846eaf9614537c16Mans Rullgard ** http://www.apache.org/licenses/LICENSE-2.0 9e2e838afcf03e603a41a0455846eaf9614537c16Mans Rullgard ** 10e2e838afcf03e603a41a0455846eaf9614537c16Mans Rullgard ** Unless required by applicable law or agreed to in writing, software 11e2e838afcf03e603a41a0455846eaf9614537c16Mans Rullgard ** distributed under the License is distributed on an "AS IS" BASIS, 12e2e838afcf03e603a41a0455846eaf9614537c16Mans Rullgard ** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13e2e838afcf03e603a41a0455846eaf9614537c16Mans Rullgard ** See the License for the specific language governing permissions and 14e2e838afcf03e603a41a0455846eaf9614537c16Mans Rullgard ** limitations under the License. 15e2e838afcf03e603a41a0455846eaf9614537c16Mans Rullgard */ 16e2e838afcf03e603a41a0455846eaf9614537c16Mans Rullgard/******************************************************************************* 17e2e838afcf03e603a41a0455846eaf9614537c16Mans Rullgard File: oper_32b.h 18e2e838afcf03e603a41a0455846eaf9614537c16Mans Rullgard 19e2e838afcf03e603a41a0455846eaf9614537c16Mans Rullgard Content: Double precision operations 20e2e838afcf03e603a41a0455846eaf9614537c16Mans Rullgard 21956c553ab0ce72f8074ad0fda2ffd66a0305700cJames Dong*******************************************************************************/ 22956c553ab0ce72f8074ad0fda2ffd66a0305700cJames Dong 23956c553ab0ce72f8074ad0fda2ffd66a0305700cJames Dong#ifndef __OPER_32b_H 24956c553ab0ce72f8074ad0fda2ffd66a0305700cJames Dong#define __OPER_32b_H 25e2e838afcf03e603a41a0455846eaf9614537c16Mans Rullgard 26e2e838afcf03e603a41a0455846eaf9614537c16Mans Rullgard#include "typedef.h" 27956c553ab0ce72f8074ad0fda2ffd66a0305700cJames Dong 28956c553ab0ce72f8074ad0fda2ffd66a0305700cJames Dong#ifdef __cplusplus 29956c553ab0ce72f8074ad0fda2ffd66a0305700cJames Dongextern "C" { 30956c553ab0ce72f8074ad0fda2ffd66a0305700cJames Dong#endif 31e2e838afcf03e603a41a0455846eaf9614537c16Mans Rullgard 32e2e838afcf03e603a41a0455846eaf9614537c16Mans Rullgard#define POW2_TABLE_BITS 8 33e2e838afcf03e603a41a0455846eaf9614537c16Mans Rullgard#define POW2_TABLE_SIZE (1<<POW2_TABLE_BITS) 34956c553ab0ce72f8074ad0fda2ffd66a0305700cJames Dong 35956c553ab0ce72f8074ad0fda2ffd66a0305700cJames Dongvoid L_Extract (Word32 L_32, Word16 *hi, Word16 *lo); 36956c553ab0ce72f8074ad0fda2ffd66a0305700cJames DongWord32 L_Comp (Word16 hi, Word16 lo); 37956c553ab0ce72f8074ad0fda2ffd66a0305700cJames DongWord32 Mpy_32 (Word16 hi1, Word16 lo1, Word16 hi2, Word16 lo2); 38956c553ab0ce72f8074ad0fda2ffd66a0305700cJames DongWord32 Mpy_32_16 (Word16 hi, Word16 lo, Word16 n); 39956c553ab0ce72f8074ad0fda2ffd66a0305700cJames DongWord32 Div_32 (Word32 L_num, Word32 denom); 40e2e838afcf03e603a41a0455846eaf9614537c16Mans RullgardWord16 iLog4(Word32 value); 41e2e838afcf03e603a41a0455846eaf9614537c16Mans RullgardWord32 rsqrt(Word32 value, Word32 accuracy); 42e2e838afcf03e603a41a0455846eaf9614537c16Mans RullgardWord32 pow2_xy(Word32 x, Word32 y); 43e2e838afcf03e603a41a0455846eaf9614537c16Mans Rullgard 44e2e838afcf03e603a41a0455846eaf9614537c16Mans Rullgard__inline Word32 L_mpy_ls(Word32 L_var2, Word16 var1) 45e2e838afcf03e603a41a0455846eaf9614537c16Mans Rullgard{ 46e2e838afcf03e603a41a0455846eaf9614537c16Mans Rullgard unsigned short swLow1; 47e2e838afcf03e603a41a0455846eaf9614537c16Mans Rullgard Word16 swHigh1; 48e2e838afcf03e603a41a0455846eaf9614537c16Mans Rullgard Word32 l_var_out; 49e2e838afcf03e603a41a0455846eaf9614537c16Mans Rullgard 50e2e838afcf03e603a41a0455846eaf9614537c16Mans Rullgard swLow1 = (unsigned short)(L_var2); 51e2e838afcf03e603a41a0455846eaf9614537c16Mans Rullgard swHigh1 = (Word16)(L_var2 >> 16); 52e2e838afcf03e603a41a0455846eaf9614537c16Mans Rullgard 53e2e838afcf03e603a41a0455846eaf9614537c16Mans Rullgard l_var_out = (long)swLow1 * (long)var1 >> 15; 54b676a05348e4c516fa8b57e33b10548e6142c3f8Mans Rullgard 55e2e838afcf03e603a41a0455846eaf9614537c16Mans Rullgard l_var_out += swHigh1 * var1 << 1; 56b676a05348e4c516fa8b57e33b10548e6142c3f8Mans Rullgard 57e2e838afcf03e603a41a0455846eaf9614537c16Mans Rullgard return(l_var_out); 58e2e838afcf03e603a41a0455846eaf9614537c16Mans Rullgard} 59e2e838afcf03e603a41a0455846eaf9614537c16Mans Rullgard 60e2e838afcf03e603a41a0455846eaf9614537c16Mans Rullgard__inline Word32 L_mpy_wx(Word32 L_var2, Word16 var1) 61e2e838afcf03e603a41a0455846eaf9614537c16Mans Rullgard{ 62e2e838afcf03e603a41a0455846eaf9614537c16Mans Rullgard#if ARMV5TE_L_MPY_LS 63b676a05348e4c516fa8b57e33b10548e6142c3f8Mans Rullgard Word32 result; 64b676a05348e4c516fa8b57e33b10548e6142c3f8Mans Rullgard asm volatile( 65b676a05348e4c516fa8b57e33b10548e6142c3f8Mans Rullgard "SMULWB %[result], %[L_var2], %[var1] \n" 66721f2bb7b28891c0811a5bea31fa62644131befcMartin Storsjo :[result]"=r"(result) 67e2e838afcf03e603a41a0455846eaf9614537c16Mans Rullgard :[L_var2]"r"(L_var2), [var1]"r"(var1) 68b676a05348e4c516fa8b57e33b10548e6142c3f8Mans Rullgard ); 69e2e838afcf03e603a41a0455846eaf9614537c16Mans Rullgard return result; 70e2e838afcf03e603a41a0455846eaf9614537c16Mans Rullgard#else 71e2e838afcf03e603a41a0455846eaf9614537c16Mans Rullgard unsigned short swLow1; 72e2e838afcf03e603a41a0455846eaf9614537c16Mans Rullgard Word16 swHigh1; 73e2e838afcf03e603a41a0455846eaf9614537c16Mans Rullgard Word32 l_var_out; 74e2e838afcf03e603a41a0455846eaf9614537c16Mans Rullgard 75e2e838afcf03e603a41a0455846eaf9614537c16Mans Rullgard swLow1 = (unsigned short)(L_var2); 76e2e838afcf03e603a41a0455846eaf9614537c16Mans Rullgard swHigh1 = (Word16)(L_var2 >> 16); 77e2e838afcf03e603a41a0455846eaf9614537c16Mans Rullgard 78b676a05348e4c516fa8b57e33b10548e6142c3f8Mans Rullgard l_var_out = (long)swLow1 * (long)var1 >> 16; 79e2e838afcf03e603a41a0455846eaf9614537c16Mans Rullgard l_var_out += swHigh1 * var1; 80b676a05348e4c516fa8b57e33b10548e6142c3f8Mans Rullgard 81e2e838afcf03e603a41a0455846eaf9614537c16Mans Rullgard return(l_var_out); 82e2e838afcf03e603a41a0455846eaf9614537c16Mans Rullgard#endif 83e2e838afcf03e603a41a0455846eaf9614537c16Mans Rullgard} 84956c553ab0ce72f8074ad0fda2ffd66a0305700cJames Dong 85956c553ab0ce72f8074ad0fda2ffd66a0305700cJames Dong#ifdef __cplusplus 86956c553ab0ce72f8074ad0fda2ffd66a0305700cJames Dong} 87956c553ab0ce72f8074ad0fda2ffd66a0305700cJames Dong#endif 88956c553ab0ce72f8074ad0fda2ffd66a0305700cJames Dong 89956c553ab0ce72f8074ad0fda2ffd66a0305700cJames Dong#endif 90