Browse code

Split the input/output data arguments to ff_adaptive_gain_control().

Originally committed as revision 22932 to svn://svn.ffmpeg.org/ffmpeg/trunk

Ronald S. Bultje authored on 2010/04/22 02:43:52
Showing 4 changed files
... ...
@@ -207,11 +207,11 @@ void ff_weighted_vector_sumf(float *out, const float *in_a, const float *in_b,
207 207
                + weight_coeff_b * in_b[i];
208 208
 }
209 209
 
210
-void ff_adaptive_gain_control(float *buf_out, float speech_energ,
210
+void ff_adaptive_gain_control(float *out, const float *in, float speech_energ,
211 211
                               int size, float alpha, float *gain_mem)
212 212
 {
213 213
     int i;
214
-    float postfilter_energ = ff_dot_productf(buf_out, buf_out, size);
214
+    float postfilter_energ = ff_dot_productf(in, in, size);
215 215
     float gain_scale_factor = 1.0;
216 216
     float mem = *gain_mem;
217 217
 
... ...
@@ -222,7 +222,7 @@ void ff_adaptive_gain_control(float *buf_out, float speech_energ,
222 222
 
223 223
     for (i = 0; i < size; i++) {
224 224
         mem = alpha * mem + gain_scale_factor;
225
-        buf_out[i] *= mem;
225
+        out[i] = in[i] * mem;
226 226
     }
227 227
 
228 228
     *gain_mem = mem;
... ...
@@ -214,13 +214,14 @@ void ff_weighted_vector_sumf(float *out, const float *in_a, const float *in_b,
214 214
 /**
215 215
  * Adaptive gain control (as used in AMR postfiltering)
216 216
  *
217
- * @param buf_out the input speech buffer
217
+ * @param out output buffer for filtered speech data
218
+ * @param in the input speech buffer (may be the same as out)
218 219
  * @param speech_energ input energy
219 220
  * @param size the input buffer size
220 221
  * @param alpha exponential filter factor
221 222
  * @param gain_mem a pointer to the filter memory (single float of size)
222 223
  */
223
-void ff_adaptive_gain_control(float *buf_out, float speech_energ,
224
+void ff_adaptive_gain_control(float *out, const float *in, float speech_energ,
224 225
                               int size, float alpha, float *gain_mem);
225 226
 
226 227
 /**
... ...
@@ -943,7 +943,7 @@ static void postfilter(AMRContext *p, float *lpc, float *buf_out)
943 943
     ff_tilt_compensation(&p->tilt_mem, tilt_factor(lpc_n, lpc_d), buf_out,
944 944
                          AMR_SUBFRAME_SIZE);
945 945
 
946
-    ff_adaptive_gain_control(buf_out, speech_gain, AMR_SUBFRAME_SIZE,
946
+    ff_adaptive_gain_control(buf_out, buf_out, speech_gain, AMR_SUBFRAME_SIZE,
947 947
                              AMR_AGC_ALPHA, &p->postfilter_agc);
948 948
 }
949 949
 
... ...
@@ -479,7 +479,8 @@ static void decode_frame(SiprContext *ctx, SiprParameters *params,
479 479
             float energy = ff_dot_productf(ctx->postfilter_syn5k0 + LP_FILTER_ORDER + i*SUBFR_SIZE,
480 480
                                            ctx->postfilter_syn5k0 + LP_FILTER_ORDER + i*SUBFR_SIZE,
481 481
                                            SUBFR_SIZE);
482
-            ff_adaptive_gain_control(&synth[i * SUBFR_SIZE], energy,
482
+            ff_adaptive_gain_control(&synth[i * SUBFR_SIZE],
483
+                                     &synth[i * SUBFR_SIZE], energy,
483 484
                                      SUBFR_SIZE, 0.9, &ctx->postfilter_agc);
484 485
         }
485 486