[FFmpeg-cvslog] avcodec/celp_math: Reuse ff_scalarproduct_float_c()

Andreas Rheinhardt git at videolan.org
Wed Apr 9 15:02:48 EEST 2025


ffmpeg | branch: master | Andreas Rheinhardt <andreas.rheinhardt at outlook.com> | Thu Apr  3 13:35:16 2025 +0200| [2c65d3be81a715a0da8eeee4f67a3a8f0dacc6c5] | committer: Andreas Rheinhardt

avcodec/celp_math: Reuse ff_scalarproduct_float_c()

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt at outlook.com>

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

 libavcodec/celp_math.c       | 14 ++------------
 libavcodec/celp_math.h       | 10 ----------
 libavcodec/tests/celp_math.c | 11 +++++++++--
 3 files changed, 11 insertions(+), 24 deletions(-)

diff --git a/libavcodec/celp_math.c b/libavcodec/celp_math.c
index a5fe7f2ea9..39220a883a 100644
--- a/libavcodec/celp_math.c
+++ b/libavcodec/celp_math.c
@@ -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);
diff --git a/libavcodec/celp_math.h b/libavcodec/celp_math.h
index 99a0470719..8228d560e0 100644
--- a/libavcodec/celp_math.h
+++ b/libavcodec/celp_math.h
@@ -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 */
diff --git a/libavcodec/tests/celp_math.c b/libavcodec/tests/celp_math.c
index 669ea70362..115817894f 100644
--- a/libavcodec/tests/celp_math.c
+++ b/libavcodec/tests/celp_math.c
@@ -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);



More information about the ffmpeg-cvslog mailing list