diff options
author | Paul B Mahol <onemda@gmail.com> | 2015-10-01 00:00:14 +0300 |
---|---|---|
committer | Paul B Mahol <onemda@gmail.com> | 2015-10-02 18:40:57 +0300 |
commit | 160556c9ad1662bf175f3c62c581834dadd3b52a (patch) | |
tree | 24dc20c298bf5a1af21258522d47d0082c4bd2b5 /libavfilter/x86 | |
parent | abaa12263e08ae7b2099f00fa4597ae6a86d7a9c (diff) |
avfilter/vf_maskedmerge: add SIMD for maskedmerge with 8 bit depth input
Signed-off-by: Paul B Mahol <onemda@gmail.com>
Diffstat (limited to 'libavfilter/x86')
-rw-r--r-- | libavfilter/x86/Makefile | 2 | ||||
-rw-r--r-- | libavfilter/x86/vf_maskedmerge.asm | 73 | ||||
-rw-r--r-- | libavfilter/x86/vf_maskedmerge_init.c | 40 |
3 files changed, 115 insertions, 0 deletions
diff --git a/libavfilter/x86/Makefile b/libavfilter/x86/Makefile index 5382027f70..db072cd433 100644 --- a/libavfilter/x86/Makefile +++ b/libavfilter/x86/Makefile @@ -4,6 +4,7 @@ OBJS-$(CONFIG_GRADFUN_FILTER) += x86/vf_gradfun_init.o OBJS-$(CONFIG_HQDN3D_FILTER) += x86/vf_hqdn3d_init.o OBJS-$(CONFIG_IDET_FILTER) += x86/vf_idet_init.o OBJS-$(CONFIG_INTERLACE_FILTER) += x86/vf_interlace_init.o +OBJS-$(CONFIG_MASKEDMERGE_FILTER) += x86/vf_maskedmerge_init.o OBJS-$(CONFIG_NOISE_FILTER) += x86/vf_noise.o OBJS-$(CONFIG_PP7_FILTER) += x86/vf_pp7_init.o OBJS-$(CONFIG_PSNR_FILTER) += x86/vf_psnr_init.o @@ -20,6 +21,7 @@ YASM-OBJS-$(CONFIG_GRADFUN_FILTER) += x86/vf_gradfun.o YASM-OBJS-$(CONFIG_HQDN3D_FILTER) += x86/vf_hqdn3d.o YASM-OBJS-$(CONFIG_IDET_FILTER) += x86/vf_idet.o YASM-OBJS-$(CONFIG_INTERLACE_FILTER) += x86/vf_interlace.o +YASM-OBJS-$(CONFIG_MASKEDMERGE_FILTER) += x86/vf_maskedmerge.o YASM-OBJS-$(CONFIG_PP7_FILTER) += x86/vf_pp7.o YASM-OBJS-$(CONFIG_PSNR_FILTER) += x86/vf_psnr.o YASM-OBJS-$(CONFIG_PULLUP_FILTER) += x86/vf_pullup.o diff --git a/libavfilter/x86/vf_maskedmerge.asm b/libavfilter/x86/vf_maskedmerge.asm new file mode 100644 index 0000000000..3b128b4f52 --- /dev/null +++ b/libavfilter/x86/vf_maskedmerge.asm @@ -0,0 +1,73 @@ +;***************************************************************************** +;* x86-optimized functions for maskedmerge filter +;* +;* Copyright (C) 2015 Paul B Mahol +;* +;* This file is part of FFmpeg. +;* +;* FFmpeg 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. +;* +;* 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 +;* Lesser General Public License for more details. +;* +;* You should have received a copy of the GNU Lesser 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 +;***************************************************************************** + +%include "libavutil/x86/x86util.asm" + +%if ARCH_X86_64 +SECTION_RODATA + +pw_128: times 8 dw 128 +pw_256: times 8 dw 256 + +SECTION .text + +INIT_XMM sse2 +cglobal maskedmerge8, 10, 11, 7, 0, bsrc, osrc, msrc, dst, blinesize, olinesize, mlinesize, dlinesize, w, h + mova m4, [pw_256] + mova m5, [pw_128] + pxor m6, m6 + add bsrcq, wq + add osrcq, wq + add msrcq, wq + add dstq, wq + neg wq +.nextrow: + mov r10q, wq + %define x r10q + + .loop: + movh m0, [bsrcq + x] + movh m1, [osrcq + x] + movh m3, [msrcq + x] + mova m2, m4 + punpcklbw m0, m6 + punpcklbw m1, m6 + punpcklbw m3, m6 + psubw m2, m3 + pmullw m2, m0 + pmullw m1, m3 + paddw m1, m2 + paddw m1, m5 + psrlw m1, 8 + packuswb m1, m1 + movh [dstq + x], m1 + add r10q, mmsize / 2 + jl .loop + + add bsrcq, blinesizeq + add osrcq, olinesizeq + add msrcq, mlinesizeq + add dstq, dlinesizeq + sub hd, 1 + jg .nextrow +REP_RET +%endif diff --git a/libavfilter/x86/vf_maskedmerge_init.c b/libavfilter/x86/vf_maskedmerge_init.c new file mode 100644 index 0000000000..443570047b --- /dev/null +++ b/libavfilter/x86/vf_maskedmerge_init.c @@ -0,0 +1,40 @@ +/* + * Copyright (c) 2015 Paul B Mahol + * + * This file is part of FFmpeg. + * + * FFmpeg 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. + * + * 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 + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser 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 + */ + +#include "libavutil/attributes.h" +#include "libavutil/cpu.h" +#include "libavutil/x86/cpu.h" +#include "libavfilter/maskedmerge.h" + +void ff_maskedmerge8_sse2(const uint8_t *bsrc, const uint8_t *osrc, + const uint8_t *msrc, uint8_t *dst, + ptrdiff_t blinesize, ptrdiff_t olinesize, + ptrdiff_t mlinesize, ptrdiff_t dlinesize, + int w, int h, + int half, int shift); + +av_cold void ff_maskedmerge_init_x86(MaskedMergeContext *s) +{ + int cpu_flags = av_get_cpu_flags(); + + if (ARCH_X86_64 && EXTERNAL_SSE2(cpu_flags) && s->depth == 8) { + s->maskedmerge = ff_maskedmerge8_sse2; + } +} |