annotate motion_test.c @ 3947:c8c591fe26f8 libavcodec

Change license headers to say 'FFmpeg' instead of 'this program/this library' and fix GPL/LGPL version mismatches.
author diego
date Sat, 07 Oct 2006 15:30:46 +0000
parents c537a97eec66
children ff9b6ac5ca2e
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
3699
c537a97eec66 Add official LGPL license headers to the files that were missing them.
diego
parents: 2967
diff changeset
1 /*
c537a97eec66 Add official LGPL license headers to the files that were missing them.
diego
parents: 2967
diff changeset
2 * (c) 2001 Fabrice Bellard
c537a97eec66 Add official LGPL license headers to the files that were missing them.
diego
parents: 2967
diff changeset
3 *
3947
c8c591fe26f8 Change license headers to say 'FFmpeg' instead of 'this program/this library'
diego
parents: 3699
diff changeset
4 * This file is part of FFmpeg.
c8c591fe26f8 Change license headers to say 'FFmpeg' instead of 'this program/this library'
diego
parents: 3699
diff changeset
5 *
c8c591fe26f8 Change license headers to say 'FFmpeg' instead of 'this program/this library'
diego
parents: 3699
diff changeset
6 * FFmpeg is free software; you can redistribute it and/or
3699
c537a97eec66 Add official LGPL license headers to the files that were missing them.
diego
parents: 2967
diff changeset
7 * modify it under the terms of the GNU Lesser General Public
c537a97eec66 Add official LGPL license headers to the files that were missing them.
diego
parents: 2967
diff changeset
8 * License as published by the Free Software Foundation; either
3947
c8c591fe26f8 Change license headers to say 'FFmpeg' instead of 'this program/this library'
diego
parents: 3699
diff changeset
9 * version 2.1 of the License, or (at your option) any later version.
3699
c537a97eec66 Add official LGPL license headers to the files that were missing them.
diego
parents: 2967
diff changeset
10 *
3947
c8c591fe26f8 Change license headers to say 'FFmpeg' instead of 'this program/this library'
diego
parents: 3699
diff changeset
11 * FFmpeg is distributed in the hope that it will be useful,
3699
c537a97eec66 Add official LGPL license headers to the files that were missing them.
diego
parents: 2967
diff changeset
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
c537a97eec66 Add official LGPL license headers to the files that were missing them.
diego
parents: 2967
diff changeset
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
c537a97eec66 Add official LGPL license headers to the files that were missing them.
diego
parents: 2967
diff changeset
14 * Lesser General Public License for more details.
c537a97eec66 Add official LGPL license headers to the files that were missing them.
diego
parents: 2967
diff changeset
15 *
c537a97eec66 Add official LGPL license headers to the files that were missing them.
diego
parents: 2967
diff changeset
16 * You should have received a copy of the GNU Lesser General Public
3947
c8c591fe26f8 Change license headers to say 'FFmpeg' instead of 'this program/this library'
diego
parents: 3699
diff changeset
17 * License along with FFmpeg; if not, write to the Free Software
3699
c537a97eec66 Add official LGPL license headers to the files that were missing them.
diego
parents: 2967
diff changeset
18 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
c537a97eec66 Add official LGPL license headers to the files that were missing them.
diego
parents: 2967
diff changeset
19 */
1106
1e39f273ecd6 per file doxy
michaelni
parents: 1064
diff changeset
20
1e39f273ecd6 per file doxy
michaelni
parents: 1064
diff changeset
21 /**
1e39f273ecd6 per file doxy
michaelni
parents: 1064
diff changeset
22 * @file motion_test.c
1e39f273ecd6 per file doxy
michaelni
parents: 1064
diff changeset
23 * motion test.
1e39f273ecd6 per file doxy
michaelni
parents: 1064
diff changeset
24 */
1e39f273ecd6 per file doxy
michaelni
parents: 1064
diff changeset
25
75
bb7d6fe159ad motion test
glantau
parents:
diff changeset
26 #include <stdlib.h>
bb7d6fe159ad motion test
glantau
parents:
diff changeset
27 #include <stdio.h>
bb7d6fe159ad motion test
glantau
parents:
diff changeset
28 #include <string.h>
bb7d6fe159ad motion test
glantau
parents:
diff changeset
29 #include <sys/time.h>
bb7d6fe159ad motion test
glantau
parents:
diff changeset
30 #include <unistd.h>
bb7d6fe159ad motion test
glantau
parents:
diff changeset
31
bb7d6fe159ad motion test
glantau
parents:
diff changeset
32 #include "dsputil.h"
bb7d6fe159ad motion test
glantau
parents:
diff changeset
33
bb7d6fe159ad motion test
glantau
parents:
diff changeset
34 #include "i386/mmx.h"
bb7d6fe159ad motion test
glantau
parents:
diff changeset
35
1064
b32afefe7d33 * UINTX -> uintx_t INTX -> intx_t
kabi
parents: 980
diff changeset
36 int pix_abs16x16_mmx(uint8_t *blk1, uint8_t *blk2, int lx);
b32afefe7d33 * UINTX -> uintx_t INTX -> intx_t
kabi
parents: 980
diff changeset
37 int pix_abs16x16_mmx1(uint8_t *blk1, uint8_t *blk2, int lx);
b32afefe7d33 * UINTX -> uintx_t INTX -> intx_t
kabi
parents: 980
diff changeset
38 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
39 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
40 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
41 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
42 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
43 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
44 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
45 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
46 int pix_abs16x16_xy2_c(uint8_t *blk1, uint8_t *blk2, int lx);
75
bb7d6fe159ad motion test
glantau
parents:
diff changeset
47
1064
b32afefe7d33 * UINTX -> uintx_t INTX -> intx_t
kabi
parents: 980
diff changeset
48 typedef int motion_func(uint8_t *blk1, uint8_t *blk2, int lx);
75
bb7d6fe159ad motion test
glantau
parents:
diff changeset
49
bb7d6fe159ad motion test
glantau
parents:
diff changeset
50 #define WIDTH 64
bb7d6fe159ad motion test
glantau
parents:
diff changeset
51 #define HEIGHT 64
bb7d6fe159ad motion test
glantau
parents:
diff changeset
52
1064
b32afefe7d33 * UINTX -> uintx_t INTX -> intx_t
kabi
parents: 980
diff changeset
53 uint8_t img1[WIDTH * HEIGHT];
b32afefe7d33 * UINTX -> uintx_t INTX -> intx_t
kabi
parents: 980
diff changeset
54 uint8_t img2[WIDTH * HEIGHT];
75
bb7d6fe159ad motion test
glantau
parents:
diff changeset
55
1064
b32afefe7d33 * UINTX -> uintx_t INTX -> intx_t
kabi
parents: 980
diff changeset
56 void fill_random(uint8_t *tab, int size)
75
bb7d6fe159ad motion test
glantau
parents:
diff changeset
57 {
bb7d6fe159ad motion test
glantau
parents:
diff changeset
58 int i;
bb7d6fe159ad motion test
glantau
parents:
diff changeset
59 for(i=0;i<size;i++) {
bb7d6fe159ad motion test
glantau
parents:
diff changeset
60 #if 1
bb7d6fe159ad motion test
glantau
parents:
diff changeset
61 tab[i] = random() % 256;
bb7d6fe159ad motion test
glantau
parents:
diff changeset
62 #else
bb7d6fe159ad motion test
glantau
parents:
diff changeset
63 tab[i] = i;
bb7d6fe159ad motion test
glantau
parents:
diff changeset
64 #endif
bb7d6fe159ad motion test
glantau
parents:
diff changeset
65 }
bb7d6fe159ad motion test
glantau
parents:
diff changeset
66 }
bb7d6fe159ad motion test
glantau
parents:
diff changeset
67
bb7d6fe159ad motion test
glantau
parents:
diff changeset
68 void help(void)
bb7d6fe159ad motion test
glantau
parents:
diff changeset
69 {
bb7d6fe159ad motion test
glantau
parents:
diff changeset
70 printf("motion-test [-h]\n"
bb7d6fe159ad motion test
glantau
parents:
diff changeset
71 "test motion implementations\n");
bb7d6fe159ad motion test
glantau
parents:
diff changeset
72 exit(1);
bb7d6fe159ad motion test
glantau
parents:
diff changeset
73 }
bb7d6fe159ad motion test
glantau
parents:
diff changeset
74
1064
b32afefe7d33 * UINTX -> uintx_t INTX -> intx_t
kabi
parents: 980
diff changeset
75 int64_t gettime(void)
75
bb7d6fe159ad motion test
glantau
parents:
diff changeset
76 {
bb7d6fe159ad motion test
glantau
parents:
diff changeset
77 struct timeval tv;
bb7d6fe159ad motion test
glantau
parents:
diff changeset
78 gettimeofday(&tv,NULL);
1064
b32afefe7d33 * UINTX -> uintx_t INTX -> intx_t
kabi
parents: 980
diff changeset
79 return (int64_t)tv.tv_sec * 1000000 + tv.tv_usec;
75
bb7d6fe159ad motion test
glantau
parents:
diff changeset
80 }
bb7d6fe159ad motion test
glantau
parents:
diff changeset
81
bb7d6fe159ad motion test
glantau
parents:
diff changeset
82 #define NB_ITS 500
bb7d6fe159ad motion test
glantau
parents:
diff changeset
83
bb7d6fe159ad motion test
glantau
parents:
diff changeset
84 int dummy;
bb7d6fe159ad motion test
glantau
parents:
diff changeset
85
bb7d6fe159ad motion test
glantau
parents:
diff changeset
86 void test_motion(const char *name,
bb7d6fe159ad motion test
glantau
parents:
diff changeset
87 motion_func *test_func, motion_func *ref_func)
bb7d6fe159ad motion test
glantau
parents:
diff changeset
88 {
bb7d6fe159ad motion test
glantau
parents:
diff changeset
89 int x, y, d1, d2, it;
1064
b32afefe7d33 * UINTX -> uintx_t INTX -> intx_t
kabi
parents: 980
diff changeset
90 uint8_t *ptr;
b32afefe7d33 * UINTX -> uintx_t INTX -> intx_t
kabi
parents: 980
diff changeset
91 int64_t ti;
75
bb7d6fe159ad motion test
glantau
parents:
diff changeset
92 printf("testing '%s'\n", name);
bb7d6fe159ad motion test
glantau
parents:
diff changeset
93
bb7d6fe159ad motion test
glantau
parents:
diff changeset
94 /* test correctness */
bb7d6fe159ad motion test
glantau
parents:
diff changeset
95 for(it=0;it<20;it++) {
bb7d6fe159ad motion test
glantau
parents:
diff changeset
96
bb7d6fe159ad motion test
glantau
parents:
diff changeset
97 fill_random(img1, WIDTH * HEIGHT);
bb7d6fe159ad motion test
glantau
parents:
diff changeset
98 fill_random(img2, WIDTH * HEIGHT);
2967
ef2149182f1c COSMETICS: Remove all trailing whitespace.
diego
parents: 1106
diff changeset
99
75
bb7d6fe159ad motion test
glantau
parents:
diff changeset
100 for(y=0;y<HEIGHT-17;y++) {
bb7d6fe159ad motion test
glantau
parents:
diff changeset
101 for(x=0;x<WIDTH-17;x++) {
2967
ef2149182f1c COSMETICS: Remove all trailing whitespace.
diego
parents: 1106
diff changeset
102 ptr = img2 + y * WIDTH + x;
644
641708b5c33c fixing tests
michaelni
parents: 429
diff changeset
103 d1 = test_func(img1, ptr, WIDTH);
641708b5c33c fixing tests
michaelni
parents: 429
diff changeset
104 d2 = ref_func(img1, ptr, WIDTH);
75
bb7d6fe159ad motion test
glantau
parents:
diff changeset
105 if (d1 != d2) {
bb7d6fe159ad motion test
glantau
parents:
diff changeset
106 printf("error: mmx=%d c=%d\n", d1, d2);
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 }
bb7d6fe159ad motion test
glantau
parents:
diff changeset
111 emms();
2967
ef2149182f1c COSMETICS: Remove all trailing whitespace.
diego
parents: 1106
diff changeset
112
75
bb7d6fe159ad motion test
glantau
parents:
diff changeset
113 /* speed test */
bb7d6fe159ad motion test
glantau
parents:
diff changeset
114 ti = gettime();
bb7d6fe159ad motion test
glantau
parents:
diff changeset
115 d1 = 0;
bb7d6fe159ad motion test
glantau
parents:
diff changeset
116 for(it=0;it<NB_ITS;it++) {
bb7d6fe159ad motion test
glantau
parents:
diff changeset
117 for(y=0;y<HEIGHT-17;y++) {
bb7d6fe159ad motion test
glantau
parents:
diff changeset
118 for(x=0;x<WIDTH-17;x++) {
2967
ef2149182f1c COSMETICS: Remove all trailing whitespace.
diego
parents: 1106
diff changeset
119 ptr = img2 + y * WIDTH + x;
644
641708b5c33c fixing tests
michaelni
parents: 429
diff changeset
120 d1 += test_func(img1, ptr, WIDTH);
75
bb7d6fe159ad motion test
glantau
parents:
diff changeset
121 }
bb7d6fe159ad motion test
glantau
parents:
diff changeset
122 }
bb7d6fe159ad motion test
glantau
parents:
diff changeset
123 }
bb7d6fe159ad motion test
glantau
parents:
diff changeset
124 emms();
bb7d6fe159ad motion test
glantau
parents:
diff changeset
125 dummy = d1; /* avoid optimisation */
bb7d6fe159ad motion test
glantau
parents:
diff changeset
126 ti = gettime() - ti;
2967
ef2149182f1c COSMETICS: Remove all trailing whitespace.
diego
parents: 1106
diff changeset
127
ef2149182f1c COSMETICS: Remove all trailing whitespace.
diego
parents: 1106
diff changeset
128 printf(" %0.0f kop/s\n",
ef2149182f1c COSMETICS: Remove all trailing whitespace.
diego
parents: 1106
diff changeset
129 (double)NB_ITS * (WIDTH - 16) * (HEIGHT - 16) /
75
bb7d6fe159ad motion test
glantau
parents:
diff changeset
130 (double)(ti / 1000.0));
bb7d6fe159ad motion test
glantau
parents:
diff changeset
131 }
bb7d6fe159ad motion test
glantau
parents:
diff changeset
132
bb7d6fe159ad motion test
glantau
parents:
diff changeset
133
bb7d6fe159ad motion test
glantau
parents:
diff changeset
134 int main(int argc, char **argv)
bb7d6fe159ad motion test
glantau
parents:
diff changeset
135 {
bb7d6fe159ad motion test
glantau
parents:
diff changeset
136 int c;
2967
ef2149182f1c COSMETICS: Remove all trailing whitespace.
diego
parents: 1106
diff changeset
137
75
bb7d6fe159ad motion test
glantau
parents:
diff changeset
138 for(;;) {
bb7d6fe159ad motion test
glantau
parents:
diff changeset
139 c = getopt(argc, argv, "h");
bb7d6fe159ad motion test
glantau
parents:
diff changeset
140 if (c == -1)
bb7d6fe159ad motion test
glantau
parents:
diff changeset
141 break;
bb7d6fe159ad motion test
glantau
parents:
diff changeset
142 switch(c) {
bb7d6fe159ad motion test
glantau
parents:
diff changeset
143 case 'h':
bb7d6fe159ad motion test
glantau
parents:
diff changeset
144 help();
bb7d6fe159ad motion test
glantau
parents:
diff changeset
145 break;
bb7d6fe159ad motion test
glantau
parents:
diff changeset
146 }
bb7d6fe159ad motion test
glantau
parents:
diff changeset
147 }
2967
ef2149182f1c COSMETICS: Remove all trailing whitespace.
diego
parents: 1106
diff changeset
148
75
bb7d6fe159ad motion test
glantau
parents:
diff changeset
149 printf("ffmpeg motion test\n");
bb7d6fe159ad motion test
glantau
parents:
diff changeset
150
bb7d6fe159ad motion test
glantau
parents:
diff changeset
151 test_motion("mmx", pix_abs16x16_mmx, pix_abs16x16_c);
bb7d6fe159ad motion test
glantau
parents:
diff changeset
152 test_motion("mmx_x2", pix_abs16x16_x2_mmx, pix_abs16x16_x2_c);
bb7d6fe159ad motion test
glantau
parents:
diff changeset
153 test_motion("mmx_y2", pix_abs16x16_y2_mmx, pix_abs16x16_y2_c);
bb7d6fe159ad motion test
glantau
parents:
diff changeset
154 test_motion("mmx_xy2", pix_abs16x16_xy2_mmx, pix_abs16x16_xy2_c);
bb7d6fe159ad motion test
glantau
parents:
diff changeset
155 return 0;
bb7d6fe159ad motion test
glantau
parents:
diff changeset
156 }