From 8200b2d16cde223df0b18c26b9ca82d733c4ee45 Mon Sep 17 00:00:00 2001 From: Jean-Marc Valin Date: Fri, 15 Oct 2010 02:18:47 -0400 Subject: [PATCH] Modifying the L1 metric for tf analysis by merging together all frequencies. Still need to make it use the right channel in stereo. --- libcelt/celt.c | 62 ++++++++++++++++++++++++++++++++------------------ 1 file changed, 40 insertions(+), 22 deletions(-) diff --git a/libcelt/celt.c b/libcelt/celt.c index 2e002f1d..26bf0c44 100644 --- a/libcelt/celt.c +++ b/libcelt/celt.c @@ -423,6 +423,26 @@ static const signed char tf_select_table[4][8] = { {0, -2, 0, -3, 2, 0, 1 -1}, }; +celt_word32 l1_metric(const celt_norm *tmp, int N, int LM, int width) +{ + int i, j; + static const celt_word16 sqrtM_1[4] = {Q15ONE, QCONST16(0.70711f,15), QCONST16(0.5f,15), QCONST16(0.35355f,15)}; + celt_word32 L1; + celt_word16 bias; + L1=0; + for (i=0;i<1<>LM;j++) + L2 = MAC16_16(L2, tmp[(j<eBands[len]-m->eBands[len-1])<eBands[i+1]-m->eBands[i])<eBands[i]<eBands[i]<eBands[i]<>LM); best_L1 = L1; /*printf ("%f ", L1);*/ for (k=0;k>(LM-k), 1<<(LM-k)); else haar1(tmp, N>>k, 1<>LM); - /*printf ("%f ", L1);*/ if (L1 < best_L1) { best_L1 = L1; @@ -508,7 +526,7 @@ static int tf_analysis(const CELTMode *m, celt_word16 *bandLogE, celt_word16 *ol } /*printf("\n");*/ /* FIXME: Figure out how to set this */ - tf_select = 1; + tf_select = 0; cost0 = 0; cost1 = lambda; @@ -743,6 +761,12 @@ int celt_encode_with_ec_float(CELTEncoder * restrict st, const celt_sig * pcm, c /* Band normalisation */ normalise_bands(st->mode, freq, X, bandE, effEnd, C, M); + ALLOC(tf_res, st->mode->nbEBands, int); + /* Needs to be before coarse energy quantization because otherwise the energy gets modified */ + tf_select = tf_analysis(st->mode, bandLogE, oldBandE, effEnd, C, isTransient, tf_res, nbAvailableBytes, X, N, LM, &tf_sum); + for (i=effEnd;iend;i++) + tf_res[i] = tf_res[effEnd-1]; + NN = M*st->mode->eBands[effEnd]; if (shortBlocks && !transient_shift) { @@ -790,12 +814,6 @@ int celt_encode_with_ec_float(CELTEncoder * restrict st, const celt_sig * pcm, c mdct_shape(st->mode, X, mdct_weight_pos+1, M, N, mdct_weight_shift, effEnd, C, 0, M); } - ALLOC(tf_res, st->mode->nbEBands, int); - /* Needs to be before coarse energy quantization because otherwise the energy gets modified */ - tf_select = tf_analysis(st->mode, bandLogE, oldBandE, effEnd, C, isTransient, tf_res, nbAvailableBytes, X, N, LM, &tf_sum); - for (i=effEnd;iend;i++) - tf_res[i] = tf_res[effEnd-1]; - ALLOC(error, C*st->mode->nbEBands, celt_word16); quant_coarse_energy(st->mode, st->start, st->end, effEnd, bandLogE, oldBandE, nbCompressedBytes*8, st->mode->prob,