]> git.sesse.net Git - x264/blob - common/x86/util.h
x264_median_mv_mmxext
[x264] / common / x86 / util.h
1 /*****************************************************************************
2  * mc.h: h264 encoder library
3  *****************************************************************************
4  * Copyright (C) 2008 Loren Merritt
5  *
6  * This program is free software; you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License as published by
8  * the Free Software Foundation; either version 2 of the License, or
9  * (at your option) any later version.
10  *
11  * This program is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with this program; if not, write to the Free Software
18  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111, USA.
19  *****************************************************************************/
20
21 #ifndef X264_X86_UTIL_H
22 #define X264_X86_UTIL_H
23
24 #ifdef __GNUC__
25 #define x264_median_mv x264_median_mv_mmxext
26 static inline void x264_median_mv_mmxext( int16_t *dst, int16_t *a, int16_t *b, int16_t *c )
27 {
28     asm(
29         "movd   %1,    %%mm0 \n"
30         "movd   %2,    %%mm1 \n"
31         "movq   %%mm0, %%mm3 \n"
32         "movd   %3,    %%mm2 \n"
33         "pmaxsw %%mm1, %%mm0 \n"
34         "pminsw %%mm3, %%mm1 \n"
35         "pminsw %%mm2, %%mm0 \n"
36         "pmaxsw %%mm1, %%mm0 \n"
37         "movd   %%mm0, %0    \n"
38         :"=m"(*(uint32_t*)dst)
39         :"m"(*(uint32_t*)a), "m"(*(uint32_t*)b), "m"(*(uint32_t*)c)
40     );
41 }
42 #endif
43
44 #endif