Commit 0ed02327 authored by Michael Niedermayer's avatar Michael Niedermayer

Merge remote-tracking branch 'qatar/master'

* qatar/master:
  h264: don't touch H264Context->ref_count[] during MB decoding
  x86: get_cpu_flags: add necessary ifdefs around function body
  x86: Drop CPU detection intrinsics
  x86: Add YASM implementations of cpuid and xgetbv from x264

Conflicts:
	configure
	libavcodec/h264_cabac.c
	libavcodec/h264_cavlc.c
Merged-by: 's avatarMichael Niedermayer <michaelni@gmx.at>
parents 2a77d4f7 f6f7d150
......@@ -1278,7 +1278,6 @@ HAVE_LIST="
clock_gettime
closesocket
cmov
cpuid
cpunop
dcbzl
dev_bktr_ioctl_bt848_h
......@@ -1354,7 +1353,6 @@ HAVE_LIST="
rint
round
roundf
rweflags
sched_getaffinity
sdl
sdl_video_size
......@@ -1399,7 +1397,6 @@ HAVE_LIST="
windows_h
winsock2_h
xform_asm
xgetbv
xmm_clobbers
"
......@@ -3401,10 +3398,7 @@ elif enabled sparc; then
elif enabled x86; then
check_code ld immintrin.h "return __xgetbv(0)" "cc" && enable xgetbv
check_code ld intrin.h "int info[4]; __cpuid(info, 0)" "cc" && enable cpuid
check_code ld intrin.h "__rdtsc()" "cc" && enable rdtsc
check_code ld intrin.h "unsigned int x = __readeflags()" "cc" && enable rweflags
check_code ld mmintrin.h "_mm_empty()" "cc" && enable mm_empty
......
OBJS += x86/cpu.o \
x86/float_dsp_init.o \
YASM-OBJS += x86/float_dsp.o \
YASM-OBJS += x86/cpuid.o \
x86/float_dsp.o \
......@@ -22,10 +22,21 @@
#include <stdlib.h>
#include <string.h>
#include "libavutil/x86/asm.h"
#include "libavutil/x86/cpu.h"
#include "libavutil/cpu.h"
#if HAVE_INLINE_ASM
#if HAVE_YASM
#define cpuid(index, eax, ebx, ecx, edx) \
ff_cpu_cpuid(index, &eax, &ebx, &ecx, &edx)
#define xgetbv(index, eax, edx) \
ff_cpu_xgetbv(index, &eax, &edx)
#elif HAVE_INLINE_ASM
/* ebx saving is necessary for PIC. gcc seems unable to see it alone */
#define cpuid(index, eax, ebx, ecx, edx) \
__asm__ volatile ( \
......@@ -34,35 +45,9 @@
"xchg %%"REG_b", %%"REG_S \
: "=a" (eax), "=S" (ebx), "=c" (ecx), "=d" (edx) \
: "0" (index))
#elif HAVE_CPUID
#include <intrin.h>
#define cpuid(index, eax, ebx, ecx, edx) \
do { \
int info[4]; \
__cpuid(info, index); \
eax = info[0]; \
ebx = info[1]; \
ecx = info[2]; \
edx = info[3]; \
} while (0)
#endif /* HAVE_CPUID */
#if HAVE_INLINE_ASM
#define xgetbv(index, eax, edx) \
__asm__ (".byte 0x0f, 0x01, 0xd0" : "=a"(eax), "=d"(edx) : "c" (index))
#elif HAVE_XGETBV
#include <immintrin.h>
#define xgetbv(index, eax, edx) \
do { \
uint64_t res = __xgetbv(index); \
eax = res; \
edx = res >> 32; \
} while (0)
#endif /* HAVE_XGETBV */
#if HAVE_INLINE_ASM
#define get_eflags(x) \
__asm__ volatile ("pushfl \n" \
......@@ -74,22 +59,16 @@
"popfl \n" \
:: "r"(x))
#elif HAVE_RWEFLAGS
#include <intrin.h>
#define get_eflags(x) \
x = __readeflags()
#define set_eflags(x) \
__writeeflags(x)
#endif /* HAVE_INLINE_ASM */
#if ARCH_X86_64
#define cpuid_test() 1
#elif HAVE_YASM
#define cpuid_test ff_cpu_cpuid_test
#elif HAVE_INLINE_ASM || HAVE_RWEFLAGS
static int cpuid_test(void)
......@@ -110,6 +89,9 @@ static int cpuid_test(void)
int ff_get_cpu_flags_x86(void)
{
int rval = 0;
#ifdef cpuid
int eax, ebx, ecx, edx;
int max_std_level, max_ext_level, std_caps = 0, ext_caps = 0;
int family = 0, model = 0;
......@@ -213,5 +195,7 @@ int ff_get_cpu_flags_x86(void)
rval |= AV_CPU_FLAG_ATOM;
}
#endif /* cpuid */
return rval;
}
......@@ -54,4 +54,8 @@
#define INLINE_AVX(flags) CPUEXT(flags, _INLINE, AVX)
#define INLINE_FMA4(flags) CPUEXT(flags, _INLINE, FMA4)
void ff_cpu_cpuid(int index, int *eax, int *ebx, int *ecx, int *edx);
void ff_cpu_xgetbv(int op, int *eax, int *edx);
int ff_cpu_cpuid_test(void);
#endif /* AVUTIL_X86_CPU_H */
;*****************************************************************************
;* Copyright (C) 2005-2010 x264 project
;*
;* Authors: Loren Merritt <lorenm@u.washington.edu>
;* Jason Garrett-Glaser <darkshikari@gmail.com>
;*
;* 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
;******************************************************************************
%include "x86inc.asm"
SECTION .text
;-----------------------------------------------------------------------------
; void ff_cpu_cpuid(int index, int *eax, int *ebx, int *ecx, int *edx)
;-----------------------------------------------------------------------------
cglobal cpu_cpuid, 5,7
push rbx
push r4
push r3
push r2
push r1
mov eax, r0d
xor ecx, ecx
cpuid
pop r4
mov [r4], eax
pop r4
mov [r4], ebx
pop r4
mov [r4], ecx
pop r4
mov [r4], edx
pop rbx
RET
;-----------------------------------------------------------------------------
; void ff_cpu_xgetbv(int op, int *eax, int *edx)
;-----------------------------------------------------------------------------
cglobal cpu_xgetbv, 3,7
push r2
push r1
mov ecx, r0d
xgetbv
pop r4
mov [r4], eax
pop r4
mov [r4], edx
RET
%if ARCH_X86_64 == 0
;-----------------------------------------------------------------------------
; int ff_cpu_cpuid_test(void)
; return 0 if unsupported
;-----------------------------------------------------------------------------
cglobal cpu_cpuid_test
pushfd
push ebx
push ebp
push esi
push edi
pushfd
pop eax
mov ebx, eax
xor eax, 0x200000
push eax
popfd
pushfd
pop eax
xor eax, ebx
pop edi
pop esi
pop ebp
pop ebx
popfd
ret
%endif
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment