aboutsummaryrefslogtreecommitdiffstats
path: root/libavcodec/acelp_vectors.c
diff options
context:
space:
mode:
authorVitor Sessak <vitor1001@gmail.com>2009-10-27 23:53:18 +0000
committerVitor Sessak <vitor1001@gmail.com>2009-10-27 23:53:18 +0000
commit504eee37debbf7ce6ec3b79ae8825727258c3fd7 (patch)
tree094306ce1889f1e9ddf817f67e6d86c681ed6aa4 /libavcodec/acelp_vectors.c
parent2be414c8dee911744268341b5bd94b9e6a96f67c (diff)
downloadandroid_external_ffmpeg-504eee37debbf7ce6ec3b79ae8825727258c3fd7.tar.gz
android_external_ffmpeg-504eee37debbf7ce6ec3b79ae8825727258c3fd7.tar.bz2
android_external_ffmpeg-504eee37debbf7ce6ec3b79ae8825727258c3fd7.zip
Commit some functions that are used by both SIPR and AMR.
Based on AMR SoC code by Robert Swain and Colin McQuillan. Originally committed as revision 20392 to svn://svn.ffmpeg.org/ffmpeg/trunk
Diffstat (limited to 'libavcodec/acelp_vectors.c')
-rw-r--r--libavcodec/acelp_vectors.c22
1 files changed, 22 insertions, 0 deletions
diff --git a/libavcodec/acelp_vectors.c b/libavcodec/acelp_vectors.c
index 5443006718..2d9aa1ad79 100644
--- a/libavcodec/acelp_vectors.c
+++ b/libavcodec/acelp_vectors.c
@@ -23,6 +23,7 @@
#include <inttypes.h>
#include "avcodec.h"
#include "acelp_vectors.h"
+#include "celp_math.h"
const uint8_t ff_fc_2pulses_9bits_track1[16] =
{
@@ -155,3 +156,24 @@ void ff_weighted_vector_sumf(float *out, const float *in_a, const float *in_b,
out[i] = weight_coeff_a * in_a[i]
+ weight_coeff_b * in_b[i];
}
+
+void ff_adaptative_gain_control(float *buf_out, float speech_energ,
+ int size, float alpha, float *gain_mem)
+{
+ int i;
+ float postfilter_energ = ff_dot_productf(buf_out, buf_out, size);
+ float gain_scale_factor = 1.0;
+ float mem = *gain_mem;
+
+ if (postfilter_energ)
+ gain_scale_factor = sqrt(speech_energ / postfilter_energ);
+
+ gain_scale_factor *= 1.0 - alpha;
+
+ for (i = 0; i < size; i++) {
+ mem = alpha * mem + gain_scale_factor;
+ buf_out[i] *= mem;
+ }
+
+ *gain_mem = mem;
+}