summaryrefslogtreecommitdiff
path: root/libavcodec/acelp_math.h
diff options
context:
space:
mode:
authorMichael Niedermayer <michaelni@gmx.at>2008-07-03 11:50:44 +0000
committerMichael Niedermayer <michaelni@gmx.at>2008-07-03 11:50:44 +0000
commit2b150e9a0cb5ffabf771f9a48a3ab22e604b4db1 (patch)
treeaa0ef9755fe33220647a142418fd6e8de2cc41f9 /libavcodec/acelp_math.h
parent58cc7dd9fc30eb7fd5fb255b58c2ca6470b31dd0 (diff)
make sum_of_squares() more generic
Originally committed as revision 14056 to svn://svn.ffmpeg.org/ffmpeg/trunk
Diffstat (limited to 'libavcodec/acelp_math.h')
-rw-r--r--libavcodec/acelp_math.h16
1 files changed, 7 insertions, 9 deletions
diff --git a/libavcodec/acelp_math.h b/libavcodec/acelp_math.h
index e503df8984..6e1344b5bd 100644
--- a/libavcodec/acelp_math.h
+++ b/libavcodec/acelp_math.h
@@ -51,23 +51,21 @@ int ff_exp2(uint16_t power);
int ff_log2(uint32_t value);
/**
- * \brief Calculates sum of array element multiplications
- * \param speech input data array
+ * \brief Calculates the dot product
+ * \param a input data array
+ * \param b input data array
* \param length number of elements
- * \param offset offset for calculation of sum of s[i]*s[i+offset]
* \param shift right shift by this value will be done before multiplication
*
* \return sum of multiplications
- *
- * \note array must be at least length+offset long!
*/
-static int sum_of_squares(const int16_t* speech, int length, int offset, int shift)
+static int dot_product(const int16_t* a, const int16_t* b, int length, int shift)
{
- const int16_t* speech_end;
int sum = 0;
+ int i;
- for(speech_end=speech+length; speech<speech_end; speech++)
- sum += (speech[0] * speech[offset]) >> shift;
+ for(i=0; i<length; i++)
+ sum += (a[i] * b[i]) >> shift;
return sum;
}