Mercurial > libavcodec.hg
annotate motion_test.c @ 3952:ff9b6ac5ca2e libavcodec
Compilation fix, printf gets redefined to please_use_av_log.
| author | diego |
|---|---|
| date | Sun, 08 Oct 2006 09:38:22 +0000 |
| parents | c8c591fe26f8 |
| children | ded320ef2a87 |
| 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 | 20 |
| 21 /** | |
| 22 * @file motion_test.c | |
| 23 * motion test. | |
| 24 */ | |
| 25 | |
| 75 | 26 #include <stdlib.h> |
| 27 #include <stdio.h> | |
| 28 #include <string.h> | |
| 29 #include <sys/time.h> | |
| 30 #include <unistd.h> | |
| 31 | |
| 32 #include "dsputil.h" | |
| 33 | |
| 34 #include "i386/mmx.h" | |
| 35 | |
|
3952
ff9b6ac5ca2e
Compilation fix, printf gets redefined to please_use_av_log.
diego
parents:
3947
diff
changeset
|
36 #undef printf |
|
ff9b6ac5ca2e
Compilation fix, printf gets redefined to please_use_av_log.
diego
parents:
3947
diff
changeset
|
37 |
| 1064 | 38 int pix_abs16x16_mmx(uint8_t *blk1, uint8_t *blk2, int lx); |
| 39 int pix_abs16x16_mmx1(uint8_t *blk1, uint8_t *blk2, int lx); | |
| 40 int pix_abs16x16_x2_mmx(uint8_t *blk1, uint8_t *blk2, int lx); | |
| 41 int pix_abs16x16_x2_mmx1(uint8_t *blk1, uint8_t *blk2, int lx); | |
| 42 int pix_abs16x16_x2_c(uint8_t *blk1, uint8_t *blk2, int lx); | |
| 43 int pix_abs16x16_y2_mmx(uint8_t *blk1, uint8_t *blk2, int lx); | |
| 44 int pix_abs16x16_y2_mmx1(uint8_t *blk1, uint8_t *blk2, int lx); | |
| 45 int pix_abs16x16_y2_c(uint8_t *blk1, uint8_t *blk2, int lx); | |
| 46 int pix_abs16x16_xy2_mmx(uint8_t *blk1, uint8_t *blk2, int lx); | |
| 47 int pix_abs16x16_xy2_mmx1(uint8_t *blk1, uint8_t *blk2, int lx); | |
| 48 int pix_abs16x16_xy2_c(uint8_t *blk1, uint8_t *blk2, int lx); | |
| 75 | 49 |
| 1064 | 50 typedef int motion_func(uint8_t *blk1, uint8_t *blk2, int lx); |
| 75 | 51 |
| 52 #define WIDTH 64 | |
| 53 #define HEIGHT 64 | |
| 54 | |
| 1064 | 55 uint8_t img1[WIDTH * HEIGHT]; |
| 56 uint8_t img2[WIDTH * HEIGHT]; | |
| 75 | 57 |
| 1064 | 58 void fill_random(uint8_t *tab, int size) |
| 75 | 59 { |
| 60 int i; | |
| 61 for(i=0;i<size;i++) { | |
| 62 #if 1 | |
| 63 tab[i] = random() % 256; | |
| 64 #else | |
| 65 tab[i] = i; | |
| 66 #endif | |
| 67 } | |
| 68 } | |
| 69 | |
| 70 void help(void) | |
| 71 { | |
| 72 printf("motion-test [-h]\n" | |
| 73 "test motion implementations\n"); | |
| 74 exit(1); | |
| 75 } | |
| 76 | |
| 1064 | 77 int64_t gettime(void) |
| 75 | 78 { |
| 79 struct timeval tv; | |
| 80 gettimeofday(&tv,NULL); | |
| 1064 | 81 return (int64_t)tv.tv_sec * 1000000 + tv.tv_usec; |
| 75 | 82 } |
| 83 | |
| 84 #define NB_ITS 500 | |
| 85 | |
| 86 int dummy; | |
| 87 | |
| 88 void test_motion(const char *name, | |
| 89 motion_func *test_func, motion_func *ref_func) | |
| 90 { | |
| 91 int x, y, d1, d2, it; | |
| 1064 | 92 uint8_t *ptr; |
| 93 int64_t ti; | |
| 75 | 94 printf("testing '%s'\n", name); |
| 95 | |
| 96 /* test correctness */ | |
| 97 for(it=0;it<20;it++) { | |
| 98 | |
| 99 fill_random(img1, WIDTH * HEIGHT); | |
| 100 fill_random(img2, WIDTH * HEIGHT); | |
| 2967 | 101 |
| 75 | 102 for(y=0;y<HEIGHT-17;y++) { |
| 103 for(x=0;x<WIDTH-17;x++) { | |
| 2967 | 104 ptr = img2 + y * WIDTH + x; |
| 644 | 105 d1 = test_func(img1, ptr, WIDTH); |
| 106 d2 = ref_func(img1, ptr, WIDTH); | |
| 75 | 107 if (d1 != d2) { |
| 108 printf("error: mmx=%d c=%d\n", d1, d2); | |
| 109 } | |
| 110 } | |
| 111 } | |
| 112 } | |
| 113 emms(); | |
| 2967 | 114 |
| 75 | 115 /* speed test */ |
| 116 ti = gettime(); | |
| 117 d1 = 0; | |
| 118 for(it=0;it<NB_ITS;it++) { | |
| 119 for(y=0;y<HEIGHT-17;y++) { | |
| 120 for(x=0;x<WIDTH-17;x++) { | |
| 2967 | 121 ptr = img2 + y * WIDTH + x; |
| 644 | 122 d1 += test_func(img1, ptr, WIDTH); |
| 75 | 123 } |
| 124 } | |
| 125 } | |
| 126 emms(); | |
| 127 dummy = d1; /* avoid optimisation */ | |
| 128 ti = gettime() - ti; | |
| 2967 | 129 |
| 130 printf(" %0.0f kop/s\n", | |
| 131 (double)NB_ITS * (WIDTH - 16) * (HEIGHT - 16) / | |
| 75 | 132 (double)(ti / 1000.0)); |
| 133 } | |
| 134 | |
| 135 | |
| 136 int main(int argc, char **argv) | |
| 137 { | |
| 138 int c; | |
| 2967 | 139 |
| 75 | 140 for(;;) { |
| 141 c = getopt(argc, argv, "h"); | |
| 142 if (c == -1) | |
| 143 break; | |
| 144 switch(c) { | |
| 145 case 'h': | |
| 146 help(); | |
| 147 break; | |
| 148 } | |
| 149 } | |
| 2967 | 150 |
| 75 | 151 printf("ffmpeg motion test\n"); |
| 152 | |
| 153 test_motion("mmx", pix_abs16x16_mmx, pix_abs16x16_c); | |
| 154 test_motion("mmx_x2", pix_abs16x16_x2_mmx, pix_abs16x16_x2_c); | |
| 155 test_motion("mmx_y2", pix_abs16x16_y2_mmx, pix_abs16x16_y2_c); | |
| 156 test_motion("mmx_xy2", pix_abs16x16_xy2_mmx, pix_abs16x16_xy2_c); | |
| 157 return 0; | |
| 158 } |
