1 ;*****************************************************************************
2 ;* x86-optimized functions for convolution filter
4 ;* This file is part of FFmpeg.
6 ;* FFmpeg is free software; you can redistribute it and/or
7 ;* modify it under the terms of the GNU Lesser General Public
8 ;* License as published by the Free Software Foundation; either
9 ;* version 2.1 of the License, or (at your option) any later version.
11 ;* FFmpeg is distributed in the hope that it will be useful,
12 ;* but WITHOUT ANY WARRANTY; without even the implied warranty of
13 ;* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 ;* Lesser General Public License for more details.
16 ;* You should have received a copy of the GNU Lesser General Public
17 ;* License along with FFmpeg; if not, write to the Free Software
18 ;* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
19 ;******************************************************************************
21 %include "libavutil/x86/x86util.asm"
28 ; void filter_3x3_sse4(uint8_t *dst, int width,
29 ; float rdiv, float bias, const int *const matrix,
30 ; const uint8_t *c[], int peak, int radius,
31 ; int dstride, int stride)
35 movss m2, [matrixq + 4 * %1]
45 movzx ptrd, byte [c%1q + xq]
46 imul ptrd, [matrixq + 4 * %1]
52 cglobal filter_3x3, 4, 15, 7, dst, width, matrix, ptr, c0, c1, c2, c3, c4, c5, c6, c7, c8, r, x
54 cglobal filter_3x3, 4, 15, 7, dst, width, rdiv, bias, matrix, ptr, c0, c1, c2, c3, c4, c5, c6, c7, c8, r, x
62 DEFINE_ARGS dst, width, matrix, ptr, c0, c1, c2, c3, c4, c5, c6, c7, c8, r, x
64 movsxdifnidn widthq, widthd
70 mov c0q, [ptrq + 0*gprsize]
71 mov c1q, [ptrq + 1*gprsize]
72 mov c2q, [ptrq + 2*gprsize]
73 mov c3q, [ptrq + 3*gprsize]
74 mov c4q, [ptrq + 4*gprsize]
75 mov c5q, [ptrq + 5*gprsize]
76 mov c6q, [ptrq + 6*gprsize]
77 mov c7q, [ptrq + 7*gprsize]
78 mov c8q, [ptrq + 8*gprsize]
89 pxor m4, m4 ; sum = 0;
102 mulps m4, m0 ; sum *= rdiv
103 addps m4, m1 ; sum += bias
104 addps m4, m5 ; sum += 0.5
108 movss [dstq + xq], m4
119 ; reuse r to hold sum, init with zero
134 mulss m4, m0 ; sum *= rdiv
135 addss m4, m1 ; sum += bias
136 addss m4, m5 ; sum += 0.5
137 ; we don't have simple scalar instructions to convert
138 ; from 32bit to 8bit with saturation, so here
139 ; just use packed version SSE instructions for simplicity.
140 cvttps2dq m4, m4 ; trunc to integer