Go to the documentation of this file.
27 # define _GNU_SOURCE // for syscall (performance monitoring API)
45 #if HAVE_SETCONSOLETEXTATTRIBUTE && HAVE_GETSTDHANDLE
47 #define COLOR_RED FOREGROUND_RED
48 #define COLOR_GREEN FOREGROUND_GREEN
49 #define COLOR_YELLOW (FOREGROUND_RED|FOREGROUND_GREEN)
53 #define COLOR_YELLOW 3
64 #if ARCH_ARM && HAVE_ARMV5TE_EXTERNAL
67 void (*checkasm_checked_call)(
void *
func,
int dummy, ...) = checkasm_checked_call_novfp;
76 #if CONFIG_AAC_DECODER
80 #if CONFIG_ALAC_DECODER
92 #if CONFIG_DCA_DECODER
95 #if CONFIG_EXR_DECODER
101 #if CONFIG_FMTCONVERT
116 #if CONFIG_HEVC_DECODER
121 #if CONFIG_HUFFYUV_DECODER
124 #if CONFIG_JPEG2000_DECODER
127 #if CONFIG_HUFFYUVDSP
130 #if CONFIG_LLVIDENCDSP
133 #if CONFIG_OPUS_DECODER
136 #if CONFIG_PIXBLOCKDSP
139 #if CONFIG_UTVIDEO_DECODER
142 #if CONFIG_V210_DECODER
145 #if CONFIG_V210_ENCODER
151 #if CONFIG_VP9_DECODER
159 #if CONFIG_AFIR_FILTER
162 #if CONFIG_BLEND_FILTER
165 #if CONFIG_COLORSPACE_FILTER
171 #if CONFIG_GBLUR_FILTER
174 #if CONFIG_HFLIP_FILTER
177 #if CONFIG_NLMEANS_FILTER
180 #if CONFIG_THRESHOLD_FILTER
196 static const struct {
296 if (llabs((int64_t)
x.i - y.
i) <= max_ulp)
307 for (
i = 0;
i <
len;
i++) {
316 float abs_diff = fabsf(
a -
b);
320 fprintf(stderr,
"test failed comparing %g with %g (abs diff=%g with EPS=%g)\n",
a,
b, abs_diff, eps);
330 for (
i = 0;
i <
len;
i++) {
343 unsigned max_ulp,
unsigned len)
347 for (
i = 0;
i <
len;
i++) {
356 double abs_diff = fabs(
a -
b);
358 return abs_diff < eps;
366 for (
i = 0;
i <
len;
i++) {
379 #if HAVE_SETCONSOLETEXTATTRIBUTE && HAVE_GETSTDHANDLE
381 static WORD org_attributes;
384 CONSOLE_SCREEN_BUFFER_INFO con_info;
385 con = GetStdHandle(STD_ERROR_HANDLE);
386 if (con && con != INVALID_HANDLE_VALUE && GetConsoleScreenBufferInfo(con, &con_info)) {
387 org_attributes = con_info.wAttributes;
393 SetConsoleTextAttribute(con, (org_attributes & 0xfff0) | (
color & 0x0f));
396 const char *term = getenv(
"TERM");
400 fprintf(stderr,
"\x1b[%d;3%dm", (
color & 0x08) >> 3,
color & 0x07);
404 vfprintf(stderr, fmt,
arg);
408 #if HAVE_SETCONSOLETEXTATTRIBUTE && HAVE_GETSTDHANDLE
409 SetConsoleTextAttribute(con, org_attributes);
411 fprintf(stderr,
"\x1b[0m");
436 void *ptr = calloc(1,
size);
438 fprintf(stderr,
"checkasm: malloc failed\n");
452 return cpus[
i].suffix;
459 return *(
const uint16_t*)
a - *(
const uint16_t*)
b;
465 uint16_t nops[10000];
470 for (
i = 0;
i < 10000;
i++) {
476 qsort(nops, 10000,
sizeof(uint16_t),
cmp_nop);
477 for (
i = 2500;
i < 7500;
i++)
480 return nop_sum / 500;
490 if (
f->versions.cpu ||
f->versions.next) {
498 }
while ((v = v->
next));
508 const char *start =
a;
509 int ascii_diff, digit_diff;
511 for (; !(ascii_diff = *(
const unsigned char*)
a - *(
const unsigned char*)
b) && *
a;
a++,
b++);
524 f->child[dir^1] =
r->child[dir];
531 #define is_red(f) ((f) && !(f)->color)
540 f->child[0]->color =
f->child[1]->color = 1;
561 if (!
f->versions.func)
566 int name_length = strlen(
name);
568 memcpy(
f->name,
name, name_length + 1);
577 int old_cpu_flag =
state.cpu_flag;
579 flag |= old_cpu_flag;
584 if (!
flag ||
state.cpu_flag != old_cpu_flag) {
600 if (
state.cpu_flag_name) {
606 #if CONFIG_LINUX_PERF
607 static int bench_init_linux(
void)
609 struct perf_event_attr attr = {
610 .type = PERF_TYPE_HARDWARE,
611 .size =
sizeof(
struct perf_event_attr),
612 .config = PERF_COUNT_HW_CPU_CYCLES,
618 printf(
"benchmarking with Linux Perf Monitoring API\n");
620 state.sysfd = syscall(__NR_perf_event_open, &attr, 0, -1, -1, 0);
621 if (
state.sysfd == -1) {
629 #if !CONFIG_LINUX_PERF
633 printf(
"benchmarking with native FFmpeg timers\n");
636 fprintf(stderr,
"checkasm: --bench is not supported on your system\n");
644 #if CONFIG_LINUX_PERF
645 int ret = bench_init_linux();
659 #if CONFIG_LINUX_PERF
665 int main(
int argc,
char *argv[])
670 #if ARCH_ARM && HAVE_ARMV5TE_EXTERNAL
672 checkasm_checked_call = checkasm_checked_call_vfp;
676 fprintf(stderr,
"checkasm: no tests to perform\n");
681 if (!strncmp(argv[1],
"--bench", 7)) {
684 if (argv[1][7] ==
'=') {
685 state.bench_pattern = argv[1] + 8;
686 state.bench_pattern_len = strlen(
state.bench_pattern);
688 state.bench_pattern =
"";
689 }
else if (!strncmp(argv[1],
"--test=", 7)) {
690 state.test_name = argv[1] + 7;
691 }
else if (!strcmp(argv[1],
"--verbose") || !strcmp(argv[1],
"-v")) {
701 fprintf(stderr,
"checkasm: using random seed %u\n",
seed);
708 if (
state.num_failed) {
709 fprintf(stderr,
"checkasm: %d of %d tests have failed\n",
state.num_failed,
state.num_checked);
712 fprintf(stderr,
"checkasm: all %d tests passed\n",
state.num_checked);
713 if (
state.bench_pattern) {
738 if (!
func || name_length <= 0 || name_length >=
sizeof(name_buf))
742 state.funcs->color = 1;
743 v = &
state.current_func->versions;
756 }
while ((v = v->
next));
764 state.current_func_ver = v;
775 return !
state.num_failed &&
state.bench_pattern &&
776 !strncmp(
state.current_func->name,
state.bench_pattern,
state.bench_pattern_len);
782 if (
state.current_func_ver->cpu &&
state.current_func_ver->ok) {
788 vfprintf(stderr, msg,
arg);
790 fprintf(stderr,
")\n");
792 state.current_func_ver->ok = 0;
801 memset(perf, 0,
sizeof(*perf));
809 static int prev_checked, prev_failed, max_length;
811 if (
state.num_checked > prev_checked) {
812 int pad_length = max_length + 4;
816 pad_length -= fprintf(stderr,
" - %s.",
state.current_test_name);
818 pad_length -= vfprintf(stderr,
name,
arg);
820 fprintf(stderr,
"%*c",
FFMAX(pad_length, 0) + 2,
'[');
822 if (
state.num_failed == prev_failed)
826 fprintf(stderr,
"]\n");
828 prev_checked =
state.num_checked;
829 prev_failed =
state.num_failed;
830 }
else if (!
state.cpu_flag) {
832 int length = strlen(
state.current_test_name);
839 if (length > max_length)
844 #define DEF_CHECKASM_CHECK_FUNC(type, fmt) \
845 int checkasm_check_##type(const char *const file, const int line, \
846 const type *buf1, ptrdiff_t stride1, \
847 const type *buf2, ptrdiff_t stride2, \
848 const int w, int h, const char *const name) \
851 stride1 /= sizeof(*buf1); \
852 stride2 /= sizeof(*buf2); \
853 for (y = 0; y < h; y++) \
854 if (memcmp(&buf1[y*stride1], &buf2[y*stride2], w*sizeof(*buf1))) \
858 checkasm_fail_func("%s:%d", file, line); \
859 if (!state.verbose) \
861 fprintf(stderr, "%s:\n", name); \
863 for (int x = 0; x < w; x++) \
864 fprintf(stderr, " " fmt, buf1[x]); \
865 fprintf(stderr, " "); \
866 for (int x = 0; x < w; x++) \
867 fprintf(stderr, " " fmt, buf2[x]); \
868 fprintf(stderr, " "); \
869 for (int x = 0; x < w; x++) \
870 fprintf(stderr, "%c", buf1[x] != buf2[x] ? 'x' : '.'); \
873 fprintf(stderr, "\n"); \
void checkasm_check_nlmeans(void)
void av_force_cpu_flags(int arg)
Disables cpu detection and forces the specified flags.
void checkasm_check_vp8dsp(void)
void checkasm_check_blockdsp(void)
#define AV_CPU_FLAG_SSE3
Prescott SSE3 functions.
static void destroy_func_tree(CheckasmFunc *f)
void checkasm_check_videodsp(void)
static int cmp_nop(const void *a, const void *b)
void checkasm_check_vf_eq(void)
av_cold void av_lfg_init(AVLFG *c, unsigned int seed)
#define u(width, name, range_min, range_max)
void checkasm_check_alacdsp(void)
void checkasm_check_v210dec(void)
int float_near_abs_eps_array(const float *a, const float *b, float eps, unsigned len)
#define AV_CPU_FLAG_SSE3SLOW
SSE3 supported, but usually not faster.
const char * bench_pattern
void checkasm_check_hevc_idct(void)
void checkasm_check_sw_scale(void)
struct CheckasmFunc * child[2]
void checkasm_check_afir(void)
static void print_cpu_name(void)
static const struct @312 tests[]
#define AV_CPU_FLAG_3DNOW
AMD 3DNOW.
int float_near_abs_eps(float a, float b, float eps)
void checkasm_check_aacpsdsp(void)
static void bench_uninit(void)
int av_get_cpu_flags(void)
Return the flags which specify extensions supported by the CPU.
static const char * cpu_suffix(int cpu)
void checkasm_check_llviddspenc(void)
void checkasm_check_h264dsp(void)
static void color_printf(int color, const char *fmt,...)
uint32_t av_get_random_seed(void)
Get a seed to use in conjunction with random functions.
int main(int argc, char *argv[])
#define AV_CPU_FLAG_SSSE3
Conroe SSSE3 functions.
int double_near_abs_eps(double a, double b, double eps)
const char * current_test_name
static CheckasmFunc * rotate_tree(CheckasmFunc *f, int dir)
#define AV_CPU_FLAG_XOP
Bulldozer XOP functions.
FFmpeg Automated Testing Environment ************************************Introduction Using FATE from your FFmpeg source directory Submitting the results to the FFmpeg result aggregation server Uploading new samples to the fate suite FATE makefile targets and variables Makefile targets Makefile variables Examples Introduction **************FATE is an extended regression suite on the client side and a means for results aggregation and presentation on the server side The first part of this document explains how you can use FATE from your FFmpeg source directory to test your ffmpeg binary The second part describes how you can run FATE to submit the results to FFmpeg’s FATE server In any way you can have a look at the publicly viewable FATE results by visiting this as it can be seen if some test on some platform broke with their recent contribution This usually happens on the platforms the developers could not test on The second part of this document describes how you can run FATE to submit your results to FFmpeg’s FATE server If you want to submit your results be sure to check that your combination of OS and compiler is not already listed on the above mentioned website In the third part you can find a comprehensive listing of FATE makefile targets and variables Using FATE from your FFmpeg source directory **********************************************If you want to run FATE on your machine you need to have the samples in place You can get the samples via the build target fate rsync Use this command from the top level source this will cause FATE to fail NOTE To use a custom wrapper to run the pass ‘ target exec’ to ‘configure’ or set the TARGET_EXEC Make variable Submitting the results to the FFmpeg result aggregation server ****************************************************************To submit your results to the server you should run fate through the shell script ‘tests fate sh’ from the FFmpeg sources This script needs to be invoked with a configuration file as its first argument tests fate sh path to fate_config A configuration file template with comments describing the individual configuration variables can be found at ‘doc fate_config sh template’ Create a configuration that suits your based on the configuration template The ‘slot’ configuration variable can be any string that is not yet but it is suggested that you name it adhering to the following pattern ‘ARCH OS COMPILER COMPILER VERSION’ The configuration file itself will be sourced in a shell therefore all shell features may be used This enables you to setup the environment as you need it for your build For your first test runs the ‘fate_recv’ variable should be empty or commented out This will run everything as normal except that it will omit the submission of the results to the server The following files should be present in $workdir as specified in the configuration it may help to try out the ‘ssh’ command with one or more ‘ v’ options You should get detailed output concerning your SSH configuration and the authentication process The only thing left is to automate the execution of the fate sh script and the synchronisation of the samples directory Uploading new samples to the fate suite *****************************************If you need a sample uploaded send a mail to samples request This is for developers who have an account on the fate suite server If you upload new please make sure they are as small as space on each network bandwidth and so on benefit from smaller test cases Also keep in mind older checkouts use existing sample that means in practice generally do not remove or overwrite files as it likely would break older checkouts or releases Also all needed samples for a commit should be ideally before the push If you need an account for frequently uploading samples or you wish to help others by doing that send a mail to ffmpeg devel rsync vauL Duo x
void checkasm_check_vp9dsp(void)
void checkasm_check_vf_threshold(void)
void checkasm_check_vf_gblur(void)
#define AV_CPU_FLAG_3DNOWEXT
AMD 3DNowExt.
int float_near_abs_eps_ulp(float a, float b, float eps, unsigned max_ulp)
#define AV_CPU_FLAG_VSX
ISA 2.06.
void checkasm_check_float_dsp(void)
#define AV_CPU_FLAG_AVX512
AVX-512 functions: requires OS support even if YMM/ZMM registers aren't used.
static int bench_init(void)
void checkasm_check_pixblockdsp(void)
void checkasm_report(const char *name,...)
static CheckasmFunc * get_func(CheckasmFunc **root, const char *name)
void checkasm_fail_func(const char *msg,...)
void checkasm_check_sw_rgb(void)
void checkasm_check_hevc_sao(void)
#define AV_CPU_FLAG_ARMV6
#define AV_CPU_FLAG_SSE4
Penryn SSE4.1 functions.
static av_always_inline int cmp(MpegEncContext *s, const int x, const int y, const int subx, const int suby, const int size, const int h, int ref_index, int src_index, me_cmp_func cmp_func, me_cmp_func chroma_cmp_func, const int flags)
compares a block (either a full macroblock or a partition thereof) against a proposed motion-compensa...
static int measure_nop_time(void)
int double_near_abs_eps_array(const double *a, const double *b, double eps, unsigned len)
void checkasm_check_fmtconvert(void)
#define AV_CPU_FLAG_CMOV
supports cmov instruction
#define AV_CPU_FLAG_ALTIVEC
standard
static void print_benchs(CheckasmFunc *f)
CheckasmFunc * current_func
#define AV_CPU_FLAG_SSE2
PIV SSE2 functions.
Context structure for the Lagged Fibonacci PRNG.
#define AV_CPU_FLAG_AVX
AVX functions: requires OS support even if YMM registers aren't used.
#define AV_CPU_FLAG_FMA4
Bulldozer FMA4 functions.
#define AV_CPU_FLAG_AVX2
AVX2 functions: requires OS support even if YMM registers aren't used.
void checkasm_check_llviddsp(void)
#define AV_CPU_FLAG_SSE2SLOW
SSE2 supported, but usually not faster.
#define DEF_CHECKASM_CHECK_FUNC(type, fmt)
printf("static const uint8_t my_array[100] = {\n")
void checkasm_check_h264pred(void)
static av_const int av_isdigit(int c)
Locale-independent conversion of ASCII isdigit.
#define AV_CPU_FLAG_FMA3
Haswell FMA3 functions.
The reader does not expect b to be semantically here and if the code is changed by maybe adding a a division or other the signedness will almost certainly be mistaken To avoid this confusion a new type was SUINT is the C unsigned type but it holds a signed int to use the same example SUINT a
void checkasm_check_huffyuvdsp(void)
int float_near_abs_eps_array_ulp(const float *a, const float *b, float eps, unsigned max_ulp, unsigned len)
CheckasmPerf * checkasm_get_perf_context(void)
void checkasm_check_fixed_dsp(void)
void checkasm_check_colorspace(void)
void checkasm_check_utvideodsp(void)
static int is_negative(union av_intfloat32 u)
void checkasm_check_audiodsp(void)
#define i(width, name, range_min, range_max)
void checkasm_check_flacdsp(void)
void * checkasm_check_func(void *func, const char *name,...)
#define AV_CPU_FLAG_SSE42
Nehalem SSE4.2 functions.
struct CheckasmFuncVersion * next
void checkasm_check_synth_filter(void)
static int cmp_func_names(const char *a, const char *b)
#define AV_CPU_FLAG_ARMV8
void checkasm_check_g722dsp(void)
#define AV_CPU_FLAG_ATOM
Atom processor, some SSSE3 instructions are slower.
void checkasm_check_vf_hflip(void)
void checkasm_check_blend(void)
#define AV_CPU_FLAG_VFPV3
void checkasm_check_bswapdsp(void)
#define FF_ARRAY_ELEMS(a)
#define AV_CPU_FLAG_ARMV5TE
#define AV_CPU_FLAG_MMX
standard MMX
static void * checkasm_malloc(size_t size)
typedef void(RENAME(mix_any_func_type))
void checkasm_check_h264qpel(void)
#define AV_CPU_FLAG_AESNI
Advanced Encryption Standard functions.
int checkasm_bench_func(void)
#define AV_CPU_FLAG_POWER8
ISA 2.07.
const char * cpu_flag_name
#define AV_CPU_FLAG_SSE
SSE functions.
static int ref[MAX_W *MAX_W]
int float_near_ulp_array(const float *a, const float *b, unsigned max_ulp, unsigned len)
#define AV_CPU_FLAG_MMXEXT
SSE integer functions or AMD MMX ext.
void checkasm_check_v210enc(void)
void checkasm_check_sbrdsp(void)
#define AV_CPU_FLAG_VFP_VM
VFPv2 vector mode, deprecated in ARMv7-A and unavailable in various CPUs implementations.
void checkasm_check_jpeg2000dsp(void)
void checkasm_check_hevc_add_res(void)
int float_near_ulp(float a, float b, unsigned max_ulp)
CheckasmFuncVersion * current_func_ver
static void check_cpu_flag(const char *name, int flag)
static int bench_init_ffmpeg(void)
CheckasmFuncVersion versions
void checkasm_check_exrdsp(void)
static void balance_tree(CheckasmFunc **root)
#define AV_CPU_FLAG_ARMV6T2
static const struct @313 cpus[]
void checkasm_check_opusdsp(void)