summaryrefslogtreecommitdiffstats
path: root/common/armv8/ih264_iquant_itrans_recon_dc_av8.s
blob: 8bb9c32a40fce24e13ca14b40a17b9ca4a368720 (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
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
//******************************************************************************
//*
//* 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_iquant_itrans_recon_dc_av8.s
// *
// * @brief
// *  Contains function definitions for single stage  inverse transform
// *
// * @author
// *  Mohit
// *
// * @par List of Functions:
// *  - ih264_iquant_itrans_recon_4x4_dc_av8()
// *     - ih264_iquant_itrans_recon_8x8_dc_av8()
// *  - ih264_iquant_itrans_recon_chroma_4x4_dc_av8()
// *
// * @remarks
// *  None
// *
// *******************************************************************************
//*/


.include "ih264_neon_macros.s"


///**
// *******************************************************************************
// *
// * @brief
// *  This function performs inverse quant and Inverse transform type Ci4 for 4*4 block
// *     for dc input pattern only, i.e. only the (0,0) element of the input 4x4 block is
// *  non-zero. For complete function, refer ih264_iquant_itrans_recon_a9.s
// *
// * @par Description:
// *  Performs inverse transform Ci4 and adds the residue to get the
// *  reconstructed block
// *
// * @param[in] pi2_src
// *  Input 4x4 coefficients
// *
// * @param[in] pu1_pred
// *  Prediction 4x4 block
// *
// * @param[out] pu1_out
// *  Output 4x4 block
// *
// * @param[in] u4_qp_div_6
// *     QP
// *
// * @param[in] pu2_weigh_mat
// * Pointer to weight matrix
// *
// * @param[in] pred_strd,
// *  Prediction stride
// *
// * @param[in] out_strd
// *  Output Stride
// *
// *@param[in] pi2_tmp
// * temporary buffer of size 1*16
// *
// * @param[in] pu2_iscal_mat
// * Pointer to the inverse quantization matrix
// *
// * @returns  Void
// *
// * @remarks
// *  None
// *
// *******************************************************************************
// */
//void ih264_iquant_itrans_recon_4x4_dc(WORD16 *pi2_src,
//                                    UWORD8 *pu1_pred,
//                                    UWORD8 *pu1_out,
//                                    WORD32 pred_strd,
//                                    WORD32 out_strd,
//                                    const UWORD16 *pu2_iscal_mat,
//                                    const UWORD16 *pu2_weigh_mat,
//                                    UWORD32 u4_qp_div_6,
//                                    WORD32 *pi4_tmp,
//                                    WORD32 iq_start_idx
//                                   WORD16 *pi2_dc_ld_addr)
//**************Variables Vs Registers*****************************************
//x0 => *pi2_src
//x1 => *pu1_pred
//x2 => *pu1_out
//x3 =>  pred_strd
//x4 =>  out_strd
//x5 => *pu2_iscal_mat
//x6 => *pu2_weigh_mat
//x7 =>  u4_qp_div_6
//   =>  pi4_tmp
//   =>  iq_start_idx
//   =>  pi2_dc_ld_addr

.text
.p2align 2

    .global ih264_iquant_itrans_recon_4x4_dc_av8
ih264_iquant_itrans_recon_4x4_dc_av8:

    ldr       w8, [sp, #8]              //Loads iq_start_idx
    subs      w8, w8, #1                // if x8 == 1 => intra case , so result of subtraction is zero and z flag is set

    ldr       x10, [sp, #16]            //Load alternate dc address
    push_v_regs
    dup       v30.4s, w7                //Populate the u4_qp_div_6 in Q15


    bne       donot_use_pi2_dc_ld_addr_luma_dc
    ld1       {v0.h}[0], [x10]
donot_use_pi2_dc_ld_addr_luma_dc:

    beq       donot_use_pi2_src_luma_dc
    ld1       {v0.h}[0], [x5]
    ld1       {v1.h}[0], [x6]
    ld1       {v2.h}[0], [x0]
    mul       v0.4h, v1.4h, v0.4h
    smull     v0.4s, v0.4h, v2.4h
    sshl      v0.4s, v0.4s, v30.4s
    sqrshrn   v0.4h, v0.4s, #4
donot_use_pi2_src_luma_dc:


    dup       v0.8h, v0.h[0]
    srshr     v0.8h, v0.8h, #6

    ld1       {v1.s}[0], [x1], x3
    ld1       {v1.s}[1], [x1], x3
    ld1       {v2.s}[0], [x1], x3
    ld1       {v2.s}[1], [x1]

    uxtl      v1.8h, v1.8b
    uxtl      v2.8h, v2.8b

    add       v1.8h, v0.8h, v1.8h
    add       v2.8h, v0.8h, v2.8h

    sqxtun    v1.8b, v1.8h
    sqxtun    v2.8b, v2.8h

    st1       {v1.s}[0], [x2], x4
    st1       {v1.s}[1], [x2], x4
    st1       {v2.s}[0], [x2], x4
    st1       {v2.s}[1], [x2]
    pop_v_regs
    ret

// /*
// ********************************************************************************
// *
// * @brief This function reconstructs a 4x4 sub block from quantized resiude and
// * prediction buffer if only dc value is present for residue
// *
// * @par Description:
// *  The quantized residue is first inverse quantized,
// *  This inverse quantized content is added to the prediction buffer to recon-
// *  struct the end output
// *
// * @param[in] pi2_src
// *  quantized dc coeffiient
// *
// * @param[in] pu1_pred
// *  prediction 4x4 block in interleaved format
// *
// * @param[in] pred_strd,
// *  Prediction buffer stride in interleaved format
// *
// * @param[in] out_strd
// *  recon buffer Stride
// *
// * @returns none
// *
// * @remarks none
// *
// *******************************************************************************
// */
// void ih264_iquant_itrans_recon_chroma_4x4_dc(WORD16 *pi2_src,
//                                             UWORD8 *pu1_pred,
//                                             UWORD8 *pu1_out,
//                                             WORD32 pred_strd,
//                                             WORD32 out_strd,
//                                             const UWORD16 *pu2_iscal_mat,
//                                             const UWORD16 *pu2_weigh_mat,
//                                             UWORD32 u4_qp_div_6,
//                                             WORD16 *pi2_tmp,
//                                             WORD16 *pi2_dc_src)
// Register Usage
// x0 : pi2_src
// x1 : pu1_pred
// x2 : pu1_out
// x3 : pred_strd
// x4 : out_strd
// x5 : pu2_iscal_mat
// x6 : pu2_weigh_mat
// x7 : u4_qp_div_6
//    : pi2_tmp
//    : pi2_dc_src
// Neon registers d0-d7, d16-d30 are used
// No need for pushing  arm and neon registers


    .global ih264_iquant_itrans_recon_chroma_4x4_dc_av8
ih264_iquant_itrans_recon_chroma_4x4_dc_av8:

    ldr       x0, [sp, #8]
    push_v_regs
    ld1       {v0.h}[0], [x0]
    dup       v0.8h, v0.h[0]
    srshr     v0.8h, v0.8h, #6


    //backup pu1_out
    mov       x0, x2

    //nop       v3.16b                            //dummy for deinterleaving
    movi      v31.8h, #0x00ff           //mask for interleaving [copy lower 8 bits]

    ld1       {v1.d}[0], [x1], x3
    ld1       {v1.d}[1], [x1], x3
    ld1       {v2.d}[0], [x1], x3
    ld1       {v2.d}[1], [x1], x3

    ld1       {v11.d}[0], [x2], x4      //load pu1_out for interleaving
    ld1       {v11.d}[1], [x2], x4
    ld1       {v12.d}[0], [x2], x4
    ld1       {v12.d}[1], [x2]

    uzp1      v1.16b, v1.16b, v3.16b
    uzp1      v2.16b, v2.16b, v3.16b

    uaddw     v1.8h, v0.8h, v1.8b
    uaddw     v2.8h, v0.8h, v2.8b

    sqxtun    v1.8b, v1.8h
    sqxtun    v2.8b, v2.8h

    uxtl      v1.8h, v1.8b
    uxtl      v2.8h, v2.8b

    bit       v11.16b, v1.16b, v31.16b
    bit       v12.16b, v2.16b, v31.16b

    st1       {v11.d}[0], [x0], x4
    st1       {v11.d}[1], [x0], x4
    st1       {v12.d}[0], [x0], x4
    st1       {v12.d}[1], [x0]
    pop_v_regs
    ret

///*
// *******************************************************************************
// *
// * //brief
// *  This function performs inverse quant and Inverse transform type Ci4 for 8*8 block
// *   [Only for Dc coeff]
// * //par Description:
// *  Performs inverse transform Ci8 and adds the residue to get the
// *  reconstructed block
// *
// * //param[in] pi2_src
// *  Input 4x4 coefficients
// *
// * //param[in] pu1_pred
// *  Prediction 4x4 block
// *
// * //param[out] pu1_out
// *  Output 4x4 block
// *
// * //param[in] u4_qp_div_6
// *     QP
// *
// * //param[in] pu2_weigh_mat
// * Pointer to weight matrix
// *
// * //param[in] pred_strd,
// *  Prediction stride
// *
// * //param[in] out_strd
// *  Output Stride
// *
// *//param[in] pi2_tmp
// * temporary buffer of size 1*64
// *
// * //param[in] pu2_iscal_mat
// * Pointer to the inverse quantization matrix
// *
// * //returns  Void
// *
// * //remarks
// *  None
// *
// *******************************************************************************
// */
//void ih264_iquant_itrans_recon_dc_8x8(WORD16 *pi2_src,
//                                   UWORD8 *pu1_pred,
//                                   UWORD8 *pu1_out,
//                                   WORD32 pred_strd,
//                                   WORD32 out_strd,
//                                   const UWORD16 *pu2_iscal_mat,
//                                   const UWORD16 *pu2_weigh_mat,
//                                   UWORD32 u4_qp_div_6,
//                                   WORD32 *pi4_tmp,
//                                   WORD32 iq_start_idx
//                                   WORD16 *pi2_dc_ld_addr)
//**************Variables Vs Registers*****************************************
//x0       => *pi2_src
//x1       => *pu1_pred
//x2       => *pu1_out
//x3       =>  pred_strd
//x4       =>  out_strd
//x5       =>  *pu2_iscal_mat
//x6       =>  *pu2_weigh_mat
//x7       =>  u4_qp_div_6
//NOT USED =>  pi4_tmp
//NOT USED =>  iq_start_idx
//NOT USED =>  pi2_dc_ld_addr

    .global ih264_iquant_itrans_recon_8x8_dc_av8
ih264_iquant_itrans_recon_8x8_dc_av8:

    push_v_regs

    ld1       {v1.h}[0], [x5]
    ld1       {v2.h}[0], [x6]
    ld1       {v0.h}[0], [x0]
    dup       v3.4s, w7


    mul       v1.8h, v1.8h, v2.8h
    smull     v0.4s, v0.4h, v1.4h
    sshl      v0.4s, v0.4s, v3.4s

    sqrshrn   v0.4h, v0.4s, #6
    srshr     v0.8h, v0.8h, #6
    dup       v0.8h, v0.h[0]

    ld1       {v22.8b}, [x1], x3
    ld1       {v23.8b}, [x1], x3
    ld1       {v24.8b}, [x1], x3
    ld1       {v25.8b}, [x1], x3
    ld1       {v26.8b}, [x1], x3
    ld1       {v27.8b}, [x1], x3
    ld1       {v28.8b}, [x1], x3
    ld1       {v29.8b}, [x1]

    uaddw     v1.8h, v0.8h, v22.8b
    uaddw     v2.8h, v0.8h, v23.8b
    uaddw     v3.8h, v0.8h, v24.8b
    uaddw     v8.8h, v0.8h, v25.8b
    uaddw     v9.8h, v0.8h, v26.8b
    uaddw     v10.8h, v0.8h, v27.8b
    uaddw     v11.8h, v0.8h, v28.8b
    uaddw     v12.8h, v0.8h, v29.8b

    sqxtun    v1.8b, v1.8h
    sqxtun    v2.8b, v2.8h
    sqxtun    v3.8b, v3.8h
    sqxtun    v8.8b, v8.8h
    sqxtun    v9.8b, v9.8h
    sqxtun    v10.8b, v10.8h
    sqxtun    v11.8b, v11.8h
    sqxtun    v12.8b, v12.8h

    st1       {v1.8b}, [x2], x4
    st1       {v2.8b}, [x2], x4
    st1       {v3.8b}, [x2], x4
    st1       {v8.8b}, [x2], x4
    st1       {v9.8b}, [x2], x4
    st1       {v10.8b}, [x2], x4
    st1       {v11.8b}, [x2], x4
    st1       {v12.8b}, [x2]

    pop_v_regs
    ret