From 8299edfc0c34aaf91ef07bf2410ad15423bcaf96 Mon Sep 17 00:00:00 2001 From: Jean-Marc Valin Date: Wed, 10 Jan 2018 17:41:50 -0500 Subject: Scaling back the pitch filter when most of the energy is above 3.2 kHz That corresponds to the fundamental for the shortest pitch period allowed --- celt/celt.h | 1 + celt/celt_encoder.c | 9 ++++++--- 2 files changed, 7 insertions(+), 3 deletions(-) (limited to 'celt') diff --git a/celt/celt.h b/celt/celt.h index f73f29dd..ce8349cf 100644 --- a/celt/celt.h +++ b/celt/celt.h @@ -63,6 +63,7 @@ typedef struct { float music_prob_max; int bandwidth; float activity_probability; + float max_pitch_ratio; /* Store as Q6 char to save space. */ unsigned char leak_boost[LEAK_BANDS]; } AnalysisInfo; diff --git a/celt/celt_encoder.c b/celt/celt_encoder.c index cb415a6b..40657354 100644 --- a/celt/celt_encoder.c +++ b/celt/celt_encoder.c @@ -1109,7 +1109,7 @@ static opus_val16 dynalloc_analysis(const opus_val16 *bandLogE, const opus_val16 static int run_prefilter(CELTEncoder *st, celt_sig *in, celt_sig *prefilter_mem, int CC, int N, - int prefilter_tapset, int *pitch, opus_val16 *gain, int *qgain, int enabled, int nbAvailableBytes) + int prefilter_tapset, int *pitch, opus_val16 *gain, int *qgain, int enabled, int nbAvailableBytes, AnalysisInfo *analysis) { int c; VARDECL(celt_sig, _pre); @@ -1165,7 +1165,10 @@ static int run_prefilter(CELTEncoder *st, celt_sig *in, celt_sig *prefilter_mem, gain1 = 0; pitch_index = COMBFILTER_MINPERIOD; } - +#ifndef DISABLE_FLOAT_API + if (analysis->valid) + gain1 *= analysis->max_pitch_ratio; +#endif /* Gain threshold for enabling the prefilter/postfilter */ pf_threshold = QCONST16(.2f,15); @@ -1603,7 +1606,7 @@ int celt_encode_with_ec(CELTEncoder * OPUS_RESTRICT st, const opus_val16 * pcm, && st->complexity >= 5; prefilter_tapset = st->tapset_decision; - pf_on = run_prefilter(st, in, prefilter_mem, CC, N, prefilter_tapset, &pitch_index, &gain1, &qg, enabled, nbAvailableBytes); + pf_on = run_prefilter(st, in, prefilter_mem, CC, N, prefilter_tapset, &pitch_index, &gain1, &qg, enabled, nbAvailableBytes, &st->analysis); if ((gain1 > QCONST16(.4f,15) || st->prefilter_gain > QCONST16(.4f,15)) && (!st->analysis.valid || st->analysis.tonality > .3) && (pitch_index > 1.26*st->prefilter_period || pitch_index < .79*st->prefilter_period)) pitch_change = 1; -- cgit v1.2.3