/src/libavc/decoder/svc/isvcd_intra_resamp.c
Line | Count | Source |
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_intra_resamp.c |
24 | | * |
25 | | * @brief |
26 | | * Contains routines that resample for SVC resampling |
27 | | * |
28 | | * @author |
29 | | * Kishore |
30 | | * |
31 | | * @par List of Functions: |
32 | | * - isvcd_get_ceil_log2() |
33 | | * - isvcd_2d_memset() |
34 | | * - isvcd_copy_data() |
35 | | * - isvcd_copy_data_semiplanr() |
36 | | * - isvcd_get_ref_layer_avlblty_dyadic() |
37 | | * - isvcd_diagonal_construct_dyadic() |
38 | | * - isvcd_left_right_padding() |
39 | | * - isvcd_left_right_padding_chroma() |
40 | | * - isvcd_top_bot_padding() |
41 | | * - isvcd_top_bot_padding_chroma() |
42 | | * - isvcd_diag_reconstruction() |
43 | | * - isvcd_diag_reconstruction_chroma() |
44 | | * - isvcd_diag_padding() |
45 | | * - isvcd_diag_padding_chroma() |
46 | | * - isvcd_corner_samp_dyadic() |
47 | | * - isvcd_fill_non_avail_pixel() |
48 | | * - isvcd_get_ref_layer_mbtype() |
49 | | * - isvcd_reflayer_construction() |
50 | | * - isvcd_reflayer_construction_dyadic() |
51 | | * - isvcd_interpolate_base_luma_dyadic() |
52 | | * - isvcd_vert_interpol_chroma_dyadic_1() |
53 | | * - isvcd_vert_interpol_chroma_dyadic_2() |
54 | | * - isvcd_vert_interpol_chroma_dyadic_3() |
55 | | * - isvcd_horz_interpol_chroma_dyadic_1() |
56 | | * - isvcd_horz_interpol_chroma_dyadic_2() |
57 | | * - isvcd_intra_resamp_mb_dyadic() |
58 | | * - isvcd_interpolate_intra_base() |
59 | | * - isvcd_intra_resamp_mb() |
60 | | * - isvcd_intra_resamp_generate_segment_lookup() |
61 | | * - isvcd_intra_resamp_populate_list() |
62 | | * - isvcd_populate_res_prms() |
63 | | * - isvcd_crop_wnd_flag_res_int() |
64 | | * - isvcd_intra_resamp_res_init() |
65 | | * |
66 | | * @remarks |
67 | | * None |
68 | | * |
69 | | ******************************************************************************* |
70 | | */ |
71 | | |
72 | | #include <assert.h> |
73 | | #include <string.h> |
74 | | |
75 | | #include "ih264_typedefs.h" |
76 | | #include "ih264_macros.h" |
77 | | #include "ih264_platform_macros.h" |
78 | | #include "ih264d_bitstrm.h" |
79 | | #include "ih264d_defs.h" |
80 | | #include "ih264d_debug.h" |
81 | | #include "isvcd_structs.h" |
82 | | #include "ih264d_parse_cavlc.h" |
83 | | #include "ih264d_mb_utils.h" |
84 | | #include "ih264d_deblocking.h" |
85 | | #include "ih264d_dpb_manager.h" |
86 | | #include "ih264d_mvpred.h" |
87 | | #include "ih264d_inter_pred.h" |
88 | | #include "ih264d_process_pslice.h" |
89 | | #include "ih264d_error_handler.h" |
90 | | #include "ih264d_cabac.h" |
91 | | #include "ih264d_tables.h" |
92 | | #include "ih264d_parse_slice.h" |
93 | | #include "ih264d_utils.h" |
94 | | #include "ih264d_parse_islice.h" |
95 | | #include "ih264d_process_bslice.h" |
96 | | #include "ih264d_process_intra_mb.h" |
97 | | #include "ih264_debug.h" |
98 | | |
99 | | ftype_intra_samp_padding *gpf_lookup_fxns_luma[32] = { |
100 | | NULL, |
101 | | NULL, |
102 | | NULL, |
103 | | NULL, |
104 | | NULL, |
105 | | NULL, |
106 | | NULL, |
107 | | NULL, |
108 | | NULL, |
109 | | &isvcd_left_right_padding, |
110 | | NULL, |
111 | | &isvcd_diag_reconstruction, |
112 | | NULL, |
113 | | &isvcd_left_right_padding, |
114 | | NULL, |
115 | | &isvcd_diag_reconstruction, |
116 | | NULL, |
117 | | NULL, |
118 | | &isvcd_top_bot_padding, |
119 | | &isvcd_diag_reconstruction, |
120 | | NULL, |
121 | | NULL, |
122 | | &isvcd_top_bot_padding, |
123 | | &isvcd_diag_reconstruction, |
124 | | NULL, |
125 | | &isvcd_left_right_padding, |
126 | | &isvcd_top_bot_padding, |
127 | | &isvcd_diag_reconstruction, |
128 | | &isvcd_diag_padding, |
129 | | &isvcd_left_right_padding, |
130 | | &isvcd_top_bot_padding, |
131 | | &isvcd_diag_reconstruction, |
132 | | }; |
133 | | |
134 | | ftype_intra_samp_padding *gpf_lookup_fxns_chroma[32] = { |
135 | | NULL, |
136 | | NULL, |
137 | | NULL, |
138 | | NULL, |
139 | | NULL, |
140 | | NULL, |
141 | | NULL, |
142 | | NULL, |
143 | | NULL, |
144 | | &isvcd_left_right_padding_chroma, |
145 | | NULL, |
146 | | &isvcd_diag_reconstruction_chroma, |
147 | | NULL, |
148 | | &isvcd_left_right_padding_chroma, |
149 | | NULL, |
150 | | &isvcd_diag_reconstruction_chroma, |
151 | | NULL, |
152 | | NULL, |
153 | | &isvcd_top_bot_padding_chroma, |
154 | | &isvcd_diag_reconstruction_chroma, |
155 | | NULL, |
156 | | NULL, |
157 | | &isvcd_top_bot_padding_chroma, |
158 | | &isvcd_diag_reconstruction_chroma, |
159 | | NULL, |
160 | | &isvcd_left_right_padding_chroma, |
161 | | &isvcd_top_bot_padding_chroma, |
162 | | &isvcd_diag_reconstruction_chroma, |
163 | | &isvcd_diag_padding_chroma, |
164 | | &isvcd_left_right_padding_chroma, |
165 | | &isvcd_top_bot_padding_chroma, |
166 | | &isvcd_diag_reconstruction_chroma, |
167 | | }; |
168 | | |
169 | | const UWORD32 gu4_valid_segs_lookup[16] = { |
170 | | 0x0F000000, 0xCF000000, 0x3F000000, 0xFF000000, 0x0F000000, 0xCF000000, 0x3F000000, 0xFF000000, |
171 | | 0x0F000000, 0x8F000000, 0x6F000000, 0xEF000000, 0x1F000000, 0x9F000000, 0x7F000000, 0xFF000000}; |
172 | | |
173 | | const WORD8 g_ai1_interp_filter_luma[64] = { |
174 | | 0, -1, -2, -3, -3, -4, -4, -3, -3, -3, -2, -1, -1, -1, -1, -1, 32, 32, 31, 30, 28, 26, |
175 | | 24, 22, 19, 16, 14, 11, 8, 6, 4, 2, 0, 2, 4, 6, 8, 11, 14, 16, 19, 22, 24, 26, |
176 | | 28, 30, 31, 32, 0, -1, -1, -1, -1, -1, -2, -3, -3, -3, -4, -4, -3, -3, -2, -1}; |
177 | | |
178 | | const UWORD8 g_au1_interp_filter_chroma[32] = {32, 30, 28, 26, 24, 22, 20, 18, 16, 14, 12, |
179 | | 10, 8, 6, 4, 2, 0, 2, 4, 6, 8, 10, |
180 | | 12, 14, 16, 18, 20, 22, 24, 26, 28, 30}; |
181 | | |
182 | | WORD32 ref_pos_luma[4][16] = {{10, 11, 12, 12, 13, 14, 14, 15, 16, 16, 17, 18, 18, 19, 20, 20}, |
183 | | {10, 10, 11, 12, 12, 13, 14, 14, 15, 16, 16, 17, 18, 18, 19, 20}, |
184 | | {2, 3, 3, 4, 5, 5, 6, 7, 7, 8, 9, 9, 10, 11, 11, 12}, |
185 | | {2, 3, 4, 4, 5, 6, 6, 7, 8, 8, 9, 10, 10, 11, 12, 12}}; |
186 | | WORD32 ref_pos_chroma[4][8] = {{6, 7, 8, 8, 9, 10, 10, 11}, |
187 | | {6, 7, 7, 8, 9, 9, 10, 11}, |
188 | | {6, 6, 7, 8, 8, 9, 10, 10}, |
189 | | {2, 3, 4, 4, 5, 6, 6, 7}}; |
190 | | |
191 | | WORD32 phase_luma[3][16] = {{13, 8, 3, 13, 8, 3, 13, 8, 3, 13, 8, 3, 13, 8, 3, 13}, |
192 | | {8, 3, 13, 8, 3, 13, 8, 3, 13, 8, 3, 13, 8, 3, 13, 8}, |
193 | | {3, 13, 8, 3, 13, 8, 3, 13, 8, 3, 13, 8, 3, 13, 8, 3}}; |
194 | | |
195 | | UWORD8 phase_luma_u8[3][16] = {{13, 8, 3, 13, 8, 3, 13, 8, 3, 13, 8, 3, 13, 8, 3, 13}, |
196 | | {8, 3, 13, 8, 3, 13, 8, 3, 13, 8, 3, 13, 8, 3, 13, 8}, |
197 | | {3, 13, 8, 3, 13, 8, 3, 13, 8, 3, 13, 8, 3, 13, 8, 3}}; |
198 | | |
199 | | WORD8 phase_luma_x86[6][16] = {{13, 8, 3, 13, 8, 3, 13, 8, 0, 0, 0, 0, 0, 0, 0, 0}, |
200 | | {3, 13, 8, 3, 13, 8, 3, 13, 0, 0, 0, 0, 0, 0, 0, 0}, |
201 | | {8, 3, 13, 8, 3, 13, 8, 3, 0, 0, 0, 0, 0, 0, 0, 0}, |
202 | | {13, 8, 3, 13, 8, 3, 13, 8, 0, 0, 0, 0, 0, 0, 0, 0}, |
203 | | {3, 13, 8, 3, 13, 8, 3, 13, 0, 0, 0, 0, 0, 0, 0, 0}, |
204 | | {8, 3, 13, 8, 3, 13, 8, 3, 0, 0, 0, 0, 0, 0, 0, 0}}; |
205 | | |
206 | | WORD32 phase_chroma[3][8] = { |
207 | | {13, 8, 3, 13, 8, 3, 13, 8}, {3, 13, 8, 3, 13, 8, 3, 13}, {8, 3, 13, 8, 3, 13, 8, 3}}; |
208 | | |
209 | | UWORD8 phase_chroma_u8[3][8] = { |
210 | | {13, 8, 3, 13, 8, 3, 13, 8}, {3, 13, 8, 3, 13, 8, 3, 13}, {8, 3, 13, 8, 3, 13, 8, 3}}; |
211 | | |
212 | | UWORD8 ref_pos_luma_mask_m48[8][16] = {{0, 1, 2, 3, 4, 5, 4, 5, 6, 7, 8, 9, 8, 9, 10, 11}, |
213 | | {2, 3, 2, 3, 4, 5, 6, 7, 6, 7, 8, 9, 10, 11, 10, 11}, |
214 | | {2, 3, 4, 5, 6, 7, 6, 7, 8, 9, 10, 11, 10, 11, 12, 13}, |
215 | | {4, 5, 4, 5, 6, 7, 8, 9, 8, 9, 10, 11, 12, 13, 12, 13}, |
216 | | {4, 5, 6, 7, 8, 9, 8, 9, 10, 11, 12, 13, 12, 13, 14, 15}, |
217 | | {6, 7, 6, 7, 8, 9, 10, 11, 10, 11, 12, 13, 14, 15, 14, 15}, |
218 | | {0, 1, 2, 3, 4, 5, 4, 5, 6, 7, 8, 9, 8, 9, 10, 11}, |
219 | | {4, 5, 4, 5, 6, 7, 8, 9, 8, 9, 10, 11, 12, 13, 12, 13}}; |
220 | | |
221 | | UWORD8 ref_pos_luma_mask_m16[8][16] = {{0, 1, 2, 3, 2, 3, 4, 5, 6, 7, 6, 7, 8, 9, 10, 11}, |
222 | | {0, 1, 2, 3, 4, 5, 4, 5, 6, 7, 8, 9, 8, 9, 10, 11}, |
223 | | {2, 3, 4, 5, 4, 5, 6, 7, 8, 9, 8, 9, 10, 11, 12, 13}, |
224 | | {2, 3, 4, 5, 6, 7, 6, 7, 8, 9, 10, 11, 10, 11, 12, 13}, |
225 | | {4, 5, 6, 7, 6, 7, 8, 9, 10, 11, 10, 11, 12, 13, 14, 15}, |
226 | | {4, 5, 6, 7, 8, 9, 8, 9, 10, 11, 12, 13, 12, 13, 14, 15}, |
227 | | {0, 1, 2, 3, 2, 3, 4, 5, 6, 7, 6, 7, 8, 9, 10, 11}, |
228 | | {2, 3, 4, 5, 6, 7, 6, 7, 8, 9, 10, 11, 10, 11, 12, 13}}; |
229 | | |
230 | | UWORD8 ref_pos_luma_mask_m32[8][16] = {{0, 1, 0, 1, 2, 3, 4, 5, 4, 5, 6, 7, 8, 9, 8, 9}, |
231 | | {0, 1, 2, 3, 2, 3, 4, 5, 6, 7, 6, 7, 8, 9, 10, 11}, |
232 | | {2, 3, 2, 3, 4, 5, 6, 7, 6, 7, 8, 9, 10, 11, 10, 11}, |
233 | | {2, 3, 4, 5, 4, 5, 6, 7, 8, 9, 8, 9, 10, 11, 12, 13}, |
234 | | {4, 5, 4, 5, 6, 7, 8, 9, 8, 9, 10, 11, 12, 13, 12, 13}, |
235 | | {4, 5, 6, 7, 6, 7, 8, 9, 10, 11, 10, 11, 12, 13, 14, 15}, |
236 | | {0, 1, 0, 1, 2, 3, 4, 5, 4, 5, 6, 7, 8, 9, 8, 9}, |
237 | | {2, 3, 4, 5, 4, 5, 6, 7, 8, 9, 8, 9, 10, 11, 12, 13}}; |
238 | | |
239 | | UWORD8 ref_pos_chroma_mask_m24[2][16] = {{0, 1, 2, 3, 4, 5, 4, 5, 6, 7, 8, 9, 8, 9, 10, 11}, |
240 | | {2, 3, 4, 5, 6, 7, 6, 7, 8, 9, 10, 11, 10, 11, 12, 13}}; |
241 | | UWORD8 ref_pos_chroma_mask_m8[2][16] = {{0, 1, 0, 1, 2, 3, 4, 5, 4, 5, 6, 7, 8, 9, 8, 9}, |
242 | | {2, 3, 2, 3, 4, 5, 6, 7, 6, 7, 8, 9, 10, 11, 10, 11}}; |
243 | | UWORD8 ref_pos_chroma_mask_m16[2][16] = {{0, 1, 2, 3, 2, 3, 4, 5, 6, 7, 6, 7, 8, 9, 10, 11}, |
244 | | {2, 3, 4, 5, 4, 5, 6, 7, 8, 9, 8, 9, 10, 11, 12, 13}}; |
245 | | |
246 | | /*****************************************************************************/ |
247 | | /* */ |
248 | | /* Function Name : isvcd_get_ceil_log2 */ |
249 | | /* */ |
250 | | /* Description : this function returns the CeilLog2 of the given number */ |
251 | | /* */ |
252 | | /* */ |
253 | | /* Inputs : i4_input : input number */ |
254 | | /* Globals : none */ |
255 | | /* Processing : it calculate the bits and returns it */ |
256 | | /* */ |
257 | | /* Outputs : none */ |
258 | | /* Returns : ceil of log to base 2 */ |
259 | | /* */ |
260 | | /* Issues : none */ |
261 | | /* */ |
262 | | /* Revision History: */ |
263 | | /* */ |
264 | | /* DD MM YYYY Author(s) Changes (Describe the changes made) */ |
265 | | /* 06 09 2021 vijayakumar creation */ |
266 | | /* */ |
267 | | /*****************************************************************************/ |
268 | | WORD32 isvcd_get_ceil_log2(WORD32 i4_input) |
269 | 19.6k | { |
270 | 19.6k | WORD32 i4_bits = 0; |
271 | | |
272 | 19.6k | i4_input--; |
273 | 126k | while(i4_input > 0) |
274 | 106k | { |
275 | 106k | i4_bits++; |
276 | 106k | i4_input >>= 1; |
277 | 106k | } |
278 | 19.6k | return (i4_bits); |
279 | 19.6k | } |
280 | | |
281 | | /*****************************************************************************/ |
282 | | /* */ |
283 | | /* Function Name : isvcd_2d_memset */ |
284 | | /* */ |
285 | | /* Description : Function performs 2D memset operation */ |
286 | | /* */ |
287 | | /* */ |
288 | | /* Inputs : 1. Buffer pointer */ |
289 | | /* 2. width */ |
290 | | /* 3. Height */ |
291 | | /* 4. Stride */ |
292 | | /* 5. value */ |
293 | | /* Globals : None */ |
294 | | /* Processing : calls memset fucntion */ |
295 | | /* */ |
296 | | /* Outputs : Updates the buffer */ |
297 | | /* Returns : status */ |
298 | | /* */ |
299 | | /* Issues : None */ |
300 | | /* */ |
301 | | /* Revision History: */ |
302 | | /* */ |
303 | | /* DD MM YYYY Author(s) Changes (Describe the changes made) */ |
304 | | /* 24 09 2021 Vijay Draft */ |
305 | | /* */ |
306 | | /*****************************************************************************/ |
307 | | void isvcd_2d_memset(void *pv_buf, WORD32 i4_width, WORD32 i4_ht, WORD32 i4_stride, WORD32 i4_val) |
308 | 0 | { |
309 | 0 | WORD32 i4_y; |
310 | 0 | UWORD8 *pu1_buf; |
311 | |
|
312 | 0 | pu1_buf = (UWORD8 *) pv_buf; |
313 | |
|
314 | 0 | for(i4_y = 0; i4_y < i4_ht; i4_y++) |
315 | 0 | { |
316 | 0 | memset(pu1_buf, i4_val, i4_width); |
317 | | /* Increment the pointer */ |
318 | 0 | pu1_buf += i4_stride; |
319 | 0 | } |
320 | 0 | } |
321 | | |
322 | | /*****************************************************************************/ |
323 | | /* */ |
324 | | /* Function Name : isvcd_copy_data */ |
325 | | /* */ |
326 | | /* Description : this module copies the data from source to destination */ |
327 | | /* the amount of data to be copied is passed as input */ |
328 | | /* */ |
329 | | /* Inputs : pu1_src : pointer to the source buffer */ |
330 | | /* u2_src_stride : source buffer stride */ |
331 | | /* pu1_dst : pointer to the destination buffer */ |
332 | | /* u2_dst_stride : destination buffer stride */ |
333 | | /* u4_num_bytes : number of bytes to be copied */ |
334 | | /* u4_num_lines : number of lines to be copied */ |
335 | | /* Globals : none */ |
336 | | /* Processing : it does a memcpy from source to destination */ |
337 | | /* */ |
338 | | /* Outputs : none */ |
339 | | /* Returns : none */ |
340 | | /* Issues : both buffers are assumed to be 2-D buffers */ |
341 | | /* */ |
342 | | /* Revision History: */ |
343 | | /* */ |
344 | | /* DD MM YYYY Author(s) Changes (Describe the changes made) */ |
345 | | /* 29 09 2021 vijayakumar creation */ |
346 | | /* */ |
347 | | /*****************************************************************************/ |
348 | | void isvcd_copy_data(UWORD8 *pu1_src, WORD32 i4_src_stride, UWORD8 *pu1_dst, WORD32 i4_dst_stride, |
349 | | WORD32 i4_num_bytes, WORD32 i4_num_lines) |
350 | 165k | { |
351 | 165k | WORD32 i4_vert_lines; |
352 | | |
353 | | /* loop for copy all the lines requried */ |
354 | 2.66M | for(i4_vert_lines = 0; i4_vert_lines < i4_num_lines; i4_vert_lines++) |
355 | 2.50M | { |
356 | 2.50M | memcpy(pu1_dst, pu1_src, i4_num_bytes); |
357 | 2.50M | pu1_src += i4_src_stride; |
358 | 2.50M | pu1_dst += i4_dst_stride; |
359 | 2.50M | } |
360 | 165k | return; |
361 | 165k | } |
362 | | |
363 | | /*****************************************************************************/ |
364 | | /* */ |
365 | | /* Function Name : isvcd_copy_data_semiplanr */ |
366 | | /* */ |
367 | | /* Description : this module copies the data from source to destination */ |
368 | | /* the amount of data to be copied is passed as input */ |
369 | | /* */ |
370 | | /* Inputs : pu1_src : pointer to the source buffer */ |
371 | | /* i4_src_stride : source buffer stride */ |
372 | | /* pu1_dst1 : pointer to the destination buffer 1 */ |
373 | | /* pu1_dst2 : pointer to the destination buffer 2 */ |
374 | | /* i4_dst_stride : destination buffer stride */ |
375 | | /* i4_num_bytes : number of bytes to be copied */ |
376 | | /* i4_num_lines : number of lines to be copied */ |
377 | | /* Globals : none */ |
378 | | /* Processing : it does a memcpy from source to destination */ |
379 | | /* */ |
380 | | /* Outputs : none */ |
381 | | /* Returns : none */ |
382 | | /* Issues : both buffers are assumed to be 2-D buffers */ |
383 | | /* */ |
384 | | /* Revision History: */ |
385 | | /* */ |
386 | | /* DD MM YYYY Author(s) Changes (Describe the changes made) */ |
387 | | /* 29 09 2021 vijayakumar creation */ |
388 | | /* */ |
389 | | /*****************************************************************************/ |
390 | | void isvcd_copy_data_semiplanr(UWORD8 *pu1_src, WORD32 i4_src_stride, UWORD8 *pu1_dst1, |
391 | | UWORD8 *pu1_dst2, WORD32 i4_dst_stride, WORD32 i4_num_bytes, |
392 | | WORD32 i4_num_lines) |
393 | 107k | { |
394 | 107k | WORD32 i4_vert_lines, u4_i; |
395 | | |
396 | | /* loop for copy all the lines requried */ |
397 | 1.43M | for(i4_vert_lines = 0; i4_vert_lines < i4_num_lines; i4_vert_lines++) |
398 | 1.33M | { |
399 | 17.2M | for(u4_i = 0; u4_i < i4_num_bytes; u4_i++) |
400 | 15.9M | { |
401 | 15.9M | *(pu1_dst1 + u4_i) = *(pu1_src + (2 * u4_i)); |
402 | 15.9M | *(pu1_dst2 + u4_i) = *(pu1_src + (2 * u4_i) + 1); |
403 | 15.9M | } |
404 | | |
405 | 1.33M | pu1_src += i4_src_stride; |
406 | 1.33M | pu1_dst1 += i4_dst_stride; |
407 | 1.33M | pu1_dst2 += i4_dst_stride; |
408 | 1.33M | } |
409 | 107k | return; |
410 | 107k | } |
411 | | |
412 | | /*****************************************************************************/ |
413 | | /* */ |
414 | | /* Function Name : isvcd_get_ref_layer_avlblty_dyadic */ |
415 | | /* */ |
416 | | /* Description : This function is used to find the mb type of the */ |
417 | | /* corresponding MB in the reference layer for dyadic cases */ |
418 | | /* */ |
419 | | /* Inputs : pv_intra_samp_ctxt : intra samp context */ |
420 | | /* pi1_ref_mb_modes : ref mb modes buffer pointer */ |
421 | | /* i4_ref_mode_stride : mb mode buffer stride */ |
422 | | /* i4_ref_mb_x : reference MB location X */ |
423 | | /* i4_ref_mb_y : reference MB location Y */ |
424 | | /* pi4_mb_type : pointer to store the mb type */ |
425 | | /* i1_curr_slice_id : slice id of current MB */ |
426 | | /* i1_cons_intr_samp_flag :constrained intra resampling flag*/ |
427 | | /* Globals : none */ |
428 | | /* Processing : it derives the bit corresponding to reference MB and */ |
429 | | /* stores the mbtype as INTRA if the bit is set */ |
430 | | /* Outputs : none */ |
431 | | /* Returns : none */ |
432 | | /* */ |
433 | | /* Issues : none */ |
434 | | /* */ |
435 | | /* Revision History: */ |
436 | | /* */ |
437 | | /* DD MM YYYY Author(s) Changes (Describe the changes made) */ |
438 | | /* 26 09 2021 vijayakumar creation */ |
439 | | /* */ |
440 | | /*****************************************************************************/ |
441 | | void isvcd_get_ref_layer_avlblty_dyadic(WORD8 *pi1_ref_mb_modes, WORD32 i4_ref_mode_stride, |
442 | | WORD32 i4_element_size, WORD32 i4_ref_mb_x, |
443 | | WORD32 i4_ref_mb_y, WORD32 *pi4_avlblty, |
444 | | WORD8 i1_curr_slice_id, WORD8 i1_cons_intr_samp_flag) |
445 | 305k | { |
446 | 305k | inter_lyr_mb_prms_t *ps_inter_lyr_mb_prms; |
447 | 305k | WORD8 i1_mb_mode; |
448 | | |
449 | | /* get the location of the byte which has the current mb mode */ |
450 | 305k | pi1_ref_mb_modes += (i4_ref_mb_y * i4_ref_mode_stride * i4_element_size); |
451 | 305k | pi1_ref_mb_modes += (i4_ref_mb_x * i4_element_size); |
452 | 305k | ps_inter_lyr_mb_prms = (inter_lyr_mb_prms_t *) pi1_ref_mb_modes; |
453 | 305k | i1_mb_mode = ps_inter_lyr_mb_prms->i1_mb_mode; |
454 | | |
455 | 305k | if(i1_mb_mode <= SVC_INTER_MB) |
456 | 256k | { |
457 | | /* INTER */ |
458 | 256k | *pi4_avlblty = 0; |
459 | 256k | } |
460 | 48.3k | else |
461 | 48.3k | { |
462 | | /* INTRA */ |
463 | 48.3k | *pi4_avlblty = 1; |
464 | 48.3k | } |
465 | | |
466 | | /* if constrained intra flag is 1 then check for same slice id */ |
467 | 305k | if(1 == i1_cons_intr_samp_flag) |
468 | 184k | { |
469 | 184k | if(1 == *pi4_avlblty) |
470 | 27.9k | { |
471 | | /* check for different slice idc */ |
472 | 27.9k | if(ps_inter_lyr_mb_prms->i1_slice_id != i1_curr_slice_id) |
473 | 3.25k | { |
474 | | /* store the mode as not available for upsampling */ |
475 | 3.25k | *pi4_avlblty = 0; |
476 | 3.25k | } |
477 | 27.9k | } |
478 | 184k | } |
479 | 305k | } |
480 | | /*****************************************************************************/ |
481 | | /* */ |
482 | | /* Function Name : isvcd_diagonal_construct_dyadic */ |
483 | | /* */ |
484 | | /* Description : This function fills the unavaible pixels in the reference*/ |
485 | | /* array with diagonally constructed samples */ |
486 | | /* Inputs : i4_x :current position in reference array X to be filled */ |
487 | | /* i4_y :current position in reference array Y to be filled */ |
488 | | /* i4_xd_index : diagonal index in horizontal direction */ |
489 | | /* i4_yd_index : diagonal index in vertical direction */ |
490 | | /* pu1_refarray : popinter to reference array */ |
491 | | /* i4_refarray_wd: width of the reference array */ |
492 | | /* Globals : none */ |
493 | | /* Processing : Fills the sample which is unavailable with filtered */ |
494 | | /* diagonal samples */ |
495 | | /* Outputs : pixel filled */ |
496 | | /* Returns : constructed pixel */ |
497 | | /* */ |
498 | | /* Issues : none */ |
499 | | /* */ |
500 | | /* Revision History: */ |
501 | | /* */ |
502 | | /* DD MM YYYY Author(s) Changes (Describe the changes made) */ |
503 | | /* 06 09 2021 Kishore creation */ |
504 | | /* */ |
505 | | /*****************************************************************************/ |
506 | | UWORD8 isvcd_diagonal_construct_dyadic(WORD32 i4_x, WORD32 i4_y, WORD32 i4_xd_index, |
507 | | WORD32 i4_yd_index, UWORD8 *pu1_refarray, |
508 | | WORD32 i4_refarray_wd) |
509 | 359k | { |
510 | 359k | WORD32 i4_diff_hor_ver, i4_sgn_xy; |
511 | 359k | WORD32 i4_xc, i4_yc; |
512 | 359k | WORD32 i4_samp1, i4_samp2, i4_samp3; |
513 | 359k | WORD32 i4_result; |
514 | 359k | UWORD8 *pu1_tmp; |
515 | | |
516 | 359k | i4_diff_hor_ver = ABS(i4_xd_index) - ABS(i4_yd_index); |
517 | 359k | i4_sgn_xy = SIGN(i4_xd_index * i4_yd_index); |
518 | | |
519 | 359k | if(i4_diff_hor_ver > 0) |
520 | 146k | { |
521 | 146k | i4_xc = i4_x - (i4_sgn_xy * i4_yd_index); |
522 | 146k | i4_yc = i4_y - i4_yd_index; |
523 | 146k | pu1_tmp = pu1_refarray + (i4_yc * i4_refarray_wd); |
524 | 146k | i4_samp1 = pu1_tmp[i4_xc - 1]; |
525 | 146k | i4_samp2 = pu1_tmp[i4_xc]; |
526 | 146k | i4_samp3 = pu1_tmp[i4_xc + 1]; |
527 | 146k | } |
528 | 212k | else if(i4_diff_hor_ver < 0) |
529 | 157k | { |
530 | 157k | i4_xc = i4_x - i4_xd_index; |
531 | 157k | i4_yc = i4_y - (i4_sgn_xy * i4_xd_index); |
532 | 157k | pu1_tmp = pu1_refarray + ((i4_yc - 1) * i4_refarray_wd); |
533 | 157k | i4_samp1 = pu1_tmp[i4_xc]; |
534 | 157k | pu1_tmp += i4_refarray_wd; |
535 | 157k | i4_samp2 = pu1_tmp[i4_xc]; |
536 | 157k | pu1_tmp += i4_refarray_wd; |
537 | 157k | i4_samp3 = pu1_tmp[i4_xc]; |
538 | 157k | } |
539 | 55.6k | else |
540 | 55.6k | { |
541 | 55.6k | WORD32 i4_ref_xd, i4_ref_yd; |
542 | | |
543 | 55.6k | i4_ref_xd = i4_x - i4_xd_index; |
544 | 55.6k | i4_ref_yd = i4_y - i4_yd_index; |
545 | 55.6k | i4_xc = i4_ref_xd + SIGN(i4_xd_index); |
546 | 55.6k | i4_yc = i4_ref_yd + SIGN(i4_yd_index); |
547 | 55.6k | pu1_tmp = pu1_refarray + (i4_ref_yd * i4_refarray_wd); |
548 | 55.6k | i4_samp1 = pu1_tmp[i4_xc]; |
549 | 55.6k | i4_samp2 = pu1_tmp[i4_ref_xd]; |
550 | 55.6k | pu1_tmp = pu1_refarray + (i4_yc * i4_refarray_wd); |
551 | 55.6k | i4_samp3 = pu1_tmp[i4_ref_xd]; |
552 | 55.6k | } |
553 | | |
554 | 359k | i4_result = (i4_samp1 + (i4_samp2 << 1) + i4_samp3 + 2) >> 2; |
555 | 359k | pu1_tmp = pu1_refarray + (i4_y * i4_refarray_wd); |
556 | | /* Store the filled sample */ |
557 | 359k | pu1_tmp[i4_x] = i4_result; |
558 | | |
559 | 359k | return (i4_result); |
560 | 359k | } |
561 | | |
562 | | /*****************************************************************************/ |
563 | | /* */ |
564 | | /* Function Name : isvcd_left_right_padding */ |
565 | | /* Description : This function does the left/right padding for intra */ |
566 | | /* upsampling */ |
567 | | /* */ |
568 | | /* Inputs : */ |
569 | | /* Globals : none */ |
570 | | /* Processing : This function does the left/right padding for intra */ |
571 | | /* upsampling */ |
572 | | /* Outputs : none */ |
573 | | /* Returns : number of leading zeroes */ |
574 | | /* Issues : none */ |
575 | | /* Revision History: */ |
576 | | /* DD MM YYYY Author(s) Changes (Describe the changes made) */ |
577 | | /* 06 09 2021 Vijay creation */ |
578 | | /*****************************************************************************/ |
579 | | void isvcd_left_right_padding(WORD32 i4_x, WORD32 i4_y, WORD8 i1_xd_index, WORD8 i1_yd_index, |
580 | | UWORD8 u1_seg_wd, UWORD8 u1_seg_ht, UWORD8 *pu1_refarray_1, |
581 | | UWORD8 *pu1_refarray_2, WORD32 i4_refarray_stride, |
582 | | WORD32 i4_mb_adjoin_x, WORD32 i4_mb_adjoin_y, |
583 | | WORD32 i4_corner_pixel_available) |
584 | 36.4k | { |
585 | 36.4k | WORD32 i4_idx_i; |
586 | 36.4k | UWORD8 *pu1_src, *pu1_dst; |
587 | | |
588 | 36.4k | UNUSED(i1_yd_index); |
589 | 36.4k | UNUSED(pu1_refarray_2); |
590 | 36.4k | UNUSED(i4_mb_adjoin_x); |
591 | 36.4k | UNUSED(i4_mb_adjoin_y); |
592 | 36.4k | UNUSED(i4_corner_pixel_available); |
593 | | |
594 | 36.4k | pu1_dst = pu1_refarray_1 + i4_x + (i4_y * i4_refarray_stride); |
595 | 36.4k | pu1_src = pu1_dst + i1_xd_index; |
596 | 36.4k | i1_xd_index = MIN(i1_xd_index, MAX_PIX_FILL_LUMA); |
597 | 36.4k | u1_seg_wd = MIN(u1_seg_wd, MAX_PIX_FILL_LUMA); |
598 | 36.4k | pu1_dst = pu1_src - i1_xd_index; |
599 | | |
600 | 276k | for(i4_idx_i = 0; i4_idx_i < u1_seg_ht; i4_idx_i++) |
601 | 239k | { |
602 | 239k | memset(pu1_dst, *pu1_src, u1_seg_wd); |
603 | 239k | pu1_dst += i4_refarray_stride; |
604 | 239k | pu1_src += i4_refarray_stride; |
605 | 239k | } |
606 | 36.4k | } |
607 | | /*****************************************************************************/ |
608 | | /* */ |
609 | | /* Function Name : isvcd_left_right_padding_chroma */ |
610 | | /* Description : This function does the left/right padding for intra */ |
611 | | /* upsampling for chroma */ |
612 | | /* */ |
613 | | /* Inputs : */ |
614 | | /* Globals : none */ |
615 | | /* Processing : This function does the left/right padding for intra */ |
616 | | /* upsampling for chroma */ |
617 | | /* Outputs : none */ |
618 | | /* Returns : none */ |
619 | | /* Issues : none */ |
620 | | /* Revision History: */ |
621 | | /* DD MM YYYY Author(s) Changes (Describe the changes made) */ |
622 | | /* 06 09 2011 Vijay creation */ |
623 | | /*****************************************************************************/ |
624 | | void isvcd_left_right_padding_chroma(WORD32 i4_x, WORD32 i4_y, WORD8 i1_xd_index, WORD8 i1_yd_index, |
625 | | UWORD8 u1_seg_wd, UWORD8 u1_seg_ht, UWORD8 *pu1_refarray_1, |
626 | | UWORD8 *pu1_refarray_2, WORD32 i4_refarray_stride, |
627 | | WORD32 i4_mb_adjoin_x, WORD32 i4_mb_adjoin_y, |
628 | | WORD32 i4_corner_pixel_available) |
629 | 36.6k | { |
630 | 36.6k | WORD32 i4_idx_i; |
631 | 36.6k | UWORD8 *pu1_src_cb, *pu1_dst_cb; |
632 | 36.6k | UWORD8 *pu1_src_cr, *pu1_dst_cr; |
633 | 36.6k | WORD32 i4_tmp; |
634 | | |
635 | 36.6k | UNUSED(i1_yd_index); |
636 | 36.6k | UNUSED(i4_mb_adjoin_x); |
637 | 36.6k | UNUSED(i4_mb_adjoin_y); |
638 | 36.6k | UNUSED(i4_corner_pixel_available); |
639 | | |
640 | 36.6k | i4_tmp = i4_x + (i4_y * i4_refarray_stride); |
641 | 36.6k | pu1_dst_cb = pu1_refarray_1 + i4_tmp; |
642 | 36.6k | pu1_src_cb = pu1_dst_cb + i1_xd_index; |
643 | 36.6k | pu1_dst_cr = pu1_refarray_2 + i4_tmp; |
644 | 36.6k | pu1_src_cr = pu1_dst_cr + i1_xd_index; |
645 | | |
646 | 36.6k | i1_xd_index = MIN(i1_xd_index, MAX_PIX_FILL_CHROMA); |
647 | 36.6k | u1_seg_wd = MIN(u1_seg_wd, MAX_PIX_FILL_CHROMA); |
648 | 36.6k | pu1_dst_cb = pu1_src_cb - i1_xd_index; |
649 | 36.6k | pu1_dst_cr = pu1_src_cr - i1_xd_index; |
650 | | |
651 | 162k | for(i4_idx_i = 0; i4_idx_i < u1_seg_ht; i4_idx_i++) |
652 | 125k | { |
653 | 125k | memset(pu1_dst_cb, *pu1_src_cb, u1_seg_wd); |
654 | 125k | pu1_dst_cb += i4_refarray_stride; |
655 | 125k | pu1_src_cb += i4_refarray_stride; |
656 | 125k | memset(pu1_dst_cr, *pu1_src_cr, u1_seg_wd); |
657 | 125k | pu1_dst_cr += i4_refarray_stride; |
658 | 125k | pu1_src_cr += i4_refarray_stride; |
659 | 125k | } |
660 | 36.6k | } |
661 | | |
662 | | /*****************************************************************************/ |
663 | | /* */ |
664 | | /* Function Name : isvcd_top_bot_padding */ |
665 | | /* Description : This function does the top/bottom padding for intra */ |
666 | | /* upsampling for chroma */ |
667 | | /* */ |
668 | | /* Inputs : */ |
669 | | /* Globals : none */ |
670 | | /* Processing : This function does the top/bottom padding for intra */ |
671 | | /* upsampling for chroma */ |
672 | | /* Outputs : none */ |
673 | | /* Returns : none */ |
674 | | /* Issues : none */ |
675 | | /* Revision History: */ |
676 | | /* DD MM YYYY Author(s) Changes (Describe the changes made) */ |
677 | | /* 06 09 2021 Vijay creation */ |
678 | | /*****************************************************************************/ |
679 | | void isvcd_top_bot_padding(WORD32 i4_x, WORD32 i4_y, WORD8 i1_xd_index, WORD8 i1_yd_index, |
680 | | UWORD8 u1_seg_wd, UWORD8 u1_seg_ht, UWORD8 *pu1_refarray_1, |
681 | | UWORD8 *pu1_refarray_2, WORD32 i4_refarray_stride, WORD32 i4_mb_adjoin_x, |
682 | | WORD32 i4_mb_adjoin_y, WORD32 i4_corner_pixel_available) |
683 | 33.4k | { |
684 | 33.4k | WORD32 i4_idx_i; |
685 | 33.4k | UWORD8 *pu1_src, *pu1_dst; |
686 | | |
687 | 33.4k | UNUSED(i1_xd_index); |
688 | 33.4k | UNUSED(pu1_refarray_2); |
689 | 33.4k | UNUSED(i4_mb_adjoin_x); |
690 | 33.4k | UNUSED(i4_mb_adjoin_y); |
691 | 33.4k | UNUSED(i4_corner_pixel_available); |
692 | | |
693 | 33.4k | pu1_dst = pu1_refarray_1 + i4_x + (i4_y * i4_refarray_stride); |
694 | 33.4k | pu1_src = pu1_dst + (i1_yd_index * i4_refarray_stride); |
695 | 33.4k | i1_yd_index = MIN(i1_yd_index, MAX_PIX_FILL_LUMA); |
696 | 33.4k | u1_seg_ht = MIN(u1_seg_ht, MAX_PIX_FILL_LUMA); |
697 | 33.4k | pu1_dst = pu1_src - (i1_yd_index * i4_refarray_stride); |
698 | | |
699 | 139k | for(i4_idx_i = 0; i4_idx_i < u1_seg_ht; i4_idx_i++) |
700 | 106k | { |
701 | 106k | memcpy(pu1_dst, pu1_src, u1_seg_wd); |
702 | 106k | pu1_dst += i4_refarray_stride; |
703 | 106k | } |
704 | 33.4k | } |
705 | | |
706 | | /*****************************************************************************/ |
707 | | /* */ |
708 | | /* Function Name : isvcd_top_bot_padding */ |
709 | | /* Description : This function does the top/bottom padding for intra */ |
710 | | /* upsampling for chroma */ |
711 | | /* */ |
712 | | /* Inputs : */ |
713 | | /* Globals : none */ |
714 | | /* Processing : This function does the top/bottom padding for intra */ |
715 | | /* upsampling for chroma */ |
716 | | /* Outputs : none */ |
717 | | /* Returns : none */ |
718 | | /* Issues : none */ |
719 | | /* Revision History: */ |
720 | | /* DD MM YYYY Author(s) Changes (Describe the changes made) */ |
721 | | /* 06 09 2021 Vijay creation */ |
722 | | /*****************************************************************************/ |
723 | | void isvcd_top_bot_padding_chroma(WORD32 i4_x, WORD32 i4_y, WORD8 i1_xd_index, WORD8 i1_yd_index, |
724 | | UWORD8 u1_seg_wd, UWORD8 u1_seg_ht, UWORD8 *pu1_refarray_1, |
725 | | UWORD8 *pu1_refarray_2, WORD32 i4_refarray_stride, |
726 | | WORD32 i4_mb_adjoin_x, WORD32 i4_mb_adjoin_y, |
727 | | WORD32 i4_corner_pixel_available) |
728 | 33.4k | { |
729 | 33.4k | WORD32 i4_idx_i; |
730 | 33.4k | UWORD8 *pu1_src_cb, *pu1_dst_cb; |
731 | 33.4k | UWORD8 *pu1_src_cr, *pu1_dst_cr; |
732 | 33.4k | WORD32 i4_tmp; |
733 | | |
734 | 33.4k | UNUSED(i1_xd_index); |
735 | 33.4k | UNUSED(pu1_refarray_2); |
736 | 33.4k | UNUSED(i4_mb_adjoin_x); |
737 | 33.4k | UNUSED(i4_mb_adjoin_y); |
738 | 33.4k | UNUSED(i4_corner_pixel_available); |
739 | | |
740 | 33.4k | i4_tmp = i4_x + (i4_y * i4_refarray_stride); |
741 | 33.4k | pu1_dst_cb = pu1_refarray_1 + i4_tmp; |
742 | 33.4k | pu1_dst_cr = pu1_refarray_2 + i4_tmp; |
743 | | |
744 | 33.4k | i4_tmp = (i1_yd_index * i4_refarray_stride); |
745 | 33.4k | pu1_src_cb = pu1_dst_cb + i4_tmp; |
746 | 33.4k | pu1_src_cr = pu1_dst_cr + i4_tmp; |
747 | 33.4k | i1_yd_index = MIN(i1_yd_index, MAX_PIX_FILL_CHROMA); |
748 | 33.4k | u1_seg_ht = MIN(u1_seg_ht, MAX_PIX_FILL_CHROMA); |
749 | | |
750 | 33.4k | i4_tmp = (i1_yd_index * i4_refarray_stride); |
751 | 33.4k | pu1_dst_cb = pu1_src_cb - i4_tmp; |
752 | 33.4k | pu1_dst_cr = pu1_src_cr - i4_tmp; |
753 | | |
754 | 90.7k | for(i4_idx_i = 0; i4_idx_i < u1_seg_ht; i4_idx_i++) |
755 | 57.3k | { |
756 | 57.3k | memcpy(pu1_dst_cb, pu1_src_cb, u1_seg_wd); |
757 | 57.3k | pu1_dst_cb += i4_refarray_stride; |
758 | 57.3k | memcpy(pu1_dst_cr, pu1_src_cr, u1_seg_wd); |
759 | 57.3k | pu1_dst_cr += i4_refarray_stride; |
760 | 57.3k | } |
761 | 33.4k | } |
762 | | |
763 | | /*****************************************************************************/ |
764 | | /* */ |
765 | | /* Function Name : isvcd_diag_reconstruction */ |
766 | | /* Description : This function does the diagonal reconstuction for intra */ |
767 | | /* upsampling for luma */ |
768 | | /* */ |
769 | | /* Inputs : */ |
770 | | /* Globals : none */ |
771 | | /* Processing : This function does the diagonal reconstruction for intra */ |
772 | | /* upsampling for luma */ |
773 | | /* Outputs : none */ |
774 | | /* Returns : none */ |
775 | | /* Issues : none */ |
776 | | /* Revision History: */ |
777 | | /* DD MM YYYY Author(s) Changes (Describe the changes made) */ |
778 | | /* 06 09 2021 Vijay creation */ |
779 | | /*****************************************************************************/ |
780 | | void isvcd_diag_reconstruction(WORD32 i4_x, WORD32 i4_y, WORD8 i1_xd_index, WORD8 i1_yd_index, |
781 | | UWORD8 u1_seg_wd, UWORD8 u1_seg_ht, UWORD8 *pu1_refarray_1, |
782 | | UWORD8 *pu1_refarray_2, WORD32 i4_refarray_stride, |
783 | | WORD32 i4_mb_adjoin_x, WORD32 i4_mb_adjoin_y, |
784 | | WORD32 i4_corner_pixel_available) |
785 | 27.3k | { |
786 | 27.3k | WORD32 i4_i; |
787 | 27.3k | UWORD8 *pu1_src_1, *pu1_src_2, *pu1_dst; |
788 | 27.3k | UWORD8 u1_filter_delay_buf[18] = {0}; |
789 | 27.3k | UWORD8 u1_out_buf[16] = {0}; |
790 | 27.3k | WORD32 i4_width, i4_height; |
791 | 27.3k | WORD32 i4_x_off, i4_y_off; |
792 | 27.3k | WORD32 i4_block_size = BLOCK_WIDTH; |
793 | | |
794 | 27.3k | UNUSED(pu1_refarray_2); |
795 | | |
796 | 27.3k | pu1_dst = pu1_refarray_1 + i4_x + (i4_y * i4_refarray_stride); |
797 | 27.3k | pu1_src_1 = pu1_dst + i1_xd_index; |
798 | 27.3k | pu1_src_2 = pu1_dst + (i1_yd_index * i4_refarray_stride); |
799 | | |
800 | 27.3k | i4_width = MAX(u1_seg_wd, (((i4_mb_adjoin_x >> 3) ^ 1) * i4_block_size)); |
801 | 27.3k | i4_height = MAX(u1_seg_ht, (((i4_mb_adjoin_y >> 4) ^ 1) * i4_block_size)); |
802 | 27.3k | i4_x_off = (i4_width - u1_seg_wd); |
803 | 27.3k | i4_y_off = (i4_height - u1_seg_ht); |
804 | | |
805 | 27.3k | if(i1_xd_index < 0 && i1_yd_index > 0) |
806 | 6.77k | { |
807 | | /* Quadrant 1 Processing load the pixel in the filter delay buffer */ |
808 | 60.7k | for(i4_i = 0; i4_i < (i4_height + 1); i4_i++) |
809 | 53.9k | { |
810 | 53.9k | u1_filter_delay_buf[i4_i] = *pu1_src_1; |
811 | 53.9k | pu1_src_1 += i4_refarray_stride; |
812 | 53.9k | } |
813 | | |
814 | 6.77k | pu1_src_2 -= i4_x_off; |
815 | 6.77k | memcpy(&u1_filter_delay_buf[i4_i], pu1_src_2, i4_width); |
816 | | |
817 | 6.77k | if(0 == i4_corner_pixel_available) |
818 | 6.32k | { |
819 | | /* interpolate the unavailable corner pixel */ |
820 | 6.32k | u1_filter_delay_buf[i4_i - 1] = |
821 | 6.32k | (u1_filter_delay_buf[i4_i] + u1_filter_delay_buf[i4_i - 2] + 1) >> 1; |
822 | 6.32k | } |
823 | | |
824 | 96.6k | for(i4_i = 0; i4_i < (i4_width + i4_height - 1); i4_i++) |
825 | 89.8k | { |
826 | | /* get the filtered output */ |
827 | 89.8k | u1_out_buf[i4_i] = ((u1_filter_delay_buf[i4_i]) + (u1_filter_delay_buf[i4_i + 1] * 2) + |
828 | 89.8k | (u1_filter_delay_buf[i4_i + 2]) + 2) >> |
829 | 89.8k | 2; |
830 | 89.8k | } |
831 | | |
832 | | /* fill the segment with diagonal reconstructed output */ |
833 | 47.6k | for(i4_i = 0; i4_i < u1_seg_ht; i4_i++) |
834 | 40.8k | { |
835 | 40.8k | memcpy(pu1_dst, &u1_out_buf[i4_x_off + i4_i], u1_seg_wd); |
836 | 40.8k | pu1_dst += i4_refarray_stride; |
837 | 40.8k | } |
838 | 6.77k | } |
839 | 20.5k | else if(i1_xd_index > 0 && i1_yd_index > 0) |
840 | 6.94k | { |
841 | | /* Quadrant 2 Processing */ |
842 | | /* load the pixel in the filter delay buffer */ |
843 | 6.94k | memcpy(&u1_filter_delay_buf[0], pu1_src_2, (i4_width + 1)); |
844 | 52.7k | for(i4_i = i4_height; i4_i > 0; i4_i--) |
845 | 45.7k | { |
846 | 45.7k | u1_filter_delay_buf[i4_width + i4_i] = *pu1_src_1; |
847 | 45.7k | pu1_src_1 += i4_refarray_stride; |
848 | 45.7k | } |
849 | | |
850 | 6.94k | if(0 == i4_corner_pixel_available) |
851 | 6.11k | { |
852 | | /* interpolate the unavailable corner pixel */ |
853 | 6.11k | u1_filter_delay_buf[i4_width] = |
854 | 6.11k | (u1_filter_delay_buf[i4_width - 1] + u1_filter_delay_buf[i4_width + 1] + 1) >> 1; |
855 | 6.11k | } |
856 | | |
857 | 101k | for(i4_i = 0; i4_i < (i4_width + i4_height - 1); i4_i++) |
858 | 94.3k | { |
859 | | /* get the filtered output */ |
860 | 94.3k | u1_out_buf[i4_i] = ((u1_filter_delay_buf[i4_i]) + (u1_filter_delay_buf[i4_i + 1] * 2) + |
861 | 94.3k | (u1_filter_delay_buf[i4_i + 2]) + 2) >> |
862 | 94.3k | 2; |
863 | 94.3k | } |
864 | | |
865 | | /* fill the segment with diagonal reconstructed output */ |
866 | 47.9k | for(i4_i = 1; i4_i <= u1_seg_ht; i4_i++) |
867 | 41.0k | { |
868 | 41.0k | memcpy(pu1_dst, &u1_out_buf[i4_height - i4_i], u1_seg_wd); |
869 | 41.0k | pu1_dst += i4_refarray_stride; |
870 | 41.0k | } |
871 | 6.94k | } |
872 | 13.6k | else if(i1_xd_index > 0 && i1_yd_index < 0) |
873 | 7.11k | { |
874 | | /* Quadrant 3 Processing */ |
875 | | /* load the pixel in the filter delay buffer */ |
876 | 7.11k | memcpy(&u1_filter_delay_buf[0], pu1_src_2, (i4_width + 1)); |
877 | | |
878 | 7.11k | pu1_src_1 -= (i4_y_off * i4_refarray_stride); |
879 | 50.8k | for(i4_i = 1; i4_i <= i4_height; i4_i++) |
880 | 43.7k | { |
881 | 43.7k | u1_filter_delay_buf[i4_width + i4_i] = *pu1_src_1; |
882 | 43.7k | pu1_src_1 += i4_refarray_stride; |
883 | 43.7k | } |
884 | | |
885 | 7.11k | if(0 == i4_corner_pixel_available) |
886 | 6.72k | { |
887 | | /* interpolate the unavailable corner pixel */ |
888 | 6.72k | u1_filter_delay_buf[i4_width] = |
889 | 6.72k | (u1_filter_delay_buf[i4_width - 1] + u1_filter_delay_buf[i4_width + 1] + 1) >> 1; |
890 | 6.72k | } |
891 | | |
892 | 100k | for(i4_i = 0; i4_i < (i4_width + i4_height - 1); i4_i++) |
893 | 93.4k | { |
894 | | /* get the filtered output */ |
895 | 93.4k | u1_out_buf[i4_i] = ((u1_filter_delay_buf[i4_i]) + (u1_filter_delay_buf[i4_i + 1] * 2) + |
896 | 93.4k | (u1_filter_delay_buf[i4_i + 2]) + 2) >> |
897 | 93.4k | 2; |
898 | 93.4k | } |
899 | | |
900 | | /* fill the segment with diagonal reconstructed output */ |
901 | 46.0k | for(i4_i = 0; i4_i < u1_seg_ht; i4_i++) |
902 | 38.9k | { |
903 | 38.9k | memcpy(pu1_dst, &u1_out_buf[i4_y_off + i4_i], u1_seg_wd); |
904 | 38.9k | pu1_dst += i4_refarray_stride; |
905 | 38.9k | } |
906 | 7.11k | } |
907 | 6.54k | else |
908 | 6.54k | { |
909 | | /* Quadrant 4 Processing */ |
910 | | /* load the pixel in the filter delay buffer */ |
911 | 6.54k | pu1_src_1 += ((u1_seg_ht - 1) * i4_refarray_stride); |
912 | 51.9k | for(i4_i = 0; i4_i <= i4_height; i4_i++) |
913 | 45.4k | { |
914 | 45.4k | u1_filter_delay_buf[i4_i] = *pu1_src_1; |
915 | 45.4k | pu1_src_1 -= i4_refarray_stride; |
916 | 45.4k | } |
917 | | |
918 | 6.54k | pu1_src_2 -= i4_x_off; |
919 | 6.54k | memcpy(&u1_filter_delay_buf[i4_i], pu1_src_2, i4_width); |
920 | | |
921 | 6.54k | if(0 == i4_corner_pixel_available) |
922 | 5.88k | { |
923 | | /* interpolate the unavailable corner pixel */ |
924 | 5.88k | u1_filter_delay_buf[i4_i - 1] = |
925 | 5.88k | (u1_filter_delay_buf[i4_i] + u1_filter_delay_buf[i4_i - 2] + 1) >> 1; |
926 | 5.88k | } |
927 | | |
928 | 86.9k | for(i4_i = 0; i4_i < (i4_width + i4_height - 1); i4_i++) |
929 | 80.3k | { |
930 | | /* get the filtered output */ |
931 | 80.3k | u1_out_buf[i4_i] = ((u1_filter_delay_buf[i4_i]) + (u1_filter_delay_buf[i4_i + 1] * 2) + |
932 | 80.3k | (u1_filter_delay_buf[i4_i + 2]) + 2) >> |
933 | 80.3k | 2; |
934 | 80.3k | } |
935 | | |
936 | | /* fill the segment with diagonal reconstructed output */ |
937 | 42.0k | for(i4_i = 1; i4_i <= u1_seg_ht; i4_i++) |
938 | 35.4k | { |
939 | 35.4k | memcpy(pu1_dst, &u1_out_buf[(u1_seg_ht + i4_x_off) - i4_i], u1_seg_wd); |
940 | 35.4k | pu1_dst += i4_refarray_stride; |
941 | 35.4k | } |
942 | 6.54k | } |
943 | 27.3k | } |
944 | | /*****************************************************************************/ |
945 | | /* */ |
946 | | /* Function Name : isvcd_diag_reconstruction_chroma */ |
947 | | /* Description : This function does the diagonal reconstuction for intra */ |
948 | | /* upsampling for chroma */ |
949 | | /* */ |
950 | | /* Inputs : */ |
951 | | /* Globals : none */ |
952 | | /* Processing : This function does the diagonal reconstruction for intra */ |
953 | | /* upsampling for chroma */ |
954 | | /* Outputs : none */ |
955 | | /* Returns : none */ |
956 | | /* Issues : none */ |
957 | | /* Revision History: */ |
958 | | /* DD MM YYYY Author(s) Changes (Describe the changes made) */ |
959 | | /* 06 09 2021 Vijay creation */ |
960 | | /*****************************************************************************/ |
961 | | void isvcd_diag_reconstruction_chroma(WORD32 i4_x, WORD32 i4_y, WORD8 i1_xd_index, |
962 | | WORD8 i1_yd_index, UWORD8 u1_seg_wd, UWORD8 u1_seg_ht, |
963 | | UWORD8 *pu1_refarray_1, UWORD8 *pu1_refarray_2, |
964 | | WORD32 i4_refarray_stride, WORD32 i4_mb_adjoin_x, |
965 | | WORD32 i4_mb_adjoin_y, WORD32 i4_corner_pixel_available) |
966 | 27.4k | { |
967 | 27.4k | WORD32 i4_i; |
968 | 27.4k | UWORD8 u1_filter_delay_buf_cb[18] = {0}; |
969 | 27.4k | UWORD8 u1_filter_delay_buf_cr[18] = {0}; |
970 | 27.4k | UWORD8 u1_out_buf_cb[16] = {0}; |
971 | 27.4k | UWORD8 u1_out_buf_cr[16] = {0}; |
972 | 27.4k | WORD32 i4_width, i4_height; |
973 | 27.4k | WORD32 i4_x_off, i4_y_off; |
974 | 27.4k | WORD32 i4_block_size = BLOCK_WIDTH >> 1; |
975 | 27.4k | UWORD8 *pu1_src_1_cb, *pu1_src_2_cb, *pu1_dst_cb; |
976 | 27.4k | UWORD8 *pu1_src_1_cr, *pu1_src_2_cr, *pu1_dst_cr; |
977 | 27.4k | WORD32 i4_tmp; |
978 | | |
979 | 27.4k | i4_tmp = i4_x + (i4_y * i4_refarray_stride); |
980 | 27.4k | pu1_dst_cb = pu1_refarray_1 + i4_tmp; |
981 | 27.4k | pu1_dst_cr = pu1_refarray_2 + i4_tmp; |
982 | | |
983 | 27.4k | pu1_src_1_cb = pu1_dst_cb + i1_xd_index; |
984 | 27.4k | pu1_src_1_cr = pu1_dst_cr + i1_xd_index; |
985 | 27.4k | i4_tmp = (i1_yd_index * i4_refarray_stride); |
986 | 27.4k | pu1_src_2_cb = pu1_dst_cb + i4_tmp; |
987 | 27.4k | pu1_src_2_cr = pu1_dst_cr + i4_tmp; |
988 | | |
989 | 27.4k | i4_width = MAX(u1_seg_wd, (((i4_mb_adjoin_x >> 3) ^ 1) * i4_block_size)); |
990 | 27.4k | i4_height = MAX(u1_seg_ht, (((i4_mb_adjoin_y >> 4) ^ 1) * i4_block_size)); |
991 | 27.4k | i4_x_off = (i4_width - u1_seg_wd); |
992 | 27.4k | i4_y_off = (i4_height - u1_seg_ht); |
993 | | |
994 | 27.4k | if(i1_xd_index < 0 && i1_yd_index > 0) |
995 | 6.77k | { |
996 | | /* Quadrant 1 Processing load the pixel in the filter delay buffer */ |
997 | 37.8k | for(i4_i = 0; i4_i < (i4_height + 1); i4_i++) |
998 | 31.0k | { |
999 | 31.0k | u1_filter_delay_buf_cb[i4_i] = *pu1_src_1_cb; |
1000 | 31.0k | pu1_src_1_cb += i4_refarray_stride; |
1001 | 31.0k | u1_filter_delay_buf_cr[i4_i] = *pu1_src_1_cr; |
1002 | 31.0k | pu1_src_1_cr += i4_refarray_stride; |
1003 | 31.0k | } |
1004 | | |
1005 | 6.77k | pu1_src_2_cb -= i4_x_off; |
1006 | 6.77k | pu1_src_2_cr -= i4_x_off; |
1007 | 6.77k | memcpy(&u1_filter_delay_buf_cb[i4_i], pu1_src_2_cb, i4_width); |
1008 | 6.77k | memcpy(&u1_filter_delay_buf_cr[i4_i], pu1_src_2_cr, i4_width); |
1009 | | |
1010 | 6.77k | if(0 == i4_corner_pixel_available) |
1011 | 6.32k | { |
1012 | | /* interpolate the unavailable corner pixel */ |
1013 | 6.32k | u1_filter_delay_buf_cb[i4_i - 1] = |
1014 | 6.32k | (u1_filter_delay_buf_cb[i4_i] + u1_filter_delay_buf_cb[i4_i - 2] + 1) >> 1; |
1015 | | |
1016 | 6.32k | u1_filter_delay_buf_cr[i4_i - 1] = |
1017 | 6.32k | (u1_filter_delay_buf_cr[i4_i] + u1_filter_delay_buf_cr[i4_i - 2] + 1) >> 1; |
1018 | 6.32k | } |
1019 | | |
1020 | 51.3k | for(i4_i = 0; i4_i < (i4_width + i4_height - 1); i4_i++) |
1021 | 44.6k | { |
1022 | | /* get the filtered output */ |
1023 | 44.6k | u1_out_buf_cb[i4_i] = |
1024 | 44.6k | ((u1_filter_delay_buf_cb[i4_i]) + (u1_filter_delay_buf_cb[i4_i + 1] * 2) + |
1025 | 44.6k | (u1_filter_delay_buf_cb[i4_i + 2]) + 2) >> |
1026 | 44.6k | 2; |
1027 | | |
1028 | 44.6k | u1_out_buf_cr[i4_i] = |
1029 | 44.6k | ((u1_filter_delay_buf_cr[i4_i]) + (u1_filter_delay_buf_cr[i4_i + 1] * 2) + |
1030 | 44.6k | (u1_filter_delay_buf_cr[i4_i + 2]) + 2) >> |
1031 | 44.6k | 2; |
1032 | 44.6k | } |
1033 | | |
1034 | | /* fill the segment with diagonal reconstructed output */ |
1035 | 28.2k | for(i4_i = 0; i4_i < u1_seg_ht; i4_i++) |
1036 | 21.4k | { |
1037 | 21.4k | memcpy(pu1_dst_cb, &u1_out_buf_cb[i4_x_off + i4_i], u1_seg_wd); |
1038 | 21.4k | pu1_dst_cb += i4_refarray_stride; |
1039 | 21.4k | memcpy(pu1_dst_cr, &u1_out_buf_cr[i4_x_off + i4_i], u1_seg_wd); |
1040 | 21.4k | pu1_dst_cr += i4_refarray_stride; |
1041 | 21.4k | } |
1042 | 6.77k | } |
1043 | 20.6k | else if(i1_xd_index > 0 && i1_yd_index > 0) |
1044 | 6.94k | { |
1045 | | /* Quadrant 2 Processing load the pixel in the filter delay buffer */ |
1046 | 6.94k | memcpy(&u1_filter_delay_buf_cb[0], pu1_src_2_cb, (i4_width + 1)); |
1047 | 6.94k | memcpy(&u1_filter_delay_buf_cr[0], pu1_src_2_cr, (i4_width + 1)); |
1048 | | |
1049 | 30.4k | for(i4_i = i4_height; i4_i > 0; i4_i--) |
1050 | 23.5k | { |
1051 | 23.5k | u1_filter_delay_buf_cb[i4_width + i4_i] = *pu1_src_1_cb; |
1052 | 23.5k | pu1_src_1_cb += i4_refarray_stride; |
1053 | | |
1054 | 23.5k | u1_filter_delay_buf_cr[i4_width + i4_i] = *pu1_src_1_cr; |
1055 | 23.5k | pu1_src_1_cr += i4_refarray_stride; |
1056 | 23.5k | } |
1057 | | |
1058 | 6.94k | if(0 == i4_corner_pixel_available) |
1059 | 6.11k | { |
1060 | | /* interpolate the unavailable corner pixel */ |
1061 | 6.11k | u1_filter_delay_buf_cb[i4_width] = |
1062 | 6.11k | (u1_filter_delay_buf_cb[i4_width - 1] + u1_filter_delay_buf_cb[i4_width + 1] + 1) >> |
1063 | 6.11k | 1; |
1064 | | |
1065 | 6.11k | u1_filter_delay_buf_cr[i4_width] = |
1066 | 6.11k | (u1_filter_delay_buf_cr[i4_width - 1] + u1_filter_delay_buf_cr[i4_width + 1] + 1) >> |
1067 | 6.11k | 1; |
1068 | 6.11k | } |
1069 | | |
1070 | 51.2k | for(i4_i = 0; i4_i < (i4_width + i4_height - 1); i4_i++) |
1071 | 44.3k | { |
1072 | | /* get the filtered output */ |
1073 | 44.3k | u1_out_buf_cb[i4_i] = |
1074 | 44.3k | ((u1_filter_delay_buf_cb[i4_i]) + (u1_filter_delay_buf_cb[i4_i + 1] * 2) + |
1075 | 44.3k | (u1_filter_delay_buf_cb[i4_i + 2]) + 2) >> |
1076 | 44.3k | 2; |
1077 | | |
1078 | 44.3k | u1_out_buf_cr[i4_i] = |
1079 | 44.3k | ((u1_filter_delay_buf_cr[i4_i]) + (u1_filter_delay_buf_cr[i4_i + 1] * 2) + |
1080 | 44.3k | (u1_filter_delay_buf_cr[i4_i + 2]) + 2) >> |
1081 | 44.3k | 2; |
1082 | 44.3k | } |
1083 | | |
1084 | | /* fill the segment with diagonal reconstructed output */ |
1085 | 28.0k | for(i4_i = 1; i4_i <= u1_seg_ht; i4_i++) |
1086 | 21.1k | { |
1087 | 21.1k | memcpy(pu1_dst_cb, &u1_out_buf_cb[i4_height - i4_i], u1_seg_wd); |
1088 | 21.1k | pu1_dst_cb += i4_refarray_stride; |
1089 | | |
1090 | 21.1k | memcpy(pu1_dst_cr, &u1_out_buf_cr[i4_height - i4_i], u1_seg_wd); |
1091 | 21.1k | pu1_dst_cr += i4_refarray_stride; |
1092 | 21.1k | } |
1093 | 6.94k | } |
1094 | 13.7k | else if(i1_xd_index > 0 && i1_yd_index < 0) |
1095 | 7.11k | { |
1096 | | /* Quadrant 3 Processing load the pixel in the filter delay buffer */ |
1097 | 7.11k | memcpy(&u1_filter_delay_buf_cb[0], pu1_src_2_cb, (i4_width + 1)); |
1098 | 7.11k | memcpy(&u1_filter_delay_buf_cr[0], pu1_src_2_cr, (i4_width + 1)); |
1099 | | |
1100 | 7.11k | i4_tmp = (i4_y_off * i4_refarray_stride); |
1101 | 7.11k | pu1_src_1_cb -= i4_tmp; |
1102 | 7.11k | pu1_src_1_cr -= i4_tmp; |
1103 | 30.3k | for(i4_i = 1; i4_i <= i4_height; i4_i++) |
1104 | 23.2k | { |
1105 | 23.2k | u1_filter_delay_buf_cb[i4_width + i4_i] = *pu1_src_1_cb; |
1106 | 23.2k | pu1_src_1_cb += i4_refarray_stride; |
1107 | | |
1108 | 23.2k | u1_filter_delay_buf_cr[i4_width + i4_i] = *pu1_src_1_cr; |
1109 | 23.2k | pu1_src_1_cr += i4_refarray_stride; |
1110 | 23.2k | } |
1111 | | |
1112 | 7.11k | if(0 == i4_corner_pixel_available) |
1113 | 6.72k | { |
1114 | | /* interpolate the unavailable corner pixel */ |
1115 | 6.72k | u1_filter_delay_buf_cb[i4_width] = |
1116 | 6.72k | (u1_filter_delay_buf_cb[i4_width - 1] + u1_filter_delay_buf_cb[i4_width + 1] + 1) >> |
1117 | 6.72k | 1; |
1118 | | |
1119 | 6.72k | u1_filter_delay_buf_cr[i4_width] = |
1120 | 6.72k | (u1_filter_delay_buf_cr[i4_width - 1] + u1_filter_delay_buf_cr[i4_width + 1] + 1) >> |
1121 | 6.72k | 1; |
1122 | 6.72k | } |
1123 | | |
1124 | 51.6k | for(i4_i = 0; i4_i < (i4_width + i4_height - 1); i4_i++) |
1125 | 44.5k | { |
1126 | | /* get the filtered output */ |
1127 | 44.5k | u1_out_buf_cb[i4_i] = |
1128 | 44.5k | ((u1_filter_delay_buf_cb[i4_i]) + (u1_filter_delay_buf_cb[i4_i + 1] * 2) + |
1129 | 44.5k | (u1_filter_delay_buf_cb[i4_i + 2]) + 2) >> |
1130 | 44.5k | 2; |
1131 | | |
1132 | 44.5k | u1_out_buf_cr[i4_i] = |
1133 | 44.5k | ((u1_filter_delay_buf_cr[i4_i]) + (u1_filter_delay_buf_cr[i4_i + 1] * 2) + |
1134 | 44.5k | (u1_filter_delay_buf_cr[i4_i + 2]) + 2) >> |
1135 | 44.5k | 2; |
1136 | 44.5k | } |
1137 | | |
1138 | | /* fill the segment with diagonal reconstructed output */ |
1139 | 28.7k | for(i4_i = 0; i4_i < u1_seg_ht; i4_i++) |
1140 | 21.6k | { |
1141 | 21.6k | memcpy(pu1_dst_cb, &u1_out_buf_cb[i4_y_off + i4_i], u1_seg_wd); |
1142 | 21.6k | pu1_dst_cb += i4_refarray_stride; |
1143 | 21.6k | memcpy(pu1_dst_cr, &u1_out_buf_cr[i4_y_off + i4_i], u1_seg_wd); |
1144 | 21.6k | pu1_dst_cr += i4_refarray_stride; |
1145 | 21.6k | } |
1146 | 7.11k | } |
1147 | 6.59k | else |
1148 | 6.59k | { |
1149 | | /* Quadrant 4 Processing load the pixel in the filter delay buffer */ |
1150 | 6.59k | i4_tmp = ((u1_seg_ht - 1) * i4_refarray_stride); |
1151 | 6.59k | pu1_src_1_cb += i4_tmp; |
1152 | 6.59k | pu1_src_1_cr += i4_tmp; |
1153 | | |
1154 | 34.0k | for(i4_i = 0; i4_i <= i4_height; i4_i++) |
1155 | 27.4k | { |
1156 | 27.4k | u1_filter_delay_buf_cb[i4_i] = *pu1_src_1_cb; |
1157 | 27.4k | pu1_src_1_cb -= i4_refarray_stride; |
1158 | | |
1159 | 27.4k | u1_filter_delay_buf_cr[i4_i] = *pu1_src_1_cr; |
1160 | 27.4k | pu1_src_1_cr -= i4_refarray_stride; |
1161 | 27.4k | } |
1162 | | |
1163 | 6.59k | pu1_src_2_cb -= i4_x_off; |
1164 | 6.59k | pu1_src_2_cr -= i4_x_off; |
1165 | 6.59k | memcpy(&u1_filter_delay_buf_cb[i4_i], pu1_src_2_cb, i4_width); |
1166 | 6.59k | memcpy(&u1_filter_delay_buf_cr[i4_i], pu1_src_2_cr, i4_width); |
1167 | | |
1168 | 6.59k | if(0 == i4_corner_pixel_available) |
1169 | 5.93k | { |
1170 | | /* interpolate the unavailable corner pixel */ |
1171 | 5.93k | u1_filter_delay_buf_cb[i4_i - 1] = |
1172 | 5.93k | (u1_filter_delay_buf_cb[i4_i] + u1_filter_delay_buf_cb[i4_i - 2] + 1) >> 1; |
1173 | | |
1174 | 5.93k | u1_filter_delay_buf_cr[i4_i - 1] = |
1175 | 5.93k | (u1_filter_delay_buf_cr[i4_i] + u1_filter_delay_buf_cr[i4_i - 2] + 1) >> 1; |
1176 | 5.93k | } |
1177 | | |
1178 | 47.1k | for(i4_i = 0; i4_i < (i4_width + i4_height - 1); i4_i++) |
1179 | 40.5k | { |
1180 | | /* get the filtered output */ |
1181 | 40.5k | u1_out_buf_cb[i4_i] = |
1182 | 40.5k | ((u1_filter_delay_buf_cb[i4_i]) + (u1_filter_delay_buf_cb[i4_i + 1] * 2) + |
1183 | 40.5k | (u1_filter_delay_buf_cb[i4_i + 2]) + 2) >> |
1184 | 40.5k | 2; |
1185 | | |
1186 | 40.5k | u1_out_buf_cr[i4_i] = |
1187 | 40.5k | ((u1_filter_delay_buf_cr[i4_i]) + (u1_filter_delay_buf_cr[i4_i + 1] * 2) + |
1188 | 40.5k | (u1_filter_delay_buf_cr[i4_i + 2]) + 2) >> |
1189 | 40.5k | 2; |
1190 | 40.5k | } |
1191 | | |
1192 | | /* fill the segment with diagonal reconstructed output */ |
1193 | 26.1k | for(i4_i = 1; i4_i <= u1_seg_ht; i4_i++) |
1194 | 19.5k | { |
1195 | 19.5k | memcpy(pu1_dst_cb, &u1_out_buf_cb[(u1_seg_ht + i4_x_off) - i4_i], u1_seg_wd); |
1196 | 19.5k | pu1_dst_cb += i4_refarray_stride; |
1197 | 19.5k | memcpy(pu1_dst_cr, &u1_out_buf_cr[(u1_seg_ht + i4_x_off) - i4_i], u1_seg_wd); |
1198 | 19.5k | pu1_dst_cr += i4_refarray_stride; |
1199 | 19.5k | } |
1200 | 6.59k | } |
1201 | 27.4k | } |
1202 | | /*****************************************************************************/ |
1203 | | /* */ |
1204 | | /* Function Name : isvcd_diag_padding */ |
1205 | | /* Description : This function does the diagonal padding for intra */ |
1206 | | /* upsampling for luma */ |
1207 | | /* */ |
1208 | | /* Inputs : */ |
1209 | | /* Globals : none */ |
1210 | | /* Processing : This function does the diagonal padding for intra */ |
1211 | | /* upsampling for luma */ |
1212 | | /* Outputs : none */ |
1213 | | /* Returns : none */ |
1214 | | /* Issues : none */ |
1215 | | /* Revision History: */ |
1216 | | /* DD MM YYYY Author(s) Changes (Describe the changes made) */ |
1217 | | /* 06 09 2021 Vijay creation */ |
1218 | | /*****************************************************************************/ |
1219 | | void isvcd_diag_padding(WORD32 i4_x, WORD32 i4_y, WORD8 i1_xd_index, WORD8 i1_yd_index, |
1220 | | UWORD8 u1_seg_wd, UWORD8 u1_seg_ht, UWORD8 *pu1_refarray_1, |
1221 | | UWORD8 *pu1_refarray_2, WORD32 i4_refarray_stride, WORD32 i4_mb_adjoin_x, |
1222 | | WORD32 i4_mb_adjoin_y, WORD32 i4_corner_pixel_available) |
1223 | | |
1224 | 22.5k | { |
1225 | 22.5k | WORD32 i4_idx_i; |
1226 | 22.5k | UWORD8 *pu1_src, *pu1_dst; |
1227 | | |
1228 | 22.5k | UNUSED(pu1_refarray_2); |
1229 | 22.5k | UNUSED(i4_mb_adjoin_x); |
1230 | 22.5k | UNUSED(i4_mb_adjoin_y); |
1231 | 22.5k | UNUSED(i4_corner_pixel_available); |
1232 | | |
1233 | 22.5k | pu1_dst = pu1_refarray_1 + i4_x + (i4_y * i4_refarray_stride); |
1234 | 22.5k | pu1_src = pu1_dst + i1_xd_index + (i1_yd_index * i4_refarray_stride); |
1235 | 22.5k | i1_xd_index = MIN(i1_xd_index, MAX_PIX_FILL_LUMA); |
1236 | 22.5k | u1_seg_wd = MIN(u1_seg_wd, MAX_PIX_FILL_LUMA); |
1237 | 22.5k | i1_yd_index = MIN(i1_yd_index, MAX_PIX_FILL_LUMA); |
1238 | 22.5k | u1_seg_ht = MIN(u1_seg_ht, MAX_PIX_FILL_LUMA); |
1239 | 22.5k | pu1_dst = pu1_src - i1_xd_index - (i1_yd_index * i4_refarray_stride); |
1240 | | |
1241 | 95.0k | for(i4_idx_i = 0; i4_idx_i < u1_seg_ht; i4_idx_i++) |
1242 | 72.4k | { |
1243 | 72.4k | memset(pu1_dst, *pu1_src, u1_seg_wd); |
1244 | 72.4k | pu1_dst += i4_refarray_stride; |
1245 | 72.4k | } |
1246 | 22.5k | } |
1247 | | |
1248 | | /*****************************************************************************/ |
1249 | | /* */ |
1250 | | /* Function Name : isvcd_diag_padding_chroma */ |
1251 | | /* Description : This function does the diagonal padding for intra */ |
1252 | | /* upsampling for chroma */ |
1253 | | /* */ |
1254 | | /* Inputs : */ |
1255 | | /* Globals : none */ |
1256 | | /* Processing : This function does the diagonal padding for intra */ |
1257 | | /* upsampling for chroma */ |
1258 | | /* Outputs : none */ |
1259 | | /* Returns : none */ |
1260 | | /* Issues : none */ |
1261 | | /* Revision History: */ |
1262 | | /* DD MM YYYY Author(s) Changes (Describe the changes made) */ |
1263 | | /* 06 09 2021 Vijay creation */ |
1264 | | /*****************************************************************************/ |
1265 | | void isvcd_diag_padding_chroma(WORD32 i4_x, WORD32 i4_y, WORD8 i1_xd_index, WORD8 i1_yd_index, |
1266 | | UWORD8 u1_seg_wd, UWORD8 u1_seg_ht, UWORD8 *pu1_refarray_1, |
1267 | | UWORD8 *pu1_refarray_2, WORD32 i4_refarray_stride, |
1268 | | WORD32 i4_mb_adjoin_x, WORD32 i4_mb_adjoin_y, |
1269 | | WORD32 i4_corner_pixel_available) |
1270 | | |
1271 | 22.5k | { |
1272 | 22.5k | WORD32 i4_idx_i; |
1273 | 22.5k | UWORD8 *pu1_src_cb, *pu1_dst_cb; |
1274 | 22.5k | UWORD8 *pu1_src_cr, *pu1_dst_cr; |
1275 | 22.5k | WORD32 i4_tmp; |
1276 | | |
1277 | 22.5k | UNUSED(i4_mb_adjoin_x); |
1278 | 22.5k | UNUSED(i4_mb_adjoin_y); |
1279 | 22.5k | UNUSED(i4_corner_pixel_available); |
1280 | | |
1281 | 22.5k | i4_tmp = i4_x + (i4_y * i4_refarray_stride); |
1282 | 22.5k | pu1_dst_cb = pu1_refarray_1 + i4_tmp; |
1283 | 22.5k | pu1_dst_cr = pu1_refarray_2 + i4_tmp; |
1284 | 22.5k | i4_tmp = i1_xd_index + (i1_yd_index * i4_refarray_stride); |
1285 | 22.5k | pu1_src_cb = pu1_dst_cb + i4_tmp; |
1286 | 22.5k | pu1_src_cr = pu1_dst_cr + i4_tmp; |
1287 | | |
1288 | 22.5k | i1_xd_index = MIN(i1_xd_index, MAX_PIX_FILL_LUMA); |
1289 | 22.5k | u1_seg_wd = MIN(u1_seg_wd, MAX_PIX_FILL_LUMA); |
1290 | 22.5k | i1_yd_index = MIN(i1_yd_index, MAX_PIX_FILL_LUMA); |
1291 | 22.5k | u1_seg_ht = MIN(u1_seg_ht, MAX_PIX_FILL_LUMA); |
1292 | | |
1293 | 22.5k | i4_tmp = (i1_xd_index + (i1_yd_index * i4_refarray_stride)); |
1294 | 22.5k | pu1_dst_cb = pu1_src_cb - i4_tmp; |
1295 | 22.5k | pu1_dst_cr = pu1_src_cr - i4_tmp; |
1296 | | |
1297 | 82.1k | for(i4_idx_i = 0; i4_idx_i < u1_seg_ht; i4_idx_i++) |
1298 | 59.6k | { |
1299 | 59.6k | memset(pu1_dst_cb, *pu1_src_cb, u1_seg_wd); |
1300 | 59.6k | pu1_dst_cb += i4_refarray_stride; |
1301 | 59.6k | memset(pu1_dst_cr, *pu1_src_cr, u1_seg_wd); |
1302 | 59.6k | pu1_dst_cr += i4_refarray_stride; |
1303 | 59.6k | } |
1304 | 22.5k | } |
1305 | | /*****************************************************************************/ |
1306 | | /* */ |
1307 | | /* Function Name : isvcd_corner_samp_dyadic */ |
1308 | | /* */ |
1309 | | /* Description : This function fills the corner sample in the reference */ |
1310 | | /* array with diagonally constructed samples */ |
1311 | | /* Inputs : i4_x :current position in reference array X to be filled */ |
1312 | | /* i4_y :current position in reference array Y to be filled */ |
1313 | | /* i4_xd_index : diagonal index in horizontal direction */ |
1314 | | /* i4_yd_index : diagonal index in vertical direction */ |
1315 | | /* pu1_refarray_y : pointer to luma reference array */ |
1316 | | /* pu1_refarray_cb : pointer to Cb reference array */ |
1317 | | /* pu1_refarray_cr : pointer to Cr reference array */ |
1318 | | /* Globals : none */ |
1319 | | /* Processing : Fills the sample which is unavailable with filtered */ |
1320 | | /* diagonal samples */ |
1321 | | /* Outputs : pixel filled */ |
1322 | | /* Returns : none */ |
1323 | | /* */ |
1324 | | /* Issues : none */ |
1325 | | /* */ |
1326 | | /* Revision History: */ |
1327 | | /* */ |
1328 | | /* DD MM YYYY Author(s) Changes (Describe the changes made) */ |
1329 | | /* 06 09 2021 Vijay creation */ |
1330 | | /* */ |
1331 | | /*****************************************************************************/ |
1332 | | void isvcd_corner_samp_dyadic(WORD32 i4_x, WORD32 i4_y, WORD32 i4_xD, WORD32 i4_yD, |
1333 | | UWORD8 *pu1_refarray_y, UWORD8 *pu1_refarray_cb, |
1334 | | UWORD8 *pu1_refarray_cr) |
1335 | 27.1k | { |
1336 | 27.1k | WORD32 i4_ref_xD, i4_ref_yD; |
1337 | 27.1k | WORD32 i4_c_ref_xD, i4_c_ref_yD; |
1338 | 27.1k | WORD32 i4_xc, i4_yc; |
1339 | 27.1k | WORD32 i4_c_xc, i4_c_yc; |
1340 | 27.1k | WORD32 i4_samp1, i4_samp2; |
1341 | 27.1k | UWORD8 *pu1_tmp_src, *pu1_tmp_dst; |
1342 | | |
1343 | 27.1k | i4_ref_xD = i4_x - i4_xD; |
1344 | 27.1k | i4_ref_yD = i4_y - i4_yD; |
1345 | 27.1k | i4_xc = i4_ref_xD + SIGN(i4_xD); |
1346 | 27.1k | i4_yc = i4_ref_yD + SIGN(i4_yD); |
1347 | | |
1348 | | /* Luma */ |
1349 | 27.1k | pu1_tmp_src = pu1_refarray_y + (i4_yc * DYADIC_REF_W_Y); |
1350 | 27.1k | i4_samp1 = pu1_tmp_src[i4_ref_xD]; |
1351 | 27.1k | pu1_tmp_src = pu1_refarray_y + (i4_ref_yD * DYADIC_REF_W_Y); |
1352 | 27.1k | i4_samp2 = pu1_tmp_src[i4_xc]; |
1353 | 27.1k | pu1_tmp_dst = pu1_tmp_src; |
1354 | 27.1k | pu1_tmp_dst[i4_ref_xD] = (i4_samp1 + i4_samp2 + 1) >> 1; |
1355 | | |
1356 | | /* Chroma */ |
1357 | 27.1k | i4_c_ref_xD = i4_ref_xD >> 1; |
1358 | 27.1k | i4_c_ref_yD = i4_ref_yD >> 1; |
1359 | 27.1k | i4_c_xc = i4_c_ref_xD + SIGN(i4_xD); |
1360 | 27.1k | i4_c_yc = i4_c_ref_yD + SIGN(i4_yD); |
1361 | | |
1362 | | /* Cb */ |
1363 | 27.1k | pu1_tmp_src = pu1_refarray_cb + (i4_c_yc * DYADIC_REF_W_C); |
1364 | 27.1k | i4_samp1 = pu1_tmp_src[i4_c_ref_xD]; |
1365 | 27.1k | pu1_tmp_src = pu1_refarray_cb + (i4_c_ref_yD * DYADIC_REF_W_C); |
1366 | 27.1k | i4_samp2 = pu1_tmp_src[i4_c_xc]; |
1367 | 27.1k | pu1_tmp_dst = pu1_tmp_src; |
1368 | 27.1k | pu1_tmp_dst[i4_c_ref_xD] = (i4_samp1 + i4_samp2 + 1) >> 1; |
1369 | | |
1370 | | /* Cr */ |
1371 | 27.1k | pu1_tmp_src = pu1_refarray_cr + (i4_c_yc * DYADIC_REF_W_C); |
1372 | 27.1k | i4_samp1 = pu1_tmp_src[i4_c_ref_xD]; |
1373 | 27.1k | pu1_tmp_src = pu1_refarray_cr + (i4_c_ref_yD * DYADIC_REF_W_C); |
1374 | 27.1k | i4_samp2 = pu1_tmp_src[i4_c_xc]; |
1375 | 27.1k | pu1_tmp_dst = pu1_tmp_src; |
1376 | 27.1k | pu1_tmp_dst[i4_c_ref_xD] = (i4_samp1 + i4_samp2 + 1) >> 1; |
1377 | 27.1k | } |
1378 | | |
1379 | | /*****************************************************************************/ |
1380 | | /* */ |
1381 | | /* Function Name : isvcd_fill_non_ava_pixel */ |
1382 | | /* */ |
1383 | | /* Description : This function does the core pixel level processing */ |
1384 | | /* while filling the non available pixel */ |
1385 | | /* */ |
1386 | | /* Inputs : pv_intra_samp_ctxt : intra sampling context */ |
1387 | | /* i4_refarray_wd : width of the reference array */ |
1388 | | /* i4_refarray_ht : height of the reference array */ |
1389 | | /* ps_mb_coord : current mb coord structure */ |
1390 | | /* i4_chroma_flag : chroam processing flag */ |
1391 | | /* Globals : none */ |
1392 | | /* Processing : based on the map buffer values the non available pixels */ |
1393 | | /* are filled using border extension algorithm */ |
1394 | | /* Outputs : none */ |
1395 | | /* Returns : none */ |
1396 | | /* */ |
1397 | | /* Issues : none */ |
1398 | | /* */ |
1399 | | /* Revision History: */ |
1400 | | /* */ |
1401 | | /* DD MM YYYY Author(s) Changes (Describe the changes made) */ |
1402 | | /* 06 09 2021 vijayakumar creation */ |
1403 | | /* */ |
1404 | | /*****************************************************************************/ |
1405 | | void isvcd_fill_non_avail_pixel(void *pv_map_ctxt, UWORD8 *pu1_refarray_1, UWORD8 *pu1_refarray_2, |
1406 | | WORD32 i4_refarray_stride, mb_coord_t *ps_mb_coord, |
1407 | | WORD32 i4_chroma_flag, UWORD8 u1_avail_map[4][4]) |
1408 | 97.7k | { |
1409 | | /* --------------------------------------------------------------------- */ |
1410 | | /* Index Variables */ |
1411 | | /* --------------------------------------------------------------------- */ |
1412 | 97.7k | intra_samp_map_ctxt_t *ps_map_ctxt; |
1413 | 97.7k | ref_mb_map_t *ps_x_off_len; |
1414 | 97.7k | ref_mb_map_t *ps_y_off_len; |
1415 | 97.7k | WORD32 i4_x, i4_y; |
1416 | 97.7k | WORD32 i4_corner_pixel_available; |
1417 | | |
1418 | | /* --------------------------------------------------------------------- */ |
1419 | | /* Local Pointer Declaration for Segment lookup */ |
1420 | | /* --------------------------------------------------------------------- */ |
1421 | 97.7k | seg_lookup_desc_t *ps_segments_x; |
1422 | 97.7k | seg_lookup_desc_t *ps_segments_y; |
1423 | 97.7k | seg_description_t *ps_seg_desc_x, *ps_seg_desc_y; |
1424 | 97.7k | seg_description_t *ps_seg_x_tmp, *ps_seg_y_tmp; |
1425 | 97.7k | UWORD8 u1_num_sgmts_x, u1_num_sgmts_y; |
1426 | | |
1427 | | /* --------------------------------------------------------------------- */ |
1428 | | /* Temp Variables for Mapping context */ |
1429 | | /* --------------------------------------------------------------------- */ |
1430 | 97.7k | WORD32 i4_x_offset; |
1431 | 97.7k | WORD32 i4_y_offset; |
1432 | 97.7k | WORD32 i4_refmb_wd; |
1433 | 97.7k | WORD32 i4_refmb_ht; |
1434 | 97.7k | WORD32 i4_mbaddr_x; |
1435 | 97.7k | WORD32 i4_mbaddr_y; |
1436 | 97.7k | WORD32 i4_xr_index, i4_yr_index; |
1437 | 97.7k | WORD32 i4_j, i4_i; |
1438 | 97.7k | WORD32 i4_cur_x; |
1439 | 97.7k | UWORD32 u4_lookup_4bit, u4_lookup_5bit, u4_4thbit; |
1440 | 97.7k | WORD32 i4_pad_size; |
1441 | 97.7k | WORD32 i4_x_min; |
1442 | 97.7k | WORD32 i4_y_min; |
1443 | 97.7k | WORD32 i4_x_start_pos, i4_y_start_pos; |
1444 | 97.7k | ref_min_max_map_t *ps_x_min_max; |
1445 | 97.7k | ref_min_max_map_t *ps_y_min_max; |
1446 | 97.7k | UWORD8 *pu1_ref_idx_x, *pu1_ref_idx_y; |
1447 | 97.7k | ftype_intra_samp_padding *pf_intra_samp_padding; |
1448 | 97.7k | ftype_intra_samp_padding **pf_intra_samp_lookup; |
1449 | | |
1450 | 97.7k | ps_map_ctxt = (intra_samp_map_ctxt_t *) pv_map_ctxt; |
1451 | 97.7k | ps_x_min_max = ps_map_ctxt->ps_x_min_max; |
1452 | 97.7k | ps_y_min_max = ps_map_ctxt->ps_y_min_max; |
1453 | 97.7k | ps_x_off_len = ps_map_ctxt->ps_x_offset_length; |
1454 | 97.7k | ps_y_off_len = ps_map_ctxt->ps_y_offset_length; |
1455 | 97.7k | i4_mbaddr_y = ps_mb_coord->u2_mb_y; |
1456 | 97.7k | i4_mbaddr_x = ps_mb_coord->u2_mb_x; |
1457 | 97.7k | i4_x_offset = ps_x_off_len[i4_mbaddr_x].i2_offset; |
1458 | 97.7k | i4_y_offset = ps_y_off_len[i4_mbaddr_y].i2_offset; |
1459 | 97.7k | i4_refmb_wd = (MB_WIDTH >> i4_chroma_flag) - 1; |
1460 | 97.7k | i4_refmb_ht = (MB_HEIGHT >> i4_chroma_flag) - 1; |
1461 | | |
1462 | 97.7k | if(0 == i4_chroma_flag) |
1463 | 48.7k | { |
1464 | 48.7k | pf_intra_samp_lookup = gpf_lookup_fxns_luma; |
1465 | 48.7k | } |
1466 | 48.9k | else |
1467 | 48.9k | { |
1468 | 48.9k | pf_intra_samp_lookup = gpf_lookup_fxns_chroma; |
1469 | 48.9k | } |
1470 | | |
1471 | | /* get the min and max positions */ |
1472 | 97.7k | i4_x_min = ps_x_min_max[i4_mbaddr_x].i2_min_pos; |
1473 | 97.7k | i4_y_min = ps_y_min_max[i4_mbaddr_y].i2_min_pos; |
1474 | | |
1475 | | /* get the start position of the MB in reference layer */ |
1476 | 97.7k | i4_pad_size = 2 >> i4_chroma_flag; |
1477 | 97.7k | i4_x_start_pos = (i4_x_min - i4_pad_size); |
1478 | 97.7k | i4_y_start_pos = (i4_y_min - i4_pad_size); |
1479 | 97.7k | i4_xr_index = (i4_x_start_pos + i4_x_offset) & i4_refmb_wd; |
1480 | 97.7k | i4_yr_index = (i4_y_start_pos + i4_y_offset) & i4_refmb_ht; |
1481 | | |
1482 | | /* Find the number of segments in x and y direction */ |
1483 | 97.7k | ps_segments_x = (ps_map_ctxt->ps_seg_lookup_horz + i4_xr_index); |
1484 | 97.7k | ps_segments_y = (ps_map_ctxt->ps_seg_lookup_vert + i4_yr_index); |
1485 | 97.7k | u1_num_sgmts_x = ps_segments_x->u1_num_segments; |
1486 | 97.7k | u1_num_sgmts_y = ps_segments_y->u1_num_segments; |
1487 | 97.7k | ps_seg_desc_x = ps_segments_x->s_segments; |
1488 | 97.7k | ps_seg_desc_y = ps_segments_y->s_segments; |
1489 | 97.7k | pu1_ref_idx_x = ps_map_ctxt->pu1_refarray_x_idx; |
1490 | 97.7k | pu1_ref_idx_y = ps_map_ctxt->pu1_refarray_y_idx; |
1491 | 97.7k | i4_cur_x = pu1_ref_idx_x[i4_x_start_pos]; |
1492 | 97.7k | u4_4thbit = ps_segments_x->u4_start_pos; |
1493 | | |
1494 | 352k | for(i4_j = 0; i4_j < u1_num_sgmts_y; i4_j++) |
1495 | 255k | { |
1496 | 255k | UWORD8 i4_idx_a, i4_idx_b; |
1497 | 255k | UWORD8 u1_seg_ht, u1_seg_wd; |
1498 | 255k | UWORD8 u1_mb_adjoin_x, u1_mb_adjoin_y; |
1499 | 255k | WORD8 i1_nearst_mb_bdry_x, i1_nearst_mb_bdry_y; |
1500 | 255k | UWORD32 u4_num_valid_segs; |
1501 | 255k | WORD32 i4_idx_a_plus_ny, i4_idx_b_plus_nx, i4_index; |
1502 | 255k | WORD8 i1_yd_index, i1_xd_index; |
1503 | | |
1504 | 255k | ps_seg_y_tmp = &ps_seg_desc_y[i4_j]; |
1505 | 255k | i4_y = i4_y_start_pos + ps_seg_y_tmp->u1_seg_off; |
1506 | 255k | u1_seg_ht = ps_seg_y_tmp->u1_seg_dim; |
1507 | 255k | i1_yd_index = ps_seg_y_tmp->i1_dist_idx; |
1508 | 255k | i1_nearst_mb_bdry_y = ps_seg_y_tmp->i1_nearst_mb_bdry; |
1509 | 255k | u1_mb_adjoin_y = ps_seg_y_tmp->u1_mb_adjoin; |
1510 | 255k | i4_idx_a = pu1_ref_idx_y[i4_y]; |
1511 | 255k | i4_idx_a_plus_ny = (i4_idx_a + i1_nearst_mb_bdry_y); |
1512 | | |
1513 | | /* Pack the availabilities of the next three horizontal MBs in 3bit |
1514 | | format and 4th bit indicating if the start position is greater than the mb_width/2 */ |
1515 | 255k | u4_lookup_4bit = u4_4thbit | u1_avail_map[i4_idx_a][i4_cur_x + 2] << 2 | |
1516 | 255k | u1_avail_map[i4_idx_a][i4_cur_x + 1] << 1 | |
1517 | 255k | u1_avail_map[i4_idx_a][i4_cur_x]; |
1518 | | |
1519 | 255k | u4_num_valid_segs = gu4_valid_segs_lookup[u4_lookup_4bit]; |
1520 | 255k | i4_i = isvcd_left_most_bit_detect(u4_num_valid_segs); |
1521 | 255k | u4_num_valid_segs <<= (i4_i + 1); |
1522 | | |
1523 | 740k | for(; i4_i < u1_num_sgmts_x; i4_i++) |
1524 | 484k | { |
1525 | 484k | ps_seg_x_tmp = &ps_seg_desc_x[i4_i]; |
1526 | 484k | i4_x = i4_x_start_pos + ps_seg_x_tmp->u1_seg_off; |
1527 | 484k | i4_idx_b = pu1_ref_idx_x[i4_x]; |
1528 | 484k | u1_seg_wd = ps_seg_x_tmp->u1_seg_dim; |
1529 | 484k | i1_xd_index = ps_seg_x_tmp->i1_dist_idx; |
1530 | 484k | i1_nearst_mb_bdry_x = ps_seg_x_tmp->i1_nearst_mb_bdry; |
1531 | 484k | u1_mb_adjoin_x = ps_seg_x_tmp->u1_mb_adjoin; |
1532 | 484k | i4_idx_b_plus_nx = (i4_idx_b + i1_nearst_mb_bdry_x); |
1533 | | |
1534 | | /* Find the avalability of (x,y-Yd),(x-Xd,y),(x-Xd,y-Yd) and pack it to 3 bits */ |
1535 | 484k | u4_lookup_5bit = u1_avail_map[i4_idx_a_plus_ny][i4_idx_b_plus_nx] << 2 | |
1536 | 484k | u1_avail_map[i4_idx_a_plus_ny][i4_idx_b] << 1 | |
1537 | 484k | u1_avail_map[i4_idx_a][i4_idx_b_plus_nx] | u1_mb_adjoin_x | |
1538 | 484k | u1_mb_adjoin_y; |
1539 | | |
1540 | 484k | i4_corner_pixel_available = u1_avail_map[i4_idx_a_plus_ny][i4_idx_b_plus_nx]; |
1541 | | |
1542 | | /* Function pointer table from lookup to get Left,Top,Bottom,Right,Diagonal padding */ |
1543 | 484k | if(u4_lookup_5bit > 31) |
1544 | 0 | { |
1545 | 0 | u4_lookup_5bit = 0; |
1546 | 0 | } |
1547 | 484k | pf_intra_samp_padding = pf_intra_samp_lookup[u4_lookup_5bit]; |
1548 | | |
1549 | 484k | if(pf_intra_samp_padding != NULL) |
1550 | 239k | { |
1551 | 239k | pf_intra_samp_padding(i4_x, i4_y, i1_xd_index, i1_yd_index, u1_seg_wd, u1_seg_ht, |
1552 | 239k | pu1_refarray_1, pu1_refarray_2, i4_refarray_stride, |
1553 | 239k | u1_mb_adjoin_x, u1_mb_adjoin_y, i4_corner_pixel_available); |
1554 | 239k | } |
1555 | | |
1556 | | /* increment to the next unavailable segment */ |
1557 | 484k | i4_index = isvcd_left_most_bit_detect(u4_num_valid_segs); |
1558 | 484k | u4_num_valid_segs <<= (i4_index + 1); |
1559 | 484k | i4_i += i4_index; |
1560 | | |
1561 | 484k | } /* end of loop over ref array width */ |
1562 | | |
1563 | 255k | } /* end of loop over ref array height */ |
1564 | 97.7k | return; |
1565 | 97.7k | } |
1566 | | |
1567 | | /*****************************************************************************/ |
1568 | | /* */ |
1569 | | /* Function Name : isvcd_get_ref_layer_mbtype */ |
1570 | | /* */ |
1571 | | /* Description : This function is used to find the mb type of the */ |
1572 | | /* corresponding MB in the reference layer */ |
1573 | | /* */ |
1574 | | /* Inputs : pv_intra_samp_ctxt : intra samp context */ |
1575 | | /* pi1_ref_mb_modes : ref mb modes buffer pointer */ |
1576 | | /* i4_ref_mode_stride : mb mode buffer stride */ |
1577 | | /* i4_x_ref : reference location X */ |
1578 | | /* i4_y_ref : reference location Y */ |
1579 | | /* pi4_mb_type : pointer to store the mb type */ |
1580 | | /* i4_chroma_flag : chroma flag */ |
1581 | | /* Globals : none */ |
1582 | | /* Processing : it derives the bit corresponding to reference MB and */ |
1583 | | /* stores the mbtype as INTRA if the bit is set */ |
1584 | | /* Outputs : none */ |
1585 | | /* Returns : none */ |
1586 | | /* */ |
1587 | | /* Issues : none */ |
1588 | | /* */ |
1589 | | /* Revision History: */ |
1590 | | /* */ |
1591 | | /* DD MM YYYY Author(s) Changes (Describe the changes made) */ |
1592 | | /* 06 09 2021 vijayakumar creation */ |
1593 | | /* */ |
1594 | | /*****************************************************************************/ |
1595 | | WORD8 isvcd_get_ref_layer_mbtype(WORD8 *pi1_ref_mb_modes, WORD32 *pi4_mb_type, |
1596 | | WORD8 i1_curr_slice_id, WORD8 i1_cons_intr_samp_flag) |
1597 | 957k | { |
1598 | 957k | WORD8 i1_intra_slice_id; |
1599 | 957k | inter_lyr_mb_prms_t *ps_inter_lyr_mb_prms; |
1600 | 957k | WORD8 i1_mb_mode; |
1601 | | |
1602 | 957k | ps_inter_lyr_mb_prms = (inter_lyr_mb_prms_t *) pi1_ref_mb_modes; |
1603 | 957k | i1_mb_mode = ps_inter_lyr_mb_prms->i1_mb_mode; |
1604 | | |
1605 | 957k | if(i1_mb_mode <= SVC_INTER_MB) |
1606 | 769k | { |
1607 | | /* INTER */ |
1608 | 769k | *pi4_mb_type = SVC_INTER_MB; |
1609 | 769k | i1_intra_slice_id = -1; |
1610 | 769k | } |
1611 | 188k | else |
1612 | 188k | { |
1613 | | /* INTRA */ |
1614 | 188k | *pi4_mb_type = SVC_INTRA_MB; |
1615 | 188k | i1_intra_slice_id = ps_inter_lyr_mb_prms->i1_slice_id; |
1616 | | |
1617 | 188k | if(1 == i1_cons_intr_samp_flag) |
1618 | 29.1k | { |
1619 | | /* check for different slice idc */ |
1620 | 29.1k | if(ps_inter_lyr_mb_prms->i1_slice_id != i1_curr_slice_id) |
1621 | 7.32k | { |
1622 | | /* store the mode as INTER (not available for upsampling) */ |
1623 | 7.32k | *pi4_mb_type = SVC_INTER_MB; |
1624 | 7.32k | } |
1625 | 29.1k | } |
1626 | 188k | } |
1627 | | |
1628 | | /* if contarained intra flag is 1 then check for same mb mode */ |
1629 | 957k | return (i1_intra_slice_id); |
1630 | 957k | } |
1631 | | /*****************************************************************************/ |
1632 | | /* */ |
1633 | | /* Function Name : isvcd_reflayer_construction */ |
1634 | | /* */ |
1635 | | /* Description : This function constructs the reference array buffer */ |
1636 | | /* used for intra resampling of a component in an MB */ |
1637 | | /* */ |
1638 | | /* Inputs : pv_intra_samp_ctxt: intra sampling context */ |
1639 | | /* pu1_inp : input (reference layer data) */ |
1640 | | /* i4_inp_stride : input buffer stride */ |
1641 | | /* ps_ref_mb_mode_map : ref layer mb mode buffer desc */ |
1642 | | /* pi4_refarr_wd : pointer to store the reference array WD */ |
1643 | | /* pi4_refarr_ht : pointer to store the reference array HT */ |
1644 | | /* pi4_x_offset : pointer to store the reference X offset */ |
1645 | | /* pi4_y_offset : pointer to store the reference Y offset */ |
1646 | | /* ps_coord : mb co-ordinate structure */ |
1647 | | /* i4_chroma_flag : chroma processing flag */ |
1648 | | /* Globals : none */ |
1649 | | /* Processing : it fills the reference layer data if they are falling in */ |
1650 | | /* INTRA MB region. If all the pixels are not filled it */ |
1651 | | /* calls the border extension algorithm to fill them */ |
1652 | | /* Outputs : none */ |
1653 | | /* Returns : none */ |
1654 | | /* */ |
1655 | | /* Issues : none */ |
1656 | | /* */ |
1657 | | /* Revision History: */ |
1658 | | /* */ |
1659 | | /* DD MM YYYY Author(s) Changes (Describe the changes made) */ |
1660 | | /* 06 09 2021 vijayakumar creation */ |
1661 | | /*****************************************************************************/ |
1662 | | WORD32 isvcd_reflayer_construction(void *pv_intra_samp_ctxt, UWORD8 *pu1_inp_1, UWORD8 *pu1_inp_2, |
1663 | | WORD32 i4_inp_stride, WORD32 i4_refarray_stride, |
1664 | | mem_element_t *ps_ref_mb_mode_map, mb_coord_t *ps_coord, |
1665 | | WORD32 i4_chroma_flag) |
1666 | 97.9k | { |
1667 | 97.9k | WORD32 i4_x, i4_y; |
1668 | | |
1669 | | /* --------------------------------------------------------------------- */ |
1670 | | /* Context and reference layer realted varaibles */ |
1671 | | /* --------------------------------------------------------------------- */ |
1672 | 97.9k | intra_sampling_ctxt_t *ps_ctxt; |
1673 | 97.9k | intra_samp_map_ctxt_t *ps_map_ctxt; |
1674 | 97.9k | intra_samp_lyr_ctxt *ps_lyr_ctxt; |
1675 | 97.9k | WORD8 *pi1_ref_mb_modes, *pi1_ref_mb_modes_bkp_1; |
1676 | 97.9k | WORD32 i4_ref_mode_stride; |
1677 | 97.9k | WORD32 i4_element_size; |
1678 | 97.9k | ref_mb_map_t *ps_x_off_len; |
1679 | 97.9k | ref_mb_map_t *ps_y_off_len; |
1680 | 97.9k | WORD32 i4_mbaddr_y; |
1681 | 97.9k | WORD32 i4_mbaddr_x; |
1682 | 97.9k | WORD32 i4_mb_ht, i4_mb_wd; |
1683 | 97.9k | UWORD8 u1_map_buf[4][4] = {0}; /*!< 4x4 mb grid buffer to store the mb availablity */ |
1684 | | /* --------------------------------------------------------------------- */ |
1685 | | /* Temp Variables for Mapping context */ |
1686 | | /* --------------------------------------------------------------------- */ |
1687 | 97.9k | WORD32 i4_ref_wd; |
1688 | 97.9k | WORD32 i4_ref_ht; |
1689 | 97.9k | WORD32 i4_x_offset; |
1690 | 97.9k | WORD32 i4_y_offset; |
1691 | 97.9k | WORD32 i4_refarray_wd; |
1692 | 97.9k | WORD32 i4_refarray_ht; |
1693 | 97.9k | WORD32 i4_mb_type; |
1694 | 97.9k | WORD8 i1_cons_intr_samp_flag; |
1695 | 97.9k | WORD8 i1_slice_id = 0; |
1696 | 97.9k | WORD32 i4_mb_wd_sft, i4_mb_ht_sft; |
1697 | | |
1698 | | /* --------------------------------------------------------------------- */ |
1699 | | /* Local Pointer Declaration for arrays in Mapping context */ |
1700 | | /* --------------------------------------------------------------------- */ |
1701 | | |
1702 | 97.9k | WORD32 i4_unfill_check; |
1703 | 97.9k | UWORD8 *pu1_refarray_1, *pu1_refarray_2; |
1704 | | |
1705 | 97.9k | UNUSED(pu1_inp_2); |
1706 | | |
1707 | 97.9k | ps_ctxt = (intra_sampling_ctxt_t *) pv_intra_samp_ctxt; |
1708 | 97.9k | ps_lyr_ctxt = &ps_ctxt->as_res_lyrs[ps_ctxt->i4_res_lyr_id]; |
1709 | 97.9k | pi1_ref_mb_modes = (WORD8 *) ps_ref_mb_mode_map->pv_buffer; |
1710 | 97.9k | i4_ref_mode_stride = ps_ref_mb_mode_map->i4_num_element_stride; |
1711 | 97.9k | i4_element_size = ps_ref_mb_mode_map->i4_element_size; |
1712 | | |
1713 | | /* get the condtrained intra sampling flag */ |
1714 | 97.9k | i1_cons_intr_samp_flag = ps_lyr_ctxt->i1_constrained_intra_rsmpl_flag; |
1715 | | |
1716 | 97.9k | if(NULL == pi1_ref_mb_modes) |
1717 | 0 | { |
1718 | 0 | return NOT_OK; |
1719 | 0 | } |
1720 | | |
1721 | | /* --------------------------------------------------------------------- */ |
1722 | | /* Based on Chroma and Luma, extracting the context information struct */ |
1723 | | /* --------------------------------------------------------------------- */ |
1724 | 97.9k | if(1 == i4_chroma_flag) |
1725 | 48.9k | ps_map_ctxt = &ps_lyr_ctxt->s_chroma_map_ctxt; |
1726 | 48.9k | else |
1727 | 48.9k | ps_map_ctxt = &ps_lyr_ctxt->s_luma_map_ctxt; |
1728 | | |
1729 | 97.9k | ps_x_off_len = ps_map_ctxt->ps_x_offset_length; |
1730 | 97.9k | ps_y_off_len = ps_map_ctxt->ps_y_offset_length; |
1731 | | |
1732 | | /* --------------------------------------------------------------------- */ |
1733 | | /* Deriving the parameters required for further processing */ |
1734 | | /* --------------------------------------------------------------------- */ |
1735 | 97.9k | { |
1736 | 97.9k | WORD32 i4_base_width = ps_lyr_ctxt->i4_ref_width; |
1737 | 97.9k | WORD32 i4_base_height = ps_lyr_ctxt->i4_ref_height; |
1738 | | |
1739 | 97.9k | i4_ref_wd = i4_base_width >> i4_chroma_flag; |
1740 | 97.9k | i4_ref_ht = i4_base_height >> i4_chroma_flag; |
1741 | 97.9k | i4_mb_wd_sft = (MB_WIDTH_SHIFT - i4_chroma_flag); |
1742 | 97.9k | i4_mb_ht_sft = (MB_HEIGHT_SHIFT - i4_chroma_flag); |
1743 | 97.9k | } |
1744 | | |
1745 | | /* --------------------------------------------------------------------- */ |
1746 | | /* Local variables based on the MB address */ |
1747 | | /* --------------------------------------------------------------------- */ |
1748 | 97.9k | i4_mbaddr_y = ps_coord->u2_mb_y; |
1749 | 97.9k | i4_mbaddr_x = ps_coord->u2_mb_x; |
1750 | 97.9k | i4_x_offset = ps_x_off_len[i4_mbaddr_x].i2_offset; |
1751 | 97.9k | i4_y_offset = ps_y_off_len[i4_mbaddr_y].i2_offset; |
1752 | 97.9k | i4_refarray_wd = ps_x_off_len[i4_mbaddr_x].i2_length; |
1753 | 97.9k | i4_refarray_ht = ps_y_off_len[i4_mbaddr_y].i2_length; |
1754 | 97.9k | i4_mb_wd = (MB_WIDTH >> i4_chroma_flag); |
1755 | 97.9k | i4_mb_ht = (MB_HEIGHT >> i4_chroma_flag); |
1756 | | |
1757 | | /* --------------------------------------------------------------------- */ |
1758 | | /* Derivation of ref slice MB idc */ |
1759 | | /* --------------------------------------------------------------------- */ |
1760 | 97.9k | if(1 == i1_cons_intr_samp_flag) |
1761 | 37.2k | { |
1762 | 37.2k | WORD32 i4_x_min, i4_x_max; |
1763 | 37.2k | WORD32 i4_y_min, i4_y_max; |
1764 | 37.2k | ref_min_max_map_t *ps_x_min_max; |
1765 | 37.2k | ref_min_max_map_t *ps_y_min_max; |
1766 | | |
1767 | 37.2k | ps_x_min_max = ps_map_ctxt->ps_x_min_max; |
1768 | 37.2k | ps_y_min_max = ps_map_ctxt->ps_y_min_max; |
1769 | | |
1770 | | /* get the min and max positions */ |
1771 | 37.2k | i4_x_min = ps_x_min_max[i4_mbaddr_x].i2_min_pos; |
1772 | 37.2k | i4_x_max = ps_x_min_max[i4_mbaddr_x].i2_max_pos; |
1773 | 37.2k | i4_y_min = ps_y_min_max[i4_mbaddr_y].i2_min_pos; |
1774 | 37.2k | i4_y_max = ps_y_min_max[i4_mbaddr_y].i2_max_pos; |
1775 | | |
1776 | | /* default initialization */ |
1777 | 37.2k | i4_mb_type = SVC_INTER_MB; |
1778 | | |
1779 | 37.2k | { |
1780 | 37.2k | WORD32 i4_x_ref; |
1781 | 37.2k | WORD32 i4_y_ref; |
1782 | 37.2k | WORD32 i4_mb_x, i4_mb_y; |
1783 | | |
1784 | 37.2k | i4_y_ref = (i4_y_min + 1) + i4_y_offset; |
1785 | 37.2k | i4_x_ref = (i4_x_min + 1) + i4_x_offset; |
1786 | 37.2k | i4_mb_x = (i4_x_ref >> i4_mb_wd_sft); |
1787 | 37.2k | i4_mb_y = (i4_y_ref >> i4_mb_ht_sft); |
1788 | 37.2k | pi1_ref_mb_modes = (WORD8 *) ps_ref_mb_mode_map->pv_buffer; |
1789 | | |
1790 | | /* get the location of the byte which has the current mb mode */ |
1791 | 37.2k | pi1_ref_mb_modes += (i4_mb_y * i4_ref_mode_stride * i4_element_size); |
1792 | 37.2k | pi1_ref_mb_modes += (i4_mb_x * i4_element_size); |
1793 | 37.2k | } |
1794 | | |
1795 | 75.1k | for(i4_y = (i4_y_min + 1); i4_y <= (i4_y_max - 1);) |
1796 | 47.9k | { |
1797 | 47.9k | WORD32 i4_x_ref; |
1798 | 47.9k | WORD32 i4_y_ref; |
1799 | 47.9k | WORD32 i4_distleftX, i4_rangeX; |
1800 | 47.9k | WORD32 i4_disttopY, i4_rangeY; |
1801 | | |
1802 | 47.9k | i4_y_ref = (i4_y + i4_y_offset); |
1803 | 47.9k | i4_disttopY = (i4_y_ref) & (i4_mb_ht - 1); |
1804 | 47.9k | i4_rangeY = (i4_mb_ht - i4_disttopY); |
1805 | | |
1806 | 47.9k | pi1_ref_mb_modes_bkp_1 = pi1_ref_mb_modes; |
1807 | | |
1808 | 100k | for(i4_x = (i4_x_min + 1); i4_x <= (i4_x_max - 1);) |
1809 | 62.1k | { |
1810 | 62.1k | i4_x_ref = (i4_x + i4_x_offset); |
1811 | 62.1k | i4_distleftX = (i4_x_ref) & (i4_mb_wd - 1); |
1812 | 62.1k | i4_rangeX = (i4_mb_wd - i4_distleftX); |
1813 | | |
1814 | | /* get the referecne layer mb type */ |
1815 | 62.1k | i1_slice_id = |
1816 | 62.1k | isvcd_get_ref_layer_mbtype(pi1_ref_mb_modes_bkp_1, &i4_mb_type, i1_slice_id, 0); |
1817 | 62.1k | if(SVC_INTRA_MB == i4_mb_type) |
1818 | 10.0k | { |
1819 | | /* if an Intra MB is returned then break the loop */ |
1820 | 10.0k | break; |
1821 | 10.0k | } |
1822 | | |
1823 | 52.0k | i4_x += i4_rangeX; |
1824 | 52.0k | pi1_ref_mb_modes_bkp_1 += i4_element_size; |
1825 | 52.0k | } /* end of loop in horizontal direction */ |
1826 | | |
1827 | 47.9k | if(SVC_INTRA_MB == i4_mb_type) |
1828 | 10.0k | { |
1829 | | /* if an Intra MB is returned then break the loop */ |
1830 | 10.0k | break; |
1831 | 10.0k | } |
1832 | | |
1833 | 37.8k | i4_y += i4_rangeY; |
1834 | 37.8k | pi1_ref_mb_modes += (i4_ref_mode_stride * i4_element_size); |
1835 | | |
1836 | 37.8k | } /* end of loop in vertical direction */ |
1837 | 37.2k | } |
1838 | 60.7k | else |
1839 | 60.7k | { |
1840 | | /* set to non valid value */ |
1841 | 60.7k | i1_slice_id = -1; |
1842 | 60.7k | } |
1843 | | |
1844 | 97.9k | i4_unfill_check = 0; |
1845 | | |
1846 | | /* --------------------------------------------------------------------- */ |
1847 | | /* Copying the data from recon buffer to refSample Array. */ |
1848 | | /* NOTE: The copying of the data from recon buffer to refSample Array */ |
1849 | | /* can be optimized by bring in data at N-MB level,thus taking */ |
1850 | | /* advantage of the overlapping data which now gets copied every MB*/ |
1851 | | /* --------------------------------------------------------------------- */ |
1852 | 97.9k | { |
1853 | 97.9k | WORD32 i4_x_ref_start, i4_x_ref_end; |
1854 | 97.9k | WORD32 i4_y_ref_start, i4_y_ref_end; |
1855 | 97.9k | WORD32 i4_rangeW, i4_rangeH; |
1856 | 97.9k | WORD32 i4_offset; |
1857 | 97.9k | UWORD8 *pu1_src, *pu1_dst; |
1858 | 97.9k | UWORD8 *pu1_dst1, *pu1_dst2; |
1859 | | |
1860 | | /* Copy (refW x refH) dimension into reference sample array */ |
1861 | 97.9k | i4_x_ref_start = MAX(0, MIN((i4_ref_wd - 1), i4_x_offset)); |
1862 | 97.9k | i4_x_ref_end = MAX(0, MIN((i4_ref_wd - 1), (i4_refarray_wd - 1) + i4_x_offset)); |
1863 | 97.9k | i4_y_ref_start = MAX(0, MIN((i4_ref_ht - 1), i4_y_offset)); |
1864 | 97.9k | i4_y_ref_end = MAX(0, MIN((i4_ref_ht - 1), (i4_refarray_ht - 1) + i4_y_offset)); |
1865 | | |
1866 | | /* find the actual data to be copied */ |
1867 | 97.9k | i4_rangeW = (i4_x_ref_end - i4_x_ref_start + 1); |
1868 | 97.9k | i4_rangeH = (i4_y_ref_end - i4_y_ref_start + 1); |
1869 | | |
1870 | | /* get the reconbuffer pointer and ref sample array pointer */ |
1871 | 97.9k | i4_offset = |
1872 | 97.9k | (i4_x_ref_start - i4_x_offset) + ((i4_y_ref_start - i4_y_offset) * i4_refarray_stride); |
1873 | | |
1874 | 97.9k | if(0 == i4_chroma_flag) |
1875 | 48.9k | { |
1876 | 48.9k | pu1_refarray_1 = ps_ctxt->pu1_refarray_buffer; |
1877 | 48.9k | pu1_refarray_2 = NULL; |
1878 | 48.9k | pu1_src = pu1_inp_1; |
1879 | 48.9k | pu1_dst = pu1_refarray_1 + i4_offset; |
1880 | | |
1881 | | /* Copy luma data into refsample array */ |
1882 | 48.9k | isvcd_copy_data(pu1_src, i4_inp_stride, pu1_dst, i4_refarray_stride, i4_rangeW, |
1883 | 48.9k | i4_rangeH); |
1884 | 48.9k | } |
1885 | 48.9k | else |
1886 | 48.9k | { |
1887 | 48.9k | pu1_refarray_1 = ps_ctxt->pu1_refarray_buffer; |
1888 | 48.9k | pu1_refarray_2 = ps_ctxt->pu1_refarray_cb; |
1889 | 48.9k | pu1_src = pu1_inp_1; |
1890 | 48.9k | pu1_dst1 = pu1_refarray_1 + i4_offset; |
1891 | 48.9k | pu1_dst2 = pu1_refarray_2 + i4_offset; |
1892 | 48.9k | isvcd_copy_data_semiplanr(pu1_src, i4_inp_stride, pu1_dst1, pu1_dst2, |
1893 | 48.9k | i4_refarray_stride, i4_rangeW, i4_rangeH); |
1894 | 48.9k | } |
1895 | 97.9k | } |
1896 | | |
1897 | | /* --------------------------------------------------------------------- */ |
1898 | | /* Loop to fill ref sample array and corresponding map for interpolation */ |
1899 | | /* --------------------------------------------------------------------- */ |
1900 | 97.9k | { |
1901 | 97.9k | WORD32 i4_i, i4_j; |
1902 | 97.9k | UWORD8 *pu1_ref_idx_x, *pu1_ref_idx_y; |
1903 | 97.9k | WORD32 i4_x_ref; |
1904 | 97.9k | WORD32 i4_y_ref; |
1905 | 97.9k | WORD32 i4_mb_x, i4_mb_y; |
1906 | | |
1907 | 97.9k | i4_y_ref = i4_y_offset; |
1908 | 97.9k | i4_x_ref = i4_x_offset; |
1909 | 97.9k | i4_mb_x = (i4_x_ref >> i4_mb_wd_sft); |
1910 | 97.9k | i4_mb_y = (i4_y_ref >> i4_mb_ht_sft); |
1911 | 97.9k | pi1_ref_mb_modes = (WORD8 *) ps_ref_mb_mode_map->pv_buffer; |
1912 | | |
1913 | | /* get the location of the byte which has the current mb mode */ |
1914 | 97.9k | pi1_ref_mb_modes += (i4_mb_y * i4_ref_mode_stride * i4_element_size); |
1915 | 97.9k | pi1_ref_mb_modes += (i4_mb_x * i4_element_size); |
1916 | 97.9k | pu1_ref_idx_x = ps_map_ctxt->pu1_refarray_x_idx; |
1917 | 97.9k | pu1_ref_idx_y = ps_map_ctxt->pu1_refarray_y_idx; |
1918 | | |
1919 | 97.9k | i4_j = 0; |
1920 | 391k | for(i4_y = 0; i4_y < i4_refarray_ht;) |
1921 | 293k | { |
1922 | 293k | WORD32 i4_x_ref; |
1923 | 293k | WORD32 i4_y_ref; |
1924 | 293k | WORD32 i4_distleftX, i4_rangeX; |
1925 | 293k | WORD32 i4_disttopY, i4_rangeY; |
1926 | | |
1927 | 293k | i4_y_ref = i4_y + i4_y_offset; |
1928 | 293k | i4_disttopY = (i4_y_ref) & (i4_mb_ht - 1); |
1929 | 293k | i4_rangeY = (i4_mb_ht - i4_disttopY); |
1930 | | |
1931 | | /* find the y-index lookup */ |
1932 | 293k | memset(pu1_ref_idx_y, i4_j, i4_rangeY); |
1933 | 293k | pu1_ref_idx_y += i4_rangeY; |
1934 | | |
1935 | 293k | i4_i = 0; |
1936 | 293k | pi1_ref_mb_modes_bkp_1 = pi1_ref_mb_modes; |
1937 | 1.18M | for(i4_x = 0; i4_x < i4_refarray_wd;) |
1938 | 895k | { |
1939 | 895k | i4_x_ref = i4_x + i4_x_offset; |
1940 | 895k | i4_distleftX = (i4_x_ref) & (i4_mb_wd - 1); |
1941 | 895k | i4_rangeX = (i4_mb_wd - i4_distleftX); |
1942 | | |
1943 | 895k | if(0 == i4_j) |
1944 | 293k | { |
1945 | | /* find the x-index lookup */ |
1946 | 293k | memset(pu1_ref_idx_x, i4_i, i4_rangeX); |
1947 | 293k | pu1_ref_idx_x += i4_rangeX; |
1948 | 293k | } |
1949 | | |
1950 | | /* get the referecne layer mb type */ |
1951 | 895k | isvcd_get_ref_layer_mbtype(pi1_ref_mb_modes_bkp_1, &i4_mb_type, i1_slice_id, |
1952 | 895k | i1_cons_intr_samp_flag); |
1953 | | |
1954 | 895k | if(SVC_INTRA_MB == i4_mb_type) |
1955 | 170k | { |
1956 | 170k | u1_map_buf[i4_j][i4_i] = 1; |
1957 | 170k | } |
1958 | 725k | else |
1959 | 725k | { |
1960 | 725k | i4_unfill_check = 1; |
1961 | 725k | } |
1962 | | |
1963 | 895k | i4_x = i4_x + i4_rangeX; |
1964 | 895k | i4_i++; |
1965 | 895k | pi1_ref_mb_modes_bkp_1 += i4_element_size; |
1966 | | |
1967 | 895k | } /* end of loop over ref array width */ |
1968 | | |
1969 | 293k | i4_j++; |
1970 | 293k | i4_y = i4_y + i4_rangeY; |
1971 | 293k | pi1_ref_mb_modes += (i4_ref_mode_stride * i4_element_size); |
1972 | 293k | } /* end of loop over ref array height */ |
1973 | 97.9k | } |
1974 | | |
1975 | | /* --------------------------------------------------------------------- */ |
1976 | | /* Calling boundary extension algorithm to fill unfilled pixels */ |
1977 | | /* --------------------------------------------------------------------- */ |
1978 | 97.9k | if(i4_unfill_check == 1) |
1979 | 97.7k | { |
1980 | 97.7k | isvcd_fill_non_avail_pixel(ps_map_ctxt, pu1_refarray_1, pu1_refarray_2, i4_refarray_stride, |
1981 | 97.7k | ps_coord, i4_chroma_flag, u1_map_buf); |
1982 | 97.7k | } |
1983 | 97.9k | return OK; |
1984 | 97.9k | } |
1985 | | |
1986 | | /*****************************************************************************/ |
1987 | | /* */ |
1988 | | /* Function Name : isvcd_reflayer_construction_dyadic */ |
1989 | | /* */ |
1990 | | /* Description : This function constructs the reference array buffer */ |
1991 | | /* for dyadic cases used for intra resampling of a */ |
1992 | | /* component in an MB */ |
1993 | | /* */ |
1994 | | /* Inputs : pv_intra_samp_ctxt : intra sampling context */ |
1995 | | /* ps_ref_mb_mode_map : ref layer mb mode buffer desc */ |
1996 | | /* pu1_inp_luma : luma input (reference layer data) */ |
1997 | | /* pu1_inp_chroma : chroma input (reference layer data) */ |
1998 | | /* i4_inp_luma_stride : luma input buffer stride */ |
1999 | | /* i4_inp_chroma_stride : chroma input buffer stride */ |
2000 | | /* i4_top : indicates whether the core 8x8 reference block */ |
2001 | | /* is one of 0 and 1 or one of 2 and 3 */ |
2002 | | /* i4_left : indicates whether the core 8x8 ref block */ |
2003 | | /* is one of 0 and 2 or one of 1 and 3 */ |
2004 | | /* ps_ref_mb_coord : coordinates of the reference MB */ |
2005 | | /* Globals : none */ |
2006 | | /* Processing : it fills the reference layer data if they are falling in */ |
2007 | | /* INTRA MB region. If all the pixels are not filled it */ |
2008 | | /* calls the border extension algorithm to fill them */ |
2009 | | /* Outputs : none */ |
2010 | | /* Returns : none */ |
2011 | | /* */ |
2012 | | /* Issues : none */ |
2013 | | /* */ |
2014 | | /* Revision History: */ |
2015 | | /* */ |
2016 | | /* DD MM YYYY Author(s) Changes (Describe the changes made) */ |
2017 | | /* 06 09 2021 Vijay creation */ |
2018 | | /* */ |
2019 | | /*****************************************************************************/ |
2020 | | WORD32 isvcd_reflayer_construction_dyadic(void *pv_intra_samp_ctxt, |
2021 | | mem_element_t *ps_ref_mb_mode_map, UWORD8 *pu1_inp_luma, |
2022 | | UWORD8 *pu1_inp_chroma, WORD32 i4_inp_luma_stride, |
2023 | | WORD32 i4_inp_chroma_stride, WORD32 i4_top, |
2024 | | WORD32 i4_left, UWORD16 u2_mb_x, UWORD16 u2_mb_y) |
2025 | 58.0k | { |
2026 | | /* Index variables */ |
2027 | 58.0k | WORD32 i4_x, i4_y; |
2028 | 58.0k | WORD32 i4_x0, i4_y0; |
2029 | 58.0k | WORD32 i4_xc0, i4_yc0; |
2030 | 58.0k | WORD32 i4_ref_xD, i4_ref_yD; |
2031 | 58.0k | WORD32 i4_c_ref_xD, i4_c_ref_yD; |
2032 | | |
2033 | | /* --------------------------------------------------------------------- */ |
2034 | | /* Context and reference layer related variables */ |
2035 | | /* --------------------------------------------------------------------- */ |
2036 | 58.0k | intra_sampling_ctxt_t *ps_ctxt; |
2037 | 58.0k | intra_samp_lyr_ctxt *ps_lyr_ctxt; |
2038 | 58.0k | WORD8 *pi1_ref_mb_modes; |
2039 | 58.0k | WORD32 i4_ref_mode_stride; |
2040 | 58.0k | WORD32 i4_element_size; |
2041 | 58.0k | WORD32 i4_mbaddr_y; |
2042 | 58.0k | WORD32 i4_mbaddr_x; |
2043 | | |
2044 | | /* --------------------------------------------------------------------- */ |
2045 | | /* Temp Variables for Mapping context */ |
2046 | | /* --------------------------------------------------------------------- */ |
2047 | 58.0k | WORD32 i4_refarray_wd_luma, i4_refarray_wd_chroma; |
2048 | 58.0k | WORD32 i4_refarray_ht_luma, i4_refarray_ht_chroma; |
2049 | 58.0k | WORD32 i4_avlblty; |
2050 | 58.0k | WORD8 i1_cons_intr_samp_flag; |
2051 | 58.0k | WORD8 i1_slice_id; |
2052 | 58.0k | WORD8 i1_corner_samp_avlbl_flag; |
2053 | 58.0k | UWORD8 u1_ny_avlblty; |
2054 | | |
2055 | | /* --------------------------------------------------------------------- */ |
2056 | | /* Local Pointer Declaration for arrays in Mapping context */ |
2057 | | /* --------------------------------------------------------------------- */ |
2058 | 58.0k | UWORD8 *pu1_refarray_luma; |
2059 | 58.0k | UWORD8 *pu1_refarray_cb, *pu1_refarray_cr; |
2060 | | |
2061 | | /* --------------------------------------------------------------------- */ |
2062 | | /* Derivation of local variables */ |
2063 | | /* --------------------------------------------------------------------- */ |
2064 | 58.0k | ps_ctxt = (intra_sampling_ctxt_t *) pv_intra_samp_ctxt; |
2065 | 58.0k | ps_lyr_ctxt = &ps_ctxt->as_res_lyrs[ps_ctxt->i4_res_lyr_id]; |
2066 | 58.0k | pi1_ref_mb_modes = (WORD8 *) ps_ref_mb_mode_map->pv_buffer; |
2067 | 58.0k | i4_ref_mode_stride = ps_ref_mb_mode_map->i4_num_element_stride; |
2068 | 58.0k | i4_element_size = ps_ref_mb_mode_map->i4_element_size; |
2069 | | |
2070 | | /* --------------------------------------------------------------------- */ |
2071 | | /* get the constrained intra resampling flag */ |
2072 | | /* --------------------------------------------------------------------- */ |
2073 | 58.0k | i1_cons_intr_samp_flag = ps_lyr_ctxt->i1_constrained_intra_rsmpl_flag; |
2074 | 58.0k | if(NULL == pi1_ref_mb_modes) |
2075 | 0 | { |
2076 | 0 | return NOT_OK; |
2077 | 0 | } |
2078 | | |
2079 | 58.0k | pu1_refarray_luma = ps_ctxt->pu1_refarray_buffer; |
2080 | 58.0k | pu1_refarray_cb = ps_ctxt->pu1_refarray_cb; |
2081 | 58.0k | pu1_refarray_cr = ps_ctxt->pu1_refarray_cr; |
2082 | | |
2083 | | /* --------------------------------------------------------------------- */ |
2084 | | /* Get the coordinates of the reference layer MB */ |
2085 | | /* --------------------------------------------------------------------- */ |
2086 | 58.0k | i4_mbaddr_x = u2_mb_x; |
2087 | 58.0k | i4_mbaddr_y = u2_mb_y; |
2088 | | |
2089 | | /* --------------------------------------------------------------------- */ |
2090 | | /* Getting the size of the valid area of ref array to be brought in */ |
2091 | | /* --------------------------------------------------------------------- */ |
2092 | 58.0k | i4_refarray_wd_luma = 20; |
2093 | 58.0k | i4_refarray_ht_luma = 20; |
2094 | 58.0k | i4_refarray_wd_chroma = i4_refarray_wd_luma >> 1; |
2095 | 58.0k | i4_refarray_ht_chroma = i4_refarray_ht_luma >> 1; |
2096 | | |
2097 | | /* --------------------------------------------------------------------- */ |
2098 | | /* Derivation of ref slice MB idc */ |
2099 | | /* --------------------------------------------------------------------- */ |
2100 | 58.0k | if(1 == i1_cons_intr_samp_flag) |
2101 | 35.0k | { |
2102 | 35.0k | inter_lyr_mb_prms_t *ps_inter_lyr_mb_prms; |
2103 | 35.0k | WORD8 *pi1_ref_mb_mode_tmp; |
2104 | 35.0k | WORD8 i1_mb_mode; |
2105 | | |
2106 | | /* get the location of the byte which has the current mb mode */ |
2107 | 35.0k | pi1_ref_mb_mode_tmp = pi1_ref_mb_modes; |
2108 | 35.0k | pi1_ref_mb_mode_tmp += (i4_mbaddr_y * i4_ref_mode_stride * i4_element_size); |
2109 | 35.0k | pi1_ref_mb_mode_tmp += (i4_mbaddr_x * i4_element_size); |
2110 | 35.0k | ps_inter_lyr_mb_prms = (inter_lyr_mb_prms_t *) pi1_ref_mb_mode_tmp; |
2111 | 35.0k | i1_mb_mode = ps_inter_lyr_mb_prms->i1_mb_mode; |
2112 | | |
2113 | | /* The reference layer MB should be intra */ |
2114 | 35.0k | UNUSED(i1_mb_mode); |
2115 | | |
2116 | 35.0k | i1_slice_id = ps_inter_lyr_mb_prms->i1_slice_id; |
2117 | 35.0k | } |
2118 | 23.0k | else |
2119 | 23.0k | { |
2120 | | /* set to non valid value */ |
2121 | 23.0k | i1_slice_id = -1; |
2122 | 23.0k | } |
2123 | | |
2124 | | /* --------------------------------------------------------------------- */ |
2125 | | /* Bring in the reference array */ |
2126 | | /* --------------------------------------------------------------------- */ |
2127 | 58.0k | { |
2128 | 58.0k | UWORD8 *pu1_src, *pu1_dst; |
2129 | 58.0k | WORD32 i4_src_stride, i4_dst_stride; |
2130 | | |
2131 | | /* Copy luma */ |
2132 | 58.0k | i4_src_stride = i4_inp_luma_stride; |
2133 | 58.0k | i4_dst_stride = DYADIC_REF_W_Y; |
2134 | 58.0k | pu1_src = pu1_inp_luma; |
2135 | 58.0k | pu1_dst = pu1_refarray_luma; |
2136 | 58.0k | isvcd_copy_data(pu1_src, i4_src_stride, pu1_dst, i4_dst_stride, i4_refarray_wd_luma, |
2137 | 58.0k | i4_refarray_ht_luma); |
2138 | | // Semi planar |
2139 | 58.0k | i4_src_stride = i4_inp_chroma_stride; |
2140 | 58.0k | i4_dst_stride = DYADIC_REF_W_C; |
2141 | 58.0k | pu1_src = pu1_inp_chroma; |
2142 | 58.0k | isvcd_copy_data_semiplanr(pu1_src, i4_src_stride, pu1_refarray_cb, pu1_refarray_cr, |
2143 | 58.0k | i4_dst_stride, i4_refarray_wd_chroma, i4_refarray_ht_chroma); |
2144 | 58.0k | } |
2145 | | |
2146 | | /* --------------------------------------------------------------------- */ |
2147 | | /* Get the availability of 5 neighboring MBs */ |
2148 | | /* --------------------------------------------------------------------- */ |
2149 | 58.0k | { |
2150 | | /* mb_x + left, mb_y + top */ |
2151 | 58.0k | isvcd_get_ref_layer_avlblty_dyadic(pi1_ref_mb_modes, i4_ref_mode_stride, i4_element_size, |
2152 | 58.0k | i4_mbaddr_x + i4_left, i4_mbaddr_y + i4_top, &i4_avlblty, |
2153 | 58.0k | i1_slice_id, i1_cons_intr_samp_flag); |
2154 | 58.0k | u1_ny_avlblty = i4_avlblty; |
2155 | | |
2156 | | /* mb_x + left, mb_y */ |
2157 | 58.0k | isvcd_get_ref_layer_avlblty_dyadic(pi1_ref_mb_modes, i4_ref_mode_stride, i4_element_size, |
2158 | 58.0k | i4_mbaddr_x + i4_left, i4_mbaddr_y, &i4_avlblty, |
2159 | 58.0k | i1_slice_id, i1_cons_intr_samp_flag); |
2160 | 58.0k | u1_ny_avlblty += (i4_avlblty << 1); |
2161 | | |
2162 | | /* mb_x, mb_y + top */ |
2163 | 58.0k | isvcd_get_ref_layer_avlblty_dyadic(pi1_ref_mb_modes, i4_ref_mode_stride, i4_element_size, |
2164 | 58.0k | i4_mbaddr_x, i4_mbaddr_y + i4_top, &i4_avlblty, |
2165 | 58.0k | i1_slice_id, i1_cons_intr_samp_flag); |
2166 | 58.0k | u1_ny_avlblty += (i4_avlblty << 2); |
2167 | | |
2168 | | /* mb_x - left, mb_y + top */ |
2169 | 58.0k | isvcd_get_ref_layer_avlblty_dyadic(pi1_ref_mb_modes, i4_ref_mode_stride, i4_element_size, |
2170 | 58.0k | i4_mbaddr_x - i4_left, i4_mbaddr_y + i4_top, &i4_avlblty, |
2171 | 58.0k | i1_slice_id, i1_cons_intr_samp_flag); |
2172 | 58.0k | u1_ny_avlblty += (i4_avlblty << 3); |
2173 | | |
2174 | | /* mb_x + left, mb_y - top */ |
2175 | 58.0k | isvcd_get_ref_layer_avlblty_dyadic(pi1_ref_mb_modes, i4_ref_mode_stride, i4_element_size, |
2176 | 58.0k | i4_mbaddr_x + i4_left, i4_mbaddr_y - i4_top, &i4_avlblty, |
2177 | 58.0k | i1_slice_id, i1_cons_intr_samp_flag); |
2178 | 58.0k | u1_ny_avlblty += (i4_avlblty << 4); |
2179 | 58.0k | } |
2180 | | |
2181 | | /* --------------------------------------------------------------------- */ |
2182 | | /* Filling the unavailable samples, if any */ |
2183 | | /* --------------------------------------------------------------------- */ |
2184 | 58.0k | if(0x7 == u1_ny_avlblty) |
2185 | 408 | { |
2186 | | /* All are available, exit */ |
2187 | 408 | return OK; |
2188 | 408 | } |
2189 | | |
2190 | 57.6k | if(!(u1_ny_avlblty & 0x7)) |
2191 | 37.9k | { |
2192 | 37.9k | UWORD8 *pu1_tmp_src, *pu1_tmp_dst1, *pu1_tmp_dst2; |
2193 | 37.9k | UWORD8 *pu1_tmp_src1, *pu1_tmp_src2; |
2194 | | |
2195 | | /* Set the 4 corner samples to (x-xD,y-yD) */ |
2196 | 37.9k | i4_x0 = 9 + (i4_left << 3) + i4_left; |
2197 | 37.9k | i4_y0 = 9 + (i4_top << 3) + i4_top; |
2198 | | |
2199 | 37.9k | i4_ref_xD = i4_x0 - i4_left - (i4_left >> 1); |
2200 | 37.9k | i4_ref_yD = i4_y0 - i4_top - (i4_top >> 1); |
2201 | | |
2202 | 37.9k | pu1_tmp_src = pu1_refarray_luma + (i4_ref_yD * DYADIC_REF_W_Y); |
2203 | 37.9k | pu1_tmp_dst1 = pu1_refarray_luma + (i4_y0 * DYADIC_REF_W_Y); |
2204 | 37.9k | pu1_tmp_dst2 = pu1_tmp_dst1 + DYADIC_REF_W_Y; |
2205 | 37.9k | pu1_tmp_dst1[i4_x0] = pu1_tmp_src[i4_ref_xD]; |
2206 | 37.9k | pu1_tmp_dst1[i4_x0 + 1] = pu1_tmp_src[i4_ref_xD]; |
2207 | 37.9k | pu1_tmp_dst2[i4_x0] = pu1_tmp_src[i4_ref_xD]; |
2208 | 37.9k | pu1_tmp_dst2[i4_x0 + 1] = pu1_tmp_src[i4_ref_xD]; |
2209 | | |
2210 | | /* Set the corner sample of Cb and Cr to (x-xD,y-yD) */ |
2211 | 37.9k | i4_xc0 = i4_x0 >> 1; |
2212 | 37.9k | i4_yc0 = i4_y0 >> 1; |
2213 | 37.9k | i4_c_ref_yD = i4_ref_yD >> 1; |
2214 | 37.9k | i4_c_ref_xD = i4_ref_xD >> 1; |
2215 | 37.9k | pu1_tmp_src1 = pu1_refarray_cb + (i4_c_ref_yD * DYADIC_REF_W_C); |
2216 | 37.9k | pu1_tmp_dst1 = pu1_refarray_cb + (i4_yc0 * DYADIC_REF_W_C); |
2217 | 37.9k | pu1_tmp_dst1[i4_xc0] = pu1_tmp_src1[i4_c_ref_xD]; |
2218 | 37.9k | pu1_tmp_src2 = pu1_refarray_cr + (i4_c_ref_yD * DYADIC_REF_W_C); |
2219 | 37.9k | pu1_tmp_dst2 = pu1_refarray_cr + (i4_yc0 * DYADIC_REF_W_C); |
2220 | 37.9k | pu1_tmp_dst2[i4_xc0] = pu1_tmp_src2[i4_c_ref_xD]; |
2221 | 37.9k | } |
2222 | | |
2223 | 57.6k | if(!(u1_ny_avlblty & 0x5)) |
2224 | 40.5k | { |
2225 | 40.5k | UWORD8 *pu1_tmp_src, *pu1_tmp_dst1, *pu1_tmp_dst2; |
2226 | 40.5k | UWORD8 *pu1_tmp_src1, *pu1_tmp_src2; |
2227 | | |
2228 | | /* Copy (x0,ref_yD), (x0+1,ref_yD), ..., (x0+7,ref_yD) to */ |
2229 | | /* (x0,y0), (x0+1,y0), ..., (x0+7,y0) and */ |
2230 | | /* (x0,y0+1), (x0+1,y0+1), ..., (x0+7,y0+1) */ |
2231 | 40.5k | i4_x0 = 2; |
2232 | 40.5k | i4_y0 = 9 + (i4_top << 3) + i4_top; |
2233 | 40.5k | if(i4_left > 0) |
2234 | 19.8k | { |
2235 | 19.8k | i4_x0 += 8; |
2236 | 19.8k | } |
2237 | 40.5k | i4_ref_yD = i4_y0 - i4_top - (i4_top >> 1); |
2238 | | |
2239 | 40.5k | pu1_tmp_src = pu1_refarray_luma + (i4_ref_yD * DYADIC_REF_W_Y); |
2240 | 40.5k | pu1_tmp_dst1 = pu1_refarray_luma + (i4_y0 * DYADIC_REF_W_Y); |
2241 | 40.5k | pu1_tmp_dst2 = pu1_tmp_dst1 + DYADIC_REF_W_Y; |
2242 | | |
2243 | 365k | for(i4_x = i4_x0; i4_x < i4_x0 + 8; i4_x++) |
2244 | 324k | { |
2245 | 324k | pu1_tmp_dst1[i4_x] = pu1_tmp_src[i4_x]; |
2246 | 324k | pu1_tmp_dst2[i4_x] = pu1_tmp_src[i4_x]; |
2247 | 324k | } |
2248 | | |
2249 | | /* Cb and Cr copy */ |
2250 | 40.5k | i4_xc0 = i4_x0 >> 1; |
2251 | 40.5k | i4_yc0 = i4_y0 >> 1; |
2252 | 40.5k | i4_c_ref_yD = i4_ref_yD >> 1; |
2253 | 40.5k | pu1_tmp_src1 = pu1_refarray_cb + (i4_c_ref_yD * DYADIC_REF_W_C); |
2254 | 40.5k | pu1_tmp_dst1 = pu1_refarray_cb + (i4_yc0 * DYADIC_REF_W_C); |
2255 | 40.5k | pu1_tmp_src2 = pu1_refarray_cr + (i4_c_ref_yD * DYADIC_REF_W_C); |
2256 | 40.5k | pu1_tmp_dst2 = pu1_refarray_cr + (i4_yc0 * DYADIC_REF_W_C); |
2257 | | |
2258 | 202k | for(i4_x = i4_xc0; i4_x < i4_xc0 + 4; i4_x++) |
2259 | 162k | { |
2260 | 162k | pu1_tmp_dst1[i4_x] = pu1_tmp_src1[i4_x]; |
2261 | 162k | pu1_tmp_dst2[i4_x] = pu1_tmp_src2[i4_x]; |
2262 | 162k | } |
2263 | 40.5k | } |
2264 | | |
2265 | 57.6k | if(!(u1_ny_avlblty & 0x3)) |
2266 | 43.7k | { |
2267 | 43.7k | UWORD8 *pu1_tmp_src, *pu1_tmp_dst1, *pu1_tmp_dst2; |
2268 | 43.7k | UWORD8 *pu1_tmp_src1, *pu1_tmp_src2; |
2269 | | |
2270 | | /* Copy (ref_xD,y0) to (x0,y0) and (x0+1,y0); */ |
2271 | | /* copy (ref_xD,y0+1) to (x0,y0+1) and (x0+1,y0+1); ... ;*/ |
2272 | | /* copy (ref_xD,y0+7) to (x0,y0+7) and (x0+1,y0+7) */ |
2273 | 43.7k | i4_x0 = 9 + (i4_left << 3) + i4_left; |
2274 | 43.7k | i4_y0 = 2; |
2275 | 43.7k | if(i4_top > 0) |
2276 | 20.8k | { |
2277 | 20.8k | i4_y0 += 8; |
2278 | 20.8k | } |
2279 | 43.7k | i4_ref_xD = i4_x0 - i4_left - (i4_left >> 1); |
2280 | | |
2281 | 43.7k | pu1_tmp_src = pu1_refarray_luma + (i4_y0 * DYADIC_REF_W_Y); |
2282 | 43.7k | pu1_tmp_dst1 = pu1_tmp_src; |
2283 | | |
2284 | 393k | for(i4_y = i4_y0; i4_y < i4_y0 + 8; i4_y++) |
2285 | 349k | { |
2286 | 349k | pu1_tmp_dst1[i4_x0] = pu1_tmp_src[i4_ref_xD]; |
2287 | 349k | pu1_tmp_dst1[i4_x0 + 1] = pu1_tmp_src[i4_ref_xD]; |
2288 | 349k | pu1_tmp_src += DYADIC_REF_W_Y; |
2289 | 349k | pu1_tmp_dst1 += DYADIC_REF_W_Y; |
2290 | 349k | } |
2291 | | |
2292 | | /* Cb and Cr copy */ |
2293 | 43.7k | i4_xc0 = i4_x0 >> 1; |
2294 | 43.7k | i4_yc0 = i4_y0 >> 1; |
2295 | 43.7k | i4_c_ref_xD = i4_ref_xD >> 1; |
2296 | 43.7k | pu1_tmp_src1 = pu1_refarray_cb + (i4_yc0 * DYADIC_REF_W_C); |
2297 | 43.7k | pu1_tmp_dst1 = pu1_tmp_src1; |
2298 | 43.7k | pu1_tmp_src2 = pu1_refarray_cr + (i4_yc0 * DYADIC_REF_W_C); |
2299 | 43.7k | pu1_tmp_dst2 = pu1_tmp_src2; |
2300 | | |
2301 | 218k | for(i4_y = i4_yc0; i4_y < i4_yc0 + 4; i4_y++) |
2302 | 174k | { |
2303 | 174k | pu1_tmp_dst1[i4_xc0] = pu1_tmp_src1[i4_c_ref_xD]; |
2304 | 174k | pu1_tmp_dst2[i4_xc0] = pu1_tmp_src2[i4_c_ref_xD]; |
2305 | 174k | pu1_tmp_src1 += DYADIC_REF_W_C; |
2306 | 174k | pu1_tmp_src2 += DYADIC_REF_W_C; |
2307 | 174k | pu1_tmp_dst1 += DYADIC_REF_W_C; |
2308 | 174k | pu1_tmp_dst2 += DYADIC_REF_W_C; |
2309 | 174k | } |
2310 | 43.7k | } |
2311 | | |
2312 | 57.6k | if(!(u1_ny_avlblty & 0x4)) |
2313 | 47.6k | { |
2314 | 47.6k | if(!(u1_ny_avlblty & 0x8)) |
2315 | 40.3k | { |
2316 | | /* (mb_x-left,mb_y+top) not available */ |
2317 | 40.3k | UWORD8 *pu1_tmp_src, *pu1_tmp_dst; |
2318 | | |
2319 | 40.3k | i4_x0 = 9 - i4_left; |
2320 | 40.3k | i4_y0 = 9 + (i4_top << 3) + i4_top; |
2321 | | |
2322 | 40.3k | i4_ref_yD = i4_y0 - i4_top - (i4_top >> 1); |
2323 | | |
2324 | | /* Copy (x0,ref_yD) and (x0+1,ref_yD) to (x0,y0) and (x0+1,y0), and */ |
2325 | | /* to (x0,y0+1) and (x0+1,y0+1) */ |
2326 | 40.3k | pu1_tmp_src = pu1_refarray_luma + (i4_ref_yD * DYADIC_REF_W_Y); |
2327 | 40.3k | pu1_tmp_dst = pu1_refarray_luma + (i4_y0 * DYADIC_REF_W_Y); |
2328 | 40.3k | pu1_tmp_dst[i4_x0] = pu1_tmp_src[i4_x0]; |
2329 | 40.3k | pu1_tmp_dst[i4_x0 + 1] = pu1_tmp_src[i4_x0 + 1]; |
2330 | 40.3k | pu1_tmp_dst += DYADIC_REF_W_Y; |
2331 | 40.3k | pu1_tmp_dst[i4_x0] = pu1_tmp_src[i4_x0]; |
2332 | 40.3k | pu1_tmp_dst[i4_x0 + 1] = pu1_tmp_src[i4_x0 + 1]; |
2333 | | |
2334 | | /* Cb copy */ |
2335 | 40.3k | i4_xc0 = i4_x0 >> 1; |
2336 | 40.3k | i4_yc0 = i4_y0 >> 1; |
2337 | 40.3k | i4_c_ref_yD = i4_ref_yD >> 1; |
2338 | 40.3k | pu1_tmp_src = pu1_refarray_cb + (i4_c_ref_yD * DYADIC_REF_W_C); |
2339 | 40.3k | pu1_tmp_dst = pu1_refarray_cb + (i4_yc0 * DYADIC_REF_W_C); |
2340 | 40.3k | pu1_tmp_dst[i4_xc0] = pu1_tmp_src[i4_xc0]; |
2341 | | |
2342 | | /* Cr copy */ |
2343 | 40.3k | pu1_tmp_src = pu1_refarray_cr + (i4_c_ref_yD * DYADIC_REF_W_C); |
2344 | 40.3k | pu1_tmp_dst = pu1_refarray_cr + (i4_yc0 * DYADIC_REF_W_C); |
2345 | 40.3k | pu1_tmp_dst[i4_xc0] = pu1_tmp_src[i4_xc0]; |
2346 | | |
2347 | 40.3k | } /* if (mb_x-left,mb_y+top) not available */ |
2348 | 7.27k | else |
2349 | 7.27k | { |
2350 | 7.27k | WORD32 i4_xD, i4_yD; |
2351 | 7.27k | WORD32 i4_c_xD, i4_c_yD; |
2352 | | |
2353 | 7.27k | isvcd_get_ref_layer_avlblty_dyadic(pi1_ref_mb_modes, i4_ref_mode_stride, |
2354 | 7.27k | i4_element_size, i4_mbaddr_x - i4_left, i4_mbaddr_y, |
2355 | 7.27k | &i4_avlblty, i1_slice_id, i1_cons_intr_samp_flag); |
2356 | 7.27k | i1_corner_samp_avlbl_flag = i4_avlblty; |
2357 | | |
2358 | 7.27k | i4_x0 = 9 - i4_left; |
2359 | 7.27k | i4_y0 = 9 + (i4_top << 3) + i4_top; |
2360 | 7.27k | i4_xc0 = i4_x0 >> 1; |
2361 | 7.27k | i4_yc0 = i4_y0 >> 1; |
2362 | 7.27k | i4_ref_yD = i4_y0 - i4_top - (i4_top >> 1); |
2363 | 7.27k | i4_ref_xD = i4_x0 - (i4_left * 7) - (i4_left >> 1); |
2364 | 7.27k | i4_c_ref_xD = i4_ref_xD >> 1; |
2365 | 7.27k | i4_c_ref_yD = i4_ref_yD >> 1; |
2366 | 7.27k | i4_xD = i4_x0 - i4_ref_xD; |
2367 | 7.27k | i4_yD = i4_y0 - i4_ref_yD; |
2368 | 7.27k | i4_c_xD = i4_xc0 - i4_c_ref_xD; |
2369 | 7.27k | i4_c_yD = i4_yc0 - i4_c_ref_yD; |
2370 | | |
2371 | | /* Fill corner sample if not available */ |
2372 | 7.27k | if(!i1_corner_samp_avlbl_flag) |
2373 | 6.99k | { |
2374 | 6.99k | isvcd_corner_samp_dyadic(i4_x0, i4_y0, i4_xD, i4_yD, pu1_refarray_luma, |
2375 | 6.99k | pu1_refarray_cb, pu1_refarray_cr); |
2376 | 6.99k | } |
2377 | | |
2378 | | /* Call diagonal construction for luma */ |
2379 | 21.8k | for(i4_y = i4_y0; i4_y < i4_y0 + 2; i4_y++) |
2380 | 14.5k | { |
2381 | 43.6k | for(i4_x = i4_x0; i4_x < i4_x0 + 2; i4_x++) |
2382 | 29.0k | { |
2383 | 29.0k | isvcd_diagonal_construct_dyadic(i4_x, i4_y, i4_xD, i4_yD, pu1_refarray_luma, |
2384 | 29.0k | DYADIC_REF_W_Y); |
2385 | 29.0k | i4_xD++; |
2386 | 29.0k | } |
2387 | 14.5k | i4_yD++; |
2388 | 14.5k | i4_xD -= 2; |
2389 | 14.5k | } |
2390 | | |
2391 | | /* Call diagonal construction for chroma */ |
2392 | 7.27k | isvcd_diagonal_construct_dyadic(i4_xc0, i4_yc0, i4_c_xD, i4_c_yD, pu1_refarray_cb, |
2393 | 7.27k | DYADIC_REF_W_C); |
2394 | | |
2395 | 7.27k | isvcd_diagonal_construct_dyadic(i4_xc0, i4_yc0, i4_c_xD, i4_c_yD, pu1_refarray_cr, |
2396 | 7.27k | DYADIC_REF_W_C); |
2397 | 7.27k | } |
2398 | 47.6k | } |
2399 | | |
2400 | 57.6k | if(!(u1_ny_avlblty & 0x2)) |
2401 | 51.5k | { |
2402 | 51.5k | if(!(u1_ny_avlblty & 0x10)) |
2403 | 44.0k | { |
2404 | 44.0k | UWORD8 *pu1_tmp_src, *pu1_tmp_dst; |
2405 | | |
2406 | 44.0k | i4_x0 = 9 + (i4_left << 3) + i4_left; |
2407 | 44.0k | i4_y0 = 9 - i4_top; |
2408 | 44.0k | i4_ref_xD = i4_x0 - i4_left - (i4_left >> 1); |
2409 | | |
2410 | | /* Copy (ref_xD,y0) to (x0,y0), (x0+1,y0), and */ |
2411 | | /* copy (ref_xD,y0+1) to (x0,y0+1), (x0+1,y0+1) */ |
2412 | 44.0k | pu1_tmp_src = pu1_refarray_luma + (i4_y0 * DYADIC_REF_W_Y); |
2413 | 44.0k | pu1_tmp_dst = pu1_tmp_src; |
2414 | 44.0k | pu1_tmp_dst[i4_x0] = pu1_tmp_src[i4_ref_xD]; |
2415 | 44.0k | pu1_tmp_dst[i4_x0 + 1] = pu1_tmp_src[i4_ref_xD]; |
2416 | 44.0k | pu1_tmp_src += DYADIC_REF_W_Y; |
2417 | 44.0k | pu1_tmp_dst += DYADIC_REF_W_Y; |
2418 | 44.0k | pu1_tmp_dst[i4_x0] = pu1_tmp_src[i4_ref_xD]; |
2419 | 44.0k | pu1_tmp_dst[i4_x0 + 1] = pu1_tmp_src[i4_ref_xD]; |
2420 | | |
2421 | | /* Cb copy */ |
2422 | 44.0k | i4_xc0 = i4_x0 >> 1; |
2423 | 44.0k | i4_yc0 = i4_y0 >> 1; |
2424 | 44.0k | i4_c_ref_xD = i4_ref_xD >> 1; |
2425 | 44.0k | pu1_tmp_src = pu1_refarray_cb + (i4_yc0 * DYADIC_REF_W_C); |
2426 | 44.0k | pu1_tmp_dst = pu1_tmp_src; |
2427 | 44.0k | pu1_tmp_dst[i4_xc0] = pu1_tmp_src[i4_c_ref_xD]; |
2428 | | |
2429 | | /* Cr copy */ |
2430 | 44.0k | pu1_tmp_src = pu1_refarray_cr + (i4_yc0 * DYADIC_REF_W_C); |
2431 | 44.0k | pu1_tmp_dst = pu1_tmp_src; |
2432 | 44.0k | pu1_tmp_dst[i4_xc0] = pu1_tmp_src[i4_c_ref_xD]; |
2433 | | |
2434 | 44.0k | } /* if (mb_x+left,mb_y-top) not available */ |
2435 | 7.54k | else |
2436 | 7.54k | { |
2437 | 7.54k | WORD32 i4_xD, i4_yD; |
2438 | 7.54k | WORD32 i4_c_xD, i4_c_yD; |
2439 | | |
2440 | 7.54k | isvcd_get_ref_layer_avlblty_dyadic(pi1_ref_mb_modes, i4_ref_mode_stride, |
2441 | 7.54k | i4_element_size, i4_mbaddr_x, i4_mbaddr_y - i4_top, |
2442 | 7.54k | &i4_avlblty, i1_slice_id, i1_cons_intr_samp_flag); |
2443 | 7.54k | i1_corner_samp_avlbl_flag = i4_avlblty; |
2444 | | |
2445 | 7.54k | i4_x0 = 9 + (i4_left << 3) + i4_left; |
2446 | 7.54k | i4_y0 = 9 - i4_top; |
2447 | 7.54k | i4_xc0 = i4_x0 >> 1; |
2448 | 7.54k | i4_yc0 = i4_y0 >> 1; |
2449 | 7.54k | i4_ref_xD = i4_x0 - i4_left - (i4_left >> 1); |
2450 | 7.54k | i4_ref_yD = i4_y0 - (i4_top * 7) - (i4_top >> 1); |
2451 | 7.54k | i4_c_ref_xD = i4_ref_xD >> 1; |
2452 | 7.54k | i4_c_ref_yD = i4_ref_yD >> 1; |
2453 | 7.54k | i4_xD = i4_x0 - i4_ref_xD; |
2454 | 7.54k | i4_yD = i4_y0 - i4_ref_yD; |
2455 | 7.54k | i4_c_xD = i4_xc0 - i4_c_ref_xD; |
2456 | 7.54k | i4_c_yD = i4_yc0 - i4_c_ref_yD; |
2457 | | |
2458 | 7.54k | if(!i1_corner_samp_avlbl_flag) |
2459 | 6.54k | { |
2460 | 6.54k | isvcd_corner_samp_dyadic(i4_x0, i4_y0, i4_xD, i4_yD, pu1_refarray_luma, |
2461 | 6.54k | pu1_refarray_cb, pu1_refarray_cr); |
2462 | 6.54k | } |
2463 | | |
2464 | | /* Call diagonal consrtuction for luma */ |
2465 | 22.6k | for(i4_y = i4_y0; i4_y < i4_y0 + 2; i4_y++) |
2466 | 15.0k | { |
2467 | 45.2k | for(i4_x = i4_x0; i4_x < i4_x0 + 2; i4_x++) |
2468 | 30.1k | { |
2469 | 30.1k | isvcd_diagonal_construct_dyadic(i4_x, i4_y, i4_xD, i4_yD, pu1_refarray_luma, |
2470 | 30.1k | DYADIC_REF_W_Y); |
2471 | 30.1k | i4_xD++; |
2472 | 30.1k | } |
2473 | 15.0k | i4_yD++; |
2474 | 15.0k | i4_xD -= 2; |
2475 | 15.0k | } |
2476 | | |
2477 | | /* Call diagonal construction for chroma */ |
2478 | 7.54k | isvcd_diagonal_construct_dyadic(i4_xc0, i4_yc0, i4_c_xD, i4_c_yD, pu1_refarray_cb, |
2479 | 7.54k | DYADIC_REF_W_C); |
2480 | | |
2481 | 7.54k | isvcd_diagonal_construct_dyadic(i4_xc0, i4_yc0, i4_c_xD, i4_c_yD, pu1_refarray_cr, |
2482 | 7.54k | DYADIC_REF_W_C); |
2483 | 7.54k | } |
2484 | 51.5k | } |
2485 | | |
2486 | 57.6k | if(u1_ny_avlblty & 1) |
2487 | 8.67k | { |
2488 | 8.67k | if(!(u1_ny_avlblty & 2)) |
2489 | 7.86k | { |
2490 | | /* (mb_x+left,mb_y) is unavailable */ |
2491 | 7.86k | WORD32 i4_xD, i4_yD; |
2492 | 7.86k | WORD32 i4_c_xD, i4_c_yD; |
2493 | 7.86k | UWORD8 *pu1_tmp_dst; |
2494 | 7.86k | UWORD8 u1_filled_samp; |
2495 | | |
2496 | 7.86k | i1_corner_samp_avlbl_flag = (u1_ny_avlblty & 4) >> 2; |
2497 | | |
2498 | 7.86k | i4_x0 = 9 + (i4_left << 3) + i4_left; |
2499 | 7.86k | i4_y0 = 2; |
2500 | 7.86k | i4_ref_yD = 1; |
2501 | 7.86k | if(i4_top > 0) |
2502 | 3.65k | { |
2503 | 3.65k | i4_y0 += 8; |
2504 | 3.65k | i4_ref_yD = 18; |
2505 | 3.65k | } |
2506 | | |
2507 | 7.86k | i4_ref_xD = i4_x0 - (i4_left) - (i4_left >> 1); |
2508 | 7.86k | i4_xD = i4_x0 - i4_ref_xD; |
2509 | 7.86k | i4_yD = i4_y0 - i4_ref_yD; |
2510 | 7.86k | i4_xc0 = i4_x0 >> 1; |
2511 | 7.86k | i4_yc0 = i4_y0 >> 1; |
2512 | 7.86k | i4_c_ref_xD = i4_ref_xD >> 1; |
2513 | 7.86k | i4_c_ref_yD = i4_ref_yD >> 1; |
2514 | 7.86k | i4_c_xD = i4_xc0 - i4_c_ref_xD; |
2515 | 7.86k | i4_c_yD = i4_yc0 - i4_c_ref_yD; |
2516 | | |
2517 | | /* Fill corner sample if unavailable */ |
2518 | 7.86k | if(!i1_corner_samp_avlbl_flag) |
2519 | 6.79k | { |
2520 | 6.79k | isvcd_corner_samp_dyadic(i4_x0, i4_y0, i4_xD, i4_yD, pu1_refarray_luma, |
2521 | 6.79k | pu1_refarray_cb, pu1_refarray_cr); |
2522 | 6.79k | } |
2523 | | |
2524 | | /* Call the diagonal construction for the 8 rows */ |
2525 | 7.86k | if(i4_top == i4_left) |
2526 | 3.77k | { |
2527 | | /* if top * left = 1 (x0,y0) */ |
2528 | 3.77k | u1_filled_samp = isvcd_diagonal_construct_dyadic(i4_x0, i4_y0, i4_xD, i4_yD, |
2529 | 3.77k | pu1_refarray_luma, DYADIC_REF_W_Y); |
2530 | | |
2531 | 3.77k | pu1_tmp_dst = pu1_refarray_luma + (i4_y0 * DYADIC_REF_W_Y); |
2532 | | |
2533 | | /* (x0,y0+1), ..., (x0,y0+7) and */ |
2534 | | /* (x0+1,y0), ..., (x0+1,y0+6) */ |
2535 | 30.2k | for(i4_y = i4_y0 + 1; i4_y < i4_y0 + 8; i4_y++) |
2536 | 26.4k | { |
2537 | 26.4k | i4_yD++; |
2538 | 26.4k | u1_filled_samp = isvcd_diagonal_construct_dyadic( |
2539 | 26.4k | i4_x0, i4_y, i4_xD, i4_yD, pu1_refarray_luma, DYADIC_REF_W_Y); |
2540 | 26.4k | pu1_tmp_dst[i4_x0 + 1] = u1_filled_samp; |
2541 | 26.4k | pu1_tmp_dst += DYADIC_REF_W_Y; |
2542 | 26.4k | } |
2543 | | |
2544 | | /* (x0+1,y0+7) */ |
2545 | 3.77k | u1_filled_samp = isvcd_diagonal_construct_dyadic( |
2546 | 3.77k | i4_x0 + 1, i4_y0 + 7, i4_xD + 1, i4_yD, pu1_refarray_luma, DYADIC_REF_W_Y); |
2547 | 3.77k | } |
2548 | 4.08k | else |
2549 | 4.08k | { |
2550 | | /* top * left = -1 (x0+1,y0) */ |
2551 | 4.08k | u1_filled_samp = isvcd_diagonal_construct_dyadic(i4_x0 + 1, i4_y0, i4_xD + 1, i4_yD, |
2552 | 4.08k | pu1_refarray_luma, DYADIC_REF_W_Y); |
2553 | | |
2554 | 4.08k | pu1_tmp_dst = pu1_refarray_luma + (i4_y0 * DYADIC_REF_W_Y); |
2555 | | |
2556 | | /* (x0,y0), ..., (x0,y0+6) and */ |
2557 | | /* (x0+1,y0+1), ..., (x0+1,y0+7) */ |
2558 | 32.6k | for(i4_y = i4_y0; i4_y < i4_y0 + 7; i4_y++) |
2559 | 28.5k | { |
2560 | 28.5k | u1_filled_samp = isvcd_diagonal_construct_dyadic( |
2561 | 28.5k | i4_x0, i4_y, i4_xD, i4_yD, pu1_refarray_luma, DYADIC_REF_W_Y); |
2562 | | |
2563 | 28.5k | pu1_tmp_dst += DYADIC_REF_W_Y; |
2564 | 28.5k | pu1_tmp_dst[i4_x0 + 1] = u1_filled_samp; |
2565 | 28.5k | i4_yD++; |
2566 | 28.5k | } |
2567 | | |
2568 | | /* (x0,y0+7) */ |
2569 | 4.08k | u1_filled_samp = isvcd_diagonal_construct_dyadic(i4_x0, i4_y0 + 7, i4_xD, i4_yD, |
2570 | 4.08k | pu1_refarray_luma, DYADIC_REF_W_Y); |
2571 | 4.08k | } |
2572 | | |
2573 | | /* For Cb and Cr */ |
2574 | 39.3k | for(i4_y = i4_yc0; i4_y < i4_yc0 + 4; i4_y++) |
2575 | 31.4k | { |
2576 | 31.4k | u1_filled_samp = isvcd_diagonal_construct_dyadic(i4_xc0, i4_y, i4_c_xD, i4_c_yD, |
2577 | 31.4k | pu1_refarray_cb, DYADIC_REF_W_C); |
2578 | 31.4k | u1_filled_samp = isvcd_diagonal_construct_dyadic(i4_xc0, i4_y, i4_c_xD, i4_c_yD, |
2579 | 31.4k | pu1_refarray_cr, DYADIC_REF_W_C); |
2580 | 31.4k | i4_c_yD++; |
2581 | 31.4k | } |
2582 | | |
2583 | 7.86k | } /* (mb_x+left,mb_y) is unavailable */ |
2584 | | |
2585 | 8.67k | if(!(u1_ny_avlblty & 4)) |
2586 | 7.08k | { |
2587 | | /* (mb_x,mb_y+top) is unavailable */ |
2588 | 7.08k | WORD32 i4_xD, i4_yD; |
2589 | 7.08k | WORD32 i4_c_xD, i4_c_yD; |
2590 | 7.08k | UWORD8 *pu1_tmp_dst; |
2591 | 7.08k | UWORD8 u1_filled_samp; |
2592 | | |
2593 | 7.08k | i1_corner_samp_avlbl_flag = (u1_ny_avlblty & 2) >> 1; |
2594 | 7.08k | i4_y0 = 9 + (i4_top << 3) + (i4_top); |
2595 | 7.08k | i4_x0 = 2; |
2596 | 7.08k | i4_ref_xD = 1; |
2597 | 7.08k | if(i4_left > 0) |
2598 | 3.92k | { |
2599 | 3.92k | i4_x0 += 8; |
2600 | 3.92k | i4_ref_xD = 18; |
2601 | 3.92k | } |
2602 | | |
2603 | 7.08k | i4_ref_yD = i4_y0 - i4_top - (i4_top >> 1); |
2604 | 7.08k | i4_xD = i4_x0 - i4_ref_xD; |
2605 | 7.08k | i4_yD = i4_y0 - i4_ref_yD; |
2606 | 7.08k | i4_xc0 = i4_x0 >> 1; |
2607 | 7.08k | i4_yc0 = i4_y0 >> 1; |
2608 | 7.08k | i4_c_ref_xD = i4_ref_xD >> 1; |
2609 | 7.08k | i4_c_ref_yD = i4_ref_yD >> 1; |
2610 | 7.08k | i4_c_xD = i4_xc0 - i4_c_ref_xD; |
2611 | 7.08k | i4_c_yD = i4_yc0 - i4_c_ref_yD; |
2612 | | |
2613 | 7.08k | if(!i1_corner_samp_avlbl_flag) |
2614 | 6.79k | { |
2615 | 6.79k | isvcd_corner_samp_dyadic(i4_x0, i4_y0, i4_xD, i4_yD, pu1_refarray_luma, |
2616 | 6.79k | pu1_refarray_cb, pu1_refarray_cr); |
2617 | 6.79k | } |
2618 | | |
2619 | | /* Call the diagonal construction for the 2 rows */ |
2620 | 7.08k | if(i4_top == i4_left) |
2621 | 3.36k | { |
2622 | | /* if top * left = 1 (x0,y0) */ |
2623 | 3.36k | u1_filled_samp = isvcd_diagonal_construct_dyadic(i4_x0, i4_y0, i4_xD, i4_yD, |
2624 | 3.36k | pu1_refarray_luma, DYADIC_REF_W_Y); |
2625 | | |
2626 | 3.36k | pu1_tmp_dst = pu1_refarray_luma + ((i4_y0 + 1) * DYADIC_REF_W_Y); |
2627 | | |
2628 | | /* (x0+1,y0), ..., (x0+7,y0) and */ |
2629 | | /* (x0,y0+1), ..., (x0+6,y0+1) */ |
2630 | 26.8k | for(i4_x = i4_x0 + 1; i4_x < i4_x0 + 8; i4_x++) |
2631 | 23.5k | { |
2632 | 23.5k | i4_xD++; |
2633 | 23.5k | u1_filled_samp = isvcd_diagonal_construct_dyadic( |
2634 | 23.5k | i4_x, i4_y0, i4_xD, i4_yD, pu1_refarray_luma, DYADIC_REF_W_Y); |
2635 | 23.5k | pu1_tmp_dst[i4_x - 1] = u1_filled_samp; |
2636 | 23.5k | } |
2637 | | |
2638 | | /* (x0+7,y0+1) */ |
2639 | 3.36k | u1_filled_samp = isvcd_diagonal_construct_dyadic( |
2640 | 3.36k | i4_x0 + 7, i4_y0 + 1, i4_xD, i4_yD + 1, pu1_refarray_luma, DYADIC_REF_W_Y); |
2641 | 3.36k | } |
2642 | 3.72k | else |
2643 | 3.72k | { |
2644 | | /* top * left = -1 */ |
2645 | | /* (x0,y0+1) */ |
2646 | 3.72k | u1_filled_samp = isvcd_diagonal_construct_dyadic(i4_x0, i4_y0 + 1, i4_xD, i4_yD + 1, |
2647 | 3.72k | pu1_refarray_luma, DYADIC_REF_W_Y); |
2648 | | |
2649 | 3.72k | pu1_tmp_dst = pu1_refarray_luma + ((i4_y0 + 1) * DYADIC_REF_W_Y); |
2650 | | |
2651 | | /* (x0,y0), ..., (x0,y0+6) and */ |
2652 | | /* (x0+1,y0+1), ..., (x0+1,y0+7) */ |
2653 | 29.7k | for(i4_x = i4_x0; i4_x < i4_x0 + 7; i4_x++) |
2654 | 26.0k | { |
2655 | 26.0k | u1_filled_samp = isvcd_diagonal_construct_dyadic( |
2656 | 26.0k | i4_x, i4_y0, i4_xD, i4_yD, pu1_refarray_luma, DYADIC_REF_W_Y); |
2657 | | |
2658 | 26.0k | pu1_tmp_dst[i4_x + 1] = u1_filled_samp; |
2659 | 26.0k | i4_xD++; |
2660 | 26.0k | } |
2661 | | |
2662 | | /* (x0+7,y0) */ |
2663 | 3.72k | u1_filled_samp = isvcd_diagonal_construct_dyadic(i4_x0 + 7, i4_y0, i4_xD, i4_yD, |
2664 | 3.72k | pu1_refarray_luma, DYADIC_REF_W_Y); |
2665 | 3.72k | } |
2666 | | |
2667 | | /* For Cb and Cr */ |
2668 | 35.4k | for(i4_x = i4_xc0; i4_x < i4_xc0 + 4; i4_x++) |
2669 | 28.3k | { |
2670 | 28.3k | u1_filled_samp = isvcd_diagonal_construct_dyadic(i4_x, i4_yc0, i4_c_xD, i4_c_yD, |
2671 | 28.3k | pu1_refarray_cb, DYADIC_REF_W_C); |
2672 | 28.3k | u1_filled_samp = isvcd_diagonal_construct_dyadic(i4_x, i4_yc0, i4_c_xD, i4_c_yD, |
2673 | 28.3k | pu1_refarray_cr, DYADIC_REF_W_C); |
2674 | 28.3k | i4_c_xD++; |
2675 | 28.3k | } |
2676 | | |
2677 | 7.08k | } /* (mb_x,mb_y+top) is unavailable */ |
2678 | 8.67k | } /* if (mb_x+left,mb_y+top) not available */ |
2679 | 48.9k | else |
2680 | 48.9k | { |
2681 | 48.9k | UWORD8 *pu1_tmp_dst1, *pu1_tmp_dst2; |
2682 | 48.9k | UWORD8 *pu1_tmp_src1, *pu1_tmp_src2; |
2683 | | |
2684 | 48.9k | if(0x02 == (u1_ny_avlblty & 0x6)) |
2685 | 2.57k | { |
2686 | | /* (mb_x+left,mb_y) available, (mb_x,mb_y+top) unavailable */ |
2687 | 2.57k | i4_x0 = 9 + (i4_left << 3) + i4_left; |
2688 | 2.57k | i4_y0 = 9 + (i4_top << 3) + i4_top; |
2689 | 2.57k | i4_ref_yD = i4_y0 - i4_top - (i4_top >> 1); |
2690 | | |
2691 | | /* Copy (x0,ref_yD), (x0+1,ref_yD) to */ |
2692 | | /* (x0,y0), (x0+1,y0), and (x0,y0+1), (x0+1,y0+1) */ |
2693 | 2.57k | pu1_tmp_src1 = pu1_refarray_luma + (i4_ref_yD * DYADIC_REF_W_Y); |
2694 | 2.57k | pu1_tmp_dst1 = pu1_refarray_luma + (i4_y0 * DYADIC_REF_W_Y); |
2695 | 2.57k | pu1_tmp_dst2 = pu1_tmp_dst1 + DYADIC_REF_W_Y; |
2696 | 2.57k | pu1_tmp_dst1[i4_x0] = pu1_tmp_src1[i4_x0]; |
2697 | 2.57k | pu1_tmp_dst2[i4_x0] = pu1_tmp_src1[i4_x0]; |
2698 | 2.57k | pu1_tmp_dst1[i4_x0 + 1] = pu1_tmp_src1[i4_x0 + 1]; |
2699 | 2.57k | pu1_tmp_dst2[i4_x0 + 1] = pu1_tmp_src1[i4_x0 + 1]; |
2700 | | |
2701 | | /* Cb and Cr copy */ |
2702 | 2.57k | i4_xc0 = i4_x0 >> 1; |
2703 | 2.57k | i4_yc0 = i4_y0 >> 1; |
2704 | 2.57k | i4_c_ref_yD = i4_ref_yD >> 1; |
2705 | 2.57k | pu1_tmp_src1 = pu1_refarray_cb + (i4_c_ref_yD * DYADIC_REF_W_C); |
2706 | 2.57k | pu1_tmp_dst1 = pu1_refarray_cb + (i4_yc0 * DYADIC_REF_W_C); |
2707 | 2.57k | pu1_tmp_src2 = pu1_refarray_cr + (i4_c_ref_yD * DYADIC_REF_W_C); |
2708 | 2.57k | pu1_tmp_dst2 = pu1_refarray_cr + (i4_yc0 * DYADIC_REF_W_C); |
2709 | 2.57k | pu1_tmp_dst1[i4_xc0] = pu1_tmp_src1[i4_xc0]; |
2710 | 2.57k | pu1_tmp_dst2[i4_xc0] = pu1_tmp_src2[i4_xc0]; |
2711 | | |
2712 | 2.57k | } /* if (mb_x+left,mb_y) available, (mb_x,mb_y+top) unavailable */ |
2713 | 46.4k | else if(0x04 == (u1_ny_avlblty & 0x6)) |
2714 | 5.71k | { |
2715 | | /* (mb_x+left,mb_y) unavailable, (mb_x,mb_y+top) available */ |
2716 | 5.71k | i4_x0 = 9 + (i4_left << 3) + i4_left; |
2717 | 5.71k | i4_y0 = 9 + (i4_top << 3) + i4_top; |
2718 | 5.71k | i4_ref_xD = i4_x0 - i4_left - (i4_left >> 1); |
2719 | | |
2720 | | /* Copy (ref_xD,y0) to (x0,y0) and (x0+1,y0) */ |
2721 | | /* copy (ref_xD,y0+1) to (x0,y0+1) and (x0+1,y0+1) */ |
2722 | 5.71k | pu1_tmp_src1 = pu1_refarray_luma + (i4_y0 * DYADIC_REF_W_Y); |
2723 | 5.71k | pu1_tmp_dst1 = pu1_tmp_src1; |
2724 | 5.71k | pu1_tmp_src2 = pu1_tmp_src1 + DYADIC_REF_W_Y; |
2725 | 5.71k | pu1_tmp_dst2 = pu1_tmp_src2; |
2726 | | |
2727 | 5.71k | pu1_tmp_dst1[i4_x0] = pu1_tmp_src1[i4_ref_xD]; |
2728 | 5.71k | pu1_tmp_dst1[i4_x0 + 1] = pu1_tmp_src1[i4_ref_xD]; |
2729 | 5.71k | pu1_tmp_dst2[i4_x0] = pu1_tmp_src2[i4_ref_xD]; |
2730 | 5.71k | pu1_tmp_dst2[i4_x0 + 1] = pu1_tmp_src2[i4_ref_xD]; |
2731 | | |
2732 | | /* Copy Cb and Cr */ |
2733 | 5.71k | i4_xc0 = i4_x0 >> 1; |
2734 | 5.71k | i4_yc0 = i4_y0 >> 1; |
2735 | 5.71k | i4_c_ref_xD = i4_ref_xD >> 1; |
2736 | | |
2737 | 5.71k | pu1_tmp_src1 = pu1_refarray_cb + (i4_yc0 * DYADIC_REF_W_C); |
2738 | 5.71k | pu1_tmp_dst1 = pu1_tmp_src1; |
2739 | 5.71k | pu1_tmp_src2 = pu1_refarray_cr + (i4_yc0 * DYADIC_REF_W_C); |
2740 | 5.71k | pu1_tmp_dst2 = pu1_tmp_src2; |
2741 | | |
2742 | 5.71k | pu1_tmp_dst1[i4_xc0] = pu1_tmp_src1[i4_c_ref_xD]; |
2743 | 5.71k | pu1_tmp_dst2[i4_xc0] = pu1_tmp_src2[i4_c_ref_xD]; |
2744 | | |
2745 | 5.71k | } /* if (mb_x+left,mb_y) unavailable, (mb_x,mb_y+top) available */ |
2746 | 40.7k | else if(0x6 == (u1_ny_avlblty & 0x6)) |
2747 | 2.70k | { |
2748 | | /* (mb_x+left,mb_y) available, (mb_x,mb_y+top) available */ |
2749 | 2.70k | WORD32 i4_xD, i4_yD; |
2750 | 2.70k | WORD32 i4_c_xD, i4_c_yD; |
2751 | | |
2752 | 2.70k | i4_y0 = 9 + (i4_top << 3) + i4_top; |
2753 | 2.70k | i4_x0 = 9 + (i4_left << 3) + i4_left; |
2754 | 2.70k | i4_ref_xD = i4_x0 - i4_left - (i4_left >> 1); |
2755 | 2.70k | i4_ref_yD = i4_y0 - i4_top - (i4_top >> 1); |
2756 | 2.70k | i4_xD = i4_x0 - i4_ref_xD; |
2757 | 2.70k | i4_yD = i4_y0 - i4_ref_yD; |
2758 | 2.70k | i4_xc0 = i4_x0 >> 1; |
2759 | 2.70k | i4_yc0 = i4_y0 >> 1; |
2760 | 2.70k | i4_c_ref_xD = i4_ref_xD >> 1; |
2761 | 2.70k | i4_c_ref_yD = i4_ref_yD >> 1; |
2762 | 2.70k | i4_c_xD = i4_xc0 - i4_c_ref_xD; |
2763 | 2.70k | i4_c_yD = i4_yc0 - i4_c_ref_yD; |
2764 | | |
2765 | | /* Call diagonal construction for luma */ |
2766 | 8.12k | for(i4_y = i4_y0; i4_y < i4_y0 + 2; i4_y++) |
2767 | 5.41k | { |
2768 | 16.2k | for(i4_x = i4_x0; i4_x < i4_x0 + 2; i4_x++) |
2769 | 10.8k | { |
2770 | 10.8k | isvcd_diagonal_construct_dyadic(i4_x, i4_y, i4_xD, i4_yD, pu1_refarray_luma, |
2771 | 10.8k | DYADIC_REF_W_Y); |
2772 | 10.8k | i4_xD++; |
2773 | 10.8k | } |
2774 | 5.41k | i4_yD++; |
2775 | 5.41k | i4_xD -= 2; |
2776 | 5.41k | } |
2777 | | |
2778 | | /* Call diagonal construction for chroma */ |
2779 | 2.70k | isvcd_diagonal_construct_dyadic(i4_xc0, i4_yc0, i4_c_xD, i4_c_yD, pu1_refarray_cb, |
2780 | 2.70k | DYADIC_REF_W_C); |
2781 | | |
2782 | 2.70k | isvcd_diagonal_construct_dyadic(i4_xc0, i4_yc0, i4_c_xD, i4_c_yD, pu1_refarray_cr, |
2783 | 2.70k | DYADIC_REF_W_C); |
2784 | | |
2785 | 2.70k | } /* if (mb_x+left,mb_y) available, (mb_x,mb_y+top) available */ |
2786 | 48.9k | } /* (mb_x+left,mb_y+top) available */ |
2787 | | |
2788 | 57.6k | return OK; |
2789 | 58.0k | } |
2790 | | /*****************************************************************************/ |
2791 | | /* */ |
2792 | | /* Function Name : isvcd_interpolate_base_luma_dyadic */ |
2793 | | /* */ |
2794 | | /* Description : This function takes the reference array buffer & performs*/ |
2795 | | /* intra resampling for dyadic scaling ratios */ |
2796 | | /* Inputs : pu1_inp_buf : ptr to the 12x12 reference sample buffer */ |
2797 | | /* pi2_tmp_filt_buf : ptr to the 12x16 buffer to hold the */ |
2798 | | /* vertically interpolated data */ |
2799 | | /* pu1_out_buf : output buffer pointer */ |
2800 | | /* i4_out_stride : output buffer stride */ |
2801 | | /* Globals : none */ |
2802 | | /* Processing : it does the interpolation in vertical direction followed */ |
2803 | | /* by horizontal direction */ |
2804 | | /* Outputs : resampled pixels */ |
2805 | | /* Returns : none */ |
2806 | | /* */ |
2807 | | /* Issues : none */ |
2808 | | /* */ |
2809 | | /* Revision History: */ |
2810 | | /* */ |
2811 | | /* DD MM YYYY Author(s) Changes (Describe the changes made) */ |
2812 | | /* 06 09 2021 Vijay creation */ |
2813 | | /* */ |
2814 | | /*****************************************************************************/ |
2815 | | void isvcd_interpolate_base_luma_dyadic(UWORD8 *pu1_inp_buf, WORD16 *pi2_tmp_filt_buf, |
2816 | | UWORD8 *pu1_out_buf, WORD32 i4_out_stride) |
2817 | 26.2k | { |
2818 | 26.2k | WORD32 i4_x, i4_y; |
2819 | 26.2k | WORD32 i4_coeff_0, i4_coeff_1, i4_coeff_2, i4_coeff_3; |
2820 | 26.2k | WORD32 i4_samp_0, i4_samp_1, i4_samp_2, i4_samp_3; |
2821 | 26.2k | WORD32 i4_rslt_1, i4_rslt_2; |
2822 | 26.2k | WORD32 i4_filt_stride, i4_src_stride; |
2823 | 26.2k | UWORD8 *pu1_inp, *pu1_out; |
2824 | 26.2k | WORD16 *pi2_tmp; |
2825 | | |
2826 | | /* Filter coefficient values for phase 4 */ |
2827 | 26.2k | i4_coeff_0 = -3; |
2828 | 26.2k | i4_coeff_1 = 28; |
2829 | 26.2k | i4_coeff_2 = 8; |
2830 | 26.2k | i4_coeff_3 = -1; |
2831 | 26.2k | i4_filt_stride = 12; |
2832 | 26.2k | i4_src_stride = DYADIC_REF_W_Y; |
2833 | 26.2k | pu1_inp = pu1_inp_buf; |
2834 | 26.2k | pi2_tmp = pi2_tmp_filt_buf; |
2835 | 26.2k | pu1_out = pu1_out_buf; |
2836 | | |
2837 | | /* Vertical interpolation */ |
2838 | 340k | for(i4_x = 0; i4_x < 12; i4_x++) |
2839 | 314k | { |
2840 | | /* y = 0, y_phase = 12 */ |
2841 | 314k | i4_samp_0 = pu1_inp[i4_x]; |
2842 | 314k | pu1_inp += i4_src_stride; |
2843 | 314k | i4_samp_1 = pu1_inp[i4_x]; |
2844 | 314k | pu1_inp += i4_src_stride; |
2845 | 314k | i4_samp_2 = pu1_inp[i4_x]; |
2846 | 314k | pu1_inp += i4_src_stride; |
2847 | 314k | i4_samp_3 = pu1_inp[i4_x]; |
2848 | 314k | pu1_inp += i4_src_stride; |
2849 | | |
2850 | | /* since y_phase 12 for y = 0 */ |
2851 | 314k | i4_rslt_1 = i4_samp_0 * i4_coeff_3; |
2852 | 314k | i4_rslt_1 += i4_samp_1 * i4_coeff_2; |
2853 | 314k | i4_rslt_1 += i4_samp_2 * i4_coeff_1; |
2854 | 314k | i4_rslt_1 += i4_samp_3 * i4_coeff_0; |
2855 | | |
2856 | | /* Store the output */ |
2857 | 314k | pi2_tmp[i4_x] = i4_rslt_1; |
2858 | | /* Increment the output ptr */ |
2859 | 314k | pi2_tmp += i4_filt_stride; |
2860 | | |
2861 | 2.51M | for(i4_y = 1; i4_y < 15; i4_y += 2) |
2862 | 2.20M | { |
2863 | 2.20M | i4_samp_0 = i4_samp_1; |
2864 | 2.20M | i4_samp_1 = i4_samp_2; |
2865 | 2.20M | i4_samp_2 = i4_samp_3; |
2866 | 2.20M | i4_samp_3 = pu1_inp[i4_x]; |
2867 | | |
2868 | | /* y_phase is 4 for odd values of y */ |
2869 | | /* and 12 for even values of y */ |
2870 | 2.20M | i4_rslt_1 = i4_samp_0 * i4_coeff_0; |
2871 | 2.20M | i4_rslt_1 += i4_samp_1 * i4_coeff_1; |
2872 | 2.20M | i4_rslt_1 += i4_samp_2 * i4_coeff_2; |
2873 | 2.20M | i4_rslt_1 += i4_samp_3 * i4_coeff_3; |
2874 | 2.20M | i4_rslt_2 = i4_samp_0 * i4_coeff_3; |
2875 | 2.20M | i4_rslt_2 += i4_samp_1 * i4_coeff_2; |
2876 | 2.20M | i4_rslt_2 += i4_samp_2 * i4_coeff_1; |
2877 | 2.20M | i4_rslt_2 += i4_samp_3 * i4_coeff_0; |
2878 | | |
2879 | | /* Storing the results */ |
2880 | 2.20M | pi2_tmp[i4_x] = i4_rslt_1; |
2881 | 2.20M | pi2_tmp += i4_filt_stride; |
2882 | 2.20M | pi2_tmp[i4_x] = i4_rslt_2; |
2883 | | |
2884 | | /* Incrementing the pointers */ |
2885 | 2.20M | pi2_tmp += i4_filt_stride; |
2886 | 2.20M | pu1_inp += i4_src_stride; |
2887 | | |
2888 | 2.20M | } /* End of loop over y */ |
2889 | | |
2890 | | /* y = 15, y_phase = 4 */ |
2891 | 314k | i4_samp_0 = i4_samp_1; |
2892 | 314k | i4_samp_1 = i4_samp_2; |
2893 | 314k | i4_samp_2 = i4_samp_3; |
2894 | 314k | i4_samp_3 = pu1_inp[i4_x]; |
2895 | | |
2896 | 314k | i4_rslt_1 = i4_samp_0 * i4_coeff_0; |
2897 | 314k | i4_rslt_1 += i4_samp_1 * i4_coeff_1; |
2898 | 314k | i4_rslt_1 += i4_samp_2 * i4_coeff_2; |
2899 | 314k | i4_rslt_1 += i4_samp_3 * i4_coeff_3; |
2900 | | |
2901 | | /* Store the output */ |
2902 | 314k | pi2_tmp[i4_x] = i4_rslt_1; |
2903 | | |
2904 | | /* Reinitializing the ptrs */ |
2905 | 314k | pu1_inp = pu1_inp_buf; |
2906 | 314k | pi2_tmp = pi2_tmp_filt_buf; |
2907 | 314k | } |
2908 | | |
2909 | | /* Horizontal interpolation */ |
2910 | 445k | for(i4_y = 0; i4_y < 16; i4_y++) |
2911 | 419k | { |
2912 | | /* x = 0, x_phase = 12 */ |
2913 | 419k | i4_samp_0 = *pi2_tmp++; |
2914 | 419k | i4_samp_1 = *pi2_tmp++; |
2915 | 419k | i4_samp_2 = *pi2_tmp++; |
2916 | 419k | i4_samp_3 = *pi2_tmp++; |
2917 | | |
2918 | | /* since x_phase 12 for x = 0 */ |
2919 | 419k | i4_rslt_1 = i4_samp_0 * i4_coeff_3; |
2920 | 419k | i4_rslt_1 += i4_samp_1 * i4_coeff_2; |
2921 | 419k | i4_rslt_1 += i4_samp_2 * i4_coeff_1; |
2922 | 419k | i4_rslt_1 += i4_samp_3 * i4_coeff_0; |
2923 | 419k | i4_rslt_1 += 512; |
2924 | | |
2925 | 419k | i4_rslt_1 >>= 10; |
2926 | | |
2927 | | /* Store the output */ |
2928 | 419k | pu1_out[0] = CLIPUCHAR(i4_rslt_1); |
2929 | | |
2930 | 3.35M | for(i4_x = 1; i4_x < 15; i4_x += 2) |
2931 | 2.93M | { |
2932 | 2.93M | i4_samp_0 = i4_samp_1; |
2933 | 2.93M | i4_samp_1 = i4_samp_2; |
2934 | 2.93M | i4_samp_2 = i4_samp_3; |
2935 | 2.93M | i4_samp_3 = *pi2_tmp++; |
2936 | | |
2937 | | /* x_phase is 4 for odd values of x */ |
2938 | | /* and 12 for even values of x */ |
2939 | 2.93M | i4_rslt_1 = i4_samp_0 * i4_coeff_0; |
2940 | 2.93M | i4_rslt_1 += i4_samp_1 * i4_coeff_1; |
2941 | 2.93M | i4_rslt_1 += i4_samp_2 * i4_coeff_2; |
2942 | 2.93M | i4_rslt_1 += i4_samp_3 * i4_coeff_3; |
2943 | 2.93M | i4_rslt_1 += 512; |
2944 | | |
2945 | 2.93M | i4_rslt_2 = i4_samp_0 * i4_coeff_3; |
2946 | 2.93M | i4_rslt_2 += i4_samp_1 * i4_coeff_2; |
2947 | 2.93M | i4_rslt_2 += i4_samp_2 * i4_coeff_1; |
2948 | 2.93M | i4_rslt_2 += i4_samp_3 * i4_coeff_0; |
2949 | 2.93M | i4_rslt_2 += 512; |
2950 | | |
2951 | 2.93M | i4_rslt_1 >>= 10; |
2952 | 2.93M | i4_rslt_2 >>= 10; |
2953 | | |
2954 | | /* Store the output */ |
2955 | 2.93M | pu1_out[i4_x] = CLIPUCHAR(i4_rslt_1); |
2956 | 2.93M | pu1_out[i4_x + 1] = CLIPUCHAR(i4_rslt_2); |
2957 | 2.93M | } |
2958 | | |
2959 | | /* x = 15 */ |
2960 | 419k | i4_samp_0 = i4_samp_1; |
2961 | 419k | i4_samp_1 = i4_samp_2; |
2962 | 419k | i4_samp_2 = i4_samp_3; |
2963 | 419k | i4_samp_3 = *pi2_tmp++; |
2964 | | |
2965 | 419k | i4_rslt_1 = i4_samp_0 * i4_coeff_0; |
2966 | 419k | i4_rslt_1 += i4_samp_1 * i4_coeff_1; |
2967 | 419k | i4_rslt_1 += i4_samp_2 * i4_coeff_2; |
2968 | 419k | i4_rslt_1 += i4_samp_3 * i4_coeff_3; |
2969 | 419k | i4_rslt_1 += 512; |
2970 | | |
2971 | 419k | i4_rslt_1 >>= 10; |
2972 | | |
2973 | | /* Store the output */ |
2974 | 419k | pu1_out[i4_x] = CLIPUCHAR(i4_rslt_1); |
2975 | | |
2976 | | /* Increment the output ptr */ |
2977 | 419k | pu1_out += i4_out_stride; |
2978 | | |
2979 | 419k | } /* End of loop over y */ |
2980 | 26.2k | } /* isvcd_interpolate_base_luma_dyadic */ |
2981 | | |
2982 | | /*****************************************************************************/ |
2983 | | /* */ |
2984 | | /* Function Name : isvcd_vert_interpol_chroma_dyadic_1 */ |
2985 | | /* */ |
2986 | | /* Description : This function takes the reference array buffer & performs*/ |
2987 | | /* vertical intra resampling for dyadic scaling ratios for */ |
2988 | | /* chroma for the following ref_lyr_chroma_phase_y_plus1 */ |
2989 | | /* chroma_phase_y_plus1: */ |
2990 | | /* ref_lyr cur_lyr */ |
2991 | | /* 0 0 */ |
2992 | | /* 1 0 */ |
2993 | | /* 1 1 */ |
2994 | | /* 1 2 */ |
2995 | | /* 2 1 */ |
2996 | | /* 2 2 */ |
2997 | | /* Inputs : pu1_inp_buf : ptr to the 6x6 reference sample buffer */ |
2998 | | /* pi2_tmp_filt_buf : ptr to the 6x8 buffer to hold the */ |
2999 | | /* vertically interpolated data */ |
3000 | | /* i4_phase_0 : y phase for even values of y */ |
3001 | | /* i4_phase_1 : y phase for odd values of y */ |
3002 | | /* Globals : none */ |
3003 | | /* Processing : it does the interpolation in vertical direction */ |
3004 | | /* Outputs : vertically resampled samples */ |
3005 | | /* Returns : none */ |
3006 | | /* */ |
3007 | | /* Issues : none */ |
3008 | | /* */ |
3009 | | /* Revision History: */ |
3010 | | /* */ |
3011 | | /* DD MM YYYY Author(s) Changes (Describe the changes made) */ |
3012 | | /* 06 09 2021 Vijay creation */ |
3013 | | /* */ |
3014 | | /*****************************************************************************/ |
3015 | | void isvcd_vert_interpol_chroma_dyadic_1(UWORD8 *pu1_inp_buf, WORD16 *pi2_tmp_filt_buf, |
3016 | | WORD32 i4_phase_0, WORD32 i4_phase_1) |
3017 | 46.9k | { |
3018 | 46.9k | WORD32 i4_x, i4_y; |
3019 | 46.9k | WORD32 i4_coeff_0, i4_coeff_1, i4_coeff_2, i4_coeff_3; |
3020 | 46.9k | WORD32 i4_samp_0, i4_samp_1; |
3021 | 46.9k | WORD32 i4_rslt_1, i4_rslt_2; |
3022 | 46.9k | WORD32 i4_filt_stride, i4_src_stride; |
3023 | 46.9k | UWORD8 *pu1_inp; |
3024 | 46.9k | WORD16 *pi2_tmp; |
3025 | | |
3026 | 46.9k | i4_coeff_0 = 8 - i4_phase_0; |
3027 | 46.9k | i4_coeff_1 = i4_phase_0; |
3028 | 46.9k | i4_coeff_2 = 8 - i4_phase_1; |
3029 | 46.9k | i4_coeff_3 = i4_phase_1; |
3030 | | |
3031 | 46.9k | pu1_inp = pu1_inp_buf; |
3032 | 46.9k | pi2_tmp = pi2_tmp_filt_buf; |
3033 | 46.9k | i4_filt_stride = 6; |
3034 | 46.9k | i4_src_stride = DYADIC_REF_W_C; |
3035 | | |
3036 | | /* Vertical interpolation */ |
3037 | 328k | for(i4_x = 0; i4_x < 6; i4_x++) |
3038 | 281k | { |
3039 | | /* y = 0, y_phase = phase_0 */ |
3040 | 281k | i4_samp_0 = pu1_inp[i4_x]; |
3041 | 281k | pu1_inp += i4_src_stride; |
3042 | 281k | i4_samp_1 = pu1_inp[i4_x]; |
3043 | 281k | pu1_inp += i4_src_stride; |
3044 | | |
3045 | | /* since y_phase = phase_0 for y = 0 */ |
3046 | 281k | i4_rslt_1 = i4_samp_0 * i4_coeff_0; |
3047 | 281k | i4_rslt_1 += i4_samp_1 * i4_coeff_1; |
3048 | | |
3049 | | /* Store the output */ |
3050 | 281k | pi2_tmp[i4_x] = i4_rslt_1; |
3051 | | |
3052 | | /* Increment the output ptr */ |
3053 | 281k | pi2_tmp += i4_filt_stride; |
3054 | | |
3055 | 1.12M | for(i4_y = 1; i4_y < 7; i4_y += 2) |
3056 | 844k | { |
3057 | 844k | i4_samp_0 = i4_samp_1; |
3058 | 844k | i4_samp_1 = pu1_inp[i4_x]; |
3059 | | |
3060 | | /* y_phase is phase_1 for odd values of y */ |
3061 | | /* and phase_0 for even values of y */ |
3062 | 844k | i4_rslt_1 = i4_samp_0 * i4_coeff_2; |
3063 | 844k | i4_rslt_1 += i4_samp_1 * i4_coeff_3; |
3064 | 844k | i4_rslt_2 = i4_samp_0 * i4_coeff_0; |
3065 | 844k | i4_rslt_2 += i4_samp_1 * i4_coeff_1; |
3066 | | |
3067 | | /* Storing the results */ |
3068 | 844k | pi2_tmp[i4_x] = i4_rslt_1; |
3069 | 844k | pi2_tmp += i4_filt_stride; |
3070 | 844k | pi2_tmp[i4_x] = i4_rslt_2; |
3071 | | |
3072 | | /* Incrementing the pointers */ |
3073 | 844k | pi2_tmp += i4_filt_stride; |
3074 | 844k | pu1_inp += i4_src_stride; |
3075 | | |
3076 | 844k | } /* End of loop over y */ |
3077 | | |
3078 | | /* y = 7, y_phase = phase_1 */ |
3079 | 281k | i4_samp_0 = i4_samp_1; |
3080 | 281k | i4_samp_1 = pu1_inp[i4_x]; |
3081 | | |
3082 | 281k | i4_rslt_1 = i4_samp_0 * i4_coeff_2; |
3083 | 281k | i4_rslt_1 += i4_samp_1 * i4_coeff_3; |
3084 | | |
3085 | | /* Store the output */ |
3086 | 281k | pi2_tmp[i4_x] = i4_rslt_1; |
3087 | | |
3088 | | /* Reinitializing the ptrs */ |
3089 | 281k | pu1_inp = pu1_inp_buf; |
3090 | 281k | pi2_tmp = pi2_tmp_filt_buf; |
3091 | | |
3092 | 281k | } /* End of loop over x */ |
3093 | 46.9k | } /* isvcd_vert_interpol_chroma_dyadic_1 */ |
3094 | | |
3095 | | /*****************************************************************************/ |
3096 | | /* */ |
3097 | | /* Function Name : isvcd_vert_interpol_chroma_dyadic_2 */ |
3098 | | /* */ |
3099 | | /* Description : This function takes the reference array buffer & performs*/ |
3100 | | /* vertical intra resampling for dyadic scaling ratios for */ |
3101 | | /* chroma for the following ref_lyr_chroma_phase_y_plus1 */ |
3102 | | /* chroma_phase_y_plus1: */ |
3103 | | /* ref_lyr cur_lyr */ |
3104 | | /* 0 1 */ |
3105 | | /* 0 2 */ |
3106 | | /* Inputs : pu1_inp_buf : ptr to the 6x6 reference sample buffer */ |
3107 | | /* pi2_tmp_filt_buf : ptr to the 6x8 buffer to hold the */ |
3108 | | /* vertically interpolated data */ |
3109 | | /* i4_phase_0 : y phase for even values of y */ |
3110 | | /* i4_phase_1 : y phase for odd values of y */ |
3111 | | /* Globals : none */ |
3112 | | /* Processing : it does the interpolation in vertical direction */ |
3113 | | /* Outputs : vertically resampled samples */ |
3114 | | /* Returns : none */ |
3115 | | /* */ |
3116 | | /* Issues : none */ |
3117 | | /* */ |
3118 | | /* Revision History: */ |
3119 | | /* */ |
3120 | | /* DD MM YYYY Author(s) Changes (Describe the changes made) */ |
3121 | | /* 06 09 2021 Vijay creation */ |
3122 | | /* */ |
3123 | | /*****************************************************************************/ |
3124 | | void isvcd_vert_interpol_chroma_dyadic_2(UWORD8 *pu1_inp_buf, WORD16 *pi2_tmp_filt_buf, |
3125 | | WORD32 i4_phase_0, WORD32 i4_phase_1) |
3126 | 4.38k | { |
3127 | 4.38k | WORD32 i4_x, i4_y; |
3128 | 4.38k | WORD32 i4_coeff_0, i4_coeff_1, i4_coeff_2, i4_coeff_3; |
3129 | 4.38k | WORD32 i4_samp_0, i4_samp_1; |
3130 | 4.38k | WORD32 i4_rslt_1, i4_rslt_2; |
3131 | 4.38k | WORD32 i4_filt_stride, i4_src_stride; |
3132 | 4.38k | UWORD8 *pu1_inp; |
3133 | 4.38k | WORD16 *pi2_tmp; |
3134 | | |
3135 | 4.38k | i4_coeff_0 = 8 - i4_phase_0; |
3136 | 4.38k | i4_coeff_1 = i4_phase_0; |
3137 | 4.38k | i4_coeff_2 = 8 - i4_phase_1; |
3138 | 4.38k | i4_coeff_3 = i4_phase_1; |
3139 | | |
3140 | 4.38k | pi2_tmp = pi2_tmp_filt_buf; |
3141 | 4.38k | i4_filt_stride = 6; |
3142 | 4.38k | i4_src_stride = DYADIC_REF_W_C; |
3143 | 4.38k | pu1_inp = pu1_inp_buf + i4_src_stride; |
3144 | | |
3145 | | /* Vertical interpolation */ |
3146 | 30.7k | for(i4_x = 0; i4_x < 6; i4_x++) |
3147 | 26.3k | { |
3148 | 26.3k | i4_samp_1 = pu1_inp[i4_x]; |
3149 | 26.3k | pu1_inp += i4_src_stride; |
3150 | | |
3151 | 131k | for(i4_y = 0; i4_y < 8; i4_y += 2) |
3152 | 105k | { |
3153 | 105k | i4_samp_0 = i4_samp_1; |
3154 | 105k | i4_samp_1 = pu1_inp[i4_x]; |
3155 | | |
3156 | | /* y_phase is phase_1 for odd values of y and phase_0 for even values of y */ |
3157 | 105k | i4_rslt_1 = i4_samp_0 * i4_coeff_0; |
3158 | 105k | i4_rslt_1 += i4_samp_1 * i4_coeff_1; |
3159 | | |
3160 | 105k | i4_rslt_2 = i4_samp_0 * i4_coeff_2; |
3161 | 105k | i4_rslt_2 += i4_samp_1 * i4_coeff_3; |
3162 | | |
3163 | | /* Storing the results */ |
3164 | 105k | pi2_tmp[i4_x] = i4_rslt_1; |
3165 | 105k | pi2_tmp += i4_filt_stride; |
3166 | 105k | pi2_tmp[i4_x] = i4_rslt_2; |
3167 | | |
3168 | | /* Incrementing the pointers */ |
3169 | 105k | pi2_tmp += i4_filt_stride; |
3170 | 105k | pu1_inp += i4_src_stride; |
3171 | | |
3172 | 105k | } /* End of loop over y */ |
3173 | | |
3174 | | /* Reinitializing the ptrs */ |
3175 | 26.3k | pu1_inp = pu1_inp_buf + i4_src_stride; |
3176 | 26.3k | pi2_tmp = pi2_tmp_filt_buf; |
3177 | | |
3178 | 26.3k | } /* End of loop over x */ |
3179 | 4.38k | } /* isvcd_vert_interpol_chroma_dyadic_2 */ |
3180 | | |
3181 | | /*****************************************************************************/ |
3182 | | /* */ |
3183 | | /* Function Name : isvcd_vert_interpol_chroma_dyadic_3 */ |
3184 | | /* */ |
3185 | | /* Description : This function takes the reference array buffer & performs*/ |
3186 | | /* vertical intra resampling for dyadic scaling ratios for */ |
3187 | | /* chroma for the following ref_lyr_chroma_phase_y_plus1 */ |
3188 | | /* chroma_phase_y_plus1: */ |
3189 | | /* ref_lyr cur_lyr */ |
3190 | | /* 2 0 */ |
3191 | | /* Inputs : pu1_inp_buf : ptr to the 6x6 reference sample buffer */ |
3192 | | /* pi2_tmp_filt_buf : ptr to the 6x8 buffer to hold the */ |
3193 | | /* vertically interpolated data */ |
3194 | | /* i4_phase_0 : y phase for even values of y */ |
3195 | | /* i4_phase_1 : y phase for odd values of y */ |
3196 | | /* Globals : none */ |
3197 | | /* Processing : it does the interpolation in vertical direction */ |
3198 | | /* Outputs : vertically resampled samples */ |
3199 | | /* Returns : none */ |
3200 | | /* */ |
3201 | | /* Issues : none */ |
3202 | | /* */ |
3203 | | /* Revision History: */ |
3204 | | /* */ |
3205 | | /* DD MM YYYY Author(s) Changes (Describe the changes made) */ |
3206 | | /* 06 09 2021 Vijay creation */ |
3207 | | /* */ |
3208 | | /*****************************************************************************/ |
3209 | | void isvcd_vert_interpol_chroma_dyadic_3(UWORD8 *pu1_inp_buf, WORD16 *pi2_tmp_filt_buf, |
3210 | | WORD32 i4_phase_0, WORD32 i4_phase_1) |
3211 | 1.11k | { |
3212 | 1.11k | WORD32 i4_x, i4_y; |
3213 | 1.11k | WORD32 i4_coeff_0, i4_coeff_1, i4_coeff_2, i4_coeff_3; |
3214 | 1.11k | WORD32 i4_samp_0, i4_samp_1; |
3215 | 1.11k | WORD32 i4_rslt_1, i4_rslt_2; |
3216 | 1.11k | WORD32 i4_filt_stride, i4_src_stride; |
3217 | 1.11k | UWORD8 *pu1_inp; |
3218 | 1.11k | WORD16 *pi2_tmp; |
3219 | | |
3220 | 1.11k | i4_coeff_0 = 8 - i4_phase_0; |
3221 | 1.11k | i4_coeff_1 = i4_phase_0; |
3222 | 1.11k | i4_coeff_2 = 8 - i4_phase_1; |
3223 | 1.11k | i4_coeff_3 = i4_phase_1; |
3224 | | |
3225 | 1.11k | pi2_tmp = pi2_tmp_filt_buf; |
3226 | 1.11k | i4_filt_stride = 6; |
3227 | 1.11k | i4_src_stride = DYADIC_REF_W_C; |
3228 | 1.11k | pu1_inp = pu1_inp_buf; |
3229 | | |
3230 | | /* Vertical interpolation */ |
3231 | 7.81k | for(i4_x = 0; i4_x < 6; i4_x++) |
3232 | 6.69k | { |
3233 | 6.69k | i4_samp_1 = pu1_inp[i4_x]; |
3234 | 6.69k | pu1_inp += i4_src_stride; |
3235 | | |
3236 | 33.4k | for(i4_y = 0; i4_y < 8; i4_y += 2) |
3237 | 26.7k | { |
3238 | 26.7k | i4_samp_0 = i4_samp_1; |
3239 | 26.7k | i4_samp_1 = pu1_inp[i4_x]; |
3240 | | |
3241 | | /* y_phase is phase_1 for odd values of y */ |
3242 | | /* and phase_0 for even values of y */ |
3243 | 26.7k | i4_rslt_1 = i4_samp_0 * i4_coeff_0; |
3244 | 26.7k | i4_rslt_1 += i4_samp_1 * i4_coeff_1; |
3245 | | |
3246 | 26.7k | i4_rslt_2 = i4_samp_0 * i4_coeff_2; |
3247 | 26.7k | i4_rslt_2 += i4_samp_1 * i4_coeff_3; |
3248 | | |
3249 | | /* Storing the results */ |
3250 | 26.7k | pi2_tmp[i4_x] = i4_rslt_1; |
3251 | 26.7k | pi2_tmp += i4_filt_stride; |
3252 | 26.7k | pi2_tmp[i4_x] = i4_rslt_2; |
3253 | | |
3254 | | /* Incrementing the pointers */ |
3255 | 26.7k | pi2_tmp += i4_filt_stride; |
3256 | 26.7k | pu1_inp += i4_src_stride; |
3257 | | |
3258 | 26.7k | } /* End of loop over y */ |
3259 | | |
3260 | | /* Reinitializing the ptrs */ |
3261 | 6.69k | pu1_inp = pu1_inp_buf; |
3262 | 6.69k | pi2_tmp = pi2_tmp_filt_buf; |
3263 | | |
3264 | 6.69k | } /* End of loop over x */ |
3265 | 1.11k | } /* isvcd_vert_interpol_chroma_dyadic_3 */ |
3266 | | |
3267 | | /*****************************************************************************/ |
3268 | | /* */ |
3269 | | /* Function Name : isvcd_horz_interpol_chroma_dyadic_1 */ |
3270 | | /* */ |
3271 | | /* Description : This function takes the reference array buffer & performs*/ |
3272 | | /* horizontal intra resampling for dyadic scaling ratios for*/ |
3273 | | /* chroma with following ref_lyr_chroma_phase_x_plus1_flag*/ |
3274 | | /* and chroma_phase_x_plus1_flag: */ |
3275 | | /* ref_lyr cur_lyr */ |
3276 | | /* 0 0 */ |
3277 | | /* 1 0 */ |
3278 | | /* 1 1 */ |
3279 | | /* Inputs : pi2_tmp_filt_buf : ptr to the 6x8 buffer containing the */ |
3280 | | /* vertically interpolated data */ |
3281 | | /* pu1_out_buf : pointer to the output buffer */ |
3282 | | /* i4_out_stride : output buffer stride */ |
3283 | | /* i4_phase_0 : x phase for even values of x */ |
3284 | | /* i4_phase_1 : x phase for odd values of x */ |
3285 | | /* Globals : none */ |
3286 | | /* Processing : it does the interpolation in vertical direction */ |
3287 | | /* Outputs : resampled samples */ |
3288 | | /* Returns : none */ |
3289 | | /* */ |
3290 | | /* Issues : none */ |
3291 | | /* */ |
3292 | | /* Revision History: */ |
3293 | | /* */ |
3294 | | /* DD MM YYYY Author(s) Changes (Describe the changes made) */ |
3295 | | /* 06 09 2021 Vijay creation */ |
3296 | | /* */ |
3297 | | /*****************************************************************************/ |
3298 | | void isvcd_horz_interpol_chroma_dyadic_1(WORD16 *pi2_tmp_filt_buf, UWORD8 *pu1_out_buf, |
3299 | | WORD32 i4_out_stride, WORD32 i4_phase_0, WORD32 i4_phase_1) |
3300 | 38.8k | { |
3301 | 38.8k | WORD32 i4_x, i4_y; |
3302 | 38.8k | WORD32 i4_coeff_0, i4_coeff_1, i4_coeff_2, i4_coeff_3; |
3303 | 38.8k | WORD32 i4_samp_0, i4_samp_1; |
3304 | 38.8k | WORD32 i4_rslt_1, i4_rslt_2; |
3305 | 38.8k | WORD32 i4_dst_stride; |
3306 | 38.8k | UWORD8 *pu1_out; |
3307 | 38.8k | WORD16 *pi2_tmp; |
3308 | | |
3309 | 38.8k | i4_coeff_0 = 8 - i4_phase_0; |
3310 | 38.8k | i4_coeff_1 = i4_phase_0; |
3311 | 38.8k | i4_coeff_2 = 8 - i4_phase_1; |
3312 | 38.8k | i4_coeff_3 = i4_phase_1; |
3313 | | |
3314 | 38.8k | pu1_out = pu1_out_buf; |
3315 | 38.8k | pi2_tmp = pi2_tmp_filt_buf; |
3316 | 38.8k | i4_dst_stride = i4_out_stride; |
3317 | | |
3318 | | /* Horizontal interpolation */ |
3319 | 349k | for(i4_y = 0; i4_y < 8; i4_y++) |
3320 | 311k | { |
3321 | | /* x = 0, x_phase = phase_0 */ |
3322 | 311k | i4_samp_0 = *pi2_tmp++; |
3323 | 311k | i4_samp_1 = *pi2_tmp++; |
3324 | | |
3325 | | /* since x_phase = phase_0 for x = 0 */ |
3326 | 311k | i4_rslt_1 = i4_samp_0 * i4_coeff_0; |
3327 | 311k | i4_rslt_1 += i4_samp_1 * i4_coeff_1; |
3328 | | |
3329 | | /* Round to 8-bit value */ |
3330 | 311k | i4_rslt_1 += 32; |
3331 | 311k | i4_rslt_1 >>= 6; |
3332 | | |
3333 | | /* Store the output */ |
3334 | 311k | pu1_out[0] = i4_rslt_1; |
3335 | | |
3336 | 1.24M | for(i4_x = 1; i4_x < 7; i4_x += 2) |
3337 | 933k | { |
3338 | 933k | i4_samp_0 = i4_samp_1; |
3339 | 933k | i4_samp_1 = *pi2_tmp++; |
3340 | | |
3341 | | /* x_phase is phase_1 for odd values of x and phase_0 for even values of x */ |
3342 | 933k | i4_rslt_1 = i4_samp_0 * i4_coeff_2; |
3343 | 933k | i4_rslt_1 += i4_samp_1 * i4_coeff_3; |
3344 | 933k | i4_rslt_2 = i4_samp_0 * i4_coeff_0; |
3345 | 933k | i4_rslt_2 += i4_samp_1 * i4_coeff_1; |
3346 | | |
3347 | | /* Rounding to 8-bit values */ |
3348 | 933k | i4_rslt_1 += 32; |
3349 | 933k | i4_rslt_1 >>= 6; |
3350 | 933k | i4_rslt_2 += 32; |
3351 | 933k | i4_rslt_2 >>= 6; |
3352 | | |
3353 | | /* Storing the results */ |
3354 | 933k | pu1_out[2 * i4_x] = i4_rslt_1; |
3355 | 933k | pu1_out[2 * (i4_x + 1)] = i4_rslt_2; |
3356 | | |
3357 | 933k | } /* End of loop over y */ |
3358 | | |
3359 | | /* y = 7, y_phase = phase_1 */ |
3360 | 311k | i4_samp_0 = i4_samp_1; |
3361 | 311k | i4_samp_1 = *pi2_tmp++; |
3362 | | |
3363 | | /* since x_phase = phase_1 for x = 7 */ |
3364 | 311k | i4_rslt_1 = i4_samp_0 * i4_coeff_2; |
3365 | 311k | i4_rslt_1 += i4_samp_1 * i4_coeff_3; |
3366 | | |
3367 | | /* Round to 8-bit value */ |
3368 | 311k | i4_rslt_1 += 32; |
3369 | 311k | i4_rslt_1 >>= 6; |
3370 | | |
3371 | | /* Store the output */ |
3372 | 311k | pu1_out[2 * 7] = i4_rslt_1; |
3373 | | |
3374 | | /* Incrementing the output ptr */ |
3375 | 311k | pu1_out += i4_dst_stride; |
3376 | | |
3377 | 311k | } /* End of loop over x */ |
3378 | 38.8k | } /* isvcd_horz_interpol_chroma_dyadic_1 */ |
3379 | | |
3380 | | /*****************************************************************************/ |
3381 | | /* */ |
3382 | | /* Function Name : isvcd_horz_interpol_chroma_dyadic_2 */ |
3383 | | /* */ |
3384 | | /* Description : This function takes the reference array buffer & performs*/ |
3385 | | /* horizontal intra resampling for dyadic scaling ratios for*/ |
3386 | | /* chroma with following ref_lyr_chroma_phase_x_plus1_flag*/ |
3387 | | /* and chroma_phase_x_plus1_flag: */ |
3388 | | /* ref_lyr cur_lyr */ |
3389 | | /* 0 1 */ |
3390 | | /* Inputs : pi2_tmp_filt_buf : ptr to the 6x8 buffer containing the */ |
3391 | | /* vertically interpolated data */ |
3392 | | /* pu1_out_buf : pointer to the output buffer */ |
3393 | | /* i4_out_stride : output buffer stride */ |
3394 | | /* i4_phase_0 : x phase for even values of x */ |
3395 | | /* i4_phase_1 : x phase for odd values of x */ |
3396 | | /* Globals : none */ |
3397 | | /* Processing : it does the interpolation in vertical direction */ |
3398 | | /* Outputs : resampled samples */ |
3399 | | /* Returns : none */ |
3400 | | /* */ |
3401 | | /* Issues : none */ |
3402 | | /* */ |
3403 | | /* Revision History: */ |
3404 | | /* */ |
3405 | | /* DD MM YYYY Author(s) Changes (Describe the changes made) */ |
3406 | | /* 06 09 2021 Vijay creation */ |
3407 | | /* */ |
3408 | | /*****************************************************************************/ |
3409 | | void isvcd_horz_interpol_chroma_dyadic_2(WORD16 *pi2_tmp_filt_buf, UWORD8 *pu1_out_buf, |
3410 | | WORD32 i4_out_stride, WORD32 i4_phase_0, WORD32 i4_phase_1) |
3411 | 13.5k | { |
3412 | 13.5k | WORD32 i4_x, i4_y; |
3413 | 13.5k | WORD32 i4_coeff_0, i4_coeff_1, i4_coeff_2, i4_coeff_3; |
3414 | 13.5k | WORD32 i4_samp_0, i4_samp_1; |
3415 | 13.5k | WORD32 i4_rslt_1, i4_rslt_2; |
3416 | 13.5k | WORD32 i4_dst_stride; |
3417 | 13.5k | UWORD8 *pu1_out; |
3418 | 13.5k | WORD16 *pi2_tmp; |
3419 | | |
3420 | 13.5k | i4_coeff_0 = 8 - i4_phase_0; |
3421 | 13.5k | i4_coeff_1 = i4_phase_0; |
3422 | 13.5k | i4_coeff_2 = 8 - i4_phase_1; |
3423 | 13.5k | i4_coeff_3 = i4_phase_1; |
3424 | | |
3425 | 13.5k | pu1_out = pu1_out_buf; |
3426 | 13.5k | pi2_tmp = pi2_tmp_filt_buf + 1; |
3427 | 13.5k | i4_dst_stride = i4_out_stride; |
3428 | | |
3429 | | /* Horizontal interpolation */ |
3430 | 121k | for(i4_y = 0; i4_y < 8; i4_y++) |
3431 | 108k | { |
3432 | | /* x = 0, x_phase = phase_0 */ |
3433 | 108k | i4_samp_1 = *pi2_tmp++; |
3434 | | |
3435 | 540k | for(i4_x = 0; i4_x < 8; i4_x += 2) |
3436 | 432k | { |
3437 | 432k | i4_samp_0 = i4_samp_1; |
3438 | 432k | i4_samp_1 = *pi2_tmp++; |
3439 | | |
3440 | | /* x_phase is phase_1 for odd values of x */ |
3441 | | /* and phase_0 for even values of x */ |
3442 | 432k | i4_rslt_1 = i4_samp_0 * i4_coeff_0; |
3443 | 432k | i4_rslt_1 += i4_samp_1 * i4_coeff_1; |
3444 | | |
3445 | 432k | i4_rslt_2 = i4_samp_0 * i4_coeff_2; |
3446 | 432k | i4_rslt_2 += i4_samp_1 * i4_coeff_3; |
3447 | | |
3448 | | /* Rounding to 8-bit values */ |
3449 | 432k | i4_rslt_1 += 32; |
3450 | 432k | i4_rslt_1 >>= 6; |
3451 | 432k | i4_rslt_2 += 32; |
3452 | 432k | i4_rslt_2 >>= 6; |
3453 | | |
3454 | | /* Storing the results */ |
3455 | 432k | pu1_out[2 * i4_x] = i4_rslt_1; |
3456 | 432k | pu1_out[2 * (i4_x + 1)] = i4_rslt_2; |
3457 | | |
3458 | 432k | } /* End of loop over x */ |
3459 | | |
3460 | | /* Incrementing the ptrs */ |
3461 | 108k | pi2_tmp += 1; |
3462 | 108k | pu1_out += i4_dst_stride; |
3463 | | |
3464 | 108k | } /* End of loop over y */ |
3465 | 13.5k | } /* isvcd_horz_interpol_chroma_dyadic_2 */ |
3466 | | |
3467 | | /*****************************************************************************/ |
3468 | | /* */ |
3469 | | /* Function Name : isvcd_intra_resamp_mb_dyadic */ |
3470 | | /* */ |
3471 | | /* Description : MB level function which performs the intra resampling */ |
3472 | | /* of data of an MB (luma and chroma inclusive) for dyadic */ |
3473 | | /* scaling ratios */ |
3474 | | /* */ |
3475 | | /* Inputs : pv_intra_samp_ctxt : intra sampling context */ |
3476 | | /* ps_ref_luma : reference layer luma data buffer desc */ |
3477 | | /* ps_ref_chroma : reference layer chroma data buffer desc */ |
3478 | | /* ps_ref_mb_mode_map : ref layer mb mode map buff desc */ |
3479 | | /* ps_curr_luma : current layer out luma buffer desc */ |
3480 | | /* ps_curr_chroma : current layer out chroma buffer desc */ |
3481 | | /* x,y : current mb coorinate */ |
3482 | | /* Globals : none */ |
3483 | | /* Processing : it calls the reference layer construction followed by */ |
3484 | | /* interpolation function for luma and cb and cr */ |
3485 | | /* Outputs : inter resampled data of current MB */ |
3486 | | /* Returns : none */ |
3487 | | /* */ |
3488 | | /* Issues : none */ |
3489 | | /* */ |
3490 | | /* Revision History: */ |
3491 | | /* */ |
3492 | | /* DD MM YYYY Author(s) Changes (Describe the changes made) */ |
3493 | | /* 06 09 2021 Vijay creation */ |
3494 | | /* */ |
3495 | | /*****************************************************************************/ |
3496 | | WORD32 isvcd_intra_resamp_mb_dyadic(void *pv_intra_samp_ctxt, mem_element_t *ps_ref_luma, |
3497 | | mem_element_t *ps_ref_chroma, mem_element_t *ps_ref_mb_mode_map, |
3498 | | mem_element_t *ps_curr_luma, mem_element_t *ps_curr_chroma, |
3499 | | mb_coord_t *ps_mb_coord, void *pv_svc_dec) |
3500 | 58.0k | { |
3501 | | /* --------------------------------------------------------------------- */ |
3502 | | /* I/O buffer params */ |
3503 | | /* --------------------------------------------------------------------- */ |
3504 | 58.0k | UWORD8 *pu1_inp_luma, *pu1_inp_chroma; |
3505 | 58.0k | UWORD8 *pu1_out_luma, *pu1_out_chroma; |
3506 | 58.0k | UWORD8 *pu1_out_cb, *pu1_out_cr; |
3507 | 58.0k | UWORD8 *pu1_refarray_luma, *pu1_refarray_cb, *pu1_refarray_cr; |
3508 | 58.0k | WORD16 *pi2_tmp_filt_buf; |
3509 | 58.0k | WORD32 i4_inp_luma_stride, i4_inp_chroma_stride; |
3510 | 58.0k | WORD32 i4_out_luma_stride, i4_out_chroma_stride; |
3511 | 58.0k | UWORD16 u2_mb_x_ref, u2_mb_y_ref; |
3512 | 58.0k | svc_dec_lyr_struct_t *ps_svc_lyr_dec = (svc_dec_lyr_struct_t *) pv_svc_dec; |
3513 | 58.0k | dec_slice_svc_ext_params_t *ps_svc_slice_params = NULL; |
3514 | | |
3515 | | /* --------------------------------------------------------------------- */ |
3516 | | /* Intra resampling ctxt pointers */ |
3517 | | /* --------------------------------------------------------------------- */ |
3518 | 58.0k | intra_sampling_ctxt_t *ps_ctxt; |
3519 | 58.0k | intra_samp_lyr_ctxt *ps_lyr_ctxt; |
3520 | | |
3521 | | /* --------------------------------------------------------------------- */ |
3522 | | /* reference and current layer MB coordinates */ |
3523 | | /* --------------------------------------------------------------------- */ |
3524 | 58.0k | WORD32 i4_scaled_mb_x, i4_scaled_mb_y; |
3525 | 58.0k | WORD32 i4_top, i4_left; |
3526 | 58.0k | WORD32 ret; |
3527 | | |
3528 | 58.0k | ps_svc_slice_params = &ps_svc_lyr_dec->s_svc_slice_params; |
3529 | | /* --------------------------------------------------------------------- */ |
3530 | | /* Pointer derivation */ |
3531 | | /* --------------------------------------------------------------------- */ |
3532 | 58.0k | ps_ctxt = (intra_sampling_ctxt_t *) pv_intra_samp_ctxt; |
3533 | 58.0k | ps_lyr_ctxt = &ps_ctxt->as_res_lyrs[ps_ctxt->i4_res_lyr_id]; |
3534 | | |
3535 | | /* --------------------------------------------------------------------- */ |
3536 | | /* MB coordinate derivation */ |
3537 | | /* --------------------------------------------------------------------- */ |
3538 | 58.0k | i4_scaled_mb_x = |
3539 | 58.0k | ps_mb_coord->u2_mb_x - (ps_svc_slice_params->i4_scaled_ref_layer_left_offset >> 4); |
3540 | 58.0k | i4_scaled_mb_y = |
3541 | 58.0k | ps_mb_coord->u2_mb_y - (ps_svc_slice_params->i4_scaled_ref_layer_top_offset >> 4); |
3542 | | |
3543 | 58.0k | if(i4_scaled_mb_x & 0x1) |
3544 | 28.9k | { |
3545 | 28.9k | i4_left = 1; |
3546 | 28.9k | } |
3547 | 29.1k | else |
3548 | 29.1k | { |
3549 | 29.1k | i4_left = -1; |
3550 | 29.1k | } |
3551 | 58.0k | if(i4_scaled_mb_y & 0x1) |
3552 | 27.7k | { |
3553 | 27.7k | i4_top = 1; |
3554 | 27.7k | } |
3555 | 30.3k | else |
3556 | 30.3k | { |
3557 | 30.3k | i4_top = -1; |
3558 | 30.3k | } |
3559 | | |
3560 | 58.0k | u2_mb_x_ref = (i4_scaled_mb_x >> 1); |
3561 | 58.0k | u2_mb_y_ref = (i4_scaled_mb_y >> 1); |
3562 | | |
3563 | | /* --------------------------------------------------------------------- */ |
3564 | | /* Reference Array Consrtuction - luma and chroma */ |
3565 | | /* --------------------------------------------------------------------- */ |
3566 | 58.0k | pu1_inp_luma = (UWORD8 *) ps_ref_luma->pv_buffer; |
3567 | 58.0k | pu1_inp_chroma = (UWORD8 *) ps_ref_chroma->pv_buffer; |
3568 | 58.0k | i4_inp_luma_stride = ps_ref_luma->i4_num_element_stride; |
3569 | 58.0k | i4_inp_chroma_stride = ps_ref_chroma->i4_num_element_stride; |
3570 | | |
3571 | | /* ------- Constructing refSampleArray ----------------------- */ |
3572 | 58.0k | ret = isvcd_reflayer_construction_dyadic( |
3573 | 58.0k | pv_intra_samp_ctxt, ps_ref_mb_mode_map, pu1_inp_luma, pu1_inp_chroma, i4_inp_luma_stride, |
3574 | 58.0k | i4_inp_chroma_stride, i4_top, i4_left, u2_mb_x_ref, u2_mb_y_ref); |
3575 | | |
3576 | 58.0k | if(ret != OK) |
3577 | 0 | { |
3578 | 0 | return NOT_OK; |
3579 | 0 | } |
3580 | | /* --------------------------------------------------------------------- */ |
3581 | | /* LUMA INTERPOLATION */ |
3582 | | /* --------------------------------------------------------------------- */ |
3583 | 58.0k | pu1_refarray_luma = ps_ctxt->pu1_refarray_buffer; |
3584 | 58.0k | if(1 == i4_top) |
3585 | 27.7k | { |
3586 | 27.7k | pu1_refarray_luma += (DYADIC_REF_W_Y << 3); |
3587 | 27.7k | } |
3588 | 58.0k | if(1 == i4_left) |
3589 | 28.9k | { |
3590 | 28.9k | pu1_refarray_luma += 8; |
3591 | 28.9k | } |
3592 | 58.0k | pu1_out_luma = (UWORD8 *) ps_curr_luma->pv_buffer; |
3593 | 58.0k | i4_out_luma_stride = ps_curr_luma->i4_num_element_stride; |
3594 | 58.0k | pi2_tmp_filt_buf = (WORD16 *) ps_ctxt->pi4_temp_interpolation_buffer; |
3595 | | |
3596 | 58.0k | ps_ctxt->pf_interpolate_base_luma_dyadic(pu1_refarray_luma, pi2_tmp_filt_buf, pu1_out_luma, |
3597 | 58.0k | i4_out_luma_stride); |
3598 | | |
3599 | | /* --------------------------------------------------------------------- */ |
3600 | | /* CHROMA INTERPOLATION */ |
3601 | | /* --------------------------------------------------------------------- */ |
3602 | 58.0k | pu1_out_chroma = (UWORD8 *) ps_curr_chroma->pv_buffer; |
3603 | 58.0k | i4_out_chroma_stride = ps_curr_chroma->i4_num_element_stride; |
3604 | | |
3605 | | /* CB */ |
3606 | 58.0k | pu1_out_cb = pu1_out_chroma; |
3607 | 58.0k | pu1_refarray_cb = ps_ctxt->pu1_refarray_cb; |
3608 | | |
3609 | 58.0k | if(1 == i4_top) |
3610 | 27.7k | { |
3611 | 27.7k | pu1_refarray_cb += (DYADIC_REF_W_C << 2); |
3612 | 27.7k | } |
3613 | 58.0k | if(1 == i4_left) |
3614 | 28.9k | { |
3615 | 28.9k | pu1_refarray_cb += 4; |
3616 | 28.9k | } |
3617 | | |
3618 | | /* Vertical interpolation */ |
3619 | 58.0k | ps_lyr_ctxt->pf_vert_chroma_interpol(pu1_refarray_cb, pi2_tmp_filt_buf, |
3620 | 58.0k | ps_lyr_ctxt->i4_y_phase_0, ps_lyr_ctxt->i4_y_phase_1); |
3621 | | |
3622 | | /* Horizontal interpolation */ |
3623 | 58.0k | ps_lyr_ctxt->pf_horz_chroma_interpol(pi2_tmp_filt_buf, pu1_out_cb, i4_out_chroma_stride, |
3624 | 58.0k | ps_lyr_ctxt->i4_x_phase_0, ps_lyr_ctxt->i4_x_phase_1); |
3625 | | |
3626 | | /* CR */ |
3627 | 58.0k | pu1_out_cr = pu1_out_chroma + 1; |
3628 | 58.0k | pu1_refarray_cr = ps_ctxt->pu1_refarray_cr; |
3629 | | |
3630 | 58.0k | if(1 == i4_top) |
3631 | 27.7k | { |
3632 | 27.7k | pu1_refarray_cr += (DYADIC_REF_W_C << 2); |
3633 | 27.7k | } |
3634 | 58.0k | if(1 == i4_left) |
3635 | 28.9k | { |
3636 | 28.9k | pu1_refarray_cr += 4; |
3637 | 28.9k | } |
3638 | | |
3639 | | /* Vertical interpolation */ |
3640 | 58.0k | ps_lyr_ctxt->pf_vert_chroma_interpol(pu1_refarray_cr, pi2_tmp_filt_buf, |
3641 | 58.0k | ps_lyr_ctxt->i4_y_phase_0, ps_lyr_ctxt->i4_y_phase_1); |
3642 | | |
3643 | | /* Horizontal interpolation */ |
3644 | 58.0k | ps_lyr_ctxt->pf_horz_chroma_interpol(pi2_tmp_filt_buf, pu1_out_cr, i4_out_chroma_stride, |
3645 | 58.0k | ps_lyr_ctxt->i4_x_phase_0, ps_lyr_ctxt->i4_x_phase_1); |
3646 | 58.0k | return OK; |
3647 | 58.0k | } |
3648 | | |
3649 | | /*****************************************************************************/ |
3650 | | /* */ |
3651 | | /* Function Name : isvcd_interpolate_intra_base */ |
3652 | | /* */ |
3653 | | /* Description : This function takes the reference array buffer & performs*/ |
3654 | | /* interpolation of a component to find the intra */ |
3655 | | /* resampled value */ |
3656 | | /* Inputs : pv_intra_samp_ctxt : intra sampling context */ |
3657 | | /* pu1_out : output buffer pointer */ |
3658 | | /* i4_out_stride : output buffer stride */ |
3659 | | /* i4_refarray_wd : reference array width */ |
3660 | | /* i4_x_offset : offset in reference layer in horz direction*/ |
3661 | | /* ps_coord : current mb co-ordinate */ |
3662 | | /* i4_chroma_flag : chroma processing flag */ |
3663 | | /* Globals : none */ |
3664 | | /* Processing : it does the interpolation in vertical direction followed */ |
3665 | | /* by horizontal direction */ |
3666 | | /* Outputs : resampled pixels */ |
3667 | | /* Returns : none */ |
3668 | | /* */ |
3669 | | /* Issues : none */ |
3670 | | /* */ |
3671 | | /* Revision History: */ |
3672 | | /* */ |
3673 | | /* DD MM YYYY Author(s) Changes (Describe the changes made) */ |
3674 | | /* 26 09 2021 vijayakumar creation */ |
3675 | | /* */ |
3676 | | /*****************************************************************************/ |
3677 | | void isvcd_interpolate_intra_base(void *pv_intra_samp_ctxt, UWORD8 *pu1_out, WORD32 i4_out_stride, |
3678 | | WORD32 i4_refarray_wd, WORD32 i4_mb_x, WORD32 i4_mb_y, |
3679 | | WORD32 i4_chroma_flag, WORD32 i4_refarray_flag) |
3680 | 84.2k | { |
3681 | | /* --------------------------------------------------------------------- */ |
3682 | | /* Index Parameters */ |
3683 | | /* --------------------------------------------------------------------- */ |
3684 | 84.2k | intra_sampling_ctxt_t *ps_ctxt; |
3685 | 84.2k | intra_samp_map_ctxt_t *ps_map_ctxt; |
3686 | 84.2k | intra_samp_lyr_ctxt *ps_lyr_ctxt; |
3687 | 84.2k | WORD32 i4_x, i4_y; |
3688 | 84.2k | WORD32 i4_frm_mb_x, i4_frm_mb_y; |
3689 | 84.2k | ref_pixel_map_t *ps_x_pos_phase; |
3690 | 84.2k | ref_pixel_map_t *ps_y_pos_phase; |
3691 | | |
3692 | 84.2k | WORD32 i4_temp_array_ht; |
3693 | 84.2k | WORD32 *pi4_interp_buff; |
3694 | 84.2k | WORD32 *pi4_interp_buff_temp; |
3695 | 84.2k | WORD32 i4_mb_wd; |
3696 | 84.2k | WORD32 i4_mb_ht; |
3697 | 84.2k | WORD32 i4_x_min, i4_x_max; |
3698 | 84.2k | ref_min_max_map_t *ps_x_min_max; |
3699 | 84.2k | UWORD8 *pu1_refarray = NULL; |
3700 | | |
3701 | | /* --------------------------------------------------------------------- */ |
3702 | | /* Extracting pointers from the context */ |
3703 | | /* --------------------------------------------------------------------- */ |
3704 | 84.2k | ps_ctxt = (intra_sampling_ctxt_t *) pv_intra_samp_ctxt; |
3705 | 84.2k | ps_lyr_ctxt = &ps_ctxt->as_res_lyrs[ps_ctxt->i4_res_lyr_id]; |
3706 | | |
3707 | 84.2k | if(0 == i4_refarray_flag) |
3708 | 56.1k | { |
3709 | 56.1k | pu1_refarray = ps_ctxt->pu1_refarray_buffer; |
3710 | 56.1k | } |
3711 | 28.0k | else if(1 == i4_refarray_flag) |
3712 | 28.0k | { |
3713 | 28.0k | pu1_refarray = ps_ctxt->pu1_refarray_cb; |
3714 | 28.0k | } |
3715 | | |
3716 | | /* --------------------------------------------------------------------- */ |
3717 | | /* LUMA or CHROMA */ |
3718 | | /* --------------------------------------------------------------------- */ |
3719 | 84.2k | if(1 == i4_chroma_flag) |
3720 | 56.1k | ps_map_ctxt = &(ps_lyr_ctxt->s_chroma_map_ctxt); |
3721 | 28.0k | else |
3722 | 28.0k | ps_map_ctxt = &(ps_lyr_ctxt->s_luma_map_ctxt); |
3723 | | |
3724 | 84.2k | i4_mb_wd = MB_WIDTH >> i4_chroma_flag; |
3725 | 84.2k | i4_mb_ht = MB_HEIGHT >> i4_chroma_flag; |
3726 | 84.2k | ps_x_min_max = ps_map_ctxt->ps_x_min_max; |
3727 | 84.2k | i4_frm_mb_y = i4_mb_y * i4_mb_ht; |
3728 | 84.2k | i4_frm_mb_x = i4_mb_x * i4_mb_wd; |
3729 | | |
3730 | | /* get the min and max positions */ |
3731 | 84.2k | i4_x_min = ps_x_min_max[i4_mb_x].i2_min_pos; |
3732 | 84.2k | i4_x_max = ps_x_min_max[i4_mb_x].i2_max_pos; |
3733 | | |
3734 | | /* --------------------------------------------------------------------- */ |
3735 | | /* Projected frame level pointers */ |
3736 | | /* --------------------------------------------------------------------- */ |
3737 | 84.2k | ps_x_pos_phase = ps_map_ctxt->ps_x_pos_phase; |
3738 | 84.2k | ps_y_pos_phase = ps_map_ctxt->ps_y_pos_phase; |
3739 | | |
3740 | | /* --------------------------------------------------------------------- */ |
3741 | | /* Pointers and Dimenstion of the temporary buffer */ |
3742 | | /* --------------------------------------------------------------------- */ |
3743 | 84.2k | i4_temp_array_ht = i4_mb_ht; |
3744 | 84.2k | pi4_interp_buff = ps_ctxt->pi4_temp_interpolation_buffer; |
3745 | 84.2k | pi4_interp_buff_temp = pi4_interp_buff; |
3746 | | |
3747 | | /* --------------------------------------------------------------------- */ |
3748 | | /* Loop for interpolation in vertical direction */ |
3749 | | /* --------------------------------------------------------------------- */ |
3750 | 982k | for(i4_y = 0; i4_y < (i4_temp_array_ht); i4_y++) |
3751 | 898k | { |
3752 | 11.9M | for(i4_x = (i4_x_min - 1); i4_x <= (i4_x_max + 2); i4_x++) |
3753 | 11.0M | { |
3754 | 11.0M | UWORD8 *pu1_refarray_temp; |
3755 | 11.0M | WORD32 i4_y_ref; |
3756 | 11.0M | WORD32 i4_y_phase; |
3757 | | /* ------------------------------------------------------------ */ |
3758 | | /* Finding the offset */ |
3759 | | /* ------------------------------------------------------------ */ |
3760 | 11.0M | i4_y_ref = ps_y_pos_phase[i4_y + i4_frm_mb_y].i2_ref_pos; |
3761 | 11.0M | i4_y_phase = ps_y_pos_phase[i4_y + i4_frm_mb_y].i2_phase; |
3762 | 11.0M | pu1_refarray_temp = pu1_refarray + i4_x + (i4_y_ref * i4_refarray_wd); |
3763 | | |
3764 | | /* ------------------------------------------------------------ */ |
3765 | | /* Check for Luma/Chroma Processing */ |
3766 | | /* ------------------------------------------------------------ */ |
3767 | 11.0M | if(0 == i4_chroma_flag) |
3768 | 6.73M | { |
3769 | 6.73M | *(pi4_interp_buff + i4_x) = |
3770 | 6.73M | (g_ai1_interp_filter_luma[i4_y_phase]) * |
3771 | 6.73M | (*(pu1_refarray_temp - i4_refarray_wd)) + |
3772 | | |
3773 | 6.73M | (g_ai1_interp_filter_luma[16 + i4_y_phase]) * (*(pu1_refarray_temp)) + |
3774 | | |
3775 | 6.73M | (g_ai1_interp_filter_luma[32 + i4_y_phase]) * |
3776 | 6.73M | (*(pu1_refarray_temp + i4_refarray_wd)) + |
3777 | | |
3778 | 6.73M | (g_ai1_interp_filter_luma[48 + i4_y_phase]) * |
3779 | 6.73M | (*(pu1_refarray_temp + (2 * i4_refarray_wd))); |
3780 | 6.73M | } |
3781 | 4.31M | else |
3782 | 4.31M | { |
3783 | 4.31M | *(pi4_interp_buff + i4_x) = |
3784 | 4.31M | (g_au1_interp_filter_chroma[i4_y_phase]) * (*(pu1_refarray_temp)) + |
3785 | | |
3786 | 4.31M | (g_au1_interp_filter_chroma[16 + i4_y_phase]) * |
3787 | 4.31M | (*(pu1_refarray_temp + i4_refarray_wd)); |
3788 | 4.31M | } |
3789 | | |
3790 | 11.0M | } /* end of loop over array width */ |
3791 | 898k | pi4_interp_buff = pi4_interp_buff + i4_refarray_wd; |
3792 | 898k | } /* end of loop over temp array height*/ |
3793 | | |
3794 | 84.2k | pi4_interp_buff = pi4_interp_buff_temp; |
3795 | | |
3796 | | /* --------------------------------------------------------------------- */ |
3797 | | /* Loop for interpolation in horizontal direction */ |
3798 | | /* --------------------------------------------------------------------- */ |
3799 | 982k | for(i4_y = 0; i4_y < i4_temp_array_ht; i4_y++) |
3800 | 898k | { |
3801 | 11.6M | for(i4_x = 0; i4_x < i4_mb_wd; i4_x++) |
3802 | 10.7M | { |
3803 | 10.7M | WORD32 i4_x_ref; |
3804 | 10.7M | WORD32 i4_x_phase; |
3805 | | /* ------------------------------------------------------------- */ |
3806 | | /* Finding the offset */ |
3807 | | /* ------------------------------------------------------------- */ |
3808 | 10.7M | i4_x_ref = ps_x_pos_phase[i4_x + i4_frm_mb_x].i2_ref_pos; |
3809 | 10.7M | i4_x_phase = ps_x_pos_phase[i4_x + i4_frm_mb_x].i2_phase; |
3810 | 10.7M | pi4_interp_buff_temp = pi4_interp_buff + i4_x_ref; |
3811 | | |
3812 | | /* ------------------------------------------------------------- */ |
3813 | | /* Check for Luma/Chroma Processing */ |
3814 | | /* ------------------------------------------------------------- */ |
3815 | 10.7M | if(0 == i4_chroma_flag) |
3816 | 7.18M | { |
3817 | 7.18M | *(pu1_out + i4_x + (i4_y * i4_out_stride)) = |
3818 | | |
3819 | 7.18M | CLIPUCHAR( |
3820 | 7.18M | ((g_ai1_interp_filter_luma[i4_x_phase]) * (*(pi4_interp_buff_temp - 1)) + |
3821 | 7.18M | (g_ai1_interp_filter_luma[16 + i4_x_phase]) * (*(pi4_interp_buff_temp)) + |
3822 | 7.18M | (g_ai1_interp_filter_luma[32 + i4_x_phase]) * |
3823 | 7.18M | (*(pi4_interp_buff_temp + 1)) + |
3824 | 7.18M | (g_ai1_interp_filter_luma[48 + i4_x_phase]) * |
3825 | 7.18M | (*(pi4_interp_buff_temp + 2)) + |
3826 | 7.18M | 512) >> |
3827 | 7.18M | 10); |
3828 | 7.18M | } |
3829 | 3.59M | else |
3830 | 3.59M | { |
3831 | 3.59M | *(pu1_out + (2 * i4_x) + (i4_y * i4_out_stride)) = CLIPUCHAR( |
3832 | 3.59M | ((g_au1_interp_filter_chroma[i4_x_phase]) * (*(pi4_interp_buff_temp)) + |
3833 | 3.59M | (g_au1_interp_filter_chroma[16 + i4_x_phase]) * (*(pi4_interp_buff_temp + 1)) + |
3834 | 3.59M | 512) >> |
3835 | 3.59M | 10); |
3836 | 3.59M | } |
3837 | | |
3838 | 10.7M | } /* end of loop over array width */ |
3839 | 898k | pi4_interp_buff = pi4_interp_buff + i4_refarray_wd; |
3840 | 898k | } /* end of loop over MB height */ |
3841 | | |
3842 | 84.2k | return; |
3843 | 84.2k | } /* End of Interpolation Function */ |
3844 | | /*****************************************************************************/ |
3845 | | /* */ |
3846 | | /* Function Name : isvcd_intra_resamp_mb */ |
3847 | | /* */ |
3848 | | /* Description : MB level function whcih perform the intra resampling */ |
3849 | | /* of data of an MB (luma and chroma insclusive) */ |
3850 | | /* */ |
3851 | | /* Inputs : pv_intra_samp_ctxt : intra sampling context */ |
3852 | | /* ps_ref_luma : reference layer luma data buffer desc */ |
3853 | | /* ps_ref_chroma : reference layer chroma data buffer desc */ |
3854 | | /* ps_ref_mb_mode_map : ref layer mb mode map buff desc */ |
3855 | | /* ps_curr_luma : current layer out luma buffer desc */ |
3856 | | /* ps_curr_chroma : current layer out chroma buffer desc */ |
3857 | | /* ps_mb_coord : current mb coorinate */ |
3858 | | /* Globals : none */ |
3859 | | /* Processing : it calls the reference layer construction followed by */ |
3860 | | /* interpolation function for luma and cb and cr */ |
3861 | | /* Outputs : inter resampled data of current MB */ |
3862 | | /* Returns : none */ |
3863 | | /* */ |
3864 | | /* Issues : none */ |
3865 | | /* */ |
3866 | | /* Revision History: */ |
3867 | | /* */ |
3868 | | /* DD MM YYYY Author(s) Changes (Describe the changes made) */ |
3869 | | /* 06 09 2021 Vijay creation */ |
3870 | | /* */ |
3871 | | /*****************************************************************************/ |
3872 | | WORD32 isvcd_intra_resamp_mb(void *pv_intra_samp_ctxt, mem_element_t *ps_ref_luma, |
3873 | | mem_element_t *ps_ref_chroma, mem_element_t *ps_ref_mb_mode_map, |
3874 | | mem_element_t *ps_curr_luma, mem_element_t *ps_curr_chroma, |
3875 | | mb_coord_t *ps_mb_coord) |
3876 | 48.9k | { |
3877 | | /* --------------------------------------------------------------------- */ |
3878 | | /* I/O buffer params */ |
3879 | | /* --------------------------------------------------------------------- */ |
3880 | 48.9k | intra_sampling_ctxt_t *ps_ctxt; |
3881 | 48.9k | UWORD8 *pu1_inp_luma, *pu1_inp_cb, *pu1_inp_cr; |
3882 | 48.9k | UWORD8 *pu1_out_luma, *pu1_out_cb, *pu1_out_cr; |
3883 | 48.9k | WORD32 i4_inp_stride; |
3884 | 48.9k | WORD32 i4_out_stride; |
3885 | 48.9k | WORD32 i4_refarray_stride; |
3886 | | |
3887 | | /* --------------------------------------------------------------------- */ |
3888 | | /* ref sample array and corresponding parametrs */ |
3889 | | /* --------------------------------------------------------------------- */ |
3890 | 48.9k | WORD32 i4_chroma_flag, ret; |
3891 | | |
3892 | 48.9k | ps_ctxt = (intra_sampling_ctxt_t *) pv_intra_samp_ctxt; |
3893 | | /* needs to be populated at proper place */ |
3894 | 48.9k | i4_refarray_stride = ps_ctxt->i4_refarray_stride; |
3895 | | |
3896 | | /* --------------------------------------------------------------------- */ |
3897 | | /* LUMA PROCESSING */ |
3898 | | /* --------------------------------------------------------------------- */ |
3899 | 48.9k | pu1_inp_luma = (UWORD8 *) ps_ref_luma->pv_buffer; |
3900 | 48.9k | pu1_out_luma = (UWORD8 *) ps_curr_luma->pv_buffer; |
3901 | 48.9k | i4_inp_stride = ps_ref_luma->i4_num_element_stride; |
3902 | 48.9k | i4_out_stride = ps_curr_luma->i4_num_element_stride; |
3903 | 48.9k | i4_chroma_flag = 0; |
3904 | | |
3905 | | /* ------- Constructing refSampleArray ----------------------- */ |
3906 | 48.9k | ret = isvcd_reflayer_construction(pv_intra_samp_ctxt, pu1_inp_luma, NULL, i4_inp_stride, |
3907 | 48.9k | i4_refarray_stride, ps_ref_mb_mode_map, ps_mb_coord, |
3908 | 48.9k | i4_chroma_flag); |
3909 | | |
3910 | 48.9k | if(ret != OK) |
3911 | 0 | { |
3912 | 0 | return NOT_OK; |
3913 | 0 | } |
3914 | | /* ---- Interpolation process for Intra_Base prediction ------ */ |
3915 | 48.9k | ps_ctxt->pf_interpolate_intra_base(pv_intra_samp_ctxt, pu1_out_luma, i4_out_stride, |
3916 | 48.9k | i4_refarray_stride, ps_mb_coord->u2_mb_x, |
3917 | 48.9k | ps_mb_coord->u2_mb_y, i4_chroma_flag, 0); |
3918 | | |
3919 | | /* --------------------------------------------------------------------- */ |
3920 | | /* CHROMA PROCESSING */ |
3921 | | /* --------------------------------------------------------------------- */ |
3922 | | /* CB */ |
3923 | 48.9k | i4_inp_stride = ps_ref_chroma->i4_num_element_stride; |
3924 | 48.9k | pu1_inp_cb = (UWORD8 *) ps_ref_chroma->pv_buffer; |
3925 | 48.9k | pu1_inp_cr = pu1_inp_cb + 1; |
3926 | 48.9k | i4_chroma_flag = 1; |
3927 | | |
3928 | | /* ------- Constructing refSampleArray ----------------------- */ |
3929 | 48.9k | ret = isvcd_reflayer_construction(pv_intra_samp_ctxt, pu1_inp_cb, pu1_inp_cr, i4_inp_stride, |
3930 | 48.9k | i4_refarray_stride, ps_ref_mb_mode_map, ps_mb_coord, |
3931 | 48.9k | i4_chroma_flag); |
3932 | | |
3933 | 48.9k | if(ret != OK) |
3934 | 0 | { |
3935 | 0 | return NOT_OK; |
3936 | 0 | } |
3937 | 48.9k | i4_out_stride = ps_curr_chroma->i4_num_element_stride; |
3938 | 48.9k | pu1_out_cb = (UWORD8 *) ps_curr_chroma->pv_buffer; |
3939 | 48.9k | pu1_out_cr = pu1_out_cb + 1; |
3940 | | |
3941 | | /* ---- Cb Interpolation process for Intra_Base prediction ------ */ |
3942 | 48.9k | ps_ctxt->pf_interpolate_intra_base(pv_intra_samp_ctxt, pu1_out_cb, i4_out_stride, |
3943 | 48.9k | i4_refarray_stride, ps_mb_coord->u2_mb_x, |
3944 | 48.9k | ps_mb_coord->u2_mb_y, i4_chroma_flag, 0); |
3945 | | |
3946 | | /* ---- Cr Interpolation process for Intra_Base prediction ------ */ |
3947 | 48.9k | ps_ctxt->pf_interpolate_intra_base(pv_intra_samp_ctxt, pu1_out_cr, i4_out_stride, |
3948 | 48.9k | i4_refarray_stride, ps_mb_coord->u2_mb_x, |
3949 | 48.9k | ps_mb_coord->u2_mb_y, i4_chroma_flag, 1); |
3950 | 48.9k | return OK; |
3951 | 48.9k | } |
3952 | | |
3953 | | /*****************************************************************************/ |
3954 | | /* */ |
3955 | | /* Function Name : isvcd_intra_resamp_generate_segment_lookup */ |
3956 | | /* */ |
3957 | | /* Description : This function generates segment lookup used to derive */ |
3958 | | /* segments which have to be be intra resampled */ |
3959 | | /* */ |
3960 | | /* Inputs : pv_lookup_table : look up table */ |
3961 | | /* i4_dimension : dimension of the block which is used in*/ |
3962 | | /* resampling process. */ |
3963 | | /* i4_mb_size : size of the mb */ |
3964 | | /* Globals : None */ |
3965 | | /* Processing : This function generates segment lookup used to derive */ |
3966 | | /* segments which have to be be intra resampled */ |
3967 | | /* Outputs : none */ |
3968 | | /* Returns : none */ |
3969 | | /* */ |
3970 | | /* Issues : None */ |
3971 | | /* */ |
3972 | | /* Revision History: */ |
3973 | | /* */ |
3974 | | /* DD MM YYYY Author(s) Changes (Describe the changes made) */ |
3975 | | /* 06 09 2021 Vijay Creation */ |
3976 | | /* */ |
3977 | | /*****************************************************************************/ |
3978 | | void isvcd_intra_resamp_generate_segment_lookup(seg_lookup_desc_t *ps_seg_lookup_table, |
3979 | | WORD32 i4_dimension, WORD32 i4_mb_size, |
3980 | | WORD32 i4_shift_val) |
3981 | 72.5k | { |
3982 | 72.5k | WORD32 i4_x; |
3983 | 72.5k | WORD32 i4_position, i4_dist_prev_mb, i4_dist_next_mb; |
3984 | 72.5k | UWORD8 u1_seg_dim; |
3985 | 72.5k | UWORD8 u1_num_sgmts; |
3986 | 72.5k | WORD32 i4_block_size = i4_mb_size >> 1; |
3987 | 72.5k | UWORD8 u1_offset = 0; |
3988 | 72.5k | seg_lookup_desc_t *ps_segments; |
3989 | 72.5k | seg_description_t *ps_seg_desc; |
3990 | | |
3991 | 72.5k | memset(ps_seg_lookup_table, 0, i4_mb_size * sizeof(seg_lookup_desc_t)); |
3992 | | |
3993 | 942k | for(i4_x = 0; i4_x < i4_mb_size; i4_x++) |
3994 | 870k | { |
3995 | 870k | ps_segments = &ps_seg_lookup_table[i4_x]; |
3996 | 870k | ps_seg_desc = ps_segments->s_segments; |
3997 | 870k | i4_position = i4_x; |
3998 | | |
3999 | 870k | if(i4_x >= i4_block_size) |
4000 | 435k | { |
4001 | | /* set the fourth bit so that later it can be directly OR ed */ |
4002 | 435k | ps_segments->u4_start_pos = 8; |
4003 | 435k | } |
4004 | 435k | else |
4005 | 435k | { |
4006 | 435k | ps_segments->u4_start_pos = 0; |
4007 | 435k | } |
4008 | | |
4009 | 870k | u1_num_sgmts = 0; |
4010 | 870k | u1_offset = 0; |
4011 | | |
4012 | 3.26M | while(i4_position < (i4_x + i4_dimension)) |
4013 | 2.39M | { |
4014 | | /* check and fill the nearest mb boundry flag */ |
4015 | 2.39M | if((i4_position & (i4_mb_size - 1)) < i4_block_size) |
4016 | 1.19M | { |
4017 | 1.19M | ps_seg_desc->i1_nearst_mb_bdry = -1; |
4018 | 1.19M | } |
4019 | 1.19M | else |
4020 | 1.19M | { |
4021 | 1.19M | ps_seg_desc->i1_nearst_mb_bdry = 1; |
4022 | 1.19M | } |
4023 | | |
4024 | | /* find the distance from the previous MB for start of segment*/ |
4025 | 2.39M | i4_dist_prev_mb = (i4_position & (i4_mb_size - 1)); |
4026 | | |
4027 | 2.39M | ps_seg_desc->i1_dist_idx = |
4028 | 2.39M | ((i4_dist_prev_mb >= i4_mb_size >> 1) ? (i4_mb_size - i4_dist_prev_mb) |
4029 | 2.39M | : -(i4_dist_prev_mb + 1)); |
4030 | | |
4031 | | /* find the size of the segment */ |
4032 | 2.39M | u1_seg_dim = (i4_block_size - (i4_position & (i4_block_size - 1))); |
4033 | 2.39M | i4_position += u1_seg_dim; |
4034 | 2.39M | if(i4_position > (i4_x + i4_dimension)) |
4035 | 725k | { |
4036 | 725k | i4_position = (i4_x + i4_dimension); |
4037 | 725k | u1_seg_dim = (i4_position & (i4_block_size - 1)); |
4038 | 725k | } |
4039 | | |
4040 | | /* find the distance from the next MB for end of segment */ |
4041 | 2.39M | i4_dist_next_mb = (i4_position & (i4_mb_size - 1)); |
4042 | 2.39M | ps_seg_desc->u1_seg_dim = u1_seg_dim; |
4043 | 2.39M | ps_seg_desc->u1_seg_off = u1_offset; |
4044 | | |
4045 | | /* check if the segment has a adjoining MB edge */ |
4046 | 2.39M | if(i4_dist_prev_mb == 0) |
4047 | 834k | { |
4048 | 834k | if(0 == u1_num_sgmts) |
4049 | 72.5k | { |
4050 | 72.5k | ps_seg_desc->u1_mb_adjoin = 0; |
4051 | 72.5k | } |
4052 | 761k | else |
4053 | 761k | { |
4054 | 761k | ps_seg_desc->u1_mb_adjoin = 1 << i4_shift_val; |
4055 | 761k | } |
4056 | 834k | } |
4057 | 1.55M | else if(i4_dist_next_mb == 0) |
4058 | 834k | { |
4059 | 834k | if(i4_position == (i4_x + i4_dimension)) |
4060 | 72.5k | { |
4061 | 72.5k | ps_seg_desc->u1_mb_adjoin = 0; |
4062 | 72.5k | } |
4063 | 761k | else |
4064 | 761k | { |
4065 | 761k | ps_seg_desc->u1_mb_adjoin = 1 << i4_shift_val; |
4066 | 761k | } |
4067 | 834k | } |
4068 | 725k | else |
4069 | 725k | { |
4070 | 725k | ps_seg_desc->u1_mb_adjoin = 0; |
4071 | 725k | } |
4072 | | |
4073 | | /* Updations */ |
4074 | 2.39M | u1_offset += u1_seg_dim; |
4075 | 2.39M | u1_num_sgmts++; |
4076 | 2.39M | ps_seg_desc++; |
4077 | 2.39M | } |
4078 | | |
4079 | | /* fill the number of segments for this position */ |
4080 | 870k | ps_segments->u1_num_segments = u1_num_sgmts; |
4081 | 870k | } |
4082 | 72.5k | } |
4083 | | |
4084 | | /*****************************************************************************/ |
4085 | | /* */ |
4086 | | /* Function Name : isvcd_intra_resamp_populate_list */ |
4087 | | /* */ |
4088 | | /* Description : This is a seq or frame level init function which fills */ |
4089 | | /* all offsets, projected locations arrays based on */ |
4090 | | /* the two resolutions and cropping parameters */ |
4091 | | /* Inputs : refer ot doxygen comments below */ |
4092 | | /* Globals : none */ |
4093 | | /* Processing : it projects the locations and computes the values */ |
4094 | | /* */ |
4095 | | /* Outputs : none */ |
4096 | | /* Returns : none */ |
4097 | | /* */ |
4098 | | /* Issues : none */ |
4099 | | /* */ |
4100 | | /* Revision History: */ |
4101 | | /* */ |
4102 | | /* DD MM YYYY Author(s) Changes (Describe the changes made) */ |
4103 | | /* 26 06 2009 vijayakumar creation */ |
4104 | | /* */ |
4105 | | /*****************************************************************************/ |
4106 | | void isvcd_intra_resamp_populate_list(intra_samp_map_ctxt_t *ps_map_ctxt, |
4107 | | res_prms_t *ps_curr_res_prms, res_prms_t *ps_ref_res_prms, |
4108 | | WORD32 i4_chroma_flag, svc_dec_lyr_struct_t *ps_svc_lyr_dec) |
4109 | 68.2k | { |
4110 | | /* --------------------------------------------------------------------- */ |
4111 | | /* Local variables required for finding the mapping between the layers */ |
4112 | | /* --------------------------------------------------------------------- */ |
4113 | 68.2k | UWORD32 i4_shift_x, i4_shift_y, i4_scale_x, i4_scale_y; |
4114 | 68.2k | WORD32 i4_offset_x, i4_offset_y; |
4115 | 68.2k | WORD32 i4_add_x, i4_add_y, i4_delta_x, i4_delta_y, i4_refphase_x, i4_refphase_y; |
4116 | 68.2k | WORD32 i4_phase_x, i4_phase_y, i4_sub_wd, i4_sub_ht, i4_mb_wd, i4_mb_ht; |
4117 | 68.2k | WORD32 i4_horz_dim, i4_vert_dim, i4_tmp; |
4118 | 68.2k | dec_struct_t *ps_dec = &ps_svc_lyr_dec->s_dec; |
4119 | | /* --------------------------------------------------------------------- */ |
4120 | | /* Local Pointer Declaration for arrays in Mapping context */ |
4121 | | /* --------------------------------------------------------------------- */ |
4122 | 68.2k | ref_mb_map_t *ps_x_off_len, *ps_y_off_len; |
4123 | 68.2k | UWORD32 i4_ref_wd, i4_ref_ht, i4_scaled_wd, i4_scaled_ht, i4_curr_lyr_width, i4_curr_lyr_height; |
4124 | | |
4125 | | /* --------------------------------------------------------------------- */ |
4126 | | /* Local Flag Declaration */ |
4127 | | /* --------------------------------------------------------------------- */ |
4128 | 68.2k | WORD32 i4_ref_layer_field_pic_flag, i4_field_pic_flag, i4_frame_mbs_only_flag; |
4129 | 68.2k | WORD32 i4_ref_layer_frame_Mbs_only_flag, i4_field_Mb_flag, i4_bot_field_flag; |
4130 | | |
4131 | | /* --------------------------------------------------------------------- */ |
4132 | | /* Cropping Parameters Declaration */ |
4133 | | /* --------------------------------------------------------------------- */ |
4134 | 68.2k | WORD32 i4_scaled_ref_layer_left_offset, i4_scaled_ref_layer_top_offset; |
4135 | 68.2k | WORD32 i4_scaled_ref_layer_right_offset, i4_scaled_ref_layer_bottom_offset; |
4136 | 68.2k | dec_seq_params_t *ps_sps; |
4137 | 68.2k | dec_svc_seq_params_t *ps_subset_sps; |
4138 | 68.2k | ps_sps = ps_dec->ps_cur_sps; |
4139 | 68.2k | ps_subset_sps = ps_svc_lyr_dec->ps_cur_subset_sps; |
4140 | | |
4141 | | /* --------------------------------------------------------------------- */ |
4142 | | /* Hardcoding flag information (assuming no field support) */ |
4143 | | /* --------------------------------------------------------------------- */ |
4144 | 68.2k | i4_ref_layer_field_pic_flag = SVCD_FALSE; |
4145 | 68.2k | i4_field_pic_flag = SVCD_FALSE; |
4146 | 68.2k | i4_frame_mbs_only_flag = SVCD_TRUE; |
4147 | 68.2k | i4_field_Mb_flag = SVCD_FALSE; |
4148 | 68.2k | i4_bot_field_flag = SVCD_FALSE; |
4149 | 68.2k | i4_ref_layer_frame_Mbs_only_flag = SVCD_TRUE; |
4150 | 68.2k | i4_horz_dim = 0; |
4151 | 68.2k | i4_vert_dim = 0; |
4152 | | |
4153 | | /* --------------------------------------------------------------------- */ |
4154 | | /* Pointer and Paramater are intialized - Chroma and Luma */ |
4155 | | /* --------------------------------------------------------------------- */ |
4156 | 68.2k | { |
4157 | 68.2k | WORD32 i4_base_width; |
4158 | 68.2k | WORD32 i4_base_height; |
4159 | 68.2k | WORD32 i4_ref_layer_chroma_phase_x_plus1_flag; |
4160 | 68.2k | WORD32 i4_ref_layer_chroma_phase_y_plus1; |
4161 | 68.2k | WORD32 i4_chroma_phase_x_plus1_flag; |
4162 | 68.2k | WORD32 i4_chroma_phase_y_plus1; |
4163 | | |
4164 | | /* ------------------------------------------------------------- */ |
4165 | | /* HARD CODED FOR 420 */ |
4166 | | /* ------------------------------------------------------------- */ |
4167 | 68.2k | WORD32 i4_sub_wd_chroma = 2; |
4168 | 68.2k | WORD32 i4_sub_ht_chroma = 2; |
4169 | | |
4170 | 68.2k | i4_base_width = ps_ref_res_prms->i4_res_width; |
4171 | 68.2k | i4_base_height = ps_ref_res_prms->i4_res_height; |
4172 | | |
4173 | 68.2k | i4_ref_layer_chroma_phase_x_plus1_flag = |
4174 | 68.2k | ps_curr_res_prms->i1_ref_lyr_chroma_phase_x_plus1_flag; |
4175 | | |
4176 | 68.2k | i4_ref_layer_chroma_phase_y_plus1 = ps_curr_res_prms->i1_ref_lyr_chroma_phase_y_plus1; |
4177 | 68.2k | i4_chroma_phase_x_plus1_flag = ps_subset_sps->s_sps_svc_ext.u1_chroma_phase_x_plus1_flag; |
4178 | 68.2k | i4_chroma_phase_y_plus1 = ps_subset_sps->s_sps_svc_ext.u1_chroma_phase_y_plus1; |
4179 | 68.2k | i4_scaled_ref_layer_bottom_offset = ps_curr_res_prms->s_ref_lyr_scaled_offset.i2_bot; |
4180 | 68.2k | i4_scaled_ref_layer_left_offset = ps_curr_res_prms->s_ref_lyr_scaled_offset.i2_left; |
4181 | 68.2k | i4_scaled_ref_layer_top_offset = ps_curr_res_prms->s_ref_lyr_scaled_offset.i2_top; |
4182 | 68.2k | i4_scaled_ref_layer_right_offset = ps_curr_res_prms->s_ref_lyr_scaled_offset.i2_rt; |
4183 | | |
4184 | | /* ----------------------------------------------------------------- */ |
4185 | | /* Computing Effective Frame Dimensions */ |
4186 | | /* ------------------------------------------------------------------*/ |
4187 | 68.2k | i4_ref_wd = (i4_base_width >> i4_chroma_flag); |
4188 | 68.2k | i4_ref_ht = (i4_base_height >> i4_chroma_flag) * (1 + i4_ref_layer_field_pic_flag); |
4189 | | |
4190 | 68.2k | i4_scaled_wd = ps_curr_res_prms->u2_scaled_ref_width; |
4191 | 68.2k | i4_scaled_ht = ps_curr_res_prms->u2_scaled_ref_height; |
4192 | 68.2k | i4_scaled_wd = (i4_scaled_wd >> i4_chroma_flag); |
4193 | 68.2k | i4_scaled_ht = (i4_scaled_ht >> i4_chroma_flag) * (1 + i4_field_pic_flag); |
4194 | | |
4195 | 68.2k | if(1 == i4_chroma_flag) |
4196 | 34.1k | { |
4197 | 34.1k | i4_refphase_x = i4_ref_layer_chroma_phase_x_plus1_flag - 1; |
4198 | 34.1k | i4_refphase_y = i4_ref_layer_chroma_phase_y_plus1 - 1; |
4199 | 34.1k | i4_phase_x = i4_chroma_phase_x_plus1_flag - 1; |
4200 | 34.1k | i4_phase_y = i4_chroma_phase_y_plus1 - 1; |
4201 | 34.1k | i4_sub_wd = i4_sub_wd_chroma; |
4202 | 34.1k | i4_sub_ht = i4_sub_ht_chroma; |
4203 | 34.1k | i4_mb_wd = MB_WIDTH >> 1; |
4204 | 34.1k | i4_mb_ht = MB_HEIGHT >> 1; |
4205 | 34.1k | } |
4206 | 34.1k | else |
4207 | 34.1k | { |
4208 | 34.1k | i4_refphase_x = 0; |
4209 | 34.1k | i4_refphase_y = 0; |
4210 | 34.1k | i4_phase_x = 0; |
4211 | 34.1k | i4_phase_y = 0; |
4212 | 34.1k | i4_sub_wd = 1; |
4213 | 34.1k | i4_sub_ht = 1; |
4214 | 34.1k | i4_mb_wd = MB_WIDTH; |
4215 | 34.1k | i4_mb_ht = MB_HEIGHT; |
4216 | 34.1k | } |
4217 | 68.2k | } |
4218 | | |
4219 | | /* --------------------------------------------------------------------- */ |
4220 | | /* Derive shift x and y based on level idd */ |
4221 | | /* --------------------------------------------------------------------- */ |
4222 | 68.2k | if(ps_sps->u1_level_idc <= 30) |
4223 | 64.3k | { |
4224 | 64.3k | i4_shift_x = 16; |
4225 | 64.3k | i4_shift_y = 16; |
4226 | 64.3k | } |
4227 | 3.92k | else |
4228 | 3.92k | { |
4229 | 3.92k | i4_shift_x = 31 - isvcd_get_ceil_log2(i4_ref_wd); |
4230 | 3.92k | i4_shift_y = 31 - isvcd_get_ceil_log2(i4_ref_ht); |
4231 | 3.92k | } |
4232 | | |
4233 | | /* --------------------------------------------------------------------- */ |
4234 | | /* The following condition is not true in our case for time being */ |
4235 | | /* --------------------------------------------------------------------- */ |
4236 | 68.2k | if((SVCD_FALSE == i4_frame_mbs_only_flag) || (SVCD_FALSE == i4_ref_layer_frame_Mbs_only_flag)) |
4237 | 0 | { |
4238 | 0 | i4_phase_y = i4_phase_y + 4 * i4_bot_field_flag; |
4239 | |
|
4240 | 0 | if(1 == i4_ref_layer_frame_Mbs_only_flag) |
4241 | 0 | i4_refphase_y = (2 * i4_refphase_y) + 2; |
4242 | 0 | else |
4243 | 0 | i4_refphase_y = i4_refphase_y + (4 * i4_bot_field_flag); |
4244 | 0 | } |
4245 | | |
4246 | | /* --------------------------------------------------------------------- */ |
4247 | | /* Dx and Dy Computation - Ratio of the base and enhance layer width */ |
4248 | | /* --------------------------------------------------------------------- */ |
4249 | 68.2k | i4_scale_x = ((i4_ref_wd << i4_shift_x) + (i4_scaled_wd >> 1)) / (i4_scaled_wd); |
4250 | 68.2k | i4_scale_y = ((i4_ref_ht << i4_shift_y) + (i4_scaled_ht >> 1)) / (i4_scaled_ht); |
4251 | | |
4252 | 68.2k | i4_offset_x = i4_scaled_ref_layer_left_offset / i4_sub_wd; |
4253 | 68.2k | i4_add_x = (((i4_ref_wd * (2 + i4_phase_x)) << (i4_shift_x - 2)) + (i4_scaled_wd >> 1)) / |
4254 | 68.2k | i4_scaled_wd + |
4255 | 68.2k | (1 << (i4_shift_x - 5)); |
4256 | 68.2k | i4_delta_x = 4 * (2 + i4_refphase_x); |
4257 | | |
4258 | 68.2k | if((SVCD_TRUE == i4_frame_mbs_only_flag) && (SVCD_TRUE == i4_ref_layer_frame_Mbs_only_flag)) |
4259 | 68.2k | { |
4260 | 68.2k | i4_offset_y = i4_scaled_ref_layer_top_offset / i4_sub_ht; |
4261 | 68.2k | i4_add_y = (((i4_ref_ht * (2 + i4_phase_y)) << (i4_shift_y - 2)) + (i4_scaled_ht >> 1)) / |
4262 | 68.2k | i4_scaled_ht + |
4263 | 68.2k | (1 << (i4_shift_y - 5)); |
4264 | 68.2k | i4_delta_y = 4 * (2 + i4_refphase_y); |
4265 | 68.2k | } |
4266 | 0 | else |
4267 | 0 | { |
4268 | 0 | i4_offset_y = i4_scaled_ref_layer_top_offset / (2 * i4_sub_ht); |
4269 | 0 | i4_add_y = (((i4_ref_ht * (2 + i4_phase_y)) << (i4_shift_y - 3)) + (i4_scaled_ht >> 1)) / |
4270 | 0 | i4_scaled_ht + |
4271 | 0 | (1 << (i4_shift_y - 5)); |
4272 | 0 | i4_delta_y = 2 * (2 + i4_refphase_y); |
4273 | 0 | } |
4274 | | |
4275 | | /* --------------------------------------------------------------------- */ |
4276 | | /* Intializing Local Pointers - Chroma and Luma */ |
4277 | | /* --------------------------------------------------------------------- */ |
4278 | 68.2k | ps_x_off_len = ps_map_ctxt->ps_x_offset_length; |
4279 | 68.2k | ps_y_off_len = ps_map_ctxt->ps_y_offset_length; |
4280 | 68.2k | i4_curr_lyr_width = ps_curr_res_prms->i4_res_width >> i4_chroma_flag; |
4281 | 68.2k | i4_curr_lyr_height = ps_curr_res_prms->i4_res_height >> i4_chroma_flag; |
4282 | | |
4283 | | /* --------------------------------------------------------------------- */ |
4284 | | /* Dyadic Scaling Ratios Handling */ |
4285 | | /* --------------------------------------------------------------------- */ |
4286 | 68.2k | if(1 == ps_curr_res_prms->u1_dyadic_flag) |
4287 | 32.0k | { |
4288 | 32.0k | WORD32 i4_refarray_wd, i4_x_offset; |
4289 | 32.0k | WORD32 i4_refarray_ht, i4_y_offset; |
4290 | 32.0k | WORD32 i4_crp_wd_lt, i4_crp_ht_top; |
4291 | 32.0k | WORD32 i4_crp_wd_rt, i4_crp_ht_bot; |
4292 | 32.0k | WORD32 i4_ref_lyr_wd, i4_ref_lyr_ht; |
4293 | 32.0k | WORD32 i4_ref_x, i4_ref_y; |
4294 | 32.0k | WORD32 i4_ofst; |
4295 | 32.0k | WORD32 i4_i, i4_j; |
4296 | | |
4297 | | /* Hard coded for dyadic case */ |
4298 | 32.0k | i4_refarray_wd = 20 >> i4_chroma_flag; |
4299 | 32.0k | i4_ofst = -2 >> i4_chroma_flag; |
4300 | 32.0k | i4_crp_wd_lt = i4_scaled_ref_layer_left_offset >> i4_chroma_flag; |
4301 | 32.0k | i4_crp_wd_rt = i4_scaled_ref_layer_right_offset >> i4_chroma_flag; |
4302 | 32.0k | i4_ref_lyr_wd = (i4_curr_lyr_width >> 1); |
4303 | | |
4304 | 32.0k | i4_ref_x = 0; |
4305 | 96.2k | for(i4_i = 0; i4_i < (WORD32) i4_curr_lyr_width; i4_i += (i4_mb_wd << 1)) |
4306 | 64.2k | { |
4307 | 64.2k | i4_x_offset = MAX(i4_ofst, (i4_ref_x + i4_ofst)); |
4308 | 64.2k | i4_x_offset = MIN(i4_x_offset, (i4_ref_lyr_wd - i4_ofst)); |
4309 | 64.2k | ps_x_off_len->i2_offset = i4_x_offset; |
4310 | 64.2k | ps_x_off_len->i2_length = i4_refarray_wd; |
4311 | 64.2k | ps_x_off_len++; |
4312 | 64.2k | ps_x_off_len->i2_offset = i4_x_offset; |
4313 | 64.2k | ps_x_off_len->i2_length = i4_refarray_wd; |
4314 | 64.2k | ps_x_off_len++; |
4315 | 64.2k | if(i4_i >= i4_crp_wd_lt) |
4316 | 64.2k | { |
4317 | 64.2k | if(i4_i <= (WORD32) (i4_curr_lyr_width - i4_crp_wd_rt)) |
4318 | 64.2k | { |
4319 | 64.2k | i4_ref_x += i4_mb_wd; |
4320 | 64.2k | } |
4321 | 64.2k | } |
4322 | 64.2k | } |
4323 | | |
4324 | 32.0k | i4_refarray_ht = 20 >> i4_chroma_flag; |
4325 | 32.0k | i4_crp_ht_top = i4_scaled_ref_layer_top_offset >> i4_chroma_flag; |
4326 | 32.0k | i4_crp_ht_bot = i4_scaled_ref_layer_bottom_offset >> i4_chroma_flag; |
4327 | 32.0k | i4_ref_lyr_ht = (i4_curr_lyr_height >> 1); |
4328 | | |
4329 | 32.0k | i4_ref_y = 0; |
4330 | 183k | for(i4_j = 0; i4_j < (WORD32) i4_curr_lyr_height; i4_j += (i4_mb_ht << 1)) |
4331 | 151k | { |
4332 | 151k | i4_y_offset = MAX(i4_ofst, (i4_ref_y + i4_ofst)); |
4333 | 151k | i4_y_offset = MIN(i4_y_offset, (i4_ref_lyr_ht - i4_ofst)); |
4334 | 151k | ps_y_off_len->i2_offset = i4_y_offset; |
4335 | 151k | ps_y_off_len->i2_length = i4_refarray_ht; |
4336 | 151k | ps_y_off_len++; |
4337 | 151k | ps_y_off_len->i2_offset = i4_y_offset; |
4338 | 151k | ps_y_off_len->i2_length = i4_refarray_ht; |
4339 | 151k | ps_y_off_len++; |
4340 | 151k | if(i4_j >= i4_crp_ht_top) |
4341 | 151k | { |
4342 | 151k | if(i4_j <= (WORD32) (i4_curr_lyr_height - i4_crp_ht_bot)) |
4343 | 151k | { |
4344 | 151k | i4_ref_y += i4_mb_ht; |
4345 | 151k | } |
4346 | 151k | } |
4347 | 151k | } |
4348 | | /* No need to process further, return */ |
4349 | 32.0k | return; |
4350 | 32.0k | } /* If dyadic path */ |
4351 | | |
4352 | | /* Proposed Algo for Optimization */ |
4353 | 36.2k | { |
4354 | 36.2k | WORD32 i4_max, i4_min; |
4355 | 36.2k | ref_min_max_map_t *ps_x_min_max; |
4356 | 36.2k | ref_min_max_map_t *ps_y_min_max; |
4357 | 36.2k | WORD32 i4_i, i4_j; |
4358 | | |
4359 | 36.2k | ps_x_min_max = ps_map_ctxt->ps_x_min_max; |
4360 | 36.2k | ps_y_min_max = ps_map_ctxt->ps_y_min_max; |
4361 | | /* ----------------------------------------------------------------- */ |
4362 | | /* Computation of offsetX refArrayW Xmin and Xmax Lists */ |
4363 | | /* ----------------------------------------------------------------- */ |
4364 | 145k | for(i4_i = 0; i4_i < (WORD32) i4_curr_lyr_width; i4_i = i4_i + i4_mb_wd) |
4365 | 108k | { |
4366 | 108k | WORD32 i4_refarray_wd, i4_xr_index; |
4367 | 108k | WORD32 i4_x_refmin16; |
4368 | 108k | WORD32 i4_x_refmax16; |
4369 | 108k | WORD32 i4_x_offset; |
4370 | | |
4371 | 108k | i4_x_refmin16 = (WORD64) (((WORD64) (i4_i - i4_offset_x) * i4_scale_x + i4_add_x) >> |
4372 | 108k | ((WORD32) (i4_shift_x - 4))) - |
4373 | 108k | i4_delta_x; |
4374 | | |
4375 | 108k | i4_x_refmax16 = |
4376 | 108k | (WORD64) (((WORD64) (i4_i + i4_mb_wd - 1 - i4_offset_x) * i4_scale_x + i4_add_x) >> |
4377 | 108k | ((WORD32) (i4_shift_x - 4))) - |
4378 | 108k | i4_delta_x; |
4379 | | |
4380 | | /* ------------------------------------------------------------- */ |
4381 | | /* Modified AC205 */ |
4382 | | /* Minimum width required - So adding 2 pixels on each side */ |
4383 | | /* ------------------------------------------------------------- */ |
4384 | 108k | i4_refarray_wd = ((i4_x_refmax16 + 15) >> 4) - (i4_x_refmin16 >> 4) + 1 + 4; |
4385 | | |
4386 | | /* ------------------------------------------------------------- */ |
4387 | | /* Setting the offset 2 pixels before */ |
4388 | | /* ------------------------------------------------------------- */ |
4389 | 108k | i4_x_offset = (i4_x_refmin16 >> 4) - 2; |
4390 | | |
4391 | | /* ------------------------------------------------------------- */ |
4392 | | /* Modifying the values based on the location */ |
4393 | | /* ------------------------------------------------------------- */ |
4394 | 108k | i4_min = i4_x_offset; |
4395 | 108k | i4_xr_index = i4_min - ((i4_min / i4_mb_wd) * i4_mb_wd); |
4396 | | |
4397 | 108k | if(i4_xr_index < (i4_mb_wd >> 1)) |
4398 | 90.6k | { |
4399 | 90.6k | i4_refarray_wd = i4_refarray_wd + (i4_mb_wd >> 1); |
4400 | 90.6k | i4_x_offset = i4_x_offset - (i4_mb_wd >> 1); |
4401 | 90.6k | } |
4402 | | |
4403 | 108k | i4_max = ((i4_x_refmax16 + 15) >> 4) + 2; |
4404 | 108k | i4_xr_index = i4_max - ((i4_max / i4_mb_wd) * i4_mb_wd); |
4405 | | |
4406 | 108k | if(i4_xr_index >= (i4_mb_wd >> 1)) i4_refarray_wd = i4_refarray_wd + (i4_mb_wd >> 1); |
4407 | | |
4408 | | /* ------------------------------------------------------------- */ |
4409 | | /* Filling the arrays with offset, min, max and refArray dim */ |
4410 | | /* ------------------------------------------------------------- */ |
4411 | 108k | ps_x_off_len->i2_offset = i4_x_offset; |
4412 | 108k | ps_x_off_len->i2_length = i4_refarray_wd; |
4413 | | |
4414 | 108k | ps_x_min_max->i2_min_pos = (i4_x_refmin16 >> 4) - i4_x_offset; |
4415 | 108k | ps_x_min_max->i2_max_pos = ((i4_x_refmax16 + 15) >> 4) - i4_x_offset; |
4416 | | |
4417 | 108k | i4_tmp = (WORD32) (ps_x_min_max->i2_max_pos - ps_x_min_max->i2_min_pos) + |
4418 | 108k | (4 >> i4_chroma_flag); |
4419 | 108k | if(i4_tmp > i4_horz_dim) |
4420 | 36.5k | { |
4421 | 36.5k | i4_horz_dim = i4_tmp; |
4422 | 36.5k | } |
4423 | | |
4424 | | /* increment the pointer */ |
4425 | 108k | ps_x_off_len++; |
4426 | 108k | ps_x_min_max++; |
4427 | 108k | } /* end of loop over scaled width */ |
4428 | | |
4429 | | /* ----------------------------------------------------------------- */ |
4430 | | /* Computation of offsetY refArrayH Ymin and Ymax Lists */ |
4431 | | /* ----------------------------------------------------------------- */ |
4432 | 362k | for(i4_j = 0; i4_j < (WORD32) i4_curr_lyr_height; i4_j = i4_j + i4_mb_ht) |
4433 | 325k | { |
4434 | 325k | WORD32 i4_refarray_ht, i4_yr_index; |
4435 | 325k | WORD32 i4_y_refmin16; |
4436 | 325k | WORD32 i4_y_refmax16; |
4437 | 325k | WORD32 i4_y_offset; |
4438 | | |
4439 | 325k | i4_y_refmin16 = (WORD64) (((WORD64) (i4_j - i4_offset_y) * i4_scale_y + i4_add_y) >> |
4440 | 325k | ((WORD32) (i4_shift_y - 4))) - |
4441 | 325k | i4_delta_y; |
4442 | | |
4443 | 325k | i4_y_refmax16 = |
4444 | 325k | (WORD64) (((WORD64) (i4_j + i4_mb_ht - 1 - i4_offset_y) * i4_scale_y + i4_add_y) >> |
4445 | 325k | ((WORD32) (i4_shift_y - 4))) - |
4446 | 325k | i4_delta_y; |
4447 | | |
4448 | | /* ------------------------------------------------------------- */ |
4449 | | /* Modified AC205 */ |
4450 | | /* Minimum width required - So adding 2 pixels on each side */ |
4451 | | /* ------------------------------------------------------------- */ |
4452 | 325k | i4_refarray_ht = ((i4_y_refmax16 + 15) >> 4) - (i4_y_refmin16 >> 4) + 1 + 4; |
4453 | | |
4454 | | /* ------------------------------------------------------------- */ |
4455 | | /* Setting the offset 2 pixels before */ |
4456 | | /* ------------------------------------------------------------- */ |
4457 | 325k | i4_y_offset = (i4_y_refmin16 >> 4) - 2; |
4458 | | |
4459 | | /* ------------------------------------------------------------- */ |
4460 | | /* Modifying the values based on the location */ |
4461 | | /* ------------------------------------------------------------- */ |
4462 | 325k | i4_min = i4_y_offset; |
4463 | 325k | i4_yr_index = i4_min - ((i4_min / i4_mb_ht) * i4_mb_ht); |
4464 | 325k | if(i4_yr_index < (i4_mb_ht >> 1)) |
4465 | 199k | { |
4466 | 199k | i4_refarray_ht = i4_refarray_ht + (i4_mb_ht >> 1); |
4467 | 199k | i4_y_offset = i4_y_offset - (i4_mb_ht >> 1); |
4468 | 199k | } |
4469 | | |
4470 | 325k | i4_max = ((i4_y_refmax16 + 15) >> 4) + 2; |
4471 | 325k | i4_yr_index = i4_max - ((i4_max / i4_mb_ht) * i4_mb_ht); |
4472 | 325k | if(i4_yr_index >= (i4_mb_ht >> 1)) i4_refarray_ht = i4_refarray_ht + (i4_mb_ht >> 1); |
4473 | | |
4474 | | /* ------------------------------------------------------------- */ |
4475 | | /* Filling the arrays with offset, min, max and refArray dim */ |
4476 | | /* ------------------------------------------------------------- */ |
4477 | 325k | ps_y_off_len->i2_offset = i4_y_offset; |
4478 | 325k | ps_y_off_len->i2_length = i4_refarray_ht; |
4479 | 325k | ps_y_min_max->i2_min_pos = (i4_y_refmin16 >> 4) - i4_y_offset; |
4480 | 325k | ps_y_min_max->i2_max_pos = ((i4_y_refmax16 + 15) >> 4) - i4_y_offset; |
4481 | | |
4482 | 325k | i4_tmp = (WORD32) (ps_y_min_max->i2_max_pos - ps_y_min_max->i2_min_pos) + |
4483 | 325k | (4 >> i4_chroma_flag); |
4484 | 325k | if(i4_tmp > i4_vert_dim) |
4485 | 36.5k | { |
4486 | 36.5k | i4_vert_dim = i4_tmp; |
4487 | 36.5k | } |
4488 | | |
4489 | | /* increment the pointer */ |
4490 | 325k | ps_y_off_len++; |
4491 | 325k | ps_y_min_max++; |
4492 | 325k | } /* end of loop over scaled height */ |
4493 | 36.2k | } |
4494 | | |
4495 | | /* --------------------------------------------------------------------- */ |
4496 | | /* Computation of Xref and Xphase List as per standard */ |
4497 | | /* --------------------------------------------------------------------- */ |
4498 | 36.2k | ps_x_off_len = ps_map_ctxt->ps_x_offset_length; |
4499 | 36.2k | ps_y_off_len = ps_map_ctxt->ps_y_offset_length; |
4500 | | |
4501 | 36.2k | { |
4502 | 36.2k | ref_pixel_map_t *ps_x_pos_phase; |
4503 | 36.2k | WORD32 i4_xc; |
4504 | 36.2k | WORD32 i4_offset_x_index; |
4505 | | |
4506 | 36.2k | ps_x_pos_phase = ps_map_ctxt->ps_x_pos_phase; |
4507 | | |
4508 | 1.34M | for(i4_xc = 0; i4_xc < (WORD32) i4_curr_lyr_width; i4_xc++) |
4509 | 1.30M | { |
4510 | 1.30M | WORD32 i4_x_offset; |
4511 | 1.30M | WORD32 i4_x_ref16; |
4512 | | |
4513 | 1.30M | i4_offset_x_index = i4_xc / i4_mb_wd; |
4514 | | |
4515 | 1.30M | i4_x_offset = ps_x_off_len[i4_offset_x_index].i2_offset; |
4516 | | |
4517 | 1.30M | i4_x_ref16 = (WORD64) (((WORD64) (i4_xc - i4_offset_x) * i4_scale_x + i4_add_x) >> |
4518 | 1.30M | ((WORD32) (i4_shift_x - 4))) - |
4519 | 1.30M | i4_delta_x; |
4520 | | |
4521 | | /* store the values */ |
4522 | 1.30M | ps_x_pos_phase->i2_ref_pos = (i4_x_ref16 >> 4) - i4_x_offset; |
4523 | 1.30M | ps_x_pos_phase->i2_phase = i4_x_ref16 & 15; |
4524 | | |
4525 | | /* increment the pointer */ |
4526 | 1.30M | ps_x_pos_phase++; |
4527 | | |
4528 | 1.30M | } /* end of loop over scaled width */ |
4529 | 36.2k | } |
4530 | | |
4531 | | /* --------------------------------------------------------------------- */ |
4532 | | /* Computation of Yref and Yphase List as per standard */ |
4533 | | /* --------------------------------------------------------------------- */ |
4534 | 36.2k | { |
4535 | 36.2k | WORD32 i4_yc; |
4536 | 36.2k | ref_pixel_map_t *ps_y_pos_phase; |
4537 | | |
4538 | 36.2k | ps_y_pos_phase = ps_map_ctxt->ps_y_pos_phase; |
4539 | | |
4540 | 3.94M | for(i4_yc = 0; i4_yc < (WORD32) i4_curr_lyr_height; i4_yc++) |
4541 | 3.90M | { |
4542 | 3.90M | WORD32 i4_y_offset; |
4543 | 3.90M | WORD32 i4_y_ref16; |
4544 | 3.90M | WORD32 i4_offset_y_index; |
4545 | | |
4546 | 3.90M | i4_offset_y_index = i4_yc / i4_mb_ht; |
4547 | | |
4548 | 3.90M | i4_y_offset = ps_y_off_len[i4_offset_y_index].i2_offset; |
4549 | | |
4550 | 3.90M | if((SVCD_FALSE == i4_frame_mbs_only_flag) || |
4551 | 3.90M | (SVCD_FALSE == i4_ref_layer_frame_Mbs_only_flag)) |
4552 | 0 | { |
4553 | 0 | i4_yc = i4_yc >> (1 - i4_field_Mb_flag); |
4554 | 0 | } |
4555 | | |
4556 | 3.90M | i4_y_ref16 = (WORD64) (((WORD64) (i4_yc - i4_offset_y) * i4_scale_y + i4_add_y) >> |
4557 | 3.90M | ((WORD32) (i4_shift_y - 4))) - |
4558 | 3.90M | i4_delta_y; |
4559 | 3.90M | ps_y_pos_phase->i2_ref_pos = (i4_y_ref16 >> 4) - i4_y_offset; |
4560 | 3.90M | ps_y_pos_phase->i2_phase = i4_y_ref16 & 15; |
4561 | | |
4562 | | /* increment the pointer */ |
4563 | 3.90M | ps_y_pos_phase++; |
4564 | | |
4565 | 3.90M | } /* end of loop over scaled height */ |
4566 | 36.2k | } |
4567 | | |
4568 | | /* --------------------------------------------------------------------- */ |
4569 | | /* Computation of Corresponding Diagonal Location */ |
4570 | | /* --------------------------------------------------------------------- */ |
4571 | 36.2k | { |
4572 | 36.2k | WORD16 *pi2_xd_index; |
4573 | 36.2k | WORD16 *pi2_yd_index; |
4574 | 36.2k | WORD16 *pi2_ya_index; |
4575 | 36.2k | WORD32 i4_i, i4_j; |
4576 | | |
4577 | 36.2k | pi2_xd_index = ps_map_ctxt->pi2_xd_index; |
4578 | 36.2k | pi2_yd_index = ps_map_ctxt->pi2_yd_index; |
4579 | 36.2k | pi2_ya_index = ps_map_ctxt->pi2_ya_index; |
4580 | | |
4581 | 471k | for(i4_i = 0; i4_i < i4_mb_wd; i4_i++) |
4582 | 435k | { |
4583 | 435k | *(pi2_xd_index + i4_i) = ((i4_i >= i4_mb_wd >> 1) ? (i4_i - i4_mb_wd) : (i4_i + 1)); |
4584 | | |
4585 | 435k | } /* end of loop over MB width */ |
4586 | | |
4587 | 471k | for(i4_j = 0; i4_j < i4_mb_ht; i4_j++) |
4588 | 435k | { |
4589 | 435k | *(pi2_yd_index + i4_j) = ((i4_j >= i4_mb_ht >> 1) ? (i4_j - i4_mb_ht) : (i4_j + 1)); |
4590 | | |
4591 | 435k | *(pi2_ya_index + i4_j) = |
4592 | 435k | *(pi2_yd_index + i4_j) - (((i4_mb_ht >> 1) + 1) * (SIGN(*(pi2_yd_index + i4_j)))); |
4593 | | |
4594 | 435k | } /* end of loop over MB height */ |
4595 | 36.2k | } |
4596 | | |
4597 | | /* generate the lookup to generate horizontal segments */ |
4598 | 36.2k | isvcd_intra_resamp_generate_segment_lookup(ps_map_ctxt->ps_seg_lookup_horz, i4_horz_dim, |
4599 | 36.2k | i4_mb_wd, 3); |
4600 | | |
4601 | | /* generate the lookup to generate vertical segments */ |
4602 | 36.2k | isvcd_intra_resamp_generate_segment_lookup(ps_map_ctxt->ps_seg_lookup_vert, i4_vert_dim, |
4603 | 36.2k | i4_mb_ht, 4); |
4604 | | |
4605 | 36.2k | return; |
4606 | 68.2k | } /* end of function "isvcd_intra_resamp_populate_list"*/ |
4607 | | |
4608 | | /*****************************************************************************/ |
4609 | | /* */ |
4610 | | /* Function Name : isvcd_populate_res_prms */ |
4611 | | /* */ |
4612 | | /* Description :this function populates the current layer params */ |
4613 | | /* from the base layer and decoder context */ |
4614 | | /* Inputs : */ |
4615 | | /* Globals : none */ |
4616 | | /* Processing : */ |
4617 | | /* */ |
4618 | | /* Outputs : none */ |
4619 | | /* Returns : none */ |
4620 | | /* */ |
4621 | | /* Issues : none */ |
4622 | | /* */ |
4623 | | /* Revision History: */ |
4624 | | /* */ |
4625 | | /* DD MM YYYY Author(s) Changes (Describe the changes made) */ |
4626 | | /* 25 11 2021 Kishore creation */ |
4627 | | /* */ |
4628 | | /*****************************************************************************/ |
4629 | | |
4630 | | WORD32 isvcd_populate_res_prms(void *pv_svc_dec) |
4631 | 135k | { |
4632 | 135k | svc_dec_lyr_struct_t *ps_svc_lyr_dec = (svc_dec_lyr_struct_t *) pv_svc_dec; |
4633 | 135k | dec_struct_t *ps_dec = &ps_svc_lyr_dec->s_dec; |
4634 | 135k | res_prms_t *ps_curr_lyr_res_prms; |
4635 | 135k | svc_dec_lyr_struct_t *ps_svc_ref_lyr_dec; |
4636 | 135k | ps_svc_ref_lyr_dec = ps_svc_lyr_dec->ps_dec_svc_ref_layer; |
4637 | 135k | ps_curr_lyr_res_prms = &ps_svc_lyr_dec->s_res_prms; |
4638 | | |
4639 | 135k | ps_curr_lyr_res_prms->i4_res_width = ps_dec->u2_pic_wd; |
4640 | 135k | ps_curr_lyr_res_prms->i4_res_height = ps_dec->u2_pic_ht; |
4641 | 135k | ps_curr_lyr_res_prms->s_ref_lyr_scaled_offset.i2_left = |
4642 | 135k | ps_svc_lyr_dec->ps_cur_subset_sps->s_sps_svc_ext.i4_seq_scaled_ref_layer_left_offset << 1; |
4643 | 135k | ps_curr_lyr_res_prms->s_ref_lyr_scaled_offset.i2_top = |
4644 | 135k | ps_svc_lyr_dec->ps_cur_subset_sps->s_sps_svc_ext.i4_seq_scaled_ref_layer_top_offset << 1; |
4645 | 135k | ps_curr_lyr_res_prms->s_ref_lyr_scaled_offset.i2_rt = |
4646 | 135k | ps_svc_lyr_dec->ps_cur_subset_sps->s_sps_svc_ext.i4_seq_scaled_ref_layer_right_offset << 1; |
4647 | 135k | ps_curr_lyr_res_prms->s_ref_lyr_scaled_offset.i2_bot = |
4648 | 135k | ps_svc_lyr_dec->ps_cur_subset_sps->s_sps_svc_ext.i4_seq_scaled_ref_layer_bottom_offset << 1; |
4649 | 135k | ps_curr_lyr_res_prms->u2_scaled_ref_width = |
4650 | 135k | (ps_dec->u2_frm_wd_in_mbs << 4) - (ps_curr_lyr_res_prms->s_ref_lyr_scaled_offset.i2_left + |
4651 | 135k | ps_curr_lyr_res_prms->s_ref_lyr_scaled_offset.i2_rt); |
4652 | | |
4653 | 135k | ps_curr_lyr_res_prms->u2_scaled_ref_height = |
4654 | 135k | (ps_dec->u2_frm_ht_in_mbs << 4) - (ps_curr_lyr_res_prms->s_ref_lyr_scaled_offset.i2_top + |
4655 | 135k | ps_curr_lyr_res_prms->s_ref_lyr_scaled_offset.i2_bot); |
4656 | | |
4657 | 135k | ps_curr_lyr_res_prms->u1_cropping_change_flag = 0; |
4658 | 135k | if(2 == ps_svc_lyr_dec->ps_cur_subset_sps->s_sps_svc_ext.u1_extended_spatial_scalability_idc) |
4659 | 69 | { |
4660 | 69 | ps_curr_lyr_res_prms->u1_cropping_change_flag = 1; |
4661 | | |
4662 | 69 | ps_curr_lyr_res_prms->s_ref_lyr_scaled_offset.i2_left = |
4663 | 69 | ps_svc_lyr_dec->s_svc_slice_params.i4_scaled_ref_layer_left_offset << 1; |
4664 | | |
4665 | 69 | ps_curr_lyr_res_prms->s_ref_lyr_scaled_offset.i2_top = |
4666 | 69 | ps_svc_lyr_dec->s_svc_slice_params.i4_scaled_ref_layer_top_offset << 1; |
4667 | 69 | ps_curr_lyr_res_prms->s_ref_lyr_scaled_offset.i2_rt = |
4668 | 69 | ps_svc_lyr_dec->s_svc_slice_params.i4_scaled_ref_layer_right_offset << 1; |
4669 | 69 | ps_curr_lyr_res_prms->s_ref_lyr_scaled_offset.i2_bot = |
4670 | 69 | ps_svc_lyr_dec->s_svc_slice_params.i4_scaled_ref_layer_bottom_offset << 1; |
4671 | 69 | ps_curr_lyr_res_prms->u2_scaled_ref_width = |
4672 | 69 | (ps_dec->u2_frm_wd_in_mbs << 4) - |
4673 | 69 | (ps_curr_lyr_res_prms->s_ref_lyr_scaled_offset.i2_left + |
4674 | 69 | ps_curr_lyr_res_prms->s_ref_lyr_scaled_offset.i2_rt); |
4675 | | |
4676 | 69 | ps_curr_lyr_res_prms->u2_scaled_ref_height = |
4677 | 69 | (ps_dec->u2_frm_ht_in_mbs << 4) - |
4678 | 69 | (ps_curr_lyr_res_prms->s_ref_lyr_scaled_offset.i2_top + |
4679 | 69 | ps_curr_lyr_res_prms->s_ref_lyr_scaled_offset.i2_bot); |
4680 | | |
4681 | 69 | return NOT_OK; |
4682 | 69 | } |
4683 | | |
4684 | 135k | ps_curr_lyr_res_prms->u1_rstrct_res_change_flag = SVCD_TRUE; |
4685 | | |
4686 | 135k | ps_curr_lyr_res_prms->u1_disable_inter_lyr_dblk_filter_idc = |
4687 | 135k | ps_svc_lyr_dec->s_svc_slice_params.u4_disable_inter_layer_deblk_filter_idc; |
4688 | 135k | ps_curr_lyr_res_prms->i1_inter_lyr_alpha_c0_offset = |
4689 | 135k | ps_svc_lyr_dec->s_svc_slice_params.i4_inter_layer_slice_alpha_c0_offset_div2; |
4690 | 135k | ps_curr_lyr_res_prms->i1_inter_lyr_beta_offset = |
4691 | 135k | ps_svc_lyr_dec->s_svc_slice_params.i4_inter_layer_slice_beta_offset_div2; |
4692 | 135k | ps_curr_lyr_res_prms->i1_constrained_intra_rsmpl_flag = |
4693 | 135k | ps_svc_lyr_dec->s_svc_slice_params.u1_constrained_intra_resampling_flag; |
4694 | 135k | ps_curr_lyr_res_prms->i1_ref_lyr_chroma_phase_x_plus1_flag = |
4695 | 135k | ps_svc_lyr_dec->ps_cur_subset_sps->s_sps_svc_ext.u1_seq_ref_layer_chroma_phase_x_plus1_flag; |
4696 | 135k | ps_curr_lyr_res_prms->i1_ref_lyr_chroma_phase_y_plus1 = |
4697 | 135k | ps_svc_lyr_dec->ps_cur_subset_sps->s_sps_svc_ext.u1_seq_ref_layer_chroma_phase_y_plus1; |
4698 | 135k | ps_curr_lyr_res_prms->u1_direct_8x8_inference_flag = |
4699 | 135k | ps_dec->ps_cur_sps->u1_direct_8x8_inference_flag; |
4700 | | |
4701 | 135k | ps_curr_lyr_res_prms->u1_remap_req_flag = 1; |
4702 | 135k | ps_curr_lyr_res_prms->u1_dyadic_flag = ps_svc_lyr_dec->u1_dyadic_flag; |
4703 | | |
4704 | | /* Derive the reference layer width and height */ |
4705 | | |
4706 | 135k | if(SVCD_TRUE != ps_svc_lyr_dec->u1_base_res_flag) |
4707 | 34.5k | { |
4708 | 34.5k | WORD32 i4_ref_lyr_width; |
4709 | 34.5k | WORD32 i4_ref_lyr_ht; |
4710 | 34.5k | WORD32 i4_dyadic_flag = SVCD_FALSE; |
4711 | 34.5k | i4_ref_lyr_width = ps_svc_ref_lyr_dec->s_res_prms.i4_res_width; |
4712 | 34.5k | i4_ref_lyr_ht = ps_svc_ref_lyr_dec->s_res_prms.i4_res_height; |
4713 | | |
4714 | | /* set the Restricted Spatial Resolution change flag */ |
4715 | 34.5k | ps_curr_lyr_res_prms->u1_rstrct_res_change_flag = SVCD_TRUE; |
4716 | | |
4717 | 34.5k | if(0 == ((ps_curr_lyr_res_prms->u2_scaled_ref_width == i4_ref_lyr_width) || |
4718 | 34.4k | (ps_curr_lyr_res_prms->u2_scaled_ref_width == (i4_ref_lyr_width << 1)))) |
4719 | 18.3k | { |
4720 | 18.3k | ps_curr_lyr_res_prms->u1_rstrct_res_change_flag = SVCD_FALSE; |
4721 | 18.3k | } |
4722 | | |
4723 | 34.5k | if(0 == ((ps_curr_lyr_res_prms->u2_scaled_ref_height == i4_ref_lyr_ht) || |
4724 | 34.3k | (ps_curr_lyr_res_prms->u2_scaled_ref_height == (i4_ref_lyr_ht << 1)))) |
4725 | 18.3k | { |
4726 | 18.3k | ps_curr_lyr_res_prms->u1_rstrct_res_change_flag = SVCD_FALSE; |
4727 | 18.3k | } |
4728 | | |
4729 | 34.5k | if(0 != (ps_curr_lyr_res_prms->s_ref_lyr_scaled_offset.i2_left & 15)) |
4730 | 0 | { |
4731 | 0 | ps_curr_lyr_res_prms->u1_rstrct_res_change_flag = SVCD_FALSE; |
4732 | 0 | } |
4733 | | |
4734 | 34.5k | if(0 != (ps_curr_lyr_res_prms->s_ref_lyr_scaled_offset.i2_top & 15)) |
4735 | 0 | { |
4736 | 0 | ps_curr_lyr_res_prms->u1_rstrct_res_change_flag = SVCD_FALSE; |
4737 | 0 | } |
4738 | | |
4739 | | /* populate the dyadic status */ |
4740 | | |
4741 | 34.5k | if((ps_curr_lyr_res_prms->u2_scaled_ref_width == (i4_ref_lyr_width << 1)) && |
4742 | 16.0k | (ps_curr_lyr_res_prms->u2_scaled_ref_height == (i4_ref_lyr_ht << 1))) |
4743 | 16.0k | { |
4744 | 16.0k | i4_dyadic_flag = SVCD_TRUE; |
4745 | 16.0k | } |
4746 | 18.4k | else if((ps_curr_lyr_res_prms->u2_scaled_ref_width != ((i4_ref_lyr_width * 3) >> 1)) || |
4747 | 18.3k | (ps_curr_lyr_res_prms->u2_scaled_ref_height != ((i4_ref_lyr_ht * 3) >> 1))) |
4748 | 366 | { |
4749 | 366 | ps_curr_lyr_res_prms->u1_dyadic_flag = i4_dyadic_flag; |
4750 | 366 | ps_svc_lyr_dec->u1_dyadic_flag = ps_curr_lyr_res_prms->u1_dyadic_flag; |
4751 | 366 | return NOT_OK; |
4752 | 366 | } |
4753 | | |
4754 | | /* check if cropping is MB aligned */ |
4755 | 34.1k | if(SVCD_TRUE == i4_dyadic_flag) |
4756 | 16.0k | { |
4757 | 16.0k | if((0 != (ps_curr_lyr_res_prms->s_ref_lyr_scaled_offset.i2_left & 15)) || |
4758 | 16.0k | (0 != (ps_curr_lyr_res_prms->s_ref_lyr_scaled_offset.i2_top & 15))) |
4759 | 0 | { |
4760 | 0 | i4_dyadic_flag = SVCD_FALSE; |
4761 | 0 | } |
4762 | 16.0k | } |
4763 | | |
4764 | 34.1k | ps_curr_lyr_res_prms->u1_dyadic_flag = i4_dyadic_flag; |
4765 | 34.1k | ps_svc_lyr_dec->u1_dyadic_flag = ps_curr_lyr_res_prms->u1_dyadic_flag; |
4766 | 34.1k | } |
4767 | | |
4768 | 134k | { |
4769 | 134k | inter_lyr_mb_prms_t *ps_tmp_prms, *ps_tmp_prms_2; |
4770 | 134k | inter_lyr_mb_prms_t *ps_ref_mb_prms; |
4771 | 134k | WORD32 i4_stride; |
4772 | 134k | WORD32 i4_ht_in_mbs, i4_wd_in_mbs; |
4773 | 134k | WORD32 i4_i; |
4774 | | |
4775 | | /* Derive the reference mb mode map */ |
4776 | | |
4777 | 134k | ps_ref_mb_prms = ps_svc_lyr_dec->ps_inter_lyr_mb_prms_frm_start; |
4778 | 134k | i4_stride = ps_svc_lyr_dec->u2_inter_lyr_mb_prms_stride; |
4779 | | |
4780 | 134k | i4_ht_in_mbs = ps_dec->u2_frm_ht_in_mbs; |
4781 | 134k | i4_wd_in_mbs = ps_dec->u2_frm_wd_in_mbs; |
4782 | | |
4783 | | /* Set the first border row to 0xFF */ |
4784 | 134k | ps_tmp_prms = (ps_ref_mb_prms - 1 - i4_stride); |
4785 | | |
4786 | 134k | memset(ps_svc_lyr_dec->ps_inter_lyr_mb_prms_base, -1, |
4787 | 134k | ps_svc_lyr_dec->u4_inter_lyr_mb_prms_size); |
4788 | 134k | memset(ps_svc_lyr_dec->pu1_svc_base_mode_flag, 0, |
4789 | 134k | ps_svc_lyr_dec->i4_frm_svc_base_mode_cabac_size); |
4790 | | |
4791 | 1.17M | for(i4_i = 0; i4_i < (i4_wd_in_mbs + 2); i4_i++) |
4792 | 1.03M | { |
4793 | 1.03M | ps_tmp_prms->i1_mb_mode = (WORD8) 0xFF; |
4794 | 1.03M | ps_tmp_prms += 1; |
4795 | 1.03M | } |
4796 | | |
4797 | | /* Set the left and right border pixels of each row to 0 */ |
4798 | 134k | ps_tmp_prms = ps_ref_mb_prms - 1; |
4799 | | |
4800 | 2.51M | for(i4_i = 0; i4_i < i4_ht_in_mbs; i4_i++) |
4801 | 2.37M | { |
4802 | 2.37M | ps_tmp_prms->i1_mb_mode = (WORD8) 0xFF; |
4803 | 2.37M | ps_tmp_prms_2 = ps_tmp_prms + (i4_wd_in_mbs + 1); |
4804 | 2.37M | ps_tmp_prms_2->i1_mb_mode = (WORD8) 0xFF; |
4805 | 2.37M | ps_tmp_prms += i4_stride; |
4806 | 2.37M | } |
4807 | | |
4808 | | /* Set the last border row to 0xFF */ |
4809 | 1.17M | for(i4_i = 0; i4_i < (i4_wd_in_mbs + 2); i4_i++) |
4810 | 1.03M | { |
4811 | 1.03M | ps_tmp_prms->i1_mb_mode = (WORD8) 0xFF; |
4812 | 1.03M | ps_tmp_prms += 1; |
4813 | 1.03M | } |
4814 | 134k | } |
4815 | | |
4816 | | /* reset residual luma, chroma buffer*/ |
4817 | 134k | memset(ps_svc_lyr_dec->pi2_il_residual_resample_luma_base, 0, |
4818 | 134k | ps_svc_lyr_dec->u4_residual_resample_luma_size); |
4819 | 134k | memset(ps_svc_lyr_dec->pi2_il_residual_resample_chroma_base, 0, |
4820 | 134k | ps_svc_lyr_dec->u4_residual_resample_chroma_size); |
4821 | | |
4822 | 134k | return OK; |
4823 | 135k | } |
4824 | | |
4825 | | /*****************************************************************************/ |
4826 | | /* */ |
4827 | | /* Function Name : isvcd_crop_wnd_flag_res_int */ |
4828 | | /* */ |
4829 | | /* Description : This routine computes the crop window flag for entire */ |
4830 | | /* dependency layer and places it in the crop window flag */ |
4831 | | /* buffer */ |
4832 | | /* Inputs : 1. ECD context structure */ |
4833 | | /* 2. Crop offset structure */ |
4834 | | /* Globals : None */ |
4835 | | /* Processing : For Mbs within the crop window, flag set to 1 and for */ |
4836 | | /* others it is set to 0 */ |
4837 | | /* */ |
4838 | | /* Outputs : Updates crop window flag buffer */ |
4839 | | /* Returns : status */ |
4840 | | /* */ |
4841 | | /* Issues : None */ |
4842 | | /* */ |
4843 | | /* Revision History: */ |
4844 | | /* */ |
4845 | | /* DD MM YYYY Author(s) Changes (Describe the changes made) */ |
4846 | | /* 06 09 2021 Vijay Draft */ |
4847 | | /* */ |
4848 | | /*****************************************************************************/ |
4849 | | void isvcd_crop_wnd_flag_res_int(void *pv_svc_dec) |
4850 | 134k | { |
4851 | 134k | UWORD8 *pu1_crop_wnd_flag; |
4852 | 134k | WORD32 i4_num_mbs; |
4853 | 134k | WORD32 i4_crop_mbs_x; |
4854 | 134k | WORD32 i4_crop_mbs_y; |
4855 | 134k | WORD32 i4_cnt; |
4856 | 134k | WORD32 i4_left_offset, i4_rt_offset; |
4857 | 134k | WORD32 i4_top_offset, i4_bot_offset; |
4858 | 134k | WORD32 i4_frm_wd_in_mbs; |
4859 | 134k | WORD32 i4_frm_ht_in_mbs; |
4860 | 134k | dec_struct_t *ps_dec; |
4861 | 134k | svc_dec_lyr_struct_t *ps_svc_lyr_dec; |
4862 | 134k | res_prms_t *ps_res_prms; |
4863 | | |
4864 | 134k | ps_svc_lyr_dec = (svc_dec_lyr_struct_t *) pv_svc_dec; |
4865 | 134k | ps_dec = &ps_svc_lyr_dec->s_dec; |
4866 | 134k | ps_res_prms = &ps_svc_lyr_dec->s_res_prms; |
4867 | 134k | i4_frm_wd_in_mbs = ps_dec->u2_frm_wd_in_mbs; |
4868 | 134k | i4_frm_ht_in_mbs = ps_dec->u2_frm_ht_in_mbs; |
4869 | | |
4870 | | /* Initializations */ |
4871 | 134k | pu1_crop_wnd_flag = ps_svc_lyr_dec->pu1_crop_wnd_flag; |
4872 | 134k | i4_num_mbs = i4_frm_wd_in_mbs * i4_frm_ht_in_mbs; |
4873 | | |
4874 | | /* bottom most layer in a resolution */ |
4875 | 134k | if(ps_res_prms->s_ref_lyr_scaled_offset.i2_left >= 0) |
4876 | 134k | { |
4877 | | /* check for offset greater than 0 */ |
4878 | 134k | i4_left_offset = (ps_res_prms->s_ref_lyr_scaled_offset.i2_left + 15) >> 4; |
4879 | 134k | } |
4880 | 0 | else |
4881 | 0 | { |
4882 | | /* if negative set it to 0*/ |
4883 | 0 | i4_left_offset = 0; |
4884 | 0 | } |
4885 | | |
4886 | 134k | if(ps_res_prms->s_ref_lyr_scaled_offset.i2_rt >= 0) |
4887 | 134k | { |
4888 | | /* check for offset greater than 0 */ |
4889 | 134k | i4_rt_offset = |
4890 | 134k | (ps_res_prms->i4_res_width - ps_res_prms->s_ref_lyr_scaled_offset.i2_rt) >> 4; |
4891 | 134k | } |
4892 | 0 | else |
4893 | 0 | { |
4894 | | /* if negative set it to framewidth in MBs */ |
4895 | 0 | i4_rt_offset = (ps_res_prms->i4_res_width >> 4); |
4896 | 0 | } |
4897 | | |
4898 | 134k | if(ps_res_prms->s_ref_lyr_scaled_offset.i2_top >= 0) |
4899 | 134k | { |
4900 | | /* check for offset greater than 0 */ |
4901 | 134k | i4_top_offset = (ps_res_prms->s_ref_lyr_scaled_offset.i2_top + 15) >> 4; |
4902 | 134k | } |
4903 | 0 | else |
4904 | 0 | { |
4905 | | /* if negative set it to 0 */ |
4906 | 0 | i4_top_offset = 0; |
4907 | 0 | } |
4908 | | |
4909 | 134k | if(ps_res_prms->s_ref_lyr_scaled_offset.i2_bot >= 0) |
4910 | 134k | { |
4911 | | /* check for offset greater than 0 */ |
4912 | 134k | i4_bot_offset = |
4913 | 134k | (ps_res_prms->i4_res_height - ps_res_prms->s_ref_lyr_scaled_offset.i2_bot) >> 4; |
4914 | 134k | } |
4915 | 6 | else |
4916 | 6 | { |
4917 | | /* if negative set it to frameheight in MBs */ |
4918 | 6 | i4_bot_offset = (ps_res_prms->i4_res_height >> 4); |
4919 | 6 | } |
4920 | | |
4921 | 134k | i4_crop_mbs_x = i4_rt_offset - i4_left_offset; |
4922 | 134k | i4_crop_mbs_y = i4_bot_offset - i4_top_offset; |
4923 | | |
4924 | | /* Set crop window flag to 0 for all mbs */ |
4925 | 134k | memset(pu1_crop_wnd_flag, 0, i4_num_mbs); |
4926 | | |
4927 | 134k | pu1_crop_wnd_flag += (i4_frm_wd_in_mbs * i4_top_offset); |
4928 | 134k | pu1_crop_wnd_flag += i4_left_offset; |
4929 | | /* Loop over MBs in crop window */ |
4930 | 2.51M | for(i4_cnt = 0; i4_cnt < i4_crop_mbs_y; i4_cnt++) |
4931 | 2.37M | { |
4932 | 2.37M | memset(pu1_crop_wnd_flag, 1, i4_crop_mbs_x); |
4933 | 2.37M | pu1_crop_wnd_flag += i4_frm_wd_in_mbs; |
4934 | 2.37M | } |
4935 | 134k | } |
4936 | | |
4937 | | /*****************************************************************************/ |
4938 | | /* */ |
4939 | | /* Function Name : isvcd_intra_resamp_res_init */ |
4940 | | /* */ |
4941 | | /* Description : this function calculates the scale factors and initialise*/ |
4942 | | /* the context structure */ |
4943 | | /* */ |
4944 | | /* Inputs : pv_intra_samp_ctxt: handle to private structure */ |
4945 | | /* ps_curr_lyr_res_prms: pointer to current resolution */ |
4946 | | /* params */ |
4947 | | /* ps_ref_lyr_res_prms : pointer to ref resolution params */ |
4948 | | /* Globals : none */ |
4949 | | /* Processing : it stores the layer dimensions */ |
4950 | | /* */ |
4951 | | /* Outputs : none */ |
4952 | | /* Returns : none */ |
4953 | | /* */ |
4954 | | /* Issues : none */ |
4955 | | /* */ |
4956 | | /* Revision History: */ |
4957 | | /* */ |
4958 | | /* DD MM YYYY Author(s) Changes (Describe the changes made) */ |
4959 | | /* 26 08 2021 vijayakumar creation */ |
4960 | | /* */ |
4961 | | /*****************************************************************************/ |
4962 | | void isvcd_intra_resamp_res_init_update_flags(void *pv_svc_dec) |
4963 | 26.0k | { |
4964 | 26.0k | intra_sampling_ctxt_t *ps_ctxt; |
4965 | 26.0k | intra_samp_lyr_ctxt *ps_lyr_ctxt; |
4966 | 26.0k | svc_dec_lyr_struct_t *ps_svc_lyr_dec = (svc_dec_lyr_struct_t *) pv_svc_dec; |
4967 | | |
4968 | 26.0k | ps_ctxt = (intra_sampling_ctxt_t *) ps_svc_lyr_dec->pv_intra_sample_ctxt;; |
4969 | | /* get the current layer ctxt */ |
4970 | 26.0k | ps_lyr_ctxt = &ps_ctxt->as_res_lyrs[ps_svc_lyr_dec->u1_layer_id - 1]; |
4971 | | |
4972 | 26.0k | ps_lyr_ctxt->i1_constrained_intra_rsmpl_flag = |
4973 | 26.0k | ps_svc_lyr_dec->s_svc_slice_params.u1_constrained_intra_resampling_flag; |
4974 | 26.0k | } |
4975 | | |
4976 | | /*****************************************************************************/ |
4977 | | /* */ |
4978 | | /* Function Name : isvcd_intra_resamp_res_init */ |
4979 | | /* */ |
4980 | | /* Description : this function calculates the scale factors and initialise*/ |
4981 | | /* the context structure */ |
4982 | | /* */ |
4983 | | /* Inputs : pv_intra_samp_ctxt: handle to private structure */ |
4984 | | /* ps_curr_lyr_res_prms: pointer to current resolution */ |
4985 | | /* params */ |
4986 | | /* ps_ref_lyr_res_prms : pointer to ref resolution params */ |
4987 | | /* Globals : none */ |
4988 | | /* Processing : it stores the layer dimensions */ |
4989 | | /* */ |
4990 | | /* Outputs : none */ |
4991 | | /* Returns : none */ |
4992 | | /* */ |
4993 | | /* Issues : none */ |
4994 | | /* */ |
4995 | | /* Revision History: */ |
4996 | | /* */ |
4997 | | /* DD MM YYYY Author(s) Changes (Describe the changes made) */ |
4998 | | /* 26 08 2021 vijayakumar creation */ |
4999 | | /* */ |
5000 | | /*****************************************************************************/ |
5001 | | WORD32 isvcd_intra_resamp_res_init(void *pv_svc_dec) |
5002 | 134k | { |
5003 | 134k | intra_sampling_ctxt_t *ps_ctxt; |
5004 | 134k | intra_samp_lyr_ctxt *ps_lyr_ctxt; |
5005 | 134k | dec_svc_seq_params_t *ps_cur_subset_sps; |
5006 | 134k | svc_dec_lyr_struct_t *ps_svc_lyr_dec = (svc_dec_lyr_struct_t *) pv_svc_dec; |
5007 | 134k | dec_struct_t *ps_dec = &ps_svc_lyr_dec->s_dec; |
5008 | 134k | dec_slice_svc_ext_params_t *ps_svc_slice_params = NULL; |
5009 | | |
5010 | 134k | void *pv_intra_samp_ctxt = ps_svc_lyr_dec->pv_intra_sample_ctxt; |
5011 | 134k | res_prms_t *ps_curr_lyr_res_prms = &ps_svc_lyr_dec->s_res_prms; |
5012 | 134k | ref_mb_map_t **pps_luma_map_horz = &ps_svc_lyr_dec->ps_intsam_luma_map_horz; |
5013 | 134k | ref_mb_map_t **pps_chroma_map_horz = &ps_svc_lyr_dec->ps_intsam_chroma_map_horz; |
5014 | 134k | ref_mb_map_t **pps_luma_map_vert = &ps_svc_lyr_dec->ps_intsam_luma_map_vert; |
5015 | 134k | ref_mb_map_t **pps_chroma_map_vert = &ps_svc_lyr_dec->ps_intsam_chroma_map_vert; |
5016 | | |
5017 | 134k | ps_svc_slice_params = &ps_svc_lyr_dec->s_svc_slice_params; |
5018 | 134k | ps_cur_subset_sps = ps_svc_lyr_dec->ps_cur_subset_sps; |
5019 | | |
5020 | 134k | ps_ctxt = (intra_sampling_ctxt_t *) pv_intra_samp_ctxt; |
5021 | | |
5022 | | /* if called for base resolution store default values */ |
5023 | 134k | if(SVCD_TRUE == ps_svc_lyr_dec->u1_base_res_flag) |
5024 | 100k | { |
5025 | 100k | *pps_luma_map_horz = NULL; |
5026 | 100k | *pps_chroma_map_horz = NULL; |
5027 | 100k | *pps_luma_map_vert = NULL; |
5028 | 100k | *pps_chroma_map_vert = NULL; |
5029 | 100k | ps_ctxt->i4_res_lyr_id = -1; |
5030 | 100k | ps_ctxt->i4_ref_width = ps_dec->u2_pic_wd; |
5031 | 100k | ps_ctxt->i4_ref_height = ps_dec->u2_pic_ht; |
5032 | | |
5033 | | /* Note: The stride option is provided for bringing in data at NMB */ |
5034 | | /* level. Hence to set a NMB level stride refSample array buffer */ |
5035 | | /* have to be increased */ |
5036 | 100k | ps_ctxt->i4_refarray_stride = REF_ARRAY_WIDTH; |
5037 | 100k | return OK; |
5038 | 100k | } |
5039 | | |
5040 | | /* derive the current sps */ |
5041 | | /* store the res id appropriately */ |
5042 | 34.1k | ps_ctxt->i4_res_lyr_id = ps_svc_lyr_dec->u1_layer_id - 1; |
5043 | | |
5044 | | /* store the resolution params */ |
5045 | 34.1k | ps_ctxt->ps_res_prms = ps_curr_lyr_res_prms; |
5046 | | |
5047 | | /* get the current layer ctxt */ |
5048 | 34.1k | ps_lyr_ctxt = &ps_ctxt->as_res_lyrs[ps_svc_lyr_dec->u1_layer_id - 1]; |
5049 | | |
5050 | 34.1k | ps_ctxt->i4_res_lyr_id = ps_svc_lyr_dec->u1_layer_id - 1; |
5051 | | /* get the width and heights */ |
5052 | 34.1k | ps_lyr_ctxt->i4_curr_width = ps_dec->u2_pic_wd; |
5053 | 34.1k | ps_lyr_ctxt->i4_curr_height = ps_dec->u2_pic_ht; |
5054 | 34.1k | ps_lyr_ctxt->i4_ref_width = ps_ctxt->i4_ref_width; |
5055 | 34.1k | ps_lyr_ctxt->i4_ref_height = ps_ctxt->i4_ref_height; |
5056 | 34.1k | ps_lyr_ctxt->i1_constrained_intra_rsmpl_flag = |
5057 | 34.1k | ps_svc_slice_params->u1_constrained_intra_resampling_flag; |
5058 | | |
5059 | | /* store the structure pointer containing projected locations */ |
5060 | 34.1k | *pps_luma_map_horz = ps_lyr_ctxt->s_luma_map_ctxt.ps_x_offset_length; |
5061 | 34.1k | *pps_chroma_map_horz = ps_lyr_ctxt->s_chroma_map_ctxt.ps_x_offset_length; |
5062 | 34.1k | *pps_luma_map_vert = ps_lyr_ctxt->s_luma_map_ctxt.ps_y_offset_length; |
5063 | 34.1k | *pps_chroma_map_vert = ps_lyr_ctxt->s_chroma_map_ctxt.ps_y_offset_length; |
5064 | | |
5065 | | /* check for recomputation of mapping required */ |
5066 | 34.1k | if(SVCD_TRUE == ps_curr_lyr_res_prms->u1_remap_req_flag) |
5067 | 34.1k | { |
5068 | 34.1k | res_prms_t s_ref_res_prms = {0}; |
5069 | 34.1k | WORD32 i4_chroma_x_phase, i4_chroma_y_phase; |
5070 | 34.1k | WORD32 i4_ref_chroma_x_phase, i4_ref_chroma_y_phase; |
5071 | 34.1k | WORD32 i4_x_phase_0, i4_x_phase_1; |
5072 | 34.1k | WORD32 i4_y_phase_0, i4_y_phase_1; |
5073 | 34.1k | WORD32 i4_vert_flag; |
5074 | | |
5075 | | /* store the reference layer resolution width and height */ |
5076 | 34.1k | s_ref_res_prms.i4_res_width = ps_ctxt->i4_ref_width; |
5077 | 34.1k | s_ref_res_prms.i4_res_height = ps_ctxt->i4_ref_height; |
5078 | | |
5079 | | /* call the frame level projections calculation function */ |
5080 | 34.1k | isvcd_intra_resamp_populate_list(&ps_lyr_ctxt->s_luma_map_ctxt, ps_curr_lyr_res_prms, |
5081 | 34.1k | &s_ref_res_prms, 0, ps_svc_lyr_dec); |
5082 | | |
5083 | 34.1k | isvcd_intra_resamp_populate_list(&ps_lyr_ctxt->s_chroma_map_ctxt, ps_curr_lyr_res_prms, |
5084 | 34.1k | &s_ref_res_prms, 1, ps_svc_lyr_dec); |
5085 | | |
5086 | | /* Compute the chroma xPhase and yPhase values */ |
5087 | 34.1k | if(1 == ps_curr_lyr_res_prms->u1_dyadic_flag) |
5088 | 16.0k | { |
5089 | 16.0k | i4_ref_chroma_x_phase = ps_curr_lyr_res_prms->i1_ref_lyr_chroma_phase_x_plus1_flag; |
5090 | 16.0k | i4_ref_chroma_y_phase = ps_curr_lyr_res_prms->i1_ref_lyr_chroma_phase_y_plus1; |
5091 | 16.0k | i4_chroma_x_phase = ps_cur_subset_sps->s_sps_svc_ext.u1_chroma_phase_x_plus1_flag; |
5092 | 16.0k | i4_chroma_y_phase = ps_cur_subset_sps->s_sps_svc_ext.u1_chroma_phase_y_plus1; |
5093 | | |
5094 | 16.0k | i4_x_phase_0 = i4_chroma_x_phase - (i4_ref_chroma_x_phase << 1); |
5095 | 16.0k | i4_x_phase_1 = (3 + i4_x_phase_0) & 0x7; |
5096 | 16.0k | i4_x_phase_0 += 7; |
5097 | 16.0k | i4_x_phase_0 &= 0x7; |
5098 | 16.0k | i4_y_phase_0 = i4_chroma_y_phase - (i4_ref_chroma_y_phase << 1); |
5099 | 16.0k | i4_y_phase_1 = (3 + i4_y_phase_0) & 0x7; |
5100 | 16.0k | i4_y_phase_0 += 7; |
5101 | 16.0k | i4_y_phase_0 &= 0x7; |
5102 | | |
5103 | 16.0k | ps_lyr_ctxt->i4_x_phase_0 = i4_x_phase_0; |
5104 | 16.0k | ps_lyr_ctxt->i4_x_phase_1 = i4_x_phase_1; |
5105 | 16.0k | ps_lyr_ctxt->i4_y_phase_0 = i4_y_phase_0; |
5106 | 16.0k | ps_lyr_ctxt->i4_y_phase_1 = i4_y_phase_1; |
5107 | | |
5108 | | /* Choose the appropriate chroma interpolation functions */ |
5109 | 16.0k | if((0 == i4_ref_chroma_x_phase) && (1 == i4_chroma_x_phase)) |
5110 | 969 | { |
5111 | 969 | ps_lyr_ctxt->pf_horz_chroma_interpol = ps_ctxt->pf_horz_chroma_interpol[1]; |
5112 | 969 | } |
5113 | 15.0k | else |
5114 | 15.0k | { |
5115 | 15.0k | ps_lyr_ctxt->pf_horz_chroma_interpol = ps_ctxt->pf_horz_chroma_interpol[0]; |
5116 | 15.0k | } |
5117 | | |
5118 | 16.0k | i4_vert_flag = 0; |
5119 | 16.0k | if(0 == i4_ref_chroma_y_phase) |
5120 | 2.12k | { |
5121 | 2.12k | if((1 == i4_chroma_y_phase) || (2 == i4_chroma_y_phase)) |
5122 | 299 | { |
5123 | 299 | i4_vert_flag = 1; |
5124 | 299 | } |
5125 | 2.12k | } |
5126 | 13.8k | else if((2 == i4_ref_chroma_y_phase) && (0 == i4_chroma_y_phase)) |
5127 | 635 | { |
5128 | 635 | i4_vert_flag = 2; |
5129 | 635 | } |
5130 | | |
5131 | 16.0k | if(1 == i4_vert_flag) |
5132 | 299 | { |
5133 | 299 | ps_lyr_ctxt->pf_vert_chroma_interpol = ps_ctxt->pf_vert_chroma_interpol[1]; |
5134 | 299 | } |
5135 | 15.7k | else if(2 == i4_vert_flag) |
5136 | 635 | { |
5137 | 635 | ps_lyr_ctxt->pf_vert_chroma_interpol = ps_ctxt->pf_vert_chroma_interpol[2]; |
5138 | 635 | } |
5139 | 15.0k | else |
5140 | 15.0k | { |
5141 | 15.0k | ps_lyr_ctxt->pf_vert_chroma_interpol = ps_ctxt->pf_vert_chroma_interpol[0]; |
5142 | 15.0k | } |
5143 | 16.0k | } |
5144 | 34.1k | } |
5145 | 0 | else |
5146 | 0 | { |
5147 | | /* should take false value */ |
5148 | 0 | if(SVCD_FALSE != ps_curr_lyr_res_prms->u1_remap_req_flag) |
5149 | 0 | { |
5150 | 0 | return NOT_OK; |
5151 | 0 | } |
5152 | 0 | } |
5153 | | |
5154 | | /* store the current layer width and height to context */ |
5155 | 34.1k | ps_ctxt->i4_ref_width = ps_curr_lyr_res_prms->i4_res_width; |
5156 | 34.1k | ps_ctxt->i4_ref_height = ps_curr_lyr_res_prms->i4_res_height; |
5157 | | |
5158 | 34.1k | return OK; |
5159 | 34.1k | } |