Commit c6c98d08 authored by Stefano Sabatini's avatar Stefano Sabatini

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
parent 9ec7458d
...@@ -633,7 +633,6 @@ SKIPHEADERS += mpegaudio3.h ...@@ -633,7 +633,6 @@ SKIPHEADERS += mpegaudio3.h
EXAMPLES = api EXAMPLES = api
TESTPROGS = cabac dct eval fft h264 iirfilter rangecoder snow TESTPROGS = cabac dct eval fft h264 iirfilter rangecoder snow
TESTPROGS-$(ARCH_X86) += x86/cpuid
TESTPROGS-$(HAVE_MMX) += motion TESTPROGS-$(HAVE_MMX) += motion
TESTOBJS = dctref.o TESTOBJS = dctref.o
......
...@@ -73,11 +73,6 @@ static void simple_idct_arm_add(uint8_t *dest, int line_size, DCTELEM *block) ...@@ -73,11 +73,6 @@ static void simple_idct_arm_add(uint8_t *dest, int line_size, DCTELEM *block)
ff_add_pixels_clamped(block, dest, line_size); ff_add_pixels_clamped(block, dest, line_size);
} }
int mm_support(void)
{
return HAVE_IWMMXT * AV_CPU_FLAG_IWMMXT;
}
void dsputil_init_arm(DSPContext* c, AVCodecContext *avctx) void dsputil_init_arm(DSPContext* c, AVCodecContext *avctx)
{ {
ff_put_pixels_clamped = c->put_pixels_clamped; ff_put_pixels_clamped = c->put_pixels_clamped;
......
...@@ -32,7 +32,7 @@ ...@@ -32,7 +32,7 @@
#define LIBAVCODEC_VERSION_MAJOR 52 #define LIBAVCODEC_VERSION_MAJOR 52
#define LIBAVCODEC_VERSION_MINOR 87 #define LIBAVCODEC_VERSION_MINOR 87
#define LIBAVCODEC_VERSION_MICRO 4 #define LIBAVCODEC_VERSION_MICRO 5
#define LIBAVCODEC_VERSION_INT AV_VERSION_INT(LIBAVCODEC_VERSION_MAJOR, \ #define LIBAVCODEC_VERSION_INT AV_VERSION_INT(LIBAVCODEC_VERSION_MAJOR, \
LIBAVCODEC_VERSION_MINOR, \ LIBAVCODEC_VERSION_MINOR, \
......
...@@ -32,6 +32,7 @@ ...@@ -32,6 +32,7 @@
#include <unistd.h> #include <unistd.h>
#include <math.h> #include <math.h>
#include "libavutil/cpu.h"
#include "libavutil/common.h" #include "libavutil/common.h"
#include "libavutil/lfg.h" #include "libavutil/lfg.h"
...@@ -554,7 +555,7 @@ int main(int argc, char **argv) ...@@ -554,7 +555,7 @@ int main(int argc, char **argv)
int test_idct = 0, test_248_dct = 0; int test_idct = 0, test_248_dct = 0;
int c,i; int c,i;
int test=1; int test=1;
cpu_flags = mm_support(); cpu_flags = av_get_cpu_flags();
ff_ref_dct_init(); ff_ref_dct_init();
idct_mmx_init(); idct_mmx_init();
......
...@@ -610,10 +610,6 @@ static inline int get_penalty_factor(int lambda, int lambda2, int type){ ...@@ -610,10 +610,6 @@ static inline int get_penalty_factor(int lambda, int lambda2, int type){
*/ */
#define emms_c() #define emms_c()
/* should be defined by architectures supporting
one or more MultiMedia extension */
int mm_support(void);
void dsputil_init_alpha(DSPContext* c, AVCodecContext *avctx); void dsputil_init_alpha(DSPContext* c, AVCodecContext *avctx);
void dsputil_init_arm(DSPContext* c, AVCodecContext *avctx); void dsputil_init_arm(DSPContext* c, AVCodecContext *avctx);
void dsputil_init_bfin(DSPContext* c, AVCodecContext *avctx); void dsputil_init_bfin(DSPContext* c, AVCodecContext *avctx);
...@@ -657,10 +653,6 @@ static inline void emms(void) ...@@ -657,10 +653,6 @@ static inline void emms(void)
#define STRIDE_ALIGN 16 #define STRIDE_ALIGN 16
#else
#define mm_support() 0
#endif #endif
#ifndef STRIDE_ALIGN #ifndef STRIDE_ALIGN
......
...@@ -25,6 +25,7 @@ ...@@ -25,6 +25,7 @@
* H.263 decoder. * H.263 decoder.
*/ */
#include "libavutil/cpu.h"
#include "internal.h" #include "internal.h"
#include "avcodec.h" #include "avcodec.h"
#include "dsputil.h" #include "dsputil.h"
...@@ -553,7 +554,7 @@ retry: ...@@ -553,7 +554,7 @@ retry:
#endif #endif
#if HAVE_MMX #if HAVE_MMX
if(s->codec_id == CODEC_ID_MPEG4 && s->xvid_build>=0 && avctx->idct_algo == FF_IDCT_AUTO && (mm_support() & AV_CPU_FLAG_MMX)){ if (s->codec_id == CODEC_ID_MPEG4 && s->xvid_build>=0 && avctx->idct_algo == FF_IDCT_AUTO && (av_get_cpu_flags() & AV_CPU_FLAG_MMX)) {
avctx->idct_algo= FF_IDCT_XVIDMMX; avctx->idct_algo= FF_IDCT_XVIDMMX;
avctx->coded_width= 0; // force reinit avctx->coded_width= 0; // force reinit
// dsputil_init(&s->dsp, avctx); // dsputil_init(&s->dsp, avctx);
......
...@@ -31,7 +31,7 @@ ...@@ -31,7 +31,7 @@
#include <xvid.h> #include <xvid.h>
#include <unistd.h> #include <unistd.h>
#include "avcodec.h" #include "avcodec.h"
#include "dsputil.h" #include "libavutil/cpu.h"
#include "libavutil/intreadwrite.h" #include "libavutil/intreadwrite.h"
#include "libxvid_internal.h" #include "libxvid_internal.h"
#if !HAVE_MKSTEMP #if !HAVE_MKSTEMP
...@@ -213,7 +213,7 @@ static av_cold int xvid_encode_init(AVCodecContext *avctx) { ...@@ -213,7 +213,7 @@ static av_cold int xvid_encode_init(AVCodecContext *avctx) {
#if ARCH_PPC #if ARCH_PPC
/* Xvid's PPC support is borked, use libavcodec to detect */ /* Xvid's PPC support is borked, use libavcodec to detect */
#if HAVE_ALTIVEC #if HAVE_ALTIVEC
if (mm_support() & AV_CPU_FLAG_ALTIVEC) { if (av_get_cpu_flags() & AV_CPU_FLAG_ALTIVEC) {
xvid_gbl_init.cpu_flags = XVID_CPU_FORCE | XVID_CPU_ALTIVEC; xvid_gbl_init.cpu_flags = XVID_CPU_FORCE | XVID_CPU_ALTIVEC;
} else } else
#endif #endif
......
...@@ -18,8 +18,7 @@ FFT-OBJS-$(HAVE_GNU_AS) += ppc/fft_altivec_s.o \ ...@@ -18,8 +18,7 @@ FFT-OBJS-$(HAVE_GNU_AS) += ppc/fft_altivec_s.o \
ALTIVEC-OBJS-$(CONFIG_FFT) += ppc/fft_altivec.o \ ALTIVEC-OBJS-$(CONFIG_FFT) += ppc/fft_altivec.o \
$(FFT-OBJS-yes) $(FFT-OBJS-yes)
OBJS-$(HAVE_ALTIVEC) += ppc/check_altivec.o \ OBJS-$(HAVE_ALTIVEC) += ppc/dsputil_altivec.o \
ppc/dsputil_altivec.o \
ppc/fdct_altivec.o \ ppc/fdct_altivec.o \
ppc/float_altivec.o \ ppc/float_altivec.o \
ppc/gmc_altivec.o \ ppc/gmc_altivec.o \
......
...@@ -20,6 +20,7 @@ ...@@ -20,6 +20,7 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/ */
#include "libavutil/cpu.h"
#include "libavcodec/dsputil.h" #include "libavcodec/dsputil.h"
#include "dsputil_altivec.h" #include "dsputil_altivec.h"
...@@ -168,7 +169,7 @@ void dsputil_init_ppc(DSPContext* c, AVCodecContext *avctx) ...@@ -168,7 +169,7 @@ void dsputil_init_ppc(DSPContext* c, AVCodecContext *avctx)
#if HAVE_ALTIVEC #if HAVE_ALTIVEC
if(CONFIG_H264_DECODER) dsputil_h264_init_ppc(c, avctx); 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); dsputil_init_altivec(c, avctx);
if(CONFIG_VC1_DECODER) if(CONFIG_VC1_DECODER)
vc1dsp_init_altivec(c, avctx); vc1dsp_init_altivec(c, avctx);
......
...@@ -18,6 +18,7 @@ ...@@ -18,6 +18,7 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/ */
#include "libavutil/cpu.h"
#include "libavcodec/dsputil.h" #include "libavcodec/dsputil.h"
#include "libavcodec/h264data.h" #include "libavcodec/h264data.h"
#include "libavcodec/h264dsp.h" #include "libavcodec/h264dsp.h"
...@@ -969,7 +970,7 @@ H264_WEIGHT( 8, 4) ...@@ -969,7 +970,7 @@ H264_WEIGHT( 8, 4)
void dsputil_h264_init_ppc(DSPContext* c, AVCodecContext *avctx) { 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->put_h264_chroma_pixels_tab[0] = put_h264_chroma_mc8_altivec;
c->avg_h264_chroma_pixels_tab[0] = avg_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; 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) { ...@@ -1001,7 +1002,7 @@ void dsputil_h264_init_ppc(DSPContext* c, AVCodecContext *avctx) {
void ff_h264dsp_init_ppc(H264DSPContext *c) 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_add = ff_h264_idct_add_altivec;
c->h264_idct_add8 = ff_h264_idct_add8_altivec; c->h264_idct_add8 = ff_h264_idct_add8_altivec;
c->h264_idct_add16 = ff_h264_idct_add16_altivec; c->h264_idct_add16 = ff_h264_idct_add16_altivec;
......
...@@ -23,6 +23,7 @@ ...@@ -23,6 +23,7 @@
#include <stdlib.h> #include <stdlib.h>
#include <stdio.h> #include <stdio.h>
#include "libavutil/cpu.h"
#include "libavcodec/dsputil.h" #include "libavcodec/dsputil.h"
#include "libavcodec/mpegvideo.h" #include "libavcodec/mpegvideo.h"
...@@ -570,7 +571,7 @@ static void dct_unquantize_h263_altivec(MpegEncContext *s, ...@@ -570,7 +571,7 @@ static void dct_unquantize_h263_altivec(MpegEncContext *s,
void MPV_common_init_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->lowres==0) {
if ((s->avctx->idct_algo == FF_IDCT_AUTO) || if ((s->avctx->idct_algo == FF_IDCT_AUTO) ||
......
...@@ -20,6 +20,7 @@ ...@@ -20,6 +20,7 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/ */
#include "libavutil/cpu.h"
#include "libavcodec/vp8dsp.h" #include "libavcodec/vp8dsp.h"
#include "dsputil_altivec.h" #include "dsputil_altivec.h"
#include "types_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 ...@@ -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) 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; return;
c->put_vp8_epel_pixels_tab[0][0][0] = put_vp8_pixels16_altivec; c->put_vp8_epel_pixels_tab[0][0][0] = put_vp8_pixels16_altivec;
......
...@@ -43,8 +43,7 @@ MMX-OBJS-$(HAVE_YASM) += x86/dsputil_yasm.o \ ...@@ -43,8 +43,7 @@ MMX-OBJS-$(HAVE_YASM) += x86/dsputil_yasm.o \
MMX-OBJS-$(CONFIG_FFT) += x86/fft.o MMX-OBJS-$(CONFIG_FFT) += x86/fft.o
OBJS-$(HAVE_MMX) += x86/cpuid.o \ OBJS-$(HAVE_MMX) += x86/dnxhd_mmx.o \
x86/dnxhd_mmx.o \
x86/dsputil_mmx.o \ x86/dsputil_mmx.o \
x86/fdct_mmx.o \ x86/fdct_mmx.o \
x86/idct_mmx_xvid.o \ x86/idct_mmx_xvid.o \
......
...@@ -23,6 +23,7 @@ ...@@ -23,6 +23,7 @@
*/ */
#include "libavutil/common.h" #include "libavutil/common.h"
#include "libavutil/cpu.h"
#include "libavutil/x86_cpu.h" #include "libavutil/x86_cpu.h"
#include "libavcodec/dsputil.h" #include "libavcodec/dsputil.h"
#include "libavcodec/cavsdsp.h" #include "libavcodec/cavsdsp.h"
...@@ -472,7 +473,7 @@ static void ff_cavsdsp_init_3dnow(CAVSDSPContext* c, AVCodecContext *avctx) { ...@@ -472,7 +473,7 @@ static void ff_cavsdsp_init_3dnow(CAVSDSPContext* c, AVCodecContext *avctx) {
void ff_cavsdsp_init_mmx(CAVSDSPContext *c, AVCodecContext *avctx) void ff_cavsdsp_init_mmx(CAVSDSPContext *c, AVCodecContext *avctx)
{ {
int mm_flags = mm_support(); int mm_flags = av_get_cpu_flags();
if (mm_flags & AV_CPU_FLAG_MMX2) ff_cavsdsp_init_mmx2 (c, avctx); if (mm_flags & AV_CPU_FLAG_MMX2) ff_cavsdsp_init_mmx2 (c, avctx);
if (mm_flags & AV_CPU_FLAG_3DNOW) ff_cavsdsp_init_3dnow(c, avctx); if (mm_flags & AV_CPU_FLAG_3DNOW) ff_cavsdsp_init_3dnow(c, avctx);
......
...@@ -52,7 +52,7 @@ static void get_pixels_8x4_sym_sse2(DCTELEM *block, const uint8_t *pixels, int l ...@@ -52,7 +52,7 @@ static void get_pixels_8x4_sym_sse2(DCTELEM *block, const uint8_t *pixels, int l
void ff_dnxhd_init_mmx(DNXHDEncContext *ctx) void ff_dnxhd_init_mmx(DNXHDEncContext *ctx)
{ {
if (mm_support() & AV_CPU_FLAG_SSE2) { if (av_get_cpu_flags() & AV_CPU_FLAG_SSE2) {
ctx->get_pixels_8x4_sym = get_pixels_8x4_sym_sse2; ctx->get_pixels_8x4_sym = get_pixels_8x4_sym_sse2;
} }
} }
...@@ -2523,7 +2523,7 @@ float ff_scalarproduct_float_sse(const float *v1, const float *v2, int order); ...@@ -2523,7 +2523,7 @@ float ff_scalarproduct_float_sse(const float *v1, const float *v2, int order);
void dsputil_init_mmx(DSPContext* c, AVCodecContext *avctx) void dsputil_init_mmx(DSPContext* c, AVCodecContext *avctx)
{ {
int mm_flags = mm_support(); int mm_flags = av_get_cpu_flags();
if (avctx->dsp_mask) { if (avctx->dsp_mask) {
if (avctx->dsp_mask & AV_CPU_FLAG_FORCE) if (avctx->dsp_mask & AV_CPU_FLAG_FORCE)
......
...@@ -22,6 +22,7 @@ ...@@ -22,6 +22,7 @@
* MMX optimization by Nick Kurshev <nickols_k@mail.ru> * MMX optimization by Nick Kurshev <nickols_k@mail.ru>
*/ */
#include "libavutil/cpu.h"
#include "libavutil/x86_cpu.h" #include "libavutil/x86_cpu.h"
#include "libavcodec/dsputil.h" #include "libavcodec/dsputil.h"
#include "libavcodec/mpegvideo.h" #include "libavcodec/mpegvideo.h"
...@@ -1350,7 +1351,7 @@ static int ssd_int8_vs_int16_mmx(const int8_t *pix1, const int16_t *pix2, int si ...@@ -1350,7 +1351,7 @@ static int ssd_int8_vs_int16_mmx(const int8_t *pix1, const int16_t *pix2, int si
void dsputilenc_init_mmx(DSPContext* c, AVCodecContext *avctx) void dsputilenc_init_mmx(DSPContext* c, AVCodecContext *avctx)
{ {
int mm_flags = mm_support(); int mm_flags = av_get_cpu_flags();
if (mm_flags & AV_CPU_FLAG_MMX) { if (mm_flags & AV_CPU_FLAG_MMX) {
const int dct_algo = avctx->dct_algo; const int dct_algo = avctx->dct_algo;
......
...@@ -16,13 +16,14 @@ ...@@ -16,13 +16,14 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/ */
#include "libavutil/cpu.h"
#include "libavcodec/dsputil.h" #include "libavcodec/dsputil.h"
#include "fft.h" #include "fft.h"
av_cold void ff_fft_init_mmx(FFTContext *s) av_cold void ff_fft_init_mmx(FFTContext *s)
{ {
#if HAVE_YASM #if HAVE_YASM
int has_vectors = mm_support(); int has_vectors = av_get_cpu_flags();
if (has_vectors & AV_CPU_FLAG_SSE && HAVE_SSE) { if (has_vectors & AV_CPU_FLAG_SSE && HAVE_SSE) {
/* SSE for P3/P4/K8 */ /* SSE for P3/P4/K8 */
s->imdct_calc = ff_imdct_calc_sse; s->imdct_calc = ff_imdct_calc_sse;
...@@ -46,7 +47,7 @@ av_cold void ff_fft_init_mmx(FFTContext *s) ...@@ -46,7 +47,7 @@ av_cold void ff_fft_init_mmx(FFTContext *s)
#if CONFIG_DCT #if CONFIG_DCT
av_cold void ff_dct_init_mmx(DCTContext *s) av_cold void ff_dct_init_mmx(DCTContext *s)
{ {
int has_vectors = mm_support(); int has_vectors = av_get_cpu_flags();
if (has_vectors & AV_CPU_FLAG_SSE && HAVE_SSE) if (has_vectors & AV_CPU_FLAG_SSE && HAVE_SSE)
s->dct32 = ff_dct32_float_sse; s->dct32 = ff_dct32_float_sse;
} }
......
...@@ -18,6 +18,7 @@ ...@@ -18,6 +18,7 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/ */
#include "libavutil/cpu.h"
#include "libavcodec/h264pred.h" #include "libavcodec/h264pred.h"
void ff_pred16x16_vertical_mmx (uint8_t *src, int stride); void ff_pred16x16_vertical_mmx (uint8_t *src, int stride);
...@@ -48,7 +49,7 @@ void ff_pred4x4_vertical_vp8_mmxext(uint8_t *src, const uint8_t *topright, int s ...@@ -48,7 +49,7 @@ void ff_pred4x4_vertical_vp8_mmxext(uint8_t *src, const uint8_t *topright, int s
void ff_h264_pred_init_x86(H264PredContext *h, int codec_id) void ff_h264_pred_init_x86(H264PredContext *h, int codec_id)
{ {
int mm_flags = mm_support(); int mm_flags = av_get_cpu_flags();
#if HAVE_YASM #if HAVE_YASM
if (mm_flags & AV_CPU_FLAG_MMX) { if (mm_flags & AV_CPU_FLAG_MMX) {
......
...@@ -18,6 +18,7 @@ ...@@ -18,6 +18,7 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/ */
#include "libavutil/cpu.h"
#include "libavutil/x86_cpu.h" #include "libavutil/x86_cpu.h"
#include "libavcodec/h264dsp.h" #include "libavcodec/h264dsp.h"
#include "dsputil_mmx.h" #include "dsputil_mmx.h"
...@@ -742,7 +743,7 @@ H264_BIWEIGHT_MMX ( 4, 2) ...@@ -742,7 +743,7 @@ H264_BIWEIGHT_MMX ( 4, 2)
void ff_h264dsp_init_x86(H264DSPContext *c) void ff_h264dsp_init_x86(H264DSPContext *c)
{ {
int mm_flags = mm_support(); int mm_flags = av_get_cpu_flags();
if (mm_flags & AV_CPU_FLAG_MMX) { if (mm_flags & AV_CPU_FLAG_MMX) {
c->h264_idct_dc_add= c->h264_idct_dc_add=
......
...@@ -427,7 +427,7 @@ PIX_SAD(mmx2) ...@@ -427,7 +427,7 @@ PIX_SAD(mmx2)
void dsputil_init_pix_mmx(DSPContext* c, AVCodecContext *avctx) void dsputil_init_pix_mmx(DSPContext* c, AVCodecContext *avctx)
{ {
int mm_flags = mm_support(); int mm_flags = av_get_cpu_flags();
if (mm_flags & AV_CPU_FLAG_MMX) { if (mm_flags & AV_CPU_FLAG_MMX) {
c->pix_abs[0][0] = sad16_mmx; c->pix_abs[0][0] = sad16_mmx;
......
...@@ -19,6 +19,7 @@ ...@@ -19,6 +19,7 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/ */
#include "libavutil/cpu.h"
#include "libavutil/x86_cpu.h" #include "libavutil/x86_cpu.h"
#define CONFIG_FLOAT 1 #define CONFIG_FLOAT 1
...@@ -149,7 +150,7 @@ static void apply_window_mp3(float *in, float *win, int *unused, float *out, ...@@ -149,7 +150,7 @@ static void apply_window_mp3(float *in, float *win, int *unused, float *out,
void ff_mpegaudiodec_init_mmx(MPADecodeContext *s) void ff_mpegaudiodec_init_mmx(MPADecodeContext *s)
{ {
int mm_flags = mm_support(); int mm_flags = av_get_cpu_flags();
if (mm_flags & AV_CPU_FLAG_SSE2) { if (mm_flags & AV_CPU_FLAG_SSE2) {
s->apply_window_mp3 = apply_window_mp3; s->apply_window_mp3 = apply_window_mp3;
......
...@@ -22,6 +22,7 @@ ...@@ -22,6 +22,7 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/ */
#include "libavutil/cpu.h"
#include "libavutil/x86_cpu.h" #include "libavutil/x86_cpu.h"
#include "libavcodec/avcodec.h" #include "libavcodec/avcodec.h"
#include "libavcodec/dsputil.h" #include "libavcodec/dsputil.h"
...@@ -625,7 +626,7 @@ static void denoise_dct_sse2(MpegEncContext *s, DCTELEM *block){ ...@@ -625,7 +626,7 @@ static void denoise_dct_sse2(MpegEncContext *s, DCTELEM *block){
void MPV_common_init_mmx(MpegEncContext *s) void MPV_common_init_mmx(MpegEncContext *s)
{ {
int mm_flags = mm_support(); int mm_flags = av_get_cpu_flags();
if (mm_flags & AV_CPU_FLAG_MMX) { if (mm_flags & AV_CPU_FLAG_MMX) {
const int dct_algo = s->avctx->dct_algo; const int dct_algo = s->avctx->dct_algo;
......
...@@ -875,7 +875,7 @@ static void ff_snow_inner_add_yblock_mmx(const uint8_t *obmc, const int obmc_str ...@@ -875,7 +875,7 @@ static void ff_snow_inner_add_yblock_mmx(const uint8_t *obmc, const int obmc_str
void ff_dwt_init_x86(DWTContext *c) void ff_dwt_init_x86(DWTContext *c)
{ {
int mm_flags = mm_support(); int mm_flags = av_get_cpu_flags();
if (mm_flags & AV_CPU_FLAG_MMX) { if (mm_flags & AV_CPU_FLAG_MMX) {
if(mm_flags & AV_CPU_FLAG_SSE2 & 0){ if(mm_flags & AV_CPU_FLAG_SSE2 & 0){
......
...@@ -24,6 +24,7 @@ ...@@ -24,6 +24,7 @@
* OTHER DEALINGS IN THE SOFTWARE. * OTHER DEALINGS IN THE SOFTWARE.
*/ */
#include "libavutil/cpu.h"
#include "libavutil/x86_cpu.h" #include "libavutil/x86_cpu.h"
#include "libavcodec/dsputil.h" #include "libavcodec/dsputil.h"
#include "dsputil_mmx.h" #include "dsputil_mmx.h"
...@@ -714,7 +715,7 @@ static void vc1_h_loop_filter16_sse4(uint8_t *src, int stride, int pq) ...@@ -714,7 +715,7 @@ static void vc1_h_loop_filter16_sse4(uint8_t *src, int stride, int pq)
#endif #endif
void ff_vc1dsp_init_mmx(DSPContext* dsp, AVCodecContext *avctx) { void ff_vc1dsp_init_mmx(DSPContext* dsp, AVCodecContext *avctx) {
int mm_flags = mm_support(); int mm_flags = av_get_cpu_flags();
dsp->put_vc1_mspel_pixels_tab[ 0] = ff_put_vc1_mspel_mc00_mmx; dsp->put_vc1_mspel_pixels_tab[ 0] = ff_put_vc1_mspel_mc00_mmx;
dsp->put_vc1_mspel_pixels_tab[ 4] = put_vc1_mspel_mc01_mmx; dsp->put_vc1_mspel_pixels_tab[ 4] = put_vc1_mspel_mc01_mmx;
......
...@@ -20,6 +20,7 @@ ...@@ -20,6 +20,7 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/ */
#include "libavutil/cpu.h"
#include "libavutil/x86_cpu.h" #include "libavutil/x86_cpu.h"
#include "libavcodec/dsputil.h" #include "libavcodec/dsputil.h"
#include "libavcodec/vp56dsp.h" #include "libavcodec/vp56dsp.h"
...@@ -32,7 +33,7 @@ void ff_vp6_filter_diag4_sse2(uint8_t *dst, uint8_t *src, int stride, ...@@ -32,7 +33,7 @@ void ff_vp6_filter_diag4_sse2(uint8_t *dst, uint8_t *src, int stride,
av_cold void ff_vp56dsp_init_x86(VP56DSPContext* c, enum CodecID codec) av_cold void ff_vp56dsp_init_x86(VP56DSPContext* c, enum CodecID codec)
{ {
#if HAVE_YASM #if HAVE_YASM
int mm_flags = mm_support(); int mm_flags = av_get_cpu_flags();
if (CONFIG_VP6_DECODER && codec == CODEC_ID_VP6) { if (CONFIG_VP6_DECODER && codec == CODEC_ID_VP6) {
if (mm_flags & AV_CPU_FLAG_MMX) { if (mm_flags & AV_CPU_FLAG_MMX) {
......
...@@ -20,6 +20,7 @@ ...@@ -20,6 +20,7 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/ */
#include "libavutil/cpu.h"
#include "libavutil/x86_cpu.h" #include "libavutil/x86_cpu.h"
#include "libavcodec/vp8dsp.h" #include "libavcodec/vp8dsp.h"
...@@ -282,7 +283,7 @@ DECLARE_LOOP_FILTER(sse4) ...@@ -282,7 +283,7 @@ DECLARE_LOOP_FILTER(sse4)
av_cold void ff_vp8dsp_init_x86(VP8DSPContext* c) av_cold void ff_vp8dsp_init_x86(VP8DSPContext* c)
{ {
int mm_flags = mm_support(); int mm_flags = av_get_cpu_flags();
#if HAVE_YASM #if HAVE_YASM
if (mm_flags & AV_CPU_FLAG_MMX) { if (mm_flags & AV_CPU_FLAG_MMX) {
......
...@@ -34,6 +34,7 @@ OBJS = adler32.o \ ...@@ -34,6 +34,7 @@ OBJS = adler32.o \
aes.o \ aes.o \
avstring.o \ avstring.o \
base64.o \ base64.o \
cpu.o \
crc.o \ crc.o \
des.o \ des.o \
error.o \ error.o \
...@@ -56,7 +57,7 @@ OBJS = adler32.o \ ...@@ -56,7 +57,7 @@ OBJS = adler32.o \
tree.o \ tree.o \
utils.o \ utils.o \
TESTPROGS = adler32 aes base64 crc des lls md5 pca sha softfloat tree TESTPROGS = adler32 aes base64 cpu crc des lls md5 pca sha softfloat tree
TESTPROGS-$(HAVE_LZO1X_999_COMPRESS) += lzo TESTPROGS-$(HAVE_LZO1X_999_COMPRESS) += lzo
DIRS = arm bfin sh4 x86 DIRS = arm bfin sh4 x86
......
/*
* 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 AVUTIL_ARM_CPU_H
#define AVUTIL_ARM_CPU_H
#include "config.h"
int av_get_cpu_flags(void)
{
return HAVE_IWMMXT * AV_CPU_FLAG_IWMMXT;
}
#endif /* AVUTIL_ARM_CPU_H */
...@@ -40,7 +40,7 @@ ...@@ -40,7 +40,7 @@
#define AV_VERSION(a, b, c) AV_VERSION_DOT(a, b, c) #define AV_VERSION(a, b, c) AV_VERSION_DOT(a, b, c)
#define LIBAVUTIL_VERSION_MAJOR 50 #define LIBAVUTIL_VERSION_MAJOR 50
#define LIBAVUTIL_VERSION_MINOR 25 #define LIBAVUTIL_VERSION_MINOR 26
#define LIBAVUTIL_VERSION_MICRO 0 #define LIBAVUTIL_VERSION_MICRO 0
#define LIBAVUTIL_VERSION_INT AV_VERSION_INT(LIBAVUTIL_VERSION_MAJOR, \ #define LIBAVUTIL_VERSION_INT AV_VERSION_INT(LIBAVUTIL_VERSION_MAJOR, \
......
/*
* 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 "cpu.h"
#include "config.h"
#if ARCH_ARM
# include "arm/cpu.h"
#elif ARCH_PPC
# include "ppc/cpu.h"
#elif ARCH_X86
# include "x86/cpu.h"
#else
int av_get_cpu_flags(void)
{
return 0;
}
#endif
#ifdef TEST
#undef printf
int main(void)
{
int cpu_flags = av_get_cpu_flags();
printf("cpu_flags = 0x%08X\n", cpu_flags);
printf("cpu_flags = %s%s%s%s%s%s%s%s%s%s%s%s\n",
#if ARCH_ARM
cpu_flags & AV_CPU_FLAG_IWMMXT ? "IWMMXT " : "",
#elif ARCH_PPC
cpu_flags & AV_CPU_FLAG_ALTIVEC ? "ALTIVEC " : "",
#elif ARCH_X86
cpu_flags & AV_CPU_FLAG_MMX ? "MMX " : "",
cpu_flags & AV_CPU_FLAG_MMX2 ? "MMX2 " : "",
cpu_flags & AV_CPU_FLAG_SSE ? "SSE " : "",
cpu_flags & AV_CPU_FLAG_SSE2 ? "SSE2 " : "",
cpu_flags & AV_CPU_FLAG_SSE2SLOW ? "SSE2(slow) " : "",
cpu_flags & AV_CPU_FLAG_SSE3 ? "SSE3 " : "",
cpu_flags & AV_CPU_FLAG_SSE3SLOW ? "SSE3(slow) " : "",
cpu_flags & AV_CPU_FLAG_SSSE3 ? "SSSE3 " : "",
cpu_flags & AV_CPU_FLAG_SSE4 ? "SSE4.1 " : "",
cpu_flags & AV_CPU_FLAG_SSE42 ? "SSE4.2 " : "",
cpu_flags & AV_CPU_FLAG_3DNOW ? "3DNow " : "",
cpu_flags & AV_CPU_FLAG_3DNOWEXT ? "3DNowExt " : "");
#endif
return 0;
}
#endif
...@@ -41,4 +41,9 @@ ...@@ -41,4 +41,9 @@
#define AV_CPU_FLAG_IWMMXT 0x0100 ///< XScale IWMMXT #define AV_CPU_FLAG_IWMMXT 0x0100 ///< XScale IWMMXT
#define AV_CPU_FLAG_ALTIVEC 0x0001 ///< standard #define AV_CPU_FLAG_ALTIVEC 0x0001 ///< standard
/**
* Return the flags which specify extensions supported by the CPU.
*/
int av_get_cpu_flags(void);
#endif /* AVUTIL_CPU_H */ #endif /* AVUTIL_CPU_H */
...@@ -16,11 +16,8 @@ ...@@ -16,11 +16,8 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/ */
#ifndef AVUTIL_PPC_CPU_H
/** #define AVUTIL_PPC_CPU_H
* @file
* Check for AltiVec presence.
*/
#ifdef __APPLE__ #ifdef __APPLE__
#undef _POSIX_C_SOURCE #undef _POSIX_C_SOURCE
...@@ -36,14 +33,12 @@ ...@@ -36,14 +33,12 @@
#endif /* __APPLE__ */ #endif /* __APPLE__ */
#include "config.h" #include "config.h"
#include "dsputil_altivec.h"
/** /**
* This function MAY rely on signal() or fork() in order to make sure AltiVec * This function MAY rely on signal() or fork() in order to make sure AltiVec
* is present. * is present.
*/ */
int av_get_cpu_flags(void)
int mm_support(void)
{ {
#if HAVE_ALTIVEC #if HAVE_ALTIVEC
#ifdef __AMIGAOS4__ #ifdef __AMIGAOS4__
...@@ -90,3 +85,4 @@ int mm_support(void) ...@@ -90,3 +85,4 @@ int mm_support(void)
return 0; return 0;
} }
#endif /* AVUTIL_PPC_CPU_H */
...@@ -20,11 +20,12 @@ ...@@ -20,11 +20,12 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/ */
#ifndef AVUTIL_X86_CPU_H2
#define AVUTIL_X86_CPU_H2
#include <stdlib.h> #include <stdlib.h>
#include "libavutil/x86_cpu.h" #include "libavutil/x86_cpu.h"
#include "libavcodec/dsputil.h" #include "libavutil/cpu.h"
#undef printf
/* ebx saving is necessary for PIC. gcc seems unable to see it alone */ /* ebx saving is necessary for PIC. gcc seems unable to see it alone */
#define cpuid(index,eax,ebx,ecx,edx)\ #define cpuid(index,eax,ebx,ecx,edx)\
...@@ -37,7 +38,7 @@ ...@@ -37,7 +38,7 @@
: "0" (index)); : "0" (index));
/* Function to test if multimedia instructions are supported... */ /* Function to test if multimedia instructions are supported... */
int mm_support(void) int av_get_cpu_flags(void)
{ {
int rval = 0; int rval = 0;
int eax, ebx, ecx, edx; int eax, ebx, ecx, edx;
...@@ -121,30 +122,7 @@ int mm_support(void) ...@@ -121,30 +122,7 @@ int mm_support(void)
if (rval & AV_CPU_FLAG_SSE3) rval ^= AV_CPU_FLAG_SSE3SLOW|AV_CPU_FLAG_SSE3; if (rval & AV_CPU_FLAG_SSE3) rval ^= AV_CPU_FLAG_SSE3SLOW|AV_CPU_FLAG_SSE3;
} }
#if 0
av_log(NULL, AV_LOG_DEBUG, "%s%s%s%s%s%s%s%s%s%s%s%s\n",
(rval&AV_CPU_FLAG_MMX) ? "MMX ":"",
(rval&AV_CPU_FLAG_MMX2) ? "MMX2 ":"",
(rval&AV_CPU_FLAG_SSE) ? "SSE ":"",
(rval&AV_CPU_FLAG_SSE2) ? "SSE2 ":"",
(rval&AV_CPU_FLAG_SSE2SLOW) ? "SSE2(slow) ":"",
(rval&AV_CPU_FLAG_SSE3) ? "SSE3 ":"",
(rval&AV_CPU_FLAG_SSE3SLOW) ? "SSE3(slow) ":"",
(rval&AV_CPU_FLAG_SSSE3) ? "SSSE3 ":"",
(rval&AV_CPU_FLAG_SSE4) ? "SSE4.1 ":"",
(rval&AV_CPU_FLAG_SSE42) ? "SSE4.2 ":"",
(rval&AV_CPU_FLAG_3DNOW) ? "3DNow ":"",
(rval&AV_CPU_FLAG_3DNOWEXT) ? "3DNowExt ":"");
#endif
return rval; return rval;
} }
#ifdef TEST #endif /* AVUTIL_X86_CPU_H2 */
int main ( void )
{
int mm_flags;
mm_flags = mm_support();
printf("mm_support = 0x%08X\n",mm_flags);
return 0;
}
#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