diff options
author | Paul B Mahol <onemda@gmail.com> | 2015-10-07 21:03:16 +0200 |
---|---|---|
committer | Paul B Mahol <onemda@gmail.com> | 2015-10-10 17:33:43 +0200 |
commit | 5740dc27e1a633b636ae37ae1f7a2ab71a060486 (patch) | |
tree | 32dc54c3a192d81a42ef8dc6d98e1af2b029b928 /libavfilter/x86 | |
parent | 0281ef907519ee395d53d523022100f2634672b3 (diff) | |
download | ffmpeg-5740dc27e1a633b636ae37ae1f7a2ab71a060486.tar.gz |
avfilter/vf_w3fdif: add x86 SIMD
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_w3fdif.asm | 234 | ||||
-rw-r--r-- | libavfilter/x86/vf_w3fdif_init.c | 62 |
3 files changed, 298 insertions, 0 deletions
diff --git a/libavfilter/x86/Makefile b/libavfilter/x86/Makefile index c02420476e..33de380bc0 100644 --- a/libavfilter/x86/Makefile +++ b/libavfilter/x86/Makefile @@ -17,6 +17,7 @@ OBJS-$(CONFIG_STEREO3D_FILTER) += x86/vf_stereo3d_init.o OBJS-$(CONFIG_TBLEND_FILTER) += x86/vf_blend_init.o OBJS-$(CONFIG_TINTERLACE_FILTER) += x86/vf_tinterlace_init.o OBJS-$(CONFIG_VOLUME_FILTER) += x86/af_volume_init.o +OBJS-$(CONFIG_W3FDIF_FILTER) += x86/vf_w3fdif_init.o OBJS-$(CONFIG_YADIF_FILTER) += x86/vf_yadif_init.o YASM-OBJS-$(CONFIG_BLEND_FILTER) += x86/vf_blend.o @@ -37,4 +38,5 @@ YASM-OBJS-$(CONFIG_STEREO3D_FILTER) += x86/vf_stereo3d.o YASM-OBJS-$(CONFIG_TBLEND_FILTER) += x86/vf_blend.o YASM-OBJS-$(CONFIG_TINTERLACE_FILTER) += x86/vf_interlace.o YASM-OBJS-$(CONFIG_VOLUME_FILTER) += x86/af_volume.o +YASM-OBJS-$(CONFIG_W3FDIF_FILTER) += x86/vf_w3fdif.o YASM-OBJS-$(CONFIG_YADIF_FILTER) += x86/vf_yadif.o x86/yadif-16.o x86/yadif-10.o diff --git a/libavfilter/x86/vf_w3fdif.asm b/libavfilter/x86/vf_w3fdif.asm new file mode 100644 index 0000000000..33acfaba24 --- /dev/null +++ b/libavfilter/x86/vf_w3fdif.asm @@ -0,0 +1,234 @@ +;***************************************************************************** +;* x86-optimized functions for w3fdif 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" + +SECTION .text + +INIT_XMM sse2 +cglobal w3fdif_scale, 3, 3, 2, 0, out_pixel, work_pixel, linesize +.loop + mova m0, [work_pixelq] + mova m1, [work_pixelq+mmsize] + psrad m0, 15 + psrad m1, 15 + packssdw m0, m1 + packuswb m0, m0 + movh [out_pixelq], m0 + add out_pixelq, mmsize/2 + add work_pixelq, mmsize*2 + sub linesized, mmsize/2 + jg .loop +REP_RET + +cglobal w3fdif_simple_low, 4, 5, 6, 0, work_line, in_lines_cur0, coef, linesize, offset + movd m1, [coefq] + DEFINE_ARGS work_line, in_lines_cur0, in_lines_cur1, linesize, offset + SPLATW m0, m1, 0 + SPLATW m1, m1, 1 + pxor m4, m4 + mov offsetq, 0 + mov in_lines_cur1q, [in_lines_cur0q + gprsize] + mov in_lines_cur0q, [in_lines_cur0q] + +.loop + movh m2, [in_lines_cur0q+offsetq] + movh m3, [in_lines_cur1q+offsetq] + punpcklbw m2, m4 + punpcklbw m3, m4 + SBUTTERFLY wd, 2, 3, 5 + pmaddwd m2, m0 + pmaddwd m3, m1 + mova [work_lineq+offsetq*4], m2 + mova [work_lineq+offsetq*4+mmsize], m3 + add offsetq, mmsize/2 + sub linesized, mmsize/2 + jg .loop +REP_RET + +cglobal w3fdif_complex_low, 4, 7, 7, 0, work_line, in_lines_cur0, coef, linesize + movq m0, [coefq] + DEFINE_ARGS work_line, in_lines_cur0, in_lines_cur1, linesize, offset, in_lines_cur2, in_lines_cur3 + pshufd m2, m0, q1111 + SPLATD m0 + mov offsetq, 0 + mov in_lines_cur3q, [in_lines_cur0q+gprsize*3] + mov in_lines_cur2q, [in_lines_cur0q+gprsize*2] + mov in_lines_cur1q, [in_lines_cur0q+gprsize] + mov in_lines_cur0q, [in_lines_cur0q] + +.loop + movh m4, [in_lines_cur0q+offsetq] + movh m5, [in_lines_cur1q+offsetq] + pxor m1, m1 + punpcklbw m4, m1 + punpcklbw m5, m1 + SBUTTERFLY wd, 4, 5, 3 + pmaddwd m4, m0 + pmaddwd m5, m0 + movh m6, [in_lines_cur2q+offsetq] + movh m3, [in_lines_cur3q+offsetq] + punpcklbw m6, m1 + punpcklbw m3, m1 + SBUTTERFLY wd, 6, 3, 1 + pmaddwd m6, m2 + pmaddwd m3, m2 + paddd m4, m6 + paddd m5, m3 + mova [work_lineq+offsetq*4], m4 + mova [work_lineq+offsetq*4+mmsize], m5 + add offsetq, mmsize/2 + sub linesized, mmsize/2 + jg .loop +REP_RET + +%if ARCH_X86_64 + +cglobal w3fdif_simple_high, 5, 9, 9, 0, work_line, in_lines_cur0, in_lines_adj0, coef, linesize + movq m2, [coefq] + DEFINE_ARGS work_line, in_lines_cur0, in_lines_adj0, in_lines_cur1, linesize, offset, in_lines_cur2, in_lines_adj1, in_lines_adj2 + SPLATW m0, m2, 0 + SPLATW m1, m2, 1 + SPLATW m2, m2, 2 + SBUTTERFLY wd, 0, 1, 7 + pxor m7, m7 + mov offsetq, 0 + mov in_lines_cur2q, [in_lines_cur0q+gprsize*2] + mov in_lines_cur1q, [in_lines_cur0q+gprsize] + mov in_lines_cur0q, [in_lines_cur0q] + mov in_lines_adj2q, [in_lines_adj0q+gprsize*2] + mov in_lines_adj1q, [in_lines_adj0q+gprsize] + mov in_lines_adj0q, [in_lines_adj0q] + +.loop + movh m3, [in_lines_cur0q+offsetq] + movh m4, [in_lines_cur1q+offsetq] + punpcklbw m3, m7 + punpcklbw m4, m7 + SBUTTERFLY wd, 3, 4, 8 + pmaddwd m3, m0 + pmaddwd m4, m1 + movh m5, [in_lines_adj0q+offsetq] + movh m6, [in_lines_adj1q+offsetq] + punpcklbw m5, m7 + punpcklbw m6, m7 + SBUTTERFLY wd, 5, 6, 8 + pmaddwd m5, m0 + pmaddwd m6, m1 + paddd m3, m5 + paddd m4, m6 + movh m5, [in_lines_cur2q+offsetq] + movh m6, [in_lines_adj2q+offsetq] + punpcklbw m5, m7 + punpcklbw m6, m7 + SBUTTERFLY wd, 5, 6, 8 + pmaddwd m5, m2 + pmaddwd m6, m2 + paddd m3, m5 + paddd m4, m6 + movu m5, [work_lineq+offsetq*4] + movu m6, [work_lineq+offsetq*4+mmsize] + paddd m3, m5 + paddd m4, m6 + mova [work_lineq+offsetq*4], m3 + mova [work_lineq+offsetq*4+mmsize], m4 + add offsetq, mmsize/2 + sub linesized, mmsize/2 + jg .loop +REP_RET + +cglobal w3fdif_complex_high, 5, 13, 10, 0, work_line, in_lines_cur0, in_lines_adj0, coef, linesize + movq m0, [coefq+0] + movd m4, [coefq+8] + DEFINE_ARGS work_line, in_lines_cur0, in_lines_adj0, in_lines_cur1, linesize, offset, in_lines_cur2, in_lines_cur3, in_lines_cur4, in_lines_adj1, in_lines_adj2, in_lines_adj3, in_lines_adj4 + pshufd m1, m0, q1111 + SPLATD m0 + SPLATW m4, m4 + pxor m3, m3 + mov offsetq, 0 + mov in_lines_cur4q, [in_lines_cur0q+gprsize*4] + mov in_lines_cur3q, [in_lines_cur0q+gprsize*3] + mov in_lines_cur2q, [in_lines_cur0q+gprsize*2] + mov in_lines_cur1q, [in_lines_cur0q+gprsize] + mov in_lines_cur0q, [in_lines_cur0q] + mov in_lines_adj4q, [in_lines_adj0q+gprsize*4] + mov in_lines_adj3q, [in_lines_adj0q+gprsize*3] + mov in_lines_adj2q, [in_lines_adj0q+gprsize*2] + mov in_lines_adj1q, [in_lines_adj0q+gprsize] + mov in_lines_adj0q, [in_lines_adj0q] + +.loop + movh m5, [in_lines_cur0q+offsetq] + movh m6, [in_lines_cur1q+offsetq] + punpcklbw m5, m3 + punpcklbw m6, m3 + SBUTTERFLY wd, 5, 6, 2 + pmaddwd m5, m0 + pmaddwd m6, m0 + movh m8, [in_lines_cur2q+offsetq] + movh m9, [in_lines_cur3q+offsetq] + punpcklbw m8, m3 + punpcklbw m9, m3 + SBUTTERFLY wd, 8, 9, 2 + pmaddwd m8, m1 + pmaddwd m9, m1 + paddd m5, m8 + paddd m6, m9 + movh m8, [in_lines_adj0q+offsetq] + movh m9, [in_lines_adj1q+offsetq] + punpcklbw m8, m3 + punpcklbw m9, m3 + SBUTTERFLY wd, 8, 9, 2 + pmaddwd m8, m0 + pmaddwd m9, m0 + paddd m5, m8 + paddd m6, m9 + movh m8, [in_lines_adj2q+offsetq] + movh m9, [in_lines_adj3q+offsetq] + punpcklbw m8, m3 + punpcklbw m9, m3 + SBUTTERFLY wd, 8, 9, 2 + pmaddwd m8, m1 + pmaddwd m9, m1 + paddd m5, m8 + paddd m6, m9 + movh m8, [in_lines_cur4q+offsetq] + movh m9, [in_lines_adj4q+offsetq] + punpcklbw m8, m3 + punpcklbw m9, m3 + SBUTTERFLY wd, 8, 9, 2 + pmaddwd m8, m4 + pmaddwd m9, m4 + paddd m5, m8 + paddd m6, m9 + movu m8, [work_lineq+offsetq*4] + movu m9, [work_lineq+offsetq*4+mmsize] + paddd m5, m8 + paddd m6, m9 + mova [work_lineq+offsetq*4], m5 + mova [work_lineq+offsetq*4+mmsize], m6 + add offsetq, mmsize/2 + sub linesized, mmsize/2 + jg .loop +REP_RET + +%endif diff --git a/libavfilter/x86/vf_w3fdif_init.c b/libavfilter/x86/vf_w3fdif_init.c new file mode 100644 index 0000000000..72ea657c8f --- /dev/null +++ b/libavfilter/x86/vf_w3fdif_init.c @@ -0,0 +1,62 @@ +/* + * 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/mem.h" +#include "libavutil/x86/asm.h" +#include "libavutil/x86/cpu.h" +#include "libavfilter/w3fdif.h" + +void ff_w3fdif_simple_low_sse2(int32_t *work_line, + uint8_t *in_lines_cur[2], + const int16_t *coef, int linesize); + +void ff_w3fdif_simple_high_sse2(int32_t *work_line, + uint8_t *in_lines_cur[3], + uint8_t *in_lines_adj[3], + const int16_t *coef, int linesize); + +void ff_w3fdif_complex_low_sse2(int32_t *work_line, + uint8_t *in_lines_cur[4], + const int16_t *coef, int linesize); + +void ff_w3fdif_complex_high_sse2(int32_t *work_line, + uint8_t *in_lines_cur[5], + uint8_t *in_lines_adj[5], + const int16_t *coef, int linesize); + +void ff_w3fdif_scale_sse2(uint8_t *out_pixel, const int32_t *work_pixel, int linesize); + +av_cold void ff_w3fdif_init_x86(W3FDIFDSPContext *dsp) +{ + int cpu_flags = av_get_cpu_flags(); + + if (EXTERNAL_SSE2(cpu_flags)) { + dsp->filter_simple_low = ff_w3fdif_simple_low_sse2; + dsp->filter_complex_low = ff_w3fdif_complex_low_sse2; + dsp->filter_scale = ff_w3fdif_scale_sse2; + } + + if (ARCH_X86_64 && EXTERNAL_SSE2(cpu_flags)) { + dsp->filter_simple_high = ff_w3fdif_simple_high_sse2; + dsp->filter_complex_high = ff_w3fdif_complex_high_sse2; + } +} |