-
Notifications
You must be signed in to change notification settings - Fork 80
/
tiled_yuv.S
179 lines (156 loc) · 3.54 KB
/
tiled_yuv.S
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
/*
* Copyright (c) 2014 Jens Kuske <[email protected]>
*
* This library 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.
*
* This library 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 this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*
*/
#if defined(__linux__) && defined(__ELF__)
.section .note.GNU-stack,"",%progbits /* mark stack as non-executable */
#endif
#ifndef __aarch64__
.text
.syntax unified
.arch armv7-a
.fpu neon
.thumb
.macro thumb_function fname
.global \fname
#ifdef __ELF__
.hidden \fname
.type \fname, %function
#endif
.thumb_func
\fname:
.endm
.macro end_function fname
#ifdef __ELF__
.size \fname, .-\fname
#endif
.endm
SRC .req r0
DST .req r1
PITCH .req r2
CNT .req r3
TLINE .req r4
HEIGHT .req r5
REST .req r6
NTILES .req r7
TMPSRC .req r8
DST2 .req r9
TSIZE .req r12
NEXTLIN .req lr
thumb_function tiled_to_planar
push {r4, r5, r6, r7, r8, lr}
ldr HEIGHT, [sp, #24]
add NEXTLIN, r3, #31
lsrs NTILES, r3, #5
bic NEXTLIN, NEXTLIN, #31
and REST, r3, #31
lsl NEXTLIN, NEXTLIN, #5
subs PITCH, r2, r3
movs TLINE, #32
rsb NEXTLIN, NEXTLIN, #32
mov TSIZE, #1024
/* y loop */
1: cbz NTILES, 3f
mov CNT, NTILES
/* x loop complete tiles */
2: pld [SRC, TSIZE]
vld1.8 {d0 - d3}, [SRC :256], TSIZE
subs CNT, #1
vst1.8 {d0 - d3}, [DST]!
bne 2b
3: cbnz REST, 4f
/* fix up dest pointer if pitch != width */
7: add DST, PITCH
/* fix up src pointer at end of line */
subs TLINE, #1
itee ne
addne SRC, NEXTLIN
subeq SRC, #992
moveq TLINE, #32
subs HEIGHT, #1
bne 1b
pop {r4, r5, r6, r7, r8, pc}
/* partly copy last tile of line */
4: mov TMPSRC, SRC
tst REST, #16
beq 5f
vld1.8 {d0 - d1}, [TMPSRC :128]!
vst1.8 {d0 - d1}, [DST]!
5: add SRC, TSIZE
ands CNT, REST, #15
beq 7b
6: vld1.8 {d0[0]}, [TMPSRC]!
subs CNT, #1
vst1.8 {d0[0]}, [DST]!
bne 6b
b 7b
end_function tiled_to_planar
thumb_function tiled_deinterleave_to_planar
push {r4, r5, r6, r7, r8, r9, lr}
mov DST2, r2
ldr HEIGHT, [sp, #32]
ldr r4, [sp, #28]
add NEXTLIN, r4, #31
lsrs NTILES, r4, #5
bic NEXTLIN, NEXTLIN, #31
ubfx REST, r4, #1, #4
lsl NEXTLIN, NEXTLIN, #5
sub PITCH, r3, r4, lsr #1
movs TLINE, #32
rsb NEXTLIN, NEXTLIN, #32
mov TSIZE, #1024
/* y loop */
1: cbz NTILES, 3f
mov CNT, NTILES
/* x loop complete tiles */
2: pld [SRC, TSIZE]
vld2.8 {d0 - d3}, [SRC :256], TSIZE
subs CNT, #1
vst1.8 {d0 - d1}, [DST]!
vst1.8 {d2 - d3}, [DST2]!
bne 2b
3: cbnz REST, 4f
/* fix up dest pointer if pitch != width */
7: add DST, PITCH
add DST2, PITCH
/* fix up src pointer at end of line */
subs TLINE, #1
itee ne
addne SRC, NEXTLIN
subeq SRC, #992
moveq TLINE, #32
subs HEIGHT, #1
bne 1b
pop {r4, r5, r6, r7, r8, r9, pc}
/* partly copy last tile of line */
4: mov TMPSRC, SRC
tst REST, #8
beq 5f
vld2.8 {d0 - d1}, [TMPSRC :128]!
vst1.8 {d0}, [DST]!
vst1.8 {d1}, [DST2]!
5: add SRC, TSIZE
ands CNT, REST, #7
beq 7b
6: vld2.8 {d0[0], d1[0]}, [TMPSRC]!
subs CNT, #1
vst1.8 {d0[0]}, [DST]!
vst1.8 {d1[0]}, [DST2]!
bne 6b
b 7b
end_function tiled_deinterleave_to_planar
#endif