[FFmpeg-cvslog] float_dsp-test: allow forcing cpuflags

James Almer git at videolan.org
Fri Oct 10 18:52:00 CEST 2014


ffmpeg | branch: master | James Almer <jamrial at gmail.com> | Fri Oct 10 02:18:14 2014 -0300| [5402d1bce5ee03e441fd314d516d0c0fda30bdfd] | committer: James Almer

float_dsp-test: allow forcing cpuflags

Reviewed-by: Michael Niedermayer <michaelni at gmx.at>
Signed-off-by: James Almer <jamrial at gmail.com>

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

 libavutil/float_dsp.c    |   35 ++++++++++++++++++++++++++++++-----
 tests/fate/libavutil.mak |    2 +-
 2 files changed, 31 insertions(+), 6 deletions(-)

diff --git a/libavutil/float_dsp.c b/libavutil/float_dsp.c
index 8ac7480..78de1a1 100644
--- a/libavutil/float_dsp.c
+++ b/libavutil/float_dsp.c
@@ -146,6 +146,12 @@ av_cold void avpriv_float_dsp_init(AVFloatDSPContext *fdsp, int bit_exact)
 #include <stdint.h>
 #include <stdlib.h>
 #include <string.h>
+#if HAVE_UNISTD_H
+#include <unistd.h> /* for getopt */
+#endif
+#if !HAVE_GETOPT
+#include "compat/getopt.c"
+#endif
 
 #include "common.h"
 #include "cpu.h"
@@ -369,7 +375,7 @@ static int test_scalarproduct_float(AVFloatDSPContext *fdsp, AVFloatDSPContext *
 
 int main(int argc, char **argv)
 {
-    int ret = 0;
+    int ret = 0, seeded = 0;
     uint32_t seed;
     AVFloatDSPContext fdsp, cdsp;
     AVLFG lfg;
@@ -380,12 +386,31 @@ int main(int argc, char **argv)
     LOCAL_ALIGNED(32, double, dbl_src0, [LEN]);
     LOCAL_ALIGNED(32, double, dbl_src1, [LEN]);
 
-    if (argc > 2 && !strcmp(argv[1], "-s"))
-        seed = strtoul(argv[2], NULL, 10);
-    else
+    for (;;) {
+        int arg = getopt(argc, argv, "s:c:");
+        if (arg == -1)
+            break;
+        switch (arg) {
+        case 's':
+            seed = strtoul(optarg, NULL, 10);
+            seeded = 1;
+            break;
+        case 'c':
+        {
+            int cpuflags = av_get_cpu_flags();
+
+            if (av_parse_cpu_caps(&cpuflags, optarg) < 0)
+                return 1;
+
+            av_force_cpu_flags(cpuflags);
+            break;
+        }
+        }
+    }
+    if (!seeded)
         seed = av_get_random_seed();
 
-    av_log(NULL, AV_LOG_INFO, "float_dsp-test: random seed %u\n", seed);
+    av_log(NULL, AV_LOG_INFO, "float_dsp-test: %s %u\n", seeded ? "seed" : "random seed", seed);
 
     av_lfg_init(&lfg, seed);
 
diff --git a/tests/fate/libavutil.mak b/tests/fate/libavutil.mak
index 579bdfb..4d1a038 100644
--- a/tests/fate/libavutil.mak
+++ b/tests/fate/libavutil.mak
@@ -53,7 +53,7 @@ fate-fifo: CMD = run libavutil/fifo-test
 
 FATE_LIBAVUTIL += fate-float-dsp
 fate-float-dsp: libavutil/float_dsp-test$(EXESUF)
-fate-float-dsp: CMD = run libavutil/float_dsp-test
+fate-float-dsp: CMD = run libavutil/float_dsp-test $(CPUFLAGS:%=-c%)
 fate-float-dsp: CMP = null
 fate-float-dsp: REF = /dev/null
 



More information about the ffmpeg-cvslog mailing list