From 7e70bb74676934416722ee0a5d471c34d48d8b72 Mon Sep 17 00:00:00 2001 From: Jean-Marc Valin Date: Thu, 3 May 2012 13:06:09 -0400 Subject: Reverts the transient_analysis() changes from 4e8b9905 This was found to cause a quality regression (e.g. in the velvet sample) --- celt/celt.c | 108 ++++++++++++++++++++++-------------------------------------- 1 file changed, 40 insertions(+), 68 deletions(-) diff --git a/celt/celt.c b/celt/celt.c index 05497a10..621493a8 100644 --- a/celt/celt.c +++ b/celt/celt.c @@ -179,7 +179,6 @@ struct OpusCustomEncoder { int consec_transient; AnalysisInfo analysis; - opus_val32 transient_mem[8]; opus_val32 preemph_memE[2]; opus_val32 preemph_memD[2]; @@ -294,8 +293,7 @@ static inline opus_val16 SIG2WORD16(celt_sig x) } static int transient_analysis(const opus_val32 * restrict in, int len, int C, - int overlap, opus_val16 *tf_estimate, int *tf_chan, - AnalysisInfo *analysis, opus_val32 *transient_mem) + int overlap, opus_val16 *tf_estimate, int *tf_chan, AnalysisInfo *analysis) { int i; VARDECL(opus_val16, tmp); @@ -308,12 +306,9 @@ static int transient_analysis(const opus_val32 * restrict in, int len, int C, VARDECL(opus_val16, bins); opus_val16 T1, T2, T3, T4, T5; opus_val16 follower; - opus_val16 coef[2][4] = {{-QCONST16(1.99994f,14), QCONST16(1.f,14), -QCONST16(1.f ,14), QCONST16(.5f ,14)}, - {-QCONST16(1.9995f ,14), QCONST16(1.f,14), -QCONST16(1.88375f,14), QCONST16(.9025f,14)}}; - int filterID; int metric=0; int fmetric=0, bmetric=0; - int count1, count2, count3, count4, count5; + int count1, count2, count3, count4, count5;; SAVE_STACK; ALLOC(tmp, len, opus_val16); @@ -324,37 +319,31 @@ static int transient_analysis(const opus_val32 * restrict in, int len, int C, *tf_estimate = 0; tf_max = 0; - for (filterID=0;filterID<2;filterID++) - { for (c=0;c=0;i--) { - opus_val32 bin; - bin = SHL32(EXTEND32(bins[i]), 15); - follower = MAX16(bins[i], MULT16_16_P15(QCONST16(0.97f, 15), follower)); - if (bin < MULT16_16(T1, follower)) + follower = MAX16(bins[i], MULT16_16_Q15(QCONST16(0.97f, 15), follower)); + if (bins[i] < MULT16_16_Q15(T1, follower)) count1++; - if (bin < MULT16_16(T2, follower)) + if (bins[i] < MULT16_16_Q15(T2, follower)) count2++; - if (bin < MULT16_16(T3, follower)) + if (bins[i] < MULT16_16_Q15(T3, follower)) count3++; - if (bin < MULT16_16(T4, follower)) + if (bins[i] < MULT16_16_Q15(T4, follower)) count4++; - if (bin < MULT16_16(T5, follower)) + if (bins[i] < MULT16_16_Q15(T5, follower)) count5++; } bmetric = 5*count1 + 4*count2 + 3*count3 + 2*count4 + count5; metric = fmetric+bmetric; - /*if (metric>40)*/ - if (metric>30+20*MAX16(analysis->tonality, analysis->noisiness)) + //if (metric>40) + if (metric>20+50*MAX16(analysis->tonality, analysis->noisiness)) is_transient=1; if (metric>tf_max) @@ -431,18 +409,12 @@ static int transient_analysis(const opus_val32 * restrict in, int len, int C, tf_max = metric; } } - } -#ifdef FIXED_POINT - tf_max = IMIN(400, tf_max); - *tf_estimate = QCONST16(1.f, 14) + SHL16(celt_sqrt(MULT16_16(10476, MAX16(0, tf_max-30))), 3); -#else *tf_estimate = 1 + MIN16(1, sqrt(MAX16(0, tf_max-30))/20); -#endif RESTORE_STACK; #ifdef FUZZING is_transient = rand()&0x1; #endif - /*printf("%d %f %d %f %f ", is_transient, *tf_estimate, tf_max, analysis->tonality, analysis->noisiness);*/ + //printf("%d %f %f %f %f\n", is_transient, *tf_estimate, tf_max, analysis->tonality, analysis->noisiness); return is_transient; } @@ -1318,7 +1290,7 @@ int celt_encode_with_ec(CELTEncoder * restrict st, const opus_val16 * pcm, int f if (st->complexity > 1) { isTransient = transient_analysis(in, N+st->overlap, CC, - st->overlap, &tf_estimate, &tf_chan, &st->analysis, st->transient_mem); + st->overlap, &tf_estimate, &tf_chan, &st->analysis); if (isTransient) shortBlocks = M; } -- cgit v1.2.1