[xiph-cvs] cvs commit: speex/libspeex filters.c ltp.c mdf.c misc.h nb_celp.c preprocess.c sb_celp.c smallft.c

Jean-Marc Valin jm at xiph.org
Tue Oct 7 21:43:00 PDT 2003



jm          03/10/08 00:42:59

  Modified:    libspeex filters.c ltp.c mdf.c misc.h nb_celp.c preprocess.c
                        sb_celp.c smallft.c
  Log:
  fixed-point: more conversion to spx_sig_t

Revision  Changes    Path
1.40      +6 -20     speex/libspeex/filters.c

Index: filters.c
===================================================================
RCS file: /usr/local/cvsroot/speex/libspeex/filters.c,v
retrieving revision 1.39
retrieving revision 1.40
diff -u -r1.39 -r1.40
--- filters.c	8 Oct 2003 04:40:41 -0000	1.39
+++ filters.c	8 Oct 2003 04:42:59 -0000	1.40
@@ -50,8 +50,6 @@
 #ifdef FIXED_POINT
 
 
-int fixed_point_on = 1;
-
 #define MUL_16_32_R15(a,bh,bl) ((a)*(bh) + ((a)*(bl)>>15))
 
 
@@ -60,14 +58,10 @@
    int i,j;
    int xi,yi;
 
-   float local_scale = 1;
-   if (!fixed_point_on)
-      local_scale = 16384.;
-
    for (i=0;i<N;i++)
    {
       int xh,xl,yh,yl;
-      xi=floor(.5+local_scale*x[i]);
+      xi=floor(.5+x[i]);
       yi = xi + (mem[0]<<2);
       xh = xi>>15; xl=xi&0x00007fff; yh = yi>>15; yl=yi&0x00007fff; 
       for (j=0;j<ord-1;j++)
@@ -75,7 +69,7 @@
          mem[j] = mem[j+1] +  MUL_16_32_R15(num[j+1],xh,xl) - MUL_16_32_R15(den[j+1],yh,yl);
       }
       mem[ord-1] = MUL_16_32_R15(num[ord],xh,xl) - MUL_16_32_R15(den[ord],yh,yl);
-      y[i] = yi*(1.f/local_scale);
+      y[i] = yi;
    }
 }
 
@@ -84,14 +78,10 @@
    int i,j;
    int xi,yi;
 
-   float local_scale = 1;
-   if (!fixed_point_on)
-      local_scale = 16384.;
-   
    for (i=0;i<N;i++)
    {
       int yh,yl;
-      xi=floor(.5+local_scale*x[i]);
+      xi=floor(.5+x[i]);
       yi = xi + (mem[0]<<2);
       yh = yi>>15; yl=yi&0x00007fff; 
       for (j=0;j<ord-1;j++)
@@ -99,7 +89,7 @@
          mem[j] = mem[j+1] - MUL_16_32_R15(den[j+1],yh,yl);
       }
       mem[ord-1] = - MUL_16_32_R15(den[ord],yh,yl);
-      y[i] = yi*(1.f/local_scale);
+      y[i] = yi;
    }
 }
 
@@ -109,14 +99,10 @@
    int i,j;
    int xi,yi;
 
-   float local_scale = 1;
-   if (!fixed_point_on)
-      local_scale = 16384.;
-
    for (i=0;i<N;i++)
    {
       int xh,xl;
-      xi=floor(.5+local_scale*x[i]);
+      xi=floor(.5+x[i]);
       yi = xi + (mem[0]<<2);
       xh = xi>>15; xl=xi&0x00007fff;
       for (j=0;j<ord-1;j++)
@@ -124,7 +110,7 @@
          mem[j] = mem[j+1] +  MUL_16_32_R15(num[j+1],xh,xl);
       }
       mem[ord-1] = MUL_16_32_R15(num[ord],xh,xl);
-      y[i] = yi*(1.f/local_scale);
+      y[i] = yi;
    }
 
 }

<p><p>1.80      +5 -4      speex/libspeex/ltp.c

Index: ltp.c
===================================================================
RCS file: /usr/local/cvsroot/speex/libspeex/ltp.c,v
retrieving revision 1.79
retrieving revision 1.80
diff -u -r1.79 -r1.80
--- ltp.c	8 Oct 2003 04:40:41 -0000	1.79
+++ ltp.c	8 Oct 2003 04:42:59 -0000	1.80
@@ -36,6 +36,8 @@
 #include "filters.h"
 #include "speex_bits.h"
 
+#include <stdio.h>
+
 #ifdef _USE_SSE
 #include "ltp_sse.h"
 #else
@@ -408,7 +410,6 @@
    if (count_lost && pitch > subframe_offset)
    {
       float gain_sum;
-
       if (1) {
          float tmp = count_lost < 4 ? last_pitch_gain : 0.4 * last_pitch_gain;
          if (tmp>.95)
@@ -448,9 +449,9 @@
    gain_val[2]=gain[2];
 
    {
-      float *e[3];
-      float *tmp2;
-      tmp2=PUSH(stack, 3*nsf, float);
+      spx_sig_t *e[3];
+      spx_sig_t *tmp2;
+      tmp2=PUSH(stack, 3*nsf, spx_sig_t);
       e[0]=tmp2;
       e[1]=tmp2+nsf;
       e[2]=tmp2+2*nsf;

<p><p>1.11      +1 -1      speex/libspeex/mdf.c

Index: mdf.c
===================================================================
RCS file: /usr/local/cvsroot/speex/libspeex/mdf.c,v
retrieving revision 1.10
retrieving revision 1.11
diff -u -r1.10 -r1.11
--- mdf.c	18 Sep 2003 03:58:58 -0000	1.10
+++ mdf.c	8 Oct 2003 04:42:59 -0000	1.11
@@ -55,7 +55,7 @@
    st->cancel_count=0;
    st->adapt_rate = .01;
 
-   st->fft_lookup = speex_alloc(sizeof(struct drft_lookup));
+   st->fft_lookup = (struct drft_lookup*)speex_alloc(sizeof(struct drft_lookup));
    drft_init(st->fft_lookup, N);
    
    st->x = (float*)speex_alloc(N*sizeof(float));

<p><p>1.30      +1 -8      speex/libspeex/misc.h

Index: misc.h
===================================================================
RCS file: /usr/local/cvsroot/speex/libspeex/misc.h,v
retrieving revision 1.29
retrieving revision 1.30
diff -u -r1.29 -r1.30
--- misc.h	8 Oct 2003 04:40:41 -0000	1.29
+++ misc.h	8 Oct 2003 04:42:59 -0000	1.30
@@ -41,15 +41,11 @@
 
 #ifdef FIXED_POINT
 
-extern int fixed_point_on;
-#define FIXED_SIGNAL fixed_point_on=1;
-#define FLOAT_SIGNAL fixed_point_on=0;
-
 typedef short        spx_word16_t;
 typedef int          spx_word32_t;
 typedef spx_word32_t spx_mem_t;
 typedef spx_word16_t spx_coef_t;
-typedef float   spx_sig_t;
+typedef long long   spx_sig_t;
 
 #define LPC_SCALING  8192.
 #define SIG_SCALING  16384.
@@ -74,9 +70,6 @@
 
 #else
 
-#define FIXED_SIGNAL
-#define FLOAT_SIGNAL
-
 typedef float spx_mem_t;
 typedef float spx_coef_t;
 typedef float spx_sig_t;

<p><p>1.132     +22 -18    speex/libspeex/nb_celp.c

Index: nb_celp.c
===================================================================
RCS file: /usr/local/cvsroot/speex/libspeex/nb_celp.c,v
retrieving revision 1.131
retrieving revision 1.132
diff -u -r1.131 -r1.132
--- nb_celp.c	8 Oct 2003 04:40:41 -0000	1.131
+++ nb_celp.c	8 Oct 2003 04:42:59 -0000	1.132
@@ -44,6 +44,8 @@
 #include "misc.h"
 #include "speex_callbacks.h"
 
+#include <stdio.h>
+
 #ifdef SLOW_TRIG
 #include "math_approx.h"
 #define cos speex_cos
@@ -123,9 +125,9 @@
       part2=(st->frameSize>>1) + (st->subframeSize>>1);
       st->window = PUSH(st->stack, st->windowSize, spx_word16_t);
       for (i=0;i<part1;i++)
-         st->window[i]=SIG_SCALING*(.54-.46*cos(M_PI*i/part1));
+         st->window[i]=(spx_word16_t)(SIG_SCALING*(.54-.46*cos(M_PI*i/part1)));
       for (i=0;i<part2;i++)
-         st->window[part1+i]=SIG_SCALING*(.54+.46*cos(M_PI*i/part2));
+         st->window[part1+i]=(spx_word16_t)(SIG_SCALING*(.54+.46*cos(M_PI*i/part2)));
    }
    /* Create the window for autocorrelation (lag-windowing) */
    st->lagWindow = PUSH(st->stack, st->lpcSize+1, float);
@@ -213,14 +215,14 @@
    stack=st->stack;
 
    /* Copy new data in input buffer */
-   speex_move(st->inBuf, st->inBuf+st->frameSize, (st->bufSize-st->frameSize)*sizeof(float));
+   speex_move(st->inBuf, st->inBuf+st->frameSize, (st->bufSize-st->frameSize)*sizeof(spx_sig_t));
    for (i=0;i<st->frameSize;i++)
       st->inBuf[st->bufSize-st->frameSize+i] = SIG_SCALING*in[i];
 
    /* Move signals 1 frame towards the past */
-   speex_move(st->exc2Buf, st->exc2Buf+st->frameSize, (st->bufSize-st->frameSize)*sizeof(float));
-   speex_move(st->excBuf, st->excBuf+st->frameSize, (st->bufSize-st->frameSize)*sizeof(float));
-   speex_move(st->swBuf, st->swBuf+st->frameSize, (st->bufSize-st->frameSize)*sizeof(float));
+   speex_move(st->exc2Buf, st->exc2Buf+st->frameSize, (st->bufSize-st->frameSize)*sizeof(spx_sig_t));
+   speex_move(st->excBuf, st->excBuf+st->frameSize, (st->bufSize-st->frameSize)*sizeof(spx_sig_t));
+   speex_move(st->swBuf, st->swBuf+st->frameSize, (st->bufSize-st->frameSize)*sizeof(spx_sig_t));
 
 
    {
@@ -233,15 +235,15 @@
       /* Compute auto-correlation */
       _spx_autocorr(w_sig, st->autocorr, st->lpcSize+1, st->windowSize);
    }
-   st->autocorr[0] *= st->lpc_floor; /* Noise floor in auto-correlation domain */
+   st->autocorr[0] = (spx_word16_t) (st->autocorr[0]*st->lpc_floor); /* Noise floor in auto-correlation domain */
 
    /* Lag windowing: equivalent to filtering in the power-spectrum domain */
    for (i=0;i<st->lpcSize+1;i++)
-      st->autocorr[i] *= st->lagWindow[i];
+      st->autocorr[i] = (spx_word16_t) (st->autocorr[i]*st->lagWindow[i]);
 
    /* Levinson-Durbin */
    _spx_lpc(st->lpc+1, st->autocorr, st->lpcSize);
-   st->lpc[0]=LPC_SCALING;
+   st->lpc[0]=(spx_coef_t)LPC_SCALING;
 
    /* LPC to LSPs (x-domain) transform */
    roots=lpc_to_lsp (st->lpc, st->lpcSize, st->lsp, 15, 0.2, stack);
@@ -1018,8 +1020,8 @@
    pitch_gain *= fact;
 
    /* Shift all buffers by one frame */
-   speex_move(st->inBuf, st->inBuf+st->frameSize, (st->bufSize-st->frameSize)*sizeof(float));
-   speex_move(st->excBuf, st->excBuf+st->frameSize, (st->bufSize-st->frameSize)*sizeof(float));
+   speex_move(st->inBuf, st->inBuf+st->frameSize, (st->bufSize-st->frameSize)*sizeof(spx_sig_t));
+   speex_move(st->excBuf, st->excBuf+st->frameSize, (st->bufSize-st->frameSize)*sizeof(spx_sig_t));
 
    awk1=PUSH(stack, (st->lpcSize+1), spx_coef_t);
    awk2=PUSH(stack, (st->lpcSize+1), spx_coef_t);
@@ -1231,8 +1233,8 @@
    }
 
    /* Shift all buffers by one frame */
-   speex_move(st->inBuf, st->inBuf+st->frameSize, (st->bufSize-st->frameSize)*sizeof(float));
-   speex_move(st->excBuf, st->excBuf+st->frameSize, (st->bufSize-st->frameSize)*sizeof(float));
+   speex_move(st->inBuf, st->inBuf+st->frameSize, (st->bufSize-st->frameSize)*sizeof(spx_sig_t));
+   speex_move(st->excBuf, st->excBuf+st->frameSize, (st->bufSize-st->frameSize)*sizeof(spx_sig_t));
 
    /* If null mode (no transmission), just set a couple things to zero*/
    if (st->submodes[st->submodeID] == NULL)
@@ -1278,7 +1280,7 @@
          lsp_dist += fabs(st->old_qlsp[i] - st->qlsp[i]);
       fact = .6*exp(-.2*lsp_dist);
       for (i=0;i<2*st->lpcSize;i++)
-         st->mem_sp[i] *= fact;
+         st->mem_sp[i] = (spx_mem_t)(st->mem_sp[i]*fact);
    }
 
 
@@ -1465,6 +1467,7 @@
              SUBMODE(ltp_unquant)(exc, pit_min, pit_max, ol_pitch_coef, SUBMODE(ltp_params), 
                                   st->subframeSize, &pitch, &pitch_gain[0], bits, stack, 
                                   st->count_lost, offset, st->last_pitch_gain, 0);
+
 #ifdef EPIC_48K
          }
 #endif
@@ -1571,6 +1574,7 @@
          } else {
             for (i=0;i<st->subframeSize;i++)
                exc[i]+=innov[i];
+            /*print_vec(exc, 40, "innov");*/
          }
          /* Decode second codebook (only for some modes) */
          if (SUBMODE(double_codebook))
@@ -1777,7 +1781,7 @@
    case SPEEX_GET_EXC:
       {
          int i;
-         float *e = (float*)ptr;
+         spx_sig_t *e = (spx_sig_t*)ptr;
          for (i=0;i<st->frameSize;i++)
             e[i]=st->exc[i];
       }
@@ -1785,7 +1789,7 @@
    case SPEEX_GET_INNOV:
       {
          int i;
-         float *e = (float*)ptr;
+         spx_sig_t *e = (spx_sig_t*)ptr;
          for (i=0;i<st->frameSize;i++)
             e[i]=st->innov[i];
       }
@@ -1877,7 +1881,7 @@
    case SPEEX_GET_EXC:
       {
          int i;
-         float *e = (float*)ptr;
+         spx_sig_t *e = (spx_sig_t*)ptr;
          for (i=0;i<st->frameSize;i++)
             e[i]=st->exc[i];
       }
@@ -1885,7 +1889,7 @@
    case SPEEX_GET_INNOV:
       {
          int i;
-         float *e = (float*)ptr;
+         spx_sig_t *e = (spx_sig_t*)ptr;
          for (i=0;i<st->frameSize;i++)
             e[i]=st->innov[i];
       }

<p><p>1.16      +1 -1      speex/libspeex/preprocess.c

Index: preprocess.c
===================================================================
RCS file: /usr/local/cvsroot/speex/libspeex/preprocess.c,v
retrieving revision 1.15
retrieving revision 1.16
diff -u -r1.15 -r1.16
--- preprocess.c	8 Oct 2003 04:35:01 -0000	1.15
+++ preprocess.c	8 Oct 2003 04:42:59 -0000	1.16
@@ -216,7 +216,7 @@
    st->loudness2 = 6000;
    st->nb_loudness_adapt = 0;
 
-   st->fft_lookup = speex_alloc(sizeof(struct drft_lookup));
+   st->fft_lookup = (struct drft_lookup*)speex_alloc(sizeof(struct drft_lookup));
    drft_init(st->fft_lookup,2*N);
 
    st->nb_adapt=0;

<p><p>1.133     +10 -10    speex/libspeex/sb_celp.c

Index: sb_celp.c
===================================================================
RCS file: /usr/local/cvsroot/speex/libspeex/sb_celp.c,v
retrieving revision 1.132
retrieving revision 1.133
diff -u -r1.132 -r1.133
--- sb_celp.c	8 Oct 2003 04:40:41 -0000	1.132
+++ sb_celp.c	8 Oct 2003 04:42:59 -0000	1.133
@@ -183,9 +183,9 @@
       part2 = st->subframeSize*5/2;
       st->window = PUSH(st->stack, st->windowSize, spx_word16_t);
       for (i=0;i<part1;i++)
-         st->window[i]=SIG_SCALING*(.54-.46*cos(M_PI*i/part1));
+         st->window[i]=(spx_word16_t)(SIG_SCALING*(.54-.46*cos(M_PI*i/part1)));
       for (i=0;i<part2;i++)
-         st->window[part1+i]=SIG_SCALING*(.54+.46*cos(M_PI*i/part2));
+         st->window[part1+i]=(spx_word16_t)(SIG_SCALING*(.54+.46*cos(M_PI*i/part2)));
    }
 
    st->lagWindow = PUSH(st->stack, st->lpcSize+1, float);
@@ -276,7 +276,7 @@
    for (i=0;i<st->frame_size;i++)
       st->high[st->windowSize-st->frame_size+i]=st->x1d[i];
 
-   speex_move(st->excBuf, st->excBuf+st->frame_size, (st->bufSize-st->frame_size)*sizeof(float));
+   speex_move(st->excBuf, st->excBuf+st->frame_size, (st->bufSize-st->frame_size)*sizeof(spx_sig_t));
 
 
    low_pi_gain = PUSH(stack, st->nbSubframes, float);
@@ -304,14 +304,14 @@
       _spx_autocorr(w_sig, st->autocorr, st->lpcSize+1, st->windowSize);
    }
 
-   st->autocorr[0] *= st->lpc_floor; /* Noise floor in auto-correlation domain */
+   st->autocorr[0] = (spx_word16_t)(st->autocorr[0]*st->lpc_floor); /* Noise floor in auto-correlation domain */
    /* Lag windowing: equivalent to filtering in the power-spectrum domain */
    for (i=0;i<st->lpcSize+1;i++)
-      st->autocorr[i] *= st->lagWindow[i];
+      st->autocorr[i] = (spx_word16_t)(st->autocorr[i]*st->lagWindow[i]);
 
    /* Levinson-Durbin */
    _spx_lpc(st->lpc+1, st->autocorr, st->lpcSize);
-   st->lpc[0]=LPC_SCALING;
+   st->lpc[0] = (spx_coef_t)LPC_SCALING;
 
    /* LPC to LSPs (x-domain) transform */
    roots=lpc_to_lsp (st->lpc, st->lpcSize, st->lsp, 15, 0.2, stack);
@@ -1274,7 +1274,7 @@
    case SPEEX_GET_EXC:
       {
          int i;
-         float *e = (float*)ptr;
+         spx_sig_t *e = (spx_sig_t*)ptr;
          for (i=0;i<st->full_frame_size;i++)
             e[i]=0;
          for (i=0;i<st->frame_size;i++)
@@ -1284,7 +1284,7 @@
    case SPEEX_GET_INNOV:
       {
          int i;
-         float *e = (float*)ptr;
+         spx_sig_t *e = (spx_sig_t*)ptr;
          for (i=0;i<st->full_frame_size;i++)
             e[i]=0;
          for (i=0;i<st->frame_size;i++)
@@ -1388,7 +1388,7 @@
    case SPEEX_GET_EXC:
       {
          int i;
-         float *e = (float*)ptr;
+         spx_sig_t *e = (spx_sig_t*)ptr;
          for (i=0;i<st->full_frame_size;i++)
             e[i]=0;
          for (i=0;i<st->frame_size;i++)
@@ -1398,7 +1398,7 @@
    case SPEEX_GET_INNOV:
       {
          int i;
-         float *e = (float*)ptr;
+         spx_sig_t *e = (spx_sig_t*)ptr;
          for (i=0;i<st->full_frame_size;i++)
             e[i]=0;
          for (i=0;i<st->frame_size;i++)

<p><p>1.4       +3 -3      speex/libspeex/smallft.c

Index: smallft.c
===================================================================
RCS file: /usr/local/cvsroot/speex/libspeex/smallft.c,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- smallft.c	18 Sep 2003 03:58:58 -0000	1.3
+++ smallft.c	8 Oct 2003 04:42:59 -0000	1.4
@@ -11,7 +11,7 @@
  ********************************************************************
 
  function: *unnormalized* fft transform
- last mod: $Id: smallft.c,v 1.3 2003/09/18 03:58:58 jm Exp $
+ last mod: $Id: smallft.c,v 1.4 2003/10/08 04:42:59 jm Exp $
 
  ********************************************************************/
 
@@ -1239,8 +1239,8 @@
 void drft_init(struct drft_lookup *l,int n)
 {
   l->n=n;
-  l->trigcache=speex_alloc(3*n*sizeof(*l->trigcache));
-  l->splitcache=speex_alloc(32*sizeof(*l->splitcache));
+  l->trigcache=(float*)speex_alloc(3*n*sizeof(*l->trigcache));
+  l->splitcache=(int*)speex_alloc(32*sizeof(*l->splitcache));
   fdrffti(n, l->trigcache, l->splitcache);
 }
 

<p><p>--- >8 ----
List archives:  http://www.xiph.org/archives/
Ogg project homepage: http://www.xiph.org/ogg/
To unsubscribe from this list, send a message to 'cvs-request at xiph.org'
containing only the word 'unsubscribe' in the body.  No subject is needed.
Unsubscribe messages sent to the list will be ignored/filtered.



More information about the commits mailing list