]> git.sesse.net Git - ffmpeg/blob - libavfilter/x86/vf_maskedmerge.asm
Merge commit 'd6dc5d15af0d8617611281a34a2c3f9ced149ccf'
[ffmpeg] / libavfilter / x86 / vf_maskedmerge.asm
1 ;*****************************************************************************
2 ;* x86-optimized functions for maskedmerge filter
3 ;*
4 ;* Copyright (C) 2015 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 %if ARCH_X86_64
26 SECTION_RODATA
27
28 pw_128: times 8 dw 128
29 pw_256: times 8 dw 256
30
31 SECTION .text
32
33 INIT_XMM sse2
34 cglobal maskedmerge8, 10, 11, 7, 0, bsrc, osrc, msrc, dst, blinesize, olinesize, mlinesize, dlinesize, w, h
35     mova        m4, [pw_256]
36     mova        m5, [pw_128]
37     pxor        m6, m6
38     add      bsrcq, wq
39     add      osrcq, wq
40     add      msrcq, wq
41     add       dstq, wq
42     neg         wq
43     %define      x  r10q
44 .nextrow:
45     mov          x, wq
46
47     .loop:
48         movh            m0, [bsrcq + x]
49         movh            m1, [osrcq + x]
50         movh            m3, [msrcq + x]
51         mova            m2, m4
52         punpcklbw       m0, m6
53         punpcklbw       m1, m6
54         punpcklbw       m3, m6
55         psubw           m2, m3
56         pmullw          m2, m0
57         pmullw          m1, m3
58         paddw           m1, m2
59         paddw           m1, m5
60         psrlw           m1, 8
61         packuswb        m1, m1
62         movh    [dstq + x], m1
63         add           r10q, mmsize / 2
64     jl .loop
65
66     add         bsrcq, blinesizeq
67     add         osrcq, olinesizeq
68     add         msrcq, mlinesizeq
69     add          dstq, dlinesizeq
70     sub         hd, 1
71     jg .nextrow
72 REP_RET
73 %endif