diff options
author | Mans Rullgard <mans@mansr.com> | 2012-10-13 16:00:16 +0000 |
---|---|---|
committer | Mans Rullgard <mans@mansr.com> | 2012-10-15 02:39:49 +0100 |
commit | 95cd815c3663603871a1f2da95846e8f72d4ea96 (patch) | |
tree | cf165c6b29431b3ab242e78998c1a8b877d7764d /libswscale | |
parent | e98b02de5f925a76bfa70ca16388b87da804baa3 (diff) | |
download | ffmpeg-95cd815c3663603871a1f2da95846e8f72d4ea96.tar.gz |
swscale: try to use mmap only if available
Some systems, e.g. Minix, have sys/mman.h defining MAP_ANONYMOUS without
providing (working) mmap and friends. The mmx filter generation code
checks only for MAP_ANONYMOUS, not for availability of mmap itself which
leads to build errors on aforementioned systems.
This changes the conditional compilation to use mmap only if all the
required functions are available.
Signed-off-by: Mans Rullgard <mans@mansr.com>
Diffstat (limited to 'libswscale')
-rw-r--r-- | libswscale/utils.c | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/libswscale/utils.c b/libswscale/utils.c index 4001606a1b..a40dfe7c00 100644 --- a/libswscale/utils.c +++ b/libswscale/utils.c @@ -1018,6 +1018,8 @@ av_cold int sws_init_context(SwsContext *c, SwsFilter *srcFilter, } } +#define USE_MMAP (HAVE_MMAP && HAVE_MPROTECT && defined MAP_ANONYMOUS) + /* precalculate horizontal scaler filter coefficients */ { #if HAVE_MMXEXT_INLINE @@ -1028,7 +1030,7 @@ av_cold int sws_init_context(SwsContext *c, SwsFilter *srcFilter, c->chrMmx2FilterCodeSize = initMMX2HScaler(c->chrDstW, c->chrXInc, NULL, NULL, NULL, 4); -#ifdef MAP_ANONYMOUS +#if USE_MMAP c->lumMmx2FilterCode = mmap(NULL, c->lumMmx2FilterCodeSize, PROT_READ | PROT_WRITE, MAP_PRIVATE | MAP_ANONYMOUS, -1, 0); c->chrMmx2FilterCode = mmap(NULL, c->chrMmx2FilterCodeSize, PROT_READ | PROT_WRITE, MAP_PRIVATE | MAP_ANONYMOUS, -1, 0); #elif HAVE_VIRTUALALLOC @@ -1051,7 +1053,7 @@ av_cold int sws_init_context(SwsContext *c, SwsFilter *srcFilter, initMMX2HScaler(c->chrDstW, c->chrXInc, c->chrMmx2FilterCode, c->hChrFilter, c->hChrFilterPos, 4); -#ifdef MAP_ANONYMOUS +#if USE_MMAP mprotect(c->lumMmx2FilterCode, c->lumMmx2FilterCodeSize, PROT_EXEC | PROT_READ); mprotect(c->chrMmx2FilterCode, c->chrMmx2FilterCodeSize, PROT_EXEC | PROT_READ); #endif @@ -1630,7 +1632,7 @@ void sws_freeContext(SwsContext *c) av_freep(&c->hChrFilterPos); #if HAVE_MMX_INLINE -#ifdef MAP_ANONYMOUS +#if USE_MMAP if (c->lumMmx2FilterCode) munmap(c->lumMmx2FilterCode, c->lumMmx2FilterCodeSize); if (c->chrMmx2FilterCode) |