annotate motion_test.c @ 1103:b05aa3f49cc8 libavcodec

doxygen config file, so ppl just have to call doxygen in the libavcodec dir and a beatifull doxy is generated ;)
author michaelni
date Thu, 06 Mar 2003 10:21:57 +0000
parents b32afefe7d33
children 1e39f273ecd6
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
429
718a22dc121f license/copyright change
glantau
parents: 75
diff changeset
1 /* motion test. (c) 2001 Fabrice Bellard. */
75
bb7d6fe159ad motion test
glantau
parents:
diff changeset
2 #include <stdlib.h>
bb7d6fe159ad motion test
glantau
parents:
diff changeset
3 #include <stdio.h>
bb7d6fe159ad motion test
glantau
parents:
diff changeset
4 #include <string.h>
bb7d6fe159ad motion test
glantau
parents:
diff changeset
5 #include <sys/time.h>
bb7d6fe159ad motion test
glantau
parents:
diff changeset
6 #include <unistd.h>
bb7d6fe159ad motion test
glantau
parents:
diff changeset
7
bb7d6fe159ad motion test
glantau
parents:
diff changeset
8 #include "dsputil.h"
bb7d6fe159ad motion test
glantau
parents:
diff changeset
9
bb7d6fe159ad motion test
glantau
parents:
diff changeset
10 #include "i386/mmx.h"
bb7d6fe159ad motion test
glantau
parents:
diff changeset
11
1064
b32afefe7d33 * UINTX -> uintx_t INTX -> intx_t
kabi
parents: 980
diff changeset
12 int pix_abs16x16_mmx(uint8_t *blk1, uint8_t *blk2, int lx);
b32afefe7d33 * UINTX -> uintx_t INTX -> intx_t
kabi
parents: 980
diff changeset
13 int pix_abs16x16_mmx1(uint8_t *blk1, uint8_t *blk2, int lx);
b32afefe7d33 * UINTX -> uintx_t INTX -> intx_t
kabi
parents: 980
diff changeset
14 int pix_abs16x16_x2_mmx(uint8_t *blk1, uint8_t *blk2, int lx);
b32afefe7d33 * UINTX -> uintx_t INTX -> intx_t
kabi
parents: 980
diff changeset
15 int pix_abs16x16_x2_mmx1(uint8_t *blk1, uint8_t *blk2, int lx);
b32afefe7d33 * UINTX -> uintx_t INTX -> intx_t
kabi
parents: 980
diff changeset
16 int pix_abs16x16_x2_c(uint8_t *blk1, uint8_t *blk2, int lx);
b32afefe7d33 * UINTX -> uintx_t INTX -> intx_t
kabi
parents: 980
diff changeset
17 int pix_abs16x16_y2_mmx(uint8_t *blk1, uint8_t *blk2, int lx);
b32afefe7d33 * UINTX -> uintx_t INTX -> intx_t
kabi
parents: 980
diff changeset
18 int pix_abs16x16_y2_mmx1(uint8_t *blk1, uint8_t *blk2, int lx);
b32afefe7d33 * UINTX -> uintx_t INTX -> intx_t
kabi
parents: 980
diff changeset
19 int pix_abs16x16_y2_c(uint8_t *blk1, uint8_t *blk2, int lx);
b32afefe7d33 * UINTX -> uintx_t INTX -> intx_t
kabi
parents: 980
diff changeset
20 int pix_abs16x16_xy2_mmx(uint8_t *blk1, uint8_t *blk2, int lx);
b32afefe7d33 * UINTX -> uintx_t INTX -> intx_t
kabi
parents: 980
diff changeset
21 int pix_abs16x16_xy2_mmx1(uint8_t *blk1, uint8_t *blk2, int lx);
b32afefe7d33 * UINTX -> uintx_t INTX -> intx_t
kabi
parents: 980
diff changeset
22 int pix_abs16x16_xy2_c(uint8_t *blk1, uint8_t *blk2, int lx);
75
bb7d6fe159ad motion test
glantau
parents:
diff changeset
23
1064
b32afefe7d33 * UINTX -> uintx_t INTX -> intx_t
kabi
parents: 980
diff changeset
24 typedef int motion_func(uint8_t *blk1, uint8_t *blk2, int lx);
75
bb7d6fe159ad motion test
glantau
parents:
diff changeset
25
bb7d6fe159ad motion test
glantau
parents:
diff changeset
26 #define WIDTH 64
bb7d6fe159ad motion test
glantau
parents:
diff changeset
27 #define HEIGHT 64
bb7d6fe159ad motion test
glantau
parents:
diff changeset
28
1064
b32afefe7d33 * UINTX -> uintx_t INTX -> intx_t
kabi
parents: 980
diff changeset
29 uint8_t img1[WIDTH * HEIGHT];
b32afefe7d33 * UINTX -> uintx_t INTX -> intx_t
kabi
parents: 980
diff changeset
30 uint8_t img2[WIDTH * HEIGHT];
75
bb7d6fe159ad motion test
glantau
parents:
diff changeset
31
1064
b32afefe7d33 * UINTX -> uintx_t INTX -> intx_t
kabi
parents: 980
diff changeset
32 void fill_random(uint8_t *tab, int size)
75
bb7d6fe159ad motion test
glantau
parents:
diff changeset
33 {
bb7d6fe159ad motion test
glantau
parents:
diff changeset
34 int i;
bb7d6fe159ad motion test
glantau
parents:
diff changeset
35 for(i=0;i<size;i++) {
bb7d6fe159ad motion test
glantau
parents:
diff changeset
36 #if 1
bb7d6fe159ad motion test
glantau
parents:
diff changeset
37 tab[i] = random() % 256;
bb7d6fe159ad motion test
glantau
parents:
diff changeset
38 #else
bb7d6fe159ad motion test
glantau
parents:
diff changeset
39 tab[i] = i;
bb7d6fe159ad motion test
glantau
parents:
diff changeset
40 #endif
bb7d6fe159ad motion test
glantau
parents:
diff changeset
41 }
bb7d6fe159ad motion test
glantau
parents:
diff changeset
42 }
bb7d6fe159ad motion test
glantau
parents:
diff changeset
43
bb7d6fe159ad motion test
glantau
parents:
diff changeset
44 void help(void)
bb7d6fe159ad motion test
glantau
parents:
diff changeset
45 {
bb7d6fe159ad motion test
glantau
parents:
diff changeset
46 printf("motion-test [-h]\n"
bb7d6fe159ad motion test
glantau
parents:
diff changeset
47 "test motion implementations\n");
bb7d6fe159ad motion test
glantau
parents:
diff changeset
48 exit(1);
bb7d6fe159ad motion test
glantau
parents:
diff changeset
49 }
bb7d6fe159ad motion test
glantau
parents:
diff changeset
50
1064
b32afefe7d33 * UINTX -> uintx_t INTX -> intx_t
kabi
parents: 980
diff changeset
51 int64_t gettime(void)
75
bb7d6fe159ad motion test
glantau
parents:
diff changeset
52 {
bb7d6fe159ad motion test
glantau
parents:
diff changeset
53 struct timeval tv;
bb7d6fe159ad motion test
glantau
parents:
diff changeset
54 gettimeofday(&tv,NULL);
1064
b32afefe7d33 * UINTX -> uintx_t INTX -> intx_t
kabi
parents: 980
diff changeset
55 return (int64_t)tv.tv_sec * 1000000 + tv.tv_usec;
75
bb7d6fe159ad motion test
glantau
parents:
diff changeset
56 }
bb7d6fe159ad motion test
glantau
parents:
diff changeset
57
bb7d6fe159ad motion test
glantau
parents:
diff changeset
58 #define NB_ITS 500
bb7d6fe159ad motion test
glantau
parents:
diff changeset
59
bb7d6fe159ad motion test
glantau
parents:
diff changeset
60 int dummy;
bb7d6fe159ad motion test
glantau
parents:
diff changeset
61
bb7d6fe159ad motion test
glantau
parents:
diff changeset
62 void test_motion(const char *name,
bb7d6fe159ad motion test
glantau
parents:
diff changeset
63 motion_func *test_func, motion_func *ref_func)
bb7d6fe159ad motion test
glantau
parents:
diff changeset
64 {
bb7d6fe159ad motion test
glantau
parents:
diff changeset
65 int x, y, d1, d2, it;
1064
b32afefe7d33 * UINTX -> uintx_t INTX -> intx_t
kabi
parents: 980
diff changeset
66 uint8_t *ptr;
b32afefe7d33 * UINTX -> uintx_t INTX -> intx_t
kabi
parents: 980
diff changeset
67 int64_t ti;
75
bb7d6fe159ad motion test
glantau
parents:
diff changeset
68 printf("testing '%s'\n", name);
bb7d6fe159ad motion test
glantau
parents:
diff changeset
69
bb7d6fe159ad motion test
glantau
parents:
diff changeset
70 /* test correctness */
bb7d6fe159ad motion test
glantau
parents:
diff changeset
71 for(it=0;it<20;it++) {
bb7d6fe159ad motion test
glantau
parents:
diff changeset
72
bb7d6fe159ad motion test
glantau
parents:
diff changeset
73 fill_random(img1, WIDTH * HEIGHT);
bb7d6fe159ad motion test
glantau
parents:
diff changeset
74 fill_random(img2, WIDTH * HEIGHT);
bb7d6fe159ad motion test
glantau
parents:
diff changeset
75
bb7d6fe159ad motion test
glantau
parents:
diff changeset
76 for(y=0;y<HEIGHT-17;y++) {
bb7d6fe159ad motion test
glantau
parents:
diff changeset
77 for(x=0;x<WIDTH-17;x++) {
bb7d6fe159ad motion test
glantau
parents:
diff changeset
78 ptr = img2 + y * WIDTH + x;
644
641708b5c33c fixing tests
michaelni
parents: 429
diff changeset
79 d1 = test_func(img1, ptr, WIDTH);
641708b5c33c fixing tests
michaelni
parents: 429
diff changeset
80 d2 = ref_func(img1, ptr, WIDTH);
75
bb7d6fe159ad motion test
glantau
parents:
diff changeset
81 if (d1 != d2) {
bb7d6fe159ad motion test
glantau
parents:
diff changeset
82 printf("error: mmx=%d c=%d\n", d1, d2);
bb7d6fe159ad motion test
glantau
parents:
diff changeset
83 }
bb7d6fe159ad motion test
glantau
parents:
diff changeset
84 }
bb7d6fe159ad motion test
glantau
parents:
diff changeset
85 }
bb7d6fe159ad motion test
glantau
parents:
diff changeset
86 }
bb7d6fe159ad motion test
glantau
parents:
diff changeset
87 emms();
bb7d6fe159ad motion test
glantau
parents:
diff changeset
88
bb7d6fe159ad motion test
glantau
parents:
diff changeset
89 /* speed test */
bb7d6fe159ad motion test
glantau
parents:
diff changeset
90 ti = gettime();
bb7d6fe159ad motion test
glantau
parents:
diff changeset
91 d1 = 0;
bb7d6fe159ad motion test
glantau
parents:
diff changeset
92 for(it=0;it<NB_ITS;it++) {
bb7d6fe159ad motion test
glantau
parents:
diff changeset
93 for(y=0;y<HEIGHT-17;y++) {
bb7d6fe159ad motion test
glantau
parents:
diff changeset
94 for(x=0;x<WIDTH-17;x++) {
bb7d6fe159ad motion test
glantau
parents:
diff changeset
95 ptr = img2 + y * WIDTH + x;
644
641708b5c33c fixing tests
michaelni
parents: 429
diff changeset
96 d1 += test_func(img1, ptr, WIDTH);
75
bb7d6fe159ad motion test
glantau
parents:
diff changeset
97 }
bb7d6fe159ad motion test
glantau
parents:
diff changeset
98 }
bb7d6fe159ad motion test
glantau
parents:
diff changeset
99 }
bb7d6fe159ad motion test
glantau
parents:
diff changeset
100 emms();
bb7d6fe159ad motion test
glantau
parents:
diff changeset
101 dummy = d1; /* avoid optimisation */
bb7d6fe159ad motion test
glantau
parents:
diff changeset
102 ti = gettime() - ti;
bb7d6fe159ad motion test
glantau
parents:
diff changeset
103
bb7d6fe159ad motion test
glantau
parents:
diff changeset
104 printf(" %0.0f kop/s\n",
bb7d6fe159ad motion test
glantau
parents:
diff changeset
105 (double)NB_ITS * (WIDTH - 16) * (HEIGHT - 16) /
bb7d6fe159ad motion test
glantau
parents:
diff changeset
106 (double)(ti / 1000.0));
bb7d6fe159ad motion test
glantau
parents:
diff changeset
107 }
bb7d6fe159ad motion test
glantau
parents:
diff changeset
108
bb7d6fe159ad motion test
glantau
parents:
diff changeset
109
bb7d6fe159ad motion test
glantau
parents:
diff changeset
110 int main(int argc, char **argv)
bb7d6fe159ad motion test
glantau
parents:
diff changeset
111 {
bb7d6fe159ad motion test
glantau
parents:
diff changeset
112 int c;
bb7d6fe159ad motion test
glantau
parents:
diff changeset
113
bb7d6fe159ad motion test
glantau
parents:
diff changeset
114 for(;;) {
bb7d6fe159ad motion test
glantau
parents:
diff changeset
115 c = getopt(argc, argv, "h");
bb7d6fe159ad motion test
glantau
parents:
diff changeset
116 if (c == -1)
bb7d6fe159ad motion test
glantau
parents:
diff changeset
117 break;
bb7d6fe159ad motion test
glantau
parents:
diff changeset
118 switch(c) {
bb7d6fe159ad motion test
glantau
parents:
diff changeset
119 case 'h':
bb7d6fe159ad motion test
glantau
parents:
diff changeset
120 help();
bb7d6fe159ad motion test
glantau
parents:
diff changeset
121 break;
bb7d6fe159ad motion test
glantau
parents:
diff changeset
122 }
bb7d6fe159ad motion test
glantau
parents:
diff changeset
123 }
bb7d6fe159ad motion test
glantau
parents:
diff changeset
124
bb7d6fe159ad motion test
glantau
parents:
diff changeset
125 printf("ffmpeg motion test\n");
bb7d6fe159ad motion test
glantau
parents:
diff changeset
126
bb7d6fe159ad motion test
glantau
parents:
diff changeset
127 test_motion("mmx", pix_abs16x16_mmx, pix_abs16x16_c);
bb7d6fe159ad motion test
glantau
parents:
diff changeset
128 test_motion("mmx_x2", pix_abs16x16_x2_mmx, pix_abs16x16_x2_c);
bb7d6fe159ad motion test
glantau
parents:
diff changeset
129 test_motion("mmx_y2", pix_abs16x16_y2_mmx, pix_abs16x16_y2_c);
bb7d6fe159ad motion test
glantau
parents:
diff changeset
130 test_motion("mmx_xy2", pix_abs16x16_xy2_mmx, pix_abs16x16_xy2_c);
bb7d6fe159ad motion test
glantau
parents:
diff changeset
131 return 0;
bb7d6fe159ad motion test
glantau
parents:
diff changeset
132 }