cpu.h 2.2 KB
Newer Older
1 2 3
/*****************************************************************************
 * cpu.h: h264 encoder library
 *****************************************************************************
4
 * Copyright (C) 2004-2008 Loren Merritt <lorenm@u.washington.edu>
5 6 7 8 9 10 11 12 13 14 15 16 17
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
18
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02111, USA.
19 20
 *****************************************************************************/

21 22
#ifndef X264_CPU_H
#define X264_CPU_H
23 24

uint32_t x264_cpu_detect( void );
25
int      x264_cpu_num_processors( void );
26 27 28 29 30 31 32 33
void     x264_cpu_emms( void );
void     x264_cpu_sfence( void );
#ifdef HAVE_MMX
#define x264_emms() x264_cpu_emms()
#else
#define x264_emms()
#endif
#define x264_sfence x264_cpu_sfence
34
void     x264_cpu_mask_misalign_sse( void );
35

36 37 38 39 40 41 42
/* kluge:
 * gcc can't give variables any greater alignment than the stack frame has.
 * We need 16 byte alignment for SSE2, so here we make sure that the stack is
 * aligned to 16 bytes.
 * gcc 4.2 introduced __attribute__((force_align_arg_pointer)) to fix this
 * problem, but I don't want to require such a new version.
 * This applies only to x86_32, since other architectures that need alignment
Steven Walters's avatar
Steven Walters committed
43
 * either have ABIs that ensure aligned stack, or don't support it at all. */
44
#if defined(ARCH_X86) && defined(HAVE_MMX)
Steven Walters's avatar
Steven Walters committed
45 46
int x264_stack_align( void (*func)(), ... );
#define x264_stack_align(func,...) x264_stack_align((void (*)())func, __VA_ARGS__)
47
#else
Steven Walters's avatar
Steven Walters committed
48
#define x264_stack_align(func,...) func(__VA_ARGS__)
49 50
#endif

51
typedef struct {
52
    const char name[16];
53
    int flags;
54 55
} x264_cpu_name_t;
extern const x264_cpu_name_t x264_cpu_names[];
56

57
#endif