]> git.sesse.net Git - ffmpeg/blobdiff - libavcodec/fft-test.c
Merge remote-tracking branch 'qatar/master'
[ffmpeg] / libavcodec / fft-test.c
index d2bd0cfecb6893d371ebf374edacfa7597321436..d9cd8bd1c7be6677b3d7949015e35b146802a481 100644 (file)
 #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>
 
@@ -186,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;
@@ -236,6 +231,10 @@ enum tf_transform {
     TRANSFORM_DCT,
 };
 
+#if !HAVE_GETOPT
+#include "compat/getopt.c"
+#endif
+
 int main(int argc, char **argv)
 {
     FFTComplex *tab, *tab1, *tab_ref;
@@ -430,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:
@@ -456,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;