1 /* motion test. (c) 2001 Fabrice Bellard. */
18 int pix_abs16x16_mmx(uint8_t *blk1
, uint8_t *blk2
, int lx
);
19 int pix_abs16x16_mmx1(uint8_t *blk1
, uint8_t *blk2
, int lx
);
20 int pix_abs16x16_x2_mmx(uint8_t *blk1
, uint8_t *blk2
, int lx
);
21 int pix_abs16x16_x2_mmx1(uint8_t *blk1
, uint8_t *blk2
, int lx
);
22 int pix_abs16x16_x2_c(uint8_t *blk1
, uint8_t *blk2
, int lx
);
23 int pix_abs16x16_y2_mmx(uint8_t *blk1
, uint8_t *blk2
, int lx
);
24 int pix_abs16x16_y2_mmx1(uint8_t *blk1
, uint8_t *blk2
, int lx
);
25 int pix_abs16x16_y2_c(uint8_t *blk1
, uint8_t *blk2
, int lx
);
26 int pix_abs16x16_xy2_mmx(uint8_t *blk1
, uint8_t *blk2
, int lx
);
27 int pix_abs16x16_xy2_mmx1(uint8_t *blk1
, uint8_t *blk2
, int lx
);
28 int pix_abs16x16_xy2_c(uint8_t *blk1
, uint8_t *blk2
, int lx
);
30 typedef int motion_func(uint8_t *blk1
, uint8_t *blk2
, int lx
);
35 uint8_t img1
[WIDTH
* HEIGHT
];
36 uint8_t img2
[WIDTH
* HEIGHT
];
38 void fill_random(uint8_t *tab
, int size
)
43 tab
[i
] = random() % 256;
52 printf("motion-test [-h]\n"
53 "test motion implementations\n");
60 gettimeofday(&tv
,NULL
);
61 return (int64_t)tv
.tv_sec
* 1000000 + tv
.tv_usec
;
68 void test_motion(const char *name
,
69 motion_func
*test_func
, motion_func
*ref_func
)
74 printf("testing '%s'\n", name
);
76 /* test correctness */
77 for(it
=0;it
<20;it
++) {
79 fill_random(img1
, WIDTH
* HEIGHT
);
80 fill_random(img2
, WIDTH
* HEIGHT
);
82 for(y
=0;y
<HEIGHT
-17;y
++) {
83 for(x
=0;x
<WIDTH
-17;x
++) {
84 ptr
= img2
+ y
* WIDTH
+ x
;
85 d1
= test_func(img1
, ptr
, WIDTH
);
86 d2
= ref_func(img1
, ptr
, WIDTH
);
88 printf("error: mmx=%d c=%d\n", d1
, d2
);
98 for(it
=0;it
<NB_ITS
;it
++) {
99 for(y
=0;y
<HEIGHT
-17;y
++) {
100 for(x
=0;x
<WIDTH
-17;x
++) {
101 ptr
= img2
+ y
* WIDTH
+ x
;
102 d1
+= test_func(img1
, ptr
, WIDTH
);
107 dummy
= d1
; /* avoid optimisation */
110 printf(" %0.0f kop/s\n",
111 (double)NB_ITS
* (WIDTH
- 16) * (HEIGHT
- 16) /
112 (double)(ti
/ 1000.0));
116 int main(int argc
, char **argv
)
121 c
= getopt(argc
, argv
, "h");
131 printf("ffmpeg motion test\n");
133 test_motion("mmx", pix_abs16x16_mmx
, pix_abs16x16_c
);
134 test_motion("mmx_x2", pix_abs16x16_x2_mmx
, pix_abs16x16_x2_c
);
135 test_motion("mmx_y2", pix_abs16x16_y2_mmx
, pix_abs16x16_y2_c
);
136 test_motion("mmx_xy2", pix_abs16x16_xy2_mmx
, pix_abs16x16_xy2_c
);