FFmpeg
vf_gblur.c
Go to the documentation of this file.
1 /*
2  * This file is part of FFmpeg.
3  *
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.
8  *
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.
13  *
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.
17  */
18 
19 #include <string.h>
20 #include "checkasm.h"
21 #include "libavfilter/gblur.h"
22 
23 #define WIDTH 256
24 #define HEIGHT 256
25 #define PIXELS (WIDTH * HEIGHT)
26 #define BUF_SIZE (PIXELS * 4)
27 
28 #define randomize_buffers(buf, size) \
29  do { \
30  int j; \
31  float *tmp_buf = (float *)buf; \
32  for (j = 0; j < size; j++) \
33  tmp_buf[j] = (float)(rnd() & 0xFF); \
34  } while (0)
35 
37 {
38  float *dst_ref = av_malloc(BUF_SIZE);
39  float *dst_new = av_malloc(BUF_SIZE);
40  int w = WIDTH;
41  int h = HEIGHT;
42  int steps = 2;
43  float nu = 0.101f;
44  float bscale = 1.112f;
46 
47  declare_func(void, float *dst, int w, int h, int steps, float nu, float bscale);
48 
49  randomize_buffers(dst_ref, PIXELS);
50  memcpy(dst_new, dst_ref, BUF_SIZE);
51 
52  ff_gblur_init(&s);
53 
54  if (check_func(s.horiz_slice, "horiz_slice")) {
55  call_ref(dst_ref, w, h, steps, nu, bscale);
56  call_new(dst_new, w, h, steps, nu, bscale);
57 
58  if (!float_near_abs_eps_array(dst_ref, dst_new, 0.01f, PIXELS)) {
59  fail();
60  }
61  bench_new(dst_new, w, h, 1, nu, bscale);
62  }
63  report("horiz_slice");
64  av_freep(&dst_ref);
65  av_freep(&dst_new);
66 }
int float_near_abs_eps_array(const float *a, const float *b, float eps, unsigned len)
Definition: checkasm.c:320
#define report
Definition: checkasm.h:124
#define av_malloc(s)
#define f(width, name)
Definition: cbs_vp9.c:255
void(* horiz_slice)(float *buffer, int width, int height, int steps, float nu, float bscale)
Definition: gblur.h:51
#define BUF_SIZE
Definition: vf_gblur.c:26
#define declare_func(ret,...)
Definition: checkasm.h:116
#define fail()
Definition: checkasm.h:121
void checkasm_check_vf_gblur(void)
Definition: vf_gblur.c:36
uint8_t w
Definition: llviddspenc.c:38
#define s(width, name)
Definition: cbs_vp9.c:257
#define WIDTH
Definition: vf_gblur.c:23
#define PIXELS
Definition: vf_gblur.c:25
#define call_ref(...)
Definition: checkasm.h:127
#define randomize_buffers(buf, size)
Definition: vf_gblur.c:28
void ff_gblur_init(GBlurContext *s)
Definition: vf_gblur.c:219
#define check_func(func,...)
Definition: checkasm.h:112
#define HEIGHT
Definition: vf_gblur.c:24
#define bench_new(...)
Definition: checkasm.h:254
#define av_freep(p)
#define call_new(...)
Definition: checkasm.h:194