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_THRESHOLD_FILTER
346  { "vf_threshold", checkasm_check_vf_threshold },
347  #endif
348  #if CONFIG_SOBEL_FILTER
349  { "vf_sobel", checkasm_check_vf_sobel },
350  #endif
351 #endif
352 #if CONFIG_SWSCALE
353  { "sw_gbrp", checkasm_check_sw_gbrp },
354  { "sw_range_convert", checkasm_check_sw_range_convert },
355  { "sw_rgb", checkasm_check_sw_rgb },
356  { "sw_scale", checkasm_check_sw_scale },
357  { "sw_xyz2rgb", checkasm_check_sw_xyz2rgb },
358  { "sw_yuv2rgb", checkasm_check_sw_yuv2rgb },
359  { "sw_yuv2yuv", checkasm_check_sw_yuv2yuv },
360  { "sw_ops", checkasm_check_sw_ops },
361 #endif
362 #if CONFIG_AVUTIL
363  { "aes", checkasm_check_aes },
364  { "crc", checkasm_check_crc },
365  { "fixed_dsp", checkasm_check_fixed_dsp },
366  { "float_dsp", checkasm_check_float_dsp },
367  { "lls", checkasm_check_lls },
368 #if CONFIG_PIXELUTILS
369  { "pixelutils",checkasm_check_pixelutils },
370 #endif
371  { "av_tx", checkasm_check_av_tx },
372 #endif
373  { NULL }
374  /* NOTE: When adding a new test to this list here, it also needs to be
375  * added in tests/fate/checkasm.mak, otherwise it doesn't get executed
376  * as part of "make fate" or "make fate-checkasm". */
377 };
378 
379 /* List of cpu flags to check */
380 static const struct {
381  const char *name;
382  const char *suffix;
383  int flag;
384 } cpus[] = {
385 #if ARCH_AARCH64
386  { "ARMV8", "armv8", AV_CPU_FLAG_ARMV8 },
387  { "NEON", "neon", AV_CPU_FLAG_NEON },
388  { "DOTPROD", "dotprod", AV_CPU_FLAG_DOTPROD },
389  { "I8MM", "i8mm", AV_CPU_FLAG_I8MM },
390  { "SVE", "sve", AV_CPU_FLAG_SVE },
391  { "SVE2", "sve2", AV_CPU_FLAG_SVE2 },
392  { "SME", "sme", AV_CPU_FLAG_SME },
393  { "SME-I16I64", "sme_i16i64", AV_CPU_FLAG_SME_I16I64 },
394  { "CRC", "crc", AV_CPU_FLAG_ARM_CRC },
395  { "SME2", "sme2", AV_CPU_FLAG_SME2 },
396  { "PMULL", "pmull_eor3", AV_CPU_FLAG_PMULL|AV_CPU_FLAG_EOR3 },
397 #elif ARCH_ARM
398  { "ARMV5TE", "armv5te", AV_CPU_FLAG_ARMV5TE },
399  { "ARMV6", "armv6", AV_CPU_FLAG_ARMV6 },
400  { "ARMV6T2", "armv6t2", AV_CPU_FLAG_ARMV6T2 },
401  { "VFP", "vfp", AV_CPU_FLAG_VFP },
402  { "VFP_VM", "vfp_vm", AV_CPU_FLAG_VFP_VM },
403  { "VFPV3", "vfp3", AV_CPU_FLAG_VFPV3 },
404  { "NEON", "neon", AV_CPU_FLAG_NEON },
405 #elif ARCH_PPC
406  { "ALTIVEC", "altivec", AV_CPU_FLAG_ALTIVEC },
407  { "VSX", "vsx", AV_CPU_FLAG_VSX },
408  { "POWER8", "power8", AV_CPU_FLAG_POWER8 },
409 #elif ARCH_RISCV
410  { "RVI", "rvi", AV_CPU_FLAG_RVI },
411  { "misaligned", "misaligned", AV_CPU_FLAG_RV_MISALIGNED },
412  { "RV_zbb", "rvb_b", AV_CPU_FLAG_RVB_BASIC },
413  { "RVB", "rvb", AV_CPU_FLAG_RVB },
414  { "RV_zve32x","rvv_i32", AV_CPU_FLAG_RVV_I32 },
415  { "RV_zve32f","rvv_f32", AV_CPU_FLAG_RVV_F32 },
416  { "RV_zve64x","rvv_i64", AV_CPU_FLAG_RVV_I64 },
417  { "RV_zve64d","rvv_f64", AV_CPU_FLAG_RVV_F64 },
418  { "RV_zvbb", "rv_zvbb", AV_CPU_FLAG_RV_ZVBB },
419 #elif ARCH_MIPS
420  { "MMI", "mmi", AV_CPU_FLAG_MMI },
421  { "MSA", "msa", AV_CPU_FLAG_MSA },
422 #elif ARCH_X86
423  { "MMX", "mmx", AV_CPU_FLAG_MMX|AV_CPU_FLAG_CMOV },
424  { "MMXEXT", "mmxext", AV_CPU_FLAG_MMXEXT },
425  { "SSE", "sse", AV_CPU_FLAG_SSE },
426  { "SSE2", "sse2", AV_CPU_FLAG_SSE2|AV_CPU_FLAG_SSE2SLOW },
427  { "SSE3", "sse3", AV_CPU_FLAG_SSE3|AV_CPU_FLAG_SSE3SLOW },
428  { "SSSE3", "ssse3", AV_CPU_FLAG_SSSE3|AV_CPU_FLAG_ATOM },
429  { "SSE4.1", "sse4", AV_CPU_FLAG_SSE4 },
430  { "SSE4.2", "sse42", AV_CPU_FLAG_SSE42 },
431  { "AES-NI", "aesni", AV_CPU_FLAG_AESNI },
432  { "CLMUL", "clmul", AV_CPU_FLAG_CLMUL },
433  { "AVX", "avx", AV_CPU_FLAG_AVX },
434  { "XOP", "xop", AV_CPU_FLAG_XOP },
435  { "FMA3", "fma3", AV_CPU_FLAG_FMA3 },
436  { "FMA4", "fma4", AV_CPU_FLAG_FMA4 },
437  { "AVX2", "avx2", AV_CPU_FLAG_AVX2 },
438  { "AVX-512", "avx512", AV_CPU_FLAG_AVX512 },
439  { "AVX-512ICL", "avx512icl", AV_CPU_FLAG_AVX512ICL },
440 #elif ARCH_LOONGARCH
441  { "LSX", "lsx", AV_CPU_FLAG_LSX },
442  { "LASX", "lasx", AV_CPU_FLAG_LASX },
443 #elif ARCH_WASM
444  { "SIMD128", "simd128", AV_CPU_FLAG_SIMD128 },
445 #endif
446  { NULL }
447 };
448 
449 typedef struct CheckasmFuncVersion {
451  void *func;
452  int ok;
453  int cpu;
456 
457 /* Binary search tree node */
458 typedef struct CheckasmFunc {
459  struct CheckasmFunc *child[2];
461  uint8_t color; /* 0 = red, 1 = black */
462  char name[1];
463 } CheckasmFunc;
464 
465 /* Internal state */
466 static struct {
470  const char *current_test_name;
471  const char *bench_pattern;
475 
476  /* perf */
477  int nop_time;
478  int sysfd;
479 
480  int cpu_flag;
481  const char *cpu_flag_name;
482  const char *test_pattern;
483  int verbose;
484  int csv;
485  int tsv;
486  volatile sig_atomic_t catch_signals;
487 } state;
488 
489 /* PRNG state */
491 
492 /* float compare support code */
493 static int is_negative(union av_intfloat32 u)
494 {
495  return u.i >> 31;
496 }
497 
498 int float_near_ulp(float a, float b, unsigned max_ulp)
499 {
500  union av_intfloat32 x, y;
501 
502  x.f = a;
503  y.f = b;
504 
505  if (is_negative(x) != is_negative(y)) {
506  // handle -0.0 == +0.0
507  return a == b;
508  }
509 
510  if (llabs((int64_t)x.i - y.i) <= max_ulp)
511  return 1;
512 
513  return 0;
514 }
515 
516 int float_near_ulp_array(const float *a, const float *b, unsigned max_ulp,
517  unsigned len)
518 {
519  unsigned i;
520 
521  for (i = 0; i < len; i++) {
522  if (!float_near_ulp(a[i], b[i], max_ulp))
523  return 0;
524  }
525  return 1;
526 }
527 
528 int float_near_abs_eps(float a, float b, float eps)
529 {
530  float abs_diff = fabsf(a - b);
531  if (abs_diff < eps)
532  return 1;
533 
534  fprintf(stderr, "test failed comparing %g with %g (abs diff=%g with EPS=%g)\n", a, b, abs_diff, eps);
535 
536  return 0;
537 }
538 
539 int float_near_abs_eps_array(const float *a, const float *b, float eps,
540  unsigned len)
541 {
542  unsigned i;
543 
544  for (i = 0; i < len; i++) {
545  if (!float_near_abs_eps(a[i], b[i], eps))
546  return 0;
547  }
548  return 1;
549 }
550 
551 int float_near_abs_eps_ulp(float a, float b, float eps, unsigned max_ulp)
552 {
553  return float_near_ulp(a, b, max_ulp) || float_near_abs_eps(a, b, eps);
554 }
555 
556 int float_near_abs_eps_array_ulp(const float *a, const float *b, float eps,
557  unsigned max_ulp, unsigned len)
558 {
559  unsigned i;
560 
561  for (i = 0; i < len; i++) {
562  if (!float_near_abs_eps_ulp(a[i], b[i], eps, max_ulp))
563  return 0;
564  }
565  return 1;
566 }
567 
568 int double_near_abs_eps(double a, double b, double eps)
569 {
570  double abs_diff = fabs(a - b);
571 
572  return abs_diff < eps;
573 }
574 
575 int double_near_abs_eps_array(const double *a, const double *b, double eps,
576  unsigned len)
577 {
578  unsigned i;
579 
580  for (i = 0; i < len; i++) {
581  if (!double_near_abs_eps(a[i], b[i], eps))
582  return 0;
583  }
584  return 1;
585 }
586 
587 /* Print colored text to stderr if the terminal supports it */
588 static void color_printf(int color, const char *fmt, ...)
589 {
590  static int use_color = -1;
591  va_list arg;
592 
593 #if HAVE_SETCONSOLETEXTATTRIBUTE && HAVE_GETSTDHANDLE
594  static HANDLE con;
595  static WORD org_attributes;
596 
597  if (use_color < 0) {
598  CONSOLE_SCREEN_BUFFER_INFO con_info;
599  con = GetStdHandle(STD_ERROR_HANDLE);
600  if (con && con != INVALID_HANDLE_VALUE && GetConsoleScreenBufferInfo(con, &con_info)) {
601  org_attributes = con_info.wAttributes;
602  use_color = 1;
603  } else
604  use_color = 0;
605  }
606  if (use_color)
607  SetConsoleTextAttribute(con, (org_attributes & 0xfff0) | (color & 0x0f));
608 #else
609  if (use_color < 0) {
610  const char *term = getenv("TERM");
611  use_color = term && strcmp(term, "dumb") && isatty(2);
612  }
613  if (use_color)
614  fprintf(stderr, "\x1b[%d;3%dm", (color & 0x08) >> 3, color & 0x07);
615 #endif
616 
617  va_start(arg, fmt);
618  vfprintf(stderr, fmt, arg);
619  va_end(arg);
620 
621  if (use_color) {
622 #if HAVE_SETCONSOLETEXTATTRIBUTE && HAVE_GETSTDHANDLE
623  SetConsoleTextAttribute(con, org_attributes);
624 #else
625  fprintf(stderr, "\x1b[0m");
626 #endif
627  }
628 }
629 
630 /* Deallocate a tree */
632 {
633  if (f) {
634  CheckasmFuncVersion *v = f->versions.next;
635  while (v) {
636  CheckasmFuncVersion *next = v->next;
637  free(v);
638  v = next;
639  }
640 
641  destroy_func_tree(f->child[0]);
642  destroy_func_tree(f->child[1]);
643  free(f);
644  }
645 }
646 
647 /* Allocate a zero-initialized block, clean up and exit on failure */
648 static void *checkasm_malloc(size_t size)
649 {
650  void *ptr = calloc(1, size);
651  if (!ptr) {
652  fprintf(stderr, "checkasm: malloc failed\n");
653  destroy_func_tree(state.funcs);
654  exit(1);
655  }
656  return ptr;
657 }
658 
659 /* Get the suffix of the specified cpu flag */
660 static const char *cpu_suffix(int cpu)
661 {
662  int i = FF_ARRAY_ELEMS(cpus);
663 
664  while (--i >= 0)
665  if (cpu & cpus[i].flag)
666  return cpus[i].suffix;
667 
668  return "c";
669 }
670 
671 static int cmp_nop(const void *a, const void *b)
672 {
673  return *(const uint16_t*)a - *(const uint16_t*)b;
674 }
675 
676 /* Measure the overhead of the timing code (in decicycles) */
677 static int measure_nop_time(void)
678 {
679  uint16_t nops[10000];
680  int i, nop_sum = 0;
681  av_unused const int sysfd = state.sysfd;
682 
683  uint64_t t = 0;
684  for (i = 0; i < 10000; i++) {
685  PERF_START(t);
686  PERF_STOP(t);
687  nops[i] = t;
688  }
689 
690  qsort(nops, 10000, sizeof(uint16_t), cmp_nop);
691  for (i = 2500; i < 7500; i++)
692  nop_sum += nops[i];
693 
694  return nop_sum / 500;
695 }
696 
697 static inline double avg_cycles_per_call(const CheckasmPerf *const p)
698 {
699  if (p->iterations) {
700  const double cycles = (double)(10 * p->cycles) / p->iterations - state.nop_time;
701  if (cycles > 0.0)
702  return cycles / 32.0; /* 32 calls per iteration */
703  }
704  return 0.0;
705 }
706 
707 /* Print benchmark results */
709 {
710  if (f) {
711  CheckasmFuncVersion *v = &f->versions;
712  const CheckasmPerf *p = &v->perf;
713  const double baseline = avg_cycles_per_call(p);
714  double decicycles;
715 
716  print_benchs(f->child[0]);
717 
718  do {
719  if (p->iterations) {
720  p = &v->perf;
721  decicycles = avg_cycles_per_call(p);
722  if (state.csv || state.tsv) {
723  const char sep = state.csv ? ',' : '\t';
724  printf("%s%c%s%c%.1f\n", f->name, sep,
725  cpu_suffix(v->cpu), sep,
726  decicycles / 10.0);
727  } else {
728  const int pad_length = 10 + 50 -
729  printf("%s_%s:", f->name, cpu_suffix(v->cpu));
730  const double ratio = decicycles ?
731  baseline / decicycles : 0.0;
732  printf("%*.1f (%5.2fx)\n", FFMAX(pad_length, 0),
733  decicycles / 10.0, ratio);
734  }
735  }
736  } while ((v = v->next));
737 
738  print_benchs(f->child[1]);
739  }
740 }
741 
742 /* ASCIIbetical sort except preserving natural order for numbers */
743 static int cmp_func_names(const char *a, const char *b)
744 {
745  const char *start = a;
746  int ascii_diff, digit_diff;
747 
748  for (; !(ascii_diff = *(const unsigned char*)a - *(const unsigned char*)b) && *a; a++, b++);
749  for (; av_isdigit(*a) && av_isdigit(*b); a++, b++);
750 
751  if (a > start && av_isdigit(a[-1]) && (digit_diff = av_isdigit(*a) - av_isdigit(*b)))
752  return digit_diff;
753 
754  return ascii_diff;
755 }
756 
757 /* Perform a tree rotation in the specified direction and return the new root */
759 {
760  CheckasmFunc *r = f->child[dir^1];
761  f->child[dir^1] = r->child[dir];
762  r->child[dir] = f;
763  r->color = f->color;
764  f->color = 0;
765  return r;
766 }
767 
768 #define is_red(f) ((f) && !(f)->color)
769 
770 /* Balance a left-leaning red-black tree at the specified node */
771 static void balance_tree(CheckasmFunc **root)
772 {
773  CheckasmFunc *f = *root;
774 
775  if (is_red(f->child[0]) && is_red(f->child[1])) {
776  f->color ^= 1;
777  f->child[0]->color = f->child[1]->color = 1;
778  }
779 
780  if (!is_red(f->child[0]) && is_red(f->child[1]))
781  *root = rotate_tree(f, 0); /* Rotate left */
782  else if (is_red(f->child[0]) && is_red(f->child[0]->child[0]))
783  *root = rotate_tree(f, 1); /* Rotate right */
784 }
785 
786 /* Get a node with the specified name, creating it if it doesn't exist */
787 static CheckasmFunc *get_func(CheckasmFunc **root, const char *name)
788 {
789  CheckasmFunc *f = *root;
790 
791  if (f) {
792  /* Search the tree for a matching node */
793  int cmp = cmp_func_names(name, f->name);
794  if (cmp) {
795  f = get_func(&f->child[cmp > 0], name);
796 
797  /* Rebalance the tree on the way up if a new node was inserted */
798  if (!f->versions.func)
799  balance_tree(root);
800  }
801  } else {
802  /* Allocate and insert a new node into the tree */
803  int name_length = strlen(name);
804  f = *root = checkasm_malloc(sizeof(CheckasmFunc) + name_length);
805  memcpy(f->name, name, name_length + 1);
806  }
807 
808  return f;
809 }
810 
812 
813 /* Crash handling: attempt to catch crashes and handle them
814  * gracefully instead of just aborting abruptly. */
815 #ifdef _WIN32
816 #if WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP)
817 static LONG NTAPI signal_handler(EXCEPTION_POINTERS *e) {
818  int s;
819 
820  if (!state.catch_signals)
821  return EXCEPTION_CONTINUE_SEARCH;
822 
823  switch (e->ExceptionRecord->ExceptionCode) {
824  case EXCEPTION_FLT_DIVIDE_BY_ZERO:
825  case EXCEPTION_INT_DIVIDE_BY_ZERO:
826  s = SIGFPE;
827  break;
828  case EXCEPTION_ILLEGAL_INSTRUCTION:
829  case EXCEPTION_PRIV_INSTRUCTION:
830  s = SIGILL;
831  break;
832  case EXCEPTION_ACCESS_VIOLATION:
833  case EXCEPTION_ARRAY_BOUNDS_EXCEEDED:
834  case EXCEPTION_DATATYPE_MISALIGNMENT:
835  case EXCEPTION_STACK_OVERFLOW:
836  s = SIGSEGV;
837  break;
838  case EXCEPTION_IN_PAGE_ERROR:
839  s = SIGBUS;
840  break;
841  default:
842  return EXCEPTION_CONTINUE_SEARCH;
843  }
844  state.catch_signals = 0;
846  return EXCEPTION_CONTINUE_EXECUTION; /* never reached, but shuts up gcc */
847 }
848 #endif
849 #elif !defined(_WASI_EMULATED_SIGNAL)
850 static void signal_handler(int s);
851 
852 static const struct sigaction signal_handler_act = {
853  .sa_handler = signal_handler,
854  .sa_flags = SA_RESETHAND,
855 };
856 
857 static void signal_handler(int s) {
858  if (state.catch_signals) {
859  state.catch_signals = 0;
860  sigaction(s, &signal_handler_act, NULL);
862  }
863 }
864 #endif
865 
866 /* Compares a string with a wildcard pattern. */
867 static int wildstrcmp(const char *str, const char *pattern)
868 {
869  const char *wild = strchr(pattern, '*');
870  if (wild) {
871  const size_t len = wild - pattern;
872  if (strncmp(str, pattern, len)) return 1;
873  while (*++wild == '*');
874  if (!*wild) return 0;
875  str += len;
876  while (*str && wildstrcmp(str, wild)) str++;
877  return !*str;
878  }
879  return strcmp(str, pattern);
880 }
881 
882 /* Perform tests and benchmarks for the specified cpu flag if supported by the host */
883 static void check_cpu_flag(const char *name, int flag)
884 {
885  int old_cpu_flag = state.cpu_flag;
886 
887  flag |= old_cpu_flag;
888  av_force_cpu_flags(-1);
889  state.cpu_flag = flag & av_get_cpu_flags();
890  av_force_cpu_flags(state.cpu_flag);
891 
892  if (!flag || state.cpu_flag != old_cpu_flag) {
893  int i;
894 
895  state.cpu_flag_name = name;
896  for (i = 0; tests[i].func; i++) {
897  if (state.test_pattern && wildstrcmp(tests[i].name, state.test_pattern))
898  continue;
899  state.current_test_name = tests[i].name;
900  tests[i].func();
901  }
902  }
903 }
904 
905 /* Print the name of the current CPU flag, but only do it once */
906 static void print_cpu_name(void)
907 {
908  if (state.cpu_flag_name) {
909  color_printf(COLOR_YELLOW, "%s:\n", state.cpu_flag_name);
910  state.cpu_flag_name = NULL;
911  }
912 }
913 
914 #if CONFIG_LINUX_PERF
915 static int bench_init_linux(void)
916 {
917  struct perf_event_attr attr = {
918  .type = PERF_TYPE_HARDWARE,
919  .size = sizeof(struct perf_event_attr),
920  .config = PERF_COUNT_HW_CPU_CYCLES,
921  .disabled = 1, // start counting only on demand
922  .exclude_kernel = 1,
923  .exclude_hv = 1,
924 #if !ARCH_X86
925  .exclude_guest = 1,
926 #endif
927  };
928 
929  fprintf(stderr, "benchmarking with Linux Perf Monitoring API\n");
930 
931  state.sysfd = syscall(__NR_perf_event_open, &attr, 0, -1, -1, 0);
932  if (state.sysfd == -1) {
933  perror("perf_event_open");
934  return -1;
935  }
936  return 0;
937 }
938 #elif CONFIG_MACOS_KPERF
939 static int bench_init_kperf(void)
940 {
941  ff_kperf_init();
942  return 0;
943 }
944 #else
945 static int bench_init_ffmpeg(void)
946 {
947 #ifdef AV_READ_TIME
948  if (!checkasm_save_context()) {
950  AV_READ_TIME();
952  } else {
953  fprintf(stderr, "checkasm: unable to execute platform specific timer\n");
954  return -1;
955  }
956  fprintf(stderr, "benchmarking with native FFmpeg timers\n");
957  return 0;
958 #else
959  fprintf(stderr, "checkasm: --bench is not supported on your system\n");
960  return -1;
961 #endif
962 }
963 #endif
964 
965 static int bench_init(void)
966 {
967 #if CONFIG_LINUX_PERF
968  int ret = bench_init_linux();
969 #elif CONFIG_MACOS_KPERF
970  int ret = bench_init_kperf();
971 #else
972  int ret = bench_init_ffmpeg();
973 #endif
974  if (ret < 0)
975  return ret;
976 
977  state.nop_time = measure_nop_time();
978  fprintf(stderr, "nop: %d.%d\n", state.nop_time/10, state.nop_time%10);
979  return 0;
980 }
981 
982 static void bench_uninit(void)
983 {
984 #if CONFIG_LINUX_PERF
985  close(state.sysfd);
986 #endif
987 }
988 
989 static int usage(const char *path)
990 {
991  fprintf(stderr,
992  "Usage: %s [options...] [seed]\n"
993  " --test=<pattern> Run specific test.\n"
994  " --bench Run benchmark.\n"
995  " --csv, --tsv Output results in rows of comma or tab separated values.\n"
996  " --runs=<ptwo> Manual number of benchmark iterations to run 2**<ptwo>.\n"
997  " --verbose Increase verbosity.\n",
998  path);
999  return 1;
1000 }
1001 
1002 int main(int argc, char *argv[])
1003 {
1004  unsigned int seed = av_get_random_seed();
1005  int i, ret = 0;
1006  char arch_info_buf[50] = "";
1007 
1008 #ifdef _WIN32
1009 #if WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP)
1010  AddVectoredExceptionHandler(0, signal_handler);
1011 #endif
1012 #elif !defined(_WASI_EMULATED_SIGNAL)
1013  sigaction(SIGBUS, &signal_handler_act, NULL);
1014  sigaction(SIGFPE, &signal_handler_act, NULL);
1015  sigaction(SIGILL, &signal_handler_act, NULL);
1016  sigaction(SIGSEGV, &signal_handler_act, NULL);
1017 #endif
1018 #if HAVE_PRCTL && defined(PR_SET_UNALIGN)
1019  prctl(PR_SET_UNALIGN, PR_UNALIGN_SIGBUS);
1020 #endif
1021 #if ARCH_ARM && HAVE_ARMV5TE_EXTERNAL
1023  checkasm_checked_call = checkasm_checked_call_vfp;
1024 #endif
1025 
1026  if (!tests[0].func || !cpus[0].flag) {
1027  fprintf(stderr, "checkasm: no tests to perform\n");
1028  return 0;
1029  }
1030 
1031  for (i = 1; i < argc; i++) {
1032  const char *arg = argv[i];
1033  unsigned long l;
1034  char *end;
1035 
1036  if (!strncmp(arg, "--bench", 7)) {
1037  if (bench_init() < 0)
1038  return 1;
1039  if (arg[7] == '=') {
1040  state.bench_pattern = arg + 8;
1041  state.bench_pattern_len = strlen(state.bench_pattern);
1042  } else
1043  state.bench_pattern = "*";
1044  } else if (!strncmp(arg, "--test=", 7)) {
1045  state.test_pattern = arg + 7;
1046  } else if (!strcmp(arg, "--csv")) {
1047  state.csv = 1; state.tsv = 0;
1048  } else if (!strcmp(arg, "--tsv")) {
1049  state.csv = 0; state.tsv = 1;
1050  } else if (!strcmp(arg, "--verbose") || !strcmp(arg, "-v")) {
1051  state.verbose = 1;
1052  } else if (!strncmp(arg, "--runs=", 7)) {
1053  l = strtoul(arg + 7, &end, 10);
1054  if (*end == '\0') {
1055  if (l > 30) {
1056  fprintf(stderr, "checkasm: error: runs exponent must be within the range 0 <= 30\n");
1057  usage(argv[0]);
1058  }
1059  bench_runs = 1U << l;
1060  } else {
1061  return usage(argv[0]);
1062  }
1063  } else if ((l = strtoul(arg, &end, 10)) <= UINT_MAX &&
1064  *end == '\0') {
1065  seed = l;
1066  } else {
1067  return usage(argv[0]);
1068  }
1069  }
1070 
1071 #if ARCH_AARCH64 && HAVE_SVE
1072  if (have_sve(av_get_cpu_flags()))
1073  snprintf(arch_info_buf, sizeof(arch_info_buf),
1074  "SVE %d bits, ", 8 * ff_aarch64_sve_length());
1075 #endif
1076 #if ARCH_AARCH64 && HAVE_SME
1077  if (have_sme(av_get_cpu_flags()))
1078  av_strlcatf(arch_info_buf, sizeof(arch_info_buf),
1079  "SME %d bits, ", 8 * ff_aarch64_sme_length());
1080 #endif
1081 #if ARCH_RISCV && HAVE_RVV
1083  snprintf(arch_info_buf, sizeof (arch_info_buf),
1084  "%zu-bit vectors, ", 8 * ff_get_rv_vlenb());
1085 #endif
1086  fprintf(stderr, "checkasm: %susing random seed %u\n", arch_info_buf, seed);
1088 
1089  if (state.bench_pattern)
1090  fprintf(stderr, "checkasm: bench runs %" PRIu64 " (1 << %i)\n", bench_runs, av_log2(bench_runs));
1091 
1092  check_cpu_flag(NULL, 0);
1093  for (i = 0; cpus[i].flag; i++)
1095 
1096  if (state.num_failed) {
1097  fprintf(stderr, "checkasm: %d of %d tests have failed\n", state.num_failed, state.num_checked);
1098  ret = 1;
1099  } else {
1100  fprintf(stderr, "checkasm: all %d tests passed\n", state.num_checked);
1101  if (state.bench_pattern) {
1102  print_benchs(state.funcs);
1103  }
1104  }
1105 
1106  destroy_func_tree(state.funcs);
1107  bench_uninit();
1108  return ret;
1109 }
1110 
1111 /* Decide whether or not the specified function needs to be tested and
1112  * allocate/initialize data structures if needed. Returns a pointer to a
1113  * reference function if the function should be tested, otherwise NULL */
1114 void *checkasm_check_func(void *func, const char *name, ...)
1115 {
1116  char name_buf[256];
1117  void *ref = func;
1119  int name_length;
1120  va_list arg;
1121 
1122  va_start(arg, name);
1123  name_length = vsnprintf(name_buf, sizeof(name_buf), name, arg);
1124  va_end(arg);
1125 
1126  if (!func || name_length <= 0 || name_length >= sizeof(name_buf))
1127  return NULL;
1128 
1129  state.current_func = get_func(&state.funcs, name_buf);
1130  state.funcs->color = 1;
1131  v = &state.current_func->versions;
1132 
1133  if (v->func) {
1134  CheckasmFuncVersion *prev;
1135  do {
1136  /* Only test functions that haven't already been tested */
1137  if (v->func == func)
1138  return NULL;
1139 
1140  if (v->ok)
1141  ref = v->func;
1142 
1143  prev = v;
1144  } while ((v = v->next));
1145 
1146  v = prev->next = checkasm_malloc(sizeof(CheckasmFuncVersion));
1147  }
1148 
1149  v->func = func;
1150  v->ok = 1;
1151  v->cpu = state.cpu_flag;
1152  state.current_func_ver = v;
1153 
1154  if (state.cpu_flag)
1155  state.num_checked++;
1156 
1157  return ref;
1158 }
1159 
1160 /* Decide whether or not the current function needs to be benchmarked */
1162 {
1163  return !state.num_failed && state.bench_pattern &&
1164  !wildstrcmp(state.current_func->name, state.bench_pattern);
1165 }
1166 
1167 /* Indicate that the current test has failed, return whether verbose printing
1168  * is requested. */
1169 int checkasm_fail_func(const char *msg, ...)
1170 {
1171  if (state.current_func_ver && state.current_func_ver->cpu &&
1172  state.current_func_ver->ok)
1173  {
1174  va_list arg;
1175 
1176  print_cpu_name();
1177  fprintf(stderr, " %s_%s (", state.current_func->name, cpu_suffix(state.current_func_ver->cpu));
1178  va_start(arg, msg);
1179  vfprintf(stderr, msg, arg);
1180  va_end(arg);
1181  fprintf(stderr, ")\n");
1182 
1183  state.current_func_ver->ok = 0;
1184  state.num_failed++;
1185  }
1186  return state.verbose;
1187 }
1188 
1190  state.catch_signals = enabled;
1191 }
1192 
1194  if (s) {
1195 #ifdef __GLIBC__
1196  checkasm_fail_func("fatal signal %d: %s", s, strsignal(s));
1197 #else
1198  checkasm_fail_func(s == SIGFPE ? "fatal arithmetic error" :
1199  s == SIGILL ? "illegal instruction" :
1200  s == SIGBUS ? "bus error" :
1201  "segmentation fault");
1202 #endif
1203  }
1204  return s;
1205 }
1206 
1207 /* Get the benchmark context of the current function */
1209 {
1210  CheckasmPerf *perf = &state.current_func_ver->perf;
1211  memset(perf, 0, sizeof(*perf));
1212  perf->sysfd = state.sysfd;
1213  return perf;
1214 }
1215 
1216 /* Print the outcome of all tests performed since the last time this function was called */
1217 void checkasm_report(const char *name, ...)
1218 {
1219  static int prev_checked, prev_failed, max_length;
1220 
1221  if (state.num_checked > prev_checked) {
1222  int pad_length = max_length + 4;
1223  va_list arg;
1224 
1225  print_cpu_name();
1226  pad_length -= fprintf(stderr, " - %s.", state.current_test_name);
1227  va_start(arg, name);
1228  pad_length -= vfprintf(stderr, name, arg);
1229  va_end(arg);
1230  fprintf(stderr, "%*c", FFMAX(pad_length, 0) + 2, '[');
1231 
1232  if (state.num_failed == prev_failed)
1233  color_printf(COLOR_GREEN, "OK");
1234  else
1235  color_printf(COLOR_RED, "FAILED");
1236  fprintf(stderr, "]\n");
1237 
1238  prev_checked = state.num_checked;
1239  prev_failed = state.num_failed;
1240  } else if (!state.cpu_flag) {
1241  /* Calculate the amount of padding required to make the output vertically aligned */
1242  int length = strlen(state.current_test_name);
1243  va_list arg;
1244 
1245  va_start(arg, name);
1246  length += vsnprintf(NULL, 0, name, arg);
1247  va_end(arg);
1248 
1249  if (length > max_length)
1250  max_length = length;
1251  }
1252 }
1253 
1254 static int check_err(const char *file, int line,
1255  const char *name, int w, int h,
1256  int *err)
1257 {
1258  if (*err)
1259  return 0;
1260  if (!checkasm_fail_func("%s:%d", file, line))
1261  return 1;
1262  *err = 1;
1263  fprintf(stderr, "%s (%dx%d):\n", name, w, h);
1264  return 0;
1265 }
1266 
1267 #define DEF_CHECKASM_CHECK_BODY(compare, type, fmt) \
1268 do { \
1269  int64_t aligned_w = (w - 1LL + align_w) & ~(align_w - 1); \
1270  int64_t aligned_h = (h - 1LL + align_h) & ~(align_h - 1); \
1271  int err = 0; \
1272  int y = 0; \
1273  av_assert0(aligned_w == (int32_t)aligned_w);\
1274  av_assert0(aligned_h == (int32_t)aligned_h);\
1275  stride1 /= sizeof(*buf1); \
1276  stride2 /= sizeof(*buf2); \
1277  for (y = 0; y < h; y++) \
1278  if (!compare(&buf1[y*stride1], &buf2[y*stride2], w)) \
1279  break; \
1280  if (y != h) { \
1281  if (check_err(file, line, name, w, h, &err)) \
1282  return 1; \
1283  for (y = 0; y < h; y++) { \
1284  for (int x = 0; x < w; x++) \
1285  fprintf(stderr, " " fmt, buf1[x]); \
1286  fprintf(stderr, " "); \
1287  for (int x = 0; x < w; x++) \
1288  fprintf(stderr, " " fmt, buf2[x]); \
1289  fprintf(stderr, " "); \
1290  for (int x = 0; x < w; x++) \
1291  fprintf(stderr, "%c", buf1[x] != buf2[x] ? 'x' : '.'); \
1292  buf1 += stride1; \
1293  buf2 += stride2; \
1294  fprintf(stderr, "\n"); \
1295  } \
1296  buf1 -= h*stride1; \
1297  buf2 -= h*stride2; \
1298  } \
1299  for (y = -padding; y < 0; y++) \
1300  if (!compare(&buf1[y*stride1 - padding], &buf2[y*stride2 - padding], \
1301  w + 2*padding)) { \
1302  if (check_err(file, line, name, w, h, &err)) \
1303  return 1; \
1304  fprintf(stderr, " overwrite above\n"); \
1305  break; \
1306  } \
1307  for (y = aligned_h; y < aligned_h + padding; y++) \
1308  if (!compare(&buf1[y*stride1 - padding], &buf2[y*stride2 - padding], \
1309  w + 2*padding)) { \
1310  if (check_err(file, line, name, w, h, &err)) \
1311  return 1; \
1312  fprintf(stderr, " overwrite below\n"); \
1313  break; \
1314  } \
1315  for (y = 0; y < h; y++) \
1316  if (!compare(&buf1[y*stride1 - padding], &buf2[y*stride2 - padding], \
1317  padding)) { \
1318  if (check_err(file, line, name, w, h, &err)) \
1319  return 1; \
1320  fprintf(stderr, " overwrite left\n"); \
1321  break; \
1322  } \
1323  for (y = 0; y < h; y++) \
1324  if (!compare(&buf1[y*stride1 + aligned_w], &buf2[y*stride2 + aligned_w], \
1325  padding)) { \
1326  if (check_err(file, line, name, w, h, &err)) \
1327  return 1; \
1328  fprintf(stderr, " overwrite right\n"); \
1329  break; \
1330  } \
1331  return err; \
1332 } while (0)
1333 
1334 #define cmp_int(a, b, len) (!memcmp(a, b, (len) * sizeof(*(a))))
1335 #define DEF_CHECKASM_CHECK_FUNC(type, fmt) \
1336 int checkasm_check_##type(const char *file, int line, \
1337  const type *buf1, ptrdiff_t stride1, \
1338  const type *buf2, ptrdiff_t stride2, \
1339  int w, int h, const char *name, \
1340  int align_w, int align_h, \
1341  int padding) \
1342 { \
1343  DEF_CHECKASM_CHECK_BODY(cmp_int, type, fmt); \
1344 }
1345 
1346 DEF_CHECKASM_CHECK_FUNC(uint8_t, "%02x")
1347 DEF_CHECKASM_CHECK_FUNC(uint16_t, "%04x")
1348 DEF_CHECKASM_CHECK_FUNC(uint32_t, "%08x")
1349 DEF_CHECKASM_CHECK_FUNC(int16_t, "%6d")
1351 
1352 int checkasm_check_float_ulp(const char *file, int line,
1353  const float *buf1, ptrdiff_t stride1,
1354  const float *buf2, ptrdiff_t stride2,
1355  int w, int h, const char *name,
1356  unsigned max_ulp, int align_w, int align_h,
1357  int padding)
1358 {
1359  #define cmp_float(a, b, len) float_near_ulp_array(a, b, max_ulp, len)
1360  DEF_CHECKASM_CHECK_BODY(cmp_float, float, "%g");
1361  #undef cmp_float
1362 }
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:472
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:631
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:671
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:867
checkasm_lfg
AVLFG checkasm_lfg
Definition: checkasm.c:490
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:539
AV_CPU_FLAG_SSE3SLOW
#define AV_CPU_FLAG_SSE3SLOW
SSE3 supported, but usually not faster.
Definition: cpu.h:42
CheckasmFunc
Definition: checkasm.c:458
checkasm_check_sw_yuv2yuv
void checkasm_check_sw_yuv2yuv(void)
Definition: sw_yuv2yuv.c:130
name
const char * name
Definition: checkasm.c:115
cpus
static const struct @581 cpus[]
checkasm_fail_func
int checkasm_fail_func(const char *msg,...)
Definition: checkasm.c:1169
checkasm_check_png
void checkasm_check_png(void)
Definition: png.c:106
bench_pattern
const char * bench_pattern
Definition: checkasm.c:471
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:156
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:459
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:906
u
#define u(width, name, range_min, range_max)
Definition: cbs_apv.c:68
tests
static const struct @580 tests[]
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:528
b
#define b
Definition: input.c:42
checkasm_check_aacpsdsp
void checkasm_check_aacpsdsp(void)
Definition: aacpsdsp.c:234
bench_uninit
static void bench_uninit(void)
Definition: checkasm.c:982
CheckasmFuncVersion::cpu
int cpu
Definition: checkasm.c:453
cpu_flag
int cpu_flag
Definition: checkasm.c:480
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:660
CheckasmPerf::sysfd
int sysfd
Definition: checkasm.h:353
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:588
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:1002
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:1352
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:568
CheckasmPerf
Definition: checkasm.h:352
current_test_name
const char * current_test_name
Definition: checkasm.c:470
PERF_START
#define PERF_START(t)
Definition: checkasm.h:425
rotate_tree
static CheckasmFunc * rotate_tree(CheckasmFunc *f, int dir)
Definition: checkasm.c:758
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
float_near_abs_eps_ulp
int float_near_abs_eps_ulp(float a, float b, float eps, unsigned max_ulp)
Definition: checkasm.c:551
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:474
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:965
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:449
COLOR_YELLOW
#define COLOR_YELLOW
Definition: checkasm.c:87
nop_time
int nop_time
Definition: checkasm.c:477
CheckasmFuncVersion::perf
CheckasmPerf perf
Definition: checkasm.c:454
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:1217
get_func
static CheckasmFunc * get_func(CheckasmFunc **root, const char *name)
Definition: checkasm.c:787
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:473
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:1189
CheckasmFuncVersion::ok
int ok
Definition: checkasm.c:452
arg
const char * arg
Definition: jacosubdec.c:65
state
static struct @582 state
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:677
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:188
double_near_abs_eps_array
int double_near_abs_eps_array(const double *a, const double *b, double eps, unsigned len)
Definition: checkasm.c:575
checkasm_check_sw_ops
void checkasm_check_sw_ops(void)
Definition: sw_ops.c:906
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:708
current_func
CheckasmFunc * current_func
Definition: checkasm.c:468
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:486
checkasm_check_h264chroma
void checkasm_check_h264chroma(void)
Definition: h264chroma.c:82
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:461
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:484
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:1193
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:113
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:1335
sysfd
int sysfd
Definition: checkasm.c:478
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:451
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
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:556
checkasm_get_perf_context
CheckasmPerf * checkasm_get_perf_context(void)
Definition: checkasm.c:1208
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:493
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:1114
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:450
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:743
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:426
is_red
#define is_red(f)
Definition: checkasm.c:768
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:483
DEF_CHECKASM_CHECK_BODY
#define DEF_CHECKASM_CHECK_BODY(compare, type, fmt)
Definition: checkasm.c:1267
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:811
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:382
checkasm_malloc
static void * checkasm_malloc(size_t size)
Definition: checkasm.c:648
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:857
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:1161
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:481
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:516
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:852
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:383
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
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:482
usage
static int usage(const char *path)
Definition: checkasm.c:989
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:498
current_func_ver
CheckasmFuncVersion * current_func_ver
Definition: checkasm.c:469
check_cpu_flag
static void check_cpu_flag(const char *name, int flag)
Definition: checkasm.c:883
checkasm_context
sigjmp_buf checkasm_context
Definition: checkasm.h:75
bench_init_ffmpeg
static int bench_init_ffmpeg(void)
Definition: checkasm.c:945
checkasm_check_rv34dsp
void checkasm_check_rv34dsp(void)
Definition: rv34dsp.c:129
CheckasmFunc::versions
CheckasmFuncVersion versions
Definition: checkasm.c:460
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:697
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:1254
cpu.h
CheckasmFunc::name
char name[1]
Definition: checkasm.c:462
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:771
AV_CPU_FLAG_ARMV6T2
#define AV_CPU_FLAG_ARMV6T2
Definition: cpu.h:70
tsv
int tsv
Definition: checkasm.c:485
checkasm_check_llvidencdsp
void checkasm_check_llvidencdsp(void)
Definition: llvidencdsp.c:134
funcs
CheckasmFunc * funcs
Definition: checkasm.c:467
checkasm_check_opusdsp
void checkasm_check_opusdsp(void)
Definition: opusdsp.c:86