diff options
author | Paul B Mahol <onemda@gmail.com> | 2017-07-03 18:42:03 +0300 |
---|---|---|
committer | Paul B Mahol <onemda@gmail.com> | 2017-07-08 12:49:54 +0300 |
commit | 01e545d04680d6398e85eb1b6d937b608b3f72a2 (patch) | |
tree | 02638f5ea7bef6ec8d1e23e5c586f3ba769c2f73 /libavfilter/x86 | |
parent | 51db262312558fc62b8b89a138b280e612f37509 (diff) |
avfilter: add limiter filter
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_limiter.asm | 84 | ||||
-rw-r--r-- | libavfilter/x86/vf_limiter_init.c | 44 |
3 files changed, 130 insertions, 0 deletions
diff --git a/libavfilter/x86/Makefile b/libavfilter/x86/Makefile index f598ceb3c8..3431625883 100644 --- a/libavfilter/x86/Makefile +++ b/libavfilter/x86/Makefile @@ -8,6 +8,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_LIMITER_FILTER) += x86/vf_limiter_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 @@ -33,6 +34,7 @@ X86ASM-OBJS-$(CONFIG_GRADFUN_FILTER) += x86/vf_gradfun.o X86ASM-OBJS-$(CONFIG_HQDN3D_FILTER) += x86/vf_hqdn3d.o X86ASM-OBJS-$(CONFIG_IDET_FILTER) += x86/vf_idet.o X86ASM-OBJS-$(CONFIG_INTERLACE_FILTER) += x86/vf_interlace.o +X86ASM-OBJS-$(CONFIG_LIMITER_FILTER) += x86/vf_limiter.o X86ASM-OBJS-$(CONFIG_MASKEDMERGE_FILTER) += x86/vf_maskedmerge.o X86ASM-OBJS-$(CONFIG_PP7_FILTER) += x86/vf_pp7.o X86ASM-OBJS-$(CONFIG_PSNR_FILTER) += x86/vf_psnr.o diff --git a/libavfilter/x86/vf_limiter.asm b/libavfilter/x86/vf_limiter.asm new file mode 100644 index 0000000000..9e7271be76 --- /dev/null +++ b/libavfilter/x86/vf_limiter.asm @@ -0,0 +1,84 @@ +;***************************************************************************** +;* x86-optimized functions for limiter filter +;* +;* 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 + +pb_0: times 16 db 0 + +SECTION .text + +INIT_XMM sse2 + +cglobal limiter_8bit, 8, 9, 3, src, dst, slinesize, dlinesize, w, h, min, max, x + movsxdifnidn wq, wd + add srcq, wq + add dstq, wq + neg wq + SPLATB_REG m1, min, [pb_0] + SPLATB_REG m2, max, [pb_0] +.nextrow: + mov xq, wq + + .loop: + movu m0, [srcq + xq] + CLIPUB m0, m1, m2 + mova [dstq+xq], m0 + add xq, mmsize + jl .loop + + add srcq, slinesizeq + add dstq, dlinesizeq + sub hd, 1 + jg .nextrow + ret + +INIT_XMM sse4 + +cglobal limiter_16bit, 8, 9, 3, src, dst, slinesize, dlinesize, w, h, min, max, x + shl wd, 1 + add srcq, wq + add dstq, wq + neg wq + movd m1, mind + SPLATW m1, m1 + movd m2, maxd + SPLATW m2, m2 +.nextrow: + mov xq, wq + + .loop: + movu m0, [srcq + xq] + pmaxuw m0, m1 + pminuw m0, m2 + mova [dstq+xq], m0 + add xq, mmsize + jl .loop + + add srcq, slinesizeq + add dstq, dlinesizeq + sub hd, 1 + jg .nextrow + ret + +%endif diff --git a/libavfilter/x86/vf_limiter_init.c b/libavfilter/x86/vf_limiter_init.c new file mode 100644 index 0000000000..ef7d20a1a0 --- /dev/null +++ b/libavfilter/x86/vf_limiter_init.c @@ -0,0 +1,44 @@ +/* + * 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/cpu.h" + +#include "libavfilter/limiter.h" + +void ff_limiter_8bit_sse2(const uint8_t *src, uint8_t *dst, + ptrdiff_t slinesize, ptrdiff_t dlinesize, + int w, int h, int min, int max); +void ff_limiter_16bit_sse4(const uint8_t *src, uint8_t *dst, + ptrdiff_t slinesize, ptrdiff_t dlinesize, + int w, int h, int min, int max); + +void ff_limiter_init_x86(LimiterDSPContext *dsp, int bpp) +{ + int cpu_flags = av_get_cpu_flags(); + + if (ARCH_X86_64 && EXTERNAL_SSE2(cpu_flags)) { + if (bpp <= 8) { + dsp->limiter = ff_limiter_8bit_sse2; + } + } + if (ARCH_X86_64 && EXTERNAL_SSE4(cpu_flags)) { + if (bpp > 8) { + dsp->limiter = ff_limiter_16bit_sse4; + } + } +} |