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
22 #include "mpegvideo.h"
23 #include "mpeg12data.h"
24 #include "mpeg4data.h"
25 #include "../libavcodec/i386/cputest.c"
26 #include "../libavcodec/i386/dsputil_mmx.c"
28 #include "../libavcodec/i386/fdct_mmx.c"
29 #include "../libavcodec/i386/idct_mmx.c"
30 #include "../libavcodec/i386/motion_est_mmx.c"
31 #include "../libavcodec/i386/simple_idct_mmx.c"
32 #include "../libavcodec/dsputil.c"
33 #include "../libavcodec/simple_idct.c"
34 #include "../libavcodec/jfdctfst.c"
40 * for testing speed of various routine - should be probably extended
41 * for a general purpose regression test later
43 * currently only for i386 - FIXME
46 #define PIX_FUNC_C(a) \
47 { #a "_c", a ## _c, 0 }, \
48 { #a "_mmx", a ## _mmx, MM_MMX }, \
49 { #a "_mmx2", a ## _mmx2, MM_MMXEXT | PAD }
52 { #a "_mmx", a ## _mmx, MM_MMX }, \
53 { #a "_3dnow", a ## _3dnow, MM_3DNOW }, \
54 { #a "_mmx2", a ## _mmx2, MM_MMXEXT | PAD }
56 #define PIX_FUNC_MMX(a) \
57 { #a "_mmx", a ## _mmx, MM_MMX | PAD }
60 PIX_FUNC_C(pix_abs16x16),
61 PIX_FUNC_C(pix_abs16x16_x2),
62 PIX_FUNC_C(pix_abs16x16_y2),
63 PIX_FUNC_C(pix_abs16x16_xy2),
64 PIX_FUNC_C(pix_abs8x8),
65 PIX_FUNC_C(pix_abs8x8_x2),
66 PIX_FUNC_C(pix_abs8x8_y2),
67 PIX_FUNC_C(pix_abs8x8_xy2),
70 static const struct pix_func {
76 PIX_FUNC_MMX(put_pixels),
77 //PIX_FUNC_MMX(get_pixels),
78 //PIX_FUNC_MMX(put_pixels_clamped),
80 PIX_FUNC(put_pixels_x2),
81 PIX_FUNC(put_pixels_y2),
82 PIX_FUNC_MMX(put_pixels_xy2),
84 PIX_FUNC(put_no_rnd_pixels_x2),
85 PIX_FUNC(put_no_rnd_pixels_y2),
86 PIX_FUNC_MMX(put_no_rnd_pixels_xy2),
89 PIX_FUNC(avg_pixels_x2),
90 PIX_FUNC(avg_pixels_y2),
91 PIX_FUNC(avg_pixels_xy2),
93 PIX_FUNC_MMX(avg_no_rnd_pixels),
94 PIX_FUNC_MMX(avg_no_rnd_pixels_x2),
95 PIX_FUNC_MMX(avg_no_rnd_pixels_y2),
96 PIX_FUNC_MMX(avg_no_rnd_pixels_xy2),
101 static inline long long rdtsc()
104 asm volatile( "rdtsc\n\t"
110 static test_speed(int step)
112 const struct pix_func* pix = pix_func;
113 const int linesize = 720;
115 char* bu =(char*)(((long)empty + 32) & ~0xf);
123 op_pixels_func func = pix->func;
126 if (pix->mm_flags & mm_flags)
128 printf("%30s... ", pix->name);
131 for(i=0; i<100000; i++){
132 func(im, im + 1000, linesize, 16);
139 printf("% 9d\n", (int)(te - ts));
140 sum += (te - ts) / 100000;
141 if (pix->mm_flags & PAD)
147 printf("Total sum: %d\n", sum);
150 int main(int argc, char* argv[])
156 // something simple for now
157 if (argc > 2 && (strcmp("-s", argv[1]) == 0
158 || strcmp("-step", argv[1]) == 0))
159 step = atoi(argv[2]);
162 mm_flags = mm_support();
163 printf("%s: detected CPU flags:", argv[0]);
164 if (mm_flags & MM_MMX)
166 if (mm_flags & MM_MMXEXT)
168 if (mm_flags & MM_3DNOW)
170 if (mm_flags & MM_SSE)
172 if (mm_flags & MM_SSE2)
176 printf("Using step: %d\n", step);