diff options
Diffstat (limited to 'pjmedia/src')
-rw-r--r-- | pjmedia/src/pjmedia-codec/speex/cb_search.c | 2 | ||||
-rw-r--r-- | pjmedia/src/pjmedia-codec/speex/config.h | 2 | ||||
-rw-r--r-- | pjmedia/src/pjmedia-codec/speex/ltp.c | 2 | ||||
-rw-r--r-- | pjmedia/src/pjmedia-codec/speex/mdf.c | 10 | ||||
-rw-r--r-- | pjmedia/src/pjmedia-codec/speex/preprocess_spx.c | 2 | ||||
-rw-r--r-- | pjmedia/src/pjmedia/largefilter.h | 6 | ||||
-rw-r--r-- | pjmedia/src/pjmedia/resample.c | 120 | ||||
-rw-r--r-- | pjmedia/src/pjmedia/smallfilter.h | 6 |
8 files changed, 76 insertions, 74 deletions
diff --git a/pjmedia/src/pjmedia-codec/speex/cb_search.c b/pjmedia/src/pjmedia-codec/speex/cb_search.c index b4a223bc..0cf91057 100644 --- a/pjmedia/src/pjmedia-codec/speex/cb_search.c +++ b/pjmedia/src/pjmedia-codec/speex/cb_search.c @@ -85,7 +85,7 @@ static void compute_weighted_codebook(const signed char *shape_cb, const spx_wor #endif #ifndef OVERRIDE_TARGET_UPDATE -static inline void target_update(spx_word16_t *t, spx_word16_t g, spx_word16_t *r, int len) +PJ_INLINE(void) target_update(spx_word16_t *t, spx_word16_t g, spx_word16_t *r, int len) { int n; for (n=0;n<len;n++) diff --git a/pjmedia/src/pjmedia-codec/speex/config.h b/pjmedia/src/pjmedia-codec/speex/config.h index 6ab22359..9f6f5c44 100644 --- a/pjmedia/src/pjmedia-codec/speex/config.h +++ b/pjmedia/src/pjmedia-codec/speex/config.h @@ -1,4 +1,6 @@ +#include <pj/types.h> + /* Check if we need to use the fixed point version */ #if !defined(PJ_HAS_FLOATING_POINT) || PJ_HAS_FLOATING_POINT==0 # define FIXED_POINT diff --git a/pjmedia/src/pjmedia-codec/speex/ltp.c b/pjmedia/src/pjmedia-codec/speex/ltp.c index 9a5a295e..009923de 100644 --- a/pjmedia/src/pjmedia-codec/speex/ltp.c +++ b/pjmedia/src/pjmedia-codec/speex/ltp.c @@ -152,7 +152,7 @@ void pitch_xcorr(const spx_word16_t *_x, const spx_word16_t *_y, spx_word32_t *c #endif #ifndef OVERRIDE_COMPUTE_PITCH_ERROR -static inline spx_word32_t compute_pitch_error(spx_word16_t *C, spx_word16_t *g, spx_word16_t pitch_control) +PJ_INLINE(spx_word32_t) compute_pitch_error(spx_word16_t *C, spx_word16_t *g, spx_word16_t pitch_control) { spx_word32_t sum = 0; sum = ADD32(sum,MULT16_16(MULT16_16_16(g[0],pitch_control),C[0])); diff --git a/pjmedia/src/pjmedia-codec/speex/mdf.c b/pjmedia/src/pjmedia-codec/speex/mdf.c index eabf4339..94e08f7f 100644 --- a/pjmedia/src/pjmedia-codec/speex/mdf.c +++ b/pjmedia/src/pjmedia-codec/speex/mdf.c @@ -146,7 +146,7 @@ struct SpeexEchoState_ { int play_buf_pos; }; -static inline void filter_dc_notch16(const spx_int16_t *in, spx_word16_t radius, spx_word16_t *out, int len, spx_mem_t *mem) +PJ_INLINE(void) filter_dc_notch16(const spx_int16_t *in, spx_word16_t radius, spx_word16_t *out, int len, spx_mem_t *mem) { int i; spx_word16_t den2; @@ -170,7 +170,7 @@ static inline void filter_dc_notch16(const spx_int16_t *in, spx_word16_t radius, } } -static inline spx_word32_t mdf_inner_prod(const spx_word16_t *x, const spx_word16_t *y, int len) +PJ_INLINE(spx_word32_t ) mdf_inner_prod(const spx_word16_t *x, const spx_word16_t *y, int len) { spx_word32_t sum=0; len >>= 1; @@ -186,7 +186,7 @@ static inline spx_word32_t mdf_inner_prod(const spx_word16_t *x, const spx_word1 } /** Compute power spectrum of a half-complex (packed) vector */ -static inline void power_spectrum(const spx_word16_t *X, spx_word32_t *ps, int N) +PJ_INLINE(void) power_spectrum(const spx_word16_t *X, spx_word32_t *ps, int N) { int i, j; ps[0]=MULT16_16(X[0],X[0]); @@ -227,7 +227,7 @@ static inline void spectral_mul_accum(const spx_word16_t *X, const spx_word32_t acc[N-1] = PSHR32(tmp1,WEIGHT_SHIFT); } #else -static inline void spectral_mul_accum(const spx_word16_t *X, const spx_word32_t *Y, spx_word16_t *acc, int N, int M) +PJ_INLINE(void) spectral_mul_accum(const spx_word16_t *X, const spx_word32_t *Y, spx_word16_t *acc, int N, int M) { int i,j; for (i=0;i<N;i++) @@ -248,7 +248,7 @@ static inline void spectral_mul_accum(const spx_word16_t *X, const spx_word32_t #endif /** Compute weighted cross-power spectrum of a half-complex (packed) vector with conjugate */ -static inline void weighted_spectral_mul_conj(const spx_float_t *w, const spx_word16_t *X, const spx_word16_t *Y, spx_word32_t *prod, int N) +PJ_INLINE(void) weighted_spectral_mul_conj(const spx_float_t *w, const spx_word16_t *X, const spx_word16_t *Y, spx_word32_t *prod, int N) { int i, j; prod[0] = FLOAT_MUL32(w[0],MULT16_16(X[0],Y[0])); diff --git a/pjmedia/src/pjmedia-codec/speex/preprocess_spx.c b/pjmedia/src/pjmedia-codec/speex/preprocess_spx.c index 826a6766..ba2e6076 100644 --- a/pjmedia/src/pjmedia-codec/speex/preprocess_spx.c +++ b/pjmedia/src/pjmedia-codec/speex/preprocess_spx.c @@ -93,7 +93,7 @@ static void conj_window(float *w, int len) which multiplied by xi/(1+xi) is the optimal gain in the loudness domain ( sqrt[amplitude] ) */ -static inline float hypergeom_gain(float x) +PJ_INLINE(float) hypergeom_gain(float x) { int ind; float integer, frac; diff --git a/pjmedia/src/pjmedia/largefilter.h b/pjmedia/src/pjmedia/largefilter.h index d237b5cb..1c3f7c0a 100644 --- a/pjmedia/src/pjmedia/largefilter.h +++ b/pjmedia/src/pjmedia/largefilter.h @@ -1,8 +1,8 @@ /* Included by resamplesubs.c */ -#define LARGE_FILTER_NMULT ((HWORD)65) +#define LARGE_FILTER_NMULT ((RES_HWORD)65) #define LARGE_FILTER_SCALE 14746 /* Unity-gain scale factor */ #define LARGE_FILTER_NWING 8192 /* Filter table length */ -static const HWORD LARGE_FILTER_IMP[] /* Impulse response */ = { +static const RES_HWORD LARGE_FILTER_IMP[] /* Impulse response */ = { 32767, 32766, 32764, @@ -8196,7 +8196,7 @@ static const HWORD LARGE_FILTER_IMP[] /* Impulse response */ = { 0, 0}; -static const HWORD LARGE_FILTER_IMPD[] /* Impulse response differences */ = { +static const RES_HWORD LARGE_FILTER_IMPD[] /* Impulse response differences */ = { -1, -2, -3, diff --git a/pjmedia/src/pjmedia/resample.c b/pjmedia/src/pjmedia/resample.c index a30215fa..98b5cf14 100644 --- a/pjmedia/src/pjmedia/resample.c +++ b/pjmedia/src/pjmedia/resample.c @@ -98,11 +98,11 @@ #define SGN(x) ((x)<0 ?(-1):((x)==0?(0):(1))) #endif -typedef char BOOL; -typedef short HWORD; -typedef unsigned short UHWORD; -typedef int WORD; -typedef unsigned int UWORD; +typedef char RES_BOOL; +typedef short RES_HWORD; +typedef int RES_WORD; +typedef unsigned short RES_UHWORD; +typedef unsigned int RES_UWORD; #define MAX_HWORD (32767) #define MIN_HWORD (-32768) @@ -221,10 +221,10 @@ typedef unsigned int UWORD; #endif -static INLINE HWORD WordToHword(WORD v, int scl) +static INLINE RES_HWORD WordToHword(RES_WORD v, int scl) { - HWORD out; - WORD llsb = (1<<(scl-1)); + RES_HWORD out; + RES_WORD llsb = (1<<(scl-1)); v += llsb; /* round */ v >>= scl; if (v>MAX_HWORD) { @@ -232,31 +232,31 @@ static INLINE HWORD WordToHword(WORD v, int scl) } else if (v < MIN_HWORD) { v = MIN_HWORD; } - out = (HWORD) v; + out = (RES_HWORD) v; return out; } /* Sampling rate conversion using linear interpolation for maximum speed. */ static int - SrcLinear(const HWORD X[], HWORD Y[], double pFactor, UHWORD nx) + SrcLinear(const RES_HWORD X[], RES_HWORD Y[], double pFactor, RES_UHWORD nx) { - HWORD iconst; - UWORD time = 0; - const HWORD *xp; - HWORD *Ystart, *Yend; - WORD v,x1,x2; + RES_HWORD iconst; + RES_UWORD time = 0; + const RES_HWORD *xp; + RES_HWORD *Ystart, *Yend; + RES_WORD v,x1,x2; double dt; /* Step through input signal */ - UWORD dtb; /* Fixed-point version of Dt */ - UWORD endTime; /* When time reaches EndTime, return to user */ + RES_UWORD dtb; /* Fixed-point version of Dt */ + RES_UWORD endTime; /* When time reaches EndTime, return to user */ dt = 1.0/pFactor; /* Output sampling period */ dtb = dt*(1<<Np) + 0.5; /* Fixed-point representation */ Ystart = Y; Yend = Ystart + (unsigned)(nx * pFactor); - endTime = time + (1<<Np)*(WORD)nx; + endTime = time + (1<<Np)*(RES_WORD)nx; while (time < endTime) { iconst = (time) & Pmask; @@ -272,15 +272,15 @@ static int return (Y - Ystart); /* Return number of output samples */ } -static WORD FilterUp(const HWORD Imp[], const HWORD ImpD[], - UHWORD Nwing, BOOL Interp, - const HWORD *Xp, HWORD Ph, HWORD Inc) +static RES_WORD FilterUp(const RES_HWORD Imp[], const RES_HWORD ImpD[], + RES_UHWORD Nwing, RES_BOOL Interp, + const RES_HWORD *Xp, RES_HWORD Ph, RES_HWORD Inc) { - const HWORD *Hp; - const HWORD *Hdp = NULL; - const HWORD *End; - HWORD a = 0; - WORD v, t; + const RES_HWORD *Hp; + const RES_HWORD *Hdp = NULL; + const RES_HWORD *End; + RES_HWORD a = 0; + RES_WORD v, t; v=0; Hp = &Imp[Ph>>Na]; @@ -301,7 +301,7 @@ static WORD FilterUp(const HWORD Imp[], const HWORD ImpD[], if (Interp) while (Hp < End) { t = *Hp; /* Get filter coeff */ - t += (((WORD)*Hdp)*a)>>Na; /* t is now interp'd filter coeff */ + t += (((RES_WORD)*Hdp)*a)>>Na; /* t is now interp'd filter coeff */ Hdp += Npc; /* Filter coeff differences step */ t *= *Xp; /* Mult coeff by input sample */ if (t & (1<<(Nhxn-1))) /* Round, if needed */ @@ -327,17 +327,17 @@ static WORD FilterUp(const HWORD Imp[], const HWORD ImpD[], } -static WORD FilterUD(const HWORD Imp[], const HWORD ImpD[], - UHWORD Nwing, BOOL Interp, - const HWORD *Xp, HWORD Ph, HWORD Inc, UHWORD dhb) +static RES_WORD FilterUD(const RES_HWORD Imp[], const RES_HWORD ImpD[], + RES_UHWORD Nwing, RES_BOOL Interp, + const RES_HWORD *Xp, RES_HWORD Ph, RES_HWORD Inc, RES_UHWORD dhb) { - HWORD a; - const HWORD *Hp, *Hdp, *End; - WORD v, t; - UWORD Ho; + RES_HWORD a; + const RES_HWORD *Hp, *Hdp, *End; + RES_WORD v, t; + RES_UWORD Ho; v=0; - Ho = (Ph*(UWORD)dhb)>>Np; + Ho = (Ph*(RES_UWORD)dhb)>>Np; End = &Imp[Nwing]; if (Inc == 1) /* If doing right wing... */ { /* ...drop extra coeff, so when Ph is */ @@ -351,7 +351,7 @@ static WORD FilterUD(const HWORD Imp[], const HWORD ImpD[], t = *Hp; /* Get IR sample */ Hdp = &ImpD[Ho>>Na]; /* get interp (lower Na) bits from diff table*/ a = Ho & Amask; /* a is logically between 0 and 1 */ - t += (((WORD)*Hdp)*a)>>Na; /* t is now interp'd filter coeff */ + t += (((RES_WORD)*Hdp)*a)>>Na; /* t is now interp'd filter coeff */ t *= *Xp; /* Mult coeff by input sample */ if (t & 1<<(Nhxn-1)) /* Round, if needed */ t += 1<<(Nhxn-1); @@ -377,34 +377,34 @@ static WORD FilterUD(const HWORD Imp[], const HWORD ImpD[], /* Sampling rate up-conversion only subroutine; * Slightly faster than down-conversion; */ -static int SrcUp(const HWORD X[], HWORD Y[], double pFactor, - UHWORD nx, UHWORD pNwing, UHWORD pLpScl, - const HWORD pImp[], const HWORD pImpD[], BOOL Interp) +static int SrcUp(const RES_HWORD X[], RES_HWORD Y[], double pFactor, + RES_UHWORD nx, RES_UHWORD pNwing, RES_UHWORD pLpScl, + const RES_HWORD pImp[], const RES_HWORD pImpD[], RES_BOOL Interp) { - const HWORD *xp; - HWORD *Ystart, *Yend; - WORD v; + const RES_HWORD *xp; + RES_HWORD *Ystart, *Yend; + RES_WORD v; double dt; /* Step through input signal */ - UWORD dtb; /* Fixed-point version of Dt */ - UWORD time = 0; - UWORD endTime; /* When time reaches EndTime, return to user */ + RES_UWORD dtb; /* Fixed-point version of Dt */ + RES_UWORD time = 0; + RES_UWORD endTime; /* When time reaches EndTime, return to user */ dt = 1.0/pFactor; /* Output sampling period */ dtb = dt*(1<<Np) + 0.5; /* Fixed-point representation */ Ystart = Y; Yend = Ystart + (unsigned)(nx * pFactor); - endTime = time + (1<<Np)*(WORD)nx; + endTime = time + (1<<Np)*(RES_WORD)nx; while (time < endTime) { xp = &X[time>>Np]; /* Ptr to current input sample */ /* Perform left-wing inner product */ v = 0; - v = FilterUp(pImp, pImpD, pNwing, Interp, xp, (HWORD)(time&Pmask),-1); + v = FilterUp(pImp, pImpD, pNwing, Interp, xp, (RES_HWORD)(time&Pmask),-1); /* Perform right-wing inner product */ - v += FilterUp(pImp, pImpD, pNwing, Interp, xp+1, (HWORD)((-time)&Pmask),1); + v += FilterUp(pImp, pImpD, pNwing, Interp, xp+1, (RES_HWORD)((-time)&Pmask),1); v >>= Nhg; /* Make guard bits */ v *= pLpScl; /* Normalize for unity filter gain */ @@ -417,19 +417,19 @@ static int SrcUp(const HWORD X[], HWORD Y[], double pFactor, /* Sampling rate conversion subroutine */ -static int SrcUD(const HWORD X[], HWORD Y[], double pFactor, - UHWORD nx, UHWORD pNwing, UHWORD pLpScl, - const HWORD pImp[], const HWORD pImpD[], BOOL Interp) +static int SrcUD(const RES_HWORD X[], RES_HWORD Y[], double pFactor, + RES_UHWORD nx, RES_UHWORD pNwing, RES_UHWORD pLpScl, + const RES_HWORD pImp[], const RES_HWORD pImpD[], RES_BOOL Interp) { - const HWORD *xp; - HWORD *Ystart, *Yend; - WORD v; + const RES_HWORD *xp; + RES_HWORD *Ystart, *Yend; + RES_WORD v; double dh; /* Step through filter impulse response */ double dt; /* Step through input signal */ - UWORD time = 0; - UWORD endTime; /* When time reaches EndTime, return to user */ - UWORD dhb, dtb; /* Fixed-point versions of Dh,Dt */ + RES_UWORD time = 0; + RES_UWORD endTime; /* When time reaches EndTime, return to user */ + RES_UWORD dhb, dtb; /* Fixed-point versions of Dh,Dt */ dt = 1.0/pFactor; /* Output sampling period */ dtb = dt*(1<<Np) + 0.5; /* Fixed-point representation */ @@ -439,13 +439,13 @@ static int SrcUD(const HWORD X[], HWORD Y[], double pFactor, Ystart = Y; Yend = Ystart + (unsigned)(nx * pFactor); - endTime = time + (1<<Np)*(WORD)nx; + endTime = time + (1<<Np)*(RES_WORD)nx; while (time < endTime) { xp = &X[time>>Np]; /* Ptr to current input sample */ - v = FilterUD(pImp, pImpD, pNwing, Interp, xp, (HWORD)(time&Pmask), + v = FilterUD(pImp, pImpD, pNwing, Interp, xp, (RES_HWORD)(time&Pmask), -1, dhb); /* Perform left-wing inner product */ - v += FilterUD(pImp, pImpD, pNwing, Interp, xp+1, (HWORD)((-time)&Pmask), + v += FilterUD(pImp, pImpD, pNwing, Interp, xp+1, (RES_HWORD)((-time)&Pmask), 1, dhb); /* Perform right-wing inner product */ v >>= Nhg; /* Make guard bits */ v *= pLpScl; /* Normalize for unity filter gain */ diff --git a/pjmedia/src/pjmedia/smallfilter.h b/pjmedia/src/pjmedia/smallfilter.h index 367999d4..396fcb14 100644 --- a/pjmedia/src/pjmedia/smallfilter.h +++ b/pjmedia/src/pjmedia/smallfilter.h @@ -1,8 +1,8 @@ /* Included by resamplesubs.c */ -#define SMALL_FILTER_NMULT ((HWORD)13) +#define SMALL_FILTER_NMULT ((RES_HWORD)13) #define SMALL_FILTER_SCALE 13128 /* Unity-gain scale factor */ #define SMALL_FILTER_NWING 1536 /* Filter table length */ -static const HWORD SMALL_FILTER_IMP[] /* Impulse response */ = { +static const RES_HWORD SMALL_FILTER_IMP[] /* Impulse response */ = { 32767, 32766, 32764, @@ -1541,7 +1541,7 @@ static const HWORD SMALL_FILTER_IMP[] /* Impulse response */ = { -1 }; -static const HWORD SMALL_FILTER_IMPD[] = { +static const RES_HWORD SMALL_FILTER_IMPD[] = { -1, -2, -4, |