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
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
|
; Copyright (C) 2009 The Android Open Source Project
;
; Licensed under the Apache License, Version 2.0 (the "License");
; you may not use this file except in compliance with the License.
; You may obtain a copy of the License at
;
; http://www.apache.org/licenses/LICENSE-2.0
;
; Unless required by applicable law or agreed to in writing, software
; distributed under the License is distributed on an "AS IS" BASIS,
; WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
; See the License for the specific language governing permissions and
; limitations under the License.
;-------------------------------------------------------------------------------
;--
;-- Abstract : ARMv6 optimized version of h264bsdInterpolateChromaHorVer
;-- function
;--
;-------------------------------------------------------------------------------
IF :DEF: H264DEC_WINASM
;// We dont use REQUIRE8 and PRESERVE8 for winasm
ELSE
REQUIRE8
PRESERVE8
ENDIF
AREA |.text|, CODE
;// h264bsdInterpolateChromaHorVer register allocation
ref RN 0
ptrA RN 0
mb RN 1
block RN 1
x0 RN 2
count RN 2
y0 RN 3
valY RN 3
width RN 4
tmp4 RN 5
height RN 5
tmp1 RN 6
tmp2 RN 7
tmp3 RN 8
valX RN 9
tmp5 RN 10
chrPW RN 10
tmp6 RN 11
chrPH RN 11
xFrac RN 12
c32 RN 14
yFrac RN 14
;// function exports and imports
IMPORT h264bsdFillBlock
EXPORT h264bsdInterpolateChromaHorVer
;// Function arguments
;//
;// u8 *ref, : 0xc4
;// u8 *predPartChroma, : 0xc8
;// i32 x0, : 0xcc
;// i32 y0, : 0xd0
;// u32 width, : 0xf8
;// u32 height, : 0xfc
;// u32 xFrac, : 0x100
;// u32 yFrac, : 0x104
;// u32 chromaPartWidth, : 0x108
;// u32 chromaPartHeight : 0x10c
h264bsdInterpolateChromaHorVer
STMFD sp!, {r0-r11,lr}
SUB sp, sp, #0xc4
LDR chrPW, [sp, #0x108] ;// chromaPartWidth
LDR xFrac, [sp, #0x100] ;// xFrac
LDR width, [sp, #0xf8] ;// width
CMP x0, #0
BLT do_fill
ADD tmp1, x0, chrPW ;// tmp1 = x0+ chromaPartWidth
ADD tmp1, tmp1, #1 ;// tmp1 = x0+ chromaPartWidth+1
CMP tmp1, width ;// x0+chromaPartWidth+1 > width
BHI do_fill
CMP y0, #0
BLT do_fill
LDR chrPH, [sp, #0x10c] ;// chromaPartHeight
LDR height, [sp, #0xfc] ;// height
ADD tmp1, y0, chrPH ;// tmp1 = y0 + chromaPartHeight
ADD tmp1, tmp1, #1 ;// tmp1 = y0 + chromaPartHeight + 1
CMP tmp1, height
BLS skip_fill
do_fill
LDR chrPH, [sp, #0x10c] ;// chromaPartHeight
LDR height, [sp, #0xfc] ;// height
ADD tmp3, chrPW, #1 ;// tmp3 = chromaPartWidth+1
ADD tmp1, chrPW, #1 ;// tmp1 = chromaPartWidth+1
ADD tmp2, chrPH, #1 ;// tmp2 = chromaPartHeight+1
STMIA sp,{width,height,tmp1,tmp2,tmp3}
ADD block, sp, #0x1c ;// block
BL h264bsdFillBlock
LDR x0, [sp, #0xcc]
LDR y0, [sp, #0xd0]
LDR ref, [sp, #0xc4] ;// ref
STMIA sp,{width,height,tmp1,tmp2,tmp3}
ADD block, sp, #0x1c ;// block
MLA ref, height, width, ref ;// ref += width * height;
MLA block, tmp2, tmp1, block;// block + (chromaPW+1)*(chromaPH+1)
BL h264bsdFillBlock
MOV x0, #0 ;// x0 = 0
MOV y0, #0 ;// y0 = 0
STR x0, [sp, #0xcc]
STR y0, [sp, #0xd0]
ADD ref, sp, #0x1c ;// ref = block
STR ref, [sp, #0xc4] ;// ref
STR tmp2, [sp, #0xfc] ;// height
STR tmp1, [sp, #0xf8] ;// width
MOV width, tmp1
skip_fill
MLA tmp3, y0, width, x0 ;// tmp3 = y0*width+x0
LDR yFrac, [sp, #0x104] ;// yFrac
LDR xFrac, [sp, #0x100]
ADD ptrA, ref, tmp3 ;// ptrA = ref + y0*width+x0
RSB valX, xFrac, #8 ;// valX = 8-xFrac
RSB valY, yFrac, #8 ;// valY = 8-yFrac
LDR mb, [sp, #0xc8] ;// predPartChroma
;// pack values to count register
;// [31:28] loop_x (chromaPartWidth-1)
;// [27:24] loop_y (chromaPartHeight-1)
;// [23:20] chromaPartWidth-1
;// [19:16] chromaPartHeight-1
;// [15:00] nothing
SUB tmp2, chrPH, #1 ;// chromaPartHeight-1
SUB tmp1, chrPW, #1 ;// chromaPartWidth-1
ADD count, count, tmp2, LSL #16 ;// chromaPartHeight-1
ADD count, count, tmp2, LSL #24 ;// loop_y
ADD count, count, tmp1, LSL #20 ;// chromaPartWidth-1
AND tmp2, count, #0x00F00000 ;// loop_x
PKHBT valY, valY, yFrac, LSL #16 ;// |yFrac|valY |
MOV c32, #32
;///////////////////////////////////////////////////////////////////////////
;// Cb
;///////////////////////////////////////////////////////////////////////////
;// 2x2 pels per iteration
;// bilinear vertical and horizontal interpolation
loop1_y
LDRB tmp1, [ptrA]
LDRB tmp3, [ptrA, width]
LDRB tmp5, [ptrA, width, LSL #1]
PKHBT tmp1, tmp1, tmp3, LSL #16 ;// |t3|t1|
PKHBT tmp3, tmp3, tmp5, LSL #16 ;// |t5|t3|
SMUAD tmp1, tmp1, valY ;// t1=(t1*valY + t3*yFrac)
SMUAD tmp3, tmp3, valY ;// t3=(t3*valY + t5*yFrac)
ADD count, count, tmp2, LSL #8
loop1_x
;// first
LDRB tmp2, [ptrA, #1]!
LDRB tmp4, [ptrA, width]
LDRB tmp6, [ptrA, width, LSL #1]
PKHBT tmp2, tmp2, tmp4, LSL #16 ;// |t4|t2|
PKHBT tmp4, tmp4, tmp6, LSL #16 ;// |t6|t4|
SMUAD tmp2, tmp2, valY ;// t2=(t2*valY + t4*yFrac)
MLA tmp5, tmp1, valX, c32 ;// t5=t1*valX+32
MLA tmp5, tmp2, xFrac, tmp5 ;// t5=t2*xFrac+t5
SMUAD tmp4, tmp4, valY ;// t4=(t4*valY + t6*yFrac)
MLA tmp6, tmp3, valX, c32 ;// t3=t3*valX+32
MLA tmp6, tmp4, xFrac, tmp6 ;// t6=t4*xFrac+t6
MOV tmp6, tmp6, LSR #6 ;// scale down
STRB tmp6, [mb, #8] ;// store pixel
MOV tmp5, tmp5, LSR #6 ;// scale down
STRB tmp5, [mb], #1 ;// store pixel
;// second
LDRB tmp1, [ptrA, #1]!
LDRB tmp3, [ptrA, width]
LDRB tmp5, [ptrA, width, LSL #1]
PKHBT tmp1, tmp1, tmp3, LSL #16 ;// |t3|t1|
PKHBT tmp3, tmp3, tmp5, LSL #16 ;// |t5|t3|
SMUAD tmp1, tmp1, valY ;// t1=(t1*valY + t3*yFrac)
MLA tmp5, tmp1, xFrac, c32 ;// t1=t1*xFrac+32
MLA tmp5, tmp2, valX, tmp5 ;// t5=t2*valX+t5
SMUAD tmp3, tmp3, valY ;// t3=(t3*valY + t5*yFrac)
MLA tmp6, tmp3, xFrac, c32 ;// t3=t3*xFrac+32
MLA tmp6, tmp4, valX, tmp6 ;// t6=t4*valX+t6
MOV tmp6, tmp6, LSR #6 ;// scale down
STRB tmp6, [mb, #8] ;// store pixel
MOV tmp5, tmp5, LSR #6 ;// scale down
STRB tmp5, [mb], #1 ;// store pixel
SUBS count, count, #2<<28
BCS loop1_x
AND tmp2, count, #0x00F00000
ADDS mb, mb, #16
SBC mb, mb, tmp2, LSR #20
ADD ptrA, ptrA, width, LSL #1
SBC ptrA, ptrA, tmp2, LSR #20
ADDS count, count, #0xE << 24
BGE loop1_y
;///////////////////////////////////////////////////////////////////////////
;// Cr
;///////////////////////////////////////////////////////////////////////////
LDR height, [sp,#0xfc] ;// height
LDR ref, [sp, #0xc4] ;// ref
LDR tmp1, [sp, #0xd0] ;// y0
LDR tmp2, [sp, #0xcc] ;// x0
LDR mb, [sp, #0xc8] ;// predPartChroma
ADD tmp1, height, tmp1
MLA tmp3, tmp1, width, tmp2
ADD ptrA, ref, tmp3
ADD mb, mb, #64
AND count, count, #0x00FFFFFF
AND tmp1, count, #0x000F0000
ADD count, count, tmp1, LSL #8
AND tmp2, count, #0x00F00000
;// 2x2 pels per iteration
;// bilinear vertical and horizontal interpolation
loop2_y
LDRB tmp1, [ptrA]
LDRB tmp3, [ptrA, width]
LDRB tmp5, [ptrA, width, LSL #1]
PKHBT tmp1, tmp1, tmp3, LSL #16 ;// |t3|t1|
PKHBT tmp3, tmp3, tmp5, LSL #16 ;// |t5|t3|
SMUAD tmp1, tmp1, valY ;// t1=(t1*valY + t3*yFrac)
SMUAD tmp3, tmp3, valY ;// t3=(t3*valY + t5*yFrac)
ADD count, count, tmp2, LSL #8
loop2_x
;// first
LDRB tmp2, [ptrA, #1]!
LDRB tmp4, [ptrA, width]
LDRB tmp6, [ptrA, width, LSL #1]
PKHBT tmp2, tmp2, tmp4, LSL #16 ;// |t4|t2|
PKHBT tmp4, tmp4, tmp6, LSL #16 ;// |t6|t4|
SMUAD tmp2, tmp2, valY ;// t2=(t2*valY + t4*yFrac)
MLA tmp5, tmp1, valX, c32 ;// t5=t1*valX+32
MLA tmp5, tmp2, xFrac, tmp5 ;// t5=t2*xFrac+t5
SMUAD tmp4, tmp4, valY ;// t4=(t4*valY + t6*yFrac)
MLA tmp6, tmp3, valX, c32 ;// t3=t3*valX+32
MLA tmp6, tmp4, xFrac, tmp6 ;// t6=t4*xFrac+t6
MOV tmp6, tmp6, LSR #6 ;// scale down
STRB tmp6, [mb, #8] ;// store pixel
MOV tmp5, tmp5, LSR #6 ;// scale down
STRB tmp5, [mb], #1 ;// store pixel
;// second
LDRB tmp1, [ptrA, #1]!
LDRB tmp3, [ptrA, width]
LDRB tmp5, [ptrA, width, LSL #1]
PKHBT tmp1, tmp1, tmp3, LSL #16 ;// |t3|t1|
PKHBT tmp3, tmp3, tmp5, LSL #16 ;// |t5|t3|
SMUAD tmp1, tmp1, valY ;// t1=(t1*valY + t3*yFrac)
MLA tmp5, tmp1, xFrac, c32 ;// t1=t1*xFrac+32
MLA tmp5, tmp2, valX, tmp5 ;// t5=t2*valX+t5
SMUAD tmp3, tmp3, valY ;// t3=(t3*valY + t5*yFrac)
MLA tmp6, tmp3, xFrac, c32 ;// t3=t3*xFrac+32
MLA tmp6, tmp4, valX, tmp6 ;// t6=t4*valX+t6
MOV tmp6, tmp6, LSR #6 ;// scale down
STRB tmp6, [mb, #8] ;// store pixel
MOV tmp5, tmp5, LSR #6 ;// scale down
STRB tmp5, [mb], #1 ;// store pixel
SUBS count, count, #2<<28
BCS loop2_x
AND tmp2, count, #0x00F00000
ADDS mb, mb, #16
SBC mb, mb, tmp2, LSR #20
ADD ptrA, ptrA, width, LSL #1
SBC ptrA, ptrA, tmp2, LSR #20
ADDS count, count, #0xE << 24
BGE loop2_y
ADD sp,sp,#0xd4
LDMFD sp!,{r4-r11,pc}
END
|