Showing the changes to libavutil/float_dsp.c (1 of 2 files). Show all
Unified · Split
| @@ -146,6 +146,12 @@ av_cold void avpriv_float_dsp_init(AVFloatDSPContext *fdsp, int bit_exact) · 145 unmodified lines | ||
| 146 | 146 | #include <stdint.h> |
| 147 | 147 | #include <stdlib.h> |
| 148 | 148 | #include <string.h> |
| 149 | +#if HAVE_UNISTD_H | |
| 150 | +#include <unistd.h> /* for getopt */ | |
| 151 | +#endif | |
| 152 | +#if !HAVE_GETOPT | |
| 153 | +#include "compat/getopt.c" | |
| 154 | +#endif | |
| 149 | 155 | |
| 150 | 156 | #include "common.h" |
| 151 | 157 | #include "cpu.h" |
| @@ -369,7 +375,7 @@ static int test_scalarproduct_float(AVFloatDSPContext *fdsp, AVFloatDSPContext * · 217 unmodified lines | ||
| 369 | 375 | |
| 370 | 376 | int main(int argc, char **argv) |
| 371 | 377 | { |
| 372 | − int ret = 0; | |
| 378 | + int ret = 0, seeded = 0; | |
| 373 | 379 | uint32_t seed; |
| 374 | 380 | AVFloatDSPContext fdsp, cdsp; |
| 375 | 381 | AVLFG lfg; |
| @@ -380,12 +386,31 @@ int main(int argc, char **argv) · 4 unmodified lines | ||
| 380 | 386 | LOCAL_ALIGNED(32, double, dbl_src0, [LEN]); |
| 381 | 387 | LOCAL_ALIGNED(32, double, dbl_src1, [LEN]); |
| 382 | 388 | |
| 383 | − if (argc > 2 && !strcmp(argv[1], "-s")) | |
| 384 | − seed = strtoul(argv[2], NULL, 10); | |
| 385 | − else | |
| 389 | + for (;;) { | |
| 390 | + int arg = getopt(argc, argv, "s:c:"); | |
| 391 | + if (arg == -1) | |
| 392 | + break; | |
| 393 | + switch (arg) { | |
| 394 | + case 's': | |
| 395 | + seed = strtoul(optarg, NULL, 10); | |
| 396 | + seeded = 1; | |
| 397 | + break; | |
| 398 | + case 'c': | |
| 399 | + { | |
| 400 | + int cpuflags = av_get_cpu_flags(); | |
| 401 | + | |
| 402 | + if (av_parse_cpu_caps(&cpuflags, optarg) < 0) | |
| 403 | + return 1; | |
| 404 | + | |
| 405 | + av_force_cpu_flags(cpuflags); | |
| 406 | + break; | |
| 407 | + } | |
| 408 | + } | |
| 409 | + } | |
| 410 | + if (!seeded) | |
| 386 | 411 | seed = av_get_random_seed(); |
| 387 | 412 | |
| 388 | − av_log(NULL, AV_LOG_INFO, "float_dsp-test: random seed %u\n", seed); | |
| 413 | + av_log(NULL, AV_LOG_INFO, "float_dsp-test: %s %u\n", seeded ? "seed" : "random seed", seed); | |
| 389 | 414 | |
| 390 | 415 | av_lfg_init(&lfg, seed); |
| 391 | 416 | |