summaryrefslogtreecommitdiffstats
path: root/postproc
diff options
context:
space:
mode:
authoraurel <aurel@b3059339-0415-0410-9bf9-f77b7e298cf2>2005-01-31 15:57:27 +0000
committeraurel <aurel@b3059339-0415-0410-9bf9-f77b7e298cf2>2005-01-31 15:57:27 +0000
commit16637df8c28d1ed3a941d46b0fc09615455e874d (patch)
tree523ae870272560e020c42a86d8cd11c7e5535a26 /postproc
parentbf4b07cf12b689519b0a45263245980b6a7970ad (diff)
downloadmpv-16637df8c28d1ed3a941d46b0fc09615455e874d.tar.bz2
mpv-16637df8c28d1ed3a941d46b0fc09615455e874d.tar.xz
makes funnyCode pages executable (for CPU with NX bit)
git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@14626 b3059339-0415-0410-9bf9-f77b7e298cf2
Diffstat (limited to 'postproc')
-rw-r--r--postproc/swscale.c22
-rw-r--r--postproc/swscale_internal.h4
2 files changed, 24 insertions, 2 deletions
diff --git a/postproc/swscale.c b/postproc/swscale.c
index 5da32037e9..3a6766bea3 100644
--- a/postproc/swscale.c
+++ b/postproc/swscale.c
@@ -61,6 +61,9 @@ untested special converters
#else
#include <stdlib.h>
#endif
+#ifdef HAVE_SYS_MMAN_H
+#include <sys/mman.h>
+#endif
#include "swscale.h"
#include "swscale_internal.h"
#include "../cpudetect.h"
@@ -1999,6 +2002,15 @@ SwsContext *sws_getContext(int srcW, int srcH, int origSrcFormat, int dstW, int
// can't downscale !!!
if(c->canMMX2BeUsed && (flags & SWS_FAST_BILINEAR))
{
+#define MAX_FUNNY_CODE_SIZE 10000
+#ifdef HAVE_SYS_MMAN_H
+ c->funnyYCode = (uint8_t*)mmap(NULL, MAX_FUNNY_CODE_SIZE, PROT_EXEC | PROT_READ | PROT_WRITE, MAP_PRIVATE | MAP_ANONYMOUS, 0, 0);
+ c->funnyUVCode = (uint8_t*)mmap(NULL, MAX_FUNNY_CODE_SIZE, PROT_EXEC | PROT_READ | PROT_WRITE, MAP_PRIVATE | MAP_ANONYMOUS, 0, 0);
+#else
+ c->funnyYCode = (uint8_t*)memalign(32, MAX_FUNNY_CODE_SIZE);
+ c->funnyUVCode = (uint8_t*)memalign(32, MAX_FUNNY_CODE_SIZE);
+#endif
+
c->lumMmx2Filter = (int16_t*)memalign(8, (dstW /8+8)*sizeof(int16_t));
c->chrMmx2Filter = (int16_t*)memalign(8, (c->chrDstW /4+8)*sizeof(int16_t));
c->lumMmx2FilterPos= (int32_t*)memalign(8, (dstW /2/8+8)*sizeof(int32_t));
@@ -2556,6 +2568,16 @@ void sws_freeContext(SwsContext *c){
if(c->hChrFilterPos) free(c->hChrFilterPos);
c->hChrFilterPos = NULL;
+#ifdef HAVE_SYS_MMAN_H
+ if(c->funnyYCode) munmap(c->funnyYCode, MAX_FUNNY_CODE_SIZE);
+ if(c->funnyUVCode) munmap(c->funnyUVCode, MAX_FUNNY_CODE_SIZE);
+#else
+ if(c->funnyYCode) free(c->funnyYCode);
+ if(c->funnyUVCode) free(c->funnyUVCode);
+#endif
+ c->funnyYCode=NULL;
+ c->funnyUVCode=NULL;
+
if(c->lumMmx2Filter) free(c->lumMmx2Filter);
c->lumMmx2Filter=NULL;
if(c->chrMmx2Filter) free(c->chrMmx2Filter);
diff --git a/postproc/swscale_internal.h b/postproc/swscale_internal.h
index a224446568..d1fae26669 100644
--- a/postproc/swscale_internal.h
+++ b/postproc/swscale_internal.h
@@ -82,8 +82,8 @@ typedef struct SwsContext{
int vLumBufSize;
int vChrBufSize;
- uint8_t __attribute__((aligned(32))) funnyYCode[10000];
- uint8_t __attribute__((aligned(32))) funnyUVCode[10000];
+ uint8_t *funnyYCode;
+ uint8_t *funnyUVCode;
int32_t *lumMmx2FilterPos;
int32_t *chrMmx2FilterPos;
int16_t *lumMmx2Filter;