From bb2dd9efd8e88a71882bb1fabe1dc5f8fa34afba Mon Sep 17 00:00:00 2001 From: "Ronald S. Bultje" Date: Wed, 21 Apr 2010 17:43:52 +0000 Subject: [PATCH] Split the input/output data arguments to ff_adaptive_gain_control(). Originally committed as revision 22932 to svn://svn.ffmpeg.org/ffmpeg/trunk --- libavcodec/acelp_vectors.c | 6 +++--- libavcodec/acelp_vectors.h | 5 +++-- libavcodec/amrnbdec.c | 2 +- libavcodec/sipr.c | 3 ++- 4 files changed, 9 insertions(+), 7 deletions(-) diff --git a/libavcodec/acelp_vectors.c b/libavcodec/acelp_vectors.c index a25011f4ff..e41e5facb6 100644 --- a/libavcodec/acelp_vectors.c +++ b/libavcodec/acelp_vectors.c @@ -207,11 +207,11 @@ void ff_weighted_vector_sumf(float *out, const float *in_a, const float *in_b, + weight_coeff_b * in_b[i]; } -void ff_adaptive_gain_control(float *buf_out, float speech_energ, +void ff_adaptive_gain_control(float *out, const float *in, float speech_energ, int size, float alpha, float *gain_mem) { int i; - float postfilter_energ = ff_dot_productf(buf_out, buf_out, size); + float postfilter_energ = ff_dot_productf(in, in, size); float gain_scale_factor = 1.0; float mem = *gain_mem; @@ -222,7 +222,7 @@ void ff_adaptive_gain_control(float *buf_out, float speech_energ, for (i = 0; i < size; i++) { mem = alpha * mem + gain_scale_factor; - buf_out[i] *= mem; + out[i] = in[i] * mem; } *gain_mem = mem; diff --git a/libavcodec/acelp_vectors.h b/libavcodec/acelp_vectors.h index 3e6652f377..ba3437fc10 100644 --- a/libavcodec/acelp_vectors.h +++ b/libavcodec/acelp_vectors.h @@ -214,13 +214,14 @@ void ff_weighted_vector_sumf(float *out, const float *in_a, const float *in_b, /** * Adaptive gain control (as used in AMR postfiltering) * - * @param buf_out the input speech buffer + * @param out output buffer for filtered speech data + * @param in the input speech buffer (may be the same as out) * @param speech_energ input energy * @param size the input buffer size * @param alpha exponential filter factor * @param gain_mem a pointer to the filter memory (single float of size) */ -void ff_adaptive_gain_control(float *buf_out, float speech_energ, +void ff_adaptive_gain_control(float *out, const float *in, float speech_energ, int size, float alpha, float *gain_mem); /** diff --git a/libavcodec/amrnbdec.c b/libavcodec/amrnbdec.c index 08ad9525c8..3e7515d0f1 100644 --- a/libavcodec/amrnbdec.c +++ b/libavcodec/amrnbdec.c @@ -943,7 +943,7 @@ static void postfilter(AMRContext *p, float *lpc, float *buf_out) ff_tilt_compensation(&p->tilt_mem, tilt_factor(lpc_n, lpc_d), buf_out, AMR_SUBFRAME_SIZE); - ff_adaptive_gain_control(buf_out, speech_gain, AMR_SUBFRAME_SIZE, + ff_adaptive_gain_control(buf_out, buf_out, speech_gain, AMR_SUBFRAME_SIZE, AMR_AGC_ALPHA, &p->postfilter_agc); } diff --git a/libavcodec/sipr.c b/libavcodec/sipr.c index fc19ecd710..5b7d87f14e 100644 --- a/libavcodec/sipr.c +++ b/libavcodec/sipr.c @@ -479,7 +479,8 @@ static void decode_frame(SiprContext *ctx, SiprParameters *params, float energy = ff_dot_productf(ctx->postfilter_syn5k0 + LP_FILTER_ORDER + i*SUBFR_SIZE, ctx->postfilter_syn5k0 + LP_FILTER_ORDER + i*SUBFR_SIZE, SUBFR_SIZE); - ff_adaptive_gain_control(&synth[i * SUBFR_SIZE], energy, + ff_adaptive_gain_control(&synth[i * SUBFR_SIZE], + &synth[i * SUBFR_SIZE], energy, SUBFR_SIZE, 0.9, &ctx->postfilter_agc); }