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 /*****************************************************************************/
isvcd_get_ceil_log2(WORD32 i4_input)268 WORD32 isvcd_get_ceil_log2(WORD32 i4_input)
269 {
270 WORD32 i4_bits = 0;
271
272 i4_input--;
273 while(i4_input > 0)
274 {
275 i4_bits++;
276 i4_input >>= 1;
277 }
278 return (i4_bits);
279 }
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 /*****************************************************************************/
isvcd_2d_memset(void * pv_buf,WORD32 i4_width,WORD32 i4_ht,WORD32 i4_stride,WORD32 i4_val)307 void isvcd_2d_memset(void *pv_buf, WORD32 i4_width, WORD32 i4_ht, WORD32 i4_stride, WORD32 i4_val)
308 {
309 WORD32 i4_y;
310 UWORD8 *pu1_buf;
311
312 pu1_buf = (UWORD8 *) pv_buf;
313
314 for(i4_y = 0; i4_y < i4_ht; i4_y++)
315 {
316 memset(pu1_buf, i4_val, i4_width);
317 /* Increment the pointer */
318 pu1_buf += i4_stride;
319 }
320 }
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 /*****************************************************************************/
isvcd_copy_data(UWORD8 * pu1_src,WORD32 i4_src_stride,UWORD8 * pu1_dst,WORD32 i4_dst_stride,WORD32 i4_num_bytes,WORD32 i4_num_lines)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 {
351 WORD32 i4_vert_lines;
352
353 /* loop for copy all the lines requried */
354 for(i4_vert_lines = 0; i4_vert_lines < i4_num_lines; i4_vert_lines++)
355 {
356 memcpy(pu1_dst, pu1_src, i4_num_bytes);
357 pu1_src += i4_src_stride;
358 pu1_dst += i4_dst_stride;
359 }
360 return;
361 }
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 /*****************************************************************************/
isvcd_copy_data_semiplanr(UWORD8 * pu1_src,WORD32 i4_src_stride,UWORD8 * pu1_dst1,UWORD8 * pu1_dst2,WORD32 i4_dst_stride,WORD32 i4_num_bytes,WORD32 i4_num_lines)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 {
394 WORD32 i4_vert_lines, u4_i;
395
396 /* loop for copy all the lines requried */
397 for(i4_vert_lines = 0; i4_vert_lines < i4_num_lines; i4_vert_lines++)
398 {
399 for(u4_i = 0; u4_i < i4_num_bytes; u4_i++)
400 {
401 *(pu1_dst1 + u4_i) = *(pu1_src + (2 * u4_i));
402 *(pu1_dst2 + u4_i) = *(pu1_src + (2 * u4_i) + 1);
403 }
404
405 pu1_src += i4_src_stride;
406 pu1_dst1 += i4_dst_stride;
407 pu1_dst2 += i4_dst_stride;
408 }
409 return;
410 }
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 /*****************************************************************************/
isvcd_get_ref_layer_avlblty_dyadic(WORD8 * pi1_ref_mb_modes,WORD32 i4_ref_mode_stride,WORD32 i4_element_size,WORD32 i4_ref_mb_x,WORD32 i4_ref_mb_y,WORD32 * pi4_avlblty,WORD8 i1_curr_slice_id,WORD8 i1_cons_intr_samp_flag)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 {
446 inter_lyr_mb_prms_t *ps_inter_lyr_mb_prms;
447 WORD8 i1_mb_mode;
448
449 /* get the location of the byte which has the current mb mode */
450 pi1_ref_mb_modes += (i4_ref_mb_y * i4_ref_mode_stride * i4_element_size);
451 pi1_ref_mb_modes += (i4_ref_mb_x * i4_element_size);
452 ps_inter_lyr_mb_prms = (inter_lyr_mb_prms_t *) pi1_ref_mb_modes;
453 i1_mb_mode = ps_inter_lyr_mb_prms->i1_mb_mode;
454
455 if(i1_mb_mode <= SVC_INTER_MB)
456 {
457 /* INTER */
458 *pi4_avlblty = 0;
459 }
460 else
461 {
462 /* INTRA */
463 *pi4_avlblty = 1;
464 }
465
466 /* if constrained intra flag is 1 then check for same slice id */
467 if(1 == i1_cons_intr_samp_flag)
468 {
469 if(1 == *pi4_avlblty)
470 {
471 /* check for different slice idc */
472 if(ps_inter_lyr_mb_prms->i1_slice_id != i1_curr_slice_id)
473 {
474 /* store the mode as not available for upsampling */
475 *pi4_avlblty = 0;
476 }
477 }
478 }
479 }
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 /*****************************************************************************/
isvcd_diagonal_construct_dyadic(WORD32 i4_x,WORD32 i4_y,WORD32 i4_xd_index,WORD32 i4_yd_index,UWORD8 * pu1_refarray,WORD32 i4_refarray_wd)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 {
510 WORD32 i4_diff_hor_ver, i4_sgn_xy;
511 WORD32 i4_xc, i4_yc;
512 WORD32 i4_samp1, i4_samp2, i4_samp3;
513 WORD32 i4_result;
514 UWORD8 *pu1_tmp;
515
516 i4_diff_hor_ver = ABS(i4_xd_index) - ABS(i4_yd_index);
517 i4_sgn_xy = SIGN(i4_xd_index * i4_yd_index);
518
519 if(i4_diff_hor_ver > 0)
520 {
521 i4_xc = i4_x - (i4_sgn_xy * i4_yd_index);
522 i4_yc = i4_y - i4_yd_index;
523 pu1_tmp = pu1_refarray + (i4_yc * i4_refarray_wd);
524 i4_samp1 = pu1_tmp[i4_xc - 1];
525 i4_samp2 = pu1_tmp[i4_xc];
526 i4_samp3 = pu1_tmp[i4_xc + 1];
527 }
528 else if(i4_diff_hor_ver < 0)
529 {
530 i4_xc = i4_x - i4_xd_index;
531 i4_yc = i4_y - (i4_sgn_xy * i4_xd_index);
532 pu1_tmp = pu1_refarray + ((i4_yc - 1) * i4_refarray_wd);
533 i4_samp1 = pu1_tmp[i4_xc];
534 pu1_tmp += i4_refarray_wd;
535 i4_samp2 = pu1_tmp[i4_xc];
536 pu1_tmp += i4_refarray_wd;
537 i4_samp3 = pu1_tmp[i4_xc];
538 }
539 else
540 {
541 WORD32 i4_ref_xd, i4_ref_yd;
542
543 i4_ref_xd = i4_x - i4_xd_index;
544 i4_ref_yd = i4_y - i4_yd_index;
545 i4_xc = i4_ref_xd + SIGN(i4_xd_index);
546 i4_yc = i4_ref_yd + SIGN(i4_yd_index);
547 pu1_tmp = pu1_refarray + (i4_ref_yd * i4_refarray_wd);
548 i4_samp1 = pu1_tmp[i4_xc];
549 i4_samp2 = pu1_tmp[i4_ref_xd];
550 pu1_tmp = pu1_refarray + (i4_yc * i4_refarray_wd);
551 i4_samp3 = pu1_tmp[i4_ref_xd];
552 }
553
554 i4_result = (i4_samp1 + (i4_samp2 << 1) + i4_samp3 + 2) >> 2;
555 pu1_tmp = pu1_refarray + (i4_y * i4_refarray_wd);
556 /* Store the filled sample */
557 pu1_tmp[i4_x] = i4_result;
558
559 return (i4_result);
560 }
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 /*****************************************************************************/
isvcd_left_right_padding(WORD32 i4_x,WORD32 i4_y,WORD8 i1_xd_index,WORD8 i1_yd_index,UWORD8 u1_seg_wd,UWORD8 u1_seg_ht,UWORD8 * pu1_refarray_1,UWORD8 * pu1_refarray_2,WORD32 i4_refarray_stride,WORD32 i4_mb_adjoin_x,WORD32 i4_mb_adjoin_y,WORD32 i4_corner_pixel_available)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 {
585 WORD32 i4_idx_i;
586 UWORD8 *pu1_src, *pu1_dst;
587
588 UNUSED(i1_yd_index);
589 UNUSED(pu1_refarray_2);
590 UNUSED(i4_mb_adjoin_x);
591 UNUSED(i4_mb_adjoin_y);
592 UNUSED(i4_corner_pixel_available);
593
594 pu1_dst = pu1_refarray_1 + i4_x + (i4_y * i4_refarray_stride);
595 pu1_src = pu1_dst + i1_xd_index;
596 i1_xd_index = MIN(i1_xd_index, MAX_PIX_FILL_LUMA);
597 u1_seg_wd = MIN(u1_seg_wd, MAX_PIX_FILL_LUMA);
598 pu1_dst = pu1_src - i1_xd_index;
599
600 for(i4_idx_i = 0; i4_idx_i < u1_seg_ht; i4_idx_i++)
601 {
602 memset(pu1_dst, *pu1_src, u1_seg_wd);
603 pu1_dst += i4_refarray_stride;
604 pu1_src += i4_refarray_stride;
605 }
606 }
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 /*****************************************************************************/
isvcd_left_right_padding_chroma(WORD32 i4_x,WORD32 i4_y,WORD8 i1_xd_index,WORD8 i1_yd_index,UWORD8 u1_seg_wd,UWORD8 u1_seg_ht,UWORD8 * pu1_refarray_1,UWORD8 * pu1_refarray_2,WORD32 i4_refarray_stride,WORD32 i4_mb_adjoin_x,WORD32 i4_mb_adjoin_y,WORD32 i4_corner_pixel_available)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 {
630 WORD32 i4_idx_i;
631 UWORD8 *pu1_src_cb, *pu1_dst_cb;
632 UWORD8 *pu1_src_cr, *pu1_dst_cr;
633 WORD32 i4_tmp;
634
635 UNUSED(i1_yd_index);
636 UNUSED(i4_mb_adjoin_x);
637 UNUSED(i4_mb_adjoin_y);
638 UNUSED(i4_corner_pixel_available);
639
640 i4_tmp = i4_x + (i4_y * i4_refarray_stride);
641 pu1_dst_cb = pu1_refarray_1 + i4_tmp;
642 pu1_src_cb = pu1_dst_cb + i1_xd_index;
643 pu1_dst_cr = pu1_refarray_2 + i4_tmp;
644 pu1_src_cr = pu1_dst_cr + i1_xd_index;
645
646 i1_xd_index = MIN(i1_xd_index, MAX_PIX_FILL_CHROMA);
647 u1_seg_wd = MIN(u1_seg_wd, MAX_PIX_FILL_CHROMA);
648 pu1_dst_cb = pu1_src_cb - i1_xd_index;
649 pu1_dst_cr = pu1_src_cr - i1_xd_index;
650
651 for(i4_idx_i = 0; i4_idx_i < u1_seg_ht; i4_idx_i++)
652 {
653 memset(pu1_dst_cb, *pu1_src_cb, u1_seg_wd);
654 pu1_dst_cb += i4_refarray_stride;
655 pu1_src_cb += i4_refarray_stride;
656 memset(pu1_dst_cr, *pu1_src_cr, u1_seg_wd);
657 pu1_dst_cr += i4_refarray_stride;
658 pu1_src_cr += i4_refarray_stride;
659 }
660 }
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 /*****************************************************************************/
isvcd_top_bot_padding(WORD32 i4_x,WORD32 i4_y,WORD8 i1_xd_index,WORD8 i1_yd_index,UWORD8 u1_seg_wd,UWORD8 u1_seg_ht,UWORD8 * pu1_refarray_1,UWORD8 * pu1_refarray_2,WORD32 i4_refarray_stride,WORD32 i4_mb_adjoin_x,WORD32 i4_mb_adjoin_y,WORD32 i4_corner_pixel_available)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 {
684 WORD32 i4_idx_i;
685 UWORD8 *pu1_src, *pu1_dst;
686
687 UNUSED(i1_xd_index);
688 UNUSED(pu1_refarray_2);
689 UNUSED(i4_mb_adjoin_x);
690 UNUSED(i4_mb_adjoin_y);
691 UNUSED(i4_corner_pixel_available);
692
693 pu1_dst = pu1_refarray_1 + i4_x + (i4_y * i4_refarray_stride);
694 pu1_src = pu1_dst + (i1_yd_index * i4_refarray_stride);
695 i1_yd_index = MIN(i1_yd_index, MAX_PIX_FILL_LUMA);
696 u1_seg_ht = MIN(u1_seg_ht, MAX_PIX_FILL_LUMA);
697 pu1_dst = pu1_src - (i1_yd_index * i4_refarray_stride);
698
699 for(i4_idx_i = 0; i4_idx_i < u1_seg_ht; i4_idx_i++)
700 {
701 memcpy(pu1_dst, pu1_src, u1_seg_wd);
702 pu1_dst += i4_refarray_stride;
703 }
704 }
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 /*****************************************************************************/
isvcd_top_bot_padding_chroma(WORD32 i4_x,WORD32 i4_y,WORD8 i1_xd_index,WORD8 i1_yd_index,UWORD8 u1_seg_wd,UWORD8 u1_seg_ht,UWORD8 * pu1_refarray_1,UWORD8 * pu1_refarray_2,WORD32 i4_refarray_stride,WORD32 i4_mb_adjoin_x,WORD32 i4_mb_adjoin_y,WORD32 i4_corner_pixel_available)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 {
729 WORD32 i4_idx_i;
730 UWORD8 *pu1_src_cb, *pu1_dst_cb;
731 UWORD8 *pu1_src_cr, *pu1_dst_cr;
732 WORD32 i4_tmp;
733
734 UNUSED(i1_xd_index);
735 UNUSED(pu1_refarray_2);
736 UNUSED(i4_mb_adjoin_x);
737 UNUSED(i4_mb_adjoin_y);
738 UNUSED(i4_corner_pixel_available);
739
740 i4_tmp = i4_x + (i4_y * i4_refarray_stride);
741 pu1_dst_cb = pu1_refarray_1 + i4_tmp;
742 pu1_dst_cr = pu1_refarray_2 + i4_tmp;
743
744 i4_tmp = (i1_yd_index * i4_refarray_stride);
745 pu1_src_cb = pu1_dst_cb + i4_tmp;
746 pu1_src_cr = pu1_dst_cr + i4_tmp;
747 i1_yd_index = MIN(i1_yd_index, MAX_PIX_FILL_CHROMA);
748 u1_seg_ht = MIN(u1_seg_ht, MAX_PIX_FILL_CHROMA);
749
750 i4_tmp = (i1_yd_index * i4_refarray_stride);
751 pu1_dst_cb = pu1_src_cb - i4_tmp;
752 pu1_dst_cr = pu1_src_cr - i4_tmp;
753
754 for(i4_idx_i = 0; i4_idx_i < u1_seg_ht; i4_idx_i++)
755 {
756 memcpy(pu1_dst_cb, pu1_src_cb, u1_seg_wd);
757 pu1_dst_cb += i4_refarray_stride;
758 memcpy(pu1_dst_cr, pu1_src_cr, u1_seg_wd);
759 pu1_dst_cr += i4_refarray_stride;
760 }
761 }
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 /*****************************************************************************/
isvcd_diag_reconstruction(WORD32 i4_x,WORD32 i4_y,WORD8 i1_xd_index,WORD8 i1_yd_index,UWORD8 u1_seg_wd,UWORD8 u1_seg_ht,UWORD8 * pu1_refarray_1,UWORD8 * pu1_refarray_2,WORD32 i4_refarray_stride,WORD32 i4_mb_adjoin_x,WORD32 i4_mb_adjoin_y,WORD32 i4_corner_pixel_available)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 {
786 WORD32 i4_i;
787 UWORD8 *pu1_src_1, *pu1_src_2, *pu1_dst;
788 UWORD8 u1_filter_delay_buf[18] = {0};
789 UWORD8 u1_out_buf[16] = {0};
790 WORD32 i4_width, i4_height;
791 WORD32 i4_x_off, i4_y_off;
792 WORD32 i4_block_size = BLOCK_WIDTH;
793
794 UNUSED(pu1_refarray_2);
795
796 pu1_dst = pu1_refarray_1 + i4_x + (i4_y * i4_refarray_stride);
797 pu1_src_1 = pu1_dst + i1_xd_index;
798 pu1_src_2 = pu1_dst + (i1_yd_index * i4_refarray_stride);
799
800 i4_width = MAX(u1_seg_wd, (((i4_mb_adjoin_x >> 3) ^ 1) * i4_block_size));
801 i4_height = MAX(u1_seg_ht, (((i4_mb_adjoin_y >> 4) ^ 1) * i4_block_size));
802 i4_x_off = (i4_width - u1_seg_wd);
803 i4_y_off = (i4_height - u1_seg_ht);
804
805 if(i1_xd_index < 0 && i1_yd_index > 0)
806 {
807 /* Quadrant 1 Processing load the pixel in the filter delay buffer */
808 for(i4_i = 0; i4_i < (i4_height + 1); i4_i++)
809 {
810 u1_filter_delay_buf[i4_i] = *pu1_src_1;
811 pu1_src_1 += i4_refarray_stride;
812 }
813
814 pu1_src_2 -= i4_x_off;
815 memcpy(&u1_filter_delay_buf[i4_i], pu1_src_2, i4_width);
816
817 if(0 == i4_corner_pixel_available)
818 {
819 /* interpolate the unavailable corner pixel */
820 u1_filter_delay_buf[i4_i - 1] =
821 (u1_filter_delay_buf[i4_i] + u1_filter_delay_buf[i4_i - 2] + 1) >> 1;
822 }
823
824 for(i4_i = 0; i4_i < (i4_width + i4_height - 1); i4_i++)
825 {
826 /* get the filtered output */
827 u1_out_buf[i4_i] = ((u1_filter_delay_buf[i4_i]) + (u1_filter_delay_buf[i4_i + 1] * 2) +
828 (u1_filter_delay_buf[i4_i + 2]) + 2) >>
829 2;
830 }
831
832 /* fill the segment with diagonal reconstructed output */
833 for(i4_i = 0; i4_i < u1_seg_ht; i4_i++)
834 {
835 memcpy(pu1_dst, &u1_out_buf[i4_x_off + i4_i], u1_seg_wd);
836 pu1_dst += i4_refarray_stride;
837 }
838 }
839 else if(i1_xd_index > 0 && i1_yd_index > 0)
840 {
841 /* Quadrant 2 Processing */
842 /* load the pixel in the filter delay buffer */
843 memcpy(&u1_filter_delay_buf[0], pu1_src_2, (i4_width + 1));
844 for(i4_i = i4_height; i4_i > 0; i4_i--)
845 {
846 u1_filter_delay_buf[i4_width + i4_i] = *pu1_src_1;
847 pu1_src_1 += i4_refarray_stride;
848 }
849
850 if(0 == i4_corner_pixel_available)
851 {
852 /* interpolate the unavailable corner pixel */
853 u1_filter_delay_buf[i4_width] =
854 (u1_filter_delay_buf[i4_width - 1] + u1_filter_delay_buf[i4_width + 1] + 1) >> 1;
855 }
856
857 for(i4_i = 0; i4_i < (i4_width + i4_height - 1); i4_i++)
858 {
859 /* get the filtered output */
860 u1_out_buf[i4_i] = ((u1_filter_delay_buf[i4_i]) + (u1_filter_delay_buf[i4_i + 1] * 2) +
861 (u1_filter_delay_buf[i4_i + 2]) + 2) >>
862 2;
863 }
864
865 /* fill the segment with diagonal reconstructed output */
866 for(i4_i = 1; i4_i <= u1_seg_ht; i4_i++)
867 {
868 memcpy(pu1_dst, &u1_out_buf[i4_height - i4_i], u1_seg_wd);
869 pu1_dst += i4_refarray_stride;
870 }
871 }
872 else if(i1_xd_index > 0 && i1_yd_index < 0)
873 {
874 /* Quadrant 3 Processing */
875 /* load the pixel in the filter delay buffer */
876 memcpy(&u1_filter_delay_buf[0], pu1_src_2, (i4_width + 1));
877
878 pu1_src_1 -= (i4_y_off * i4_refarray_stride);
879 for(i4_i = 1; i4_i <= i4_height; i4_i++)
880 {
881 u1_filter_delay_buf[i4_width + i4_i] = *pu1_src_1;
882 pu1_src_1 += i4_refarray_stride;
883 }
884
885 if(0 == i4_corner_pixel_available)
886 {
887 /* interpolate the unavailable corner pixel */
888 u1_filter_delay_buf[i4_width] =
889 (u1_filter_delay_buf[i4_width - 1] + u1_filter_delay_buf[i4_width + 1] + 1) >> 1;
890 }
891
892 for(i4_i = 0; i4_i < (i4_width + i4_height - 1); i4_i++)
893 {
894 /* get the filtered output */
895 u1_out_buf[i4_i] = ((u1_filter_delay_buf[i4_i]) + (u1_filter_delay_buf[i4_i + 1] * 2) +
896 (u1_filter_delay_buf[i4_i + 2]) + 2) >>
897 2;
898 }
899
900 /* fill the segment with diagonal reconstructed output */
901 for(i4_i = 0; i4_i < u1_seg_ht; i4_i++)
902 {
903 memcpy(pu1_dst, &u1_out_buf[i4_y_off + i4_i], u1_seg_wd);
904 pu1_dst += i4_refarray_stride;
905 }
906 }
907 else
908 {
909 /* Quadrant 4 Processing */
910 /* load the pixel in the filter delay buffer */
911 pu1_src_1 += ((u1_seg_ht - 1) * i4_refarray_stride);
912 for(i4_i = 0; i4_i <= i4_height; i4_i++)
913 {
914 u1_filter_delay_buf[i4_i] = *pu1_src_1;
915 pu1_src_1 -= i4_refarray_stride;
916 }
917
918 pu1_src_2 -= i4_x_off;
919 memcpy(&u1_filter_delay_buf[i4_i], pu1_src_2, i4_width);
920
921 if(0 == i4_corner_pixel_available)
922 {
923 /* interpolate the unavailable corner pixel */
924 u1_filter_delay_buf[i4_i - 1] =
925 (u1_filter_delay_buf[i4_i] + u1_filter_delay_buf[i4_i - 2] + 1) >> 1;
926 }
927
928 for(i4_i = 0; i4_i < (i4_width + i4_height - 1); i4_i++)
929 {
930 /* get the filtered output */
931 u1_out_buf[i4_i] = ((u1_filter_delay_buf[i4_i]) + (u1_filter_delay_buf[i4_i + 1] * 2) +
932 (u1_filter_delay_buf[i4_i + 2]) + 2) >>
933 2;
934 }
935
936 /* fill the segment with diagonal reconstructed output */
937 for(i4_i = 1; i4_i <= u1_seg_ht; i4_i++)
938 {
939 memcpy(pu1_dst, &u1_out_buf[(u1_seg_ht + i4_x_off) - i4_i], u1_seg_wd);
940 pu1_dst += i4_refarray_stride;
941 }
942 }
943 }
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 /*****************************************************************************/
isvcd_diag_reconstruction_chroma(WORD32 i4_x,WORD32 i4_y,WORD8 i1_xd_index,WORD8 i1_yd_index,UWORD8 u1_seg_wd,UWORD8 u1_seg_ht,UWORD8 * pu1_refarray_1,UWORD8 * pu1_refarray_2,WORD32 i4_refarray_stride,WORD32 i4_mb_adjoin_x,WORD32 i4_mb_adjoin_y,WORD32 i4_corner_pixel_available)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 {
967 WORD32 i4_i;
968 UWORD8 u1_filter_delay_buf_cb[18] = {0};
969 UWORD8 u1_filter_delay_buf_cr[18] = {0};
970 UWORD8 u1_out_buf_cb[16] = {0};
971 UWORD8 u1_out_buf_cr[16] = {0};
972 WORD32 i4_width, i4_height;
973 WORD32 i4_x_off, i4_y_off;
974 WORD32 i4_block_size = BLOCK_WIDTH >> 1;
975 UWORD8 *pu1_src_1_cb, *pu1_src_2_cb, *pu1_dst_cb;
976 UWORD8 *pu1_src_1_cr, *pu1_src_2_cr, *pu1_dst_cr;
977 WORD32 i4_tmp;
978
979 i4_tmp = i4_x + (i4_y * i4_refarray_stride);
980 pu1_dst_cb = pu1_refarray_1 + i4_tmp;
981 pu1_dst_cr = pu1_refarray_2 + i4_tmp;
982
983 pu1_src_1_cb = pu1_dst_cb + i1_xd_index;
984 pu1_src_1_cr = pu1_dst_cr + i1_xd_index;
985 i4_tmp = (i1_yd_index * i4_refarray_stride);
986 pu1_src_2_cb = pu1_dst_cb + i4_tmp;
987 pu1_src_2_cr = pu1_dst_cr + i4_tmp;
988
989 i4_width = MAX(u1_seg_wd, (((i4_mb_adjoin_x >> 3) ^ 1) * i4_block_size));
990 i4_height = MAX(u1_seg_ht, (((i4_mb_adjoin_y >> 4) ^ 1) * i4_block_size));
991 i4_x_off = (i4_width - u1_seg_wd);
992 i4_y_off = (i4_height - u1_seg_ht);
993
994 if(i1_xd_index < 0 && i1_yd_index > 0)
995 {
996 /* Quadrant 1 Processing load the pixel in the filter delay buffer */
997 for(i4_i = 0; i4_i < (i4_height + 1); i4_i++)
998 {
999 u1_filter_delay_buf_cb[i4_i] = *pu1_src_1_cb;
1000 pu1_src_1_cb += i4_refarray_stride;
1001 u1_filter_delay_buf_cr[i4_i] = *pu1_src_1_cr;
1002 pu1_src_1_cr += i4_refarray_stride;
1003 }
1004
1005 pu1_src_2_cb -= i4_x_off;
1006 pu1_src_2_cr -= i4_x_off;
1007 memcpy(&u1_filter_delay_buf_cb[i4_i], pu1_src_2_cb, i4_width);
1008 memcpy(&u1_filter_delay_buf_cr[i4_i], pu1_src_2_cr, i4_width);
1009
1010 if(0 == i4_corner_pixel_available)
1011 {
1012 /* interpolate the unavailable corner pixel */
1013 u1_filter_delay_buf_cb[i4_i - 1] =
1014 (u1_filter_delay_buf_cb[i4_i] + u1_filter_delay_buf_cb[i4_i - 2] + 1) >> 1;
1015
1016 u1_filter_delay_buf_cr[i4_i - 1] =
1017 (u1_filter_delay_buf_cr[i4_i] + u1_filter_delay_buf_cr[i4_i - 2] + 1) >> 1;
1018 }
1019
1020 for(i4_i = 0; i4_i < (i4_width + i4_height - 1); i4_i++)
1021 {
1022 /* get the filtered output */
1023 u1_out_buf_cb[i4_i] =
1024 ((u1_filter_delay_buf_cb[i4_i]) + (u1_filter_delay_buf_cb[i4_i + 1] * 2) +
1025 (u1_filter_delay_buf_cb[i4_i + 2]) + 2) >>
1026 2;
1027
1028 u1_out_buf_cr[i4_i] =
1029 ((u1_filter_delay_buf_cr[i4_i]) + (u1_filter_delay_buf_cr[i4_i + 1] * 2) +
1030 (u1_filter_delay_buf_cr[i4_i + 2]) + 2) >>
1031 2;
1032 }
1033
1034 /* fill the segment with diagonal reconstructed output */
1035 for(i4_i = 0; i4_i < u1_seg_ht; i4_i++)
1036 {
1037 memcpy(pu1_dst_cb, &u1_out_buf_cb[i4_x_off + i4_i], u1_seg_wd);
1038 pu1_dst_cb += i4_refarray_stride;
1039 memcpy(pu1_dst_cr, &u1_out_buf_cr[i4_x_off + i4_i], u1_seg_wd);
1040 pu1_dst_cr += i4_refarray_stride;
1041 }
1042 }
1043 else if(i1_xd_index > 0 && i1_yd_index > 0)
1044 {
1045 /* Quadrant 2 Processing load the pixel in the filter delay buffer */
1046 memcpy(&u1_filter_delay_buf_cb[0], pu1_src_2_cb, (i4_width + 1));
1047 memcpy(&u1_filter_delay_buf_cr[0], pu1_src_2_cr, (i4_width + 1));
1048
1049 for(i4_i = i4_height; i4_i > 0; i4_i--)
1050 {
1051 u1_filter_delay_buf_cb[i4_width + i4_i] = *pu1_src_1_cb;
1052 pu1_src_1_cb += i4_refarray_stride;
1053
1054 u1_filter_delay_buf_cr[i4_width + i4_i] = *pu1_src_1_cr;
1055 pu1_src_1_cr += i4_refarray_stride;
1056 }
1057
1058 if(0 == i4_corner_pixel_available)
1059 {
1060 /* interpolate the unavailable corner pixel */
1061 u1_filter_delay_buf_cb[i4_width] =
1062 (u1_filter_delay_buf_cb[i4_width - 1] + u1_filter_delay_buf_cb[i4_width + 1] + 1) >>
1063 1;
1064
1065 u1_filter_delay_buf_cr[i4_width] =
1066 (u1_filter_delay_buf_cr[i4_width - 1] + u1_filter_delay_buf_cr[i4_width + 1] + 1) >>
1067 1;
1068 }
1069
1070 for(i4_i = 0; i4_i < (i4_width + i4_height - 1); i4_i++)
1071 {
1072 /* get the filtered output */
1073 u1_out_buf_cb[i4_i] =
1074 ((u1_filter_delay_buf_cb[i4_i]) + (u1_filter_delay_buf_cb[i4_i + 1] * 2) +
1075 (u1_filter_delay_buf_cb[i4_i + 2]) + 2) >>
1076 2;
1077
1078 u1_out_buf_cr[i4_i] =
1079 ((u1_filter_delay_buf_cr[i4_i]) + (u1_filter_delay_buf_cr[i4_i + 1] * 2) +
1080 (u1_filter_delay_buf_cr[i4_i + 2]) + 2) >>
1081 2;
1082 }
1083
1084 /* fill the segment with diagonal reconstructed output */
1085 for(i4_i = 1; i4_i <= u1_seg_ht; i4_i++)
1086 {
1087 memcpy(pu1_dst_cb, &u1_out_buf_cb[i4_height - i4_i], u1_seg_wd);
1088 pu1_dst_cb += i4_refarray_stride;
1089
1090 memcpy(pu1_dst_cr, &u1_out_buf_cr[i4_height - i4_i], u1_seg_wd);
1091 pu1_dst_cr += i4_refarray_stride;
1092 }
1093 }
1094 else if(i1_xd_index > 0 && i1_yd_index < 0)
1095 {
1096 /* Quadrant 3 Processing load the pixel in the filter delay buffer */
1097 memcpy(&u1_filter_delay_buf_cb[0], pu1_src_2_cb, (i4_width + 1));
1098 memcpy(&u1_filter_delay_buf_cr[0], pu1_src_2_cr, (i4_width + 1));
1099
1100 i4_tmp = (i4_y_off * i4_refarray_stride);
1101 pu1_src_1_cb -= i4_tmp;
1102 pu1_src_1_cr -= i4_tmp;
1103 for(i4_i = 1; i4_i <= i4_height; i4_i++)
1104 {
1105 u1_filter_delay_buf_cb[i4_width + i4_i] = *pu1_src_1_cb;
1106 pu1_src_1_cb += i4_refarray_stride;
1107
1108 u1_filter_delay_buf_cr[i4_width + i4_i] = *pu1_src_1_cr;
1109 pu1_src_1_cr += i4_refarray_stride;
1110 }
1111
1112 if(0 == i4_corner_pixel_available)
1113 {
1114 /* interpolate the unavailable corner pixel */
1115 u1_filter_delay_buf_cb[i4_width] =
1116 (u1_filter_delay_buf_cb[i4_width - 1] + u1_filter_delay_buf_cb[i4_width + 1] + 1) >>
1117 1;
1118
1119 u1_filter_delay_buf_cr[i4_width] =
1120 (u1_filter_delay_buf_cr[i4_width - 1] + u1_filter_delay_buf_cr[i4_width + 1] + 1) >>
1121 1;
1122 }
1123
1124 for(i4_i = 0; i4_i < (i4_width + i4_height - 1); i4_i++)
1125 {
1126 /* get the filtered output */
1127 u1_out_buf_cb[i4_i] =
1128 ((u1_filter_delay_buf_cb[i4_i]) + (u1_filter_delay_buf_cb[i4_i + 1] * 2) +
1129 (u1_filter_delay_buf_cb[i4_i + 2]) + 2) >>
1130 2;
1131
1132 u1_out_buf_cr[i4_i] =
1133 ((u1_filter_delay_buf_cr[i4_i]) + (u1_filter_delay_buf_cr[i4_i + 1] * 2) +
1134 (u1_filter_delay_buf_cr[i4_i + 2]) + 2) >>
1135 2;
1136 }
1137
1138 /* fill the segment with diagonal reconstructed output */
1139 for(i4_i = 0; i4_i < u1_seg_ht; i4_i++)
1140 {
1141 memcpy(pu1_dst_cb, &u1_out_buf_cb[i4_y_off + i4_i], u1_seg_wd);
1142 pu1_dst_cb += i4_refarray_stride;
1143 memcpy(pu1_dst_cr, &u1_out_buf_cr[i4_y_off + i4_i], u1_seg_wd);
1144 pu1_dst_cr += i4_refarray_stride;
1145 }
1146 }
1147 else
1148 {
1149 /* Quadrant 4 Processing load the pixel in the filter delay buffer */
1150 i4_tmp = ((u1_seg_ht - 1) * i4_refarray_stride);
1151 pu1_src_1_cb += i4_tmp;
1152 pu1_src_1_cr += i4_tmp;
1153
1154 for(i4_i = 0; i4_i <= i4_height; i4_i++)
1155 {
1156 u1_filter_delay_buf_cb[i4_i] = *pu1_src_1_cb;
1157 pu1_src_1_cb -= i4_refarray_stride;
1158
1159 u1_filter_delay_buf_cr[i4_i] = *pu1_src_1_cr;
1160 pu1_src_1_cr -= i4_refarray_stride;
1161 }
1162
1163 pu1_src_2_cb -= i4_x_off;
1164 pu1_src_2_cr -= i4_x_off;
1165 memcpy(&u1_filter_delay_buf_cb[i4_i], pu1_src_2_cb, i4_width);
1166 memcpy(&u1_filter_delay_buf_cr[i4_i], pu1_src_2_cr, i4_width);
1167
1168 if(0 == i4_corner_pixel_available)
1169 {
1170 /* interpolate the unavailable corner pixel */
1171 u1_filter_delay_buf_cb[i4_i - 1] =
1172 (u1_filter_delay_buf_cb[i4_i] + u1_filter_delay_buf_cb[i4_i - 2] + 1) >> 1;
1173
1174 u1_filter_delay_buf_cr[i4_i - 1] =
1175 (u1_filter_delay_buf_cr[i4_i] + u1_filter_delay_buf_cr[i4_i - 2] + 1) >> 1;
1176 }
1177
1178 for(i4_i = 0; i4_i < (i4_width + i4_height - 1); i4_i++)
1179 {
1180 /* get the filtered output */
1181 u1_out_buf_cb[i4_i] =
1182 ((u1_filter_delay_buf_cb[i4_i]) + (u1_filter_delay_buf_cb[i4_i + 1] * 2) +
1183 (u1_filter_delay_buf_cb[i4_i + 2]) + 2) >>
1184 2;
1185
1186 u1_out_buf_cr[i4_i] =
1187 ((u1_filter_delay_buf_cr[i4_i]) + (u1_filter_delay_buf_cr[i4_i + 1] * 2) +
1188 (u1_filter_delay_buf_cr[i4_i + 2]) + 2) >>
1189 2;
1190 }
1191
1192 /* fill the segment with diagonal reconstructed output */
1193 for(i4_i = 1; i4_i <= u1_seg_ht; i4_i++)
1194 {
1195 memcpy(pu1_dst_cb, &u1_out_buf_cb[(u1_seg_ht + i4_x_off) - i4_i], u1_seg_wd);
1196 pu1_dst_cb += i4_refarray_stride;
1197 memcpy(pu1_dst_cr, &u1_out_buf_cr[(u1_seg_ht + i4_x_off) - i4_i], u1_seg_wd);
1198 pu1_dst_cr += i4_refarray_stride;
1199 }
1200 }
1201 }
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 /*****************************************************************************/
isvcd_diag_padding(WORD32 i4_x,WORD32 i4_y,WORD8 i1_xd_index,WORD8 i1_yd_index,UWORD8 u1_seg_wd,UWORD8 u1_seg_ht,UWORD8 * pu1_refarray_1,UWORD8 * pu1_refarray_2,WORD32 i4_refarray_stride,WORD32 i4_mb_adjoin_x,WORD32 i4_mb_adjoin_y,WORD32 i4_corner_pixel_available)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 {
1225 WORD32 i4_idx_i;
1226 UWORD8 *pu1_src, *pu1_dst;
1227
1228 UNUSED(pu1_refarray_2);
1229 UNUSED(i4_mb_adjoin_x);
1230 UNUSED(i4_mb_adjoin_y);
1231 UNUSED(i4_corner_pixel_available);
1232
1233 pu1_dst = pu1_refarray_1 + i4_x + (i4_y * i4_refarray_stride);
1234 pu1_src = pu1_dst + i1_xd_index + (i1_yd_index * i4_refarray_stride);
1235 i1_xd_index = MIN(i1_xd_index, MAX_PIX_FILL_LUMA);
1236 u1_seg_wd = MIN(u1_seg_wd, MAX_PIX_FILL_LUMA);
1237 i1_yd_index = MIN(i1_yd_index, MAX_PIX_FILL_LUMA);
1238 u1_seg_ht = MIN(u1_seg_ht, MAX_PIX_FILL_LUMA);
1239 pu1_dst = pu1_src - i1_xd_index - (i1_yd_index * i4_refarray_stride);
1240
1241 for(i4_idx_i = 0; i4_idx_i < u1_seg_ht; i4_idx_i++)
1242 {
1243 memset(pu1_dst, *pu1_src, u1_seg_wd);
1244 pu1_dst += i4_refarray_stride;
1245 }
1246 }
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 /*****************************************************************************/
isvcd_diag_padding_chroma(WORD32 i4_x,WORD32 i4_y,WORD8 i1_xd_index,WORD8 i1_yd_index,UWORD8 u1_seg_wd,UWORD8 u1_seg_ht,UWORD8 * pu1_refarray_1,UWORD8 * pu1_refarray_2,WORD32 i4_refarray_stride,WORD32 i4_mb_adjoin_x,WORD32 i4_mb_adjoin_y,WORD32 i4_corner_pixel_available)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 {
1272 WORD32 i4_idx_i;
1273 UWORD8 *pu1_src_cb, *pu1_dst_cb;
1274 UWORD8 *pu1_src_cr, *pu1_dst_cr;
1275 WORD32 i4_tmp;
1276
1277 UNUSED(i4_mb_adjoin_x);
1278 UNUSED(i4_mb_adjoin_y);
1279 UNUSED(i4_corner_pixel_available);
1280
1281 i4_tmp = i4_x + (i4_y * i4_refarray_stride);
1282 pu1_dst_cb = pu1_refarray_1 + i4_tmp;
1283 pu1_dst_cr = pu1_refarray_2 + i4_tmp;
1284 i4_tmp = i1_xd_index + (i1_yd_index * i4_refarray_stride);
1285 pu1_src_cb = pu1_dst_cb + i4_tmp;
1286 pu1_src_cr = pu1_dst_cr + i4_tmp;
1287
1288 i1_xd_index = MIN(i1_xd_index, MAX_PIX_FILL_LUMA);
1289 u1_seg_wd = MIN(u1_seg_wd, MAX_PIX_FILL_LUMA);
1290 i1_yd_index = MIN(i1_yd_index, MAX_PIX_FILL_LUMA);
1291 u1_seg_ht = MIN(u1_seg_ht, MAX_PIX_FILL_LUMA);
1292
1293 i4_tmp = (i1_xd_index + (i1_yd_index * i4_refarray_stride));
1294 pu1_dst_cb = pu1_src_cb - i4_tmp;
1295 pu1_dst_cr = pu1_src_cr - i4_tmp;
1296
1297 for(i4_idx_i = 0; i4_idx_i < u1_seg_ht; i4_idx_i++)
1298 {
1299 memset(pu1_dst_cb, *pu1_src_cb, u1_seg_wd);
1300 pu1_dst_cb += i4_refarray_stride;
1301 memset(pu1_dst_cr, *pu1_src_cr, u1_seg_wd);
1302 pu1_dst_cr += i4_refarray_stride;
1303 }
1304 }
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 /*****************************************************************************/
isvcd_corner_samp_dyadic(WORD32 i4_x,WORD32 i4_y,WORD32 i4_xD,WORD32 i4_yD,UWORD8 * pu1_refarray_y,UWORD8 * pu1_refarray_cb,UWORD8 * pu1_refarray_cr)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 {
1336 WORD32 i4_ref_xD, i4_ref_yD;
1337 WORD32 i4_c_ref_xD, i4_c_ref_yD;
1338 WORD32 i4_xc, i4_yc;
1339 WORD32 i4_c_xc, i4_c_yc;
1340 WORD32 i4_samp1, i4_samp2;
1341 UWORD8 *pu1_tmp_src, *pu1_tmp_dst;
1342
1343 i4_ref_xD = i4_x - i4_xD;
1344 i4_ref_yD = i4_y - i4_yD;
1345 i4_xc = i4_ref_xD + SIGN(i4_xD);
1346 i4_yc = i4_ref_yD + SIGN(i4_yD);
1347
1348 /* Luma */
1349 pu1_tmp_src = pu1_refarray_y + (i4_yc * DYADIC_REF_W_Y);
1350 i4_samp1 = pu1_tmp_src[i4_ref_xD];
1351 pu1_tmp_src = pu1_refarray_y + (i4_ref_yD * DYADIC_REF_W_Y);
1352 i4_samp2 = pu1_tmp_src[i4_xc];
1353 pu1_tmp_dst = pu1_tmp_src;
1354 pu1_tmp_dst[i4_ref_xD] = (i4_samp1 + i4_samp2 + 1) >> 1;
1355
1356 /* Chroma */
1357 i4_c_ref_xD = i4_ref_xD >> 1;
1358 i4_c_ref_yD = i4_ref_yD >> 1;
1359 i4_c_xc = i4_c_ref_xD + SIGN(i4_xD);
1360 i4_c_yc = i4_c_ref_yD + SIGN(i4_yD);
1361
1362 /* Cb */
1363 pu1_tmp_src = pu1_refarray_cb + (i4_c_yc * DYADIC_REF_W_C);
1364 i4_samp1 = pu1_tmp_src[i4_c_ref_xD];
1365 pu1_tmp_src = pu1_refarray_cb + (i4_c_ref_yD * DYADIC_REF_W_C);
1366 i4_samp2 = pu1_tmp_src[i4_c_xc];
1367 pu1_tmp_dst = pu1_tmp_src;
1368 pu1_tmp_dst[i4_c_ref_xD] = (i4_samp1 + i4_samp2 + 1) >> 1;
1369
1370 /* Cr */
1371 pu1_tmp_src = pu1_refarray_cr + (i4_c_yc * DYADIC_REF_W_C);
1372 i4_samp1 = pu1_tmp_src[i4_c_ref_xD];
1373 pu1_tmp_src = pu1_refarray_cr + (i4_c_ref_yD * DYADIC_REF_W_C);
1374 i4_samp2 = pu1_tmp_src[i4_c_xc];
1375 pu1_tmp_dst = pu1_tmp_src;
1376 pu1_tmp_dst[i4_c_ref_xD] = (i4_samp1 + i4_samp2 + 1) >> 1;
1377 }
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 /*****************************************************************************/
isvcd_fill_non_avail_pixel(void * pv_map_ctxt,UWORD8 * pu1_refarray_1,UWORD8 * pu1_refarray_2,WORD32 i4_refarray_stride,mb_coord_t * ps_mb_coord,WORD32 i4_chroma_flag,UWORD8 u1_avail_map[4][4])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 {
1409 /* --------------------------------------------------------------------- */
1410 /* Index Variables */
1411 /* --------------------------------------------------------------------- */
1412 intra_samp_map_ctxt_t *ps_map_ctxt;
1413 ref_mb_map_t *ps_x_off_len;
1414 ref_mb_map_t *ps_y_off_len;
1415 WORD32 i4_x, i4_y;
1416 WORD32 i4_corner_pixel_available;
1417
1418 /* --------------------------------------------------------------------- */
1419 /* Local Pointer Declaration for Segment lookup */
1420 /* --------------------------------------------------------------------- */
1421 seg_lookup_desc_t *ps_segments_x;
1422 seg_lookup_desc_t *ps_segments_y;
1423 seg_description_t *ps_seg_desc_x, *ps_seg_desc_y;
1424 seg_description_t *ps_seg_x_tmp, *ps_seg_y_tmp;
1425 UWORD8 u1_num_sgmts_x, u1_num_sgmts_y;
1426
1427 /* --------------------------------------------------------------------- */
1428 /* Temp Variables for Mapping context */
1429 /* --------------------------------------------------------------------- */
1430 WORD32 i4_x_offset;
1431 WORD32 i4_y_offset;
1432 WORD32 i4_refmb_wd;
1433 WORD32 i4_refmb_ht;
1434 WORD32 i4_mbaddr_x;
1435 WORD32 i4_mbaddr_y;
1436 WORD32 i4_xr_index, i4_yr_index;
1437 WORD32 i4_j, i4_i;
1438 WORD32 i4_cur_x;
1439 UWORD32 u4_lookup_4bit, u4_lookup_5bit, u4_4thbit;
1440 WORD32 i4_pad_size;
1441 WORD32 i4_x_min;
1442 WORD32 i4_y_min;
1443 WORD32 i4_x_start_pos, i4_y_start_pos;
1444 ref_min_max_map_t *ps_x_min_max;
1445 ref_min_max_map_t *ps_y_min_max;
1446 UWORD8 *pu1_ref_idx_x, *pu1_ref_idx_y;
1447 ftype_intra_samp_padding *pf_intra_samp_padding;
1448 ftype_intra_samp_padding **pf_intra_samp_lookup;
1449
1450 ps_map_ctxt = (intra_samp_map_ctxt_t *) pv_map_ctxt;
1451 ps_x_min_max = ps_map_ctxt->ps_x_min_max;
1452 ps_y_min_max = ps_map_ctxt->ps_y_min_max;
1453 ps_x_off_len = ps_map_ctxt->ps_x_offset_length;
1454 ps_y_off_len = ps_map_ctxt->ps_y_offset_length;
1455 i4_mbaddr_y = ps_mb_coord->u2_mb_y;
1456 i4_mbaddr_x = ps_mb_coord->u2_mb_x;
1457 i4_x_offset = ps_x_off_len[i4_mbaddr_x].i2_offset;
1458 i4_y_offset = ps_y_off_len[i4_mbaddr_y].i2_offset;
1459 i4_refmb_wd = (MB_WIDTH >> i4_chroma_flag) - 1;
1460 i4_refmb_ht = (MB_HEIGHT >> i4_chroma_flag) - 1;
1461
1462 if(0 == i4_chroma_flag)
1463 {
1464 pf_intra_samp_lookup = gpf_lookup_fxns_luma;
1465 }
1466 else
1467 {
1468 pf_intra_samp_lookup = gpf_lookup_fxns_chroma;
1469 }
1470
1471 /* get the min and max positions */
1472 i4_x_min = ps_x_min_max[i4_mbaddr_x].i2_min_pos;
1473 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 i4_pad_size = 2 >> i4_chroma_flag;
1477 i4_x_start_pos = (i4_x_min - i4_pad_size);
1478 i4_y_start_pos = (i4_y_min - i4_pad_size);
1479 i4_xr_index = (i4_x_start_pos + i4_x_offset) & i4_refmb_wd;
1480 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 ps_segments_x = (ps_map_ctxt->ps_seg_lookup_horz + i4_xr_index);
1484 ps_segments_y = (ps_map_ctxt->ps_seg_lookup_vert + i4_yr_index);
1485 u1_num_sgmts_x = ps_segments_x->u1_num_segments;
1486 u1_num_sgmts_y = ps_segments_y->u1_num_segments;
1487 ps_seg_desc_x = ps_segments_x->s_segments;
1488 ps_seg_desc_y = ps_segments_y->s_segments;
1489 pu1_ref_idx_x = ps_map_ctxt->pu1_refarray_x_idx;
1490 pu1_ref_idx_y = ps_map_ctxt->pu1_refarray_y_idx;
1491 i4_cur_x = pu1_ref_idx_x[i4_x_start_pos];
1492 u4_4thbit = ps_segments_x->u4_start_pos;
1493
1494 for(i4_j = 0; i4_j < u1_num_sgmts_y; i4_j++)
1495 {
1496 UWORD8 i4_idx_a, i4_idx_b;
1497 UWORD8 u1_seg_ht, u1_seg_wd;
1498 UWORD8 u1_mb_adjoin_x, u1_mb_adjoin_y;
1499 WORD8 i1_nearst_mb_bdry_x, i1_nearst_mb_bdry_y;
1500 UWORD32 u4_num_valid_segs;
1501 WORD32 i4_idx_a_plus_ny, i4_idx_b_plus_nx, i4_index;
1502 WORD8 i1_yd_index, i1_xd_index;
1503
1504 ps_seg_y_tmp = &ps_seg_desc_y[i4_j];
1505 i4_y = i4_y_start_pos + ps_seg_y_tmp->u1_seg_off;
1506 u1_seg_ht = ps_seg_y_tmp->u1_seg_dim;
1507 i1_yd_index = ps_seg_y_tmp->i1_dist_idx;
1508 i1_nearst_mb_bdry_y = ps_seg_y_tmp->i1_nearst_mb_bdry;
1509 u1_mb_adjoin_y = ps_seg_y_tmp->u1_mb_adjoin;
1510 i4_idx_a = pu1_ref_idx_y[i4_y];
1511 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 u4_lookup_4bit = u4_4thbit | u1_avail_map[i4_idx_a][i4_cur_x + 2] << 2 |
1516 u1_avail_map[i4_idx_a][i4_cur_x + 1] << 1 |
1517 u1_avail_map[i4_idx_a][i4_cur_x];
1518
1519 u4_num_valid_segs = gu4_valid_segs_lookup[u4_lookup_4bit];
1520 i4_i = isvcd_left_most_bit_detect(u4_num_valid_segs);
1521 u4_num_valid_segs <<= (i4_i + 1);
1522
1523 for(; i4_i < u1_num_sgmts_x; i4_i++)
1524 {
1525 ps_seg_x_tmp = &ps_seg_desc_x[i4_i];
1526 i4_x = i4_x_start_pos + ps_seg_x_tmp->u1_seg_off;
1527 i4_idx_b = pu1_ref_idx_x[i4_x];
1528 u1_seg_wd = ps_seg_x_tmp->u1_seg_dim;
1529 i1_xd_index = ps_seg_x_tmp->i1_dist_idx;
1530 i1_nearst_mb_bdry_x = ps_seg_x_tmp->i1_nearst_mb_bdry;
1531 u1_mb_adjoin_x = ps_seg_x_tmp->u1_mb_adjoin;
1532 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 u4_lookup_5bit = u1_avail_map[i4_idx_a_plus_ny][i4_idx_b_plus_nx] << 2 |
1536 u1_avail_map[i4_idx_a_plus_ny][i4_idx_b] << 1 |
1537 u1_avail_map[i4_idx_a][i4_idx_b_plus_nx] | u1_mb_adjoin_x |
1538 u1_mb_adjoin_y;
1539
1540 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 if(u4_lookup_5bit > 31)
1544 {
1545 u4_lookup_5bit = 0;
1546 }
1547 pf_intra_samp_padding = pf_intra_samp_lookup[u4_lookup_5bit];
1548
1549 if(pf_intra_samp_padding != NULL)
1550 {
1551 pf_intra_samp_padding(i4_x, i4_y, i1_xd_index, i1_yd_index, u1_seg_wd, u1_seg_ht,
1552 pu1_refarray_1, pu1_refarray_2, i4_refarray_stride,
1553 u1_mb_adjoin_x, u1_mb_adjoin_y, i4_corner_pixel_available);
1554 }
1555
1556 /* increment to the next unavailable segment */
1557 i4_index = isvcd_left_most_bit_detect(u4_num_valid_segs);
1558 u4_num_valid_segs <<= (i4_index + 1);
1559 i4_i += i4_index;
1560
1561 } /* end of loop over ref array width */
1562
1563 } /* end of loop over ref array height */
1564 return;
1565 }
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 /*****************************************************************************/
isvcd_get_ref_layer_mbtype(WORD8 * pi1_ref_mb_modes,WORD32 * pi4_mb_type,WORD8 i1_curr_slice_id,WORD8 i1_cons_intr_samp_flag)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 {
1598 WORD8 i1_intra_slice_id;
1599 inter_lyr_mb_prms_t *ps_inter_lyr_mb_prms;
1600 WORD8 i1_mb_mode;
1601
1602 ps_inter_lyr_mb_prms = (inter_lyr_mb_prms_t *) pi1_ref_mb_modes;
1603 i1_mb_mode = ps_inter_lyr_mb_prms->i1_mb_mode;
1604
1605 if(i1_mb_mode <= SVC_INTER_MB)
1606 {
1607 /* INTER */
1608 *pi4_mb_type = SVC_INTER_MB;
1609 i1_intra_slice_id = -1;
1610 }
1611 else
1612 {
1613 /* INTRA */
1614 *pi4_mb_type = SVC_INTRA_MB;
1615 i1_intra_slice_id = ps_inter_lyr_mb_prms->i1_slice_id;
1616
1617 if(1 == i1_cons_intr_samp_flag)
1618 {
1619 /* check for different slice idc */
1620 if(ps_inter_lyr_mb_prms->i1_slice_id != i1_curr_slice_id)
1621 {
1622 /* store the mode as INTER (not available for upsampling) */
1623 *pi4_mb_type = SVC_INTER_MB;
1624 }
1625 }
1626 }
1627
1628 /* if contarained intra flag is 1 then check for same mb mode */
1629 return (i1_intra_slice_id);
1630 }
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 /*****************************************************************************/
isvcd_reflayer_construction(void * pv_intra_samp_ctxt,UWORD8 * pu1_inp_1,UWORD8 * pu1_inp_2,WORD32 i4_inp_stride,WORD32 i4_refarray_stride,mem_element_t * ps_ref_mb_mode_map,mb_coord_t * ps_coord,WORD32 i4_chroma_flag)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 {
1667 WORD32 i4_x, i4_y;
1668
1669 /* --------------------------------------------------------------------- */
1670 /* Context and reference layer realted varaibles */
1671 /* --------------------------------------------------------------------- */
1672 intra_sampling_ctxt_t *ps_ctxt;
1673 intra_samp_map_ctxt_t *ps_map_ctxt;
1674 intra_samp_lyr_ctxt *ps_lyr_ctxt;
1675 WORD8 *pi1_ref_mb_modes, *pi1_ref_mb_modes_bkp_1;
1676 WORD32 i4_ref_mode_stride;
1677 WORD32 i4_element_size;
1678 ref_mb_map_t *ps_x_off_len;
1679 ref_mb_map_t *ps_y_off_len;
1680 WORD32 i4_mbaddr_y;
1681 WORD32 i4_mbaddr_x;
1682 WORD32 i4_mb_ht, i4_mb_wd;
1683 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 WORD32 i4_ref_wd;
1688 WORD32 i4_ref_ht;
1689 WORD32 i4_x_offset;
1690 WORD32 i4_y_offset;
1691 WORD32 i4_refarray_wd;
1692 WORD32 i4_refarray_ht;
1693 WORD32 i4_mb_type;
1694 WORD8 i1_cons_intr_samp_flag;
1695 WORD8 i1_slice_id = 0;
1696 WORD32 i4_mb_wd_sft, i4_mb_ht_sft;
1697
1698 /* --------------------------------------------------------------------- */
1699 /* Local Pointer Declaration for arrays in Mapping context */
1700 /* --------------------------------------------------------------------- */
1701
1702 WORD32 i4_unfill_check;
1703 UWORD8 *pu1_refarray_1, *pu1_refarray_2;
1704
1705 UNUSED(pu1_inp_2);
1706
1707 ps_ctxt = (intra_sampling_ctxt_t *) pv_intra_samp_ctxt;
1708 ps_lyr_ctxt = &ps_ctxt->as_res_lyrs[ps_ctxt->i4_res_lyr_id];
1709 pi1_ref_mb_modes = (WORD8 *) ps_ref_mb_mode_map->pv_buffer;
1710 i4_ref_mode_stride = ps_ref_mb_mode_map->i4_num_element_stride;
1711 i4_element_size = ps_ref_mb_mode_map->i4_element_size;
1712
1713 /* get the condtrained intra sampling flag */
1714 i1_cons_intr_samp_flag = ps_lyr_ctxt->i1_constrained_intra_rsmpl_flag;
1715
1716 if(NULL == pi1_ref_mb_modes)
1717 {
1718 return NOT_OK;
1719 }
1720
1721 /* --------------------------------------------------------------------- */
1722 /* Based on Chroma and Luma, extracting the context information struct */
1723 /* --------------------------------------------------------------------- */
1724 if(1 == i4_chroma_flag)
1725 ps_map_ctxt = &ps_lyr_ctxt->s_chroma_map_ctxt;
1726 else
1727 ps_map_ctxt = &ps_lyr_ctxt->s_luma_map_ctxt;
1728
1729 ps_x_off_len = ps_map_ctxt->ps_x_offset_length;
1730 ps_y_off_len = ps_map_ctxt->ps_y_offset_length;
1731
1732 /* --------------------------------------------------------------------- */
1733 /* Deriving the parameters required for further processing */
1734 /* --------------------------------------------------------------------- */
1735 {
1736 WORD32 i4_base_width = ps_lyr_ctxt->i4_ref_width;
1737 WORD32 i4_base_height = ps_lyr_ctxt->i4_ref_height;
1738
1739 i4_ref_wd = i4_base_width >> i4_chroma_flag;
1740 i4_ref_ht = i4_base_height >> i4_chroma_flag;
1741 i4_mb_wd_sft = (MB_WIDTH_SHIFT - i4_chroma_flag);
1742 i4_mb_ht_sft = (MB_HEIGHT_SHIFT - i4_chroma_flag);
1743 }
1744
1745 /* --------------------------------------------------------------------- */
1746 /* Local variables based on the MB address */
1747 /* --------------------------------------------------------------------- */
1748 i4_mbaddr_y = ps_coord->u2_mb_y;
1749 i4_mbaddr_x = ps_coord->u2_mb_x;
1750 i4_x_offset = ps_x_off_len[i4_mbaddr_x].i2_offset;
1751 i4_y_offset = ps_y_off_len[i4_mbaddr_y].i2_offset;
1752 i4_refarray_wd = ps_x_off_len[i4_mbaddr_x].i2_length;
1753 i4_refarray_ht = ps_y_off_len[i4_mbaddr_y].i2_length;
1754 i4_mb_wd = (MB_WIDTH >> i4_chroma_flag);
1755 i4_mb_ht = (MB_HEIGHT >> i4_chroma_flag);
1756
1757 /* --------------------------------------------------------------------- */
1758 /* Derivation of ref slice MB idc */
1759 /* --------------------------------------------------------------------- */
1760 if(1 == i1_cons_intr_samp_flag)
1761 {
1762 WORD32 i4_x_min, i4_x_max;
1763 WORD32 i4_y_min, i4_y_max;
1764 ref_min_max_map_t *ps_x_min_max;
1765 ref_min_max_map_t *ps_y_min_max;
1766
1767 ps_x_min_max = ps_map_ctxt->ps_x_min_max;
1768 ps_y_min_max = ps_map_ctxt->ps_y_min_max;
1769
1770 /* get the min and max positions */
1771 i4_x_min = ps_x_min_max[i4_mbaddr_x].i2_min_pos;
1772 i4_x_max = ps_x_min_max[i4_mbaddr_x].i2_max_pos;
1773 i4_y_min = ps_y_min_max[i4_mbaddr_y].i2_min_pos;
1774 i4_y_max = ps_y_min_max[i4_mbaddr_y].i2_max_pos;
1775
1776 /* default initialization */
1777 i4_mb_type = SVC_INTER_MB;
1778
1779 {
1780 WORD32 i4_x_ref;
1781 WORD32 i4_y_ref;
1782 WORD32 i4_mb_x, i4_mb_y;
1783
1784 i4_y_ref = (i4_y_min + 1) + i4_y_offset;
1785 i4_x_ref = (i4_x_min + 1) + i4_x_offset;
1786 i4_mb_x = (i4_x_ref >> i4_mb_wd_sft);
1787 i4_mb_y = (i4_y_ref >> i4_mb_ht_sft);
1788 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 pi1_ref_mb_modes += (i4_mb_y * i4_ref_mode_stride * i4_element_size);
1792 pi1_ref_mb_modes += (i4_mb_x * i4_element_size);
1793 }
1794
1795 for(i4_y = (i4_y_min + 1); i4_y <= (i4_y_max - 1);)
1796 {
1797 WORD32 i4_x_ref;
1798 WORD32 i4_y_ref;
1799 WORD32 i4_distleftX, i4_rangeX;
1800 WORD32 i4_disttopY, i4_rangeY;
1801
1802 i4_y_ref = (i4_y + i4_y_offset);
1803 i4_disttopY = (i4_y_ref) & (i4_mb_ht - 1);
1804 i4_rangeY = (i4_mb_ht - i4_disttopY);
1805
1806 pi1_ref_mb_modes_bkp_1 = pi1_ref_mb_modes;
1807
1808 for(i4_x = (i4_x_min + 1); i4_x <= (i4_x_max - 1);)
1809 {
1810 i4_x_ref = (i4_x + i4_x_offset);
1811 i4_distleftX = (i4_x_ref) & (i4_mb_wd - 1);
1812 i4_rangeX = (i4_mb_wd - i4_distleftX);
1813
1814 /* get the referecne layer mb type */
1815 i1_slice_id =
1816 isvcd_get_ref_layer_mbtype(pi1_ref_mb_modes_bkp_1, &i4_mb_type, i1_slice_id, 0);
1817 if(SVC_INTRA_MB == i4_mb_type)
1818 {
1819 /* if an Intra MB is returned then break the loop */
1820 break;
1821 }
1822
1823 i4_x += i4_rangeX;
1824 pi1_ref_mb_modes_bkp_1 += i4_element_size;
1825 } /* end of loop in horizontal direction */
1826
1827 if(SVC_INTRA_MB == i4_mb_type)
1828 {
1829 /* if an Intra MB is returned then break the loop */
1830 break;
1831 }
1832
1833 i4_y += i4_rangeY;
1834 pi1_ref_mb_modes += (i4_ref_mode_stride * i4_element_size);
1835
1836 } /* end of loop in vertical direction */
1837 }
1838 else
1839 {
1840 /* set to non valid value */
1841 i1_slice_id = -1;
1842 }
1843
1844 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 {
1853 WORD32 i4_x_ref_start, i4_x_ref_end;
1854 WORD32 i4_y_ref_start, i4_y_ref_end;
1855 WORD32 i4_rangeW, i4_rangeH;
1856 WORD32 i4_offset;
1857 UWORD8 *pu1_src, *pu1_dst;
1858 UWORD8 *pu1_dst1, *pu1_dst2;
1859
1860 /* Copy (refW x refH) dimension into reference sample array */
1861 i4_x_ref_start = MAX(0, MIN((i4_ref_wd - 1), i4_x_offset));
1862 i4_x_ref_end = MAX(0, MIN((i4_ref_wd - 1), (i4_refarray_wd - 1) + i4_x_offset));
1863 i4_y_ref_start = MAX(0, MIN((i4_ref_ht - 1), i4_y_offset));
1864 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 i4_rangeW = (i4_x_ref_end - i4_x_ref_start + 1);
1868 i4_rangeH = (i4_y_ref_end - i4_y_ref_start + 1);
1869
1870 /* get the reconbuffer pointer and ref sample array pointer */
1871 i4_offset =
1872 (i4_x_ref_start - i4_x_offset) + ((i4_y_ref_start - i4_y_offset) * i4_refarray_stride);
1873
1874 if(0 == i4_chroma_flag)
1875 {
1876 pu1_refarray_1 = ps_ctxt->pu1_refarray_buffer;
1877 pu1_refarray_2 = NULL;
1878 pu1_src = pu1_inp_1;
1879 pu1_dst = pu1_refarray_1 + i4_offset;
1880
1881 /* Copy luma data into refsample array */
1882 isvcd_copy_data(pu1_src, i4_inp_stride, pu1_dst, i4_refarray_stride, i4_rangeW,
1883 i4_rangeH);
1884 }
1885 else
1886 {
1887 pu1_refarray_1 = ps_ctxt->pu1_refarray_buffer;
1888 pu1_refarray_2 = ps_ctxt->pu1_refarray_cb;
1889 pu1_src = pu1_inp_1;
1890 pu1_dst1 = pu1_refarray_1 + i4_offset;
1891 pu1_dst2 = pu1_refarray_2 + i4_offset;
1892 isvcd_copy_data_semiplanr(pu1_src, i4_inp_stride, pu1_dst1, pu1_dst2,
1893 i4_refarray_stride, i4_rangeW, i4_rangeH);
1894 }
1895 }
1896
1897 /* --------------------------------------------------------------------- */
1898 /* Loop to fill ref sample array and corresponding map for interpolation */
1899 /* --------------------------------------------------------------------- */
1900 {
1901 WORD32 i4_i, i4_j;
1902 UWORD8 *pu1_ref_idx_x, *pu1_ref_idx_y;
1903 WORD32 i4_x_ref;
1904 WORD32 i4_y_ref;
1905 WORD32 i4_mb_x, i4_mb_y;
1906
1907 i4_y_ref = i4_y_offset;
1908 i4_x_ref = i4_x_offset;
1909 i4_mb_x = (i4_x_ref >> i4_mb_wd_sft);
1910 i4_mb_y = (i4_y_ref >> i4_mb_ht_sft);
1911 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 pi1_ref_mb_modes += (i4_mb_y * i4_ref_mode_stride * i4_element_size);
1915 pi1_ref_mb_modes += (i4_mb_x * i4_element_size);
1916 pu1_ref_idx_x = ps_map_ctxt->pu1_refarray_x_idx;
1917 pu1_ref_idx_y = ps_map_ctxt->pu1_refarray_y_idx;
1918
1919 i4_j = 0;
1920 for(i4_y = 0; i4_y < i4_refarray_ht;)
1921 {
1922 WORD32 i4_x_ref;
1923 WORD32 i4_y_ref;
1924 WORD32 i4_distleftX, i4_rangeX;
1925 WORD32 i4_disttopY, i4_rangeY;
1926
1927 i4_y_ref = i4_y + i4_y_offset;
1928 i4_disttopY = (i4_y_ref) & (i4_mb_ht - 1);
1929 i4_rangeY = (i4_mb_ht - i4_disttopY);
1930
1931 /* find the y-index lookup */
1932 memset(pu1_ref_idx_y, i4_j, i4_rangeY);
1933 pu1_ref_idx_y += i4_rangeY;
1934
1935 i4_i = 0;
1936 pi1_ref_mb_modes_bkp_1 = pi1_ref_mb_modes;
1937 for(i4_x = 0; i4_x < i4_refarray_wd;)
1938 {
1939 i4_x_ref = i4_x + i4_x_offset;
1940 i4_distleftX = (i4_x_ref) & (i4_mb_wd - 1);
1941 i4_rangeX = (i4_mb_wd - i4_distleftX);
1942
1943 if(0 == i4_j)
1944 {
1945 /* find the x-index lookup */
1946 memset(pu1_ref_idx_x, i4_i, i4_rangeX);
1947 pu1_ref_idx_x += i4_rangeX;
1948 }
1949
1950 /* get the referecne layer mb type */
1951 isvcd_get_ref_layer_mbtype(pi1_ref_mb_modes_bkp_1, &i4_mb_type, i1_slice_id,
1952 i1_cons_intr_samp_flag);
1953
1954 if(SVC_INTRA_MB == i4_mb_type)
1955 {
1956 u1_map_buf[i4_j][i4_i] = 1;
1957 }
1958 else
1959 {
1960 i4_unfill_check = 1;
1961 }
1962
1963 i4_x = i4_x + i4_rangeX;
1964 i4_i++;
1965 pi1_ref_mb_modes_bkp_1 += i4_element_size;
1966
1967 } /* end of loop over ref array width */
1968
1969 i4_j++;
1970 i4_y = i4_y + i4_rangeY;
1971 pi1_ref_mb_modes += (i4_ref_mode_stride * i4_element_size);
1972 } /* end of loop over ref array height */
1973 }
1974
1975 /* --------------------------------------------------------------------- */
1976 /* Calling boundary extension algorithm to fill unfilled pixels */
1977 /* --------------------------------------------------------------------- */
1978 if(i4_unfill_check == 1)
1979 {
1980 isvcd_fill_non_avail_pixel(ps_map_ctxt, pu1_refarray_1, pu1_refarray_2, i4_refarray_stride,
1981 ps_coord, i4_chroma_flag, u1_map_buf);
1982 }
1983 return OK;
1984 }
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 /*****************************************************************************/
isvcd_reflayer_construction_dyadic(void * pv_intra_samp_ctxt,mem_element_t * ps_ref_mb_mode_map,UWORD8 * pu1_inp_luma,UWORD8 * pu1_inp_chroma,WORD32 i4_inp_luma_stride,WORD32 i4_inp_chroma_stride,WORD32 i4_top,WORD32 i4_left,UWORD16 u2_mb_x,UWORD16 u2_mb_y)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 {
2026 /* Index variables */
2027 WORD32 i4_x, i4_y;
2028 WORD32 i4_x0, i4_y0;
2029 WORD32 i4_xc0, i4_yc0;
2030 WORD32 i4_ref_xD, i4_ref_yD;
2031 WORD32 i4_c_ref_xD, i4_c_ref_yD;
2032
2033 /* --------------------------------------------------------------------- */
2034 /* Context and reference layer related variables */
2035 /* --------------------------------------------------------------------- */
2036 intra_sampling_ctxt_t *ps_ctxt;
2037 intra_samp_lyr_ctxt *ps_lyr_ctxt;
2038 WORD8 *pi1_ref_mb_modes;
2039 WORD32 i4_ref_mode_stride;
2040 WORD32 i4_element_size;
2041 WORD32 i4_mbaddr_y;
2042 WORD32 i4_mbaddr_x;
2043
2044 /* --------------------------------------------------------------------- */
2045 /* Temp Variables for Mapping context */
2046 /* --------------------------------------------------------------------- */
2047 WORD32 i4_refarray_wd_luma, i4_refarray_wd_chroma;
2048 WORD32 i4_refarray_ht_luma, i4_refarray_ht_chroma;
2049 WORD32 i4_avlblty;
2050 WORD8 i1_cons_intr_samp_flag;
2051 WORD8 i1_slice_id;
2052 WORD8 i1_corner_samp_avlbl_flag;
2053 UWORD8 u1_ny_avlblty;
2054
2055 /* --------------------------------------------------------------------- */
2056 /* Local Pointer Declaration for arrays in Mapping context */
2057 /* --------------------------------------------------------------------- */
2058 UWORD8 *pu1_refarray_luma;
2059 UWORD8 *pu1_refarray_cb, *pu1_refarray_cr;
2060
2061 /* --------------------------------------------------------------------- */
2062 /* Derivation of local variables */
2063 /* --------------------------------------------------------------------- */
2064 ps_ctxt = (intra_sampling_ctxt_t *) pv_intra_samp_ctxt;
2065 ps_lyr_ctxt = &ps_ctxt->as_res_lyrs[ps_ctxt->i4_res_lyr_id];
2066 pi1_ref_mb_modes = (WORD8 *) ps_ref_mb_mode_map->pv_buffer;
2067 i4_ref_mode_stride = ps_ref_mb_mode_map->i4_num_element_stride;
2068 i4_element_size = ps_ref_mb_mode_map->i4_element_size;
2069
2070 /* --------------------------------------------------------------------- */
2071 /* get the constrained intra resampling flag */
2072 /* --------------------------------------------------------------------- */
2073 i1_cons_intr_samp_flag = ps_lyr_ctxt->i1_constrained_intra_rsmpl_flag;
2074 if(NULL == pi1_ref_mb_modes)
2075 {
2076 return NOT_OK;
2077 }
2078
2079 pu1_refarray_luma = ps_ctxt->pu1_refarray_buffer;
2080 pu1_refarray_cb = ps_ctxt->pu1_refarray_cb;
2081 pu1_refarray_cr = ps_ctxt->pu1_refarray_cr;
2082
2083 /* --------------------------------------------------------------------- */
2084 /* Get the coordinates of the reference layer MB */
2085 /* --------------------------------------------------------------------- */
2086 i4_mbaddr_x = u2_mb_x;
2087 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 i4_refarray_wd_luma = 20;
2093 i4_refarray_ht_luma = 20;
2094 i4_refarray_wd_chroma = i4_refarray_wd_luma >> 1;
2095 i4_refarray_ht_chroma = i4_refarray_ht_luma >> 1;
2096
2097 /* --------------------------------------------------------------------- */
2098 /* Derivation of ref slice MB idc */
2099 /* --------------------------------------------------------------------- */
2100 if(1 == i1_cons_intr_samp_flag)
2101 {
2102 inter_lyr_mb_prms_t *ps_inter_lyr_mb_prms;
2103 WORD8 *pi1_ref_mb_mode_tmp;
2104 WORD8 i1_mb_mode;
2105
2106 /* get the location of the byte which has the current mb mode */
2107 pi1_ref_mb_mode_tmp = pi1_ref_mb_modes;
2108 pi1_ref_mb_mode_tmp += (i4_mbaddr_y * i4_ref_mode_stride * i4_element_size);
2109 pi1_ref_mb_mode_tmp += (i4_mbaddr_x * i4_element_size);
2110 ps_inter_lyr_mb_prms = (inter_lyr_mb_prms_t *) pi1_ref_mb_mode_tmp;
2111 i1_mb_mode = ps_inter_lyr_mb_prms->i1_mb_mode;
2112
2113 /* The reference layer MB should be intra */
2114 UNUSED(i1_mb_mode);
2115
2116 i1_slice_id = ps_inter_lyr_mb_prms->i1_slice_id;
2117 }
2118 else
2119 {
2120 /* set to non valid value */
2121 i1_slice_id = -1;
2122 }
2123
2124 /* --------------------------------------------------------------------- */
2125 /* Bring in the reference array */
2126 /* --------------------------------------------------------------------- */
2127 {
2128 UWORD8 *pu1_src, *pu1_dst;
2129 WORD32 i4_src_stride, i4_dst_stride;
2130
2131 /* Copy luma */
2132 i4_src_stride = i4_inp_luma_stride;
2133 i4_dst_stride = DYADIC_REF_W_Y;
2134 pu1_src = pu1_inp_luma;
2135 pu1_dst = pu1_refarray_luma;
2136 isvcd_copy_data(pu1_src, i4_src_stride, pu1_dst, i4_dst_stride, i4_refarray_wd_luma,
2137 i4_refarray_ht_luma);
2138 // Semi planar
2139 i4_src_stride = i4_inp_chroma_stride;
2140 i4_dst_stride = DYADIC_REF_W_C;
2141 pu1_src = pu1_inp_chroma;
2142 isvcd_copy_data_semiplanr(pu1_src, i4_src_stride, pu1_refarray_cb, pu1_refarray_cr,
2143 i4_dst_stride, i4_refarray_wd_chroma, i4_refarray_ht_chroma);
2144 }
2145
2146 /* --------------------------------------------------------------------- */
2147 /* Get the availability of 5 neighboring MBs */
2148 /* --------------------------------------------------------------------- */
2149 {
2150 /* mb_x + left, mb_y + top */
2151 isvcd_get_ref_layer_avlblty_dyadic(pi1_ref_mb_modes, i4_ref_mode_stride, i4_element_size,
2152 i4_mbaddr_x + i4_left, i4_mbaddr_y + i4_top, &i4_avlblty,
2153 i1_slice_id, i1_cons_intr_samp_flag);
2154 u1_ny_avlblty = i4_avlblty;
2155
2156 /* mb_x + left, mb_y */
2157 isvcd_get_ref_layer_avlblty_dyadic(pi1_ref_mb_modes, i4_ref_mode_stride, i4_element_size,
2158 i4_mbaddr_x + i4_left, i4_mbaddr_y, &i4_avlblty,
2159 i1_slice_id, i1_cons_intr_samp_flag);
2160 u1_ny_avlblty += (i4_avlblty << 1);
2161
2162 /* mb_x, mb_y + top */
2163 isvcd_get_ref_layer_avlblty_dyadic(pi1_ref_mb_modes, i4_ref_mode_stride, i4_element_size,
2164 i4_mbaddr_x, i4_mbaddr_y + i4_top, &i4_avlblty,
2165 i1_slice_id, i1_cons_intr_samp_flag);
2166 u1_ny_avlblty += (i4_avlblty << 2);
2167
2168 /* mb_x - left, mb_y + top */
2169 isvcd_get_ref_layer_avlblty_dyadic(pi1_ref_mb_modes, i4_ref_mode_stride, i4_element_size,
2170 i4_mbaddr_x - i4_left, i4_mbaddr_y + i4_top, &i4_avlblty,
2171 i1_slice_id, i1_cons_intr_samp_flag);
2172 u1_ny_avlblty += (i4_avlblty << 3);
2173
2174 /* mb_x + left, mb_y - top */
2175 isvcd_get_ref_layer_avlblty_dyadic(pi1_ref_mb_modes, i4_ref_mode_stride, i4_element_size,
2176 i4_mbaddr_x + i4_left, i4_mbaddr_y - i4_top, &i4_avlblty,
2177 i1_slice_id, i1_cons_intr_samp_flag);
2178 u1_ny_avlblty += (i4_avlblty << 4);
2179 }
2180
2181 /* --------------------------------------------------------------------- */
2182 /* Filling the unavailable samples, if any */
2183 /* --------------------------------------------------------------------- */
2184 if(0x7 == u1_ny_avlblty)
2185 {
2186 /* All are available, exit */
2187 return OK;
2188 }
2189
2190 if(!(u1_ny_avlblty & 0x7))
2191 {
2192 UWORD8 *pu1_tmp_src, *pu1_tmp_dst1, *pu1_tmp_dst2;
2193 UWORD8 *pu1_tmp_src1, *pu1_tmp_src2;
2194
2195 /* Set the 4 corner samples to (x-xD,y-yD) */
2196 i4_x0 = 9 + (i4_left << 3) + i4_left;
2197 i4_y0 = 9 + (i4_top << 3) + i4_top;
2198
2199 i4_ref_xD = i4_x0 - i4_left - (i4_left >> 1);
2200 i4_ref_yD = i4_y0 - i4_top - (i4_top >> 1);
2201
2202 pu1_tmp_src = pu1_refarray_luma + (i4_ref_yD * DYADIC_REF_W_Y);
2203 pu1_tmp_dst1 = pu1_refarray_luma + (i4_y0 * DYADIC_REF_W_Y);
2204 pu1_tmp_dst2 = pu1_tmp_dst1 + DYADIC_REF_W_Y;
2205 pu1_tmp_dst1[i4_x0] = pu1_tmp_src[i4_ref_xD];
2206 pu1_tmp_dst1[i4_x0 + 1] = pu1_tmp_src[i4_ref_xD];
2207 pu1_tmp_dst2[i4_x0] = pu1_tmp_src[i4_ref_xD];
2208 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 i4_xc0 = i4_x0 >> 1;
2212 i4_yc0 = i4_y0 >> 1;
2213 i4_c_ref_yD = i4_ref_yD >> 1;
2214 i4_c_ref_xD = i4_ref_xD >> 1;
2215 pu1_tmp_src1 = pu1_refarray_cb + (i4_c_ref_yD * DYADIC_REF_W_C);
2216 pu1_tmp_dst1 = pu1_refarray_cb + (i4_yc0 * DYADIC_REF_W_C);
2217 pu1_tmp_dst1[i4_xc0] = pu1_tmp_src1[i4_c_ref_xD];
2218 pu1_tmp_src2 = pu1_refarray_cr + (i4_c_ref_yD * DYADIC_REF_W_C);
2219 pu1_tmp_dst2 = pu1_refarray_cr + (i4_yc0 * DYADIC_REF_W_C);
2220 pu1_tmp_dst2[i4_xc0] = pu1_tmp_src2[i4_c_ref_xD];
2221 }
2222
2223 if(!(u1_ny_avlblty & 0x5))
2224 {
2225 UWORD8 *pu1_tmp_src, *pu1_tmp_dst1, *pu1_tmp_dst2;
2226 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 i4_x0 = 2;
2232 i4_y0 = 9 + (i4_top << 3) + i4_top;
2233 if(i4_left > 0)
2234 {
2235 i4_x0 += 8;
2236 }
2237 i4_ref_yD = i4_y0 - i4_top - (i4_top >> 1);
2238
2239 pu1_tmp_src = pu1_refarray_luma + (i4_ref_yD * DYADIC_REF_W_Y);
2240 pu1_tmp_dst1 = pu1_refarray_luma + (i4_y0 * DYADIC_REF_W_Y);
2241 pu1_tmp_dst2 = pu1_tmp_dst1 + DYADIC_REF_W_Y;
2242
2243 for(i4_x = i4_x0; i4_x < i4_x0 + 8; i4_x++)
2244 {
2245 pu1_tmp_dst1[i4_x] = pu1_tmp_src[i4_x];
2246 pu1_tmp_dst2[i4_x] = pu1_tmp_src[i4_x];
2247 }
2248
2249 /* Cb and Cr copy */
2250 i4_xc0 = i4_x0 >> 1;
2251 i4_yc0 = i4_y0 >> 1;
2252 i4_c_ref_yD = i4_ref_yD >> 1;
2253 pu1_tmp_src1 = pu1_refarray_cb + (i4_c_ref_yD * DYADIC_REF_W_C);
2254 pu1_tmp_dst1 = pu1_refarray_cb + (i4_yc0 * DYADIC_REF_W_C);
2255 pu1_tmp_src2 = pu1_refarray_cr + (i4_c_ref_yD * DYADIC_REF_W_C);
2256 pu1_tmp_dst2 = pu1_refarray_cr + (i4_yc0 * DYADIC_REF_W_C);
2257
2258 for(i4_x = i4_xc0; i4_x < i4_xc0 + 4; i4_x++)
2259 {
2260 pu1_tmp_dst1[i4_x] = pu1_tmp_src1[i4_x];
2261 pu1_tmp_dst2[i4_x] = pu1_tmp_src2[i4_x];
2262 }
2263 }
2264
2265 if(!(u1_ny_avlblty & 0x3))
2266 {
2267 UWORD8 *pu1_tmp_src, *pu1_tmp_dst1, *pu1_tmp_dst2;
2268 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 i4_x0 = 9 + (i4_left << 3) + i4_left;
2274 i4_y0 = 2;
2275 if(i4_top > 0)
2276 {
2277 i4_y0 += 8;
2278 }
2279 i4_ref_xD = i4_x0 - i4_left - (i4_left >> 1);
2280
2281 pu1_tmp_src = pu1_refarray_luma + (i4_y0 * DYADIC_REF_W_Y);
2282 pu1_tmp_dst1 = pu1_tmp_src;
2283
2284 for(i4_y = i4_y0; i4_y < i4_y0 + 8; i4_y++)
2285 {
2286 pu1_tmp_dst1[i4_x0] = pu1_tmp_src[i4_ref_xD];
2287 pu1_tmp_dst1[i4_x0 + 1] = pu1_tmp_src[i4_ref_xD];
2288 pu1_tmp_src += DYADIC_REF_W_Y;
2289 pu1_tmp_dst1 += DYADIC_REF_W_Y;
2290 }
2291
2292 /* Cb and Cr copy */
2293 i4_xc0 = i4_x0 >> 1;
2294 i4_yc0 = i4_y0 >> 1;
2295 i4_c_ref_xD = i4_ref_xD >> 1;
2296 pu1_tmp_src1 = pu1_refarray_cb + (i4_yc0 * DYADIC_REF_W_C);
2297 pu1_tmp_dst1 = pu1_tmp_src1;
2298 pu1_tmp_src2 = pu1_refarray_cr + (i4_yc0 * DYADIC_REF_W_C);
2299 pu1_tmp_dst2 = pu1_tmp_src2;
2300
2301 for(i4_y = i4_yc0; i4_y < i4_yc0 + 4; i4_y++)
2302 {
2303 pu1_tmp_dst1[i4_xc0] = pu1_tmp_src1[i4_c_ref_xD];
2304 pu1_tmp_dst2[i4_xc0] = pu1_tmp_src2[i4_c_ref_xD];
2305 pu1_tmp_src1 += DYADIC_REF_W_C;
2306 pu1_tmp_src2 += DYADIC_REF_W_C;
2307 pu1_tmp_dst1 += DYADIC_REF_W_C;
2308 pu1_tmp_dst2 += DYADIC_REF_W_C;
2309 }
2310 }
2311
2312 if(!(u1_ny_avlblty & 0x4))
2313 {
2314 if(!(u1_ny_avlblty & 0x8))
2315 {
2316 /* (mb_x-left,mb_y+top) not available */
2317 UWORD8 *pu1_tmp_src, *pu1_tmp_dst;
2318
2319 i4_x0 = 9 - i4_left;
2320 i4_y0 = 9 + (i4_top << 3) + i4_top;
2321
2322 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 pu1_tmp_src = pu1_refarray_luma + (i4_ref_yD * DYADIC_REF_W_Y);
2327 pu1_tmp_dst = pu1_refarray_luma + (i4_y0 * DYADIC_REF_W_Y);
2328 pu1_tmp_dst[i4_x0] = pu1_tmp_src[i4_x0];
2329 pu1_tmp_dst[i4_x0 + 1] = pu1_tmp_src[i4_x0 + 1];
2330 pu1_tmp_dst += DYADIC_REF_W_Y;
2331 pu1_tmp_dst[i4_x0] = pu1_tmp_src[i4_x0];
2332 pu1_tmp_dst[i4_x0 + 1] = pu1_tmp_src[i4_x0 + 1];
2333
2334 /* Cb copy */
2335 i4_xc0 = i4_x0 >> 1;
2336 i4_yc0 = i4_y0 >> 1;
2337 i4_c_ref_yD = i4_ref_yD >> 1;
2338 pu1_tmp_src = pu1_refarray_cb + (i4_c_ref_yD * DYADIC_REF_W_C);
2339 pu1_tmp_dst = pu1_refarray_cb + (i4_yc0 * DYADIC_REF_W_C);
2340 pu1_tmp_dst[i4_xc0] = pu1_tmp_src[i4_xc0];
2341
2342 /* Cr copy */
2343 pu1_tmp_src = pu1_refarray_cr + (i4_c_ref_yD * DYADIC_REF_W_C);
2344 pu1_tmp_dst = pu1_refarray_cr + (i4_yc0 * DYADIC_REF_W_C);
2345 pu1_tmp_dst[i4_xc0] = pu1_tmp_src[i4_xc0];
2346
2347 } /* if (mb_x-left,mb_y+top) not available */
2348 else
2349 {
2350 WORD32 i4_xD, i4_yD;
2351 WORD32 i4_c_xD, i4_c_yD;
2352
2353 isvcd_get_ref_layer_avlblty_dyadic(pi1_ref_mb_modes, i4_ref_mode_stride,
2354 i4_element_size, i4_mbaddr_x - i4_left, i4_mbaddr_y,
2355 &i4_avlblty, i1_slice_id, i1_cons_intr_samp_flag);
2356 i1_corner_samp_avlbl_flag = i4_avlblty;
2357
2358 i4_x0 = 9 - i4_left;
2359 i4_y0 = 9 + (i4_top << 3) + i4_top;
2360 i4_xc0 = i4_x0 >> 1;
2361 i4_yc0 = i4_y0 >> 1;
2362 i4_ref_yD = i4_y0 - i4_top - (i4_top >> 1);
2363 i4_ref_xD = i4_x0 - (i4_left * 7) - (i4_left >> 1);
2364 i4_c_ref_xD = i4_ref_xD >> 1;
2365 i4_c_ref_yD = i4_ref_yD >> 1;
2366 i4_xD = i4_x0 - i4_ref_xD;
2367 i4_yD = i4_y0 - i4_ref_yD;
2368 i4_c_xD = i4_xc0 - i4_c_ref_xD;
2369 i4_c_yD = i4_yc0 - i4_c_ref_yD;
2370
2371 /* Fill corner sample if not available */
2372 if(!i1_corner_samp_avlbl_flag)
2373 {
2374 isvcd_corner_samp_dyadic(i4_x0, i4_y0, i4_xD, i4_yD, pu1_refarray_luma,
2375 pu1_refarray_cb, pu1_refarray_cr);
2376 }
2377
2378 /* Call diagonal construction for luma */
2379 for(i4_y = i4_y0; i4_y < i4_y0 + 2; i4_y++)
2380 {
2381 for(i4_x = i4_x0; i4_x < i4_x0 + 2; i4_x++)
2382 {
2383 isvcd_diagonal_construct_dyadic(i4_x, i4_y, i4_xD, i4_yD, pu1_refarray_luma,
2384 DYADIC_REF_W_Y);
2385 i4_xD++;
2386 }
2387 i4_yD++;
2388 i4_xD -= 2;
2389 }
2390
2391 /* Call diagonal construction for chroma */
2392 isvcd_diagonal_construct_dyadic(i4_xc0, i4_yc0, i4_c_xD, i4_c_yD, pu1_refarray_cb,
2393 DYADIC_REF_W_C);
2394
2395 isvcd_diagonal_construct_dyadic(i4_xc0, i4_yc0, i4_c_xD, i4_c_yD, pu1_refarray_cr,
2396 DYADIC_REF_W_C);
2397 }
2398 }
2399
2400 if(!(u1_ny_avlblty & 0x2))
2401 {
2402 if(!(u1_ny_avlblty & 0x10))
2403 {
2404 UWORD8 *pu1_tmp_src, *pu1_tmp_dst;
2405
2406 i4_x0 = 9 + (i4_left << 3) + i4_left;
2407 i4_y0 = 9 - i4_top;
2408 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 pu1_tmp_src = pu1_refarray_luma + (i4_y0 * DYADIC_REF_W_Y);
2413 pu1_tmp_dst = pu1_tmp_src;
2414 pu1_tmp_dst[i4_x0] = pu1_tmp_src[i4_ref_xD];
2415 pu1_tmp_dst[i4_x0 + 1] = pu1_tmp_src[i4_ref_xD];
2416 pu1_tmp_src += DYADIC_REF_W_Y;
2417 pu1_tmp_dst += DYADIC_REF_W_Y;
2418 pu1_tmp_dst[i4_x0] = pu1_tmp_src[i4_ref_xD];
2419 pu1_tmp_dst[i4_x0 + 1] = pu1_tmp_src[i4_ref_xD];
2420
2421 /* Cb copy */
2422 i4_xc0 = i4_x0 >> 1;
2423 i4_yc0 = i4_y0 >> 1;
2424 i4_c_ref_xD = i4_ref_xD >> 1;
2425 pu1_tmp_src = pu1_refarray_cb + (i4_yc0 * DYADIC_REF_W_C);
2426 pu1_tmp_dst = pu1_tmp_src;
2427 pu1_tmp_dst[i4_xc0] = pu1_tmp_src[i4_c_ref_xD];
2428
2429 /* Cr copy */
2430 pu1_tmp_src = pu1_refarray_cr + (i4_yc0 * DYADIC_REF_W_C);
2431 pu1_tmp_dst = pu1_tmp_src;
2432 pu1_tmp_dst[i4_xc0] = pu1_tmp_src[i4_c_ref_xD];
2433
2434 } /* if (mb_x+left,mb_y-top) not available */
2435 else
2436 {
2437 WORD32 i4_xD, i4_yD;
2438 WORD32 i4_c_xD, i4_c_yD;
2439
2440 isvcd_get_ref_layer_avlblty_dyadic(pi1_ref_mb_modes, i4_ref_mode_stride,
2441 i4_element_size, i4_mbaddr_x, i4_mbaddr_y - i4_top,
2442 &i4_avlblty, i1_slice_id, i1_cons_intr_samp_flag);
2443 i1_corner_samp_avlbl_flag = i4_avlblty;
2444
2445 i4_x0 = 9 + (i4_left << 3) + i4_left;
2446 i4_y0 = 9 - i4_top;
2447 i4_xc0 = i4_x0 >> 1;
2448 i4_yc0 = i4_y0 >> 1;
2449 i4_ref_xD = i4_x0 - i4_left - (i4_left >> 1);
2450 i4_ref_yD = i4_y0 - (i4_top * 7) - (i4_top >> 1);
2451 i4_c_ref_xD = i4_ref_xD >> 1;
2452 i4_c_ref_yD = i4_ref_yD >> 1;
2453 i4_xD = i4_x0 - i4_ref_xD;
2454 i4_yD = i4_y0 - i4_ref_yD;
2455 i4_c_xD = i4_xc0 - i4_c_ref_xD;
2456 i4_c_yD = i4_yc0 - i4_c_ref_yD;
2457
2458 if(!i1_corner_samp_avlbl_flag)
2459 {
2460 isvcd_corner_samp_dyadic(i4_x0, i4_y0, i4_xD, i4_yD, pu1_refarray_luma,
2461 pu1_refarray_cb, pu1_refarray_cr);
2462 }
2463
2464 /* Call diagonal consrtuction for luma */
2465 for(i4_y = i4_y0; i4_y < i4_y0 + 2; i4_y++)
2466 {
2467 for(i4_x = i4_x0; i4_x < i4_x0 + 2; i4_x++)
2468 {
2469 isvcd_diagonal_construct_dyadic(i4_x, i4_y, i4_xD, i4_yD, pu1_refarray_luma,
2470 DYADIC_REF_W_Y);
2471 i4_xD++;
2472 }
2473 i4_yD++;
2474 i4_xD -= 2;
2475 }
2476
2477 /* Call diagonal construction for chroma */
2478 isvcd_diagonal_construct_dyadic(i4_xc0, i4_yc0, i4_c_xD, i4_c_yD, pu1_refarray_cb,
2479 DYADIC_REF_W_C);
2480
2481 isvcd_diagonal_construct_dyadic(i4_xc0, i4_yc0, i4_c_xD, i4_c_yD, pu1_refarray_cr,
2482 DYADIC_REF_W_C);
2483 }
2484 }
2485
2486 if(u1_ny_avlblty & 1)
2487 {
2488 if(!(u1_ny_avlblty & 2))
2489 {
2490 /* (mb_x+left,mb_y) is unavailable */
2491 WORD32 i4_xD, i4_yD;
2492 WORD32 i4_c_xD, i4_c_yD;
2493 UWORD8 *pu1_tmp_dst;
2494 UWORD8 u1_filled_samp;
2495
2496 i1_corner_samp_avlbl_flag = (u1_ny_avlblty & 4) >> 2;
2497
2498 i4_x0 = 9 + (i4_left << 3) + i4_left;
2499 i4_y0 = 2;
2500 i4_ref_yD = 1;
2501 if(i4_top > 0)
2502 {
2503 i4_y0 += 8;
2504 i4_ref_yD = 18;
2505 }
2506
2507 i4_ref_xD = i4_x0 - (i4_left) - (i4_left >> 1);
2508 i4_xD = i4_x0 - i4_ref_xD;
2509 i4_yD = i4_y0 - i4_ref_yD;
2510 i4_xc0 = i4_x0 >> 1;
2511 i4_yc0 = i4_y0 >> 1;
2512 i4_c_ref_xD = i4_ref_xD >> 1;
2513 i4_c_ref_yD = i4_ref_yD >> 1;
2514 i4_c_xD = i4_xc0 - i4_c_ref_xD;
2515 i4_c_yD = i4_yc0 - i4_c_ref_yD;
2516
2517 /* Fill corner sample if unavailable */
2518 if(!i1_corner_samp_avlbl_flag)
2519 {
2520 isvcd_corner_samp_dyadic(i4_x0, i4_y0, i4_xD, i4_yD, pu1_refarray_luma,
2521 pu1_refarray_cb, pu1_refarray_cr);
2522 }
2523
2524 /* Call the diagonal construction for the 8 rows */
2525 if(i4_top == i4_left)
2526 {
2527 /* if top * left = 1 (x0,y0) */
2528 u1_filled_samp = isvcd_diagonal_construct_dyadic(i4_x0, i4_y0, i4_xD, i4_yD,
2529 pu1_refarray_luma, DYADIC_REF_W_Y);
2530
2531 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 for(i4_y = i4_y0 + 1; i4_y < i4_y0 + 8; i4_y++)
2536 {
2537 i4_yD++;
2538 u1_filled_samp = isvcd_diagonal_construct_dyadic(
2539 i4_x0, i4_y, i4_xD, i4_yD, pu1_refarray_luma, DYADIC_REF_W_Y);
2540 pu1_tmp_dst[i4_x0 + 1] = u1_filled_samp;
2541 pu1_tmp_dst += DYADIC_REF_W_Y;
2542 }
2543
2544 /* (x0+1,y0+7) */
2545 u1_filled_samp = isvcd_diagonal_construct_dyadic(
2546 i4_x0 + 1, i4_y0 + 7, i4_xD + 1, i4_yD, pu1_refarray_luma, DYADIC_REF_W_Y);
2547 }
2548 else
2549 {
2550 /* top * left = -1 (x0+1,y0) */
2551 u1_filled_samp = isvcd_diagonal_construct_dyadic(i4_x0 + 1, i4_y0, i4_xD + 1, i4_yD,
2552 pu1_refarray_luma, DYADIC_REF_W_Y);
2553
2554 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 for(i4_y = i4_y0; i4_y < i4_y0 + 7; i4_y++)
2559 {
2560 u1_filled_samp = isvcd_diagonal_construct_dyadic(
2561 i4_x0, i4_y, i4_xD, i4_yD, pu1_refarray_luma, DYADIC_REF_W_Y);
2562
2563 pu1_tmp_dst += DYADIC_REF_W_Y;
2564 pu1_tmp_dst[i4_x0 + 1] = u1_filled_samp;
2565 i4_yD++;
2566 }
2567
2568 /* (x0,y0+7) */
2569 u1_filled_samp = isvcd_diagonal_construct_dyadic(i4_x0, i4_y0 + 7, i4_xD, i4_yD,
2570 pu1_refarray_luma, DYADIC_REF_W_Y);
2571 }
2572
2573 /* For Cb and Cr */
2574 for(i4_y = i4_yc0; i4_y < i4_yc0 + 4; i4_y++)
2575 {
2576 u1_filled_samp = isvcd_diagonal_construct_dyadic(i4_xc0, i4_y, i4_c_xD, i4_c_yD,
2577 pu1_refarray_cb, DYADIC_REF_W_C);
2578 u1_filled_samp = isvcd_diagonal_construct_dyadic(i4_xc0, i4_y, i4_c_xD, i4_c_yD,
2579 pu1_refarray_cr, DYADIC_REF_W_C);
2580 i4_c_yD++;
2581 }
2582
2583 } /* (mb_x+left,mb_y) is unavailable */
2584
2585 if(!(u1_ny_avlblty & 4))
2586 {
2587 /* (mb_x,mb_y+top) is unavailable */
2588 WORD32 i4_xD, i4_yD;
2589 WORD32 i4_c_xD, i4_c_yD;
2590 UWORD8 *pu1_tmp_dst;
2591 UWORD8 u1_filled_samp;
2592
2593 i1_corner_samp_avlbl_flag = (u1_ny_avlblty & 2) >> 1;
2594 i4_y0 = 9 + (i4_top << 3) + (i4_top);
2595 i4_x0 = 2;
2596 i4_ref_xD = 1;
2597 if(i4_left > 0)
2598 {
2599 i4_x0 += 8;
2600 i4_ref_xD = 18;
2601 }
2602
2603 i4_ref_yD = i4_y0 - i4_top - (i4_top >> 1);
2604 i4_xD = i4_x0 - i4_ref_xD;
2605 i4_yD = i4_y0 - i4_ref_yD;
2606 i4_xc0 = i4_x0 >> 1;
2607 i4_yc0 = i4_y0 >> 1;
2608 i4_c_ref_xD = i4_ref_xD >> 1;
2609 i4_c_ref_yD = i4_ref_yD >> 1;
2610 i4_c_xD = i4_xc0 - i4_c_ref_xD;
2611 i4_c_yD = i4_yc0 - i4_c_ref_yD;
2612
2613 if(!i1_corner_samp_avlbl_flag)
2614 {
2615 isvcd_corner_samp_dyadic(i4_x0, i4_y0, i4_xD, i4_yD, pu1_refarray_luma,
2616 pu1_refarray_cb, pu1_refarray_cr);
2617 }
2618
2619 /* Call the diagonal construction for the 2 rows */
2620 if(i4_top == i4_left)
2621 {
2622 /* if top * left = 1 (x0,y0) */
2623 u1_filled_samp = isvcd_diagonal_construct_dyadic(i4_x0, i4_y0, i4_xD, i4_yD,
2624 pu1_refarray_luma, DYADIC_REF_W_Y);
2625
2626 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 for(i4_x = i4_x0 + 1; i4_x < i4_x0 + 8; i4_x++)
2631 {
2632 i4_xD++;
2633 u1_filled_samp = isvcd_diagonal_construct_dyadic(
2634 i4_x, i4_y0, i4_xD, i4_yD, pu1_refarray_luma, DYADIC_REF_W_Y);
2635 pu1_tmp_dst[i4_x - 1] = u1_filled_samp;
2636 }
2637
2638 /* (x0+7,y0+1) */
2639 u1_filled_samp = isvcd_diagonal_construct_dyadic(
2640 i4_x0 + 7, i4_y0 + 1, i4_xD, i4_yD + 1, pu1_refarray_luma, DYADIC_REF_W_Y);
2641 }
2642 else
2643 {
2644 /* top * left = -1 */
2645 /* (x0,y0+1) */
2646 u1_filled_samp = isvcd_diagonal_construct_dyadic(i4_x0, i4_y0 + 1, i4_xD, i4_yD + 1,
2647 pu1_refarray_luma, DYADIC_REF_W_Y);
2648
2649 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 for(i4_x = i4_x0; i4_x < i4_x0 + 7; i4_x++)
2654 {
2655 u1_filled_samp = isvcd_diagonal_construct_dyadic(
2656 i4_x, i4_y0, i4_xD, i4_yD, pu1_refarray_luma, DYADIC_REF_W_Y);
2657
2658 pu1_tmp_dst[i4_x + 1] = u1_filled_samp;
2659 i4_xD++;
2660 }
2661
2662 /* (x0+7,y0) */
2663 u1_filled_samp = isvcd_diagonal_construct_dyadic(i4_x0 + 7, i4_y0, i4_xD, i4_yD,
2664 pu1_refarray_luma, DYADIC_REF_W_Y);
2665 }
2666
2667 /* For Cb and Cr */
2668 for(i4_x = i4_xc0; i4_x < i4_xc0 + 4; i4_x++)
2669 {
2670 u1_filled_samp = isvcd_diagonal_construct_dyadic(i4_x, i4_yc0, i4_c_xD, i4_c_yD,
2671 pu1_refarray_cb, DYADIC_REF_W_C);
2672 u1_filled_samp = isvcd_diagonal_construct_dyadic(i4_x, i4_yc0, i4_c_xD, i4_c_yD,
2673 pu1_refarray_cr, DYADIC_REF_W_C);
2674 i4_c_xD++;
2675 }
2676
2677 } /* (mb_x,mb_y+top) is unavailable */
2678 } /* if (mb_x+left,mb_y+top) not available */
2679 else
2680 {
2681 UWORD8 *pu1_tmp_dst1, *pu1_tmp_dst2;
2682 UWORD8 *pu1_tmp_src1, *pu1_tmp_src2;
2683
2684 if(0x02 == (u1_ny_avlblty & 0x6))
2685 {
2686 /* (mb_x+left,mb_y) available, (mb_x,mb_y+top) unavailable */
2687 i4_x0 = 9 + (i4_left << 3) + i4_left;
2688 i4_y0 = 9 + (i4_top << 3) + i4_top;
2689 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 pu1_tmp_src1 = pu1_refarray_luma + (i4_ref_yD * DYADIC_REF_W_Y);
2694 pu1_tmp_dst1 = pu1_refarray_luma + (i4_y0 * DYADIC_REF_W_Y);
2695 pu1_tmp_dst2 = pu1_tmp_dst1 + DYADIC_REF_W_Y;
2696 pu1_tmp_dst1[i4_x0] = pu1_tmp_src1[i4_x0];
2697 pu1_tmp_dst2[i4_x0] = pu1_tmp_src1[i4_x0];
2698 pu1_tmp_dst1[i4_x0 + 1] = pu1_tmp_src1[i4_x0 + 1];
2699 pu1_tmp_dst2[i4_x0 + 1] = pu1_tmp_src1[i4_x0 + 1];
2700
2701 /* Cb and Cr copy */
2702 i4_xc0 = i4_x0 >> 1;
2703 i4_yc0 = i4_y0 >> 1;
2704 i4_c_ref_yD = i4_ref_yD >> 1;
2705 pu1_tmp_src1 = pu1_refarray_cb + (i4_c_ref_yD * DYADIC_REF_W_C);
2706 pu1_tmp_dst1 = pu1_refarray_cb + (i4_yc0 * DYADIC_REF_W_C);
2707 pu1_tmp_src2 = pu1_refarray_cr + (i4_c_ref_yD * DYADIC_REF_W_C);
2708 pu1_tmp_dst2 = pu1_refarray_cr + (i4_yc0 * DYADIC_REF_W_C);
2709 pu1_tmp_dst1[i4_xc0] = pu1_tmp_src1[i4_xc0];
2710 pu1_tmp_dst2[i4_xc0] = pu1_tmp_src2[i4_xc0];
2711
2712 } /* if (mb_x+left,mb_y) available, (mb_x,mb_y+top) unavailable */
2713 else if(0x04 == (u1_ny_avlblty & 0x6))
2714 {
2715 /* (mb_x+left,mb_y) unavailable, (mb_x,mb_y+top) available */
2716 i4_x0 = 9 + (i4_left << 3) + i4_left;
2717 i4_y0 = 9 + (i4_top << 3) + i4_top;
2718 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 pu1_tmp_src1 = pu1_refarray_luma + (i4_y0 * DYADIC_REF_W_Y);
2723 pu1_tmp_dst1 = pu1_tmp_src1;
2724 pu1_tmp_src2 = pu1_tmp_src1 + DYADIC_REF_W_Y;
2725 pu1_tmp_dst2 = pu1_tmp_src2;
2726
2727 pu1_tmp_dst1[i4_x0] = pu1_tmp_src1[i4_ref_xD];
2728 pu1_tmp_dst1[i4_x0 + 1] = pu1_tmp_src1[i4_ref_xD];
2729 pu1_tmp_dst2[i4_x0] = pu1_tmp_src2[i4_ref_xD];
2730 pu1_tmp_dst2[i4_x0 + 1] = pu1_tmp_src2[i4_ref_xD];
2731
2732 /* Copy Cb and Cr */
2733 i4_xc0 = i4_x0 >> 1;
2734 i4_yc0 = i4_y0 >> 1;
2735 i4_c_ref_xD = i4_ref_xD >> 1;
2736
2737 pu1_tmp_src1 = pu1_refarray_cb + (i4_yc0 * DYADIC_REF_W_C);
2738 pu1_tmp_dst1 = pu1_tmp_src1;
2739 pu1_tmp_src2 = pu1_refarray_cr + (i4_yc0 * DYADIC_REF_W_C);
2740 pu1_tmp_dst2 = pu1_tmp_src2;
2741
2742 pu1_tmp_dst1[i4_xc0] = pu1_tmp_src1[i4_c_ref_xD];
2743 pu1_tmp_dst2[i4_xc0] = pu1_tmp_src2[i4_c_ref_xD];
2744
2745 } /* if (mb_x+left,mb_y) unavailable, (mb_x,mb_y+top) available */
2746 else if(0x6 == (u1_ny_avlblty & 0x6))
2747 {
2748 /* (mb_x+left,mb_y) available, (mb_x,mb_y+top) available */
2749 WORD32 i4_xD, i4_yD;
2750 WORD32 i4_c_xD, i4_c_yD;
2751
2752 i4_y0 = 9 + (i4_top << 3) + i4_top;
2753 i4_x0 = 9 + (i4_left << 3) + i4_left;
2754 i4_ref_xD = i4_x0 - i4_left - (i4_left >> 1);
2755 i4_ref_yD = i4_y0 - i4_top - (i4_top >> 1);
2756 i4_xD = i4_x0 - i4_ref_xD;
2757 i4_yD = i4_y0 - i4_ref_yD;
2758 i4_xc0 = i4_x0 >> 1;
2759 i4_yc0 = i4_y0 >> 1;
2760 i4_c_ref_xD = i4_ref_xD >> 1;
2761 i4_c_ref_yD = i4_ref_yD >> 1;
2762 i4_c_xD = i4_xc0 - i4_c_ref_xD;
2763 i4_c_yD = i4_yc0 - i4_c_ref_yD;
2764
2765 /* Call diagonal construction for luma */
2766 for(i4_y = i4_y0; i4_y < i4_y0 + 2; i4_y++)
2767 {
2768 for(i4_x = i4_x0; i4_x < i4_x0 + 2; i4_x++)
2769 {
2770 isvcd_diagonal_construct_dyadic(i4_x, i4_y, i4_xD, i4_yD, pu1_refarray_luma,
2771 DYADIC_REF_W_Y);
2772 i4_xD++;
2773 }
2774 i4_yD++;
2775 i4_xD -= 2;
2776 }
2777
2778 /* Call diagonal construction for chroma */
2779 isvcd_diagonal_construct_dyadic(i4_xc0, i4_yc0, i4_c_xD, i4_c_yD, pu1_refarray_cb,
2780 DYADIC_REF_W_C);
2781
2782 isvcd_diagonal_construct_dyadic(i4_xc0, i4_yc0, i4_c_xD, i4_c_yD, pu1_refarray_cr,
2783 DYADIC_REF_W_C);
2784
2785 } /* if (mb_x+left,mb_y) available, (mb_x,mb_y+top) available */
2786 } /* (mb_x+left,mb_y+top) available */
2787
2788 return OK;
2789 }
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 /*****************************************************************************/
isvcd_interpolate_base_luma_dyadic(UWORD8 * pu1_inp_buf,WORD16 * pi2_tmp_filt_buf,UWORD8 * pu1_out_buf,WORD32 i4_out_stride)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 {
2818 WORD32 i4_x, i4_y;
2819 WORD32 i4_coeff_0, i4_coeff_1, i4_coeff_2, i4_coeff_3;
2820 WORD32 i4_samp_0, i4_samp_1, i4_samp_2, i4_samp_3;
2821 WORD32 i4_rslt_1, i4_rslt_2;
2822 WORD32 i4_filt_stride, i4_src_stride;
2823 UWORD8 *pu1_inp, *pu1_out;
2824 WORD16 *pi2_tmp;
2825
2826 /* Filter coefficient values for phase 4 */
2827 i4_coeff_0 = -3;
2828 i4_coeff_1 = 28;
2829 i4_coeff_2 = 8;
2830 i4_coeff_3 = -1;
2831 i4_filt_stride = 12;
2832 i4_src_stride = DYADIC_REF_W_Y;
2833 pu1_inp = pu1_inp_buf;
2834 pi2_tmp = pi2_tmp_filt_buf;
2835 pu1_out = pu1_out_buf;
2836
2837 /* Vertical interpolation */
2838 for(i4_x = 0; i4_x < 12; i4_x++)
2839 {
2840 /* y = 0, y_phase = 12 */
2841 i4_samp_0 = pu1_inp[i4_x];
2842 pu1_inp += i4_src_stride;
2843 i4_samp_1 = pu1_inp[i4_x];
2844 pu1_inp += i4_src_stride;
2845 i4_samp_2 = pu1_inp[i4_x];
2846 pu1_inp += i4_src_stride;
2847 i4_samp_3 = pu1_inp[i4_x];
2848 pu1_inp += i4_src_stride;
2849
2850 /* since y_phase 12 for y = 0 */
2851 i4_rslt_1 = i4_samp_0 * i4_coeff_3;
2852 i4_rslt_1 += i4_samp_1 * i4_coeff_2;
2853 i4_rslt_1 += i4_samp_2 * i4_coeff_1;
2854 i4_rslt_1 += i4_samp_3 * i4_coeff_0;
2855
2856 /* Store the output */
2857 pi2_tmp[i4_x] = i4_rslt_1;
2858 /* Increment the output ptr */
2859 pi2_tmp += i4_filt_stride;
2860
2861 for(i4_y = 1; i4_y < 15; i4_y += 2)
2862 {
2863 i4_samp_0 = i4_samp_1;
2864 i4_samp_1 = i4_samp_2;
2865 i4_samp_2 = i4_samp_3;
2866 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 i4_rslt_1 = i4_samp_0 * i4_coeff_0;
2871 i4_rslt_1 += i4_samp_1 * i4_coeff_1;
2872 i4_rslt_1 += i4_samp_2 * i4_coeff_2;
2873 i4_rslt_1 += i4_samp_3 * i4_coeff_3;
2874 i4_rslt_2 = i4_samp_0 * i4_coeff_3;
2875 i4_rslt_2 += i4_samp_1 * i4_coeff_2;
2876 i4_rslt_2 += i4_samp_2 * i4_coeff_1;
2877 i4_rslt_2 += i4_samp_3 * i4_coeff_0;
2878
2879 /* Storing the results */
2880 pi2_tmp[i4_x] = i4_rslt_1;
2881 pi2_tmp += i4_filt_stride;
2882 pi2_tmp[i4_x] = i4_rslt_2;
2883
2884 /* Incrementing the pointers */
2885 pi2_tmp += i4_filt_stride;
2886 pu1_inp += i4_src_stride;
2887
2888 } /* End of loop over y */
2889
2890 /* y = 15, y_phase = 4 */
2891 i4_samp_0 = i4_samp_1;
2892 i4_samp_1 = i4_samp_2;
2893 i4_samp_2 = i4_samp_3;
2894 i4_samp_3 = pu1_inp[i4_x];
2895
2896 i4_rslt_1 = i4_samp_0 * i4_coeff_0;
2897 i4_rslt_1 += i4_samp_1 * i4_coeff_1;
2898 i4_rslt_1 += i4_samp_2 * i4_coeff_2;
2899 i4_rslt_1 += i4_samp_3 * i4_coeff_3;
2900
2901 /* Store the output */
2902 pi2_tmp[i4_x] = i4_rslt_1;
2903
2904 /* Reinitializing the ptrs */
2905 pu1_inp = pu1_inp_buf;
2906 pi2_tmp = pi2_tmp_filt_buf;
2907 }
2908
2909 /* Horizontal interpolation */
2910 for(i4_y = 0; i4_y < 16; i4_y++)
2911 {
2912 /* x = 0, x_phase = 12 */
2913 i4_samp_0 = *pi2_tmp++;
2914 i4_samp_1 = *pi2_tmp++;
2915 i4_samp_2 = *pi2_tmp++;
2916 i4_samp_3 = *pi2_tmp++;
2917
2918 /* since x_phase 12 for x = 0 */
2919 i4_rslt_1 = i4_samp_0 * i4_coeff_3;
2920 i4_rslt_1 += i4_samp_1 * i4_coeff_2;
2921 i4_rslt_1 += i4_samp_2 * i4_coeff_1;
2922 i4_rslt_1 += i4_samp_3 * i4_coeff_0;
2923 i4_rslt_1 += 512;
2924
2925 i4_rslt_1 >>= 10;
2926
2927 /* Store the output */
2928 pu1_out[0] = CLIPUCHAR(i4_rslt_1);
2929
2930 for(i4_x = 1; i4_x < 15; i4_x += 2)
2931 {
2932 i4_samp_0 = i4_samp_1;
2933 i4_samp_1 = i4_samp_2;
2934 i4_samp_2 = i4_samp_3;
2935 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 i4_rslt_1 = i4_samp_0 * i4_coeff_0;
2940 i4_rslt_1 += i4_samp_1 * i4_coeff_1;
2941 i4_rslt_1 += i4_samp_2 * i4_coeff_2;
2942 i4_rslt_1 += i4_samp_3 * i4_coeff_3;
2943 i4_rslt_1 += 512;
2944
2945 i4_rslt_2 = i4_samp_0 * i4_coeff_3;
2946 i4_rslt_2 += i4_samp_1 * i4_coeff_2;
2947 i4_rslt_2 += i4_samp_2 * i4_coeff_1;
2948 i4_rslt_2 += i4_samp_3 * i4_coeff_0;
2949 i4_rslt_2 += 512;
2950
2951 i4_rslt_1 >>= 10;
2952 i4_rslt_2 >>= 10;
2953
2954 /* Store the output */
2955 pu1_out[i4_x] = CLIPUCHAR(i4_rslt_1);
2956 pu1_out[i4_x + 1] = CLIPUCHAR(i4_rslt_2);
2957 }
2958
2959 /* x = 15 */
2960 i4_samp_0 = i4_samp_1;
2961 i4_samp_1 = i4_samp_2;
2962 i4_samp_2 = i4_samp_3;
2963 i4_samp_3 = *pi2_tmp++;
2964
2965 i4_rslt_1 = i4_samp_0 * i4_coeff_0;
2966 i4_rslt_1 += i4_samp_1 * i4_coeff_1;
2967 i4_rslt_1 += i4_samp_2 * i4_coeff_2;
2968 i4_rslt_1 += i4_samp_3 * i4_coeff_3;
2969 i4_rslt_1 += 512;
2970
2971 i4_rslt_1 >>= 10;
2972
2973 /* Store the output */
2974 pu1_out[i4_x] = CLIPUCHAR(i4_rslt_1);
2975
2976 /* Increment the output ptr */
2977 pu1_out += i4_out_stride;
2978
2979 } /* End of loop over y */
2980 } /* 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 /*****************************************************************************/
isvcd_vert_interpol_chroma_dyadic_1(UWORD8 * pu1_inp_buf,WORD16 * pi2_tmp_filt_buf,WORD32 i4_phase_0,WORD32 i4_phase_1)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 {
3018 WORD32 i4_x, i4_y;
3019 WORD32 i4_coeff_0, i4_coeff_1, i4_coeff_2, i4_coeff_3;
3020 WORD32 i4_samp_0, i4_samp_1;
3021 WORD32 i4_rslt_1, i4_rslt_2;
3022 WORD32 i4_filt_stride, i4_src_stride;
3023 UWORD8 *pu1_inp;
3024 WORD16 *pi2_tmp;
3025
3026 i4_coeff_0 = 8 - i4_phase_0;
3027 i4_coeff_1 = i4_phase_0;
3028 i4_coeff_2 = 8 - i4_phase_1;
3029 i4_coeff_3 = i4_phase_1;
3030
3031 pu1_inp = pu1_inp_buf;
3032 pi2_tmp = pi2_tmp_filt_buf;
3033 i4_filt_stride = 6;
3034 i4_src_stride = DYADIC_REF_W_C;
3035
3036 /* Vertical interpolation */
3037 for(i4_x = 0; i4_x < 6; i4_x++)
3038 {
3039 /* y = 0, y_phase = phase_0 */
3040 i4_samp_0 = pu1_inp[i4_x];
3041 pu1_inp += i4_src_stride;
3042 i4_samp_1 = pu1_inp[i4_x];
3043 pu1_inp += i4_src_stride;
3044
3045 /* since y_phase = phase_0 for y = 0 */
3046 i4_rslt_1 = i4_samp_0 * i4_coeff_0;
3047 i4_rslt_1 += i4_samp_1 * i4_coeff_1;
3048
3049 /* Store the output */
3050 pi2_tmp[i4_x] = i4_rslt_1;
3051
3052 /* Increment the output ptr */
3053 pi2_tmp += i4_filt_stride;
3054
3055 for(i4_y = 1; i4_y < 7; i4_y += 2)
3056 {
3057 i4_samp_0 = i4_samp_1;
3058 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 i4_rslt_1 = i4_samp_0 * i4_coeff_2;
3063 i4_rslt_1 += i4_samp_1 * i4_coeff_3;
3064 i4_rslt_2 = i4_samp_0 * i4_coeff_0;
3065 i4_rslt_2 += i4_samp_1 * i4_coeff_1;
3066
3067 /* Storing the results */
3068 pi2_tmp[i4_x] = i4_rslt_1;
3069 pi2_tmp += i4_filt_stride;
3070 pi2_tmp[i4_x] = i4_rslt_2;
3071
3072 /* Incrementing the pointers */
3073 pi2_tmp += i4_filt_stride;
3074 pu1_inp += i4_src_stride;
3075
3076 } /* End of loop over y */
3077
3078 /* y = 7, y_phase = phase_1 */
3079 i4_samp_0 = i4_samp_1;
3080 i4_samp_1 = pu1_inp[i4_x];
3081
3082 i4_rslt_1 = i4_samp_0 * i4_coeff_2;
3083 i4_rslt_1 += i4_samp_1 * i4_coeff_3;
3084
3085 /* Store the output */
3086 pi2_tmp[i4_x] = i4_rslt_1;
3087
3088 /* Reinitializing the ptrs */
3089 pu1_inp = pu1_inp_buf;
3090 pi2_tmp = pi2_tmp_filt_buf;
3091
3092 } /* End of loop over x */
3093 } /* 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 /*****************************************************************************/
isvcd_vert_interpol_chroma_dyadic_2(UWORD8 * pu1_inp_buf,WORD16 * pi2_tmp_filt_buf,WORD32 i4_phase_0,WORD32 i4_phase_1)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 {
3127 WORD32 i4_x, i4_y;
3128 WORD32 i4_coeff_0, i4_coeff_1, i4_coeff_2, i4_coeff_3;
3129 WORD32 i4_samp_0, i4_samp_1;
3130 WORD32 i4_rslt_1, i4_rslt_2;
3131 WORD32 i4_filt_stride, i4_src_stride;
3132 UWORD8 *pu1_inp;
3133 WORD16 *pi2_tmp;
3134
3135 i4_coeff_0 = 8 - i4_phase_0;
3136 i4_coeff_1 = i4_phase_0;
3137 i4_coeff_2 = 8 - i4_phase_1;
3138 i4_coeff_3 = i4_phase_1;
3139
3140 pi2_tmp = pi2_tmp_filt_buf;
3141 i4_filt_stride = 6;
3142 i4_src_stride = DYADIC_REF_W_C;
3143 pu1_inp = pu1_inp_buf + i4_src_stride;
3144
3145 /* Vertical interpolation */
3146 for(i4_x = 0; i4_x < 6; i4_x++)
3147 {
3148 i4_samp_1 = pu1_inp[i4_x];
3149 pu1_inp += i4_src_stride;
3150
3151 for(i4_y = 0; i4_y < 8; i4_y += 2)
3152 {
3153 i4_samp_0 = i4_samp_1;
3154 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 i4_rslt_1 = i4_samp_0 * i4_coeff_0;
3158 i4_rslt_1 += i4_samp_1 * i4_coeff_1;
3159
3160 i4_rslt_2 = i4_samp_0 * i4_coeff_2;
3161 i4_rslt_2 += i4_samp_1 * i4_coeff_3;
3162
3163 /* Storing the results */
3164 pi2_tmp[i4_x] = i4_rslt_1;
3165 pi2_tmp += i4_filt_stride;
3166 pi2_tmp[i4_x] = i4_rslt_2;
3167
3168 /* Incrementing the pointers */
3169 pi2_tmp += i4_filt_stride;
3170 pu1_inp += i4_src_stride;
3171
3172 } /* End of loop over y */
3173
3174 /* Reinitializing the ptrs */
3175 pu1_inp = pu1_inp_buf + i4_src_stride;
3176 pi2_tmp = pi2_tmp_filt_buf;
3177
3178 } /* End of loop over x */
3179 } /* 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 /*****************************************************************************/
isvcd_vert_interpol_chroma_dyadic_3(UWORD8 * pu1_inp_buf,WORD16 * pi2_tmp_filt_buf,WORD32 i4_phase_0,WORD32 i4_phase_1)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 {
3212 WORD32 i4_x, i4_y;
3213 WORD32 i4_coeff_0, i4_coeff_1, i4_coeff_2, i4_coeff_3;
3214 WORD32 i4_samp_0, i4_samp_1;
3215 WORD32 i4_rslt_1, i4_rslt_2;
3216 WORD32 i4_filt_stride, i4_src_stride;
3217 UWORD8 *pu1_inp;
3218 WORD16 *pi2_tmp;
3219
3220 i4_coeff_0 = 8 - i4_phase_0;
3221 i4_coeff_1 = i4_phase_0;
3222 i4_coeff_2 = 8 - i4_phase_1;
3223 i4_coeff_3 = i4_phase_1;
3224
3225 pi2_tmp = pi2_tmp_filt_buf;
3226 i4_filt_stride = 6;
3227 i4_src_stride = DYADIC_REF_W_C;
3228 pu1_inp = pu1_inp_buf;
3229
3230 /* Vertical interpolation */
3231 for(i4_x = 0; i4_x < 6; i4_x++)
3232 {
3233 i4_samp_1 = pu1_inp[i4_x];
3234 pu1_inp += i4_src_stride;
3235
3236 for(i4_y = 0; i4_y < 8; i4_y += 2)
3237 {
3238 i4_samp_0 = i4_samp_1;
3239 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 i4_rslt_1 = i4_samp_0 * i4_coeff_0;
3244 i4_rslt_1 += i4_samp_1 * i4_coeff_1;
3245
3246 i4_rslt_2 = i4_samp_0 * i4_coeff_2;
3247 i4_rslt_2 += i4_samp_1 * i4_coeff_3;
3248
3249 /* Storing the results */
3250 pi2_tmp[i4_x] = i4_rslt_1;
3251 pi2_tmp += i4_filt_stride;
3252 pi2_tmp[i4_x] = i4_rslt_2;
3253
3254 /* Incrementing the pointers */
3255 pi2_tmp += i4_filt_stride;
3256 pu1_inp += i4_src_stride;
3257
3258 } /* End of loop over y */
3259
3260 /* Reinitializing the ptrs */
3261 pu1_inp = pu1_inp_buf;
3262 pi2_tmp = pi2_tmp_filt_buf;
3263
3264 } /* End of loop over x */
3265 } /* 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 /*****************************************************************************/
isvcd_horz_interpol_chroma_dyadic_1(WORD16 * pi2_tmp_filt_buf,UWORD8 * pu1_out_buf,WORD32 i4_out_stride,WORD32 i4_phase_0,WORD32 i4_phase_1)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 {
3301 WORD32 i4_x, i4_y;
3302 WORD32 i4_coeff_0, i4_coeff_1, i4_coeff_2, i4_coeff_3;
3303 WORD32 i4_samp_0, i4_samp_1;
3304 WORD32 i4_rslt_1, i4_rslt_2;
3305 WORD32 i4_dst_stride;
3306 UWORD8 *pu1_out;
3307 WORD16 *pi2_tmp;
3308
3309 i4_coeff_0 = 8 - i4_phase_0;
3310 i4_coeff_1 = i4_phase_0;
3311 i4_coeff_2 = 8 - i4_phase_1;
3312 i4_coeff_3 = i4_phase_1;
3313
3314 pu1_out = pu1_out_buf;
3315 pi2_tmp = pi2_tmp_filt_buf;
3316 i4_dst_stride = i4_out_stride;
3317
3318 /* Horizontal interpolation */
3319 for(i4_y = 0; i4_y < 8; i4_y++)
3320 {
3321 /* x = 0, x_phase = phase_0 */
3322 i4_samp_0 = *pi2_tmp++;
3323 i4_samp_1 = *pi2_tmp++;
3324
3325 /* since x_phase = phase_0 for x = 0 */
3326 i4_rslt_1 = i4_samp_0 * i4_coeff_0;
3327 i4_rslt_1 += i4_samp_1 * i4_coeff_1;
3328
3329 /* Round to 8-bit value */
3330 i4_rslt_1 += 32;
3331 i4_rslt_1 >>= 6;
3332
3333 /* Store the output */
3334 pu1_out[0] = i4_rslt_1;
3335
3336 for(i4_x = 1; i4_x < 7; i4_x += 2)
3337 {
3338 i4_samp_0 = i4_samp_1;
3339 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 i4_rslt_1 = i4_samp_0 * i4_coeff_2;
3343 i4_rslt_1 += i4_samp_1 * i4_coeff_3;
3344 i4_rslt_2 = i4_samp_0 * i4_coeff_0;
3345 i4_rslt_2 += i4_samp_1 * i4_coeff_1;
3346
3347 /* Rounding to 8-bit values */
3348 i4_rslt_1 += 32;
3349 i4_rslt_1 >>= 6;
3350 i4_rslt_2 += 32;
3351 i4_rslt_2 >>= 6;
3352
3353 /* Storing the results */
3354 pu1_out[2 * i4_x] = i4_rslt_1;
3355 pu1_out[2 * (i4_x + 1)] = i4_rslt_2;
3356
3357 } /* End of loop over y */
3358
3359 /* y = 7, y_phase = phase_1 */
3360 i4_samp_0 = i4_samp_1;
3361 i4_samp_1 = *pi2_tmp++;
3362
3363 /* since x_phase = phase_1 for x = 7 */
3364 i4_rslt_1 = i4_samp_0 * i4_coeff_2;
3365 i4_rslt_1 += i4_samp_1 * i4_coeff_3;
3366
3367 /* Round to 8-bit value */
3368 i4_rslt_1 += 32;
3369 i4_rslt_1 >>= 6;
3370
3371 /* Store the output */
3372 pu1_out[2 * 7] = i4_rslt_1;
3373
3374 /* Incrementing the output ptr */
3375 pu1_out += i4_dst_stride;
3376
3377 } /* End of loop over x */
3378 } /* 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 /*****************************************************************************/
isvcd_horz_interpol_chroma_dyadic_2(WORD16 * pi2_tmp_filt_buf,UWORD8 * pu1_out_buf,WORD32 i4_out_stride,WORD32 i4_phase_0,WORD32 i4_phase_1)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 {
3412 WORD32 i4_x, i4_y;
3413 WORD32 i4_coeff_0, i4_coeff_1, i4_coeff_2, i4_coeff_3;
3414 WORD32 i4_samp_0, i4_samp_1;
3415 WORD32 i4_rslt_1, i4_rslt_2;
3416 WORD32 i4_dst_stride;
3417 UWORD8 *pu1_out;
3418 WORD16 *pi2_tmp;
3419
3420 i4_coeff_0 = 8 - i4_phase_0;
3421 i4_coeff_1 = i4_phase_0;
3422 i4_coeff_2 = 8 - i4_phase_1;
3423 i4_coeff_3 = i4_phase_1;
3424
3425 pu1_out = pu1_out_buf;
3426 pi2_tmp = pi2_tmp_filt_buf + 1;
3427 i4_dst_stride = i4_out_stride;
3428
3429 /* Horizontal interpolation */
3430 for(i4_y = 0; i4_y < 8; i4_y++)
3431 {
3432 /* x = 0, x_phase = phase_0 */
3433 i4_samp_1 = *pi2_tmp++;
3434
3435 for(i4_x = 0; i4_x < 8; i4_x += 2)
3436 {
3437 i4_samp_0 = i4_samp_1;
3438 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 i4_rslt_1 = i4_samp_0 * i4_coeff_0;
3443 i4_rslt_1 += i4_samp_1 * i4_coeff_1;
3444
3445 i4_rslt_2 = i4_samp_0 * i4_coeff_2;
3446 i4_rslt_2 += i4_samp_1 * i4_coeff_3;
3447
3448 /* Rounding to 8-bit values */
3449 i4_rslt_1 += 32;
3450 i4_rslt_1 >>= 6;
3451 i4_rslt_2 += 32;
3452 i4_rslt_2 >>= 6;
3453
3454 /* Storing the results */
3455 pu1_out[2 * i4_x] = i4_rslt_1;
3456 pu1_out[2 * (i4_x + 1)] = i4_rslt_2;
3457
3458 } /* End of loop over x */
3459
3460 /* Incrementing the ptrs */
3461 pi2_tmp += 1;
3462 pu1_out += i4_dst_stride;
3463
3464 } /* End of loop over y */
3465 } /* 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 /*****************************************************************************/
isvcd_intra_resamp_mb_dyadic(void * pv_intra_samp_ctxt,mem_element_t * ps_ref_luma,mem_element_t * ps_ref_chroma,mem_element_t * ps_ref_mb_mode_map,mem_element_t * ps_curr_luma,mem_element_t * ps_curr_chroma,mb_coord_t * ps_mb_coord,void * pv_svc_dec)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 {
3501 /* --------------------------------------------------------------------- */
3502 /* I/O buffer params */
3503 /* --------------------------------------------------------------------- */
3504 UWORD8 *pu1_inp_luma, *pu1_inp_chroma;
3505 UWORD8 *pu1_out_luma, *pu1_out_chroma;
3506 UWORD8 *pu1_out_cb, *pu1_out_cr;
3507 UWORD8 *pu1_refarray_luma, *pu1_refarray_cb, *pu1_refarray_cr;
3508 WORD16 *pi2_tmp_filt_buf;
3509 WORD32 i4_inp_luma_stride, i4_inp_chroma_stride;
3510 WORD32 i4_out_luma_stride, i4_out_chroma_stride;
3511 UWORD16 u2_mb_x_ref, u2_mb_y_ref;
3512 svc_dec_lyr_struct_t *ps_svc_lyr_dec = (svc_dec_lyr_struct_t *) pv_svc_dec;
3513 dec_slice_svc_ext_params_t *ps_svc_slice_params = NULL;
3514
3515 /* --------------------------------------------------------------------- */
3516 /* Intra resampling ctxt pointers */
3517 /* --------------------------------------------------------------------- */
3518 intra_sampling_ctxt_t *ps_ctxt;
3519 intra_samp_lyr_ctxt *ps_lyr_ctxt;
3520
3521 /* --------------------------------------------------------------------- */
3522 /* reference and current layer MB coordinates */
3523 /* --------------------------------------------------------------------- */
3524 WORD32 i4_scaled_mb_x, i4_scaled_mb_y;
3525 WORD32 i4_top, i4_left;
3526 WORD32 ret;
3527
3528 ps_svc_slice_params = &ps_svc_lyr_dec->s_svc_slice_params;
3529 /* --------------------------------------------------------------------- */
3530 /* Pointer derivation */
3531 /* --------------------------------------------------------------------- */
3532 ps_ctxt = (intra_sampling_ctxt_t *) pv_intra_samp_ctxt;
3533 ps_lyr_ctxt = &ps_ctxt->as_res_lyrs[ps_ctxt->i4_res_lyr_id];
3534
3535 /* --------------------------------------------------------------------- */
3536 /* MB coordinate derivation */
3537 /* --------------------------------------------------------------------- */
3538 i4_scaled_mb_x =
3539 ps_mb_coord->u2_mb_x - (ps_svc_slice_params->i4_scaled_ref_layer_left_offset >> 4);
3540 i4_scaled_mb_y =
3541 ps_mb_coord->u2_mb_y - (ps_svc_slice_params->i4_scaled_ref_layer_top_offset >> 4);
3542
3543 if(i4_scaled_mb_x & 0x1)
3544 {
3545 i4_left = 1;
3546 }
3547 else
3548 {
3549 i4_left = -1;
3550 }
3551 if(i4_scaled_mb_y & 0x1)
3552 {
3553 i4_top = 1;
3554 }
3555 else
3556 {
3557 i4_top = -1;
3558 }
3559
3560 u2_mb_x_ref = (i4_scaled_mb_x >> 1);
3561 u2_mb_y_ref = (i4_scaled_mb_y >> 1);
3562
3563 /* --------------------------------------------------------------------- */
3564 /* Reference Array Consrtuction - luma and chroma */
3565 /* --------------------------------------------------------------------- */
3566 pu1_inp_luma = (UWORD8 *) ps_ref_luma->pv_buffer;
3567 pu1_inp_chroma = (UWORD8 *) ps_ref_chroma->pv_buffer;
3568 i4_inp_luma_stride = ps_ref_luma->i4_num_element_stride;
3569 i4_inp_chroma_stride = ps_ref_chroma->i4_num_element_stride;
3570
3571 /* ------- Constructing refSampleArray ----------------------- */
3572 ret = isvcd_reflayer_construction_dyadic(
3573 pv_intra_samp_ctxt, ps_ref_mb_mode_map, pu1_inp_luma, pu1_inp_chroma, i4_inp_luma_stride,
3574 i4_inp_chroma_stride, i4_top, i4_left, u2_mb_x_ref, u2_mb_y_ref);
3575
3576 if(ret != OK)
3577 {
3578 return NOT_OK;
3579 }
3580 /* --------------------------------------------------------------------- */
3581 /* LUMA INTERPOLATION */
3582 /* --------------------------------------------------------------------- */
3583 pu1_refarray_luma = ps_ctxt->pu1_refarray_buffer;
3584 if(1 == i4_top)
3585 {
3586 pu1_refarray_luma += (DYADIC_REF_W_Y << 3);
3587 }
3588 if(1 == i4_left)
3589 {
3590 pu1_refarray_luma += 8;
3591 }
3592 pu1_out_luma = (UWORD8 *) ps_curr_luma->pv_buffer;
3593 i4_out_luma_stride = ps_curr_luma->i4_num_element_stride;
3594 pi2_tmp_filt_buf = (WORD16 *) ps_ctxt->pi4_temp_interpolation_buffer;
3595
3596 ps_ctxt->pf_interpolate_base_luma_dyadic(pu1_refarray_luma, pi2_tmp_filt_buf, pu1_out_luma,
3597 i4_out_luma_stride);
3598
3599 /* --------------------------------------------------------------------- */
3600 /* CHROMA INTERPOLATION */
3601 /* --------------------------------------------------------------------- */
3602 pu1_out_chroma = (UWORD8 *) ps_curr_chroma->pv_buffer;
3603 i4_out_chroma_stride = ps_curr_chroma->i4_num_element_stride;
3604
3605 /* CB */
3606 pu1_out_cb = pu1_out_chroma;
3607 pu1_refarray_cb = ps_ctxt->pu1_refarray_cb;
3608
3609 if(1 == i4_top)
3610 {
3611 pu1_refarray_cb += (DYADIC_REF_W_C << 2);
3612 }
3613 if(1 == i4_left)
3614 {
3615 pu1_refarray_cb += 4;
3616 }
3617
3618 /* Vertical interpolation */
3619 ps_lyr_ctxt->pf_vert_chroma_interpol(pu1_refarray_cb, pi2_tmp_filt_buf,
3620 ps_lyr_ctxt->i4_y_phase_0, ps_lyr_ctxt->i4_y_phase_1);
3621
3622 /* Horizontal interpolation */
3623 ps_lyr_ctxt->pf_horz_chroma_interpol(pi2_tmp_filt_buf, pu1_out_cb, i4_out_chroma_stride,
3624 ps_lyr_ctxt->i4_x_phase_0, ps_lyr_ctxt->i4_x_phase_1);
3625
3626 /* CR */
3627 pu1_out_cr = pu1_out_chroma + 1;
3628 pu1_refarray_cr = ps_ctxt->pu1_refarray_cr;
3629
3630 if(1 == i4_top)
3631 {
3632 pu1_refarray_cr += (DYADIC_REF_W_C << 2);
3633 }
3634 if(1 == i4_left)
3635 {
3636 pu1_refarray_cr += 4;
3637 }
3638
3639 /* Vertical interpolation */
3640 ps_lyr_ctxt->pf_vert_chroma_interpol(pu1_refarray_cr, pi2_tmp_filt_buf,
3641 ps_lyr_ctxt->i4_y_phase_0, ps_lyr_ctxt->i4_y_phase_1);
3642
3643 /* Horizontal interpolation */
3644 ps_lyr_ctxt->pf_horz_chroma_interpol(pi2_tmp_filt_buf, pu1_out_cr, i4_out_chroma_stride,
3645 ps_lyr_ctxt->i4_x_phase_0, ps_lyr_ctxt->i4_x_phase_1);
3646 return OK;
3647 }
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 /*****************************************************************************/
isvcd_interpolate_intra_base(void * pv_intra_samp_ctxt,UWORD8 * pu1_out,WORD32 i4_out_stride,WORD32 i4_refarray_wd,WORD32 i4_mb_x,WORD32 i4_mb_y,WORD32 i4_chroma_flag,WORD32 i4_refarray_flag)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 {
3681 /* --------------------------------------------------------------------- */
3682 /* Index Parameters */
3683 /* --------------------------------------------------------------------- */
3684 intra_sampling_ctxt_t *ps_ctxt;
3685 intra_samp_map_ctxt_t *ps_map_ctxt;
3686 intra_samp_lyr_ctxt *ps_lyr_ctxt;
3687 WORD32 i4_x, i4_y;
3688 WORD32 i4_frm_mb_x, i4_frm_mb_y;
3689 ref_pixel_map_t *ps_x_pos_phase;
3690 ref_pixel_map_t *ps_y_pos_phase;
3691
3692 WORD32 i4_temp_array_ht;
3693 WORD32 *pi4_interp_buff;
3694 WORD32 *pi4_interp_buff_temp;
3695 WORD32 i4_mb_wd;
3696 WORD32 i4_mb_ht;
3697 WORD32 i4_x_min, i4_x_max;
3698 ref_min_max_map_t *ps_x_min_max;
3699 UWORD8 *pu1_refarray = NULL;
3700
3701 /* --------------------------------------------------------------------- */
3702 /* Extracting pointers from the context */
3703 /* --------------------------------------------------------------------- */
3704 ps_ctxt = (intra_sampling_ctxt_t *) pv_intra_samp_ctxt;
3705 ps_lyr_ctxt = &ps_ctxt->as_res_lyrs[ps_ctxt->i4_res_lyr_id];
3706
3707 if(0 == i4_refarray_flag)
3708 {
3709 pu1_refarray = ps_ctxt->pu1_refarray_buffer;
3710 }
3711 else if(1 == i4_refarray_flag)
3712 {
3713 pu1_refarray = ps_ctxt->pu1_refarray_cb;
3714 }
3715
3716 /* --------------------------------------------------------------------- */
3717 /* LUMA or CHROMA */
3718 /* --------------------------------------------------------------------- */
3719 if(1 == i4_chroma_flag)
3720 ps_map_ctxt = &(ps_lyr_ctxt->s_chroma_map_ctxt);
3721 else
3722 ps_map_ctxt = &(ps_lyr_ctxt->s_luma_map_ctxt);
3723
3724 i4_mb_wd = MB_WIDTH >> i4_chroma_flag;
3725 i4_mb_ht = MB_HEIGHT >> i4_chroma_flag;
3726 ps_x_min_max = ps_map_ctxt->ps_x_min_max;
3727 i4_frm_mb_y = i4_mb_y * i4_mb_ht;
3728 i4_frm_mb_x = i4_mb_x * i4_mb_wd;
3729
3730 /* get the min and max positions */
3731 i4_x_min = ps_x_min_max[i4_mb_x].i2_min_pos;
3732 i4_x_max = ps_x_min_max[i4_mb_x].i2_max_pos;
3733
3734 /* --------------------------------------------------------------------- */
3735 /* Projected frame level pointers */
3736 /* --------------------------------------------------------------------- */
3737 ps_x_pos_phase = ps_map_ctxt->ps_x_pos_phase;
3738 ps_y_pos_phase = ps_map_ctxt->ps_y_pos_phase;
3739
3740 /* --------------------------------------------------------------------- */
3741 /* Pointers and Dimenstion of the temporary buffer */
3742 /* --------------------------------------------------------------------- */
3743 i4_temp_array_ht = i4_mb_ht;
3744 pi4_interp_buff = ps_ctxt->pi4_temp_interpolation_buffer;
3745 pi4_interp_buff_temp = pi4_interp_buff;
3746
3747 /* --------------------------------------------------------------------- */
3748 /* Loop for interpolation in vertical direction */
3749 /* --------------------------------------------------------------------- */
3750 for(i4_y = 0; i4_y < (i4_temp_array_ht); i4_y++)
3751 {
3752 for(i4_x = (i4_x_min - 1); i4_x <= (i4_x_max + 2); i4_x++)
3753 {
3754 UWORD8 *pu1_refarray_temp;
3755 WORD32 i4_y_ref;
3756 WORD32 i4_y_phase;
3757 /* ------------------------------------------------------------ */
3758 /* Finding the offset */
3759 /* ------------------------------------------------------------ */
3760 i4_y_ref = ps_y_pos_phase[i4_y + i4_frm_mb_y].i2_ref_pos;
3761 i4_y_phase = ps_y_pos_phase[i4_y + i4_frm_mb_y].i2_phase;
3762 pu1_refarray_temp = pu1_refarray + i4_x + (i4_y_ref * i4_refarray_wd);
3763
3764 /* ------------------------------------------------------------ */
3765 /* Check for Luma/Chroma Processing */
3766 /* ------------------------------------------------------------ */
3767 if(0 == i4_chroma_flag)
3768 {
3769 *(pi4_interp_buff + i4_x) =
3770 (g_ai1_interp_filter_luma[i4_y_phase]) *
3771 (*(pu1_refarray_temp - i4_refarray_wd)) +
3772
3773 (g_ai1_interp_filter_luma[16 + i4_y_phase]) * (*(pu1_refarray_temp)) +
3774
3775 (g_ai1_interp_filter_luma[32 + i4_y_phase]) *
3776 (*(pu1_refarray_temp + i4_refarray_wd)) +
3777
3778 (g_ai1_interp_filter_luma[48 + i4_y_phase]) *
3779 (*(pu1_refarray_temp + (2 * i4_refarray_wd)));
3780 }
3781 else
3782 {
3783 *(pi4_interp_buff + i4_x) =
3784 (g_au1_interp_filter_chroma[i4_y_phase]) * (*(pu1_refarray_temp)) +
3785
3786 (g_au1_interp_filter_chroma[16 + i4_y_phase]) *
3787 (*(pu1_refarray_temp + i4_refarray_wd));
3788 }
3789
3790 } /* end of loop over array width */
3791 pi4_interp_buff = pi4_interp_buff + i4_refarray_wd;
3792 } /* end of loop over temp array height*/
3793
3794 pi4_interp_buff = pi4_interp_buff_temp;
3795
3796 /* --------------------------------------------------------------------- */
3797 /* Loop for interpolation in horizontal direction */
3798 /* --------------------------------------------------------------------- */
3799 for(i4_y = 0; i4_y < i4_temp_array_ht; i4_y++)
3800 {
3801 for(i4_x = 0; i4_x < i4_mb_wd; i4_x++)
3802 {
3803 WORD32 i4_x_ref;
3804 WORD32 i4_x_phase;
3805 /* ------------------------------------------------------------- */
3806 /* Finding the offset */
3807 /* ------------------------------------------------------------- */
3808 i4_x_ref = ps_x_pos_phase[i4_x + i4_frm_mb_x].i2_ref_pos;
3809 i4_x_phase = ps_x_pos_phase[i4_x + i4_frm_mb_x].i2_phase;
3810 pi4_interp_buff_temp = pi4_interp_buff + i4_x_ref;
3811
3812 /* ------------------------------------------------------------- */
3813 /* Check for Luma/Chroma Processing */
3814 /* ------------------------------------------------------------- */
3815 if(0 == i4_chroma_flag)
3816 {
3817 *(pu1_out + i4_x + (i4_y * i4_out_stride)) =
3818
3819 CLIPUCHAR(
3820 ((g_ai1_interp_filter_luma[i4_x_phase]) * (*(pi4_interp_buff_temp - 1)) +
3821 (g_ai1_interp_filter_luma[16 + i4_x_phase]) * (*(pi4_interp_buff_temp)) +
3822 (g_ai1_interp_filter_luma[32 + i4_x_phase]) *
3823 (*(pi4_interp_buff_temp + 1)) +
3824 (g_ai1_interp_filter_luma[48 + i4_x_phase]) *
3825 (*(pi4_interp_buff_temp + 2)) +
3826 512) >>
3827 10);
3828 }
3829 else
3830 {
3831 *(pu1_out + (2 * i4_x) + (i4_y * i4_out_stride)) = CLIPUCHAR(
3832 ((g_au1_interp_filter_chroma[i4_x_phase]) * (*(pi4_interp_buff_temp)) +
3833 (g_au1_interp_filter_chroma[16 + i4_x_phase]) * (*(pi4_interp_buff_temp + 1)) +
3834 512) >>
3835 10);
3836 }
3837
3838 } /* end of loop over array width */
3839 pi4_interp_buff = pi4_interp_buff + i4_refarray_wd;
3840 } /* end of loop over MB height */
3841
3842 return;
3843 } /* 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 /*****************************************************************************/
isvcd_intra_resamp_mb(void * pv_intra_samp_ctxt,mem_element_t * ps_ref_luma,mem_element_t * ps_ref_chroma,mem_element_t * ps_ref_mb_mode_map,mem_element_t * ps_curr_luma,mem_element_t * ps_curr_chroma,mb_coord_t * ps_mb_coord)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 {
3877 /* --------------------------------------------------------------------- */
3878 /* I/O buffer params */
3879 /* --------------------------------------------------------------------- */
3880 intra_sampling_ctxt_t *ps_ctxt;
3881 UWORD8 *pu1_inp_luma, *pu1_inp_cb, *pu1_inp_cr;
3882 UWORD8 *pu1_out_luma, *pu1_out_cb, *pu1_out_cr;
3883 WORD32 i4_inp_stride;
3884 WORD32 i4_out_stride;
3885 WORD32 i4_refarray_stride;
3886
3887 /* --------------------------------------------------------------------- */
3888 /* ref sample array and corresponding parametrs */
3889 /* --------------------------------------------------------------------- */
3890 WORD32 i4_chroma_flag, ret;
3891
3892 ps_ctxt = (intra_sampling_ctxt_t *) pv_intra_samp_ctxt;
3893 /* needs to be populated at proper place */
3894 i4_refarray_stride = ps_ctxt->i4_refarray_stride;
3895
3896 /* --------------------------------------------------------------------- */
3897 /* LUMA PROCESSING */
3898 /* --------------------------------------------------------------------- */
3899 pu1_inp_luma = (UWORD8 *) ps_ref_luma->pv_buffer;
3900 pu1_out_luma = (UWORD8 *) ps_curr_luma->pv_buffer;
3901 i4_inp_stride = ps_ref_luma->i4_num_element_stride;
3902 i4_out_stride = ps_curr_luma->i4_num_element_stride;
3903 i4_chroma_flag = 0;
3904
3905 /* ------- Constructing refSampleArray ----------------------- */
3906 ret = isvcd_reflayer_construction(pv_intra_samp_ctxt, pu1_inp_luma, NULL, i4_inp_stride,
3907 i4_refarray_stride, ps_ref_mb_mode_map, ps_mb_coord,
3908 i4_chroma_flag);
3909
3910 if(ret != OK)
3911 {
3912 return NOT_OK;
3913 }
3914 /* ---- Interpolation process for Intra_Base prediction ------ */
3915 ps_ctxt->pf_interpolate_intra_base(pv_intra_samp_ctxt, pu1_out_luma, i4_out_stride,
3916 i4_refarray_stride, ps_mb_coord->u2_mb_x,
3917 ps_mb_coord->u2_mb_y, i4_chroma_flag, 0);
3918
3919 /* --------------------------------------------------------------------- */
3920 /* CHROMA PROCESSING */
3921 /* --------------------------------------------------------------------- */
3922 /* CB */
3923 i4_inp_stride = ps_ref_chroma->i4_num_element_stride;
3924 pu1_inp_cb = (UWORD8 *) ps_ref_chroma->pv_buffer;
3925 pu1_inp_cr = pu1_inp_cb + 1;
3926 i4_chroma_flag = 1;
3927
3928 /* ------- Constructing refSampleArray ----------------------- */
3929 ret = isvcd_reflayer_construction(pv_intra_samp_ctxt, pu1_inp_cb, pu1_inp_cr, i4_inp_stride,
3930 i4_refarray_stride, ps_ref_mb_mode_map, ps_mb_coord,
3931 i4_chroma_flag);
3932
3933 if(ret != OK)
3934 {
3935 return NOT_OK;
3936 }
3937 i4_out_stride = ps_curr_chroma->i4_num_element_stride;
3938 pu1_out_cb = (UWORD8 *) ps_curr_chroma->pv_buffer;
3939 pu1_out_cr = pu1_out_cb + 1;
3940
3941 /* ---- Cb Interpolation process for Intra_Base prediction ------ */
3942 ps_ctxt->pf_interpolate_intra_base(pv_intra_samp_ctxt, pu1_out_cb, i4_out_stride,
3943 i4_refarray_stride, ps_mb_coord->u2_mb_x,
3944 ps_mb_coord->u2_mb_y, i4_chroma_flag, 0);
3945
3946 /* ---- Cr Interpolation process for Intra_Base prediction ------ */
3947 ps_ctxt->pf_interpolate_intra_base(pv_intra_samp_ctxt, pu1_out_cr, i4_out_stride,
3948 i4_refarray_stride, ps_mb_coord->u2_mb_x,
3949 ps_mb_coord->u2_mb_y, i4_chroma_flag, 1);
3950 return OK;
3951 }
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 /*****************************************************************************/
isvcd_intra_resamp_generate_segment_lookup(seg_lookup_desc_t * ps_seg_lookup_table,WORD32 i4_dimension,WORD32 i4_mb_size,WORD32 i4_shift_val)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 {
3982 WORD32 i4_x;
3983 WORD32 i4_position, i4_dist_prev_mb, i4_dist_next_mb;
3984 UWORD8 u1_seg_dim;
3985 UWORD8 u1_num_sgmts;
3986 WORD32 i4_block_size = i4_mb_size >> 1;
3987 UWORD8 u1_offset = 0;
3988 seg_lookup_desc_t *ps_segments;
3989 seg_description_t *ps_seg_desc;
3990
3991 memset(ps_seg_lookup_table, 0, i4_mb_size * sizeof(seg_lookup_desc_t));
3992
3993 for(i4_x = 0; i4_x < i4_mb_size; i4_x++)
3994 {
3995 ps_segments = &ps_seg_lookup_table[i4_x];
3996 ps_seg_desc = ps_segments->s_segments;
3997 i4_position = i4_x;
3998
3999 if(i4_x >= i4_block_size)
4000 {
4001 /* set the fourth bit so that later it can be directly OR ed */
4002 ps_segments->u4_start_pos = 8;
4003 }
4004 else
4005 {
4006 ps_segments->u4_start_pos = 0;
4007 }
4008
4009 u1_num_sgmts = 0;
4010 u1_offset = 0;
4011
4012 while(i4_position < (i4_x + i4_dimension))
4013 {
4014 /* check and fill the nearest mb boundry flag */
4015 if((i4_position & (i4_mb_size - 1)) < i4_block_size)
4016 {
4017 ps_seg_desc->i1_nearst_mb_bdry = -1;
4018 }
4019 else
4020 {
4021 ps_seg_desc->i1_nearst_mb_bdry = 1;
4022 }
4023
4024 /* find the distance from the previous MB for start of segment*/
4025 i4_dist_prev_mb = (i4_position & (i4_mb_size - 1));
4026
4027 ps_seg_desc->i1_dist_idx =
4028 ((i4_dist_prev_mb >= i4_mb_size >> 1) ? (i4_mb_size - i4_dist_prev_mb)
4029 : -(i4_dist_prev_mb + 1));
4030
4031 /* find the size of the segment */
4032 u1_seg_dim = (i4_block_size - (i4_position & (i4_block_size - 1)));
4033 i4_position += u1_seg_dim;
4034 if(i4_position > (i4_x + i4_dimension))
4035 {
4036 i4_position = (i4_x + i4_dimension);
4037 u1_seg_dim = (i4_position & (i4_block_size - 1));
4038 }
4039
4040 /* find the distance from the next MB for end of segment */
4041 i4_dist_next_mb = (i4_position & (i4_mb_size - 1));
4042 ps_seg_desc->u1_seg_dim = u1_seg_dim;
4043 ps_seg_desc->u1_seg_off = u1_offset;
4044
4045 /* check if the segment has a adjoining MB edge */
4046 if(i4_dist_prev_mb == 0)
4047 {
4048 if(0 == u1_num_sgmts)
4049 {
4050 ps_seg_desc->u1_mb_adjoin = 0;
4051 }
4052 else
4053 {
4054 ps_seg_desc->u1_mb_adjoin = 1 << i4_shift_val;
4055 }
4056 }
4057 else if(i4_dist_next_mb == 0)
4058 {
4059 if(i4_position == (i4_x + i4_dimension))
4060 {
4061 ps_seg_desc->u1_mb_adjoin = 0;
4062 }
4063 else
4064 {
4065 ps_seg_desc->u1_mb_adjoin = 1 << i4_shift_val;
4066 }
4067 }
4068 else
4069 {
4070 ps_seg_desc->u1_mb_adjoin = 0;
4071 }
4072
4073 /* Updations */
4074 u1_offset += u1_seg_dim;
4075 u1_num_sgmts++;
4076 ps_seg_desc++;
4077 }
4078
4079 /* fill the number of segments for this position */
4080 ps_segments->u1_num_segments = u1_num_sgmts;
4081 }
4082 }
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 /*****************************************************************************/
isvcd_intra_resamp_populate_list(intra_samp_map_ctxt_t * ps_map_ctxt,res_prms_t * ps_curr_res_prms,res_prms_t * ps_ref_res_prms,WORD32 i4_chroma_flag,svc_dec_lyr_struct_t * ps_svc_lyr_dec)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 {
4110 /* --------------------------------------------------------------------- */
4111 /* Local variables required for finding the mapping between the layers */
4112 /* --------------------------------------------------------------------- */
4113 UWORD32 i4_shift_x, i4_shift_y, i4_scale_x, i4_scale_y;
4114 WORD32 i4_offset_x, i4_offset_y;
4115 WORD32 i4_add_x, i4_add_y, i4_delta_x, i4_delta_y, i4_refphase_x, i4_refphase_y;
4116 WORD32 i4_phase_x, i4_phase_y, i4_sub_wd, i4_sub_ht, i4_mb_wd, i4_mb_ht;
4117 WORD32 i4_horz_dim, i4_vert_dim, i4_tmp;
4118 dec_struct_t *ps_dec = &ps_svc_lyr_dec->s_dec;
4119 /* --------------------------------------------------------------------- */
4120 /* Local Pointer Declaration for arrays in Mapping context */
4121 /* --------------------------------------------------------------------- */
4122 ref_mb_map_t *ps_x_off_len, *ps_y_off_len;
4123 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 WORD32 i4_ref_layer_field_pic_flag, i4_field_pic_flag, i4_frame_mbs_only_flag;
4129 WORD32 i4_ref_layer_frame_Mbs_only_flag, i4_field_Mb_flag, i4_bot_field_flag;
4130
4131 /* --------------------------------------------------------------------- */
4132 /* Cropping Parameters Declaration */
4133 /* --------------------------------------------------------------------- */
4134 WORD32 i4_scaled_ref_layer_left_offset, i4_scaled_ref_layer_top_offset;
4135 WORD32 i4_scaled_ref_layer_right_offset, i4_scaled_ref_layer_bottom_offset;
4136 dec_seq_params_t *ps_sps;
4137 dec_svc_seq_params_t *ps_subset_sps;
4138 ps_sps = ps_dec->ps_cur_sps;
4139 ps_subset_sps = ps_svc_lyr_dec->ps_cur_subset_sps;
4140
4141 /* --------------------------------------------------------------------- */
4142 /* Hardcoding flag information (assuming no field support) */
4143 /* --------------------------------------------------------------------- */
4144 i4_ref_layer_field_pic_flag = SVCD_FALSE;
4145 i4_field_pic_flag = SVCD_FALSE;
4146 i4_frame_mbs_only_flag = SVCD_TRUE;
4147 i4_field_Mb_flag = SVCD_FALSE;
4148 i4_bot_field_flag = SVCD_FALSE;
4149 i4_ref_layer_frame_Mbs_only_flag = SVCD_TRUE;
4150 i4_horz_dim = 0;
4151 i4_vert_dim = 0;
4152
4153 /* --------------------------------------------------------------------- */
4154 /* Pointer and Paramater are intialized - Chroma and Luma */
4155 /* --------------------------------------------------------------------- */
4156 {
4157 WORD32 i4_base_width;
4158 WORD32 i4_base_height;
4159 WORD32 i4_ref_layer_chroma_phase_x_plus1_flag;
4160 WORD32 i4_ref_layer_chroma_phase_y_plus1;
4161 WORD32 i4_chroma_phase_x_plus1_flag;
4162 WORD32 i4_chroma_phase_y_plus1;
4163
4164 /* ------------------------------------------------------------- */
4165 /* HARD CODED FOR 420 */
4166 /* ------------------------------------------------------------- */
4167 WORD32 i4_sub_wd_chroma = 2;
4168 WORD32 i4_sub_ht_chroma = 2;
4169
4170 i4_base_width = ps_ref_res_prms->i4_res_width;
4171 i4_base_height = ps_ref_res_prms->i4_res_height;
4172
4173 i4_ref_layer_chroma_phase_x_plus1_flag =
4174 ps_curr_res_prms->i1_ref_lyr_chroma_phase_x_plus1_flag;
4175
4176 i4_ref_layer_chroma_phase_y_plus1 = ps_curr_res_prms->i1_ref_lyr_chroma_phase_y_plus1;
4177 i4_chroma_phase_x_plus1_flag = ps_subset_sps->s_sps_svc_ext.u1_chroma_phase_x_plus1_flag;
4178 i4_chroma_phase_y_plus1 = ps_subset_sps->s_sps_svc_ext.u1_chroma_phase_y_plus1;
4179 i4_scaled_ref_layer_bottom_offset = ps_curr_res_prms->s_ref_lyr_scaled_offset.i2_bot;
4180 i4_scaled_ref_layer_left_offset = ps_curr_res_prms->s_ref_lyr_scaled_offset.i2_left;
4181 i4_scaled_ref_layer_top_offset = ps_curr_res_prms->s_ref_lyr_scaled_offset.i2_top;
4182 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 i4_ref_wd = (i4_base_width >> i4_chroma_flag);
4188 i4_ref_ht = (i4_base_height >> i4_chroma_flag) * (1 + i4_ref_layer_field_pic_flag);
4189
4190 i4_scaled_wd = ps_curr_res_prms->u2_scaled_ref_width;
4191 i4_scaled_ht = ps_curr_res_prms->u2_scaled_ref_height;
4192 i4_scaled_wd = (i4_scaled_wd >> i4_chroma_flag);
4193 i4_scaled_ht = (i4_scaled_ht >> i4_chroma_flag) * (1 + i4_field_pic_flag);
4194
4195 if(1 == i4_chroma_flag)
4196 {
4197 i4_refphase_x = i4_ref_layer_chroma_phase_x_plus1_flag - 1;
4198 i4_refphase_y = i4_ref_layer_chroma_phase_y_plus1 - 1;
4199 i4_phase_x = i4_chroma_phase_x_plus1_flag - 1;
4200 i4_phase_y = i4_chroma_phase_y_plus1 - 1;
4201 i4_sub_wd = i4_sub_wd_chroma;
4202 i4_sub_ht = i4_sub_ht_chroma;
4203 i4_mb_wd = MB_WIDTH >> 1;
4204 i4_mb_ht = MB_HEIGHT >> 1;
4205 }
4206 else
4207 {
4208 i4_refphase_x = 0;
4209 i4_refphase_y = 0;
4210 i4_phase_x = 0;
4211 i4_phase_y = 0;
4212 i4_sub_wd = 1;
4213 i4_sub_ht = 1;
4214 i4_mb_wd = MB_WIDTH;
4215 i4_mb_ht = MB_HEIGHT;
4216 }
4217 }
4218
4219 /* --------------------------------------------------------------------- */
4220 /* Derive shift x and y based on level idd */
4221 /* --------------------------------------------------------------------- */
4222 if(ps_sps->u1_level_idc <= 30)
4223 {
4224 i4_shift_x = 16;
4225 i4_shift_y = 16;
4226 }
4227 else
4228 {
4229 i4_shift_x = 31 - isvcd_get_ceil_log2(i4_ref_wd);
4230 i4_shift_y = 31 - isvcd_get_ceil_log2(i4_ref_ht);
4231 }
4232
4233 /* --------------------------------------------------------------------- */
4234 /* The following condition is not true in our case for time being */
4235 /* --------------------------------------------------------------------- */
4236 if((SVCD_FALSE == i4_frame_mbs_only_flag) || (SVCD_FALSE == i4_ref_layer_frame_Mbs_only_flag))
4237 {
4238 i4_phase_y = i4_phase_y + 4 * i4_bot_field_flag;
4239
4240 if(1 == i4_ref_layer_frame_Mbs_only_flag)
4241 i4_refphase_y = (2 * i4_refphase_y) + 2;
4242 else
4243 i4_refphase_y = i4_refphase_y + (4 * i4_bot_field_flag);
4244 }
4245
4246 /* --------------------------------------------------------------------- */
4247 /* Dx and Dy Computation - Ratio of the base and enhance layer width */
4248 /* --------------------------------------------------------------------- */
4249 i4_scale_x = ((i4_ref_wd << i4_shift_x) + (i4_scaled_wd >> 1)) / (i4_scaled_wd);
4250 i4_scale_y = ((i4_ref_ht << i4_shift_y) + (i4_scaled_ht >> 1)) / (i4_scaled_ht);
4251
4252 i4_offset_x = i4_scaled_ref_layer_left_offset / i4_sub_wd;
4253 i4_add_x = (((i4_ref_wd * (2 + i4_phase_x)) << (i4_shift_x - 2)) + (i4_scaled_wd >> 1)) /
4254 i4_scaled_wd +
4255 (1 << (i4_shift_x - 5));
4256 i4_delta_x = 4 * (2 + i4_refphase_x);
4257
4258 if((SVCD_TRUE == i4_frame_mbs_only_flag) && (SVCD_TRUE == i4_ref_layer_frame_Mbs_only_flag))
4259 {
4260 i4_offset_y = i4_scaled_ref_layer_top_offset / i4_sub_ht;
4261 i4_add_y = (((i4_ref_ht * (2 + i4_phase_y)) << (i4_shift_y - 2)) + (i4_scaled_ht >> 1)) /
4262 i4_scaled_ht +
4263 (1 << (i4_shift_y - 5));
4264 i4_delta_y = 4 * (2 + i4_refphase_y);
4265 }
4266 else
4267 {
4268 i4_offset_y = i4_scaled_ref_layer_top_offset / (2 * i4_sub_ht);
4269 i4_add_y = (((i4_ref_ht * (2 + i4_phase_y)) << (i4_shift_y - 3)) + (i4_scaled_ht >> 1)) /
4270 i4_scaled_ht +
4271 (1 << (i4_shift_y - 5));
4272 i4_delta_y = 2 * (2 + i4_refphase_y);
4273 }
4274
4275 /* --------------------------------------------------------------------- */
4276 /* Intializing Local Pointers - Chroma and Luma */
4277 /* --------------------------------------------------------------------- */
4278 ps_x_off_len = ps_map_ctxt->ps_x_offset_length;
4279 ps_y_off_len = ps_map_ctxt->ps_y_offset_length;
4280 i4_curr_lyr_width = ps_curr_res_prms->i4_res_width >> i4_chroma_flag;
4281 i4_curr_lyr_height = ps_curr_res_prms->i4_res_height >> i4_chroma_flag;
4282
4283 /* --------------------------------------------------------------------- */
4284 /* Dyadic Scaling Ratios Handling */
4285 /* --------------------------------------------------------------------- */
4286 if(1 == ps_curr_res_prms->u1_dyadic_flag)
4287 {
4288 WORD32 i4_refarray_wd, i4_x_offset;
4289 WORD32 i4_refarray_ht, i4_y_offset;
4290 WORD32 i4_crp_wd_lt, i4_crp_ht_top;
4291 WORD32 i4_crp_wd_rt, i4_crp_ht_bot;
4292 WORD32 i4_ref_lyr_wd, i4_ref_lyr_ht;
4293 WORD32 i4_ref_x, i4_ref_y;
4294 WORD32 i4_ofst;
4295 WORD32 i4_i, i4_j;
4296
4297 /* Hard coded for dyadic case */
4298 i4_refarray_wd = 20 >> i4_chroma_flag;
4299 i4_ofst = -2 >> i4_chroma_flag;
4300 i4_crp_wd_lt = i4_scaled_ref_layer_left_offset >> i4_chroma_flag;
4301 i4_crp_wd_rt = i4_scaled_ref_layer_right_offset >> i4_chroma_flag;
4302 i4_ref_lyr_wd = (i4_curr_lyr_width >> 1);
4303
4304 i4_ref_x = 0;
4305 for(i4_i = 0; i4_i < (WORD32) i4_curr_lyr_width; i4_i += (i4_mb_wd << 1))
4306 {
4307 i4_x_offset = MAX(i4_ofst, (i4_ref_x + i4_ofst));
4308 i4_x_offset = MIN(i4_x_offset, (i4_ref_lyr_wd - i4_ofst));
4309 ps_x_off_len->i2_offset = i4_x_offset;
4310 ps_x_off_len->i2_length = i4_refarray_wd;
4311 ps_x_off_len++;
4312 ps_x_off_len->i2_offset = i4_x_offset;
4313 ps_x_off_len->i2_length = i4_refarray_wd;
4314 ps_x_off_len++;
4315 if(i4_i >= i4_crp_wd_lt)
4316 {
4317 if(i4_i <= (WORD32) (i4_curr_lyr_width - i4_crp_wd_rt))
4318 {
4319 i4_ref_x += i4_mb_wd;
4320 }
4321 }
4322 }
4323
4324 i4_refarray_ht = 20 >> i4_chroma_flag;
4325 i4_crp_ht_top = i4_scaled_ref_layer_top_offset >> i4_chroma_flag;
4326 i4_crp_ht_bot = i4_scaled_ref_layer_bottom_offset >> i4_chroma_flag;
4327 i4_ref_lyr_ht = (i4_curr_lyr_height >> 1);
4328
4329 i4_ref_y = 0;
4330 for(i4_j = 0; i4_j < (WORD32) i4_curr_lyr_height; i4_j += (i4_mb_ht << 1))
4331 {
4332 i4_y_offset = MAX(i4_ofst, (i4_ref_y + i4_ofst));
4333 i4_y_offset = MIN(i4_y_offset, (i4_ref_lyr_ht - i4_ofst));
4334 ps_y_off_len->i2_offset = i4_y_offset;
4335 ps_y_off_len->i2_length = i4_refarray_ht;
4336 ps_y_off_len++;
4337 ps_y_off_len->i2_offset = i4_y_offset;
4338 ps_y_off_len->i2_length = i4_refarray_ht;
4339 ps_y_off_len++;
4340 if(i4_j >= i4_crp_ht_top)
4341 {
4342 if(i4_j <= (WORD32) (i4_curr_lyr_height - i4_crp_ht_bot))
4343 {
4344 i4_ref_y += i4_mb_ht;
4345 }
4346 }
4347 }
4348 /* No need to process further, return */
4349 return;
4350 } /* If dyadic path */
4351
4352 /* Proposed Algo for Optimization */
4353 {
4354 WORD32 i4_max, i4_min;
4355 ref_min_max_map_t *ps_x_min_max;
4356 ref_min_max_map_t *ps_y_min_max;
4357 WORD32 i4_i, i4_j;
4358
4359 ps_x_min_max = ps_map_ctxt->ps_x_min_max;
4360 ps_y_min_max = ps_map_ctxt->ps_y_min_max;
4361 /* ----------------------------------------------------------------- */
4362 /* Computation of offsetX refArrayW Xmin and Xmax Lists */
4363 /* ----------------------------------------------------------------- */
4364 for(i4_i = 0; i4_i < (WORD32) i4_curr_lyr_width; i4_i = i4_i + i4_mb_wd)
4365 {
4366 WORD32 i4_refarray_wd, i4_xr_index;
4367 WORD32 i4_x_refmin16;
4368 WORD32 i4_x_refmax16;
4369 WORD32 i4_x_offset;
4370
4371 i4_x_refmin16 = (WORD64) (((WORD64) (i4_i - i4_offset_x) * i4_scale_x + i4_add_x) >>
4372 ((WORD32) (i4_shift_x - 4))) -
4373 i4_delta_x;
4374
4375 i4_x_refmax16 =
4376 (WORD64) (((WORD64) (i4_i + i4_mb_wd - 1 - i4_offset_x) * i4_scale_x + i4_add_x) >>
4377 ((WORD32) (i4_shift_x - 4))) -
4378 i4_delta_x;
4379
4380 /* ------------------------------------------------------------- */
4381 /* Modified AC205 */
4382 /* Minimum width required - So adding 2 pixels on each side */
4383 /* ------------------------------------------------------------- */
4384 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 i4_x_offset = (i4_x_refmin16 >> 4) - 2;
4390
4391 /* ------------------------------------------------------------- */
4392 /* Modifying the values based on the location */
4393 /* ------------------------------------------------------------- */
4394 i4_min = i4_x_offset;
4395 i4_xr_index = i4_min - ((i4_min / i4_mb_wd) * i4_mb_wd);
4396
4397 if(i4_xr_index < (i4_mb_wd >> 1))
4398 {
4399 i4_refarray_wd = i4_refarray_wd + (i4_mb_wd >> 1);
4400 i4_x_offset = i4_x_offset - (i4_mb_wd >> 1);
4401 }
4402
4403 i4_max = ((i4_x_refmax16 + 15) >> 4) + 2;
4404 i4_xr_index = i4_max - ((i4_max / i4_mb_wd) * i4_mb_wd);
4405
4406 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 ps_x_off_len->i2_offset = i4_x_offset;
4412 ps_x_off_len->i2_length = i4_refarray_wd;
4413
4414 ps_x_min_max->i2_min_pos = (i4_x_refmin16 >> 4) - i4_x_offset;
4415 ps_x_min_max->i2_max_pos = ((i4_x_refmax16 + 15) >> 4) - i4_x_offset;
4416
4417 i4_tmp = (WORD32) (ps_x_min_max->i2_max_pos - ps_x_min_max->i2_min_pos) +
4418 (4 >> i4_chroma_flag);
4419 if(i4_tmp > i4_horz_dim)
4420 {
4421 i4_horz_dim = i4_tmp;
4422 }
4423
4424 /* increment the pointer */
4425 ps_x_off_len++;
4426 ps_x_min_max++;
4427 } /* end of loop over scaled width */
4428
4429 /* ----------------------------------------------------------------- */
4430 /* Computation of offsetY refArrayH Ymin and Ymax Lists */
4431 /* ----------------------------------------------------------------- */
4432 for(i4_j = 0; i4_j < (WORD32) i4_curr_lyr_height; i4_j = i4_j + i4_mb_ht)
4433 {
4434 WORD32 i4_refarray_ht, i4_yr_index;
4435 WORD32 i4_y_refmin16;
4436 WORD32 i4_y_refmax16;
4437 WORD32 i4_y_offset;
4438
4439 i4_y_refmin16 = (WORD64) (((WORD64) (i4_j - i4_offset_y) * i4_scale_y + i4_add_y) >>
4440 ((WORD32) (i4_shift_y - 4))) -
4441 i4_delta_y;
4442
4443 i4_y_refmax16 =
4444 (WORD64) (((WORD64) (i4_j + i4_mb_ht - 1 - i4_offset_y) * i4_scale_y + i4_add_y) >>
4445 ((WORD32) (i4_shift_y - 4))) -
4446 i4_delta_y;
4447
4448 /* ------------------------------------------------------------- */
4449 /* Modified AC205 */
4450 /* Minimum width required - So adding 2 pixels on each side */
4451 /* ------------------------------------------------------------- */
4452 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 i4_y_offset = (i4_y_refmin16 >> 4) - 2;
4458
4459 /* ------------------------------------------------------------- */
4460 /* Modifying the values based on the location */
4461 /* ------------------------------------------------------------- */
4462 i4_min = i4_y_offset;
4463 i4_yr_index = i4_min - ((i4_min / i4_mb_ht) * i4_mb_ht);
4464 if(i4_yr_index < (i4_mb_ht >> 1))
4465 {
4466 i4_refarray_ht = i4_refarray_ht + (i4_mb_ht >> 1);
4467 i4_y_offset = i4_y_offset - (i4_mb_ht >> 1);
4468 }
4469
4470 i4_max = ((i4_y_refmax16 + 15) >> 4) + 2;
4471 i4_yr_index = i4_max - ((i4_max / i4_mb_ht) * i4_mb_ht);
4472 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 ps_y_off_len->i2_offset = i4_y_offset;
4478 ps_y_off_len->i2_length = i4_refarray_ht;
4479 ps_y_min_max->i2_min_pos = (i4_y_refmin16 >> 4) - i4_y_offset;
4480 ps_y_min_max->i2_max_pos = ((i4_y_refmax16 + 15) >> 4) - i4_y_offset;
4481
4482 i4_tmp = (WORD32) (ps_y_min_max->i2_max_pos - ps_y_min_max->i2_min_pos) +
4483 (4 >> i4_chroma_flag);
4484 if(i4_tmp > i4_vert_dim)
4485 {
4486 i4_vert_dim = i4_tmp;
4487 }
4488
4489 /* increment the pointer */
4490 ps_y_off_len++;
4491 ps_y_min_max++;
4492 } /* end of loop over scaled height */
4493 }
4494
4495 /* --------------------------------------------------------------------- */
4496 /* Computation of Xref and Xphase List as per standard */
4497 /* --------------------------------------------------------------------- */
4498 ps_x_off_len = ps_map_ctxt->ps_x_offset_length;
4499 ps_y_off_len = ps_map_ctxt->ps_y_offset_length;
4500
4501 {
4502 ref_pixel_map_t *ps_x_pos_phase;
4503 WORD32 i4_xc;
4504 WORD32 i4_offset_x_index;
4505
4506 ps_x_pos_phase = ps_map_ctxt->ps_x_pos_phase;
4507
4508 for(i4_xc = 0; i4_xc < (WORD32) i4_curr_lyr_width; i4_xc++)
4509 {
4510 WORD32 i4_x_offset;
4511 WORD32 i4_x_ref16;
4512
4513 i4_offset_x_index = i4_xc / i4_mb_wd;
4514
4515 i4_x_offset = ps_x_off_len[i4_offset_x_index].i2_offset;
4516
4517 i4_x_ref16 = (WORD64) (((WORD64) (i4_xc - i4_offset_x) * i4_scale_x + i4_add_x) >>
4518 ((WORD32) (i4_shift_x - 4))) -
4519 i4_delta_x;
4520
4521 /* store the values */
4522 ps_x_pos_phase->i2_ref_pos = (i4_x_ref16 >> 4) - i4_x_offset;
4523 ps_x_pos_phase->i2_phase = i4_x_ref16 & 15;
4524
4525 /* increment the pointer */
4526 ps_x_pos_phase++;
4527
4528 } /* end of loop over scaled width */
4529 }
4530
4531 /* --------------------------------------------------------------------- */
4532 /* Computation of Yref and Yphase List as per standard */
4533 /* --------------------------------------------------------------------- */
4534 {
4535 WORD32 i4_yc;
4536 ref_pixel_map_t *ps_y_pos_phase;
4537
4538 ps_y_pos_phase = ps_map_ctxt->ps_y_pos_phase;
4539
4540 for(i4_yc = 0; i4_yc < (WORD32) i4_curr_lyr_height; i4_yc++)
4541 {
4542 WORD32 i4_y_offset;
4543 WORD32 i4_y_ref16;
4544 WORD32 i4_offset_y_index;
4545
4546 i4_offset_y_index = i4_yc / i4_mb_ht;
4547
4548 i4_y_offset = ps_y_off_len[i4_offset_y_index].i2_offset;
4549
4550 if((SVCD_FALSE == i4_frame_mbs_only_flag) ||
4551 (SVCD_FALSE == i4_ref_layer_frame_Mbs_only_flag))
4552 {
4553 i4_yc = i4_yc >> (1 - i4_field_Mb_flag);
4554 }
4555
4556 i4_y_ref16 = (WORD64) (((WORD64) (i4_yc - i4_offset_y) * i4_scale_y + i4_add_y) >>
4557 ((WORD32) (i4_shift_y - 4))) -
4558 i4_delta_y;
4559 ps_y_pos_phase->i2_ref_pos = (i4_y_ref16 >> 4) - i4_y_offset;
4560 ps_y_pos_phase->i2_phase = i4_y_ref16 & 15;
4561
4562 /* increment the pointer */
4563 ps_y_pos_phase++;
4564
4565 } /* end of loop over scaled height */
4566 }
4567
4568 /* --------------------------------------------------------------------- */
4569 /* Computation of Corresponding Diagonal Location */
4570 /* --------------------------------------------------------------------- */
4571 {
4572 WORD16 *pi2_xd_index;
4573 WORD16 *pi2_yd_index;
4574 WORD16 *pi2_ya_index;
4575 WORD32 i4_i, i4_j;
4576
4577 pi2_xd_index = ps_map_ctxt->pi2_xd_index;
4578 pi2_yd_index = ps_map_ctxt->pi2_yd_index;
4579 pi2_ya_index = ps_map_ctxt->pi2_ya_index;
4580
4581 for(i4_i = 0; i4_i < i4_mb_wd; i4_i++)
4582 {
4583 *(pi2_xd_index + i4_i) = ((i4_i >= i4_mb_wd >> 1) ? (i4_i - i4_mb_wd) : (i4_i + 1));
4584
4585 } /* end of loop over MB width */
4586
4587 for(i4_j = 0; i4_j < i4_mb_ht; i4_j++)
4588 {
4589 *(pi2_yd_index + i4_j) = ((i4_j >= i4_mb_ht >> 1) ? (i4_j - i4_mb_ht) : (i4_j + 1));
4590
4591 *(pi2_ya_index + i4_j) =
4592 *(pi2_yd_index + i4_j) - (((i4_mb_ht >> 1) + 1) * (SIGN(*(pi2_yd_index + i4_j))));
4593
4594 } /* end of loop over MB height */
4595 }
4596
4597 /* generate the lookup to generate horizontal segments */
4598 isvcd_intra_resamp_generate_segment_lookup(ps_map_ctxt->ps_seg_lookup_horz, i4_horz_dim,
4599 i4_mb_wd, 3);
4600
4601 /* generate the lookup to generate vertical segments */
4602 isvcd_intra_resamp_generate_segment_lookup(ps_map_ctxt->ps_seg_lookup_vert, i4_vert_dim,
4603 i4_mb_ht, 4);
4604
4605 return;
4606 } /* 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
isvcd_populate_res_prms(void * pv_svc_dec)4630 WORD32 isvcd_populate_res_prms(void *pv_svc_dec)
4631 {
4632 svc_dec_lyr_struct_t *ps_svc_lyr_dec = (svc_dec_lyr_struct_t *) pv_svc_dec;
4633 dec_struct_t *ps_dec = &ps_svc_lyr_dec->s_dec;
4634 res_prms_t *ps_curr_lyr_res_prms;
4635 svc_dec_lyr_struct_t *ps_svc_ref_lyr_dec;
4636 ps_svc_ref_lyr_dec = ps_svc_lyr_dec->ps_dec_svc_ref_layer;
4637 ps_curr_lyr_res_prms = &ps_svc_lyr_dec->s_res_prms;
4638
4639 ps_curr_lyr_res_prms->i4_res_width = ps_dec->u2_pic_wd;
4640 ps_curr_lyr_res_prms->i4_res_height = ps_dec->u2_pic_ht;
4641 ps_curr_lyr_res_prms->s_ref_lyr_scaled_offset.i2_left =
4642 ps_svc_lyr_dec->ps_cur_subset_sps->s_sps_svc_ext.i4_seq_scaled_ref_layer_left_offset << 1;
4643 ps_curr_lyr_res_prms->s_ref_lyr_scaled_offset.i2_top =
4644 ps_svc_lyr_dec->ps_cur_subset_sps->s_sps_svc_ext.i4_seq_scaled_ref_layer_top_offset << 1;
4645 ps_curr_lyr_res_prms->s_ref_lyr_scaled_offset.i2_rt =
4646 ps_svc_lyr_dec->ps_cur_subset_sps->s_sps_svc_ext.i4_seq_scaled_ref_layer_right_offset << 1;
4647 ps_curr_lyr_res_prms->s_ref_lyr_scaled_offset.i2_bot =
4648 ps_svc_lyr_dec->ps_cur_subset_sps->s_sps_svc_ext.i4_seq_scaled_ref_layer_bottom_offset << 1;
4649 ps_curr_lyr_res_prms->u2_scaled_ref_width =
4650 (ps_dec->u2_frm_wd_in_mbs << 4) - (ps_curr_lyr_res_prms->s_ref_lyr_scaled_offset.i2_left +
4651 ps_curr_lyr_res_prms->s_ref_lyr_scaled_offset.i2_rt);
4652
4653 ps_curr_lyr_res_prms->u2_scaled_ref_height =
4654 (ps_dec->u2_frm_ht_in_mbs << 4) - (ps_curr_lyr_res_prms->s_ref_lyr_scaled_offset.i2_top +
4655 ps_curr_lyr_res_prms->s_ref_lyr_scaled_offset.i2_bot);
4656
4657 ps_curr_lyr_res_prms->u1_cropping_change_flag = 0;
4658 if(2 == ps_svc_lyr_dec->ps_cur_subset_sps->s_sps_svc_ext.u1_extended_spatial_scalability_idc)
4659 {
4660 ps_curr_lyr_res_prms->u1_cropping_change_flag = 1;
4661
4662 ps_curr_lyr_res_prms->s_ref_lyr_scaled_offset.i2_left =
4663 ps_svc_lyr_dec->s_svc_slice_params.i4_scaled_ref_layer_left_offset << 1;
4664
4665 ps_curr_lyr_res_prms->s_ref_lyr_scaled_offset.i2_top =
4666 ps_svc_lyr_dec->s_svc_slice_params.i4_scaled_ref_layer_top_offset << 1;
4667 ps_curr_lyr_res_prms->s_ref_lyr_scaled_offset.i2_rt =
4668 ps_svc_lyr_dec->s_svc_slice_params.i4_scaled_ref_layer_right_offset << 1;
4669 ps_curr_lyr_res_prms->s_ref_lyr_scaled_offset.i2_bot =
4670 ps_svc_lyr_dec->s_svc_slice_params.i4_scaled_ref_layer_bottom_offset << 1;
4671 ps_curr_lyr_res_prms->u2_scaled_ref_width =
4672 (ps_dec->u2_frm_wd_in_mbs << 4) -
4673 (ps_curr_lyr_res_prms->s_ref_lyr_scaled_offset.i2_left +
4674 ps_curr_lyr_res_prms->s_ref_lyr_scaled_offset.i2_rt);
4675
4676 ps_curr_lyr_res_prms->u2_scaled_ref_height =
4677 (ps_dec->u2_frm_ht_in_mbs << 4) -
4678 (ps_curr_lyr_res_prms->s_ref_lyr_scaled_offset.i2_top +
4679 ps_curr_lyr_res_prms->s_ref_lyr_scaled_offset.i2_bot);
4680
4681 return NOT_OK;
4682 }
4683
4684 ps_curr_lyr_res_prms->u1_rstrct_res_change_flag = SVCD_TRUE;
4685
4686 ps_curr_lyr_res_prms->u1_disable_inter_lyr_dblk_filter_idc =
4687 ps_svc_lyr_dec->s_svc_slice_params.u4_disable_inter_layer_deblk_filter_idc;
4688 ps_curr_lyr_res_prms->i1_inter_lyr_alpha_c0_offset =
4689 ps_svc_lyr_dec->s_svc_slice_params.i4_inter_layer_slice_alpha_c0_offset_div2;
4690 ps_curr_lyr_res_prms->i1_inter_lyr_beta_offset =
4691 ps_svc_lyr_dec->s_svc_slice_params.i4_inter_layer_slice_beta_offset_div2;
4692 ps_curr_lyr_res_prms->i1_constrained_intra_rsmpl_flag =
4693 ps_svc_lyr_dec->s_svc_slice_params.u1_constrained_intra_resampling_flag;
4694 ps_curr_lyr_res_prms->i1_ref_lyr_chroma_phase_x_plus1_flag =
4695 ps_svc_lyr_dec->ps_cur_subset_sps->s_sps_svc_ext.u1_seq_ref_layer_chroma_phase_x_plus1_flag;
4696 ps_curr_lyr_res_prms->i1_ref_lyr_chroma_phase_y_plus1 =
4697 ps_svc_lyr_dec->ps_cur_subset_sps->s_sps_svc_ext.u1_seq_ref_layer_chroma_phase_y_plus1;
4698 ps_curr_lyr_res_prms->u1_direct_8x8_inference_flag =
4699 ps_dec->ps_cur_sps->u1_direct_8x8_inference_flag;
4700
4701 ps_curr_lyr_res_prms->u1_remap_req_flag = 1;
4702 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 if(SVCD_TRUE != ps_svc_lyr_dec->u1_base_res_flag)
4707 {
4708 WORD32 i4_ref_lyr_width;
4709 WORD32 i4_ref_lyr_ht;
4710 WORD32 i4_dyadic_flag = SVCD_FALSE;
4711 i4_ref_lyr_width = ps_svc_ref_lyr_dec->s_res_prms.i4_res_width;
4712 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 ps_curr_lyr_res_prms->u1_rstrct_res_change_flag = SVCD_TRUE;
4716
4717 if(0 == ((ps_curr_lyr_res_prms->u2_scaled_ref_width == i4_ref_lyr_width) ||
4718 (ps_curr_lyr_res_prms->u2_scaled_ref_width == (i4_ref_lyr_width << 1))))
4719 {
4720 ps_curr_lyr_res_prms->u1_rstrct_res_change_flag = SVCD_FALSE;
4721 }
4722
4723 if(0 == ((ps_curr_lyr_res_prms->u2_scaled_ref_height == i4_ref_lyr_ht) ||
4724 (ps_curr_lyr_res_prms->u2_scaled_ref_height == (i4_ref_lyr_ht << 1))))
4725 {
4726 ps_curr_lyr_res_prms->u1_rstrct_res_change_flag = SVCD_FALSE;
4727 }
4728
4729 if(0 != (ps_curr_lyr_res_prms->s_ref_lyr_scaled_offset.i2_left & 15))
4730 {
4731 ps_curr_lyr_res_prms->u1_rstrct_res_change_flag = SVCD_FALSE;
4732 }
4733
4734 if(0 != (ps_curr_lyr_res_prms->s_ref_lyr_scaled_offset.i2_top & 15))
4735 {
4736 ps_curr_lyr_res_prms->u1_rstrct_res_change_flag = SVCD_FALSE;
4737 }
4738
4739 /* populate the dyadic status */
4740
4741 if((ps_curr_lyr_res_prms->u2_scaled_ref_width == (i4_ref_lyr_width << 1)) &&
4742 (ps_curr_lyr_res_prms->u2_scaled_ref_height == (i4_ref_lyr_ht << 1)))
4743 {
4744 i4_dyadic_flag = SVCD_TRUE;
4745 }
4746 else if((ps_curr_lyr_res_prms->u2_scaled_ref_width != ((i4_ref_lyr_width * 3) >> 1)) ||
4747 (ps_curr_lyr_res_prms->u2_scaled_ref_height != ((i4_ref_lyr_ht * 3) >> 1)))
4748 {
4749 ps_curr_lyr_res_prms->u1_dyadic_flag = i4_dyadic_flag;
4750 ps_svc_lyr_dec->u1_dyadic_flag = ps_curr_lyr_res_prms->u1_dyadic_flag;
4751 return NOT_OK;
4752 }
4753
4754 /* check if cropping is MB aligned */
4755 if(SVCD_TRUE == i4_dyadic_flag)
4756 {
4757 if((0 != (ps_curr_lyr_res_prms->s_ref_lyr_scaled_offset.i2_left & 15)) ||
4758 (0 != (ps_curr_lyr_res_prms->s_ref_lyr_scaled_offset.i2_top & 15)))
4759 {
4760 i4_dyadic_flag = SVCD_FALSE;
4761 }
4762 }
4763
4764 ps_curr_lyr_res_prms->u1_dyadic_flag = i4_dyadic_flag;
4765 ps_svc_lyr_dec->u1_dyadic_flag = ps_curr_lyr_res_prms->u1_dyadic_flag;
4766 }
4767
4768 {
4769 inter_lyr_mb_prms_t *ps_tmp_prms, *ps_tmp_prms_2;
4770 inter_lyr_mb_prms_t *ps_ref_mb_prms;
4771 WORD32 i4_stride;
4772 WORD32 i4_ht_in_mbs, i4_wd_in_mbs;
4773 WORD32 i4_i;
4774
4775 /* Derive the reference mb mode map */
4776
4777 ps_ref_mb_prms = ps_svc_lyr_dec->ps_inter_lyr_mb_prms_frm_start;
4778 i4_stride = ps_svc_lyr_dec->u2_inter_lyr_mb_prms_stride;
4779
4780 i4_ht_in_mbs = ps_dec->u2_frm_ht_in_mbs;
4781 i4_wd_in_mbs = ps_dec->u2_frm_wd_in_mbs;
4782
4783 /* Set the first border row to 0xFF */
4784 ps_tmp_prms = (ps_ref_mb_prms - 1 - i4_stride);
4785
4786 memset(ps_svc_lyr_dec->ps_inter_lyr_mb_prms_base, -1,
4787 ps_svc_lyr_dec->u4_inter_lyr_mb_prms_size);
4788 memset(ps_svc_lyr_dec->pu1_svc_base_mode_flag, 0,
4789 ps_svc_lyr_dec->i4_frm_svc_base_mode_cabac_size);
4790
4791 for(i4_i = 0; i4_i < (i4_wd_in_mbs + 2); i4_i++)
4792 {
4793 ps_tmp_prms->i1_mb_mode = (WORD8) 0xFF;
4794 ps_tmp_prms += 1;
4795 }
4796
4797 /* Set the left and right border pixels of each row to 0 */
4798 ps_tmp_prms = ps_ref_mb_prms - 1;
4799
4800 for(i4_i = 0; i4_i < i4_ht_in_mbs; i4_i++)
4801 {
4802 ps_tmp_prms->i1_mb_mode = (WORD8) 0xFF;
4803 ps_tmp_prms_2 = ps_tmp_prms + (i4_wd_in_mbs + 1);
4804 ps_tmp_prms_2->i1_mb_mode = (WORD8) 0xFF;
4805 ps_tmp_prms += i4_stride;
4806 }
4807
4808 /* Set the last border row to 0xFF */
4809 for(i4_i = 0; i4_i < (i4_wd_in_mbs + 2); i4_i++)
4810 {
4811 ps_tmp_prms->i1_mb_mode = (WORD8) 0xFF;
4812 ps_tmp_prms += 1;
4813 }
4814 }
4815
4816 /* reset residual luma, chroma buffer*/
4817 memset(ps_svc_lyr_dec->pi2_il_residual_resample_luma_base, 0,
4818 ps_svc_lyr_dec->u4_residual_resample_luma_size);
4819 memset(ps_svc_lyr_dec->pi2_il_residual_resample_chroma_base, 0,
4820 ps_svc_lyr_dec->u4_residual_resample_chroma_size);
4821
4822 return OK;
4823 }
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 /*****************************************************************************/
isvcd_crop_wnd_flag_res_int(void * pv_svc_dec)4849 void isvcd_crop_wnd_flag_res_int(void *pv_svc_dec)
4850 {
4851 UWORD8 *pu1_crop_wnd_flag;
4852 WORD32 i4_num_mbs;
4853 WORD32 i4_crop_mbs_x;
4854 WORD32 i4_crop_mbs_y;
4855 WORD32 i4_cnt;
4856 WORD32 i4_left_offset, i4_rt_offset;
4857 WORD32 i4_top_offset, i4_bot_offset;
4858 WORD32 i4_frm_wd_in_mbs;
4859 WORD32 i4_frm_ht_in_mbs;
4860 dec_struct_t *ps_dec;
4861 svc_dec_lyr_struct_t *ps_svc_lyr_dec;
4862 res_prms_t *ps_res_prms;
4863
4864 ps_svc_lyr_dec = (svc_dec_lyr_struct_t *) pv_svc_dec;
4865 ps_dec = &ps_svc_lyr_dec->s_dec;
4866 ps_res_prms = &ps_svc_lyr_dec->s_res_prms;
4867 i4_frm_wd_in_mbs = ps_dec->u2_frm_wd_in_mbs;
4868 i4_frm_ht_in_mbs = ps_dec->u2_frm_ht_in_mbs;
4869
4870 /* Initializations */
4871 pu1_crop_wnd_flag = ps_svc_lyr_dec->pu1_crop_wnd_flag;
4872 i4_num_mbs = i4_frm_wd_in_mbs * i4_frm_ht_in_mbs;
4873
4874 /* bottom most layer in a resolution */
4875 if(ps_res_prms->s_ref_lyr_scaled_offset.i2_left >= 0)
4876 {
4877 /* check for offset greater than 0 */
4878 i4_left_offset = (ps_res_prms->s_ref_lyr_scaled_offset.i2_left + 15) >> 4;
4879 }
4880 else
4881 {
4882 /* if negative set it to 0*/
4883 i4_left_offset = 0;
4884 }
4885
4886 if(ps_res_prms->s_ref_lyr_scaled_offset.i2_rt >= 0)
4887 {
4888 /* check for offset greater than 0 */
4889 i4_rt_offset =
4890 (ps_res_prms->i4_res_width - ps_res_prms->s_ref_lyr_scaled_offset.i2_rt) >> 4;
4891 }
4892 else
4893 {
4894 /* if negative set it to framewidth in MBs */
4895 i4_rt_offset = (ps_res_prms->i4_res_width >> 4);
4896 }
4897
4898 if(ps_res_prms->s_ref_lyr_scaled_offset.i2_top >= 0)
4899 {
4900 /* check for offset greater than 0 */
4901 i4_top_offset = (ps_res_prms->s_ref_lyr_scaled_offset.i2_top + 15) >> 4;
4902 }
4903 else
4904 {
4905 /* if negative set it to 0 */
4906 i4_top_offset = 0;
4907 }
4908
4909 if(ps_res_prms->s_ref_lyr_scaled_offset.i2_bot >= 0)
4910 {
4911 /* check for offset greater than 0 */
4912 i4_bot_offset =
4913 (ps_res_prms->i4_res_height - ps_res_prms->s_ref_lyr_scaled_offset.i2_bot) >> 4;
4914 }
4915 else
4916 {
4917 /* if negative set it to frameheight in MBs */
4918 i4_bot_offset = (ps_res_prms->i4_res_height >> 4);
4919 }
4920
4921 i4_crop_mbs_x = i4_rt_offset - i4_left_offset;
4922 i4_crop_mbs_y = i4_bot_offset - i4_top_offset;
4923
4924 /* Set crop window flag to 0 for all mbs */
4925 memset(pu1_crop_wnd_flag, 0, i4_num_mbs);
4926
4927 pu1_crop_wnd_flag += (i4_frm_wd_in_mbs * i4_top_offset);
4928 pu1_crop_wnd_flag += i4_left_offset;
4929 /* Loop over MBs in crop window */
4930 for(i4_cnt = 0; i4_cnt < i4_crop_mbs_y; i4_cnt++)
4931 {
4932 memset(pu1_crop_wnd_flag, 1, i4_crop_mbs_x);
4933 pu1_crop_wnd_flag += i4_frm_wd_in_mbs;
4934 }
4935 }
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 /*****************************************************************************/
isvcd_intra_resamp_res_init_update_flags(void * pv_svc_dec)4962 void isvcd_intra_resamp_res_init_update_flags(void *pv_svc_dec)
4963 {
4964 intra_sampling_ctxt_t *ps_ctxt;
4965 intra_samp_lyr_ctxt *ps_lyr_ctxt;
4966 svc_dec_lyr_struct_t *ps_svc_lyr_dec = (svc_dec_lyr_struct_t *) pv_svc_dec;
4967
4968 ps_ctxt = (intra_sampling_ctxt_t *) ps_svc_lyr_dec->pv_intra_sample_ctxt;;
4969 /* get the current layer ctxt */
4970 ps_lyr_ctxt = &ps_ctxt->as_res_lyrs[ps_svc_lyr_dec->u1_layer_id - 1];
4971
4972 ps_lyr_ctxt->i1_constrained_intra_rsmpl_flag =
4973 ps_svc_lyr_dec->s_svc_slice_params.u1_constrained_intra_resampling_flag;
4974 }
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 /*****************************************************************************/
isvcd_intra_resamp_res_init(void * pv_svc_dec)5001 WORD32 isvcd_intra_resamp_res_init(void *pv_svc_dec)
5002 {
5003 intra_sampling_ctxt_t *ps_ctxt;
5004 intra_samp_lyr_ctxt *ps_lyr_ctxt;
5005 dec_svc_seq_params_t *ps_cur_subset_sps;
5006 svc_dec_lyr_struct_t *ps_svc_lyr_dec = (svc_dec_lyr_struct_t *) pv_svc_dec;
5007 dec_struct_t *ps_dec = &ps_svc_lyr_dec->s_dec;
5008 dec_slice_svc_ext_params_t *ps_svc_slice_params = NULL;
5009
5010 void *pv_intra_samp_ctxt = ps_svc_lyr_dec->pv_intra_sample_ctxt;
5011 res_prms_t *ps_curr_lyr_res_prms = &ps_svc_lyr_dec->s_res_prms;
5012 ref_mb_map_t **pps_luma_map_horz = &ps_svc_lyr_dec->ps_intsam_luma_map_horz;
5013 ref_mb_map_t **pps_chroma_map_horz = &ps_svc_lyr_dec->ps_intsam_chroma_map_horz;
5014 ref_mb_map_t **pps_luma_map_vert = &ps_svc_lyr_dec->ps_intsam_luma_map_vert;
5015 ref_mb_map_t **pps_chroma_map_vert = &ps_svc_lyr_dec->ps_intsam_chroma_map_vert;
5016
5017 ps_svc_slice_params = &ps_svc_lyr_dec->s_svc_slice_params;
5018 ps_cur_subset_sps = ps_svc_lyr_dec->ps_cur_subset_sps;
5019
5020 ps_ctxt = (intra_sampling_ctxt_t *) pv_intra_samp_ctxt;
5021
5022 /* if called for base resolution store default values */
5023 if(SVCD_TRUE == ps_svc_lyr_dec->u1_base_res_flag)
5024 {
5025 *pps_luma_map_horz = NULL;
5026 *pps_chroma_map_horz = NULL;
5027 *pps_luma_map_vert = NULL;
5028 *pps_chroma_map_vert = NULL;
5029 ps_ctxt->i4_res_lyr_id = -1;
5030 ps_ctxt->i4_ref_width = ps_dec->u2_pic_wd;
5031 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 ps_ctxt->i4_refarray_stride = REF_ARRAY_WIDTH;
5037 return OK;
5038 }
5039
5040 /* derive the current sps */
5041 /* store the res id appropriately */
5042 ps_ctxt->i4_res_lyr_id = ps_svc_lyr_dec->u1_layer_id - 1;
5043
5044 /* store the resolution params */
5045 ps_ctxt->ps_res_prms = ps_curr_lyr_res_prms;
5046
5047 /* get the current layer ctxt */
5048 ps_lyr_ctxt = &ps_ctxt->as_res_lyrs[ps_svc_lyr_dec->u1_layer_id - 1];
5049
5050 ps_ctxt->i4_res_lyr_id = ps_svc_lyr_dec->u1_layer_id - 1;
5051 /* get the width and heights */
5052 ps_lyr_ctxt->i4_curr_width = ps_dec->u2_pic_wd;
5053 ps_lyr_ctxt->i4_curr_height = ps_dec->u2_pic_ht;
5054 ps_lyr_ctxt->i4_ref_width = ps_ctxt->i4_ref_width;
5055 ps_lyr_ctxt->i4_ref_height = ps_ctxt->i4_ref_height;
5056 ps_lyr_ctxt->i1_constrained_intra_rsmpl_flag =
5057 ps_svc_slice_params->u1_constrained_intra_resampling_flag;
5058
5059 /* store the structure pointer containing projected locations */
5060 *pps_luma_map_horz = ps_lyr_ctxt->s_luma_map_ctxt.ps_x_offset_length;
5061 *pps_chroma_map_horz = ps_lyr_ctxt->s_chroma_map_ctxt.ps_x_offset_length;
5062 *pps_luma_map_vert = ps_lyr_ctxt->s_luma_map_ctxt.ps_y_offset_length;
5063 *pps_chroma_map_vert = ps_lyr_ctxt->s_chroma_map_ctxt.ps_y_offset_length;
5064
5065 /* check for recomputation of mapping required */
5066 if(SVCD_TRUE == ps_curr_lyr_res_prms->u1_remap_req_flag)
5067 {
5068 res_prms_t s_ref_res_prms = {0};
5069 WORD32 i4_chroma_x_phase, i4_chroma_y_phase;
5070 WORD32 i4_ref_chroma_x_phase, i4_ref_chroma_y_phase;
5071 WORD32 i4_x_phase_0, i4_x_phase_1;
5072 WORD32 i4_y_phase_0, i4_y_phase_1;
5073 WORD32 i4_vert_flag;
5074
5075 /* store the reference layer resolution width and height */
5076 s_ref_res_prms.i4_res_width = ps_ctxt->i4_ref_width;
5077 s_ref_res_prms.i4_res_height = ps_ctxt->i4_ref_height;
5078
5079 /* call the frame level projections calculation function */
5080 isvcd_intra_resamp_populate_list(&ps_lyr_ctxt->s_luma_map_ctxt, ps_curr_lyr_res_prms,
5081 &s_ref_res_prms, 0, ps_svc_lyr_dec);
5082
5083 isvcd_intra_resamp_populate_list(&ps_lyr_ctxt->s_chroma_map_ctxt, ps_curr_lyr_res_prms,
5084 &s_ref_res_prms, 1, ps_svc_lyr_dec);
5085
5086 /* Compute the chroma xPhase and yPhase values */
5087 if(1 == ps_curr_lyr_res_prms->u1_dyadic_flag)
5088 {
5089 i4_ref_chroma_x_phase = ps_curr_lyr_res_prms->i1_ref_lyr_chroma_phase_x_plus1_flag;
5090 i4_ref_chroma_y_phase = ps_curr_lyr_res_prms->i1_ref_lyr_chroma_phase_y_plus1;
5091 i4_chroma_x_phase = ps_cur_subset_sps->s_sps_svc_ext.u1_chroma_phase_x_plus1_flag;
5092 i4_chroma_y_phase = ps_cur_subset_sps->s_sps_svc_ext.u1_chroma_phase_y_plus1;
5093
5094 i4_x_phase_0 = i4_chroma_x_phase - (i4_ref_chroma_x_phase << 1);
5095 i4_x_phase_1 = (3 + i4_x_phase_0) & 0x7;
5096 i4_x_phase_0 += 7;
5097 i4_x_phase_0 &= 0x7;
5098 i4_y_phase_0 = i4_chroma_y_phase - (i4_ref_chroma_y_phase << 1);
5099 i4_y_phase_1 = (3 + i4_y_phase_0) & 0x7;
5100 i4_y_phase_0 += 7;
5101 i4_y_phase_0 &= 0x7;
5102
5103 ps_lyr_ctxt->i4_x_phase_0 = i4_x_phase_0;
5104 ps_lyr_ctxt->i4_x_phase_1 = i4_x_phase_1;
5105 ps_lyr_ctxt->i4_y_phase_0 = i4_y_phase_0;
5106 ps_lyr_ctxt->i4_y_phase_1 = i4_y_phase_1;
5107
5108 /* Choose the appropriate chroma interpolation functions */
5109 if((0 == i4_ref_chroma_x_phase) && (1 == i4_chroma_x_phase))
5110 {
5111 ps_lyr_ctxt->pf_horz_chroma_interpol = ps_ctxt->pf_horz_chroma_interpol[1];
5112 }
5113 else
5114 {
5115 ps_lyr_ctxt->pf_horz_chroma_interpol = ps_ctxt->pf_horz_chroma_interpol[0];
5116 }
5117
5118 i4_vert_flag = 0;
5119 if(0 == i4_ref_chroma_y_phase)
5120 {
5121 if((1 == i4_chroma_y_phase) || (2 == i4_chroma_y_phase))
5122 {
5123 i4_vert_flag = 1;
5124 }
5125 }
5126 else if((2 == i4_ref_chroma_y_phase) && (0 == i4_chroma_y_phase))
5127 {
5128 i4_vert_flag = 2;
5129 }
5130
5131 if(1 == i4_vert_flag)
5132 {
5133 ps_lyr_ctxt->pf_vert_chroma_interpol = ps_ctxt->pf_vert_chroma_interpol[1];
5134 }
5135 else if(2 == i4_vert_flag)
5136 {
5137 ps_lyr_ctxt->pf_vert_chroma_interpol = ps_ctxt->pf_vert_chroma_interpol[2];
5138 }
5139 else
5140 {
5141 ps_lyr_ctxt->pf_vert_chroma_interpol = ps_ctxt->pf_vert_chroma_interpol[0];
5142 }
5143 }
5144 }
5145 else
5146 {
5147 /* should take false value */
5148 if(SVCD_FALSE != ps_curr_lyr_res_prms->u1_remap_req_flag)
5149 {
5150 return NOT_OK;
5151 }
5152 }
5153
5154 /* store the current layer width and height to context */
5155 ps_ctxt->i4_ref_width = ps_curr_lyr_res_prms->i4_res_width;
5156 ps_ctxt->i4_ref_height = ps_curr_lyr_res_prms->i4_res_height;
5157
5158 return OK;
5159 }