wideband VBR seems to (almost) work. Need to adapt it to work on ultra-
authorjm <jm@0101bb08-14d6-0310-b084-bc0e0c8e3800>
Wed, 27 Nov 2002 05:22:47 +0000 (05:22 +0000)
committerjm <jm@0101bb08-14d6-0310-b084-bc0e0c8e3800>
Wed, 27 Nov 2002 05:22:47 +0000 (05:22 +0000)
wideband too.

git-svn-id: http://svn.xiph.org/trunk/speex@4122 0101bb08-14d6-0310-b084-bc0e0c8e3800

libspeex/nb_celp.c
libspeex/sb_celp.c

index e6a289b..e3ff6a2 100644 (file)
@@ -384,8 +384,12 @@ void nb_encode(void *state, float *in, SpeexBits *bits)
                break;
             mode--;
          }
                break;
             mode--;
          }
-         fprintf (stderr, "%f %d\n", st->relative_quality, mode);
+         /*fprintf(stderr, "");
+         fprintf (stderr, "encode %f %d\n", st->relative_quality, mode);
+         fprintf(stderr, "encode: %d %d\n",st->submodeID, mode);*/
+
          speex_encoder_ctl(state, SPEEX_SET_MODE, &mode);
          speex_encoder_ctl(state, SPEEX_SET_MODE, &mode);
+         /*fprintf(stderr, "encode: %d %d\n",st->submodeID, mode);*/
       } else {
          st->relative_quality = -1;
       }
       } else {
          st->relative_quality = -1;
       }
index b4662b6..62f93dd 100644 (file)
@@ -346,7 +346,7 @@ void sb_encode(void *state, float *in, SpeexBits *bits)
       st->lsp[i] = acos(st->lsp[i]);
 
    /* VBR code */
       st->lsp[i] = acos(st->lsp[i]);
 
    /* VBR code */
-   if (0){
+   if (st->vbr_enabled){
       float e_low=0, e_high=0;
       float ratio;
       float low_qual;
       float e_low=0, e_high=0;
       float ratio;
       float low_qual;
@@ -389,8 +389,9 @@ void sb_encode(void *state, float *in, SpeexBits *bits)
                break;
             mode--;
          }
                break;
             mode--;
          }
-         fprintf (stderr, "%f %d\n", low_qual, mode);
+         /*fprintf (stderr, "%f %d\n", low_qual, mode);*/
          speex_encoder_ctl(state, SPEEX_SET_HIGH_MODE, &mode);
          speex_encoder_ctl(state, SPEEX_SET_HIGH_MODE, &mode);
+         /*fprintf (stderr, "%d %d\n", st->submodeID, mode);*/
       }
       /*fprintf (stderr, "%f %f\n", ratio, low_qual);*/
    }
       }
       /*fprintf (stderr, "%f %f\n", ratio, low_qual);*/
    }
@@ -763,7 +764,7 @@ static void sb_decode_lost(SBDecState *st, float *out, void *stack)
    st->first=1;
    
    /* Final signal synthesis from excitation */
    st->first=1;
    
    /* Final signal synthesis from excitation */
-   iir_mem2(st->exc, st->interp_qlpc, st->high, st->subframeSize, st->lpcSize, st->mem_sp);
+   iir_mem2(st->exc, st->interp_qlpc, st->high, st->frame_size, st->lpcSize, st->mem_sp);
    
    /* Reconstruct the original */
    fir_mem_up(st->x0d, h0, st->y0, st->full_frame_size, QMF_ORDER, st->g0_mem, stack);
    
    /* Reconstruct the original */
    fir_mem_up(st->x0d, h0, st->y0, st->full_frame_size, QMF_ORDER, st->g0_mem, stack);
@@ -827,7 +828,7 @@ int sb_decode(void *state, SpeexBits *bits, float *out)
       st->first=1;
 
       /* Final signal synthesis from excitation */
       st->first=1;
 
       /* Final signal synthesis from excitation */
-      iir_mem2(st->exc, st->interp_qlpc, st->high, st->subframeSize, st->lpcSize, st->mem_sp);
+      iir_mem2(st->exc, st->interp_qlpc, st->high, st->frame_size, st->lpcSize, st->mem_sp);
 
       fir_mem_up(st->x0d, h0, st->y0, st->full_frame_size, QMF_ORDER, st->g0_mem, stack);
       fir_mem_up(st->high, h1, st->y1, st->full_frame_size, QMF_ORDER, st->g1_mem, stack);
 
       fir_mem_up(st->x0d, h0, st->y0, st->full_frame_size, QMF_ORDER, st->g0_mem, stack);
       fir_mem_up(st->high, h1, st->y1, st->full_frame_size, QMF_ORDER, st->g1_mem, stack);
@@ -982,8 +983,12 @@ void sb_encoder_ctl(void *state, int request, void *ptr)
       speex_encoder_ctl(st, SPEEX_SET_QUALITY, ptr);
       break;
    case SPEEX_SET_VBR:
       speex_encoder_ctl(st, SPEEX_SET_QUALITY, ptr);
       break;
    case SPEEX_SET_VBR:
+      st->vbr_enabled = (*(int*)ptr);
       speex_encoder_ctl(st->st_low, SPEEX_SET_VBR, ptr);
       break;
       speex_encoder_ctl(st->st_low, SPEEX_SET_VBR, ptr);
       break;
+   case SPEEX_GET_VBR:
+      (*(int*)ptr) = st->vbr_enabled;
+      break;
    case SPEEX_SET_VBR_QUALITY:
       {
          int q;
    case SPEEX_SET_VBR_QUALITY:
       {
          int q;
@@ -1036,10 +1041,12 @@ void sb_encoder_ctl(void *state, int request, void *ptr)
       break;
    case SPEEX_GET_BITRATE:
       speex_encoder_ctl(st->st_low, request, ptr);
       break;
    case SPEEX_GET_BITRATE:
       speex_encoder_ctl(st->st_low, request, ptr);
+      /*fprintf (stderr, "before: %d\n", (*(int*)ptr));*/
       if (st->submodes[st->submodeID])
          (*(int*)ptr) += st->sampling_rate*SUBMODE(bits_per_frame)/st->full_frame_size;
       else
          (*(int*)ptr) += st->sampling_rate*(SB_SUBMODE_BITS+1)/st->full_frame_size;
       if (st->submodes[st->submodeID])
          (*(int*)ptr) += st->sampling_rate*SUBMODE(bits_per_frame)/st->full_frame_size;
       else
          (*(int*)ptr) += st->sampling_rate*(SB_SUBMODE_BITS+1)/st->full_frame_size;
+      /*fprintf (stderr, "after: %d\n", (*(int*)ptr));*/
       break;
    case SPEEX_SET_SAMPLING_RATE:
       {
       break;
    case SPEEX_SET_SAMPLING_RATE:
       {