[xiph-commits] r12152 - trunk/speex/libspeex
jm at svn.xiph.org
jm at svn.xiph.org
Tue Nov 28 15:24:06 PST 2006
Author: jm
Date: 2006-11-28 15:24:02 -0800 (Tue, 28 Nov 2006)
New Revision: 12152
Modified:
trunk/speex/libspeex/filters.c
trunk/speex/libspeex/filters.h
trunk/speex/libspeex/sb_celp.c
trunk/speex/libspeex/sb_celp.h
Log:
Saved another 2kB from the decoder by converting high-band synthesis to
16-bit.
Modified: trunk/speex/libspeex/filters.c
===================================================================
--- trunk/speex/libspeex/filters.c 2006-11-28 14:56:27 UTC (rev 12151)
+++ trunk/speex/libspeex/filters.c 2006-11-28 23:24:02 UTC (rev 12152)
@@ -618,68 +618,12 @@
mem[i]=SHR16(xx[N-i-1],1);
}
-
-/* By segher */
-void fir_mem_up(const spx_sig_t *x, const spx_word16_t *a, spx_sig_t *y, int N, int M, spx_word32_t *mem, char *stack)
+void qmf_synth(const spx_word16_t *x1, const spx_word16_t *x2, const spx_word16_t *a, spx_word16_t *y, int N, int M, spx_word32_t *mem1, spx_word32_t *mem2, char *stack)
/* assumptions:
all odd x[i] are zero -- well, actually they are left out of the array now
N and M are multiples of 4 */
{
int i, j;
- VARDECL(spx_word16_t *xx);
-
- ALLOC(xx, M+N-1, spx_word16_t);
-
- for (i = 0; i < N/2; i++)
- xx[2*i] = PSHR32(x[N/2-1-i],SIG_SHIFT);
- for (i = 0; i < M - 1; i += 2)
- xx[N+i] = mem[i+1];
-
- for (i = 0; i < N; i += 4) {
- spx_sig_t y0, y1, y2, y3;
- spx_word16_t x0;
-
- y0 = y1 = y2 = y3 = 0;
- x0 = xx[N-4-i];
-
- for (j = 0; j < M; j += 4) {
- spx_word16_t x1;
- spx_word16_t a0, a1;
-
- a0 = a[j];
- a1 = a[j+1];
- x1 = xx[N-2+j-i];
-
- y0 = ADD32(y0,MULT16_16(a0, x1));
- y1 = ADD32(y1,MULT16_16(a1, x1));
- y2 = ADD32(y2,MULT16_16(a0, x0));
- y3 = ADD32(y3,MULT16_16(a1, x0));
-
- a0 = a[j+2];
- a1 = a[j+3];
- x0 = xx[N+j-i];
-
- y0 = ADD32(y0,MULT16_16(a0, x0));
- y1 = ADD32(y1,MULT16_16(a1, x0));
- y2 = ADD32(y2,MULT16_16(a0, x1));
- y3 = ADD32(y3,MULT16_16(a1, x1));
- }
- y[i] = SHR32(y0,1);
- y[i+1] = SHR32(y1,1);
- y[i+2] = SHR32(y2,1);
- y[i+3] = SHR32(y3,1);
- }
-
- for (i = 0; i < M - 1; i += 2)
- mem[i+1] = xx[i];
-}
-
-void qmf_synth(const spx_sig_t *x1, const spx_sig_t *x2, const spx_word16_t *a, spx_word16_t *y, int N, int M, spx_word32_t *mem1, spx_word32_t *mem2, char *stack)
- /* assumptions:
- all odd x[i] are zero -- well, actually they are left out of the array now
- N and M are multiples of 4 */
-{
- int i, j;
VARDECL(spx_word16_t *xx1);
VARDECL(spx_word16_t *xx2);
@@ -687,11 +631,11 @@
ALLOC(xx2, M+N-1, spx_word16_t);
for (i = 0; i < N/2; i++)
- xx1[2*i] = PSHR32(x1[N/2-1-i],SIG_SHIFT);
+ xx1[2*i] = x1[N/2-1-i];
for (i = 0; i < M - 1; i += 2)
xx1[N+i] = mem1[i+1];
for (i = 0; i < N/2; i++)
- xx2[2*i] = PSHR32(x2[N/2-1-i],SIG_SHIFT);
+ xx2[2*i] = x2[N/2-1-i];
for (i = 0; i < M - 1; i += 2)
xx2[N+i] = mem2[i+1];
Modified: trunk/speex/libspeex/filters.h
===================================================================
--- trunk/speex/libspeex/filters.h 2006-11-28 14:56:27 UTC (rev 12151)
+++ trunk/speex/libspeex/filters.h 2006-11-28 23:24:02 UTC (rev 12152)
@@ -59,8 +59,7 @@
void qmf_decomp(const spx_word16_t *xx, const spx_word16_t *aa, spx_sig_t *, spx_sig_t *y2, int N, int M, spx_word16_t *mem, char *stack);
-void fir_mem_up(const spx_sig_t *x, const spx_word16_t *a, spx_sig_t *y, int N, int M, spx_word32_t *mem, char *stack);
-void qmf_synth(const spx_sig_t *x1, const spx_sig_t *x2, const spx_word16_t *a, spx_word16_t *y, int N, int M, spx_word32_t *mem1, spx_word32_t *mem2, char *stack);
+void qmf_synth(const spx_word16_t *x1, const spx_word16_t *x2, const spx_word16_t *a, spx_word16_t *y, int N, int M, spx_word32_t *mem1, spx_word32_t *mem2, char *stack);
void filter_mem2(const spx_sig_t *x, const spx_coef_t *num, const spx_coef_t *den, spx_sig_t *y, int N, int ord, spx_mem_t *mem);
void fir_mem2(const spx_sig_t *x, const spx_coef_t *num, spx_sig_t *y, int N, int ord, spx_mem_t *mem);
Modified: trunk/speex/libspeex/sb_celp.c
===================================================================
--- trunk/speex/libspeex/sb_celp.c 2006-11-28 14:56:27 UTC (rev 12151)
+++ trunk/speex/libspeex/sb_celp.c 2006-11-28 23:24:02 UTC (rev 12152)
@@ -126,9 +126,6 @@
#ifdef FIXED_POINT
static const spx_word16_t h0[64] = {2, -7, -7, 18, 15, -39, -25, 75, 35, -130, -41, 212, 38, -327, -17, 483, -32, -689, 124, 956, -283, -1307, 543, 1780, -973, -2467, 1733, 3633, -3339, -6409, 9059, 30153, 30153, 9059, -6409, -3339, 3633, 1733, -2467, -973, 1780, 543, -1307, -283, 956, 124, -689, -32, 483, -17, -327, 38, 212, -41, -130, 35, 75, -25, -39, 15, 18, -7, -7, 2};
-static const spx_word16_t h1[64] = {2, 7, -7, -18, 15, 39, -25, -75, 35, 130, -41, -212, 38, 327, -17, -483, -32, 689, 124, -956, -283, 1307, 543, -1780, -973, 2467, 1733, -3633, -3339, 6409, 9059, -30153, 30153, -9059, -6409, 3339, 3633, -1733, -2467, 973, 1780, -543, -1307, 283, 956, -124, -689, 32, 483, 17, -327, -38, 212, 41, -130, -35, 75, 25, -39, -15, 18, 7, -7, -2};
-
-
#else
static const float h0[64] = {
3.596189e-05f, -0.0001123515f,
@@ -165,40 +162,6 @@
-0.0001123515f, 3.596189e-05f
};
-static const float h1[64] = {
- 3.596189e-05f, 0.0001123515f,
- -0.0001104587f, -0.0002790277f,
- 0.0002298438f, 0.0005953563f,
- -0.0003823631f, -0.00113826f,
- 0.0005308539f, 0.001986177f,
- -0.0006243724f, -0.003235877f,
- 0.0005743159f, 0.004989147f,
- -0.0002584767f, -0.007367171f,
- -0.0004857935f, 0.01050689f,
- 0.001894714f, -0.01459396f,
- -0.004313674f, 0.01994365f,
- 0.00828756f, -0.02716055f,
- -0.01485397f, 0.03764973f,
- 0.026447f, -0.05543245f,
- -0.05095487f, 0.09779096f,
- 0.1382363f, -0.4600981f,
- 0.4600981f, -0.1382363f,
- -0.09779096f, 0.05095487f,
- 0.05543245f, -0.026447f,
- -0.03764973f, 0.01485397f,
- 0.02716055f, -0.00828756f,
- -0.01994365f, 0.004313674f,
- 0.01459396f, -0.001894714f,
- -0.01050689f, 0.0004857935f,
- 0.007367171f, 0.0002584767f,
- -0.004989147f, -0.0005743159f,
- 0.003235877f, 0.0006243724f,
- -0.001986177f, -0.0005308539f,
- 0.00113826f, 0.0003823631f,
- -0.0005953563f, -0.0002298438f,
- 0.0002790277f, 0.0001104587f,
- -0.0001123515f, -3.596189e-05f
-};
#endif
extern const spx_word16_t lpc_window[];
@@ -842,9 +805,8 @@
st->first=1;
- st->x0d = (spx_sig_t*)speex_alloc((st->frame_size)*sizeof(spx_sig_t));
- st->x1d = (spx_sig_t*)speex_alloc((st->frame_size)*sizeof(spx_sig_t));
- st->high = (spx_sig_t*)speex_alloc((st->full_frame_size)*sizeof(spx_sig_t));
+ st->x0d = (spx_word16_t*)speex_alloc((st->frame_size)*sizeof(spx_word16_t));
+ st->high = (spx_word16_t*)speex_alloc((st->frame_size)*sizeof(spx_word16_t));
st->g0_mem = (spx_word32_t*)speex_alloc((QMF_ORDER)*sizeof(spx_word32_t));
st->g1_mem = (spx_word32_t*)speex_alloc((QMF_ORDER)*sizeof(spx_word32_t));
@@ -884,7 +846,6 @@
#endif
speex_free(st->x0d);
- speex_free(st->x1d);
speex_free(st->high);
speex_free(st->g0_mem);
speex_free(st->g1_mem);
@@ -927,10 +888,10 @@
}
for (i=0;i<st->frame_size;i++)
- st->high[i]=st->exc[i];
+ st->high[i]=EXTRACT16(PSHR32(st->exc[i],SIG_SHIFT));
- iir_mem2(st->high, st->interp_qlpc, st->high, st->frame_size, st->lpcSize,
- st->mem_sp);
+ iir_mem16(st->high, st->interp_qlpc, st->high, st->frame_size, st->lpcSize,
+ st->mem_sp, stack);
/* Reconstruct the original */
@@ -969,7 +930,7 @@
ret = speex_decode_native(st->st_low, bits, low);
for (i=0;i<st->frame_size;i++)
- st->x0d[i] = SHL32(EXTEND32(low[i]), SIG_SHIFT);
+ st->x0d[i] = low[i];
}
speex_decoder_ctl(st->st_low, SPEEX_GET_DTX_STATUS, &dtx);
@@ -1022,11 +983,13 @@
for (i=0;i<st->frame_size;i++)
st->exc[i]=VERY_SMALL;
+ for (i=0;i<st->frame_size;i++)
+ st->high[i]=VERY_SMALL;
st->first=1;
/* Final signal synthesis from excitation */
- iir_mem2(st->exc, st->interp_qlpc, st->high, st->frame_size, st->lpcSize, st->mem_sp);
+ iir_mem16(st->high, st->interp_qlpc, st->high, st->frame_size, st->lpcSize, st->mem_sp, stack);
qmf_synth(st->x0d, st->high, h0, out, st->full_frame_size, QMF_ORDER, st->g0_mem, st->g1_mem, stack);
@@ -1054,7 +1017,8 @@
for (sub=0;sub<st->nbSubframes;sub++)
{
- spx_sig_t *exc, *sp, *innov_save=NULL;
+ spx_sig_t *exc, *innov_save=NULL;
+ spx_word16_t *sp;
spx_word16_t filter_ratio;
spx_word16_t el=0;
int offset;
@@ -1184,9 +1148,9 @@
}
for (i=0;i<st->subframeSize;i++)
- sp[i]=st->excBuf[i];
- iir_mem2(sp, st->interp_qlpc, sp, st->subframeSize, st->lpcSize,
- st->mem_sp);
+ sp[i]=EXTRACT16(PSHR32(st->excBuf[i],SIG_SHIFT));
+ iir_mem16(sp, st->interp_qlpc, sp, st->subframeSize, st->lpcSize,
+ st->mem_sp, stack);
for (i=0;i<st->subframeSize;i++)
st->excBuf[i]=exc[i];
for (i=0;i<st->lpcSize;i++)
Modified: trunk/speex/libspeex/sb_celp.h
===================================================================
--- trunk/speex/libspeex/sb_celp.h 2006-11-28 14:56:27 UTC (rev 12151)
+++ trunk/speex/libspeex/sb_celp.h 2006-11-28 23:24:02 UTC (rev 12152)
@@ -124,8 +124,8 @@
int lpc_enh_enabled;
char *stack;
- spx_sig_t *x0d, *x1d;
- spx_sig_t *high;
+ spx_word16_t *x0d;
+ spx_word16_t *high;
spx_word32_t *g0_mem, *g1_mem;
spx_sig_t *exc;
More information about the commits
mailing list