1
0
Fork 0
forked from len0rd/rockbox

Change decoder struct dynamic array members to static arrays sized based on current maximums. Move decoder state structs into IRAM for big speedups This means only one decoder can be instantiated at a time, but that should not be a problem. Tweak Makefile to use -O2 for Coldfire. Update SVN revision info to sync-time revision.

git-svn-id: svn://svn.rockbox.org/rockbox/trunk@15256 a1c6a512-1295-4272-9138-f99709370657
This commit is contained in:
Thom Johansen 2007-10-21 23:24:06 +00:00
parent 4f41af3740
commit 86a999c478
8 changed files with 51 additions and 34 deletions

View file

@ -14,7 +14,15 @@ ifdef APPEXTRA
INCLUDES += $(patsubst %,-I$(APPSDIR)/%,$(subst :, ,$(APPEXTRA))) INCLUDES += $(patsubst %,-I$(APPSDIR)/%,$(subst :, ,$(APPEXTRA)))
endif endif
SPEEXOPTS = -O -DHAVE_CONFIG_H SPEEXOPTS = -DHAVE_CONFIG_H
# We're faster on ARM-targets with -O1 instead of -O2
ifeq ($(CPU),arm)
SPEEXOPTS += -O
else
SPEEXOPTS += -O2
endif
CFLAGS = $(INCLUDES) $(GCCOPTS) $(TARGET_INC) $(SPEEXOPTS) $(TARGET) \ CFLAGS = $(INCLUDES) $(GCCOPTS) $(TARGET_INC) $(SPEEXOPTS) $(TARGET) \
$(EXTRA_DEFINES) -DMEM=${MEMORYSIZE} ${PROFILE_OPTS} -Wno-unused-parameter $(EXTRA_DEFINES) -DMEM=${MEMORYSIZE} ${PROFILE_OPTS} -Wno-unused-parameter

View file

@ -1,4 +1,4 @@
Library: libspeex-1.2beta2 (SVN version 12966) Library: libspeex-1.2beta2 (SVN version 14014)
Imported: 2007-03-12 by Dan Everton Imported: 2007-03-12 by Dan Everton

View file

@ -6,7 +6,7 @@
/* Make use of ARM4 assembly optimizations */ /* Make use of ARM4 assembly optimizations */
/* #undef ARM4_ASM */ /* #undef ARM4_ASM */
/* Make use of ARM5E assembly optimizations */ /* Make use of ARM4E assembly optimizations */
#if defined(CPU_ARM) #if defined(CPU_ARM)
#define ARM4_ASM #define ARM4_ASM
#endif #endif

View file

@ -1024,14 +1024,16 @@ int nb_encode(void *state, void *vin, SpeexBits *bits)
return 1; return 1;
} }
static DecState global_decstate IBSS_ATTR;
void *nb_decoder_init(const SpeexMode *m) void *nb_decoder_init(const SpeexMode *m)
{ {
DecState *st; DecState *st = &global_decstate;
const SpeexNBMode *mode; const SpeexNBMode *mode;
int i; int i;
mode=(const SpeexNBMode*)m->mode; mode=(const SpeexNBMode*)m->mode;
st = (DecState *)speex_alloc(sizeof(DecState)); /* st = (DecState *)speex_alloc(sizeof(DecState)); */
if (!st) if (!st)
return NULL; return NULL;
#if defined(VAR_ARRAYS) || defined (USE_ALLOCA) #if defined(VAR_ARRAYS) || defined (USE_ALLOCA)
@ -1062,15 +1064,15 @@ void *nb_decoder_init(const SpeexMode *m)
st->lpc_enh_enabled=1; st->lpc_enh_enabled=1;
st->excBuf = (spx_word16_t*)speex_alloc((st->frameSize + 2*st->max_pitch + st->subframeSize + 12)*sizeof(spx_word16_t)); /* st->excBuf = (spx_word16_t*)speex_alloc((st->frameSize + 2*st->max_pitch + st->subframeSize + 12)*sizeof(spx_word16_t)); */
st->exc = st->excBuf + 2*st->max_pitch + st->subframeSize + 6; st->exc = st->excBuf + 2*st->max_pitch + st->subframeSize + 6;
for (i=0;i<st->frameSize + st->max_pitch + 1;i++) for (i=0;i<st->frameSize + st->max_pitch + 1;i++)
st->excBuf[i]=0; st->excBuf[i]=0;
st->interp_qlpc = (spx_coef_t*)speex_alloc(st->lpcSize*sizeof(spx_coef_t)); /* st->interp_qlpc = (spx_coef_t*)speex_alloc(st->lpcSize*sizeof(spx_coef_t)); */
st->old_qlsp = (spx_lsp_t*)speex_alloc(st->lpcSize*sizeof(spx_lsp_t)); /* st->old_qlsp = (spx_lsp_t*)speex_alloc(st->lpcSize*sizeof(spx_lsp_t)); */
st->mem_sp = (spx_mem_t*)speex_alloc(st->lpcSize*sizeof(spx_mem_t)); /* st->mem_sp = (spx_mem_t*)speex_alloc(st->lpcSize*sizeof(spx_mem_t)); */
st->pi_gain = (spx_word32_t*)speex_alloc((st->nbSubframes)*sizeof(spx_word32_t)); /* st->pi_gain = (spx_word32_t*)speex_alloc((st->nbSubframes)*sizeof(spx_word32_t)); */
st->last_pitch = 40; st->last_pitch = 40;
st->count_lost=0; st->count_lost=0;
st->pitch_gain_buf[0] = st->pitch_gain_buf[1] = st->pitch_gain_buf[2] = 0; st->pitch_gain_buf[0] = st->pitch_gain_buf[1] = st->pitch_gain_buf[2] = 0;
@ -1105,7 +1107,7 @@ void nb_decoder_destroy(void *state)
#if !(defined(VAR_ARRAYS) || defined (USE_ALLOCA)) #if !(defined(VAR_ARRAYS) || defined (USE_ALLOCA))
speex_free_scratch(st->stack); speex_free_scratch(st->stack);
#endif #endif
/*
speex_free (st->excBuf); speex_free (st->excBuf);
speex_free (st->interp_qlpc); speex_free (st->interp_qlpc);
speex_free (st->old_qlsp); speex_free (st->old_qlsp);
@ -1113,6 +1115,7 @@ void nb_decoder_destroy(void *state)
speex_free (st->pi_gain); speex_free (st->pi_gain);
speex_free(state); speex_free(state);
*/
} }
#define median3(a, b, c) ((a) < (b) ? ((b) < (c) ? (b) : ((a) < (c) ? (c) : (a))) : ((c) < (b) ? (b) : ((c) < (a) ? (c) : (a)))) #define median3(a, b, c) ((a) < (b) ? ((b) < (c) ? (b) : ((a) < (c) ? (c) : (a))) : ((c) < (b) ? (b) : ((c) < (a) ? (c) : (a))))

View file

@ -141,13 +141,15 @@ typedef struct DecState {
spx_word16_t last_ol_gain; /**< Open-loop gain for previous frame */ spx_word16_t last_ol_gain; /**< Open-loop gain for previous frame */
char *stack; /**< Pseudo-stack allocation for temporary memory */ char *stack; /**< Pseudo-stack allocation for temporary memory */
spx_word16_t *excBuf; /**< Excitation buffer */ /* Size calculated from maximum values of frameSize, max_pitch and
* subframeSize, being respectively 320, 144 and 80 (for uwb) */
spx_word16_t excBuf[556]; /**< Excitation buffer */
spx_word16_t *exc; /**< Start of excitation frame */ spx_word16_t *exc; /**< Start of excitation frame */
spx_lsp_t *old_qlsp; /**< Quantized LSPs for previous frame */ spx_lsp_t old_qlsp[10]; /**< Quantized LSPs for previous frame */
spx_coef_t *interp_qlpc; /**< Interpolated quantized LPCs */ spx_coef_t interp_qlpc[10]; /**< Interpolated quantized LPCs */
spx_mem_t *mem_sp; /**< Filter memory for synthesis signal */ spx_mem_t mem_sp[10]; /**< Filter memory for synthesis signal */
spx_mem_t mem_hp[2]; /**< High-pass filter memory */ spx_mem_t mem_hp[2]; /**< High-pass filter memory */
spx_word32_t *pi_gain; /**< Gain of LPC filter at theta=pi (fe/2) */ spx_word32_t pi_gain[5]; /**< Gain of LPC filter at theta=pi (fe/2) */
spx_word16_t *innov_save; /** If non-NULL, innovation is copied here */ spx_word16_t *innov_save; /** If non-NULL, innovation is copied here */
spx_word16_t level; spx_word16_t level;

View file

@ -754,13 +754,14 @@ int sb_encode(void *state, void *vin, SpeexBits *bits)
static SBDecState global_decstate IBSS_ATTR;
void *sb_decoder_init(const SpeexMode *m) void *sb_decoder_init(const SpeexMode *m)
{ {
spx_int32_t tmp; spx_int32_t tmp;
SBDecState *st; SBDecState *st = &global_decstate;
const SpeexSBMode *mode; const SpeexSBMode *mode;
st = (SBDecState*)speex_alloc(sizeof(SBDecState)); /* st = (SBDecState*)speex_alloc(sizeof(SBDecState)); */
if (!st) if (!st)
return NULL; return NULL;
st->mode = m; st->mode = m;
@ -790,17 +791,17 @@ void *sb_decoder_init(const SpeexMode *m)
st->first=1; st->first=1;
st->g0_mem = (spx_word32_t*)speex_alloc((QMF_ORDER)*sizeof(spx_word32_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)); /* st->g1_mem = (spx_word32_t*)speex_alloc((QMF_ORDER)*sizeof(spx_word32_t)); */
st->excBuf = (spx_word16_t*)speex_alloc((st->subframeSize)*sizeof(spx_word16_t)); /* st->excBuf = (spx_word16_t*)speex_alloc((st->subframeSize)*sizeof(spx_word16_t)); */
st->old_qlsp = (spx_lsp_t*)speex_alloc((st->lpcSize)*sizeof(spx_lsp_t)); /* st->old_qlsp = (spx_lsp_t*)speex_alloc((st->lpcSize)*sizeof(spx_lsp_t)); */
st->interp_qlpc = (spx_coef_t*)speex_alloc(st->lpcSize*sizeof(spx_coef_t)); /* st->interp_qlpc = (spx_coef_t*)speex_alloc(st->lpcSize*sizeof(spx_coef_t)); */
st->pi_gain = (spx_word32_t*)speex_alloc((st->nbSubframes)*sizeof(spx_word32_t)); /* st->pi_gain = (spx_word32_t*)speex_alloc((st->nbSubframes)*sizeof(spx_word32_t)); */
st->exc_rms = (spx_word16_t*)speex_alloc((st->nbSubframes)*sizeof(spx_word16_t)); /*st->exc_rms = (spx_word16_t*)speex_alloc((st->nbSubframes)*sizeof(spx_word16_t)); */
st->mem_sp = (spx_mem_t*)speex_alloc((2*st->lpcSize)*sizeof(spx_mem_t)); /* st->mem_sp = (spx_mem_t*)speex_alloc((2*st->lpcSize)*sizeof(spx_mem_t)); */
st->innov_save = NULL; st->innov_save = NULL;
@ -822,7 +823,7 @@ void sb_decoder_destroy(void *state)
#if !(defined(VAR_ARRAYS) || defined (USE_ALLOCA)) #if !(defined(VAR_ARRAYS) || defined (USE_ALLOCA))
/*speex_free_scratch(st->stack);*/ /*speex_free_scratch(st->stack);*/
#endif #endif
/*
speex_free(st->g0_mem); speex_free(st->g0_mem);
speex_free(st->g1_mem); speex_free(st->g1_mem);
speex_free(st->excBuf); speex_free(st->excBuf);
@ -833,6 +834,7 @@ void sb_decoder_destroy(void *state)
speex_free(st->mem_sp); speex_free(st->mem_sp);
speex_free(state); speex_free(state);
*/
} }
static void sb_decode_lost(SBDecState *st, spx_word16_t *out, int dtx, char *stack) static void sb_decode_lost(SBDecState *st, spx_word16_t *out, int dtx, char *stack)

View file

@ -109,15 +109,15 @@ typedef struct SBDecState {
int lpc_enh_enabled; int lpc_enh_enabled;
char *stack; char *stack;
spx_word32_t *g0_mem, *g1_mem; spx_word32_t g0_mem[64], g1_mem[64];
spx_word16_t *excBuf; spx_word16_t excBuf[80];
spx_lsp_t *old_qlsp; spx_lsp_t old_qlsp[10];
spx_coef_t *interp_qlpc; spx_coef_t interp_qlpc[10];
spx_mem_t *mem_sp; spx_mem_t mem_sp[20];
spx_word32_t *pi_gain; spx_word32_t pi_gain[5];
spx_word16_t *exc_rms; spx_word16_t exc_rms[5];
spx_word16_t *innov_save; /** If non-NULL, innovation is copied here */ spx_word16_t *innov_save; /** If non-NULL, innovation is copied here */
spx_word16_t last_ener; spx_word16_t last_ener;

View file

@ -35,6 +35,8 @@
#ifndef STACK_ALLOC_H #ifndef STACK_ALLOC_H
#define STACK_ALLOC_H #define STACK_ALLOC_H
#include "config-speex.h"
#ifdef USE_ALLOCA #ifdef USE_ALLOCA
# ifdef WIN32 # ifdef WIN32
# include <malloc.h> # include <malloc.h>