update gsm codec based on codecs from open h323.

git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@171 d0543943-73ff-0310-b7d9-9358b9ac24b2
This commit is contained in:
Michael Jerris committed 2005-12-18 20:41:43 +00:00
1 parent 342e73399e
commit 07920c0a94
26 files changed
+177 -2298

No files matched your search

+16 -33
View File
@@ -1,10 +1,11 @@
/*
* preprocess.c
*
* Copyright 1992 by Jutta Degener and Carsten Bormann, Technische
* Universitaet Berlin. See the accompanying file "COPYRIGHT" for
* details. THERE IS ABSOLUTELY NO WARRANTY FOR THIS SOFTWARE.
*/
/* $Header$ */
#include <stdio.h>
#include <assert.h>
@@ -42,10 +43,14 @@ void Gsm_Preprocess P3((S, s, so),
word mp = S->mp;
word s1;
longword L_s2;
longword L_temp;
word msp, lsp;
word SO;
longword ltmp; /* for ADD */
ulongword utmp; /* for L_ADD */
register int k = 160;
@@ -54,8 +59,7 @@ void Gsm_Preprocess P3((S, s, so),
/* 4.2.1 Downscaling of the input signal
*/
/* SO = SASR( *s, 3 ) << 2;*/
SO = SASR( *s, 1 ) & ~3;
SO = SASR( *s, 3 ) << 2;
s++;
assert (SO >= -0x4000); /* downscaled by */
@@ -77,41 +81,21 @@ void Gsm_Preprocess P3((S, s, so),
assert(s1 != MIN_WORD);
/* SJB Remark: float might be faster than the mess that follows */
/* Compute the recursive part
*/
L_s2 = s1;
L_s2 <<= 15;
/* Execution of a 31 bv 16 bits multiplication
*/
{
word msp;
#ifndef __GNUC__
word lsp;
#endif
longword L_s2;
longword L_temp;
L_s2 = s1;
L_s2 <<= 15;
#ifndef __GNUC__
msp = (word)SASR( L_z2, 15 );
lsp = (word)(L_z2 & 0x7fff); /* gsm_L_sub(L_z2,(msp<<15)); */
msp = (word) SASR( L_z2, 15 );
lsp = (word) (L_z2-((longword)msp<<15)); /* gsm_L_sub(L_z2,(msp<<15)); */
L_s2 += GSM_MULT_R( lsp, 32735 );
L_temp = (longword)msp * 32735; /* GSM_L_MULT(msp,32735) >> 1;*/
L_z2 = GSM_L_ADD( L_temp, L_s2 );
/* above does L_z2 = L_z2 * 0x7fd5/0x8000 + L_s2 */
#else
L_z2 = ((long long)L_z2*32735 + 0x4000)>>15;
/* alternate (ansi) version of above line does slightly different rounding:
* L_temp = L_z2 >> 9;
* L_temp += L_temp >> 5;
* L_temp = (++L_temp) >> 1;
* L_z2 = L_z2 - L_temp;
*/
L_z2 = GSM_L_ADD(L_z2,L_s2);
#endif
/* Compute sof[k] with rounding
*/
L_temp = GSM_L_ADD( L_z2, 16384 );
@@ -119,10 +103,9 @@ void Gsm_Preprocess P3((S, s, so),
/* 4.2.3 Preemphasis
*/
msp = (word)GSM_MULT_R( mp, -28180 );
mp = (word)SASR( L_temp, 15 );
*so++ = GSM_ADD( mp, msp );
}
msp = (word) GSM_MULT_R( mp, -28180 );
mp = (word) SASR( L_temp, 15 );
*so++ = (word) GSM_ADD( mp, msp );
}
S->z1 = z1;