]> git.sesse.net Git - ffmpeg/blobdiff - libavcodec/fft-test.c
Merge remote-tracking branch 'qatar/master'
[ffmpeg] / libavcodec / fft-test.c
index 6b3880cf5d74bb4ec6f8f946821615254d8c7a4e..d9cd8bd1c7be6677b3d7949015e35b146802a481 100644 (file)
  * FFT and MDCT tests.
  */
 
+#include "libavutil/cpu.h"
 #include "libavutil/mathematics.h"
 #include "libavutil/lfg.h"
 #include "libavutil/log.h"
+#include "libavutil/time.h"
 #include "fft.h"
 #if CONFIG_FFT_FLOAT
 #include "dct.h"
 #include "rdft.h"
 #endif
 #include <math.h>
+#if HAVE_UNISTD_H
 #include <unistd.h>
-#include <sys/time.h>
+#endif
 #include <stdlib.h>
 #include <string.h>
 
@@ -185,13 +188,6 @@ static FFTSample frandom(AVLFG *prng)
     return (int16_t)av_lfg_get(prng) / 32768.0 * RANGE;
 }
 
-static int64_t gettime(void)
-{
-    struct timeval tv;
-    gettimeofday(&tv,NULL);
-    return (int64_t)tv.tv_sec * 1000000 + tv.tv_usec;
-}
-
 static int check_diff(FFTSample *tab1, FFTSample *tab2, int n, double scale)
 {
     int i;
@@ -235,11 +231,16 @@ enum tf_transform {
     TRANSFORM_DCT,
 };
 
+#if !HAVE_GETOPT
+#include "compat/getopt.c"
+#endif
+
 int main(int argc, char **argv)
 {
     FFTComplex *tab, *tab1, *tab_ref;
     FFTSample *tab2;
     int it, i, c;
+    int cpuflags;
     int do_speed = 0;
     int err = 1;
     enum tf_transform transform = TRANSFORM_FFT;
@@ -258,7 +259,7 @@ int main(int argc, char **argv)
 
     fft_nbits = 9;
     for(;;) {
-        c = getopt(argc, argv, "hsimrdn:f:");
+        c = getopt(argc, argv, "hsimrdn:f:c:");
         if (c == -1)
             break;
         switch(c) {
@@ -286,6 +287,12 @@ int main(int argc, char **argv)
         case 'f':
             scale = atof(optarg);
             break;
+        case 'c':
+            cpuflags = av_parse_cpu_flags(optarg);
+            if (cpuflags < 0)
+                return 1;
+            av_set_cpu_flags_mask(cpuflags);
+            break;
         }
     }
 
@@ -422,7 +429,7 @@ int main(int argc, char **argv)
         /* we measure during about 1 seconds */
         nb_its = 1;
         for(;;) {
-            time_start = gettime();
+            time_start = av_gettime();
             for (it = 0; it < nb_its; it++) {
                 switch (transform) {
                 case TRANSFORM_MDCT:
@@ -448,7 +455,7 @@ int main(int argc, char **argv)
 #endif
                 }
             }
-            duration = gettime() - time_start;
+            duration = av_gettime() - time_start;
             if (duration >= 1000000)
                 break;
             nb_its *= 2;