[xiph-cvs] cvs commit: speex/libspeex quant_lsp.c sb_celp.c
Jean-Marc Valin
jm at xiph.org
Thu Nov 20 22:59:26 PST 2003
jm 03/11/21 01:59:26
Modified: libspeex quant_lsp.c sb_celp.c
Log:
fixed-point: wideband work (LSP and excitation gain decoding)
Revision Changes Path
1.32 +9 -4 speex/libspeex/quant_lsp.c
Index: quant_lsp.c
===================================================================
RCS file: /usr/local/cvsroot/speex/libspeex/quant_lsp.c,v
retrieving revision 1.31
retrieving revision 1.32
diff -u -r1.31 -r1.32
--- quant_lsp.c 6 Nov 2003 21:35:30 -0000 1.31
+++ quant_lsp.c 21 Nov 2003 06:59:25 -0000 1.32
@@ -38,19 +38,24 @@
/* FIXME: Get rid of this kludge quick before someone gets hurt */
#ifdef FIXED_POINT
+
#define LSP_LINEAR(i) (SHL(i+1,11))
+#define LSP_LINEAR_HIGH(i) (ADD16(MULT16_16_16(i,2560),6144))
#define LSP_DIV_256(x) (SHL((spx_word16_t)x, 5))
#define LSP_DIV_512(x) (SHL((spx_word16_t)x, 4))
#define LSP_DIV_1024(x) (SHL((spx_word16_t)x, 3))
#define LSP_PI 25736
+
#else
#define LSP_LINEAR(i) (.25*(i)+.25)
+#define LSP_LINEAR_HIGH(i) (.3125*(i)+.75)
#define LSP_SCALE 256.
#define LSP_DIV_256(x) (0.0039062*(x))
#define LSP_DIV_512(x) (0.0019531*(x))
#define LSP_DIV_1024(x) (0.00097656*(x))
#define LSP_PI M_PI
+
#endif
static void compute_quant_weights(spx_lsp_t *qlsp, spx_word16_t *quant_weight, int order)
@@ -310,7 +315,7 @@
}*/
for (i=0;i<order;i++)
- qlsp[i]-=LSP_SCALING*(.3125*i+.75);
+ qlsp[i]-=LSP_LINEAR_HIGH(i);
#ifndef FIXED_POINT
for (i=0;i<order;i++)
qlsp[i] = qlsp[i]*LSP_SCALE;
@@ -341,17 +346,17 @@
int i, id;
for (i=0;i<order;i++)
- lsp[i]=LSP_SCALING*(.3125*i+.75);
+ lsp[i]=LSP_LINEAR_HIGH(i);
id=speex_bits_unpack_unsigned(bits, 6);
for (i=0;i<order;i++)
- lsp[i] += LSP_SCALING*0.0039062*high_lsp_cdbk[id*order+i];
+ lsp[i] += LSP_DIV_256(high_lsp_cdbk[id*order+i]);
id=speex_bits_unpack_unsigned(bits, 6);
for (i=0;i<order;i++)
- lsp[i] += LSP_SCALING*0.0019531*high_lsp_cdbk2[id*order+i];
+ lsp[i] += LSP_DIV_512(high_lsp_cdbk2[id*order+i]);
}
<p><p>1.157 +16 -9 speex/libspeex/sb_celp.c
Index: sb_celp.c
===================================================================
RCS file: /usr/local/cvsroot/speex/libspeex/sb_celp.c,v
retrieving revision 1.156
retrieving revision 1.157
diff -u -r1.156 -r1.157
--- sb_celp.c 21 Nov 2003 03:06:42 -0000 1.156
+++ sb_celp.c 21 Nov 2003 06:59:25 -0000 1.157
@@ -543,7 +543,7 @@
if (!SUBMODE(innovation_quant)) {/* 1 for spectral folding excitation, 0 for stochastic */
float g;
- float el;
+ spx_word16_t el;
el = compute_rms(low_innov+offset, st->subframeSize);
/* Gain to use if we want to use the low-band excitation for high-band */
@@ -966,7 +966,8 @@
for (sub=0;sub<st->nbSubframes;sub++)
{
spx_sig_t *exc, *sp;
- float filter_ratio, el=0;
+ spx_word16_t filter_ratio;
+ spx_word16_t el=0;
int offset;
spx_word32_t rl=0,rh=0;
@@ -1018,7 +1019,6 @@
rl = low_pi_gain[sub];
#ifdef FIXED_POINT
filter_ratio=DIV32_16(SHL(rl+82,2),SHR(82+rh,5));
- filter_ratio /= 128.;
#else
filter_ratio=(rl+.01)/(rh+.01);
#endif
@@ -1033,30 +1033,37 @@
quant = speex_bits_unpack_unsigned(bits, 5);
g= exp(((float)quant-10)/8.0);
- /*printf ("unquant folding gain: %f\n", g);*/
+#ifdef FIXED_POINT
+ g /= filter_ratio/128.;
+#else
g /= filter_ratio;
-
+#endif
/* High-band excitation using the low-band excitation and a gain */
for (i=0;i<st->subframeSize;i++)
exc[i]=mode->folding_gain*g*low_innov[offset+i];
/*speex_rand_vec(mode->folding_gain*g*sqrt(el/st->subframeSize), exc, st->subframeSize);*/
} else {
- float gc, scale;
+ spx_word16_t gc;
+ spx_word32_t scale;
int qgc = speex_bits_unpack_unsigned(bits, 4);
el = compute_rms(low_exc+offset, st->subframeSize);
+#ifdef FIXED_POINT
+ gc = MULT16_32_Q15(28626,gc_quant_bound[qgc]);
+#else
gc = exp((1/3.7)*qgc-0.15556);
+#endif
if (st->subframeSize==80)
gc *= 1.4142;
- scale = gc*(1+el)/filter_ratio;
+ scale = SHL(MULT16_16(DIV32_16(SHL(gc,SIG_SHIFT-4),filter_ratio),(1+el)),4);
SUBMODE(innovation_unquant)(exc, SUBMODE(innovation_params), st->subframeSize,
bits, stack);
- signal_mul(exc,exc,SIG_SCALING*scale,st->subframeSize);
+ signal_mul(exc,exc,scale,st->subframeSize);
if (SUBMODE(double_codebook)) {
char *tmp_stack=stack;
@@ -1066,7 +1073,7 @@
SUBMODE(innovation_unquant)(innov2, SUBMODE(innovation_params), st->subframeSize,
bits, tmp_stack);
for (i=0;i<st->subframeSize;i++)
- innov2[i]*=scale*(1/2.5);
+ innov2[i]*=scale/(float)SIG_SCALING*(1/2.5);
for (i=0;i<st->subframeSize;i++)
exc[i] += innov2[i];
}
<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