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

Jean-Marc Valin jm at xiph.org
Fri Dec 13 14:59:27 PST 2002



jm          02/12/13 17:59:27

  Modified:    libspeex nb_celp.c nb_celp.h sb_celp.c
  Log:
  Starting (still incomplete) average bit-rate (ABR) implementation

Revision  Changes    Path
1.93      +28 -6     speex/libspeex/nb_celp.c

Index: nb_celp.c
===================================================================
RCS file: /usr/local/cvsroot/speex/libspeex/nb_celp.c,v
retrieving revision 1.92
retrieving revision 1.93
diff -u -r1.92 -r1.93
--- nb_celp.c	13 Dec 2002 01:47:24 -0000	1.92
+++ nb_celp.c	13 Dec 2002 22:59:27 -0000	1.93
@@ -167,6 +167,8 @@
    st->vbr_quality = 8;
    st->vbr_enabled = 0;
    st->vad_enabled = 0;
+   st->abr_enabled = 0;
+   st->abr_drift = 0;
 
    st->complexity=2;
    st->sampling_rate=8000;
@@ -370,6 +372,20 @@
    /*VBR stuff*/
    if (st->vbr && (st->vbr_enabled||st->vad_enabled))
    {
+      
+      if (st->abr_enabled)
+      {
+         if (st->abr_drift>0)
+            st->vbr_quality -= .02;
+         else
+            st->vbr_quality += .02;
+         if (st->vbr_quality>10)
+            st->vbr_quality=10;
+         if (st->vbr_quality<0)
+            st->vbr_quality=0;
+         /*printf ("%f %f\n", st->abr_drift, st->vbr_quality);*/
+      }
+
       st->relative_quality = vbr_analysis(st->vbr, in, st->frameSize, ol_pitch, ol_pitch_coef);
       /*if (delta_qual<0)*/
       /*  delta_qual*=.1*(3+st->vbr_quality);*/
@@ -395,6 +411,13 @@
          fprintf(stderr, "encode: %d %d\n",st->submodeID, mode);*/
 
          speex_encoder_ctl(state, SPEEX_SET_MODE, &mode);
+
+         if (st->abr_enabled)
+         {
+            int bitrate;
+            speex_encoder_ctl(state, SPEEX_GET_BITRATE, &bitrate);
+            st->abr_drift+=(bitrate-st->abr_enabled);
+         }
          /*fprintf(stderr, "encode: %d %d\n",st->submodeID, mode);*/
       } else {
          /*VAD only case*/
@@ -650,7 +673,9 @@
          for (i=0;i<st->subframeSize;i++)
             ener+=st->buf2[i]*st->buf2[i];
          ener=sqrt(.1+ener/st->subframeSize);
-
+         /*for (i=0;i<st->subframeSize;i++)
+            printf ("%f\n", st->buf2[i]/ener);
+         */
          
          ener /= ol_gain;
 
@@ -945,7 +970,7 @@
          innov_gain=sqrt(innov_gain/160);
       for (i=0;i<st->subframeSize;i++)
       {
-#if 0
+#if 1
          exc[i] = pitch_gain * exc[i - st->last_pitch] + fact*sqrt(1-pitch_gain)*st->innov[i+offset];
          /*Just so it give the same lost packets as with if 0*/
          rand();
@@ -1297,9 +1322,6 @@
          /*Vocoder mode*/
          if (st->submodeID==1) 
          {
-            /*FIXME: Remove static var*/
-            /*static float mean=0, m1=0,m2=0;
-              static int offset=0;*/
             float g=ol_pitch_coef;
 
             
@@ -1458,7 +1480,7 @@
       {
          int i=10, rate, target;
          target = (*(int*)ptr);
-         while (i>=1)
+         while (i>=0)
          {
             speex_encoder_ctl(st, SPEEX_SET_QUALITY, &i);
             speex_encoder_ctl(st, SPEEX_GET_BITRATE, &rate);

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

Index: nb_celp.h
===================================================================
RCS file: /usr/local/cvsroot/speex/libspeex/nb_celp.h,v
retrieving revision 1.38
retrieving revision 1.39
diff -u -r1.38 -r1.39
--- nb_celp.h	12 Dec 2002 07:51:35 -0000	1.38
+++ nb_celp.h	13 Dec 2002 22:59:27 -0000	1.39
@@ -103,6 +103,8 @@
    float  relative_quality; /**< Relative quality that will be needed by VBR */
    int    vbr_enabled;    /**< 1 for enabling VBR, 0 otherwise */
    int    vad_enabled;    /**< 1 for enabling VAD, 0 otherwise */
+   int    abr_enabled;    /**< 1 for enabling ABR, 0 otherwise */
+   float  abr_drift;
    int    complexity;     /**< Complexity setting (0-10 from least complex to most complex) */
    int    sampling_rate;
 

<p><p>1.102     +1 -1      speex/libspeex/sb_celp.c

Index: sb_celp.c
===================================================================
RCS file: /usr/local/cvsroot/speex/libspeex/sb_celp.c,v
retrieving revision 1.101
retrieving revision 1.102
diff -u -r1.101 -r1.102
--- sb_celp.c	13 Dec 2002 01:47:24 -0000	1.101
+++ sb_celp.c	13 Dec 2002 22:59:27 -0000	1.102
@@ -1133,7 +1133,7 @@
       {
          int i=10, rate, target;
          target = (*(int*)ptr);
-         while (i>=1)
+         while (i>=0)
          {
             speex_encoder_ctl(st, SPEEX_SET_QUALITY, &i);
             speex_encoder_ctl(st, SPEEX_GET_BITRATE, &rate);

<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