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

Jean-Marc Valin jm at xiph.org
Fri Nov 28 18:45:04 PST 2003



jm          03/11/28 21:45:04

  Modified:    libspeex ltp.c ltp.h modes.h nb_celp.c
  Log:
  fixed-point: pitch gain stuff

Revision  Changes    Path
1.102     +17 -16    speex/libspeex/ltp.c

Index: ltp.c
===================================================================
RCS file: /usr/local/cvsroot/speex/libspeex/ltp.c,v
retrieving revision 1.101
retrieving revision 1.102
diff -u -r1.101 -r1.102
--- ltp.c	28 Nov 2003 05:39:57 -0000	1.101
+++ ltp.c	29 Nov 2003 02:45:02 -0000	1.102
@@ -171,7 +171,7 @@
    {
       spx_word16_t g;
       i=pitch[j];
-      g = DIV32(corr[i-start], 10+SHR(MULT16_16(spx_sqrt(e0),spx_sqrt(energy[i-start])),8));
+      g = DIV32(corr[i-start], 10+SHR(MULT16_16(spx_sqrt(e0),spx_sqrt(energy[i-start])),6));
       /* FIXME: g = max(g,corr/energy) */
       if (g<0)
          g = 0;
@@ -421,7 +421,7 @@
 void *par,
 int   start,                    /* Smallest pitch value allowed */
 int   end,                      /* Largest pitch value allowed */
-float pitch_coef,               /* Voicing (pitch) coefficient */
+spx_word16_t pitch_coef,               /* Voicing (pitch) coefficient */
 int   p,                        /* Number of LPC coeffs */
 int   nsf,                      /* Number of samples in subframe */
 SpeexBits *bits,
@@ -495,7 +495,7 @@
 spx_sig_t exc[],                    /* Excitation */
 int   start,                    /* Smallest pitch value allowed */
 int   end,                      /* Largest pitch value allowed */
-float pitch_coef,               /* Voicing (pitch) coefficient */
+spx_word16_t pitch_coef,               /* Voicing (pitch) coefficient */
 void *par,
 int   nsf,                      /* Number of samples in subframe */
 int *pitch_val,
@@ -504,7 +504,7 @@
 char *stack,
 int count_lost,
 int subframe_offset,
-float last_pitch_gain,
+spx_word16_t last_pitch_gain,
 int cdbk_offset
 )
 {
@@ -545,7 +545,7 @@
       gain[2] = 0.015625*sgain[2];
 #endif
       if (1) {
-	 float tmp = count_lost < 4 ? last_pitch_gain : 0.4 * last_pitch_gain;
+	 float tmp = count_lost < 4 ? GAIN_SCALING_1*last_pitch_gain : 0.4 * GAIN_SCALING_1 * last_pitch_gain;
          if (tmp>.95)
             tmp=.95;
          gain_sum = fabs(gain[1]);
@@ -646,7 +646,7 @@
 void *par,
 int   start,                    /* Smallest pitch value allowed */
 int   end,                      /* Largest pitch value allowed */
-float pitch_coef,               /* Voicing (pitch) coefficient */
+spx_word16_t pitch_coef,               /* Voicing (pitch) coefficient */
 int   p,                        /* Number of LPC coeffs */
 int   nsf,                      /* Number of samples in subframe */
 SpeexBits *bits,
@@ -658,11 +658,12 @@
 )
 {
    int i;
-   if (pitch_coef>.99)
-      pitch_coef=.99;
+   float coef = GAIN_SCALING_1*pitch_coef;
+   if (coef>.99)
+      coef=.99;
    for (i=0;i<nsf;i++)
    {
-      exc[i]=exc[i-start]*pitch_coef;
+      exc[i]=exc[i-start]*coef;
    }
    return start;
 }
@@ -672,7 +673,7 @@
 spx_sig_t exc[],                    /* Excitation */
 int   start,                    /* Smallest pitch value allowed */
 int   end,                      /* Largest pitch value allowed */
-float pitch_coef,               /* Voicing (pitch) coefficient */
+spx_word16_t pitch_coef,               /* Voicing (pitch) coefficient */
 void *par,
 int   nsf,                      /* Number of samples in subframe */
 int *pitch_val,
@@ -681,19 +682,19 @@
 char *stack,
 int count_lost,
 int subframe_offset,
-float last_pitch_gain,
+spx_word16_t last_pitch_gain,
 int cdbk_offset
 )
 {
    int i;
-   /*pitch_coef=.9;*/
-   if (pitch_coef>.99)
-      pitch_coef=.99;
+   float coef = GAIN_SCALING_1*pitch_coef;
+   if (coef>.99)
+      coef=.99;
    for (i=0;i<nsf;i++)
    {
-      exc[i]=exc[i-start]*pitch_coef;
+      exc[i]=exc[i-start]*coef;
    }
    *pitch_val = start;
    gain_val[0]=gain_val[2]=0;
-   gain_val[1] = GAIN_SCALING*pitch_coef;
+   gain_val[1] = pitch_coef;
 }

<p><p>1.39      +6 -6      speex/libspeex/ltp.h

Index: ltp.h
===================================================================
RCS file: /usr/local/cvsroot/speex/libspeex/ltp.h,v
retrieving revision 1.38
retrieving revision 1.39
diff -u -r1.38 -r1.39
--- ltp.h	28 Nov 2003 05:39:57 -0000	1.38
+++ ltp.h	29 Nov 2003 02:45:02 -0000	1.39
@@ -59,7 +59,7 @@
 void *par,
 int   start,                    /* Smallest pitch value allowed */
 int   end,                      /* Largest pitch value allowed */
-float pitch_coef,               /* Voicing (pitch) coefficient */
+spx_word16_t pitch_coef,               /* Voicing (pitch) coefficient */
 int   p,                        /* Number of LPC coeffs */
 int   nsf,                      /* Number of samples in subframe */
 SpeexBits *bits,
@@ -75,7 +75,7 @@
 spx_sig_t exc[],                    /* Excitation */
 int   start,                    /* Smallest pitch value allowed */
 int   end,                      /* Largest pitch value allowed */
-float pitch_coef,               /* Voicing (pitch) coefficient */
+spx_word16_t pitch_coef,               /* Voicing (pitch) coefficient */
 void *par,
 int   nsf,                      /* Number of samples in subframe */
 int *pitch_val,
@@ -84,7 +84,7 @@
 char *stack,
 int lost,
 int subframe_offset,
-float last_pitch_gain,
+spx_word16_t last_pitch_gain,
 int cdbk_offset
 );
 
@@ -99,7 +99,7 @@
 void *par,
 int   start,                    /* Smallest pitch value allowed */
 int   end,                      /* Largest pitch value allowed */
-float pitch_coef,               /* Voicing (pitch) coefficient */
+spx_word16_t pitch_coef,               /* Voicing (pitch) coefficient */
 int   p,                        /* Number of LPC coeffs */
 int   nsf,                      /* Number of samples in subframe */
 SpeexBits *bits,
@@ -115,7 +115,7 @@
 spx_sig_t exc[],                    /* Excitation */
 int   start,                    /* Smallest pitch value allowed */
 int   end,                      /* Largest pitch value allowed */
-float pitch_coef,               /* Voicing (pitch) coefficient */
+spx_word16_t pitch_coef,               /* Voicing (pitch) coefficient */
 void *par,
 int   nsf,                      /* Number of samples in subframe */
 int *pitch_val,
@@ -124,6 +124,6 @@
 char *stack,
 int lost,
 int subframe_offset,
-float last_pitch_gain,
+spx_word16_t last_pitch_gain,
 int cdbk_offset
 );

<p><p>1.49      +3 -3      speex/libspeex/modes.h

Index: modes.h
===================================================================
RCS file: /usr/local/cvsroot/speex/libspeex/modes.h,v
retrieving revision 1.48
retrieving revision 1.49
diff -u -r1.48 -r1.49
--- modes.h	28 Nov 2003 05:39:57 -0000	1.48
+++ modes.h	29 Nov 2003 02:45:02 -0000	1.49
@@ -56,12 +56,12 @@
 
 /** Long-term predictor quantization */
 typedef int (*ltp_quant_func)(spx_sig_t *, spx_sig_t *, spx_coef_t *, spx_coef_t *, 
-                              spx_coef_t *, spx_sig_t *, void *, int, int, float, 
+                              spx_coef_t *, spx_sig_t *, void *, int, int, spx_word16_t, 
                               int, int, SpeexBits*, char *, spx_sig_t *, spx_sig_t *, int, int);
 
 /** Long-term un-quantize */
-typedef void (*ltp_unquant_func)(spx_sig_t *, int, int, float, void *, int, int *,
-                                 spx_word16_t *, SpeexBits*, char*, int, int, float, int);
+typedef void (*ltp_unquant_func)(spx_sig_t *, int, int, spx_word16_t, void *, int, int *,
+                                 spx_word16_t *, SpeexBits*, char*, int, int, spx_word16_t, int);
 
 
 /** Innovation quantization function */

<p><p>1.158     +9 -9      speex/libspeex/nb_celp.c

Index: nb_celp.c
===================================================================
RCS file: /usr/local/cvsroot/speex/libspeex/nb_celp.c,v
retrieving revision 1.157
retrieving revision 1.158
diff -u -r1.157 -r1.158
--- nb_celp.c	28 Nov 2003 05:39:57 -0000	1.157
+++ nb_celp.c	29 Nov 2003 02:45:02 -0000	1.158
@@ -347,7 +347,7 @@
 #endif
 
 #ifdef FIXED_POINT
-         ol_pitch_coef *= 0.0039062;
+         ol_pitch_coef *= GAIN_SCALING_1;
 #endif
       } else {
          ol_pitch=0;
@@ -761,7 +761,7 @@
          if (st->lbr_48k)
          {
             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,
+                                       exc, SUBMODE(ltp_params), pit_min, pit_max, GAIN_SCALING*ol_pitch_coef,
                                        st->lpcSize, st->subframeSize, bits, stack, 
                                        exc2, syn_resp, st->complexity, ol_pitch_id);
          } else {
@@ -769,7 +769,7 @@
 
          /* Perform pitch search */
          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,
+                                    exc, SUBMODE(ltp_params), pit_min, pit_max, GAIN_SCALING*ol_pitch_coef,
                                     st->lpcSize, st->subframeSize, bits, stack, 
                                     exc2, syn_resp, st->complexity, 0);
 #ifdef EPIC_48K
@@ -1140,7 +1140,7 @@
    spx_word16_t pitch_gain[3];
    spx_word32_t ol_gain=0;
    int ol_pitch=0;
-   float ol_pitch_coef=0;
+   spx_word16_t ol_pitch_coef=0;
    int best_pitch=40;
    spx_word16_t best_pitch_gain=0;
    int wideband;
@@ -1325,7 +1325,7 @@
       pitch_half[1] = pitch_half[0]+speex_bits_unpack_unsigned(bits, 2)-1;
 
       ol_pitch_id = speex_bits_unpack_unsigned(bits, 3);
-      ol_pitch_coef=0.13514*ol_pitch_id;
+      ol_pitch_coef=GAIN_SCALING*0.13514*ol_pitch_id;
 
       {
          int qe;
@@ -1346,7 +1346,7 @@
    {
       int quant;
       quant = speex_bits_unpack_unsigned(bits, 4);
-      ol_pitch_coef=0.066667*quant;
+      ol_pitch_coef=GAIN_SCALING*0.066667*quant;
    }
    
    /* Get global excitation gain */
@@ -1488,13 +1488,13 @@
          {
              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, ol_pitch_id);
+                                  st->count_lost, offset, GAIN_SCALING*st->last_pitch_gain, ol_pitch_id);
          } else {
 #endif
 
              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);
+                                  st->count_lost, offset, GAIN_SCALING*st->last_pitch_gain, 0);
 
 #ifdef EPIC_48K
          }
@@ -1561,7 +1561,7 @@
          /*Vocoder mode*/
          if (st->submodeID==1) 
          {
-            float g=ol_pitch_coef;
+            float g=ol_pitch_coef*GAIN_SCALING_1;
 
             
             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