⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 enh40.h

📁 最新的ITU-T的宽带语音编解码标准G.729.1,是对原先的G.729的最好的调整.码流输出速率可以进行自适应调整.满足未来通信要求.希望对大家有所帮助.
💻 H
📖 第 1 页 / 共 2 页
字号:
/*  ===========================================================================   File: ENH40.H                                         v.2.1 - March 2006  ===========================================================================            ITU-T  STL  BASIC OPERATORS            40-BIT ARITHMETIC OPERATORS   History:   07 Nov 04   v2.0     Incorporation of new 32-bit / 40-bit / control                        operators for the ITU-T Standard Tool Library as                         described in Geneva, 20-30 January 2004 WP 3/16 Q10/16                        TD 11 document and subsequent discussions on the                        wp3audio@yahoogroups.com email reflector.   March 06   v2.1      Changed to improve portability.                          ============================================================================*/#ifndef _ENH40_H#define _ENH40_H#include "stl.h"#ifdef WMOPSextern BASIC_OP multiCounter[MAXCOUNTERS];extern int currCounter;#endif /* ifdef WMOPS *//***************************************************************************** * *  Constants and Globals * *****************************************************************************/#ifdef _MSC_VER#define MAX_40 (0x0000007fffffffff)#define MIN_40 (0xffffff8000000000)#endif /* ifdef _MSC_VER *//***************************************************************************** * *  Macros for 40 bit arithmetic overflow management : *  Upon 40-bit overflow beyond MAX_40 or underflow beyond MIN_40, *  the application will exit. * *****************************************************************************/#define L40_OVERFLOW_OCCURED(  L40_var1) (Overflow = 1, exit(1), L40_var1) #define L40_UNDERFLOW_OCCURED( L40_var1) (Overflow = 1, exit(2), L40_var1)  /***************************************************************************** * *  Prototypes for enhanced 40 bit arithmetic operators * *****************************************************************************/Word40 L40_shr(   Word40 L40_var1, Word16 var2);Word40 L40_shr_r( Word40 L40_var1, Word16 var2);Word40 L40_shl(   Word40 L40_var1, Word16 var2);Word40 L40_shl_r( Word40 L40_var1, Word16 var2);static __inline Word40 L40_mult(      Word16 var1,   Word16 var2);static __inline Word40 L40_mac(      Word40 L40_var1, Word16 var1,   Word16 var2);static __inline Word16 mac_r40(      Word40 L40_var1, Word16 var1,   Word16 var2);static __inline Word40 L40_msu(      Word40 L40_var1, Word16 var1,   Word16 var2);static __inline Word16 msu_r40(      Word40 L40_var1, Word16 var1,   Word16 var2);void Mpy_32_16_ss( Word32 L_var1, Word16 var2,   Word32 *L_varout_h, UWord16 *varout_l);void Mpy_32_32_ss( Word32 L_var1, Word32 L_var2, Word32 *L_varout_h, UWord32 *L_varout_l);Word40 L40_lshl(  Word40 L40_var1, Word16 var2);Word40 L40_lshr(  Word40 L40_var1, Word16 var2);static __inline Word40 L40_set(      Word40 L40_var1);static __inline UWord16 Extract40_H( Word40 L40_var1);static __inline UWord16 Extract40_L( Word40 L40_var1);static __inline UWord32 L_Extract40(  Word40 L40_var1);static __inline Word40 L40_deposit_h( Word16 var1);static __inline Word40 L40_deposit_l( Word16 var1);static __inline Word40 L40_deposit32( Word32 L_var1);static __inline Word40 L40_round(     Word40 L40_var1);static __inline Word16 round40(       Word40 L40_var1);Word40 L40_add( Word40 L40_var1, Word40 L40_var2);Word40 L40_sub( Word40 L40_var1, Word40 L40_var2);Word40 L40_abs( Word40 L40_var1);Word40 L40_negate( Word40 L40_var1);Word40 L40_max( Word40 L40_var1, Word40 L40_var2);Word40 L40_min( Word40 L40_var1, Word40 L40_var2);Word32 L_saturate40( Word40 L40_var1);Word16 norm_L40(     Word40 L40_var1);/***************************************************************************** * *  Functions * *****************************************************************************//***************************************************************************** * *  Function Name : L40_set * *  Purpose : * *    Assigns a 40 constant to a Word40 with adequate initialization depending *    on underlying architecture constraints (for example to keep consistency *    of sign bits). Current implementation only validated on MSVC++6.0. * *  Complexity weight : 3 * *  Inputs : * *    L40_var1    40 bit long signed integer (Word40) whose value falls in the *                range : MIN_40 <= L40_var1 <= MAX_40. * *  Outputs : * *    none * *  Return Value : * *    L40_var_out 40 bit long signed integer (Word40) whose value falls in *                the range : MIN_40 <= L40_var_out <= MAX_40. * *****************************************************************************//*#ifdef _MSC_VER*/static __inline Word40 L40_set( Word40 L40_var1) {   Word40 L40_var_out;      L40_var_out =  L40_var1 & 0x000000ffffffffff;   if( L40_var1 & 0x8000000000)      L40_var_out = L40_var_out | 0xffffff0000000000;   #ifdef WMOPS   multiCounter[currCounter].L40_set++;   #endif /* ifdef WMOPS */   return( L40_var_out);}/*#endif*/ /* ifdef _MSC_VER *//***************************************************************************** * *  Function Name : Extract40_H * *  Purpose : * *    Returns the bits [31-16] of L40_var1. * *  Complexity weight : 1 * *  Inputs : * *    L40_var1    40 bit long signed integer (Word40) whose value falls in the *                range : MIN_40 <= L40_var1 <= MAX_40. * *  Outputs : * *    none * *  Return Value : * *    var_out     16 bit short unsigned integer (UWord16) whose value falls in *                the range : MIN_U_16 <= var_out <= MAX_U_16. * *****************************************************************************/static __inline UWord16 Extract40_H( Word40 L40_var1) {   UWord16 var_out;   var_out = ( UWord16)( L40_var1 >> 16);   #if (WMOPS)   multiCounter[currCounter].Extract40_H++;   #endif /* ifdef WMOPS */   return( var_out);}/***************************************************************************** * *  Function Name : Extract40_L * *  Purpose : * *    Returns the bits [15-0] of L40_var1. * *  Complexity weight : 1 * *  Inputs : * *    L40_var1    40 bit long signed integer (Word40) whose value falls in the *                range : MIN_40 <= L40_var1 <= MAX_40. * *  Outputs : * *    none * *  Return Value : * *    var_out     16 bit short unsigned integer (UWord16) whose value falls in *                the range : MIN_U_16 <= var_out <= MAX_U_16. * *****************************************************************************/static __inline UWord16 Extract40_L( Word40 L40_var1) {   UWord16 var_out;   var_out = ( UWord16)( L40_var1);   #if (WMOPS)   multiCounter[currCounter].Extract40_L++;   #endif /* ifdef WMOPS */   return( var_out);}/***************************************************************************** * *  Function Name : L_Extract40 * *  Purpose : * *    Returns the bits [31-0] of L40_var1. * *  Complexity weight : 1 * *  Inputs : * *    L40_var1    40 bit long signed integer (Word40) whose value falls in the *                range : MIN_40 <= L40_var1 <= MAX_40. * *  Outputs : * *    none * *  Return Value : * *    L_var_out   32 bit long unsigned integer (UWord32) whose value falls in *                range : MIN_U_32 <= L_var_out <= MAX_U_32. * *****************************************************************************/static __inline UWord32 L_Extract40( Word40 L40_var1) {   UWord32 L_var_out;   L_var_out = ( UWord32) L40_var1;   #if (WMOPS)   multiCounter[currCounter].L_Extract40++;   #endif /* ifdef WMOPS */   return(L_var_out);} /***************************************************************************** * *  Function Name : L40_deposit_h * *  Purpose : * *    Deposits var1 in the bits [31-16] in a 40-bit number. The 16 LSBits of *    the output are zeroed and the 8 MSBits sign extend var1 sign bit. * *  Complexity weight : 1 * *  Inputs : * *    var1        16 bit short signed integer (Word16) whose value falls in  *                the range : MIN_16 <= var1 <= MAX_16. * *  Outputs : * *    none * *  Return Value : * *    L40_var_out 40 bit long signed integer (Word40) whose value falls in *                the range : MIN_40 <= L40_var_out <= MAX_40. * *****************************************************************************/static __inline Word40 L40_deposit_h( Word16 var1) {   Word40 L40_var_out;   L40_var_out = (( Word40) var1) << 16;   if( var1 & 0x8000) {      L40_var_out = L40_set( L40_var_out | 0xff00000000);      #if (WMOPS)      multiCounter[currCounter].L40_set--;      #endif /* ifdef WMOPS */   }   #if (WMOPS)   multiCounter[currCounter].L40_deposit_h++;   #endif /* ifdef WMOPS */   return( L40_var_out);}   /***************************************************************************** * *  Function Name : L40_deposit_l * *  Purpose : * *    Deposits var1 in the bits [15-0] in a 40-bit number. The 24 MSBits sign *    extend var1 sign bit. * *  Complexity weight : 1 * *  Inputs : * *    var1        16 bit short signed integer (Word16) whose value falls in  *                the range : MIN_16 <= var1 <= MAX_16. * *  Outputs : * *    none * *  Return Value : * *    L40_var_out 40 bit long signed integer (Word40) whose value falls in *                the range : MIN_40 <= L40_var_out <= MAX_40. * *****************************************************************************/static __inline Word40 L40_deposit_l( Word16 var1) {   Word40 L40_var_out;   L40_var_out = var1;   if( var1 & 0x8000) {      L40_var_out = L40_set( L40_var_out | 0xffffff0000);      #if (WMOPS)      multiCounter[currCounter].L40_set--;      #endif /* ifdef WMOPS */   }   #if (WMOPS)   multiCounter[currCounter].L40_deposit_l++;   #endif /* ifdef WMOPS */   return( L40_var_out);}   /***************************************************************************** * *  Function Name : L40_deposit32 * *  Purpose : * *    Deposits L_var1 in the bits [31-0] in a 40-bit number. The 8 MSBits sign *    extend L_var1 sign bit. * *  Complexity weight : 1 * *  Inputs : * *    L_var1      32 bit long signed integer (Word32) whose value falls in the *                range : 0x8000 0000 <= L_var1 <= 0x7fff ffff. * *  Outputs : * *    none * *  Return Value : * *    L40_var_out 40 bit long signed integer (Word40) whose value falls in *                the range : MIN_40 <= L40_var_out <= MAX_40. * *****************************************************************************/static __inline Word40 L40_deposit32( Word32 L_var1) {   Word40 L40_var_out;   L40_var_out = ( Word40) L_var1;   if( L_var1 & 0x80000000) {      L40_var_out = L40_set( L40_var_out | 0xff00000000);      #if (WMOPS)      multiCounter[currCounter].L40_set--;      #endif /* ifdef WMOPS */   }   #if (WMOPS)   multiCounter[currCounter].L40_deposit32++;   #endif /* ifdef WMOPS */      return( L40_var_out);}/***************************************************************************** * *  Function Name : L40_round

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -