diff options
-rw-r--r-- | ChangeLog | 3 | ||||
-rw-r--r-- | INSTALL | 8 | ||||
-rw-r--r-- | README | 14 | ||||
-rw-r--r-- | TODO | 10 | ||||
-rw-r--r-- | libspeex/bits.c | 2 | ||||
-rw-r--r-- | libspeex/ltp.c | 19 | ||||
-rw-r--r-- | libspeex/mpulse.c | 23 | ||||
-rw-r--r-- | libspeex/quant_lsp.c | 10 | ||||
-rw-r--r-- | libspeex/speex.c | 8 | ||||
-rw-r--r-- | src/speexdec.c | 2 |
10 files changed, 64 insertions, 35 deletions
@@ -1,3 +1,6 @@ +2002/03/27 Jean-Marc Valin: +Working encoder and decoder for both narrowband and wideband. + 2002/02/27 Jean-Marc Valin: Got the basic encoder working as a demo with quantization only on some parameters. @@ -0,0 +1,8 @@ +Installing Speex is as easy as: + +% ./configure [--prefix=<install-path>] +% make +% make install + +Note that if you are using the code from CVS, you will need to run "autogen.sh" +instead of "configure". @@ -0,0 +1,14 @@ +See INSTALL file for instruction on how to install Speex. + +The Speex project aims to build an open-source patent-free voice codec. +Unlike other codecs like MP3 and Ogg Vorbis, Speex is specially designed +for compressing voice at low bit-rates for applications such as voice over +IP (VoIP). In some sense, it is meant to be complementary to the Ogg +Vorbis codec. + +Although we aim at providing a patent-free codec, we strongly suggest you +have a look at patent issues if you are thinking of using Speex +commercially. The speech coding field is a real patent mine field and +the scope and enforceability of all these patents is sometimes unclear, +not to mention that each country has different laws. + @@ -1,13 +1,3 @@ -- Improve stochastic codebook - -- Define bit-stream, multiple modes - - VBR - VAD & comfort noise generation - -- Implement decoder - -- Implement wideband codec - -- Search for not patented algorithms diff --git a/libspeex/bits.c b/libspeex/bits.c index f812796..434d1aa 100644 --- a/libspeex/bits.c +++ b/libspeex/bits.c @@ -84,8 +84,6 @@ void frame_bits_flush(FrameBits *bits) void frame_bits_read_whole_bytes(FrameBits *bits, char *bytes, int len) { int i,pos; - printf ("reading:\n"); - printf ("%d %d %d\n", bits->nbBits, bits->bytePtr, bits->bitPtr); frame_bits_flush(bits); pos=bits->nbBits>>3; for (i=0;i<len;i++) diff --git a/libspeex/ltp.c b/libspeex/ltp.c index f1b3c37..62adfe0 100644 --- a/libspeex/ltp.c +++ b/libspeex/ltp.c @@ -54,7 +54,9 @@ void open_loop_pitch(float *sw, int start, int end, int len, int *pitch, int *vu energy+=sw[-i-1]*sw[-i-1] - sw[-i+len]*sw[-i+len]; } pred_gain=e0/(1+fabs(e0+best_gain*best_gain*best_energy-2*best_gain*best_corr)); +#ifdef DEBUG printf ("pred = %f\n", pred_gain); +#endif *vuv=1; } @@ -86,8 +88,10 @@ float *stack &exc[-end], end-start+1, gain, pitch, p, nsf); *pitch=end-*pitch; +#ifdef DEBUG printf ("ol score: %d %f\n", *pitch, sc); #endif +#endif base=*pitch; exc_ptr=exc-*pitch; size = fact*nsf + filt_side*2 + 16*fact; @@ -127,7 +131,9 @@ float *stack frac_pitch = *pitch-(j/(float)fact); best_score=score; } +#ifdef DEBUG printf ("corr: %d %d %f\n", correction, *pitch, score); +#endif } /*for (i=0;i<nsf;i++) printf ("%f ", oexc[4*(i+8)]); @@ -210,13 +216,16 @@ float *stack exc[i]=best_gain*x[1][i];*/ /*for (i=0;i<nsf;i++) exc[i]=best_gain*oexc[fact*(best_cor+i)+frac];*/ +#ifdef DEBUG printf ("frac gains: %f %f %f\n", gain[0], gain[1], gain[2]); - +#endif POP(stack); POP(stack); POP(stack); } +#ifdef DEBUG printf ("frac pitch = %f %f\n", frac_pitch, best_score); +#endif POP(stack); POP(stack); @@ -307,7 +316,9 @@ float *stack for (i=0;i<nsf;i++) tmp2+=(target[i]-gain[2]*x[0][i]-gain[1]*x[1][i]-gain[0]*x[2][i]) * (target[i]-gain[2]*x[0][i]-gain[1]*x[1][i]-gain[0]*x[2][i]); +#ifdef DEBUG printf ("prediction gain = %f\n",tmp1/(tmp2+1)); +#endif return tmp1/(tmp2+1); } #endif @@ -411,8 +422,8 @@ float *stack /*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]; +#ifdef DEBUG printf ("3-tap pitch = %d, gains = [%f %f %f]\n",pitch, gain[0], gain[1], gain[2]); - { float tmp1=0,tmp2=0; for (i=0;i<nsf;i++) @@ -422,6 +433,7 @@ float *stack * (target[i]-gain[2]*x[0][i]-gain[1]*x[1][i]-gain[0]*x[2][i]); printf ("prediction gain = %f\n",tmp1/(tmp2+1)); } +#endif } @@ -450,8 +462,9 @@ float *stack gain[0] = gain_cdbk[gain_index*12]; gain[1] = gain_cdbk[gain_index*12+1]; gain[2] = gain_cdbk[gain_index*12+2]; +#ifdef DEBUG printf ("unquantized pitch: %d %f %f %f\n", pitch, gain[0], gain[1], gain[2]); - +#endif /*FIXME: backward or forward? (ie recursive or not?)*/ /*for(i=0;i<nsf;i++)*/ for (i=nsf-1;i>=0;i--) diff --git a/libspeex/mpulse.c b/libspeex/mpulse.c index d39572c..e1ed885 100644 --- a/libspeex/mpulse.c +++ b/libspeex/mpulse.c @@ -55,6 +55,7 @@ int porder(int *p, int *s, int *o, int len) } } } +#ifdef DEBUG printf ("quant_pulse\n"); for (i=0;i<len;i++) printf ("%d ", p[i]); @@ -62,7 +63,7 @@ int porder(int *p, int *s, int *o, int len) for (i=0;i<len;i++) printf ("%d ", s[i]); printf ("\n"); - +#endif for (i=0;i<len;i++) { rep[p[i]]++; @@ -111,10 +112,11 @@ int porder(int *p, int *s, int *o, int len) } } } +#ifdef DEBUG for (i=0;i<len;i++) printf ("%d ", o[i]); printf ("\n"); - +#endif return s[0]; } @@ -158,12 +160,12 @@ void rorder(int *p, int *s, int *o, int bit, int len) ss[0]=bit; n=1; - +#ifdef DEBUG printf ("unquant_pulse\n"); for (i=0;i<len;i++) printf ("%d ", o[i]); printf ("\n"); - +#endif for (i=1;i<len;i++) { if (i>1&&p[i-1]==p[i-2]) @@ -190,11 +192,11 @@ void rorder(int *p, int *s, int *o, int bit, int len) if (i<len&&o[i]!=o[i+1]) n++; } - +#ifdef DEBUG for (i=0;i<len;i++) printf ("%d ", s[i]); printf ("\n"); - +#endif } @@ -274,6 +276,9 @@ float *stack { int k; float dist=0; + /*Fill any track until it's full*/ + /*if (nb[j%nb_tracks]==pulses_per_track) + continue;*/ /*Constrain search in alternating tracks*/ if ((i%nb_tracks) != (j%nb_tracks)) continue; @@ -301,7 +306,9 @@ float *stack best_ind=j; } } +#ifdef DEBUG printf ("best pulse: %d %d %f %f %f %f\n", i, best_ind, best_gain, te, ee, g); +#endif /*Remove pulse contribution from target*/ for (j=best_ind;j<nsf;j++) t[j] -= best_gain * resp[j-best_ind]; @@ -343,14 +350,18 @@ float *stack for (i=0;i<nsf;i++) e[i]=g*pulses[i]; +#ifdef DEBUG printf ("global gain = %f\n", g); +#endif for (i=0;i<nsf;i++) t[i]=target[i]-f*resp[i]; } +#ifdef DEBUG for (i=0;i<nsf;i++) printf ("%f ", e[i]); printf ("\n"); +#endif for (i=0;i<nsf;i++) exc[i]+=e[i]; for (i=0;i<nsf;i++) diff --git a/libspeex/quant_lsp.c b/libspeex/quant_lsp.c index cc3053b..aeded5f 100644 --- a/libspeex/quant_lsp.c +++ b/libspeex/quant_lsp.c @@ -99,23 +99,18 @@ void lsp_quant_nb(float *lsp, float *qlsp, int order, FrameBits *bits) quant_weight[i] = tmp1 > tmp2 ? tmp1 : tmp2; } id = lsp_quant(qlsp, cdbk_nb, NB_CDBK_SIZE, order); - printf ("qid = %d\n", id); frame_bits_pack(bits, id, 6); id = lsp_weight_quant(qlsp, quant_weight, cdbk_nb_low1, NB_CDBK_SIZE_LOW1, 5); - printf ("qid = %d\n", id); frame_bits_pack(bits, id, 6); id = lsp_weight_quant(qlsp, quant_weight, cdbk_nb_low2, NB_CDBK_SIZE_LOW2, 5); - printf ("qid = %d\n", id); frame_bits_pack(bits, id, 6); id = lsp_weight_quant(qlsp+5, quant_weight+5, cdbk_nb_high1, NB_CDBK_SIZE_HIGH1, 5); - printf ("qid = %d\n", id); frame_bits_pack(bits, id, 6); id = lsp_weight_quant(qlsp+5, quant_weight+5, cdbk_nb_high2, NB_CDBK_SIZE_HIGH2, 5); - printf ("qid = %d\n", id); frame_bits_pack(bits, id, 6); for (i=0;i<order;i++) @@ -130,27 +125,22 @@ void lsp_unquant_nb(float *lsp, int order, FrameBits *bits) id=frame_bits_unpack_unsigned(bits, 6); - printf ("did = %d\n", id); for (i=0;i<10;i++) lsp[i] += cdbk_nb[id*10+i]; id=frame_bits_unpack_unsigned(bits, 6); - printf ("did = %d\n", id); for (i=0;i<5;i++) lsp[i] += cdbk_nb_low1[id*5+i]; id=frame_bits_unpack_unsigned(bits, 6); - printf ("did = %d\n", id); for (i=0;i<5;i++) lsp[i] += cdbk_nb_low2[id*5+i]; id=frame_bits_unpack_unsigned(bits, 6); - printf ("did = %d\n", id); for (i=0;i<5;i++) lsp[i+5] += cdbk_nb_high1[id*5+i]; id=frame_bits_unpack_unsigned(bits, 6); - printf ("did = %d\n", id); for (i=0;i<5;i++) lsp[i+5] += cdbk_nb_high2[id*5+i]; } diff --git a/libspeex/speex.c b/libspeex/speex.c index 0719533..d44f0ab 100644 --- a/libspeex/speex.c +++ b/libspeex/speex.c @@ -277,6 +277,7 @@ void encode(EncState *st, float *in, FrameBits *bits) for (i=2;i<=st->lpcSize;i++) st->bw_lpc2[i]=0; } +#ifdef DEBUG printf ("\nlpc0 "); for (i=0;i<=st->lpcSize;i++) printf ("%f ", st->interp_lpc[i]); @@ -287,7 +288,7 @@ void encode(EncState *st, float *in, FrameBits *bits) for (i=0;i<=st->lpcSize;i++) printf ("%f ", st->bw_lpc2[i]); printf ("\n\n"); - +#endif /* Reset excitation */ for (i=0;i<st->subframeSize;i++) exc[i]=0; @@ -346,7 +347,9 @@ void encode(EncState *st, float *in, FrameBits *bits) for (i=0;i<st->subframeSize;i++) enoise += target[i]*target[i]; snr = 10*log10((esig+1)/(enoise+1)); +#ifdef DEBUG printf ("pitch SNR = %f\n", snr); +#endif #if 0 /*If set to 1, compute "real innovation" i.e. cheat to get perfect reconstruction*/ syn_filt_zero(target, st->bw_lpc1, res, st->subframeSize, st->lpcSize); @@ -377,8 +380,9 @@ void encode(EncState *st, float *in, FrameBits *bits) for (i=0;i<st->subframeSize;i++) enoise += target[i]*target[i]; snr = 10*log10((esig+1)/(enoise+1)); +#ifdef DEBUG printf ("seg SNR = %f\n", snr); - +#endif /*Keep the previous memory*/ for (i=0;i<st->lpcSize;i++) mem[i]=st->mem_sp[i]; diff --git a/src/speexdec.c b/src/speexdec.c index d1b1fd9..27be46f 100644 --- a/src/speexdec.c +++ b/src/speexdec.c @@ -156,14 +156,12 @@ int main(int argc, char **argv) if (nb_read>0&&!at_end) { nb_read=fread(cbits, sizeof(char), nb_read, fin); - printf ("nb_read = %d\n", nb_read); if (feof(fin)) at_end=1; if (nb_read>0 && !at_end) frame_bits_read_whole_bytes(&bits, cbits, nb_read); } - printf ("bits.nbBits = %d, bits.bytePtr = %d\n", bits.nbBits>>3, bits.bytePtr); if (((bits.nbBits>>3)-bits.bytePtr)<2) break; |