]> git.sesse.net Git - ffmpeg/blobdiff - libavcodec/celp_math.c
aarch64: vp9: Add NEON optimizations of VP9 MC functions
[ffmpeg] / libavcodec / celp_math.c
index a34508f85ca038b1c36460c59e52bf53be772707..8a788f58ec0863e46d9226df9caa72531d454a9a 100644 (file)
 
 #include "avcodec.h"
 #include "celp_math.h"
-#include "libavutil/common.h"
+#include "mathops.h"
 
-/**
- * Cosine table: base_cos[i] = (1<<15) * cos(i*PI/64)
- */
-static const int16_t tab_cos[65] =
-{
-  32767,  32738,  32617,  32421,  32145,  31793,  31364,  30860,
-  30280,  29629,  28905,  28113,  27252,  26326,  25336,  24285,
-  23176,  22011,  20793,  19525,  18210,  16851,  15451,  14014,
-  12543,  11043,   9515,   7965,   6395,   4810,   3214,   1609,
-      1,  -1607,  -3211,  -4808,  -6393,  -7962,  -9513, -11040,
- -12541, -14012, -15449, -16848, -18207, -19523, -20791, -22009,
- -23174, -24283, -25334, -26324, -27250, -28111, -28904, -29627,
- -30279, -30858, -31363, -31792, -32144, -32419, -32616, -32736, -32768,
-};
+#include "libavutil/common.h"
 
 static const uint16_t exp2a[]=
 {
@@ -59,16 +46,6 @@ static const uint16_t exp2b[]=
  17176, 17898, 18620, 19343, 20066, 20790, 21514, 22238,
 };
 
-int16_t ff_cos(uint16_t arg)
-{
-    uint8_t offset= arg;
-    uint8_t ind = arg >> 8;
-
-    assert(arg <= 0x3fff);
-
-    return tab_cos[ind] + (offset * (tab_cos[ind+1] - tab_cos[ind]) >> 8);
-}
-
 int ff_exp2(uint16_t power)
 {
     unsigned int result= exp2a[power>>10] + 0x10000;
@@ -92,7 +69,7 @@ static const uint16_t tab_log2[33] =
   26457,  27294,  28116,  28924,  29719,  30500,  31269,  32025,  32769,
 };
 
-int ff_log2(uint32_t value)
+int ff_log2_q15(uint32_t value)
 {
     uint8_t  power_int;
     uint8_t  frac_x0;
@@ -112,13 +89,13 @@ int ff_log2(uint32_t value)
     return (power_int << 15) + value;
 }
 
-float ff_dot_productf(const float* a, const float* b, int length)
+int64_t ff_dot_product(const int16_t *a, const int16_t *b, int length)
 {
-    float sum = 0;
     int i;
+    int64_t sum = 0;
 
-    for(i=0; i<length; i++)
-        sum += a[i] * b[i];
+    for (i = 0; i < length; i++)
+        sum += MUL16(a[i], b[i]);
 
     return sum;
 }