* #36737: switch back to svn repo, remove assert in sip_transaction.c
diff --git a/jni/pjproject-android/.svn/pristine/cc/cc4d813ebc787e205d75f8d0645cd9c260d6ed34.svn-base b/jni/pjproject-android/.svn/pristine/cc/cc4d813ebc787e205d75f8d0645cd9c260d6ed34.svn-base
new file mode 100644
index 0000000..a9c5328
--- /dev/null
+++ b/jni/pjproject-android/.svn/pristine/cc/cc4d813ebc787e205d75f8d0645cd9c260d6ed34.svn-base
Binary files differ
diff --git a/jni/pjproject-android/.svn/pristine/cc/cc7d773cb906ffa0001106d3403cbda354ee2e01.svn-base b/jni/pjproject-android/.svn/pristine/cc/cc7d773cb906ffa0001106d3403cbda354ee2e01.svn-base
new file mode 100644
index 0000000..1fbb4d6
--- /dev/null
+++ b/jni/pjproject-android/.svn/pristine/cc/cc7d773cb906ffa0001106d3403cbda354ee2e01.svn-base
@@ -0,0 +1,1177 @@
+/* Copyright (C) 2003-2006 Jean-Marc Valin
+
+ File: mdf.c
+ Echo canceller based on the MDF algorithm (see below)
+
+ Redistribution and use in source and binary forms, with or without
+ modification, are permitted provided that the following conditions are
+ met:
+
+ 1. Redistributions of source code must retain the above copyright notice,
+ this list of conditions and the following disclaimer.
+
+ 2. Redistributions in binary form must reproduce the above copyright
+ notice, this list of conditions and the following disclaimer in the
+ documentation and/or other materials provided with the distribution.
+
+ 3. The name of the author may not be used to endorse or promote products
+ derived from this software without specific prior written permission.
+
+ THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT,
+ INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+ SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
+ STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
+ ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ POSSIBILITY OF SUCH DAMAGE.
+*/
+
+/*
+ The echo canceller is based on the MDF algorithm described in:
+
+ J. S. Soo, K. K. Pang Multidelay block frequency adaptive filter,
+ IEEE Trans. Acoust. Speech Signal Process., Vol. ASSP-38, No. 2,
+ February 1990.
+
+ We use the Alternatively Updated MDF (AUMDF) variant. Robustness to
+ double-talk is achieved using a variable learning rate as described in:
+
+ Valin, J.-M., On Adjusting the Learning Rate in Frequency Domain Echo
+ Cancellation With Double-Talk. IEEE Transactions on Audio,
+ Speech and Language Processing, Vol. 15, No. 3, pp. 1030-1034, 2007.
+ http://people.xiph.org/~jm/papers/valin_taslp2006.pdf
+
+ There is no explicit double-talk detection, but a continuous variation
+ in the learning rate based on residual echo, double-talk and background
+ noise.
+
+ About the fixed-point version:
+ All the signals are represented with 16-bit words. The filter weights
+ are represented with 32-bit words, but only the top 16 bits are used
+ in most cases. The lower 16 bits are completely unreliable (due to the
+ fact that the update is done only on the top bits), but help in the
+ adaptation -- probably by removing a "threshold effect" due to
+ quantization (rounding going to zero) when the gradient is small.
+
+ Another kludge that seems to work good: when performing the weight
+ update, we only move half the way toward the "goal" this seems to
+ reduce the effect of quantization noise in the update phase. This
+ can be seen as applying a gradient descent on a "soft constraint"
+ instead of having a hard constraint.
+
+*/
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include "arch.h"
+#include "speex/speex_echo.h"
+#include "fftwrap.h"
+#include "pseudofloat.h"
+#include "math_approx.h"
+#include "os_support.h"
+
+#ifndef M_PI
+#define M_PI 3.14159265358979323846
+#endif
+
+#ifdef FIXED_POINT
+#define WEIGHT_SHIFT 11
+#define NORMALIZE_SCALEDOWN 5
+#define NORMALIZE_SCALEUP 3
+#else
+#define WEIGHT_SHIFT 0
+#endif
+
+/* If enabled, the AEC will use a foreground filter and a background filter to be more robust to double-talk
+ and difficult signals in general. The cost is an extra FFT and a matrix-vector multiply */
+#define TWO_PATH
+
+#ifdef FIXED_POINT
+static const spx_float_t MIN_LEAK = {20972, -22};
+
+/* Constants for the two-path filter */
+static const spx_float_t VAR1_SMOOTH = {23593, -16};
+static const spx_float_t VAR2_SMOOTH = {23675, -15};
+static const spx_float_t VAR1_UPDATE = {16384, -15};
+static const spx_float_t VAR2_UPDATE = {16384, -16};
+static const spx_float_t VAR_BACKTRACK = {16384, -12};
+#define TOP16(x) ((x)>>16)
+
+#else
+
+static const spx_float_t MIN_LEAK = .005f;
+
+/* Constants for the two-path filter */
+static const spx_float_t VAR1_SMOOTH = .36f;
+static const spx_float_t VAR2_SMOOTH = .7225f;
+static const spx_float_t VAR1_UPDATE = .5f;
+static const spx_float_t VAR2_UPDATE = .25f;
+static const spx_float_t VAR_BACKTRACK = 4.f;
+#define TOP16(x) (x)
+#endif
+
+
+#define PLAYBACK_DELAY 2
+
+void speex_echo_get_residual(SpeexEchoState *st, spx_word32_t *Yout, int len);
+
+
+/** Speex echo cancellation state. */
+struct SpeexEchoState_ {
+ int frame_size; /**< Number of samples processed each time */
+ int window_size;
+ int M;
+ int cancel_count;
+ int adapted;
+ int saturated;
+ int screwed_up;
+ spx_int32_t sampling_rate;
+ spx_word16_t spec_average;
+ spx_word16_t beta0;
+ spx_word16_t beta_max;
+ spx_word32_t sum_adapt;
+ spx_word16_t leak_estimate;
+
+ spx_word16_t *e; /* scratch */
+ spx_word16_t *x; /* Far-end input buffer (2N) */
+ spx_word16_t *X; /* Far-end buffer (M+1 frames) in frequency domain */
+ spx_word16_t *input; /* scratch */
+ spx_word16_t *y; /* scratch */
+ spx_word16_t *last_y;
+ spx_word16_t *Y; /* scratch */
+ spx_word16_t *E;
+ spx_word32_t *PHI; /* scratch */
+ spx_word32_t *W; /* (Background) filter weights */
+#ifdef TWO_PATH
+ spx_word16_t *foreground; /* Foreground filter weights */
+ spx_word32_t Davg1; /* 1st recursive average of the residual power difference */
+ spx_word32_t Davg2; /* 2nd recursive average of the residual power difference */
+ spx_float_t Dvar1; /* Estimated variance of 1st estimator */
+ spx_float_t Dvar2; /* Estimated variance of 2nd estimator */
+#endif
+ spx_word32_t *power; /* Power of the far-end signal */
+ spx_float_t *power_1;/* Inverse power of far-end */
+ spx_word16_t *wtmp; /* scratch */
+#ifdef FIXED_POINT
+ spx_word16_t *wtmp2; /* scratch */
+#endif
+ spx_word32_t *Rf; /* scratch */
+ spx_word32_t *Yf; /* scratch */
+ spx_word32_t *Xf; /* scratch */
+ spx_word32_t *Eh;
+ spx_word32_t *Yh;
+ spx_float_t Pey;
+ spx_float_t Pyy;
+ spx_word16_t *window;
+ spx_word16_t *prop;
+ void *fft_table;
+ spx_word16_t memX, memD, memE;
+ spx_word16_t preemph;
+ spx_word16_t notch_radius;
+ spx_mem_t notch_mem[2];
+
+ /* NOTE: If you only use speex_echo_cancel() and want to save some memory, remove this */
+ spx_int16_t *play_buf;
+ int play_buf_pos;
+ int play_buf_started;
+};
+
+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)
+{
+ int i;
+ spx_word16_t den2;
+#ifdef FIXED_POINT
+ den2 = MULT16_16_Q15(radius,radius) + MULT16_16_Q15(QCONST16(.7,15),MULT16_16_Q15(32767-radius,32767-radius));
+#else
+ den2 = radius*radius + .7*(1-radius)*(1-radius);
+#endif
+ /*printf ("%d %d %d %d %d %d\n", num[0], num[1], num[2], den[0], den[1], den[2]);*/
+ for (i=0;i<len;i++)
+ {
+ spx_word16_t vin = in[i];
+ spx_word32_t vout = mem[0] + SHL32(EXTEND32(vin),15);
+#ifdef FIXED_POINT
+ mem[0] = mem[1] + SHL32(SHL32(-EXTEND32(vin),15) + MULT16_32_Q15(radius,vout),1);
+#else
+ mem[0] = mem[1] + 2*(-vin + radius*vout);
+#endif
+ mem[1] = SHL32(EXTEND32(vin),15) - MULT16_32_Q15(den2,vout);
+ out[i] = SATURATE32(PSHR32(MULT16_32_Q15(radius,vout),15),32767);
+ }
+}
+
+/* This inner product is slightly different from the codec version because of fixed-point */
+static 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;
+ while(len--)
+ {
+ spx_word32_t part=0;
+ part = MAC16_16(part,*x++,*y++);
+ part = MAC16_16(part,*x++,*y++);
+ /* HINT: If you had a 40-bit accumulator, you could shift only at the end */
+ sum = ADD32(sum,SHR32(part,6));
+ }
+ return sum;
+}
+
+/** 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)
+{
+ int i, j;
+ ps[0]=MULT16_16(X[0],X[0]);
+ for (i=1,j=1;i<N-1;i+=2,j++)
+ {
+ ps[j] = MULT16_16(X[i],X[i]) + MULT16_16(X[i+1],X[i+1]);
+ }
+ ps[j]=MULT16_16(X[i],X[i]);
+}
+
+/** Compute cross-power spectrum of a half-complex (packed) vectors and add to acc */
+#ifdef FIXED_POINT
+static 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;
+ spx_word32_t tmp1=0,tmp2=0;
+ for (j=0;j<M;j++)
+ {
+ tmp1 = MAC16_16(tmp1, X[j*N],TOP16(Y[j*N]));
+ }
+ acc[0] = PSHR32(tmp1,WEIGHT_SHIFT);
+ for (i=1;i<N-1;i+=2)
+ {
+ tmp1 = tmp2 = 0;
+ for (j=0;j<M;j++)
+ {
+ tmp1 = SUB32(MAC16_16(tmp1, X[j*N+i],TOP16(Y[j*N+i])), MULT16_16(X[j*N+i+1],TOP16(Y[j*N+i+1])));
+ tmp2 = MAC16_16(MAC16_16(tmp2, X[j*N+i+1],TOP16(Y[j*N+i])), X[j*N+i], TOP16(Y[j*N+i+1]));
+ }
+ acc[i] = PSHR32(tmp1,WEIGHT_SHIFT);
+ acc[i+1] = PSHR32(tmp2,WEIGHT_SHIFT);
+ }
+ tmp1 = tmp2 = 0;
+ for (j=0;j<M;j++)
+ {
+ tmp1 = MAC16_16(tmp1, X[(j+1)*N-1],TOP16(Y[(j+1)*N-1]));
+ }
+ acc[N-1] = PSHR32(tmp1,WEIGHT_SHIFT);
+}
+static inline void spectral_mul_accum16(const spx_word16_t *X, const spx_word16_t *Y, spx_word16_t *acc, int N, int M)
+{
+ int i,j;
+ spx_word32_t tmp1=0,tmp2=0;
+ for (j=0;j<M;j++)
+ {
+ tmp1 = MAC16_16(tmp1, X[j*N],Y[j*N]);
+ }
+ acc[0] = PSHR32(tmp1,WEIGHT_SHIFT);
+ for (i=1;i<N-1;i+=2)
+ {
+ tmp1 = tmp2 = 0;
+ for (j=0;j<M;j++)
+ {
+ tmp1 = SUB32(MAC16_16(tmp1, X[j*N+i],Y[j*N+i]), MULT16_16(X[j*N+i+1],Y[j*N+i+1]));
+ tmp2 = MAC16_16(MAC16_16(tmp2, X[j*N+i+1],Y[j*N+i]), X[j*N+i], Y[j*N+i+1]);
+ }
+ acc[i] = PSHR32(tmp1,WEIGHT_SHIFT);
+ acc[i+1] = PSHR32(tmp2,WEIGHT_SHIFT);
+ }
+ tmp1 = tmp2 = 0;
+ for (j=0;j<M;j++)
+ {
+ tmp1 = MAC16_16(tmp1, X[(j+1)*N-1],Y[(j+1)*N-1]);
+ }
+ 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)
+{
+ int i,j;
+ for (i=0;i<N;i++)
+ acc[i] = 0;
+ for (j=0;j<M;j++)
+ {
+ acc[0] += X[0]*Y[0];
+ for (i=1;i<N-1;i+=2)
+ {
+ acc[i] += (X[i]*Y[i] - X[i+1]*Y[i+1]);
+ acc[i+1] += (X[i+1]*Y[i] + X[i]*Y[i+1]);
+ }
+ acc[i] += X[i]*Y[i];
+ X += N;
+ Y += N;
+ }
+}
+#define spectral_mul_accum16 spectral_mul_accum
+#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_float_t p, const spx_word16_t *X, const spx_word16_t *Y, spx_word32_t *prod, int N)
+{
+ int i, j;
+ spx_float_t W;
+ W = FLOAT_AMULT(p, w[0]);
+ prod[0] = FLOAT_MUL32(W,MULT16_16(X[0],Y[0]));
+ for (i=1,j=1;i<N-1;i+=2,j++)
+ {
+ W = FLOAT_AMULT(p, w[j]);
+ prod[i] = FLOAT_MUL32(W,MAC16_16(MULT16_16(X[i],Y[i]), X[i+1],Y[i+1]));
+ prod[i+1] = FLOAT_MUL32(W,MAC16_16(MULT16_16(-X[i+1],Y[i]), X[i],Y[i+1]));
+ }
+ W = FLOAT_AMULT(p, w[j]);
+ prod[i] = FLOAT_MUL32(W,MULT16_16(X[i],Y[i]));
+}
+
+static inline void mdf_adjust_prop(const spx_word32_t *W, int N, int M, spx_word16_t *prop)
+{
+ int i, j;
+ spx_word16_t max_sum = 1;
+ spx_word32_t prop_sum = 1;
+ for (i=0;i<M;i++)
+ {
+ spx_word32_t tmp = 1;
+ for (j=0;j<N;j++)
+ tmp += MULT16_16(EXTRACT16(SHR32(W[i*N+j],18)), EXTRACT16(SHR32(W[i*N+j],18)));
+#ifdef FIXED_POINT
+ /* Just a security in case an overflow were to occur */
+ tmp = MIN32(ABS32(tmp), 536870912);
+#endif
+ prop[i] = spx_sqrt(tmp);
+ if (prop[i] > max_sum)
+ max_sum = prop[i];
+ }
+ for (i=0;i<M;i++)
+ {
+ prop[i] += MULT16_16_Q15(QCONST16(.1f,15),max_sum);
+ prop_sum += EXTEND32(prop[i]);
+ }
+ for (i=0;i<M;i++)
+ {
+ prop[i] = DIV32(MULT16_16(QCONST16(.99f,15), prop[i]),prop_sum);
+ /*printf ("%f ", prop[i]);*/
+ }
+ /*printf ("\n");*/
+}
+
+#ifdef DUMP_ECHO_CANCEL_DATA
+#include <stdio.h>
+static FILE *rFile=NULL, *pFile=NULL, *oFile=NULL;
+
+static void dump_audio(const spx_int16_t *rec, const spx_int16_t *play, const spx_int16_t *out, int len)
+{
+ if (!(rFile && pFile && oFile))
+ {
+ speex_fatal("Dump files not open");
+ }
+ fwrite(rec, sizeof(spx_int16_t), len, rFile);
+ fwrite(play, sizeof(spx_int16_t), len, pFile);
+ fwrite(out, sizeof(spx_int16_t), len, oFile);
+}
+#endif
+
+/** Creates a new echo canceller state */
+SpeexEchoState *speex_echo_state_init(int frame_size, int filter_length)
+{
+ int i,N,M;
+ SpeexEchoState *st = (SpeexEchoState *)speex_alloc(sizeof(SpeexEchoState));
+
+#ifdef DUMP_ECHO_CANCEL_DATA
+ if (rFile || pFile || oFile)
+ speex_fatal("Opening dump files twice");
+ rFile = fopen("aec_rec.sw", "wb");
+ pFile = fopen("aec_play.sw", "wb");
+ oFile = fopen("aec_out.sw", "wb");
+#endif
+
+ st->frame_size = frame_size;
+ st->window_size = 2*frame_size;
+ N = st->window_size;
+ M = st->M = (filter_length+st->frame_size-1)/frame_size;
+ st->cancel_count=0;
+ st->sum_adapt = 0;
+ st->saturated = 0;
+ st->screwed_up = 0;
+ /* This is the default sampling rate */
+ st->sampling_rate = 8000;
+ st->spec_average = DIV32_16(SHL32(EXTEND32(st->frame_size), 15), st->sampling_rate);
+#ifdef FIXED_POINT
+ st->beta0 = DIV32_16(SHL32(EXTEND32(st->frame_size), 16), st->sampling_rate);
+ st->beta_max = DIV32_16(SHL32(EXTEND32(st->frame_size), 14), st->sampling_rate);
+#else
+ st->beta0 = (2.0f*st->frame_size)/st->sampling_rate;
+ st->beta_max = (.5f*st->frame_size)/st->sampling_rate;
+#endif
+ st->leak_estimate = 0;
+
+ st->fft_table = spx_fft_init(N);
+
+ st->e = (spx_word16_t*)speex_alloc(N*sizeof(spx_word16_t));
+ st->x = (spx_word16_t*)speex_alloc(N*sizeof(spx_word16_t));
+ st->input = (spx_word16_t*)speex_alloc(st->frame_size*sizeof(spx_word16_t));
+ st->y = (spx_word16_t*)speex_alloc(N*sizeof(spx_word16_t));
+ st->last_y = (spx_word16_t*)speex_alloc(N*sizeof(spx_word16_t));
+ st->Yf = (spx_word32_t*)speex_alloc((st->frame_size+1)*sizeof(spx_word32_t));
+ st->Rf = (spx_word32_t*)speex_alloc((st->frame_size+1)*sizeof(spx_word32_t));
+ st->Xf = (spx_word32_t*)speex_alloc((st->frame_size+1)*sizeof(spx_word32_t));
+ st->Yh = (spx_word32_t*)speex_alloc((st->frame_size+1)*sizeof(spx_word32_t));
+ st->Eh = (spx_word32_t*)speex_alloc((st->frame_size+1)*sizeof(spx_word32_t));
+
+ st->X = (spx_word16_t*)speex_alloc((M+1)*N*sizeof(spx_word16_t));
+ st->Y = (spx_word16_t*)speex_alloc(N*sizeof(spx_word16_t));
+ st->E = (spx_word16_t*)speex_alloc(N*sizeof(spx_word16_t));
+ st->W = (spx_word32_t*)speex_alloc(M*N*sizeof(spx_word32_t));
+#ifdef TWO_PATH
+ st->foreground = (spx_word16_t*)speex_alloc(M*N*sizeof(spx_word16_t));
+#endif
+ st->PHI = (spx_word32_t*)speex_alloc(N*sizeof(spx_word32_t));
+ st->power = (spx_word32_t*)speex_alloc((frame_size+1)*sizeof(spx_word32_t));
+ st->power_1 = (spx_float_t*)speex_alloc((frame_size+1)*sizeof(spx_float_t));
+ st->window = (spx_word16_t*)speex_alloc(N*sizeof(spx_word16_t));
+ st->prop = (spx_word16_t*)speex_alloc(M*sizeof(spx_word16_t));
+ st->wtmp = (spx_word16_t*)speex_alloc(N*sizeof(spx_word16_t));
+#ifdef FIXED_POINT
+ st->wtmp2 = (spx_word16_t*)speex_alloc(N*sizeof(spx_word16_t));
+ for (i=0;i<N>>1;i++)
+ {
+ st->window[i] = (16383-SHL16(spx_cos(DIV32_16(MULT16_16(25736,i<<1),N)),1));
+ st->window[N-i-1] = st->window[i];
+ }
+#else
+ for (i=0;i<N;i++)
+ st->window[i] = .5-.5*cos(2*M_PI*i/N);
+#endif
+ for (i=0;i<=st->frame_size;i++)
+ st->power_1[i] = FLOAT_ONE;
+ for (i=0;i<N*M;i++)
+ st->W[i] = 0;
+ {
+ spx_word32_t sum = 0;
+ /* Ratio of ~10 between adaptation rate of first and last block */
+ spx_word16_t decay = SHR32(spx_exp(NEG16(DIV32_16(QCONST16(2.4,11),M))),1);
+ st->prop[0] = QCONST16(.7, 15);
+ sum = EXTEND32(st->prop[0]);
+ for (i=1;i<M;i++)
+ {
+ st->prop[i] = MULT16_16_Q15(st->prop[i-1], decay);
+ sum = ADD32(sum, EXTEND32(st->prop[i]));
+ }
+ for (i=M-1;i>=0;i--)
+ {
+ st->prop[i] = DIV32(MULT16_16(QCONST16(.8,15), st->prop[i]),sum);
+ }
+ }
+
+ st->memX=st->memD=st->memE=0;
+ st->preemph = QCONST16(.9,15);
+ if (st->sampling_rate<12000)
+ st->notch_radius = QCONST16(.9, 15);
+ else if (st->sampling_rate<24000)
+ st->notch_radius = QCONST16(.982, 15);
+ else
+ st->notch_radius = QCONST16(.992, 15);
+
+ st->notch_mem[0] = st->notch_mem[1] = 0;
+ st->adapted = 0;
+ st->Pey = st->Pyy = FLOAT_ONE;
+
+#ifdef TWO_PATH
+ st->Davg1 = st->Davg2 = 0;
+ st->Dvar1 = st->Dvar2 = FLOAT_ZERO;
+#endif
+
+ st->play_buf = (spx_int16_t*)speex_alloc((PLAYBACK_DELAY+1)*st->frame_size*sizeof(spx_int16_t));
+ st->play_buf_pos = PLAYBACK_DELAY*st->frame_size;
+ st->play_buf_started = 0;
+
+ return st;
+}
+
+/** Resets echo canceller state */
+void speex_echo_state_reset(SpeexEchoState *st)
+{
+ int i, M, N;
+ st->cancel_count=0;
+ st->screwed_up = 0;
+ N = st->window_size;
+ M = st->M;
+ for (i=0;i<N*M;i++)
+ st->W[i] = 0;
+#ifdef TWO_PATH
+ for (i=0;i<N*M;i++)
+ st->foreground[i] = 0;
+#endif
+ for (i=0;i<N*(M+1);i++)
+ st->X[i] = 0;
+ for (i=0;i<=st->frame_size;i++)
+ {
+ st->power[i] = 0;
+ st->power_1[i] = FLOAT_ONE;
+ st->Eh[i] = 0;
+ st->Yh[i] = 0;
+ }
+ for (i=0;i<st->frame_size;i++)
+ {
+ st->last_y[i] = 0;
+ }
+ for (i=0;i<N;i++)
+ {
+ st->E[i] = 0;
+ st->x[i] = 0;
+ }
+ st->notch_mem[0] = st->notch_mem[1] = 0;
+ st->memX=st->memD=st->memE=0;
+
+ st->saturated = 0;
+ st->adapted = 0;
+ st->sum_adapt = 0;
+ st->Pey = st->Pyy = FLOAT_ONE;
+#ifdef TWO_PATH
+ st->Davg1 = st->Davg2 = 0;
+ st->Dvar1 = st->Dvar2 = FLOAT_ZERO;
+#endif
+ for (i=0;i<3*st->frame_size;i++)
+ st->play_buf[i] = 0;
+ st->play_buf_pos = PLAYBACK_DELAY*st->frame_size;
+ st->play_buf_started = 0;
+
+}
+
+/** Destroys an echo canceller state */
+void speex_echo_state_destroy(SpeexEchoState *st)
+{
+ spx_fft_destroy(st->fft_table);
+
+ speex_free(st->e);
+ speex_free(st->x);
+ speex_free(st->input);
+ speex_free(st->y);
+ speex_free(st->last_y);
+ speex_free(st->Yf);
+ speex_free(st->Rf);
+ speex_free(st->Xf);
+ speex_free(st->Yh);
+ speex_free(st->Eh);
+
+ speex_free(st->X);
+ speex_free(st->Y);
+ speex_free(st->E);
+ speex_free(st->W);
+#ifdef TWO_PATH
+ speex_free(st->foreground);
+#endif
+ speex_free(st->PHI);
+ speex_free(st->power);
+ speex_free(st->power_1);
+ speex_free(st->window);
+ speex_free(st->prop);
+ speex_free(st->wtmp);
+#ifdef FIXED_POINT
+ speex_free(st->wtmp2);
+#endif
+ speex_free(st->play_buf);
+ speex_free(st);
+
+#ifdef DUMP_ECHO_CANCEL_DATA
+ fclose(rFile);
+ fclose(pFile);
+ fclose(oFile);
+ rFile = pFile = oFile = NULL;
+#endif
+}
+
+void speex_echo_capture(SpeexEchoState *st, const spx_int16_t *rec, spx_int16_t *out)
+{
+ int i;
+ /*speex_warning_int("capture with fill level ", st->play_buf_pos/st->frame_size);*/
+ st->play_buf_started = 1;
+ if (st->play_buf_pos>=st->frame_size)
+ {
+ speex_echo_cancellation(st, rec, st->play_buf, out);
+ st->play_buf_pos -= st->frame_size;
+ for (i=0;i<st->play_buf_pos;i++)
+ st->play_buf[i] = st->play_buf[i+st->frame_size];
+ } else {
+ speex_warning("No playback frame available (your application is buggy and/or got xruns)");
+ if (st->play_buf_pos!=0)
+ {
+ speex_warning("internal playback buffer corruption?");
+ st->play_buf_pos = 0;
+ }
+ for (i=0;i<st->frame_size;i++)
+ out[i] = rec[i];
+ }
+}
+
+void speex_echo_playback(SpeexEchoState *st, const spx_int16_t *play)
+{
+ /*speex_warning_int("playback with fill level ", st->play_buf_pos/st->frame_size);*/
+ if (!st->play_buf_started)
+ {
+ speex_warning("discarded first playback frame");
+ return;
+ }
+ if (st->play_buf_pos<=PLAYBACK_DELAY*st->frame_size)
+ {
+ int i;
+ for (i=0;i<st->frame_size;i++)
+ st->play_buf[st->play_buf_pos+i] = play[i];
+ st->play_buf_pos += st->frame_size;
+ if (st->play_buf_pos <= (PLAYBACK_DELAY-1)*st->frame_size)
+ {
+ speex_warning("Auto-filling the buffer (your application is buggy and/or got xruns)");
+ for (i=0;i<st->frame_size;i++)
+ st->play_buf[st->play_buf_pos+i] = play[i];
+ st->play_buf_pos += st->frame_size;
+ }
+ } else {
+ speex_warning("Had to discard a playback frame (your application is buggy and/or got xruns)");
+ }
+}
+
+/** Performs echo cancellation on a frame (deprecated, last arg now ignored) */
+void speex_echo_cancel(SpeexEchoState *st, const spx_int16_t *in, const spx_int16_t *far_end, spx_int16_t *out, spx_int32_t *Yout)
+{
+ speex_echo_cancellation(st, in, far_end, out);
+}
+
+/** Performs echo cancellation on a frame */
+void speex_echo_cancellation(SpeexEchoState *st, const spx_int16_t *in, const spx_int16_t *far_end, spx_int16_t *out)
+{
+ int i,j;
+ int N,M;
+ spx_word32_t Syy,See,Sxx,Sdd, Sff;
+#ifdef TWO_PATH
+ spx_word32_t Dbf;
+ int update_foreground;
+#endif
+ spx_word32_t Sey;
+ spx_word16_t ss, ss_1;
+ spx_float_t Pey = FLOAT_ONE, Pyy=FLOAT_ONE;
+ spx_float_t alpha, alpha_1;
+ spx_word16_t RER;
+ spx_word32_t tmp32;
+
+ N = st->window_size;
+ M = st->M;
+ st->cancel_count++;
+#ifdef FIXED_POINT
+ ss=DIV32_16(11469,M);
+ ss_1 = SUB16(32767,ss);
+#else
+ ss=.35/M;
+ ss_1 = 1-ss;
+#endif
+
+ /* Apply a notch filter to make sure DC doesn't end up causing problems */
+ filter_dc_notch16(in, st->notch_radius, st->input, st->frame_size, st->notch_mem);
+ /* Copy input data to buffer and apply pre-emphasis */
+ for (i=0;i<st->frame_size;i++)
+ {
+ spx_word32_t tmp32;
+ tmp32 = SUB32(EXTEND32(far_end[i]), EXTEND32(MULT16_16_P15(st->preemph, st->memX)));
+#ifdef FIXED_POINT
+ /* If saturation occurs here, we need to freeze adaptation for M+1 frames (not just one) */
+ if (tmp32 > 32767)
+ {
+ tmp32 = 32767;
+ st->saturated = M+1;
+ }
+ if (tmp32 < -32767)
+ {
+ tmp32 = -32767;
+ st->saturated = M+1;
+ }
+#endif
+ st->x[i+st->frame_size] = EXTRACT16(tmp32);
+ st->memX = far_end[i];
+
+ tmp32 = SUB32(EXTEND32(st->input[i]), EXTEND32(MULT16_16_P15(st->preemph, st->memD)));
+#ifdef FIXED_POINT
+ if (tmp32 > 32767)
+ {
+ tmp32 = 32767;
+ if (st->saturated == 0)
+ st->saturated = 1;
+ }
+ if (tmp32 < -32767)
+ {
+ tmp32 = -32767;
+ if (st->saturated == 0)
+ st->saturated = 1;
+ }
+#endif
+ st->memD = st->input[i];
+ st->input[i] = tmp32;
+ }
+
+ /* Shift memory: this could be optimized eventually*/
+ for (j=M-1;j>=0;j--)
+ {
+ for (i=0;i<N;i++)
+ st->X[(j+1)*N+i] = st->X[j*N+i];
+ }
+
+ /* Convert x (far end) to frequency domain */
+ spx_fft(st->fft_table, st->x, &st->X[0]);
+ for (i=0;i<N;i++)
+ st->last_y[i] = st->x[i];
+ Sxx = mdf_inner_prod(st->x+st->frame_size, st->x+st->frame_size, st->frame_size);
+ for (i=0;i<st->frame_size;i++)
+ st->x[i] = st->x[i+st->frame_size];
+ /* From here on, the top part of x is used as scratch space */
+
+#ifdef TWO_PATH
+ /* Compute foreground filter */
+ spectral_mul_accum16(st->X, st->foreground, st->Y, N, M);
+ spx_ifft(st->fft_table, st->Y, st->e);
+ for (i=0;i<st->frame_size;i++)
+ st->e[i] = SUB16(st->input[i], st->e[i+st->frame_size]);
+ Sff = mdf_inner_prod(st->e, st->e, st->frame_size);
+#endif
+
+ /* Adjust proportional adaption rate */
+ mdf_adjust_prop (st->W, N, M, st->prop);
+ /* Compute weight gradient */
+ if (st->saturated == 0)
+ {
+ for (j=M-1;j>=0;j--)
+ {
+ weighted_spectral_mul_conj(st->power_1, FLOAT_SHL(PSEUDOFLOAT(st->prop[j]),-15), &st->X[(j+1)*N], st->E, st->PHI, N);
+ for (i=0;i<N;i++)
+ st->W[j*N+i] = ADD32(st->W[j*N+i], st->PHI[i]);
+
+ }
+ } else {
+ st->saturated--;
+ }
+
+ /* Update weight to prevent circular convolution (MDF / AUMDF) */
+ for (j=0;j<M;j++)
+ {
+ /* This is a variant of the Alternatively Updated MDF (AUMDF) */
+ /* Remove the "if" to make this an MDF filter */
+ if (j==0 || st->cancel_count%(M-1) == j-1)
+ {
+#ifdef FIXED_POINT
+ for (i=0;i<N;i++)
+ st->wtmp2[i] = EXTRACT16(PSHR32(st->W[j*N+i],NORMALIZE_SCALEDOWN+16));
+ spx_ifft(st->fft_table, st->wtmp2, st->wtmp);
+ for (i=0;i<st->frame_size;i++)
+ {
+ st->wtmp[i]=0;
+ }
+ for (i=st->frame_size;i<N;i++)
+ {
+ st->wtmp[i]=SHL16(st->wtmp[i],NORMALIZE_SCALEUP);
+ }
+ spx_fft(st->fft_table, st->wtmp, st->wtmp2);
+ /* The "-1" in the shift is a sort of kludge that trades less efficient update speed for decrease noise */
+ for (i=0;i<N;i++)
+ st->W[j*N+i] -= SHL32(EXTEND32(st->wtmp2[i]),16+NORMALIZE_SCALEDOWN-NORMALIZE_SCALEUP-1);
+#else
+ spx_ifft(st->fft_table, &st->W[j*N], st->wtmp);
+ for (i=st->frame_size;i<N;i++)
+ {
+ st->wtmp[i]=0;
+ }
+ spx_fft(st->fft_table, st->wtmp, &st->W[j*N]);
+#endif
+ }
+ }
+
+ /* Compute filter response Y */
+ spectral_mul_accum(st->X, st->W, st->Y, N, M);
+ spx_ifft(st->fft_table, st->Y, st->y);
+
+#ifdef TWO_PATH
+ /* Difference in response, this is used to estimate the variance of our residual power estimate */
+ for (i=0;i<st->frame_size;i++)
+ st->e[i] = SUB16(st->e[i+st->frame_size], st->y[i+st->frame_size]);
+ Dbf = 10+mdf_inner_prod(st->e, st->e, st->frame_size);
+#endif
+
+ for (i=0;i<st->frame_size;i++)
+ st->e[i] = SUB16(st->input[i], st->y[i+st->frame_size]);
+ See = mdf_inner_prod(st->e, st->e, st->frame_size);
+#ifndef TWO_PATH
+ Sff = See;
+#endif
+
+#ifdef TWO_PATH
+ /* Logic for updating the foreground filter */
+
+ /* For two time windows, compute the mean of the energy difference, as well as the variance */
+ st->Davg1 = ADD32(MULT16_32_Q15(QCONST16(.6f,15),st->Davg1), MULT16_32_Q15(QCONST16(.4f,15),SUB32(Sff,See)));
+ st->Davg2 = ADD32(MULT16_32_Q15(QCONST16(.85f,15),st->Davg2), MULT16_32_Q15(QCONST16(.15f,15),SUB32(Sff,See)));
+ st->Dvar1 = FLOAT_ADD(FLOAT_MULT(VAR1_SMOOTH, st->Dvar1), FLOAT_MUL32U(MULT16_32_Q15(QCONST16(.4f,15),Sff), MULT16_32_Q15(QCONST16(.4f,15),Dbf)));
+ st->Dvar2 = FLOAT_ADD(FLOAT_MULT(VAR2_SMOOTH, st->Dvar2), FLOAT_MUL32U(MULT16_32_Q15(QCONST16(.15f,15),Sff), MULT16_32_Q15(QCONST16(.15f,15),Dbf)));
+
+ /* Equivalent float code:
+ st->Davg1 = .6*st->Davg1 + .4*(Sff-See);
+ st->Davg2 = .85*st->Davg2 + .15*(Sff-See);
+ st->Dvar1 = .36*st->Dvar1 + .16*Sff*Dbf;
+ st->Dvar2 = .7225*st->Dvar2 + .0225*Sff*Dbf;
+ */
+
+ update_foreground = 0;
+ /* Check if we have a statistically significant reduction in the residual echo */
+ /* Note that this is *not* Gaussian, so we need to be careful about the longer tail */
+ if (FLOAT_GT(FLOAT_MUL32U(SUB32(Sff,See),ABS32(SUB32(Sff,See))), FLOAT_MUL32U(Sff,Dbf)))
+ update_foreground = 1;
+ else if (FLOAT_GT(FLOAT_MUL32U(st->Davg1, ABS32(st->Davg1)), FLOAT_MULT(VAR1_UPDATE,(st->Dvar1))))
+ update_foreground = 1;
+ else if (FLOAT_GT(FLOAT_MUL32U(st->Davg2, ABS32(st->Davg2)), FLOAT_MULT(VAR2_UPDATE,(st->Dvar2))))
+ update_foreground = 1;
+
+ /* Do we update? */
+ if (update_foreground)
+ {
+ st->Davg1 = st->Davg2 = 0;
+ st->Dvar1 = st->Dvar2 = FLOAT_ZERO;
+ /* Copy background filter to foreground filter */
+ for (i=0;i<N*M;i++)
+ st->foreground[i] = EXTRACT16(PSHR32(st->W[i],16));
+ /* Apply a smooth transition so as to not introduce blocking artifacts */
+ for (i=0;i<st->frame_size;i++)
+ st->e[i+st->frame_size] = MULT16_16_Q15(st->window[i+st->frame_size],st->e[i+st->frame_size]) + MULT16_16_Q15(st->window[i],st->y[i+st->frame_size]);
+ } else {
+ int reset_background=0;
+ /* Otherwise, check if the background filter is significantly worse */
+ if (FLOAT_GT(FLOAT_MUL32U(NEG32(SUB32(Sff,See)),ABS32(SUB32(Sff,See))), FLOAT_MULT(VAR_BACKTRACK,FLOAT_MUL32U(Sff,Dbf))))
+ reset_background = 1;
+ if (FLOAT_GT(FLOAT_MUL32U(NEG32(st->Davg1), ABS32(st->Davg1)), FLOAT_MULT(VAR_BACKTRACK,st->Dvar1)))
+ reset_background = 1;
+ if (FLOAT_GT(FLOAT_MUL32U(NEG32(st->Davg2), ABS32(st->Davg2)), FLOAT_MULT(VAR_BACKTRACK,st->Dvar2)))
+ reset_background = 1;
+ if (reset_background)
+ {
+ /* Copy foreground filter to background filter */
+ for (i=0;i<N*M;i++)
+ st->W[i] = SHL32(EXTEND32(st->foreground[i]),16);
+ /* We also need to copy the output so as to get correct adaptation */
+ for (i=0;i<st->frame_size;i++)
+ st->y[i+st->frame_size] = st->e[i+st->frame_size];
+ for (i=0;i<st->frame_size;i++)
+ st->e[i] = SUB16(st->input[i], st->y[i+st->frame_size]);
+ See = Sff;
+ st->Davg1 = st->Davg2 = 0;
+ st->Dvar1 = st->Dvar2 = FLOAT_ZERO;
+ }
+ }
+#endif
+
+ /* Compute error signal (for the output with de-emphasis) */
+ for (i=0;i<st->frame_size;i++)
+ {
+ spx_word32_t tmp_out;
+#ifdef TWO_PATH
+ tmp_out = SUB32(EXTEND32(st->input[i]), EXTEND32(st->e[i+st->frame_size]));
+#else
+ tmp_out = SUB32(EXTEND32(st->input[i]), EXTEND32(st->y[i+st->frame_size]));
+#endif
+ /* Saturation */
+ if (tmp_out>32767)
+ tmp_out = 32767;
+ else if (tmp_out<-32768)
+ tmp_out = -32768;
+ tmp_out = ADD32(tmp_out, EXTEND32(MULT16_16_P15(st->preemph, st->memE)));
+ /* This is an arbitrary test for saturation in the microphone signal */
+ if (in[i] <= -32000 || in[i] >= 32000)
+ {
+ tmp_out = 0;
+ if (st->saturated == 0)
+ st->saturated = 1;
+ }
+ out[i] = (spx_int16_t)tmp_out;
+ st->memE = tmp_out;
+ }
+
+#ifdef DUMP_ECHO_CANCEL_DATA
+ dump_audio(in, far_end, out, st->frame_size);
+#endif
+
+ /* Compute error signal (filter update version) */
+ for (i=0;i<st->frame_size;i++)
+ {
+ st->e[i+st->frame_size] = st->e[i];
+ st->e[i] = 0;
+ }
+
+ /* Compute a bunch of correlations */
+ Sey = mdf_inner_prod(st->e+st->frame_size, st->y+st->frame_size, st->frame_size);
+ Syy = mdf_inner_prod(st->y+st->frame_size, st->y+st->frame_size, st->frame_size);
+ Sdd = mdf_inner_prod(st->input, st->input, st->frame_size);
+
+ /*printf ("%f %f %f %f\n", Sff, See, Syy, Sdd, st->update_cond);*/
+
+ /* Do some sanity check */
+ if (!(Syy>=0 && Sxx>=0 && See >= 0)
+#ifndef FIXED_POINT
+ || !(Sff < N*1e9 && Syy < N*1e9 && Sxx < N*1e9)
+#endif
+ )
+ {
+ /* Things have gone really bad */
+ st->screwed_up += 50;
+ for (i=0;i<st->frame_size;i++)
+ out[i] = 0;
+ } else if (SHR32(Sff, 2) > ADD32(Sdd, SHR32(MULT16_16(N, 10000),6)))
+ {
+ /* AEC seems to add lots of echo instead of removing it, let's see if it will improve */
+ st->screwed_up++;
+ } else {
+ /* Everything's fine */
+ st->screwed_up=0;
+ }
+ if (st->screwed_up>=50)
+ {
+ speex_warning("The echo canceller started acting funny and got slapped (reset). It swears it will behave now.");
+ speex_echo_state_reset(st);
+ return;
+ }
+
+ /* Add a small noise floor to make sure not to have problems when dividing */
+ See = MAX32(See, SHR32(MULT16_16(N, 100),6));
+
+ /* Convert error to frequency domain */
+ spx_fft(st->fft_table, st->e, st->E);
+ for (i=0;i<st->frame_size;i++)
+ st->y[i] = 0;
+ spx_fft(st->fft_table, st->y, st->Y);
+
+ /* Compute power spectrum of far end (X), error (E) and filter response (Y) */
+ power_spectrum(st->E, st->Rf, N);
+ power_spectrum(st->Y, st->Yf, N);
+ power_spectrum(st->X, st->Xf, N);
+
+ /* Smooth far end energy estimate over time */
+ for (j=0;j<=st->frame_size;j++)
+ st->power[j] = MULT16_32_Q15(ss_1,st->power[j]) + 1 + MULT16_32_Q15(ss,st->Xf[j]);
+
+ /* Enable this to compute the power based only on the tail (would need to compute more
+ efficiently to make this really useful */
+ if (0)
+ {
+ float scale2 = .5f/M;
+ for (j=0;j<=st->frame_size;j++)
+ st->power[j] = 100;
+ for (i=0;i<M;i++)
+ {
+ power_spectrum(&st->X[i*N], st->Xf, N);
+ for (j=0;j<=st->frame_size;j++)
+ st->power[j] += scale2*st->Xf[j];
+ }
+ }
+
+ /* Compute filtered spectra and (cross-)correlations */
+ for (j=st->frame_size;j>=0;j--)
+ {
+ spx_float_t Eh, Yh;
+ Eh = PSEUDOFLOAT(st->Rf[j] - st->Eh[j]);
+ Yh = PSEUDOFLOAT(st->Yf[j] - st->Yh[j]);
+ Pey = FLOAT_ADD(Pey,FLOAT_MULT(Eh,Yh));
+ Pyy = FLOAT_ADD(Pyy,FLOAT_MULT(Yh,Yh));
+#ifdef FIXED_POINT
+ st->Eh[j] = MAC16_32_Q15(MULT16_32_Q15(SUB16(32767,st->spec_average),st->Eh[j]), st->spec_average, st->Rf[j]);
+ st->Yh[j] = MAC16_32_Q15(MULT16_32_Q15(SUB16(32767,st->spec_average),st->Yh[j]), st->spec_average, st->Yf[j]);
+#else
+ st->Eh[j] = (1-st->spec_average)*st->Eh[j] + st->spec_average*st->Rf[j];
+ st->Yh[j] = (1-st->spec_average)*st->Yh[j] + st->spec_average*st->Yf[j];
+#endif
+ }
+
+ Pyy = FLOAT_SQRT(Pyy);
+ Pey = FLOAT_DIVU(Pey,Pyy);
+
+ /* Compute correlation updatete rate */
+ tmp32 = MULT16_32_Q15(st->beta0,Syy);
+ if (tmp32 > MULT16_32_Q15(st->beta_max,See))
+ tmp32 = MULT16_32_Q15(st->beta_max,See);
+ alpha = FLOAT_DIV32(tmp32, See);
+ alpha_1 = FLOAT_SUB(FLOAT_ONE, alpha);
+ /* Update correlations (recursive average) */
+ st->Pey = FLOAT_ADD(FLOAT_MULT(alpha_1,st->Pey) , FLOAT_MULT(alpha,Pey));
+ st->Pyy = FLOAT_ADD(FLOAT_MULT(alpha_1,st->Pyy) , FLOAT_MULT(alpha,Pyy));
+ if (FLOAT_LT(st->Pyy, FLOAT_ONE))
+ st->Pyy = FLOAT_ONE;
+ /* We don't really hope to get better than 33 dB (MIN_LEAK-3dB) attenuation anyway */
+ if (FLOAT_LT(st->Pey, FLOAT_MULT(MIN_LEAK,st->Pyy)))
+ st->Pey = FLOAT_MULT(MIN_LEAK,st->Pyy);
+ if (FLOAT_GT(st->Pey, st->Pyy))
+ st->Pey = st->Pyy;
+ /* leak_estimate is the linear regression result */
+ st->leak_estimate = FLOAT_EXTRACT16(FLOAT_SHL(FLOAT_DIVU(st->Pey, st->Pyy),14));
+ /* This looks like a stupid bug, but it's right (because we convert from Q14 to Q15) */
+ if (st->leak_estimate > 16383)
+ st->leak_estimate = 32767;
+ else
+ st->leak_estimate = SHL16(st->leak_estimate,1);
+ /*printf ("%f\n", st->leak_estimate);*/
+
+ /* Compute Residual to Error Ratio */
+#ifdef FIXED_POINT
+ tmp32 = MULT16_32_Q15(st->leak_estimate,Syy);
+ tmp32 = ADD32(SHR32(Sxx,13), ADD32(tmp32, SHL32(tmp32,1)));
+ /* Check for y in e (lower bound on RER) */
+ {
+ spx_float_t bound = PSEUDOFLOAT(Sey);
+ bound = FLOAT_DIVU(FLOAT_MULT(bound, bound), PSEUDOFLOAT(ADD32(1,Syy)));
+ if (FLOAT_GT(bound, PSEUDOFLOAT(See)))
+ tmp32 = See;
+ else if (tmp32 < FLOAT_EXTRACT32(bound))
+ tmp32 = FLOAT_EXTRACT32(bound);
+ }
+ if (tmp32 > SHR32(See,1))
+ tmp32 = SHR32(See,1);
+ RER = FLOAT_EXTRACT16(FLOAT_SHL(FLOAT_DIV32(tmp32,See),15));
+#else
+ RER = (.0001*Sxx + 3.*MULT16_32_Q15(st->leak_estimate,Syy)) / See;
+ /* Check for y in e (lower bound on RER) */
+ if (RER < Sey*Sey/(1+See*Syy))
+ RER = Sey*Sey/(1+See*Syy);
+ if (RER > .5)
+ RER = .5;
+#endif
+
+ /* We consider that the filter has had minimal adaptation if the following is true*/
+ if (!st->adapted && st->sum_adapt > SHL32(EXTEND32(M),15) && MULT16_32_Q15(st->leak_estimate,Syy) > MULT16_32_Q15(QCONST16(.03f,15),Syy))
+ {
+ st->adapted = 1;
+ }
+
+ if (st->adapted)
+ {
+ /* Normal learning rate calculation once we're past the minimal adaptation phase */
+ for (i=0;i<=st->frame_size;i++)
+ {
+ spx_word32_t r, e;
+ /* Compute frequency-domain adaptation mask */
+ r = MULT16_32_Q15(st->leak_estimate,SHL32(st->Yf[i],3));
+ e = SHL32(st->Rf[i],3)+1;
+#ifdef FIXED_POINT
+ if (r>SHR32(e,1))
+ r = SHR32(e,1);
+#else
+ if (r>.5*e)
+ r = .5*e;
+#endif
+ r = MULT16_32_Q15(QCONST16(.7,15),r) + MULT16_32_Q15(QCONST16(.3,15),(spx_word32_t)(MULT16_32_Q15(RER,e)));
+ /*st->power_1[i] = adapt_rate*r/(e*(1+st->power[i]));*/
+ st->power_1[i] = FLOAT_SHL(FLOAT_DIV32_FLOAT(r,FLOAT_MUL32U(e,st->power[i]+10)),WEIGHT_SHIFT+16);
+ }
+ } else {
+ /* Temporary adaption rate if filter is not yet adapted enough */
+ spx_word16_t adapt_rate=0;
+
+ if (Sxx > SHR32(MULT16_16(N, 1000),6))
+ {
+ tmp32 = MULT16_32_Q15(QCONST16(.25f, 15), Sxx);
+#ifdef FIXED_POINT
+ if (tmp32 > SHR32(See,2))
+ tmp32 = SHR32(See,2);
+#else
+ if (tmp32 > .25*See)
+ tmp32 = .25*See;
+#endif
+ adapt_rate = FLOAT_EXTRACT16(FLOAT_SHL(FLOAT_DIV32(tmp32, See),15));
+ }
+ for (i=0;i<=st->frame_size;i++)
+ st->power_1[i] = FLOAT_SHL(FLOAT_DIV32(EXTEND32(adapt_rate),ADD32(st->power[i],10)),WEIGHT_SHIFT+1);
+
+
+ /* How much have we adapted so far? */
+ st->sum_adapt = ADD32(st->sum_adapt,adapt_rate);
+ }
+
+ /* Save residual echo so it can be used by the nonlinear processor */
+ if (st->adapted)
+ {
+ /* If the filter is adapted, take the filtered echo */
+ for (i=0;i<st->frame_size;i++)
+ st->last_y[i] = st->last_y[st->frame_size+i];
+ for (i=0;i<st->frame_size;i++)
+ st->last_y[st->frame_size+i] = in[i]-out[i];
+ } else {
+ /* If filter isn't adapted yet, all we can do is take the far end signal directly */
+ /* moved earlier: for (i=0;i<N;i++)
+ st->last_y[i] = st->x[i];*/
+ }
+
+}
+
+/* Compute spectrum of estimated echo for use in an echo post-filter */
+void speex_echo_get_residual(SpeexEchoState *st, spx_word32_t *residual_echo, int len)
+{
+ int i;
+ spx_word16_t leak2;
+ int N;
+
+ N = st->window_size;
+
+ /* Apply hanning window (should pre-compute it)*/
+ for (i=0;i<N;i++)
+ st->y[i] = MULT16_16_Q15(st->window[i],st->last_y[i]);
+
+ /* Compute power spectrum of the echo */
+ spx_fft(st->fft_table, st->y, st->Y);
+ power_spectrum(st->Y, residual_echo, N);
+
+#ifdef FIXED_POINT
+ if (st->leak_estimate > 16383)
+ leak2 = 32767;
+ else
+ leak2 = SHL16(st->leak_estimate, 1);
+#else
+ if (st->leak_estimate>.5)
+ leak2 = 1;
+ else
+ leak2 = 2*st->leak_estimate;
+#endif
+ /* Estimate residual echo */
+ for (i=0;i<=st->frame_size;i++)
+ residual_echo[i] = (spx_int32_t)MULT16_32_Q15(leak2,residual_echo[i]);
+
+}
+
+int speex_echo_ctl(SpeexEchoState *st, int request, void *ptr)
+{
+ switch(request)
+ {
+
+ case SPEEX_ECHO_GET_FRAME_SIZE:
+ (*(int*)ptr) = st->frame_size;
+ break;
+ case SPEEX_ECHO_SET_SAMPLING_RATE:
+ st->sampling_rate = (*(int*)ptr);
+ st->spec_average = DIV32_16(SHL32(EXTEND32(st->frame_size), 15), st->sampling_rate);
+#ifdef FIXED_POINT
+ st->beta0 = DIV32_16(SHL32(EXTEND32(st->frame_size), 16), st->sampling_rate);
+ st->beta_max = DIV32_16(SHL32(EXTEND32(st->frame_size), 14), st->sampling_rate);
+#else
+ st->beta0 = (2.0f*st->frame_size)/st->sampling_rate;
+ st->beta_max = (.5f*st->frame_size)/st->sampling_rate;
+#endif
+ if (st->sampling_rate<12000)
+ st->notch_radius = QCONST16(.9, 15);
+ else if (st->sampling_rate<24000)
+ st->notch_radius = QCONST16(.982, 15);
+ else
+ st->notch_radius = QCONST16(.992, 15);
+ break;
+ case SPEEX_ECHO_GET_SAMPLING_RATE:
+ (*(int*)ptr) = st->sampling_rate;
+ break;
+ default:
+ speex_warning_int("Unknown speex_echo_ctl request: ", request);
+ return -1;
+ }
+ return 0;
+}
diff --git a/jni/pjproject-android/.svn/pristine/cc/cc7df8a172bae7e0ea5222eb819b8d26d7dd9e89.svn-base b/jni/pjproject-android/.svn/pristine/cc/cc7df8a172bae7e0ea5222eb819b8d26d7dd9e89.svn-base
new file mode 100644
index 0000000..1a8229d
--- /dev/null
+++ b/jni/pjproject-android/.svn/pristine/cc/cc7df8a172bae7e0ea5222eb819b8d26d7dd9e89.svn-base
@@ -0,0 +1,4 @@
+export M_CFLAGS := $(CC_DEF)PJ_M_I386=1
+export M_CXXFLAGS :=
+export M_LDFLAGS :=
+export M_SOURCES :=
diff --git a/jni/pjproject-android/.svn/pristine/cc/cc84754b75564559efe7069d9b85f7b6f3791f43.svn-base b/jni/pjproject-android/.svn/pristine/cc/cc84754b75564559efe7069d9b85f7b6f3791f43.svn-base
new file mode 100644
index 0000000..27300c5
--- /dev/null
+++ b/jni/pjproject-android/.svn/pristine/cc/cc84754b75564559efe7069d9b85f7b6f3791f43.svn-base
@@ -0,0 +1,549 @@
+/* $Id$ */
+/*
+ * Copyright (C) 2008-2011 Teluu Inc. (http://www.teluu.com)
+ * Copyright (C) 2003-2008 Benny Prijono <benny@prijono.org>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ */
+/*
+ * Based on implementation found in Carnegie Mellon Speech Group Software
+ * depository (ftp://ftp.cs.cmu.edu/project/fgdata/index.html). No copyright
+ * was claimed in the original source codes.
+ */
+#include <pjmedia/errno.h>
+#include <pj/assert.h>
+#include <pj/pool.h>
+
+#include "g722_dec.h"
+
+#if defined(PJMEDIA_HAS_G722_CODEC) && (PJMEDIA_HAS_G722_CODEC != 0)
+
+#define MODE 1
+
+#define SATURATE(v, max, min) \
+ if (v>max) v = max; \
+ else if (v<min) v = min
+
+extern const int g722_qmf_coeff[24];
+
+static const int qm4[16] =
+{
+ 0, -20456, -12896, -8968,
+ -6288, -4240, -2584, -1200,
+ 20456, 12896, 8968, 6288,
+ 4240, 2584, 1200, 0
+};
+static const int ilb[32] = {
+ 2048, 2093, 2139, 2186, 2233, 2282, 2332,
+ 2383, 2435, 2489, 2543, 2599, 2656, 2714,
+ 2774, 2834, 2896, 2960, 3025, 3091, 3158,
+ 3228, 3298, 3371, 3444, 3520, 3597, 3676,
+ 3756, 3838, 3922, 4008
+};
+
+
+static int block2l (int il, int detl)
+{
+ int dlt ;
+ int ril, wd2 ;
+
+ /* INVQAL */
+ ril = il >> 2 ;
+ wd2 = qm4[ril] ;
+ dlt = (detl * wd2) >> 15 ;
+
+ return (dlt) ;
+}
+
+
+static int block3l (g722_dec_t *dec, int il)
+{
+ int detl ;
+ int ril, il4, wd, wd1, wd2, wd3, nbpl, depl ;
+ static const int wl[8] = {
+ -60, -30, 58, 172, 334, 538, 1198, 3042
+ };
+ static const int rl42[16] = {
+ 0, 7, 6, 5, 4, 3, 2, 1, 7, 6, 5, 4, 3, 2, 1, 0
+ };
+
+ /* LOGSCL */
+ ril = il >> 2 ;
+ il4 = rl42[ril] ;
+ wd = (dec->nbl * 32512) >> 15 ;
+ nbpl = wd + wl[il4] ;
+
+ if (nbpl < 0) nbpl = 0 ;
+ if (nbpl > 18432) nbpl = 18432 ;
+
+ /* SCALEL */
+ wd1 = (nbpl >> 6) & 31 ;
+ wd2 = nbpl >> 11 ;
+ if ((8 - wd2) < 0) wd3 = ilb[wd1] << (wd2 - 8) ;
+ else wd3 = ilb[wd1] >> (8 - wd2) ;
+ depl = wd3 << 2 ;
+
+ /* DELAYA */
+ dec->nbl = nbpl ;
+ /* DELAYL */
+ detl = depl ;
+
+ return (detl) ;
+}
+
+
+static int block4l (g722_dec_t *dec, int dl)
+{
+ int sl = dec->slow ;
+ int i ;
+ int wd, wd1, wd2, wd3, wd4, wd5/*, wd6 */;
+
+ dec->dlt[0] = dl;
+
+ /* RECONS */
+ dec->rlt[0] = sl + dec->dlt[0] ;
+ SATURATE(dec->rlt[0], 32767, -32768);
+
+ /* PARREC */
+ dec->plt[0] = dec->dlt[0] + dec->szl ;
+ SATURATE(dec->plt[0], 32767, -32768);
+
+ /* UPPOL2 */
+ dec->sgl[0] = dec->plt[0] >> 15 ;
+ dec->sgl[1] = dec->plt[1] >> 15 ;
+ dec->sgl[2] = dec->plt[2] >> 15 ;
+
+ wd1 = dec->al[1] << 2;
+ SATURATE(wd1, 32767, -32768);
+
+ if ( dec->sgl[0] == dec->sgl[1] ) wd2 = - wd1 ;
+ else wd2 = wd1 ;
+ if (wd2 > 32767) wd2 = 32767;
+ wd2 = wd2 >> 7 ;
+
+ if ( dec->sgl[0] == dec->sgl[2] ) wd3 = 128 ;
+ else wd3 = - 128 ;
+
+ wd4 = wd2 + wd3 ;
+ wd5 = (dec->al[2] * 32512) >> 15 ;
+
+ dec->apl[2] = wd4 + wd5 ;
+ SATURATE(dec->apl[2], 12288, -12288);
+
+ /* UPPOL1 */
+ dec->sgl[0] = dec->plt[0] >> 15 ;
+ dec->sgl[1] = dec->plt[1] >> 15 ;
+
+ if ( dec->sgl[0] == dec->sgl[1] ) wd1 = 192 ;
+ else wd1 = - 192 ;
+
+ wd2 = (dec->al[1] * 32640) >> 15 ;
+
+ dec->apl[1] = wd1 + wd2 ;
+ SATURATE(dec->apl[1], 32767, -32768);
+
+ wd3 = (15360 - dec->apl[2]) ;
+ SATURATE(wd3, 32767, -32768);
+ if ( dec->apl[1] > wd3) dec->apl[1] = wd3 ;
+ if ( dec->apl[1] < -wd3) dec->apl[1] = -wd3 ;
+
+ /* UPZERO */
+ if ( dec->dlt[0] == 0 ) wd1 = 0 ;
+ else wd1 = 128 ;
+
+ dec->sgl[0] = dec->dlt[0] >> 15 ;
+
+ for ( i = 1; i < 7; i++ ) {
+ dec->sgl[i] = dec->dlt[i] >> 15 ;
+ if ( dec->sgl[i] == dec->sgl[0] ) wd2 = wd1 ;
+ else wd2 = - wd1 ;
+ wd3 = (dec->bl[i] * 32640) >> 15 ;
+ dec->bpl[i] = wd2 + wd3 ;
+ SATURATE(dec->bpl[i], 32767, -32768);
+ }
+
+ /* DELAYA */
+ for ( i = 6; i > 0; i-- ) {
+ dec->dlt[i] = dec->dlt[i-1] ;
+ dec->bl[i] = dec->bpl[i] ;
+ }
+
+ for ( i = 2; i > 0; i-- ) {
+ dec->rlt[i] = dec->rlt[i-1] ;
+ dec->plt[i] = dec->plt[i-1] ;
+ dec->al[i] = dec->apl[i] ;
+ }
+
+ /* FILTEP */
+ wd1 = dec->rlt[1] << 1;
+ SATURATE(wd1, 32767, -32768);
+ wd1 = ( dec->al[1] * wd1 ) >> 15 ;
+
+ wd2 = dec->rlt[2] << 1;
+ SATURATE(wd2, 32767, -32768);
+ wd2 = ( dec->al[2] * wd2 ) >> 15 ;
+
+ dec->spl = wd1 + wd2 ;
+ SATURATE(dec->spl, 32767, -32768);
+
+ /* FILTEZ */
+ dec->szl = 0 ;
+ for (i=6; i>0; i--) {
+ wd = dec->dlt[i] << 1;
+ SATURATE(wd, 32767, -32768);
+ dec->szl += (dec->bl[i] * wd) >> 15 ;
+ SATURATE(dec->szl, 32767, -32768);
+ }
+
+ /* PREDIC */
+ sl = dec->spl + dec->szl ;
+ SATURATE(sl, 32767, -32768);
+
+ return (sl) ;
+}
+
+static int block5l (int ilr, int sl, int detl, int mode)
+{
+ int yl ;
+ int ril, dl, wd2 = 0;
+ static const int qm5[32] = {
+ -280, -280, -23352, -17560,
+ -14120, -11664, -9752, -8184,
+ -6864, -5712, -4696, -3784,
+ -2960, -2208, -1520, -880,
+ 23352, 17560, 14120, 11664,
+ 9752, 8184, 6864, 5712,
+ 4696, 3784, 2960, 2208,
+ 1520, 880, 280, -280
+ };
+ static const int qm6[64] = {
+ -136, -136, -136, -136,
+ -24808, -21904, -19008, -16704,
+ -14984, -13512, -12280, -11192,
+ -10232, -9360, -8576, -7856,
+ -7192, -6576, -6000, -5456,
+ -4944, -4464, -4008, -3576,
+ -3168, -2776, -2400, -2032,
+ -1688, -1360, -1040, -728,
+ 24808, 21904, 19008, 16704,
+ 14984, 13512, 12280, 11192,
+ 10232, 9360, 8576, 7856,
+ 7192, 6576, 6000, 5456,
+ 4944, 4464, 4008, 3576,
+ 3168, 2776, 2400, 2032,
+ 1688, 1360, 1040, 728,
+ 432, 136, -432, -136
+ };
+
+ /* INVQBL */
+ if (mode == 1) {
+ ril = ilr ;
+ wd2 = qm6[ril] ;
+ }
+
+ if (mode == 2) {
+ ril = ilr >> 1 ;
+ wd2 = qm5[ril] ;
+ }
+
+ if (mode == 3) {
+ ril = ilr >> 2 ;
+ wd2 = qm4[ril] ;
+ }
+
+ dl = (detl * wd2 ) >> 15 ;
+
+ /* RECONS */
+ yl = sl + dl ;
+ SATURATE(yl, 32767, -32768);
+
+ return (yl) ;
+}
+
+static int block6l (int yl)
+{
+ int rl ;
+
+ rl = yl ;
+ SATURATE(rl, 16383, -16384);
+
+ return (rl) ;
+}
+
+static int block2h (int ih, int deth)
+{
+ int dh ;
+ int wd2 ;
+ static const int qm2[4] = {-7408, -1616, 7408, 1616} ;
+
+ /* INVQAH */
+ wd2 = qm2[ih] ;
+ dh = (deth * wd2) >> 15 ;
+
+ return (dh) ;
+}
+
+static int block3h (g722_dec_t *dec, int ih)
+{
+ int deth ;
+ int ih2, wd, wd1, wd2, wd3, nbph, deph ;
+ static const int wh[3] = {0, -214, 798} ;
+ static const int rh2[4] = {2, 1, 2, 1} ;
+
+ /* LOGSCH */
+ ih2 = rh2[ih] ;
+ wd = (dec->nbh * 32512) >> 15 ;
+ nbph = wd + wh[ih2] ;
+
+ if (nbph < 0) nbph = 0 ;
+ if (nbph > 22528) nbph = 22528 ;
+
+
+ /* SCALEH */
+ wd1 = (nbph >> 6) & 31 ;
+ wd2 = nbph >> 11 ;
+ if ((10 - wd2) < 0) wd3 = ilb[wd1] << (wd2 - 10) ;
+ else wd3 = ilb[wd1] >> (10 - wd2) ;
+ deph = wd3 << 2 ;
+
+ /* DELAYA */
+ dec->nbh = nbph ;
+
+ /* DELAYH */
+ deth = deph ;
+
+ return (deth) ;
+}
+
+static int block4h (g722_dec_t *dec, int d)
+{
+ int sh = dec->shigh;
+ int i ;
+ int wd, wd1, wd2, wd3, wd4, wd5/*, wd6 */;
+
+ dec->dh[0] = d;
+
+ /* RECONS */
+ dec->rh[0] = sh + dec->dh[0] ;
+ SATURATE(dec->rh[0], 32767, -32768);
+
+ /* PARREC */
+ dec->ph[0] = dec->dh[0] + dec->szh ;
+ SATURATE(dec->ph[0], 32767, -32768);
+
+ /* UPPOL2 */
+ dec->sgh[0] = dec->ph[0] >> 15 ;
+ dec->sgh[1] = dec->ph[1] >> 15 ;
+ dec->sgh[2] = dec->ph[2] >> 15 ;
+
+ wd1 = dec->ah[1] << 2;
+ SATURATE(wd1, 32767, -32768);
+
+ if ( dec->sgh[0] == dec->sgh[1] ) wd2 = - wd1 ;
+ else wd2 = wd1 ;
+ if (wd2 > 32767) wd2 = 32767;
+
+ wd2 = wd2 >> 7 ;
+
+ if ( dec->sgh[0] == dec->sgh[2] ) wd3 = 128 ;
+ else wd3 = - 128 ;
+
+ wd4 = wd2 + wd3 ;
+ wd5 = (dec->ah[2] * 32512) >> 15 ;
+
+ dec->aph[2] = wd4 + wd5 ;
+ SATURATE(dec->aph[2], 12288, -12288);
+
+ /* UPPOL1 */
+ dec->sgh[0] = dec->ph[0] >> 15 ;
+ dec->sgh[1] = dec->ph[1] >> 15 ;
+
+ if ( dec->sgh[0] == dec->sgh[1] ) wd1 = 192 ;
+ else wd1 = - 192 ;
+
+ wd2 = (dec->ah[1] * 32640) >> 15 ;
+
+ dec->aph[1] = wd1 + wd2 ;
+ SATURATE(dec->aph[1], 32767, -32768);
+ //dec->aph[2]?
+ //if (aph[2] > 32767) aph[2] = 32767;
+ //if (aph[2] < -32768) aph[2] = -32768;
+
+ wd3 = (15360 - dec->aph[2]) ;
+ SATURATE(wd3, 32767, -32768);
+ if ( dec->aph[1] > wd3) dec->aph[1] = wd3 ;
+ if ( dec->aph[1] < -wd3) dec->aph[1] = -wd3 ;
+
+ /* UPZERO */
+ if ( dec->dh[0] == 0 ) wd1 = 0 ;
+ if ( dec->dh[0] != 0 ) wd1 = 128 ;
+
+ dec->sgh[0] = dec->dh[0] >> 15 ;
+
+ for ( i = 1; i < 7; i++ ) {
+ dec->sgh[i] = dec->dh[i] >> 15 ;
+ if ( dec->sgh[i] == dec->sgh[0] ) wd2 = wd1 ;
+ else wd2 = - wd1 ;
+ wd3 = (dec->bh[i] * 32640) >> 15 ;
+ dec->bph[i] = wd2 + wd3 ;
+ }
+
+ /* DELAYA */
+ for ( i = 6; i > 0; i-- ) {
+ dec->dh[i] = dec->dh[i-1] ;
+ dec->bh[i] = dec->bph[i] ;
+ }
+
+ for ( i = 2; i > 0; i-- ) {
+ dec->rh[i] = dec->rh[i-1] ;
+ dec->ph[i] = dec->ph[i-1] ;
+ dec->ah[i] = dec->aph[i] ;
+ }
+
+ /* FILTEP */
+ wd1 = dec->rh[1] << 1 ;
+ SATURATE(wd1, 32767, -32768);
+ wd1 = ( dec->ah[1] * wd1 ) >> 15 ;
+
+ wd2 = dec->rh[2] << 1;
+ SATURATE(wd2, 32767, -32768);
+ wd2 = ( dec->ah[2] * wd2 ) >> 15 ;
+
+ dec->sph = wd1 + wd2 ;
+ SATURATE(dec->sph, 32767, -32768);
+
+ /* FILTEZ */
+ dec->szh = 0 ;
+ for (i=6; i>0; i--) {
+ wd = dec->dh[i] << 1;
+ SATURATE(wd, 32767, -32768);
+ dec->szh += (dec->bh[i] * wd) >> 15 ;
+ SATURATE(dec->szh, 32767, -32768);
+ }
+
+ /* PREDIC */
+ sh = dec->sph + dec->szh ;
+ SATURATE(sh, 32767, -32768);
+
+ return (sh) ;
+}
+
+static int block5h (int dh, int sh)
+{
+ int rh ;
+
+ rh = dh + sh;
+ SATURATE(rh, 16383, -16384);
+
+ return (rh) ;
+}
+
+void rx_qmf(g722_dec_t *dec, int rl, int rh, int *xout1, int *xout2)
+{
+ int i;
+
+ pj_memmove(&dec->xd[1], dec->xd, 11*sizeof(dec->xd[0]));
+ pj_memmove(&dec->xs[1], dec->xs, 11*sizeof(dec->xs[0]));
+
+ /* RECA */
+ dec->xd[0] = rl - rh ;
+ if (dec->xd[0] > 16383) dec->xd[0] = 16383;
+ else if (dec->xd[0] < -16384) dec->xd[0] = -16384;
+
+ /* RECB */
+ dec->xs[0] = rl + rh ;
+ if (dec->xs[0] > 16383) dec->xs[0] = 16383;
+ else if (dec->xs[0] < -16384) dec->xs[0] = -16384;
+
+ /* ACCUMC */
+ *xout1 = 0;
+ for (i=0; i<12; ++i) *xout1 += dec->xd[i] * g722_qmf_coeff[2*i];
+ *xout1 = *xout1 >> 12 ;
+ if (*xout1 > 16383) *xout1 = 16383 ;
+ else if (*xout1 < -16384) *xout1 = -16384 ;
+
+ /* ACCUMD */
+ *xout2 = 0;
+ for (i=0; i<12; ++i) *xout2 += dec->xs[i] * g722_qmf_coeff[2*i+1];
+ *xout2 = *xout2 >> 12 ;
+ if (*xout2 > 16383) *xout2 = 16383 ;
+ else if (*xout2 < -16384) *xout2 = -16384 ;
+}
+
+
+PJ_DEF(pj_status_t) g722_dec_init(g722_dec_t *dec)
+{
+ PJ_ASSERT_RETURN(dec, PJ_EINVAL);
+
+ pj_bzero(dec, sizeof(g722_dec_t));
+
+ dec->detlow = 32;
+ dec->dethigh = 8;
+
+ return PJ_SUCCESS;
+}
+
+PJ_DEF(pj_status_t) g722_dec_decode( g722_dec_t *dec,
+ void *in,
+ pj_size_t in_size,
+ pj_int16_t out[],
+ pj_size_t *nsamples)
+{
+ unsigned i;
+ int ilowr, ylow, rlow, dlowt;
+ int ihigh, rhigh, dhigh;
+ int pcm1, pcm2;
+ pj_uint8_t *in_ = (pj_uint8_t*) in;
+
+ PJ_ASSERT_RETURN(dec && in && in_size && out && nsamples, PJ_EINVAL);
+ PJ_ASSERT_RETURN(*nsamples >= (in_size << 1), PJ_ETOOSMALL);
+
+ for(i = 0; i < in_size; ++i) {
+ ilowr = in_[i] & 63;
+ ihigh = (in_[i] >> 6) & 3;
+
+ /* low band decoder */
+ ylow = block5l (ilowr, dec->slow, dec->detlow, MODE) ;
+ rlow = block6l (ylow) ;
+ dlowt = block2l (ilowr, dec->detlow) ;
+ dec->detlow = block3l (dec, ilowr) ;
+ dec->slow = block4l (dec, dlowt) ;
+ /* rlow <= output low band pcm */
+
+ /* high band decoder */
+ dhigh = block2h (ihigh, dec->dethigh) ;
+ rhigh = block5h (dhigh, dec->shigh) ;
+ dec->dethigh = block3h (dec, ihigh) ;
+ dec->shigh = block4h (dec, dhigh) ;
+ /* rhigh <= output high band pcm */
+
+ rx_qmf(dec, rlow, rhigh, &pcm1, &pcm2);
+ out[i*2] = (pj_int16_t)pcm1;
+ out[i*2+1] = (pj_int16_t)pcm2;
+ }
+
+ *nsamples = in_size << 1;
+
+ return PJ_SUCCESS;
+}
+
+PJ_DEF(pj_status_t) g722_dec_deinit(g722_dec_t *dec)
+{
+ pj_bzero(dec, sizeof(g722_dec_t));
+
+ return PJ_SUCCESS;
+}
+
+#endif
diff --git a/jni/pjproject-android/.svn/pristine/cc/cc9188c60c5d276b305ed9b9b6077589de34dc22.svn-base b/jni/pjproject-android/.svn/pristine/cc/cc9188c60c5d276b305ed9b9b6077589de34dc22.svn-base
new file mode 100644
index 0000000..d419b45
--- /dev/null
+++ b/jni/pjproject-android/.svn/pristine/cc/cc9188c60c5d276b305ed9b9b6077589de34dc22.svn-base
Binary files differ
diff --git a/jni/pjproject-android/.svn/pristine/cc/cc9649d6162e8f8db851f2fa8d8653592eeade3b.svn-base b/jni/pjproject-android/.svn/pristine/cc/cc9649d6162e8f8db851f2fa8d8653592eeade3b.svn-base
new file mode 100644
index 0000000..ab83af9
--- /dev/null
+++ b/jni/pjproject-android/.svn/pristine/cc/cc9649d6162e8f8db851f2fa8d8653592eeade3b.svn-base
@@ -0,0 +1,348 @@
+/* $Id$ */
+/*
+ * Copyright (C) 2008-2011 Teluu Inc. (http://www.teluu.com)
+ * Copyright (C) 2003-2008 Benny Prijono <benny@prijono.org>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ */
+#include <pjlib.h>
+
+/*
+ * addr_resolv.h
+ */
+PJ_EXPORT_SYMBOL(pj_gethostbyname)
+
+/*
+ * array.h
+ */
+PJ_EXPORT_SYMBOL(pj_array_insert)
+PJ_EXPORT_SYMBOL(pj_array_erase)
+PJ_EXPORT_SYMBOL(pj_array_find)
+
+/*
+ * config.h
+ */
+PJ_EXPORT_SYMBOL(pj_dump_config)
+
+/*
+ * errno.h
+ */
+PJ_EXPORT_SYMBOL(pj_get_os_error)
+PJ_EXPORT_SYMBOL(pj_set_os_error)
+PJ_EXPORT_SYMBOL(pj_get_netos_error)
+PJ_EXPORT_SYMBOL(pj_set_netos_error)
+PJ_EXPORT_SYMBOL(pj_strerror)
+
+/*
+ * except.h
+ */
+PJ_EXPORT_SYMBOL(pj_throw_exception_)
+PJ_EXPORT_SYMBOL(pj_push_exception_handler_)
+PJ_EXPORT_SYMBOL(pj_pop_exception_handler_)
+PJ_EXPORT_SYMBOL(pj_setjmp)
+PJ_EXPORT_SYMBOL(pj_longjmp)
+PJ_EXPORT_SYMBOL(pj_exception_id_alloc)
+PJ_EXPORT_SYMBOL(pj_exception_id_free)
+PJ_EXPORT_SYMBOL(pj_exception_id_name)
+
+
+/*
+ * fifobuf.h
+ */
+PJ_EXPORT_SYMBOL(pj_fifobuf_init)
+PJ_EXPORT_SYMBOL(pj_fifobuf_max_size)
+PJ_EXPORT_SYMBOL(pj_fifobuf_alloc)
+PJ_EXPORT_SYMBOL(pj_fifobuf_unalloc)
+PJ_EXPORT_SYMBOL(pj_fifobuf_free)
+
+/*
+ * guid.h
+ */
+PJ_EXPORT_SYMBOL(pj_generate_unique_string)
+PJ_EXPORT_SYMBOL(pj_create_unique_string)
+
+/*
+ * hash.h
+ */
+PJ_EXPORT_SYMBOL(pj_hash_calc)
+PJ_EXPORT_SYMBOL(pj_hash_create)
+PJ_EXPORT_SYMBOL(pj_hash_get)
+PJ_EXPORT_SYMBOL(pj_hash_set)
+PJ_EXPORT_SYMBOL(pj_hash_count)
+PJ_EXPORT_SYMBOL(pj_hash_first)
+PJ_EXPORT_SYMBOL(pj_hash_next)
+PJ_EXPORT_SYMBOL(pj_hash_this)
+
+/*
+ * ioqueue.h
+ */
+PJ_EXPORT_SYMBOL(pj_ioqueue_create)
+PJ_EXPORT_SYMBOL(pj_ioqueue_destroy)
+PJ_EXPORT_SYMBOL(pj_ioqueue_set_lock)
+PJ_EXPORT_SYMBOL(pj_ioqueue_register_sock)
+PJ_EXPORT_SYMBOL(pj_ioqueue_unregister)
+PJ_EXPORT_SYMBOL(pj_ioqueue_get_user_data)
+PJ_EXPORT_SYMBOL(pj_ioqueue_poll)
+PJ_EXPORT_SYMBOL(pj_ioqueue_read)
+PJ_EXPORT_SYMBOL(pj_ioqueue_recv)
+PJ_EXPORT_SYMBOL(pj_ioqueue_recvfrom)
+PJ_EXPORT_SYMBOL(pj_ioqueue_write)
+PJ_EXPORT_SYMBOL(pj_ioqueue_send)
+PJ_EXPORT_SYMBOL(pj_ioqueue_sendto)
+#if defined(PJ_HAS_TCP) && PJ_HAS_TCP != 0
+PJ_EXPORT_SYMBOL(pj_ioqueue_accept)
+PJ_EXPORT_SYMBOL(pj_ioqueue_connect)
+#endif
+
+/*
+ * list.h
+ */
+PJ_EXPORT_SYMBOL(pj_list_insert_before)
+PJ_EXPORT_SYMBOL(pj_list_insert_nodes_before)
+PJ_EXPORT_SYMBOL(pj_list_insert_after)
+PJ_EXPORT_SYMBOL(pj_list_insert_nodes_after)
+PJ_EXPORT_SYMBOL(pj_list_merge_first)
+PJ_EXPORT_SYMBOL(pj_list_merge_last)
+PJ_EXPORT_SYMBOL(pj_list_erase)
+PJ_EXPORT_SYMBOL(pj_list_find_node)
+PJ_EXPORT_SYMBOL(pj_list_search)
+
+
+/*
+ * log.h
+ */
+PJ_EXPORT_SYMBOL(pj_log_write)
+#if PJ_LOG_MAX_LEVEL >= 1
+PJ_EXPORT_SYMBOL(pj_log_set_log_func)
+PJ_EXPORT_SYMBOL(pj_log_get_log_func)
+PJ_EXPORT_SYMBOL(pj_log_set_level)
+PJ_EXPORT_SYMBOL(pj_log_get_level)
+PJ_EXPORT_SYMBOL(pj_log_set_decor)
+PJ_EXPORT_SYMBOL(pj_log_get_decor)
+PJ_EXPORT_SYMBOL(pj_log_1)
+#endif
+#if PJ_LOG_MAX_LEVEL >= 2
+PJ_EXPORT_SYMBOL(pj_log_2)
+#endif
+#if PJ_LOG_MAX_LEVEL >= 3
+PJ_EXPORT_SYMBOL(pj_log_3)
+#endif
+#if PJ_LOG_MAX_LEVEL >= 4
+PJ_EXPORT_SYMBOL(pj_log_4)
+#endif
+#if PJ_LOG_MAX_LEVEL >= 5
+PJ_EXPORT_SYMBOL(pj_log_5)
+#endif
+#if PJ_LOG_MAX_LEVEL >= 6
+PJ_EXPORT_SYMBOL(pj_log_6)
+#endif
+
+/*
+ * os.h
+ */
+PJ_EXPORT_SYMBOL(pj_init)
+PJ_EXPORT_SYMBOL(pj_getpid)
+PJ_EXPORT_SYMBOL(pj_thread_register)
+PJ_EXPORT_SYMBOL(pj_thread_create)
+PJ_EXPORT_SYMBOL(pj_thread_get_name)
+PJ_EXPORT_SYMBOL(pj_thread_resume)
+PJ_EXPORT_SYMBOL(pj_thread_this)
+PJ_EXPORT_SYMBOL(pj_thread_join)
+PJ_EXPORT_SYMBOL(pj_thread_destroy)
+PJ_EXPORT_SYMBOL(pj_thread_sleep)
+#if defined(PJ_OS_HAS_CHECK_STACK) && PJ_OS_HAS_CHECK_STACK != 0
+PJ_EXPORT_SYMBOL(pj_thread_check_stack)
+PJ_EXPORT_SYMBOL(pj_thread_get_stack_max_usage)
+PJ_EXPORT_SYMBOL(pj_thread_get_stack_info)
+#endif
+PJ_EXPORT_SYMBOL(pj_atomic_create)
+PJ_EXPORT_SYMBOL(pj_atomic_destroy)
+PJ_EXPORT_SYMBOL(pj_atomic_set)
+PJ_EXPORT_SYMBOL(pj_atomic_get)
+PJ_EXPORT_SYMBOL(pj_atomic_inc)
+PJ_EXPORT_SYMBOL(pj_atomic_dec)
+PJ_EXPORT_SYMBOL(pj_thread_local_alloc)
+PJ_EXPORT_SYMBOL(pj_thread_local_free)
+PJ_EXPORT_SYMBOL(pj_thread_local_set)
+PJ_EXPORT_SYMBOL(pj_thread_local_get)
+PJ_EXPORT_SYMBOL(pj_enter_critical_section)
+PJ_EXPORT_SYMBOL(pj_leave_critical_section)
+PJ_EXPORT_SYMBOL(pj_mutex_create)
+PJ_EXPORT_SYMBOL(pj_mutex_lock)
+PJ_EXPORT_SYMBOL(pj_mutex_unlock)
+PJ_EXPORT_SYMBOL(pj_mutex_trylock)
+PJ_EXPORT_SYMBOL(pj_mutex_destroy)
+#if defined(PJ_DEBUG) && PJ_DEBUG != 0
+PJ_EXPORT_SYMBOL(pj_mutex_is_locked)
+#endif
+#if defined(PJ_HAS_SEMAPHORE) && PJ_HAS_SEMAPHORE != 0
+PJ_EXPORT_SYMBOL(pj_sem_create)
+PJ_EXPORT_SYMBOL(pj_sem_wait)
+PJ_EXPORT_SYMBOL(pj_sem_trywait)
+PJ_EXPORT_SYMBOL(pj_sem_post)
+PJ_EXPORT_SYMBOL(pj_sem_destroy)
+#endif
+PJ_EXPORT_SYMBOL(pj_gettimeofday)
+PJ_EXPORT_SYMBOL(pj_time_decode)
+#if defined(PJ_HAS_HIGH_RES_TIMER) && PJ_HAS_HIGH_RES_TIMER != 0
+PJ_EXPORT_SYMBOL(pj_gettickcount)
+PJ_EXPORT_SYMBOL(pj_get_timestamp)
+PJ_EXPORT_SYMBOL(pj_get_timestamp_freq)
+PJ_EXPORT_SYMBOL(pj_elapsed_time)
+PJ_EXPORT_SYMBOL(pj_elapsed_usec)
+PJ_EXPORT_SYMBOL(pj_elapsed_nanosec)
+PJ_EXPORT_SYMBOL(pj_elapsed_cycle)
+#endif
+
+
+/*
+ * pool.h
+ */
+PJ_EXPORT_SYMBOL(pj_pool_create)
+PJ_EXPORT_SYMBOL(pj_pool_release)
+PJ_EXPORT_SYMBOL(pj_pool_getobjname)
+PJ_EXPORT_SYMBOL(pj_pool_reset)
+PJ_EXPORT_SYMBOL(pj_pool_get_capacity)
+PJ_EXPORT_SYMBOL(pj_pool_get_used_size)
+PJ_EXPORT_SYMBOL(pj_pool_alloc)
+PJ_EXPORT_SYMBOL(pj_pool_calloc)
+PJ_EXPORT_SYMBOL(pj_pool_factory_default_policy)
+PJ_EXPORT_SYMBOL(pj_pool_create_int)
+PJ_EXPORT_SYMBOL(pj_pool_init_int)
+PJ_EXPORT_SYMBOL(pj_pool_destroy_int)
+PJ_EXPORT_SYMBOL(pj_caching_pool_init)
+PJ_EXPORT_SYMBOL(pj_caching_pool_destroy)
+
+/*
+ * rand.h
+ */
+PJ_EXPORT_SYMBOL(pj_rand)
+PJ_EXPORT_SYMBOL(pj_srand)
+
+/*
+ * rbtree.h
+ */
+PJ_EXPORT_SYMBOL(pj_rbtree_init)
+PJ_EXPORT_SYMBOL(pj_rbtree_first)
+PJ_EXPORT_SYMBOL(pj_rbtree_last)
+PJ_EXPORT_SYMBOL(pj_rbtree_next)
+PJ_EXPORT_SYMBOL(pj_rbtree_prev)
+PJ_EXPORT_SYMBOL(pj_rbtree_insert)
+PJ_EXPORT_SYMBOL(pj_rbtree_find)
+PJ_EXPORT_SYMBOL(pj_rbtree_erase)
+PJ_EXPORT_SYMBOL(pj_rbtree_max_height)
+PJ_EXPORT_SYMBOL(pj_rbtree_min_height)
+
+/*
+ * sock.h
+ */
+PJ_EXPORT_SYMBOL(PJ_AF_UNIX)
+PJ_EXPORT_SYMBOL(PJ_AF_INET)
+PJ_EXPORT_SYMBOL(PJ_AF_INET6)
+PJ_EXPORT_SYMBOL(PJ_AF_PACKET)
+PJ_EXPORT_SYMBOL(PJ_AF_IRDA)
+PJ_EXPORT_SYMBOL(PJ_SOCK_STREAM)
+PJ_EXPORT_SYMBOL(PJ_SOCK_DGRAM)
+PJ_EXPORT_SYMBOL(PJ_SOCK_RAW)
+PJ_EXPORT_SYMBOL(PJ_SOCK_RDM)
+PJ_EXPORT_SYMBOL(PJ_SOL_SOCKET)
+PJ_EXPORT_SYMBOL(PJ_SOL_IP)
+PJ_EXPORT_SYMBOL(PJ_SOL_TCP)
+PJ_EXPORT_SYMBOL(PJ_SOL_UDP)
+PJ_EXPORT_SYMBOL(PJ_SOL_IPV6)
+PJ_EXPORT_SYMBOL(pj_ntohs)
+PJ_EXPORT_SYMBOL(pj_htons)
+PJ_EXPORT_SYMBOL(pj_ntohl)
+PJ_EXPORT_SYMBOL(pj_htonl)
+PJ_EXPORT_SYMBOL(pj_inet_ntoa)
+PJ_EXPORT_SYMBOL(pj_inet_aton)
+PJ_EXPORT_SYMBOL(pj_inet_addr)
+PJ_EXPORT_SYMBOL(pj_sockaddr_in_set_str_addr)
+PJ_EXPORT_SYMBOL(pj_sockaddr_in_init)
+PJ_EXPORT_SYMBOL(pj_gethostname)
+PJ_EXPORT_SYMBOL(pj_gethostaddr)
+PJ_EXPORT_SYMBOL(pj_sock_socket)
+PJ_EXPORT_SYMBOL(pj_sock_close)
+PJ_EXPORT_SYMBOL(pj_sock_bind)
+PJ_EXPORT_SYMBOL(pj_sock_bind_in)
+#if defined(PJ_HAS_TCP) && PJ_HAS_TCP != 0
+PJ_EXPORT_SYMBOL(pj_sock_listen)
+PJ_EXPORT_SYMBOL(pj_sock_accept)
+PJ_EXPORT_SYMBOL(pj_sock_shutdown)
+#endif
+PJ_EXPORT_SYMBOL(pj_sock_connect)
+PJ_EXPORT_SYMBOL(pj_sock_getpeername)
+PJ_EXPORT_SYMBOL(pj_sock_getsockname)
+PJ_EXPORT_SYMBOL(pj_sock_getsockopt)
+PJ_EXPORT_SYMBOL(pj_sock_setsockopt)
+PJ_EXPORT_SYMBOL(pj_sock_recv)
+PJ_EXPORT_SYMBOL(pj_sock_recvfrom)
+PJ_EXPORT_SYMBOL(pj_sock_send)
+PJ_EXPORT_SYMBOL(pj_sock_sendto)
+
+/*
+ * sock_select.h
+ */
+PJ_EXPORT_SYMBOL(PJ_FD_ZERO)
+PJ_EXPORT_SYMBOL(PJ_FD_SET)
+PJ_EXPORT_SYMBOL(PJ_FD_CLR)
+PJ_EXPORT_SYMBOL(PJ_FD_ISSET)
+PJ_EXPORT_SYMBOL(pj_sock_select)
+
+/*
+ * string.h
+ */
+PJ_EXPORT_SYMBOL(pj_str)
+PJ_EXPORT_SYMBOL(pj_strassign)
+PJ_EXPORT_SYMBOL(pj_strcpy)
+PJ_EXPORT_SYMBOL(pj_strcpy2)
+PJ_EXPORT_SYMBOL(pj_strdup)
+PJ_EXPORT_SYMBOL(pj_strdup_with_null)
+PJ_EXPORT_SYMBOL(pj_strdup2)
+PJ_EXPORT_SYMBOL(pj_strdup3)
+PJ_EXPORT_SYMBOL(pj_strcmp)
+PJ_EXPORT_SYMBOL(pj_strcmp2)
+PJ_EXPORT_SYMBOL(pj_strncmp)
+PJ_EXPORT_SYMBOL(pj_strncmp2)
+PJ_EXPORT_SYMBOL(pj_stricmp)
+PJ_EXPORT_SYMBOL(pj_stricmp2)
+PJ_EXPORT_SYMBOL(pj_strnicmp)
+PJ_EXPORT_SYMBOL(pj_strnicmp2)
+PJ_EXPORT_SYMBOL(pj_strcat)
+PJ_EXPORT_SYMBOL(pj_strltrim)
+PJ_EXPORT_SYMBOL(pj_strrtrim)
+PJ_EXPORT_SYMBOL(pj_strtrim)
+PJ_EXPORT_SYMBOL(pj_create_random_string)
+PJ_EXPORT_SYMBOL(pj_strtoul)
+PJ_EXPORT_SYMBOL(pj_utoa)
+PJ_EXPORT_SYMBOL(pj_utoa_pad)
+
+/*
+ * timer.h
+ */
+PJ_EXPORT_SYMBOL(pj_timer_heap_mem_size)
+PJ_EXPORT_SYMBOL(pj_timer_heap_create)
+PJ_EXPORT_SYMBOL(pj_timer_entry_init)
+PJ_EXPORT_SYMBOL(pj_timer_heap_schedule)
+PJ_EXPORT_SYMBOL(pj_timer_heap_cancel)
+PJ_EXPORT_SYMBOL(pj_timer_heap_count)
+PJ_EXPORT_SYMBOL(pj_timer_heap_earliest_time)
+PJ_EXPORT_SYMBOL(pj_timer_heap_poll)
+
+/*
+ * types.h
+ */
+PJ_EXPORT_SYMBOL(pj_time_val_normalize)
+
diff --git a/jni/pjproject-android/.svn/pristine/cc/cc99cffe6c6367e8163b41fa3c29aeba66fe40d1.svn-base b/jni/pjproject-android/.svn/pristine/cc/cc99cffe6c6367e8163b41fa3c29aeba66fe40d1.svn-base
new file mode 100644
index 0000000..c395234
--- /dev/null
+++ b/jni/pjproject-android/.svn/pristine/cc/cc99cffe6c6367e8163b41fa3c29aeba66fe40d1.svn-base
@@ -0,0 +1,149 @@
+/* $Id$ */
+/*
+ * Copyright (C) 2008-2011 Teluu Inc. (http://www.teluu.com)
+ * Copyright (C) 2003-2008 Benny Prijono <benny@prijono.org>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ */
+#ifndef __PJ_COMPAT_OS_LINUX_KERNEL_H__
+#define __PJ_COMPAT_OS_LINUX_KERNEL_H__
+
+/**
+ * @file os_linux.h
+ * @brief Describes Linux operating system specifics.
+ */
+
+#define PJ_OS_NAME "linux-module"
+
+#define PJ_HAS_ARPA_INET_H 0
+#define PJ_HAS_ASSERT_H 0
+#define PJ_HAS_CTYPE_H 0
+#define PJ_HAS_ERRNO_H 0
+#define PJ_HAS_LINUX_SOCKET_H 1
+#define PJ_HAS_MALLOC_H 0
+#define PJ_HAS_NETDB_H 0
+#define PJ_HAS_NETINET_IN_H 0
+#define PJ_HAS_SETJMP_H 0
+#define PJ_HAS_STDARG_H 1
+#define PJ_HAS_STDDEF_H 0
+#define PJ_HAS_STDIO_H 0
+#define PJ_HAS_STDLIB_H 0
+#define PJ_HAS_STRING_H 0
+#define PJ_HAS_SYS_IOCTL_H 0
+#define PJ_HAS_SYS_SELECT_H 0
+#define PJ_HAS_SYS_SOCKET_H 0
+#define PJ_HAS_SYS_TIME_H 0
+#define PJ_HAS_SYS_TIMEB_H 0
+#define PJ_HAS_SYS_TYPES_H 0
+#define PJ_HAS_TIME_H 0
+#define PJ_HAS_UNISTD_H 0
+
+#define PJ_HAS_MSWSOCK_H 0
+#define PJ_HAS_WINSOCK_H 0
+#define PJ_HAS_WINSOCK2_H 0
+
+#define PJ_SOCK_HAS_INET_ATON 0
+
+/* Set 1 if native sockaddr_in has sin_len member.
+ * Default: 0
+ */
+#define PJ_SOCKADDR_HAS_LEN 0
+
+/* When this macro is set, getsockopt(SOL_SOCKET, SO_ERROR) will return
+ * the status of non-blocking connect() operation.
+ */
+#define PJ_HAS_SO_ERROR 1
+
+/**
+ * If this macro is set, it tells select I/O Queue that select() needs to
+ * be given correct value of nfds (i.e. largest fd + 1). This requires
+ * select ioqueue to re-scan the descriptors on each registration and
+ * unregistration.
+ * If this macro is not set, then ioqueue will always give FD_SETSIZE for
+ * nfds argument when calling select().
+ *
+ * Default: 0
+ */
+#define PJ_SELECT_NEEDS_NFDS 0
+
+/* Is errno a good way to retrieve OS errors?
+ * (probably no for linux kernel)
+ * If you answer no here, you'll need to tell pjlib how to get OS
+ * error (a compile error will tell you exactly where)
+ */
+#define PJ_HAS_ERRNO_VAR 0
+
+/* This value specifies the value set in errno by the OS when a non-blocking
+ * socket recv() can not return immediate daata.
+ */
+#define PJ_BLOCKING_ERROR_VAL EAGAIN
+
+/* This value specifies the value set in errno by the OS when a non-blocking
+ * socket connect() can not get connected immediately.
+ */
+#define PJ_BLOCKING_CONNECT_ERROR_VAL EINPROGRESS
+
+#ifndef PJ_HAS_THREADS
+# define PJ_HAS_THREADS (1)
+#endif
+
+
+/*
+ * Declare __FD_SETSIZE now before including <linux*>.
+ */
+#define __FD_SETSIZE PJ_IOQUEUE_MAX_HANDLES
+
+#define NULL ((void*)0)
+
+#include <linux/module.h> /* Needed by all modules */
+#include <linux/kernel.h> /* Needed for KERN_INFO */
+
+#define __PJ_EXPORT_SYMBOL(a) EXPORT_SYMBOL(a);
+
+/*
+ * Override features.
+ */
+#define PJ_HAS_FLOATING_POINT 0
+#define PJ_HAS_MALLOC 0
+#define PJ_HAS_SEMAPHORE 0
+#define PJ_HAS_EVENT_OBJ 0
+#define PJ_HAS_HIGH_RES_TIMER 1
+#ifndef PJ_OS_HAS_CHECK_STACK
+# define PJ_OS_HAS_CHECK_STACK 0
+#endif
+#define PJ_TERM_HAS_COLOR 0
+#define PJ_NATIVE_STRING_IS_UNICODE 0
+
+#define PJ_ATOMIC_VALUE_TYPE int
+#define PJ_THREAD_DESC_SIZE 128
+
+/* If 1, use Read/Write mutex emulation for platforms that don't support it */
+#define PJ_EMULATE_RWMUTEX 0
+
+/* If 1, pj_thread_create() should enforce the stack size when creating
+ * threads.
+ * Default: 0 (let OS decide the thread's stack size).
+ */
+#define PJ_THREAD_SET_STACK_SIZE 0
+
+/* If 1, pj_thread_create() should allocate stack from the pool supplied.
+ * Default: 0 (let OS allocate memory for thread's stack).
+ */
+#define PJ_THREAD_ALLOCATE_STACK 0
+
+
+
+#endif /* __PJ_COMPAT_OS_LINUX_KERNEL_H__ */
+