[FFmpeg-cvslog] Add dot_product function for use by the G.723.1 decoder

Mohamed Naufal Basheer git at videolan.org
Thu Sep 29 22:09:46 CEST 2011


ffmpeg | branch: master | Mohamed Naufal Basheer <naufal11 at gmail.com> | Thu Mar 17 23:56:48 2011 +0100| [a82c6238ae286c12318e5ad512107b86ec337369] | committer: Michael Niedermayer

Add dot_product function for use by the G.723.1 decoder

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=a82c6238ae286c12318e5ad512107b86ec337369
---

 libavcodec/celp_math.c |   12 ++++++++++++
 libavcodec/celp_math.h |   11 +++++++++++
 2 files changed, 23 insertions(+), 0 deletions(-)

diff --git a/libavcodec/celp_math.c b/libavcodec/celp_math.c
index 09111da..b78edd1 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;
diff --git a/libavcodec/celp_math.h b/libavcodec/celp_math.h
index 4cf656f..476e668 100644
--- a/libavcodec/celp_math.h
+++ b/libavcodec/celp_math.h
@@ -64,6 +64,17 @@ static inline int bidir_sal(int value, int offset)
 }
 
 /**
+ * returns the dot product of 2 int16_t vectors.
+ * @param a input data array
+ * @param b input data array
+ * @param length number of elements
+ * @param shift the result is scaled by 2^shift
+ *
+ * @return dot product = sum of elementwise products
+ */
+int ff_dot_product(const int16_t *a, const int16_t *b, int length, int shift);
+
+/**
  * returns the dot product.
  * @param a input data array
  * @param b input data array



More information about the ffmpeg-cvslog mailing list