Coverage Report

Created: 2025-07-09 06:41

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