From f67b4476a03013733c89bfec2e1a7bbd45200c24 Mon Sep 17 00:00:00 2001 From: Jean-Marc Valin Date: Fri, 27 Aug 2010 01:32:40 -0400 Subject: [PATCH] More IMDCT de-uglification --- libcelt/celt.c | 38 +++++++++++++++++++------------------- libcelt/mdct.c | 2 +- 2 files changed, 20 insertions(+), 20 deletions(-) diff --git a/libcelt/celt.c b/libcelt/celt.c index 08850e13..84886963 100644 --- a/libcelt/celt.c +++ b/libcelt/celt.c @@ -353,52 +353,47 @@ static void compute_inv_mdcts(const CELTMode *mode, int shortBlocks, celt_sig *X int b; int N2 = N; int B = 1; - int n4offset=0; SAVE_STACK; - ALLOC(x, 2*N, celt_word32); + ALLOC(x, N+overlap, celt_word32); ALLOC(tmp, N, celt_word32); if (shortBlocks) { - /*lookup = &mode->mdct[0];*/ N2 = mode->shortMdctSize; B = shortBlocks; - n4offset = N4; } /* Prevents problems from the imdct doing the overlap-add */ - CELT_MEMSET(x+N4, 0, N2); + CELT_MEMSET(x, 0, overlap); for (b=0;bmdct, tmp, x+n4offset+N2*b, mode->window, overlap, shortBlocks ? mode->maxLM : mode->maxLM-LM); + clt_mdct_backward(&mode->mdct, tmp, x+N2*b, mode->window, overlap, shortBlocks ? mode->maxLM : mode->maxLM-LM); } if (transient_shift > 0) { #ifdef FIXED_POINT for (j=0;j<16;j++) - x[N4+transient_time+j-16] = MULT16_32_Q15(SHR16(Q15_ONE-transientWindow[j],transient_shift)+transientWindow[j], SHL32(x[N4+transient_time+j-16],transient_shift)); + x[transient_time+j-16] = MULT16_32_Q15(SHR16(Q15_ONE-transientWindow[j],transient_shift)+transientWindow[j], SHL32(x[N4+transient_time+j-16],transient_shift)); for (j=transient_time;jloss_count = 0; - if ((st->decode_mem!=NULL) && (st->out_mem[0]!=NULL) && (st->oldBandE!=NULL) && + if ((st->decode_mem[0]!=NULL) && (st->oldBandE!=NULL) && (st->lpc!=NULL)) { if (error) @@ -1540,6 +1535,7 @@ int celt_decode_with_ec_float(CELTDecoder * restrict st, const unsigned char *da VARDECL(int, offsets); VARDECL(int, fine_priority); VARDECL(int, tf_res); + celt_sig *out_syn[2]; int shortBlocks; int isTransient; @@ -1689,11 +1685,15 @@ int celt_decode_with_ec_float(CELTDecoder * restrict st, const unsigned char *da for (i=M*st->mode->eBands[effEnd];iout_mem[0]+MAX_PERIOD-N; + if (C==2) + out_syn[1] = st->out_mem[1]+MAX_PERIOD-N; + /* Compute inverse MDCTs */ compute_inv_mdcts(st->mode, shortBlocks, freq, transient_time, - transient_shift, st->out_mem, st->overlap_mem, C, LM); + transient_shift, out_syn, st->overlap_mem, C, LM); - deemphasis(st->out_mem, pcm, N, C, st->mode->preemph, st->preemph_memD); + deemphasis(out_syn, pcm, N, C, st->mode->preemph, st->preemph_memD); st->loss_count = 0; RESTORE_STACK; if (ec_dec_get_error(dec)) diff --git a/libcelt/mdct.c b/libcelt/mdct.c index a970d33f..e06f8a96 100644 --- a/libcelt/mdct.c +++ b/libcelt/mdct.c @@ -285,7 +285,7 @@ void clt_mdct_backward(const mdct_lookup *l, kiss_fft_scalar *in, kiss_fft_scala fp2 -= 2; } } - + out -= (N2-overlap)>>1; /* Mirror on both sides for TDAC */ { kiss_fft_scalar * restrict fp1 = f2+N4-1;