summaryrefslogtreecommitdiffstats
path: root/video/filter/vf_noise.c
diff options
context:
space:
mode:
authorNatanael Copa <ncopa@alpinelinux.org>2013-11-26 08:46:53 +0000
committerwm4 <wm4@nowhere>2013-11-26 23:43:56 +0100
commitce1a511e221b032acc863d86b8d5b1644af00445 (patch)
treeff184bf8d2d09b7b0bcbcb591dd82664b589550e /video/filter/vf_noise.c
parent7a0299478e169ea076fe57028fda1ef7292a5431 (diff)
downloadmpv-ce1a511e221b032acc863d86b8d5b1644af00445.tar.bz2
mpv-ce1a511e221b032acc863d86b8d5b1644af00445.tar.xz
video/filter: fix PIC compile on x86
When using PIC on x86 (eg with hardened toolchains) the ebx register is reserverd and cannot be used in assembly code. For vf_eq we allow the compiler to use memory as input. For vf_noise we temoporarily borrow the ebp register. This fixes #361. Signed-off-by: Natanael Copa <ncopa@alpinelinux.org>
Diffstat (limited to 'video/filter/vf_noise.c')
-rw-r--r--video/filter/vf_noise.c9
1 files changed, 7 insertions, 2 deletions
diff --git a/video/filter/vf_noise.c b/video/filter/vf_noise.c
index c81a1d1338..5e7bf75cd1 100644
--- a/video/filter/vf_noise.c
+++ b/video/filter/vf_noise.c
@@ -216,13 +216,16 @@ static inline void lineNoise_C(uint8_t *dst, uint8_t *src, int8_t *noise, int le
#if HAVE_MMX
static inline void lineNoiseAvg_MMX(uint8_t *dst, uint8_t *src, int len, int8_t **shift){
x86_reg mmx_len= len&(~7);
+ uint8_t *src_mmx_len = src+mmx_len;
__asm__ volatile(
+ "push %%"REG_BP" \n\t"
+ "mov %0, %%"REG_BP" \n\t"
"mov %5, %%"REG_a" \n\t"
".align 4 \n\t"
"1: \n\t"
"movq (%1, %%"REG_a"), %%mm1 \n\t"
- "movq (%0, %%"REG_a"), %%mm0 \n\t"
+ "movq (%%"REG_BP", %%"REG_a"), %%mm0 \n\t"
"paddb (%2, %%"REG_a"), %%mm1 \n\t"
"paddb (%3, %%"REG_a"), %%mm1 \n\t"
"movq %%mm0, %%mm2 \n\t"
@@ -243,7 +246,9 @@ static inline void lineNoiseAvg_MMX(uint8_t *dst, uint8_t *src, int len, int8_t
"movq %%mm1, (%4, %%"REG_a") \n\t"
"add $8, %%"REG_a" \n\t"
" js 1b \n\t"
- :: "r" (src+mmx_len), "r" (shift[0]+mmx_len), "r" (shift[1]+mmx_len), "r" (shift[2]+mmx_len),
+ "pop %%"REG_BP" \n\t"
+ :: "g" (src_mmx_len), "r" (shift[0]+mmx_len),
+ "r" (shift[1]+mmx_len), "r" (shift[2]+mmx_len),
"r" (dst+mmx_len), "g" (-mmx_len)
: "%"REG_a
);