[FFmpeg-devel] [PATCH] split input and output parameters for ff_adaptive_gain_control

Ronald S. Bultje rsbultje
Sat Mar 27 17:13:22 CET 2010


Hi,

as per $subj.

Ronald
-------------- next part --------------
Index: ffmpeg-svn/libavcodec/acelp_vectors.c
===================================================================
--- ffmpeg-svn.orig/libavcodec/acelp_vectors.c	2010-03-27 10:48:32.000000000 -0400
+++ ffmpeg-svn/libavcodec/acelp_vectors.c	2010-03-27 11:44:02.000000000 -0400
@@ -207,11 +207,11 @@
                + 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 @@
 
     for (i = 0; i < size; i++) {
         mem = alpha * mem + gain_scale_factor;
-        buf_out[i] *= mem;
+        out[i] = in[i] * mem;
     }
 
     *gain_mem = mem;
Index: ffmpeg-svn/libavcodec/acelp_vectors.h
===================================================================
--- ffmpeg-svn.orig/libavcodec/acelp_vectors.h	2010-03-27 10:48:32.000000000 -0400
+++ ffmpeg-svn/libavcodec/acelp_vectors.h	2010-03-27 11:44:17.000000000 -0400
@@ -214,13 +214,14 @@
 /**
  * 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);
 
 /**
Index: ffmpeg-svn/libavcodec/amrnbdec.c
===================================================================
--- ffmpeg-svn.orig/libavcodec/amrnbdec.c	2010-03-27 11:47:42.000000000 -0400
+++ ffmpeg-svn/libavcodec/amrnbdec.c	2010-03-27 11:47:52.000000000 -0400
@@ -943,7 +943,7 @@
     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);
 }
 
Index: ffmpeg-svn/libavcodec/sipr.c
===================================================================
--- ffmpeg-svn.orig/libavcodec/sipr.c	2010-03-27 11:47:42.000000000 -0400
+++ ffmpeg-svn/libavcodec/sipr.c	2010-03-27 11:47:52.000000000 -0400
@@ -479,7 +479,8 @@
             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);
         }
 



More information about the ffmpeg-devel mailing list