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 <assert.h>
20 #include <stddef.h>
21
27
28 enum {
31 /// Horizontal tests operate on 4x8 blocks
33 /// Vertical tests operate on 8x4 blocks
35 };
36
37 #define randomize_buffers(buf0, buf1, size) \
38 do { \
39 static_assert(sizeof(buf0[0]) == 1 && sizeof(buf1[0]) == 1, \
40 "Pointer arithmetic needs to be adapted"); \
41 for (size_t k = 0; k < (size & ~3); k += 4) { \
42 uint32_t r = rnd(); \
43 AV_WN32A(buf0 + k, r); \
44 AV_WN32A(buf1 + k, r); \
45 } \
46 for (size_t k = size & ~3; k < size; ++k) \
47 buf0[k] = buf1[k] = rnd(); \
48 } while (0)
49
50
52 {
58 int *const bounding_values = bounding_values_array + 127;
60 static const struct {
63 int lines_above, lines_below;
64 int pixels_left, pixels_right;
65 unsigned alignment;
66 int horizontal;
68 #define TEST(NAME) .name = #NAME, .offset = offsetof(VP3DSPContext, NAME)
69 {
TEST(v_loop_filter_unaligned), 2, 1, 0, 7, 1, 0 },
70 {
TEST(h_loop_filter_unaligned), 0, 7, 2, 1, 1, 1 },
73 };
75
77
78 int filter_limit =
rnd() % 128;
79
81
83 void (*
loop_filter)(uint8_t *, ptrdiff_t,
int*) = *(
void(**)(uint8_t *, ptrdiff_t,
int*))((
char*)&vp3dsp +
tests[
i].
offset);
84
86 uint8_t *buf0 =
tests[
i].horizontal ? hor_buf0 : ver_buf0;
87 uint8_t *buf1 =
tests[
i].horizontal ? hor_buf1 : ver_buf1;
90 // Don't always use pointers that are aligned to 8.
95
97 // Flip stride.
101 }
102
106 if (memcmp(buf0, buf1, bufsize))
109 }
110 }
111 }
112
114 {
116 }