[xiph-commits] r11122 - trunk/speex/libspeex
jm at svn.xiph.org
jm at svn.xiph.org
Tue Apr 11 08:34:54 PDT 2006
Author: jm
Date: 2006-04-11 08:34:50 -0700 (Tue, 11 Apr 2006)
New Revision: 11122
Modified:
trunk/speex/libspeex/filters.c
trunk/speex/libspeex/filters.h
trunk/speex/libspeex/nb_celp.c
Log:
open-loop excitation gain computed in 16 bits
Modified: trunk/speex/libspeex/filters.c
===================================================================
--- trunk/speex/libspeex/filters.c 2006-04-11 14:03:45 UTC (rev 11121)
+++ trunk/speex/libspeex/filters.c 2006-04-11 15:34:50 UTC (rev 11122)
@@ -163,7 +163,25 @@
return EXTRACT16(PSHR32(SHL32(EXTEND32(spx_sqrt(1+DIV32(sum,len))),(sig_shift+3)),SIG_SHIFT));
}
+spx_word16_t compute_rms16(const spx_word16_t *x, int len)
+{
+ int i;
+ spx_word32_t sum=0;
+ spx_word16_t max_val=1;
+ for (i=0;i<len;i+=4)
+ {
+ spx_word32_t sum2=0;
+ sum2 = MAC16_16(sum2,x[i],x[i]);
+ sum2 = MAC16_16(sum2,x[i+1],x[i+1]);
+ sum2 = MAC16_16(sum2,x[i+2],x[i+2]);
+ sum2 = MAC16_16(sum2,x[i+3],x[i+3]);
+ sum = ADD32(sum,SHR32(sum2,6));
+ }
+
+ return SHL16(spx_sqrt(1+DIV32(sum,len)),3);
+}
+
#ifndef OVERRIDE_NORMALIZE16
int normalize16(const spx_sig_t *x, spx_word16_t *y, spx_sig_t max_scale, int len)
{
@@ -206,6 +224,10 @@
}
return sqrt(.1+sum/len);
}
+spx_word16_t compute_rms16(const spx_word16_t *x, int len)
+{
+ return compute_rms(x, len);
+}
#endif
@@ -384,13 +406,30 @@
#endif
#endif
+void fir_mem16(const spx_word16_t *x, const spx_coef_t *num, spx_word16_t *y, int N, int ord, spx_mem_t *mem)
+{
+ int i,j;
+ spx_word16_t xi,yi;
+ for (i=0;i<N;i++)
+ {
+ xi=x[i];
+ yi = EXTRACT16(SATURATE(ADD32(EXTEND32(x[i]),PSHR32(mem[0],LPC_SHIFT)),32767));
+ for (j=0;j<ord-1;j++)
+ {
+ mem[j] = MAC16_16(mem[j+1], num[j],xi);
+ }
+ mem[ord-1] = MULT16_16(num[ord-1],xi);
+ y[i] = yi;
+ }
+}
+
void syn_percep_zero(const spx_sig_t *xx, const spx_coef_t *ak, const spx_coef_t *awk1, const spx_coef_t *awk2, spx_sig_t *y, int N, int ord, char *stack)
{
int i;
@@ -698,14 +737,14 @@
if (corr_pitch>40)
{
for (i=0;i<nsf;i++)
- new_exc[i] = exc[i] + (.7*g1*gg1*iexc[i] + .3*g2*gg2*iexc[i+nsf]);
+ new_exc[i] = SHL32(exc[i] + (.7*g1*gg1*iexc[i] + .3*g2*gg2*iexc[i+nsf]),SIG_SHIFT);
} else {
for (i=0;i<nsf;i++)
- new_exc[i] = exc[i] + (.6*g1*gg1*iexc[i] + .6*g2*gg2*iexc[i+nsf]);
+ new_exc[i] = SHL32(exc[i] + (.6*g1*gg1*iexc[i] + .6*g2*gg2*iexc[i+nsf]),SIG_SHIFT);
}
- new_ener = compute_rms(new_exc, nsf);
+ new_ener = compute_rms16(new_exc, nsf);
old_ener = compute_rms(exc, nsf);
- ngain = old_ener/(1+new_ener);
+ ngain = old_ener/(1.+new_ener);
for (i=0;i<nsf;i++)
new_exc[i] *= ngain;
}
Modified: trunk/speex/libspeex/filters.h
===================================================================
--- trunk/speex/libspeex/filters.h 2006-04-11 14:03:45 UTC (rev 11121)
+++ trunk/speex/libspeex/filters.h 2006-04-11 15:34:50 UTC (rev 11122)
@@ -38,6 +38,7 @@
#include "misc.h"
spx_word16_t compute_rms(const spx_sig_t *x, int len);
+spx_word16_t compute_rms16(const spx_word16_t *x, int len);
void signal_mul(const spx_sig_t *x, spx_sig_t *y, spx_word32_t scale, int len);
void signal_div(const spx_sig_t *x, spx_sig_t *y, spx_word32_t scale, int len);
@@ -65,6 +66,7 @@
void filter_mem16(const spx_word16_t *x, const spx_coef_t *num, const spx_coef_t *den, spx_word16_t *y, int N, int ord, spx_mem_t *mem);
void iir_mem16(const spx_word16_t *x, const spx_coef_t *den, spx_word16_t *y, int N, int ord, spx_mem_t *mem);
+void fir_mem16(const spx_word16_t *x, const spx_coef_t *num, spx_word16_t *y, int N, int ord, spx_mem_t *mem);
/* Apply bandwidth expansion on LPC coef */
void bw_lpc(spx_word16_t , const spx_coef_t *lpc_in, spx_coef_t *lpc_out, int order);
@@ -80,7 +82,7 @@
#ifdef NEW_ENHANCER
void multicomb(
spx_sig_t *exc, /*decoded excitation*/
-spx_sig_t *new_exc, /*enhanced excitation*/
+spx_word16_t *new_exc, /*enhanced excitation*/
spx_coef_t *ak, /*LPC filter coefs*/
int p, /*LPC order*/
int nsf, /*sub-frame size*/
Modified: trunk/speex/libspeex/nb_celp.c
===================================================================
--- trunk/speex/libspeex/nb_celp.c 2006-04-11 14:03:45 UTC (rev 11121)
+++ trunk/speex/libspeex/nb_celp.c 2006-04-11 15:34:50 UTC (rev 11122)
@@ -404,12 +404,15 @@
ol_pitch=0;
ol_pitch_coef=0;
}
+
/*Compute "real" excitation*/
+ /* FIXME: Are we breaking aliasing rules? */
+ spx_word16_t *exc16_alias = (spx_word16_t*)st->exc;
for (i=0;i<st->windowSize-st->frameSize;i++)
- st->exc[i] = SHL32(st->winBuf[i],SIG_SHIFT);
+ exc16_alias[i] = st->winBuf[i];
for (;i<st->frameSize;i++)
- st->exc[i] = SHL32(in[i-st->windowSize+st->frameSize],SIG_SHIFT);
- fir_mem2(st->exc, st->interp_lpc, st->exc, st->frameSize, st->lpcSize, st->mem_exc);
+ exc16_alias[i] = in[i-st->windowSize+st->frameSize];
+ fir_mem16(exc16_alias, st->interp_lpc, exc16_alias, st->frameSize, st->lpcSize, st->mem_exc);
/* Compute open-loop excitation gain */
#ifdef EPIC_48K
@@ -431,7 +434,7 @@
} else {
#endif
- ol_gain = SHL32(EXTEND32(compute_rms(st->exc, st->frameSize)),SIG_SHIFT);
+ ol_gain = SHL32(EXTEND32(compute_rms16(exc16_alias, st->frameSize)),SIG_SHIFT);
#ifdef EPIC_48K
}
#endif
More information about the commits
mailing list