2 * MMX optimized DSP utils
3 * Copyright (c) 2000, 2001, 2002 Fabrice Bellard.
5 * This library is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Lesser General Public
7 * License as published by the Free Software Foundation; either
8 * version 2 of the License, or (at your option) any later version.
10 * This library is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * Lesser General Public License for more details.
15 * You should have received a copy of the GNU Lesser General Public
16 * License along with this library; if not, write to the Free Software
17 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
21 //#include "../libavcodec/dsputil.c"
22 #include "../libavcodec/i386/cputest.c"
23 #include "../libavcodec/i386/dsputil_mmx.c"
28 * for testing speed of various routine - should be probably extended
29 * for a general purpose regression test later
31 * currently only for i386 - FIXME
34 #define PIX_FUNC_C(a) \
35 { #a "_c", a ## _c, 0 }, \
36 { #a "_mmx", a ## _mmx, MM_MMX }, \
37 { #a "_mmx2", a ## _mmx2, MM_MMXEXT | PAD }
40 { #a "_mmx", a ## _mmx, MM_MMX }, \
41 { #a "_3dnow", a ## _3dnow, MM_3DNOW }, \
42 { #a "_mmx2", a ## _mmx2, MM_MMXEXT | PAD }
44 #define PIX_FUNC_MMX(a) \
45 { #a "_mmx", a ## _mmx, MM_MMX | PAD }
48 PIX_FUNC_C(pix_abs16x16),
49 PIX_FUNC_C(pix_abs16x16_x2),
50 PIX_FUNC_C(pix_abs16x16_y2),
51 PIX_FUNC_C(pix_abs16x16_xy2),
52 PIX_FUNC_C(pix_abs8x8),
53 PIX_FUNC_C(pix_abs8x8_x2),
54 PIX_FUNC_C(pix_abs8x8_y2),
55 PIX_FUNC_C(pix_abs8x8_xy2),
58 static const struct pix_func {
64 PIX_FUNC_MMX(put_pixels),
66 PIX_FUNC(put_pixels_x2),
67 PIX_FUNC(put_pixels_y2),
68 PIX_FUNC_MMX(put_pixels_xy2),
70 PIX_FUNC(put_no_rnd_pixels_x2),
71 PIX_FUNC(put_no_rnd_pixels_y2),
72 PIX_FUNC_MMX(put_no_rnd_pixels_xy2),
75 PIX_FUNC(avg_pixels_x2),
76 PIX_FUNC(avg_pixels_y2),
77 PIX_FUNC(avg_pixels_xy2),
82 static inline long long rdtsc()
85 asm volatile( "rdtsc\n\t"
91 static test_speed(int step)
93 const struct pix_func* pix = pix_func;
94 const int linesize = 720;
96 char* bu =(char*)(((long)empty + 32) & ~0xf);
104 op_pixels_func func = pix->func;
107 if (!(pix->mm_flags & mm_flags))
110 printf("%30s... ", pix->name);
113 for(i=0; i<100000; i++){
114 func(im, im + 1000, linesize, 16);
121 printf("% 9d\n", (int)(te - ts));
122 sum += (te - ts) / 100000;
123 if (pix->mm_flags & PAD)
128 printf("Total sum: %d\n", sum);
131 int main(int argc, char* argv[])
137 // something simple for now
138 if (argc > 2 && (strcmp("-s", argv[1]) == 0
139 || strcmp("-step", argv[1]) == 0))
140 step = atoi(argv[2]);
143 mm_flags = mm_support();
144 printf("%s: detected CPU flags:", argv[0]);
145 if (mm_flags & MM_MMX)
147 if (mm_flags & MM_MMXEXT)
149 if (mm_flags & MM_3DNOW)
151 if (mm_flags & MM_SSE)
153 if (mm_flags & MM_SSE2)
157 printf("Using step: %d\n", step);