]> git.sesse.net Git - ffmpeg/blob - tests/checkasm/videodsp.c
avutil: remove deprecated AVClass.child_class_next
[ffmpeg] / tests / checkasm / videodsp.c
1 /*
2  * Copyright (c) 2016 Ronald S. Bultje <rsbultje@gmail.com>
3  *
4  * This file is part of FFmpeg.
5  *
6  * FFmpeg is free software; you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License as published by
8  * the Free Software Foundation; either version 2 of the License, or
9  * (at your option) any later version.
10  *
11  * FFmpeg is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License along
17  * with FFmpeg; if not, write to the Free Software Foundation, Inc.,
18  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
19  */
20
21 #include <string.h>
22 #include "checkasm.h"
23 #include "libavcodec/videodsp.h"
24 #include "libavutil/internal.h"
25 #include "libavutil/intreadwrite.h"
26 #include "libavutil/mem_internal.h"
27
28 #define randomize_buffers(w, h)                         \
29     do {                                                \
30         int i;                                          \
31         for (i = 0; i < w * h * sizeof(*src0); i += 4)  \
32             AV_WN32A(((uint8_t *) src0) + i, rnd());    \
33     } while (0)
34
35 #define iter_1d(type, fix, fix_val, var, var_start, var_end)        \
36     for (fix = fix_val, var = var_start; var <= var_end; var++) {   \
37         call_ref((type *) dst0, (const type *) (src0 + y * pw + x), \
38                  bw * sizeof(type), pw * sizeof(type),              \
39                  bw, bh, x, y, pw, ph);                             \
40         call_new((type *) dst1, (const type *) (src1 + y * pw + x), \
41                  bw * sizeof(type), pw * sizeof(type),              \
42                  bw, bh, x, y, pw, ph);                             \
43         if (memcmp(dst0, dst1, bw * bh * sizeof(type)))             \
44             fail();                                                 \
45         bench_new((type *) dst1, (const type *) (src1 + y * pw + x),\
46                   bw * sizeof(type), pw * sizeof(type),             \
47                   bw, bh, x, y, pw, ph);                            \
48     }
49
50 #define check_emu_edge_size(type, src_w, src_h, dst_w, dst_h)   \
51     do {                                                        \
52         LOCAL_ALIGNED_16(type, src0, [src_w * src_h]);          \
53         LOCAL_ALIGNED_16(type, src1, [src_w * src_h]);          \
54         int bw = dst_w, bh = dst_h;                             \
55         int pw = src_w, ph = src_h;                             \
56         int y, x;                                               \
57         randomize_buffers(src_w, src_h);                        \
58         memcpy(src1, src0, pw * ph * sizeof(type));             \
59         iter_1d(type, y, 0 - src_h, x, 0 - src_w, src_w - 0);   \
60         iter_1d(type, x, src_w - 0, y, 0 - src_h, src_h - 0);   \
61         iter_1d(type, y, src_h - 0, x, 0 - src_w, src_w - 0);   \
62         iter_1d(type, x, 0 - src_w, y, 0 - src_h, src_h - 0);   \
63     } while (0)
64
65 #define check_emu_edge(type)                                    \
66     do {                                                        \
67         LOCAL_ALIGNED_16(type, dst0, [64 * 64]);                \
68         LOCAL_ALIGNED_16(type, dst1, [64 * 64]);                \
69         declare_func_emms(AV_CPU_FLAG_MMX | AV_CPU_FLAG_MMXEXT, \
70                           void, type *dst, const type *src,     \
71                           ptrdiff_t dst_linesize,               \
72                           ptrdiff_t src_linesize,               \
73                           int block_w, int block_h,             \
74                           int src_x, int src_y,                 \
75                           int src_w, int src_h);                \
76         check_emu_edge_size(type, 16,  1, 64, 64);              \
77         check_emu_edge_size(type, 16, 16, 64, 64);              \
78         check_emu_edge_size(type, 64, 64, 64, 64);              \
79     } while (0)
80
81 void checkasm_check_videodsp(void)
82 {
83     VideoDSPContext vdsp;
84
85     ff_videodsp_init(&vdsp, 8);
86     if (check_func(vdsp.emulated_edge_mc, "emulated_edge_mc_8"))
87         check_emu_edge(uint8_t);
88
89     report("emulated_edge_mc");
90 }