📄 basop_t.c
字号:
#include "typedef.h"
#include "basop.h"
#include "cst_lbc.h"
#include "tab_lbc.h"
#include "coder.h"
#include "decod.h"
#include "exc_lbc.h"
#include "cod_cng.h"
#include "dec_cng.h"
#include "vad.h"
#include "tame.h"
#include "lsp.h"
#include "lpc.h"
#include "util_cng.h"
DECSTATDEF DecStat ;
CODCNGDEF CodCng;
CODSTATDEF CodStat ;
DECCNGDEF DecCng;
VADSTATDEF VadStat ;
/* Global variables */
enum Wmode WrkMode = Both ;
enum Crate WrkRate = Rate63 ;
int PackedFrameSize[2] = {
24 ,
20
} ;
Flag UseHp = True ;
Flag UsePf = True ;
Flag UseVx = False ;
Flag UsePr = True ;
char SignOn[] = "ACL/USH/FT/DSPG ANSI C CODEC ITU LBC Ver 5.00\n" ;
/*___________________________________________________________________________
| |
| Basics operators. |
|___________________________________________________________________________|
*/
/*___________________________________________________________________________
| |
| Include-Files |
|___________________________________________________________________________|
*/
/*___________________________________________________________________________
| |
| Local Functions |
|___________________________________________________________________________|
*/
Word16 sature(Word32 L_var1);
/*___________________________________________________________________________
| |
| Constants and Globals |
|___________________________________________________________________________|
*/
Flag Overflow =0;
Flag Carry =0;
/*___________________________________________________________________________
| |
| Functions |
|___________________________________________________________________________|
*/
/*___________________________________________________________________________
| |
| Function Name : sature |
| |
| Purpose : |
| |
| Limit the 32 bit input to the range of a 16 bit word. |
| |
| 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 : |
| |
| var_out |
| 16 bit short signed integer (Word16) whose value falls in the |
| range : 0xffff 8000 <= var_out <= 0x0000 7fff. |
|___________________________________________________________________________|
*/
Word16 sature(Word32 L_var1)
{
Word16 var_out;
if (L_var1 > 0X00007fffL) {
Overflow = 1;
var_out = MAX_16;
}
else {
if (L_var1 < (Word32)0xffff8000L) {
Overflow = 1;
var_out = MIN_16;
}
else {
Overflow = 0;
var_out = extract_l(L_var1);
}
}
return(var_out);
}
/*___________________________________________________________________________
| |
| Function Name : add |
| |
| Purpose : |
| |
| Performs the addition (var1+var2) with overflow control and saturation;|
| the 16 bit result is set at +32767 when overflow occurs or at -32768 |
| when underflow occurs. |
| |
| 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 add(Word16 var1,Word16 var2)
{
Word16 var_out;
Word32 L_somme;
L_somme = (Word32) var1 + (Word32) var2;
var_out = sature(L_somme);
return(var_out);
}
/*___________________________________________________________________________
| |
| Function Name : sub |
| |
| Purpose : |
| |
| Performs the subtraction (var1+var2) with overflow control and satu- |
| ration; the 16 bit result is set at +32767 when overflow occurs or at |
| -32768 when underflow occurs. |
| |
| 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 sub(Word16 var1,Word16 var2)
{
Word16 var_out;
Word32 L_diff;
L_diff = (Word32) var1 - (Word32) var2;
var_out = sature(L_diff);
return(var_out);
}
/*___________________________________________________________________________
| |
| Function Name : abs_s |
| |
| Purpose : |
| |
| Absolute value of var1; abs_s(-32768) = 32767. |
| |
| Complexity weight : 1 |
| |
| Inputs : |
| |
| var1 |
| 16 bit short signed integer (Word16) whose value falls in the |
| range : 0xffff 8000 <= var1 <= 0x0000 7fff. |
| |
| Outputs : |
| |
| none |
| |
| Return Value : |
| |
| var_out |
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -