2 * This file is part of FFmpeg.
4 * FFmpeg is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; either version 2 of the License, or
7 * (at your option) any later version.
9 * FFmpeg is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
14 * You should have received a copy of the GNU General Public License along
15 * with FFmpeg; if not, write to the Free Software Foundation, Inc.,
16 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
22 #include "libavfilter/gblur.h"
26 #define PIXELS (WIDTH * HEIGHT)
27 #define BUF_SIZE (PIXELS * 4)
29 #define randomize_buffers(buf, size) \
32 float *tmp_buf = (float *)buf; \
33 for (j = 0; j < size; j++) \
34 tmp_buf[j] = (float)(rnd() & 0xFF); \
37 static void check_horiz_slice(float *dst_ref, float *dst_new)
41 float bscale = 1.112f;
43 declare_func(void, float *dst, int w, int h, int steps, float nu, float bscale);
44 call_ref(dst_ref, WIDTH, HEIGHT, steps, nu, bscale);
45 call_new(dst_new, WIDTH, HEIGHT, steps, nu, bscale);
46 if (!float_near_abs_eps_array(dst_ref, dst_new, 0.01f, PIXELS)) {
49 bench_new(dst_new, WIDTH, HEIGHT, 1, nu, bscale);
52 static void check_postscale_slice(float *dst_ref, float *dst_new)
54 float postscale = 0.0603f;
56 declare_func(void, float *dst, int len, float postscale, float min, float max);
57 call_ref(dst_ref, PIXELS, postscale, -FLT_MAX, FLT_MAX);
58 call_new(dst_new, PIXELS, postscale, -FLT_MAX, FLT_MAX);
59 if (!float_near_abs_eps_array(dst_ref, dst_new, FLT_EPSILON, PIXELS)) {
62 bench_new(dst_new, PIXELS, postscale, -FLT_MAX, FLT_MAX);
65 void checkasm_check_vf_gblur(void)
67 float *dst_ref = av_malloc(BUF_SIZE);
68 float *dst_new = av_malloc(BUF_SIZE);
71 randomize_buffers(dst_ref, PIXELS);
72 memcpy(dst_new, dst_ref, BUF_SIZE);
76 if (check_func(s.horiz_slice, "horiz_slice")) {
77 check_horiz_slice(dst_ref, dst_new);
79 report("horiz_slice");
81 randomize_buffers(dst_ref, PIXELS);
82 memcpy(dst_new, dst_ref, BUF_SIZE);
83 if (check_func(s.postscale_slice, "postscale_slice")) {
84 check_postscale_slice(dst_ref, dst_new);
86 report("postscale_slice");