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-03-26 23:48:01 +0300
committerjmvalin <jmvalin@0101bb08-14d6-0310-b084-bc0e0c8e3800>2002-03-26 23:48:01 +0300
commit069bc664fe1d579dc9007ae780b05ace1ab415ba (patch)
tree3b79eb9cae9e20a321f82b939399694fcdc67544 /libspeex
parent1ca4542935827d00511f85597a315b47aaba9273 (diff)
Fixed pre-emphasis/de-emphasis in the decoder for wideband
(and narrowband). Now both should work (really!) git-svn-id: http://svn.xiph.org/trunk/speex@3187 0101bb08-14d6-0310-b084-bc0e0c8e3800
Diffstat (limited to 'libspeex')
-rw-r--r--libspeex/modes.c4
-rw-r--r--libspeex/mpulse.c4
-rw-r--r--libspeex/speex.c16
-rw-r--r--libspeex/speex.h2
-rw-r--r--libspeex/testenc_wb.c1
5 files changed, 16 insertions, 11 deletions
diff --git a/libspeex/modes.c b/libspeex/modes.c
index 1c05904..a49bad5 100644
--- a/libspeex/modes.c
+++ b/libspeex/modes.c
@@ -165,10 +165,10 @@ SpeexMode mp_wb_mode = {
35, /*pitchStart*/
290, /*pitchEnd*/
0.9, /*gamma1*/
- -1.0, /*gamma2*/
+ -0.2, /*gamma2*/
.002, /*lag_factor*/
1.0001,/*lpc_floor*/
- 0.7, /*preemph*/
+ 0.55, /*preemph*/
/*LSP quantization*/
lsp_quant_wb,
diff --git a/libspeex/mpulse.c b/libspeex/mpulse.c
index f16512d..d39572c 100644
--- a/libspeex/mpulse.c
+++ b/libspeex/mpulse.c
@@ -413,7 +413,9 @@ float *stack
quant_gain=frame_bits_unpack_unsigned(bits, 7);
g=exp((quant_gain/8.0)+1);
-
+ /*Removes glitches when energy is near-zero*/
+ if (g<3)
+ g=0;
for (i=0;i<nb_tracks;i++)
{
int ind;
diff --git a/libspeex/speex.c b/libspeex/speex.c
index eef675e..0719533 100644
--- a/libspeex/speex.c
+++ b/libspeex/speex.c
@@ -219,8 +219,7 @@ void encode(EncState *st, float *in, FrameBits *bits)
printf ("QLSP ");
for (i=0;i<st->lpcSize;i++)
printf ("%f ", st->qlsp[i]);
- printf ("\n");
- return;*/
+ printf ("\n");*/
/* Special case for first frame */
if (st->first)
{
@@ -426,7 +425,9 @@ void decoder_init(DecState *st, SpeexMode *mode)
st->gamma2=mode->gamma2;
st->min_pitch=mode->pitchStart;
st->max_pitch=mode->pitchEnd;
+ st->preemph = mode->preemph;
+ st->pre_mem=0;
st->lsp_unquant = mode->lsp_unquant;
st->ltp_unquant = mode->ltp_unquant;
st->ltp_params = mode->ltp_params;
@@ -480,11 +481,6 @@ void decode(DecState *st, FrameBits *bits, float *out)
st->old_qlsp[i] = st->qlsp[i];
}
- printf ("decode LSPs: ");
- for (i=0;i<st->lpcSize;i++)
- printf ("%f ", st->qlsp[i]);
- printf ("\n");
-
/*Loop on subframes */
for (sub=0;sub<st->nbSubframes;sub++)
{
@@ -527,6 +523,12 @@ void decode(DecState *st, FrameBits *bits, float *out)
for (i=0;i<st->frameSize;i++)
out[i]=st->frame[i];
+ out[0] = st->frame[0] + st->preemph*st->pre_mem;
+ for (i=1;i<st->frameSize;i++)
+ out[i]=st->frame[i] + st->preemph*out[i-1];
+ st->pre_mem=out[st->frameSize-1];
+
+
/* Store the LSPs for interpolation in the next frame */
for (i=0;i<st->lpcSize;i++)
st->old_qlsp[i] = st->qlsp[i];
diff --git a/libspeex/speex.h b/libspeex/speex.h
index 1741c3f..4452c4f 100644
--- a/libspeex/speex.h
+++ b/libspeex/speex.h
@@ -92,6 +92,8 @@ typedef struct DecState {
int max_pitch; /* Maximum pitch value allowed */
float gamma1; /* Perceptual filter: A(z/gamma1) */
float gamma2; /* Perceptual filter: A(z/gamma2) */
+ float preemph; /* Pre-emphasis: P(z) = 1 - a*z^-1*/
+ float pre_mem; /* 1-element memory for pre-emphasis */
float *stack;
float *inBuf; /* Input buffer (original signal) */
float *frame; /* Start of original frame */
diff --git a/libspeex/testenc_wb.c b/libspeex/testenc_wb.c
index 95bfedd..588735e 100644
--- a/libspeex/testenc_wb.c
+++ b/libspeex/testenc_wb.c
@@ -57,7 +57,6 @@ int main(int argc, char **argv)
snr = 10*log10((esig+1)/(enoise+1));
printf ("real SNR = %f\n", snr);
}
-
frame_bits_rewind(&bits);
decode(&dec, &bits, input);