From 617af25e5c652e0c7151f8d136371fb2f794bb70 Mon Sep 17 00:00:00 2001 From: Jean-Marc Valin Date: Fri, 23 Jul 2010 16:54:20 -0400 Subject: [PATCH] Cleaning up intra_decision() --- libcelt/celt.c | 2 +- libcelt/quant_bands.c | 16 +++++++++------- libcelt/quant_bands.h | 2 +- 3 files changed, 11 insertions(+), 9 deletions(-) diff --git a/libcelt/celt.c b/libcelt/celt.c index 8e9e4f61..3e3c0cb6 100644 --- a/libcelt/celt.c +++ b/libcelt/celt.c @@ -883,7 +883,7 @@ int celt_encode_with_ec_float(CELTEncoder * restrict st, const celt_sig * pcm, c /* Don't use intra energy when we're operating at low bit-rate */ intra_ener = st->force_intra || (!has_pitch && st->delayedIntra && nbAvailableBytes > st->end); - if (shortBlocks || intra_decision(bandLogE, st->oldBandE, effEnd)) + if (shortBlocks || intra_decision(bandLogE, st->oldBandE, st->start, effEnd, st->mode->nbEBands, C)) st->delayedIntra = 1; else st->delayedIntra = 0; diff --git a/libcelt/quant_bands.c b/libcelt/quant_bands.c index 9e452921..52f64106 100644 --- a/libcelt/quant_bands.c +++ b/libcelt/quant_bands.c @@ -53,17 +53,19 @@ static const celt_word16 pred_coef[4] = {29440, 26112, 21248, 16384}; static const celt_word16 pred_coef[4] = {29440/32768., 26112/32768., 21248/32768., 16384/32768.}; #endif -/* FIXME: Implement for stereo */ -int intra_decision(celt_word16 *eBands, celt_word16 *oldEBands, int len) +int intra_decision(celt_word16 *eBands, celt_word16 *oldEBands, int start, int end, int len, int C) { - int i; + int c, i; celt_word32 dist = 0; - for (i=0;i 2*len; + return SHR32(dist,2*DB_SHIFT) > 2*C*(end-start); } int *quant_prob_alloc(const CELTMode *m) diff --git a/libcelt/quant_bands.h b/libcelt/quant_bands.h index 722a5343..a90ec4fd 100644 --- a/libcelt/quant_bands.h +++ b/libcelt/quant_bands.h @@ -54,7 +54,7 @@ void quant_prob_free(int *freq); void compute_fine_allocation(const CELTMode *m, int *bits, int budget); -int intra_decision(celt_word16 *eBands, celt_word16 *oldEBands, int len); +int intra_decision(celt_word16 *eBands, celt_word16 *oldEBands, int start, int end, int len, int C); void quant_coarse_energy(const CELTMode *m, int start, int end, const celt_word16 *eBands, celt_word16 *oldEBands, int budget, int intra, int *prob, celt_word16 *error, ec_enc *enc, int _C, int LM, celt_word16 max_decay);