Ignore:
Timestamp:
Nov 23, 2006 10:19:46 AM (17 years ago)
Author:
bennylp
Message:

Updated Speex to their latest SVN (1.2-beta). AEC seems
to work much better now and take less CPU, so I increased
default tail length in PJSUA to 800ms.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • pjproject/trunk/pjmedia/src/pjmedia-codec/speex/filters.c

    r628 r823  
    1 /* Copyright (C) 2002 Jean-Marc Valin  
     1/* Copyright (C) 2002-2006 Jean-Marc Valin  
    22   File: filters.c 
    33   Various analysis/synthesis filters 
     
    6363} 
    6464 
     65void highpass(const spx_word16_t *x, spx_word16_t *y, int len, int filtID, spx_mem_t *mem) 
     66{ 
     67   int i; 
     68#ifdef FIXED_POINT 
     69   const spx_word16_t Pcoef[5][3] = {{16384, -31313, 14991}, {16384, -31569, 15249}, {16384, -31677, 15328}, {16384, -32313, 15947}, {16384, -22446, 6537}}; 
     70   const spx_word16_t Zcoef[5][3] = {{15672, -31344, 15672}, {15802, -31601, 15802}, {15847, -31694, 15847}, {16162, -32322, 16162}, {14418, -28836, 14418}}; 
     71#else 
     72   const spx_word16_t Pcoef[5][3] = {{1.00000f, -1.91120f, 0.91498f}, {1.00000f, -1.92683f, 0.93071f}, {1.00000f, -1.93338f, 0.93553f}, {1.00000f, -1.97226f, 0.97332f}, {1.00000f, -1.37000f, 0.39900f}}; 
     73   const spx_word16_t Zcoef[5][3] = {{0.95654f, -1.91309f, 0.95654f}, {0.96446f, -1.92879f, 0.96446f}, {0.96723f, -1.93445f, 0.96723f}, {0.98645f, -1.97277f, 0.98645f}, {0.88000f, -1.76000f, 0.88000f}}; 
     74#endif 
     75   const spx_word16_t *den, *num; 
     76   if (filtID>4) 
     77      filtID=4; 
     78    
     79   den = Pcoef[filtID]; num = Zcoef[filtID]; 
     80   /*return;*/ 
     81   for (i=0;i<len;i++) 
     82   { 
     83      spx_word16_t yi; 
     84      spx_word32_t vout = ADD32(MULT16_16(num[0], x[i]),mem[0]); 
     85      yi = EXTRACT16(SATURATE(PSHR32(vout,14),32767)); 
     86      mem[0] = ADD32(MAC16_16(mem[1], num[1],x[i]), SHL32(MULT16_32_Q15(-den[1],vout),1)); 
     87      mem[1] = ADD32(MULT16_16(num[2],x[i]), SHL32(MULT16_32_Q15(-den[2],vout),1)); 
     88      y[i] = yi; 
     89   } 
     90} 
    6591 
    6692#ifdef FIXED_POINT 
     
    193219      { 
    194220         spx_word32_t sum2=0; 
    195          sum2 = MAC16_16(sum2,PSHR16(x[i],1),PSHR16(x[i],1)); 
    196          sum2 = MAC16_16(sum2,PSHR16(x[i+1],1),PSHR16(x[i+1],1)); 
    197          sum2 = MAC16_16(sum2,PSHR16(x[i+2],1),PSHR16(x[i+2],1)); 
    198          sum2 = MAC16_16(sum2,PSHR16(x[i+3],1),PSHR16(x[i+3],1)); 
     221         sum2 = MAC16_16(sum2,SHR16(x[i],1),SHR16(x[i],1)); 
     222         sum2 = MAC16_16(sum2,SHR16(x[i+1],1),SHR16(x[i+1],1)); 
     223         sum2 = MAC16_16(sum2,SHR16(x[i+2],1),SHR16(x[i+2],1)); 
     224         sum2 = MAC16_16(sum2,SHR16(x[i+3],1),SHR16(x[i+3],1)); 
    199225         sum = ADD32(sum,SHR32(sum2,6)); 
    200226      } 
     
    625651         x1 = xx[N-2+j-i]; 
    626652 
    627          y0 = ADD32(y0,SHR(MULT16_16(a0, x1),2)); 
    628          y1 = ADD32(y1,SHR(MULT16_16(a1, x1),2)); 
    629          y2 = ADD32(y2,SHR(MULT16_16(a0, x0),2)); 
    630          y3 = ADD32(y3,SHR(MULT16_16(a1, x0),2)); 
     653         y0 = ADD32(y0,SHR32(MULT16_16(a0, x1),2)); 
     654         y1 = ADD32(y1,SHR32(MULT16_16(a1, x1),2)); 
     655         y2 = ADD32(y2,SHR32(MULT16_16(a0, x0),2)); 
     656         y3 = ADD32(y3,SHR32(MULT16_16(a1, x0),2)); 
    631657 
    632658         a0 = a[j+2]; 
     
    634660         x0 = xx[N+j-i]; 
    635661 
    636          y0 = ADD32(y0,SHR(MULT16_16(a0, x0),2)); 
    637          y1 = ADD32(y1,SHR(MULT16_16(a1, x0),2)); 
    638          y2 = ADD32(y2,SHR(MULT16_16(a0, x1),2)); 
    639          y3 = ADD32(y3,SHR(MULT16_16(a1, x1),2)); 
     662         y0 = ADD32(y0,SHR32(MULT16_16(a0, x0),2)); 
     663         y1 = ADD32(y1,SHR32(MULT16_16(a1, x0),2)); 
     664         y2 = ADD32(y2,SHR32(MULT16_16(a0, x1),2)); 
     665         y3 = ADD32(y3,SHR32(MULT16_16(a1, x1),2)); 
    640666      } 
    641667      y[i] = y0; 
     
    651677#ifdef FIXED_POINT 
    652678#if 0 
    653 spx_word16_t shift_filt[3][7] = {{-33,    1043,   -4551,   19959,   19959,   -4551,    1043}, 
     679const spx_word16_t shift_filt[3][7] = {{-33,    1043,   -4551,   19959,   19959,   -4551,    1043}, 
    654680                                 {-98,    1133,   -4425,   29179,    8895,   -2328,     444}, 
    655681                                 {444,   -2328,    8895,   29179,   -4425,    1133,     -98}}; 
    656682#else 
    657 spx_word16_t shift_filt[3][7] = {{-390,    1540,   -4993,   20123,   20123,   -4993,    1540}, 
     683const spx_word16_t shift_filt[3][7] = {{-390,    1540,   -4993,   20123,   20123,   -4993,    1540}, 
    658684                                {-1064,    2817,   -6694,   31589,    6837,    -990,    -209}, 
    659685                                 {-209,    -990,    6837,   31589,   -6694,    2817,   -1064}}; 
     
    661687#else 
    662688#if 0 
    663 float shift_filt[3][7] = {{-9.9369e-04, 3.1831e-02, -1.3889e-01, 6.0910e-01, 6.0910e-01, -1.3889e-01, 3.1831e-02}, 
     689const float shift_filt[3][7] = {{-9.9369e-04, 3.1831e-02, -1.3889e-01, 6.0910e-01, 6.0910e-01, -1.3889e-01, 3.1831e-02}, 
    664690                          {-0.0029937, 0.0345613, -0.1350474, 0.8904793, 0.2714479, -0.0710304, 0.0135403}, 
    665691                          {0.0135403, -0.0710304, 0.2714479, 0.8904793, -0.1350474, 0.0345613,  -0.0029937}}; 
    666692#else 
    667 float shift_filt[3][7] = {{-0.011915, 0.046995, -0.152373, 0.614108, 0.614108, -0.152373, 0.046995}, 
    668                           {-0.0324855, 0.0859768, -0.2042986, 0.9640297, 0.2086420, -0.0302054, -0.0063646}, 
    669                           {-0.0063646, -0.0302054, 0.2086420, 0.9640297, -0.2042986, 0.0859768, -0.0324855}}; 
     693const float shift_filt[3][7] = {{-0.011915f, 0.046995f, -0.152373f, 0.614108f, 0.614108f, -0.152373f, 0.046995f}, 
     694                          {-0.0324855f, 0.0859768f, -0.2042986f, 0.9640297f, 0.2086420f, -0.0302054f, -0.0063646f}, 
     695                          {-0.0063646f, -0.0302054f, 0.2086420f, 0.9640297f, -0.2042986f, 0.0859768f, -0.0324855f}}; 
    670696#endif 
    671697#endif 
     
    759785   spx_word16_t ngain; 
    760786   spx_word16_t gg1, gg2; 
    761  
     787#ifdef FIXED_POINT 
     788   int scaledown=0; 
     789#endif 
    762790#if 0 /* Set to 1 to enable full pitch search */ 
    763791   int nol_pitch[6]; 
     
    794822      interp_pitch(exc, iexc+nsf, -corr_pitch, 80); 
    795823 
     824#ifdef FIXED_POINT 
     825   for (i=0;i<nsf;i++) 
     826   { 
     827      if (ABS16(exc[i])>16383) 
     828      { 
     829         scaledown = 1; 
     830         break; 
     831      } 
     832   } 
     833   if (scaledown) 
     834   { 
     835      for (i=0;i<nsf;i++) 
     836         exc[i] = SHR16(exc[i],1); 
     837      for (i=0;i<2*nsf;i++) 
     838         iexc[i] = SHR16(iexc[i],1); 
     839   } 
     840#endif 
    796841   /*interp_pitch(exc, iexc+2*nsf, 2*corr_pitch, 80);*/ 
    797842    
     
    873918   for (i=0;i<nsf;i++) 
    874919      new_exc[i] = MULT16_16_Q14(ngain, new_exc[i]); 
    875 } 
    876  
     920#ifdef FIXED_POINT 
     921   if (scaledown) 
     922   { 
     923      for (i=0;i<nsf;i++) 
     924         exc[i] = SHL16(exc[i],1); 
     925      for (i=0;i<nsf;i++) 
     926         new_exc[i] = SHL16(SATURATE16(new_exc[i],16383),1); 
     927   } 
     928#endif 
     929} 
     930 
Note: See TracChangeset for help on using the changeset viewer.