]> git.sesse.net Git - ffmpeg/blobdiff - libavcodec/dct-test.c
Merge remote-tracking branch 'qatar/master'
[ffmpeg] / libavcodec / dct-test.c
index f85bccb4206379f35174020f23eeda067e51986f..9ea8f099146c6fafc4b450730c876328d26b3fcb 100644 (file)
 #include <stdlib.h>
 #include <stdio.h>
 #include <string.h>
-#include <sys/time.h>
 #include <unistd.h>
 #include <math.h>
 
 #include "libavutil/cpu.h"
 #include "libavutil/common.h"
 #include "libavutil/lfg.h"
+#include "libavutil/time.h"
 
 #include "simple_idct.h"
 #include "aandcttab.h"
@@ -99,13 +99,14 @@ static const struct algo fdct_tab[] = {
     { 0 }
 };
 
-#if HAVE_MMX && HAVE_YASM
+#if ARCH_X86_64 && HAVE_MMX && HAVE_YASM
 void ff_prores_idct_put_10_sse2(uint16_t *dst, int linesize,
                                 DCTELEM *block, int16_t *qmat);
 
 static void ff_prores_idct_put_10_sse2_wrap(DCTELEM *dst){
-    int16_t qmat[64]; int i;
-    int16_t tmp[64];
+    DECLARE_ALIGNED(16, static int16_t, qmat)[64];
+    DECLARE_ALIGNED(16, static int16_t, tmp)[64];
+    int i;
 
     for(i=0; i<64; i++){
         qmat[i]=4;
@@ -162,13 +163,6 @@ static const struct algo idct_tab[] = {
 
 #define AANSCALE_BITS 12
 
-static int64_t gettime(void)
-{
-    struct timeval tv;
-    gettimeofday(&tv, NULL);
-    return (int64_t)tv.tv_sec * 1000000 + tv.tv_usec;
-}
-
 #define NB_ITS 20000
 #define NB_ITS_SPEED 50000
 
@@ -200,14 +194,6 @@ static void idct_mmx_init(void)
 DECLARE_ALIGNED(16, static DCTELEM, block)[64];
 DECLARE_ALIGNED(8,  static DCTELEM, block1)[64];
 
-static inline void mmx_emms(void)
-{
-#if HAVE_MMX
-    if (cpu_flags & AV_CPU_FLAG_MMX)
-        __asm__ volatile ("emms\n\t");
-#endif
-}
-
 static void init_block(DCTELEM block[64], int test, int is_idct, AVLFG *prng, int vals)
 {
     int i, j;
@@ -286,7 +272,7 @@ static int dct_error(const struct algo *dct, int test, int is_idct, int speed, c
         permute(block, block1, dct->format);
 
         dct->func(block);
-        mmx_emms();
+        emms_c();
 
         if (dct->format == SCALE_PERM) {
             for (i = 0; i < 64; i++) {
@@ -344,16 +330,16 @@ static int dct_error(const struct algo *dct, int test, int is_idct, int speed, c
     init_block(block, test, is_idct, &prng, vals);
     permute(block1, block, dct->format);
 
-    ti = gettime();
+    ti = av_gettime();
     it1 = 0;
     do {
         for (it = 0; it < NB_ITS_SPEED; it++) {
             memcpy(block, block1, sizeof(block));
             dct->func(block);
         }
-        mmx_emms();
+        emms_c();
         it1 += NB_ITS_SPEED;
-        ti1 = gettime() - ti;
+        ti1 = av_gettime() - ti;
     } while (ti1 < 1000000);
 
     printf("%s %s: %0.1f kdct/s\n", is_idct ? "IDCT" : "DCT", dct->name,
@@ -504,7 +490,7 @@ static void idct248_error(const char *name,
     if (!speed)
         return;
 
-    ti = gettime();
+    ti = av_gettime();
     it1 = 0;
     do {
         for (it = 0; it < NB_ITS_SPEED; it++) {
@@ -512,9 +498,9 @@ static void idct248_error(const char *name,
                 block[i] = block1[i];
             idct248_put(img_dest, 8, block);
         }
-        mmx_emms();
+        emms_c();
         it1 += NB_ITS_SPEED;
-        ti1 = gettime() - ti;
+        ti1 = av_gettime() - ti;
     } while (ti1 < 1000000);
 
     printf("%s %s: %0.1f kdct/s\n", 1 ? "IDCT248" : "DCT248", name,