]> git.sesse.net Git - ffmpeg/blob - libavfilter/x86/vf_threshold.asm
avcodec: postpone removal of deprecated libopenh264 wrapper options
[ffmpeg] / libavfilter / x86 / vf_threshold.asm
1 ;*****************************************************************************
2 ;* x86-optimized functions for threshold filter
3 ;*
4 ;* Copyright (C) 2017 Paul B Mahol
5 ;*
6 ;* This file is part of FFmpeg.
7 ;*
8 ;* FFmpeg is free software; you can redistribute it and/or
9 ;* modify it under the terms of the GNU Lesser General Public
10 ;* License as published by the Free Software Foundation; either
11 ;* version 2.1 of the License, or (at your option) any later version.
12 ;*
13 ;* FFmpeg is distributed in the hope that it will be useful,
14 ;* but WITHOUT ANY WARRANTY; without even the implied warranty of
15 ;* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
16 ;* Lesser General Public License for more details.
17 ;*
18 ;* You should have received a copy of the GNU Lesser General Public
19 ;* License along with FFmpeg; if not, write to the Free Software
20 ;* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
21 ;*****************************************************************************
22
23 %include "libavutil/x86/x86util.asm"
24
25 SECTION_RODATA
26
27 pb_128: times 16 db 128
28 pb_128_0 : times 8 db 0, 128
29
30 SECTION .text
31
32 ;%1 depth (8 or 16) ; %2 b or w ; %3 constant
33 %macro THRESHOLD 3
34 %if ARCH_X86_64
35 cglobal threshold%1, 10, 13, 5, in, threshold, min, max, out, ilinesize, tlinesize, flinesize, slinesize, olinesize, w, h, x
36     mov             wd, dword wm
37     mov             hd, dword hm
38 %else
39 cglobal threshold%1, 5, 7, 5, in, threshold, min, max, out, w, x
40     mov             wd, r10m
41 %define     ilinesizeq  r5mp
42 %define     tlinesizeq  r6mp
43 %define     flinesizeq  r7mp
44 %define     slinesizeq  r8mp
45 %define     olinesizeq  r9mp
46 %define             hd  r11mp
47 %endif
48     VBROADCASTI128  m4, [%3]
49 %if %1 == 16
50     add             wq, wq ; w *= 2 (16 bits instead of 8)
51 %endif
52     add            inq, wq
53     add     thresholdq, wq
54     add           minq, wq
55     add           maxq, wq
56     add           outq, wq
57     neg             wq
58 .nextrow:
59     mov         xq, wq
60
61     .loop:
62         movu            m1, [inq + xq]
63         movu            m0, [thresholdq + xq]
64         movu            m2, [minq + xq]
65         movu            m3, [maxq + xq]
66         pxor            m0, m4
67         pxor            m1, m4
68         pcmpgt%2        m0, m1
69         PBLENDVB        m3, m2, m0
70         movu   [outq + xq], m3
71         add             xq, mmsize
72     jl .loop
73
74     add          inq, ilinesizeq
75     add   thresholdq, tlinesizeq
76     add         minq, flinesizeq
77     add         maxq, slinesizeq
78     add         outq, olinesizeq
79     sub         hd, 1
80     jg .nextrow
81 RET
82 %endmacro
83
84 INIT_XMM sse4
85 THRESHOLD 8, b, pb_128
86 THRESHOLD 16, w, pb_128_0
87
88 %if HAVE_AVX2_EXTERNAL
89 INIT_YMM avx2
90 THRESHOLD 8, b, pb_128
91 THRESHOLD 16, w, pb_128_0
92 %endif