diff --git a/libcelt/bands.c b/libcelt/bands.c index 10d30d52..4032aa58 100644 --- a/libcelt/bands.c +++ b/libcelt/bands.c @@ -444,7 +444,7 @@ static void deinterleave_vector(celt_norm *X, int N0, int stride) RESTORE_STACK; } -static void haar1(celt_norm *X, int N0, int stride) +void haar1(celt_norm *X, int N0, int stride) { int i, j; N0 >>= 1; diff --git a/libcelt/bands.h b/libcelt/bands.h index 1764ccf9..cbf1b6a3 100644 --- a/libcelt/bands.h +++ b/libcelt/bands.h @@ -72,6 +72,8 @@ int folding_decision(const CELTMode *m, celt_norm *X, int *average, int *last_de void measure_norm_mse(const CELTMode *m, float *X, float *X0, float *bandE, float *bandE0, int M, int N, int C); #endif +void haar1(celt_norm *X, int N0, int stride); + /** Quantisation/encoding of the residual spectrum * @param m Mode data * @param X Residual (normalised) diff --git a/libcelt/celt.c b/libcelt/celt.c index 5c22d971..feaa480f 100644 --- a/libcelt/celt.c +++ b/libcelt/celt.c @@ -391,17 +391,17 @@ static const signed char tf_select_table[4][8] = { {0, -2, 0, -3, 2, 0, 1 -1}, }; -static int tf_analysis(celt_word16 *bandLogE, celt_word16 *oldBandE, int len, int C, int isTransient, int *tf_res, int nbCompressedBytes) +static int tf_analysis(const CELTMode *m, celt_word16 *bandLogE, celt_word16 *oldBandE, + int len, int C, int isTransient, int *tf_res, int nbCompressedBytes, celt_norm *X, int N0, int LM) { int i; - celt_word16 threshold; - VARDECL(celt_word16, metric); - celt_word32 average=0; - celt_word32 cost0; - celt_word32 cost1; + VARDECL(int, metric); + int cost0; + int cost1; VARDECL(int, path0); VARDECL(int, path1); - celt_word16 lambda; + VARDECL(celt_norm, tmp); + int lambda; int tf_select=0; SAVE_STACK; @@ -413,49 +413,75 @@ static int tf_analysis(celt_word16 *bandLogE, celt_word16 *oldBandE, int len, in return 0; } if (nbCompressedBytes<40) - lambda = QCONST16(5.f, DB_SHIFT); + lambda = 10; else if (nbCompressedBytes<60) - lambda = QCONST16(2.f, DB_SHIFT); + lambda = 4; else if (nbCompressedBytes<100) - lambda = QCONST16(1.f, DB_SHIFT); + lambda = 2; else - lambda = QCONST16(.5f, DB_SHIFT); + lambda = 1; - ALLOC(metric, len, celt_word16); + ALLOC(metric, len, int); + ALLOC(tmp, (m->eBands[len]-m->eBands[len-1])<eBands[i+1]-m->eBands[i])<eBands[i]<eBands[i]<>(LM-k), 1<<(LM-k)); + else + haar1(tmp, N>>k, 1< QCONST16(3.f,DB_SHIFT); - } else { - threshold = QCONST16(.5f,DB_SHIFT); - tf_select = average > QCONST16(1.f,DB_SHIFT); - } + /*printf("\n");*/ + /* FIXME: Figure out how to set this */ + tf_select = 1; + cost0 = 0; cost1 = lambda; /* Viterbi forward pass */ for (i=1;imode->nbEBands, int); /* Needs to be before coarse energy quantization because otherwise the energy gets modified */ - tf_select = tf_analysis(bandLogE, oldBandE, effEnd, C, isTransient, tf_res, nbAvailableBytes); + tf_select = tf_analysis(st->mode, bandLogE, oldBandE, effEnd, C, isTransient, tf_res, nbAvailableBytes, X, N, LM); for (i=effEnd;iend;i++) tf_res[i] = tf_res[effEnd-1];