1 ;******************************************************************************
2 ;* x86-optimized functions for the CFHD encoder
3 ;* Copyright (c) 2021 Paul B Mahol
5 ;* This file is part of FFmpeg.
7 ;* FFmpeg is free software; you can redistribute it and/or
8 ;* modify it under the terms of the GNU Lesser General Public
9 ;* License as published by the Free Software Foundation; either
10 ;* version 2.1 of the License, or (at your option) any later version.
12 ;* FFmpeg is distributed in the hope that it will be useful,
13 ;* but WITHOUT ANY WARRANTY; without even the implied warranty of
14 ;* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 ;* Lesser General Public License for more details.
17 ;* You should have received a copy of the GNU Lesser General Public
18 ;* License along with FFmpeg; if not, write to the Free Software
19 ;* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
20 ;******************************************************************************
22 %include "libavutil/x86/x86util.asm"
26 pw_p1_n1: dw 1, -1, 1, -1, 1, -1, 1, -1
27 pw_n1_p1: dw -1, 1, -1, 1, -1, 1, -1, 1
28 pw_p5_n11: dw 5, -11, 5, -11, 5, -11, 5, -11
29 pw_n5_p11: dw -5, 11, -5, 11, -5, 11, -5, 11
30 pw_p11_n5: dw 11, -5, 11, -5, 11, -5, 11, -5
31 pw_n11_p5: dw -11, 5, -11, 5, -11, 5, -11, 5
42 cglobal cfhdenc_horiz_filter, 8, 10, 11, input, low, high, istride, lwidth, hwidth, width, y, x, temp
51 movsxdifnidn widthq, widthd
54 movsx xq, word [inputq]
56 movsx tempq, word [inputq + 2]
62 mov word [lowq], tempw
64 movsx xq, word [inputq]
66 movsx tempq, word [inputq + 2]
70 movsx xq, word [inputq + 4]
74 movsx xq, word [inputq + 6]
78 movsx xq, word [inputq + 8]
82 movsx xq, word [inputq + 10]
92 mov word [highq], tempw
97 movu m0, [inputq + xq * 2]
98 movu m1, [inputq + xq * 2 + mmsize]
106 movu m2, [inputq + xq * 2 - 4]
107 movu m3, [inputq + xq * 2 - 4 + mmsize]
112 movu m0, [inputq + xq * 2 + 4]
113 movu m1, [inputq + xq * 2 + 4 + mmsize]
127 movu m5, [inputq + xq * 2 + 0]
128 movu m6, [inputq + xq * 2 + mmsize]
145 lea inputq, [inputq + widthq * 2]
147 movsx xq, word [inputq - 4]
148 movsx tempq, word [inputq - 2]
154 mov word [lowq-2], tempw
156 movsx tempq, word [inputq - 4]
158 movsx xq, word [inputq - 2]
162 movsx xq, word [inputq - 6]
166 movsx xq, word [inputq - 8]
170 movsx xq, word [inputq - 10]
173 movsx xq, word [inputq - 12]
182 mov word [highq-2], tempw
200 cglobal cfhdenc_vert_filter, 8, 11, 14, input, low, high, istride, lwidth, hwidth, width, height, x, y, pos
219 movu m0, [inputq + posq]
221 movu m1, [inputq + posq]
229 movu m0, [inputq + posq]
231 movu m1, [inputq + posq]
233 movu m2, [inputq + posq]
235 movu m3, [inputq + posq]
237 movu m4, [inputq + posq]
239 movu m5, [inputq + posq]
253 pmaddwd m0, [pw_p5_n11]
254 pmaddwd m1, [pw_n11_p5]
272 movu [highq + xq], m0
280 movu m0, [inputq + posq]
283 movu m1, [inputq + posq]
291 movu [lowq + posq], m0
299 movu m0, [inputq + posq]
301 movu m1, [inputq + posq]
303 movu m2, [inputq + posq]
305 movu m3, [inputq + posq]
307 movu m4, [inputq + posq]
309 movu m5, [inputq + posq]
348 movu [highq + posq], m0
358 movu m0, [inputq + posq]
360 movu m1, [inputq + posq]
368 movu [lowq + posq], m0
376 movu m0, [inputq + posq]
378 movu m1, [inputq + posq]
380 movu m2, [inputq + posq]
382 movu m3, [inputq + posq]
384 movu m4, [inputq + posq]
386 movu m5, [inputq + posq]
406 pmaddwd m4, [pw_p11_n5]
407 pmaddwd m5, [pw_n5_p11]
426 movu [highq + posq], m4