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

Jean-Marc Valin jm at xiph.org
Tue Dec 23 00:11:14 PST 2003



jm          03/12/23 03:11:14

  Modified:    libspeex modes.c modes.h nb_celp.c nb_celp.h sb_celp.c
  Log:
  fixed-point: some perceptual enhancement coef converted.

Revision  Changes    Path
1.112     +80 -30    speex/libspeex/modes.c

Index: modes.c
===================================================================
RCS file: /usr/local/cvsroot/speex/libspeex/modes.c,v
retrieving revision 1.111
retrieving revision 1.112
diff -u -r1.111 -r1.112
--- modes.c	4 Dec 2003 21:29:18 -0000	1.111
+++ modes.c	23 Dec 2003 08:11:13 -0000	1.112
@@ -181,7 +181,11 @@
    noise_codebook_quant,
    noise_codebook_unquant,
    NULL,
-   .7, .7, -1,
+#ifdef FIXED_POINT
+   22938, 22938, 0, -1,
+#else
+   .7, .7, 0, -1,
+#endif
    43
 };
 
@@ -202,8 +206,11 @@
    split_cb_search_shape_sign,
    split_cb_shape_sign_unquant,
    &split_cb_nb_ulbr,
-
-   0.7, 0.5, .65,
+#ifdef FIXED_POINT
+   22938, 16384, 11796, .65,
+#else
+   0.7, 0.5, .36, .65,
+#endif
    79
 };
 
@@ -224,8 +231,11 @@
    split_cb_search_shape_sign,
    split_cb_shape_sign_unquant,
    &split_cb_nb_vlbr,
-
-   0.7, 0.5, .55,
+#ifdef FIXED_POINT
+   22938, 16384, 11796, .55,
+#else
+   0.7, 0.5, .36, .55,
+#endif
    119
 };
 
@@ -246,8 +256,11 @@
    split_cb_search_shape_sign,
    split_cb_shape_sign_unquant,
    &split_cb_nb_lbr,
-
-   0.7, 0.55, .45,
+#ifdef FIXED_POINT
+   22938, 18022, 9830, .45,
+#else
+   0.7, 0.55, .30, .45,
+#endif
    160
 };
 
@@ -268,8 +281,11 @@
    split_cb_search_shape_sign,
    split_cb_shape_sign_unquant,
    &split_cb_nb_med,
-
-   0.7, 0.63, .35,
+#ifdef FIXED_POINT
+   22938, 20644, 5243, .35,
+#else
+   0.7, 0.63, .16, .35,
+#endif
    220
 };
 
@@ -290,8 +306,11 @@
    split_cb_search_shape_sign,
    split_cb_shape_sign_unquant,
    &split_cb_nb,
-
-   0.7, 0.65, .25,
+#ifdef FIXED_POINT
+   22938, 21299, 3932, .25,
+#else
+   0.7, 0.65, .12, .25,
+#endif
    300
 };
 
@@ -312,8 +331,11 @@
    split_cb_search_shape_sign,
    split_cb_shape_sign_unquant,
    &split_cb_sb,
-
-   0.68, 0.65, .1,
+#ifdef FIXED_POINT
+   22282, 21299, 2294, .1,
+#else
+   0.68, 0.65, .07, .1,
+#endif
    364
 };
 
@@ -334,8 +356,11 @@
    split_cb_search_shape_sign,
    split_cb_shape_sign_unquant,
    &split_cb_nb,
-
-   0.65, 0.65, -1,
+#ifdef FIXED_POINT
+   21299, 21299, 0, -1,
+#else
+   0.65, 0.65, .0, -1,
+#endif
    492
 };
 
@@ -348,8 +373,11 @@
    640,    /*bufSize*/
    17,     /*pitchStart*/
    144,    /*pitchEnd*/
-   0.9,    /*gamma1*/
-   0.6,    /*gamma2*/
+#ifdef FIXED_POINT
+   29491, 19661, /* gamma1, gamma2 */
+#else
+   0.9, 0.6, /* gamma1, gamma2 */
+#endif
    .012,   /*lag_factor*/
    1.0002, /*lpc_floor*/
 #ifdef EPIC_48K
@@ -398,8 +426,11 @@
    NULL,
    NULL,
    NULL,
-
-   .75, .75, -1,
+#ifdef FIXED_POINT
+   24576, 24576, 0, -1,
+#else
+   .75, .75, .0, -1,
+#endif
    36
 };
 
@@ -420,8 +451,11 @@
    split_cb_search_shape_sign,
    split_cb_shape_sign_unquant,
    &split_cb_high_lbr,
-
-   .85, .6, -1,
+#ifdef FIXED_POINT
+   27853, 19661, 8192, -1,
+#else
+   .85, .6, .25, -1,
+#endif
    112
 };
 
@@ -443,7 +477,11 @@
    split_cb_shape_sign_unquant,
    &split_cb_high,
 
-   .75, .7, -1,
+#ifdef FIXED_POINT
+   24576, 22938, 1638, -1,
+#else
+   .75, .7, .05, -1,
+#endif
    192
 };
 
@@ -463,8 +501,11 @@
    split_cb_search_shape_sign,
    split_cb_shape_sign_unquant,
    &split_cb_high,
-
-   .75, .75, -1,
+#ifdef FIXED_POINT
+   24576, 24576, 0, -1,
+#else
+   .75, .75, .0, -1,
+#endif
    352
 };
 
@@ -476,8 +517,11 @@
    40,     /*subframeSize*/
    8,     /*lpcSize*/
    640,    /*bufSize*/
-   .9,    /*gamma1*/
-   0.6,    /*gamma2*/
+#ifdef FIXED_POINT
+   29491, 19661, /* gamma1, gamma2 */
+#else
+   0.9, 0.6, /* gamma1, gamma2 */
+#endif
    .001,   /*lag_factor*/
    1.0001, /*lpc_floor*/
    0.9,
@@ -519,8 +563,11 @@
    80,     /*subframeSize*/
    8,     /*lpcSize*/
    1280,    /*bufSize*/
-   .9,    /*gamma1*/
-   0.6,    /*gamma2*/
+#ifdef FIXED_POINT
+   29491, 19661, /* gamma1, gamma2 */
+#else
+   0.9, 0.6, /* gamma1, gamma2 */
+#endif
    .002,   /*lag_factor*/
    1.0001, /*lpc_floor*/
    0.7,
@@ -590,8 +637,11 @@
    split_cb_search_shape_sign,
    split_cb_shape_sign_unquant,
    &split_cb_nb_48k,
-
-   0.7, 0.5, .55,
+#ifdef FIXED_POINT
+   22938, 16384, 11796, .55,
+#else
+   0.7, 0.5, .36, .55,
+#endif
    144
 };
 

<p><p>1.51      +7 -6      speex/libspeex/modes.h

Index: modes.h
===================================================================
RCS file: /usr/local/cvsroot/speex/libspeex/modes.h,v
retrieving revision 1.50
retrieving revision 1.51
diff -u -r1.50 -r1.51
--- modes.h	4 Dec 2003 21:29:18 -0000	1.50
+++ modes.h	23 Dec 2003 08:11:13 -0000	1.51
@@ -92,8 +92,9 @@
    const void             *innovation_params; /**< Innovation quantization parameters*/
 
    /*Synthesis filter enhancement*/
-   float             lpc_enh_k1; /**< Enhancer constant */
-   float             lpc_enh_k2; /**< Enhancer constant */
+   spx_word16_t      lpc_enh_k1; /**< Enhancer constant */
+   spx_word16_t      lpc_enh_k2; /**< Enhancer constant */
+   spx_word16_t      lpc_enh_k3; /**< Enhancer constant */
    float             comb_gain;  /**< Gain of enhancer comb filter */
 
    int               bits_per_frame; /**< Number of bits per frame after encoding*/
@@ -108,8 +109,8 @@
    int     pitchStart;     /**< Smallest pitch value allowed */
    int     pitchEnd;       /**< Largest pitch value allowed */
 
-   float   gamma1;         /**< Perceptual filter parameter #1 */
-   float   gamma2;         /**< Perceptual filter parameter #2 */
+   spx_word16_t gamma1;    /**< Perceptual filter parameter #1 */
+   spx_word16_t gamma2;    /**< Perceptual filter parameter #2 */
    float   lag_factor;     /**< Lag-windowing parameter */
    float   lpc_floor;      /**< Noise floor for LPC analysis */
 
@@ -130,8 +131,8 @@
    int     subframeSize;  /**< Size of sub-frames used for encoding */
    int     lpcSize;       /**< Order of LPC filter */
    int     bufSize;       /**< Signal buffer size in encoder */
-   float   gamma1;        /**< Perceptual filter parameter #1 */
-   float   gamma2;        /**< Perceptual filter parameter #1 */
+   spx_word16_t gamma1;   /**< Perceptual filter parameter #1 */
+   spx_word16_t gamma2;   /**< Perceptual filter parameter #1 */
    float   lag_factor;    /**< Lag-windowing parameter */
    float   lpc_floor;     /**< Noise floor for LPC analysis */
    float   folding_gain;

<p><p>1.163     +13 -33    speex/libspeex/nb_celp.c

Index: nb_celp.c
===================================================================
RCS file: /usr/local/cvsroot/speex/libspeex/nb_celp.c,v
retrieving revision 1.162
retrieving revision 1.163
diff -u -r1.162 -r1.163
--- nb_celp.c	4 Dec 2003 21:29:18 -0000	1.162
+++ nb_celp.c	23 Dec 2003 08:11:13 -0000	1.163
@@ -107,8 +107,8 @@
    st->subframeSize=mode->subframeSize;
    st->lpcSize = mode->lpcSize;
    st->bufSize = mode->bufSize;
-   st->gamma1=GAMMA_SCALING*mode->gamma1;
-   st->gamma2=GAMMA_SCALING*mode->gamma2;
+   st->gamma1=mode->gamma1;
+   st->gamma2=mode->gamma2;
    st->min_pitch=mode->pitchStart;
    st->max_pitch=mode->pitchEnd;
    st->lag_factor=mode->lag_factor;
@@ -961,8 +961,6 @@
    st->subframeSize=mode->subframeSize;
    st->lpcSize = mode->lpcSize;
    st->bufSize = mode->bufSize;
-   st->gamma1=mode->gamma1;
-   st->gamma2=mode->gamma2;
    st->min_pitch=mode->pitchStart;
    st->max_pitch=mode->pitchEnd;
 
@@ -1061,29 +1059,23 @@
       /* Calculate perceptually enhanced LPC filter */
       if (st->lpc_enh_enabled)
       {
-         float r=.9;
-         
-         float k1,k2,k3;
+         spx_word16_t k1,k2,k3;
          if (st->submodes[st->submodeID] != NULL)
          {
             k1=SUBMODE(lpc_enh_k1);
             k2=SUBMODE(lpc_enh_k2);
+            k3=SUBMODE(lpc_enh_k3);
          } else {
-            k1=k2=.7;
+            k1=k2=.7*GAMMA_SCALING;
+            k3=.0;
          }
-         k3=(1-(1-r*k1)/(1-r*k2))/r;
-         if (!st->lpc_enh_enabled)
-         {
-            k1=k2;
-            k3=0;
-         }
-         bw_lpc(GAMMA_SCALING*k1, st->interp_qlpc, awk1, st->lpcSize);
-         bw_lpc(GAMMA_SCALING*k2, st->interp_qlpc, awk2, st->lpcSize);
-         bw_lpc(GAMMA_SCALING*k3, st->interp_qlpc, awk3, st->lpcSize);
+         bw_lpc(k1, st->interp_qlpc, awk1, st->lpcSize);
+         bw_lpc(k2, st->interp_qlpc, awk2, st->lpcSize);
+         bw_lpc(k3, st->interp_qlpc, awk3, st->lpcSize);
       }
         
       /* Make up a plausible excitation */
-      /* THIS CAN BE IMPROVED */
+      /* FIXME: THIS CAN BE IMPROVED */
       /*if (pitch_gain>.95)
         pitch_gain=.95;*/
       {
@@ -1425,21 +1417,9 @@
       /* Compute enhanced synthesis filter */
       if (st->lpc_enh_enabled)
       {
-         float r=.9;
-         
-         float k1,k2,k3;
-         k1=SUBMODE(lpc_enh_k1);
-         k2=SUBMODE(lpc_enh_k2);
-         k3=(1-(1-r*k1)/(1-r*k2))/r;
-         if (!st->lpc_enh_enabled)
-         {
-            k1=k2;
-            k3=0;
-         }
-         bw_lpc(GAMMA_SCALING*k1, st->interp_qlpc, awk1, st->lpcSize);
-         bw_lpc(GAMMA_SCALING*k2, st->interp_qlpc, awk2, st->lpcSize);
-         bw_lpc(GAMMA_SCALING*k3, st->interp_qlpc, awk3, st->lpcSize);
-         
+         bw_lpc(SUBMODE(lpc_enh_k1), st->interp_qlpc, awk1, st->lpcSize);
+         bw_lpc(SUBMODE(lpc_enh_k2), st->interp_qlpc, awk2, st->lpcSize);
+         bw_lpc(SUBMODE(lpc_enh_k3), st->interp_qlpc, awk3, st->lpcSize);
       }
 
       /* Compute analysis filter at w=pi */

<p><p>1.65      +0 -2      speex/libspeex/nb_celp.h

Index: nb_celp.h
===================================================================
RCS file: /usr/local/cvsroot/speex/libspeex/nb_celp.h,v
retrieving revision 1.64
retrieving revision 1.65
diff -u -r1.64 -r1.65
--- nb_celp.h	4 Dec 2003 21:29:18 -0000	1.64
+++ nb_celp.h	23 Dec 2003 08:11:13 -0000	1.65
@@ -141,8 +141,6 @@
 
    spx_word16_t  last_ol_gain;   /**< Open-loop gain for previous frame */
 
-   float  gamma1;         /**< Perceptual filter: A(z/gamma1) */
-   float  gamma2;         /**< Perceptual filter: A(z/gamma2) */
    char  *stack;          /**< Pseudo-stack allocation for temporary memory */
    spx_sig_t *inBuf;          /**< Input buffer (original signal) */
    spx_sig_t *frame;          /**< Start of original frame */

<p><p>1.163     +14 -29    speex/libspeex/sb_celp.c

Index: sb_celp.c
===================================================================
RCS file: /usr/local/cvsroot/speex/libspeex/sb_celp.c,v
retrieving revision 1.162
retrieving revision 1.163
diff -u -r1.162 -r1.163
--- sb_celp.c	5 Dec 2003 14:59:48 -0000	1.162
+++ sb_celp.c	23 Dec 2003 08:11:13 -0000	1.163
@@ -197,8 +197,8 @@
 
    st->lag_factor = mode->lag_factor;
    st->lpc_floor = mode->lpc_floor;
-   st->gamma1=GAMMA_SCALING*mode->gamma1;
-   st->gamma2=GAMMA_SCALING*mode->gamma2;
+   st->gamma1=mode->gamma1;
+   st->gamma2=mode->gamma2;
    st->first=1;
 
    st->x0d=PUSH(st->stack, st->frame_size, spx_sig_t);
@@ -793,26 +793,19 @@
    
    if (st->lpc_enh_enabled)
    {
-      float r=.9;
-      
-      float k1,k2,k3;
+      spx_word16_t k1,k2,k3;
       if (st->submodes[st->submodeID] != NULL)
       {
          k1=SUBMODE(lpc_enh_k1);
          k2=SUBMODE(lpc_enh_k2);
+         k3=SUBMODE(lpc_enh_k3);
       } else {
-         k1=k2=.7;
+         k1=k2=.7*GAMMA_SCALING;
+         k3 = 0;
       }
-      k3=(1-(1-r*k1)/(1-r*k2))/r;
-      k3=k1-k2;
-      if (!st->lpc_enh_enabled)
-      {
-         k1=k2;
-         k3=0;
-      }
-      bw_lpc(GAMMA_SCALING*k1, st->interp_qlpc, awk1, st->lpcSize);
-      bw_lpc(GAMMA_SCALING*k2, st->interp_qlpc, awk2, st->lpcSize);
-      bw_lpc(GAMMA_SCALING*k3, st->interp_qlpc, awk3, st->lpcSize);
+      bw_lpc(k1, st->interp_qlpc, awk1, st->lpcSize);
+      bw_lpc(k2, st->interp_qlpc, awk2, st->lpcSize);
+      bw_lpc(k3, st->interp_qlpc, awk3, st->lpcSize);
       /*fprintf (stderr, "%f %f %f\n", k1, k2, k3);*/
    }
    
@@ -996,21 +989,13 @@
 
       if (st->lpc_enh_enabled)
       {
-         float r=.9;
-         
-         float k1,k2,k3;
+         spx_word16_t k1,k2,k3;
          k1=SUBMODE(lpc_enh_k1);
          k2=SUBMODE(lpc_enh_k2);
-         k3=(1-(1-r*k1)/(1-r*k2))/r;
-         k3=k1-k2;
-         if (!st->lpc_enh_enabled)
-         {
-            k1=k2;
-            k3=0;
-         }
-         bw_lpc(GAMMA_SCALING*k1, st->interp_qlpc, awk1, st->lpcSize);
-         bw_lpc(GAMMA_SCALING*k2, st->interp_qlpc, awk2, st->lpcSize);
-         bw_lpc(GAMMA_SCALING*k3, st->interp_qlpc, awk3, st->lpcSize);
+         k3=SUBMODE(lpc_enh_k3);
+         bw_lpc(k1, st->interp_qlpc, awk1, st->lpcSize);
+         bw_lpc(k2, st->interp_qlpc, awk2, st->lpcSize);
+         bw_lpc(k3, st->interp_qlpc, awk3, st->lpcSize);
          /*fprintf (stderr, "%f %f %f\n", k1, k2, k3);*/
       }
 

<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