summaryrefslogtreecommitdiffstats
path: root/common/arm64/ihevc_inter_pred_chroma_vert_w16inp.s
blob: e6cc617924cba47fc0ad6b9744046086e83fcf18 (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
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
354
355
356
///*****************************************************************************
//*
//* Copyright (C) 2012 Ittiam Systems Pvt Ltd, Bangalore
//*
//* 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.
//*
//*****************************************************************************/
///**
//*******************************************************************************
//* //file
//*  ihevc_inter_pred_chroma_vert_neon_w16inp_neon.s
//*
//* //brief
//*  contains function definitions for inter prediction  interpolation.
//* functions are coded using neon  intrinsics and can be compiled using

//* rvct
//*
//* //author
//*  yogeswaran rs / parthiban
//*
//* //par list of functions:
//*
//*
//* //remarks
//*  none
//*
//*******************************************************************************
//*/
///**
///**
//*******************************************************************************
//*
//* //brief
//*       chroma interprediction filter for 16bit vertical input.
//*
//* //par description:
//*    applies a vertical filter with coefficients pointed to  by 'pi1_coeff' to
//*    the elements pointed by 'pu1_src' and  writes to the location pointed by
//*    'pu1_dst'  input is 16 bits  the filter output is downshifted by 12 and
//*    clipped to lie  between 0 and 255   assumptions : the function is
//*    optimized considering the fact width and  height are multiple of 2.
//*
//* //param[in] pi2_src
//*  word16 pointer to the source
//*
//* //param[out] pu1_dst
//*  uword8 pointer to the destination
//*
//* //param[in] src_strd
//*  integer source stride
//*
//* //param[in] dst_strd
//*  integer destination stride
//*
//* //param[in] pi1_coeff
//*  word8 pointer to the filter coefficients
//*
//* //param[in] ht
//*  integer height of the array
//*
//* //param[in] wd
//*  integer width of the array
//*
//* //returns
//*
//* //remarks
//*  none
//*
//*******************************************************************************
//*/
//void ihevc_inter_pred_chroma_vert_w16inp(word16 *pi2_src,
//                                          uword8 *pu1_dst,
//                                          word32 src_strd,
//                                          word32 dst_strd,
//                                          word8 *pi1_coeff,
//                                          word32 ht,
//                                          word32 wd)
//**************variables vs registers*****************************************
//x0 => *pu1_src
//x1 => *pi2_dst
//x2 =>  src_strd
//x3 =>  dst_strd

.text
.align 4

.include "ihevc_neon_macros.s"

.globl ihevc_inter_pred_chroma_vert_w16inp_av8

.type ihevc_inter_pred_chroma_vert_w16inp_av8, %function

ihevc_inter_pred_chroma_vert_w16inp_av8:

    // stmfd sp!, {x4-x12, x14}                    //stack stores the values of the arguments

    stp         x19, x20,[sp,#-16]!

    mov         x15,x4 // pi1_coeff
    mov         x16,x5 // ht
    mov         x17,x6 // wd

    mov         x4, x15                     //loads pi1_coeff
    mov         x6, x17                     //wd
    lsl         x2,x2,#1                    //src_strd = 2* src_strd
    mov         x5,x16                      //loads ht
    ld1         {v0.8b},[x4]                //loads pi1_coeff
    sub         x4,x0,x2                    //pu1_src - src_strd
    sxtl        v0.8h, v0.8b                //long the value

    tst         x6,#3                       //checks wd  == 2
    dup         v16.4h, v0.h[0]             //coeff_0
    dup         v17.4h, v0.h[1]             //coeff_1
    dup         v18.4h, v0.h[2]             //coeff_2
    dup         v19.4h, v0.h[3]             //coeff_3

    bgt         core_loop_ht_2              //jumps to loop handles wd 2

    tst         x5,#3                       //checks ht == mul of 4
    beq         core_loop_ht_4              //jumps to loop handles ht mul of 4

core_loop_ht_2:
    lsl         x7,x2,#1                    //2*src_strd
    lsl         x12,x3,#1                   //2*dst_strd
    lsl         x9,x6,#2                    //4*wd
    sub         x6,x12,x6,lsl #1            //2*dst_strd - 2*wd
    sub         x8,x7,x9                    //2*src_strd - 4*wd
    mov         x12,x9                      //4wd

inner_loop_ht_2:
    add         x0,x4,x2                    //increments pi2_src
    ld1         {v0.4h},[x4],#8             //loads pu1_src
    smull       v0.4s, v0.4h, v16.4h        //vmull_s16(src_tmp1, coeff_0)
    subs        x12,x12,#8                  //2wd + 8
    ld1         {v2.4h},[x0],x2             //loads pi2_src
    smull       v7.4s, v2.4h, v16.4h        //vmull_s16(src_tmp2, coeff_0)
    ld1         {v3.4h},[x0],x2             //loads pi2_src
    smlal       v0.4s, v2.4h, v17.4h
    ld1         {v6.4h},[x0],x2
    smlal       v7.4s, v3.4h, v17.4h
    ld1         {v2.4h},[x0]
    add         x7,x1,x3                    //pu1_dst + dst_strd
    smlal       v0.4s, v3.4h, v18.4h
    smlal       v7.4s, v6.4h, v18.4h
    smlal       v0.4s, v6.4h, v19.4h
    smlal       v7.4s, v2.4h, v19.4h
    sqshrn      v0.4h, v0.4s,#6             //right shift
    sqshrn      v30.4h, v7.4s,#6            //right shift
    sqrshrun    v0.8b, v0.8h,#6             //rounding shift
    sqrshrun    v30.8b, v30.8h,#6           //rounding shift
    st1         {v0.s}[0],[x1],#4           //stores the loaded value
    st1         {v30.s}[0],[x7]             //stores the loaded value
    bgt         inner_loop_ht_2             //inner loop -again

    //inner loop ends
    subs        x5,x5,#2                    //increments ht
    add         x1,x1,x6                    //pu1_dst += 2*dst_strd - 2*wd
    mov         x12,x9                      //4wd
    add         x4,x4,x8                    //pi1_src_tmp1 += 2*src_strd - 4*wd
    bgt         inner_loop_ht_2             //loop again

    b           end_loops                   //jumps to end

core_loop_ht_4:
    lsl         x7,x2,#2                    //2*src_strd
    lsl         x12,x3,#2                   //2*dst_strd
    lsr         x11, x6, #1                 //divide by 2
    sub         x14,x12,x6,lsl #1           //2*dst_strd - 2*wd
    sub         x8,x7,x6,lsl #2             //2*src_strd - 4*wd

    mul         x12, x5 , x11               //multiply height by width
    sub         x12, x12,#4                 //subtract by one for epilog
    lsl         x11, x6, #1                 //2*wd

prolog:
    add         x0,x4,x2                    //increments pi2_src
    ld1         {v0.4h},[x4],#8             //loads pu1_src
    ld1         {v1.4h},[x0],x2             //loads pi2_src
    subs        x11,x11,#4
    ld1         {v2.4h},[x0],x2             //loads pi2_src
    smull       v30.4s, v0.4h, v16.4h       //vmull_s16(src_tmp1, coeff_0)
    ld1         {v3.4h},[x0],x2
    smlal       v30.4s, v1.4h, v17.4h
    smlal       v30.4s, v2.4h, v18.4h
    add         x9,x1,x3                    //pu1_dst + dst_strd
    smlal       v30.4s, v3.4h, v19.4h

    ld1         {v4.4h},[x0],x2
    smull       v28.4s, v1.4h, v16.4h       //vmull_s16(src_tmp2, coeff_0)
    add         x20,x4,x8
    csel        x4, x20, x4,le
    smlal       v28.4s, v2.4h, v17.4h
    ld1         {v5.4h},[x0],x2
    smlal       v28.4s, v3.4h, v18.4h
    ld1         {v6.4h},[x0],x2
    smlal       v28.4s, v4.4h, v19.4h
    lsl         x20,x6,#1
    csel        x11, x20, x11,le

    sqshrn      v30.4h, v30.4s,#6           //right shift

    smull       v26.4s, v2.4h, v16.4h       //vmull_s16(src_tmp2, coeff_0)
    add         x0,x4,x2
    smlal       v26.4s, v3.4h, v17.4h
    smlal       v26.4s, v4.4h, v18.4h
    ld1         {v0.4h},[x4],#8             //loads pu1_src
    smlal       v26.4s, v5.4h, v19.4h

    sqrshrun    v30.8b, v30.8h,#6           //rounding shift
    sqshrn      v28.4h, v28.4s,#6           //right shift

    ld1         {v1.4h},[x0],x2             //loads pi2_src
    smull       v24.4s, v3.4h, v16.4h       //vmull_s16(src_tmp2, coeff_0)
    st1         {v30.s}[0],[x1],#4          //stores the loaded value
    smlal       v24.4s, v4.4h, v17.4h
    ld1         {v2.4h},[x0],x2             //loads pi2_src
    smlal       v24.4s, v5.4h, v18.4h
    ld1         {v3.4h},[x0],x2
    smlal       v24.4s, v6.4h, v19.4h
    add         x20,x1,x14
    csel        x1, x20, x1,le

    sqshrn      v26.4h, v26.4s,#6           //right shift
    subs        x12,x12,#4
    sqrshrun    v28.8b, v28.8h,#6           //rounding shift

    beq         epilog                      //jumps to epilog

kernel_4:
    smull       v30.4s, v0.4h, v16.4h       //vmull_s16(src_tmp1, coeff_0)
    subs        x11,x11,#4
    smlal       v30.4s, v1.4h, v17.4h
    st1         {v28.s}[0],[x9],x3          //stores the loaded value
    smlal       v30.4s, v2.4h, v18.4h
    smlal       v30.4s, v3.4h, v19.4h

    sqshrn      v24.4h, v24.4s,#6           //right shift
    sqrshrun    v26.8b, v26.8h,#6           //rounding shift

    ld1         {v4.4h},[x0],x2
    smull       v28.4s, v1.4h, v16.4h       //vmull_s16(src_tmp2, coeff_0)
    smlal       v28.4s, v2.4h, v17.4h
    smlal       v28.4s, v3.4h, v18.4h
    smlal       v28.4s, v4.4h, v19.4h
    st1         {v26.s}[0],[x9],x3          //stores the loaded value
    add         x20,x4,x8
    csel        x4, x20, x4,le
    lsl         x20,x6,#1
    csel        x11, x20, x11,le

    sqshrn      v30.4h, v30.4s,#6           //right shift
    sqrshrun    v24.8b, v24.8h,#6           //rounding shift

    ld1         {v5.4h},[x0],x2
    smull       v26.4s, v2.4h, v16.4h       //vmull_s16(src_tmp2, coeff_0)
    ld1         {v6.4h},[x0],x2
    smlal       v26.4s, v3.4h, v17.4h
    st1         {v24.s}[0],[x9]             //stores the loaded value
    add         x0,x4,x2
    smlal       v26.4s, v4.4h, v18.4h
    ld1         {v0.4h},[x4],#8             //loads pu1_src
    smlal       v26.4s, v5.4h, v19.4h

    sqshrn      v28.4h, v28.4s,#6           //right shift
    sqrshrun    v30.8b, v30.8h,#6           //rounding shift

    ld1         {v1.4h},[x0],x2             //loads pi2_src
    smull       v24.4s, v3.4h, v16.4h       //vmull_s16(src_tmp2, coeff_0)
    add         x9,x1,x3                    //pu1_dst + dst_strd
    ld1         {v2.4h},[x0],x2             //loads pi2_src
    smlal       v24.4s, v4.4h, v17.4h
    ld1         {v3.4h},[x0],x2
    smlal       v24.4s, v5.4h, v18.4h

    st1         {v30.s}[0],[x1],#4          //stores the loaded value
    smlal       v24.4s, v6.4h, v19.4h

    sqshrn      v26.4h, v26.4s,#6           //right shift
    sqrshrun    v28.8b, v28.8h,#6           //rounding shift
    add         x20,x1,x14
    csel        x1, x20, x1,le

    subs        x12,x12,#4

    bgt         kernel_4                    //jumps to kernel_4

epilog:
    smull       v30.4s, v0.4h, v16.4h       //vmull_s16(src_tmp1, coeff_0)
    st1         {v28.s}[0],[x9],x3          //stores the loaded value
    smlal       v30.4s, v1.4h, v17.4h
    smlal       v30.4s, v2.4h, v18.4h
    smlal       v30.4s, v3.4h, v19.4h

    sqshrn      v24.4h, v24.4s,#6           //right shift
    sqrshrun    v26.8b, v26.8h,#6           //rounding shift

    smull       v28.4s, v1.4h, v16.4h       //vmull_s16(src_tmp2, coeff_0)
    ld1         {v4.4h},[x0],x2
    smlal       v28.4s, v2.4h, v17.4h
    st1         {v26.s}[0],[x9],x3          //stores the loaded value
    smlal       v28.4s, v3.4h, v18.4h
    smlal       v28.4s, v4.4h, v19.4h

    sqshrn      v30.4h, v30.4s,#6           //right shift
    sqrshrun    v24.8b, v24.8h,#6           //rounding shift

    smull       v26.4s, v2.4h, v16.4h       //vmull_s16(src_tmp2, coeff_0)
    ld1         {v5.4h},[x0],x2
    smlal       v26.4s, v3.4h, v17.4h
    smlal       v26.4s, v4.4h, v18.4h
    smlal       v26.4s, v5.4h, v19.4h

    sqshrn      v28.4h, v28.4s,#6           //right shift
    sqrshrun    v30.8b, v30.8h,#6           //rounding shift

    st1         {v24.s}[0],[x9]             //stores the loaded value
    smull       v24.4s, v3.4h, v16.4h       //vmull_s16(src_tmp2, coeff_0)
    smlal       v24.4s, v4.4h, v17.4h
    add         x9,x1,x3                    //pu1_dst + dst_strd
    ld1         {v6.4h},[x0],x2
    smlal       v24.4s, v5.4h, v18.4h
    smlal       v24.4s, v6.4h, v19.4h
    st1         {v30.s}[0],[x1],#4          //stores the loaded value

    sqrshrun    v28.8b, v28.8h,#6           //rounding shift
    sqshrn      v26.4h, v26.4s,#6           //right shift

    st1         {v28.s}[0],[x9],x3          //stores the loaded value
    sqrshrun    v26.8b, v26.8h,#6           //rounding shift

    sqshrn      v24.4h, v24.4s,#6           //right shift
    st1         {v26.s}[0],[x9],x3          //stores the loaded value
    sqrshrun    v24.8b, v24.8h,#6           //rounding shift

    st1         {v24.s}[0],[x9]             //stores the loaded value

end_loops:
    // ldmfd sp!,{x4-x12,x15}                  //reload the registers from sp
    ldp         x19, x20,[sp],#16

    ret