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

jm at svn.xiph.org jm at svn.xiph.org
Sun Dec 3 01:57:11 PST 2006


Author: jm
Date: 2006-12-03 01:57:08 -0800 (Sun, 03 Dec 2006)
New Revision: 12169

Modified:
   trunk/speex/libspeex/filters.c
   trunk/speex/libspeex/filters.h
   trunk/speex/libspeex/sb_celp.c
   trunk/speex/libspeex/sb_celp.h
Log:
Another 1 kB off the encoder state by converting the qmf_decomp output to 
16-bit.


Modified: trunk/speex/libspeex/filters.c
===================================================================
--- trunk/speex/libspeex/filters.c	2006-12-02 23:35:07 UTC (rev 12168)
+++ trunk/speex/libspeex/filters.c	2006-12-03 09:57:08 UTC (rev 12169)
@@ -581,7 +581,7 @@
 }
 #endif
 
-void qmf_decomp(const spx_word16_t *xx, const spx_word16_t *aa, spx_sig_t *y1, spx_sig_t *y2, int N, int M, spx_word16_t *mem, char *stack)
+void qmf_decomp(const spx_word16_t *xx, const spx_word16_t *aa, spx_word16_t *y1, spx_word16_t *y2, int N, int M, spx_word16_t *mem, char *stack)
 {
    int i,j,k,M2;
    VARDECL(spx_word16_t *a);
@@ -601,18 +601,17 @@
       x[i+M-1]=SHR16(xx[i],1);
    for (i=0,k=0;i<N;i+=2,k++)
    {
-      y1[k]=0;
-      y2[k]=0;
+      spx_word32_t y1k=0, y2k=0;
       for (j=0;j<M2;j++)
       {
-         y1[k]=ADD32(y1[k],MULT16_16(a[j],ADD16(x[i+j],x2[i-j])));
-         y2[k]=SUB32(y2[k],MULT16_16(a[j],SUB16(x[i+j],x2[i-j])));
+         y1k=ADD32(y1k,MULT16_16(a[j],ADD16(x[i+j],x2[i-j])));
+         y2k=SUB32(y2k,MULT16_16(a[j],SUB16(x[i+j],x2[i-j])));
          j++;
-         y1[k]=ADD32(y1[k],MULT16_16(a[j],ADD16(x[i+j],x2[i-j])));
-         y2[k]=ADD32(y2[k],MULT16_16(a[j],SUB16(x[i+j],x2[i-j])));
+         y1k=ADD32(y1k,MULT16_16(a[j],ADD16(x[i+j],x2[i-j])));
+         y2k=ADD32(y2k,MULT16_16(a[j],SUB16(x[i+j],x2[i-j])));
       }
-      y1[k] = SHR32(y1[k],1);
-      y2[k] = SHR32(y2[k],1);
+      y1[k] = EXTRACT16(SATURATE(PSHR32(y1k,15),32767));
+      y2[k] = EXTRACT16(SATURATE(PSHR32(y2k,15),32767));
    }
    for (i=0;i<M-1;i++)
      mem[i]=SHR16(xx[N-i-1],1);

Modified: trunk/speex/libspeex/filters.h
===================================================================
--- trunk/speex/libspeex/filters.h	2006-12-02 23:35:07 UTC (rev 12168)
+++ trunk/speex/libspeex/filters.h	2006-12-03 09:57:08 UTC (rev 12169)
@@ -58,7 +58,7 @@
 void highpass(const spx_word16_t *x, spx_word16_t *y, int len, int filtID, spx_mem_t *mem);
 
 
-void qmf_decomp(const spx_word16_t *xx, const spx_word16_t *aa, spx_sig_t *, spx_sig_t *y2, int N, int M, spx_word16_t *mem, char *stack);
+void qmf_decomp(const spx_word16_t *xx, const spx_word16_t *aa, spx_word16_t *, spx_word16_t *y2, int N, int M, spx_word16_t *mem, char *stack);
 void qmf_synth(const spx_word16_t *x1, const spx_word16_t *x2, const spx_word16_t *a, spx_word16_t *y, int N, int M, spx_word32_t *mem1, spx_word32_t *mem2, char *stack);
 
 void filter_mem2(const spx_sig_t *x, const spx_coef_t *num, const spx_coef_t *den, spx_sig_t *y, int N, int ord, spx_mem_t *mem);

Modified: trunk/speex/libspeex/sb_celp.c
===================================================================
--- trunk/speex/libspeex/sb_celp.c	2006-12-02 23:35:07 UTC (rev 12168)
+++ trunk/speex/libspeex/sb_celp.c	2006-12-03 09:57:08 UTC (rev 12169)
@@ -210,8 +210,8 @@
    st->gamma2=mode->gamma2;
    st->first=1;
 
-   st->x0d=(spx_sig_t*)speex_alloc((st->frame_size)*sizeof(spx_sig_t));
-   st->x1d=(spx_sig_t*)speex_alloc((st->frame_size)*sizeof(spx_sig_t));
+   st->x0d=(spx_word16_t*)speex_alloc((st->frame_size)*sizeof(spx_word16_t));
+   st->x1d=(spx_word16_t*)speex_alloc((st->frame_size)*sizeof(spx_word16_t));
    st->high=(spx_sig_t*)speex_alloc((st->full_frame_size)*sizeof(spx_sig_t));
 
    st->h0_mem=(spx_word16_t*)speex_alloc((QMF_ORDER)*sizeof(spx_word16_t));
@@ -326,6 +326,7 @@
    VARDECL(spx_word16_t *syn_resp);
    VARDECL(spx_word32_t *low_pi_gain);
    VARDECL(spx_word16_t *low_exc);
+   VARDECL(spx_word16_t *low);
    const SpeexSBMode *mode;
    spx_int32_t dtx;
    spx_word16_t *in = (spx_word16_t*)vin;
@@ -333,28 +334,19 @@
    st = (SBEncState*)state;
    stack=st->stack;
    mode = (const SpeexSBMode*)(st->mode->mode);
+   ALLOC(low, st->frame_size, spx_word16_t);
 
-   {
-      VARDECL(spx_word16_t *low);
-      ALLOC(low, st->frame_size, spx_word16_t);
-
       /* Compute the two sub-bands by filtering with h0 and h1*/
-      qmf_decomp(in, h0, st->x0d, st->x1d, st->full_frame_size, QMF_ORDER, st->h0_mem, stack);
+      qmf_decomp(in, h0, low, st->x1d, st->full_frame_size, QMF_ORDER, st->h0_mem, stack);
       
-      for (i=0;i<st->frame_size;i++)
-         low[i] = EXTRACT16(SATURATE(PSHR32(st->x0d[i],SIG_SHIFT),32767));
-      
       /* Encode the narrowband part*/
       speex_encode_native(st->st_low, low, bits);
 
-      for (i=0;i<st->frame_size;i++)
-         st->x0d[i] = SHL32(EXTEND32(low[i]),SIG_SHIFT);
-   }
    /* High-band buffering / sync with low band */
    for (i=0;i<st->windowSize-st->frame_size;i++)
       st->high[i] = st->high[st->frame_size+i];
    for (i=0;i<st->frame_size;i++)
-      st->high[st->windowSize-st->frame_size+i]=SATURATE(st->x1d[i],536854528);
+      st->high[st->windowSize-st->frame_size+i]=SHL32(st->x1d[i],SIG_SHIFT);
 
    speex_move(st->excBuf, st->excBuf+st->frame_size, (st->bufSize-st->frame_size)*sizeof(spx_sig_t));
 
@@ -430,7 +422,7 @@
 
 
       /*FIXME: Are the two signals (low, high) in sync? */
-      e_low = compute_rms(st->x0d, st->frame_size);
+      e_low = compute_rms16(low, st->frame_size);
       e_high = compute_rms(st->high, st->frame_size);
       ratio = 2*log((1+e_high)/(1+e_low));
       
@@ -509,7 +501,7 @@
 
 #ifdef RESYNTH
       /* Reconstruct the original */
-      qmf_synth(st->x0d, st->high, h0, in, st->full_frame_size, QMF_ORDER, st->g0_mem, st->g1_mem, stack);
+      qmf_synth(low, st->high, h0, in, st->full_frame_size, QMF_ORDER, st->g0_mem, st->g1_mem, stack);
 #endif
 
       if (dtx)
@@ -752,7 +744,7 @@
 
 #ifdef RESYNTH
    /* Reconstruct the original */
-   qmf_synth(st->x0d, st->high, h0, in, st->full_frame_size, QMF_ORDER, st->g0_mem, st->g1_mem, stack);
+   qmf_synth(low, st->high, h0, in, st->full_frame_size, QMF_ORDER, st->g0_mem, st->g1_mem, stack);
 #endif
    for (i=0;i<st->lpcSize;i++)
       st->old_lsp[i] = st->lsp[i];

Modified: trunk/speex/libspeex/sb_celp.h
===================================================================
--- trunk/speex/libspeex/sb_celp.h	2006-12-02 23:35:07 UTC (rev 12168)
+++ trunk/speex/libspeex/sb_celp.h	2006-12-03 09:57:08 UTC (rev 12169)
@@ -58,7 +58,7 @@
    spx_word16_t  gamma2;          /**< Perceptual weighting coef 2 */
 
    char  *stack;                  /**< Temporary allocation stack */
-   spx_sig_t *x0d, *x1d;          /**< QMF filter signals*/
+   spx_word16_t *x0d, *x1d;          /**< QMF filter signals*/
    spx_sig_t *high;               /**< High-band signal (buffer) */
    spx_word16_t *h0_mem, *h1_mem;
    spx_word32_t *g0_mem, *g1_mem; /**< QMF memories */



More information about the commits mailing list