[xiph-cvs] cvs commit: speex/libspeex cb_search.c cb_search.h ltp.c ltp.h modes.h nb_celp.c sb_celp.c

Jean-Marc Valin jm at xiph.org
Wed Oct 23 09:35:38 PDT 2002



jm          02/10/23 12:35:38

  Modified:    libspeex cb_search.c cb_search.h ltp.c ltp.h modes.h
                        nb_celp.c sb_celp.c
  Log:
  Compute impulse response of "perceptual synthesis filter" globally and
  use it in pitch prediction to reduce some calculations.

Revision  Changes    Path
1.73      +3 -7      speex/libspeex/cb_search.c

Index: cb_search.c
===================================================================
RCS file: /usr/local/cvsroot/speex/libspeex/cb_search.c,v
retrieving revision 1.72
retrieving revision 1.73
diff -u -r1.72 -r1.73
--- cb_search.c	23 Oct 2002 06:24:57 -0000	1.72
+++ cb_search.c	23 Oct 2002 16:35:37 -0000	1.73
@@ -60,6 +60,7 @@
 int   p,                        /* number of LPC coeffs */
 int   nsf,                      /* number of samples in subframe */
 float *exc,
+float *r,
 SpeexBits *bits,
 float *stack,
 int   complexity
@@ -67,7 +68,7 @@
 {
    int i,j,k,m,n,q;
    float *resp;
-   float *t, *r, *e, *E;
+   float *t, *e, *E;
    /*FIXME: Should make this dynamic*/
    float *tmp, *_ot[20], *_nt[20];
    float *ndist, *odist;
@@ -101,7 +102,6 @@
    have_sign = params->have_sign;
    resp = PUSH(stack, shape_cb_size*subvect_size);
    t = PUSH(stack, nsf);
-   r = PUSH(stack, nsf);
    e = PUSH(stack, nsf);
    E = PUSH(stack, shape_cb_size);
    /*FIXME: This breaks if sizeof(int) != sizeof(float) */
@@ -141,11 +141,6 @@
    for (i=0;i<nsf;i++)
       t[i]=target[i];
 
-   e[0]=1;
-   for (i=1;i<nsf;i++)
-      e[i]=0;
-   syn_percep_zero(e, ak, awk1, awk2, r, nsf,p, stack);
-
    /* Pre-compute codewords response and energy */
    for (i=0;i<shape_cb_size;i++)
    {
@@ -380,6 +375,7 @@
 int   p,                        /* number of LPC coeffs */
 int   nsf,                      /* number of samples in subframe */
 float *exc,
+float *r,
 SpeexBits *bits,
 float *stack,
 int   complexity

<p><p>1.25      +2 -0      speex/libspeex/cb_search.h

Index: cb_search.h
===================================================================
RCS file: /usr/local/cvsroot/speex/libspeex/cb_search.h,v
retrieving revision 1.24
retrieving revision 1.25
diff -u -r1.24 -r1.25
--- cb_search.h	23 Oct 2002 06:03:16 -0000	1.24
+++ cb_search.h	23 Oct 2002 16:35:37 -0000	1.25
@@ -53,6 +53,7 @@
 int   p,                        /* number of LPC coeffs */
 int   nsf,                      /* number of samples in subframe */
 float *exc,
+float *r,
 SpeexBits *bits,
 float *stack,
 int   complexity
@@ -76,6 +77,7 @@
 int   p,                        /* number of LPC coeffs */
 int   nsf,                      /* number of samples in subframe */
 float *exc,
+float *r,
 SpeexBits *bits,
 float *stack,
 int   complexity

<p><p>1.58      +22 -4     speex/libspeex/ltp.c

Index: ltp.c
===================================================================
RCS file: /usr/local/cvsroot/speex/libspeex/ltp.c,v
retrieving revision 1.57
retrieving revision 1.58
diff -u -r1.57 -r1.58
--- ltp.c	21 Oct 2002 20:39:38 -0000	1.57
+++ ltp.c	23 Oct 2002 16:35:37 -0000	1.58
@@ -151,6 +151,7 @@
 SpeexBits *bits,
 float *stack,
 float *exc2,
+float *r,
 int  *cdbk_index
 )
 {
@@ -164,6 +165,7 @@
    int   gain_cdbk_size;
    float *gain_cdbk;
    float err1,err2;
+
    ltp_params *params;
    params = (ltp_params*) par;
    gain_cdbk=params->gain_cdbk;
@@ -179,7 +181,7 @@
    e[1]=tmp2+nsf;
    e[2]=tmp2+2*nsf;
    
-   for (i=0;i<3;i++)
+   for (i=2;i>=0;i--)
    {
       int pp=pitch+1-i;
       for (j=0;j<nsf;j++)
@@ -192,7 +194,15 @@
             e[i][j]=0;
       }
 
-      syn_percep_zero(e[i], ak, awk1, awk2, x[i], nsf, p, stack);
+      if (i==2)
+         syn_percep_zero(e[i], ak, awk1, awk2, x[i], nsf, p, stack);
+      else {
+         for (j=0;j<nsf-1;j++)
+            x[i][j+1]=x[i+1][j];
+         x[i][0]=0;
+         for (j=0;j<nsf;j++)
+            x[i][j]+=e[i][0]*r[j];
+      }
    }
 
    for (i=0;i<3;i++)
@@ -327,6 +337,7 @@
 SpeexBits *bits,
 float *stack,
 float *exc2,
+float *r,
 int complexity
 )
 {
@@ -362,7 +373,7 @@
       for (j=0;j<nsf;j++)
          exc[j]=0;
       err=pitch_gain_search_3tap(target, ak, awk1, awk2, exc, par, pitch, p, nsf,
-                                 bits, stack, exc2, &cdbk_index);
+                                 bits, stack, exc2, r, &cdbk_index);
       if (err<best_err || best_err<0)
       {
          for (j=0;j<nsf;j++)
@@ -453,8 +464,14 @@
          {
             if (j-pp<0)
                e[i][j]=exc[j-pp];
-            else
+            else if (j-pp-pitch<0)
                e[i][j]=exc[j-pp-pitch];
+            else
+               e[i][j]=0;
+         /*if (j-pp<0)
+               e[i][j]=exc[j-pp];
+            else
+            e[i][j]=exc[j-pp-pitch];*/
          }
       }
       for (i=0;i<nsf;i++)
@@ -481,6 +498,7 @@
 SpeexBits *bits,
 float *stack,
 float *exc2,
+float *r,
 int complexity
 )
 {

<p><p>1.28      +3 -0      speex/libspeex/ltp.h

Index: ltp.h
===================================================================
RCS file: /usr/local/cvsroot/speex/libspeex/ltp.h,v
retrieving revision 1.27
retrieving revision 1.28
diff -u -r1.27 -r1.28
--- ltp.h	11 Oct 2002 03:39:34 -0000	1.27
+++ ltp.h	23 Oct 2002 16:35:37 -0000	1.28
@@ -60,6 +60,7 @@
 SpeexBits *bits,
 float *stack,
 float *exc2,
+float *r,
 int   complexity
 );
 
@@ -91,6 +92,7 @@
 SpeexBits *bits,
 float *stack,
 float *exc2,
+float *r,
 int  *cdbk_index
 );
 
@@ -112,6 +114,7 @@
 SpeexBits *bits,
 float *stack,
 float *exc2,
+float *r,
 int complexity
 );
 

<p><p>1.36      +2 -2      speex/libspeex/modes.h

Index: modes.h
===================================================================
RCS file: /usr/local/cvsroot/speex/libspeex/modes.h,v
retrieving revision 1.35
retrieving revision 1.36
diff -u -r1.35 -r1.36
--- modes.h	11 Oct 2002 03:39:34 -0000	1.35
+++ modes.h	23 Oct 2002 16:35:37 -0000	1.36
@@ -57,7 +57,7 @@
 /** Long-term predictor quantization */
 typedef int (*ltp_quant_func)(float *, float *, float *, float *, 
                               float *, float *, void *, int, int, float, 
-                              int, int, SpeexBits*, float *, float *, int);
+                              int, int, SpeexBits*, float *, float *, float *, int);
 
 /** Long-term un-quantize */
 typedef void (*ltp_unquant_func)(float *, int, int, float, void *, int, int *,
@@ -66,7 +66,7 @@
 
 /** Innovation quantization function */
 typedef void (*innovation_quant_func)(float *, float *, float *, float *, void *, int, int, 
-                                      float *, SpeexBits *, float *, int);
+                                      float *, float *, SpeexBits *, float *, int);
 
 /** Innovation unquantization function */
 typedef void (*innovation_unquant_func)(float *, void *, int, SpeexBits*, float *);

<p><p>1.66      +10 -3     speex/libspeex/nb_celp.c

Index: nb_celp.c
===================================================================
RCS file: /usr/local/cvsroot/speex/libspeex/nb_celp.c,v
retrieving revision 1.65
retrieving revision 1.66
diff -u -r1.65 -r1.66
--- nb_celp.c	23 Oct 2002 06:24:57 -0000	1.65
+++ nb_celp.c	23 Oct 2002 16:35:37 -0000	1.66
@@ -217,6 +217,7 @@
    float delta_qual=0;
    float *res, *target, *mem;
    float *stack;
+   float *syn_resp;
 
    st=state;
    stack=st->stack;
@@ -442,6 +443,7 @@
    res = PUSH(stack, st->subframeSize);
    /* Target signal */
    target = PUSH(stack, st->subframeSize);
+   syn_resp = PUSH(stack, st->subframeSize);
    mem = PUSH(stack, st->lpcSize);
 
    /* Loop on sub-frames */
@@ -506,6 +508,11 @@
             st->bw_lpc2[i]=0;
       }
 
+      for (i=0;i<st->subframeSize;i++)
+         exc[i]=0;
+      exc[0]=1;
+      syn_percep_zero(exc, st->interp_qlpc, st->bw_lpc1, st->bw_lpc2, syn_resp, st->subframeSize, st->lpcSize, stack);
+
       /* Reset excitation */
       for (i=0;i<st->subframeSize;i++)
          exc[i]=0;
@@ -567,7 +574,7 @@
          pitch = SUBMODE(ltp_quant)(target, sw, st->interp_qlpc, st->bw_lpc1, st->bw_lpc2,
                                     exc, SUBMODE(ltp_params), pit_min, pit_max, ol_pitch_coef,
                                     st->lpcSize, st->subframeSize, bits, stack, 
-                                    exc2, st->complexity);
+                                    exc2, syn_resp, st->complexity);
 
          /*printf ("cl_pitch: %d\n", pitch);*/
          st->pitch[sub]=pitch;
@@ -651,7 +658,7 @@
             /* Normal quantization */
             SUBMODE(innovation_quant)(target, st->interp_qlpc, st->bw_lpc1, st->bw_lpc2, 
                                       SUBMODE(innovation_params), st->lpcSize, st->subframeSize, 
-                                      innov, bits, stack, st->complexity);
+                                      innov, syn_resp, bits, stack, st->complexity);
             for (i=0;i<st->subframeSize;i++)
                innov[i]*=ener;
             for (i=0;i<st->subframeSize;i++)
@@ -669,7 +676,7 @@
                target[i]*=2.2;
             SUBMODE(innovation_quant)(target, st->interp_qlpc, st->bw_lpc1, st->bw_lpc2, 
                                       SUBMODE(innovation_params), st->lpcSize, st->subframeSize, 
-                                      innov2, bits, tmp_stack, st->complexity);
+                                      innov2, syn_resp, bits, tmp_stack, st->complexity);
             for (i=0;i<st->subframeSize;i++)
                innov2[i]*=ener*(1/2.2);
             for (i=0;i<st->subframeSize;i++)

<p><p>1.78      +9 -3      speex/libspeex/sb_celp.c

Index: sb_celp.c
===================================================================
RCS file: /usr/local/cvsroot/speex/libspeex/sb_celp.c,v
retrieving revision 1.77
retrieving revision 1.78
diff -u -r1.77 -r1.78
--- sb_celp.c	23 Oct 2002 06:03:16 -0000	1.77
+++ sb_celp.c	23 Oct 2002 16:35:37 -0000	1.78
@@ -270,7 +270,7 @@
    SBEncState *st;
    int i, roots, sub;
    float *stack;
-   float *mem, *innov;
+   float *mem, *innov, *syn_resp;
 
    st = state;
    stack=st->stack;
@@ -395,6 +395,7 @@
    }
    
    mem=PUSH(stack, st->lpcSize);
+   syn_resp=PUSH(stack, st->subframeSize);
    innov = PUSH(stack, st->subframeSize);
 
    for (sub=0;sub<st->nbSubframes;sub++)
@@ -516,6 +517,11 @@
             }
          }
 
+         for (i=0;i<st->subframeSize;i++)
+            exc[i]=0;
+         exc[0]=1;
+         syn_percep_zero(exc, st->interp_qlpc, st->bw_lpc1, st->bw_lpc2, syn_resp, st->subframeSize, st->lpcSize, stack);
+         
          /* Reset excitation */
          for (i=0;i<st->subframeSize;i++)
             exc[i]=0;
@@ -569,7 +575,7 @@
          /*print_vec(target, st->subframeSize, "\ntarget");*/
          SUBMODE(innovation_quant)(target, st->interp_qlpc, st->bw_lpc1, st->bw_lpc2, 
                                    SUBMODE(innovation_params), st->lpcSize, st->subframeSize, 
-                                   innov, bits, stack, (st->complexity+1)>>1);
+                                   innov, syn_resp, bits, stack, (st->complexity+1)>>1);
          /*print_vec(target, st->subframeSize, "after");*/
 
          for (i=0;i<st->subframeSize;i++)
@@ -584,7 +590,7 @@
                target[i]*=2.5;
             SUBMODE(innovation_quant)(target, st->interp_qlpc, st->bw_lpc1, st->bw_lpc2, 
                                       SUBMODE(innovation_params), st->lpcSize, st->subframeSize, 
-                                      innov2, bits, tmp_stack, (st->complexity+1)>>1);
+                                      innov2, syn_resp, bits, tmp_stack, (st->complexity+1)>>1);
             for (i=0;i<st->subframeSize;i++)
                innov2[i]*=scale*(1/2.5);
             for (i=0;i<st->subframeSize;i++)

<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