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

Jean-Marc Valin jm at xiph.org
Wed Nov 13 16:51:35 PST 2002



jm          02/11/13 19:51:35

  Modified:    libspeex nb_celp.c vbr.c vbr.h
  Log:
  Trying a new VBR implementation... still experimental

Revision  Changes    Path
1.81      +17 -1     speex/libspeex/nb_celp.c

Index: nb_celp.c
===================================================================
RCS file: /usr/local/cvsroot/speex/libspeex/nb_celp.c,v
retrieving revision 1.80
retrieving revision 1.81
diff -u -r1.80 -r1.81
--- nb_celp.c	11 Nov 2002 01:08:29 -0000	1.80
+++ nb_celp.c	14 Nov 2002 00:51:35 -0000	1.81
@@ -367,9 +367,11 @@
    {
       delta_qual = vbr_analysis(st->vbr, in, st->frameSize, ol_pitch, ol_pitch_coef);
       /*if (delta_qual<0)*/
-         delta_qual*=.1*(3+st->vbr_quality);
+      /*  delta_qual*=.1*(3+st->vbr_quality);*/
       if (st->vbr_enabled) 
       {
+         if (0) 
+         {
          int qual = (int)floor(st->vbr_quality+delta_qual+.5);
          if (qual<1 && delta_qual>-3.5)
             qual=1;
@@ -380,6 +382,20 @@
          if (qual==10 && st->vbr_quality<10)
             qual=9;
          speex_encoder_ctl(state, SPEEX_SET_QUALITY, &qual);
+         } else {
+            int vqual, mode;
+            float level = delta_qual+7;
+            /*fprintf(stderr, "%f\n", level);*/
+            vqual = (int)floor(.5+st->vbr_quality);
+            mode = 7;
+            while (mode)
+            {
+               if (level > vbr_nb_thresh[mode][vqual])
+                  break;
+               mode--;
+            }
+            speex_encoder_ctl(state, SPEEX_SET_MODE, &mode);
+         }
       }
    }
    /*printf ("VBR quality = %f\n", vbr_qual);*/

<p><p>1.9       +14 -1     speex/libspeex/vbr.c

Index: vbr.c
===================================================================
RCS file: /usr/local/cvsroot/speex/libspeex/vbr.c,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -r1.8 -r1.9
--- vbr.c	11 Oct 2002 03:39:34 -0000	1.8
+++ vbr.c	14 Nov 2002 00:51:35 -0000	1.9
@@ -44,6 +44,19 @@
 #define MIN_ENERGY 1000
 #define NOISE_POW .3
 
+
+float vbr_nb_thresh[8][11]={
+   {-1.0, -1.0, -1.0, -1.0, -1.0, -1.0, -1.0, -1.0, -1.0, -1.0, -1.0}, /* silence */
+   { 4.5,  3.5,  2.5,  1.5,  0.5,  0.0,  0.0,  0.0,  0.0,  0.0, -1.0}, /*  2 kbps */
+   { 9.5,  7.5,  6.5,  5.5,  5.0,  4.0,  4.5,  3.0,  2.0,  1.0,  0.0}, /*  6 kbps */
+   {11.0,  9.5,  8.5,  7.5,  7.0,  6.5,  6.0,  5.0,  4.0,  3.0,  1.0}, /*  8 kbps */
+   {11.0, 11.0, 11.0,  9.5,  8.5,  7.5,  6.5,  6.0,  5.0,  4.0,  2.0}, /* 11 kbps */
+   {11.0, 11.0, 11.0, 11.0,  9.5,  9.0,  8.0,  7.5,  6.5,  5.0,  3.0}, /* 15 kbps */
+   {11.0, 11.0, 11.0, 11.0, 11.0, 11.0,  9.5,  8.5,  8.0,  6.5,  4.0}, /* 18 kbps */
+   {11.0, 11.0, 11.0, 11.0, 11.0, 11.0, 11.0, 11.0,  9.5,  7.5,  5.5}  /* 24 kbps */ 
+};
+
+
 void vbr_init(VBRState *vbr)
 {
    int i;
@@ -172,7 +185,7 @@
          qual -= .6;
    }
    vbr->soft_pitch = .6*vbr->soft_pitch + .4*pitch_coef;
-   qual += (pitch_coef-.4) + (vbr->soft_pitch-.4);
+   qual += 1.0*((pitch_coef-.4) + (vbr->soft_pitch-.4));
 
    if (qual < vbr->last_quality)
       qual = .5*qual + .5*vbr->last_quality;

<p><p>1.7       +2 -0      speex/libspeex/vbr.h

Index: vbr.h
===================================================================
RCS file: /usr/local/cvsroot/speex/libspeex/vbr.h,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -r1.6 -r1.7
--- vbr.h	11 Oct 2002 03:39:34 -0000	1.6
+++ vbr.h	14 Nov 2002 00:51:35 -0000	1.7
@@ -38,6 +38,8 @@
 
 #define VBR_MEMORY_SIZE 5
 
+extern float vbr_nb_thresh[8][11];
+
 typedef struct VBRState {
    float energy_alpha;
    float average_energy;

<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