[xiph-cvs] cvs commit: speex/src speexdec.c
Jean-Marc Valin
jm at xiph.org
Tue Oct 7 21:35:02 PDT 2003
jm 03/10/08 00:35:02
Modified: libspeex cb_search.c misc.h modes.c modes.h nb_celp.c
nb_celp.h preprocess.c stereo.c
src speexdec.c
Log:
fixed-point: removed pre-emphasis, more cleanup
Revision Changes Path
1.88 +2 -1 speex/libspeex/cb_search.c
Index: cb_search.c
===================================================================
RCS file: /usr/local/cvsroot/speex/libspeex/cb_search.c,v
retrieving revision 1.87
retrieving revision 1.88
diff -u -r1.87 -r1.88
--- cb_search.c 8 Oct 2003 04:27:51 -0000 1.87
+++ cb_search.c 8 Oct 2003 04:35:01 -0000 1.88
@@ -136,7 +136,8 @@
{
res[j]=0;
for (k=0;k<=j;k++)
- res[j] += 0.03125*shape[k]*r[j-k];
+ res[j] += shape[k]*r[j-k];
+ res[j] *= 0.03125;
}
/* Compute codeword energy */
<p><p>1.26 +1 -8 speex/libspeex/misc.h
Index: misc.h
===================================================================
RCS file: /usr/local/cvsroot/speex/libspeex/misc.h,v
retrieving revision 1.25
retrieving revision 1.26
diff -u -r1.25 -r1.26
--- misc.h 8 Oct 2003 04:32:24 -0000 1.25
+++ misc.h 8 Oct 2003 04:35:01 -0000 1.26
@@ -36,16 +36,9 @@
#define MISC_H
#ifndef VERSION
-#define VERSION "speex-1.0"
+#define VERSION "speex-1.1"
#endif
-/*Disable some warnings on VC++*/
-#ifdef _MSC_VER
-#pragma warning(disable : 4244)
-#pragma warning(disable : 4305)
-#endif
-
-
#ifdef FIXED_POINT
typedef short spx_word16_t;
<p><p>1.109 +0 -4 speex/libspeex/modes.c
Index: modes.c
===================================================================
RCS file: /usr/local/cvsroot/speex/libspeex/modes.c,v
retrieving revision 1.108
retrieving revision 1.109
diff -u -r1.108 -r1.109
--- modes.c 8 Oct 2003 04:33:36 -0000 1.108
+++ modes.c 8 Oct 2003 04:35:01 -0000 1.109
@@ -352,7 +352,6 @@
0.6, /*gamma2*/
.012, /*lag_factor*/
1.0002, /*lpc_floor*/
- 0.0, /*preemph*/
#ifdef EPIC_48K
0,
#endif
@@ -481,7 +480,6 @@
0.6, /*gamma2*/
.001, /*lag_factor*/
1.0001, /*lpc_floor*/
- 0.0, /*preemph*/
0.9,
{NULL, &wb_submode1, &wb_submode2, &wb_submode3, &wb_submode4, NULL, NULL, NULL},
3,
@@ -525,7 +523,6 @@
0.6, /*gamma2*/
.002, /*lag_factor*/
1.0001, /*lpc_floor*/
- 0.0, /*preemph*/
0.7,
{NULL, &wb_submode1, NULL, NULL, NULL, NULL, NULL, NULL},
1,
@@ -611,7 +608,6 @@
0.6, /*gamma2*/
.01, /*lag_factor*/
1.0003, /*lpc_floor*/
- 0.0, /*preemph*/
1,
{NULL, NULL, &nb_48k_submode, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL},
2,
<p><p>1.45 +0 -2 speex/libspeex/modes.h
Index: modes.h
===================================================================
RCS file: /usr/local/cvsroot/speex/libspeex/modes.h,v
retrieving revision 1.44
retrieving revision 1.45
diff -u -r1.44 -r1.45
--- modes.h 8 Oct 2003 04:27:51 -0000 1.44
+++ modes.h 8 Oct 2003 04:35:01 -0000 1.45
@@ -112,7 +112,6 @@
float gamma2; /**< Perceptual filter parameter #2 */
float lag_factor; /**< Lag-windowing parameter */
float lpc_floor; /**< Noise floor for LPC analysis */
- float preemph; /**< Pre-emphasis */
#ifdef EPIC_48K
int lbr48k; /**< 1 for the special 4.8 kbps mode */
@@ -135,7 +134,6 @@
float gamma2; /**< Perceptual filter parameter #1 */
float lag_factor; /**< Lag-windowing parameter */
float lpc_floor; /**< Noise floor for LPC analysis */
- float preemph; /**< Pre-emphasis */
float folding_gain;
SpeexSubmode *submodes[SB_SUBMODES]; /**< Sub-mode data for the mode */
<p><p>1.127 +15 -34 speex/libspeex/nb_celp.c
Index: nb_celp.c
===================================================================
RCS file: /usr/local/cvsroot/speex/libspeex/nb_celp.c,v
retrieving revision 1.126
retrieving revision 1.127
diff -u -r1.126 -r1.127
--- nb_celp.c 8 Oct 2003 04:32:24 -0000 1.126
+++ nb_celp.c 8 Oct 2003 04:35:01 -0000 1.127
@@ -59,9 +59,9 @@
#define SUBMODE(x) st->submodes[st->submodeID]->x
-float exc_gain_quant_scal3[8]={-2.794750, -1.810660, -1.169850, -0.848119, -0.587190, -0.329818, -0.063266, 0.282826};
+float exc_gain_quant_scal3[8]={-2.794750f, -1.810660f, -1.169850f, -0.848119f, -0.587190f, -0.329818f, -0.063266f, 0.282826f};
-float exc_gain_quant_scal1[2]={-0.35, 0.05};
+float exc_gain_quant_scal1[2]={-0.35f, 0.05f};
#define sqr(x) ((x)*(x))
@@ -92,12 +92,9 @@
st->max_pitch=mode->pitchEnd;
st->lag_factor=mode->lag_factor;
st->lpc_floor = mode->lpc_floor;
- st->preemph = mode->preemph;
st->submodes=mode->submodes;
st->submodeID=st->submodeSelect=mode->defaultSubmode;
- st->pre_mem=0;
- st->pre_mem2=0;
st->bounded_pitch = 1;
st->encode_submode = 1;
@@ -217,10 +214,8 @@
/* Copy new data in input buffer */
speex_move(st->inBuf, st->inBuf+st->frameSize, (st->bufSize-st->frameSize)*sizeof(float));
- st->inBuf[st->bufSize-st->frameSize] = in[0] - st->preemph*st->pre_mem;
- for (i=1;i<st->frameSize;i++)
- st->inBuf[st->bufSize-st->frameSize+i] = in[i] - st->preemph*in[i-1];
- st->pre_mem = in[st->frameSize-1];
+ for (i=0;i<st->frameSize;i++)
+ st->inBuf[st->bufSize-st->frameSize+i] = in[i];
/* Move signals 1 frame towards the past */
speex_move(st->exc2Buf, st->exc2Buf+st->frameSize, (st->bufSize-st->frameSize)*sizeof(float));
@@ -504,10 +499,8 @@
/* Final signal synthesis from excitation */
iir_mem2(st->exc, st->interp_qlpc, st->frame, st->frameSize, st->lpcSize, st->mem_sp);
- in[0] = st->frame[0] + st->preemph*st->pre_mem2;
- for (i=1;i<st->frameSize;i++)
- in[i]=st->frame[i] + st->preemph*in[i-1];
- st->pre_mem2=in[st->frameSize-1];
+ for (i=0;i<st->frameSize;i++)
+ in[i]=st->frame[i];
return 0;
@@ -678,8 +671,7 @@
else
{
st->bw_lpc2[0]=1;
- st->bw_lpc2[1]=-st->preemph;
- for (i=2;i<=st->lpcSize;i++)
+ for (i=1;i<=st->lpcSize;i++)
st->bw_lpc2[i]=0;
}
@@ -909,10 +901,8 @@
}
/* Replace input by synthesized speech */
- in[0] = st->frame[0] + st->preemph*st->pre_mem2;
- for (i=1;i<st->frameSize;i++)
- in[i]=st->frame[i] + st->preemph*in[i-1];
- st->pre_mem2=in[st->frameSize-1];
+ for (i=0;i<st->frameSize;i++)
+ in[i]=st->frame[i];
if (SUBMODE(innovation_quant) == noise_codebook_quant || st->submodeID==0)
st->bounded_pitch = 1;
@@ -952,12 +942,10 @@
st->gamma2=mode->gamma2;
st->min_pitch=mode->pitchStart;
st->max_pitch=mode->pitchEnd;
- st->preemph = mode->preemph;
st->submodes=mode->submodes;
st->submodeID=mode->defaultSubmode;
- st->pre_mem=0;
st->lpc_enh_enabled=0;
@@ -1110,10 +1098,8 @@
}
}
- 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];
+ for (i=0;i<st->frameSize;i++)
+ out[i]=st->frame[i];
st->first = 0;
st->count_lost++;
@@ -1272,10 +1258,8 @@
/* Final signal synthesis from excitation */
iir_mem2(st->exc, lpc, st->frame, st->frameSize, st->lpcSize, st->mem_sp);
- 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];
+ for (i=0;i<st->frameSize;i++)
+ out[i]=st->frame[i];
st->count_lost=0;
return 0;
}
@@ -1624,11 +1608,8 @@
}
/*Copy output signal*/
- 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];
-
+ for (i=0;i<st->frameSize;i++)
+ out[i]=st->frame[i];
/* Store the LSPs for interpolation in the next frame */
for (i=0;i<st->lpcSize;i++)
<p><p>1.54 +0 -5 speex/libspeex/nb_celp.h
Index: nb_celp.h
===================================================================
RCS file: /usr/local/cvsroot/speex/libspeex/nb_celp.h,v
retrieving revision 1.53
retrieving revision 1.54
diff -u -r1.53 -r1.54
--- nb_celp.h 8 Oct 2003 04:30:25 -0000 1.53
+++ nb_celp.h 8 Oct 2003 04:35:01 -0000 1.54
@@ -69,9 +69,6 @@
float gamma2; /**< Perceptual filter: A(z/gamma2) */
float lag_factor; /**< Lag windowing Gaussian width */
float lpc_floor; /**< Noise floor multiplier for A[0] in LPC analysis*/
- float preemph; /**< Pre-emphasis: P(z) = 1 - a*z^-1*/
- float pre_mem; /**< 1-element memory for pre-emphasis */
- float pre_mem2; /**< 1-element memory for pre-emphasis */
char *stack; /**< Pseudo-stack allocation for temporary memory */
float *inBuf; /**< Input buffer (original signal) */
float *frame; /**< Start of original frame */
@@ -146,8 +143,6 @@
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 */
char *stack; /**< Pseudo-stack allocation for temporary memory */
float *inBuf; /**< Input buffer (original signal) */
float *frame; /**< Start of original frame */
<p><p>1.15 +8 -7 speex/libspeex/preprocess.c
Index: preprocess.c
===================================================================
RCS file: /usr/local/cvsroot/speex/libspeex/preprocess.c,v
retrieving revision 1.14
retrieving revision 1.15
diff -u -r1.14 -r1.15
--- preprocess.c 8 Oct 2003 04:27:51 -0000 1.14
+++ preprocess.c 8 Oct 2003 04:35:01 -0000 1.15
@@ -582,7 +582,7 @@
st->Smin[i] = st->Stmp[i] = st->S[i]+100;
}
- if (st->nb_preprocess%80==0)
+ if (st->nb_preprocess%100==0)
{
for (i=1;i<N-1;i++)
{
@@ -670,14 +670,15 @@
else
min_gamma *= 4.;
#else
- min_gamma = .2*fabs(mean_prior - mean_post)*fabs(mean_prior - mean_post);
- if (min_gamma>.6)
- min_gamma = .6;
- if (min_gamma<.01)
- min_gamma = .01;
+ min_gamma = .1*fabs(mean_prior - mean_post)*fabs(mean_prior - mean_post);
+ if (min_gamma>.15)
+ min_gamma = .15;
+ if (min_gamma<.02)
+ min_gamma = .02;
#endif
+ /*min_gamma = .08;*/
- if (gamma<min_gamma)
+ /*if (gamma<min_gamma)*/
gamma=min_gamma;
for (i=1;i<N;i++)
<p><p>1.6 +1 -1 speex/libspeex/stereo.c
Index: stereo.c
===================================================================
RCS file: /usr/local/cvsroot/speex/libspeex/stereo.c,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -r1.5 -r1.6
--- stereo.c 6 Jan 2003 22:06:45 -0000 1.5
+++ stereo.c 8 Oct 2003 04:35:01 -0000 1.6
@@ -35,7 +35,7 @@
#include <math.h>
/*float e_ratio_quant[4] = {1, 1.26, 1.587, 2};*/
-static float e_ratio_quant[4] = {.25, .315, .397, .5};
+static float e_ratio_quant[4] = {.25f, .315f, .397f, .5f};
void speex_encode_stereo(float *data, int frame_size, SpeexBits *bits)
{
<p><p>1.82 +1 -0 speex/src/speexdec.c
Index: speexdec.c
===================================================================
RCS file: /usr/local/cvsroot/speex/src/speexdec.c,v
retrieving revision 1.81
retrieving revision 1.82
diff -u -r1.81 -r1.82
--- speexdec.c 8 Oct 2003 04:27:52 -0000 1.81
+++ speexdec.c 8 Oct 2003 04:35:02 -0000 1.82
@@ -194,6 +194,7 @@
#endif
info.play.encoding = AUDIO_ENCODING_SLINEAR;
info.play.precision = 16;
+ info.play.sample_rate = rate;
info.play.channels = *channels;
if (ioctl(audio_fd, AUDIO_SETINFO, &info) < 0)
<p><p>--- >8 ----
List archives: http://www.xiph.org/archives/
Ogg project homepage: http://www.xiph.org/ogg/
To unsubscribe from this list, send a message to 'cvs-request at xiph.org'
containing only the word 'unsubscribe' in the body. No subject is needed.
Unsubscribe messages sent to the list will be ignored/filtered.
More information about the commits
mailing list