More ABR work...
authorjm <jm@0101bb08-14d6-0310-b084-bc0e0c8e3800>
Sat, 14 Dec 2002 06:29:08 +0000 (06:29 +0000)
committerjm <jm@0101bb08-14d6-0310-b084-bc0e0c8e3800>
Sat, 14 Dec 2002 06:29:08 +0000 (06:29 +0000)
git-svn-id: http://svn.xiph.org/trunk/speex@4151 0101bb08-14d6-0310-b084-bc0e0c8e3800

libspeex/nb_celp.c
libspeex/speex.h

index dbb545f..83d1f77 100644 (file)
@@ -1452,6 +1452,29 @@ void nb_encoder_ctl(void *state, int request, void *ptr)
    case SPEEX_GET_VAD:
       (*(int*)ptr) = st->vad_enabled;
       break;
+   case SPEEX_SET_ABR:
+      st->abr_enabled = (*(int*)ptr);
+      {
+         int i=10, rate, target, vbr_qual;
+         target = (*(int*)ptr);
+         while (i>=0)
+         {
+            speex_encoder_ctl(st, SPEEX_SET_QUALITY, &i);
+            speex_encoder_ctl(st, SPEEX_GET_BITRATE, &rate);
+            if (rate <= target)
+               break;
+            i--;
+         }
+         vbr_qual=i;
+         if (vbr_qual<0)
+            vbr_qual=0;
+         speex_encoder_ctl(st, SPEEX_SET_VBR_QUALITY, &vbr_qual);
+      }
+      
+      break;
+   case SPEEX_GET_ABR:
+      (*(int*)ptr) = st->abr_enabled;
+      break;
    case SPEEX_SET_VBR_QUALITY:
       st->vbr_quality = (*(float*)ptr);
       break;
index 032ab39..5a48294 100644 (file)
@@ -109,6 +109,9 @@ extern "C" {
 #define SPEEX_SET_VAD 30
 #define SPEEX_GET_VAD 31
 
+#define SPEEX_SET_ABR 32
+#define SPEEX_GET_ABR 33
+
 
    /* Used internally, not to be used in applications */
 #define SPEEX_GET_PI_GAIN 100