1 /*
2 *
3 * This file is part of FFmpeg.
4 *
5 * FFmpeg is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
9 *
10 * FFmpeg is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License along
16 * with FFmpeg; if not, write to the Free Software Foundation, Inc.,
17 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
18 */
19
20 #include <string.h>
21
25
27
29
31 {
35 }
36 }
37
39 {
40 /* test configurarion */
41 #define ITERATIONS 16
42 #define WIDTH 64
43 #define HEIGHT 64
44
45 /* motion estimation can look up to 17 bytes ahead */
46 static const int look_ahead = 17;
47
48 int i, x, y,
h, d1, d2;
49 uint8_t *ptr;
50
53
55 uint8_t *blk1 /* align width (8 or 16) */,
56 uint8_t *blk2
/* align 1 */, ptrdiff_t
stride,
58
59 if (test_func ==
NULL) {
60 return;
61 }
62
63 /* test correctness */
66
71 // Pick a random h between 4 and 16; pick an even value.
72 h = 4 + ((
rnd() % (16 + 1 - 4)) & ~1);
73
77
78 if (d1 != d2) {
80 printf(
"func: %s, x=%d y=%d h=%d, error: asm=%d c=%d\n",
name, x, y,
h, d1, d2);
81 break;
82 }
83 }
84 // Test with a fixed offset, for benchmark stability
87 }
88 }
89
90 #define ME_CMP_1D_ARRAYS(XX) \
91 XX(sad) \
92 XX(sse) \
93 XX(hadamard8_diff) \
94 XX(vsad) \
95 XX(vsse) \
96 XX(nsse) \
97 XX(me_pre_cmp) \
98 XX(me_cmp) \
99 XX(me_sub_cmp) \
100 XX(mb_cmp) \
101 XX(ildct_cmp) \
102 XX(frame_skip_cmp) \
103 XX(median_sad)
104
105 // tests for functions not yet implemented
106 #if 0
108 XX(quant_psnr) \
110 XX(rd) \
111 XX(w53) \
112 XX(w97) \
113 XX(dct_max) \
114 XX(dct264_sad) \
115
116 #endif
117
119 {
120 char buf[64];
123
124 memset(&me_ctx, 0, sizeof(me_ctx));
125
126 /* allocate AVCodecContext */
129
131
134 snprintf(buf,
sizeof(buf),
"pix_abs_%d_%d",
i, j);
136 }
137 }
138
139 #define XX(me_cmp_array) \
140 for (int i = 0; i < FF_ARRAY_ELEMS(me_ctx.me_cmp_array); i++) { \
141 snprintf(buf, sizeof(buf), #me_cmp_array "_%d", i); \
142 test_motion(buf, me_ctx.me_cmp_array[i]); \
143 }
145 #undef XX
146
148 }
149
151 {
154 }