FFmpeg
checkasm.c
Go to the documentation of this file.
1 /*
2  * Assembly testing and benchmarking tool
3  * Copyright (c) 2015 Henrik Gramner
4  * Copyright (c) 2008 Loren Merritt
5  *
6  * This file is part of FFmpeg.
7  *
8  * FFmpeg is free software; you can redistribute it and/or modify
9  * it under the terms of the GNU General Public License as published by
10  * the Free Software Foundation; either version 2 of the License, or
11  * (at your option) any later version.
12  *
13  * FFmpeg is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16  * GNU General Public License for more details.
17  *
18  * You should have received a copy of the GNU General Public License along
19  * with FFmpeg; if not, write to the Free Software Foundation, Inc.,
20  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
21  *
22  * Copyright © 2018, VideoLAN and dav1d authors
23  * Copyright © 2018, Two Orioles, LLC
24  * All rights reserved.
25  *
26  * Redistribution and use in source and binary forms, with or without
27  * modification, are permitted provided that the following conditions are met:
28  *
29  * 1. Redistributions of source code must retain the above copyright notice, this
30  * list of conditions and the following disclaimer.
31  *
32  * 2. Redistributions in binary form must reproduce the above copyright notice,
33  * this list of conditions and the following disclaimer in the documentation
34  * and/or other materials provided with the distribution.
35  *
36  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
37  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
38  * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
39  * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
40  * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
41  * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
42  * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
43  * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
44  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
45  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
46  */
47 
48 #include "config.h"
49 #include "config_components.h"
50 
51 #ifndef _GNU_SOURCE
52 # define _GNU_SOURCE // for syscall (performance monitoring API), strsignal()
53 #endif
54 
55 #include <signal.h>
56 #include <stdarg.h>
57 #include <stdio.h>
58 #include <stdlib.h>
59 #include <string.h>
60 #include "checkasm.h"
61 #include "libavutil/avassert.h"
62 #include "libavutil/common.h"
63 #include "libavutil/cpu.h"
64 #include "libavutil/intfloat.h"
65 #include "libavutil/random_seed.h"
66 
67 #if HAVE_IO_H
68 #include <io.h>
69 #endif
70 #if HAVE_PRCTL
71 #include <sys/prctl.h>
72 #endif
73 
74 #if defined(_WIN32) && !defined(SIGBUS)
75 /* non-standard, use the same value as mingw-w64 */
76 #define SIGBUS 10
77 #endif
78 
79 #if HAVE_SETCONSOLETEXTATTRIBUTE && HAVE_GETSTDHANDLE
80 #include <windows.h>
81 #define COLOR_RED FOREGROUND_RED
82 #define COLOR_GREEN FOREGROUND_GREEN
83 #define COLOR_YELLOW (FOREGROUND_RED|FOREGROUND_GREEN)
84 #else
85 #define COLOR_RED 1
86 #define COLOR_GREEN 2
87 #define COLOR_YELLOW 3
88 #endif
89 
90 #if HAVE_UNISTD_H
91 #include <unistd.h>
92 #endif
93 
94 #if !HAVE_ISATTY
95 #define isatty(fd) 1
96 #endif
97 
98 #if ARCH_AARCH64
99 #include "libavutil/aarch64/cpu.h"
100 #elif ARCH_RISCV
101 #include "libavutil/riscv/cpu.h"
102 #endif
103 
104 #if ARCH_ARM && HAVE_ARMV5TE_EXTERNAL
105 #include "libavutil/arm/cpu.h"
106 
107 void (*checkasm_checked_call)(void *func, int dummy, ...) = checkasm_checked_call_novfp;
108 #endif
109 
110 /* Trade-off between speed and accuracy */
111 uint64_t bench_runs = 1U << 10;
112 
113 /* List of tests to invoke */
114 static const struct {
115  const char *name;
116  void (*func)(void);
117 } tests[] = {
118  /* NOTE: When adding a new test to this list here, it also needs to be
119  * added in tests/fate/checkasm.mak, otherwise it doesn't get executed
120  * as part of "make fate" or "make fate-checkasm". */
121 #if CONFIG_AVCODEC
122  #if CONFIG_AAC_DECODER
123  { "aacpsdsp", checkasm_check_aacpsdsp },
124  { "sbrdsp", checkasm_check_sbrdsp },
125  #endif
126  #if CONFIG_AAC_ENCODER
127  { "aacencdsp", checkasm_check_aacencdsp },
128  #endif
129  #if CONFIG_AC3DSP
130  { "ac3dsp", checkasm_check_ac3dsp },
131  #endif
132  #if CONFIG_ALAC_DECODER
133  { "alacdsp", checkasm_check_alacdsp },
134  #endif
135  #if CONFIG_APV_DECODER
136  { "apv_dsp", checkasm_check_apv_dsp },
137  #endif
138  #if CONFIG_AUDIODSP
139  { "audiodsp", checkasm_check_audiodsp },
140  #endif
141  #if CONFIG_BLOCKDSP
142  { "blockdsp", checkasm_check_blockdsp },
143  #endif
144  #if CONFIG_BSWAPDSP
145  { "bswapdsp", checkasm_check_bswapdsp },
146  #endif
147  #if CONFIG_CAVS_DECODER
148  { "cavsdsp", checkasm_check_cavsdsp },
149  #endif
150  #if CONFIG_DCA_DECODER
151  { "dcadsp", checkasm_check_dcadsp },
152  { "synth_filter", checkasm_check_synth_filter },
153  #endif
154  #if CONFIG_DIRAC_DECODER
155  { "diracdsp", checkasm_check_diracdsp },
156  #endif
157  #if CONFIG_EXR_DECODER
158  { "exrdsp", checkasm_check_exrdsp },
159  #endif
160  #if CONFIG_FDCTDSP
161  { "fdctdsp", checkasm_check_fdctdsp },
162  #endif
163  #if CONFIG_FLAC_DECODER
164  { "flacdsp", checkasm_check_flacdsp },
165  #endif
166  #if CONFIG_FMTCONVERT
167  { "fmtconvert", checkasm_check_fmtconvert },
168  #endif
169  #if CONFIG_G722DSP
170  { "g722dsp", checkasm_check_g722dsp },
171  #endif
172  #if CONFIG_H263DSP
173  { "h263dsp", checkasm_check_h263dsp },
174  #endif
175  #if CONFIG_H264CHROMA
176  { "h264chroma", checkasm_check_h264chroma },
177  #endif
178  #if CONFIG_H264DSP
179  { "h264dsp", checkasm_check_h264dsp },
180  #endif
181  #if CONFIG_H264PRED
182  { "h264pred", checkasm_check_h264pred },
183  #endif
184  #if CONFIG_H264QPEL
185  { "h264qpel", checkasm_check_h264qpel },
186  #endif
187  #if CONFIG_HEVC_DECODER
188  { "hevc_add_res", checkasm_check_hevc_add_res },
189  { "hevc_deblock", checkasm_check_hevc_deblock },
190  { "hevc_dequant", checkasm_check_hevc_dequant },
191  { "hevc_idct", checkasm_check_hevc_idct },
192  { "hevc_pel", checkasm_check_hevc_pel },
193  { "hevc_pred", checkasm_check_hevc_pred },
194  { "hevc_sao", checkasm_check_hevc_sao },
195  #endif
196  #if CONFIG_HPELDSP
197  { "hpeldsp", checkasm_check_hpeldsp },
198  #endif
199  #if CONFIG_HUFFYUVDSP
200  { "huffyuvdsp", checkasm_check_huffyuvdsp },
201  #endif
202  #if CONFIG_HUFFYUVENCDSP
203  { "huffyuvencdsp", checkasm_check_huffyuvencdsp },
204  #endif
205  #if CONFIG_IDCTDSP
206  { "idctdsp", checkasm_check_idctdsp },
207  #endif
208  #if CONFIG_JPEG2000_DECODER
209  { "jpeg2000dsp", checkasm_check_jpeg2000dsp },
210  #endif
211  #if CONFIG_LLAUDDSP
212  { "llauddsp", checkasm_check_llauddsp },
213  #endif
214  #if CONFIG_HUFFYUVDSP
215  { "llviddsp", checkasm_check_llviddsp },
216  #endif
217  #if CONFIG_LLVIDENCDSP
218  { "llvidencdsp", checkasm_check_llvidencdsp },
219  #endif
220  #if CONFIG_LPC
221  { "lpc", checkasm_check_lpc },
222  #endif
223  #if CONFIG_ME_CMP
224  { "motion", checkasm_check_motion },
225  #endif
226  #if CONFIG_MPEG4_DECODER
227  { "mpeg4videodsp", checkasm_check_mpeg4videodsp },
228  #endif
229  #if CONFIG_MPEGVIDEO
230  { "mpegvideo_unquantize", checkasm_check_mpegvideo_unquantize },
231  #endif
232  #if CONFIG_MPEGVIDEOENCDSP
233  { "mpegvideoencdsp", checkasm_check_mpegvideoencdsp },
234  #endif
235  #if CONFIG_OPUS_DECODER
236  { "opusdsp", checkasm_check_opusdsp },
237  #endif
238  #if CONFIG_PIXBLOCKDSP
239  { "pixblockdsp", checkasm_check_pixblockdsp },
240  #endif
241  #if CONFIG_PNG_DECODER
242  { "png", checkasm_check_png },
243  #endif
244  #if CONFIG_QPELDSP
245  { "qpeldsp", checkasm_check_qpeldsp },
246  #endif
247  #if CONFIG_RV34DSP
248  { "rv34dsp", checkasm_check_rv34dsp },
249  #endif
250  #if CONFIG_RV40_DECODER
251  { "rv40dsp", checkasm_check_rv40dsp },
252  #endif
253  #if CONFIG_SBC_ENCODER
254  { "sbcdsp", checkasm_check_sbcdsp },
255  #endif
256  #if CONFIG_SNOW_DECODER
257  { "snowdsp", checkasm_check_snowdsp },
258  #endif
259  #if CONFIG_SVQ1_ENCODER
260  { "svq1enc", checkasm_check_svq1enc },
261  #endif
262  #if CONFIG_TAK_DECODER
263  { "takdsp", checkasm_check_takdsp },
264  #endif
265  #if CONFIG_UTVIDEO_DECODER
266  { "utvideodsp", checkasm_check_utvideodsp },
267  #endif
268  #if CONFIG_V210_DECODER
269  { "v210dec", checkasm_check_v210dec },
270  #endif
271  #if CONFIG_V210_ENCODER
272  { "v210enc", checkasm_check_v210enc },
273  #endif
274  #if CONFIG_VC1DSP
275  { "vc1dsp", checkasm_check_vc1dsp },
276  #endif
277  #if CONFIG_VP3DSP
278  { "vp3dsp", checkasm_check_vp3dsp },
279  #endif
280  #if CONFIG_VP6_DECODER
281  { "vp6dsp", checkasm_check_vp6dsp },
282  #endif
283  #if CONFIG_VP8DSP
284  { "vp8dsp", checkasm_check_vp8dsp },
285  #endif
286  #if CONFIG_VP9_DECODER
287  { "vp9dsp", checkasm_check_vp9dsp }, // all of the below
288  { "vp9_ipred", checkasm_check_vp9_ipred },
289  { "vp9_itxfm", checkasm_check_vp9_itxfm },
290  { "vp9_loopfilter", checkasm_check_vp9_loopfilter },
291  { "vp9_mc", checkasm_check_vp9_mc },
292  #endif
293  #if CONFIG_VIDEODSP
294  { "videodsp", checkasm_check_videodsp },
295  #endif
296  #if CONFIG_VORBIS_DECODER
297  { "vorbisdsp", checkasm_check_vorbisdsp },
298  #endif
299  #if CONFIG_VVC_DECODER
300  { "vvc_alf", checkasm_check_vvc_alf },
301  { "vvc_mc", checkasm_check_vvc_mc },
302  { "vvc_sao", checkasm_check_vvc_sao },
303  #endif
304 #endif
305 #if CONFIG_AVFILTER
306  #if CONFIG_SCENE_SAD
307  { "scene_sad", checkasm_check_scene_sad },
308  #endif
309  #if CONFIG_AFIR_FILTER
310  { "af_afir", checkasm_check_afir },
311  #endif
312  #if CONFIG_BLACKDETECT_FILTER
313  { "vf_blackdetect", checkasm_check_blackdetect },
314  #endif
315  #if CONFIG_BLEND_FILTER
316  { "vf_blend", checkasm_check_blend },
317  #endif
318  #if CONFIG_BWDIF_FILTER
319  { "vf_bwdif", checkasm_check_vf_bwdif },
320  #endif
321  #if CONFIG_COLORDETECT_FILTER
322  { "vf_colordetect", checkasm_check_colordetect },
323  #endif
324  #if CONFIG_COLORSPACE_FILTER
325  { "vf_colorspace", checkasm_check_colorspace },
326  #endif
327  #if CONFIG_EQ_FILTER
328  { "vf_eq", checkasm_check_vf_eq },
329  #endif
330  #if CONFIG_FSPP_FILTER
331  { "vf_fspp", checkasm_check_vf_fspp },
332  #endif
333  #if CONFIG_GBLUR_FILTER
334  { "vf_gblur", checkasm_check_vf_gblur },
335  #endif
336  #if CONFIG_HFLIP_FILTER
337  { "vf_hflip", checkasm_check_vf_hflip },
338  #endif
339  #if CONFIG_IDET_FILTER
340  { "vf_idet", checkasm_check_idet },
341  #endif
342  #if CONFIG_NLMEANS_FILTER
343  { "vf_nlmeans", checkasm_check_nlmeans },
344  #endif
345  #if CONFIG_PP7_FILTER
346  { "vf_pp7", checkasm_check_vf_pp7 },
347  #endif
348  #if CONFIG_THRESHOLD_FILTER
349  { "vf_threshold", checkasm_check_vf_threshold },
350  #endif
351  #if CONFIG_SOBEL_FILTER
352  { "vf_sobel", checkasm_check_vf_sobel },
353  #endif
354 #endif
355 #if CONFIG_SWSCALE
356  { "sw_gbrp", checkasm_check_sw_gbrp },
357  { "sw_range_convert", checkasm_check_sw_range_convert },
358  { "sw_rgb", checkasm_check_sw_rgb },
359  { "sw_scale", checkasm_check_sw_scale },
360  { "sw_xyz2rgb", checkasm_check_sw_xyz2rgb },
361  { "sw_yuv2rgb", checkasm_check_sw_yuv2rgb },
362  { "sw_yuv2yuv", checkasm_check_sw_yuv2yuv },
363  { "sw_ops", checkasm_check_sw_ops },
364 #endif
365 #if CONFIG_AVUTIL
366  { "aes", checkasm_check_aes },
367  { "crc", checkasm_check_crc },
368  { "fixed_dsp", checkasm_check_fixed_dsp },
369  { "float_dsp", checkasm_check_float_dsp },
370  { "lls", checkasm_check_lls },
371 #if CONFIG_PIXELUTILS
372  { "pixelutils",checkasm_check_pixelutils },
373 #endif
374  { "av_tx", checkasm_check_av_tx },
375 #endif
376  { NULL }
377  /* NOTE: When adding a new test to this list here, it also needs to be
378  * added in tests/fate/checkasm.mak, otherwise it doesn't get executed
379  * as part of "make fate" or "make fate-checkasm". */
380 };
381 
382 /* List of cpu flags to check */
383 static const struct {
384  const char *name;
385  const char *suffix;
386  int flag;
387 } cpus[] = {
388 #if ARCH_AARCH64
389  { "ARMV8", "armv8", AV_CPU_FLAG_ARMV8 },
390  { "NEON", "neon", AV_CPU_FLAG_NEON },
391  { "DOTPROD", "dotprod", AV_CPU_FLAG_DOTPROD },
392  { "I8MM", "i8mm", AV_CPU_FLAG_I8MM },
393  { "SVE", "sve", AV_CPU_FLAG_SVE },
394  { "SVE2", "sve2", AV_CPU_FLAG_SVE2 },
395  { "SME", "sme", AV_CPU_FLAG_SME },
396  { "SME-I16I64", "sme_i16i64", AV_CPU_FLAG_SME_I16I64 },
397  { "CRC", "crc", AV_CPU_FLAG_ARM_CRC },
398  { "SME2", "sme2", AV_CPU_FLAG_SME2 },
399  { "PMULL", "pmull_eor3", AV_CPU_FLAG_PMULL|AV_CPU_FLAG_EOR3 },
400 #elif ARCH_ARM
401  { "ARMV5TE", "armv5te", AV_CPU_FLAG_ARMV5TE },
402  { "ARMV6", "armv6", AV_CPU_FLAG_ARMV6 },
403  { "ARMV6T2", "armv6t2", AV_CPU_FLAG_ARMV6T2 },
404  { "VFP", "vfp", AV_CPU_FLAG_VFP },
405  { "VFP_VM", "vfp_vm", AV_CPU_FLAG_VFP_VM },
406  { "VFPV3", "vfp3", AV_CPU_FLAG_VFPV3 },
407  { "NEON", "neon", AV_CPU_FLAG_NEON },
408 #elif ARCH_PPC
409  { "ALTIVEC", "altivec", AV_CPU_FLAG_ALTIVEC },
410  { "VSX", "vsx", AV_CPU_FLAG_VSX },
411  { "POWER8", "power8", AV_CPU_FLAG_POWER8 },
412 #elif ARCH_RISCV
413  { "RVI", "rvi", AV_CPU_FLAG_RVI },
414  { "misaligned", "misaligned", AV_CPU_FLAG_RV_MISALIGNED },
415  { "RV_zbb", "rvb_b", AV_CPU_FLAG_RVB_BASIC },
416  { "RVB", "rvb", AV_CPU_FLAG_RVB },
417  { "RV_zve32x","rvv_i32", AV_CPU_FLAG_RVV_I32 },
418  { "RV_zve32f","rvv_f32", AV_CPU_FLAG_RVV_F32 },
419  { "RV_zve64x","rvv_i64", AV_CPU_FLAG_RVV_I64 },
420  { "RV_zve64d","rvv_f64", AV_CPU_FLAG_RVV_F64 },
421  { "RV_zvbb", "rv_zvbb", AV_CPU_FLAG_RV_ZVBB },
422 #elif ARCH_MIPS
423  { "MMI", "mmi", AV_CPU_FLAG_MMI },
424  { "MSA", "msa", AV_CPU_FLAG_MSA },
425 #elif ARCH_X86
426  { "MMX", "mmx", AV_CPU_FLAG_MMX|AV_CPU_FLAG_CMOV },
427  { "MMXEXT", "mmxext", AV_CPU_FLAG_MMXEXT },
428  { "SSE", "sse", AV_CPU_FLAG_SSE },
429  { "SSE2", "sse2", AV_CPU_FLAG_SSE2|AV_CPU_FLAG_SSE2SLOW },
430  { "SSE3", "sse3", AV_CPU_FLAG_SSE3|AV_CPU_FLAG_SSE3SLOW },
431  { "SSSE3", "ssse3", AV_CPU_FLAG_SSSE3|AV_CPU_FLAG_ATOM },
432  { "SSE4.1", "sse4", AV_CPU_FLAG_SSE4 },
433  { "SSE4.2", "sse42", AV_CPU_FLAG_SSE42 },
434  { "AES-NI", "aesni", AV_CPU_FLAG_AESNI },
435  { "CLMUL", "clmul", AV_CPU_FLAG_CLMUL },
436  { "AVX", "avx", AV_CPU_FLAG_AVX },
437  { "XOP", "xop", AV_CPU_FLAG_XOP },
438  { "FMA3", "fma3", AV_CPU_FLAG_FMA3 },
439  { "FMA4", "fma4", AV_CPU_FLAG_FMA4 },
440  { "AVX2", "avx2", AV_CPU_FLAG_AVX2 },
441  { "AVX-512", "avx512", AV_CPU_FLAG_AVX512 },
442  { "AVX-512ICL", "avx512icl", AV_CPU_FLAG_AVX512ICL },
443 #elif ARCH_LOONGARCH
444  { "LSX", "lsx", AV_CPU_FLAG_LSX },
445  { "LASX", "lasx", AV_CPU_FLAG_LASX },
446 #elif ARCH_WASM
447  { "SIMD128", "simd128", AV_CPU_FLAG_SIMD128 },
448 #endif
449  { NULL }
450 };
451 
452 typedef struct CheckasmFuncVersion {
454  void *func;
455  int ok;
456  int cpu;
459 
460 /* Binary search tree node */
461 typedef struct CheckasmFunc {
462  struct CheckasmFunc *child[2];
464  uint8_t color; /* 0 = red, 1 = black */
465  char name[1];
466 } CheckasmFunc;
467 
468 /* Internal state */
469 static struct {
473  const char *current_test_name;
474  const char *bench_pattern;
478 
479  /* perf */
480  int nop_time;
481  int sysfd;
482 
483  int cpu_flag;
484  const char *cpu_flag_name;
485  const char *test_pattern;
486  int verbose;
487  int csv;
488  int tsv;
489  volatile sig_atomic_t catch_signals;
490 } state;
491 
492 /* PRNG state */
494 
495 /* float compare support code */
496 static int is_negative(union av_intfloat32 u)
497 {
498  return u.i >> 31;
499 }
500 
501 int float_near_ulp(float a, float b, unsigned max_ulp)
502 {
503  union av_intfloat32 x, y;
504 
505  x.f = a;
506  y.f = b;
507 
508  if (is_negative(x) != is_negative(y)) {
509  // handle -0.0 == +0.0
510  return a == b;
511  }
512 
513  if (llabs((int64_t)x.i - y.i) <= max_ulp)
514  return 1;
515 
516  return 0;
517 }
518 
519 int float_near_ulp_array(const float *a, const float *b, unsigned max_ulp,
520  unsigned len)
521 {
522  unsigned i;
523 
524  for (i = 0; i < len; i++) {
525  if (!float_near_ulp(a[i], b[i], max_ulp))
526  return 0;
527  }
528  return 1;
529 }
530 
531 int float_near_abs_eps(float a, float b, float eps)
532 {
533  float abs_diff = fabsf(a - b);
534  if (abs_diff < eps)
535  return 1;
536 
537  fprintf(stderr, "test failed comparing %g with %g (abs diff=%g with EPS=%g)\n", a, b, abs_diff, eps);
538 
539  return 0;
540 }
541 
542 int float_near_abs_eps_array(const float *a, const float *b, float eps,
543  unsigned len)
544 {
545  unsigned i;
546 
547  for (i = 0; i < len; i++) {
548  if (!float_near_abs_eps(a[i], b[i], eps))
549  return 0;
550  }
551  return 1;
552 }
553 
554 int float_near_abs_eps_ulp(float a, float b, float eps, unsigned max_ulp)
555 {
556  return float_near_ulp(a, b, max_ulp) || float_near_abs_eps(a, b, eps);
557 }
558 
559 int float_near_abs_eps_array_ulp(const float *a, const float *b, float eps,
560  unsigned max_ulp, unsigned len)
561 {
562  unsigned i;
563 
564  for (i = 0; i < len; i++) {
565  if (!float_near_abs_eps_ulp(a[i], b[i], eps, max_ulp))
566  return 0;
567  }
568  return 1;
569 }
570 
571 int double_near_abs_eps(double a, double b, double eps)
572 {
573  double abs_diff = fabs(a - b);
574 
575  return abs_diff < eps;
576 }
577 
578 int double_near_abs_eps_array(const double *a, const double *b, double eps,
579  unsigned len)
580 {
581  unsigned i;
582 
583  for (i = 0; i < len; i++) {
584  if (!double_near_abs_eps(a[i], b[i], eps))
585  return 0;
586  }
587  return 1;
588 }
589 
590 /* Print colored text to stderr if the terminal supports it */
591 static void color_printf(int color, const char *fmt, ...)
592 {
593  static int use_color = -1;
594  va_list arg;
595 
596 #if HAVE_SETCONSOLETEXTATTRIBUTE && HAVE_GETSTDHANDLE
597  static HANDLE con;
598  static WORD org_attributes;
599 
600  if (use_color < 0) {
601  CONSOLE_SCREEN_BUFFER_INFO con_info;
602  con = GetStdHandle(STD_ERROR_HANDLE);
603  if (con && con != INVALID_HANDLE_VALUE && GetConsoleScreenBufferInfo(con, &con_info)) {
604  org_attributes = con_info.wAttributes;
605  use_color = 1;
606  } else
607  use_color = 0;
608  }
609  if (use_color)
610  SetConsoleTextAttribute(con, (org_attributes & 0xfff0) | (color & 0x0f));
611 #else
612  if (use_color < 0) {
613  const char *term = getenv("TERM");
614  use_color = term && strcmp(term, "dumb") && isatty(2);
615  }
616  if (use_color)
617  fprintf(stderr, "\x1b[%d;3%dm", (color & 0x08) >> 3, color & 0x07);
618 #endif
619 
620  va_start(arg, fmt);
621  vfprintf(stderr, fmt, arg);
622  va_end(arg);
623 
624  if (use_color) {
625 #if HAVE_SETCONSOLETEXTATTRIBUTE && HAVE_GETSTDHANDLE
626  SetConsoleTextAttribute(con, org_attributes);
627 #else
628  fprintf(stderr, "\x1b[0m");
629 #endif
630  }
631 }
632 
633 /* Deallocate a tree */
635 {
636  if (f) {
637  CheckasmFuncVersion *v = f->versions.next;
638  while (v) {
639  CheckasmFuncVersion *next = v->next;
640  free(v);
641  v = next;
642  }
643 
644  destroy_func_tree(f->child[0]);
645  destroy_func_tree(f->child[1]);
646  free(f);
647  }
648 }
649 
650 /* Allocate a zero-initialized block, clean up and exit on failure */
651 static void *checkasm_malloc(size_t size)
652 {
653  void *ptr = calloc(1, size);
654  if (!ptr) {
655  fprintf(stderr, "checkasm: malloc failed\n");
656  destroy_func_tree(state.funcs);
657  exit(1);
658  }
659  return ptr;
660 }
661 
662 /* Get the suffix of the specified cpu flag */
663 static const char *cpu_suffix(int cpu)
664 {
665  int i = FF_ARRAY_ELEMS(cpus);
666 
667  while (--i >= 0)
668  if (cpu & cpus[i].flag)
669  return cpus[i].suffix;
670 
671  return "c";
672 }
673 
674 static int cmp_nop(const void *a, const void *b)
675 {
676  return *(const uint16_t*)a - *(const uint16_t*)b;
677 }
678 
679 /* Measure the overhead of the timing code (in decicycles) */
680 static int measure_nop_time(void)
681 {
682  uint16_t nops[10000];
683  int i, nop_sum = 0;
684  av_unused const int sysfd = state.sysfd;
685 
686  uint64_t t = 0;
687  for (i = 0; i < 10000; i++) {
688  PERF_START(t);
689  PERF_STOP(t);
690  nops[i] = t;
691  }
692 
693  qsort(nops, 10000, sizeof(uint16_t), cmp_nop);
694  for (i = 2500; i < 7500; i++)
695  nop_sum += nops[i];
696 
697  return nop_sum / 500;
698 }
699 
700 static inline double avg_cycles_per_call(const CheckasmPerf *const p)
701 {
702  if (p->iterations) {
703  const double cycles = (double)(10 * p->cycles) / p->iterations - state.nop_time;
704  if (cycles > 0.0)
705  return cycles / 32.0; /* 32 calls per iteration */
706  }
707  return 0.0;
708 }
709 
710 /* Print benchmark results */
712 {
713  if (f) {
714  CheckasmFuncVersion *v = &f->versions;
715  const CheckasmPerf *p = &v->perf;
716  const double baseline = avg_cycles_per_call(p);
717  double decicycles;
718 
719  print_benchs(f->child[0]);
720 
721  do {
722  if (p->iterations) {
723  p = &v->perf;
724  decicycles = avg_cycles_per_call(p);
725  if (state.csv || state.tsv) {
726  const char sep = state.csv ? ',' : '\t';
727  printf("%s%c%s%c%.1f\n", f->name, sep,
728  cpu_suffix(v->cpu), sep,
729  decicycles / 10.0);
730  } else {
731  const int pad_length = 10 + 50 -
732  printf("%s_%s:", f->name, cpu_suffix(v->cpu));
733  const double ratio = decicycles ?
734  baseline / decicycles : 0.0;
735  printf("%*.1f (%5.2fx)\n", FFMAX(pad_length, 0),
736  decicycles / 10.0, ratio);
737  }
738  }
739  } while ((v = v->next));
740 
741  print_benchs(f->child[1]);
742  }
743 }
744 
745 /* ASCIIbetical sort except preserving natural order for numbers */
746 static int cmp_func_names(const char *a, const char *b)
747 {
748  const char *start = a;
749  int ascii_diff, digit_diff;
750 
751  for (; !(ascii_diff = *(const unsigned char*)a - *(const unsigned char*)b) && *a; a++, b++);
752  for (; av_isdigit(*a) && av_isdigit(*b); a++, b++);
753 
754  if (a > start && av_isdigit(a[-1]) && (digit_diff = av_isdigit(*a) - av_isdigit(*b)))
755  return digit_diff;
756 
757  return ascii_diff;
758 }
759 
760 /* Perform a tree rotation in the specified direction and return the new root */
762 {
763  CheckasmFunc *r = f->child[dir^1];
764  f->child[dir^1] = r->child[dir];
765  r->child[dir] = f;
766  r->color = f->color;
767  f->color = 0;
768  return r;
769 }
770 
771 #define is_red(f) ((f) && !(f)->color)
772 
773 /* Balance a left-leaning red-black tree at the specified node */
774 static void balance_tree(CheckasmFunc **root)
775 {
776  CheckasmFunc *f = *root;
777 
778  if (is_red(f->child[0]) && is_red(f->child[1])) {
779  f->color ^= 1;
780  f->child[0]->color = f->child[1]->color = 1;
781  }
782 
783  if (!is_red(f->child[0]) && is_red(f->child[1]))
784  *root = rotate_tree(f, 0); /* Rotate left */
785  else if (is_red(f->child[0]) && is_red(f->child[0]->child[0]))
786  *root = rotate_tree(f, 1); /* Rotate right */
787 }
788 
789 /* Get a node with the specified name, creating it if it doesn't exist */
790 static CheckasmFunc *get_func(CheckasmFunc **root, const char *name)
791 {
792  CheckasmFunc *f = *root;
793 
794  if (f) {
795  /* Search the tree for a matching node */
796  int cmp = cmp_func_names(name, f->name);
797  if (cmp) {
798  f = get_func(&f->child[cmp > 0], name);
799 
800  /* Rebalance the tree on the way up if a new node was inserted */
801  if (!f->versions.func)
802  balance_tree(root);
803  }
804  } else {
805  /* Allocate and insert a new node into the tree */
806  int name_length = strlen(name);
807  f = *root = checkasm_malloc(sizeof(CheckasmFunc) + name_length);
808  memcpy(f->name, name, name_length + 1);
809  }
810 
811  return f;
812 }
813 
815 
816 /* Crash handling: attempt to catch crashes and handle them
817  * gracefully instead of just aborting abruptly. */
818 #ifdef _WIN32
819 #if WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP)
820 static LONG NTAPI signal_handler(EXCEPTION_POINTERS *e) {
821  int s;
822 
823  if (!state.catch_signals)
824  return EXCEPTION_CONTINUE_SEARCH;
825 
826  switch (e->ExceptionRecord->ExceptionCode) {
827  case EXCEPTION_FLT_DIVIDE_BY_ZERO:
828  case EXCEPTION_INT_DIVIDE_BY_ZERO:
829  s = SIGFPE;
830  break;
831  case EXCEPTION_ILLEGAL_INSTRUCTION:
832  case EXCEPTION_PRIV_INSTRUCTION:
833  s = SIGILL;
834  break;
835  case EXCEPTION_ACCESS_VIOLATION:
836  case EXCEPTION_ARRAY_BOUNDS_EXCEEDED:
837  case EXCEPTION_DATATYPE_MISALIGNMENT:
838  case EXCEPTION_STACK_OVERFLOW:
839  s = SIGSEGV;
840  break;
841  case EXCEPTION_IN_PAGE_ERROR:
842  s = SIGBUS;
843  break;
844  default:
845  return EXCEPTION_CONTINUE_SEARCH;
846  }
847  state.catch_signals = 0;
849  return EXCEPTION_CONTINUE_EXECUTION; /* never reached, but shuts up gcc */
850 }
851 #endif
852 #elif !defined(_WASI_EMULATED_SIGNAL)
853 static void signal_handler(int s);
854 
855 static const struct sigaction signal_handler_act = {
856  .sa_handler = signal_handler,
857  .sa_flags = SA_RESETHAND,
858 };
859 
860 static void signal_handler(int s) {
861  if (state.catch_signals) {
862  state.catch_signals = 0;
863  sigaction(s, &signal_handler_act, NULL);
865  }
866 }
867 #endif
868 
869 /* Compares a string with a wildcard pattern. */
870 static int wildstrcmp(const char *str, const char *pattern)
871 {
872  const char *wild = strchr(pattern, '*');
873  if (wild) {
874  const size_t len = wild - pattern;
875  if (strncmp(str, pattern, len)) return 1;
876  while (*++wild == '*');
877  if (!*wild) return 0;
878  str += len;
879  while (*str && wildstrcmp(str, wild)) str++;
880  return !*str;
881  }
882  return strcmp(str, pattern);
883 }
884 
885 /* Perform tests and benchmarks for the specified cpu flag if supported by the host */
886 static void check_cpu_flag(const char *name, int flag)
887 {
888  int old_cpu_flag = state.cpu_flag;
889 
890  flag |= old_cpu_flag;
891  av_force_cpu_flags(-1);
892  state.cpu_flag = flag & av_get_cpu_flags();
893  av_force_cpu_flags(state.cpu_flag);
894 
895  if (!flag || state.cpu_flag != old_cpu_flag) {
896  int i;
897 
898  state.cpu_flag_name = name;
899  for (i = 0; tests[i].func; i++) {
900  if (state.test_pattern && wildstrcmp(tests[i].name, state.test_pattern))
901  continue;
902  state.current_test_name = tests[i].name;
903  tests[i].func();
904  }
905  }
906 }
907 
908 /* Print the name of the current CPU flag, but only do it once */
909 static void print_cpu_name(void)
910 {
911  if (state.cpu_flag_name) {
912  color_printf(COLOR_YELLOW, "%s:\n", state.cpu_flag_name);
913  state.cpu_flag_name = NULL;
914  }
915 }
916 
917 #if CONFIG_LINUX_PERF
918 static int bench_init_linux(void)
919 {
920  struct perf_event_attr attr = {
921  .type = PERF_TYPE_HARDWARE,
922  .size = sizeof(struct perf_event_attr),
923  .config = PERF_COUNT_HW_CPU_CYCLES,
924  .disabled = 1, // start counting only on demand
925  .exclude_kernel = 1,
926  .exclude_hv = 1,
927 #if !ARCH_X86
928  .exclude_guest = 1,
929 #endif
930  };
931 
932  fprintf(stderr, "benchmarking with Linux Perf Monitoring API\n");
933 
934  state.sysfd = syscall(__NR_perf_event_open, &attr, 0, -1, -1, 0);
935  if (state.sysfd == -1) {
936  perror("perf_event_open");
937  return -1;
938  }
939  return 0;
940 }
941 #elif CONFIG_MACOS_KPERF
942 static int bench_init_kperf(void)
943 {
944  ff_kperf_init();
945  return 0;
946 }
947 #else
948 static int bench_init_ffmpeg(void)
949 {
950 #ifdef AV_READ_TIME
951  if (!checkasm_save_context()) {
953  AV_READ_TIME();
955  } else {
956  fprintf(stderr, "checkasm: unable to execute platform specific timer\n");
957  return -1;
958  }
959  fprintf(stderr, "benchmarking with native FFmpeg timers\n");
960  return 0;
961 #else
962  fprintf(stderr, "checkasm: --bench is not supported on your system\n");
963  return -1;
964 #endif
965 }
966 #endif
967 
968 static int bench_init(void)
969 {
970 #if CONFIG_LINUX_PERF
971  int ret = bench_init_linux();
972 #elif CONFIG_MACOS_KPERF
973  int ret = bench_init_kperf();
974 #else
975  int ret = bench_init_ffmpeg();
976 #endif
977  if (ret < 0)
978  return ret;
979 
980  state.nop_time = measure_nop_time();
981  fprintf(stderr, "nop: %d.%d\n", state.nop_time/10, state.nop_time%10);
982  return 0;
983 }
984 
985 static void bench_uninit(void)
986 {
987 #if CONFIG_LINUX_PERF
988  close(state.sysfd);
989 #endif
990 }
991 
992 static int usage(const char *path)
993 {
994  fprintf(stderr,
995  "Usage: %s [options...] [seed]\n"
996  " --test=<pattern> Run specific test.\n"
997  " --bench Run benchmark.\n"
998  " --csv, --tsv Output results in rows of comma or tab separated values.\n"
999  " --runs=<ptwo> Manual number of benchmark iterations to run 2**<ptwo>.\n"
1000  " --verbose Increase verbosity.\n",
1001  path);
1002  return 1;
1003 }
1004 
1005 int main(int argc, char *argv[])
1006 {
1007  unsigned int seed = av_get_random_seed();
1008  int i, ret = 0;
1009  char arch_info_buf[50] = "";
1010 
1011 #ifdef _WIN32
1012 #if WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP)
1013  AddVectoredExceptionHandler(0, signal_handler);
1014 #endif
1015 #elif !defined(_WASI_EMULATED_SIGNAL)
1016  sigaction(SIGBUS, &signal_handler_act, NULL);
1017  sigaction(SIGFPE, &signal_handler_act, NULL);
1018  sigaction(SIGILL, &signal_handler_act, NULL);
1019  sigaction(SIGSEGV, &signal_handler_act, NULL);
1020 #endif
1021 #if HAVE_PRCTL && defined(PR_SET_UNALIGN)
1022  prctl(PR_SET_UNALIGN, PR_UNALIGN_SIGBUS);
1023 #endif
1024 #if ARCH_ARM && HAVE_ARMV5TE_EXTERNAL
1026  checkasm_checked_call = checkasm_checked_call_vfp;
1027 #endif
1028 
1029  if (!tests[0].func || !cpus[0].flag) {
1030  fprintf(stderr, "checkasm: no tests to perform\n");
1031  return 0;
1032  }
1033 
1034  for (i = 1; i < argc; i++) {
1035  const char *arg = argv[i];
1036  unsigned long l;
1037  char *end;
1038 
1039  if (!strncmp(arg, "--bench", 7)) {
1040  if (bench_init() < 0)
1041  return 1;
1042  if (arg[7] == '=') {
1043  state.bench_pattern = arg + 8;
1044  state.bench_pattern_len = strlen(state.bench_pattern);
1045  } else
1046  state.bench_pattern = "*";
1047  } else if (!strncmp(arg, "--test=", 7)) {
1048  state.test_pattern = arg + 7;
1049  } else if (!strcmp(arg, "--csv")) {
1050  state.csv = 1; state.tsv = 0;
1051  } else if (!strcmp(arg, "--tsv")) {
1052  state.csv = 0; state.tsv = 1;
1053  } else if (!strcmp(arg, "--verbose") || !strcmp(arg, "-v")) {
1054  state.verbose = 1;
1055  } else if (!strncmp(arg, "--runs=", 7)) {
1056  l = strtoul(arg + 7, &end, 10);
1057  if (*end == '\0') {
1058  if (l > 30) {
1059  fprintf(stderr, "checkasm: error: runs exponent must be within the range 0 <= 30\n");
1060  usage(argv[0]);
1061  }
1062  bench_runs = 1U << l;
1063  } else {
1064  return usage(argv[0]);
1065  }
1066  } else if ((l = strtoul(arg, &end, 10)) <= UINT_MAX &&
1067  *end == '\0') {
1068  seed = l;
1069  } else {
1070  return usage(argv[0]);
1071  }
1072  }
1073 
1074 #if ARCH_AARCH64 && HAVE_SVE
1075  if (have_sve(av_get_cpu_flags()))
1076  snprintf(arch_info_buf, sizeof(arch_info_buf),
1077  "SVE %d bits, ", 8 * ff_aarch64_sve_length());
1078 #endif
1079 #if ARCH_AARCH64 && HAVE_SME
1080  if (have_sme(av_get_cpu_flags()))
1081  av_strlcatf(arch_info_buf, sizeof(arch_info_buf),
1082  "SME %d bits, ", 8 * ff_aarch64_sme_length());
1083 #endif
1084 #if ARCH_RISCV && HAVE_RVV
1086  snprintf(arch_info_buf, sizeof (arch_info_buf),
1087  "%zu-bit vectors, ", 8 * ff_get_rv_vlenb());
1088 #endif
1089  fprintf(stderr, "checkasm: %susing random seed %u\n", arch_info_buf, seed);
1091 
1092  if (state.bench_pattern)
1093  fprintf(stderr, "checkasm: bench runs %" PRIu64 " (1 << %i)\n", bench_runs, av_log2(bench_runs));
1094 
1095  check_cpu_flag(NULL, 0);
1096  for (i = 0; cpus[i].flag; i++)
1098 
1099  if (state.num_failed) {
1100  fprintf(stderr, "checkasm: %d of %d tests have failed\n", state.num_failed, state.num_checked);
1101  ret = 1;
1102  } else {
1103  fprintf(stderr, "checkasm: all %d tests passed\n", state.num_checked);
1104  if (state.bench_pattern) {
1105  print_benchs(state.funcs);
1106  }
1107  }
1108 
1109  destroy_func_tree(state.funcs);
1110  bench_uninit();
1111  return ret;
1112 }
1113 
1114 /* Decide whether or not the specified function needs to be tested and
1115  * allocate/initialize data structures if needed. Returns a pointer to a
1116  * reference function if the function should be tested, otherwise NULL */
1117 void *checkasm_check_func(void *func, const char *name, ...)
1118 {
1119  char name_buf[256];
1120  void *ref = func;
1122  int name_length;
1123  va_list arg;
1124 
1125  va_start(arg, name);
1126  name_length = vsnprintf(name_buf, sizeof(name_buf), name, arg);
1127  va_end(arg);
1128 
1129  if (!func || name_length <= 0 || name_length >= sizeof(name_buf))
1130  return NULL;
1131 
1132  state.current_func = get_func(&state.funcs, name_buf);
1133  state.funcs->color = 1;
1134  v = &state.current_func->versions;
1135 
1136  if (v->func) {
1137  CheckasmFuncVersion *prev;
1138  do {
1139  /* Only test functions that haven't already been tested */
1140  if (v->func == func)
1141  return NULL;
1142 
1143  if (v->ok)
1144  ref = v->func;
1145 
1146  prev = v;
1147  } while ((v = v->next));
1148 
1149  v = prev->next = checkasm_malloc(sizeof(CheckasmFuncVersion));
1150  }
1151 
1152  v->func = func;
1153  v->ok = 1;
1154  v->cpu = state.cpu_flag;
1155  state.current_func_ver = v;
1156 
1157  if (state.cpu_flag)
1158  state.num_checked++;
1159 
1160  return ref;
1161 }
1162 
1163 /* Decide whether or not the current function needs to be benchmarked */
1165 {
1166  return !state.num_failed && state.bench_pattern &&
1167  !wildstrcmp(state.current_func->name, state.bench_pattern);
1168 }
1169 
1170 /* Indicate that the current test has failed, return whether verbose printing
1171  * is requested. */
1172 int checkasm_fail_func(const char *msg, ...)
1173 {
1174  if (state.current_func_ver && state.current_func_ver->cpu &&
1175  state.current_func_ver->ok)
1176  {
1177  va_list arg;
1178 
1179  print_cpu_name();
1180  fprintf(stderr, " %s_%s (", state.current_func->name, cpu_suffix(state.current_func_ver->cpu));
1181  va_start(arg, msg);
1182  vfprintf(stderr, msg, arg);
1183  va_end(arg);
1184  fprintf(stderr, ")\n");
1185 
1186  state.current_func_ver->ok = 0;
1187  state.num_failed++;
1188  }
1189  return state.verbose;
1190 }
1191 
1193  state.catch_signals = enabled;
1194 }
1195 
1197  if (s) {
1198 #ifdef __GLIBC__
1199  checkasm_fail_func("fatal signal %d: %s", s, strsignal(s));
1200 #else
1201  checkasm_fail_func(s == SIGFPE ? "fatal arithmetic error" :
1202  s == SIGILL ? "illegal instruction" :
1203  s == SIGBUS ? "bus error" :
1204  "segmentation fault");
1205 #endif
1206  }
1207  return s;
1208 }
1209 
1210 /* Get the benchmark context of the current function */
1212 {
1213  CheckasmPerf *perf = &state.current_func_ver->perf;
1214  memset(perf, 0, sizeof(*perf));
1215  perf->sysfd = state.sysfd;
1216  return perf;
1217 }
1218 
1219 /* Print the outcome of all tests performed since the last time this function was called */
1220 void checkasm_report(const char *name, ...)
1221 {
1222  static int prev_checked, prev_failed, max_length;
1223 
1224  if (state.num_checked > prev_checked) {
1225  int pad_length = max_length + 4;
1226  va_list arg;
1227 
1228  print_cpu_name();
1229  pad_length -= fprintf(stderr, " - %s.", state.current_test_name);
1230  va_start(arg, name);
1231  pad_length -= vfprintf(stderr, name, arg);
1232  va_end(arg);
1233  fprintf(stderr, "%*c", FFMAX(pad_length, 0) + 2, '[');
1234 
1235  if (state.num_failed == prev_failed)
1236  color_printf(COLOR_GREEN, "OK");
1237  else
1238  color_printf(COLOR_RED, "FAILED");
1239  fprintf(stderr, "]\n");
1240 
1241  prev_checked = state.num_checked;
1242  prev_failed = state.num_failed;
1243  } else if (!state.cpu_flag) {
1244  /* Calculate the amount of padding required to make the output vertically aligned */
1245  int length = strlen(state.current_test_name);
1246  va_list arg;
1247 
1248  va_start(arg, name);
1249  length += vsnprintf(NULL, 0, name, arg);
1250  va_end(arg);
1251 
1252  if (length > max_length)
1253  max_length = length;
1254  }
1255 }
1256 
1257 static int check_err(const char *file, int line,
1258  const char *name, int w, int h,
1259  int *err)
1260 {
1261  if (*err)
1262  return 0;
1263  if (!checkasm_fail_func("%s:%d", file, line))
1264  return 1;
1265  *err = 1;
1266  fprintf(stderr, "%s (%dx%d):\n", name, w, h);
1267  return 0;
1268 }
1269 
1270 #define DEF_CHECKASM_CHECK_BODY(compare, type, fmt) \
1271 do { \
1272  int64_t aligned_w = (w - 1LL + align_w) & ~(align_w - 1); \
1273  int64_t aligned_h = (h - 1LL + align_h) & ~(align_h - 1); \
1274  int err = 0; \
1275  int y = 0; \
1276  av_assert0(aligned_w == (int32_t)aligned_w);\
1277  av_assert0(aligned_h == (int32_t)aligned_h);\
1278  stride1 /= sizeof(*buf1); \
1279  stride2 /= sizeof(*buf2); \
1280  for (y = 0; y < h; y++) \
1281  if (!compare(&buf1[y*stride1], &buf2[y*stride2], w)) \
1282  break; \
1283  if (y != h) { \
1284  if (check_err(file, line, name, w, h, &err)) \
1285  return 1; \
1286  for (y = 0; y < h; y++) { \
1287  for (int x = 0; x < w; x++) \
1288  fprintf(stderr, " " fmt, buf1[x]); \
1289  fprintf(stderr, " "); \
1290  for (int x = 0; x < w; x++) \
1291  fprintf(stderr, " " fmt, buf2[x]); \
1292  fprintf(stderr, " "); \
1293  for (int x = 0; x < w; x++) \
1294  fprintf(stderr, "%c", buf1[x] != buf2[x] ? 'x' : '.'); \
1295  buf1 += stride1; \
1296  buf2 += stride2; \
1297  fprintf(stderr, "\n"); \
1298  } \
1299  buf1 -= h*stride1; \
1300  buf2 -= h*stride2; \
1301  } \
1302  for (y = -padding; y < 0; y++) \
1303  if (!compare(&buf1[y*stride1 - padding], &buf2[y*stride2 - padding], \
1304  w + 2*padding)) { \
1305  if (check_err(file, line, name, w, h, &err)) \
1306  return 1; \
1307  fprintf(stderr, " overwrite above\n"); \
1308  break; \
1309  } \
1310  for (y = aligned_h; y < aligned_h + padding; y++) \
1311  if (!compare(&buf1[y*stride1 - padding], &buf2[y*stride2 - padding], \
1312  w + 2*padding)) { \
1313  if (check_err(file, line, name, w, h, &err)) \
1314  return 1; \
1315  fprintf(stderr, " overwrite below\n"); \
1316  break; \
1317  } \
1318  for (y = 0; y < h; y++) \
1319  if (!compare(&buf1[y*stride1 - padding], &buf2[y*stride2 - padding], \
1320  padding)) { \
1321  if (check_err(file, line, name, w, h, &err)) \
1322  return 1; \
1323  fprintf(stderr, " overwrite left\n"); \
1324  break; \
1325  } \
1326  for (y = 0; y < h; y++) \
1327  if (!compare(&buf1[y*stride1 + aligned_w], &buf2[y*stride2 + aligned_w], \
1328  padding)) { \
1329  if (check_err(file, line, name, w, h, &err)) \
1330  return 1; \
1331  fprintf(stderr, " overwrite right\n"); \
1332  break; \
1333  } \
1334  return err; \
1335 } while (0)
1336 
1337 #define cmp_int(a, b, len) (!memcmp(a, b, (len) * sizeof(*(a))))
1338 #define DEF_CHECKASM_CHECK_FUNC(type, fmt) \
1339 int checkasm_check_##type(const char *file, int line, \
1340  const type *buf1, ptrdiff_t stride1, \
1341  const type *buf2, ptrdiff_t stride2, \
1342  int w, int h, const char *name, \
1343  int align_w, int align_h, \
1344  int padding) \
1345 { \
1346  DEF_CHECKASM_CHECK_BODY(cmp_int, type, fmt); \
1347 }
1348 
1349 DEF_CHECKASM_CHECK_FUNC(uint8_t, "%02x")
1350 DEF_CHECKASM_CHECK_FUNC(uint16_t, "%04x")
1351 DEF_CHECKASM_CHECK_FUNC(uint32_t, "%08x")
1352 DEF_CHECKASM_CHECK_FUNC(int16_t, "%6d")
1354 
1355 int checkasm_check_float_ulp(const char *file, int line,
1356  const float *buf1, ptrdiff_t stride1,
1357  const float *buf2, ptrdiff_t stride2,
1358  int w, int h, const char *name,
1359  unsigned max_ulp, int align_w, int align_h,
1360  int padding)
1361 {
1362  #define cmp_float(a, b, len) float_near_ulp_array(a, b, max_ulp, len)
1363  DEF_CHECKASM_CHECK_BODY(cmp_float, float, "%g");
1364  #undef cmp_float
1365 }
checkasm_check_nlmeans
void checkasm_check_nlmeans(void)
Definition: vf_nlmeans.c:34
AV_CPU_FLAG_VFP
#define AV_CPU_FLAG_VFP
Definition: cpu.h:71
checkasm_check_sw_gbrp
void checkasm_check_sw_gbrp(void)
Definition: sw_gbrp.c:398
bench_pattern_len
int bench_pattern_len
Definition: checkasm.c:475
av_force_cpu_flags
void av_force_cpu_flags(int arg)
Disables cpu detection and forces the specified flags.
Definition: cpu.c:81
checkasm_check_vp8dsp
void checkasm_check_vp8dsp(void)
Definition: vp8dsp.c:511
checkasm_check_idet
void checkasm_check_idet(void)
Definition: vf_idet.c:58
checkasm_check_blockdsp
void checkasm_check_blockdsp(void)
Definition: blockdsp.c:78
AV_CPU_FLAG_SSE3
#define AV_CPU_FLAG_SSE3
Prescott SSE3 functions.
Definition: cpu.h:41
checkasm_check_fdctdsp
void checkasm_check_fdctdsp(void)
Definition: fdctdsp.c:67
destroy_func_tree
static void destroy_func_tree(CheckasmFunc *f)
Definition: checkasm.c:634
r
const char * r
Definition: vf_curves.c:127
checkasm_check_sw_xyz2rgb
void checkasm_check_sw_xyz2rgb(void)
Definition: sw_xyz2rgb.c:104
printf
__device__ int printf(const char *,...)
checkasm_check_videodsp
void checkasm_check_videodsp(void)
Definition: videodsp.c:80
cmp_nop
static int cmp_nop(const void *a, const void *b)
Definition: checkasm.c:674
checkasm_check_vf_eq
void checkasm_check_vf_eq(void)
Definition: vf_eq.c:76
AV_CPU_FLAG_RVB_BASIC
#define AV_CPU_FLAG_RVB_BASIC
Basic bit-manipulations.
Definition: cpu.h:105
COLOR_RED
#define COLOR_RED
Definition: checkasm.c:85
checkasm_check_dcadsp
void checkasm_check_dcadsp(void)
Definition: dcadsp.c:89
wildstrcmp
static int wildstrcmp(const char *str, const char *pattern)
Definition: checkasm.c:870
checkasm_lfg
AVLFG checkasm_lfg
Definition: checkasm.c:493
color
Definition: vf_paletteuse.c:513
av_lfg_init
av_cold void av_lfg_init(AVLFG *c, unsigned int seed)
Definition: lfg.c:32
checkasm_check_alacdsp
void checkasm_check_alacdsp(void)
Definition: alacdsp.c:116
AV_CPU_FLAG_LSX
#define AV_CPU_FLAG_LSX
Definition: cpu.h:92
checkasm_check_v210dec
void checkasm_check_v210dec(void)
Definition: v210dec.c:47
float_near_abs_eps_array
int float_near_abs_eps_array(const float *a, const float *b, float eps, unsigned len)
Definition: checkasm.c:542
AV_CPU_FLAG_SSE3SLOW
#define AV_CPU_FLAG_SSE3SLOW
SSE3 supported, but usually not faster.
Definition: cpu.h:42
CheckasmFunc
Definition: checkasm.c:461
checkasm_check_sw_yuv2yuv
void checkasm_check_sw_yuv2yuv(void)
Definition: sw_yuv2yuv.c:130
name
const char * name
Definition: checkasm.c:115
checkasm_fail_func
int checkasm_fail_func(const char *msg,...)
Definition: checkasm.c:1172
checkasm_check_png
void checkasm_check_png(void)
Definition: png.c:106
bench_pattern
const char * bench_pattern
Definition: checkasm.c:474
AV_CPU_FLAG_RV_ZVBB
#define AV_CPU_FLAG_RV_ZVBB
Vector basic bit-manipulations.
Definition: cpu.h:109
int64_t
long long int64_t
Definition: coverity.c:34
av_unused
#define av_unused
Definition: attributes.h:164
checkasm_check_hevc_idct
void checkasm_check_hevc_idct(void)
Definition: hevc_idct.c:108
checkasm_check_sw_scale
void checkasm_check_sw_scale(void)
Definition: sw_scale.c:460
CheckasmFunc::child
struct CheckasmFunc * child[2]
Definition: checkasm.c:462
AV_CPU_FLAG_SVE2
#define AV_CPU_FLAG_SVE2
Definition: cpu.h:79
checkasm_check_afir
void checkasm_check_afir(void)
Definition: af_afir.c:144
checkasm_check_aes
void checkasm_check_aes(void)
Definition: aes.c:28
print_cpu_name
static void print_cpu_name(void)
Definition: checkasm.c:909
u
#define u(width, name, range_min, range_max)
Definition: cbs_apv.c:68
av_intfloat32::i
uint32_t i
Definition: intfloat.h:28
AV_CPU_FLAG_SVE
#define AV_CPU_FLAG_SVE
Definition: cpu.h:78
float_near_abs_eps
int float_near_abs_eps(float a, float b, float eps)
Definition: checkasm.c:531
b
#define b
Definition: input.c:43
checkasm_check_aacpsdsp
void checkasm_check_aacpsdsp(void)
Definition: aacpsdsp.c:234
bench_uninit
static void bench_uninit(void)
Definition: checkasm.c:985
CheckasmFuncVersion::cpu
int cpu
Definition: checkasm.c:456
cpu_flag
int cpu_flag
Definition: checkasm.c:483
AV_CPU_FLAG_DOTPROD
#define AV_CPU_FLAG_DOTPROD
Definition: cpu.h:76
checkasm_check_vvc_sao
void checkasm_check_vvc_sao(void)
Definition: vvc_sao.c:134
FFMAX
#define FFMAX(a, b)
Definition: macros.h:47
av_get_cpu_flags
int av_get_cpu_flags(void)
Return the flags which specify extensions supported by the CPU.
Definition: cpu.c:109
cpu_suffix
static const char * cpu_suffix(int cpu)
Definition: checkasm.c:663
CheckasmPerf::sysfd
int sysfd
Definition: checkasm.h:354
intfloat.h
checkasm_check_h264dsp
void checkasm_check_h264dsp(void)
Definition: h264dsp.c:503
av_strlcatf
size_t av_strlcatf(char *dst, size_t size, const char *fmt,...)
Definition: avstring.c:103
tf_sess_config.config
config
Definition: tf_sess_config.py:33
color_printf
static void color_printf(int color, const char *fmt,...)
Definition: checkasm.c:591
AV_CPU_FLAG_RVV_F64
#define AV_CPU_FLAG_RVV_F64
Vectors of double's.
Definition: cpu.h:104
dummy
static int dummy
Definition: ffplay.c:3751
checkasm_check_vp9_ipred
void checkasm_check_vp9_ipred(void)
Definition: vp9dsp.c:50
av_get_random_seed
uint32_t av_get_random_seed(void)
Get a seed to use in conjunction with random functions.
Definition: random_seed.c:196
main
int main(int argc, char *argv[])
Definition: checkasm.c:1005
checkasm_check_float_ulp
int checkasm_check_float_ulp(const char *file, int line, const float *buf1, ptrdiff_t stride1, const float *buf2, ptrdiff_t stride2, int w, int h, const char *name, unsigned max_ulp, int align_w, int align_h, int padding)
Definition: checkasm.c:1355
checkasm_check_motion
void checkasm_check_motion(void)
Definition: motion.c:137
close
static av_cold void close(AVCodecParserContext *s)
Definition: apv_parser.c:197
checkasm_check_h263dsp
void checkasm_check_h263dsp(void)
Definition: h263dsp.c:54
AV_CPU_FLAG_RVB
#define AV_CPU_FLAG_RVB
B (bit manipulations)
Definition: cpu.h:111
AV_CPU_FLAG_SSSE3
#define AV_CPU_FLAG_SSSE3
Conroe SSSE3 functions.
Definition: cpu.h:44
double_near_abs_eps
int double_near_abs_eps(double a, double b, double eps)
Definition: checkasm.c:571
CheckasmPerf
Definition: checkasm.h:353
current_test_name
const char * current_test_name
Definition: checkasm.c:473
PERF_START
#define PERF_START(t)
Definition: checkasm.h:426
rotate_tree
static CheckasmFunc * rotate_tree(CheckasmFunc *f, int dir)
Definition: checkasm.c:761
AV_CPU_FLAG_XOP
#define AV_CPU_FLAG_XOP
Bulldozer XOP functions.
Definition: cpu.h:53
checkasm_check_vp9dsp
void checkasm_check_vp9dsp(void)
Definition: vp9dsp.c:627
checkasm.h
checkasm_check_vf_threshold
void checkasm_check_vf_threshold(void)
Definition: vf_threshold.c:79
checkasm_check_vf_gblur
void checkasm_check_vf_gblur(void)
Definition: vf_gblur.c:82
tests
static const struct @581 tests[]
float_near_abs_eps_ulp
int float_near_abs_eps_ulp(float a, float b, float eps, unsigned max_ulp)
Definition: checkasm.c:554
have_sve
#define have_sve(flags)
Definition: cpu.h:33
checkasm_check_vvc_mc
void checkasm_check_vvc_mc(void)
Definition: vvc_mc.c:471
checkasm_check_sbcdsp
void checkasm_check_sbcdsp(void)
Definition: sbcdsp.c:111
AV_CPU_FLAG_VSX
#define AV_CPU_FLAG_VSX
ISA 2.06.
Definition: cpu.h:65
fabsf
static __device__ float fabsf(float a)
Definition: cuda_runtime.h:181
checkasm_check_sw_yuv2rgb
void checkasm_check_sw_yuv2rgb(void)
Definition: sw_yuv2rgb.c:234
AV_CPU_FLAG_PMULL
#define AV_CPU_FLAG_PMULL
Definition: cpu.h:85
AV_CPU_FLAG_RVV_F32
#define AV_CPU_FLAG_RVV_F32
Vectors of float's *‍/.
Definition: cpu.h:102
num_failed
int num_failed
Definition: checkasm.c:477
checkasm_check_float_dsp
void checkasm_check_float_dsp(void)
Definition: float_dsp.c:297
AV_CPU_FLAG_AVX512
#define AV_CPU_FLAG_AVX512
AVX-512 functions: requires OS support even if YMM/ZMM registers aren't used.
Definition: cpu.h:60
checkasm_check_hevc_dequant
void checkasm_check_hevc_dequant(void)
Definition: hevc_dequant.c:65
bench_init
static int bench_init(void)
Definition: checkasm.c:968
avassert.h
checkasm_check_pixblockdsp
void checkasm_check_pixblockdsp(void)
Definition: pixblockdsp.c:82
FF_ARRAY_ELEMS
#define FF_ARRAY_ELEMS(a)
Definition: sinewin_tablegen.c:29
CheckasmFuncVersion
Definition: checkasm.c:452
COLOR_YELLOW
#define COLOR_YELLOW
Definition: checkasm.c:87
nop_time
int nop_time
Definition: checkasm.c:480
CheckasmFuncVersion::perf
CheckasmPerf perf
Definition: checkasm.c:457
s
#define s(width, name)
Definition: cbs_vp9.c:198
checkasm_check_vf_bwdif
void checkasm_check_vf_bwdif(void)
Definition: vf_bwdif.c:72
checkasm_report
void checkasm_report(const char *name,...)
Definition: checkasm.c:1220
get_func
static CheckasmFunc * get_func(CheckasmFunc **root, const char *name)
Definition: checkasm.c:790
cpu.h
checkasm_check_sw_rgb
void checkasm_check_sw_rgb(void)
Definition: sw_rgb.c:804
checkasm_check_hevc_sao
void checkasm_check_hevc_sao(void)
Definition: hevc_sao.c:136
num_checked
int num_checked
Definition: checkasm.c:476
AV_CPU_FLAG_ARMV6
#define AV_CPU_FLAG_ARMV6
Definition: cpu.h:69
AV_READ_TIME
#define AV_READ_TIME
Definition: timer.h:28
AV_CPU_FLAG_SSE4
#define AV_CPU_FLAG_SSE4
Penryn SSE4.1 functions.
Definition: cpu.h:47
AV_CPU_FLAG_SME2
#define AV_CPU_FLAG_SME2
Definition: cpu.h:82
checkasm_check_hevc_pel
void checkasm_check_hevc_pel(void)
Definition: hevc_pel.c:621
checkasm_set_signal_handler_state
void checkasm_set_signal_handler_state(int enabled)
Definition: checkasm.c:1192
CheckasmFuncVersion::ok
int ok
Definition: checkasm.c:455
arg
const char * arg
Definition: jacosubdec.c:65
func
void(* func)(void)
Definition: checkasm.c:116
cmp_float
#define cmp_float(a, b, len)
checkasm_check_mpeg4videodsp
void checkasm_check_mpeg4videodsp(void)
Definition: mpeg4videodsp.c:146
fabs
static __device__ float fabs(float a)
Definition: cuda_runtime.h:182
NULL
#define NULL
Definition: coverity.c:32
measure_nop_time
static int measure_nop_time(void)
Definition: checkasm.c:680
checkasm_check_takdsp
void checkasm_check_takdsp(void)
Definition: takdsp.c:145
checkasm_check_hevc_pred
void checkasm_check_hevc_pred(void)
Definition: hevc_pred.c:301
double_near_abs_eps_array
int double_near_abs_eps_array(const double *a, const double *b, double eps, unsigned len)
Definition: checkasm.c:578
checkasm_check_sw_ops
void checkasm_check_sw_ops(void)
Definition: sw_ops.c:909
AV_CPU_FLAG_LASX
#define AV_CPU_FLAG_LASX
Definition: cpu.h:93
AV_CPU_FLAG_AVX512ICL
#define AV_CPU_FLAG_AVX512ICL
F/CD/BW/DQ/VL/VNNI/IFMA/VBMI/VBMI2/VPOPCNTDQ/BITALG/GFNI/VAES/VPCLMULQDQ.
Definition: cpu.h:61
checkasm_check_fmtconvert
void checkasm_check_fmtconvert(void)
Definition: fmtconvert.c:46
checkasm_load_context
#define checkasm_load_context(s)
Definition: checkasm.h:77
AV_CPU_FLAG_MSA
#define AV_CPU_FLAG_MSA
Definition: cpu.h:89
checkasm_save_context
#define checkasm_save_context()
Definition: checkasm.h:76
COLOR_GREEN
#define COLOR_GREEN
Definition: checkasm.c:86
checkasm_check_aacencdsp
void checkasm_check_aacencdsp(void)
Definition: aacencdsp.c:100
checkasm_check_vorbisdsp
void checkasm_check_vorbisdsp(void)
Definition: vorbisdsp.c:76
cpu.h
double
double
Definition: af_crystalizer.c:132
av_intfloat32
Definition: intfloat.h:27
checkasm_check_cavsdsp
void checkasm_check_cavsdsp(void)
Definition: cavsdsp.c:116
checkasm_check_apv_dsp
void checkasm_check_apv_dsp(void)
Definition: apv_dsp.c:61
AV_CPU_FLAG_CMOV
#define AV_CPU_FLAG_CMOV
supports cmov instruction
Definition: cpu.h:55
seed
static unsigned int seed
Definition: videogen.c:78
checkasm_check_hpeldsp
void checkasm_check_hpeldsp(void)
Definition: hpeldsp.c:54
AV_CPU_FLAG_ALTIVEC
#define AV_CPU_FLAG_ALTIVEC
standard
Definition: cpu.h:64
checkasm_check_rv40dsp
void checkasm_check_rv40dsp(void)
Definition: rv40dsp.c:71
print_benchs
static void print_benchs(CheckasmFunc *f)
Definition: checkasm.c:711
current_func
CheckasmFunc * current_func
Definition: checkasm.c:471
AV_CPU_FLAG_I8MM
#define AV_CPU_FLAG_I8MM
Definition: cpu.h:77
checkasm_check_vc1dsp
void checkasm_check_vc1dsp(void)
Definition: vc1dsp.c:476
catch_signals
volatile sig_atomic_t catch_signals
Definition: checkasm.c:489
checkasm_check_h264chroma
void checkasm_check_h264chroma(void)
Definition: h264chroma.c:83
AV_CPU_FLAG_SSE2
#define AV_CPU_FLAG_SSE2
PIV SSE2 functions.
Definition: cpu.h:37
AV_CPU_FLAG_CLMUL
#define AV_CPU_FLAG_CLMUL
Carry-less Multiplication instruction.
Definition: cpu.h:50
CheckasmFunc::color
uint8_t color
Definition: checkasm.c:464
AVLFG
Context structure for the Lagged Fibonacci PRNG.
Definition: lfg.h:33
f
f
Definition: af_crystalizer.c:122
checkasm_check_llauddsp
void checkasm_check_llauddsp(void)
Definition: llauddsp.c:108
AV_CPU_FLAG_AVX
#define AV_CPU_FLAG_AVX
AVX functions: requires OS support even if YMM registers aren't used.
Definition: cpu.h:51
csv
int csv
Definition: checkasm.c:487
AV_CPU_FLAG_FMA4
#define AV_CPU_FLAG_FMA4
Bulldozer FMA4 functions.
Definition: cpu.h:54
checkasm_check_vp9_loopfilter
void checkasm_check_vp9_loopfilter(void)
Definition: vp9dsp.c:452
cpu.h
AV_CPU_FLAG_AVX2
#define AV_CPU_FLAG_AVX2
AVX2 functions: requires OS support even if YMM registers aren't used.
Definition: cpu.h:56
i
#define i(width, name, range_min, range_max)
Definition: cbs_h264.c:63
checkasm_check_llviddsp
void checkasm_check_llviddsp(void)
Definition: llviddsp.c:183
checkasm_handle_signal
int checkasm_handle_signal(int s)
Definition: checkasm.c:1196
AV_CPU_FLAG_ARM_CRC
#define AV_CPU_FLAG_ARM_CRC
Definition: cpu.h:81
AV_CPU_FLAG_SSE2SLOW
#define AV_CPU_FLAG_SSE2SLOW
SSE2 supported, but usually not faster.
Definition: cpu.h:38
checkasm_check_vp9_mc
void checkasm_check_vp9_mc(void)
Definition: vp9dsp.c:559
AV_CPU_FLAG_NEON
#define AV_CPU_FLAG_NEON
Definition: cpu.h:73
size
int size
Definition: twinvq_data.h:10344
checkasm_check_vp3dsp
void checkasm_check_vp3dsp(void)
Definition: vp3dsp.c:193
checkasm_check_vf_pp7
void checkasm_check_vf_pp7(void)
Definition: vf_pp7.c:58
checkasm_check_diracdsp
void checkasm_check_diracdsp(void)
Definition: diracdsp.c:85
DEF_CHECKASM_CHECK_FUNC
#define DEF_CHECKASM_CHECK_FUNC(type, fmt)
Definition: checkasm.c:1338
sysfd
int sysfd
Definition: checkasm.c:481
cmp
static av_always_inline int cmp(MPVEncContext *const 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...
Definition: motion_est.c:263
have_neon
#define have_neon(flags)
Definition: cpu.h:26
CheckasmFuncVersion::func
void * func
Definition: checkasm.c:454
checkasm_check_h264pred
void checkasm_check_h264pred(void)
Definition: h264pred.c:233
av_isdigit
static av_const int av_isdigit(int c)
Locale-independent conversion of ASCII isdigit.
Definition: avstring.h:202
AV_CPU_FLAG_FMA3
#define AV_CPU_FLAG_FMA3
Haswell FMA3 functions.
Definition: cpu.h:57
a
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
Definition: undefined.txt:41
ff_kperf_init
void ff_kperf_init(void)
Definition: macos_kperf.c:102
bench_runs
uint64_t bench_runs
Definition: checkasm.c:111
checkasm_check_huffyuvdsp
void checkasm_check_huffyuvdsp(void)
Definition: huffyuvdsp.c:95
state
static struct @583 state
line
Definition: graph2dot.c:48
float_near_abs_eps_array_ulp
int float_near_abs_eps_array_ulp(const float *a, const float *b, float eps, unsigned max_ulp, unsigned len)
Definition: checkasm.c:559
checkasm_get_perf_context
CheckasmPerf * checkasm_get_perf_context(void)
Definition: checkasm.c:1211
checkasm_check_fixed_dsp
void checkasm_check_fixed_dsp(void)
Definition: fixed_dsp.c:133
checkasm_check_colorspace
void checkasm_check_colorspace(void)
Definition: vf_colorspace.c:309
checkasm_check_utvideodsp
void checkasm_check_utvideodsp(void)
Definition: utvideodsp.c:90
is_negative
static int is_negative(union av_intfloat32 u)
Definition: checkasm.c:496
checkasm_check_audiodsp
void checkasm_check_audiodsp(void)
Definition: audiodsp.c:52
checkasm_check_huffyuvencdsp
void checkasm_check_huffyuvencdsp(void)
Definition: huffyuvencdsp.c:73
checkasm_check_sw_range_convert
void checkasm_check_sw_range_convert(void)
Definition: sw_range_convert.c:224
AV_CPU_FLAG_RV_MISALIGNED
#define AV_CPU_FLAG_RV_MISALIGNED
Fast misaligned accesses.
Definition: cpu.h:110
checkasm_check_mpegvideoencdsp
void checkasm_check_mpegvideoencdsp(void)
Definition: mpegvideoencdsp.c:191
AV_CPU_FLAG_SIMD128
#define AV_CPU_FLAG_SIMD128
Definition: cpu.h:114
checkasm_check_flacdsp
void checkasm_check_flacdsp(void)
Definition: flacdsp.c:155
checkasm_check_func
void * checkasm_check_func(void *func, const char *name,...)
Definition: checkasm.c:1117
AV_CPU_FLAG_SSE42
#define AV_CPU_FLAG_SSE42
Nehalem SSE4.2 functions.
Definition: cpu.h:48
checkasm_check_idctdsp
void checkasm_check_idctdsp(void)
Definition: idctdsp.c:95
CheckasmFuncVersion::next
struct CheckasmFuncVersion * next
Definition: checkasm.c:453
vsnprintf
#define vsnprintf
Definition: snprintf.h:36
common.h
use_color
static int use_color
Definition: log.c:128
AV_CPU_FLAG_RVV_I32
#define AV_CPU_FLAG_RVV_I32
Vectors of 8/16/32-bit int's *‍/.
Definition: cpu.h:101
checkasm_check_synth_filter
void checkasm_check_synth_filter(void)
Definition: synth_filter.c:47
cmp_func_names
static int cmp_func_names(const char *a, const char *b)
Definition: checkasm.c:746
AV_CPU_FLAG_SME_I16I64
#define AV_CPU_FLAG_SME_I16I64
Definition: cpu.h:83
AV_CPU_FLAG_ARMV8
#define AV_CPU_FLAG_ARMV8
Definition: cpu.h:74
checkasm_check_lpc
void checkasm_check_lpc(void)
Definition: lpc.c:96
len
int len
Definition: vorbis_enc_data.h:426
checkasm_check_g722dsp
void checkasm_check_g722dsp(void)
Definition: g722dsp.c:53
checkasm_check_ac3dsp
void checkasm_check_ac3dsp(void)
Definition: ac3dsp.c:193
PERF_STOP
#define PERF_STOP(t)
Definition: checkasm.h:427
is_red
#define is_red(f)
Definition: checkasm.c:771
AV_CPU_FLAG_ATOM
#define AV_CPU_FLAG_ATOM
Atom processor, some SSSE3 instructions are slower.
Definition: cpu.h:46
have_vfp
#define have_vfp(flags)
Definition: cpu.h:27
checkasm_check_svq1enc
void checkasm_check_svq1enc(void)
Definition: svq1enc.c:63
checkasm_check_vf_hflip
void checkasm_check_vf_hflip(void)
Definition: vf_hflip.c:72
ret
ret
Definition: filter_design.txt:187
checkasm_check_lls
void checkasm_check_lls(void)
Definition: lls.c:84
have_sme
#define have_sme(flags)
Definition: cpu.h:35
checkasm_check_scene_sad
void checkasm_check_scene_sad(void)
Definition: scene_sad.c:66
checkasm_check_blend
void checkasm_check_blend(void)
Definition: vf_blend.c:89
verbose
int verbose
Definition: checkasm.c:486
DEF_CHECKASM_CHECK_BODY
#define DEF_CHECKASM_CHECK_BODY(compare, type, fmt)
Definition: checkasm.c:1270
AV_CPU_FLAG_VFPV3
#define AV_CPU_FLAG_VFPV3
Definition: cpu.h:72
checkasm_check_bswapdsp
void checkasm_check_bswapdsp(void)
Definition: bswapdsp.c:60
checkasm_context_buf
checkasm_context checkasm_context_buf
Definition: checkasm.c:814
U
#define U(x)
Definition: vpx_arith.h:37
AV_CPU_FLAG_ARMV5TE
#define AV_CPU_FLAG_ARMV5TE
Definition: cpu.h:68
checkasm_check_vf_fspp
void checkasm_check_vf_fspp(void)
Definition: vf_fspp.c:165
AV_CPU_FLAG_MMX
#define AV_CPU_FLAG_MMX
standard MMX
Definition: cpu.h:32
suffix
const char * suffix
Definition: checkasm.c:385
checkasm_malloc
static void * checkasm_malloc(size_t size)
Definition: checkasm.c:651
AV_CPU_FLAG_RVI
#define AV_CPU_FLAG_RVI
I (full GPR bank)
Definition: cpu.h:96
checkasm_check_h264qpel
void checkasm_check_h264qpel(void)
Definition: h264qpel.c:51
random_seed.h
signal_handler
static void signal_handler(int s)
Definition: checkasm.c:860
checkasm_check_colordetect
void checkasm_check_colordetect(void)
Definition: vf_colordetect.c:135
AV_CPU_FLAG_AESNI
#define AV_CPU_FLAG_AESNI
Advanced Encryption Standard functions.
Definition: cpu.h:49
checkasm_bench_func
int checkasm_bench_func(void)
Definition: checkasm.c:1164
AV_CPU_FLAG_EOR3
#define AV_CPU_FLAG_EOR3
Definition: cpu.h:86
checkasm_check_mpegvideo_unquantize
void checkasm_check_mpegvideo_unquantize(void)
Definition: mpegvideo_unquantize.c:196
AV_CPU_FLAG_POWER8
#define AV_CPU_FLAG_POWER8
ISA 2.07.
Definition: cpu.h:66
cpu_flag_name
const char * cpu_flag_name
Definition: checkasm.c:484
AV_CPU_FLAG_SME
#define AV_CPU_FLAG_SME
Definition: cpu.h:80
checkasm_check_vf_sobel
void checkasm_check_vf_sobel(void)
Definition: vf_convolution.c:100
AV_CPU_FLAG_SSE
#define AV_CPU_FLAG_SSE
SSE functions.
Definition: cpu.h:36
ref
static int ref[MAX_W *MAX_W]
Definition: jpeg2000dwt.c:117
float_near_ulp_array
int float_near_ulp_array(const float *a, const float *b, unsigned max_ulp, unsigned len)
Definition: checkasm.c:519
checkasm_check_crc
void checkasm_check_crc(void)
Definition: crc.c:71
signal_handler_act
static const struct sigaction signal_handler_act
Definition: checkasm.c:855
AV_CPU_FLAG_MMXEXT
#define AV_CPU_FLAG_MMXEXT
SSE integer functions or AMD MMX ext.
Definition: cpu.h:33
Windows::Graphics::DirectX::Direct3D11::p
IDirect3DDxgiInterfaceAccess _COM_Outptr_ void ** p
Definition: vsrc_gfxcapture_winrt.hpp:53
checkasm_check_vp6dsp
void checkasm_check_vp6dsp(void)
Definition: vp6dsp.c:39
checkasm_check_av_tx
void checkasm_check_av_tx(void)
Definition: av_tx.c:102
checkasm_check_qpeldsp
void checkasm_check_qpeldsp(void)
Definition: qpeldsp.c:52
checkasm_check_vp9_itxfm
void checkasm_check_vp9_itxfm(void)
Definition: vp9dsp.c:311
checkasm_check_blackdetect
void checkasm_check_blackdetect(void)
Definition: vf_blackdetect.c:62
av_intfloat32::f
float f
Definition: intfloat.h:29
flag
int flag
Definition: checkasm.c:386
checkasm_check_v210enc
void checkasm_check_v210enc(void)
Definition: v210enc.c:83
checkasm_check_sbrdsp
void checkasm_check_sbrdsp(void)
Definition: sbrdsp.c:257
checkasm_check_pixelutils
void checkasm_check_pixelutils(void)
Definition: pixelutils.c:95
checkasm_check_hevc_deblock
void checkasm_check_hevc_deblock(void)
Definition: hevc_deblock.c:264
cpus
static const struct @582 cpus[]
w
uint8_t w
Definition: llvidencdsp.c:39
checkasm_check_snowdsp
void checkasm_check_snowdsp(void)
Definition: snowdsp.c:136
test_pattern
const char * test_pattern
Definition: checkasm.c:485
usage
static int usage(const char *path)
Definition: checkasm.c:992
AV_CPU_FLAG_VFP_VM
#define AV_CPU_FLAG_VFP_VM
VFPv2 vector mode, deprecated in ARMv7-A and unavailable in various CPUs implementations.
Definition: cpu.h:75
AV_CPU_FLAG_MMI
#define AV_CPU_FLAG_MMI
Definition: cpu.h:88
checkasm_check_jpeg2000dsp
void checkasm_check_jpeg2000dsp(void)
Definition: jpeg2000dsp.c:92
checkasm_check_hevc_add_res
void checkasm_check_hevc_add_res(void)
Definition: hevc_add_res.c:87
int32_t
int32_t
Definition: audioconvert.c:56
float_near_ulp
int float_near_ulp(float a, float b, unsigned max_ulp)
Definition: checkasm.c:501
current_func_ver
CheckasmFuncVersion * current_func_ver
Definition: checkasm.c:472
check_cpu_flag
static void check_cpu_flag(const char *name, int flag)
Definition: checkasm.c:886
checkasm_context
sigjmp_buf checkasm_context
Definition: checkasm.h:75
bench_init_ffmpeg
static int bench_init_ffmpeg(void)
Definition: checkasm.c:948
checkasm_check_rv34dsp
void checkasm_check_rv34dsp(void)
Definition: rv34dsp.c:129
CheckasmFunc::versions
CheckasmFuncVersion versions
Definition: checkasm.c:463
isatty
#define isatty(fd)
Definition: checkasm.c:95
h
h
Definition: vp9dsp_template.c:2070
avg_cycles_per_call
static double avg_cycles_per_call(const CheckasmPerf *const p)
Definition: checkasm.c:700
AV_CPU_FLAG_RVV_I64
#define AV_CPU_FLAG_RVV_I64
Vectors of 64-bit int's *‍/.
Definition: cpu.h:103
check_err
static int check_err(const char *file, int line, const char *name, int w, int h, int *err)
Definition: checkasm.c:1257
cpu.h
CheckasmFunc::name
char name[1]
Definition: checkasm.c:465
checkasm_check_vvc_alf
void checkasm_check_vvc_alf(void)
Definition: vvc_alf.c:178
snprintf
#define snprintf
Definition: snprintf.h:34
av_log2
int av_log2(unsigned v)
Definition: intmath.c:26
checkasm_check_exrdsp
void checkasm_check_exrdsp(void)
Definition: exrdsp.c:77
balance_tree
static void balance_tree(CheckasmFunc **root)
Definition: checkasm.c:774
AV_CPU_FLAG_ARMV6T2
#define AV_CPU_FLAG_ARMV6T2
Definition: cpu.h:70
tsv
int tsv
Definition: checkasm.c:488
checkasm_check_llvidencdsp
void checkasm_check_llvidencdsp(void)
Definition: llvidencdsp.c:134
funcs
CheckasmFunc * funcs
Definition: checkasm.c:470
checkasm_check_opusdsp
void checkasm_check_opusdsp(void)
Definition: opusdsp.c:86