Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mumble-voip/speex.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorjmvalin <jmvalin@0101bb08-14d6-0310-b084-bc0e0c8e3800>2002-04-10 03:33:47 +0400
committerjmvalin <jmvalin@0101bb08-14d6-0310-b084-bc0e0c8e3800>2002-04-10 03:33:47 +0400
commit8edb430c2a212d2dc9c6496eff262d4677146a05 (patch)
tree0d20a514cbf1f5c82e2ad23372950c207bafc658 /libspeex
parent18ba9b8d4695a50351c73699e62ae5f3f58b10ba (diff)
decoder stuff
git-svn-id: http://svn.xiph.org/trunk/speex@3235 0101bb08-14d6-0310-b084-bc0e0c8e3800
Diffstat (limited to 'libspeex')
-rw-r--r--libspeex/quant_lsp.c18
-rw-r--r--libspeex/quant_lsp.h3
-rw-r--r--libspeex/sb_celp.c79
-rw-r--r--libspeex/speex.c13
-rw-r--r--libspeex/speex.h1
-rw-r--r--libspeex/testenc_sb.c2
6 files changed, 112 insertions, 4 deletions
diff --git a/libspeex/quant_lsp.c b/libspeex/quant_lsp.c
index 9c994cb..e291360 100644
--- a/libspeex/quant_lsp.c
+++ b/libspeex/quant_lsp.c
@@ -283,3 +283,21 @@ void lsp_quant_high(float *lsp, float *qlsp, int order, FrameBits *bits)
for (i=0;i<order;i++)
qlsp[i]=lsp[i]-qlsp[i];
}
+
+void lsp_unquant_high(float *lsp, int order, FrameBits *bits)
+{
+
+ int i, id;
+ for (i=0;i<order;i++)
+ lsp[i]=0;
+
+
+ id=frame_bits_unpack_unsigned(bits, 6);
+ for (i=0;i<order;i++)
+ lsp[i] += high_lsp_cdbk[id*order+i];
+
+
+ id=frame_bits_unpack_unsigned(bits, 6);
+ for (i=0;i<order;i++)
+ lsp[i] += high_lsp_cdbk2[id*order+i];
+}
diff --git a/libspeex/quant_lsp.h b/libspeex/quant_lsp.h
index 1814ed8..15aceda 100644
--- a/libspeex/quant_lsp.h
+++ b/libspeex/quant_lsp.h
@@ -52,4 +52,7 @@ void lsp_unquant_wb(float *lsp, int order, FrameBits *bits);
/* Quantizes high-band LSPs with 12 bits */
void lsp_quant_high(float *lsp, float *qlsp, int order, FrameBits *bits);
+/* Decodes high-band LSPs */
+void lsp_unquant_high(float *lsp, int order, FrameBits *bits);
+
#endif
diff --git a/libspeex/sb_celp.c b/libspeex/sb_celp.c
index 04b921b..3dd5593 100644
--- a/libspeex/sb_celp.c
+++ b/libspeex/sb_celp.c
@@ -401,7 +401,7 @@ void sb_encode(SBEncState *st, float *in, FrameBits *bits)
tmp=1;
for (i=0;i<=st->lpcSize;i++)
{
- rh += tmp*st->interp_lpc[i];
+ rh += tmp*st->interp_qlpc[i];
tmp = -tmp;
}
rl = st->st_low.pi_gain[sub];
@@ -668,7 +668,7 @@ void sb_decoder_destroy(SBDecState *st)
void sb_decode(SBDecState *st, FrameBits *bits, float *out)
{
- int i;
+ int i, sub;
/* Decode the low-band */
decode(&st->st_low, bits, st->x0d);
@@ -676,7 +676,82 @@ void sb_decode(SBDecState *st, FrameBits *bits, float *out)
for (i=0;i<st->frame_size;i++)
st->exc[i]=0;
+ lsp_unquant_high(st->qlsp, st->lpcSize, bits);
+
+ if (st->first)
+ {
+ for (i=0;i<st->lpcSize;i++)
+ st->old_qlsp[i] = st->qlsp[i];
+ }
+ for (sub=0;sub<st->nbSubframes;sub++)
+ {
+ float *exc, *sp, tmp, filter_ratio;
+ int offset;
+
+ offset = st->subframeSize*sub;
+ sp=st->high+offset;
+ exc=st->exc+offset;
+
+ /* LSP interpolation */
+ tmp = (.5 + sub)/st->nbSubframes;
+ for (i=0;i<st->lpcSize;i++)
+ st->interp_qlsp[i] = (1-tmp)*st->old_qlsp[i] + tmp*st->qlsp[i];
+
+ /* LSPs to x-domain */
+ for (i=0;i<st->lpcSize;i++)
+ st->interp_qlsp[i] = cos(st->interp_qlsp[i]);
+
+ /* LSP to LPC */
+ lsp_to_lpc(st->interp_qlsp, st->interp_qlpc, st->lpcSize, st->stack);
+
+ {
+ float rl=0, rh=0;
+ tmp=1;
+ for (i=0;i<=st->lpcSize;i++)
+ {
+ rh += tmp*st->interp_qlpc[i];
+ tmp = -tmp;
+ }
+ rl = st->st_low.pi_gain[sub];
+ rl=1/(fabs(rl)+.001);
+ rh=1/(fabs(rh)+.001);
+ filter_ratio=fabs(.001+rh)/(.001+fabs(rl));
+ printf ("filter_ratio: %f\n", filter_ratio);
+ }
+
+ {
+ int k,N=4;
+ float el=0,eh=0,g;
+ int *index;
+ float *gains;
+ int of=k*st->subframeSize/N;
+ gains = PUSH(st->stack, N);
+ index = (int*) PUSH(st->stack, N);
+
+ for (k=0;k<N;k++)
+ index[k] = frame_bits_unpack_unsigned(bits,6);
+
+ for (k=0;k<N;k++)
+ {
+ int sign, gain_ind;
+ sign = frame_bits_unpack_unsigned(bits,1);
+ gain_ind = frame_bits_unpack_unsigned(bits,3);
+ gains[k] = quant_high_gain2[gain_ind];
+ if (sign)
+ gains[k] =- gains[k];
+ }
+
+ for (k=0;k<N;k++)
+ {
+ for (i=0;i<st->subframeSize/N;i++)
+ exc[of+i]=gains[k]*stoc[index[k]+i];
+ }
+
+ POP(st->stack);
+ POP(st->stack);
+ }
+ }
/* Up-sample coded low-band and high-band*/
for (i=0;i<st->frame_size;i++)
diff --git a/libspeex/speex.c b/libspeex/speex.c
index a2c5707..7fe131b 100644
--- a/libspeex/speex.c
+++ b/libspeex/speex.c
@@ -273,7 +273,7 @@ void encode(EncState *st, float *in, FrameBits *bits)
st->pi_gain[sub]=0;
for (i=0;i<=st->lpcSize;i++)
{
- st->pi_gain[sub] += tmp*st->interp_lpc[i];
+ st->pi_gain[sub] += tmp*st->interp_qlpc[i];
tmp = -tmp;
}
@@ -471,6 +471,8 @@ void decoder_init(DecState *st, SpeexMode *mode)
st->interp_qlsp = malloc(st->lpcSize*sizeof(float));
st->mem_sp = calloc(st->lpcSize, sizeof(float));
+ st->pi_gain = calloc(st->nbSubframes, sizeof(float));
+
}
void decoder_destroy(DecState *st)
@@ -483,6 +485,7 @@ void decoder_destroy(DecState *st)
free(st->interp_qlsp);
free(st->stack);
free(st->mem_sp);
+ free(st->pi_gain);
}
void decode(DecState *st, FrameBits *bits, float *out)
@@ -523,6 +526,14 @@ void decode(DecState *st, FrameBits *bits, float *out)
st->interp_qlsp[i] = cos(st->interp_qlsp[i]);
lsp_to_lpc(st->interp_qlsp, st->interp_qlpc, st->lpcSize, st->stack);
+ tmp=1;
+ st->pi_gain[sub]=0;
+ for (i=0;i<=st->lpcSize;i++)
+ {
+ st->pi_gain[sub] += tmp*st->interp_qlpc[i];
+ tmp = -tmp;
+ }
+
/* Reset excitation */
for (i=0;i<st->subframeSize;i++)
exc[i]=0;
diff --git a/libspeex/speex.h b/libspeex/speex.h
index 7227a01..aa92284 100644
--- a/libspeex/speex.h
+++ b/libspeex/speex.h
@@ -105,6 +105,7 @@ typedef struct DecState {
float *interp_qlsp; /* Interpolated quantized LSPs */
float *interp_qlpc; /* Interpolated quantized LPCs */
float *mem_sp;
+ float *pi_gain;
lsp_unquant_func lsp_unquant;
ltp_unquant_func ltp_unquant;
diff --git a/libspeex/testenc_sb.c b/libspeex/testenc_sb.c
index 07f905b..7b91c12 100644
--- a/libspeex/testenc_sb.c
+++ b/libspeex/testenc_sb.c
@@ -78,5 +78,5 @@ int main(int argc, char **argv)
sb_encoder_destroy(&st);
sb_decoder_destroy(&dec);
- return 1;
+ return 0;
}