inv_wht_sse2.asm revision 7ce0a1d1337c01056ba24006efab21f00e179e04
1;
2;  Copyright (c) 2015 The WebM project authors. All Rights Reserved.
3;
4;  Use of this source code is governed by a BSD-style license
5;  that can be found in the LICENSE file in the root of the source
6;  tree. An additional intellectual property rights grant can be found
7;  in the file PATENTS.  All contributing project authors may
8;  be found in the AUTHORS file in the root of the source tree.
9;
10
11%include "third_party/x86inc/x86inc.asm"
12
13SECTION .text
14
15%macro REORDER_INPUTS 0
16  ; a c d b  to  a b c d
17  SWAP 1, 3, 2
18%endmacro
19
20%macro TRANSFORM_COLS 0
21  ; input:
22  ; m0 a
23  ; m1 b
24  ; m2 c
25  ; m3 d
26  paddw           m0,        m2
27  psubw           m3,        m1
28
29  ; wide subtract
30  punpcklwd       m4,        m0
31  punpcklwd       m5,        m3
32  psrad           m4,        16
33  psrad           m5,        16
34  psubd           m4,        m5
35  psrad           m4,        1
36  packssdw        m4,        m4             ; e
37
38  psubw           m5,        m4,        m1  ; b
39  psubw           m4,        m2             ; c
40  psubw           m0,        m5
41  paddw           m3,        m4
42                                ; m0 a
43  SWAP            1,         5  ; m1 b
44  SWAP            2,         4  ; m2 c
45                                ; m3 d
46%endmacro
47
48%macro TRANSPOSE_4X4 0
49  punpcklwd       m0,        m2
50  punpcklwd       m1,        m3
51  mova            m2,        m0
52  punpcklwd       m0,        m1
53  punpckhwd       m2,        m1
54  pshufd          m1,        m0, 0x0e
55  pshufd          m3,        m2, 0x0e
56%endmacro
57
58; transpose a 4x4 int16 matrix in xmm0 and xmm1 to the bottom half of xmm0-xmm3
59%macro TRANSPOSE_4X4_WIDE 0
60  mova            m3, m0
61  punpcklwd       m0, m1
62  punpckhwd       m3, m1
63  mova            m2, m0
64  punpcklwd       m0, m3
65  punpckhwd       m2, m3
66  pshufd          m1, m0, 0x0e
67  pshufd          m3, m2, 0x0e
68%endmacro
69
70%macro ADD_STORE_4P_2X 5  ; src1, src2, tmp1, tmp2, zero
71  movd            m%3,       [outputq]
72  movd            m%4,       [outputq + strideq]
73  punpcklbw       m%3,       m%5
74  punpcklbw       m%4,       m%5
75  paddw           m%1,       m%3
76  paddw           m%2,       m%4
77  packuswb        m%1,       m%5
78  packuswb        m%2,       m%5
79  movd            [outputq], m%1
80  movd            [outputq + strideq], m%2
81%endmacro
82
83INIT_XMM sse2
84cglobal iwht4x4_16_add, 3, 3, 7, input, output, stride
85  mova            m0,        [inputq +  0]
86  mova            m1,        [inputq + 16]
87
88  psraw           m0,        2
89  psraw           m1,        2
90
91  TRANSPOSE_4X4_WIDE
92  REORDER_INPUTS
93  TRANSFORM_COLS
94  TRANSPOSE_4X4
95  REORDER_INPUTS
96  TRANSFORM_COLS
97
98  pxor            m4, m4
99  ADD_STORE_4P_2X  0, 1, 5, 6, 4
100  lea             outputq, [outputq + 2 * strideq]
101  ADD_STORE_4P_2X  2, 3, 5, 6, 4
102
103  RET
104