Imported Upstream version 1.4
[deb_x265.git] / source / common / x86 / loopfilter.asm
1 ;*****************************************************************************
2 ;* Copyright (C) 2013 x265 project
3 ;*
4 ;* Authors: Min Chen <chenm001@163.com>
5 ;* Praveen Kumar Tiwari <praveen@multicorewareinc.com>
6 ;* Nabajit Deka <nabajit@multicorewareinc.com>
7 ;* Dnyaneshwar Gorade <dnyaneshwar@multicorewareinc.com>
8 ;* Murugan Vairavel <murugan@multicorewareinc.com>
9 ;* Yuvaraj Venkatesh <yuvaraj@multicorewareinc.com>
10 ;* This program is free software; you can redistribute it and/or modify
11 ;* it under the terms of the GNU General Public License as published by
12 ;* the Free Software Foundation; either version 2 of the License, or
13 ;* (at your option) any later version.
14 ;*
15 ;* This program is distributed in the hope that it will be useful,
16 ;* but WITHOUT ANY WARRANTY; without even the implied warranty of
17 ;* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 ;* GNU General Public License for more details.
19 ;*
20 ;* You should have received a copy of the GNU General Public License
21 ;* along with this program; if not, write to the Free Software
22 ;* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111, USA.
23 ;*
24 ;* This program is also available under a commercial proprietary license.
25 ;* For more information, contact us at license @ x265.com.
26 ;*****************************************************************************/
27
28 %include "x86inc.asm"
29
30 SECTION_RODATA 32
31
32 pw_2: times 16 db 2
33
34 SECTION .text
35
36 ;============================================================================================================
37 ; void saoCuOrgE0(pixel * rec, int8_t * offsetEo, int lcuWidth, int8_t signLeft)
38 ;============================================================================================================
39 INIT_XMM sse4
40 cglobal saoCuOrgE0, 4, 4, 8, rec, offsetEo, lcuWidth, signLeft
41
42 neg r3 ; r3 = -iSignLeft
43 movd m0, r3d
44 pslldq m0, 15 ; m0 = [iSignLeft x .. x]
45 pcmpeqb m4, m4 ; m4 = [pb -1]
46 pxor m5, m5 ; m5 = 0
47 movh m6, [r1] ; m6 = m_offsetEo
48
49 .loop:
50 movu m7, [r0] ; m1 = pRec[x]
51 mova m1, m7
52 movu m2, [r0+1] ; m2 = pRec[x+1]
53
54 psubusb m3, m2, m7
55 psubusb m1, m2
56 pcmpeqb m3, m5
57 pcmpeqb m1, m5
58 pcmpeqb m2, m7
59
60 pabsb m3, m3 ; m1 = (pRec[x] - pRec[x+1]) > 0) ? 1 : 0
61 por m1, m3 ; m1 = iSignRight
62 pandn m2, m1
63
64 palignr m3, m2, m0, 15 ; m3 = -iSignLeft
65 psignb m3, m4 ; m3 = iSignLeft
66 mova m0, m4
67 pslldq m0, 15
68 pand m0, m2 ; [pb 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,-1]
69 paddb m2, m3
70 paddb m2, [pw_2] ; m1 = uiEdgeType
71 pshufb m3, m6, m2
72 pmovzxbw m2, m7 ; rec
73 punpckhbw m7, m5
74 pmovsxbw m1, m3 ; iOffsetEo
75 punpckhbw m3, m3
76 psraw m3, 8
77 paddw m2, m1
78 paddw m7, m3
79 packuswb m2, m7
80 movu [r0], m2
81
82 add r0q, 16
83 sub r2d, 16
84 jnz .loop
85 RET