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
|
;*****************************************************************************
;* x86-optimized functions for hflip filter
;*
;* Copyright (C) 2017 Paul B Mahol
;*
;* This file is part of FFmpeg.
;*
;* FFmpeg is free software; you can redistribute it and/or
;* modify it under the terms of the GNU Lesser General Public
;* License as published by the Free Software Foundation; either
;* version 2.1 of the License, or (at your option) any later version.
;*
;* FFmpeg is distributed in the hope that it will be useful,
;* but WITHOUT ANY WARRANTY; without even the implied warranty of
;* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
;* Lesser General Public License for more details.
;*
;* You should have received a copy of the GNU Lesser General Public
;* License along with FFmpeg; if not, write to the Free Software
;* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
;*****************************************************************************
%include "libavutil/x86/x86util.asm"
SECTION_RODATA
pb_flip_byte: db 15,14,13,12,11,10,9,8,7,6,5,4,3,2,1,0
pb_flip_short: db 14,15,12,13,10,11,8,9,6,7,4,5,2,3,0,1
SECTION .text
INIT_XMM ssse3
cglobal hflip_byte, 3, 5, 3, src, dst, w, r, x
mova m0, [pb_flip_byte]
mov xq, 0
mov wd, dword wm
mov rq, wq
and rq, 2 * mmsize - 1
cmp wq, 2 * mmsize
jl .loop1
sub wq, rq
.loop0:
neg xq
movu m1, [srcq + xq - mmsize + 1]
movu m2, [srcq + xq - 2 * mmsize + 1]
pshufb m1, m0
pshufb m2, m0
neg xq
movu [dstq + xq ], m1
movu [dstq + xq + mmsize], m2
add xq, mmsize * 2
cmp xq, wq
jl .loop0
cmp rq, 0
je .end
add wq, rq
.loop1:
neg xq
mov rb, [srcq + xq]
neg xq
mov [dstq + xq], rb
add xq, 1
cmp xq, wq
jl .loop1
.end:
RET
cglobal hflip_short, 3, 5, 3, src, dst, w, r, x
mova m0, [pb_flip_short]
mov xq, 0
mov wd, dword wm
add wq, wq
mov rq, wq
and rq, 2 * mmsize - 1
cmp wq, 2 * mmsize
jl .loop1
sub wq, rq
.loop0:
neg xq
movu m1, [srcq + xq - mmsize + 2]
movu m2, [srcq + xq - 2 * mmsize + 2]
pshufb m1, m0
pshufb m2, m0
neg xq
movu [dstq + xq ], m1
movu [dstq + xq + mmsize], m2
add xq, mmsize * 2
cmp xq, wq
jl .loop0
cmp rq, 0
je .end
add wq, rq
.loop1:
neg xq
mov rw, [srcq + xq]
neg xq
mov [dstq + xq], rw
add xq, 2
cmp xq, wq
jl .loop1
.end:
RET
|