summaryrefslogtreecommitdiff
path: root/media/libvpx/vp8/encoder/x86/subtract_mmx.asm
blob: 794dd22f7eddca5c1d4fb8f0de8e666c1fe57e07 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
;
;  Copyright (c) 2010 The WebM project authors. All Rights Reserved.
;
;  Use of this source code is governed by a BSD-style license
;  that can be found in the LICENSE file in the root of the source
;  tree. An additional intellectual property rights grant can be found
;  in the file PATENTS.  All contributing project authors may
;  be found in the AUTHORS file in the root of the source tree.
;


%include "vpx_ports/x86_abi_support.asm"

;void vp8_subtract_b_mmx_impl(unsigned char *z,  int src_stride,
;                            short *diff, unsigned char *Predictor,
;                            int pitch);
global sym(vp8_subtract_b_mmx_impl) PRIVATE
sym(vp8_subtract_b_mmx_impl):
    push        rbp
    mov         rbp, rsp
    SHADOW_ARGS_TO_STACK 5
    push rsi
    push rdi
    ; end prolog


        mov     rdi,        arg(2) ;diff
        mov     rax,        arg(3) ;Predictor
        mov     rsi,        arg(0) ;z
        movsxd  rdx,        dword ptr arg(1);src_stride;
        movsxd  rcx,        dword ptr arg(4);pitch
        pxor    mm7,        mm7

        movd    mm0,        [rsi]
        movd    mm1,        [rax]
        punpcklbw   mm0,    mm7
        punpcklbw   mm1,    mm7
        psubw   mm0,        mm1
        movq    [rdi],      mm0


        movd    mm0,        [rsi+rdx]
        movd    mm1,        [rax+rcx]
        punpcklbw   mm0,    mm7
        punpcklbw   mm1,    mm7
        psubw   mm0,        mm1
        movq    [rdi+rcx*2],mm0


        movd    mm0,        [rsi+rdx*2]
        movd    mm1,        [rax+rcx*2]
        punpcklbw   mm0,    mm7
        punpcklbw   mm1,    mm7
        psubw   mm0,        mm1
        movq    [rdi+rcx*4],        mm0

        lea     rsi,        [rsi+rdx*2]
        lea     rcx,        [rcx+rcx*2]



        movd    mm0,        [rsi+rdx]
        movd    mm1,        [rax+rcx]
        punpcklbw   mm0,    mm7
        punpcklbw   mm1,    mm7
        psubw   mm0,        mm1
        movq    [rdi+rcx*2],        mm0

    ; begin epilog
    pop rdi
    pop rsi
    UNSHADOW_ARGS
    pop         rbp
    ret

;void vp8_subtract_mby_mmx(short *diff, unsigned char *src, int src_stride,
;unsigned char *pred, int pred_stride)
global sym(vp8_subtract_mby_mmx) PRIVATE
sym(vp8_subtract_mby_mmx):
    push        rbp
    mov         rbp, rsp
    SHADOW_ARGS_TO_STACK 5
    push rsi
    push rdi
    ; end prolog

    mov         rdi,        arg(0)          ;diff
    mov         rsi,        arg(1)          ;src
    movsxd      rdx,        dword ptr arg(2);src_stride
    mov         rax,        arg(3)          ;pred
    push        rbx
    movsxd      rbx,        dword ptr arg(4);pred_stride

    pxor        mm0,        mm0
    mov         rcx,        16


.submby_loop:
    movq        mm1,        [rsi]
    movq        mm3,        [rax]

    movq        mm2,        mm1
    movq        mm4,        mm3

    punpcklbw   mm1,        mm0
    punpcklbw   mm3,        mm0

    punpckhbw   mm2,        mm0
    punpckhbw   mm4,        mm0

    psubw       mm1,        mm3
    psubw       mm2,        mm4

    movq        [rdi],      mm1
    movq        [rdi+8],    mm2

    movq        mm1,        [rsi+8]
    movq        mm3,        [rax+8]

    movq        mm2,        mm1
    movq        mm4,        mm3

    punpcklbw   mm1,        mm0
    punpcklbw   mm3,        mm0

    punpckhbw   mm2,        mm0
    punpckhbw   mm4,        mm0

    psubw       mm1,        mm3
    psubw       mm2,        mm4

    movq        [rdi+16],   mm1
    movq        [rdi+24],   mm2
    add         rdi,        32
    lea         rax,        [rax+rbx]
    lea         rsi,        [rsi+rdx]
    dec         rcx
    jnz         .submby_loop

    pop rbx
    pop rdi
    pop rsi
    ; begin epilog
    UNSHADOW_ARGS
    pop         rbp
    ret


;vp8_subtract_mbuv_mmx(short *diff, unsigned char *usrc, unsigned char *vsrc,
;                         int src_stride, unsigned char *upred,
;                         unsigned char *vpred, int pred_stride)

global sym(vp8_subtract_mbuv_mmx) PRIVATE
sym(vp8_subtract_mbuv_mmx):
    push        rbp
    mov         rbp, rsp
    SHADOW_ARGS_TO_STACK 7
    push rsi
    push rdi
    ; end prolog

    mov         rdi,        arg(0)          ;diff
    mov         rsi,        arg(1)          ;usrc
    movsxd      rdx,        dword ptr arg(3);src_stride;
    mov         rax,        arg(4)          ;upred
    add         rdi,        256*2           ;diff = diff + 256 (shorts)
    mov         rcx,        8
    push        rbx
    movsxd      rbx,        dword ptr arg(6);pred_stride

    pxor        mm7,        mm7

.submbu_loop:
    movq        mm0,        [rsi]
    movq        mm1,        [rax]
    movq        mm3,        mm0
    movq        mm4,        mm1
    punpcklbw   mm0,        mm7
    punpcklbw   mm1,        mm7
    punpckhbw   mm3,        mm7
    punpckhbw   mm4,        mm7
    psubw       mm0,        mm1
    psubw       mm3,        mm4
    movq        [rdi],      mm0
    movq        [rdi+8],    mm3
    add         rdi, 16
    add         rsi, rdx
    add         rax, rbx

    dec         rcx
    jnz         .submbu_loop

    mov         rsi,        arg(2)          ;vsrc
    mov         rax,        arg(5)          ;vpred
    mov         rcx,        8

.submbv_loop:
    movq        mm0,        [rsi]
    movq        mm1,        [rax]
    movq        mm3,        mm0
    movq        mm4,        mm1
    punpcklbw   mm0,        mm7
    punpcklbw   mm1,        mm7
    punpckhbw   mm3,        mm7
    punpckhbw   mm4,        mm7
    psubw       mm0,        mm1
    psubw       mm3,        mm4
    movq        [rdi],      mm0
    movq        [rdi+8],    mm3
    add         rdi, 16
    add         rsi, rdx
    add         rax, rbx

    dec         rcx
    jnz         .submbv_loop

    pop         rbx
    ; begin epilog
    pop rdi
    pop rsi
    UNSHADOW_ARGS
    pop         rbp
    ret