From 610d3b4cc5f47d8773cf8947827ebb34b5ff263d Mon Sep 17 00:00:00 2001 From: Michael Giacomelli Date: Sun, 8 Jul 2007 21:52:49 +0000 Subject: Merge bit reverse tables together. git-svn-id: svn://svn.rockbox.org/rockbox/trunk@13822 a1c6a512-1295-4272-9138-f99709370657 --- apps/codecs/libwma/wmadeci.c | 50 +++++++++++++++++++++++++++++--------------- 1 file changed, 33 insertions(+), 17 deletions(-) (limited to 'apps/codecs/libwma/wmadeci.c') diff --git a/apps/codecs/libwma/wmadeci.c b/apps/codecs/libwma/wmadeci.c index f018cfbc53..f296a516f8 100644 --- a/apps/codecs/libwma/wmadeci.c +++ b/apps/codecs/libwma/wmadeci.c @@ -118,7 +118,7 @@ FFTComplex *exparray[5]; //these are the fft uint16_t *revarray[5]; FFTComplex exptab0[512] IBSS_ATTR;//, exptab1[256], exptab2[128], exptab3[64], exptab4[32]; //folded these in! -uint16_t revtab0[1024], revtab1[512], revtab2[256], revtab3[128], revtab4[64]; +uint16_t revtab0[1024];//, revtab1[512], revtab2[256], revtab3[128], revtab4[64]; uint16_t *runtabarray[2], *levtabarray[2]; //these are VLC lookup tables @@ -142,7 +142,7 @@ static VLC_TYPE vlcbuf3[1536][2] IBSS_ATTR; //small so lets try iram */ int fft_inits(FFTContext *s, int nbits, int inverse) { - int i, j, m, n; + int i, n; fixed32 c1, s1; int s2; @@ -153,7 +153,9 @@ int fft_inits(FFTContext *s, int nbits, int inverse) //s->exptab = av_malloc((n >> 1) * sizeof(FFTComplex)); //if (!s->exptab) // goto fail; - s->revtab = revarray[10-nbits]; + + //s->revtab = revarray[10-nbits]; + //s->revtab = av_malloc(n * sizeof(uint16_t)); //if (!s->revtab) // goto fail; @@ -196,7 +198,7 @@ int fft_inits(FFTContext *s, int nbits, int inverse) /* compute bit reverse table */ - +/* for(i=0;irevtab[i]=m; - } + } */ return 0; //fail: // av_freep(&s->revtab); @@ -586,6 +588,7 @@ int ff_mdct_init(MDCTContext *s, int nbits, int inverse) } if (fft_inits(&s->fft, s->nbits - 2, inverse) < 0) goto fail; + return 0; fail: // av_freep(&s->tcos); @@ -605,11 +608,11 @@ void ff_imdct_calc(MDCTContext *s, FFTComplex *tmp) { int k, n8, n4, n2, n, j,scale; - const uint16_t *revtab = s->fft.revtab; const fixed32 *tcos = s->tcos; const fixed32 *tsin = s->tsin; const fixed32 *in1, *in2; FFTComplex *z = (FFTComplex *)tmp; + int revtabshift = 12 - s->nbits; n = 1 << s->nbits; @@ -624,7 +627,7 @@ void ff_imdct_calc(MDCTContext *s, for(k = 0; k < n4; k++) { - j=revtab[k]; + j=revtab0[k<block_len; bsize = s->frame_len_bits - s->block_len_bits; - vector_fmul_add_add(out, in, s->windows[bsize], - out, 0, block_len, 1); + vector_fmul_add_add(out, in, s->windows[bsize], block_len); } else { block_len = 1 << s->prev_block_len_bits; n = (s->block_len - block_len) / 2; bsize = s->frame_len_bits - s->prev_block_len_bits; - vector_fmul_add_add(out+n, in+n, s->windows[bsize], - out+n, 0, block_len, 1); + vector_fmul_add_add(out+n, in+n, s->windows[bsize], block_len); memcpy(out+n+block_len, in+n+block_len, n*sizeof(fixed32)); } @@ -795,7 +796,7 @@ static void init_coef_vlc(VLC *vlc, int wma_decode_init(WMADecodeContext* s, asf_waveformatex_t *wfx) { //WMADecodeContext *s = avctx->priv_data; - int i, flags1, flags2; + int i, m, j, flags1, flags2; fixed32 *window; uint8_t *extradata; fixed64 bps1; @@ -1068,11 +1069,13 @@ int wma_decode_init(WMADecodeContext* s, asf_waveformatex_t *wfx) } /* init MDCT */ + /*TODO: figure out how to fold this up into one array*/ tcosarray[0] = tcos0; tcosarray[1] = tcos1; tcosarray[2] = tcos2; tcosarray[3] = tcos3;tcosarray[4] = tcos4; tsinarray[0] = tsin0; tsinarray[1] = tsin1; tsinarray[2] = tsin2; tsinarray[3] = tsin3;tsinarray[4] = tsin4; + /*these are folded up now*/ exparray[0] = exptab0; //exparray[1] = exptab1; exparray[2] = exptab2; exparray[3] = exptab3; exparray[4] = exptab4; - revarray[0]=revtab0; revarray[1]=revtab1; revarray[2]=revtab2; revarray[3]=revtab3; revarray[4]=revtab4; + revarray[0]=revtab0; //revarray[1]=revtab1; revarray[2]=revtab2; revarray[3]=revtab3; revarray[4]=revtab4; s->mdct_tmp = mdct_tmp; /* temporary storage for imdct */ for(i = 0; i < s->nb_block_sizes; ++i) @@ -1080,6 +1083,19 @@ int wma_decode_init(WMADecodeContext* s, asf_waveformatex_t *wfx) ff_mdct_init(&s->mdct_ctx[i], s->frame_len_bits - i + 1, 1); } + /* init the MDCT bit reverse table here rather then in fft_init */ + + for(i=0;i<1024;i++) /*hard coded to a 2048 bit rotation*/ + { /*smaller sizes can reuse the largest*/ + m=0; + for(j=0;j<10;j++) + { + m |= ((i >> j) & 1) << (10-j-1); + } + + revtab0[i]=m; + } + /*ffmpeg uses malloc to only allocate as many window sizes as needed. However, we're really only interested in the worst case memory usage. * In the worst case you can have 5 window sizes, 128 doubling up 2048 * Smaller windows are handled differently. -- cgit v1.2.3