summaryrefslogtreecommitdiffstats
path: root/libswscale
diff options
context:
space:
mode:
authorramiro <ramiro@b3059339-0415-0410-9bf9-f77b7e298cf2>2009-08-13 18:31:07 +0000
committerramiro <ramiro@b3059339-0415-0410-9bf9-f77b7e298cf2>2009-08-13 18:31:07 +0000
commit301a0e49404adc78521430da261bafb07ceb1a06 (patch)
treec2970530b56f660a5045324579a68369b62b95c9 /libswscale
parenta409c31dd1e0e0cd675f7fbcdd8517aa81df2857 (diff)
downloadmpv-301a0e49404adc78521430da261bafb07ceb1a06.tar.bz2
mpv-301a0e49404adc78521430da261bafb07ceb1a06.tar.xz
MMX2 horizontal scaler: Determine code size at runtime.
git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@29510 b3059339-0415-0410-9bf9-f77b7e298cf2
Diffstat (limited to 'libswscale')
-rw-r--r--libswscale/swscale.c36
-rw-r--r--libswscale/swscale_internal.h2
2 files changed, 24 insertions, 14 deletions
diff --git a/libswscale/swscale.c b/libswscale/swscale.c
index 4a69ab8ea1..f185d2354a 100644
--- a/libswscale/swscale.c
+++ b/libswscale/swscale.c
@@ -1753,7 +1753,7 @@ error:
}
#ifdef COMPILE_MMX2
-static void initMMX2HScaler(int dstW, int xInc, uint8_t *filterCode, int16_t *filter, int32_t *filterPos, int numSplits)
+static int initMMX2HScaler(int dstW, int xInc, uint8_t *filterCode, int16_t *filter, int32_t *filterPos, int numSplits)
{
uint8_t *fragmentA;
x86_reg imm8OfPShufW1A;
@@ -1870,6 +1870,7 @@ static void initMMX2HScaler(int dstW, int xInc, uint8_t *filterCode, int16_t *fi
int maxShift= 3-(d+inc);
int shift=0;
+ if (filterCode) {
filter[i ] = (( xpos & 0xFFFF) ^ 0xFFFF)>>9;
filter[i+1] = (((xpos+xInc ) & 0xFFFF) ^ 0xFFFF)>>9;
filter[i+2] = (((xpos+xInc*2) & 0xFFFF) ^ 0xFFFF)>>9;
@@ -1892,14 +1893,19 @@ static void initMMX2HScaler(int dstW, int xInc, uint8_t *filterCode, int16_t *fi
filterCode[fragmentPos + imm8OfPShufW2]+= 0x55*shift;
filterPos[i/2]-=shift;
}
+ }
fragmentPos+= fragmentLength;
+ if (filterCode)
filterCode[fragmentPos]= RET;
}
xpos+=xInc;
}
+ if (filterCode)
filterPos[((i/2)+1)&(~1)]= xpos>>16; // needed to jump to the next part
+
+ return fragmentPos + 1;
}
#endif /* COMPILE_MMX2 */
@@ -2808,20 +2814,22 @@ SwsContext *sws_getContext(int srcW, int srcH, enum PixelFormat srcFormat, int d
(flags&SWS_BICUBLIN) ? (flags|SWS_BILINEAR) : flags,
srcFilter->chrH, dstFilter->chrH, c->param);
-#define MAX_MMX2_FILTER_CODE_SIZE 10000
#if defined(COMPILE_MMX2)
// can't downscale !!!
if (c->canMMX2BeUsed && (flags & SWS_FAST_BILINEAR))
{
+ c->lumMmx2FilterCodeSize = initMMX2HScaler( dstW, c->lumXInc, NULL, NULL, NULL, 8);
+ c->chrMmx2FilterCodeSize = initMMX2HScaler(c->chrDstW, c->chrXInc, NULL, NULL, NULL, 4);
+
#ifdef MAP_ANONYMOUS
- c->lumMmx2FilterCode = mmap(NULL, MAX_MMX2_FILTER_CODE_SIZE, PROT_READ | PROT_WRITE, MAP_PRIVATE | MAP_ANONYMOUS, 0, 0);
- c->chrMmx2FilterCode = mmap(NULL, MAX_MMX2_FILTER_CODE_SIZE, PROT_READ | PROT_WRITE, MAP_PRIVATE | MAP_ANONYMOUS, 0, 0);
+ c->lumMmx2FilterCode = mmap(NULL, c->lumMmx2FilterCodeSize, PROT_READ | PROT_WRITE, MAP_PRIVATE | MAP_ANONYMOUS, 0, 0);
+ c->chrMmx2FilterCode = mmap(NULL, c->chrMmx2FilterCodeSize, PROT_READ | PROT_WRITE, MAP_PRIVATE | MAP_ANONYMOUS, 0, 0);
#elif HAVE_VIRTUALALLOC
- c->lumMmx2FilterCode = VirtualAlloc(NULL, MAX_MMX2_FILTER_CODE_SIZE, MEM_COMMIT, PAGE_EXECUTE_READWRITE);
- c->chrMmx2FilterCode = VirtualAlloc(NULL, MAX_MMX2_FILTER_CODE_SIZE, MEM_COMMIT, PAGE_EXECUTE_READWRITE);
+ c->lumMmx2FilterCode = VirtualAlloc(NULL, c->lumMmx2FilterCodeSize, MEM_COMMIT, PAGE_EXECUTE_READWRITE);
+ c->chrMmx2FilterCode = VirtualAlloc(NULL, c->chrMmx2FilterCodeSize, MEM_COMMIT, PAGE_EXECUTE_READWRITE);
#else
- c->lumMmx2FilterCode = av_malloc(MAX_MMX2_FILTER_CODE_SIZE);
- c->chrMmx2FilterCode = av_malloc(MAX_MMX2_FILTER_CODE_SIZE);
+ c->lumMmx2FilterCode = av_malloc(c->lumMmx2FilterCodeSize);
+ c->chrMmx2FilterCode = av_malloc(c->chrMmx2FilterCodeSize);
#endif
c->lumMmx2Filter = av_malloc((dstW /8+8)*sizeof(int16_t));
@@ -2833,8 +2841,8 @@ SwsContext *sws_getContext(int srcW, int srcH, enum PixelFormat srcFormat, int d
initMMX2HScaler(c->chrDstW, c->chrXInc, c->chrMmx2FilterCode, c->chrMmx2Filter, c->chrMmx2FilterPos, 4);
#ifdef MAP_ANONYMOUS
- mprotect(c->lumMmx2FilterCode, MAX_MMX2_FILTER_CODE_SIZE, PROT_EXEC | PROT_READ);
- mprotect(c->chrMmx2FilterCode, MAX_MMX2_FILTER_CODE_SIZE, PROT_EXEC | PROT_READ);
+ mprotect(c->lumMmx2FilterCode, c->lumMmx2FilterCodeSize, PROT_EXEC | PROT_READ);
+ mprotect(c->chrMmx2FilterCode, c->chrMmx2FilterCodeSize, PROT_EXEC | PROT_READ);
#endif
}
#endif /* defined(COMPILE_MMX2) */
@@ -3504,11 +3512,11 @@ void sws_freeContext(SwsContext *c){
#if ARCH_X86 && CONFIG_GPL
#ifdef MAP_ANONYMOUS
- if (c->lumMmx2FilterCode) munmap(c->lumMmx2FilterCode, MAX_MMX2_FILTER_CODE_SIZE);
- if (c->chrMmx2FilterCode) munmap(c->chrMmx2FilterCode, MAX_MMX2_FILTER_CODE_SIZE);
+ if (c->lumMmx2FilterCode) munmap(c->lumMmx2FilterCode, c->lumMmx2FilterCodeSize);
+ if (c->chrMmx2FilterCode) munmap(c->chrMmx2FilterCode, c->chrMmx2FilterCodeSize);
#elif HAVE_VIRTUALALLOC
- if (c->lumMmx2FilterCode) VirtualFree(c->lumMmx2FilterCode, MAX_MMX2_FILTER_CODE_SIZE, MEM_RELEASE);
- if (c->chrMmx2FilterCode) VirtualFree(c->chrMmx2FilterCode, MAX_MMX2_FILTER_CODE_SIZE, MEM_RELEASE);
+ if (c->lumMmx2FilterCode) VirtualFree(c->lumMmx2FilterCode, c->lumMmx2FilterCodeSize, MEM_RELEASE);
+ if (c->chrMmx2FilterCode) VirtualFree(c->chrMmx2FilterCode, c->chrMmx2FilterCodeSize, MEM_RELEASE);
#else
av_free(c->lumMmx2FilterCode);
av_free(c->chrMmx2FilterCode);
diff --git a/libswscale/swscale_internal.h b/libswscale/swscale_internal.h
index 4813894bcb..9063a20fba 100644
--- a/libswscale/swscale_internal.h
+++ b/libswscale/swscale_internal.h
@@ -111,6 +111,8 @@ typedef struct SwsContext{
int vLumBufSize;
int vChrBufSize;
+ int lumMmx2FilterCodeSize;
+ int chrMmx2FilterCodeSize;
uint8_t *lumMmx2FilterCode;
uint8_t *chrMmx2FilterCode;
int32_t *lumMmx2FilterPos;