diff options
author | jmvalin <jmvalin@0101bb08-14d6-0310-b084-bc0e0c8e3800> | 2002-03-13 10:29:28 +0300 |
---|---|---|
committer | jmvalin <jmvalin@0101bb08-14d6-0310-b084-bc0e0c8e3800> | 2002-03-13 10:29:28 +0300 |
commit | ead4dde2b6887cfe09d73c232bba4d39cb9e4762 (patch) | |
tree | fd79928fd04b23e8fa4f4e087eecb2e8b33cf7d9 /libspeex | |
parent | 0241c4383f08dbf8e9173bfe8db3219b26c2807f (diff) |
More decoder stuff
git-svn-id: http://svn.xiph.org/trunk/speex@3138 0101bb08-14d6-0310-b084-bc0e0c8e3800
Diffstat (limited to 'libspeex')
-rw-r--r-- | libspeex/cb_search.c | 29 | ||||
-rw-r--r-- | libspeex/cb_search.h | 7 | ||||
-rw-r--r-- | libspeex/ltp.c | 13 | ||||
-rw-r--r-- | libspeex/speex.c | 5 |
4 files changed, 44 insertions, 10 deletions
diff --git a/libspeex/cb_search.c b/libspeex/cb_search.c index b3e73a2..e5e3885 100644 --- a/libspeex/cb_search.c +++ b/libspeex/cb_search.c @@ -136,7 +136,7 @@ float target[], /* target vector */ float ak[], /* LPCs for this subframe */ float awk1[], /* Weighted LPCs for this subframe */ float awk2[], /* Weighted LPCs for this subframe */ -float codebook[][8], /* overlapping codebook */ +float codebook[][8], /* non-overlapping codebook */ int entries, /* number of entries to search */ float *gain, /* gain of optimum entries */ int *index, /* index of optimum entries */ @@ -182,7 +182,11 @@ FrameBits *bits best_gain=corr/(.001+E[j]); } } - frame_bits_pack(bits,best_index,8); + frame_bits_pack(bits,best_index,7); + if (best_gain>0) + frame_bits_pack(bits,0,1); + else + frame_bits_pack(bits,1,1); ind[i]=best_index; gains[i]=best_gain*Ee[ind[i]]; if (0) { /* Simulating scalar quantization of the gain*/ @@ -290,3 +294,24 @@ FrameBits *bits target[i]=t[i]; } +void split_cb_unquant( +float *exc, +float codebook[][8], /* non-overlapping codebook */ +int nsf, /* number of samples in subframe */ +FrameBits *bits +) +{ + int i; + int ind[5]; + float gains[5]; + float sign[5]; + for (i=0;i<5;i++) + { + ind[i] = frame_bits_unpack_unsigned(bits, 7); + if (frame_bits_unpack_unsigned(bits, 1)) + sign[i]=-1; + else + sign[i]=1; + } + frame_bits_unpack_unsigned(bits, 11); +} diff --git a/libspeex/cb_search.h b/libspeex/cb_search.h index 2bd61b0..696f844 100644 --- a/libspeex/cb_search.h +++ b/libspeex/cb_search.h @@ -51,4 +51,11 @@ float *exc, FrameBits *bits ); +void split_cb_unquant( +float *exc, +float codebook[][8], /* non-overlapping codebook */ +int nsf, /* number of samples in subframe */ +FrameBits *bits +); + #endif diff --git a/libspeex/ltp.c b/libspeex/ltp.c index 4b127d4..a6bf7a6 100644 --- a/libspeex/ltp.c +++ b/libspeex/ltp.c @@ -401,8 +401,12 @@ float *stack frame_bits_pack(bits,best_cdbk,7); } - --*pitch; - + + /*FIXME: backward or forward? (ie recursive or not?)*/ + /*for (i=0;i<nsf;i++)*/ + for (i=nsf-1;i>=0;i--) + exc[i]=gain[0]*exc[i-*pitch+1]+gain[1]*exc[i-*pitch]+gain[2]*exc[i-*pitch-1]; + printf ("3-tap pitch = %d, gains = [%f %f %f]\n",*pitch, gain[0], gain[1], gain[2]); { float tmp1=0,tmp2=0; @@ -437,8 +441,9 @@ float *stack gain[2] = gain_cdbk_nb[gain_index*12+2]; printf ("unquantized pitch: %d %f %f %f\n", pitch, gain[0], gain[1], gain[2]); - /*Go backward in case pitch < nsf*/ - for(i=nsf-1;i>=0;i--) + /*FIXME: backward or forward? (ie recursive or not?)*/ + /*for(i=0;i<nsf;i++)*/ + for (i=nsf-1;i>=0;i--) { exc[i]=gain[0]*exc[i-pitch+1] + gain[1]*exc[i-pitch] + gain[2]*exc[i-pitch-1]; } diff --git a/libspeex/speex.c b/libspeex/speex.c index 7a996cc..b768773 100644 --- a/libspeex/speex.c +++ b/libspeex/speex.c @@ -316,9 +316,6 @@ void encode(EncState *st, float *in, FrameBits *bits) pitch_search_3tap(target, st->interp_qlpc, st->bw_lpc1, st->bw_lpc2, exc, 20, 147, &gain[0], &pitch, &pitch_gain_index, st->lpcSize, st->subframeSize, bits, st->stack); - for (i=0;i<st->subframeSize;i++) - exc[i]=gain[0]*exc[i-pitch]+gain[1]*exc[i-pitch-1]+gain[2]*exc[i-pitch-2]; - printf ("3-tap pitch = %d, gains = [%f %f %f]\n",pitch, gain[0], gain[1], gain[2]); #endif /* Update target for adaptive codebook contribution */ residue_zero(exc, st->bw_lpc1, res, st->subframeSize, st->lpcSize); @@ -548,7 +545,7 @@ void decode(DecState *st, FrameBits *bits, float *out) pitch_unquant_3tap(exc, st->min_pitch, st->max_pitch, st->subframeSize, bits, st->stack); /*Fixed codebook contribution*/ - frame_bits_unpack_unsigned(bits, 51); + split_cb_unquant(exc, exc_table, st->subframeSize, bits); /*Compute decoded signal*/ syn_filt_mem(exc, st->interp_qlpc, sp, st->subframeSize, st->lpcSize, st->mem_sp); |