Skip to content

Commit

Permalink
detect available SIMD extensions when runtime-cpudetect is enabled
Browse files Browse the repository at this point in the history
initialize cpu extension with mm_support() in libpostproc and libswscale
if no one is set.

git-svn-id: http://svn.mythtv.org/svn/trunk@25829 7dbf422c-18fa-0310-86e9-fd20926502f2
  • Loading branch information
jannau committed Aug 24, 2010
1 parent bf2d1b4 commit 2069741
Show file tree
Hide file tree
Showing 4 changed files with 44 additions and 2 deletions.
2 changes: 1 addition & 1 deletion mythtv/external/FFmpeg/libpostproc/Makefile
@@ -1,7 +1,7 @@
include $(SUBDIR)../config.mak

NAME = postproc
FFLIBS = avutil
FFLIBS = avcodec avcore avutil

# x86_32 needs -O1 -fomit-frame-pointer to compile inline asm
ifeq ($(ARCH_X86_32), yes)
Expand Down
20 changes: 20 additions & 0 deletions mythtv/external/FFmpeg/libpostproc/postprocess.c
Expand Up @@ -87,6 +87,10 @@ try to unroll inner for(x=0 ... loop to avoid these damn if(x ... checks
#include "postprocess.h"
#include "postprocess_internal.h"

// for mm_support()
#include "libavcodec/avcodec.h"
#include "libavcodec/dsputil.h"

unsigned postproc_version(void)
{
return LIBPOSTPROC_VERSION_INT;
Expand Down Expand Up @@ -964,6 +968,22 @@ pp_context *pp_get_context(int width, int height, int cpuCaps){
PPContext *c= av_malloc(sizeof(PPContext));
int stride= FFALIGN(width, 16); //assumed / will realloc if needed
int qpStride= (width+15)/16 + 2; //assumed / will realloc if needed
int cpuflags;

if (CONFIG_RUNTIME_CPUDETECT &&
!(cpuCaps & (PP_CPU_CAPS_MMX | PP_CPU_CAPS_MMX2 |
PP_CPU_CAPS_3DNOW | PP_CPU_CAPS_ALTIVEC ))) {
cpuflags = mm_support();

if (cpuflags & FF_MM_MMX)
cpuCaps |= PP_CPU_CAPS_MMX;
if (cpuflags & FF_MM_MMX2)
cpuCaps |= PP_CPU_CAPS_MMX2;
if (cpuflags & FF_MM_3DNOW)
cpuCaps |= PP_CPU_CAPS_3DNOW;
if (cpuflags & FF_MM_ALTIVEC)
cpuCaps |= PP_CPU_CAPS_ALTIVEC;
}

memset(c, 0, sizeof(PPContext));
c->av_class = &av_codec_context_class;
Expand Down
2 changes: 1 addition & 1 deletion mythtv/external/FFmpeg/libswscale/Makefile
@@ -1,7 +1,7 @@
include $(SUBDIR)../config.mak

NAME = swscale
FFLIBS = avutil
FFLIBS = avcodec avcore avutil

HEADERS = swscale.h

Expand Down
22 changes: 22 additions & 0 deletions mythtv/external/FFmpeg/libswscale/utils.c
Expand Up @@ -45,6 +45,10 @@
#include "libavutil/bswap.h"
#include "libavutil/pixdesc.h"

// for mm_support()
#include "libavcodec/avcodec.h"
#include "libavcodec/dsputil.h"

unsigned swscale_version(void)
{
return LIBSWSCALE_VERSION_INT;
Expand Down Expand Up @@ -730,6 +734,24 @@ SwsContext *sws_getContext(int srcW, int srcH, enum PixelFormat srcFormat,
int unscaled;
int srcRange, dstRange;
SwsFilter dummyFilter= {NULL, NULL, NULL, NULL};
int cpuflags;

if (CONFIG_RUNTIME_CPUDETECT &&
!(flags & (SWS_CPU_CAPS_MMX | SWS_CPU_CAPS_MMX2 |
SWS_CPU_CAPS_3DNOW | SWS_CPU_CAPS_ALTIVEC |
SWS_CPU_CAPS_BFIN ))) {
cpuflags = mm_support();

if (cpuflags & FF_MM_MMX)
flags |= SWS_CPU_CAPS_MMX;
if (cpuflags & FF_MM_MMX2)
flags |= SWS_CPU_CAPS_MMX2;
if (cpuflags & FF_MM_3DNOW)
flags |= SWS_CPU_CAPS_3DNOW;
if (cpuflags & FF_MM_ALTIVEC)
flags |= SWS_CPU_CAPS_ALTIVEC;
}

#if ARCH_X86
if (flags & SWS_CPU_CAPS_MMX)
__asm__ volatile("emms\n\t"::: "memory");
Expand Down

0 comments on commit 2069741

Please sign in to comment.