• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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_ii_pred.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_ii_pred_res_init()
33  *  - isvcd_ii_get_ref_mb_mode()
34  *  - isvcd_ii_get_ref_projections()
35  *  - isvcd_ii_pred_compute_flags_mb()
36  *  - isvcd_ii_pred_mb()
37  *
38  * @remarks
39  *  None
40  *
41  *******************************************************************************
42  */
43 
44 #include <assert.h>
45 #include <string.h>
46 #include "ih264_typedefs.h"
47 #include "ih264_macros.h"
48 #include "ih264_platform_macros.h"
49 #include "ih264_defs.h"
50 #include "ih264d_bitstrm.h"
51 #include "ih264d_defs.h"
52 #include "ih264d_debug.h"
53 #include "isvcd_structs.h"
54 #include "ih264d_parse_cavlc.h"
55 #include "ih264d_mb_utils.h"
56 #include "ih264d_deblocking.h"
57 #include "ih264d_dpb_manager.h"
58 #include "ih264d_mvpred.h"
59 #include "ih264d_inter_pred.h"
60 #include "ih264d_process_pslice.h"
61 #include "ih264d_error_handler.h"
62 #include "ih264d_cabac.h"
63 #include "ih264d_tables.h"
64 #include "ih264d_parse_slice.h"
65 #include "ih264d_utils.h"
66 #include "ih264d_parse_islice.h"
67 #include "ih264d_process_bslice.h"
68 #include "ih264d_process_intra_mb.h"
69 #include "isvcd_mode_mv_resamp.h"
70 #include "isvcd_ii_pred.h"
71 #include "ih264_debug.h"
72 
73 /*****************************************************************************/
74 /*                                                                           */
75 /*  Function Name : isvcd_ii_pred_res_init                                    */
76 /*                                                                           */
77 /*  Description   : this function initialises the resolution level params    */
78 /*                  into the context structure                               */
79 /*                                                                           */
80 /*  Inputs        : pv_ii_pred_ctxt: Intra inter pred  handle                */
81 /*                  pi2_ref_loc_x             : pointer to buffer having the */
82 /*                                              projected locations horz     */
83 /*                  pi2_ref_loc_y             : pointer to buffer having the */
84 /*                                              projected location vertical  */
85 /*  Globals       : none                                                     */
86 /*  Processing    :                                                          */
87 /*                                                                           */
88 /*  Outputs       : none                                                     */
89 /*  Returns       : none                                                     */
90 /*                                                                           */
91 /*  Issues        : none                                                     */
92 /*                                                                           */
93 /*  Revision History:                                                        */
94 /*                                                                           */
95 /*         DD MM YYYY   Author(s)       Changes (Describe the changes made)  */
96 /*         06 09 2021   Vijay                creation                        */
97 /*                                                                           */
98 /*****************************************************************************/
isvcd_ii_pred_res_init(void * pv_svc_dec)99 WORD32 isvcd_ii_pred_res_init(void *pv_svc_dec)
100 {
101     /* local vaiables */
102     intra_inter_pred_ctxt_t *ps_ii_pred_ctxt;
103     mode_motion_ctxt_t *ps_ctxt;
104     mode_motion_lyr_ctxt *ps_lyr_mem;
105     WORD32 i4_base_res_flag;
106     svc_dec_lyr_struct_t *ps_svc_lyr_dec = (svc_dec_lyr_struct_t *) pv_svc_dec;
107 
108     res_prms_t *ps_res_prms = &ps_svc_lyr_dec->s_res_prms;
109     ps_ii_pred_ctxt = (intra_inter_pred_ctxt_t *) ps_svc_lyr_dec->pv_ii_pred_ctxt;
110     ps_ctxt = (mode_motion_ctxt_t *) ps_svc_lyr_dec->pv_mode_mv_sample_ctxt;
111     i4_base_res_flag = ps_svc_lyr_dec->u1_base_res_flag;
112 
113     if((0 != ps_svc_lyr_dec->u1_layer_id) && (SVCD_FALSE == i4_base_res_flag))
114     {
115         /* if not first resolution layer */
116         ps_ii_pred_ctxt->i4_ref_res_lyr_wd = ps_ii_pred_ctxt->i4_cur_res_lyr_wd;
117         ps_ii_pred_ctxt->i4_ref_res_lyr_ht = ps_ii_pred_ctxt->i4_cur_res_lyr_ht;
118     }
119 
120     ps_lyr_mem = &ps_ctxt->as_res_lyr_mem[ps_ctxt->i4_res_id];
121 
122     ps_ii_pred_ctxt->pi2_ref_loc_x = ps_lyr_mem->pi2_ref_loc_x;
123     ps_ii_pred_ctxt->pi2_ref_loc_y = ps_lyr_mem->pi2_ref_loc_y;
124 
125     /* Store the dimensions */
126     ps_ii_pred_ctxt->i4_cur_res_lyr_wd = ps_res_prms->i4_res_width;
127     ps_ii_pred_ctxt->i4_cur_res_lyr_ht = ps_res_prms->i4_res_height;
128 
129     return (OK);
130 }
131 
132 /*****************************************************************************/
133 /*                                                                           */
134 /*  Function Name : isvcd_ii_get_ref_mb_mode                                  */
135 /*                                                                           */
136 /*  Description   : This function is used to find the mb type of the         */
137 /*                  corresponding MB in the reference layer is INTER or      */
138 /*                  INTRA                                                    */
139 /*  Inputs        : pu1_ref_mb_modes : ref mb modes buffer pointer           */
140 /*                  i4_ref_mode_stride : mb mode buffer stride               */
141 /*                  i4_x_ref : reference location X                          */
142 /*                  i4_y_ref : reference location Y                          */
143 /*  Globals       : none                                                     */
144 /*  Processing    : it derives the byte corresponding to reference MB and    */
145 /*                  and gets the mb type                                     */
146 /*  Outputs       : none                                                     */
147 /*  Returns       : SVCD_TRUE if INTRA MB else SVCD_FALSE                    */
148 /*                                                                           */
149 /*  Issues        : none                                                     */
150 /*                                                                           */
151 /*  Revision History:                                                        */
152 /*                                                                           */
153 /*         DD MM YYYY   Author(s)       Changes (Describe the changes made)  */
154 /*         06 09 2021   Vijay                creation                        */
155 /*                                                                           */
156 /*****************************************************************************/
isvcd_ii_get_ref_mb_mode(WORD8 * pi1_ref_mb_modes,WORD32 i4_ref_mode_stride,WORD32 i4_ref_mode_size,WORD32 i4_x_ref,WORD32 i4_y_ref)157 WORD32 isvcd_ii_get_ref_mb_mode(WORD8 *pi1_ref_mb_modes, WORD32 i4_ref_mode_stride,
158                                 WORD32 i4_ref_mode_size, WORD32 i4_x_ref, WORD32 i4_y_ref)
159 {
160     WORD32 i4_mb_x, i4_mb_y;
161     inter_lyr_mb_prms_t *ps_inter_lyr_mb_prms;
162     WORD8 i1_mb_mode;
163 
164     i4_mb_x = (i4_x_ref >> MB_WIDTH_SHIFT);
165     i4_mb_y = (i4_y_ref >> MB_HEIGHT_SHIFT);
166 
167     /* get the location of the byte which has the current mb mode */
168     pi1_ref_mb_modes += (i4_mb_y * i4_ref_mode_stride * i4_ref_mode_size);
169     pi1_ref_mb_modes += (i4_mb_x * i4_ref_mode_size);
170     ps_inter_lyr_mb_prms = (inter_lyr_mb_prms_t *) pi1_ref_mb_modes;
171     i1_mb_mode = ps_inter_lyr_mb_prms->i1_mb_mode;
172 
173     if(i1_mb_mode <= SVC_INTER_MB)
174     {
175         /* INTER */
176         return (SVCD_FALSE);
177     }
178     else
179     {
180         /* INTRA */
181         return (SVCD_TRUE);
182     }
183 }
184 /*****************************************************************************/
185 /*                                                                           */
186 /*  Function Name : isvcd_ii_get_ref_projections                              */
187 /*                                                                           */
188 /*  Description   : this function projects the corners of current MB and     */
189 /*                  finds out if any point is falling into an INTRA MB in    */
190 /*                  reference layer. it also calculates the intersection     */
191 /*                  point of MB boundaries in the projected region           */
192 /*  Inputs        : ps_ctxt : Intra Inter context pointer                    */
193 /*                  ps_ii_mb_ctxt : Curretn MB context pointer               */
194 /*                  ps_ref_mb_mode : reference MB mode buffer descriptor     */
195 /*                  i4_mb_x : MB_X of current MB                             */
196 /*                  i4_mb_y : MB_Y of current MB                             */
197 /*  Globals       : none                                                     */
198 /*  Processing    : it derives the intra status of the corners and calculates*/
199 /*                  the intersection point                                   */
200 /*  Outputs       : non                                                      */
201 /*  Returns       : SVCD_TRUE or SVCD_FALSE                                  */
202 /*                                                                           */
203 /*  Issues        : none                                                     */
204 /*                                                                           */
205 /*  Revision History:                                                        */
206 /*                                                                           */
207 /*         DD MM YYYY   Author(s)       Changes (Describe the changes made)  */
208 /*         06 09 2021   Vijay                creation                        */
209 /*                                                                           */
210 /*****************************************************************************/
isvcd_ii_get_ref_projections(intra_inter_pred_ctxt_t * ps_ctxt,intra_inter_mb_t * ps_ii_mb_ctxt,mem_element_t * ps_ref_mb_mode,WORD32 i4_mb_x,WORD32 i4_mb_y)211 WORD32 isvcd_ii_get_ref_projections(intra_inter_pred_ctxt_t *ps_ctxt,
212                                     intra_inter_mb_t *ps_ii_mb_ctxt, mem_element_t *ps_ref_mb_mode,
213                                     WORD32 i4_mb_x, WORD32 i4_mb_y)
214 {
215     WORD16 *pi2_ref_loc_x;
216     WORD16 *pi2_ref_loc_y;
217     WORD8 *pi1_ref_mb_mode;
218     WORD32 i4_ref_mode_stride;
219     WORD32 i4_element_size;
220     WORD32 i4_ref_x, i4_ref_y;
221     WORD32 i4_frame_x, i4_frame_y;
222     WORD32 i4_flag;
223 
224     pi2_ref_loc_x = ps_ctxt->pi2_ref_loc_x;
225     pi2_ref_loc_y = ps_ctxt->pi2_ref_loc_y;
226 
227     pi1_ref_mb_mode = (WORD8 *) ps_ref_mb_mode->pv_buffer;
228     i4_ref_mode_stride = ps_ref_mb_mode->i4_num_element_stride;
229     i4_element_size = ps_ref_mb_mode->i4_element_size;
230 
231     /* get the current MB frame positions */
232     i4_frame_x = i4_mb_x << 4;
233     i4_frame_y = i4_mb_y << 4;
234 
235     /* reset the flag */
236     i4_flag = SVCD_FALSE;
237 
238     /* project the (0,0) of current MB and get the ref MB mode */
239     i4_ref_x = pi2_ref_loc_x[i4_frame_x];
240     i4_ref_y = pi2_ref_loc_y[i4_frame_y];
241 
242     if((i4_ref_x < ps_ctxt->i4_ref_res_lyr_wd) && (i4_ref_y < ps_ctxt->i4_ref_res_lyr_ht))
243     {
244         ps_ii_mb_ctxt->u1_top_left_intra_flag = isvcd_ii_get_ref_mb_mode(
245             pi1_ref_mb_mode, i4_ref_mode_stride, i4_element_size, i4_ref_x, i4_ref_y);
246     }
247     else
248     {
249         /* If projection is outside the picture boundary */
250         ps_ii_mb_ctxt->u1_top_left_intra_flag = SVCD_FALSE;
251     }
252     /* project the (15,0) of current MB and get the ref MB mode */
253     i4_ref_x = pi2_ref_loc_x[i4_frame_x + 15];
254     i4_ref_y = pi2_ref_loc_y[i4_frame_y];
255 
256     if((i4_ref_x < ps_ctxt->i4_ref_res_lyr_wd) && (i4_ref_y < ps_ctxt->i4_ref_res_lyr_ht))
257     {
258         ps_ii_mb_ctxt->u1_top_rt_intra_flag = isvcd_ii_get_ref_mb_mode(
259             pi1_ref_mb_mode, i4_ref_mode_stride, i4_element_size, i4_ref_x, i4_ref_y);
260     }
261     else
262     {
263         ps_ii_mb_ctxt->u1_top_rt_intra_flag = SVCD_FALSE;
264     }
265 
266     /* project the (0,15) of current MB and get the ref MB mode */
267     i4_ref_x = pi2_ref_loc_x[i4_frame_x];
268     i4_ref_y = pi2_ref_loc_y[i4_frame_y + 15];
269 
270     if((i4_ref_x < ps_ctxt->i4_ref_res_lyr_wd) && (i4_ref_y < ps_ctxt->i4_ref_res_lyr_ht))
271     {
272         ps_ii_mb_ctxt->u1_bot_left_intra_flag = isvcd_ii_get_ref_mb_mode(
273             pi1_ref_mb_mode, i4_ref_mode_stride, i4_element_size, i4_ref_x, i4_ref_y);
274     }
275     else
276     {
277         ps_ii_mb_ctxt->u1_bot_left_intra_flag = SVCD_FALSE;
278     }
279 
280     /* project the (15,15) of current MB and get the ref MB mode */
281     i4_ref_x = pi2_ref_loc_x[i4_frame_x + 15];
282     i4_ref_y = pi2_ref_loc_y[i4_frame_y + 15];
283 
284     if((i4_ref_x < ps_ctxt->i4_ref_res_lyr_wd) && (i4_ref_y < ps_ctxt->i4_ref_res_lyr_ht))
285     {
286         ps_ii_mb_ctxt->u1_bot_rt_intra_flag = isvcd_ii_get_ref_mb_mode(
287             pi1_ref_mb_mode, i4_ref_mode_stride, i4_element_size, i4_ref_x, i4_ref_y);
288     }
289     else
290     {
291         ps_ii_mb_ctxt->u1_bot_rt_intra_flag = SVCD_FALSE;
292     }
293 
294     /* if any of the 4 cormers are falling into intra region
295       set the INTRA INTER Flag */
296     if((SVCD_TRUE == ps_ii_mb_ctxt->u1_top_left_intra_flag) ||
297        (SVCD_TRUE == ps_ii_mb_ctxt->u1_top_rt_intra_flag) ||
298        (SVCD_TRUE == ps_ii_mb_ctxt->u1_bot_left_intra_flag) ||
299        (SVCD_TRUE == ps_ii_mb_ctxt->u1_bot_rt_intra_flag))
300     {
301         i4_flag = SVCD_TRUE;
302     }
303 
304     /* derive the intersection point of MB boundaries */
305     if(SVCD_TRUE == i4_flag)
306     {
307         WORD32 i4_intr_x, i4_intr_y;
308         WORD32 i4_ref_mb_init_x, i4_ref_mb_init_y;
309         WORD32 i4_ctr;
310 
311         /* set the variables to initial values */
312         i4_intr_x = 0;
313         i4_intr_y = 0;
314         i4_ref_mb_init_x = pi2_ref_loc_x[i4_frame_x] >> MB_WIDTH_SHIFT;
315         i4_ref_mb_init_y = pi2_ref_loc_y[i4_frame_y] >> MB_HEIGHT_SHIFT;
316 
317         /* loop until an Mb boundary is found in horizontal direction */
318         for(i4_ctr = 0; i4_ctr < MB_WIDTH; i4_ctr++)
319         {
320             i4_ref_x = pi2_ref_loc_x[i4_frame_x + i4_ctr];
321             i4_ref_x >>= MB_WIDTH_SHIFT;
322 
323             /* check if the locations are falling into same MB */
324             if(i4_ref_x != i4_ref_mb_init_x)
325             {
326                 break;
327             }
328             /* increment the position */
329             i4_intr_x++;
330         }
331 
332         /* loop until an Mb boundary is found in vertical direction */
333         for(i4_ctr = 0; i4_ctr < MB_HEIGHT; i4_ctr++)
334         {
335             i4_ref_y = pi2_ref_loc_y[i4_frame_y + i4_ctr];
336             i4_ref_y >>= MB_HEIGHT_SHIFT;
337 
338             /* check if the locations are falling into same MB */
339             if(i4_ref_y != i4_ref_mb_init_y)
340             {
341                 break;
342             }
343             /* increment the position */
344             i4_intr_y++;
345         }
346         /* store the intersection points */
347         ps_ii_mb_ctxt->u1_intersection_x = i4_intr_x;
348         ps_ii_mb_ctxt->u1_intersection_y = i4_intr_y;
349     }
350     else
351     {
352         /* set to default value */
353         ps_ii_mb_ctxt->u1_intersection_x = 0;
354         ps_ii_mb_ctxt->u1_intersection_y = 0;
355     }
356 
357     return (i4_flag);
358 }
359 /*****************************************************************************/
360 /*                                                                           */
361 /*  Function Name : isvcd_ii_pred_compute_flags_mb                            */
362 /*                                                                           */
363 /*  Description   : this function checks all the criteria for an MB to       */
364 /*                  under go Inter-Intra prediction  and stores the MB mode  */
365 /*                   as INTER_INTRA for appropriate MBs                      */
366 /*  Inputs        : refer to comments below                                  */
367 /*  Globals       : none                                                     */
368 /*  Processing    : it checks the criteria for anMB to undergo Inter-Intra   */
369 /*                  pred process and updates the MB mode                     */
370 /*  Outputs       : MB mode set for each MB with INTRA-INTER status          */
371 /*  Returns       : SVCD_EOK or SVCD_EFAIL                                   */
372 /*                                                                           */
373 /*  Issues        : none                                                     */
374 /*                                                                           */
375 /*  Revision History:                                                        */
376 /*                                                                           */
377 /*         DD MM YYYY   Author(s)       Changes (Describe the changes made)  */
378 /*         06 09 2021   Vijay                creation                        */
379 /*                                                                           */
380 /*****************************************************************************/
isvcd_ii_pred_compute_flags_mb(void * pv_ii_pred_ctxt,mem_element_t * ps_ref_mb_mode,mb_coord_t * ps_coord,void * pv_mb_prms,void * pv_svc_mb_prms,UWORD8 * pu1_ii_mb_mode)381 WORD32 isvcd_ii_pred_compute_flags_mb(void *pv_ii_pred_ctxt, mem_element_t *ps_ref_mb_mode,
382                                       mb_coord_t *ps_coord, void *pv_mb_prms, void *pv_svc_mb_prms,
383                                       UWORD8 *pu1_ii_mb_mode)
384 {
385     intra_inter_pred_ctxt_t *ps_ctxt;
386     WORD32 i4_mb_x, i4_mb_y;
387     dec_svc_mb_info_t *ps_svc_mb_prms;
388     UNUSED(pv_mb_prms);
389 
390     if((NULL == pv_ii_pred_ctxt) || (NULL == ps_ref_mb_mode) || (NULL == ps_coord) ||
391        (NULL == pu1_ii_mb_mode))
392     {
393         return NOT_OK;
394     }
395 
396     ps_ctxt = (intra_inter_pred_ctxt_t *) pv_ii_pred_ctxt;
397     ps_svc_mb_prms = (dec_svc_mb_info_t *) pv_svc_mb_prms;
398 
399     /* get mb co-ordinates */
400     i4_mb_x = ps_coord->u2_mb_x;
401     i4_mb_y = ps_coord->u2_mb_y;
402 
403     {
404         intra_inter_mb_t *ps_ii_mb_ctxt;
405         WORD32 i4_ii_flag;
406 
407         /* get the current MB strcuture pointer */
408         ps_ii_mb_ctxt = &ps_ctxt->s_intra_inter_mb_prms;
409 
410         /* reset the Intra Inter qualified flag for current MB */
411         i4_ii_flag = SVCD_FALSE;
412 
413         /* check for base mode flag and Inter MB status */
414         if(1 == ps_svc_mb_prms->u1_base_mode_flag)
415         {
416             /* call the function which calculates the projections
417                and returns whether current MB has to under go
418                Inter Intra Prediction */
419             i4_ii_flag = isvcd_ii_get_ref_projections(ps_ctxt, ps_ii_mb_ctxt, ps_ref_mb_mode,
420                                                       i4_mb_x, i4_mb_y);
421         }
422 
423         /* If the current MB requires Intra Inter prediction */
424         if(SVCD_TRUE == i4_ii_flag)
425         {
426             /* set the mb mode */
427             *pu1_ii_mb_mode = SVC_INTRA_INTER_MB;
428         }
429         else
430         {
431             /* set all MB params to default values */
432             ps_ii_mb_ctxt->u1_bot_left_intra_flag = SVCD_FALSE;
433             ps_ii_mb_ctxt->u1_bot_rt_intra_flag = SVCD_FALSE;
434             ps_ii_mb_ctxt->u1_top_left_intra_flag = SVCD_FALSE;
435             ps_ii_mb_ctxt->u1_top_rt_intra_flag = SVCD_FALSE;
436             ps_ii_mb_ctxt->u1_intersection_x = 0;
437             ps_ii_mb_ctxt->u1_intersection_y = 0;
438 
439             /* set the mb mode to 0 (which has no interpretation) */
440             *pu1_ii_mb_mode = 0;
441         }
442     }
443     return (OK);
444 }
445 
446 /*****************************************************************************/
447 /*                                                                           */
448 /*  Function Name : isvcd_ii_pred_mb                                          */
449 /*                                                                           */
450 /*  Description   : This function performs the Intra-Inter Preduction of the */
451 /*                  given MB                                                 */
452 /*                                                                           */
453 /*  Inputs        : ps_mb_ctxt : Intra Inter mb context strcuture            */
454 /*                  ps_mb_buf : current MB buffers strcuture pointer         */
455 /*  Globals       : none                                                     */
456 /*  Processing    : it processes all partitions based on the Intra flag      */
457 /*                                                                           */
458 /*  Outputs       : Intra Inter Predecited and reconstructed MB              */
459 /*  Returns       : none                                                     */
460 /*                                                                           */
461 /*  Issues        : none                                                     */
462 /*                                                                           */
463 /*  Revision History:                                                        */
464 /*                                                                           */
465 /*         DD MM YYYY   Author(s)       Changes (Describe the changes made)  */
466 /*         06 09 2021   Vijay                creation                        */
467 /*                                                                           */
468 /*****************************************************************************/
isvcd_ii_pred_mb(void * pv_svc_dec,dec_mb_info_t * ps_cur_mb_info)469 void isvcd_ii_pred_mb(void *pv_svc_dec, dec_mb_info_t *ps_cur_mb_info)
470 {
471     intra_inter_mb_t *ps_mb_ctxt;
472     UWORD8 *pu1_rec_y, *pu1_rec_uv;
473     UWORD8 *pu1_recon_luma;
474     WORD32 i4_recon_luma_stride;
475     UWORD8 *pu1_recon_chroma;
476     WORD32 i4_recon_chroma_stride;
477     UWORD8 *pu1_pred_luma;
478     UWORD8 *pu1_pred_chroma;
479     WORD32 i4_pred_luma_stride;
480     WORD32 i4_pred_chroma_stride;
481     WORD32 i4_intr_x, i4_intr_y;
482     intra_inter_pred_ctxt_t *ps_ctxt;
483     pic_buffer_t *ps_frame_buf;
484     svc_dec_lyr_struct_t *ps_svc_lyr_dec = (svc_dec_lyr_struct_t *) pv_svc_dec;
485     dec_struct_t *ps_dec = &ps_svc_lyr_dec->s_dec;
486 
487     ps_ctxt = (intra_inter_pred_ctxt_t *) ps_svc_lyr_dec->pv_ii_pred_ctxt;
488     ps_mb_ctxt = &ps_ctxt->s_intra_inter_mb_prms;
489     ps_frame_buf = ps_dec->ps_cur_pic;
490     i4_recon_luma_stride = ps_dec->u2_frm_wd_y;
491     i4_recon_chroma_stride = ps_dec->u2_frm_wd_uv;
492 
493     /* derive the intersection point */
494     i4_intr_x = ps_mb_ctxt->u1_intersection_x;
495     i4_intr_y = ps_mb_ctxt->u1_intersection_y;
496 
497     pu1_rec_y = ps_frame_buf->pu1_buf1 + (ps_cur_mb_info->u2_mbx << 4) +
498                 (i4_recon_luma_stride * (ps_cur_mb_info->u2_mby << 4));
499 
500     pu1_rec_uv = ps_frame_buf->pu1_buf2 + (ps_cur_mb_info->u2_mbx << 3) * YUV420SP_FACTOR +
501                  (i4_recon_chroma_stride * (ps_cur_mb_info->u2_mby << 3));
502 
503     pu1_pred_luma = ps_svc_lyr_dec->pu1_ii_resamp_buffer_luma;
504     pu1_pred_chroma = ps_svc_lyr_dec->pu1_ii_resamp_buffer_chroma;
505     i4_pred_luma_stride = MB_SIZE;
506     i4_pred_chroma_stride = MB_SIZE;
507 
508     /* get the recon and residual buffer pointer */
509     pu1_recon_luma = pu1_rec_y;
510     pu1_recon_chroma = pu1_rec_uv;
511 
512     /*-----------------------------------------------------------------------*/
513     /* Reconstruct TOP_LEFT Partition                                        */
514     /*-----------------------------------------------------------------------*/
515     {
516         WORD32 i4_width, i4_height;
517 
518         /* assign the appropriate buffer params based on Intra status */
519         if(SVCD_TRUE == ps_mb_ctxt->u1_top_left_intra_flag)
520         {
521             /* Luma Processing */
522             isvcd_copy_data(pu1_pred_luma, i4_pred_luma_stride, pu1_recon_luma,
523                             i4_recon_luma_stride, i4_intr_x, i4_intr_y);
524 
525             /* assign appropriate width and height for chroma */
526             i4_width = (((i4_intr_x + 1) >> 1) << 1);
527             i4_height = ((i4_intr_y + 1) & ~1);
528             i4_height >>= 1;
529             /* Chroma Processing (cb and cr interleaved) */
530             isvcd_copy_data(pu1_pred_chroma, i4_pred_chroma_stride, pu1_recon_chroma,
531                             i4_recon_chroma_stride, i4_width, i4_height);
532         }
533     }
534 
535     /*-----------------------------------------------------------------------*/
536     /* Reconstruct TOP_RIGHT Partition                                       */
537     /*-----------------------------------------------------------------------*/
538     {
539         WORD32 i4_width, i4_height;
540 
541         /* assign the appropriate buffer params based on Intra status */
542         if(SVCD_TRUE == ps_mb_ctxt->u1_top_rt_intra_flag)
543         {
544             pu1_pred_luma += i4_intr_x;
545             pu1_pred_chroma += (((i4_intr_x + 1) >> 1) << 1);
546 
547             /* ----------------------- Luma ------------------------ */
548             /* get the recon and residual buffer pointer */
549             pu1_recon_luma = pu1_rec_y + i4_intr_x;
550 
551             /* assign appropriate width and height for luma */
552             i4_width = MB_WIDTH - i4_intr_x;
553             i4_height = i4_intr_y;
554 
555             /* Luma Processing */
556             /* Luma Processing */
557             isvcd_copy_data(pu1_pred_luma, i4_pred_luma_stride, pu1_recon_luma,
558                             i4_recon_luma_stride, i4_width, i4_height);
559 
560             /* ----------------------- Chroma ----------------------- */
561             /* assign appropriate width and height for luma */
562             i4_width = (BLOCK_WIDTH - ((i4_intr_x + 1) >> 1)) << 1;
563 
564             /* Height includes for both Cb & Cr */
565             i4_height = ((i4_intr_y + 1) & ~1);
566             i4_height >>= 1;
567             /* get the recon and residual buffer pointer */
568             pu1_recon_chroma = pu1_rec_uv;
569             {
570                 WORD32 i4_temp;
571                 i4_temp = (((i4_intr_x + 1) >> 1) << 1);
572                 pu1_recon_chroma += i4_temp;
573             }
574 
575             /* Chroma Processing (cb and cr  interleaved) */
576             isvcd_copy_data(pu1_pred_chroma, i4_pred_chroma_stride, pu1_recon_chroma,
577                             i4_recon_chroma_stride, i4_width, i4_height);
578         }
579     }
580 
581     /*-----------------------------------------------------------------------*/
582     /* Reconstruct BOTTOM_LEFT Partition                                     */
583     /*-----------------------------------------------------------------------*/
584     {
585         WORD32 i4_width, i4_height;
586 
587         /* assign the appropriate buffer params based on Intra status */
588         if(SVCD_TRUE == ps_mb_ctxt->u1_bot_left_intra_flag)
589         {
590             pu1_pred_luma = ps_svc_lyr_dec->pu1_ii_resamp_buffer_luma;
591             pu1_pred_chroma = ps_svc_lyr_dec->pu1_ii_resamp_buffer_chroma;
592 
593             /* increment to current vertical offset */
594             pu1_pred_luma += i4_intr_y * i4_pred_luma_stride;
595             pu1_pred_chroma += (((i4_intr_y + 1) & ~1) >> 1) * i4_pred_chroma_stride;
596 
597             /* ----------------------- Luma ----------------------- */
598             /* get the recon and residual buffer pointer */
599             pu1_recon_luma = pu1_rec_y;
600             pu1_recon_luma += i4_intr_y * i4_recon_luma_stride;
601 
602             /* assign appropriate width and height */
603             i4_width = i4_intr_x;
604             i4_height = MB_HEIGHT - i4_intr_y;
605 
606             /* Luma Processing */
607             isvcd_copy_data(pu1_pred_luma, i4_pred_luma_stride, pu1_recon_luma,
608                             i4_recon_luma_stride, i4_width, i4_height);
609 
610             /* ----------------------- Chroma ----------------------- */
611             pu1_recon_chroma = pu1_rec_uv;
612             {
613                 WORD32 i4_temp;
614                 i4_temp = ((i4_intr_y + 1) & ~1) >> 1;
615                 pu1_recon_chroma += (i4_temp * i4_recon_chroma_stride);
616             }
617             /* assign appropriate width and height */
618             i4_width = ((i4_intr_x + 1) >> 1) << 1;
619             i4_height = MB_HEIGHT - (i4_intr_y & ~1);
620             i4_height >>= 1;
621             /* Chroma Processing (cb and cr interleaved) */
622             isvcd_copy_data(pu1_pred_chroma, i4_pred_chroma_stride, pu1_recon_chroma,
623                             i4_recon_chroma_stride, i4_width, i4_height);
624         }
625     }
626 
627     /*-----------------------------------------------------------------------*/
628     /* Reconstruct BOTTOM_RIGHT Partition                                    */
629     /*-----------------------------------------------------------------------*/
630     {
631         WORD32 i4_width, i4_height;
632 
633         /* assign the appropriate buffer params based on Intra status */
634         if(SVCD_TRUE == ps_mb_ctxt->u1_bot_rt_intra_flag)
635         {
636             pu1_pred_luma = ps_svc_lyr_dec->pu1_ii_resamp_buffer_luma;
637             pu1_pred_chroma = ps_svc_lyr_dec->pu1_ii_resamp_buffer_chroma;
638 
639             /* increment to current vertical offset */
640             pu1_pred_luma += i4_intr_x;
641             pu1_pred_luma += i4_intr_y * i4_pred_luma_stride;
642             pu1_pred_chroma += (((i4_intr_y + 1) & ~1) >> 1) * i4_pred_chroma_stride;
643             pu1_pred_chroma += ((i4_intr_x + 1) >> 1) << 1;
644 
645             /* ----------------------- Luma ----------------------- */
646             /* get the recon and residual buffer pointer horz */
647             pu1_recon_luma = pu1_rec_y + i4_intr_x;
648 
649             /* get the recon and residual buffer pointer vertical */
650             pu1_recon_luma += (i4_intr_y * i4_recon_luma_stride);
651 
652             /* assign appropriate width and height */
653             i4_width = MB_WIDTH - i4_intr_x;
654             i4_height = MB_HEIGHT - i4_intr_y;
655 
656             /* Luma Processing */
657             isvcd_copy_data(pu1_pred_luma, i4_pred_luma_stride, pu1_recon_luma,
658                             i4_recon_luma_stride, i4_width, i4_height);
659 
660             /* ----------------------- Chroma ----------------------- */
661             /* get the recon and residual buffer pointer horz */
662             pu1_recon_chroma = pu1_rec_uv;
663             {
664                 WORD32 i4_temp;
665                 i4_temp = ((i4_intr_y + 1) & ~1) >> 1;
666                 i4_temp *= i4_recon_chroma_stride;
667                 i4_temp += (((i4_intr_x + 1) >> 1) << 1);
668                 pu1_recon_chroma += i4_temp;
669             }
670 
671             /* assign appropriate width and height */
672             i4_width = (BLOCK_WIDTH - ((i4_intr_x + 1) >> 1)) << 1;
673             i4_height = MB_HEIGHT - (i4_intr_y & ~1);
674             i4_height >>= 1;
675             /* Chroma Processing (cb and cr interleaved) */
676             isvcd_copy_data(pu1_pred_chroma, i4_pred_chroma_stride, pu1_recon_chroma,
677                             i4_recon_chroma_stride, i4_width, i4_height);
678         }
679     }
680     return;
681 }