Fixed a pitch prediction bug when pitch is forced (end=start)
authorjmvalin <jmvalin@0101bb08-14d6-0310-b084-bc0e0c8e3800>
Fri, 19 Jul 2002 18:15:14 +0000 (18:15 +0000)
committerjmvalin <jmvalin@0101bb08-14d6-0310-b084-bc0e0c8e3800>
Fri, 19 Jul 2002 18:15:14 +0000 (18:15 +0000)
git-svn-id: http://svn.xiph.org/trunk/speex@3694 0101bb08-14d6-0310-b084-bc0e0c8e3800

libspeex/ltp.c
libspeex/modes.c
libspeex/nb_celp.c

index 41bf1fd..83a4755 100644 (file)
@@ -249,7 +249,7 @@ int  *cdbk_index
 #ifdef DEBUG
    printf ("prediction gain = %f\n",err1/(err2+1));
 #endif
-   
+
    POP(stack);
    POP(stack);
    return err2;
@@ -289,7 +289,8 @@ float *exc2
    
    best_exc=PUSH(stack,nsf);
    
-   
+   if (N>end-start+1)
+      N=end-start+1;
    open_loop_nbest_pitch(sw, start, end, nsf, nbest, gains, N, stack);
    for (i=0;i<N;i++)
    {
@@ -344,6 +345,7 @@ int lost)
    gain_cdbk=params->gain_cdbk;
 
    pitch = speex_bits_unpack_unsigned(bits, params->pitch_bits);
+   printf ("decode ltp: %d %d %d\n", start, end, pitch);
    pitch += start;
    gain_index = speex_bits_unpack_unsigned(bits, params->gain_bits);
    /*printf ("decode pitch: %d %d\n", pitch, gain_index);*/
index 203dade..d5121cc 100644 (file)
@@ -38,6 +38,7 @@ extern float hexc_table[];
 extern float exc_5_256_table[];
 extern float exc_5_64_table[];
 extern float exc_8_128_table[];
+extern float exc_8_32_table[];
 extern float exc_10_32_table[];
 extern float exc_10_16_table[];
 extern float hexc_10_32_table[];
@@ -108,7 +109,7 @@ static split_cb_params split_cb_nb_vlbr = {
 
 /* Split-VQ innovation parameters for low bit-rate narrowband */
 static split_cb_params split_cb_nb_lbr = {
-   10,               /*subvect_size*/
+   10,              /*subvect_size*/
    4,               /*nb_subvect*/
    exc_10_32_table, /*shape_cb*/
    5,               /*shape_bits*/
index 1f2dd2b..bf02d95 100644 (file)
@@ -278,6 +278,8 @@ void nb_encode(void *state, float *in, SpeexBits *bits)
    if (st->vbr)
    {
       delta_qual = vbr_analysis(st->vbr, in, st->frameSize, ol_pitch, ol_pitch_coef);
+      if (delta_qual<0)
+         delta_qual*=.1*(4+st->vbr_quality);
       if (st->vbr_enabled) 
       {
          int qual = (int)floor(st->vbr_quality+delta_qual+.5);
@@ -451,12 +453,12 @@ void nb_encode(void *state, float *in, SpeexBits *bits)
             int pit_min, pit_max;
             int margin;
             margin = SUBMODE(lbr_pitch);
-            if (ol_pitch < st->min_pitch+margin-1)
-               ol_pitch=st->min_pitch+margin-1;
-            if (ol_pitch > st->max_pitch-margin)
-               ol_pitch=st->max_pitch-margin;
             if (margin)
             {
+               if (ol_pitch < st->min_pitch+margin-1)
+                  ol_pitch=st->min_pitch+margin-1;
+               if (ol_pitch > st->max_pitch-margin)
+                  ol_pitch=st->max_pitch-margin;
                pit_min = ol_pitch-margin+1;
                pit_max = ol_pitch+margin;
             } else {
@@ -834,12 +836,12 @@ void nb_decode(void *state, SpeexBits *bits, float *out, int lost)
             int pit_min, pit_max;
             int margin;
             margin = SUBMODE(lbr_pitch);
-            if (ol_pitch < st->min_pitch+margin-1)
-               ol_pitch=st->min_pitch+margin-1;
-            if (ol_pitch > st->max_pitch-margin)
-               ol_pitch=st->max_pitch-margin;
             if (margin)
             {
+               if (ol_pitch < st->min_pitch+margin-1)
+                  ol_pitch=st->min_pitch+margin-1;
+               if (ol_pitch > st->max_pitch-margin)
+                  ol_pitch=st->max_pitch-margin;
                pit_min = ol_pitch-margin+1;
                pit_max = ol_pitch+margin;
             } else {