From d55ed011abb0962eafcbe5977a18a0f1b0b61144 Mon Sep 17 00:00:00 2001 From: wm4 Date: Sat, 19 Apr 2014 15:50:52 +0200 Subject: vf_noise: remove line asm I didn't test the speed, but by default, this filter diverts to libavfilter already. So this would help only if libavfilter is disabled, or libavfilter doesn't have vf_noise (like on Libav). For these cases, we still provide the (possibly but not necessarily) slower C implementation of vf_noise. --- video/filter/vf_noise.c | 134 ++---------------------------------------------- 1 file changed, 4 insertions(+), 130 deletions(-) (limited to 'video') diff --git a/video/filter/vf_noise.c b/video/filter/vf_noise.c index bb8fc8b426..178c1c1c8f 100644 --- a/video/filter/vf_noise.c +++ b/video/filter/vf_noise.c @@ -26,7 +26,6 @@ #include "config.h" #include "common/msg.h" -#include "common/cpudetect.h" #include "options/m_option.h" #include "video/img_format.h" @@ -43,11 +42,8 @@ //===========================================================================// -static inline void lineNoise_C(uint8_t *dst, uint8_t *src, int8_t *noise, int len, int shift); -static inline void lineNoiseAvg_C(uint8_t *dst, uint8_t *src, int len, int8_t **shift); - -static void (*lineNoise)(uint8_t *dst, uint8_t *src, int8_t *noise, int len, int shift)= lineNoise_C; -static void (*lineNoiseAvg)(uint8_t *dst, uint8_t *src, int len, int8_t **shift)= lineNoiseAvg_C; +static inline void lineNoise(uint8_t *dst, uint8_t *src, int8_t *noise, int len, int shift); +static inline void lineNoiseAvg(uint8_t *dst, uint8_t *src, int len, int8_t **shift); typedef struct FilterParam{ int strength; @@ -151,64 +147,7 @@ static int8_t *initNoise(FilterParam *fp){ /***************************************************************************/ -#if HAVE_MMX -static inline void lineNoise_MMX(uint8_t *dst, uint8_t *src, int8_t *noise, int len, int shift){ - x86_reg mmx_len= len&(~7); - noise+=shift; - - __asm__ volatile( - "mov %3, %%"REG_a" \n\t" - "pcmpeqb %%mm7, %%mm7 \n\t" - "psllw $15, %%mm7 \n\t" - "packsswb %%mm7, %%mm7 \n\t" - ".align 4 \n\t" - "1: \n\t" - "movq (%0, %%"REG_a"), %%mm0 \n\t" - "movq (%1, %%"REG_a"), %%mm1 \n\t" - "pxor %%mm7, %%mm0 \n\t" - "paddsb %%mm1, %%mm0 \n\t" - "pxor %%mm7, %%mm0 \n\t" - "movq %%mm0, (%2, %%"REG_a") \n\t" - "add $8, %%"REG_a" \n\t" - " js 1b \n\t" - :: "r" (src+mmx_len), "r" (noise+mmx_len), "r" (dst+mmx_len), "g" (-mmx_len) - : "%"REG_a - ); - if(mmx_len!=len) - lineNoise_C(dst+mmx_len, src+mmx_len, noise+mmx_len, len-mmx_len, 0); -} -#endif - -//duplicate of previous except movntq -#if HAVE_MMX2 -static inline void lineNoise_MMX2(uint8_t *dst, uint8_t *src, int8_t *noise, int len, int shift){ - x86_reg mmx_len= len&(~7); - noise+=shift; - - __asm__ volatile( - "mov %3, %%"REG_a" \n\t" - "pcmpeqb %%mm7, %%mm7 \n\t" - "psllw $15, %%mm7 \n\t" - "packsswb %%mm7, %%mm7 \n\t" - ".align 4 \n\t" - "1: \n\t" - "movq (%0, %%"REG_a"), %%mm0 \n\t" - "movq (%1, %%"REG_a"), %%mm1 \n\t" - "pxor %%mm7, %%mm0 \n\t" - "paddsb %%mm1, %%mm0 \n\t" - "pxor %%mm7, %%mm0 \n\t" - "movntq %%mm0, (%2, %%"REG_a") \n\t" - "add $8, %%"REG_a" \n\t" - " js 1b \n\t" - :: "r" (src+mmx_len), "r" (noise+mmx_len), "r" (dst+mmx_len), "g" (-mmx_len) - : "%"REG_a - ); - if(mmx_len!=len) - lineNoise_C(dst+mmx_len, src+mmx_len, noise+mmx_len, len-mmx_len, 0); -} -#endif - -static inline void lineNoise_C(uint8_t *dst, uint8_t *src, int8_t *noise, int len, int shift){ +static inline void lineNoise(uint8_t *dst, uint8_t *src, int8_t *noise, int len, int shift){ int i; noise+= shift; for(i=0; iplanes[1], mpi->planes[1], dmpi->stride[1], mpi->stride[1], mpi->w/2, mpi->h/2, &vf->priv->chromaParam); donoise(dmpi->planes[2], mpi->planes[2], dmpi->stride[2], mpi->stride[2], mpi->w/2, mpi->h/2, &vf->priv->chromaParam); -#if HAVE_MMX - if(gCpuCaps.hasMMX) __asm__ volatile ("emms\n\t"); -#endif -#if HAVE_MMX2 - if(gCpuCaps.hasMMX2) __asm__ volatile ("sfence\n\t"); -#endif - if (dmpi != mpi) talloc_free(mpi); return dmpi; @@ -396,17 +281,6 @@ static int vf_open(vf_instance_t *vf){ parse(&vf->priv->lumaParam, vf->priv); parse(&vf->priv->chromaParam, vf->priv); -#if HAVE_MMX - if(gCpuCaps.hasMMX){ - lineNoise= lineNoise_MMX; - lineNoiseAvg= lineNoiseAvg_MMX; - } -#endif -#if HAVE_MMX2 - if(gCpuCaps.hasMMX2) lineNoise= lineNoise_MMX2; -// if(gCpuCaps.hasMMX) lineNoiseAvg= lineNoiseAvg_MMX2; -#endif - return 1; } -- cgit v1.2.3