[xiph-commits] r11649 - trunk/speex/libspeex

jm at svn.xiph.org jm at svn.xiph.org
Sun Jun 25 04:10:40 PDT 2006


Author: jm
Date: 2006-06-25 04:10:32 -0700 (Sun, 25 Jun 2006)
New Revision: 11649

Modified:
   trunk/speex/libspeex/filters.c
   trunk/speex/libspeex/filters.h
   trunk/speex/libspeex/nb_celp.c
   trunk/speex/libspeex/nb_celp.h
   trunk/speex/libspeex/sb_celp.c
Log:
Removed old enhancer code (was already disabled)


Modified: trunk/speex/libspeex/filters.c
===================================================================
--- trunk/speex/libspeex/filters.c	2006-06-25 02:20:17 UTC (rev 11648)
+++ trunk/speex/libspeex/filters.c	2006-06-25 11:10:32 UTC (rev 11649)
@@ -648,8 +648,6 @@
       mem[i+1] = xx[i];
 }
 
-#ifndef OLD_ENHANCER
-
 #ifdef FIXED_POINT
 #if 0
 spx_word16_t shift_filt[3][7] = {{-33,    1043,   -4551,   19959,   19959,   -4551,    1043},
@@ -876,125 +874,3 @@
       new_exc[i] = MULT16_16_Q14(ngain, new_exc[i]);
 }
 
-#else
-
-void comb_filter_mem_init (CombFilterMem *mem)
-{
-   mem->last_pitch=0;
-   mem->last_pitch_gain[0]=mem->last_pitch_gain[1]=mem->last_pitch_gain[2]=0;
-   mem->smooth_gain=1;
-}
-
-#ifdef FIXED_POINT
-#define COMB_STEP 32767
-#else
-#define COMB_STEP 1.0
-#endif
-
-void comb_filter(
-spx_sig_t *exc,          /*decoded excitation*/
-spx_word16_t *_new_exc,      /*enhanced excitation*/
-spx_coef_t *ak,           /*LPC filter coefs*/
-int p,               /*LPC order*/
-int nsf,             /*sub-frame size*/
-int pitch,           /*pitch period*/
-spx_word16_t *pitch_gain,   /*pitch gain (3-tap)*/
-spx_word16_t  comb_gain,    /*gain of comb filter*/
-CombFilterMem *mem
-)
-{
-   int i;
-   spx_word16_t exc_energy=0, new_exc_energy=0;
-   spx_word16_t gain;
-   spx_word16_t step;
-   spx_word16_t fact;
-   /* FIXME: This is a temporary kludge */
-   spx_sig_t new_exc[40];
-   
-   /*Compute excitation amplitude prior to enhancement*/
-   exc_energy = compute_rms(exc, nsf);
-   /*for (i=0;i<nsf;i++)
-     exc_energy+=((float)exc[i])*exc[i];*/
-
-   /*Some gain adjustment if pitch is too high or if unvoiced*/
-#ifdef FIXED_POINT
-   {
-      spx_word16_t g = gain_3tap_to_1tap(pitch_gain)+gain_3tap_to_1tap(mem->last_pitch_gain);
-      if (g > 166)
-         comb_gain = MULT16_16_Q15(DIV32_16(SHL32(EXTEND32(165),15),g), comb_gain);
-      if (g < 64)
-         comb_gain = MULT16_16_Q15(SHL16(g, 9), comb_gain);
-   }
-#else
-   {
-      float g=0;
-      g = GAIN_SCALING_1*.5*(gain_3tap_to_1tap(pitch_gain)+gain_3tap_to_1tap(mem->last_pitch_gain));
-      if (g>1.3)
-         comb_gain*=1.3/g;
-      if (g<.5)
-         comb_gain*=2.*g;
-   }
-#endif
-   step = DIV32(COMB_STEP, nsf);
-   fact=0;
-
-   /*Apply pitch comb-filter (filter out noise between pitch harmonics)*/
-   for (i=0;i<nsf;i++)
-   {
-      spx_word32_t exc1, exc2;
-
-      fact = ADD16(fact,step);
-      
-      exc1 = SHL32(MULT16_32_Q15(SHL16(pitch_gain[0],7),exc[i-pitch+1]) +
-                 MULT16_32_Q15(SHL16(pitch_gain[1],7),exc[i-pitch]) +
-                 MULT16_32_Q15(SHL16(pitch_gain[2],7),exc[i-pitch-1]) , 2);
-      exc2 = SHL32(MULT16_32_Q15(SHL16(mem->last_pitch_gain[0],7),exc[i-mem->last_pitch+1]) +
-                 MULT16_32_Q15(SHL16(mem->last_pitch_gain[1],7),exc[i-mem->last_pitch]) +
-                 MULT16_32_Q15(SHL16(mem->last_pitch_gain[2],7),exc[i-mem->last_pitch-1]),2);
-
-      new_exc[i] = exc[i] + MULT16_32_Q15(comb_gain, ADD32(MULT16_32_Q15(fact,exc1), MULT16_32_Q15(SUB16(COMB_STEP,fact), exc2)));
-   }
-
-   mem->last_pitch_gain[0] = pitch_gain[0];
-   mem->last_pitch_gain[1] = pitch_gain[1];
-   mem->last_pitch_gain[2] = pitch_gain[2];
-   mem->last_pitch = pitch;
-
-   /*Amplitude after enhancement*/
-   new_exc_energy = compute_rms(new_exc, nsf);
-
-   if (exc_energy > new_exc_energy)
-      exc_energy = new_exc_energy;
-   
-   if (new_exc_energy<1)
-      new_exc_energy=1;
-   if (exc_energy<1)
-      exc_energy=1;
-   gain = DIV32_16(SUB32(SHL32(exc_energy,15),1),new_exc_energy);
-
-#ifdef FIXED_POINT
-   if (gain < 16384)
-      gain = 16384;
-#else
-   if (gain < .5)
-      gain=.5;
-#endif
-
-#ifdef FIXED_POINT
-   for (i=0;i<nsf;i++)
-   {
-      mem->smooth_gain = ADD16(MULT16_16_Q15(31457,mem->smooth_gain), MULT16_16_Q15(1311,gain));
-      new_exc[i] = MULT16_32_Q15(mem->smooth_gain, new_exc[i]);
-   }
-#else
-   for (i=0;i<nsf;i++)
-   {
-      mem->smooth_gain = .96*mem->smooth_gain + .04*gain;
-      new_exc[i] *= mem->smooth_gain;
-   }
-#endif
-   for (i=0;i<nsf;i++)
-      _new_exc[i] = EXTRACT16(PSHR32(new_exc[i],SIG_SHIFT));
-}
-
-#endif

Modified: trunk/speex/libspeex/filters.h
===================================================================
--- trunk/speex/libspeex/filters.h	2006-06-25 02:20:17 UTC (rev 11648)
+++ trunk/speex/libspeex/filters.h	2006-06-25 11:10:32 UTC (rev 11649)
@@ -72,7 +72,6 @@
 
 void compute_impulse_response(const spx_coef_t *ak, const spx_coef_t *awk1, const spx_coef_t *awk2, spx_word16_t *y, int N, int ord, char *stack);
 
-#ifndef OLD_ENHANCER
 void multicomb(
 spx_word16_t *exc,          /*decoded excitation*/
 spx_word16_t *new_exc,      /*enhanced excitation*/
@@ -84,28 +83,5 @@
 spx_word16_t  comb_gain,    /*gain of comb filter*/
 char *stack
 );
-#else
 
-/** Combined filter memory. */
-typedef struct {
-   int   last_pitch;
-   spx_word16_t last_pitch_gain[3];
-   spx_word16_t smooth_gain;
-} CombFilterMem;
-
-void comb_filter_mem_init (CombFilterMem *mem);
-
-void comb_filter(
-spx_sig_t *exc,          /*decoded excitation*/
-spx_word16_t *new_exc,      /*enhanced excitation*/
-spx_coef_t *ak,           /*LPC filter coefs*/
-int p,               /*LPC order*/
-int nsf,             /*sub-frame size*/
-int pitch,           /*pitch period*/
-spx_word16_t *pitch_gain,   /*pitch gain (3-tap)*/
-spx_word16_t  comb_gain,    /*gain of comb filter*/
-CombFilterMem *mem
-);
 #endif
-
-#endif

Modified: trunk/speex/libspeex/nb_celp.c
===================================================================
--- trunk/speex/libspeex/nb_celp.c	2006-06-25 02:20:17 UTC (rev 11648)
+++ trunk/speex/libspeex/nb_celp.c	2006-06-25 11:10:32 UTC (rev 11649)
@@ -1065,23 +1065,14 @@
 
    st->lpc_enh_enabled=1;
 
-#ifdef OLD_ENHANCER
-   st->excBuf = speex_alloc((st->frameSize + st->max_pitch + 1)*sizeof(spx_word16_t));
-   st->exc = st->excBuf + st->max_pitch + 1;
-#else
    st->excBuf = speex_alloc((st->frameSize + 2*st->max_pitch + st->subframeSize + 12)*sizeof(spx_word16_t));
    st->exc = st->excBuf + 2*st->max_pitch + st->subframeSize + 6;
-#endif
    for (i=0;i<st->frameSize + st->max_pitch + 1;i++)
       st->excBuf[i]=0;
 
    st->interp_qlpc = speex_alloc(st->lpcSize*sizeof(spx_coef_t));
    st->old_qlsp = speex_alloc(st->lpcSize*sizeof(spx_lsp_t));
    st->mem_sp = speex_alloc(st->lpcSize*sizeof(spx_mem_t));
-#ifdef OLD_ENHANCER
-   st->comb_mem = speex_alloc(sizeof(CombFilterMem));
-   comb_filter_mem_init (st->comb_mem);
-#endif
    st->pi_gain = speex_alloc((st->nbSubframes)*sizeof(spx_word32_t));
    st->last_pitch = 40;
    st->count_lost=0;
@@ -1119,9 +1110,6 @@
    speex_free (st->interp_qlpc);
    speex_free (st->old_qlsp);
    speex_free (st->mem_sp);
-#ifdef OLD_ENHANCER
-   speex_free (st->comb_mem);
-#endif
    speex_free (st->pi_gain);
 
    speex_free(state);
@@ -1168,11 +1156,7 @@
    pitch_gain = MULT16_16_Q15(fact,pitch_gain) + VERY_SMALL;
 
    /* Shift all buffers by one frame */
-#ifdef OLD_ENHANCER
-   speex_move(st->excBuf, st->excBuf+st->frameSize, (st->max_pitch + 1)*sizeof(spx_word16_t));
-#else
    speex_move(st->excBuf, st->excBuf+st->frameSize, (2*st->max_pitch + st->subframeSize + 12)*sizeof(spx_word16_t));
-#endif   
    for (sub=0;sub<st->nbSubframes;sub++)
    {
       int offset;
@@ -1204,13 +1188,8 @@
          exc[i]= MULT16_16_Q15(pitch_gain, (exc[i-pitch_val]+VERY_SMALL)) + 
                MULT16_16_Q15(fact, MULT16_16_Q15(SHL(Q15ONE,15)-SHL(MULT16_16(pitch_gain,pitch_gain),1),speex_rand(innov_gain, &st->seed)));
       }
-#ifdef OLD_ENHANCER
       for (i=0;i<st->subframeSize;i++)
-         sp[i]=exc[i];
-#else
-      for (i=0;i<st->subframeSize;i++)
          sp[i]=exc[i-st->subframeSize];
-#endif 
       iir_mem16(sp, st->interp_qlpc, sp, st->subframeSize, st->lpcSize, 
                 st->mem_sp, stack);
 
@@ -1350,11 +1329,7 @@
    }
 
    /* Shift all buffers by one frame */
-#ifdef OLD_ENHANCER
-   speex_move(st->excBuf, st->excBuf+st->frameSize, (st->max_pitch + 1)*sizeof(spx_word16_t));
-#else
    speex_move(st->excBuf, st->excBuf+st->frameSize, (2*st->max_pitch + st->subframeSize + 12)*sizeof(spx_word16_t));
-#endif   
 
    /* If null mode (no transmission), just set a couple things to zero*/
    if (st->submodes[st->submodeID] == NULL)
@@ -1669,25 +1644,11 @@
             }
             stack = tmp_stack;
          }
-
       }
-
-#ifdef OLD_ENHANCER
-      if (st->lpc_enh_enabled && SUBMODE(comb_gain)>0 && !st->count_lost)
-      {
-         comb_filter(exc, sp, st->interp_qlpc, st->lpcSize, st->subframeSize,
-                     pitch, pitch_gain, SUBMODE(comb_gain), st->comb_mem);
-      } else {
-         for (i=0;i<st->subframeSize;i++)
-            sp[i]=exc[i];
-      }
-#endif      
-
    }
    
    ALLOC(interp_qlsp, st->lpcSize, spx_lsp_t);
 
-#ifndef OLD_ENHANCER
    if (st->lpc_enh_enabled && SUBMODE(comb_gain)>0 && !st->count_lost)
    {
       multicomb(st->exc-st->subframeSize, out, st->interp_qlpc, st->lpcSize, 2*st->subframeSize, best_pitch, 40, SUBMODE(comb_gain), stack);
@@ -1696,7 +1657,6 @@
       for (i=0;i<st->frameSize;i++)
          out[i]=st->exc[i-st->subframeSize];
    }
-#endif
    
    /* If the last packet was lost, re-scale the excitation to obtain the same energy as encoded in ol_gain */
    if (st->count_lost) 
@@ -1718,11 +1678,7 @@
       for (i=0;i<st->frameSize;i++)
       {
          st->exc[i] = MULT16_16_Q14(gain, st->exc[i]);
-#ifdef OLD_ENHANCER
-         out[i]=st->exc[i];
-#else
          out[i]=st->exc[i-st->subframeSize];
-#endif
       }
    }
 
@@ -1748,11 +1704,6 @@
       /* Compute interpolated LPCs (unquantized) */
       lsp_to_lpc(interp_qlsp, ak, st->lpcSize, stack);
 
-#ifdef OLD_ENHANCER
-      for (i=0;i<st->lpcSize;i++)
-         st->interp_qlpc[i] = ak[i];
-#endif
-      
       /* Compute analysis filter at w=pi */
       {
          spx_word32_t pi_g=LPC_SCALING;
@@ -2038,11 +1989,7 @@
       (*(int*)ptr) = st->encode_submode;
       break;
    case SPEEX_GET_LOOKAHEAD:
-#ifdef OLD_ENHANCER
-      (*(int*)ptr)=0;
-#else
       (*(int*)ptr)=st->subframeSize;
-#endif
       break;
    case SPEEX_GET_PI_GAIN:
       {

Modified: trunk/speex/libspeex/nb_celp.h
===================================================================
--- trunk/speex/libspeex/nb_celp.h	2006-06-25 02:20:17 UTC (rev 11648)
+++ trunk/speex/libspeex/nb_celp.h	2006-06-25 11:10:32 UTC (rev 11649)
@@ -156,9 +156,6 @@
    const SpeexSubmode * const *submodes; /**< Sub-mode data */
    int    submodeID;      /**< Activated sub-mode */
    int    lpc_enh_enabled; /**< 1 when LPC enhancer is on, 0 otherwise */
-#ifdef OLD_ENHANCER
-   CombFilterMem *comb_mem;
-#endif
    SpeexCallback speex_callbacks[SPEEX_MAX_CALLBACKS];
 
    SpeexCallback user_callback;

Modified: trunk/speex/libspeex/sb_celp.c
===================================================================
--- trunk/speex/libspeex/sb_celp.c	2006-06-25 02:20:17 UTC (rev 11648)
+++ trunk/speex/libspeex/sb_celp.c	2006-06-25 11:10:32 UTC (rev 11649)
@@ -1111,11 +1111,6 @@
       /* LSP to LPC */
       lsp_to_lpc(st->interp_qlsp, ak, st->lpcSize, stack);
 
-#ifdef OLD_ENHANCER
-      for (i=0;i<st->lpcSize;i++)
-         st->interp_qlpc[i] = ak[i];
-#endif
-
       /* Calculate reponse ratio between the low and high filter in the middle
          of the band (4000 Hz) */
       
@@ -1220,20 +1215,14 @@
             innov_save[2*i]=exc[i];
       }
       
-#ifdef OLD_ENHANCER
       for (i=0;i<st->subframeSize;i++)
-         st->excBuf[i]=exc[i];
-#endif
-      for (i=0;i<st->subframeSize;i++)
          sp[i]=st->excBuf[i];
       iir_mem2(sp, st->interp_qlpc, sp, st->subframeSize, st->lpcSize, 
                st->mem_sp);
-#ifndef OLD_ENHANCER
       for (i=0;i<st->subframeSize;i++)
          st->excBuf[i]=exc[i];
       for (i=0;i<st->lpcSize;i++)
          st->interp_qlpc[i] = ak[i];
-#endif
 
    }
 



More information about the commits mailing list