/src/libavc/decoder/svc/isvcd_iquant_itrans.c
Line | Count | Source (jump to first uncovered line) |
1 | | /****************************************************************************** |
2 | | * |
3 | | * Copyright (C) 2022 The Android Open Source Project |
4 | | * |
5 | | * Licensed under the Apache License, Version 2.0 (the "License"); |
6 | | * you may not use this file except in compliance with the License. |
7 | | * You may obtain a copy of the License at: |
8 | | * |
9 | | * http://www.apache.org/licenses/LICENSE-2.0 |
10 | | * |
11 | | * Unless required by applicable law or agreed to in writing, software |
12 | | * distributed under the License is distributed on an "AS IS" BASIS, |
13 | | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
14 | | * See the License for the specific language governing permissions and |
15 | | * limitations under the License. |
16 | | * |
17 | | ***************************************************************************** |
18 | | * Originally developed and contributed by Ittiam Systems Pvt. Ltd, Bangalore |
19 | | */ |
20 | | /** |
21 | | ******************************************************************************* |
22 | | * @file |
23 | | * isvcd_iquant_itrans.c |
24 | | * |
25 | | * @brief |
26 | | * Contains definition of functions for h264 inverse quantization inverse |
27 | | transformation and resd comp |
28 | | * |
29 | | * @author |
30 | | * Kishore |
31 | | * |
32 | | * @par List of Functions: |
33 | | * - isvcd_iquant_itrans_4x4() |
34 | | * - isvcd_iquant_itrans_8x8() |
35 | | * - isvcd_iquant_itrans_4x4_dc() |
36 | | * - isvcd_iquant_itrans_8x8_dc() |
37 | | * - isvcd_iquant_itrans_chroma_4x4() |
38 | | * - isvcd_iquant_itrans_chroma_4x4_dc() |
39 | | |
40 | | * |
41 | | * @remarks |
42 | | * |
43 | | ******************************************************************************* |
44 | | */ |
45 | | |
46 | | /*****************************************************************************/ |
47 | | /* File Includes */ |
48 | | /*****************************************************************************/ |
49 | | |
50 | | /* User include files */ |
51 | | #include "ih264_typedefs.h" |
52 | | #include "ih264_defs.h" |
53 | | #include "ih264_trans_macros.h" |
54 | | #include "ih264_macros.h" |
55 | | #include "ih264_platform_macros.h" |
56 | | #include "ih264_trans_data.h" |
57 | | #include "ih264_size_defs.h" |
58 | | #include "ih264_structs.h" |
59 | | #include "isvcd_iquant_itrans.h" |
60 | | |
61 | | /*****************************************************************************/ |
62 | | /* */ |
63 | | /* Function Name : isvcd_iquant_itrans_4x4 */ |
64 | | /* */ |
65 | | /* Description : this function computes the inverse quantized and */ |
66 | | /* inverse transformed output */ |
67 | | /* */ |
68 | | /* Inputs : */ |
69 | | /* Globals : none */ |
70 | | /* Processing : */ |
71 | | /* */ |
72 | | /* Outputs : none */ |
73 | | /* Returns : none */ |
74 | | /* */ |
75 | | /* Issues : none */ |
76 | | /* */ |
77 | | /* Revision History: */ |
78 | | /* */ |
79 | | /* DD MM YYYY Author(s) Changes (Describe the changes made) */ |
80 | | /* 25 11 2021 Kishore creation */ |
81 | | /* */ |
82 | | /*****************************************************************************/ |
83 | | void isvcd_iquant_itrans_4x4(WORD16 *pi2_src, WORD16 *pi2_out, WORD32 out_strd, |
84 | | const UWORD16 *pu2_iscal_mat, const UWORD16 *pu2_weigh_mat, |
85 | | UWORD32 u4_qp_div_6, WORD16 *pi2_tmp, WORD32 iq_start_idx, |
86 | | WORD16 *pi2_dc_ld_addr) |
87 | 23.0k | { |
88 | 23.0k | WORD16 *pi2_src_ptr = pi2_src; |
89 | 23.0k | WORD16 *pi2_tmp_ptr = pi2_tmp; |
90 | 23.0k | WORD16 *pi2_out_ptr = pi2_out; |
91 | 23.0k | WORD16 x0, x1, x2, x3, i; |
92 | 23.0k | WORD32 q0, q1, q2, q3; |
93 | 23.0k | WORD16 i_macro; |
94 | 23.0k | WORD16 rnd_fact = (u4_qp_div_6 < 4) ? 1 << (3 - u4_qp_div_6) : 0; |
95 | | |
96 | | /* inverse quant */ |
97 | | /*horizontal inverse transform */ |
98 | 115k | for(i = 0; i < SUB_BLK_WIDTH_4x4; i++) |
99 | 92.2k | { |
100 | 92.2k | q0 = pi2_src_ptr[0]; |
101 | 92.2k | INV_QUANT(q0, pu2_iscal_mat[0], pu2_weigh_mat[0], u4_qp_div_6, rnd_fact, 4); |
102 | 92.2k | if(i == 0 && iq_start_idx == 1) |
103 | 0 | q0 = pi2_dc_ld_addr[0]; // Restoring dc value for intra case |
104 | | |
105 | 92.2k | q2 = pi2_src_ptr[2]; |
106 | 92.2k | INV_QUANT(q2, pu2_iscal_mat[2], pu2_weigh_mat[2], u4_qp_div_6, rnd_fact, 4); |
107 | | |
108 | 92.2k | x0 = q0 + q2; |
109 | 92.2k | x1 = q0 - q2; |
110 | | |
111 | 92.2k | q1 = pi2_src_ptr[1]; |
112 | 92.2k | INV_QUANT(q1, pu2_iscal_mat[1], pu2_weigh_mat[1], u4_qp_div_6, rnd_fact, 4); |
113 | | |
114 | 92.2k | q3 = pi2_src_ptr[3]; |
115 | 92.2k | INV_QUANT(q3, pu2_iscal_mat[3], pu2_weigh_mat[3], u4_qp_div_6, rnd_fact, 4); |
116 | | |
117 | 92.2k | x2 = (q1 >> 1) - q3; |
118 | 92.2k | x3 = q1 + (q3 >> 1); |
119 | | |
120 | 92.2k | pi2_tmp_ptr[0] = x0 + x3; |
121 | 92.2k | pi2_tmp_ptr[1] = x1 + x2; |
122 | 92.2k | pi2_tmp_ptr[2] = x1 - x2; |
123 | 92.2k | pi2_tmp_ptr[3] = x0 - x3; |
124 | | |
125 | 92.2k | pi2_src_ptr += SUB_BLK_WIDTH_4x4; |
126 | 92.2k | pi2_tmp_ptr += SUB_BLK_WIDTH_4x4; |
127 | 92.2k | pu2_iscal_mat += SUB_BLK_WIDTH_4x4; |
128 | 92.2k | pu2_weigh_mat += SUB_BLK_WIDTH_4x4; |
129 | 92.2k | } |
130 | | |
131 | | /* vertical inverse transform */ |
132 | 23.0k | pi2_tmp_ptr = pi2_tmp; |
133 | 115k | for(i = 0; i < SUB_BLK_WIDTH_4x4; i++) |
134 | 92.2k | { |
135 | 92.2k | pi2_out = pi2_out_ptr; |
136 | | |
137 | 92.2k | x0 = (pi2_tmp_ptr[0] + pi2_tmp_ptr[8]); |
138 | 92.2k | x1 = (pi2_tmp_ptr[0] - pi2_tmp_ptr[8]); |
139 | 92.2k | x2 = (pi2_tmp_ptr[4] >> 1) - pi2_tmp_ptr[12]; |
140 | 92.2k | x3 = pi2_tmp_ptr[4] + (pi2_tmp_ptr[12] >> 1); |
141 | | |
142 | | /* inverse prediction */ |
143 | 92.2k | i_macro = x0 + x3; |
144 | 92.2k | *pi2_out = CLIP_RSD((i_macro + 32) >> 6); |
145 | 92.2k | pi2_out += out_strd; |
146 | | |
147 | 92.2k | i_macro = x1 + x2; |
148 | 92.2k | *pi2_out = CLIP_RSD((i_macro + 32) >> 6); |
149 | 92.2k | pi2_out += out_strd; |
150 | | |
151 | 92.2k | i_macro = x1 - x2; |
152 | 92.2k | *pi2_out = CLIP_RSD((i_macro + 32) >> 6); |
153 | 92.2k | pi2_out += out_strd; |
154 | | |
155 | 92.2k | i_macro = x0 - x3; |
156 | 92.2k | *pi2_out = CLIP_RSD((i_macro + 32) >> 6); |
157 | 92.2k | pi2_tmp_ptr++; |
158 | 92.2k | pi2_out_ptr++; |
159 | 92.2k | } |
160 | 23.0k | } |
161 | | |
162 | | /*****************************************************************************/ |
163 | | /* */ |
164 | | /* Function Name : isvcd_iquant_itrans_4x4_dc */ |
165 | | /* */ |
166 | | /* Description : this function computes the inverse quantized and */ |
167 | | /* inverse transformed output */ |
168 | | /* */ |
169 | | /* Inputs : */ |
170 | | /* Globals : none */ |
171 | | /* Processing : */ |
172 | | /* */ |
173 | | /* Outputs : none */ |
174 | | /* Returns : none */ |
175 | | /* */ |
176 | | /* Issues : none */ |
177 | | /* */ |
178 | | /* Revision History: */ |
179 | | /* */ |
180 | | /* DD MM YYYY Author(s) Changes (Describe the changes made) */ |
181 | | /* 25 11 2021 Kishore creation */ |
182 | | /* */ |
183 | | /*****************************************************************************/ |
184 | | void isvcd_iquant_itrans_4x4_dc(WORD16 *pi2_src, WORD16 *pi2_out, WORD32 out_strd, |
185 | | const UWORD16 *pu2_iscal_mat, const UWORD16 *pu2_weigh_mat, |
186 | | UWORD32 u4_qp_div_6, WORD16 *pi2_tmp, WORD32 iq_start_idx, |
187 | | WORD16 *pi2_dc_ld_addr) |
188 | 5.25k | { |
189 | 5.25k | WORD16 *pi2_out_ptr = pi2_out; |
190 | 5.25k | WORD32 q0; |
191 | 5.25k | WORD16 i_macro, i; |
192 | 5.25k | WORD16 rnd_fact = (u4_qp_div_6 < 4) ? 1 << (3 - u4_qp_div_6) : 0; |
193 | 5.25k | UNUSED(pi2_tmp); |
194 | | |
195 | 5.25k | if(iq_start_idx == 0) |
196 | 5.25k | { |
197 | 5.25k | q0 = pi2_src[0]; |
198 | 5.25k | INV_QUANT(q0, pu2_iscal_mat[0], pu2_weigh_mat[0], u4_qp_div_6, rnd_fact, 4); |
199 | 5.25k | } |
200 | 0 | else |
201 | 0 | { |
202 | 0 | q0 = pi2_dc_ld_addr[0]; // Restoring dc value for intra case3 |
203 | 0 | } |
204 | 5.25k | i_macro = CLIP_RSD((q0 + 32) >> 6); |
205 | 26.2k | for(i = 0; i < SUB_BLK_WIDTH_4x4; i++) |
206 | 21.0k | { |
207 | 21.0k | pi2_out = pi2_out_ptr; |
208 | | |
209 | | /* inverse prediction */ |
210 | 21.0k | *pi2_out = i_macro; |
211 | 21.0k | pi2_out += out_strd; |
212 | 21.0k | *pi2_out = i_macro; |
213 | 21.0k | pi2_out += out_strd; |
214 | 21.0k | *pi2_out = i_macro; |
215 | 21.0k | pi2_out += out_strd; |
216 | 21.0k | *pi2_out = i_macro; |
217 | 21.0k | pi2_out_ptr++; |
218 | 21.0k | } |
219 | 5.25k | } |
220 | | |
221 | | /*****************************************************************************/ |
222 | | /* */ |
223 | | /* Function Name : isvcd_iquant_itrans_chroma_4x4 */ |
224 | | /* */ |
225 | | /* Description : this function computes the inverse quantized and */ |
226 | | /* inverse transformed output */ |
227 | | /* */ |
228 | | /* Inputs : */ |
229 | | /* Globals : none */ |
230 | | /* Processing : */ |
231 | | /* */ |
232 | | /* Outputs : none */ |
233 | | /* Returns : none */ |
234 | | /* */ |
235 | | /* Issues : none */ |
236 | | /* */ |
237 | | /* Revision History: */ |
238 | | /* */ |
239 | | /* DD MM YYYY Author(s) Changes (Describe the changes made) */ |
240 | | /* 25 11 2021 Kishore creation */ |
241 | | /* */ |
242 | | /*****************************************************************************/ |
243 | | void isvcd_iquant_itrans_chroma_4x4(WORD16 *pi2_src, WORD16 *pi2_out, WORD32 out_strd, |
244 | | const UWORD16 *pu2_iscal_mat, const UWORD16 *pu2_weigh_mat, |
245 | | UWORD32 u4_qp_div_6, WORD16 *pi2_tmp, WORD16 *pi2_dc_src) |
246 | 5.16k | { |
247 | 5.16k | WORD16 *pi2_src_ptr = pi2_src; |
248 | 5.16k | WORD16 *pi2_tmp_ptr = pi2_tmp; |
249 | 5.16k | WORD16 *pi2_out_ptr = pi2_out; |
250 | 5.16k | WORD16 x0, x1, x2, x3, i; |
251 | 5.16k | WORD32 q0, q1, q2, q3; |
252 | 5.16k | WORD16 i_macro; |
253 | 5.16k | WORD16 rnd_fact = (u4_qp_div_6 < 4) ? 1 << (3 - u4_qp_div_6) : 0; |
254 | | |
255 | | /* inverse quant */ |
256 | | /*horizontal inverse transform */ |
257 | 25.8k | for(i = 0; i < SUB_BLK_WIDTH_4x4; i++) |
258 | 20.6k | { |
259 | 20.6k | if(i == 0) |
260 | 5.16k | { |
261 | 5.16k | q0 = pi2_dc_src[0]; |
262 | 5.16k | } |
263 | 15.5k | else |
264 | 15.5k | { |
265 | 15.5k | q0 = pi2_src_ptr[0]; |
266 | 15.5k | INV_QUANT(q0, pu2_iscal_mat[0], pu2_weigh_mat[0], u4_qp_div_6, rnd_fact, 4); |
267 | 15.5k | } |
268 | | |
269 | 20.6k | q2 = pi2_src_ptr[2]; |
270 | 20.6k | INV_QUANT(q2, pu2_iscal_mat[2], pu2_weigh_mat[2], u4_qp_div_6, rnd_fact, 4); |
271 | | |
272 | 20.6k | x0 = q0 + q2; |
273 | 20.6k | x1 = q0 - q2; |
274 | | |
275 | 20.6k | q1 = pi2_src_ptr[1]; |
276 | 20.6k | INV_QUANT(q1, pu2_iscal_mat[1], pu2_weigh_mat[1], u4_qp_div_6, rnd_fact, 4); |
277 | | |
278 | 20.6k | q3 = pi2_src_ptr[3]; |
279 | 20.6k | INV_QUANT(q3, pu2_iscal_mat[3], pu2_weigh_mat[3], u4_qp_div_6, rnd_fact, 4); |
280 | | |
281 | 20.6k | x2 = (q1 >> 1) - q3; |
282 | 20.6k | x3 = q1 + (q3 >> 1); |
283 | | |
284 | 20.6k | pi2_tmp_ptr[0] = x0 + x3; |
285 | 20.6k | pi2_tmp_ptr[1] = x1 + x2; |
286 | 20.6k | pi2_tmp_ptr[2] = x1 - x2; |
287 | 20.6k | pi2_tmp_ptr[3] = x0 - x3; |
288 | | |
289 | 20.6k | pi2_src_ptr += SUB_BLK_WIDTH_4x4; |
290 | 20.6k | pi2_tmp_ptr += SUB_BLK_WIDTH_4x4; |
291 | 20.6k | pu2_iscal_mat += SUB_BLK_WIDTH_4x4; |
292 | 20.6k | pu2_weigh_mat += SUB_BLK_WIDTH_4x4; |
293 | 20.6k | } |
294 | | |
295 | | /* vertical inverse transform */ |
296 | 5.16k | pi2_tmp_ptr = pi2_tmp; |
297 | 25.8k | for(i = 0; i < SUB_BLK_WIDTH_4x4; i++) |
298 | 20.6k | { |
299 | 20.6k | pi2_out = pi2_out_ptr; |
300 | | |
301 | 20.6k | x0 = (pi2_tmp_ptr[0] + pi2_tmp_ptr[8]); |
302 | 20.6k | x1 = (pi2_tmp_ptr[0] - pi2_tmp_ptr[8]); |
303 | 20.6k | x2 = (pi2_tmp_ptr[4] >> 1) - pi2_tmp_ptr[12]; |
304 | 20.6k | x3 = pi2_tmp_ptr[4] + (pi2_tmp_ptr[12] >> 1); |
305 | | |
306 | | /* inverse prediction */ |
307 | 20.6k | i_macro = x0 + x3; |
308 | 20.6k | *pi2_out = CLIP_RSD((i_macro + 32) >> 6); |
309 | 20.6k | pi2_out += out_strd; |
310 | | |
311 | 20.6k | i_macro = x1 + x2; |
312 | 20.6k | *pi2_out = CLIP_RSD((i_macro + 32) >> 6); |
313 | 20.6k | pi2_out += out_strd; |
314 | | |
315 | 20.6k | i_macro = x1 - x2; |
316 | 20.6k | *pi2_out = CLIP_RSD((i_macro + 32) >> 6); |
317 | 20.6k | pi2_out += out_strd; |
318 | | |
319 | 20.6k | i_macro = x0 - x3; |
320 | 20.6k | *pi2_out = CLIP_RSD((i_macro + 32) >> 6); |
321 | 20.6k | pi2_tmp_ptr++; |
322 | 20.6k | pi2_out_ptr += 2; // Interleaved store for output |
323 | 20.6k | } |
324 | 5.16k | } |
325 | | /*****************************************************************************/ |
326 | | /* */ |
327 | | /* Function Name : isvcd_iquant_itrans_chroma_4x4_dc */ |
328 | | /* */ |
329 | | /* Description : this function computes the inverse quantized and */ |
330 | | /* inverse transformed output */ |
331 | | /* */ |
332 | | /* Inputs : */ |
333 | | /* Globals : none */ |
334 | | /* Processing : */ |
335 | | /* */ |
336 | | /* Outputs : none */ |
337 | | /* Returns : none */ |
338 | | /* */ |
339 | | /* Issues : none */ |
340 | | /* */ |
341 | | /* Revision History: */ |
342 | | /* */ |
343 | | /* DD MM YYYY Author(s) Changes (Describe the changes made) */ |
344 | | /* 25 11 2021 Kishore creation */ |
345 | | /* */ |
346 | | /*****************************************************************************/ |
347 | | |
348 | | void isvcd_iquant_itrans_chroma_4x4_dc(WORD16 *pi2_src, WORD16 *pi2_out, WORD32 out_strd, |
349 | | const UWORD16 *pu2_iscal_mat, const UWORD16 *pu2_weigh_mat, |
350 | | UWORD32 u4_qp_div_6, WORD16 *pi2_tmp, WORD16 *pi2_dc_src) |
351 | 13.8k | { |
352 | 13.8k | WORD16 *pi2_out_ptr = pi2_out; |
353 | 13.8k | WORD32 q0; |
354 | 13.8k | WORD16 i_macro, i; |
355 | 13.8k | UNUSED(pi2_src); |
356 | 13.8k | UNUSED(pu2_iscal_mat); |
357 | 13.8k | UNUSED(pu2_weigh_mat); |
358 | 13.8k | UNUSED(u4_qp_div_6); |
359 | 13.8k | UNUSED(pi2_tmp); |
360 | | |
361 | 13.8k | q0 = pi2_dc_src[0]; // Restoring dc value for intra case3 |
362 | 13.8k | i_macro = CLIP_RSD((q0 + 32) >> 6); |
363 | | |
364 | 69.3k | for(i = 0; i < SUB_BLK_WIDTH_4x4; i++) |
365 | 55.4k | { |
366 | 55.4k | pi2_out = pi2_out_ptr; |
367 | | |
368 | | /* inverse prediction */ |
369 | 55.4k | *pi2_out = i_macro; |
370 | 55.4k | pi2_out += out_strd; |
371 | | |
372 | 55.4k | *pi2_out = i_macro; |
373 | 55.4k | pi2_out += out_strd; |
374 | | |
375 | 55.4k | *pi2_out = i_macro; |
376 | 55.4k | pi2_out += out_strd; |
377 | | |
378 | 55.4k | *pi2_out = i_macro; |
379 | | |
380 | 55.4k | pi2_out_ptr += 2; |
381 | 55.4k | } |
382 | 13.8k | } |
383 | | |
384 | | /** |
385 | | ******************************************************************************* |
386 | | * |
387 | | * @brief |
388 | | * This function performs inverse quant and Inverse transform type Ci4 for 8x8 |
389 | | *block |
390 | | * |
391 | | * @par Description: |
392 | | * Performs inverse transform Ci8 and adds the residue to get the |
393 | | * reconstructed block |
394 | | * |
395 | | * @param[in] pi2_src |
396 | | * Input 8x8coefficients |
397 | | * |
398 | | * @param[in] pu1_pred |
399 | | * Prediction 8x8 block |
400 | | * |
401 | | * @param[out] pu1_recon |
402 | | * Output 8x8 block |
403 | | * |
404 | | * @param[in] q_div |
405 | | * QP/6 |
406 | | * |
407 | | * @param[in] q_rem |
408 | | * QP%6 |
409 | | * |
410 | | * @param[in] q_lev |
411 | | * Quantizer level |
412 | | * |
413 | | * @param[in] src_strd |
414 | | * Input stride |
415 | | * |
416 | | * @param[in] pred_strd, |
417 | | * Prediction stride |
418 | | * |
419 | | * @param[in] out_strd |
420 | | * Output Stride |
421 | | * |
422 | | * @param[in] pi4_tmp |
423 | | * temporary buffer of size 1*16 we dont need a bigger blcok since we reuse |
424 | | * the tmp for each block |
425 | | * |
426 | | * @param[in] pu4_iquant_mat |
427 | | * Pointer to the inverse quantization matrix |
428 | | * |
429 | | * @returns Void |
430 | | * |
431 | | * @remarks |
432 | | * None |
433 | | * |
434 | | ******************************************************************************* |
435 | | */ |
436 | | void isvcd_iquant_itrans_8x8_dc(WORD16 *pi2_src, WORD16 *pi2_out, WORD32 out_strd, |
437 | | const UWORD16 *pu2_iscale_mat, const UWORD16 *pu2_weigh_mat, |
438 | | UWORD32 qp_div, WORD16 *pi2_tmp, WORD32 iq_start_idx, |
439 | | WORD16 *pi2_dc_ld_addr) |
440 | 1.99k | { |
441 | 1.99k | WORD16 *pi2_out_ptr = pi2_out; |
442 | 1.99k | WORD16 i, i_macro; |
443 | 1.99k | WORD32 q; |
444 | 1.99k | WORD32 rnd_fact = (qp_div < 6) ? (1 << (5 - qp_div)) : 0; |
445 | 1.99k | UNUSED(pi2_tmp); |
446 | 1.99k | UNUSED(iq_start_idx); |
447 | 1.99k | UNUSED(pi2_dc_ld_addr); |
448 | | /*************************************************************/ |
449 | | /* Dequantization of coefficients. Will be replaced by SIMD */ |
450 | | /* operations on platform. Note : DC coeff is not scaled */ |
451 | | /*************************************************************/ |
452 | 1.99k | q = pi2_src[0]; |
453 | 1.99k | INV_QUANT(q, pu2_iscale_mat[0], pu2_weigh_mat[0], qp_div, rnd_fact, 6); |
454 | 1.99k | i_macro = CLIP_RSD((q + 32) >> 6); |
455 | | /* Perform Inverse transform */ |
456 | | /*--------------------------------------------------------------------*/ |
457 | | /* IDCT [ Horizontal transformation ] */ |
458 | | /*--------------------------------------------------------------------*/ |
459 | | /*--------------------------------------------------------------------*/ |
460 | | /* IDCT [ Vertical transformation] and Xij = (xij + 32)>>6 */ |
461 | | /* */ |
462 | | /* Add the prediction and store it back to reconstructed frame buffer */ |
463 | | /* [Prediction buffer itself in this case] */ |
464 | | /*--------------------------------------------------------------------*/ |
465 | 17.9k | for(i = 0; i < SUB_BLK_WIDTH_8x8; i++) |
466 | 15.9k | { |
467 | 15.9k | pi2_out = pi2_out_ptr; |
468 | | |
469 | 15.9k | *pi2_out = i_macro; |
470 | | /* Change uc_recBuffer to Point to next element in the same column*/ |
471 | 15.9k | pi2_out += out_strd; |
472 | | |
473 | 15.9k | *pi2_out = i_macro; |
474 | 15.9k | pi2_out += out_strd; |
475 | | |
476 | 15.9k | *pi2_out = i_macro; |
477 | 15.9k | pi2_out += out_strd; |
478 | | |
479 | 15.9k | *pi2_out = i_macro; |
480 | 15.9k | pi2_out += out_strd; |
481 | | |
482 | 15.9k | *pi2_out = i_macro; |
483 | 15.9k | pi2_out += out_strd; |
484 | | |
485 | 15.9k | *pi2_out = i_macro; |
486 | 15.9k | pi2_out += out_strd; |
487 | | |
488 | 15.9k | *pi2_out = i_macro; |
489 | 15.9k | pi2_out += out_strd; |
490 | | |
491 | 15.9k | *pi2_out = i_macro; |
492 | | |
493 | 15.9k | pi2_out_ptr++; |
494 | 15.9k | } |
495 | 1.99k | } |
496 | | /*****************************************************************************/ |
497 | | /* */ |
498 | | /* Function Name : isvcd_iquant_itrans_8x8 */ |
499 | | /* */ |
500 | | /* Description : this function computes the inverse quantized and */ |
501 | | /* inverse transformed output */ |
502 | | /* */ |
503 | | /* Inputs : */ |
504 | | /* Globals : none */ |
505 | | /* Processing : */ |
506 | | /* */ |
507 | | /* Outputs : none */ |
508 | | /* Returns : none */ |
509 | | /* */ |
510 | | /* Issues : none */ |
511 | | /* */ |
512 | | /* Revision History: */ |
513 | | /* */ |
514 | | /* DD MM YYYY Author(s) Changes (Describe the changes made) */ |
515 | | /* 25 11 2021 Kishore creation */ |
516 | | /* */ |
517 | | /*****************************************************************************/ |
518 | | |
519 | | void isvcd_iquant_itrans_8x8(WORD16 *pi2_src, WORD16 *pi2_out, WORD32 out_strd, |
520 | | const UWORD16 *pu2_iscale_mat, const UWORD16 *pu2_weigh_mat, |
521 | | UWORD32 qp_div, WORD16 *pi2_tmp, WORD32 iq_start_idx, |
522 | | WORD16 *pi2_dc_ld_addr) |
523 | 6.41k | { |
524 | 6.41k | WORD32 i; |
525 | 6.41k | WORD16 *pi2_tmp_ptr = pi2_tmp; |
526 | 6.41k | WORD16 *pi2_out_ptr = pi2_out; |
527 | 6.41k | WORD16 i_z0, i_z1, i_z2, i_z3, i_z4, i_z5, i_z6, i_z7; |
528 | 6.41k | WORD16 i_y0, i_y1, i_y2, i_y3, i_y4, i_y5, i_y6, i_y7; |
529 | 6.41k | WORD32 q; |
530 | 6.41k | WORD32 rnd_fact = (qp_div < 6) ? (1 << (5 - qp_div)) : 0; |
531 | 6.41k | UNUSED(iq_start_idx); |
532 | 6.41k | UNUSED(pi2_dc_ld_addr); |
533 | | /*************************************************************/ |
534 | | /* De quantization of coefficients. Will be replaced by SIMD */ |
535 | | /* operations on platform. Note : DC coeff is not scaled */ |
536 | | /*************************************************************/ |
537 | 416k | for(i = 0; i < (SUB_BLK_WIDTH_8x8 * SUB_BLK_WIDTH_8x8); i++) |
538 | 410k | { |
539 | 410k | q = pi2_src[i]; |
540 | 410k | INV_QUANT(q, pu2_iscale_mat[i], pu2_weigh_mat[i], qp_div, rnd_fact, 6); |
541 | 410k | pi2_tmp_ptr[i] = q; |
542 | 410k | } |
543 | | /* Perform Inverse transform */ |
544 | | /*--------------------------------------------------------------------*/ |
545 | | /* IDCT [ Horizontal transformation ] */ |
546 | | /*--------------------------------------------------------------------*/ |
547 | 57.7k | for(i = 0; i < SUB_BLK_WIDTH_8x8; i++) |
548 | 51.3k | { |
549 | | /*------------------------------------------------------------------*/ |
550 | | /* y0 = w0 + w4 */ |
551 | | /* y1 = -w3 + w5 - w7 - (w7 >> 1) */ |
552 | | /* y2 = w0 - w4 */ |
553 | | /* y3 = w1 + w7 - w3 - (w3 >> 1) */ |
554 | | /* y4 = (w2 >> 1) - w6 */ |
555 | | /* y5 = -w1 + w7 + w5 + (w5 >> 1) */ |
556 | | /* y6 = w2 + (w6 >> 1) */ |
557 | | /* y7 = w3 + w5 + w1 + (w1 >> 1) */ |
558 | | /*------------------------------------------------------------------*/ |
559 | 51.3k | i_y0 = (pi2_tmp_ptr[0] + pi2_tmp_ptr[4]); |
560 | | |
561 | 51.3k | i_y1 = |
562 | 51.3k | ((WORD32) (-pi2_tmp_ptr[3]) + pi2_tmp_ptr[5] - pi2_tmp_ptr[7] - (pi2_tmp_ptr[7] >> 1)); |
563 | | |
564 | 51.3k | i_y2 = (pi2_tmp_ptr[0] - pi2_tmp_ptr[4]); |
565 | | |
566 | 51.3k | i_y3 = ((WORD32) pi2_tmp_ptr[1] + pi2_tmp_ptr[7] - pi2_tmp_ptr[3] - (pi2_tmp_ptr[3] >> 1)); |
567 | | |
568 | 51.3k | i_y4 = ((pi2_tmp_ptr[2] >> 1) - pi2_tmp_ptr[6]); |
569 | | |
570 | 51.3k | i_y5 = |
571 | 51.3k | ((WORD32) (-pi2_tmp_ptr[1]) + pi2_tmp_ptr[7] + pi2_tmp_ptr[5] + (pi2_tmp_ptr[5] >> 1)); |
572 | | |
573 | 51.3k | i_y6 = (pi2_tmp_ptr[2] + (pi2_tmp_ptr[6] >> 1)); |
574 | | |
575 | 51.3k | i_y7 = ((WORD32) pi2_tmp_ptr[3] + pi2_tmp_ptr[5] + pi2_tmp_ptr[1] + (pi2_tmp_ptr[1] >> 1)); |
576 | | |
577 | | /*------------------------------------------------------------------*/ |
578 | | /* z0 = y0 + y6 */ |
579 | | /* z1 = y1 + (y7 >> 2) */ |
580 | | /* z2 = y2 + y4 */ |
581 | | /* z3 = y3 + (y5 >> 2) */ |
582 | | /* z4 = y2 - y4 */ |
583 | | /* z5 = (y3 >> 2) - y5 */ |
584 | | /* z6 = y0 - y6 */ |
585 | | /* z7 = y7 - (y1 >> 2) */ |
586 | | /*------------------------------------------------------------------*/ |
587 | 51.3k | i_z0 = i_y0 + i_y6; |
588 | 51.3k | i_z1 = i_y1 + (i_y7 >> 2); |
589 | 51.3k | i_z2 = i_y2 + i_y4; |
590 | 51.3k | i_z3 = i_y3 + (i_y5 >> 2); |
591 | 51.3k | i_z4 = i_y2 - i_y4; |
592 | 51.3k | i_z5 = (i_y3 >> 2) - i_y5; |
593 | 51.3k | i_z6 = i_y0 - i_y6; |
594 | 51.3k | i_z7 = i_y7 - (i_y1 >> 2); |
595 | | |
596 | | /*------------------------------------------------------------------*/ |
597 | | /* x0 = z0 + z7 */ |
598 | | /* x1 = z2 + z5 */ |
599 | | /* x2 = z4 + z3 */ |
600 | | /* x3 = z6 + z1 */ |
601 | | /* x4 = z6 - z1 */ |
602 | | /* x5 = z4 - z3 */ |
603 | | /* x6 = z2 - z5 */ |
604 | | /* x7 = z0 - z7 */ |
605 | | /*------------------------------------------------------------------*/ |
606 | 51.3k | pi2_tmp_ptr[0] = i_z0 + i_z7; |
607 | 51.3k | pi2_tmp_ptr[1] = i_z2 + i_z5; |
608 | 51.3k | pi2_tmp_ptr[2] = i_z4 + i_z3; |
609 | 51.3k | pi2_tmp_ptr[3] = i_z6 + i_z1; |
610 | 51.3k | pi2_tmp_ptr[4] = i_z6 - i_z1; |
611 | 51.3k | pi2_tmp_ptr[5] = i_z4 - i_z3; |
612 | 51.3k | pi2_tmp_ptr[6] = i_z2 - i_z5; |
613 | 51.3k | pi2_tmp_ptr[7] = i_z0 - i_z7; |
614 | | |
615 | | /* move to the next row */ |
616 | | // pi2_src_ptr += SUB_BLK_WIDTH_8x8; |
617 | 51.3k | pi2_tmp_ptr += SUB_BLK_WIDTH_8x8; |
618 | 51.3k | } |
619 | | /*--------------------------------------------------------------------*/ |
620 | | /* IDCT [ Vertical transformation] and Xij = (xij + 32)>>6 */ |
621 | | /* */ |
622 | | /* Add the prediction and store it back to reconstructed frame buffer */ |
623 | | /* [Prediction buffer itself in this case] */ |
624 | | /*--------------------------------------------------------------------*/ |
625 | | |
626 | 6.41k | pi2_tmp_ptr = pi2_tmp; |
627 | 57.7k | for(i = 0; i < SUB_BLK_WIDTH_8x8; i++) |
628 | 51.3k | { |
629 | 51.3k | pi2_out = pi2_out_ptr; |
630 | | /*------------------------------------------------------------------*/ |
631 | | /* y0j = w0j + w4j */ |
632 | | /* y1j = -w3j + w5j -w7j -(w7j >> 1) */ |
633 | | /* y2j = w0j -w4j */ |
634 | | /* y3j = w1j + w7j -w3j -(w3j >> 1) */ |
635 | | /* y4j = ( w2j >> 1 ) -w6j */ |
636 | | /* y5j = -w1j + w7j + w5j + (w5j >> 1) */ |
637 | | /* y6j = w2j + ( w6j >> 1 ) */ |
638 | | /* y7j = w3j + w5j + w1j + (w1j >> 1) */ |
639 | | /*------------------------------------------------------------------*/ |
640 | 51.3k | i_y0 = pi2_tmp_ptr[0] + pi2_tmp_ptr[32]; |
641 | | |
642 | 51.3k | i_y1 = (WORD32) (-pi2_tmp_ptr[24]) + pi2_tmp_ptr[40] - pi2_tmp_ptr[56] - |
643 | 51.3k | (pi2_tmp_ptr[56] >> 1); |
644 | | |
645 | 51.3k | i_y2 = pi2_tmp_ptr[0] - pi2_tmp_ptr[32]; |
646 | | |
647 | 51.3k | i_y3 = (WORD32) pi2_tmp_ptr[8] + pi2_tmp_ptr[56] - pi2_tmp_ptr[24] - (pi2_tmp_ptr[24] >> 1); |
648 | | |
649 | 51.3k | i_y4 = (pi2_tmp_ptr[16] >> 1) - pi2_tmp_ptr[48]; |
650 | | |
651 | 51.3k | i_y5 = |
652 | 51.3k | (WORD32) (-pi2_tmp_ptr[8]) + pi2_tmp_ptr[56] + pi2_tmp_ptr[40] + (pi2_tmp_ptr[40] >> 1); |
653 | | |
654 | 51.3k | i_y6 = pi2_tmp_ptr[16] + (pi2_tmp_ptr[48] >> 1); |
655 | | |
656 | 51.3k | i_y7 = (WORD32) pi2_tmp_ptr[24] + pi2_tmp_ptr[40] + pi2_tmp_ptr[8] + (pi2_tmp_ptr[8] >> 1); |
657 | | |
658 | | /*------------------------------------------------------------------*/ |
659 | | /* z0j = y0j + y6j */ |
660 | | /* z1j = y1j + (y7j >> 2) */ |
661 | | /* z2j = y2j + y4j */ |
662 | | /* z3j = y3j + (y5j >> 2) */ |
663 | | /* z4j = y2j -y4j */ |
664 | | /* z5j = (y3j >> 2) -y5j */ |
665 | | /* z6j = y0j -y6j */ |
666 | | /* z7j = y7j -(y1j >> 2) */ |
667 | | /*------------------------------------------------------------------*/ |
668 | 51.3k | i_z0 = i_y0 + i_y6; |
669 | 51.3k | i_z1 = i_y1 + (i_y7 >> 2); |
670 | 51.3k | i_z2 = i_y2 + i_y4; |
671 | 51.3k | i_z3 = i_y3 + (i_y5 >> 2); |
672 | 51.3k | i_z4 = i_y2 - i_y4; |
673 | 51.3k | i_z5 = (i_y3 >> 2) - i_y5; |
674 | 51.3k | i_z6 = i_y0 - i_y6; |
675 | 51.3k | i_z7 = i_y7 - (i_y1 >> 2); |
676 | | |
677 | | /*------------------------------------------------------------------*/ |
678 | | /* x0j = z0j + z7j */ |
679 | | /* x1j = z2j + z5j */ |
680 | | /* x2j = z4j + z3j */ |
681 | | /* x3j = z6j + z1j */ |
682 | | /* x4j = z6j -z1j */ |
683 | | /* x5j = z4j -z3j */ |
684 | | /* x6j = z2j -z5j */ |
685 | | /* x7j = z0j -z7j */ |
686 | | /*------------------------------------------------------------------*/ |
687 | 51.3k | *pi2_out = CLIP_RSD((i_z0 + i_z7 + 32) >> 6); |
688 | | /* Change uc_recBuffer to Point to next element in the same column*/ |
689 | 51.3k | pi2_out += out_strd; |
690 | | |
691 | 51.3k | *pi2_out = CLIP_RSD((i_z2 + i_z5 + 32) >> 6); |
692 | 51.3k | pi2_out += out_strd; |
693 | | |
694 | 51.3k | *pi2_out = CLIP_RSD((i_z4 + i_z3 + 32) >> 6); |
695 | 51.3k | pi2_out += out_strd; |
696 | | |
697 | 51.3k | *pi2_out = CLIP_RSD((i_z6 + i_z1 + 32) >> 6); |
698 | 51.3k | pi2_out += out_strd; |
699 | | |
700 | 51.3k | *pi2_out = CLIP_RSD((i_z6 - i_z1 + 32) >> 6); |
701 | 51.3k | pi2_out += out_strd; |
702 | | |
703 | 51.3k | *pi2_out = CLIP_RSD((i_z4 - i_z3 + 32) >> 6); |
704 | 51.3k | pi2_out += out_strd; |
705 | | |
706 | 51.3k | *pi2_out = CLIP_RSD((i_z2 - i_z5 + 32) >> 6); |
707 | 51.3k | pi2_out += out_strd; |
708 | | |
709 | 51.3k | *pi2_out = CLIP_RSD((i_z0 - i_z7 + 32) >> 6); |
710 | | |
711 | 51.3k | pi2_tmp_ptr++; |
712 | 51.3k | pi2_out_ptr++; |
713 | 51.3k | } |
714 | 6.41k | } |