summaryrefslogtreecommitdiff
path: root/libavcodec/celp_math.c
diff options
context:
space:
mode:
authorMohamed Naufal Basheer <naufal11@gmail.com>2011-03-17 23:56:48 +0100
committerMichael Niedermayer <michaelni@gmx.at>2011-09-29 21:44:03 +0200
commita82c6238ae286c12318e5ad512107b86ec337369 (patch)
tree44ff0fe97f63a9312722cc62b6a054044ba5c62d /libavcodec/celp_math.c
parentbcc67dffa0e40602f2ce3240e831db173fe939a1 (diff)
downloadffmpeg-a82c6238ae286c12318e5ad512107b86ec337369.tar.gz
Add dot_product function for use by the G.723.1 decoder
Diffstat (limited to 'libavcodec/celp_math.c')
-rw-r--r--libavcodec/celp_math.c12
1 files changed, 12 insertions, 0 deletions
diff --git a/libavcodec/celp_math.c b/libavcodec/celp_math.c
index 09111da819..b78edd1ebd 100644
--- a/libavcodec/celp_math.c
+++ b/libavcodec/celp_math.c
@@ -25,6 +25,7 @@
#include <assert.h>
#include "avcodec.h"
+#include "mathops.h"
#include "celp_math.h"
#ifdef G729_BITEXACT
@@ -196,6 +197,17 @@ int ff_log2(uint32_t value)
return (power_int << 15) + value;
}
+int ff_dot_product(const int16_t *a, const int16_t *b, int length, int shift)
+{
+ int i, sum = 0;
+
+ for (i = 0; i < length; i++) {
+ int64_t prod = av_clipl_int32(MUL64(a[i], b[i]) << shift);
+ sum = av_clipl_int32(sum + prod);
+ }
+ return sum;
+}
+
float ff_dot_productf(const float* a, const float* b, int length)
{
float sum = 0;