Remove CPU detection and inline asm handling

Not needed anymore. I'm not opposed to having asm, but inline asm is too
much of a pain, and it was planned long ago to eventually get rid fo all
inline asm uses.

For the note, the inline asm use that was removed with the previous
commits was almost worthless. It was confined to video filters, and most
video filtering is now done with libavfilter. Some mpv filters (like
vf_pullup) actually redirect to libavfilter if possible.

If asm is added in the future, it should happen in the form of external
files.
This commit is contained in:
wm4 2014-04-19 17:09:24 +02:00
parent 061c7eba97
commit 0cff5836c3
12 changed files with 9 additions and 508 deletions

View File

@ -1,43 +0,0 @@
/*
* This file is part of MPlayer.
*
* MPlayer 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.
*
* MPlayer 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 MPlayer; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <libavutil/cpu.h>
#include "compat/libav.h"
#include "config.h"
#include "common/cpudetect.h"
CpuCaps gCpuCaps;
void GetCpuCaps(CpuCaps *c)
{
memset(c, 0, sizeof(*c));
int flags = av_get_cpu_flags();
#if ARCH_X86
c->hasMMX = flags & AV_CPU_FLAG_MMX;
c->hasMMX2 = flags & AV_CPU_FLAG_MMX2;
c->hasSSE = flags & AV_CPU_FLAG_SSE;
c->hasSSE2 = (flags & AV_CPU_FLAG_SSE2) && !(flags & AV_CPU_FLAG_SSE2SLOW);
c->hasSSE3 = (flags & AV_CPU_FLAG_SSE3) && !(flags & AV_CPU_FLAG_SSE3SLOW);
c->hasSSSE3 = flags & AV_CPU_FLAG_SSSE3;
#endif
}

View File

@ -1,40 +0,0 @@
/*
* This file is part of MPlayer.
*
* MPlayer 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.
*
* MPlayer 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 MPlayer; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
#ifndef MPLAYER_CPUDETECT_H
#define MPLAYER_CPUDETECT_H
#include <stdbool.h>
#include "config.h"
#include "compat/x86_cpu.h"
typedef struct cpucaps_s {
bool hasMMX;
bool hasMMX2;
bool hasSSE;
bool hasSSE2;
bool hasSSE3;
bool hasSSSE3;
} CpuCaps;
extern CpuCaps gCpuCaps;
void GetCpuCaps(CpuCaps *caps);
#endif /* MPLAYER_CPUDETECT_H */

View File

@ -1,46 +0,0 @@
/*
* CPP macros to deal with different symbol mangling across binary formats.
*
* Copyright (C) 2002 Felix Buenemann <atmosfear at users.sourceforge.net>
*
* This file is part of MPlayer.
*
* MPlayer 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.
*
* MPlayer 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 MPlayer; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
#ifndef MPLAYER_MANGLE_H
#define MPLAYER_MANGLE_H
#include "config.h"
#if (__GNUC__ * 100 + __GNUC_MINOR__ >= 300)
#define attribute_used __attribute__((used))
#else
#define attribute_used
#endif
#if defined(_WIN32) && !defined(_WIN64) || defined(__APPLE__)
#define EXTERN_PREFIX "_"
#else
#define EXTERN_PREFIX ""
#endif
#if ARCH_X86_64 && defined(PIC)
#define MANGLE(a) EXTERN_PREFIX #a "(%%rip)"
#else
#define MANGLE(a) EXTERN_PREFIX #a
#endif
#endif /* MPLAYER_MANGLE_H */

View File

@ -1,76 +0,0 @@
/*
* copyright (c) 2006 Michael Niedermayer <michaelni@gmx.at>
*
* This file is part of FFmpeg.
*
* FFmpeg is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* FFmpeg 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
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with FFmpeg; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
#ifndef MP_AVUTIL_X86_CPU_H
#define MP_AVUTIL_X86_CPU_H
#include <stdint.h>
#include "config.h"
#if ARCH_X86_64
# define REG_a "rax"
# define REG_b "rbx"
# define REG_c "rcx"
# define REG_d "rdx"
# define REG_D "rdi"
# define REG_S "rsi"
# define PTR_SIZE "8"
typedef int64_t x86_reg;
# define REG_SP "rsp"
# define REG_BP "rbp"
# define REGBP rbp
# define REGa rax
# define REGb rbx
# define REGc rcx
# define REGd rdx
# define REGSP rsp
#elif ARCH_X86_32
# define REG_a "eax"
# define REG_b "ebx"
# define REG_c "ecx"
# define REG_d "edx"
# define REG_D "edi"
# define REG_S "esi"
# define PTR_SIZE "4"
typedef int32_t x86_reg;
# define REG_SP "esp"
# define REG_BP "ebp"
# define REGBP ebp
# define REGa eax
# define REGb ebx
# define REGc ecx
# define REGd edx
# define REGSP esp
#else
typedef int x86_reg;
#endif
#define HAVE_7REGS (ARCH_X86_64 || (HAVE_EBX_AVAILABLE && HAVE_EBP_AVAILABLE))
#define HAVE_6REGS (ARCH_X86_64 || (HAVE_EBX_AVAILABLE || HAVE_EBP_AVAILABLE))
#if ARCH_X86_64 && defined(PIC)
# define BROKEN_RELOCATIONS 1
#endif
#endif /* AVUTIL_X86_CPU_H */

View File

@ -129,14 +129,6 @@ EOF
compile_check $TMPC $@
}
inline_asm_check() {
cat > $TMPC << EOF
int main(void) { __asm__ volatile ($1); return 0; }
EOF
shift
compile_check $TMPC $@
}
# The following checks are special and should only be used with broken and
# non-selfsufficient headers that do not include all of their dependencies.
@ -207,46 +199,6 @@ netbsd() { issystem "NetBSD"; }
openbsd() { issystem "OpenBSD"; }
win32() { cygwin || mingw32; }
# arch test boolean functions
x86_32() {
case "$host_arch" in
i[3-9]86|k5|k6|k6-2|k6-3|pentium*|athlon*|i586-i686) return 0 ;;
*) return 1 ;;
esac
}
x86_64() {
case "$host_arch" in
x86_64|amd64) return 0 ;;
*) return 1 ;;
esac
}
x86() {
x86_32 || x86_64
}
ppc() {
case "$host_arch" in
ppc|ppc64|powerpc|powerpc64) return 0;;
*) return 1;;
esac
}
alpha() {
case "$host_arch" in
alpha*) return 0;;
*) return 1;;
esac
}
arm() {
case "$host_arch" in
arm*) return 0;;
*) return 1;;
esac
}
# Use this before starting a check
echocheck() {
echo "============ Checking for $@ ============" >> "$TMPLOG"
@ -776,7 +728,7 @@ if test "$_cc" = auto ; then
fi
fi
# Determine our OS name and CPU architecture
# Determine our OS name
if test -z "$_target" ; then
# OS name
system_name=$(uname -s 2>&1)
@ -800,41 +752,6 @@ if test -z "$_target" ; then
;;
esac
# host's CPU/instruction set
host_arch=$(uname -p 2>&1)
case "$host_arch" in
i386|sparc|ppc|alpha|arm|mips|vax)
;;
powerpc) # Darwin returns 'powerpc'
host_arch=ppc
;;
*) # uname -p on Linux returns 'unknown' for the processor type,
# OpenBSD returns 'Intel Pentium/MMX ("Genuine Intel" 586-class)'
# Maybe uname -m (machine hardware name) returns something we
# recognize.
case "$(uname -m 2>&1)" in
x86_64|amd64|i[3-9]86*|k5|k6|k6_2|k6_3|k6-2|k6-3|pentium*|athlon*|i586_i686|i586-i686|BePC) host_arch=i386 ;;
ia64) host_arch=ia64 ;;
macppc|ppc) host_arch=ppc ;;
ppc64) host_arch=ppc64 ;;
alpha) host_arch=alpha ;;
sparc) host_arch=sparc ;;
sparc64) host_arch=sparc64 ;;
parisc*|hppa*|9000*) host_arch=hppa ;;
arm*|zaurus|cats) host_arch=arm ;;
sh3|sh4|sh4a) host_arch=sh ;;
s390) host_arch=s390 ;;
s390x) host_arch=s390x ;;
*mips*) host_arch=mips ;;
vax) host_arch=vax ;;
xtensa*) host_arch=xtensa ;;
*) host_arch=UNKNOWN ;;
esac
;;
esac
else # if test -z "$_target"
for i in 2 3; do
system_name=$(echo $_target | cut -d '-' -f $i)
@ -851,11 +768,6 @@ else # if test -z "$_target"
esac
break
done
# We need to convert underscores so that values like k6-2 and pentium-mmx can be passed
host_arch=$(echo $_target | cut -d '-' -f 1)
if test $(echo $host_arch) != "x86_64" ; then
host_arch=$(echo $host_arch | tr '_' '-')
fi
fi
extra_cflags="-I. -D_GNU_SOURCE $extra_cflags"
@ -1019,114 +931,11 @@ echocheck "perl"
command_check perl -Mv5.8 -e';' || die "Perl is not functioning correctly or is ancient. Install the latest perl available."
echo yes
if test -z "$_target" && x86 ; then
cat > $TMPC << EOF
int main(void) {
int test[(int)sizeof(char *)-7];
return 0;
}
EOF
cc_check && host_arch=x86_64 || host_arch=i386
fi
echo "Detected operating system: $system_name"
echo "Detected host architecture: $host_arch"
# ---
# now that we know what compiler should be used for compilation, try to find
# out which assembler is used by the $_cc compiler
if test "$_as" = auto ; then
_as=$($_cc -print-prog-name=as)
test -z "$_as" && _as=as
fi
def_fast_64bit='#define HAVE_FAST_64BIT 0'
def_arch_x86='#define ARCH_X86 0'
def_arch_x86_32='#define ARCH_X86_32 0'
def_arch_x86_64='#define ARCH_X86_64 0'
case "$host_arch" in
i[3-9]86|x86|x86pc|k5|k6|k6-2|k6-3|pentium*|athlon*|i586-i686)
arch='x86'
subarch='x86_32'
def_arch_x86='#define ARCH_X86 1'
def_arch_x86_32='#define ARCH_X86_32 1'
;;
ia64)
arch='ia64'
def_fast_64bit='#define HAVE_FAST_64BIT 1'
;;
x86_64|amd64)
arch='x86'
subarch='x86_64'
def_arch_x86='#define ARCH_X86 1'
def_arch_x86_64='#define ARCH_X86_64 1'
def_fast_64bit='#define HAVE_FAST_64BIT 1'
;;
sparc|sparc64)
arch='sparc'
;;
arm*)
arch='arm'
;;
avr32)
arch='avr32'
;;
sh|sh4)
arch='sh4'
;;
ppc|ppc64|powerpc|powerpc64)
arch='ppc'
;;
alpha*)
arch='alpha'
;;
mips*)
arch='mips'
;;
hppa)
arch='pa_risc'
;;
s390)
arch='s390'
;;
s390x)
arch='s390x'
;;
vax)
arch='vax'
;;
xtensa)
arch='xtensa'
;;
generic)
arch='generic'
;;
*)
echo "The architecture of your CPU ($host_arch) is not supported by this configure script"
echo "It seems nobody has ported mpv to your OS or CPU type yet."
die "unsupported architecture $host_arch"
;;
esac # case "$host_arch" in
echocheck "assembler support of -pipe option"
echocheck "compiler support of -pipe option"
# -I. helps to detect compilers that just misunderstand -pipe like Sun C
cflag_check -pipe -I. && _pipe="-pipe" && echores "yes" || echores "no"
@ -1180,44 +989,6 @@ if test -n "$CPPFLAGS" ; then
fi
echocheck "PIC"
pic=no
cat > $TMPC << EOF
int main(void) {
#if !(defined(__PIC__) || defined(__pic__) || defined(PIC))
#error PIC not enabled
#endif
return 0;
}
EOF
cc_check && pic=yes && extra_cflags="$extra_cflags -DPIC"
echores $pic
if x86 ; then
echocheck "ebx availability"
ebx_available=no
def_ebx_available='#define HAVE_EBX_AVAILABLE 0'
cat > $TMPC << EOF
int main(void) {
int x;
__asm__ volatile(
"xor %0, %0"
:"=b"(x)
// just adding ebx to clobber list seems unreliable with some
// compilers, e.g. Haiku's gcc 2.95
);
// and the above check does not work for OSX 64 bit...
__asm__ volatile("":::"%ebx");
return 0;
}
EOF
cc_check && ebx_available=yes && def_ebx_available='#define HAVE_EBX_AVAILABLE 1'
echores $ebx_available
fi #if x86
######################
# MAIN TESTS GO HERE #
######################
@ -3061,7 +2832,6 @@ fi
extra_ldflags="$extra_ldflags $_ld_pthread"
libs_mplayer="$libs_mplayer $_ld_dl"
(netbsd || openbsd) && x86_32 && libs_mplayer="$libs_mplayer -li386"
echocheck "joystick"
@ -3297,20 +3067,6 @@ $def_priority
/* configurable options */
$def_stream_cache
/* CPU stuff */
$def_ebx_available
$def_arch_x86
$def_arch_x86_32
$def_arch_x86_64
#define HAVE_MMX ARCH_X86
#define HAVE_MMX2 ARCH_X86
#define HAVE_SSE ARCH_X86
#define HAVE_SSE2 ARCH_X86
#define HAVE_SSSE3 ARCH_X86
/* Blu-ray/DVD/VCD/CD */
#define DEFAULT_CDROM_DEVICE "$default_cdrom_device"
#define DEFAULT_DVD_DEVICE "$default_dvd_device"
@ -3426,11 +3182,6 @@ $def_pthreads
$def_atomic
$def_sync
#define HAVE_INLINE_ASM 1
/* Use these registers in x86 inline asm. No proper detection yet. */
#define HAVE_EBP_AVAILABLE 1
#endif /* MPLAYER_CONFIG_H */
EOF

View File

@ -179,7 +179,6 @@ SOURCES = audio/audio.c \
common/av_log.c \
common/av_opts.c \
common/codecs.c \
common/cpudetect.c \
common/common.c \
common/msg.c \
common/playlist.c \

View File

@ -35,7 +35,6 @@
#include "common/av_log.h"
#include "common/codecs.h"
#include "common/cpudetect.h"
#include "common/encode.h"
#include "options/m_config.h"
#include "options/m_option.h"
@ -307,7 +306,6 @@ static int cfg_include(void *ctx, char *filename, int flags)
struct MPContext *mp_create(void)
{
mp_time_init();
GetCpuCaps(&gCpuCaps);
struct MPContext *mpctx = talloc(NULL, MPContext);
*mpctx = (struct MPContext){

View File

@ -21,6 +21,7 @@
#include <string.h>
#include <limits.h>
#include <math.h>
#include <stdint.h>
#include "config.h"
#include "common/msg.h"
@ -97,13 +98,15 @@ static unsigned int checksum_plane(unsigned char *p, unsigned char *z,
}
*/
#define FAST_64BIT (UINTPTR_MAX >= UINT64_MAX)
static unsigned int checksum_plane(unsigned char *p, unsigned char *z,
int w, int h, int s, int zs, int arg)
{
unsigned int shift;
uint32_t sum, t;
unsigned char *e, *e2;
#if HAVE_FAST_64BIT
#if FAST_64BIT
typedef uint64_t wsum_t;
#else
typedef uint32_t wsum_t;
@ -118,7 +121,7 @@ static unsigned int checksum_plane(unsigned char *p, unsigned char *z,
for(wsum=0, e2=e-sizeof(wsum_t)+1; p<e2; p+=sizeof(wsum_t))
wsum^=*(wsum_t *)p;
#if HAVE_FAST_64BIT
#if FAST_64BIT
t=be2me_32((uint32_t)(wsum>>32^wsum));
#else
t=be2me_32(wsum);

View File

@ -1,28 +0,0 @@
def x86(ctx):
ctx.define('ARCH_X86', 1)
ctx.define('ARCH_X86_32', 1)
def x86_64(ctx):
ctx.define('ARCH_X86', 1)
ctx.define('ARCH_X86_64', 1)
ctx.define('HAVE_FAST_64BIT', 1)
def ia64(ctx):
ctx.define('HAVE_FAST_64BIT', 1)
def default(ctx):
pass
def configure(ctx):
ctx.define('ARCH_X86', 0)
ctx.define('ARCH_X86_32', 0)
ctx.define('ARCH_X86_64', 0)
ctx.define('HAVE_FAST_64BIT', 0)
ctx.define('HAVE_MMX', 'HAVE_ASM && ARCH_X86', quote=False)
ctx.define('HAVE_MMX2', 'HAVE_ASM && ARCH_X86', quote=False)
ctx.define('HAVE_SSE', 'HAVE_ASM && ARCH_X86', quote=False)
ctx.define('HAVE_SSE2', 'HAVE_ASM && ARCH_X86', quote=False)
ctx.define('HAVE_SSSE3', 'HAVE_ASM && ARCH_X86', quote=False)
globals().get(ctx.env.DEST_CPU, default)(ctx)

View File

@ -1,12 +0,0 @@
int main(void) {
int x;
__asm__ volatile(
"xor %0, %0"
:"=b"(x)
// just adding ebx to clobber list seems unreliable with some
// compilers, e.g. Haiku's gcc 2.95
);
// and the above check does not work for OSX 64 bit...
__asm__ volatile("":::"%ebx");
return 0;
}

View File

@ -69,8 +69,9 @@ build_options = [
'deps_any': [ 'os-win32', 'os-cygwin'],
'func': check_ctx_vars('WINDRES')
}, {
# does nothing - left for backward and forward compatibility
'name': '--asm',
'desc': 'inline assembly',
'desc': 'inline assembly (currently without effect)',
'default': 'enable',
'func': check_true,
}
@ -85,10 +86,6 @@ main_dependencies = [
'name': 'noexecstack',
'desc': 'linker support for --nxcompat --no-seh --dynamicbase',
'func': check_cc(linkflags=['-Wl,--nxcompat', '-Wl,--no-seh', '-Wl,--dynamicbase'])
}, {
'name': 'ebx-available',
'desc': 'ebx availability',
'func': check_cc(fragment=load_fragment('ebx.c'))
} , {
'name': 'libm',
'desc': '-lm',
@ -798,7 +795,6 @@ def configure(ctx):
ctx.load('waf_customizations')
ctx.load('dependencies')
ctx.load('detections.compiler')
ctx.load('detections.cpu')
ctx.load('detections.devices')
if ctx.env.DEST_OS in ('freebsd', 'openbsd'):

View File

@ -158,7 +158,6 @@ def build(ctx):
( "common/av_log.c" ),
( "common/av_opts.c" ),
( "common/codecs.c" ),
( "common/cpudetect.c" ),
( "common/encode_lavc.c", "encoding" ),
( "common/common.c" ),
( "common/tags.c" ),