2 * (c) 2001 Fabrice Bellard
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2 of the License, or (at your option) any later version.
9 * This library 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 GNU
12 * Lesser General Public License for more details.
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with this library; if not, write to the Free Software
16 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
34 int pix_abs16x16_mmx(uint8_t *blk1, uint8_t *blk2, int lx);
35 int pix_abs16x16_mmx1(uint8_t *blk1, uint8_t *blk2, int lx);
36 int pix_abs16x16_x2_mmx(uint8_t *blk1, uint8_t *blk2, int lx);
37 int pix_abs16x16_x2_mmx1(uint8_t *blk1, uint8_t *blk2, int lx);
38 int pix_abs16x16_x2_c(uint8_t *blk1, uint8_t *blk2, int lx);
39 int pix_abs16x16_y2_mmx(uint8_t *blk1, uint8_t *blk2, int lx);
40 int pix_abs16x16_y2_mmx1(uint8_t *blk1, uint8_t *blk2, int lx);
41 int pix_abs16x16_y2_c(uint8_t *blk1, uint8_t *blk2, int lx);
42 int pix_abs16x16_xy2_mmx(uint8_t *blk1, uint8_t *blk2, int lx);
43 int pix_abs16x16_xy2_mmx1(uint8_t *blk1, uint8_t *blk2, int lx);
44 int pix_abs16x16_xy2_c(uint8_t *blk1, uint8_t *blk2, int lx);
46 typedef int motion_func(uint8_t *blk1, uint8_t *blk2, int lx);
51 uint8_t img1[WIDTH * HEIGHT];
52 uint8_t img2[WIDTH * HEIGHT];
54 void fill_random(uint8_t *tab, int size)
59 tab[i] = random() % 256;
68 printf("motion-test [-h]\n"
69 "test motion implementations\n");
76 gettimeofday(&tv,NULL);
77 return (int64_t)tv.tv_sec * 1000000 + tv.tv_usec;
84 void test_motion(const char *name,
85 motion_func *test_func, motion_func *ref_func)
90 printf("testing '%s'\n", name);
92 /* test correctness */
93 for(it=0;it<20;it++) {
95 fill_random(img1, WIDTH * HEIGHT);
96 fill_random(img2, WIDTH * HEIGHT);
98 for(y=0;y<HEIGHT-17;y++) {
99 for(x=0;x<WIDTH-17;x++) {
100 ptr = img2 + y * WIDTH + x;
101 d1 = test_func(img1, ptr, WIDTH);
102 d2 = ref_func(img1, ptr, WIDTH);
104 printf("error: mmx=%d c=%d\n", d1, d2);
114 for(it=0;it<NB_ITS;it++) {
115 for(y=0;y<HEIGHT-17;y++) {
116 for(x=0;x<WIDTH-17;x++) {
117 ptr = img2 + y * WIDTH + x;
118 d1 += test_func(img1, ptr, WIDTH);
123 dummy = d1; /* avoid optimisation */
126 printf(" %0.0f kop/s\n",
127 (double)NB_ITS * (WIDTH - 16) * (HEIGHT - 16) /
128 (double)(ti / 1000.0));
132 int main(int argc, char **argv)
137 c = getopt(argc, argv, "h");
147 printf("ffmpeg motion test\n");
149 test_motion("mmx", pix_abs16x16_mmx, pix_abs16x16_c);
150 test_motion("mmx_x2", pix_abs16x16_x2_mmx, pix_abs16x16_x2_c);
151 test_motion("mmx_y2", pix_abs16x16_y2_mmx, pix_abs16x16_y2_c);
152 test_motion("mmx_xy2", pix_abs16x16_xy2_mmx, pix_abs16x16_xy2_c);