From d23c2ad6403f8c5157b1b3260ce1bf8ad623f38e Mon Sep 17 00:00:00 2001 From: Jean-Marc Valin Date: Wed, 19 Dec 2012 12:39:29 -0500 Subject: more bands.c cleaning up --- celt/bands.c | 66 ++++++++++++++++++++++++------------------------------------ 1 file changed, 26 insertions(+), 40 deletions(-) diff --git a/celt/bands.c b/celt/bands.c index 89bfd457..a9331b78 100644 --- a/celt/bands.c +++ b/celt/bands.c @@ -886,6 +886,9 @@ static unsigned quant_partition(int encode, const CELTMode *m, int i, celt_norm int itheta; int qalloc; struct split_ctx ctx; + celt_norm *next_lowband2=NULL; + opus_int32 rebalance; + N >>= 1; Y = X+N; LM -= 1; @@ -908,9 +911,6 @@ static unsigned quant_partition(int encode, const CELTMode *m, int i, celt_norm side = (1.f/32768)*iside; #endif - celt_norm *next_lowband2=NULL; - opus_int32 rebalance; - /* Give more bits to low-energy MDCTs than they would otherwise deserve */ if (B0>1 && (itheta&0x3fff)) { @@ -931,31 +931,22 @@ static unsigned quant_partition(int encode, const CELTMode *m, int i, celt_norm rebalance = *remaining_bits; if (mbits >= sbits) { - /* In stereo mode, we do not apply a scaling to the mid because we need the normalized - mid for folding later */ cm = quant_partition(encode, m, i, X, N, mbits, spread, B, lowband, ec, remaining_bits, LM, seed, MULT16_16_P15(gain,mid), fill); rebalance = mbits - (rebalance-*remaining_bits); if (rebalance > 3<>B)<<(B0>>1); } else { - /* For a stereo split, the high bits of fill are always zero, so no - folding will be done to the side. */ cm = quant_partition(encode, m, i, Y, N, sbits, spread, B, next_lowband2, ec, remaining_bits, LM, seed, MULT16_16_P15(gain,side), fill>>B)<<(B0>>1); rebalance = sbits - (rebalance-*remaining_bits); if (rebalance > 3<= sbits) { /* In stereo mode, we do not apply a scaling to the mid because we need the normalized - mid for folding later */ + mid for folding later. */ cm = quant_band(encode, m, i, X, N, mbits, spread, B, tf_change, - lowband, ec, remaining_bits, LM, next_lowband_out1, + lowband, ec, remaining_bits, LM, lowband_out, seed, Q15ONE, lowband_scratch, fill); rebalance = mbits - (rebalance-*remaining_bits); if (rebalance > 3<>B); } else { /* For a stereo split, the high bits of fill are always zero, so no - folding will be done to the side. */ + folding will be done to the side. */ cm = quant_band(encode, m, i, Y, N, sbits, spread, B, tf_change, - next_lowband2, ec, remaining_bits, LM, NULL, + NULL, ec, remaining_bits, LM, NULL, seed, side, NULL, fill>>B); rebalance = sbits - (rebalance-*remaining_bits); if (rebalance > 3<nbEBands-1]-norm_offset), celt_norm); norm = _norm; norm2 = norm + M*eBands[m->nbEBands-1]-norm_offset; /* We can use the last band as scratch space because we don't need that - scratch space for the last band */ + scratch space for the last band. */ lowband_scratch = X_+M*eBands[m->nbEBands-1]; lowband_offset = 0; @@ -1417,7 +1403,7 @@ void quant_all_bands(int encode, const CELTMode *m, int start, int end, lowband_scratch = NULL; /* Get a conservative estimate of the collapse_mask's for the bands we're - going to be folding from. */ + going to be folding from. */ if (lowband_offset != 0 && (spread!=SPREAD_AGGRESSIVE || B>1 || tf_change<0)) { int fold_start; @@ -1436,7 +1422,7 @@ void quant_all_bands(int encode, const CELTMode *m, int start, int end, } while (++fold_i(N<