Finished cleaning up the sub-band mode
authorjmvalin <jmvalin@0101bb08-14d6-0310-b084-bc0e0c8e3800>
Mon, 6 May 2002 21:12:59 +0000 (21:12 +0000)
committerjmvalin <jmvalin@0101bb08-14d6-0310-b084-bc0e0c8e3800>
Mon, 6 May 2002 21:12:59 +0000 (21:12 +0000)
git-svn-id: http://svn.xiph.org/trunk/speex@3283 0101bb08-14d6-0310-b084-bc0e0c8e3800

libspeex/cb_search.c
libspeex/cb_search.h
libspeex/modes.c
libspeex/sb_celp.c
libspeex/sb_celp.h

index b54c984..725eb19 100644 (file)
@@ -765,7 +765,6 @@ void split_cb_nogain_unquant(
 float *exc,
 void *par,                      /* non-overlapping codebook */
 int   nsf,                      /* number of samples in subframe */
-float gain,
 FrameBits *bits,
 float *stack
 )
@@ -791,7 +790,7 @@ float *stack
    /* Compute decoded excitation */
    for (i=0;i<nb_subvect;i++)
       for (j=0;j<subvect_size;j++)
-         exc[subvect_size*i+j]+=gain*shape_cb[ind[i]*subvect_size+j];
+         exc[subvect_size*i+j]+=shape_cb[ind[i]*subvect_size+j];
 
    POP(stack);
 }
index 87efc90..e7f752b 100644 (file)
@@ -96,7 +96,6 @@ void split_cb_nogain_unquant(
 float *exc,
 void *par,                      /* non-overlapping codebook */
 int   nsf,                      /* number of samples in subframe */
-float gain,
 FrameBits *bits,
 float *stack
 );
index 0fae31a..9fb9e94 100644 (file)
@@ -34,40 +34,50 @@ extern float exc_table[];
 extern float exc_wb_table[];
 extern float exc_gains_wb_table[];
 extern float exc_sb_table[];
-ltp_params ltp_params_nb = {
+extern float hexc_table[];
+
+static ltp_params ltp_params_nb = {
    gain_cdbk_nb,
    7,
    7
 };
 
-ltp_params ltp_params_wb = {
+static ltp_params ltp_params_wb = {
    gain_cdbk_nb,
    7,
    8
 };
 
-split_cb_params split_cb_nb = {
+static split_cb_params split_cb_nb = {
    8,               /*subvect_size*/
    5,               /*nb_subvect*/
    exc_table,       /*shape_cb*/
    7,               /*shape_bits*/
 };
 
-split_cb_params split_cb_sb = {
+static split_cb_params split_cb_sb = {
    5,               /*subvect_size*/
    8,              /*nb_subvect*/
    exc_sb_table,    /*shape_cb*/
    7,               /*shape_bits*/
 };
 
-split_cb_params split_cb_wb = {
+static split_cb_params split_cb_wb = {
    8,               /*subvect_size*/
    10,              /*nb_subvect*/
    exc_wb_table,    /*shape_cb*/
    7,               /*shape_bits*/
 };
 
-mpulse_params mpulse_nb = {
+static split_cb_params split_cb_high = {
+   8,               /*subvect_size*/
+   5,               /*nb_subvect*/
+   hexc_table,       /*shape_cb*/
+   8,               /*shape_bits*/
+};
+
+
+static mpulse_params mpulse_nb = {
    15,     /*nb_pulse*/
    5,      /*nb_tracks*/
    4,    /*gain_coef*/
@@ -75,7 +85,7 @@ mpulse_params mpulse_nb = {
 };
 
 
-mpulse_params mpulse_sb = {
+static mpulse_params mpulse_sb = {
    15,     /*nb_pulse*/
    5,      /*nb_tracks*/
    3.8,    /*gain_coef*/
@@ -83,7 +93,7 @@ mpulse_params mpulse_sb = {
 };
 
 
-mpulse_params mpulse_wb = {
+static mpulse_params mpulse_wb = {
    24,     /*nb_pulse*/
    4,      /*nb_tracks*/
    2.2,    /*gain_coef*/
@@ -91,7 +101,7 @@ mpulse_params mpulse_wb = {
 };
 
 
-SpeexNBMode mp_nb_mode = {
+static SpeexNBMode mp_nb_mode = {
    160,    /*frameSize*/
    40,     /*subframeSize*/
    320,    /*windowSize*/
@@ -117,7 +127,7 @@ SpeexNBMode mp_nb_mode = {
    &mpulse_nb
 };
 
-SpeexNBMode low_sb_mode = {
+static SpeexNBMode low_sb_mode = {
    160,    /*frameSize*/
    40,     /*subframeSize*/
    320,    /*windowSize*/
@@ -160,7 +170,7 @@ SpeexMode low_wb_mode = {
    160
 };
 
-SpeexSBMode sb_wb_mode = {
+static SpeexSBMode sb_wb_mode = {
    &low_wb_mode,
    160,    /*frameSize*/
    40,     /*subframeSize*/
@@ -170,19 +180,18 @@ SpeexSBMode sb_wb_mode = {
    .9,    /*gamma1*/
    0.6,    /*gamma2*/
    .002,   /*lag_factor*/
-   1.00005, /*lpc_floor*/
+   1.0001, /*lpc_floor*/
    0.0,    /*preemph*/
    /*LSP quantization*/
-   lsp_quant_nb,
-   lsp_unquant_nb,
+   lsp_quant_high,
+   lsp_unquant_high,
    /*Innovation quantization*/
-   split_cb_search2,
-   split_cb_unquant,
-   &split_cb_sb
+   split_cb_search_nogain,
+   split_cb_nogain_unquant,
+   &split_cb_high
 };
 
 
-
 SpeexMode nb_mode = {
    &mp_nb_mode,
    &nb_encoder_init,
index 0f672a3..445f9a1 100644 (file)
@@ -203,10 +203,10 @@ void *sb_encoder_init(SpeexMode *m)
    st->lpcSize=mode->lpcSize;
    st->bufSize=mode->bufSize;
 
-   st->lag_factor = .002;
-   st->lpc_floor = 1.0001;
-   st->gamma1=.9;
-   st->gamma2=.6;
+   st->lag_factor = mode->lag_factor;
+   st->lpc_floor = mode->lpc_floor;
+   st->gamma1=mode->gamma1;
+   st->gamma2=mode->gamma2;
    st->first=1;
    st->stack = calloc(10000, sizeof(float));
 
@@ -256,6 +256,10 @@ void *sb_encoder_init(SpeexMode *m)
    st->mem_sp = calloc(st->lpcSize, sizeof(float));
    st->mem_sp2 = calloc(st->lpcSize, sizeof(float));
    st->mem_sw = calloc(st->lpcSize, sizeof(float));
+
+   st->lsp_quant = mode->lsp_quant;
+   st->innovation_quant = mode->innovation_quant;
+   st->innovation_params = mode->innovation_params;
    return st;
 }
 
@@ -306,13 +310,6 @@ void sb_encoder_destroy(void *state)
    free(st);
 }
 
-extern float hexc_table[];
-split_cb_params split_cb_high = {
-   8,               /*subvect_size*/
-   5,               /*nb_subvect*/
-   hexc_table,       /*shape_cb*/
-   8,               /*shape_bits*/
-};
 
 void sb_encode(void *state, float *in, FrameBits *bits)
 {
@@ -374,7 +371,7 @@ void sb_encode(void *state, float *in, FrameBits *bits)
       st->lsp[i] = acos(st->lsp[i]);
 
    /* LSP quantization */
-   lsp_quant_high(st->lsp, st->qlsp, st->lpcSize, bits);
+   st->lsp_quant(st->lsp, st->qlsp, st->lpcSize, bits);
    
    /*printf ("high_lsp:");
    for (i=0;i<st->lpcSize;i++)
@@ -444,6 +441,7 @@ void sb_encode(void *state, float *in, FrameBits *bits)
 
       fold = filter_ratio<5;
       printf ("filter_ratio %f\n", filter_ratio);
+      fold=0;
 
       if (fold) {/* 1 for spectral folding excitation, 0 for stochastic */
          float el=0,eh=0,g;
@@ -537,8 +535,8 @@ void sb_encode(void *state, float *in, FrameBits *bits)
             innov[i]=0;
 
          print_vec(target, st->subframeSize, "\ntarget");
-         split_cb_search_nogain(target, st->interp_qlpc, st->bw_lpc1, st->bw_lpc2, 
-                                &split_cb_high, st->lpcSize, st->subframeSize, 
+         st->innovation_quant(target, st->interp_qlpc, st->bw_lpc1, st->bw_lpc2, 
+                                st->innovation_params, st->lpcSize, st->subframeSize, 
                                 innov, bits, st->stack);
          print_vec(target, st->subframeSize, "after");
 
@@ -643,6 +641,10 @@ void *sb_decoder_init(SpeexMode *m)
    st->mem_pf_exc1 = calloc(st->pf_order, sizeof(float));
    st->mem_pf_exc2 = calloc(st->pf_order, sizeof(float));
    st->mem_pf_sp = calloc(st->pf_order, sizeof(float));
+
+   st->lsp_unquant = mode->lsp_unquant;
+   st->innovation_unquant = mode->innovation_unquant;
+   st->innovation_params = mode->innovation_params;
    return st;
 }
 
@@ -697,7 +699,7 @@ void sb_decode(void *state, FrameBits *bits, float *out)
    for (i=0;i<st->frame_size;i++)
       st->exc[i]=0;
 
-   lsp_unquant_high(st->qlsp, st->lpcSize, bits);
+   st->lsp_unquant(st->qlsp, st->lpcSize, bits);
    
    if (st->first)
    {
@@ -761,8 +763,10 @@ void sb_decode(void *state, FrameBits *bits, float *out)
          for (i=0;i<st->subframeSize;i++)
             exc[i]=g*((DecState*)st->st_low)->exc[offset+i];
       } else {
-         split_cb_nogain_unquant(exc, &split_cb_high, st->subframeSize, gain, 
-                                 bits, st->stack);
+         st->innovation_unquant(exc, st->innovation_params, st->subframeSize, 
+                                bits, st->stack);
+         for (i=0;i<st->subframeSize;i++)
+            exc[i]*=gain;
       }
       syn_filt_mem(exc, st->interp_qlpc, sp, st->subframeSize, st->lpcSize, st->mem_sp);
 
index 88373e3..f08f708 100644 (file)
@@ -72,6 +72,10 @@ typedef struct SBEncState {
    float *mem_sp;              /* Synthesis signal memory */
    float *mem_sp2;
    float *mem_sw;              /* Perceptual signal memory */
+
+   lsp_quant_func    lsp_quant;
+   innovation_quant_func innovation_quant;
+   void             *innovation_params;
 } SBEncState;
 
 
@@ -109,6 +113,10 @@ typedef struct SBDecState {
    float *mem_pf_exc1;
    float *mem_pf_exc2;
    float *mem_pf_sp;
+
+   lsp_unquant_func  lsp_unquant;
+   innovation_unquant_func innovation_unquant;
+   void             *innovation_params;
 } SBDecState;