diff options
author | Stefano Sabatini <stefano.sabatini-lala@poste.it> | 2010-09-08 15:07:14 +0000 |
---|---|---|
committer | Stefano Sabatini <stefano.sabatini-lala@poste.it> | 2010-09-08 15:07:14 +0000 |
commit | c6c98d0897ce1e040d041a655fb3e7dc14e96c45 (patch) | |
tree | c4a37da46c09d39c84e91b7a9159633bc2a30d89 /libavcodec/ppc | |
parent | 9ec7458ddfe3da9537f225e35670d99f98b654eb (diff) | |
download | ffmpeg-c6c98d0897ce1e040d041a655fb3e7dc14e96c45.tar.gz |
Move mm_support() from libavcodec to libavutil, make it a public
function and rename it to av_get_cpu_flags().
Originally committed as revision 25076 to svn://svn.ffmpeg.org/ffmpeg/trunk
Diffstat (limited to 'libavcodec/ppc')
-rw-r--r-- | libavcodec/ppc/Makefile | 3 | ||||
-rw-r--r-- | libavcodec/ppc/check_altivec.c | 92 | ||||
-rw-r--r-- | libavcodec/ppc/dsputil_ppc.c | 3 | ||||
-rw-r--r-- | libavcodec/ppc/h264_altivec.c | 5 | ||||
-rw-r--r-- | libavcodec/ppc/mpegvideo_altivec.c | 3 | ||||
-rw-r--r-- | libavcodec/ppc/vp8dsp_altivec.c | 3 |
6 files changed, 10 insertions, 99 deletions
diff --git a/libavcodec/ppc/Makefile b/libavcodec/ppc/Makefile index 175b1093b0..9b2358d49c 100644 --- a/libavcodec/ppc/Makefile +++ b/libavcodec/ppc/Makefile @@ -18,8 +18,7 @@ FFT-OBJS-$(HAVE_GNU_AS) += ppc/fft_altivec_s.o \ ALTIVEC-OBJS-$(CONFIG_FFT) += ppc/fft_altivec.o \ $(FFT-OBJS-yes) -OBJS-$(HAVE_ALTIVEC) += ppc/check_altivec.o \ - ppc/dsputil_altivec.o \ +OBJS-$(HAVE_ALTIVEC) += ppc/dsputil_altivec.o \ ppc/fdct_altivec.o \ ppc/float_altivec.o \ ppc/gmc_altivec.o \ diff --git a/libavcodec/ppc/check_altivec.c b/libavcodec/ppc/check_altivec.c deleted file mode 100644 index 95ca742668..0000000000 --- a/libavcodec/ppc/check_altivec.c +++ /dev/null @@ -1,92 +0,0 @@ -/* - * 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 - */ - - -/** - * @file - * Check for AltiVec presence. - */ - -#ifdef __APPLE__ -#undef _POSIX_C_SOURCE -#include <sys/sysctl.h> -#elif defined(__OpenBSD__) -#include <sys/param.h> -#include <sys/sysctl.h> -#include <machine/cpu.h> -#elif defined(__AMIGAOS4__) -#include <exec/exec.h> -#include <interfaces/exec.h> -#include <proto/exec.h> -#endif /* __APPLE__ */ - -#include "config.h" -#include "dsputil_altivec.h" - -/** - * This function MAY rely on signal() or fork() in order to make sure AltiVec - * is present. - */ - -int mm_support(void) -{ -#if HAVE_ALTIVEC -#ifdef __AMIGAOS4__ - ULONG result = 0; - extern struct ExecIFace *IExec; - - IExec->GetCPUInfoTags(GCIT_VectorUnit, &result, TAG_DONE); - if (result == VECTORTYPE_ALTIVEC) - return AV_CPU_FLAG_ALTIVEC; - return 0; -#elif defined(__APPLE__) || defined(__OpenBSD__) -#ifdef __OpenBSD__ - int sels[2] = {CTL_MACHDEP, CPU_ALTIVEC}; -#else - int sels[2] = {CTL_HW, HW_VECTORUNIT}; -#endif - int has_vu = 0; - size_t len = sizeof(has_vu); - int err; - - err = sysctl(sels, 2, &has_vu, &len, NULL, 0); - - if (err == 0) - return has_vu ? AV_CPU_FLAG_ALTIVEC : 0; - return 0; -#elif CONFIG_RUNTIME_CPUDETECT - int proc_ver; - // Support of mfspr PVR emulation added in Linux 2.6.17. - __asm__ volatile("mfspr %0, 287" : "=r" (proc_ver)); - proc_ver >>= 16; - if (proc_ver & 0x8000 || - proc_ver == 0x000c || - proc_ver == 0x0039 || proc_ver == 0x003c || - proc_ver == 0x0044 || proc_ver == 0x0045 || - proc_ver == 0x0070) - return AV_CPU_FLAG_ALTIVEC; - return 0; -#else - // Since we were compiled for AltiVec, just assume we have it - // until someone comes up with a proper way (not involving signal hacks). - return AV_CPU_FLAG_ALTIVEC; -#endif /* __AMIGAOS4__ */ -#endif /* HAVE_ALTIVEC */ - return 0; -} - diff --git a/libavcodec/ppc/dsputil_ppc.c b/libavcodec/ppc/dsputil_ppc.c index 3c930a8179..9e4f1aa667 100644 --- a/libavcodec/ppc/dsputil_ppc.c +++ b/libavcodec/ppc/dsputil_ppc.c @@ -20,6 +20,7 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ +#include "libavutil/cpu.h" #include "libavcodec/dsputil.h" #include "dsputil_altivec.h" @@ -168,7 +169,7 @@ void dsputil_init_ppc(DSPContext* c, AVCodecContext *avctx) #if HAVE_ALTIVEC if(CONFIG_H264_DECODER) dsputil_h264_init_ppc(c, avctx); - if (mm_support() & AV_CPU_FLAG_ALTIVEC) { + if (av_get_cpu_flags() & AV_CPU_FLAG_ALTIVEC) { dsputil_init_altivec(c, avctx); if(CONFIG_VC1_DECODER) vc1dsp_init_altivec(c, avctx); diff --git a/libavcodec/ppc/h264_altivec.c b/libavcodec/ppc/h264_altivec.c index 77f80b912d..aee2bc2d1a 100644 --- a/libavcodec/ppc/h264_altivec.c +++ b/libavcodec/ppc/h264_altivec.c @@ -18,6 +18,7 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ +#include "libavutil/cpu.h" #include "libavcodec/dsputil.h" #include "libavcodec/h264data.h" #include "libavcodec/h264dsp.h" @@ -969,7 +970,7 @@ H264_WEIGHT( 8, 4) void dsputil_h264_init_ppc(DSPContext* c, AVCodecContext *avctx) { - if (mm_support() & AV_CPU_FLAG_ALTIVEC) { + if (av_get_cpu_flags() & AV_CPU_FLAG_ALTIVEC) { c->put_h264_chroma_pixels_tab[0] = put_h264_chroma_mc8_altivec; c->avg_h264_chroma_pixels_tab[0] = avg_h264_chroma_mc8_altivec; c->put_no_rnd_vc1_chroma_pixels_tab[0] = put_no_rnd_vc1_chroma_mc8_altivec; @@ -1001,7 +1002,7 @@ void dsputil_h264_init_ppc(DSPContext* c, AVCodecContext *avctx) { void ff_h264dsp_init_ppc(H264DSPContext *c) { - if (mm_support() & AV_CPU_FLAG_ALTIVEC) { + if (av_get_cpu_flags() & AV_CPU_FLAG_ALTIVEC) { c->h264_idct_add = ff_h264_idct_add_altivec; c->h264_idct_add8 = ff_h264_idct_add8_altivec; c->h264_idct_add16 = ff_h264_idct_add16_altivec; diff --git a/libavcodec/ppc/mpegvideo_altivec.c b/libavcodec/ppc/mpegvideo_altivec.c index 3b34a27bec..64898a10d0 100644 --- a/libavcodec/ppc/mpegvideo_altivec.c +++ b/libavcodec/ppc/mpegvideo_altivec.c @@ -23,6 +23,7 @@ #include <stdlib.h> #include <stdio.h> +#include "libavutil/cpu.h" #include "libavcodec/dsputil.h" #include "libavcodec/mpegvideo.h" @@ -570,7 +571,7 @@ static void dct_unquantize_h263_altivec(MpegEncContext *s, void MPV_common_init_altivec(MpegEncContext *s) { - if (!(mm_support() & AV_CPU_FLAG_ALTIVEC)) return; + if (!(av_get_cpu_flags() & AV_CPU_FLAG_ALTIVEC)) return; if (s->avctx->lowres==0) { if ((s->avctx->idct_algo == FF_IDCT_AUTO) || diff --git a/libavcodec/ppc/vp8dsp_altivec.c b/libavcodec/ppc/vp8dsp_altivec.c index b294154c6c..8096c4a535 100644 --- a/libavcodec/ppc/vp8dsp_altivec.c +++ b/libavcodec/ppc/vp8dsp_altivec.c @@ -20,6 +20,7 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ +#include "libavutil/cpu.h" #include "libavcodec/vp8dsp.h" #include "dsputil_altivec.h" #include "types_altivec.h" @@ -265,7 +266,7 @@ static void put_vp8_pixels16_altivec(uint8_t *dst, int stride, uint8_t *src, int av_cold void ff_vp8dsp_init_altivec(VP8DSPContext *c) { - if (!(mm_support() & AV_CPU_FLAG_ALTIVEC)) + if (!(av_get_cpu_flags() & AV_CPU_FLAG_ALTIVEC)) return; c->put_vp8_epel_pixels_tab[0][0][0] = put_vp8_pixels16_altivec; |