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/avfilter.h"
22 #include "libavfilter/vf_eq.h"
23 #include "libavutil/intreadwrite.h"
24
25 #define WIDTH 256
26 #define HEIGHT 256
27 #define SRC_STRIDE 256
28 #define PIXELS (WIDTH * HEIGHT)
29 #define RANDOM_RANGE 80000
30 #define SCALE 10000
31
32 #define randomize_buffers(buf, size) \
33 do { \
34 int j; \
35 uint8_t *tmp_buf = (uint8_t *)buf;\
36 for (j = 0; j< size; j++) \
37 tmp_buf[j] = rnd() & 0xFF; \
38 } while (0)
39
check_eq(void)40 static void check_eq(void)
41 {
42 LOCAL_ALIGNED_32(uint8_t, src, [PIXELS]);
43 LOCAL_ALIGNED_32(uint8_t, dst_ref, [PIXELS]);
44 LOCAL_ALIGNED_32(uint8_t, dst_new, [PIXELS]);
45 int w = WIDTH;
46 int h = HEIGHT;
47 int src_stride = SRC_STRIDE;
48 int dst_stride = SRC_STRIDE;
49 EQParameters pa;
50 EQContext eq;
51 declare_func(void, EQParameters *param, uint8_t *dst, int dst_stride,
52 const uint8_t *src, int src_stride, int w, int h);
53
54 double rand_contrast = (int)(rnd() % (RANDOM_RANGE * 2) - RANDOM_RANGE) /
55 (SCALE * 1.0);
56 double rand_brightness = (int)(rnd() % (SCALE * 2) - SCALE) /
57 (SCALE * 1.0);
58 pa.contrast = rand_contrast;
59 pa.brightness = rand_brightness;
60
61 memset(dst_ref, 0, PIXELS);
62 memset(dst_new, 0, PIXELS);
63 randomize_buffers(src, PIXELS);
64 ff_eq_init(&eq);
65
66 if (check_func(eq.process, "process")) {
67 call_ref(&pa, dst_ref, dst_stride, src, src_stride, w, h);
68 call_new(&pa, dst_new, dst_stride, src, src_stride, w, h);
69 if (memcmp(dst_ref, dst_new, PIXELS))
70 fail();
71 bench_new(&pa, dst_new, dst_stride, src, src_stride, w, h);
72 }
73 }
74
checkasm_check_vf_eq(void)75 void checkasm_check_vf_eq(void)
76 {
77 check_eq();
78 report("eq");
79 }
80