📄 operg722.c
字号:
/* Version: 2.00 - 01.Jul.95 ============================================================================ U U GGG SSSS TTTTT U U G S T U U G GG SSSS T U U G G S T UUU GG SSS T ======================================== ITU-T - USER'S GROUP ON SOFTWARE TOOLS ======================================== ============================================================= COPYRIGHT NOTE: This source code, and all of its derivations, is subject to the "ITU-T General Public License". Please have it read in the distribution disk, or in the ITU-T Recommendation G.191 on "SOFTWARE TOOLS FOR SPEECH AND AUDIO CODING STANDARDS". ** This code has (C) Copyright by CNET Lannion A TSS/CMC ** =============================================================MODULE: G722.C 7kHz ADPCM AT 64 KBIT/S MODULE ENCODER AND DECODER BASIC OPERATORSORIGINAL BY: J-P PETIT CNET - Centre Lannion A LAA-TSS Tel: +33-96-05-39-41 Route de Tregastel - BP 40 Fax: +33-96-05-13-16 F-22301 Lannion CEDEX Email: petitjp@lannion.cnet.fr FRANCE History: 14.Mar.95 v1.0 Released for use ITU-T UGST software package Tool based on the CNET's 07/01/90 version 2.00 01.Jul.95 v2.0 Changed function declarations to work with many compilers; reformated <simao@ctd.comsat.com> ============================================================================*/#include <stdio.h>#include <stdlib.h>#include "operg722.h"/* DEFINITION FOR SMART PROTOTYPES */#ifndef ARGS#if defined(MSDOS) || defined(__MSDOS__) || defined(__STDC__) || defined(VMS) || defined (__CYGWIN__) || defined (_MSC_VER)#define ARGS(x) x#else /* Unix: no parameters in prototype! */#define ARGS(x) ()#endif#endif/* Local function prototypes */Word16 sature ARGS((Word32 L_var1));Word16 extract_l ARGS((Word32 L_var1));Word16 add ARGS((Word16 var1, Word16 var2));Word16 sub ARGS((Word16 var1, Word16 var2));Word16 shl ARGS((Word16 var1, Word16 var2));Word16 shr ARGS((Word16 var1, Word16 var2));Word16 mult ARGS((Word16 var1, Word16 var2));Word16 negate ARGS((Word16 var1));Word32 L_add ARGS((Word32 L_var1, Word32 L_var2));Word32 L_shr ARGS((Word32 L_var1, Word16 var2));Word32 L_shl ARGS((Word32 L_var1, Word16 var2));/*___________________________________________________________________________ | | | 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 (L_var1)Word32 L_var1;{ Word16 var_out; if (L_var1 > 0X00007fffL) { var_out = MAX_16; } else { if (L_var1 < (Word32) 0xffff8000L) { var_out = MIN_16; } else { var_out = extract_l (L_var1); } } return (var_out);}/* ....................... end of sature() ............................ *//*___________________________________________________________________________ | | | Function Name : extract_l | | | | Purpose : | | | | Return the 16 LSB of L_var1. | | | | 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 : | | | | var_out | | 16 bit short signed integer (Word16) whose value falls in the | | range : 0xffff 8000 <= var_out <= 0x0000 7fff. | |___________________________________________________________________________| */Word16 extract_l (L_var1)Word32 L_var1;{ Word16 var_out; var_out = (Word16) L_var1; return (var_out);}/* ....................... end of extract_l() ............................ *//*___________________________________________________________________________ | | | 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 (var1, var2)Word16 var1;Word16 var2;{ Word16 var_out; Word32 L_somme; L_somme = (Word32) var1 + (Word32) var2; var_out = sature (L_somme); return (var_out);}/* ....................... end of add() ............................ *//*___________________________________________________________________________ | | | 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 |
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -