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
340
341
342
343
344
345
346
347
348
349
350
351
352
353
|
//******************************************************************************
//*
//* Copyright (C) 2015 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.
//*
//*****************************************************************************
//* Originally developed and contributed by Ittiam Systems Pvt. Ltd, Bangalore
//*/
///**
//******************************************************************************
//* @file
//* ih264_default_weighted_pred_av8.s
//*
//* @brief
//* Contains function definitions for default weighted prediction.
//* Functions are coded using NEON intrinsics and can be compiled using ARM RVCT
//*
//* @author
//* Kaushik Senthoor R
//*
//* @par List of Functions:
//*
//* - ih264_default_weighted_pred_luma_av8()
//* - ih264_default_weighted_pred_chroma_av8()
//*
//* @remarks
//* None
//*
//*******************************************************************************
//*/
//*******************************************************************************
//* @function
//* ih264_default_weighted_pred_luma_av8()
//*
//* @brief
//* This routine performs the default weighted prediction as described in sec
//* 8.4.2.3.1 titled "Default weighted sample prediction process" for luma.
//*
//* @par Description:
//* This function gets two ht x wd blocks, calculates their rounded-average and
//* stores it in the destination block.
//*
//* @param[in] puc_src1:
//* UWORD8 Pointer to the buffer containing the first input block.
//*
//* @param[in] puc_src2:
//* UWORD8 Pointer to the buffer containing the second input block.
//*
//* @param[out] puc_dst
//* UWORD8 pointer to the destination where the output block is stored.
//*
//* @param[in] src_strd1
//* Stride of the first input buffer
//*
//* @param[in] src_strd2
//* Stride of the second input buffer
//*
//* @param[in] dst_strd
//* Stride of the destination buffer
//*
//* @param[in] ht
//* integer height of the array
//*
//* @param[in] wd
//* integer width of the array
//*
//* @returns
//* None
//*
//* @remarks
//* (ht,wd) can be (4,4), (4,8), (8,4), (8,8), (8,16), (16,8) or (16,16).
//*
//*******************************************************************************
//*/
//void ih264_default_weighted_pred_luma_av8(UWORD8 *puc_src1,
// UWORD8 *puc_src2,
// UWORD8 *puc_dst,
// WORD32 src_strd1,
// WORD32 src_strd2,
// WORD32 dst_strd,
// UWORD8 ht,
// UWORD8 wd)
//
//**************Variables Vs Registers*****************************************
// x0 => puc_src1
// x1 => puc_src2
// x2 => puc_dst
// x3 => src_strd1
// [sp] => src_strd2 (x4)
// [sp+4] => dst_strd (x5)
// [sp+8] => ht (x6)
// [sp+12] => wd (x7)
//
.text
.p2align 2
.include "ih264_neon_macros.s"
.global ih264_default_weighted_pred_luma_av8
ih264_default_weighted_pred_luma_av8:
push_v_regs
stp x19, x20, [sp, #-16]!
cmp w7, #16
beq loop_16 //branch if wd is 16
cmp w7, #8
beq loop_8 //branch if wd is 8
loop_4: //each iteration processes four rows
ld1 {v0.s}[0], [x0], x3 //load row 1 in source 1
ld1 {v0.s}[1], [x0], x3 //load row 2 in source 1
ld1 {v2.s}[0], [x1], x4 //load row 1 in source 2
ld1 {v2.s}[1], [x1], x4 //load row 2 in source 2
ld1 {v1.s}[0], [x0], x3 //load row 3 in source 1
ld1 {v1.s}[1], [x0], x3 //load row 4 in source 1
urhadd v0.8b, v0.8b , v2.8b
ld1 {v3.s}[0], [x1], x4 //load row 3 in source 2
ld1 {v3.s}[1], [x1], x4 //load row 4 in source 2
subs w6, w6, #4 //decrement ht by 4
st1 {v0.s}[0], [x2], x5 //load row 1 in destination
st1 {v0.s}[1], [x2], x5 //load row 2 in destination
urhadd v1.8b, v1.8b , v3.8b
st1 {v1.s}[0], [x2], x5 //load row 3 in destination
st1 {v1.s}[1], [x2], x5 //load row 4 in destination
bgt loop_4 //if greater than 0 repeat the loop again
b end_loops
loop_8: //each iteration processes four rows
ld1 {v0.8b}, [x0], x3 //load row 1 in source 1
ld1 {v4.8b}, [x1], x4 //load row 1 in source 2
ld1 {v1.8b}, [x0], x3 //load row 2 in source 1
ld1 {v5.8b}, [x1], x4 //load row 2 in source 2
ld1 {v2.8b}, [x0], x3 //load row 3 in source 1
urhadd v0.16b, v0.16b , v4.16b
urhadd v1.16b, v1.16b , v5.16b
ld1 {v6.8b}, [x1], x4 //load row 3 in source 2
ld1 {v3.8b}, [x0], x3 //load row 4 in source 1
urhadd v2.8b, v2.8b , v6.8b
ld1 {v7.8b}, [x1], x4 //load row 4 in source 2
subs w6, w6, #4 //decrement ht by 4
st1 {v0.8b}, [x2], x5 //load row 1 in destination
urhadd v3.8b, v3.8b , v7.8b
st1 {v1.8b}, [x2], x5 //load row 2 in destination
st1 {v2.8b}, [x2], x5 //load row 3 in destination
st1 {v3.8b}, [x2], x5 //load row 4 in destination
bgt loop_8 //if greater than 0 repeat the loop again
b end_loops
loop_16: //each iteration processes eight rows
ld1 {v0.8b, v1.8b}, [x0], x3 //load row 1 in source 1
ld1 {v16.8b, v17.8b}, [x1], x4 //load row 1 in source 2
ld1 {v2.8b, v3.8b}, [x0], x3 //load row 2 in source 1
ld1 {v18.8b, v19.8b}, [x1], x4 //load row 2 in source 2
urhadd v0.16b, v0.16b , v16.16b
urhadd v1.16b, v1.16b , v17.16b
ld1 {v4.8b, v5.8b}, [x0], x3 //load row 3 in source 1
ld1 {v20.8b, v21.8b}, [x1], x4 //load row 3 in source 2
urhadd v2.16b, v2.16b , v18.16b
urhadd v3.16b, v3.16b , v19.16b
ld1 {v6.8b, v7.8b}, [x0], x3 //load row 4 in source 1
ld1 {v22.8b, v23.8b}, [x1], x4 //load row 4 in source 2
urhadd v4.16b, v4.16b , v20.16b
urhadd v5.16b, v5.16b , v21.16b
ld1 {v8.8b, v9.8b}, [x0], x3 //load row 5 in source 1
ld1 {v24.8b, v25.8b}, [x1], x4 //load row 5 in source 2
urhadd v6.16b, v6.16b , v22.16b
urhadd v7.16b, v7.16b , v23.16b
ld1 {v10.8b, v11.8b}, [x0], x3 //load row 6 in source 1
ld1 {v26.8b, v27.8b}, [x1], x4 //load row 6 in source 2
urhadd v8.16b, v8.16b , v24.16b
urhadd v9.16b, v9.16b , v25.16b
ld1 {v12.8b, v13.8b}, [x0], x3 //load row 7 in source 1
ld1 {v28.8b, v29.8b}, [x1], x4 //load row 7 in source 2
urhadd v10.16b, v10.16b , v26.16b
urhadd v11.16b, v11.16b , v27.16b
ld1 {v14.8b, v15.8b}, [x0], x3 //load row 8 in source 1
ld1 {v30.8b, v31.8b}, [x1], x4 //load row 8 in source 2
urhadd v12.16b, v12.16b , v28.16b
urhadd v13.16b, v13.16b , v29.16b
st1 {v0.8b, v1.8b}, [x2], x5 //load row 1 in destination
st1 {v2.8b, v3.8b}, [x2], x5 //load row 2 in destination
urhadd v14.16b, v14.16b , v30.16b
urhadd v15.16b, v15.16b , v31.16b
st1 {v4.8b, v5.8b}, [x2], x5 //load row 3 in destination
st1 {v6.8b, v7.8b}, [x2], x5 //load row 4 in destination
subs w6, w6, #8 //decrement ht by 8
st1 {v8.8b, v9.8b}, [x2], x5 //load row 5 in destination
st1 {v10.8b, v11.8b}, [x2], x5 //load row 6 in destination
st1 {v12.8b, v13.8b}, [x2], x5 //load row 7 in destination
st1 {v14.8b, v15.8b}, [x2], x5 //load row 8 in destination
bgt loop_16 //if greater than 0 repeat the loop again
end_loops:
// LDMFD sp!,{x4-x7,x15} //Reload the registers from sp
ldp x19, x20, [sp], #16
pop_v_regs
ret
//*******************************************************************************
//* @function
//* ih264_default_weighted_pred_chroma_av8()
//*
//* @brief
//* This routine performs the default weighted prediction as described in sec
//* 8.4.2.3.1 titled "Default weighted sample prediction process" for chroma.
//*
//* @par Description:
//* This function gets two ht x wd blocks, calculates their rounded-average and
//* stores it in the destination block for U and V.
//*
//* @param[in] puc_src1:
//* UWORD8 Pointer to the buffer containing the first input block.
//*
//* @param[in] puc_src2:
//* UWORD8 Pointer to the buffer containing the second input block.
//*
//* @param[out] puc_dst
//* UWORD8 pointer to the destination where the output block is stored.
//*
//* @param[in] src_strd1
//* Stride of the first input buffer
//*
//* @param[in] src_strd2
//* Stride of the second input buffer
//*
//* @param[in] dst_strd
//* Stride of the destination buffer
//*
//* @param[in] ht
//* integer height of the array
//*
//* @param[in] wd
//* integer width of the array
//*
//* @returns
//* None
//*
//* @remarks
//* (ht,wd) can be (2,2), (2,4), (4,2), (4,4), (4,8), (8,4) or (8,8).
//*
//*******************************************************************************
//*/
//void ih264_default_weighted_pred_chroma_av8(UWORD8 *puc_src1,
// UWORD8 *puc_src2,
// UWORD8 *puc_dst,
// WORD32 src_strd1,
// WORD32 src_strd2,
// WORD32 dst_strd,
// UWORD8 ht,
// UWORD8 wd)
//
//**************Variables Vs Registers*****************************************
// x0 => puc_src1
// x1 => puc_src2
// x2 => puc_dst
// x3 => src_strd1
// [sp] => src_strd2 (x4)
// [sp+4] => dst_strd (x5)
// [sp+8] => ht (x6)
// [sp+12] => wd (x7)
//
.global ih264_default_weighted_pred_chroma_av8
ih264_default_weighted_pred_chroma_av8:
push_v_regs
stp x19, x20, [sp, #-16]!
cmp w7, #8
beq loop_8_uv //branch if wd is 8
cmp w7, #4
beq loop_4_uv //branch if wd is 4
loop_2_uv: //each iteration processes two rows
ld1 {v0.s}[0], [x0], x3 //load row 1 in source 1
ld1 {v0.s}[1], [x0], x3 //load row 2 in source 1
ld1 {v1.s}[0], [x1], x4 //load row 1 in source 2
ld1 {v1.s}[1], [x1], x4 //load row 2 in source 2
urhadd v0.8b, v0.8b , v1.8b
subs w6, w6, #2 //decrement ht by 2
st1 {v0.s}[0], [x2], x5 //load row 1 in destination
st1 {v0.s}[1], [x2], x5 //load row 2 in destination
bgt loop_2_uv //if greater than 0 repeat the loop again
b end_loops_uv
loop_4_uv: //each iteration processes two rows
ld1 {v0.8b}, [x0], x3 //load row 1 in source 1
ld1 {v2.8b}, [x1], x4 //load row 1 in source 2
ld1 {v1.8b}, [x0], x3 //load row 2 in source 1
urhadd v0.8b, v0.8b , v2.8b
ld1 {v3.8b}, [x1], x4 //load row 2 in source 2
urhadd v1.8b, v1.8b , v3.8b
st1 {v0.8b}, [x2], x5 //load row 1 in destination
subs w6, w6, #2 //decrement ht by 2
st1 {v1.8b}, [x2], x5 //load row 2 in destination
bgt loop_4_uv //if greater than 0 repeat the loop again
b end_loops_uv
loop_8_uv: //each iteration processes four rows
ld1 {v0.8b, v1.8b}, [x0], x3 //load row 1 in source 1
ld1 {v8.8b, v9.8b}, [x1], x4 //load row 1 in source 2
ld1 {v2.8b, v3.8b}, [x0], x3 //load row 2 in source 1
urhadd v0.16b, v0.16b , v8.16b
urhadd v1.16b, v1.16b , v9.16b
ld1 {v10.8b, v11.8b}, [x1], x4 //load row 2 in source 2
ld1 {v4.8b, v5.8b}, [x0], x3 //load row 3 in source 1
urhadd v2.16b, v2.16b , v10.16b
urhadd v3.16b, v3.16b , v11.16b
ld1 {v12.8b, v13.8b}, [x1], x4 //load row 3 in source 2
ld1 {v6.8b, v7.8b}, [x0], x3 //load row 4 in source 1
urhadd v4.16b, v4.16b , v12.16b
urhadd v5.16b, v5.16b , v13.16b
ld1 {v14.8b, v15.8b}, [x1], x4 //load row 4 in source 2
st1 {v0.8b, v1.8b}, [x2], x5 //load row 1 in destination
urhadd v6.16b, v6.16b , v14.16b
urhadd v7.16b, v7.16b , v15.16b
st1 {v2.8b, v3.8b}, [x2], x5 //load row 2 in destination
subs w6, w6, #4 //decrement ht by 4
st1 {v4.8b, v5.8b}, [x2], x5 //load row 3 in destination
st1 {v6.8b, v7.8b}, [x2], x5 //load row 4 in destination
bgt loop_8_uv //if greater than 0 repeat the loop again
end_loops_uv:
ldp x19, x20, [sp], #16
pop_v_regs
ret
|