diff options
author | jmvalin <jmvalin@0101bb08-14d6-0310-b084-bc0e0c8e3800> | 2002-07-19 22:15:14 +0400 |
---|---|---|
committer | jmvalin <jmvalin@0101bb08-14d6-0310-b084-bc0e0c8e3800> | 2002-07-19 22:15:14 +0400 |
commit | 2199db7bf2e2cf1f20e3d8f58ab50fbe28eb22a8 (patch) | |
tree | 002de88261ef22cb78dbd1079b3137e90c8d2af6 | |
parent | b26b4578f916c12a07ffb6467cc904ef94e72b29 (diff) |
Fixed a pitch prediction bug when pitch is forced (end=start)
git-svn-id: http://svn.xiph.org/trunk/speex@3694 0101bb08-14d6-0310-b084-bc0e0c8e3800
-rw-r--r-- | libspeex/ltp.c | 6 | ||||
-rw-r--r-- | libspeex/modes.c | 3 | ||||
-rw-r--r-- | libspeex/nb_celp.c | 18 |
3 files changed, 16 insertions, 11 deletions
diff --git a/libspeex/ltp.c b/libspeex/ltp.c index 41bf1fd..83a4755 100644 --- a/libspeex/ltp.c +++ b/libspeex/ltp.c @@ -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);*/ diff --git a/libspeex/modes.c b/libspeex/modes.c index 203dade..d5121cc 100644 --- a/libspeex/modes.c +++ b/libspeex/modes.c @@ -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*/ diff --git a/libspeex/nb_celp.c b/libspeex/nb_celp.c index 1f2dd2b..bf02d95 100644 --- a/libspeex/nb_celp.c +++ b/libspeex/nb_celp.c @@ -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 { |