operg722.c

来自「Reference Implementation of G.711 standa」· C语言 代码 · 共 684 行 · 第 1/3 页

C
684
字号
 |             16 bit short signed integer (Word16) whose value falls in the | |             range : 0xffff 8000 <= var1 <= 0x0000 7fff.                   | |                                                                           | |   Outputs :                                                               | |                                                                           | |    none                                                                   | |                                                                           | |   Return Value :                                                          | |                                                                           | |    var_out                                                                | |             16 bit short signed integer (Word16) whose value falls in the | |             range : 0xffff 8000 <= var_out <= 0x0000 7fff.                | |___________________________________________________________________________| */Word16 sub (var1, var2)Word16 var1;Word16 var2;{  Word16          var_out;  Word32          L_diff;  L_diff = (Word32) var1 - (Word32) var2;  var_out = sature (L_diff);  return (var_out);}/* ....................... end of sub() ............................ *//*___________________________________________________________________________ |                                                                           | |   Function Name : shl                                                     | |                                                                           | |   Purpose :                                                               | |                                                                           | |   Arithmetically shift the 16 bit input var1 left var2 positions.Zero fill| |   the var2 LSB of the result. If var2 is negative, arithmetically shift   | |   var1 right by -var2 with sign extension. Saturate the result in case of | |   underflows or overflows.                                                | |                                                                           | |   Complexity weight : 1                                                   | |                                                                           | |   Inputs :                                                                | |                                                                           | |    var1                                                                   | |             16 bit short signed integer (Word16) whose value falls in the | |             range : 0xffff 8000 <= var1 <= 0x0000 7fff.                   | |                                                                           | |    var2                                                                   | |             16 bit short signed integer (Word16) whose value falls in the | |             range : 0xffff 8000 <= var1 <= 0x0000 7fff.                   | |                                                                           | |   Outputs :                                                               | |                                                                           | |    none                                                                   | |                                                                           | |   Return Value :                                                          | |                                                                           | |    var_out                                                                | |             16 bit short signed integer (Word16) whose value falls in the | |             range : 0xffff 8000 <= var_out <= 0x0000 7fff.                | |___________________________________________________________________________| */Word16 shl (var1, var2)Word16 var1;Word16 var2;{  Word16          var_out;  Word32          L_result;  if (var2 < 0)  {    var_out = shr (var1, -var2);  }  else  {    L_result = (Word32) var1 *((Word32) 1 << var2);    if (((var2 > 15) && (var1 != 0)) ||	(L_result != (Word32) ((Word16) L_result)))    {      var_out = (var1 > 0) ? MAX_16 : MIN_16;    }    else    {      var_out = extract_l (L_result);    }  }  return (var_out);}/* ....................... end of shl() ............................ *//*___________________________________________________________________________ |                                                                           | |   Function Name : shr                                                     | |                                                                           | |   Purpose :                                                               | |                                                                           | |   Arithmetically shift the 16 bit input var1 right var2 positions with    | |   sign extension. If var2 is negative, arithmetically shift var1 left by  | |   -var2 with sign extension. Saturate the result in case of underflows or | |   overflows.                                                              | |                                                                           | |   Complexity weight : 1                                                   | |                                                                           | |   Inputs :                                                                | |                                                                           | |    var1                                                                   | |             16 bit short signed integer (Word16) whose value falls in the | |             range : 0xffff 8000 <= var1 <= 0x0000 7fff.                   | |                                                                           | |    var2                                                                   | |             16 bit short signed integer (Word16) whose value falls in the | |             range : 0xffff 8000 <= var1 <= 0x0000 7fff.                   | |                                                                           | |   Outputs :                                                               | |                                                                           | |    none                                                                   | |                                                                           | |   Return Value :                                                          | |                                                                           | |    var_out                                                                | |             16 bit short signed integer (Word16) whose value falls in the | |             range : 0xffff 8000 <= var_out <= 0x0000 7fff.                | |___________________________________________________________________________| */Word16 shr (var1, var2)Word16 var1;Word16 var2;{  Word16          var_out;  if (var2 < 0)  {    var_out = shl (var1, -var2);  }  else  {    if (var2 >= 15)    {      var_out = (var1 < (Word16) 0) ? (Word16) - 1 : (Word16) 0;    }    else    {      if (var1 < 0)      {	var_out = ~((~var1) >> var2);      }      else      {	var_out = var1 >> var2;      }    }  }  return (var_out);}/* ....................... end of shr() ............................ *//*___________________________________________________________________________ |                                                                           | |   Function Name : mult                                                    | |                                                                           | |   Purpose :                                                               | |                                                                           | |    Performs the multiplication of var1 by var2 and gives a 16 bit result  | |    which is scaled i.e.:                                                  | |             mult(var1,var2) = shr((var1 times var2),15) and               | |             mult(-32768,-32768) = 32767.                                  | |                                                                           | |   Complexity weight : 1                                                   | |                                                                           | |   Inputs :                                                                | |                                                                           | |    var1                                                                   | |             16 bit short signed integer (Word16) whose value falls in the | |             range : 0xffff 8000 <= var1 <= 0x0000 7fff.                   | |                                                                           | |    var2                                                                   | |             16 bit short signed integer (Word16) whose value falls in the | |             range : 0xffff 8000 <= var1 <= 0x0000 7fff.                   | |                                                                           | |   Outputs :                                                               | |                                                                           | |    none                                                                   | |                                                                           | |   Return Value :                                                          | |                                                                           | |    var_out                                                                | |             16 bit short signed integer (Word16) whose value falls in the | |             range : 0xffff 8000 <= var_out <= 0x0000 7fff.                | |___________________________________________________________________________| */Word16 mult (var1, var2)Word16 var1;Word16 var2;{  Word16          var_out;  Word32          L_produit;  L_produit = (Word32) var1 *(Word32) var2;  L_produit = (L_produit & (Word32) 0xffff8000L) >> 15;  if (L_produit & (Word32) 0x00010000L)  {    L_produit |= (Word32) 0xffff0000L;  }  var_out = sature (L_produit);  return (var_out);}/* ....................... end of mult() ............................ *//*___________________________________________________________________________ |                                                                           | |   Function Name : negate                                                  | |                                                                           | |   Purpose :                                                               |

⌨️ 快捷键说明

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