1 /* motion test. (c) 2001 Fabrice Bellard. */
13 int pix_abs16x16_mmx(UINT8 *blk1, UINT8 *blk2, int lx);
14 int pix_abs16x16_mmx1(UINT8 *blk1, UINT8 *blk2, int lx);
15 int pix_abs16x16_x2_mmx(UINT8 *blk1, UINT8 *blk2, int lx);
16 int pix_abs16x16_x2_mmx1(UINT8 *blk1, UINT8 *blk2, int lx);
17 int pix_abs16x16_x2_c(UINT8 *blk1, UINT8 *blk2, int lx);
18 int pix_abs16x16_y2_mmx(UINT8 *blk1, UINT8 *blk2, int lx);
19 int pix_abs16x16_y2_mmx1(UINT8 *blk1, UINT8 *blk2, int lx);
20 int pix_abs16x16_y2_c(UINT8 *blk1, UINT8 *blk2, int lx);
21 int pix_abs16x16_xy2_mmx(UINT8 *blk1, UINT8 *blk2, int lx);
22 int pix_abs16x16_xy2_mmx1(UINT8 *blk1, UINT8 *blk2, int lx);
23 int pix_abs16x16_xy2_c(UINT8 *blk1, UINT8 *blk2, int lx);
25 typedef int motion_func(UINT8 *blk1, UINT8 *blk2, int lx);
30 UINT8 img1[WIDTH * HEIGHT];
31 UINT8 img2[WIDTH * HEIGHT];
33 void fill_random(UINT8 *tab, int size)
38 tab[i] = random() % 256;
47 printf("motion-test [-h]\n"
48 "test motion implementations\n");
55 gettimeofday(&tv,NULL);
56 return (INT64)tv.tv_sec * 1000000 + tv.tv_usec;
63 void test_motion(const char *name,
64 motion_func *test_func, motion_func *ref_func)
69 printf("testing '%s'\n", name);
71 /* test correctness */
72 for(it=0;it<20;it++) {
74 fill_random(img1, WIDTH * HEIGHT);
75 fill_random(img2, WIDTH * HEIGHT);
77 for(y=0;y<HEIGHT-17;y++) {
78 for(x=0;x<WIDTH-17;x++) {
79 ptr = img2 + y * WIDTH + x;
80 d1 = test_func(img1, ptr, WIDTH);
81 d2 = ref_func(img1, ptr, WIDTH);
83 printf("error: mmx=%d c=%d\n", d1, d2);
93 for(it=0;it<NB_ITS;it++) {
94 for(y=0;y<HEIGHT-17;y++) {
95 for(x=0;x<WIDTH-17;x++) {
96 ptr = img2 + y * WIDTH + x;
97 d1 += test_func(img1, ptr, WIDTH);
102 dummy = d1; /* avoid optimisation */
105 printf(" %0.0f kop/s\n",
106 (double)NB_ITS * (WIDTH - 16) * (HEIGHT - 16) /
107 (double)(ti / 1000.0));
111 int main(int argc, char **argv)
116 c = getopt(argc, argv, "h");
126 printf("ffmpeg motion test\n");
128 test_motion("mmx", pix_abs16x16_mmx, pix_abs16x16_c);
129 test_motion("mmx_x2", pix_abs16x16_x2_mmx, pix_abs16x16_x2_c);
130 test_motion("mmx_y2", pix_abs16x16_y2_mmx, pix_abs16x16_y2_c);
131 test_motion("mmx_xy2", pix_abs16x16_xy2_mmx, pix_abs16x16_xy2_c);