]> git.sesse.net Git - ffmpeg/blob - libavfilter/x86/af_anlmdn.asm
Merge commit 'bb515e3a735f526ccb1068031e289eb5aeb69e22'
[ffmpeg] / libavfilter / x86 / af_anlmdn.asm
1 ;*****************************************************************************
2 ;* x86-optimized functions for anlmdn filter
3 ;* Copyright (c) 2017 Paul B Mahol
4 ;*
5 ;* This file is part of FFmpeg.
6 ;*
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.
11 ;*
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.
16 ;*
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 ;******************************************************************************
21
22 %include "libavutil/x86/x86util.asm"
23
24 SECTION .text
25
26 ;------------------------------------------------------------------------------
27 ; float ff_compute_distance_ssd(float *f1, const float *f2, ptrdiff_t len)
28 ;------------------------------------------------------------------------------
29
30 INIT_XMM sse
31 cglobal compute_distance_ssd, 3,5,3, f1, f2, len, r, x
32     mov       xq, lenq
33     shl       xq, 2
34     neg       xq
35     add       f1q, xq
36     add       f2q, xq
37     xor       xq, xq
38     shl       lenq, 1
39     add       lenq, 1
40     shl       lenq, 2
41     mov       rq, lenq
42     and       rq, mmsize - 1
43     xorps     m0, m0
44     cmp       lenq, mmsize
45     jl .loop1
46     sub       lenq, rq
47 ALIGN 16
48     .loop0:
49         movups    m1, [f1q + xq]
50         movups    m2, [f2q + xq]
51         subps     m1, m2
52         mulps     m1, m1
53         addps     m0, m1
54         add       xq, mmsize
55         cmp       xq, lenq
56         jl .loop0
57
58     movhlps   xmm1, xmm0
59     addps     xmm0, xmm1
60     movss     xmm1, xmm0
61     shufps    xmm0, xmm0, 1
62     addss     xmm0, xmm1
63
64     cmp       rq, 0
65     je .end
66     add       lenq, rq
67     .loop1:
68         movss    xm1, [f1q + xq]
69         subss    xm1, [f2q + xq]
70         mulss    xm1, xm1
71         addss    xm0, xm1
72         add       xq, 4
73         cmp       xq, lenq
74         jl .loop1
75     .end:
76 %if ARCH_X86_64 == 0
77     movss     r0m, xm0
78     fld dword r0m
79 %endif
80     RET