[vlc-devel] [PATCH 3/3] deinterlace: x86: update yadif asm to libav's external asm
Thomas Guillem
thomas at gllm.fr
Thu Oct 27 09:56:51 CEST 2016
Hello,
This break android arm and windows win32 build:
android arm build error:
../../modules/video_filter/deinterlace/algo_yadif.c:113:13: error:
implicit declaration of function 'vlc_CPU_SSSE3' is
invalid in C99 [-Werror,-Wimplicit-function-declaration]
if( vlc_CPU_SSSE3() )
^
../../modules/video_filter/deinterlace/algo_yadif.c:116:22: error: use
of undeclared identifier
'vlcpriv_yadif_filter_line_ssse3'
filter = vlcpriv_yadif_filter_line_ssse3;
^
../doltlibtool --mode=compile --tag=ASM
/home/tom/work/git/vlc-android/toolchains/arm/bin/yasm
-I../../extras/include
../../modules/video_filter/deinterlace/yadif_x86.asm -o
video_filter/deinterlace/yadif_x86.lo
../../modules/video_filter/deinterlace/algo_yadif.c:119:13: error:
implicit declaration of function 'vlc_CPU_SSE2' is
invalid in C99 [-Werror,-Wimplicit-function-declaration]
if( vlc_CPU_SSE2() )
^
../../modules/video_filter/deinterlace/algo_yadif.c:119:13: note: did
you mean 'vlc_CPU_SSSE3'?
../../modules/video_filter/deinterlace/algo_yadif.c:113:13: note:
'vlc_CPU_SSSE3' declared here
if( vlc_CPU_SSSE3() )
^
../../modules/video_filter/deinterlace/algo_yadif.c:120:22: error: use
of undeclared identifier
'vlcpriv_yadif_filter_line_sse2'
filter = vlcpriv_yadif_filter_line_sse2;
^
win32 build error:
video_filter/deinterlace/.libs/libdeinterlace_plugin_la-algo_yadif.o: In
function `RenderYadif':
/home/tom/work/git/vlc/build-win32/modules/../../extras/package/win32/../../../modules/video_filter/deinterlace/algo_yadif.c:120:
undefined reference to `vlcpriv_yadif_filter_line_sse2'
/home/tom/work/git/vlc/build-win32/modules/../../extras/package/win32/../../../modules/video_filter/deinterlace/algo_yadif.c:116:
undefined reference to `vlcpriv_yadif_filter_line_ssse3'
/home/tom/work/git/vlc/build-win32/modules/../../extras/package/win32/../../../modules/video_filter/deinterlace/algo_yadif.c:179:
undefined reference to `vlcpriv_yadif_filter_line_mmxext'
/home/tom/work/git/vlc/build-win32/modules/../../extras/package/win32/../../../modules/video_filter/deinterlace/algo_yadif.c:124:
undefined reference to `vlcpriv_yadif_filter_line_mmxext'
/home/tom/work/git/vlc/build-win32/modules/../../extras/package/win32/../../../modules/video_filter/deinterlace/algo_yadif.c:180:
undefined reference to `vlcpriv_emms_ext_asm'
On Thu, Oct 20, 2016, at 00:53, Janne Grunau wrote:
> ---
> modules/video_filter/Makefile.am | 3 +-
> modules/video_filter/deinterlace/algo_yadif.c | 22 +-
> modules/video_filter/deinterlace/yadif.h | 68 +-----
> modules/video_filter/deinterlace/yadif_template.h | 282
> ----------------------
> modules/video_filter/deinterlace/yadif_x86.asm | 254
> +++++++++++++++++++
> 5 files changed, 277 insertions(+), 352 deletions(-)
> delete mode 100644 modules/video_filter/deinterlace/yadif_template.h
> create mode 100644 modules/video_filter/deinterlace/yadif_x86.asm
>
> diff --git a/modules/video_filter/Makefile.am
> b/modules/video_filter/Makefile.am
> index 92c5bc3..506c5ec9 100644
> --- a/modules/video_filter/Makefile.am
> +++ b/modules/video_filter/Makefile.am
> @@ -115,7 +115,7 @@ libdeinterlace_plugin_la_SOURCES = \
> video_filter/deinterlace/algo_basic.c video_filter/deinterlace/algo_basic.h \
> video_filter/deinterlace/algo_x.c video_filter/deinterlace/algo_x.h \
> video_filter/deinterlace/algo_yadif.c video_filter/deinterlace/algo_yadif.h \
> - video_filter/deinterlace/yadif.h
> video_filter/deinterlace/yadif_template.h \
> + video_filter/deinterlace/yadif.h \
> video_filter/deinterlace/algo_phosphor.c video_filter/deinterlace/algo_phosphor.h \
> video_filter/deinterlace/algo_ivtc.c video_filter/deinterlace/algo_ivtc.h
> # inline ASM doesn't build with -O0
> @@ -123,6 +123,7 @@ libdeinterlace_plugin_la_CFLAGS = $(AM_CFLAGS) -O2
> if HAVE_YASM
> libdeinterlace_plugin_la_CFLAGS += -DHAVE_YASM
> libdeinterlace_plugin_la_SOURCES +=
> video_filter/deinterlace/deinterlace_x86.asm
> +libdeinterlace_plugin_la_SOURCES +=
> video_filter/deinterlace/yadif_x86.asm
> endif
> if HAVE_NEON
> libdeinterlace_plugin_la_SOURCES += video_filter/deinterlace/merge_arm.S
> diff --git a/modules/video_filter/deinterlace/algo_yadif.c
> b/modules/video_filter/deinterlace/algo_yadif.c
> index da3470d..8b5be3f 100644
> --- a/modules/video_filter/deinterlace/algo_yadif.c
> +++ b/modules/video_filter/deinterlace/algo_yadif.c
> @@ -108,21 +108,19 @@ int RenderYadif( filter_t *p_filter, picture_t
> *p_dst, picture_t *p_src,
> void (*filter)(uint8_t *dst, uint8_t *prev, uint8_t *cur,
> uint8_t *next,
> int w, int prefs, int mrefs, int parity, int
> mode);
>
> -#if defined(HAVE_YADIF_SSSE3)
> +#if defined(HAVE_YASM)
> if( vlc_CPU_SSSE3() )
> - filter = yadif_filter_line_ssse3;
> + filter = vlcpriv_yadif_filter_line_ssse3;
> else
> -#endif
> -#if defined(HAVE_YADIF_SSE2)
> if( vlc_CPU_SSE2() )
> - filter = yadif_filter_line_sse2;
> + filter = vlcpriv_yadif_filter_line_sse2;
> else
> -#endif
> -#if defined(HAVE_YADIF_MMX)
> - if( vlc_CPU_MMX() )
> - filter = yadif_filter_line_mmx;
> +#if defined(__i386__)
> + if( vlc_CPU_MMXEXT() )
> + filter = vlcpriv_yadif_filter_line_mmxext;
> else
> #endif
> +#endif
> filter = yadif_filter_line_c;
>
> if( p_sys->chroma->pixel_size == 2 )
> @@ -172,6 +170,12 @@ int RenderYadif( filter_t *p_filter, picture_t
> *p_dst, picture_t *p_src,
> }
> }
>
> +
> +#if defined(HAVE_YASM) && defined(__i386__)
> + if( filter == vlcpriv_yadif_filter_line_mmxext )
> + vlcpriv_emms_ext_asm();
> +#endif
> +
> p_sys->i_frame_offset = 1; /* p_cur will be rendered at next
> frame, too */
>
> return VLC_SUCCESS;
> diff --git a/modules/video_filter/deinterlace/yadif.h
> b/modules/video_filter/deinterlace/yadif.h
> index 05e5492..3763477 100644
> --- a/modules/video_filter/deinterlace/yadif.h
> +++ b/modules/video_filter/deinterlace/yadif.h
> @@ -22,66 +22,6 @@
> # include "config.h"
> #endif
>
> -#if defined(__GNUC__)
> -# define DECLARE_ALIGNED(n,t,v) t __attribute__ ((aligned (n))) v
> -# if VLC_GCC_VERSION(3,1)
> -# define DECLARE_ASM_CONST(n,t,v) static const t
> __attribute__((used)) __attribute__ ((aligned (n))) v
> -# else
> -# define DECLARE_ASM_CONST(n,t,v) static const t __attribute__
> ((aligned (n))) v
> -# endif
> -#elif defined(_MSC_VER)
> -# define DECLARE_ASM_CONST(n,t,v) __declspec(align(n)) static
> const t v
> -#endif
> -
> -typedef intptr_t x86_reg;
> -typedef struct { uint64_t a, b; } xmm_reg;
> -
> -DECLARE_ASM_CONST(16, xmm_reg, pb_1) = {0x0101010101010101ULL,
> 0x0101010101010101ULL};
> -DECLARE_ASM_CONST(16, xmm_reg, pw_1) = {0x0001000100010001ULL,
> 0x0001000100010001ULL};
> -
> -
> -#ifdef CAN_COMPILE_SSSE3
> -#if defined(__SSE__) || VLC_GCC_VERSION(4, 4) || defined(__clang__)
> -// ================ SSSE3 =================
> -#define HAVE_YADIF_SSSE3
> -#define COMPILE_TEMPLATE_SSE 1
> -#define COMPILE_TEMPLATE_SSSE3 1
> -#define VLC_TARGET VLC_SSE
> -#define RENAME(a) a ## _ssse3
> -#include "yadif_template.h"
> -#undef COMPILE_TEMPLATE_SSE
> -#undef COMPILE_TEMPLATE_SSSE3
> -#undef VLC_TARGET
> -#undef RENAME
> -#endif
> -#endif
> -
> -#ifdef CAN_COMPILE_SSE2
> -#if defined(__SSE__) || VLC_GCC_VERSION(4, 4) || defined(__clang__)
> -// ================= SSE2 =================
> -#define HAVE_YADIF_SSE2
> -#define COMPILE_TEMPLATE_SSE 1
> -#define VLC_TARGET VLC_SSE
> -#define RENAME(a) a ## _sse2
> -#include "yadif_template.h"
> -#undef COMPILE_TEMPLATE_SSE
> -#undef VLC_TARGET
> -#undef RENAME
> -#endif
> -#endif
> -
> -#ifdef CAN_COMPILE_MMX
> -#if defined(__MMX__) || VLC_GCC_VERSION(4, 4) || defined(__clang__)
> -// ================ MMX =================
> -#define HAVE_YADIF_MMX
> -#define VLC_TARGET VLC_MMX
> -#define RENAME(a) a ## _mmx
> -#include "yadif_template.h"
> -#undef VLC_TARGET
> -#undef RENAME
> -#endif
> -#endif
> -
> #define FFABS abs
>
> #define CHECK(j)\
> @@ -147,3 +87,11 @@ static void yadif_filter_line_c_16bit(uint16_t *dst,
> uint16_t *prev, uint16_t *c
> prefs /= 2;
> FILTER
> }
> +
> +#if defined(__i386__) || defined(__x86_64__)
> +void vlcpriv_yadif_filter_line_ssse3(uint8_t *dst, uint8_t *prev,
> uint8_t *cur, uint8_t *next, int w, int prefs, int mrefs, int parity, int
> mode);
> +void vlcpriv_yadif_filter_line_sse2(uint8_t *dst, uint8_t *prev, uint8_t
> *cur, uint8_t *next, int w, int prefs, int mrefs, int parity, int mode);
> +#endif
> +#if defined(__i386__)
> +void vlcpriv_yadif_filter_line_mmxext(uint8_t *dst, uint8_t *prev,
> uint8_t *cur, uint8_t *next, int w, int prefs, int mrefs, int parity, int
> mode);
> +#endif
> diff --git a/modules/video_filter/deinterlace/yadif_template.h
> b/modules/video_filter/deinterlace/yadif_template.h
> deleted file mode 100644
> index df4897d..0000000
> --- a/modules/video_filter/deinterlace/yadif_template.h
> +++ /dev/null
> @@ -1,282 +0,0 @@
> -/*
> - * Copyright (C) 2006 Michael Niedermayer <michaelni at gmx.at>
> - *
> - * This file is part of FFmpeg.
> - *
> - * FFmpeg is free software; you can redistribute it and/or modify
> - * it under the terms of the GNU General Public License as published by
> - * the Free Software Foundation; either version 2 of the License, or
> - * (at your option) any later version.
> - *
> - * FFmpeg is distributed in the hope that it will be useful,
> - * but WITHOUT ANY WARRANTY; without even the implied warranty of
> - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
> - * GNU General Public License for more details.
> - *
> - * You should have received a copy of the GNU General Public License
> along
> - * with FFmpeg; if not, write to the Free Software Foundation, Inc.,
> - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
> - */
> -
> -/* For some reason clang doens't like that %%rip macro */
> -
> -#if defined(__x86_64__) && !defined(__APPLE__)
> -#define MANGLE(a) "" #a "(%%rip)"
> -#define MANGLEVARIABLES [mode] "g"(mode),
> -#else
> -#define MANGLE(a) "" "%["#a"]"
> -#define MANGLEVARIABLES [pw_1] "m"(pw_1),\
> - [pb_1] "m"(pb_1),\
> - [mode] "g"(mode),
> -#endif
> -
> -#ifdef COMPILE_TEMPLATE_SSE
> -#define REGMM "xmm"
> -#define MM "%%"REGMM
> -#define MOV "movq"
> -#define MOVQ "movdqa"
> -#define MOVQU "movdqu"
> -#define STEP 8
> -#define LOAD(mem,dst) \
> - MOV" "mem", "dst" \n\t"\
> - "punpcklbw "MM"7, "dst" \n\t"
> -#define PSRL1(reg) "psrldq $1, "reg" \n\t"
> -#define PSRL2(reg) "psrldq $2, "reg" \n\t"
> -#define PSHUF(src,dst) "movdqa "dst", "src" \n\t"\
> - "psrldq $2, "src" \n\t"
> -#else
> -#define REGMM "mm"
> -#define MM "%%"REGMM
> -#define MOV "movd"
> -#define MOVQ "movq"
> -#define MOVQU "movq"
> -#define STEP 4
> -#define LOAD(mem,dst) \
> - MOV" "mem", "dst" \n\t"\
> - "punpcklbw "MM"7, "dst" \n\t"
> -#define PSRL1(reg) "psrlq $8, "reg" \n\t"
> -#define PSRL2(reg) "psrlq $16, "reg" \n\t"
> -#define PSHUF(src,dst) "pshufw $9, "dst", "src" \n\t"
> -#endif
> -
> -#ifdef COMPILE_TEMPLATE_SSSE3
> -#define PABS(tmp,dst) \
> - "pabsw "dst", "dst" \n\t"
> -#else
> -#define PABS(tmp,dst) \
> - "pxor "tmp", "tmp" \n\t"\
> - "psubw "dst", "tmp" \n\t"\
> - "pmaxsw "tmp", "dst" \n\t"
> -#endif
> -
> -
> -#define CHECK(pj,mj) \
> - MOVQU" "#pj"(%[cur],%[mrefs]), "MM"2 \n\t" /*
> cur[x-refs-1+j] */\
> - MOVQU" "#mj"(%[cur],%[prefs]), "MM"3 \n\t" /*
> cur[x+refs-1-j] */\
> - MOVQ" "MM"2, "MM"4 \n\t"\
> - MOVQ" "MM"2, "MM"5 \n\t"\
> - "pxor "MM"3, "MM"4 \n\t"\
> - "pavgb "MM"3, "MM"5 \n\t"\
> - "pand "MANGLE(pb_1)", "MM"4 \n\t"\
> - "psubusb "MM"4, "MM"5 \n\t"\
> - PSRL1(MM"5") \
> - "punpcklbw "MM"7, "MM"5 \n\t" /* (cur[x-refs+j] +
> cur[x+refs-j])>>1 */\
> - MOVQ" "MM"2, "MM"4 \n\t"\
> - "psubusb "MM"3, "MM"2 \n\t"\
> - "psubusb "MM"4, "MM"3 \n\t"\
> - "pmaxub "MM"3, "MM"2 \n\t"\
> - MOVQ" "MM"2, "MM"3 \n\t"\
> - MOVQ" "MM"2, "MM"4 \n\t" /* ABS(cur[x-refs-1+j] -
> cur[x+refs-1-j]) */\
> - PSRL1(MM"3") /* ABS(cur[x-refs +j] -
> cur[x+refs -j]) */\
> - PSRL2(MM"4") /* ABS(cur[x-refs+1+j] -
> cur[x+refs+1-j]) */\
> - "punpcklbw "MM"7, "MM"2 \n\t"\
> - "punpcklbw "MM"7, "MM"3 \n\t"\
> - "punpcklbw "MM"7, "MM"4 \n\t"\
> - "paddw "MM"3, "MM"2 \n\t"\
> - "paddw "MM"4, "MM"2 \n\t" /* score */
> -
> -#define CHECK1 \
> - MOVQ" "MM"0, "MM"3 \n\t"\
> - "pcmpgtw "MM"2, "MM"3 \n\t" /* if(score < spatial_score)
> */\
> - "pminsw "MM"2, "MM"0 \n\t" /* spatial_score= score; */\
> - MOVQ" "MM"3, "MM"6 \n\t"\
> - "pand "MM"3, "MM"5 \n\t"\
> - "pandn "MM"1, "MM"3 \n\t"\
> - "por "MM"5, "MM"3 \n\t"\
> - MOVQ" "MM"3, "MM"1 \n\t" /* spatial_pred=
> (cur[x-refs+j] + cur[x+refs-j])>>1; */
> -
> -#define CHECK2 /* pretend not to have checked dir=2 if dir=1 was bad.\
> - hurts both quality and speed, but matches the C
> version. */\
> - "paddw "MANGLE(pw_1)", "MM"6 \n\t"\
> - "psllw $14, "MM"6 \n\t"\
> - "paddsw "MM"6, "MM"2 \n\t"\
> - MOVQ" "MM"0, "MM"3 \n\t"\
> - "pcmpgtw "MM"2, "MM"3 \n\t"\
> - "pminsw "MM"2, "MM"0 \n\t"\
> - "pand "MM"3, "MM"5 \n\t"\
> - "pandn "MM"1, "MM"3 \n\t"\
> - "por "MM"5, "MM"3 \n\t"\
> - MOVQ" "MM"3, "MM"1 \n\t"
> -
> -#if defined(__MINGW32__) && defined(_WIN32) && !defined(_WIN64)
> -__attribute__((__force_align_arg_pointer__))
> -#endif
> -VLC_TARGET static void RENAME(yadif_filter_line)(uint8_t *dst,
> - uint8_t *prev, uint8_t *cur, uint8_t
> *next,
> - int w, int prefs, int mrefs, int parity,
> int mode)
> -{
> - uint8_t tmpU[5*16];
> - uint8_t *tmp= (uint8_t*)(((uintptr_t)(tmpU+15)) & ~15);
> - int x;
> -
> -#define FILTER\
> - for(x=0; x<w; x+=STEP){\
> - __asm__ volatile(\
> - "pxor "MM"7, "MM"7 \n\t"\
> - LOAD("(%[cur],%[mrefs])", MM"0") /* c = cur[x-refs] */\
> - LOAD("(%[cur],%[prefs])", MM"1") /* e = cur[x+refs] */\
> - LOAD("(%["prev2"])", MM"2") /* prev2[x] */\
> - LOAD("(%["next2"])", MM"3") /* next2[x] */\
> - MOVQ" "MM"3, "MM"4 \n\t"\
> - "paddw "MM"2, "MM"3 \n\t"\
> - "psraw $1, "MM"3 \n\t" /* d = (prev2[x] +
> next2[x])>>1 */\
> - MOVQ" "MM"0, (%[tmp]) \n\t" /* c */\
> - MOVQ" "MM"3, 16(%[tmp]) \n\t" /* d */\
> - MOVQ" "MM"1, 32(%[tmp]) \n\t" /* e */\
> - "psubw "MM"4, "MM"2 \n\t"\
> - PABS( MM"4", MM"2") /* temporal_diff0 */\
> - LOAD("(%[prev],%[mrefs])", MM"3") /* prev[x-refs] */\
> - LOAD("(%[prev],%[prefs])", MM"4") /* prev[x+refs] */\
> - "psubw "MM"0, "MM"3 \n\t"\
> - "psubw "MM"1, "MM"4 \n\t"\
> - PABS( MM"5", MM"3")\
> - PABS( MM"5", MM"4")\
> - "paddw "MM"4, "MM"3 \n\t" /* temporal_diff1 */\
> - "psrlw $1, "MM"2 \n\t"\
> - "psrlw $1, "MM"3 \n\t"\
> - "pmaxsw "MM"3, "MM"2 \n\t"\
> - LOAD("(%[next],%[mrefs])", MM"3") /* next[x-refs] */\
> - LOAD("(%[next],%[prefs])", MM"4") /* next[x+refs] */\
> - "psubw "MM"0, "MM"3 \n\t"\
> - "psubw "MM"1, "MM"4 \n\t"\
> - PABS( MM"5", MM"3")\
> - PABS( MM"5", MM"4")\
> - "paddw "MM"4, "MM"3 \n\t" /* temporal_diff2 */\
> - "psrlw $1, "MM"3 \n\t"\
> - "pmaxsw "MM"3, "MM"2 \n\t"\
> - MOVQ" "MM"2, 48(%[tmp]) \n\t" /* diff */\
> -\
> - "paddw "MM"0, "MM"1 \n\t"\
> - "paddw "MM"0, "MM"0 \n\t"\
> - "psubw "MM"1, "MM"0 \n\t"\
> - "psrlw $1, "MM"1 \n\t" /* spatial_pred */\
> - PABS( MM"2", MM"0") /* ABS(c-e) */\
> -\
> - MOVQU" -1(%[cur],%[mrefs]), "MM"2 \n\t" /* cur[x-refs-1] */\
> - MOVQU" -1(%[cur],%[prefs]), "MM"3 \n\t" /* cur[x+refs-1] */\
> - MOVQ" "MM"2, "MM"4 \n\t"\
> - "psubusb "MM"3, "MM"2 \n\t"\
> - "psubusb "MM"4, "MM"3 \n\t"\
> - "pmaxub "MM"3, "MM"2 \n\t"\
> - PSHUF(MM"3", MM"2") \
> - "punpcklbw "MM"7, "MM"2 \n\t" /* ABS(cur[x-refs-1] -
> cur[x+refs-1]) */\
> - "punpcklbw "MM"7, "MM"3 \n\t" /* ABS(cur[x-refs+1] -
> cur[x+refs+1]) */\
> - "paddw "MM"2, "MM"0 \n\t"\
> - "paddw "MM"3, "MM"0 \n\t"\
> - "psubw "MANGLE(pw_1)", "MM"0 \n\t" /* spatial_score */\
> -\
> - CHECK(-2,0)\
> - CHECK1\
> - CHECK(-3,1)\
> - CHECK2\
> - CHECK(0,-2)\
> - CHECK1\
> - CHECK(1,-3)\
> - CHECK2\
> -\
> - /* if(p->mode<2) ... */\
> - MOVQ" 48(%[tmp]), "MM"6 \n\t" /* diff */\
> - "cmpl $2, %[mode] \n\t"\
> - "jge 1f \n\t"\
> - LOAD("(%["prev2"],%[mrefs],2)", MM"2") /* prev2[x-2*refs]
> */\
> - LOAD("(%["next2"],%[mrefs],2)", MM"4") /* next2[x-2*refs]
> */\
> - LOAD("(%["prev2"],%[prefs],2)", MM"3") /* prev2[x+2*refs]
> */\
> - LOAD("(%["next2"],%[prefs],2)", MM"5") /* next2[x+2*refs]
> */\
> - "paddw "MM"4, "MM"2 \n\t"\
> - "paddw "MM"5, "MM"3 \n\t"\
> - "psrlw $1, "MM"2 \n\t" /* b */\
> - "psrlw $1, "MM"3 \n\t" /* f */\
> - MOVQ" (%[tmp]), "MM"4 \n\t" /* c */\
> - MOVQ" 16(%[tmp]), "MM"5 \n\t" /* d */\
> - MOVQ" 32(%[tmp]), "MM"7 \n\t" /* e */\
> - "psubw "MM"4, "MM"2 \n\t" /* b-c */\
> - "psubw "MM"7, "MM"3 \n\t" /* f-e */\
> - MOVQ" "MM"5, "MM"0 \n\t"\
> - "psubw "MM"4, "MM"5 \n\t" /* d-c */\
> - "psubw "MM"7, "MM"0 \n\t" /* d-e */\
> - MOVQ" "MM"2, "MM"4 \n\t"\
> - "pminsw "MM"3, "MM"2 \n\t"\
> - "pmaxsw "MM"4, "MM"3 \n\t"\
> - "pmaxsw "MM"5, "MM"2 \n\t"\
> - "pminsw "MM"5, "MM"3 \n\t"\
> - "pmaxsw "MM"0, "MM"2 \n\t" /* max */\
> - "pminsw "MM"0, "MM"3 \n\t" /* min */\
> - "pxor "MM"4, "MM"4 \n\t"\
> - "pmaxsw "MM"3, "MM"6 \n\t"\
> - "psubw "MM"2, "MM"4 \n\t" /* -max */\
> - "pmaxsw "MM"4, "MM"6 \n\t" /* diff= MAX3(diff, min,
> -max); */\
> - "1: \n\t"\
> -\
> - MOVQ" 16(%[tmp]), "MM"2 \n\t" /* d */\
> - MOVQ" "MM"2, "MM"3 \n\t"\
> - "psubw "MM"6, "MM"2 \n\t" /* d-diff */\
> - "paddw "MM"6, "MM"3 \n\t" /* d+diff */\
> - "pmaxsw "MM"2, "MM"1 \n\t"\
> - "pminsw "MM"3, "MM"1 \n\t" /* d = clip(spatial_pred,
> d-diff, d+diff); */\
> - "packuswb "MM"1, "MM"1 \n\t"\
> -\
> - ::[prev] "r"(prev),\
> - [cur] "r"(cur),\
> - [next] "r"(next),\
> - [prefs]"r"((x86_reg)prefs),\
> - [mrefs]"r"((x86_reg)mrefs),\
> - MANGLEVARIABLES\
> - [tmp] "r"(tmp)\
> - );\
> - __asm__ volatile(MOV" "MM"1, %0" :"=m"(*dst));\
> - dst += STEP;\
> - prev+= STEP;\
> - cur += STEP;\
> - next+= STEP;\
> - }
> -
> - if (parity) {
> -#define prev2 "prev"
> -#define next2 "cur"
> - FILTER
> -#undef prev2
> -#undef next2
> - } else {
> -#define prev2 "cur"
> -#define next2 "next"
> - FILTER
> -#undef prev2
> -#undef next2
> - }
> -}
> -#undef STEP
> -#undef REGMM
> -#undef MM
> -#undef MOV
> -#undef MOVQ
> -#undef MOVQU
> -#undef PSHUF
> -#undef PSRL1
> -#undef PSRL2
> -#undef LOAD
> -#undef PABS
> -#undef CHECK
> -#undef CHECK1
> -#undef CHECK2
> -#undef FILTER
> -
> diff --git a/modules/video_filter/deinterlace/yadif_x86.asm
> b/modules/video_filter/deinterlace/yadif_x86.asm
> new file mode 100644
> index 0000000..2e97fa2
> --- /dev/null
> +++ b/modules/video_filter/deinterlace/yadif_x86.asm
> @@ -0,0 +1,254 @@
> +;*****************************************************************************
> +;* x86-optimized functions for yadif filter
> +;*
> +;* Copyright (C) 2006 Michael Niedermayer <michaelni at gmx.at>
> +;* Copyright (c) 2013 Daniel Kang <daniel.d.kang at gmail.com>
> +;*
> +;* This file is part of Libav.
> +;*
> +;* Libav is free software; you can redistribute it and/or
> +;* modify it under the terms of the GNU Lesser General Public
> +;* License as published by the Free Software Foundation; either
> +;* version 2.1 of the License, or (at your option) any later version.
> +;*
> +;* Libav is distributed in the hope that it will be useful,
> +;* but WITHOUT ANY WARRANTY; without even the implied warranty of
> +;* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
> +;* Lesser General Public License for more details.
> +;*
> +;* You should have received a copy of the GNU Lesser General Public
> +;* License along with Libav; if not, write to the Free Software
> +;* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
> 02110-1301 USA
> +;******************************************************************************
> +
> +%include "x86util.asm"
> +
> +SECTION_RODATA
> +
> +pb_1: times 16 db 1
> +pw_1: times 8 dw 1
> +
> +SECTION .text
> +
> +%macro CHECK 2
> + movu m2, [curq+t1+%1]
> + movu m3, [curq+t0+%2]
> + mova m4, m2
> + mova m5, m2
> + pxor m4, m3
> + pavgb m5, m3
> + pand m4, [pb_1]
> + psubusb m5, m4
> +%if mmsize == 16
> + psrldq m5, 1
> +%else
> + psrlq m5, 8
> +%endif
> + punpcklbw m5, m7
> + mova m4, m2
> + psubusb m2, m3
> + psubusb m3, m4
> + pmaxub m2, m3
> + mova m3, m2
> + mova m4, m2
> +%if mmsize == 16
> + psrldq m3, 1
> + psrldq m4, 2
> +%else
> + psrlq m3, 8
> + psrlq m4, 16
> +%endif
> + punpcklbw m2, m7
> + punpcklbw m3, m7
> + punpcklbw m4, m7
> + paddw m2, m3
> + paddw m2, m4
> +%endmacro
> +
> +%macro CHECK1 0
> + mova m3, m0
> + pcmpgtw m3, m2
> + pminsw m0, m2
> + mova m6, m3
> + pand m5, m3
> + pandn m3, m1
> + por m3, m5
> + mova m1, m3
> +%endmacro
> +
> +%macro CHECK2 0
> + paddw m6, [pw_1]
> + psllw m6, 14
> + paddsw m2, m6
> + mova m3, m0
> + pcmpgtw m3, m2
> + pminsw m0, m2
> + pand m5, m3
> + pandn m3, m1
> + por m3, m5
> + mova m1, m3
> +%endmacro
> +
> +%macro LOAD 2
> + movh m%1, %2
> + punpcklbw m%1, m7
> +%endmacro
> +
> +%macro FILTER 3
> +.loop%1:
> + pxor m7, m7
> + LOAD 0, [curq+t1]
> + LOAD 1, [curq+t0]
> + LOAD 2, [%2]
> + LOAD 3, [%3]
> + mova m4, m3
> + paddw m3, m2
> + psraw m3, 1
> + mova [rsp+ 0], m0
> + mova [rsp+16], m3
> + mova [rsp+32], m1
> + psubw m2, m4
> + ABS1 m2, m4
> + LOAD 3, [prevq+t1]
> + LOAD 4, [prevq+t0]
> + psubw m3, m0
> + psubw m4, m1
> + ABS1 m3, m5
> + ABS1 m4, m5
> + paddw m3, m4
> + psrlw m2, 1
> + psrlw m3, 1
> + pmaxsw m2, m3
> + LOAD 3, [nextq+t1]
> + LOAD 4, [nextq+t0]
> + psubw m3, m0
> + psubw m4, m1
> + ABS1 m3, m5
> + ABS1 m4, m5
> + paddw m3, m4
> + psrlw m3, 1
> + pmaxsw m2, m3
> + mova [rsp+48], m2
> +
> + paddw m1, m0
> + paddw m0, m0
> + psubw m0, m1
> + psrlw m1, 1
> + ABS1 m0, m2
> +
> + movu m2, [curq+t1-1]
> + movu m3, [curq+t0-1]
> + mova m4, m2
> + psubusb m2, m3
> + psubusb m3, m4
> + pmaxub m2, m3
> +%if mmsize == 16
> + mova m3, m2
> + psrldq m3, 2
> +%else
> + pshufw m3, m2, q0021
> +%endif
> + punpcklbw m2, m7
> + punpcklbw m3, m7
> + paddw m0, m2
> + paddw m0, m3
> + psubw m0, [pw_1]
> +
> + CHECK -2, 0
> + CHECK1
> + CHECK -3, 1
> + CHECK2
> + CHECK 0, -2
> + CHECK1
> + CHECK 1, -3
> + CHECK2
> +
> + mova m6, [rsp+48]
> + cmp DWORD r8m, 2
> + jge .end%1
> + LOAD 2, [%2+t1*2]
> + LOAD 4, [%3+t1*2]
> + LOAD 3, [%2+t0*2]
> + LOAD 5, [%3+t0*2]
> + paddw m2, m4
> + paddw m3, m5
> + psrlw m2, 1
> + psrlw m3, 1
> + mova m4, [rsp+ 0]
> + mova m5, [rsp+16]
> + mova m7, [rsp+32]
> + psubw m2, m4
> + psubw m3, m7
> + mova m0, m5
> + psubw m5, m4
> + psubw m0, m7
> + mova m4, m2
> + pminsw m2, m3
> + pmaxsw m3, m4
> + pmaxsw m2, m5
> + pminsw m3, m5
> + pmaxsw m2, m0
> + pminsw m3, m0
> + pxor m4, m4
> + pmaxsw m6, m3
> + psubw m4, m2
> + pmaxsw m6, m4
> +
> +.end%1:
> + mova m2, [rsp+16]
> + mova m3, m2
> + psubw m2, m6
> + paddw m3, m6
> + pmaxsw m1, m2
> + pminsw m1, m3
> + packuswb m1, m1
> +
> + movh [dstq], m1
> + add dstq, mmsize/2
> + add prevq, mmsize/2
> + add curq, mmsize/2
> + add nextq, mmsize/2
> + sub DWORD r4m, mmsize/2
> + jg .loop%1
> +%endmacro
> +
> +%macro YADIF 0
> +%if ARCH_X86_32
> +cglobal yadif_filter_line, 4, 6, 8, 80, dst, prev, cur, next, w, prefs,
> \
> + mrefs, parity, mode
> +%else
> +cglobal yadif_filter_line, 4, 7, 8, 80, dst, prev, cur, next, w, prefs,
> \
> + mrefs, parity, mode
> +%endif
> + cmp DWORD wm, 0
> + jle .ret
> +%if ARCH_X86_32
> + mov r4, r5mp
> + mov r5, r6mp
> + DECLARE_REG_TMP 4,5
> +%else
> + movsxd r5, DWORD r5m
> + movsxd r6, DWORD r6m
> + DECLARE_REG_TMP 5,6
> +%endif
> +
> + cmp DWORD paritym, 0
> + je .parity0
> + FILTER 1, prevq, curq
> + jmp .ret
> +
> +.parity0:
> + FILTER 0, curq, nextq
> +
> +.ret:
> + RET
> +%endmacro
> +
> +INIT_XMM ssse3
> +YADIF
> +INIT_XMM sse2
> +YADIF
> +%if ARCH_X86_32
> +INIT_MMX mmxext
> +YADIF
> +%endif
> --
> 2.10.1
>
> _______________________________________________
> vlc-devel mailing list
> To unsubscribe or modify your subscription options:
> https://mailman.videolan.org/listinfo/vlc-devel
More information about the vlc-devel
mailing list