[xiph-commits] r11690 - trunk/speex/libspeex

jm at svn.xiph.org jm at svn.xiph.org
Mon Jul 3 06:22:21 PDT 2006


Author: jm
Date: 2006-07-03 06:22:16 -0700 (Mon, 03 Jul 2006)
New Revision: 11690

Modified:
   trunk/speex/libspeex/sb_celp.c
   trunk/speex/libspeex/sb_celp.h
Log:
Max VBR bit-rate implemented for wideband (semi tested), still doesn't quite
work for ultra-wideband.


Modified: trunk/speex/libspeex/sb_celp.c
===================================================================
--- trunk/speex/libspeex/sb_celp.c	2006-07-03 10:15:26 UTC (rev 11689)
+++ trunk/speex/libspeex/sb_celp.c	2006-07-03 13:22:16 UTC (rev 11690)
@@ -309,6 +309,7 @@
    st->vbr_quality = 8;
    st->vbr_enabled = 0;
    st->vbr_max = 0;
+   st->vbr_max_high = 20000;  /* We just need a big value here */
    st->vad_enabled = 0;
    st->abr_enabled = 0;
    st->relative_quality=0;
@@ -512,7 +513,7 @@
             else
                thresh = (st->vbr_quality-v1)   * mode->vbr_thresh[modeid][v1+1] + 
                         (1+v1-st->vbr_quality) * mode->vbr_thresh[modeid][v1];
-            if (st->relative_quality >= thresh)
+            if (st->relative_quality >= thresh && st->sampling_rate*st->submodes[modeid]->bits_per_frame/st->full_frame_size <= st->vbr_max_high)
                break;
             modeid--;
          }
@@ -1419,25 +1420,28 @@
       break;
    case SPEEX_SET_VBR_MAX_BITRATE:
       {
-         int high_mode;
-         spx_int32_t high_rate;
          st->vbr_max = (*(spx_int32_t*)ptr);
          if (SPEEX_SET_VBR_MAX_BITRATE<1)
+         {
             speex_encoder_ctl(st->st_low, SPEEX_SET_VBR_MAX_BITRATE, &st->vbr_max);
-         else {
-            if (st->vbr_max > 42200)
+            st->vbr_max_high = 17600;
+         } else {
+            spx_int32_t low_rate;
+            /* FIXME: Need to adapt that to ultra-wideband */
+            if (st->vbr_max >= 42200)
             {
-               high_mode = 4;
-            } else if (st->vbr_max > 27800)
+               st->vbr_max_high = 17600;
+            } else if (st->vbr_max >= 27800)
             {
-               high_mode = 3;
+               st->vbr_max_high = 9600;
             } else if (st->vbr_max > 20600)
             {
-               high_mode = 2;
-            } else high_mode = 1;
-            high_rate = st->sampling_rate*st->submodes[high_mode]->bits_per_frame/st->full_frame_size;
-            high_rate = st->vbr_max - high_rate;
-            speex_encoder_ctl(st->st_low, SPEEX_SET_VBR_MAX_BITRATE, &high_rate);
+               st->vbr_max_high = 5600;
+            } else {
+               st->vbr_max_high = 1800;
+            }
+            low_rate = st->vbr_max - st->vbr_max_high;
+            speex_encoder_ctl(st->st_low, SPEEX_SET_VBR_MAX_BITRATE, &low_rate);
          }
       }
       break;

Modified: trunk/speex/libspeex/sb_celp.h
===================================================================
--- trunk/speex/libspeex/sb_celp.h	2006-07-03 10:15:26 UTC (rev 11689)
+++ trunk/speex/libspeex/sb_celp.h	2006-07-03 13:22:16 UTC (rev 11690)
@@ -92,8 +92,9 @@
 
    float  vbr_quality;            /**< Quality setting for VBR encoding */
    int    vbr_enabled;            /**< 1 for enabling VBR, 0 otherwise */
-   spx_int32_t vbr_max;           /**< Max bit-rate allowed in VBR mode */
-   spx_int32_t abr_enabled;            /**< ABR setting (in bps), 0 if off */
+   spx_int32_t vbr_max;           /**< Max bit-rate allowed in VBR mode (total) */
+   spx_int32_t vbr_max_high;      /**< Max bit-rate allowed in VBR mode for the high-band */
+   spx_int32_t abr_enabled;       /**< ABR setting (in bps), 0 if off */
    float  abr_drift;
    float  abr_drift2;
    float  abr_count;



More information about the commits mailing list