From d830d089237e774bb06a542e7a5082ffe4fc079d Mon Sep 17 00:00:00 2001 From: Gregory Maxwell Date: Mon, 15 Aug 2011 16:05:40 -0400 Subject: [PATCH] Avoid passing 'resynth' argument since resynth is either !encode or it's always 1 if -DRESYNTH. --- libcelt/bands.c | 32 +++++++++++++++++++++----------- libcelt/bands.h | 2 +- libcelt/celt.c | 12 ++---------- libcelt/vq.c | 12 ++++++------ libcelt/vq.h | 2 +- 5 files changed, 31 insertions(+), 29 deletions(-) diff --git a/libcelt/bands.c b/libcelt/bands.c index 7cdfd178..d057c261 100644 --- a/libcelt/bands.c +++ b/libcelt/bands.c @@ -632,7 +632,7 @@ static int compute_qn(int N, int b, int offset, int pulse_cap, int stereo) in two and transmit the energy difference with the two half-bands. It can be called recursively so bands can end up being split in 8 parts. */ static unsigned quant_band(int encode, const CELTMode *m, int i, celt_norm *X, celt_norm *Y, - int N, int b, int spread, int B, int intensity, int tf_change, celt_norm *lowband, int resynth, ec_ctx *ec, + int N, int b, int spread, int B, int intensity, int tf_change, celt_norm *lowband, ec_ctx *ec, opus_int32 *remaining_bits, int LM, celt_norm *lowband_out, const celt_ener *bandE, int level, opus_uint32 *seed, opus_val16 gain, celt_norm *lowband_scratch, int fill) { @@ -651,6 +651,11 @@ static unsigned quant_band(int encode, const CELTMode *m, int i, celt_norm *X, c opus_val16 mid=0, side=0; int longBlocks; unsigned cm=0; +#ifdef RESYNTH + int resynth = 1; +#else + int resynth = !encode; +#endif longBlocks = B0==1; @@ -949,7 +954,7 @@ static unsigned quant_band(int encode, const CELTMode *m, int i, celt_norm *X, c sign = 1-2*sign; /* We use orig_fill here because we want to fold the side, but if itheta==16384, we'll have cleared the low bits of fill. */ - cm = quant_band(encode, m, i, x2, NULL, N, mbits, spread, B, intensity, tf_change, lowband, resynth, ec, remaining_bits, LM, lowband_out, NULL, level, seed, gain, lowband_scratch, orig_fill); + cm = quant_band(encode, m, i, x2, NULL, N, mbits, spread, B, intensity, tf_change, lowband, ec, remaining_bits, LM, lowband_out, NULL, level, seed, gain, lowband_scratch, orig_fill); /* We don't split N=2 bands, so cm is either 1 or 0 (for a fold-collapse), and there's no need to worry about mixing with the other channel. */ y2[0] = -sign*x2[1]; @@ -1005,7 +1010,7 @@ static unsigned quant_band(int encode, const CELTMode *m, int i, celt_norm *X, c /* In stereo mode, we do not apply a scaling to the mid because we need the normalized mid for folding later */ cm = quant_band(encode, m, i, X, NULL, N, mbits, spread, B, intensity, tf_change, - lowband, resynth, ec, remaining_bits, LM, next_lowband_out1, + lowband, ec, remaining_bits, LM, next_lowband_out1, NULL, next_level, seed, stereo ? Q15ONE : MULT16_16_P15(gain,mid), lowband_scratch, fill); rebalance = mbits - (rebalance-*remaining_bits); if (rebalance > 3<>B)<<(B0>>1&stereo-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_band(encode, m, i, Y, NULL, N, sbits, spread, B, intensity, tf_change, - next_lowband2, resynth, ec, remaining_bits, LM, NULL, + next_lowband2, ec, remaining_bits, LM, NULL, NULL, next_level, seed, MULT16_16_P15(gain,side), NULL, fill>>B)<<(B0>>1&stereo-1); rebalance = sbits - (rebalance-*remaining_bits); if (rebalance > 3<channels); const int C = CHANNELS(st->stream_channels); int LM, M; @@ -1231,12 +1230,6 @@ int celt_encode_with_ec_float(CELTEncoder * restrict st, const celt_sig * pcm, i RESTORE_STACK; } -#ifdef RESYNTH - resynth = 1; -#else - resynth = 0; -#endif - isTransient = 0; shortBlocks = 0; if (LM>0 && ec_tell(enc)+3<=total_bits) @@ -1534,7 +1527,7 @@ int celt_encode_with_ec_float(CELTEncoder * restrict st, const celt_sig * pcm, i /* Residual quantisation */ ALLOC(collapse_masks, C*st->mode->nbEBands, unsigned char); quant_all_bands(1, st->mode, st->start, st->end, X, C==2 ? X+N : NULL, collapse_masks, - bandE, pulses, shortBlocks, st->spread_decision, dual_stereo, intensity, tf_res, resynth, + bandE, pulses, shortBlocks, st->spread_decision, dual_stereo, intensity, tf_res, nbCompressedBytes*(8<rng); if (anti_collapse_rsv > 0) @@ -1555,7 +1548,6 @@ int celt_encode_with_ec_float(CELTEncoder * restrict st, const celt_sig * pcm, i #ifdef RESYNTH /* Re-synthesis of the coded audio if required */ - if (resynth) { celt_sig *out_mem[2]; celt_sig *overlap_mem[2]; @@ -2510,7 +2502,7 @@ int celt_decode_with_ec_float(CELTDecoder * restrict st, const unsigned char *da /* Decode fixed codebook */ ALLOC(collapse_masks, C*st->mode->nbEBands, unsigned char); quant_all_bands(0, st->mode, st->start, st->end, X, C==2 ? X+N : NULL, collapse_masks, - NULL, pulses, shortBlocks, spread_decision, dual_stereo, intensity, tf_res, 1, + NULL, pulses, shortBlocks, spread_decision, dual_stereo, intensity, tf_res, len*(8<rng); if (anti_collapse_rsv > 0) diff --git a/libcelt/vq.c b/libcelt/vq.c index 62d7fa18..05806ec3 100644 --- a/libcelt/vq.c +++ b/libcelt/vq.c @@ -167,7 +167,7 @@ static unsigned extract_collapse_mask(int *iy, int N, int B) } unsigned alg_quant(celt_norm *X, int N, int K, int spread, int B, - int resynth, ec_enc *enc, opus_val16 gain) + ec_enc *enc, opus_val16 gain) { VARDECL(celt_norm, y); VARDECL(int, iy); @@ -320,11 +320,11 @@ unsigned alg_quant(celt_norm *X, int N, int K, int spread, int B, } while (++j