gsm library port to msvc, fix some warnings.
git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@168 d0543943-73ff-0310-b7d9-9358b9ac24b2
This commit is contained in:
parent
644656c84c
commit
20ff10947b
|
@ -136,6 +136,11 @@ static __inline__ short GSM_SUB(short a, short b)
|
|||
|
||||
#else
|
||||
|
||||
#ifdef WIN32
|
||||
#define inline __inline
|
||||
#define __inline__ __inline
|
||||
#endif
|
||||
|
||||
# define GSM_L_ADD(a, b) \
|
||||
( (a) < 0 ? ( (b) >= 0 ? (a) + (b) \
|
||||
: (utmp = (ulongword)-((a) + 1) + (ulongword)-((b) + 1)) \
|
||||
|
@ -144,25 +149,19 @@ static __inline__ short GSM_SUB(short a, short b)
|
|||
: (utmp = (ulongword)(a) + (ulongword)(b)) >= MAX_LONGWORD \
|
||||
? MAX_LONGWORD : utmp))
|
||||
|
||||
/*
|
||||
* # define GSM_ADD(a, b) \
|
||||
* ((ltmp = (longword)(a) + (longword)(b)) >= MAX_WORD \
|
||||
* ? MAX_WORD : ltmp <= MIN_WORD ? MIN_WORD : ltmp)
|
||||
*/
|
||||
/* Nonportable, but faster: */
|
||||
static inline word GSM_ADD(a, b)
|
||||
{
|
||||
register longword ltmp;
|
||||
ltmp = (longword) (a) + (longword) (b);
|
||||
return (word)((ulongword) (ltmp - MIN_WORD) > MAX_WORD - MIN_WORD ? (ltmp > 0 ? MAX_WORD : MIN_WORD) : ltmp);
|
||||
};
|
||||
|
||||
# define GSM_ADD(a, b) ({ \
|
||||
register longword ltmp; \
|
||||
ltmp = (longword) (a) + (longword) (b); \
|
||||
((ulongword) (ltmp - MIN_WORD) > MAX_WORD - MIN_WORD ? \
|
||||
(ltmp > 0 ? MAX_WORD : MIN_WORD) : ltmp); \
|
||||
})
|
||||
|
||||
#define GSM_SUB(a, b) ({ \
|
||||
register longword ltmp; \
|
||||
ltmp = (longword) (a) - (longword) (b); \
|
||||
(ltmp >= MAX_WORD ? MAX_WORD : ltmp <= MIN_WORD ? MIN_WORD : ltmp); \
|
||||
})
|
||||
static inline word GSM_SUB(a, b)
|
||||
{
|
||||
register longword ltmp;
|
||||
ltmp = (longword) (a) - (longword) (b);
|
||||
return (word)(ltmp >= MAX_WORD ? MAX_WORD : ltmp <= MIN_WORD ? MIN_WORD : ltmp);
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
|
|
|
@ -0,0 +1,253 @@
|
|||
<?xml version="1.0" encoding="Windows-1252"?>
|
||||
<VisualStudioProject
|
||||
ProjectType="Visual C++"
|
||||
Version="8.00"
|
||||
Name="libgsm"
|
||||
ProjectGUID="{8FD2E297-4096-47E5-9258-C48FF1841523}"
|
||||
RootNamespace="libgsm"
|
||||
Keyword="Win32Proj"
|
||||
>
|
||||
<Platforms>
|
||||
<Platform
|
||||
Name="Win32"
|
||||
/>
|
||||
</Platforms>
|
||||
<ToolFiles>
|
||||
</ToolFiles>
|
||||
<Configurations>
|
||||
<Configuration
|
||||
Name="Debug|Win32"
|
||||
OutputDirectory="$(SolutionDir)$(ConfigurationName)"
|
||||
IntermediateDirectory="$(ConfigurationName)"
|
||||
ConfigurationType="4"
|
||||
CharacterSet="1"
|
||||
>
|
||||
<Tool
|
||||
Name="VCPreBuildEventTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCCustomBuildTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCXMLDataGeneratorTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCWebServiceProxyGeneratorTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCMIDLTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
Optimization="0"
|
||||
AdditionalIncludeDirectories="inc"
|
||||
PreprocessorDefinitions="WIN32;_DEBUG;_LIB"
|
||||
MinimalRebuild="true"
|
||||
BasicRuntimeChecks="3"
|
||||
RuntimeLibrary="3"
|
||||
UsePrecompiledHeader="0"
|
||||
WarningLevel="3"
|
||||
Detect64BitPortabilityProblems="true"
|
||||
DebugInformationFormat="4"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCManagedResourceCompilerTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCResourceCompilerTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCPreLinkEventTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCLibrarianTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCALinkTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCXDCMakeTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCBscMakeTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCFxCopTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCPostBuildEventTool"
|
||||
/>
|
||||
</Configuration>
|
||||
<Configuration
|
||||
Name="Release|Win32"
|
||||
OutputDirectory="$(SolutionDir)$(ConfigurationName)"
|
||||
IntermediateDirectory="$(ConfigurationName)"
|
||||
ConfigurationType="4"
|
||||
CharacterSet="1"
|
||||
WholeProgramOptimization="1"
|
||||
>
|
||||
<Tool
|
||||
Name="VCPreBuildEventTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCCustomBuildTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCXMLDataGeneratorTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCWebServiceProxyGeneratorTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCMIDLTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
AdditionalIncludeDirectories="inc"
|
||||
PreprocessorDefinitions="WIN32;NDEBUG;_LIB"
|
||||
RuntimeLibrary="2"
|
||||
UsePrecompiledHeader="0"
|
||||
WarningLevel="3"
|
||||
Detect64BitPortabilityProblems="true"
|
||||
DebugInformationFormat="3"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCManagedResourceCompilerTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCResourceCompilerTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCPreLinkEventTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCLibrarianTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCALinkTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCXDCMakeTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCBscMakeTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCFxCopTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCPostBuildEventTool"
|
||||
/>
|
||||
</Configuration>
|
||||
</Configurations>
|
||||
<References>
|
||||
</References>
|
||||
<Files>
|
||||
<Filter
|
||||
Name="Source Files"
|
||||
Filter="cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx"
|
||||
UniqueIdentifier="{4FC737F1-C7A5-4376-A066-2A32D752A2FF}"
|
||||
>
|
||||
<File
|
||||
RelativePath=".\src\add.c"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\src\code.c"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\src\debug.c"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\src\decode.c"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\src\gsm_create.c"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\src\gsm_decode.c"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\src\gsm_destroy.c"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\src\gsm_encode.c"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\src\gsm_explode.c"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\src\gsm_implode.c"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\src\gsm_option.c"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\src\gsm_print.c"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\src\long_term.c"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\src\lpc.c"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\src\preprocess.c"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\src\rpe.c"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\src\short_term.c"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\src\table.c"
|
||||
>
|
||||
</File>
|
||||
</Filter>
|
||||
<Filter
|
||||
Name="Header Files"
|
||||
Filter="h;hpp;hxx;hm;inl;inc;xsd"
|
||||
UniqueIdentifier="{93995380-89BD-4b04-88EB-625FBE52EBFB}"
|
||||
>
|
||||
<File
|
||||
RelativePath=".\inc\config.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\inc\gsm.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\inc\private.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\inc\proto.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\inc\unproto.h"
|
||||
>
|
||||
</File>
|
||||
</Filter>
|
||||
</Files>
|
||||
<Globals>
|
||||
</Globals>
|
||||
</VisualStudioProject>
|
|
@ -23,19 +23,19 @@
|
|||
word gsm_add P2((a,b), word a, word b)
|
||||
{
|
||||
longword sum = (longword)a + (longword)b;
|
||||
return saturate(sum);
|
||||
return (word)saturate(sum);
|
||||
}
|
||||
|
||||
word gsm_sub P2((a,b), word a, word b)
|
||||
{
|
||||
longword diff = (longword)a - (longword)b;
|
||||
return saturate(diff);
|
||||
return (word)saturate(diff);
|
||||
}
|
||||
|
||||
word gsm_mult P2((a,b), word a, word b)
|
||||
{
|
||||
if (a == MIN_WORD && b == MIN_WORD) return MAX_WORD;
|
||||
else return SASR( (longword)a * (longword)b, 15 );
|
||||
else return (word)SASR( (longword)a * (longword)b, 15 );
|
||||
}
|
||||
|
||||
word gsm_mult_r P2((a,b), word a, word b)
|
||||
|
@ -44,7 +44,7 @@ word gsm_mult_r P2((a,b), word a, word b)
|
|||
else {
|
||||
longword prod = (longword)a * (longword)b + 16384;
|
||||
prod >>= 15;
|
||||
return prod & 0xFFFF;
|
||||
return (word)(prod & 0xFFFF);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -62,10 +62,6 @@ void Gsm_Coder P8((S,s,LARc,Nc,bc,Mc,xmaxc,xMc),
|
|||
|
||||
word so[160];
|
||||
|
||||
#if !(defined(__GNUC__) && defined(__i386__))
|
||||
longword ltmp;
|
||||
#endif
|
||||
|
||||
Gsm_Preprocess (S, s, so);
|
||||
Gsm_LPC_Analysis (S, so, LARc);
|
||||
Gsm_Short_Term_Analysis_Filter (S, LARc, so);
|
||||
|
|
|
@ -25,7 +25,7 @@ static void Postprocessing P2((S,s),
|
|||
register word tmp;
|
||||
|
||||
for (k = 160; k--; s++) {
|
||||
tmp = GSM_MULT_R( msr, 28180 );
|
||||
tmp = (word)GSM_MULT_R( msr, 28180 );
|
||||
msr = GSM_ADD(*s, tmp); /* Deemphasis */
|
||||
*s = GSM_ADD(msr, msr) & 0xFFF8; /* Truncation & Upscaling */
|
||||
}
|
||||
|
|
|
@ -278,8 +278,8 @@ static void Calculation_of_the_LTP_parameters P4((d,dp,bc_out,Nc_out),
|
|||
|
||||
temp = gsm_norm( L_power );
|
||||
|
||||
R = SASR( L_max << temp, 16 );
|
||||
S = SASR( L_power << temp, 16 );
|
||||
R = (word)SASR( L_max << temp, 16 );
|
||||
S = (word)SASR( L_power << temp, 16 );
|
||||
|
||||
/* Coding of the LTP gain
|
||||
*/
|
||||
|
@ -856,7 +856,7 @@ static void Long_term_analysis_filtering P6((bc,Nc,dp,d,dpp,e),
|
|||
# undef STEP
|
||||
# define STEP(BP) \
|
||||
for (k = 0; k <= 39; k++) { \
|
||||
dpp[k] = GSM_MULT_R( BP, dp[k - Nc]); \
|
||||
dpp[k] = (word)GSM_MULT_R( BP, dp[k - Nc]); \
|
||||
e[k] = GSM_SUB( d[k], dpp[k] ); \
|
||||
}
|
||||
|
||||
|
@ -939,7 +939,7 @@ void Gsm_Long_Term_Synthesis_Filtering P5((S,Ncr,bcr,erp,drp),
|
|||
assert(brp != MIN_WORD);
|
||||
|
||||
for (k = 0; k <= 39; k++) {
|
||||
drpp = GSM_MULT_R( brp, drp[ k - Nr ] );
|
||||
drpp = (word)GSM_MULT_R( brp, drp[ k - Nr ] );
|
||||
drp[k] = GSM_ADD( erp[k], drpp );
|
||||
}
|
||||
|
||||
|
|
|
@ -84,7 +84,7 @@ static void Autocorrelation P2((s, L_ACF),
|
|||
# else
|
||||
# define SCALE(n) \
|
||||
case n: for (k = 0; k <= 159; k++) \
|
||||
s[k] = GSM_MULT_R( s[k], 16384 >> (n-1) );\
|
||||
s[k] = (word)GSM_MULT_R( s[k], 16384 >> (n-1) );\
|
||||
break;
|
||||
# endif /* USE_FLOAT_MUL */
|
||||
|
||||
|
@ -229,7 +229,7 @@ static void Reflection_coefficients P2( (L_ACF, r),
|
|||
assert(temp >= 0 && temp < 32);
|
||||
|
||||
/* ? overflow ? */
|
||||
for (i = 0; i <= 8; i++) ACF[i] = SASR( L_ACF[i] << temp, 16 );
|
||||
for (i = 0; i <= 8; i++) ACF[i] = (word)SASR( L_ACF[i] << temp, 16 );
|
||||
|
||||
/* Initialize array P[..] and K[..] for the recursion.
|
||||
*/
|
||||
|
@ -257,14 +257,14 @@ static void Reflection_coefficients P2( (L_ACF, r),
|
|||
|
||||
/* Schur recursion
|
||||
*/
|
||||
temp = GSM_MULT_R( P[1], *r );
|
||||
temp = (word)GSM_MULT_R( P[1], *r );
|
||||
P[0] = GSM_ADD( P[0], temp );
|
||||
|
||||
for (m = 1; m <= 8 - n; m++) {
|
||||
temp = GSM_MULT_R( K[ m ], *r );
|
||||
temp = (word)GSM_MULT_R( K[ m ], *r );
|
||||
P[m] = GSM_ADD( P[ m+1 ], temp );
|
||||
|
||||
temp = GSM_MULT_R( P[ m+1 ], *r );
|
||||
temp = (word)GSM_MULT_R( P[ m+1 ], *r );
|
||||
K[m] = GSM_ADD( K[ m ], temp );
|
||||
}
|
||||
}
|
||||
|
@ -331,10 +331,10 @@ static void Quantization_and_coding P1((LAR),
|
|||
|
||||
# undef STEP
|
||||
# define STEP( A, B, MAC, MIC ) \
|
||||
temp = GSM_MULT( A, *LAR ); \
|
||||
temp = (word)GSM_MULT( A, *LAR ); \
|
||||
temp = GSM_ADD( temp, B ); \
|
||||
temp = GSM_ADD( temp, 256 ); \
|
||||
temp = SASR( temp, 9 ); \
|
||||
temp = (word)SASR( temp, 9 ); \
|
||||
*LAR = temp>MAC ? MAC - MIC : (temp<MIC ? 0 : temp - MIC); \
|
||||
LAR++;
|
||||
|
||||
|
|
|
@ -95,8 +95,8 @@ void Gsm_Preprocess P3((S, s, so),
|
|||
L_s2 = s1;
|
||||
L_s2 <<= 15;
|
||||
#ifndef __GNUC__
|
||||
msp = SASR( L_z2, 15 );
|
||||
lsp = L_z2 & 0x7fff; /* gsm_L_sub(L_z2,(msp<<15)); */
|
||||
msp = (word)SASR( L_z2, 15 );
|
||||
lsp = (word)(L_z2 & 0x7fff); /* 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;*/
|
||||
|
@ -119,8 +119,8 @@ void Gsm_Preprocess P3((S, s, so),
|
|||
/* 4.2.3 Preemphasis
|
||||
*/
|
||||
|
||||
msp = GSM_MULT_R( mp, -28180 );
|
||||
mp = SASR( L_temp, 15 );
|
||||
msp = (word)GSM_MULT_R( mp, -28180 );
|
||||
mp = (word)SASR( L_temp, 15 );
|
||||
*so++ = GSM_ADD( mp, msp );
|
||||
}
|
||||
}
|
||||
|
|
|
@ -108,7 +108,7 @@ static void Weighting_filter P2((e, x),
|
|||
*/
|
||||
|
||||
L_result = SASR( L_result, 13 );
|
||||
x[k] = ( L_result < MIN_WORD ? MIN_WORD
|
||||
x[k] = (word)( L_result < MIN_WORD ? MIN_WORD
|
||||
: (L_result > MAX_WORD ? MAX_WORD : L_result ));
|
||||
}
|
||||
}
|
||||
|
@ -334,7 +334,7 @@ static void APCM_quantization P5((xM,xMc,mant_out,exp_out,xmaxc_out),
|
|||
assert(temp1 >= 0 && temp1 < 16);
|
||||
|
||||
temp = xM[i] << temp1;
|
||||
temp = GSM_MULT( temp, temp2 );
|
||||
temp = (word)GSM_MULT( temp, temp2 );
|
||||
temp = SASR(temp, 12);
|
||||
xMc[i] = temp + 4; /* see note below */
|
||||
}
|
||||
|
@ -378,7 +378,7 @@ static void APCM_inverse_quantization P4((xMc,mant,exp,xMp),
|
|||
assert( temp <= 7 && temp >= -7 ); /* 4 bit signed */
|
||||
|
||||
temp <<= 12; /* 16 bit signed */
|
||||
temp = GSM_MULT_R( temp1, temp );
|
||||
temp = (word)GSM_MULT_R( temp1, temp );
|
||||
temp = GSM_ADD( temp, temp3 );
|
||||
*xMp++ = gsm_asr( temp, temp2 );
|
||||
}
|
||||
|
|
|
@ -58,7 +58,7 @@ static void Decoding_of_the_coded_Log_Area_Ratios P2((LARc,LARpp),
|
|||
#define STEP( B, MIC, INVA ) \
|
||||
temp1 = GSM_ADD( *LARc++, MIC ) << 10; \
|
||||
temp1 = GSM_SUB( temp1, B << 1 ); \
|
||||
temp1 = GSM_MULT_R( INVA, temp1 ); \
|
||||
temp1 = (word)GSM_MULT_R( INVA, temp1 ); \
|
||||
*LARpp++ = GSM_ADD( temp1, temp1 );
|
||||
|
||||
STEP( 0, -32, 13107 );
|
||||
|
@ -214,7 +214,7 @@ static void Short_term_analysis_filtering P4((u0,rp0,k_n,s),
|
|||
for (rp=rp0, u=u0; u<u_top;) {
|
||||
register longword ui, rpi;
|
||||
ui = *u;
|
||||
*u++ = u_out;
|
||||
*u++ = (word)u_out;
|
||||
rpi = *rp++;
|
||||
u_out = ui + (((rpi*di)+0x4000)>>15);
|
||||
di = di + (((rpi*ui)+0x4000)>>15);
|
||||
|
@ -226,7 +226,7 @@ static void Short_term_analysis_filtering P4((u0,rp0,k_n,s),
|
|||
if (di>MAX_WORD) di=MAX_WORD;
|
||||
else if (di<MIN_WORD) di=MIN_WORD;
|
||||
}
|
||||
*s++ = di;
|
||||
*s++ = (word)di;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
@ -315,9 +315,9 @@ static void Short_term_synthesis_filtering P5((S,rrp,k,wt,sr),
|
|||
if (tmp1 != (word)tmp1) {
|
||||
tmp1 = (tmp1<0)? MIN_WORD:MAX_WORD;
|
||||
}
|
||||
v[i+1] = tmp1;
|
||||
v[i+1] = (word)tmp1;
|
||||
}
|
||||
*sr++ = v[0] = sri;
|
||||
*sr++ = v[0] = (word)sri;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -373,7 +373,7 @@ void Gsm_Short_Term_Analysis_Filter P3((S,LARc,s),
|
|||
word * LARpp_j_1 = S->LARpp[ S->j ^= 1 ];
|
||||
|
||||
word LARp[8];
|
||||
int i;
|
||||
|
||||
#undef FILTER
|
||||
#if defined(FAST) && defined(USE_FLOAT_MUL)
|
||||
# define FILTER (* (S->fast \
|
||||
|
|
Loading…
Reference in New Issue