Coverage Report

Created: 2026-10-17 07:28

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/libavc/decoder/svc/isvcd_process_epslice.c
Line
Count
Source
1
/******************************************************************************
2
 *
3
 * Copyright (C) 2022 The Android Open Source Project
4
 *
5
 * Licensed under the Apache License, Version 2.0 (the "License");
6
 * you may not use this file except in compliance with the License.
7
 * You may obtain a copy of the License at:
8
 *
9
 * http://www.apache.org/licenses/LICENSE-2.0
10
 *
11
 * Unless required by applicable law or agreed to in writing, software
12
 * distributed under the License is distributed on an "AS IS" BASIS,
13
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
 * See the License for the specific language governing permissions and
15
 * limitations under the License.
16
 *
17
 *****************************************************************************
18
 * Originally developed and contributed by Ittiam Systems Pvt. Ltd, Bangalore
19
 */
20
/**
21
 *******************************************************************************
22
 * @file
23
 *  isvcd_process_epslice.c
24
 *
25
 * @brief
26
 *  Contains routines that decode a I slice type
27
 *
28
 * @author
29
 *  Kishore
30
 *
31
 * @remarks
32
 *  None
33
 *
34
 *******************************************************************************
35
 */
36
37
#include <assert.h>
38
#include <string.h>
39
40
#include "ih264_typedefs.h"
41
#include "ih264_macros.h"
42
#include "ih264_platform_macros.h"
43
#include "ih264d_bitstrm.h"
44
#include "ih264d_defs.h"
45
#include "ih264d_debug.h"
46
#include "isvcd_structs.h"
47
#include "ih264d_defs.h"
48
#include "ih264d_parse_cavlc.h"
49
#include "ih264d_mb_utils.h"
50
#include "ih264d_deblocking.h"
51
#include "ih264d_dpb_manager.h"
52
#include "ih264d_mvpred.h"
53
#include "ih264d_inter_pred.h"
54
#include "ih264d_process_pslice.h"
55
#include "isvcd_process_epslice.h"
56
#include "ih264d_error_handler.h"
57
#include "ih264d_cabac.h"
58
#include "ih264d_debug.h"
59
#include "ih264d_tables.h"
60
#include "ih264d_parse_slice.h"
61
#include "ih264d_utils.h"
62
#include "ih264d_parse_islice.h"
63
#include "ih264d_process_bslice.h"
64
#include "ih264d_process_intra_mb.h"
65
#include "isvcd_mode_mv_resamp.h"
66
#include "ih264_debug.h"
67
68
/*!
69
 **************************************************************************
70
 * \if Function name : isvcd_retrive_infer_mode_mv \endif
71
 *
72
 * \brief
73
 *
74
 * \return
75
 *    0 on Success and Error code otherwise
76
 **************************************************************************
77
 */
78
void isvcd_retrive_infer_mode_mv(svc_dec_lyr_struct_t *ps_svc_lyr_dec, mv_pred_t *ps_mvpred,
79
                                 UWORD8 u1_lx, UWORD8 u1_sub_mb_num)
80
14.7k
{
81
14.7k
    mode_motion_ctxt_t *ps_ctxt;
82
14.7k
    mv_pred_t *ps_motion_pred;
83
14.7k
    UWORD8 u1_tmp_lx = (u1_lx << 1);
84
85
14.7k
    ps_ctxt = (mode_motion_ctxt_t *) ps_svc_lyr_dec->pv_mode_mv_sample_ctxt;
86
14.7k
    ps_motion_pred = ps_ctxt->ps_motion_pred_struct;
87
14.7k
    ps_motion_pred += u1_sub_mb_num;
88
14.7k
    ps_mvpred->i2_mv[u1_tmp_lx] = ps_motion_pred->i2_mv[u1_tmp_lx];
89
14.7k
    ps_mvpred->i2_mv[u1_tmp_lx + 1] = ps_motion_pred->i2_mv[u1_tmp_lx + 1];
90
91
14.7k
    return;
92
14.7k
}
93
/*!
94
 **************************************************************************
95
 * \if Function name : isvcd_interlyr_motion_mode_pred \endif
96
 *
97
 * \brief
98
 *
99
 *
100
 * \return
101
 *    0 on Success and Error code otherwise
102
 **************************************************************************
103
 */
104
WORD32 isvcd_interlyr_motion_mode_pred(svc_dec_lyr_struct_t *ps_svc_lyr_dec,
105
                                       dec_mb_info_t *ps_cur_mb_info,
106
                                       dec_svc_mb_info_t *ps_svc_cur_mb_info,
107
                                       parse_pmbarams_t *ps_mb_part_info,
108
                                       parse_part_params_t *ps_part)
109
367k
{
110
367k
    dec_struct_t *ps_dec = &ps_svc_lyr_dec->s_dec;
111
367k
    WORD32 i4_inter_layer_pred_req_flag;
112
367k
    WORD32 i4_listx;
113
367k
    WORD32 i4_mb_mode = -1;
114
367k
    i4_inter_layer_pred_req_flag = SVCD_FALSE;
115
367k
    i4_listx = (ps_dec->ps_cur_slice->u1_slice_type == B_SLICE) ? 2 : 1;
116
    /* check Base mode flag and motion predcition flags */
117
367k
    if(1 == ps_svc_cur_mb_info->u1_base_mode_flag)
118
4.17k
    {
119
4.17k
        i4_inter_layer_pred_req_flag = SVCD_TRUE;
120
4.17k
    }
121
363k
    else
122
363k
    {
123
363k
        UWORD8 u1_mot_pred_flag;
124
125
        /* get the packed the motion pred flag of list 0 */
126
363k
        u1_mot_pred_flag = ps_svc_cur_mb_info->au1_motion_pred_flag[0];
127
128
        /* extract the last 4 bits */
129
363k
        u1_mot_pred_flag &= 0x0F;
130
131
363k
        if(0 != u1_mot_pred_flag)
132
1.71k
        {
133
1.71k
            i4_inter_layer_pred_req_flag = SVCD_TRUE;
134
1.71k
        }
135
136
        /* check for list 1 flags if required */
137
363k
        if((2 == i4_listx) && (SVCD_FALSE == i4_inter_layer_pred_req_flag))
138
563
        {
139
            /* get the packed the motion pred flag of list 1 */
140
563
            u1_mot_pred_flag = ps_svc_cur_mb_info->au1_motion_pred_flag[1];
141
142
            /* extract the last 4 bits */
143
563
            u1_mot_pred_flag &= 0x0F;
144
145
563
            if(0 != u1_mot_pred_flag)
146
0
            {
147
0
                i4_inter_layer_pred_req_flag = SVCD_TRUE;
148
0
            }
149
563
        }
150
363k
    }
151
152
367k
    if(SVCD_TRUE == i4_inter_layer_pred_req_flag)
153
5.89k
    {
154
5.89k
        mode_motion_ctxt_t *ps_ctxt;
155
5.89k
        mode_motion_lyr_ctxt *ps_lyr_mem;
156
157
5.89k
        ps_ctxt = (mode_motion_ctxt_t *) ps_svc_lyr_dec->pv_mode_mv_sample_ctxt;
158
        /* get the current layer ctxt */
159
5.89k
        ps_lyr_mem = &ps_ctxt->as_res_lyr_mem[ps_ctxt->i4_res_id];
160
161
5.89k
        {
162
5.89k
            ps_ctxt->i4_listx = i4_listx;
163
164
5.89k
            i4_mb_mode =
165
5.89k
                ps_lyr_mem->pf_inter_lyr_pred(ps_svc_lyr_dec->pv_mode_mv_sample_ctxt, ps_cur_mb_info,
166
5.89k
                                          ps_svc_cur_mb_info, ps_dec, ps_mb_part_info, ps_part);
167
5.89k
        }
168
5.89k
    }
169
367k
    return i4_mb_mode;
170
367k
}
171
/*!
172
 **************************************************************************
173
 * \if Function name : isvcd_mv_pred_ref_tfr_nby2_epmb \endif
174
 *
175
 * \brief
176
 *
177
 * \return
178
 *    0 on Success and Error code otherwise
179
 **************************************************************************
180
 */
181
WORD32 isvcd_mv_pred_ref_tfr_nby2_epmb(dec_struct_t *ps_dec, UWORD32 u4_mb_idx, UWORD32 u4_num_mbs)
182
52.4k
{
183
52.4k
    svc_dec_lyr_struct_t *ps_svc_lyr_dec = (svc_dec_lyr_struct_t *) ps_dec;
184
52.4k
    parse_pmbarams_t *ps_mb_part_info;
185
52.4k
    parse_part_params_t *ps_part;
186
52.4k
    mv_pred_t *ps_mv_nmb, *ps_mv_nmb_start, *ps_mv_ntop, *ps_mv_ntop_start;
187
52.4k
    UWORD32 i, j;
188
52.4k
    const UWORD32 u1_mbaff = ps_dec->ps_cur_slice->u1_mbaff_frame_flag;
189
52.4k
    dec_mb_info_t *ps_cur_mb_info;
190
52.4k
    dec_svc_mb_info_t *ps_svc_cur_mb_info;
191
52.4k
    WORD32 i2_mv_x, i2_mv_y;
192
193
52.4k
    ps_dec->i4_submb_ofst -= (u4_num_mbs - u4_mb_idx) << 4;
194
52.4k
    ps_mb_part_info = ps_dec->ps_parse_mb_data;
195
52.4k
    ps_part = ps_dec->ps_parse_part_params;
196
197
    /* N/2 Mb MvPred and Transfer Setup Loop */
198
419k
    for(i = u4_mb_idx; i < u4_num_mbs; i++, ps_mb_part_info++)
199
367k
    {
200
367k
        UWORD32 u1_colz;
201
367k
        UWORD32 u1_field;
202
367k
        mv_pred_t s_mvPred = {0};
203
367k
        mv_pred_t *ps_mv_pred = &s_mvPred;
204
205
367k
        *ps_mv_pred = ps_dec->s_default_mv_pred;
206
207
367k
        ps_dec->i4_submb_ofst += SUB_BLK_SIZE;
208
209
        /* Restore the slice scratch MbX and MbY context */
210
367k
        ps_cur_mb_info = ps_dec->ps_nmb_info + i;
211
367k
        ps_svc_cur_mb_info = ps_svc_lyr_dec->ps_svc_nmb_info + i;
212
367k
        u1_field = ps_cur_mb_info->u1_mb_field_decodingflag;
213
214
367k
        ps_mv_nmb_start = ps_dec->ps_mv_cur + (i << 4);
215
367k
        ps_dec->u2_mbx = ps_cur_mb_info->u2_mbx;
216
367k
        ps_dec->u2_mby = ps_cur_mb_info->u2_mby;
217
367k
        ps_dec->u2_mv_2mb[i & 0x1] = 0;
218
219
        /* Look for MV Prediction and Reference Transfer in Non-I Mbs */
220
367k
        if(!ps_mb_part_info->u4_isI_mb)
221
366k
        {
222
366k
            UWORD32 u1_blk_no;
223
366k
            WORD32 i1_ref_idx, i1_ref_idx1;
224
366k
            UWORD32 u1_sub_mb_x, u1_sub_mb_y, u1_sub_mb_num;
225
366k
            UWORD32 u1_num_part, u1_num_ref, u1_wd, u1_ht;
226
366k
            UWORD32 *pu4_wt_offst, **ppu4_wt_ofst;
227
366k
            UWORD32 u1_scale_ref, u4_bot_mb;
228
366k
            WORD8 *pi1_ref_idx = ps_mb_part_info->i1_ref_idx[0];
229
366k
            pic_buffer_t *ps_ref_frame, **pps_ref_frame;
230
366k
            deblk_mb_t *ps_cur_deblk_mb = ps_dec->ps_deblk_mbn + i;
231
366k
            WORD32 i4_mb_mode_svc;
232
366k
            UWORD8 u1_motion_pred_flag_l0 = ps_svc_cur_mb_info->au1_motion_pred_flag[0];
233
234
            /* MB Level initialisations */
235
366k
            ps_dec->u4_num_pmbair = i >> u1_mbaff;
236
366k
            ps_dec->u4_mb_idx_mv = i;
237
366k
            ppu4_wt_ofst = ps_mb_part_info->pu4_wt_offst;
238
366k
            pps_ref_frame = ps_dec->ps_ref_pic_buf_lx[0];
239
240
366k
            i4_mb_mode_svc = isvcd_interlyr_motion_mode_pred(
241
366k
                ps_svc_lyr_dec, ps_cur_mb_info, ps_svc_cur_mb_info, ps_mb_part_info, ps_part);
242
243
366k
            if((-1 == i4_mb_mode_svc) || (SVC_INTER_MB == i4_mb_mode_svc))
244
366k
            {
245
366k
                ps_mv_ntop_start =
246
366k
                    ps_mv_nmb_start - (ps_dec->u2_frm_wd_in_mbs << (4 + u1_mbaff)) + 12;
247
248
366k
                u1_num_part = ps_mb_part_info->u1_num_part;
249
366k
                ps_cur_deblk_mb->u1_mb_type |= (u1_num_part > 1) << 1;
250
366k
                ps_cur_mb_info->u4_pred_info_pkd_idx = ps_dec->u4_pred_info_pkd_idx;
251
366k
                ps_cur_mb_info->u1_num_pred_parts = 0;
252
253
                /****************************************************/
254
                /* weighted u4_ofst pointer calculations, this loop  */
255
                /* runs maximum 4 times, even in direct cases       */
256
                /****************************************************/
257
366k
                u1_scale_ref = u1_mbaff & u1_field;
258
259
366k
                u4_bot_mb = 1 - ps_cur_mb_info->u1_topmb;
260
366k
                if(ps_dec->ps_cur_pps->u1_wted_pred_flag)
261
267k
                {
262
267k
                    u1_num_ref = MIN(u1_num_part, 4);
263
543k
                    for(u1_blk_no = 0; u1_blk_no < u1_num_ref; u1_blk_no++)
264
275k
                    {
265
275k
                        i1_ref_idx = pi1_ref_idx[u1_blk_no];
266
275k
                        if(u1_scale_ref) i1_ref_idx >>= 1;
267
275k
                        pu4_wt_offst = (UWORD32 *) &ps_dec->pu4_wt_ofsts[2 * X3(i1_ref_idx)];
268
275k
                        ppu4_wt_ofst[u1_blk_no] = pu4_wt_offst;
269
275k
                    }
270
267k
                }
271
98.7k
                else
272
98.7k
                {
273
98.7k
                    ppu4_wt_ofst[0] = NULL;
274
98.7k
                    ppu4_wt_ofst[1] = NULL;
275
98.7k
                    ppu4_wt_ofst[2] = NULL;
276
98.7k
                    ppu4_wt_ofst[3] = NULL;
277
98.7k
                }
278
279
                /**************************************************/
280
                /* Loop on Partitions                             */
281
                /**************************************************/
282
753k
                for(j = 0; j < u1_num_part; j++, ps_part++)
283
386k
                {
284
386k
                    u1_sub_mb_num = ps_part->u1_sub_mb_num;
285
386k
                    ps_dec->u1_sub_mb_num = u1_sub_mb_num;
286
287
386k
                    if(PART_NOT_DIRECT != ps_part->u1_is_direct)
288
347k
                    {
289
                        /* Mb Skip Mode */
290
                        /* Setting the default and other members of MvPred Structure */
291
347k
                        s_mvPred.i2_mv[2] = -1;
292
347k
                        s_mvPred.i2_mv[3] = -1;
293
347k
                        s_mvPred.i1_ref_frame[0] = 0;
294
347k
                        i1_ref_idx = (u1_scale_ref && u4_bot_mb) ? MAX_REF_BUFS : 0;
295
347k
                        ps_ref_frame = pps_ref_frame[i1_ref_idx];
296
347k
                        s_mvPred.u1_col_ref_pic_idx = ps_ref_frame->u1_mv_buf_id;
297
347k
                        s_mvPred.u1_pic_type = ps_ref_frame->u1_pic_type;
298
347k
                        pu4_wt_offst = (UWORD32 *) &ps_dec->pu4_wt_ofsts[0];
299
300
347k
                        ps_dec->pf_mvpred(ps_dec, ps_cur_mb_info, ps_mv_nmb_start, ps_mv_ntop_start,
301
347k
                                          &s_mvPred, 0, 4, 0, 1, MB_SKIP);
302
303
347k
                        {
304
347k
                            pred_info_pkd_t *ps_pred_pkd;
305
347k
                            ps_pred_pkd = ps_dec->ps_pred_pkd + ps_dec->u4_pred_info_pkd_idx;
306
347k
                            ih264d_fill_pred_info(s_mvPred.i2_mv, 4, 4, 0, PRED_L0, ps_pred_pkd,
307
347k
                                                  ps_ref_frame->u1_pic_buf_id,
308
347k
                                                  (i1_ref_idx >> u1_scale_ref), pu4_wt_offst,
309
347k
                                                  ps_ref_frame->u1_pic_type);
310
311
347k
                            ps_dec->u4_pred_info_pkd_idx++;
312
347k
                            ps_cur_mb_info->u1_num_pred_parts++;
313
347k
                        }
314
315
                        /* Storing colocated zero information */
316
347k
                        u1_colz = ((ABS(s_mvPred.i2_mv[0]) <= 1) && (ABS(s_mvPred.i2_mv[1]) <= 1)) +
317
347k
                                  (u1_field << 1);
318
319
347k
                        if(ps_mv_nmb_start)
320
347k
                        {
321
347k
                            ih264d_rep_mv_colz(ps_dec, &s_mvPred, ps_mv_nmb_start, 0, u1_colz, 4,
322
347k
                                               4);
323
347k
                        }
324
0
                        else
325
0
                        {
326
0
                            return NOT_OK;
327
0
                        }
328
347k
                    }
329
39.4k
                    else
330
39.4k
                    {
331
39.4k
                        u1_sub_mb_x = u1_sub_mb_num & 0x03;
332
39.4k
                        u1_sub_mb_y = u1_sub_mb_num >> 2;
333
39.4k
                        u1_blk_no = (u1_num_part < 4)
334
39.4k
                                        ? j
335
39.4k
                                        : (((u1_sub_mb_y >> 1) << 1) + (u1_sub_mb_x >> 1));
336
337
39.4k
                        ps_mv_ntop = ps_mv_ntop_start + u1_sub_mb_x;
338
39.4k
                        ps_mv_nmb = ps_mv_nmb_start + u1_sub_mb_num;
339
340
39.4k
                        u1_wd = ps_part->u1_partwidth;
341
39.4k
                        u1_ht = ps_part->u1_partheight;
342
343
                        /* Populate the colpic info and reference frames */
344
39.4k
                        i1_ref_idx = pi1_ref_idx[u1_blk_no];
345
                        /********************************************************************/
346
                        /* If reference index is inferred from the base layer and it is     */
347
                        /* exceeding the number of active reference in the current layer.   */
348
                        /* Then reference index is clipped to the max in the current layer  */
349
                        /********************************************************************/
350
39.4k
                        if(ps_svc_cur_mb_info->u1_base_mode_flag == 1)
351
6.05k
                        {
352
6.05k
                            if(i1_ref_idx > (ps_dec->ps_cur_slice->u1_num_ref_idx_lx_active[0] - 1))
353
14
                            {
354
14
                                i1_ref_idx = ps_dec->ps_cur_slice->u1_num_ref_idx_lx_active[0] - 1;
355
14
                            }
356
6.05k
                        }
357
39.4k
                        s_mvPred.i1_ref_frame[0] = i1_ref_idx;
358
359
39.4k
                        if((1 != ps_svc_cur_mb_info->u1_base_mode_flag) &&
360
33.4k
                           (0 == (u1_motion_pred_flag_l0 & (1 << u1_blk_no))))
361
25.5k
                        {
362
                            /********************************************************/
363
                            /* Predict Mv                                           */
364
                            /* Add Mv Residuals and store back                      */
365
                            /********************************************************/
366
25.5k
                            ps_dec->pf_mvpred(ps_dec, ps_cur_mb_info, ps_mv_nmb, ps_mv_ntop,
367
25.5k
                                              &s_mvPred, u1_sub_mb_num, u1_wd, 0, 1,
368
25.5k
                                              ps_cur_mb_info->u1_mb_mc_mode);
369
370
25.5k
                            i2_mv_x = ps_mv_nmb->i2_mv[0];
371
25.5k
                            i2_mv_y = ps_mv_nmb->i2_mv[1];
372
25.5k
                            i2_mv_x += s_mvPred.i2_mv[0];
373
25.5k
                            i2_mv_y += s_mvPred.i2_mv[1];
374
25.5k
                            s_mvPred.i2_mv[0] = i2_mv_x;
375
25.5k
                            s_mvPred.i2_mv[1] = i2_mv_y;
376
25.5k
                        }
377
13.9k
                        else
378
13.9k
                        {
379
13.9k
                            isvcd_retrive_infer_mode_mv(ps_svc_lyr_dec, &s_mvPred, 0,
380
13.9k
                                                        u1_sub_mb_num);
381
382
13.9k
                            if(0 != (u1_motion_pred_flag_l0 & (1 << u1_blk_no)))
383
7.90k
                            {
384
7.90k
                                i2_mv_x = ps_mv_nmb->i2_mv[0];
385
7.90k
                                i2_mv_y = ps_mv_nmb->i2_mv[1];
386
7.90k
                                i2_mv_x += s_mvPred.i2_mv[0];
387
7.90k
                                i2_mv_y += s_mvPred.i2_mv[1];
388
7.90k
                                s_mvPred.i2_mv[0] = i2_mv_x;
389
7.90k
                                s_mvPred.i2_mv[1] = i2_mv_y;
390
7.90k
                            }
391
13.9k
                            i2_mv_x = s_mvPred.i2_mv[0];
392
13.9k
                            i2_mv_y = s_mvPred.i2_mv[1];
393
13.9k
                        }
394
                        /********************************************************/
395
                        /* Transfer setup call                                  */
396
                        /* convert RefIdx if it is MbAff                        */
397
                        /* Pass Weight Offset and refFrame                      */
398
                        /********************************************************/
399
39.4k
                        i1_ref_idx1 = i1_ref_idx >> u1_scale_ref;
400
39.4k
                        if(u1_scale_ref && ((i1_ref_idx & 0x01) != u4_bot_mb))
401
0
                            i1_ref_idx1 += MAX_REF_BUFS;
402
39.4k
                        if(-1 == i1_ref_idx1) return NOT_OK;
403
39.4k
                        ps_ref_frame = pps_ref_frame[i1_ref_idx1];
404
39.4k
                        pu4_wt_offst = ppu4_wt_ofst[u1_blk_no];
405
406
39.4k
                        {
407
39.4k
                            pred_info_pkd_t *ps_pred_pkd;
408
39.4k
                            ps_pred_pkd = ps_dec->ps_pred_pkd + ps_dec->u4_pred_info_pkd_idx;
409
39.4k
                            ih264d_fill_pred_info(s_mvPred.i2_mv, u1_wd, u1_ht, u1_sub_mb_num,
410
39.4k
                                                  PRED_L0, ps_pred_pkd, ps_ref_frame->u1_pic_buf_id,
411
39.4k
                                                  (i1_ref_idx >> u1_scale_ref), pu4_wt_offst,
412
39.4k
                                                  ps_ref_frame->u1_pic_type);
413
414
39.4k
                            ps_dec->u4_pred_info_pkd_idx++;
415
39.4k
                            ps_cur_mb_info->u1_num_pred_parts++;
416
39.4k
                        }
417
418
                        /* Fill colocated info in MvPred structure */
419
39.4k
                        s_mvPred.u1_col_ref_pic_idx = ps_ref_frame->u1_mv_buf_id;
420
39.4k
                        s_mvPred.u1_pic_type = ps_ref_frame->u1_pic_type;
421
422
                        /* Calculating colocated zero information */
423
39.4k
                        u1_colz = (u1_field << 1) |
424
39.4k
                                  ((i1_ref_idx == 0) && (ABS(i2_mv_x) <= 1) && (ABS(i2_mv_y) <= 1));
425
39.4k
                        u1_colz |= ps_mb_part_info->u1_col_info[u1_blk_no];
426
427
                        /* Replicate the motion vectors and colzero u4_flag  */
428
                        /* for all sub-partitions                         */
429
430
39.4k
                        if(ps_mv_nmb)
431
39.4k
                        {
432
39.4k
                            ih264d_rep_mv_colz(ps_dec, &s_mvPred, ps_mv_nmb, u1_sub_mb_num, u1_colz,
433
39.4k
                                               u1_ht, u1_wd);
434
39.4k
                        }
435
0
                        else
436
0
                        {
437
0
                            return NOT_OK;
438
0
                        }
439
39.4k
                    }
440
386k
                }
441
442
                /* to take care of 16 parttitions increment for base mode flag case*/
443
366k
                if(1 == ps_svc_cur_mb_info->u1_base_mode_flag)
444
3.58k
                {
445
3.58k
                    ps_part += (MAX_NUM_MB_PART - u1_num_part);
446
3.58k
                }
447
366k
            }
448
123
            else
449
123
            {
450
123
                ps_cur_deblk_mb->u1_mb_type |= D_INTRA_IBL;
451
123
                if((ps_svc_lyr_dec->u1_layer_identifier != TARGET_LAYER) &&
452
0
                   (DBLK_ENABLED == ps_dec->ps_cur_slice->u1_disable_dblk_filter_idc))
453
0
                {
454
0
                    ps_cur_deblk_mb->u1_deblocking_mode = MB_ENABLE_FILTERING;
455
0
                }
456
                /* to take care of 16 parttitions increment for base mode flag case*/
457
123
                if(1 != ps_svc_cur_mb_info->u1_base_mode_flag)
458
0
                {
459
0
                    return NOT_OK;
460
0
                }
461
123
                {
462
123
                    ps_part += (MAX_NUM_MB_PART);
463
123
                }
464
                /* Storing colocated zero information */
465
123
                if(ps_mv_nmb_start)
466
123
                {
467
123
                    ih264d_rep_mv_colz(ps_dec, &s_mvPred, ps_mv_nmb_start, 0,
468
123
                                       (UWORD8) (u1_field << 1), 4, 4);
469
123
                }
470
0
                else
471
0
                {
472
0
                    return NOT_OK;
473
0
                }
474
123
            }
475
366k
        }
476
523
        else
477
523
        {
478
            /* Storing colocated zero information */
479
523
            if(ps_mv_nmb_start)
480
523
            {
481
523
                ih264d_rep_mv_colz(ps_dec, &s_mvPred, ps_mv_nmb_start, 0, (UWORD8) (u1_field << 1),
482
523
                                   4, 4);
483
523
            }
484
0
            else
485
0
            {
486
0
                return NOT_OK;
487
0
            }
488
523
        }
489
367k
    }
490
491
52.4k
    return OK;
492
52.4k
}
493
/*!
494
 **************************************************************************
495
 * \if Function name : isvcd_update_intra_mb_inter_layer_info \endif
496
 *
497
 * \brief : IT
498
 *    This function decodes an Inter MB fornfor ot target base layers
499
 *    Only for Progressive : saves residual for upper enhancement layers
500
 *
501
 * \return
502
 *    0 on Success and Error code otherwise
503
 **************************************************************************
504
 */
505
void isvcd_update_intra_mb_inter_layer_info(svc_dec_lyr_struct_t *ps_svc_lyr_dec,
506
                                            dec_mb_info_t *ps_cur_mb_info)
507
6.21k
{
508
6.21k
    ps_svc_lyr_dec->ps_inter_lyr_mb_prms_cur_mb =
509
6.21k
        ps_svc_lyr_dec->ps_inter_lyr_mb_prms_frm_start + ps_cur_mb_info->u2_mbx +
510
6.21k
        (ps_svc_lyr_dec->u2_inter_lyr_mb_prms_stride * (ps_cur_mb_info->u2_mby));
511
512
6.21k
    ps_svc_lyr_dec->ps_inter_lyr_mb_prms_cur_mb->i1_mb_mode = SVC_INTRA_MB;
513
6.21k
    ps_svc_lyr_dec->ps_inter_lyr_mb_prms_cur_mb->i1_tx_size = ps_cur_mb_info->u1_tran_form8x8;
514
6.21k
    ps_svc_lyr_dec->ps_inter_lyr_mb_prms_cur_mb->u2_luma_nnz = 0;
515
6.21k
    ps_svc_lyr_dec->ps_inter_lyr_mb_prms_cur_mb->u1_chroma_nnz = 0;
516
6.21k
}
517
518
/*!
519
**************************************************************************
520
* \if Function name : isvcd_update_ipcm_mb_inter_layer_info \endif
521
*
522
* \brief : IT
523
*    This function decodes an IPM MB fornfor ot target base layers
524
*    Only for Progressive : saves residual for upper enhancement layers
525
*
526
* \return
527
*    0 on Success and Error code otherwise
528
**************************************************************************
529
*/
530
void isvcd_update_ipcm_mb_inter_layer_info(svc_dec_lyr_struct_t *ps_svc_lyr_dec,
531
                                           dec_mb_info_t *ps_cur_mb_info)
532
34
{
533
34
    ps_svc_lyr_dec->ps_inter_lyr_mb_prms_cur_mb->i1_mb_mode = SVC_IPCM_MB;
534
34
    ps_svc_lyr_dec->ps_inter_lyr_mb_prms_cur_mb->i1_tx_size = ps_cur_mb_info->u1_tran_form8x8;
535
34
    ps_svc_lyr_dec->ps_inter_lyr_mb_prms_cur_mb->u2_luma_nnz = 0;
536
34
    ps_svc_lyr_dec->ps_inter_lyr_mb_prms_cur_mb->u1_chroma_nnz = 0;
537
34
}
538
539
/*!
540
**************************************************************************
541
* \if Function name : isvcd_update_ibl_mb_inter_layer_info \endif
542
*
543
* \brief : IT
544
*    This function decodes an IBL MB fornfor ot target base layers
545
*    Only for Progressive : saves residual for upper enhancement layers
546
*
547
* \return
548
*    0 on Success and Error code otherwise
549
**************************************************************************
550
*/
551
void isvcd_update_ibl_mb_inter_layer_info(svc_dec_lyr_struct_t *ps_svc_lyr_dec,
552
                                          dec_mb_info_t *ps_cur_mb_info)
553
123
{
554
123
    ps_svc_lyr_dec->ps_inter_lyr_mb_prms_cur_mb->i1_mb_mode = SVC_IBL_MB;
555
123
    ps_svc_lyr_dec->ps_inter_lyr_mb_prms_cur_mb->i1_tx_size = ps_cur_mb_info->u1_tran_form8x8;
556
123
    ps_svc_lyr_dec->ps_inter_lyr_mb_prms_cur_mb->u2_luma_nnz = 0;
557
123
    ps_svc_lyr_dec->ps_inter_lyr_mb_prms_cur_mb->u1_chroma_nnz = 0;
558
123
}
559
/*!
560
**************************************************************************
561
* \if Function name : isvcd_update_inter_mb_inter_layer_info \endif
562
*
563
* \brief : IT
564
*    This function decodes an IBL MB fornfor ot target base layers
565
*    Only for Progressive : saves residual for upper enhancement layers
566
*
567
* \return
568
*    0 on Success and Error code otherwise
569
**************************************************************************
570
*/
571
void isvcd_update_inter_mb_inter_layer_info(svc_dec_lyr_struct_t *ps_svc_lyr_dec,
572
                                            dec_mb_info_t *ps_cur_mb_info, UWORD8 u1_inference_mode)
573
965
{
574
965
    ps_svc_lyr_dec->ps_inter_lyr_mb_prms_cur_mb =
575
965
        ps_svc_lyr_dec->ps_inter_lyr_mb_prms_frm_start + ps_cur_mb_info->u2_mbx +
576
965
        (ps_svc_lyr_dec->u2_inter_lyr_mb_prms_stride * (ps_cur_mb_info->u2_mby));
577
965
    ps_svc_lyr_dec->ps_inter_lyr_mb_prms_cur_mb->i1_mb_mode =
578
965
        u1_inference_mode ? SVC_IBL_MB : SVC_INTER_MB;
579
965
    ps_svc_lyr_dec->ps_inter_lyr_mb_prms_cur_mb->i1_tx_size = ps_cur_mb_info->u1_tran_form8x8;
580
965
    ps_svc_lyr_dec->ps_inter_lyr_mb_prms_cur_mb->u2_luma_nnz = ps_cur_mb_info->u2_luma_csbp;
581
965
    ps_svc_lyr_dec->ps_inter_lyr_mb_prms_cur_mb->u1_chroma_nnz =
582
965
        (UWORD8) ps_cur_mb_info->u2_chroma_csbp;
583
965
    if(CHECKBIT(ps_cur_mb_info->u1_yuv_dc_block_flag, 1))
584
72
    {
585
        /* Four bits for Cb in DC only cbp */
586
72
        ps_svc_lyr_dec->ps_inter_lyr_mb_prms_cur_mb->u1_chroma_nnz |= 0x0F;
587
72
    }
588
965
    if(CHECKBIT(ps_cur_mb_info->u1_yuv_dc_block_flag, 2))
589
78
    {
590
        /* Four bits for Cr in DC only cbp */
591
78
        ps_svc_lyr_dec->ps_inter_lyr_mb_prms_cur_mb->u1_chroma_nnz |= 0xF0;
592
78
    }
593
965
}
594
/*!
595
 **************************************************************************
596
 * \if Function name : isvcd_process_inter_mb_no_rsd_pred_non_target \endif
597
 *
598
 * \brief : IT
599
 *    This function decodes an Inter MB fornfor ot target base layers
600
 *    Only for Progressive : saves residual for upper enhancement layers
601
 *
602
 * \return
603
 *    0 on Success and Error code otherwise
604
 **************************************************************************
605
 */
606
WORD32 isvcd_process_inter_mb_no_rsd_pred_non_target(svc_dec_lyr_struct_t *ps_svc_lyr_dec,
607
                                                     dec_mb_info_t *ps_cur_mb_info,
608
                                                     UWORD8 u1_inference_mode)
609
8.02k
{
610
8.02k
    dec_struct_t *ps_dec = &ps_svc_lyr_dec->s_dec;
611
8.02k
    UWORD16 u2_luma_stride, u2_chroma_stride;
612
8.02k
    WORD16 *pi2_y_coeff, *pi2_luma_res_ptr, *pi2_chroma_res_ptr;
613
8.02k
    UWORD32 u4_luma_dc_only_csbp = 0;
614
8.02k
    UWORD32 u4_luma_dc_only_cbp = 0;
615
616
8.02k
    if(0 != ps_dec->ps_cur_slice->u1_mbaff_frame_flag)
617
0
    {
618
0
        return NOT_OK;
619
0
    }
620
8.02k
    u2_luma_stride = ps_svc_lyr_dec->u2_residual_resample_luma_stride;
621
8.02k
    pi2_luma_res_ptr = ps_svc_lyr_dec->pi2_il_residual_resample_mb_luma_frm_start +
622
8.02k
                       (ps_cur_mb_info->u2_mbx << 4) +
623
8.02k
                       ((ps_cur_mb_info->u2_mby << 4) * u2_luma_stride);
624
625
8.02k
    u2_chroma_stride = ps_svc_lyr_dec->u2_residual_resample_chroma_stride;
626
8.02k
    pi2_chroma_res_ptr = ps_svc_lyr_dec->pi2_il_residual_resample_mb_chroma_frm_start +
627
8.02k
                         (ps_cur_mb_info->u2_mbx << 4) +
628
8.02k
                         ((ps_cur_mb_info->u2_mby << 3) * u2_chroma_stride);
629
630
8.02k
    if(!ps_cur_mb_info->u1_tran_form8x8)
631
4.47k
    {
632
4.47k
        u4_luma_dc_only_csbp = ih264d_unpack_luma_coeff4x4_mb(ps_dec, ps_cur_mb_info, 0);
633
4.47k
    }
634
3.55k
    else
635
3.55k
    {
636
3.55k
        if(!ps_dec->ps_cur_pps->u1_entropy_coding_mode)
637
0
        {
638
0
            u4_luma_dc_only_cbp = ih264d_unpack_luma_coeff4x4_mb(ps_dec, ps_cur_mb_info, 0);
639
0
        }
640
3.55k
        else
641
3.55k
        {
642
3.55k
            u4_luma_dc_only_cbp = ih264d_unpack_luma_coeff8x8_mb(ps_dec, ps_cur_mb_info);
643
3.55k
        }
644
3.55k
    }
645
646
8.02k
    pi2_y_coeff = ps_dec->pi2_coeff_data;
647
    /* Inverse Transform and Reconstruction */
648
8.02k
    if(ps_cur_mb_info->u1_cbp & 0x0f)
649
6.45k
    {
650
6.45k
        if(!ps_cur_mb_info->u1_tran_form8x8)
651
2.89k
        {
652
2.89k
            UWORD32 i;
653
2.89k
            WORD16 ai2_tmp[16] = {0};
654
49.2k
            for(i = 0; i < 16; i++)
655
46.3k
            {
656
46.3k
                if(CHECKBIT(ps_cur_mb_info->u2_luma_csbp, i))
657
25.1k
                {
658
25.1k
                    WORD16 *pi2_level = pi2_y_coeff + (i << 4);
659
25.1k
                    WORD16 *pi2_out = pi2_luma_res_ptr + ((i & 0x3) * BLK_SIZE) +
660
25.1k
                                      (i >> 2) * (u2_luma_stride << 2);
661
25.1k
                    PROFILE_DISABLE_IQ_IT_RECON()
662
25.1k
                    {
663
25.1k
                        if(CHECKBIT(u4_luma_dc_only_csbp, i))
664
1.53k
                        {
665
1.53k
                            ps_svc_lyr_dec->pf_iquant_itrans_luma_4x4_dc(
666
1.53k
                                pi2_level, pi2_out, u2_luma_stride,
667
1.53k
                                gau2_ih264_iquant_scale_4x4[ps_cur_mb_info->u1_qp_rem6],
668
1.53k
                                (UWORD16 *) ps_dec->s_high_profile.i2_scalinglist4x4[3],
669
1.53k
                                ps_cur_mb_info->u1_qp_div6, ai2_tmp, 0, NULL);
670
1.53k
                        }
671
23.5k
                        else
672
23.5k
                        {
673
23.5k
                            ps_svc_lyr_dec->pf_iquant_itrans_luma_4x4(
674
23.5k
                                pi2_level, pi2_out, u2_luma_stride,
675
23.5k
                                gau2_ih264_iquant_scale_4x4[ps_cur_mb_info->u1_qp_rem6],
676
23.5k
                                (UWORD16 *) ps_dec->s_high_profile.i2_scalinglist4x4[3],
677
23.5k
                                ps_cur_mb_info->u1_qp_div6, ai2_tmp, 0, NULL);
678
23.5k
                        }
679
25.1k
                    }
680
25.1k
                }
681
46.3k
            }
682
2.89k
        }
683
3.55k
        else
684
3.55k
        {
685
3.55k
            WORD16 *pi2_scale_matrix_ptr;
686
3.55k
            WORD32 i;
687
688
3.55k
            pi2_scale_matrix_ptr = ps_dec->s_high_profile.i2_scalinglist8x8[1];
689
690
17.7k
            for(i = 0; i < 4; i++)
691
14.2k
            {
692
14.2k
                WORD16 ai2_tmp[64] = {0};
693
14.2k
                WORD16 *pi16_levelBlock =
694
14.2k
                    pi2_y_coeff + (i << 6); /* move to the next 8x8 adding 64 */
695
696
14.2k
                WORD16 *pi2_out =
697
14.2k
                    pi2_luma_res_ptr + ((i & 0x1) * BLK8x8SIZE) + (i >> 1) * (u2_luma_stride << 3);
698
14.2k
                if(CHECKBIT(ps_cur_mb_info->u1_cbp, i))
699
8.41k
                {
700
8.41k
                    PROFILE_DISABLE_IQ_IT_RECON()
701
8.41k
                    {
702
8.41k
                        if(CHECKBIT(u4_luma_dc_only_cbp, i))
703
617
                        {
704
617
                            ps_svc_lyr_dec->pf_iquant_itrans_luma_8x8_dc(
705
617
                                pi16_levelBlock, pi2_out, u2_luma_stride,
706
617
                                gau1_ih264d_dequant8x8_cavlc[ps_cur_mb_info->u1_qp_rem6],
707
617
                                (UWORD16 *) pi2_scale_matrix_ptr, ps_cur_mb_info->u1_qp_div6,
708
617
                                ai2_tmp, 0, NULL);
709
617
                        }
710
7.80k
                        else
711
7.80k
                        {
712
7.80k
                            ps_svc_lyr_dec->pf_iquant_itrans_luma_8x8(
713
7.80k
                                pi16_levelBlock, pi2_out, u2_luma_stride,
714
7.80k
                                gau1_ih264d_dequant8x8_cavlc[ps_cur_mb_info->u1_qp_rem6],
715
7.80k
                                (UWORD16 *) pi2_scale_matrix_ptr, ps_cur_mb_info->u1_qp_div6,
716
7.80k
                                ai2_tmp, 0, NULL);
717
7.80k
                        }
718
8.41k
                    }
719
8.41k
                }
720
14.2k
            }
721
3.55k
        }
722
6.45k
    }
723
724
    /* Decode Chroma Block */
725
8.02k
    ih264d_unpack_chroma_coeff4x4_mb(ps_dec, ps_cur_mb_info);
726
    /*--------------------------------------------------------------------*/
727
    /* Chroma Blocks decoding                                             */
728
    /*--------------------------------------------------------------------*/
729
8.02k
    {
730
8.02k
        UWORD8 u1_chroma_cbp = (UWORD8) (ps_cur_mb_info->u1_cbp >> 4);
731
732
8.02k
        if(u1_chroma_cbp != CBPC_ALLZERO)
733
1.99k
        {
734
1.99k
            UWORD32 u4_scale_u = ps_cur_mb_info->u1_qpc_div6;
735
1.99k
            UWORD32 u4_scale_v = ps_cur_mb_info->u1_qpcr_div6;
736
1.99k
            UWORD16 u2_chroma_csbp = ps_cur_mb_info->u2_chroma_csbp;
737
738
1.99k
            pi2_y_coeff = ps_dec->pi2_coeff_data;
739
740
1.99k
            {
741
1.99k
                UWORD32 i;
742
1.99k
                WORD16 ai2_tmp[16] = {0};
743
9.95k
                for(i = 0; i < 4; i++)
744
7.96k
                {
745
7.96k
                    WORD16 *pi2_level = pi2_y_coeff + (i << 4);
746
7.96k
                    WORD16 *pi2_out = pi2_chroma_res_ptr +
747
7.96k
                                      ((i & 0x1) * BLK_SIZE * YUV420SP_FACTOR) +
748
7.96k
                                      (i >> 1) * (u2_chroma_stride << 2);
749
7.96k
                    PROFILE_DISABLE_IQ_IT_RECON()
750
7.96k
                    {
751
7.96k
                        if(CHECKBIT(u2_chroma_csbp, i))
752
928
                        {
753
928
                            ps_svc_lyr_dec->pf_iquant_itrans_chroma_4x4(
754
928
                                pi2_level, pi2_out, u2_chroma_stride,
755
928
                                gau2_ih264_iquant_scale_4x4[ps_cur_mb_info->u1_qpc_rem6],
756
928
                                (UWORD16 *) ps_dec->s_high_profile.i2_scalinglist4x4[4], u4_scale_u,
757
928
                                ai2_tmp, pi2_level);
758
928
                        }
759
7.03k
                        else if(pi2_level[0] != 0)
760
3.07k
                        {
761
3.07k
                            ps_svc_lyr_dec->pf_iquant_itrans_chroma_4x4_dc(
762
3.07k
                                pi2_level, pi2_out, u2_chroma_stride,
763
3.07k
                                gau2_ih264_iquant_scale_4x4[ps_cur_mb_info->u1_qpc_rem6],
764
3.07k
                                (UWORD16 *) ps_dec->s_high_profile.i2_scalinglist4x4[4], u4_scale_u,
765
3.07k
                                ai2_tmp, pi2_level);
766
3.07k
                        }
767
7.96k
                    }
768
7.96k
                }
769
1.99k
            }
770
771
1.99k
            pi2_y_coeff += MB_CHROM_SIZE;
772
1.99k
            u2_chroma_csbp >>= 4;
773
774
1.99k
            {
775
1.99k
                UWORD32 i;
776
1.99k
                WORD16 ai2_tmp[16] = {0};
777
9.95k
                for(i = 0; i < 4; i++)
778
7.96k
                {
779
7.96k
                    WORD16 *pi2_level = pi2_y_coeff + (i << 4);
780
7.96k
                    WORD16 *pi2_out = pi2_chroma_res_ptr + 1 +
781
7.96k
                                      ((i & 0x1) * BLK_SIZE * YUV420SP_FACTOR) +
782
7.96k
                                      (i >> 1) * (u2_chroma_stride << 2);
783
7.96k
                    PROFILE_DISABLE_IQ_IT_RECON()
784
7.96k
                    {
785
7.96k
                        if(CHECKBIT(u2_chroma_csbp, i))
786
1.32k
                        {
787
1.32k
                            ps_svc_lyr_dec->pf_iquant_itrans_chroma_4x4(
788
1.32k
                                pi2_level, pi2_out, u2_chroma_stride,
789
1.32k
                                gau2_ih264_iquant_scale_4x4[ps_cur_mb_info->u1_qpcr_rem6],
790
1.32k
                                (UWORD16 *) ps_dec->s_high_profile.i2_scalinglist4x4[5], u4_scale_v,
791
1.32k
                                ai2_tmp, pi2_level);
792
1.32k
                        }
793
6.63k
                        else if(pi2_level[0] != 0)
794
3.34k
                        {
795
3.34k
                            ps_svc_lyr_dec->pf_iquant_itrans_chroma_4x4_dc(
796
3.34k
                                pi2_level, pi2_out, u2_chroma_stride,
797
3.34k
                                gau2_ih264_iquant_scale_4x4[ps_cur_mb_info->u1_qpcr_rem6],
798
3.34k
                                (UWORD16 *) ps_dec->s_high_profile.i2_scalinglist4x4[5], u4_scale_v,
799
3.34k
                                ai2_tmp, pi2_level);
800
3.34k
                        }
801
7.96k
                    }
802
7.96k
                }
803
1.99k
            }
804
1.99k
        }
805
8.02k
    }
806
807
8.02k
    ps_svc_lyr_dec->ps_inter_lyr_mb_prms_cur_mb =
808
8.02k
        ps_svc_lyr_dec->ps_inter_lyr_mb_prms_frm_start + ps_cur_mb_info->u2_mbx +
809
8.02k
        (ps_svc_lyr_dec->u2_inter_lyr_mb_prms_stride * (ps_cur_mb_info->u2_mby));
810
8.02k
    ps_svc_lyr_dec->ps_inter_lyr_mb_prms_cur_mb->i1_mb_mode =
811
8.02k
        u1_inference_mode ? SVC_IBL_MB : SVC_INTER_MB;
812
8.02k
    ps_svc_lyr_dec->ps_inter_lyr_mb_prms_cur_mb->i1_tx_size = ps_cur_mb_info->u1_tran_form8x8;
813
8.02k
    ps_svc_lyr_dec->ps_inter_lyr_mb_prms_cur_mb->u2_luma_nnz = ps_cur_mb_info->u2_luma_csbp;
814
8.02k
    ps_svc_lyr_dec->ps_inter_lyr_mb_prms_cur_mb->u1_chroma_nnz =
815
8.02k
        (UWORD8) ps_cur_mb_info->u2_chroma_csbp;
816
8.02k
    if(CHECKBIT(ps_cur_mb_info->u1_yuv_dc_block_flag, 1))
817
1.01k
    {
818
        /* Four bits for Cb in DC only cbp */
819
1.01k
        ps_svc_lyr_dec->ps_inter_lyr_mb_prms_cur_mb->u1_chroma_nnz |= 0x0F;
820
1.01k
    }
821
8.02k
    if(CHECKBIT(ps_cur_mb_info->u1_yuv_dc_block_flag, 2))
822
1.08k
    {
823
        /* Four bits for Cr in DC only cbp */
824
1.08k
        ps_svc_lyr_dec->ps_inter_lyr_mb_prms_cur_mb->u1_chroma_nnz |= 0xF0;
825
1.08k
    }
826
8.02k
    return OK;
827
8.02k
}
828
829
/*!
830
 **************************************************************************
831
 * \if Function name : isvcd_process_inter_mb_rsd_pred_non_target \endif
832
 *
833
 * \brief : IT + Residual :
834
 *    This function decodes an Inter MB for non target layers
835
 *    Only for Progressive : saves residual + IT for upper enhancement layers
836
 *
837
 * \return
838
 *    0 on Success and Error code otherwise
839
 **************************************************************************
840
 */
841
WORD32 isvcd_process_inter_mb_rsd_pred_non_target(svc_dec_lyr_struct_t *ps_svc_lyr_dec,
842
                                                  dec_mb_info_t *ps_cur_mb_info,
843
                                                  UWORD8 u1_inference_mode,
844
                                                  UWORD16 *pu2_res_luma_csbp)
845
0
{
846
0
    dec_struct_t *ps_dec = &ps_svc_lyr_dec->s_dec;
847
0
    UWORD16 u2_luma_stride, u2_chroma_stride;
848
0
    WORD16 *pi2_y_coeff, *pi2_luma_res_ptr, *pi2_chroma_res_ptr;
849
0
    UWORD32 u4_luma_dc_only_csbp = 0;
850
0
    UWORD32 u4_luma_dc_only_cbp = 0;
851
0
    UWORD16 u2_res_luma_csbp = 0;
852
0
    UWORD16 u2_res_chroma_csbp = 0, u2_res_chroma_nnz = 0;
853
0
    WORD32 ret;
854
855
0
    if(0 != ps_dec->ps_cur_slice->u1_mbaff_frame_flag)
856
0
    {
857
0
        return NOT_OK;
858
0
    }
859
0
    u2_luma_stride = ps_svc_lyr_dec->u2_residual_resample_luma_stride;
860
0
    pi2_luma_res_ptr = ps_svc_lyr_dec->pi2_il_residual_resample_mb_luma_frm_start +
861
0
                       (ps_cur_mb_info->u2_mbx << 4) +
862
0
                       ((ps_cur_mb_info->u2_mby << 4) * u2_luma_stride);
863
864
0
    u2_chroma_stride = ps_svc_lyr_dec->u2_residual_resample_chroma_stride;
865
0
    pi2_chroma_res_ptr = ps_svc_lyr_dec->pi2_il_residual_resample_mb_chroma_frm_start +
866
0
                         (ps_cur_mb_info->u2_mbx << 4) +
867
0
                         ((ps_cur_mb_info->u2_mby << 3) * u2_chroma_stride);
868
869
    // residual prediction SVC
870
0
    ret = isvcd_process_residual_resample_mb(ps_svc_lyr_dec, ps_cur_mb_info);
871
0
    if(ret != OK)
872
0
    {
873
0
        return ret;
874
0
    }
875
876
0
    if(!ps_cur_mb_info->u1_tran_form8x8)
877
0
    {
878
0
        u4_luma_dc_only_csbp = ih264d_unpack_luma_coeff4x4_mb(ps_dec, ps_cur_mb_info, 0);
879
0
    }
880
0
    else
881
0
    {
882
0
        if(!ps_dec->ps_cur_pps->u1_entropy_coding_mode)
883
0
        {
884
0
            u4_luma_dc_only_cbp = ih264d_unpack_luma_coeff4x4_mb(ps_dec, ps_cur_mb_info, 0);
885
0
        }
886
0
        else
887
0
        {
888
0
            u4_luma_dc_only_cbp = ih264d_unpack_luma_coeff8x8_mb(ps_dec, ps_cur_mb_info);
889
0
        }
890
0
    }
891
892
0
    *pu2_res_luma_csbp = 0;
893
0
    pi2_y_coeff = ps_dec->pi2_coeff_data;
894
    /* Inverse Transform and Reconstruction */
895
0
    if(ps_cur_mb_info->u1_cbp & 0x0f)
896
0
    {
897
0
        if(!ps_cur_mb_info->u1_tran_form8x8)
898
0
        {
899
0
            UWORD32 i;
900
0
            WORD16 ai2_tmp[16] = {0};
901
0
            for(i = 0; i < 16; i++)
902
0
            {
903
0
                if(CHECKBIT(ps_cur_mb_info->u2_luma_csbp, i))
904
0
                {
905
0
                    WORD16 *pi2_level = pi2_y_coeff + (i << 4);
906
0
                    WORD16 *pi2_out = pi2_luma_res_ptr + ((i & 0x3) * BLK_SIZE) +
907
0
                                      (i >> 2) * (u2_luma_stride << 2);
908
0
                    PROFILE_DISABLE_IQ_IT_RECON()
909
0
                    {
910
0
                        if(CHECKBIT(u4_luma_dc_only_csbp, i))
911
0
                        {
912
0
                            u2_res_luma_csbp =
913
0
                                ps_svc_lyr_dec->pf_iquant_itrans_residual_luma_4x4_dc(
914
0
                                    pi2_level, pi2_out, pi2_out, u2_luma_stride, u2_luma_stride,
915
0
                                    gau2_ih264_iquant_scale_4x4[ps_cur_mb_info->u1_qp_rem6],
916
0
                                    (UWORD16 *) ps_dec->s_high_profile.i2_scalinglist4x4[3],
917
0
                                    ps_cur_mb_info->u1_qp_div6, ai2_tmp, 0, NULL);
918
0
                        }
919
0
                        else
920
0
                        {
921
0
                            u2_res_luma_csbp = ps_svc_lyr_dec->pf_iquant_itrans_residual_luma_4x4(
922
0
                                pi2_level, pi2_out, pi2_out, u2_luma_stride, u2_luma_stride,
923
0
                                gau2_ih264_iquant_scale_4x4[ps_cur_mb_info->u1_qp_rem6],
924
0
                                (UWORD16 *) ps_dec->s_high_profile.i2_scalinglist4x4[3],
925
0
                                ps_cur_mb_info->u1_qp_div6, ai2_tmp, 0, NULL);
926
0
                        }
927
0
                    }
928
0
                }
929
0
                else
930
0
                {
931
0
                    WORD16 *pi2_out = pi2_luma_res_ptr + ((i & 0x3) * BLK_SIZE) +
932
0
                                      (i >> 2) * (u2_luma_stride << 2);
933
934
0
                    u2_res_luma_csbp =
935
0
                        ps_svc_lyr_dec->pf_residual_luma_4x4(pi2_out, u2_luma_stride);
936
0
                }
937
0
                *pu2_res_luma_csbp |= (u2_res_luma_csbp << i);
938
0
            }
939
0
        }
940
0
        else
941
0
        {
942
0
            WORD16 *pi2_scale_matrix_ptr;
943
0
            WORD32 i;
944
945
0
            pi2_scale_matrix_ptr = ps_dec->s_high_profile.i2_scalinglist8x8[1];
946
947
0
            for(i = 0; i < 4; i++)
948
0
            {
949
0
                WORD16 ai2_tmp[64] = {0};
950
0
                WORD16 *pi16_levelBlock =
951
0
                    pi2_y_coeff + (i << 6); /* move to the next 8x8 adding 64 */
952
953
0
                WORD16 *pi2_out =
954
0
                    pi2_luma_res_ptr + ((i & 0x1) * BLK8x8SIZE) + (i >> 1) * (u2_luma_stride << 3);
955
0
                if(CHECKBIT(ps_cur_mb_info->u1_cbp, i))
956
0
                {
957
0
                    PROFILE_DISABLE_IQ_IT_RECON()
958
0
                    {
959
0
                        if(CHECKBIT(u4_luma_dc_only_cbp, i))
960
0
                        {
961
0
                            u2_res_luma_csbp =
962
0
                                ps_svc_lyr_dec->pf_iquant_itrans_residual_luma_8x8_dc(
963
0
                                    pi16_levelBlock, pi2_out, pi2_out, u2_luma_stride,
964
0
                                    u2_luma_stride,
965
0
                                    gau1_ih264d_dequant8x8_cavlc[ps_cur_mb_info->u1_qp_rem6],
966
0
                                    (UWORD16 *) pi2_scale_matrix_ptr, ps_cur_mb_info->u1_qp_div6,
967
0
                                    ai2_tmp, 0, NULL);
968
0
                        }
969
0
                        else
970
0
                        {
971
0
                            u2_res_luma_csbp = ps_svc_lyr_dec->pf_iquant_itrans_residual_luma_8x8(
972
0
                                pi16_levelBlock, pi2_out, pi2_out, u2_luma_stride, u2_luma_stride,
973
0
                                gau1_ih264d_dequant8x8_cavlc[ps_cur_mb_info->u1_qp_rem6],
974
0
                                (UWORD16 *) pi2_scale_matrix_ptr, ps_cur_mb_info->u1_qp_div6,
975
0
                                ai2_tmp, 0, NULL);
976
0
                        }
977
0
                    }
978
0
                }
979
0
                else
980
0
                {
981
0
                    WORD16 *pi2_out = pi2_luma_res_ptr + ((i & 0x1) * BLK8x8SIZE) +
982
0
                                      (i >> 1) * (u2_luma_stride << 3);
983
984
0
                    u2_res_luma_csbp =
985
0
                        ps_svc_lyr_dec->pf_residual_luma_8x8(pi2_out, u2_luma_stride);
986
0
                }
987
0
                *pu2_res_luma_csbp |= (u2_res_luma_csbp << (((i >> 1) << 3) + ((i & 0x01) << 1)));
988
0
            }
989
0
        }
990
0
    }
991
0
    else
992
0
    {
993
0
        WORD16 *pi2_out = pi2_luma_res_ptr;
994
995
0
        *pu2_res_luma_csbp = ps_svc_lyr_dec->pf_residual_luma_16x16(pi2_out, u2_luma_stride);
996
0
    }
997
998
    /* Decode Chroma Block */
999
0
    ih264d_unpack_chroma_coeff4x4_mb(ps_dec, ps_cur_mb_info);
1000
    /*--------------------------------------------------------------------*/
1001
    /* Chroma Blocks decoding                                             */
1002
    /*--------------------------------------------------------------------*/
1003
0
    {
1004
0
        UWORD8 u1_chroma_cbp = (UWORD8) (ps_cur_mb_info->u1_cbp >> 4);
1005
1006
0
        u2_res_chroma_nnz =
1007
0
            ps_svc_lyr_dec->pf_residual_chroma_cb_cr_8x8(pi2_chroma_res_ptr, u2_chroma_stride);
1008
1009
0
        if(u1_chroma_cbp != CBPC_ALLZERO)
1010
0
        {
1011
0
            UWORD32 u4_scale_u = ps_cur_mb_info->u1_qpc_div6;
1012
0
            UWORD32 u4_scale_v = ps_cur_mb_info->u1_qpcr_div6;
1013
0
            UWORD16 u2_chroma_csbp = ps_cur_mb_info->u2_chroma_csbp;
1014
1015
0
            pi2_y_coeff = ps_dec->pi2_coeff_data;
1016
1017
0
            {
1018
0
                UWORD32 i;
1019
0
                WORD16 ai2_tmp[16] = {0};
1020
0
                for(i = 0; i < 4; i++)
1021
0
                {
1022
0
                    WORD16 *pi2_level = pi2_y_coeff + (i << 4);
1023
0
                    WORD16 *pi2_out = pi2_chroma_res_ptr +
1024
0
                                      ((i & 0x1) * BLK_SIZE * YUV420SP_FACTOR) +
1025
0
                                      (i >> 1) * (u2_chroma_stride << 2);
1026
0
                    PROFILE_DISABLE_IQ_IT_RECON()
1027
0
                    {
1028
0
                        if(CHECKBIT(u2_chroma_csbp, i))
1029
0
                        {
1030
0
                            u2_res_chroma_csbp =
1031
0
                                ps_svc_lyr_dec->pf_iquant_itrans_residual_chroma_4x4(
1032
0
                                    pi2_level, pi2_out, pi2_out, u2_chroma_stride, u2_chroma_stride,
1033
0
                                    gau2_ih264_iquant_scale_4x4[ps_cur_mb_info->u1_qpc_rem6],
1034
0
                                    (UWORD16 *) ps_dec->s_high_profile.i2_scalinglist4x4[4],
1035
0
                                    u4_scale_u, ai2_tmp, pi2_level);
1036
0
                            u2_res_chroma_nnz &= (0XFF ^ (1 << i));
1037
0
                            u2_res_chroma_nnz |= (u2_res_chroma_csbp << i);
1038
0
                        }
1039
0
                        else if(pi2_level[0] != 0)
1040
0
                        {
1041
0
                            u2_res_chroma_csbp =
1042
0
                                ps_svc_lyr_dec->pf_iquant_itrans_residual_chroma_4x4_dc(
1043
0
                                    pi2_level, pi2_out, pi2_out, u2_chroma_stride, u2_chroma_stride,
1044
0
                                    gau2_ih264_iquant_scale_4x4[ps_cur_mb_info->u1_qpc_rem6],
1045
0
                                    (UWORD16 *) ps_dec->s_high_profile.i2_scalinglist4x4[4],
1046
0
                                    u4_scale_u, ai2_tmp, pi2_level);
1047
0
                            u2_res_chroma_nnz &= (0XFF ^ (1 << i));
1048
0
                            u2_res_chroma_nnz |= (u2_res_chroma_csbp << i);
1049
0
                        }
1050
0
                    }
1051
0
                }
1052
0
            }
1053
1054
0
            pi2_y_coeff += MB_CHROM_SIZE;
1055
0
            u2_chroma_csbp >>= 4;
1056
1057
0
            {
1058
0
                UWORD32 i;
1059
0
                WORD16 ai2_tmp[16] = {0};
1060
0
                for(i = 0; i < 4; i++)
1061
0
                {
1062
0
                    WORD16 *pi2_level = pi2_y_coeff + (i << 4);
1063
0
                    WORD16 *pi2_out = pi2_chroma_res_ptr + 1 +
1064
0
                                      ((i & 0x1) * BLK_SIZE * YUV420SP_FACTOR) +
1065
0
                                      (i >> 1) * (u2_chroma_stride << 2);
1066
0
                    PROFILE_DISABLE_IQ_IT_RECON()
1067
0
                    {
1068
0
                        if(CHECKBIT(u2_chroma_csbp, i))
1069
0
                        {
1070
0
                            u2_res_chroma_csbp =
1071
0
                                ps_svc_lyr_dec->pf_iquant_itrans_residual_chroma_4x4(
1072
0
                                    pi2_level, pi2_out, pi2_out, u2_chroma_stride, u2_chroma_stride,
1073
0
                                    gau2_ih264_iquant_scale_4x4[ps_cur_mb_info->u1_qpcr_rem6],
1074
0
                                    (UWORD16 *) ps_dec->s_high_profile.i2_scalinglist4x4[5],
1075
0
                                    u4_scale_v, ai2_tmp, pi2_level);
1076
0
                            u2_res_chroma_nnz &= (0XFF ^ (1 << (i + 4)));
1077
0
                            u2_res_chroma_nnz |= (u2_res_chroma_csbp << (i + 4));
1078
0
                        }
1079
0
                        else if(pi2_level[0] != 0)
1080
0
                        {
1081
0
                            u2_res_chroma_csbp =
1082
0
                                ps_svc_lyr_dec->pf_iquant_itrans_residual_chroma_4x4_dc(
1083
0
                                    pi2_level, pi2_out, pi2_out, u2_chroma_stride, u2_chroma_stride,
1084
0
                                    gau2_ih264_iquant_scale_4x4[ps_cur_mb_info->u1_qpcr_rem6],
1085
0
                                    (UWORD16 *) ps_dec->s_high_profile.i2_scalinglist4x4[5],
1086
0
                                    u4_scale_v, ai2_tmp, pi2_level);
1087
0
                            u2_res_chroma_nnz &= (0XFF ^ (1 << (i + 4)));
1088
0
                            u2_res_chroma_nnz |= (u2_res_chroma_csbp << (i + 4));
1089
0
                        }
1090
0
                    }
1091
0
                }
1092
0
            }
1093
0
        }
1094
0
    }
1095
1096
0
    ps_svc_lyr_dec->ps_inter_lyr_mb_prms_cur_mb =
1097
0
        ps_svc_lyr_dec->ps_inter_lyr_mb_prms_frm_start + ps_cur_mb_info->u2_mbx +
1098
0
        (ps_svc_lyr_dec->u2_inter_lyr_mb_prms_stride * (ps_cur_mb_info->u2_mby));
1099
0
    ps_svc_lyr_dec->ps_inter_lyr_mb_prms_cur_mb->i1_mb_mode =
1100
0
        u1_inference_mode ? SVC_IBL_MB : SVC_INTER_MB;
1101
0
    ps_svc_lyr_dec->ps_inter_lyr_mb_prms_cur_mb->i1_tx_size = ps_cur_mb_info->u1_tran_form8x8;
1102
1103
0
    ps_svc_lyr_dec->ps_inter_lyr_mb_prms_cur_mb->u2_luma_nnz = *pu2_res_luma_csbp;
1104
0
    ps_svc_lyr_dec->ps_inter_lyr_mb_prms_cur_mb->u1_chroma_nnz = (UWORD8) u2_res_chroma_nnz;
1105
0
    return OK;
1106
0
}
1107
/*!
1108
**************************************************************************
1109
* \if Function name : isvcd_process_ii_mb \endif
1110
*
1111
* \brief
1112
*    This function decodes an intra inter mb
1113
*
1114
* \return
1115
*    0 on Success and Error code otherwise
1116
**************************************************************************
1117
*/
1118
WORD32 isvcd_process_ii_mb(svc_dec_lyr_struct_t *ps_svc_lyr_dec, dec_mb_info_t *ps_cur_mb_info,
1119
                           dec_svc_mb_info_t *ps_svc_cur_mb_info, UWORD8 u1_mb_num)
1120
1.03k
{
1121
1.03k
    res_prms_t *ps_res_prms;
1122
1.03k
    WORD32 i4_status;
1123
1.03k
    UWORD8 u1_ii_mb_mode = 0;
1124
1.03k
    mb_coord_t s_mb_coord = {0};
1125
1.03k
    mem_element_t s_ref_mb_mode = {0};
1126
1.03k
    svc_dec_lyr_struct_t *ps_svc_dec_ref_layer;
1127
1128
1.03k
    ps_svc_dec_ref_layer = ps_svc_lyr_dec->ps_dec_svc_ref_layer;
1129
1.03k
    ps_res_prms = &ps_svc_lyr_dec->s_res_prms;
1130
1.03k
    s_mb_coord.u2_mb_x = ps_cur_mb_info->u2_mbx;
1131
1.03k
    s_mb_coord.u2_mb_y = ps_cur_mb_info->u2_mby;
1132
1133
    /* Restricted resolution change has significance only */
1134
    /* at resolution change layer                         */
1135
1.03k
    if(SVCD_FALSE == ps_res_prms->u1_rstrct_res_change_flag)
1136
1.03k
    {
1137
1.03k
        s_ref_mb_mode.pv_buffer = ps_svc_dec_ref_layer->ps_inter_lyr_mb_prms_frm_start;
1138
1.03k
        s_ref_mb_mode.i4_element_size = sizeof(inter_lyr_mb_prms_t);
1139
1.03k
        s_ref_mb_mode.i4_num_element_stride = ps_svc_dec_ref_layer->u2_inter_lyr_mb_prms_stride;
1140
1141
1.03k
        i4_status = isvcd_ii_pred_compute_flags_mb(ps_svc_lyr_dec->pv_ii_pred_ctxt, &s_ref_mb_mode,
1142
1.03k
                                                   &s_mb_coord, ps_cur_mb_info, ps_svc_cur_mb_info,
1143
1.03k
                                                   &u1_ii_mb_mode);
1144
1145
1.03k
        if(OK != i4_status)
1146
0
        {
1147
0
            return i4_status;
1148
0
        }
1149
1.03k
    }
1150
1151
1.03k
    if(SVC_INTRA_INTER_MB == u1_ii_mb_mode)
1152
298
    {
1153
298
        i4_status = isvcd_process_ibl_mb(ps_svc_lyr_dec, ps_cur_mb_info, u1_mb_num, 1);
1154
298
        if(OK != i4_status)
1155
0
        {
1156
0
            return i4_status;
1157
0
        }
1158
298
        isvcd_ii_pred_mb(ps_svc_lyr_dec, ps_cur_mb_info);
1159
298
    }
1160
1.03k
    return OK;
1161
1.03k
}
1162
/*!
1163
 **************************************************************************
1164
 * \if Function name : isvcd_decode_recon_tfr_nmb_non_base_lyr \endif
1165
 *
1166
 * \brief
1167
 *
1168
 *
1169
 * \return
1170
 *    0 on Success and Error code otherwise
1171
 **************************************************************************
1172
 */
1173
WORD32 isvcd_decode_recon_tfr_nmb_non_base_lyr(svc_dec_lyr_struct_t *ps_svc_lyr_dec,
1174
                                               UWORD32 u4_mb_idx, UWORD32 u4_num_mbs,
1175
                                               UWORD32 u4_num_mbs_next, UWORD32 u4_tfr_n_mb,
1176
                                               UWORD32 u4_end_of_row)
1177
2.05k
{
1178
2.05k
    WORD32 i, j;
1179
2.05k
    dec_struct_t *ps_dec = &ps_svc_lyr_dec->s_dec;
1180
2.05k
    UWORD32 u1_end_of_row_next;
1181
2.05k
    dec_mb_info_t *ps_cur_mb_info;
1182
2.05k
    dec_svc_mb_info_t *ps_svc_cur_mb_info;
1183
2.05k
    UWORD16 *pu2_res_luma_csbp;
1184
2.05k
    const UWORD32 u1_mbaff = ps_dec->ps_cur_slice->u1_mbaff_frame_flag;
1185
2.05k
    const UWORD32 u1_slice_type = ps_dec->ps_cur_slice->u1_slice_type;
1186
2.05k
    const WORD32 u1_skip_th =
1187
2.05k
        ((u1_slice_type != I_SLICE) ? (ps_dec->u1_B ? B_8x8 : PRED_8x8R0) : -1);
1188
2.05k
    const UWORD32 u1_ipcm_th = ((u1_slice_type != I_SLICE) ? (ps_dec->u1_B ? 23 : 5) : 0);
1189
2.05k
    WORD32 ret = OK;
1190
1191
2.05k
    if(!((0 == ps_svc_lyr_dec->u1_base_res_flag) ||
1192
0
         ((1 == ps_svc_lyr_dec->u1_base_res_flag) &&
1193
0
          (1 == ps_svc_lyr_dec->ps_nal_svc_ext->u1_no_inter_layer_pred_flag))))
1194
0
    {
1195
0
        return NOT_OK;
1196
0
    }
1197
    /* N Mb MC Loop */
1198
10.0k
    for(i = u4_mb_idx; i < u4_num_mbs; i++)
1199
7.99k
    {
1200
7.99k
        ps_cur_mb_info = ps_dec->ps_nmb_info + i;
1201
7.99k
        ps_dec->u4_dma_buf_idx = 0;
1202
7.99k
        ps_dec->u4_pred_info_idx = 0;
1203
1204
        /*Pointer assignment for Residual NNZ */
1205
7.99k
        pu2_res_luma_csbp = ps_svc_lyr_dec->pu2_frm_res_luma_csbp + ps_cur_mb_info->u2_mbx;
1206
7.99k
        pu2_res_luma_csbp += ps_cur_mb_info->u2_mby * ps_svc_lyr_dec->i4_frm_res_luma_csbp_stride;
1207
1208
7.99k
        if(ps_cur_mb_info->u1_mb_type <= u1_skip_th)
1209
7.32k
        {
1210
7.32k
            {
1211
7.32k
                WORD32 pred_cnt = 0;
1212
7.32k
                pred_info_pkd_t *ps_pred_pkd;
1213
7.32k
                UWORD32 u4_pred_info_pkd_idx;
1214
1215
7.32k
                u4_pred_info_pkd_idx = ps_cur_mb_info->u4_pred_info_pkd_idx;
1216
1217
31.0k
                while(pred_cnt < ps_cur_mb_info->u1_num_pred_parts)
1218
23.7k
                {
1219
23.7k
                    ps_pred_pkd = ps_dec->ps_pred_pkd + u4_pred_info_pkd_idx;
1220
1221
23.7k
                    ps_dec->p_form_mb_part_info(ps_pred_pkd, ps_dec, ps_cur_mb_info->u2_mbx,
1222
23.7k
                                                ps_cur_mb_info->u2_mby, (i >> u1_mbaff),
1223
23.7k
                                                ps_cur_mb_info);
1224
23.7k
                    u4_pred_info_pkd_idx++;
1225
23.7k
                    pred_cnt++;
1226
23.7k
                }
1227
7.32k
            }
1228
7.32k
            if(ps_svc_lyr_dec->u1_layer_identifier == TARGET_LAYER)
1229
7.32k
            {
1230
7.32k
                ps_dec->p_motion_compensate(ps_dec, ps_cur_mb_info);
1231
7.32k
            }
1232
7.32k
        }
1233
672
        else if(ps_cur_mb_info->u1_mb_type == MB_SKIP)
1234
464
        {
1235
464
            {
1236
464
                WORD32 pred_cnt = 0;
1237
464
                pred_info_pkd_t *ps_pred_pkd;
1238
464
                UWORD32 u4_pred_info_pkd_idx;
1239
1240
464
                u4_pred_info_pkd_idx = ps_cur_mb_info->u4_pred_info_pkd_idx;
1241
1242
1.07k
                while(pred_cnt < ps_cur_mb_info->u1_num_pred_parts)
1243
609
                {
1244
609
                    ps_pred_pkd = ps_dec->ps_pred_pkd + u4_pred_info_pkd_idx;
1245
1246
609
                    ps_dec->p_form_mb_part_info(ps_pred_pkd, ps_dec, ps_cur_mb_info->u2_mbx,
1247
609
                                                ps_cur_mb_info->u2_mby, (i >> u1_mbaff),
1248
609
                                                ps_cur_mb_info);
1249
1250
609
                    u4_pred_info_pkd_idx++;
1251
609
                    pred_cnt++;
1252
609
                }
1253
464
            }
1254
464
            if(ps_svc_lyr_dec->u1_layer_identifier == TARGET_LAYER)
1255
464
            {
1256
                /* Decode MB skip */
1257
464
                ps_dec->p_motion_compensate(ps_dec, ps_cur_mb_info);
1258
464
            }
1259
1260
464
            *pu2_res_luma_csbp = 0;
1261
464
            ps_svc_lyr_dec->ps_inter_lyr_mb_prms_cur_mb =
1262
464
                ps_svc_lyr_dec->ps_inter_lyr_mb_prms_frm_start + ps_cur_mb_info->u2_mbx +
1263
464
                (ps_svc_lyr_dec->u2_inter_lyr_mb_prms_stride * (ps_cur_mb_info->u2_mby));
1264
464
            ps_svc_lyr_dec->ps_inter_lyr_mb_prms_cur_mb->i1_mb_mode = SVC_INTER_MB;
1265
464
            ps_svc_lyr_dec->ps_inter_lyr_mb_prms_cur_mb->i1_tx_size =
1266
464
                ps_cur_mb_info->u1_tran_form8x8;
1267
464
            ps_svc_lyr_dec->ps_inter_lyr_mb_prms_cur_mb->u2_luma_nnz = 0;
1268
464
            ps_svc_lyr_dec->ps_inter_lyr_mb_prms_cur_mb->u1_chroma_nnz = 0;
1269
464
        }
1270
7.99k
    }
1271
1272
    /* N Mb IQ IT RECON  Loop */
1273
10.0k
    for(j = u4_mb_idx; j < i; j++)
1274
7.99k
    {
1275
7.99k
        ps_cur_mb_info = ps_dec->ps_nmb_info + j;
1276
7.99k
        ps_svc_cur_mb_info = ps_svc_lyr_dec->ps_svc_nmb_info + j;
1277
1278
7.99k
        ps_svc_lyr_dec->ps_inter_lyr_mb_prms_cur_mb =
1279
7.99k
            ps_svc_lyr_dec->ps_inter_lyr_mb_prms_frm_start + ps_cur_mb_info->u2_mbx +
1280
7.99k
            (ps_svc_lyr_dec->u2_inter_lyr_mb_prms_stride * (ps_cur_mb_info->u2_mby));
1281
1282
7.99k
        ps_svc_lyr_dec->ps_inter_lyr_mb_prms_cur_mb->i1_slice_id = (WORD8) ps_dec->u2_cur_slice_num;
1283
1284
        /*Pointer assignment for Residual NNZ */
1285
7.99k
        pu2_res_luma_csbp = ps_svc_lyr_dec->pu2_frm_res_luma_csbp + ps_cur_mb_info->u2_mbx;
1286
7.99k
        pu2_res_luma_csbp += ps_cur_mb_info->u2_mby * ps_svc_lyr_dec->i4_frm_res_luma_csbp_stride;
1287
1288
7.99k
        if(ps_cur_mb_info->u1_mb_type <= u1_skip_th)
1289
7.32k
        {
1290
7.32k
            if(ps_svc_lyr_dec->u1_layer_identifier == TARGET_LAYER)
1291
7.32k
            {
1292
                /* inter intra pred generation */
1293
7.32k
                if(SVCD_FALSE == ps_svc_lyr_dec->u1_dyadic_flag)
1294
446
                {
1295
446
                    ret =
1296
446
                        isvcd_process_ii_mb(ps_svc_lyr_dec, ps_cur_mb_info, ps_svc_cur_mb_info, j);
1297
446
                    if(ret != OK) return ret;
1298
446
                }
1299
7.32k
                if(0 == ps_svc_cur_mb_info->u1_residual_prediction_flag)
1300
268
                {
1301
                    // IT + Recon
1302
268
                    ih264d_process_inter_mb(ps_dec, ps_cur_mb_info, j);
1303
268
                    isvcd_update_inter_mb_inter_layer_info(ps_svc_lyr_dec, ps_cur_mb_info, 0);
1304
268
                    *pu2_res_luma_csbp = ps_cur_mb_info->u2_luma_csbp;
1305
268
                }
1306
7.05k
                else
1307
7.05k
                {
1308
                    // IT + Residual + Recon
1309
7.05k
                    ret = isvcd_process_inter_mb_rsd_pred_target_lyr(ps_svc_lyr_dec, ps_cur_mb_info,
1310
7.05k
                                                                     j, 0, pu2_res_luma_csbp);
1311
7.05k
                    if(ret != OK) return ret;
1312
7.05k
                }
1313
7.32k
            }
1314
0
            else if(ps_svc_lyr_dec->u1_layer_identifier == MEDIAL_ENHANCEMENT_LAYER)
1315
0
            {
1316
0
                if(0 == ps_svc_cur_mb_info->u1_residual_prediction_flag)
1317
0
                {
1318
                    // IT : to be consumed by Target
1319
0
                    ret = isvcd_process_inter_mb_no_rsd_pred_non_target(ps_svc_lyr_dec,
1320
0
                                                                        ps_cur_mb_info, 0);
1321
0
                    *pu2_res_luma_csbp = ps_cur_mb_info->u2_luma_csbp;
1322
0
                    if(ret != OK) return ret;
1323
0
                }
1324
0
                else
1325
0
                {
1326
                    // IT + Residual : to be consumed by target
1327
0
                    ret = isvcd_process_inter_mb_rsd_pred_non_target(ps_svc_lyr_dec, ps_cur_mb_info,
1328
0
                                                                     0, pu2_res_luma_csbp);
1329
0
                    if(ret != OK) return ret;
1330
0
                }
1331
0
            }
1332
0
            else
1333
0
            {
1334
0
                return NOT_OK;
1335
0
            }
1336
7.32k
        }
1337
672
        else if((ps_cur_mb_info->u1_mb_type != MB_SKIP) && (ps_cur_mb_info->u1_mb_type != MB_INFER))
1338
208
        {
1339
208
            if((u1_ipcm_th + 25) != ps_cur_mb_info->u1_mb_type)
1340
175
            {
1341
175
                ps_cur_mb_info->u1_mb_type -= (u1_skip_th + 1);
1342
175
                ih264d_process_intra_mb(ps_dec, ps_cur_mb_info, j);
1343
175
                isvcd_update_intra_mb_inter_layer_info(ps_svc_lyr_dec, ps_cur_mb_info);
1344
175
            }
1345
33
            else
1346
33
            {
1347
33
                isvcd_update_ipcm_mb_inter_layer_info(ps_svc_lyr_dec, ps_cur_mb_info);
1348
33
            }
1349
208
            *pu2_res_luma_csbp = 0;
1350
208
        }
1351
464
        else if(ps_cur_mb_info->u1_mb_type == MB_INFER)
1352
0
        {
1353
            /* inter layer intra prediction : intra upsample, IQ, IT ,deblock */
1354
            /* Intra resample for IBL mode */
1355
0
            ret = isvcd_process_ibl_mb(ps_svc_lyr_dec, ps_cur_mb_info, j, 0);
1356
0
            if(ret != OK) return ret;
1357
0
            ih264d_process_inter_mb(ps_dec, ps_cur_mb_info, j);
1358
0
            isvcd_update_inter_mb_inter_layer_info(ps_svc_lyr_dec, ps_cur_mb_info, 1);
1359
0
            *pu2_res_luma_csbp = ps_cur_mb_info->u2_luma_csbp;
1360
1361
0
            ps_dec->pi1_left_pred_mode[0] = DC;
1362
0
            ps_dec->pi1_left_pred_mode[1] = DC;
1363
0
            ps_dec->pi1_left_pred_mode[2] = DC;
1364
0
            ps_dec->pi1_left_pred_mode[3] = DC;
1365
1366
0
            ps_cur_mb_info->ps_curmb->pi1_intrapredmodes[0] = DC;
1367
0
            ps_cur_mb_info->ps_curmb->pi1_intrapredmodes[1] = DC;
1368
0
            ps_cur_mb_info->ps_curmb->pi1_intrapredmodes[2] = DC;
1369
0
            ps_cur_mb_info->ps_curmb->pi1_intrapredmodes[3] = DC;
1370
1371
0
            isvcd_update_ibl_mb_inter_layer_info(ps_svc_lyr_dec, ps_cur_mb_info);
1372
0
        }
1373
1374
7.99k
        if(ps_svc_lyr_dec->u1_layer_identifier == TARGET_LAYER)
1375
7.99k
        {
1376
7.99k
            if(ps_dec->u4_num_cores < 3)
1377
7.99k
            {
1378
7.99k
                if(ps_dec->u4_app_disable_deblk_frm == 0)
1379
7.99k
                    ps_svc_lyr_dec->pf_svc_compute_bs(ps_svc_lyr_dec, ps_cur_mb_info,
1380
7.99k
                                                      (UWORD16) (j >> u1_mbaff));
1381
7.99k
            }
1382
7.99k
        }
1383
0
        else if(ps_svc_lyr_dec->u1_layer_identifier == MEDIAL_ENHANCEMENT_LAYER)
1384
0
        {
1385
0
            if(ps_dec->u4_num_cores < 3)
1386
0
            {
1387
0
                if(ps_dec->u4_app_disable_deblk_frm == 0)
1388
0
                    ps_svc_lyr_dec->pf_svc_compute_bs(ps_svc_lyr_dec, ps_cur_mb_info,
1389
0
                                                      (UWORD16) (j >> u1_mbaff));
1390
0
            }
1391
0
        }
1392
1393
7.99k
        if(ps_dec->u4_use_intrapred_line_copy)
1394
7.99k
        {
1395
7.99k
            ih264d_copy_intra_pred_line(ps_dec, ps_cur_mb_info, j);
1396
7.99k
        }
1397
7.99k
    }
1398
1399
    /*MB deblocking*/
1400
2.05k
    if(ps_dec->u4_nmb_deblk == 1)
1401
2.05k
    {
1402
2.05k
        UWORD32 u4_wd_y, u4_wd_uv;
1403
2.05k
        tfr_ctxt_t *ps_tfr_cxt = &(ps_dec->s_tran_addrecon);
1404
2.05k
        UWORD8 u1_field_pic_flag = ps_dec->ps_cur_slice->u1_field_pic_flag;
1405
2.05k
        const WORD32 i4_cb_qp_idx_ofst = ps_dec->ps_cur_pps->i1_chroma_qp_index_offset;
1406
2.05k
        const WORD32 i4_cr_qp_idx_ofst = ps_dec->ps_cur_pps->i1_second_chroma_qp_index_offset;
1407
1408
2.05k
        u4_wd_y = ps_dec->u2_frm_wd_y << u1_field_pic_flag;
1409
2.05k
        u4_wd_uv = ps_dec->u2_frm_wd_uv << u1_field_pic_flag;
1410
1411
2.05k
        ps_cur_mb_info = ps_dec->ps_nmb_info + u4_mb_idx;
1412
1413
2.05k
        ps_dec->u4_deblk_mb_x = ps_cur_mb_info->u2_mbx;
1414
2.05k
        ps_dec->u4_deblk_mb_y = ps_cur_mb_info->u2_mby;
1415
1416
10.0k
        for(j = u4_mb_idx; j < i; j++)
1417
7.99k
        {
1418
7.99k
            if(ps_dec->u4_cur_deblk_mb_num > ps_dec->ps_cur_sps->u4_max_mb_addr)
1419
0
            {
1420
0
                return NOT_OK;
1421
0
            }
1422
7.99k
            ih264d_deblock_mb_nonmbaff(ps_dec, ps_tfr_cxt, i4_cb_qp_idx_ofst, i4_cr_qp_idx_ofst,
1423
7.99k
                                       u4_wd_y, u4_wd_uv);
1424
7.99k
        }
1425
2.05k
    }
1426
1427
2.05k
    if(u4_tfr_n_mb)
1428
2.05k
    {
1429
        /****************************************************************/
1430
        /* Check for End Of Row in Next iteration                       */
1431
        /****************************************************************/
1432
2.05k
        u1_end_of_row_next =
1433
2.05k
            u4_num_mbs_next && (u4_num_mbs_next <= (ps_dec->u4_recon_mb_grp >> u1_mbaff));
1434
1435
        /****************************************************************/
1436
        /* Transfer the Following things                                */
1437
        /* N-Mb DeblkParams Data    ( To Ext DeblkParams Buffer )       */
1438
        /* N-Mb Recon Data          ( To Ext Frame Buffer )             */
1439
        /* N-Mb Intrapredline Data  ( Updated Internally)               */
1440
        /* N-Mb MV Data             ( To Ext MV Buffer )                */
1441
        /* N-Mb MVTop/TopRight Data ( To Int MV Top Scratch Buffers)    */
1442
        /****************************************************************/
1443
2.05k
        ih264d_transfer_mb_group_data(ps_dec, u4_num_mbs, u4_end_of_row, u1_end_of_row_next);
1444
2.05k
        ps_dec->u4_num_mbs_prev_nmb = u4_num_mbs;
1445
2.05k
        ps_dec->u4_pred_info_idx = 0;
1446
2.05k
        ps_dec->u4_dma_buf_idx = 0;
1447
2.05k
    }
1448
2.05k
    return OK;
1449
2.05k
}
1450
/*!
1451
 **************************************************************************
1452
 * \if Function name : isvcd_decode_recon_tfr_nmb_base_lyr \endif
1453
 *
1454
 * \brief
1455
 *
1456
 *
1457
 * \return
1458
 *    0 on Success and Error code otherwise
1459
 **************************************************************************
1460
 */
1461
WORD32 isvcd_decode_recon_tfr_nmb_base_lyr(svc_dec_lyr_struct_t *ps_svc_lyr_dec, UWORD32 u1_mb_idx,
1462
                                           UWORD32 u4_num_mbs, UWORD32 u4_num_mbs_next,
1463
                                           UWORD32 u4_tfr_n_mb, UWORD32 u4_end_of_row)
1464
28.1k
{
1465
28.1k
    WORD32 j;
1466
28.1k
    dec_struct_t *ps_dec = &ps_svc_lyr_dec->s_dec;
1467
28.1k
    UWORD32 u1_end_of_row_next;
1468
28.1k
    dec_mb_info_t *ps_cur_mb_info;
1469
28.1k
    const UWORD32 u1_mbaff = ps_dec->ps_cur_slice->u1_mbaff_frame_flag;
1470
28.1k
    const UWORD32 u1_slice_type = ps_dec->ps_cur_slice->u1_slice_type;
1471
28.1k
    const WORD32 u1_skip_th =
1472
28.1k
        ((u1_slice_type != I_SLICE) ? (ps_dec->u1_B ? B_8x8 : PRED_8x8R0) : -1);
1473
28.1k
    const UWORD32 u1_ipcm_th = ((u1_slice_type != I_SLICE) ? (ps_dec->u1_B ? 23 : 5) : 0);
1474
28.1k
    WORD32 ret = OK;
1475
1476
28.1k
    if(1 != ps_svc_lyr_dec->u1_base_res_flag)
1477
0
    {
1478
0
        return NOT_OK;
1479
0
    }
1480
28.1k
    if(ps_svc_lyr_dec->u1_layer_identifier == TARGET_LAYER)
1481
0
    {
1482
0
        return NOT_OK;
1483
0
    }
1484
1485
    /* N Mb IQ IT + Residual Store for Inter / + Recon for Intra Loop */
1486
84.4k
    for(j = u1_mb_idx; j < u4_num_mbs; j++)
1487
56.3k
    {
1488
56.3k
        ps_dec->u4_dma_buf_idx = 0;
1489
56.3k
        ps_dec->u4_pred_info_idx = 0;
1490
56.3k
        ps_cur_mb_info = ps_dec->ps_nmb_info + j;
1491
1492
56.3k
        ps_svc_lyr_dec->ps_inter_lyr_mb_prms_cur_mb =
1493
56.3k
            ps_svc_lyr_dec->ps_inter_lyr_mb_prms_frm_start + ps_cur_mb_info->u2_mbx +
1494
56.3k
            (ps_svc_lyr_dec->u2_inter_lyr_mb_prms_stride * (ps_cur_mb_info->u2_mby));
1495
1496
56.3k
        ps_svc_lyr_dec->ps_inter_lyr_mb_prms_cur_mb->i1_slice_id = (WORD8) ps_dec->u2_cur_slice_num;
1497
1498
56.3k
        if(ps_cur_mb_info->u1_mb_type == MB_SKIP)
1499
42.6k
        {
1500
42.6k
            ps_svc_lyr_dec->ps_inter_lyr_mb_prms_cur_mb->i1_mb_mode = SVC_INTER_MB;
1501
42.6k
            ps_svc_lyr_dec->ps_inter_lyr_mb_prms_cur_mb->i1_tx_size =
1502
42.6k
                ps_cur_mb_info->u1_tran_form8x8;
1503
42.6k
            ps_svc_lyr_dec->ps_inter_lyr_mb_prms_cur_mb->u2_luma_nnz = 0;
1504
42.6k
            ps_svc_lyr_dec->ps_inter_lyr_mb_prms_cur_mb->u1_chroma_nnz = 0;
1505
42.6k
        }
1506
13.7k
        else if(ps_cur_mb_info->u1_mb_type <= u1_skip_th)
1507
8.02k
        {
1508
            /* Only IT : Store Residual (WORD16) for Higher Layers : Base layer*/
1509
8.02k
            ret = isvcd_process_inter_mb_no_rsd_pred_non_target(ps_svc_lyr_dec, ps_cur_mb_info, 0);
1510
8.02k
            if(ret != OK) return ret;
1511
8.02k
        }
1512
5.69k
        else if(ps_cur_mb_info->u1_mb_type != MB_SKIP)
1513
5.69k
        {
1514
5.69k
            if((u1_ipcm_th + 25) != ps_cur_mb_info->u1_mb_type)
1515
5.69k
            {
1516
5.69k
                ps_cur_mb_info->u1_mb_type -= (u1_skip_th + 1);
1517
5.69k
                ih264d_process_intra_mb(ps_dec, ps_cur_mb_info, j);
1518
5.69k
                isvcd_update_intra_mb_inter_layer_info(ps_svc_lyr_dec, ps_cur_mb_info);
1519
5.69k
            }
1520
1
            else
1521
1
            {
1522
1
                isvcd_update_ipcm_mb_inter_layer_info(ps_svc_lyr_dec, ps_cur_mb_info);
1523
1
            }
1524
5.69k
        }
1525
1526
56.3k
        if(ps_dec->u4_use_intrapred_line_copy)
1527
56.3k
        {
1528
56.3k
            ih264d_copy_intra_pred_line(ps_dec, ps_cur_mb_info, j);
1529
56.3k
        }
1530
56.3k
    }
1531
1532
    /*MB deblocking*/
1533
28.1k
    if(ps_dec->u4_nmb_deblk == 1)
1534
28.1k
    {
1535
28.1k
        UWORD32 u4_wd_y, u4_wd_uv;
1536
28.1k
        tfr_ctxt_t *ps_tfr_cxt = &(ps_dec->s_tran_addrecon);
1537
28.1k
        UWORD8 u1_field_pic_flag = ps_dec->ps_cur_slice->u1_field_pic_flag;
1538
28.1k
        const WORD32 i4_cb_qp_idx_ofst = ps_dec->ps_cur_pps->i1_chroma_qp_index_offset;
1539
28.1k
        const WORD32 i4_cr_qp_idx_ofst = ps_dec->ps_cur_pps->i1_second_chroma_qp_index_offset;
1540
1541
28.1k
        u4_wd_y = ps_dec->u2_frm_wd_y << u1_field_pic_flag;
1542
28.1k
        u4_wd_uv = ps_dec->u2_frm_wd_uv << u1_field_pic_flag;
1543
1544
28.1k
        ps_cur_mb_info = ps_dec->ps_nmb_info + u1_mb_idx;
1545
1546
28.1k
        ps_dec->u4_deblk_mb_x = ps_cur_mb_info->u2_mbx;
1547
28.1k
        ps_dec->u4_deblk_mb_y = ps_cur_mb_info->u2_mby;
1548
1549
84.4k
        for(j = u1_mb_idx; j < u4_num_mbs; j++)
1550
56.3k
        {
1551
            /* IN SVC base layers only intra MB's Need to be deblocked*/
1552
56.3k
            deblk_mb_t *ps_top_mb, *ps_left_mb, *ps_cur_mb;
1553
56.3k
            ps_cur_mb = ps_dec->ps_cur_deblk_mb;
1554
56.3k
            if(!(ps_cur_mb->u1_deblocking_mode & MB_DISABLE_FILTERING))
1555
5.69k
            {
1556
5.69k
                if(ps_dec->u4_deblk_mb_x)
1557
2.89k
                {
1558
2.89k
                    ps_left_mb = ps_cur_mb - 1;
1559
2.89k
                }
1560
2.79k
                else
1561
2.79k
                {
1562
2.79k
                    ps_left_mb = NULL;
1563
2.79k
                }
1564
5.69k
                if(ps_dec->u4_deblk_mb_y != 0)
1565
5.42k
                {
1566
5.42k
                    ps_top_mb = ps_cur_mb - (ps_dec->u2_frm_wd_in_mbs);
1567
5.42k
                }
1568
262
                else
1569
262
                {
1570
262
                    ps_top_mb = NULL;
1571
262
                }
1572
1573
5.69k
                if(ps_cur_mb->u1_deblocking_mode & MB_DISABLE_LEFT_EDGE) ps_left_mb = NULL;
1574
5.69k
                if(ps_cur_mb->u1_deblocking_mode & MB_DISABLE_TOP_EDGE) ps_top_mb = NULL;
1575
1576
                /* Top Horizontal Edge*/
1577
5.69k
                if(NULL != ps_top_mb)
1578
5.42k
                {
1579
5.42k
                    if(!(ps_top_mb->u1_mb_type & D_INTRA_MB))
1580
1.19k
                    {
1581
1.19k
                        ps_cur_mb->u4_bs_table[0] = 0;
1582
1.19k
                    }
1583
5.42k
                }
1584
262
                else
1585
262
                {
1586
262
                    ps_cur_mb->u4_bs_table[0] = 0;
1587
262
                }
1588
1589
                /* Left Vertical Edge*/
1590
5.69k
                if(NULL != ps_left_mb)
1591
2.89k
                {
1592
2.89k
                    if(!(ps_left_mb->u1_mb_type & D_INTRA_MB))
1593
671
                    {
1594
671
                        ps_cur_mb->u4_bs_table[4] = 0;
1595
671
                    }
1596
2.89k
                }
1597
2.79k
                else
1598
2.79k
                {
1599
2.79k
                    ps_cur_mb->u4_bs_table[4] = 0;
1600
2.79k
                }
1601
5.69k
            }
1602
1603
56.3k
            if(ps_dec->u4_cur_deblk_mb_num > ps_dec->ps_cur_sps->u4_max_mb_addr)
1604
0
            {
1605
0
                return NOT_OK;
1606
0
            }
1607
1608
56.3k
            ih264d_deblock_mb_nonmbaff(ps_dec, ps_tfr_cxt, i4_cb_qp_idx_ofst, i4_cr_qp_idx_ofst,
1609
56.3k
                                       u4_wd_y, u4_wd_uv);
1610
56.3k
        }
1611
28.1k
    }
1612
1613
28.1k
    if(u4_tfr_n_mb)
1614
28.1k
    {
1615
        /****************************************************************/
1616
        /* Check for End Of Row in Next iteration                       */
1617
        /****************************************************************/
1618
28.1k
        u1_end_of_row_next =
1619
28.1k
            u4_num_mbs_next && (u4_num_mbs_next <= (ps_dec->u4_recon_mb_grp >> u1_mbaff));
1620
1621
        /****************************************************************/
1622
        /* Transfer the Following things                                */
1623
        /* N-Mb DeblkParams Data    ( To Ext DeblkParams Buffer )       */
1624
        /* N-Mb Recon Data          ( To Ext Frame Buffer )             */
1625
        /* N-Mb Intrapredline Data  ( Updated Internally)               */
1626
        /* N-Mb MV Data             ( To Ext MV Buffer )                */
1627
        /* N-Mb MVTop/TopRight Data ( To Int MV Top Scratch Buffers)    */
1628
        /****************************************************************/
1629
28.1k
        ih264d_transfer_mb_group_data(ps_dec, u4_num_mbs, u4_end_of_row, u1_end_of_row_next);
1630
28.1k
        ps_dec->u4_num_mbs_prev_nmb = u4_num_mbs;
1631
28.1k
        ps_dec->u4_pred_info_idx = 0;
1632
28.1k
        ps_dec->u4_dma_buf_idx = 0;
1633
28.1k
    }
1634
28.1k
    return OK;
1635
28.1k
}
1636
/*!
1637
**************************************************************************
1638
* \if Function name : isvcd_process_ibl_mb \endif
1639
*
1640
* \brief
1641
*    This function decodes an ibl mb
1642
*
1643
*
1644
* \return
1645
*
1646
**************************************************************************
1647
*/
1648
WORD32 isvcd_process_ibl_mb(svc_dec_lyr_struct_t *ps_svc_lyr_dec, dec_mb_info_t *ps_cur_mb_info,
1649
                            UWORD32 u4_mb_num, UWORD8 u1_inter_intra_mode)
1650
421
{
1651
421
    dec_struct_t *ps_dec = &ps_svc_lyr_dec->s_dec;
1652
421
    intra_sampling_ctxt_t *ps_ctxt;
1653
421
    svc_dec_lyr_struct_t *ps_svc_dec_ref_layer;
1654
421
    pic_buffer_t *ps_frame_buf = ps_dec->ps_cur_pic;
1655
421
    pic_buffer_t *ps_frame_buf_ref_layer;
1656
421
    intra_samp_lyr_ctxt *ps_lyr_ctxt;
1657
421
    mem_element_t s_ref_mb_mode = {0};
1658
421
    mem_element_t s_inp_luma = {0};
1659
421
    mem_element_t s_inp_chroma = {0};
1660
421
    mem_element_t s_out_luma = {0};
1661
421
    mem_element_t s_out_chroma = {0};
1662
421
    WORD32 i4_ref_x_luma, i4_ref_y_luma, i4_luma_incr = 0;
1663
421
    WORD32 i4_ref_x_chroma, i4_ref_y_chroma, i4_chroma_incr = 0;
1664
421
    UWORD32 u4_cur_y_stride, u4_cur_uv_stride;
1665
421
    UWORD32 u4_ref_y_stride, u4_ref_uv_stride;
1666
421
    WORD32 i4_ref_luma_instra_sample_correction_offset = 0;
1667
421
    WORD32 i4_ref_chroma_instra_sample_correction_offset = 0;
1668
421
    ref_mb_map_t *ps_x_off_len_luma;
1669
421
    ref_mb_map_t *ps_y_off_len_luma;
1670
421
    ref_mb_map_t *ps_x_off_len_chroma;
1671
421
    ref_mb_map_t *ps_y_off_len_chroma;
1672
421
    mb_coord_t s_mb_coord = {0};
1673
421
    WORD32 ret = OK;
1674
421
    UNUSED(u4_mb_num);
1675
1676
421
    ps_ctxt = (intra_sampling_ctxt_t *) ps_svc_lyr_dec->pv_intra_sample_ctxt;
1677
421
    ps_svc_dec_ref_layer = ps_svc_lyr_dec->ps_dec_svc_ref_layer;
1678
1679
421
    ps_lyr_ctxt = &ps_ctxt->as_res_lyrs[ps_ctxt->i4_res_lyr_id];
1680
421
    u4_cur_y_stride = ps_dec->u2_frm_wd_y;
1681
421
    u4_cur_uv_stride = ps_dec->u2_frm_wd_uv;
1682
421
    u4_ref_y_stride = ps_svc_dec_ref_layer->s_dec.u2_frm_wd_y;
1683
421
    u4_ref_uv_stride = ps_svc_dec_ref_layer->s_dec.u2_frm_wd_uv;
1684
1685
421
    ps_frame_buf_ref_layer = ps_svc_dec_ref_layer->s_dec.ps_cur_pic;
1686
421
    if(0 == u1_inter_intra_mode)
1687
123
    {
1688
123
        s_out_luma.pv_buffer = ps_frame_buf->pu1_buf1 + (ps_cur_mb_info->u2_mbx << 4) +
1689
123
                               (u4_cur_y_stride * (ps_cur_mb_info->u2_mby << 4));
1690
123
        s_out_luma.i4_element_size = 1;
1691
123
        s_out_luma.i4_num_element_stride = u4_cur_y_stride;
1692
1693
123
        s_out_chroma.pv_buffer = ps_frame_buf->pu1_buf2 +
1694
123
                                 (ps_cur_mb_info->u2_mbx << 3) * YUV420SP_FACTOR +
1695
123
                                 (u4_cur_uv_stride * (ps_cur_mb_info->u2_mby << 3));
1696
123
        s_out_chroma.i4_element_size = 1;
1697
123
        s_out_chroma.i4_num_element_stride = u4_cur_uv_stride;
1698
123
    }
1699
298
    else
1700
298
    {
1701
298
        if(SVCD_TRUE == ps_svc_lyr_dec->s_res_prms.u1_dyadic_flag)
1702
0
        {
1703
0
            return NOT_OK;
1704
0
        }
1705
1706
298
        s_out_luma.pv_buffer = ps_svc_lyr_dec->pu1_ii_resamp_buffer_luma;
1707
298
        s_out_luma.i4_element_size = 1;
1708
298
        s_out_luma.i4_num_element_stride = MB_SIZE;
1709
1710
298
        s_out_chroma.pv_buffer = ps_svc_lyr_dec->pu1_ii_resamp_buffer_chroma;
1711
298
        s_out_chroma.i4_element_size = 1;
1712
298
        s_out_chroma.i4_num_element_stride = MB_SIZE;
1713
298
    }
1714
1715
    /* get the projected locations buffer pointers */
1716
421
    {
1717
421
        intra_samp_map_ctxt_t *ps_luma_map, *ps_chroma_map;
1718
1719
421
        ps_luma_map = &ps_lyr_ctxt->s_luma_map_ctxt;
1720
421
        ps_chroma_map = &ps_lyr_ctxt->s_chroma_map_ctxt;
1721
1722
421
        ps_x_off_len_luma = ps_luma_map->ps_x_offset_length;
1723
421
        ps_y_off_len_luma = ps_luma_map->ps_y_offset_length;
1724
421
        ps_x_off_len_chroma = ps_chroma_map->ps_x_offset_length;
1725
421
        ps_y_off_len_chroma = ps_chroma_map->ps_y_offset_length;
1726
421
    }
1727
421
    i4_ref_x_luma = ps_svc_lyr_dec->ps_intsam_luma_map_horz[ps_cur_mb_info->u2_mbx].i2_offset;
1728
421
    i4_ref_y_luma = ps_svc_lyr_dec->ps_intsam_luma_map_vert[ps_cur_mb_info->u2_mby].i2_offset;
1729
1730
421
    i4_luma_incr = ps_x_off_len_luma[ps_cur_mb_info->u2_mbx].i2_offset - i4_ref_x_luma;
1731
421
    i4_luma_incr +=
1732
421
        (ps_y_off_len_luma[ps_cur_mb_info->u2_mby].i2_offset - i4_ref_y_luma) * u4_ref_y_stride;
1733
1734
421
    i4_ref_x_chroma = ps_svc_lyr_dec->ps_intsam_chroma_map_horz[ps_cur_mb_info->u2_mbx].i2_offset;
1735
421
    i4_ref_y_chroma = ps_svc_lyr_dec->ps_intsam_chroma_map_vert[ps_cur_mb_info->u2_mby].i2_offset;
1736
1737
421
    i4_chroma_incr = ps_x_off_len_chroma[ps_cur_mb_info->u2_mbx].i2_offset - i4_ref_x_chroma;
1738
421
    i4_chroma_incr <<= 1;
1739
421
    i4_chroma_incr += (ps_y_off_len_chroma[ps_cur_mb_info->u2_mby].i2_offset - i4_ref_y_chroma) *
1740
421
                      u4_ref_uv_stride;
1741
421
    if(SVCD_FALSE == ps_svc_lyr_dec->s_res_prms.u1_dyadic_flag)
1742
421
    {
1743
421
        i4_ref_x_luma = CLIP3(0, (ps_svc_dec_ref_layer->s_dec.u2_frm_wd_y - 1), i4_ref_x_luma);
1744
421
        i4_ref_y_luma = CLIP3(0, (ps_svc_dec_ref_layer->s_dec.u2_frm_ht_y - 1), i4_ref_y_luma);
1745
421
    }
1746
1747
421
    i4_ref_luma_instra_sample_correction_offset =
1748
421
        i4_ref_x_luma + (i4_ref_y_luma) * (WORD32) u4_ref_y_stride;
1749
1750
421
    s_inp_luma.pv_buffer = ps_frame_buf_ref_layer->pu1_buf1 + i4_luma_incr +
1751
421
                           i4_ref_luma_instra_sample_correction_offset;
1752
421
    s_inp_luma.i4_element_size = 1;
1753
421
    s_inp_luma.i4_num_element_stride = u4_ref_y_stride;
1754
1755
421
    if(SVCD_FALSE == ps_svc_lyr_dec->s_res_prms.u1_dyadic_flag)
1756
421
    {
1757
421
        i4_ref_x_chroma = CLIP3(0, (ps_svc_dec_ref_layer->s_dec.u2_frm_wd_uv - 1), i4_ref_x_chroma);
1758
421
        i4_ref_y_chroma = CLIP3(0, (ps_svc_dec_ref_layer->s_dec.u2_frm_ht_uv - 1), i4_ref_y_chroma);
1759
421
    }
1760
421
    i4_ref_chroma_instra_sample_correction_offset =
1761
421
        (i4_ref_x_chroma << 1) + (i4_ref_y_chroma) * (WORD32) u4_ref_uv_stride;
1762
1763
421
    s_inp_chroma.pv_buffer = ps_frame_buf_ref_layer->pu1_buf2 + i4_chroma_incr +
1764
421
                             i4_ref_chroma_instra_sample_correction_offset;
1765
421
    s_inp_chroma.i4_element_size = 1;
1766
421
    s_inp_chroma.i4_num_element_stride = u4_ref_uv_stride;
1767
1768
421
    s_ref_mb_mode.pv_buffer = ps_svc_dec_ref_layer->ps_inter_lyr_mb_prms_frm_start;
1769
421
    s_ref_mb_mode.i4_element_size = sizeof(inter_lyr_mb_prms_t);
1770
421
    s_ref_mb_mode.i4_num_element_stride = ps_svc_dec_ref_layer->u2_inter_lyr_mb_prms_stride;
1771
1772
421
    s_mb_coord.u2_mb_x = ps_cur_mb_info->u2_mbx;
1773
421
    s_mb_coord.u2_mb_y = ps_cur_mb_info->u2_mby;
1774
1775
421
    if(SVCD_TRUE == ps_svc_lyr_dec->s_res_prms.u1_dyadic_flag)
1776
0
    {
1777
0
        ret = isvcd_intra_resamp_mb_dyadic(ps_ctxt, &s_inp_luma, &s_inp_chroma, &s_ref_mb_mode,
1778
0
                                           &s_out_luma, &s_out_chroma, &s_mb_coord, ps_svc_lyr_dec);
1779
0
    }
1780
421
    else
1781
421
    {
1782
421
        ret = isvcd_intra_resamp_mb(ps_ctxt, &s_inp_luma, &s_inp_chroma, &s_ref_mb_mode,
1783
421
                                    &s_out_luma, &s_out_chroma, &s_mb_coord);
1784
421
    }
1785
421
    if(OK != ret) return ret;
1786
421
    return OK;
1787
421
}
1788
/*!
1789
**************************************************************************
1790
* \if Function name : isvcd_process_residual_resample_mb \endif
1791
*
1792
* \brief
1793
*    This function decodes a residual resample mb
1794
*
1795
*
1796
* \return
1797
*
1798
**************************************************************************
1799
*/
1800
WORD32 isvcd_process_residual_resample_mb(svc_dec_lyr_struct_t *ps_svc_lyr_dec,
1801
                                          dec_mb_info_t *ps_cur_mb_info)
1802
19.2k
{
1803
19.2k
    residual_sampling_ctxt_t *ps_ctxt;
1804
19.2k
    svc_dec_lyr_struct_t *ps_svc_dec_ref_layer;
1805
19.2k
    res_lyr_ctxt *ps_lyr_ctxt;
1806
19.2k
    mem_element_t s_ref_mb_mode = {0};
1807
19.2k
    mem_element_t s_inp_luma = {0};
1808
19.2k
    mem_element_t s_inp_chroma = {0};
1809
19.2k
    mem_element_t s_out_luma = {0};
1810
19.2k
    mem_element_t s_out_chroma = {0};
1811
1812
    /* projected locations pointer */
1813
19.2k
    ref_mb_map_t *ps_x_off_len_luma;
1814
19.2k
    ref_mb_map_t *ps_y_off_len_luma;
1815
19.2k
    ref_mb_map_t *ps_x_off_len_chroma;
1816
19.2k
    ref_mb_map_t *ps_y_off_len_chroma;
1817
19.2k
    WORD32 i4_ref_x_luma, i4_ref_y_luma;
1818
19.2k
    WORD32 i4_ref_x_chroma, i4_ref_y_chroma;
1819
19.2k
    WORD32 i4_ref_luma_ressam_correction_offset = 0;
1820
19.2k
    WORD32 i4_ref_chroma_ressam_correction_offset = 0;
1821
19.2k
    WORD32 i4_inp_luma_stride, i4_inp_chroma_stride;
1822
19.2k
    WORD32 i4_out_luma_stride, i4_out_chroma_stride;
1823
19.2k
    WORD32 i4_inp_luma_offset = 0, i4_inp_chroma_offset = 0;
1824
19.2k
    WORD32 ret;
1825
1826
19.2k
    ps_svc_dec_ref_layer = ps_svc_lyr_dec->ps_dec_svc_ref_layer;
1827
19.2k
    ps_ctxt = (residual_sampling_ctxt_t *) ps_svc_lyr_dec->pv_residual_sample_ctxt;
1828
19.2k
    ps_lyr_ctxt = &ps_ctxt->as_res_lyrs[ps_ctxt->i4_res_lyr_id];
1829
1830
19.2k
    i4_inp_luma_stride = ps_svc_dec_ref_layer->u2_residual_resample_luma_stride;
1831
19.2k
    i4_inp_chroma_stride = ps_svc_dec_ref_layer->u2_residual_resample_chroma_stride;
1832
19.2k
    i4_out_luma_stride = ps_svc_lyr_dec->u2_residual_resample_luma_stride;
1833
19.2k
    i4_out_chroma_stride = ps_svc_lyr_dec->u2_residual_resample_chroma_stride;
1834
1835
19.2k
    {
1836
19.2k
        residual_samp_map_ctxt_t *ps_luma_map, *ps_chroma_map;
1837
1838
19.2k
        ps_luma_map = &ps_lyr_ctxt->s_luma_map_ctxt;
1839
19.2k
        ps_chroma_map = &ps_lyr_ctxt->s_chroma_map_ctxt;
1840
19.2k
        ps_x_off_len_luma = ps_luma_map->ps_x_offset_length;
1841
19.2k
        ps_y_off_len_luma = ps_luma_map->ps_y_offset_length;
1842
19.2k
        ps_x_off_len_chroma = ps_chroma_map->ps_x_offset_length;
1843
19.2k
        ps_y_off_len_chroma = ps_chroma_map->ps_y_offset_length;
1844
19.2k
    }
1845
19.2k
    i4_ref_x_luma = ps_svc_lyr_dec->ps_ressam_luma_map_horz[ps_cur_mb_info->u2_mbx].i2_offset;
1846
19.2k
    i4_ref_y_luma = ps_svc_lyr_dec->ps_ressam_luma_map_vert[ps_cur_mb_info->u2_mby].i2_offset;
1847
1848
19.2k
    i4_ref_x_chroma = ps_svc_lyr_dec->ps_ressam_chroma_map_horz[ps_cur_mb_info->u2_mbx].i2_offset;
1849
19.2k
    i4_ref_y_chroma = ps_svc_lyr_dec->ps_ressam_chroma_map_vert[ps_cur_mb_info->u2_mby].i2_offset;
1850
1851
19.2k
    i4_ref_x_luma = CLIP3(0, (ps_lyr_ctxt->i4_ref_width - 1), i4_ref_x_luma);
1852
19.2k
    i4_ref_y_luma = CLIP3(0, (ps_lyr_ctxt->i4_ref_height - 1), i4_ref_y_luma);
1853
19.2k
    i4_ref_x_chroma = CLIP3(0, ((ps_lyr_ctxt->i4_ref_width >> 1) - 1), i4_ref_x_chroma);
1854
19.2k
    i4_ref_y_chroma = CLIP3(0, ((ps_lyr_ctxt->i4_ref_height >> 1) - 1), i4_ref_y_chroma);
1855
1856
19.2k
    {
1857
19.2k
        WORD32 i4_offset_x, i4_offset_y;
1858
1859
19.2k
        i4_offset_x = ps_x_off_len_luma[ps_cur_mb_info->u2_mbx].i2_offset;
1860
19.2k
        i4_offset_y = ps_y_off_len_luma[ps_cur_mb_info->u2_mby].i2_offset;
1861
1862
        /* check for offsets inside frame dimensions */
1863
19.2k
        if(0 <= i4_offset_x)
1864
14.8k
        {
1865
            /* validity of pointer passed */
1866
14.8k
            if(!(i4_offset_x >= i4_ref_x_luma))
1867
0
            {
1868
0
                return NOT_OK;
1869
0
            }
1870
14.8k
            i4_inp_luma_offset += (i4_offset_x - i4_ref_x_luma);
1871
14.8k
        }
1872
1873
19.2k
        if(0 <= i4_offset_y)
1874
17.7k
        {
1875
            /* validity of pointer passed */
1876
17.7k
            if(!(i4_offset_y >= i4_ref_y_luma))
1877
0
            {
1878
0
                return NOT_OK;
1879
0
            }
1880
17.7k
            i4_inp_luma_offset += (i4_offset_y - i4_ref_y_luma) * i4_inp_luma_stride;
1881
17.7k
        }
1882
1883
19.2k
        i4_offset_x = ps_x_off_len_chroma[ps_cur_mb_info->u2_mbx].i2_offset;
1884
19.2k
        i4_offset_y = ps_y_off_len_chroma[ps_cur_mb_info->u2_mby].i2_offset;
1885
1886
        /* check for offsets inside frame dimensions */
1887
19.2k
        if(0 <= i4_offset_x)
1888
14.8k
        {
1889
            /* validity of pointer passed */
1890
14.8k
            if(!(i4_offset_x >= i4_ref_x_chroma))
1891
0
            {
1892
0
                return NOT_OK;
1893
0
            }
1894
14.8k
            i4_inp_chroma_offset += (i4_offset_x - i4_ref_x_chroma) << 1;
1895
14.8k
        }
1896
1897
19.2k
        if(0 <= i4_offset_y)
1898
17.7k
        {
1899
            /* validity of pointer passed */
1900
17.7k
            if(!(i4_offset_y >= i4_ref_y_chroma))
1901
0
            {
1902
0
                return NOT_OK;
1903
0
            }
1904
17.7k
            i4_inp_chroma_offset += (i4_offset_y - i4_ref_y_chroma) * (i4_inp_chroma_stride << 1);
1905
17.7k
        }
1906
19.2k
    }
1907
1908
19.2k
    i4_ref_luma_ressam_correction_offset = i4_ref_x_luma + (i4_ref_y_luma) *i4_inp_luma_stride;
1909
1910
19.2k
    s_inp_luma.pv_buffer = ps_svc_dec_ref_layer->pi2_il_residual_resample_mb_luma_frm_start +
1911
19.2k
                           i4_inp_luma_offset + i4_ref_luma_ressam_correction_offset;
1912
19.2k
    s_inp_luma.i4_element_size = 1;
1913
19.2k
    s_inp_luma.i4_num_element_stride = i4_inp_luma_stride;
1914
1915
19.2k
    i4_ref_chroma_ressam_correction_offset =
1916
19.2k
        (i4_ref_x_chroma << 1) + (i4_ref_y_chroma) *i4_inp_chroma_stride;
1917
1918
19.2k
    s_inp_chroma.pv_buffer = ps_svc_dec_ref_layer->pi2_il_residual_resample_mb_chroma_frm_start +
1919
19.2k
                             i4_inp_chroma_offset + i4_ref_chroma_ressam_correction_offset;
1920
19.2k
    s_inp_chroma.i4_element_size = 1;
1921
19.2k
    s_inp_chroma.i4_num_element_stride = i4_inp_luma_stride;
1922
1923
19.2k
    s_ref_mb_mode.pv_buffer = ps_svc_dec_ref_layer->ps_inter_lyr_mb_prms_frm_start;
1924
19.2k
    s_ref_mb_mode.i4_element_size = sizeof(inter_lyr_mb_prms_t);
1925
19.2k
    s_ref_mb_mode.i4_num_element_stride = ps_svc_dec_ref_layer->u2_inter_lyr_mb_prms_stride;
1926
1927
19.2k
    s_out_luma.i4_element_size = 1;
1928
19.2k
    s_out_luma.pv_buffer =
1929
19.2k
        ps_svc_lyr_dec->pi2_il_residual_resample_mb_luma_frm_start +
1930
19.2k
        ((ps_cur_mb_info->u2_mbx << 4) +
1931
19.2k
         (i4_out_luma_stride * (ps_cur_mb_info->u2_mby << 4)) * s_out_luma.i4_element_size);
1932
1933
19.2k
    s_out_luma.i4_num_element_stride = i4_out_luma_stride;
1934
1935
19.2k
    s_out_chroma.i4_element_size = 1;
1936
19.2k
    s_out_chroma.pv_buffer =
1937
19.2k
        ps_svc_lyr_dec->pi2_il_residual_resample_mb_chroma_frm_start +
1938
19.2k
        ((ps_cur_mb_info->u2_mbx << 4) +
1939
19.2k
         (i4_out_chroma_stride * (ps_cur_mb_info->u2_mby << 3)) * s_out_chroma.i4_element_size);
1940
19.2k
    s_out_chroma.i4_num_element_stride = i4_out_chroma_stride;
1941
1942
19.2k
    ret = ps_lyr_ctxt->pf_residual_samp_mb(ps_ctxt, &s_inp_luma, &s_inp_chroma, &s_ref_mb_mode,
1943
19.2k
                                           &s_out_luma, &s_out_chroma, ps_cur_mb_info->u2_mbx,
1944
19.2k
                                           ps_cur_mb_info->u2_mby);
1945
19.2k
    if(ret != OK)
1946
0
    {
1947
0
        return ret;
1948
0
    }
1949
19.2k
    return OK;
1950
19.2k
}
1951
1952
/*!
1953
 **************************************************************************
1954
 * \if Function name : isvcd_process_inter_mb_rsd_pred_target_lyr \endif
1955
 *
1956
 * \brief IT+ Residual + Recon
1957
 *    This function decodes an Inter MB.
1958
 *
1959
 *
1960
 * \return
1961
 *    0 on Success and Error code otherwise
1962
 **************************************************************************
1963
 */
1964
WORD32 isvcd_process_inter_mb_rsd_pred_target_lyr(svc_dec_lyr_struct_t *ps_svc_lyr_dec,
1965
                                                  dec_mb_info_t *ps_cur_mb_info, UWORD32 u4_mb_num,
1966
                                                  UWORD8 u1_inference_mode,
1967
                                                  UWORD16 *pu2_res_luma_csbp)
1968
19.2k
{
1969
19.2k
    UWORD8 *pu1_rec_y, *pu1_rec_u;
1970
19.2k
    dec_struct_t *ps_dec = &ps_svc_lyr_dec->s_dec;
1971
19.2k
    UWORD32 ui_rec_width, u4_recwidth_cr;
1972
19.2k
    UWORD16 u2_luma_stride, u2_chroma_stride;
1973
19.2k
    WORD16 *pi2_y_coeff, *pi2_luma_res_ptr, *pi2_chroma_res_ptr;
1974
19.2k
    UWORD32 u1_mb_field_decoding_flag;
1975
19.2k
    const UWORD8 u1_mbaff = ps_dec->ps_cur_slice->u1_mbaff_frame_flag;
1976
19.2k
    UWORD32 uc_botMb;
1977
19.2k
    UWORD32 u4_num_pmbair;
1978
19.2k
    tfr_ctxt_t *ps_frame_buf = ps_dec->ps_frame_buf_ip_recon;
1979
19.2k
    UWORD32 u4_luma_dc_only_csbp = 0;
1980
19.2k
    UWORD32 u4_luma_dc_only_cbp = 0;
1981
19.2k
    UWORD16 u2_res_luma_csbp = 0;
1982
19.2k
    WORD32 ret;
1983
1984
19.2k
    if(0 != ps_dec->ps_cur_slice->u1_mbaff_frame_flag)
1985
0
    {
1986
0
        return NOT_OK;
1987
0
    }
1988
19.2k
    uc_botMb = 1 - ps_cur_mb_info->u1_topmb;
1989
19.2k
    u4_num_pmbair = (u4_mb_num >> u1_mbaff);
1990
19.2k
    u1_mb_field_decoding_flag = ps_cur_mb_info->u1_mb_field_decodingflag;
1991
1992
19.2k
    pu1_rec_y = ps_frame_buf->pu1_dest_y + (u4_num_pmbair << 4);
1993
19.2k
    pu1_rec_u = ps_frame_buf->pu1_dest_u + (u4_num_pmbair << 3) * YUV420SP_FACTOR;
1994
19.2k
    ui_rec_width = ps_dec->u2_frm_wd_y << u1_mb_field_decoding_flag;
1995
19.2k
    u4_recwidth_cr = ps_dec->u2_frm_wd_uv << u1_mb_field_decoding_flag;
1996
1997
19.2k
    u2_luma_stride = ps_svc_lyr_dec->u2_residual_resample_luma_stride;
1998
19.2k
    pi2_luma_res_ptr = ps_svc_lyr_dec->pi2_il_residual_resample_mb_luma_frm_start +
1999
19.2k
                       (ps_cur_mb_info->u2_mbx << 4) +
2000
19.2k
                       ((ps_cur_mb_info->u2_mby << 4) * u2_luma_stride);
2001
2002
19.2k
    u2_chroma_stride = ps_svc_lyr_dec->u2_residual_resample_chroma_stride;
2003
19.2k
    pi2_chroma_res_ptr = ps_svc_lyr_dec->pi2_il_residual_resample_mb_chroma_frm_start +
2004
19.2k
                         (ps_cur_mb_info->u2_mbx << 4) +
2005
19.2k
                         ((ps_cur_mb_info->u2_mby << 3) * u2_chroma_stride);
2006
2007
19.2k
    ret = isvcd_process_residual_resample_mb(ps_svc_lyr_dec, ps_cur_mb_info);
2008
19.2k
    if(ret != OK)
2009
0
    {
2010
0
        return ret;
2011
0
    }
2012
19.2k
    if(u1_mbaff)
2013
0
    {
2014
0
        if(uc_botMb)
2015
0
        {
2016
0
            pu1_rec_y += (u1_mb_field_decoding_flag ? (ui_rec_width >> 1) : (ui_rec_width << 4));
2017
0
            pu1_rec_u +=
2018
0
                (u1_mb_field_decoding_flag ? (u4_recwidth_cr >> 1) : (u4_recwidth_cr << 3));
2019
0
        }
2020
0
    }
2021
2022
19.2k
    if(!ps_cur_mb_info->u1_tran_form8x8)
2023
3.63k
    {
2024
3.63k
        u4_luma_dc_only_csbp = ih264d_unpack_luma_coeff4x4_mb(ps_dec, ps_cur_mb_info, 0);
2025
3.63k
    }
2026
15.6k
    else
2027
15.6k
    {
2028
15.6k
        if(!ps_dec->ps_cur_pps->u1_entropy_coding_mode)
2029
5
        {
2030
5
            u4_luma_dc_only_cbp = ih264d_unpack_luma_coeff4x4_mb(ps_dec, ps_cur_mb_info, 0);
2031
5
        }
2032
15.6k
        else
2033
15.6k
        {
2034
15.6k
            u4_luma_dc_only_cbp = ih264d_unpack_luma_coeff8x8_mb(ps_dec, ps_cur_mb_info);
2035
15.6k
        }
2036
15.6k
    }
2037
2038
19.2k
    *pu2_res_luma_csbp = 0;
2039
19.2k
    pi2_y_coeff = ps_dec->pi2_coeff_data;
2040
2041
    /* Inverse Transform and Reconstruction */
2042
19.2k
    if(ps_cur_mb_info->u1_cbp & 0x0f)
2043
18.4k
    {
2044
18.4k
        if(!ps_cur_mb_info->u1_tran_form8x8)
2045
2.80k
        {
2046
2.80k
            UWORD32 i;
2047
2.80k
            WORD16 ai2_tmp[16] = {0};
2048
47.6k
            for(i = 0; i < 16; i++)
2049
44.8k
            {
2050
44.8k
                if(CHECKBIT(ps_cur_mb_info->u2_luma_csbp, i))
2051
28.1k
                {
2052
28.1k
                    WORD16 *pi2_level = pi2_y_coeff + (i << 4);
2053
28.1k
                    UWORD8 *pu1_pred_sblk =
2054
28.1k
                        pu1_rec_y + ((i & 0x3) * BLK_SIZE) + (i >> 2) * (ui_rec_width << 2);
2055
28.1k
                    WORD16 *pi2_out = pi2_luma_res_ptr + ((i & 0x3) * BLK_SIZE) +
2056
28.1k
                                      (i >> 2) * (u2_luma_stride << 2);
2057
28.1k
                    PROFILE_DISABLE_IQ_IT_RECON()
2058
28.1k
                    {
2059
28.1k
                        if(CHECKBIT(u4_luma_dc_only_csbp, i))
2060
325
                        {
2061
325
                            u2_res_luma_csbp =
2062
325
                                ps_svc_lyr_dec->pf_iquant_itrans_residual_recon_luma_4x4_dc(
2063
325
                                    pi2_level, pu1_pred_sblk, pi2_out, pu1_pred_sblk, ui_rec_width,
2064
325
                                    u2_luma_stride, ui_rec_width,
2065
325
                                    gau2_ih264_iquant_scale_4x4[ps_cur_mb_info->u1_qp_rem6],
2066
325
                                    (UWORD16 *) ps_dec->s_high_profile.i2_scalinglist4x4[3],
2067
325
                                    ps_cur_mb_info->u1_qp_div6, ai2_tmp, 0, NULL);
2068
325
                        }
2069
27.7k
                        else
2070
27.7k
                        {
2071
27.7k
                            u2_res_luma_csbp =
2072
27.7k
                                ps_svc_lyr_dec->pf_iquant_itrans_residual_recon_luma_4x4(
2073
27.7k
                                    pi2_level, pu1_pred_sblk, pi2_out, pu1_pred_sblk, ui_rec_width,
2074
27.7k
                                    u2_luma_stride, ui_rec_width,
2075
27.7k
                                    gau2_ih264_iquant_scale_4x4[ps_cur_mb_info->u1_qp_rem6],
2076
27.7k
                                    (UWORD16 *) ps_dec->s_high_profile.i2_scalinglist4x4[3],
2077
27.7k
                                    ps_cur_mb_info->u1_qp_div6, ai2_tmp, 0, NULL);
2078
27.7k
                        }
2079
28.1k
                    }
2080
28.1k
                }
2081
16.6k
                else
2082
16.6k
                {
2083
16.6k
                    UWORD8 *pu1_pred_sblk =
2084
16.6k
                        pu1_rec_y + ((i & 0x3) * BLK_SIZE) + (i >> 2) * (ui_rec_width << 2);
2085
16.6k
                    WORD16 *pi2_out = pi2_luma_res_ptr + ((i & 0x3) * BLK_SIZE) +
2086
16.6k
                                      (i >> 2) * (u2_luma_stride << 2);
2087
2088
16.6k
                    u2_res_luma_csbp = ps_svc_lyr_dec->pf_pred_residual_recon_luma_4x4(
2089
16.6k
                        pu1_pred_sblk, pi2_out, pu1_pred_sblk, ui_rec_width, u2_luma_stride,
2090
16.6k
                        ui_rec_width);
2091
16.6k
                }
2092
44.8k
                *pu2_res_luma_csbp |= (u2_res_luma_csbp << i);
2093
44.8k
            }
2094
2.80k
        }
2095
15.6k
        else
2096
15.6k
        {
2097
15.6k
            WORD16 *pi2_scale_matrix_ptr;
2098
15.6k
            WORD32 i;
2099
2100
15.6k
            pi2_scale_matrix_ptr = ps_dec->s_high_profile.i2_scalinglist8x8[1];
2101
2102
78.2k
            for(i = 0; i < 4; i++)
2103
62.6k
            {
2104
62.6k
                WORD16 ai2_tmp[64] = {0};
2105
62.6k
                WORD16 *pi16_levelBlock =
2106
62.6k
                    pi2_y_coeff + (i << 6); /* move to the next 8x8 adding 64 */
2107
2108
62.6k
                UWORD8 *pu1_pred_sblk =
2109
62.6k
                    pu1_rec_y + ((i & 0x1) * BLK8x8SIZE) + (i >> 1) * (ui_rec_width << 3);
2110
62.6k
                WORD16 *pi2_out =
2111
62.6k
                    pi2_luma_res_ptr + ((i & 0x1) * BLK8x8SIZE) + (i >> 1) * (u2_luma_stride << 3);
2112
62.6k
                if(CHECKBIT(ps_cur_mb_info->u1_cbp, i))
2113
58.3k
                {
2114
58.3k
                    PROFILE_DISABLE_IQ_IT_RECON()
2115
58.3k
                    {
2116
58.3k
                        if(CHECKBIT(u4_luma_dc_only_cbp, i))
2117
356
                        {
2118
356
                            u2_res_luma_csbp =
2119
356
                                ps_svc_lyr_dec->pf_iquant_itrans_residual_recon_luma_8x8_dc(
2120
356
                                    pi16_levelBlock, pu1_pred_sblk, pi2_out, pu1_pred_sblk,
2121
356
                                    ui_rec_width, u2_luma_stride, ui_rec_width,
2122
356
                                    gau1_ih264d_dequant8x8_cavlc[ps_cur_mb_info->u1_qp_rem6],
2123
356
                                    (UWORD16 *) pi2_scale_matrix_ptr, ps_cur_mb_info->u1_qp_div6,
2124
356
                                    ai2_tmp, 0, NULL);
2125
356
                        }
2126
57.9k
                        else
2127
57.9k
                        {
2128
57.9k
                            u2_res_luma_csbp =
2129
57.9k
                                ps_svc_lyr_dec->pf_iquant_itrans_residual_recon_luma_8x8(
2130
57.9k
                                    pi16_levelBlock, pu1_pred_sblk, pi2_out, pu1_pred_sblk,
2131
57.9k
                                    ui_rec_width, u2_luma_stride, ui_rec_width,
2132
57.9k
                                    gau1_ih264d_dequant8x8_cavlc[ps_cur_mb_info->u1_qp_rem6],
2133
57.9k
                                    (UWORD16 *) pi2_scale_matrix_ptr, ps_cur_mb_info->u1_qp_div6,
2134
57.9k
                                    ai2_tmp, 0, NULL);
2135
57.9k
                        }
2136
58.3k
                    }
2137
58.3k
                }
2138
4.29k
                else
2139
4.29k
                {
2140
4.29k
                    UWORD8 *pu1_pred_sblk =
2141
4.29k
                        pu1_rec_y + ((i & 0x1) * BLK8x8SIZE) + (i >> 1) * (ui_rec_width << 3);
2142
4.29k
                    WORD16 *pi2_out = pi2_luma_res_ptr + ((i & 0x1) * BLK8x8SIZE) +
2143
4.29k
                                      (i >> 1) * (u2_luma_stride << 3);
2144
2145
4.29k
                    u2_res_luma_csbp = ps_svc_lyr_dec->pf_pred_residual_recon_luma_8x8(
2146
4.29k
                        pu1_pred_sblk, pi2_out, pu1_pred_sblk, ui_rec_width, u2_luma_stride,
2147
4.29k
                        ui_rec_width);
2148
4.29k
                }
2149
62.6k
                *pu2_res_luma_csbp |= (u2_res_luma_csbp << (((i >> 1) << 3) + ((i & 0x01) << 1)));
2150
62.6k
            }
2151
15.6k
        }
2152
18.4k
    }
2153
834
    else
2154
834
    {
2155
834
        UWORD8 *pu1_pred_sblk = pu1_rec_y;
2156
834
        WORD16 *pi2_out = pi2_luma_res_ptr;
2157
2158
834
        *pu2_res_luma_csbp = ps_svc_lyr_dec->pf_pred_residual_recon_luma_16x16(
2159
834
            pu1_pred_sblk, pi2_out, pu1_pred_sblk, ui_rec_width, u2_luma_stride, ui_rec_width);
2160
834
    }
2161
2162
    /* Decode Chroma Block */
2163
19.2k
    ih264d_unpack_chroma_coeff4x4_mb(ps_dec, ps_cur_mb_info);
2164
    /*--------------------------------------------------------------------*/
2165
    /* Chroma Blocks decoding                                             */
2166
    /*--------------------------------------------------------------------*/
2167
19.2k
    {
2168
19.2k
        UWORD8 u1_chroma_cbp = (UWORD8) (ps_cur_mb_info->u1_cbp >> 4);
2169
2170
19.2k
        if(u1_chroma_cbp != CBPC_ALLZERO)
2171
11.7k
        {
2172
11.7k
            UWORD32 u4_scale_u = ps_cur_mb_info->u1_qpc_div6;
2173
11.7k
            UWORD32 u4_scale_v = ps_cur_mb_info->u1_qpcr_div6;
2174
11.7k
            UWORD16 u2_chroma_csbp = ps_cur_mb_info->u2_chroma_csbp;
2175
2176
11.7k
            pi2_y_coeff = ps_dec->pi2_coeff_data;
2177
2178
11.7k
            {
2179
11.7k
                UWORD32 i;
2180
11.7k
                WORD16 ai2_tmp[16] = {0};
2181
58.6k
                for(i = 0; i < 4; i++)
2182
46.9k
                {
2183
46.9k
                    WORD16 *pi2_level = pi2_y_coeff + (i << 4);
2184
46.9k
                    UWORD8 *pu1_pred_sblk = pu1_rec_u + ((i & 0x1) * BLK_SIZE * YUV420SP_FACTOR) +
2185
46.9k
                                            (i >> 1) * (u4_recwidth_cr << 2);
2186
46.9k
                    WORD16 *pi2_out = pi2_chroma_res_ptr +
2187
46.9k
                                      ((i & 0x1) * BLK_SIZE * YUV420SP_FACTOR) +
2188
46.9k
                                      (i >> 1) * (u2_chroma_stride << 2);
2189
46.9k
                    PROFILE_DISABLE_IQ_IT_RECON()
2190
46.9k
                    {
2191
46.9k
                        if(CHECKBIT(u2_chroma_csbp, i))
2192
1.86k
                        {
2193
1.86k
                            ps_svc_lyr_dec->pf_iquant_itrans_residual_recon_chroma_4x4(
2194
1.86k
                                pi2_level, pu1_pred_sblk, pi2_out, pu1_pred_sblk, u4_recwidth_cr,
2195
1.86k
                                u2_chroma_stride, u4_recwidth_cr,
2196
1.86k
                                gau2_ih264_iquant_scale_4x4[ps_cur_mb_info->u1_qpc_rem6],
2197
1.86k
                                (UWORD16 *) ps_dec->s_high_profile.i2_scalinglist4x4[4], u4_scale_u,
2198
1.86k
                                ai2_tmp, pi2_level);
2199
1.86k
                        }
2200
45.0k
                        else if(pi2_level[0] != 0)
2201
39.9k
                        {
2202
39.9k
                            ps_svc_lyr_dec->pf_iquant_itrans_residual_recon_chroma_4x4_dc(
2203
39.9k
                                pi2_level, pu1_pred_sblk, pi2_out, pu1_pred_sblk, u4_recwidth_cr,
2204
39.9k
                                u2_chroma_stride, u4_recwidth_cr,
2205
39.9k
                                gau2_ih264_iquant_scale_4x4[ps_cur_mb_info->u1_qpc_rem6],
2206
39.9k
                                (UWORD16 *) ps_dec->s_high_profile.i2_scalinglist4x4[4], u4_scale_u,
2207
39.9k
                                ai2_tmp, pi2_level);
2208
39.9k
                        }
2209
5.15k
                        else
2210
5.15k
                        {
2211
5.15k
                            ps_svc_lyr_dec->pf_pred_residual_recon_chroma_4x4(
2212
5.15k
                                pu1_pred_sblk, pi2_out, pu1_pred_sblk, u4_recwidth_cr,
2213
5.15k
                                u2_chroma_stride, u4_recwidth_cr);
2214
5.15k
                        }
2215
46.9k
                    }
2216
46.9k
                }
2217
11.7k
            }
2218
2219
11.7k
            pi2_y_coeff += MB_CHROM_SIZE;
2220
11.7k
            u2_chroma_csbp >>= 4;
2221
2222
11.7k
            {
2223
11.7k
                UWORD32 i;
2224
11.7k
                WORD16 ai2_tmp[16] = {0};
2225
58.6k
                for(i = 0; i < 4; i++)
2226
46.9k
                {
2227
46.9k
                    WORD16 *pi2_level = pi2_y_coeff + (i << 4);
2228
46.9k
                    UWORD8 *pu1_pred_sblk = pu1_rec_u + 1 +
2229
46.9k
                                            ((i & 0x1) * BLK_SIZE * YUV420SP_FACTOR) +
2230
46.9k
                                            (i >> 1) * (u4_recwidth_cr << 2);
2231
46.9k
                    WORD16 *pi2_out = pi2_chroma_res_ptr + 1 +
2232
46.9k
                                      ((i & 0x1) * BLK_SIZE * YUV420SP_FACTOR) +
2233
46.9k
                                      (i >> 1) * (u2_chroma_stride << 2);
2234
46.9k
                    PROFILE_DISABLE_IQ_IT_RECON()
2235
46.9k
                    {
2236
46.9k
                        if(CHECKBIT(u2_chroma_csbp, i))
2237
1.69k
                        {
2238
1.69k
                            ps_svc_lyr_dec->pf_iquant_itrans_residual_recon_chroma_4x4(
2239
1.69k
                                pi2_level, pu1_pred_sblk, pi2_out, pu1_pred_sblk, u4_recwidth_cr,
2240
1.69k
                                u2_chroma_stride, u4_recwidth_cr,
2241
1.69k
                                gau2_ih264_iquant_scale_4x4[ps_cur_mb_info->u1_qpcr_rem6],
2242
1.69k
                                (UWORD16 *) ps_dec->s_high_profile.i2_scalinglist4x4[5], u4_scale_v,
2243
1.69k
                                ai2_tmp, pi2_level);
2244
1.69k
                        }
2245
45.2k
                        else if(pi2_level[0] != 0)
2246
40.7k
                        {
2247
40.7k
                            ps_svc_lyr_dec->pf_iquant_itrans_residual_recon_chroma_4x4_dc(
2248
40.7k
                                pi2_level, pu1_pred_sblk, pi2_out, pu1_pred_sblk, u4_recwidth_cr,
2249
40.7k
                                u2_chroma_stride, u4_recwidth_cr,
2250
40.7k
                                gau2_ih264_iquant_scale_4x4[ps_cur_mb_info->u1_qpcr_rem6],
2251
40.7k
                                (UWORD16 *) ps_dec->s_high_profile.i2_scalinglist4x4[5], u4_scale_v,
2252
40.7k
                                ai2_tmp, pi2_level);
2253
40.7k
                        }
2254
4.52k
                        else
2255
4.52k
                        {
2256
4.52k
                            ps_svc_lyr_dec->pf_pred_residual_recon_chroma_4x4(
2257
4.52k
                                pu1_pred_sblk, pi2_out, pu1_pred_sblk, u4_recwidth_cr,
2258
4.52k
                                u2_chroma_stride, u4_recwidth_cr);
2259
4.52k
                        }
2260
46.9k
                    }
2261
46.9k
                }
2262
11.7k
            }
2263
11.7k
        }
2264
7.55k
        else
2265
7.55k
        {
2266
            /* Cr*/
2267
7.55k
            {
2268
7.55k
                UWORD8 *pu1_pred_sblk = pu1_rec_u;
2269
7.55k
                WORD16 *pi2_out = pi2_chroma_res_ptr;
2270
2271
7.55k
                ps_svc_lyr_dec->pf_pred_residual_recon_chroma_8x8(pu1_pred_sblk, pi2_out,
2272
7.55k
                                                                  pu1_pred_sblk, u4_recwidth_cr,
2273
7.55k
                                                                  u2_chroma_stride, u4_recwidth_cr);
2274
7.55k
            }
2275
2276
            /* Cb*/
2277
7.55k
            {
2278
7.55k
                UWORD8 *pu1_pred_sblk = pu1_rec_u + 1;
2279
7.55k
                WORD16 *pi2_out = pi2_chroma_res_ptr + 1;
2280
7.55k
                ps_svc_lyr_dec->pf_pred_residual_recon_chroma_8x8(pu1_pred_sblk, pi2_out,
2281
7.55k
                                                                  pu1_pred_sblk, u4_recwidth_cr,
2282
7.55k
                                                                  u2_chroma_stride, u4_recwidth_cr);
2283
7.55k
            }
2284
7.55k
        }
2285
19.2k
    }
2286
19.2k
    ps_svc_lyr_dec->ps_inter_lyr_mb_prms_cur_mb =
2287
19.2k
        ps_svc_lyr_dec->ps_inter_lyr_mb_prms_frm_start + ps_cur_mb_info->u2_mbx +
2288
19.2k
        (ps_svc_lyr_dec->u2_inter_lyr_mb_prms_stride * (ps_cur_mb_info->u2_mby));
2289
19.2k
    ps_svc_lyr_dec->ps_inter_lyr_mb_prms_cur_mb->i1_mb_mode =
2290
19.2k
        u1_inference_mode ? SVC_IBL_MB : SVC_INTER_MB;
2291
19.2k
    ps_svc_lyr_dec->ps_inter_lyr_mb_prms_cur_mb->i1_tx_size = ps_cur_mb_info->u1_tran_form8x8;
2292
19.2k
    ps_svc_lyr_dec->ps_inter_lyr_mb_prms_cur_mb->u2_luma_nnz = ps_cur_mb_info->u2_luma_csbp;
2293
19.2k
    ps_svc_lyr_dec->ps_inter_lyr_mb_prms_cur_mb->u1_chroma_nnz =
2294
19.2k
        (UWORD8) ps_cur_mb_info->u2_chroma_csbp;
2295
19.2k
    if(CHECKBIT(ps_cur_mb_info->u1_yuv_dc_block_flag, 1))
2296
10.4k
    {
2297
        /* Four bits for Cb in DC only cbp */
2298
10.4k
        ps_svc_lyr_dec->ps_inter_lyr_mb_prms_cur_mb->u1_chroma_nnz |= 0x0F;
2299
10.4k
    }
2300
19.2k
    if(CHECKBIT(ps_cur_mb_info->u1_yuv_dc_block_flag, 2))
2301
10.5k
    {
2302
        /* Four bits for Cr in DC only cbp */
2303
10.5k
        ps_svc_lyr_dec->ps_inter_lyr_mb_prms_cur_mb->u1_chroma_nnz |= 0xF0;
2304
10.5k
    }
2305
19.2k
    return (0);
2306
19.2k
}