avcodec/celp_math: Reuse ff_scalarproduct_float_c()
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
This commit is contained in:
parent
159b482835
commit
2c65d3be81
@ -24,6 +24,7 @@
|
||||
|
||||
#include "config.h"
|
||||
#include "libavutil/avassert.h"
|
||||
#include "libavutil/float_dsp.h"
|
||||
#include "libavutil/intmath.h"
|
||||
#include "mathops.h"
|
||||
#include "celp_math.h"
|
||||
@ -107,20 +108,9 @@ int64_t ff_dot_product(const int16_t *a, const int16_t *b, int length)
|
||||
return sum;
|
||||
}
|
||||
|
||||
float ff_dot_productf(const float* a, const float* b, int length)
|
||||
{
|
||||
float sum = 0;
|
||||
int i;
|
||||
|
||||
for(i=0; i<length; i++)
|
||||
sum += a[i] * b[i];
|
||||
|
||||
return sum;
|
||||
}
|
||||
|
||||
void ff_celp_math_init(CELPMContext *c)
|
||||
{
|
||||
c->dot_productf = ff_dot_productf;
|
||||
c->dot_productf = ff_scalarproduct_float_c;
|
||||
|
||||
#if HAVE_MIPSFPU
|
||||
ff_celp_math_init_mips(c);
|
||||
|
@ -84,14 +84,4 @@ static inline unsigned bidir_sal(unsigned value, int offset)
|
||||
else return value << offset;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the dot product.
|
||||
* @param a input data array
|
||||
* @param b input data array
|
||||
* @param length number of elements
|
||||
*
|
||||
* @return dot product = sum of elementwise products
|
||||
*/
|
||||
float ff_dot_productf(const float* a, const float* b, int length);
|
||||
|
||||
#endif /* AVCODEC_CELP_MATH_H */
|
||||
|
@ -16,8 +16,15 @@
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
|
||||
#include <math.h>
|
||||
#include <stdint.h>
|
||||
|
||||
#include "libavutil/avassert.h"
|
||||
#include "libavutil/float_dsp.h"
|
||||
#include "libavutil/libm.h"
|
||||
#include "libavcodec/celp_math.c"
|
||||
#include "libavutil/macros.h"
|
||||
|
||||
#include "libavcodec/celp_math.h"
|
||||
|
||||
static inline void IsAlmostEqual(float A, float B, float epsilon)
|
||||
{
|
||||
@ -36,7 +43,7 @@ int main(void)
|
||||
const int16_t i1[3] = {6, 7, 8};
|
||||
const int16_t i2[3] = {9, 10, 11};
|
||||
|
||||
float r = ff_dot_productf(f1, f2, FF_ARRAY_ELEMS(f1));
|
||||
float r = ff_scalarproduct_float_c(f1, f2, FF_ARRAY_ELEMS(f1));
|
||||
int64_t d = ff_dot_product(i1, i2, FF_ARRAY_ELEMS(i1));
|
||||
|
||||
IsAlmostEqual(16.94f, r, 0.000001f);
|
||||
|
Loading…
x
Reference in New Issue
Block a user