Coverage Report

Created: 2026-03-31 06:08

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
281k
{
81
281k
    mode_motion_ctxt_t *ps_ctxt;
82
281k
    mv_pred_t *ps_motion_pred;
83
281k
    UWORD8 u1_tmp_lx = (u1_lx << 1);
84
85
281k
    ps_ctxt = (mode_motion_ctxt_t *) ps_svc_lyr_dec->pv_mode_mv_sample_ctxt;
86
281k
    ps_motion_pred = ps_ctxt->ps_motion_pred_struct;
87
281k
    ps_motion_pred += u1_sub_mb_num;
88
281k
    ps_mvpred->i2_mv[u1_tmp_lx] = ps_motion_pred->i2_mv[u1_tmp_lx];
89
281k
    ps_mvpred->i2_mv[u1_tmp_lx + 1] = ps_motion_pred->i2_mv[u1_tmp_lx + 1];
90
91
281k
    return;
92
281k
}
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
7.00M
{
110
7.00M
    dec_struct_t *ps_dec = &ps_svc_lyr_dec->s_dec;
111
7.00M
    WORD32 i4_inter_layer_pred_req_flag;
112
7.00M
    WORD32 i4_listx;
113
7.00M
    WORD32 i4_mb_mode = -1;
114
7.00M
    i4_inter_layer_pred_req_flag = SVCD_FALSE;
115
7.00M
    i4_listx = (ps_dec->ps_cur_slice->u1_slice_type == B_SLICE) ? 2 : 1;
116
    /* check Base mode flag and motion predcition flags */
117
7.00M
    if(1 == ps_svc_cur_mb_info->u1_base_mode_flag)
118
166k
    {
119
166k
        i4_inter_layer_pred_req_flag = SVCD_TRUE;
120
166k
    }
121
6.84M
    else
122
6.84M
    {
123
6.84M
        UWORD8 u1_mot_pred_flag;
124
125
        /* get the packed the motion pred flag of list 0 */
126
6.84M
        u1_mot_pred_flag = ps_svc_cur_mb_info->au1_motion_pred_flag[0];
127
128
        /* extract the last 4 bits */
129
6.84M
        u1_mot_pred_flag &= 0x0F;
130
131
6.84M
        if(0 != u1_mot_pred_flag)
132
24.0k
        {
133
24.0k
            i4_inter_layer_pred_req_flag = SVCD_TRUE;
134
24.0k
        }
135
136
        /* check for list 1 flags if required */
137
6.84M
        if((2 == i4_listx) && (SVCD_FALSE == i4_inter_layer_pred_req_flag))
138
89.7k
        {
139
            /* get the packed the motion pred flag of list 1 */
140
89.7k
            u1_mot_pred_flag = ps_svc_cur_mb_info->au1_motion_pred_flag[1];
141
142
            /* extract the last 4 bits */
143
89.7k
            u1_mot_pred_flag &= 0x0F;
144
145
89.7k
            if(0 != u1_mot_pred_flag)
146
4.68k
            {
147
4.68k
                i4_inter_layer_pred_req_flag = SVCD_TRUE;
148
4.68k
            }
149
89.7k
        }
150
6.84M
    }
151
152
7.00M
    if(SVCD_TRUE == i4_inter_layer_pred_req_flag)
153
194k
    {
154
194k
        mode_motion_ctxt_t *ps_ctxt;
155
194k
        mode_motion_lyr_ctxt *ps_lyr_mem;
156
157
194k
        ps_ctxt = (mode_motion_ctxt_t *) ps_svc_lyr_dec->pv_mode_mv_sample_ctxt;
158
        /* get the current layer ctxt */
159
194k
        ps_lyr_mem = &ps_ctxt->as_res_lyr_mem[ps_ctxt->i4_res_id];
160
161
194k
        {
162
194k
            ps_ctxt->i4_listx = i4_listx;
163
164
194k
            i4_mb_mode =
165
194k
                ps_lyr_mem->pf_inter_lyr_pred(ps_svc_lyr_dec->pv_mode_mv_sample_ctxt, ps_cur_mb_info,
166
194k
                                          ps_svc_cur_mb_info, ps_dec, ps_mb_part_info, ps_part);
167
194k
        }
168
194k
    }
169
7.00M
    return i4_mb_mode;
170
7.00M
}
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
1.21M
{
183
1.21M
    svc_dec_lyr_struct_t *ps_svc_lyr_dec = (svc_dec_lyr_struct_t *) ps_dec;
184
1.21M
    parse_pmbarams_t *ps_mb_part_info;
185
1.21M
    parse_part_params_t *ps_part;
186
1.21M
    mv_pred_t *ps_mv_nmb, *ps_mv_nmb_start, *ps_mv_ntop, *ps_mv_ntop_start;
187
1.21M
    UWORD32 i, j;
188
1.21M
    const UWORD32 u1_mbaff = ps_dec->ps_cur_slice->u1_mbaff_frame_flag;
189
1.21M
    dec_mb_info_t *ps_cur_mb_info;
190
1.21M
    dec_svc_mb_info_t *ps_svc_cur_mb_info;
191
1.21M
    WORD32 i2_mv_x, i2_mv_y;
192
193
1.21M
    ps_dec->i4_submb_ofst -= (u4_num_mbs - u4_mb_idx) << 4;
194
1.21M
    ps_mb_part_info = ps_dec->ps_parse_mb_data;
195
1.21M
    ps_part = ps_dec->ps_parse_part_params;
196
197
    /* N/2 Mb MvPred and Transfer Setup Loop */
198
8.08M
    for(i = u4_mb_idx; i < u4_num_mbs; i++, ps_mb_part_info++)
199
6.87M
    {
200
6.87M
        UWORD32 u1_colz;
201
6.87M
        UWORD32 u1_field;
202
6.87M
        mv_pred_t s_mvPred = {0};
203
6.87M
        mv_pred_t *ps_mv_pred = &s_mvPred;
204
205
6.87M
        *ps_mv_pred = ps_dec->s_default_mv_pred;
206
207
6.87M
        ps_dec->i4_submb_ofst += SUB_BLK_SIZE;
208
209
        /* Restore the slice scratch MbX and MbY context */
210
6.87M
        ps_cur_mb_info = ps_dec->ps_nmb_info + i;
211
6.87M
        ps_svc_cur_mb_info = ps_svc_lyr_dec->ps_svc_nmb_info + i;
212
6.87M
        u1_field = ps_cur_mb_info->u1_mb_field_decodingflag;
213
214
6.87M
        ps_mv_nmb_start = ps_dec->ps_mv_cur + (i << 4);
215
6.87M
        ps_dec->u2_mbx = ps_cur_mb_info->u2_mbx;
216
6.87M
        ps_dec->u2_mby = ps_cur_mb_info->u2_mby;
217
6.87M
        ps_dec->u2_mv_2mb[i & 0x1] = 0;
218
219
        /* Look for MV Prediction and Reference Transfer in Non-I Mbs */
220
6.87M
        if(!ps_mb_part_info->u4_isI_mb)
221
6.86M
        {
222
6.86M
            UWORD32 u1_blk_no;
223
6.86M
            WORD32 i1_ref_idx, i1_ref_idx1;
224
6.86M
            UWORD32 u1_sub_mb_x, u1_sub_mb_y, u1_sub_mb_num;
225
6.86M
            UWORD32 u1_num_part, u1_num_ref, u1_wd, u1_ht;
226
6.86M
            UWORD32 *pu4_wt_offst, **ppu4_wt_ofst;
227
6.86M
            UWORD32 u1_scale_ref, u4_bot_mb;
228
6.86M
            WORD8 *pi1_ref_idx = ps_mb_part_info->i1_ref_idx[0];
229
6.86M
            pic_buffer_t *ps_ref_frame, **pps_ref_frame;
230
6.86M
            deblk_mb_t *ps_cur_deblk_mb = ps_dec->ps_deblk_mbn + i;
231
6.86M
            WORD32 i4_mb_mode_svc;
232
6.86M
            UWORD8 u1_motion_pred_flag_l0 = ps_svc_cur_mb_info->au1_motion_pred_flag[0];
233
234
            /* MB Level initialisations */
235
6.86M
            ps_dec->u4_num_pmbair = i >> u1_mbaff;
236
6.86M
            ps_dec->u4_mb_idx_mv = i;
237
6.86M
            ppu4_wt_ofst = ps_mb_part_info->pu4_wt_offst;
238
6.86M
            pps_ref_frame = ps_dec->ps_ref_pic_buf_lx[0];
239
240
6.86M
            i4_mb_mode_svc = isvcd_interlyr_motion_mode_pred(
241
6.86M
                ps_svc_lyr_dec, ps_cur_mb_info, ps_svc_cur_mb_info, ps_mb_part_info, ps_part);
242
243
6.86M
            if((-1 == i4_mb_mode_svc) || (SVC_INTER_MB == i4_mb_mode_svc))
244
6.85M
            {
245
6.85M
                ps_mv_ntop_start =
246
6.85M
                    ps_mv_nmb_start - (ps_dec->u2_frm_wd_in_mbs << (4 + u1_mbaff)) + 12;
247
248
6.85M
                u1_num_part = ps_mb_part_info->u1_num_part;
249
6.85M
                ps_cur_deblk_mb->u1_mb_type |= (u1_num_part > 1) << 1;
250
6.85M
                ps_cur_mb_info->u4_pred_info_pkd_idx = ps_dec->u4_pred_info_pkd_idx;
251
6.85M
                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
6.85M
                u1_scale_ref = u1_mbaff & u1_field;
258
259
6.85M
                u4_bot_mb = 1 - ps_cur_mb_info->u1_topmb;
260
6.85M
                if(ps_dec->ps_cur_pps->u1_wted_pred_flag)
261
3.66M
                {
262
3.66M
                    u1_num_ref = MIN(u1_num_part, 4);
263
7.34M
                    for(u1_blk_no = 0; u1_blk_no < u1_num_ref; u1_blk_no++)
264
3.68M
                    {
265
3.68M
                        i1_ref_idx = pi1_ref_idx[u1_blk_no];
266
3.68M
                        if(u1_scale_ref) i1_ref_idx >>= 1;
267
3.68M
                        pu4_wt_offst = (UWORD32 *) &ps_dec->pu4_wt_ofsts[2 * X3(i1_ref_idx)];
268
3.68M
                        ppu4_wt_ofst[u1_blk_no] = pu4_wt_offst;
269
3.68M
                    }
270
3.66M
                }
271
3.18M
                else
272
3.18M
                {
273
3.18M
                    ppu4_wt_ofst[0] = NULL;
274
3.18M
                    ppu4_wt_ofst[1] = NULL;
275
3.18M
                    ppu4_wt_ofst[2] = NULL;
276
3.18M
                    ppu4_wt_ofst[3] = NULL;
277
3.18M
                }
278
279
                /**************************************************/
280
                /* Loop on Partitions                             */
281
                /**************************************************/
282
13.7M
                for(j = 0; j < u1_num_part; j++, ps_part++)
283
6.94M
                {
284
6.94M
                    u1_sub_mb_num = ps_part->u1_sub_mb_num;
285
6.94M
                    ps_dec->u1_sub_mb_num = u1_sub_mb_num;
286
287
6.94M
                    if(PART_NOT_DIRECT != ps_part->u1_is_direct)
288
6.70M
                    {
289
                        /* Mb Skip Mode */
290
                        /* Setting the default and other members of MvPred Structure */
291
6.70M
                        s_mvPred.i2_mv[2] = -1;
292
6.70M
                        s_mvPred.i2_mv[3] = -1;
293
6.70M
                        s_mvPred.i1_ref_frame[0] = 0;
294
6.70M
                        i1_ref_idx = (u1_scale_ref && u4_bot_mb) ? MAX_REF_BUFS : 0;
295
6.70M
                        ps_ref_frame = pps_ref_frame[i1_ref_idx];
296
6.70M
                        s_mvPred.u1_col_ref_pic_idx = ps_ref_frame->u1_mv_buf_id;
297
6.70M
                        s_mvPred.u1_pic_type = ps_ref_frame->u1_pic_type;
298
6.70M
                        pu4_wt_offst = (UWORD32 *) &ps_dec->pu4_wt_ofsts[0];
299
300
6.70M
                        ps_dec->pf_mvpred(ps_dec, ps_cur_mb_info, ps_mv_nmb_start, ps_mv_ntop_start,
301
6.70M
                                          &s_mvPred, 0, 4, 0, 1, MB_SKIP);
302
303
6.70M
                        {
304
6.70M
                            pred_info_pkd_t *ps_pred_pkd;
305
6.70M
                            ps_pred_pkd = ps_dec->ps_pred_pkd + ps_dec->u4_pred_info_pkd_idx;
306
6.70M
                            ih264d_fill_pred_info(s_mvPred.i2_mv, 4, 4, 0, PRED_L0, ps_pred_pkd,
307
6.70M
                                                  ps_ref_frame->u1_pic_buf_id,
308
6.70M
                                                  (i1_ref_idx >> u1_scale_ref), pu4_wt_offst,
309
6.70M
                                                  ps_ref_frame->u1_pic_type);
310
311
6.70M
                            ps_dec->u4_pred_info_pkd_idx++;
312
6.70M
                            ps_cur_mb_info->u1_num_pred_parts++;
313
6.70M
                        }
314
315
                        /* Storing colocated zero information */
316
6.70M
                        u1_colz = ((ABS(s_mvPred.i2_mv[0]) <= 1) && (ABS(s_mvPred.i2_mv[1]) <= 1)) +
317
6.70M
                                  (u1_field << 1);
318
319
6.70M
                        if(ps_mv_nmb_start)
320
6.70M
                        {
321
6.70M
                            ih264d_rep_mv_colz(ps_dec, &s_mvPred, ps_mv_nmb_start, 0, u1_colz, 4,
322
6.70M
                                               4);
323
6.70M
                        }
324
0
                        else
325
0
                        {
326
0
                            return NOT_OK;
327
0
                        }
328
6.70M
                    }
329
234k
                    else
330
234k
                    {
331
234k
                        u1_sub_mb_x = u1_sub_mb_num & 0x03;
332
234k
                        u1_sub_mb_y = u1_sub_mb_num >> 2;
333
234k
                        u1_blk_no = (u1_num_part < 4)
334
234k
                                        ? j
335
234k
                                        : (((u1_sub_mb_y >> 1) << 1) + (u1_sub_mb_x >> 1));
336
337
234k
                        ps_mv_ntop = ps_mv_ntop_start + u1_sub_mb_x;
338
234k
                        ps_mv_nmb = ps_mv_nmb_start + u1_sub_mb_num;
339
340
234k
                        u1_wd = ps_part->u1_partwidth;
341
234k
                        u1_ht = ps_part->u1_partheight;
342
343
                        /* Populate the colpic info and reference frames */
344
234k
                        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
234k
                        if(ps_svc_cur_mb_info->u1_base_mode_flag == 1)
351
163k
                        {
352
163k
                            if(i1_ref_idx > (ps_dec->ps_cur_slice->u1_num_ref_idx_lx_active[0] - 1))
353
4.80k
                            {
354
4.80k
                                i1_ref_idx = ps_dec->ps_cur_slice->u1_num_ref_idx_lx_active[0] - 1;
355
4.80k
                            }
356
163k
                        }
357
234k
                        s_mvPred.i1_ref_frame[0] = i1_ref_idx;
358
359
234k
                        if((1 != ps_svc_cur_mb_info->u1_base_mode_flag) &&
360
71.2k
                           (0 == (u1_motion_pred_flag_l0 & (1 << u1_blk_no))))
361
46.7k
                        {
362
                            /********************************************************/
363
                            /* Predict Mv                                           */
364
                            /* Add Mv Residuals and store back                      */
365
                            /********************************************************/
366
46.7k
                            ps_dec->pf_mvpred(ps_dec, ps_cur_mb_info, ps_mv_nmb, ps_mv_ntop,
367
46.7k
                                              &s_mvPred, u1_sub_mb_num, u1_wd, 0, 1,
368
46.7k
                                              ps_cur_mb_info->u1_mb_mc_mode);
369
370
46.7k
                            i2_mv_x = ps_mv_nmb->i2_mv[0];
371
46.7k
                            i2_mv_y = ps_mv_nmb->i2_mv[1];
372
46.7k
                            i2_mv_x += s_mvPred.i2_mv[0];
373
46.7k
                            i2_mv_y += s_mvPred.i2_mv[1];
374
46.7k
                            s_mvPred.i2_mv[0] = i2_mv_x;
375
46.7k
                            s_mvPred.i2_mv[1] = i2_mv_y;
376
46.7k
                        }
377
187k
                        else
378
187k
                        {
379
187k
                            isvcd_retrive_infer_mode_mv(ps_svc_lyr_dec, &s_mvPred, 0,
380
187k
                                                        u1_sub_mb_num);
381
382
187k
                            if(0 != (u1_motion_pred_flag_l0 & (1 << u1_blk_no)))
383
24.5k
                            {
384
24.5k
                                i2_mv_x = ps_mv_nmb->i2_mv[0];
385
24.5k
                                i2_mv_y = ps_mv_nmb->i2_mv[1];
386
24.5k
                                i2_mv_x += s_mvPred.i2_mv[0];
387
24.5k
                                i2_mv_y += s_mvPred.i2_mv[1];
388
24.5k
                                s_mvPred.i2_mv[0] = i2_mv_x;
389
24.5k
                                s_mvPred.i2_mv[1] = i2_mv_y;
390
24.5k
                            }
391
187k
                            i2_mv_x = s_mvPred.i2_mv[0];
392
187k
                            i2_mv_y = s_mvPred.i2_mv[1];
393
187k
                        }
394
                        /********************************************************/
395
                        /* Transfer setup call                                  */
396
                        /* convert RefIdx if it is MbAff                        */
397
                        /* Pass Weight Offset and refFrame                      */
398
                        /********************************************************/
399
234k
                        i1_ref_idx1 = i1_ref_idx >> u1_scale_ref;
400
234k
                        if(u1_scale_ref && ((i1_ref_idx & 0x01) != u4_bot_mb))
401
0
                            i1_ref_idx1 += MAX_REF_BUFS;
402
234k
                        if(-1 == i1_ref_idx1) return NOT_OK;
403
234k
                        ps_ref_frame = pps_ref_frame[i1_ref_idx1];
404
234k
                        pu4_wt_offst = ppu4_wt_ofst[u1_blk_no];
405
406
234k
                        {
407
234k
                            pred_info_pkd_t *ps_pred_pkd;
408
234k
                            ps_pred_pkd = ps_dec->ps_pred_pkd + ps_dec->u4_pred_info_pkd_idx;
409
234k
                            ih264d_fill_pred_info(s_mvPred.i2_mv, u1_wd, u1_ht, u1_sub_mb_num,
410
234k
                                                  PRED_L0, ps_pred_pkd, ps_ref_frame->u1_pic_buf_id,
411
234k
                                                  (i1_ref_idx >> u1_scale_ref), pu4_wt_offst,
412
234k
                                                  ps_ref_frame->u1_pic_type);
413
414
234k
                            ps_dec->u4_pred_info_pkd_idx++;
415
234k
                            ps_cur_mb_info->u1_num_pred_parts++;
416
234k
                        }
417
418
                        /* Fill colocated info in MvPred structure */
419
234k
                        s_mvPred.u1_col_ref_pic_idx = ps_ref_frame->u1_mv_buf_id;
420
234k
                        s_mvPred.u1_pic_type = ps_ref_frame->u1_pic_type;
421
422
                        /* Calculating colocated zero information */
423
234k
                        u1_colz = (u1_field << 1) |
424
234k
                                  ((i1_ref_idx == 0) && (ABS(i2_mv_x) <= 1) && (ABS(i2_mv_y) <= 1));
425
234k
                        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
234k
                        if(ps_mv_nmb)
431
234k
                        {
432
234k
                            ih264d_rep_mv_colz(ps_dec, &s_mvPred, ps_mv_nmb, u1_sub_mb_num, u1_colz,
433
234k
                                               u1_ht, u1_wd);
434
234k
                        }
435
0
                        else
436
0
                        {
437
0
                            return NOT_OK;
438
0
                        }
439
234k
                    }
440
6.94M
                }
441
442
                /* to take care of 16 parttitions increment for base mode flag case*/
443
6.85M
                if(1 == ps_svc_cur_mb_info->u1_base_mode_flag)
444
108k
                {
445
108k
                    ps_part += (MAX_NUM_MB_PART - u1_num_part);
446
108k
                }
447
6.85M
            }
448
18.9k
            else
449
18.9k
            {
450
18.9k
                ps_cur_deblk_mb->u1_mb_type |= D_INTRA_IBL;
451
18.9k
                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
18.9k
                if(1 != ps_svc_cur_mb_info->u1_base_mode_flag)
458
0
                {
459
0
                    return NOT_OK;
460
0
                }
461
18.9k
                {
462
18.9k
                    ps_part += (MAX_NUM_MB_PART);
463
18.9k
                }
464
                /* Storing colocated zero information */
465
18.9k
                if(ps_mv_nmb_start)
466
18.9k
                {
467
18.9k
                    ih264d_rep_mv_colz(ps_dec, &s_mvPred, ps_mv_nmb_start, 0,
468
18.9k
                                       (UWORD8) (u1_field << 1), 4, 4);
469
18.9k
                }
470
0
                else
471
0
                {
472
0
                    return NOT_OK;
473
0
                }
474
18.9k
            }
475
6.86M
        }
476
3.56k
        else
477
3.56k
        {
478
            /* Storing colocated zero information */
479
3.56k
            if(ps_mv_nmb_start)
480
3.56k
            {
481
3.56k
                ih264d_rep_mv_colz(ps_dec, &s_mvPred, ps_mv_nmb_start, 0, (UWORD8) (u1_field << 1),
482
3.56k
                                   4, 4);
483
3.56k
            }
484
0
            else
485
0
            {
486
0
                return NOT_OK;
487
0
            }
488
3.56k
        }
489
6.87M
    }
490
491
1.21M
    return OK;
492
1.21M
}
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
45.0k
{
508
45.0k
    ps_svc_lyr_dec->ps_inter_lyr_mb_prms_cur_mb =
509
45.0k
        ps_svc_lyr_dec->ps_inter_lyr_mb_prms_frm_start + ps_cur_mb_info->u2_mbx +
510
45.0k
        (ps_svc_lyr_dec->u2_inter_lyr_mb_prms_stride * (ps_cur_mb_info->u2_mby));
511
512
45.0k
    ps_svc_lyr_dec->ps_inter_lyr_mb_prms_cur_mb->i1_mb_mode = SVC_INTRA_MB;
513
45.0k
    ps_svc_lyr_dec->ps_inter_lyr_mb_prms_cur_mb->i1_tx_size = ps_cur_mb_info->u1_tran_form8x8;
514
45.0k
    ps_svc_lyr_dec->ps_inter_lyr_mb_prms_cur_mb->u2_luma_nnz = 0;
515
45.0k
    ps_svc_lyr_dec->ps_inter_lyr_mb_prms_cur_mb->u1_chroma_nnz = 0;
516
45.0k
}
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
873
{
533
873
    ps_svc_lyr_dec->ps_inter_lyr_mb_prms_cur_mb->i1_mb_mode = SVC_IPCM_MB;
534
873
    ps_svc_lyr_dec->ps_inter_lyr_mb_prms_cur_mb->i1_tx_size = ps_cur_mb_info->u1_tran_form8x8;
535
873
    ps_svc_lyr_dec->ps_inter_lyr_mb_prms_cur_mb->u2_luma_nnz = 0;
536
873
    ps_svc_lyr_dec->ps_inter_lyr_mb_prms_cur_mb->u1_chroma_nnz = 0;
537
873
}
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
81.2k
{
554
81.2k
    ps_svc_lyr_dec->ps_inter_lyr_mb_prms_cur_mb->i1_mb_mode = SVC_IBL_MB;
555
81.2k
    ps_svc_lyr_dec->ps_inter_lyr_mb_prms_cur_mb->i1_tx_size = ps_cur_mb_info->u1_tran_form8x8;
556
81.2k
    ps_svc_lyr_dec->ps_inter_lyr_mb_prms_cur_mb->u2_luma_nnz = 0;
557
81.2k
    ps_svc_lyr_dec->ps_inter_lyr_mb_prms_cur_mb->u1_chroma_nnz = 0;
558
81.2k
}
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
134k
{
574
134k
    ps_svc_lyr_dec->ps_inter_lyr_mb_prms_cur_mb =
575
134k
        ps_svc_lyr_dec->ps_inter_lyr_mb_prms_frm_start + ps_cur_mb_info->u2_mbx +
576
134k
        (ps_svc_lyr_dec->u2_inter_lyr_mb_prms_stride * (ps_cur_mb_info->u2_mby));
577
134k
    ps_svc_lyr_dec->ps_inter_lyr_mb_prms_cur_mb->i1_mb_mode =
578
134k
        u1_inference_mode ? SVC_IBL_MB : SVC_INTER_MB;
579
134k
    ps_svc_lyr_dec->ps_inter_lyr_mb_prms_cur_mb->i1_tx_size = ps_cur_mb_info->u1_tran_form8x8;
580
134k
    ps_svc_lyr_dec->ps_inter_lyr_mb_prms_cur_mb->u2_luma_nnz = ps_cur_mb_info->u2_luma_csbp;
581
134k
    ps_svc_lyr_dec->ps_inter_lyr_mb_prms_cur_mb->u1_chroma_nnz =
582
134k
        (UWORD8) ps_cur_mb_info->u2_chroma_csbp;
583
134k
    if(CHECKBIT(ps_cur_mb_info->u1_yuv_dc_block_flag, 1))
584
6.75k
    {
585
        /* Four bits for Cb in DC only cbp */
586
6.75k
        ps_svc_lyr_dec->ps_inter_lyr_mb_prms_cur_mb->u1_chroma_nnz |= 0x0F;
587
6.75k
    }
588
134k
    if(CHECKBIT(ps_cur_mb_info->u1_yuv_dc_block_flag, 2))
589
6.64k
    {
590
        /* Four bits for Cr in DC only cbp */
591
6.64k
        ps_svc_lyr_dec->ps_inter_lyr_mb_prms_cur_mb->u1_chroma_nnz |= 0xF0;
592
6.64k
    }
593
134k
}
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
76.9k
{
610
76.9k
    dec_struct_t *ps_dec = &ps_svc_lyr_dec->s_dec;
611
76.9k
    UWORD16 u2_luma_stride, u2_chroma_stride;
612
76.9k
    WORD16 *pi2_y_coeff, *pi2_luma_res_ptr, *pi2_chroma_res_ptr;
613
76.9k
    UWORD32 u4_luma_dc_only_csbp = 0;
614
76.9k
    UWORD32 u4_luma_dc_only_cbp = 0;
615
616
76.9k
    if(0 != ps_dec->ps_cur_slice->u1_mbaff_frame_flag)
617
0
    {
618
0
        return NOT_OK;
619
0
    }
620
76.9k
    u2_luma_stride = ps_svc_lyr_dec->u2_residual_resample_luma_stride;
621
76.9k
    pi2_luma_res_ptr = ps_svc_lyr_dec->pi2_il_residual_resample_mb_luma_frm_start +
622
76.9k
                       (ps_cur_mb_info->u2_mbx << 4) +
623
76.9k
                       ((ps_cur_mb_info->u2_mby << 4) * u2_luma_stride);
624
625
76.9k
    u2_chroma_stride = ps_svc_lyr_dec->u2_residual_resample_chroma_stride;
626
76.9k
    pi2_chroma_res_ptr = ps_svc_lyr_dec->pi2_il_residual_resample_mb_chroma_frm_start +
627
76.9k
                         (ps_cur_mb_info->u2_mbx << 4) +
628
76.9k
                         ((ps_cur_mb_info->u2_mby << 3) * u2_chroma_stride);
629
630
76.9k
    if(!ps_cur_mb_info->u1_tran_form8x8)
631
71.0k
    {
632
71.0k
        u4_luma_dc_only_csbp = ih264d_unpack_luma_coeff4x4_mb(ps_dec, ps_cur_mb_info, 0);
633
71.0k
    }
634
5.99k
    else
635
5.99k
    {
636
5.99k
        if(!ps_dec->ps_cur_pps->u1_entropy_coding_mode)
637
624
        {
638
624
            u4_luma_dc_only_cbp = ih264d_unpack_luma_coeff4x4_mb(ps_dec, ps_cur_mb_info, 0);
639
624
        }
640
5.36k
        else
641
5.36k
        {
642
5.36k
            u4_luma_dc_only_cbp = ih264d_unpack_luma_coeff8x8_mb(ps_dec, ps_cur_mb_info);
643
5.36k
        }
644
5.99k
    }
645
646
76.9k
    pi2_y_coeff = ps_dec->pi2_coeff_data;
647
    /* Inverse Transform and Reconstruction */
648
76.9k
    if(ps_cur_mb_info->u1_cbp & 0x0f)
649
15.5k
    {
650
15.5k
        if(!ps_cur_mb_info->u1_tran_form8x8)
651
9.57k
        {
652
9.57k
            UWORD32 i;
653
9.57k
            WORD16 ai2_tmp[16] = {0};
654
162k
            for(i = 0; i < 16; i++)
655
153k
            {
656
153k
                if(CHECKBIT(ps_cur_mb_info->u2_luma_csbp, i))
657
59.4k
                {
658
59.4k
                    WORD16 *pi2_level = pi2_y_coeff + (i << 4);
659
59.4k
                    WORD16 *pi2_out = pi2_luma_res_ptr + ((i & 0x3) * BLK_SIZE) +
660
59.4k
                                      (i >> 2) * (u2_luma_stride << 2);
661
59.4k
                    PROFILE_DISABLE_IQ_IT_RECON()
662
59.4k
                    {
663
59.4k
                        if(CHECKBIT(u4_luma_dc_only_csbp, i))
664
5.83k
                        {
665
5.83k
                            ps_svc_lyr_dec->pf_iquant_itrans_luma_4x4_dc(
666
5.83k
                                pi2_level, pi2_out, u2_luma_stride,
667
5.83k
                                gau2_ih264_iquant_scale_4x4[ps_cur_mb_info->u1_qp_rem6],
668
5.83k
                                (UWORD16 *) ps_dec->s_high_profile.i2_scalinglist4x4[3],
669
5.83k
                                ps_cur_mb_info->u1_qp_div6, ai2_tmp, 0, NULL);
670
5.83k
                        }
671
53.6k
                        else
672
53.6k
                        {
673
53.6k
                            ps_svc_lyr_dec->pf_iquant_itrans_luma_4x4(
674
53.6k
                                pi2_level, pi2_out, u2_luma_stride,
675
53.6k
                                gau2_ih264_iquant_scale_4x4[ps_cur_mb_info->u1_qp_rem6],
676
53.6k
                                (UWORD16 *) ps_dec->s_high_profile.i2_scalinglist4x4[3],
677
53.6k
                                ps_cur_mb_info->u1_qp_div6, ai2_tmp, 0, NULL);
678
53.6k
                        }
679
59.4k
                    }
680
59.4k
                }
681
153k
            }
682
9.57k
        }
683
5.99k
        else
684
5.99k
        {
685
5.99k
            WORD16 *pi2_scale_matrix_ptr;
686
5.99k
            WORD32 i;
687
688
5.99k
            pi2_scale_matrix_ptr = ps_dec->s_high_profile.i2_scalinglist8x8[1];
689
690
29.9k
            for(i = 0; i < 4; i++)
691
23.9k
            {
692
23.9k
                WORD16 ai2_tmp[64] = {0};
693
23.9k
                WORD16 *pi16_levelBlock =
694
23.9k
                    pi2_y_coeff + (i << 6); /* move to the next 8x8 adding 64 */
695
696
23.9k
                WORD16 *pi2_out =
697
23.9k
                    pi2_luma_res_ptr + ((i & 0x1) * BLK8x8SIZE) + (i >> 1) * (u2_luma_stride << 3);
698
23.9k
                if(CHECKBIT(ps_cur_mb_info->u1_cbp, i))
699
12.8k
                {
700
12.8k
                    PROFILE_DISABLE_IQ_IT_RECON()
701
12.8k
                    {
702
12.8k
                        if(CHECKBIT(u4_luma_dc_only_cbp, i))
703
2.98k
                        {
704
2.98k
                            ps_svc_lyr_dec->pf_iquant_itrans_luma_8x8_dc(
705
2.98k
                                pi16_levelBlock, pi2_out, u2_luma_stride,
706
2.98k
                                gau1_ih264d_dequant8x8_cavlc[ps_cur_mb_info->u1_qp_rem6],
707
2.98k
                                (UWORD16 *) pi2_scale_matrix_ptr, ps_cur_mb_info->u1_qp_div6,
708
2.98k
                                ai2_tmp, 0, NULL);
709
2.98k
                        }
710
9.82k
                        else
711
9.82k
                        {
712
9.82k
                            ps_svc_lyr_dec->pf_iquant_itrans_luma_8x8(
713
9.82k
                                pi16_levelBlock, pi2_out, u2_luma_stride,
714
9.82k
                                gau1_ih264d_dequant8x8_cavlc[ps_cur_mb_info->u1_qp_rem6],
715
9.82k
                                (UWORD16 *) pi2_scale_matrix_ptr, ps_cur_mb_info->u1_qp_div6,
716
9.82k
                                ai2_tmp, 0, NULL);
717
9.82k
                        }
718
12.8k
                    }
719
12.8k
                }
720
23.9k
            }
721
5.99k
        }
722
15.5k
    }
723
724
    /* Decode Chroma Block */
725
76.9k
    ih264d_unpack_chroma_coeff4x4_mb(ps_dec, ps_cur_mb_info);
726
    /*--------------------------------------------------------------------*/
727
    /* Chroma Blocks decoding                                             */
728
    /*--------------------------------------------------------------------*/
729
76.9k
    {
730
76.9k
        UWORD8 u1_chroma_cbp = (UWORD8) (ps_cur_mb_info->u1_cbp >> 4);
731
732
76.9k
        if(u1_chroma_cbp != CBPC_ALLZERO)
733
7.65k
        {
734
7.65k
            UWORD32 u4_scale_u = ps_cur_mb_info->u1_qpc_div6;
735
7.65k
            UWORD32 u4_scale_v = ps_cur_mb_info->u1_qpcr_div6;
736
7.65k
            UWORD16 u2_chroma_csbp = ps_cur_mb_info->u2_chroma_csbp;
737
738
7.65k
            pi2_y_coeff = ps_dec->pi2_coeff_data;
739
740
7.65k
            {
741
7.65k
                UWORD32 i;
742
7.65k
                WORD16 ai2_tmp[16] = {0};
743
38.2k
                for(i = 0; i < 4; i++)
744
30.6k
                {
745
30.6k
                    WORD16 *pi2_level = pi2_y_coeff + (i << 4);
746
30.6k
                    WORD16 *pi2_out = pi2_chroma_res_ptr +
747
30.6k
                                      ((i & 0x1) * BLK_SIZE * YUV420SP_FACTOR) +
748
30.6k
                                      (i >> 1) * (u2_chroma_stride << 2);
749
30.6k
                    PROFILE_DISABLE_IQ_IT_RECON()
750
30.6k
                    {
751
30.6k
                        if(CHECKBIT(u2_chroma_csbp, i))
752
4.83k
                        {
753
4.83k
                            ps_svc_lyr_dec->pf_iquant_itrans_chroma_4x4(
754
4.83k
                                pi2_level, pi2_out, u2_chroma_stride,
755
4.83k
                                gau2_ih264_iquant_scale_4x4[ps_cur_mb_info->u1_qpc_rem6],
756
4.83k
                                (UWORD16 *) ps_dec->s_high_profile.i2_scalinglist4x4[4], u4_scale_u,
757
4.83k
                                ai2_tmp, pi2_level);
758
4.83k
                        }
759
25.7k
                        else if(pi2_level[0] != 0)
760
11.3k
                        {
761
11.3k
                            ps_svc_lyr_dec->pf_iquant_itrans_chroma_4x4_dc(
762
11.3k
                                pi2_level, pi2_out, u2_chroma_stride,
763
11.3k
                                gau2_ih264_iquant_scale_4x4[ps_cur_mb_info->u1_qpc_rem6],
764
11.3k
                                (UWORD16 *) ps_dec->s_high_profile.i2_scalinglist4x4[4], u4_scale_u,
765
11.3k
                                ai2_tmp, pi2_level);
766
11.3k
                        }
767
30.6k
                    }
768
30.6k
                }
769
7.65k
            }
770
771
7.65k
            pi2_y_coeff += MB_CHROM_SIZE;
772
7.65k
            u2_chroma_csbp >>= 4;
773
774
7.65k
            {
775
7.65k
                UWORD32 i;
776
7.65k
                WORD16 ai2_tmp[16] = {0};
777
38.2k
                for(i = 0; i < 4; i++)
778
30.6k
                {
779
30.6k
                    WORD16 *pi2_level = pi2_y_coeff + (i << 4);
780
30.6k
                    WORD16 *pi2_out = pi2_chroma_res_ptr + 1 +
781
30.6k
                                      ((i & 0x1) * BLK_SIZE * YUV420SP_FACTOR) +
782
30.6k
                                      (i >> 1) * (u2_chroma_stride << 2);
783
30.6k
                    PROFILE_DISABLE_IQ_IT_RECON()
784
30.6k
                    {
785
30.6k
                        if(CHECKBIT(u2_chroma_csbp, i))
786
5.69k
                        {
787
5.69k
                            ps_svc_lyr_dec->pf_iquant_itrans_chroma_4x4(
788
5.69k
                                pi2_level, pi2_out, u2_chroma_stride,
789
5.69k
                                gau2_ih264_iquant_scale_4x4[ps_cur_mb_info->u1_qpcr_rem6],
790
5.69k
                                (UWORD16 *) ps_dec->s_high_profile.i2_scalinglist4x4[5], u4_scale_v,
791
5.69k
                                ai2_tmp, pi2_level);
792
5.69k
                        }
793
24.9k
                        else if(pi2_level[0] != 0)
794
10.5k
                        {
795
10.5k
                            ps_svc_lyr_dec->pf_iquant_itrans_chroma_4x4_dc(
796
10.5k
                                pi2_level, pi2_out, u2_chroma_stride,
797
10.5k
                                gau2_ih264_iquant_scale_4x4[ps_cur_mb_info->u1_qpcr_rem6],
798
10.5k
                                (UWORD16 *) ps_dec->s_high_profile.i2_scalinglist4x4[5], u4_scale_v,
799
10.5k
                                ai2_tmp, pi2_level);
800
10.5k
                        }
801
30.6k
                    }
802
30.6k
                }
803
7.65k
            }
804
7.65k
        }
805
76.9k
    }
806
807
76.9k
    ps_svc_lyr_dec->ps_inter_lyr_mb_prms_cur_mb =
808
76.9k
        ps_svc_lyr_dec->ps_inter_lyr_mb_prms_frm_start + ps_cur_mb_info->u2_mbx +
809
76.9k
        (ps_svc_lyr_dec->u2_inter_lyr_mb_prms_stride * (ps_cur_mb_info->u2_mby));
810
76.9k
    ps_svc_lyr_dec->ps_inter_lyr_mb_prms_cur_mb->i1_mb_mode =
811
76.9k
        u1_inference_mode ? SVC_IBL_MB : SVC_INTER_MB;
812
76.9k
    ps_svc_lyr_dec->ps_inter_lyr_mb_prms_cur_mb->i1_tx_size = ps_cur_mb_info->u1_tran_form8x8;
813
76.9k
    ps_svc_lyr_dec->ps_inter_lyr_mb_prms_cur_mb->u2_luma_nnz = ps_cur_mb_info->u2_luma_csbp;
814
76.9k
    ps_svc_lyr_dec->ps_inter_lyr_mb_prms_cur_mb->u1_chroma_nnz =
815
76.9k
        (UWORD8) ps_cur_mb_info->u2_chroma_csbp;
816
76.9k
    if(CHECKBIT(ps_cur_mb_info->u1_yuv_dc_block_flag, 1))
817
3.74k
    {
818
        /* Four bits for Cb in DC only cbp */
819
3.74k
        ps_svc_lyr_dec->ps_inter_lyr_mb_prms_cur_mb->u1_chroma_nnz |= 0x0F;
820
3.74k
    }
821
76.9k
    if(CHECKBIT(ps_cur_mb_info->u1_yuv_dc_block_flag, 2))
822
3.94k
    {
823
        /* Four bits for Cr in DC only cbp */
824
3.94k
        ps_svc_lyr_dec->ps_inter_lyr_mb_prms_cur_mb->u1_chroma_nnz |= 0xF0;
825
3.94k
    }
826
76.9k
    return OK;
827
76.9k
}
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
127k
{
1121
127k
    res_prms_t *ps_res_prms;
1122
127k
    WORD32 i4_status;
1123
127k
    UWORD8 u1_ii_mb_mode = 0;
1124
127k
    mb_coord_t s_mb_coord = {0};
1125
127k
    mem_element_t s_ref_mb_mode = {0};
1126
127k
    svc_dec_lyr_struct_t *ps_svc_dec_ref_layer;
1127
1128
127k
    ps_svc_dec_ref_layer = ps_svc_lyr_dec->ps_dec_svc_ref_layer;
1129
127k
    ps_res_prms = &ps_svc_lyr_dec->s_res_prms;
1130
127k
    s_mb_coord.u2_mb_x = ps_cur_mb_info->u2_mbx;
1131
127k
    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
127k
    if(SVCD_FALSE == ps_res_prms->u1_rstrct_res_change_flag)
1136
127k
    {
1137
127k
        s_ref_mb_mode.pv_buffer = ps_svc_dec_ref_layer->ps_inter_lyr_mb_prms_frm_start;
1138
127k
        s_ref_mb_mode.i4_element_size = sizeof(inter_lyr_mb_prms_t);
1139
127k
        s_ref_mb_mode.i4_num_element_stride = ps_svc_dec_ref_layer->u2_inter_lyr_mb_prms_stride;
1140
1141
127k
        i4_status = isvcd_ii_pred_compute_flags_mb(ps_svc_lyr_dec->pv_ii_pred_ctxt, &s_ref_mb_mode,
1142
127k
                                                   &s_mb_coord, ps_cur_mb_info, ps_svc_cur_mb_info,
1143
127k
                                                   &u1_ii_mb_mode);
1144
1145
127k
        if(OK != i4_status)
1146
0
        {
1147
0
            return i4_status;
1148
0
        }
1149
127k
    }
1150
1151
127k
    if(SVC_INTRA_INTER_MB == u1_ii_mb_mode)
1152
14.9k
    {
1153
14.9k
        i4_status = isvcd_process_ibl_mb(ps_svc_lyr_dec, ps_cur_mb_info, u1_mb_num, 1);
1154
14.9k
        if(OK != i4_status)
1155
0
        {
1156
0
            return i4_status;
1157
0
        }
1158
14.9k
        isvcd_ii_pred_mb(ps_svc_lyr_dec, ps_cur_mb_info);
1159
14.9k
    }
1160
127k
    return OK;
1161
127k
}
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
40.2k
{
1178
40.2k
    WORD32 i, j;
1179
40.2k
    dec_struct_t *ps_dec = &ps_svc_lyr_dec->s_dec;
1180
40.2k
    UWORD32 u1_end_of_row_next;
1181
40.2k
    dec_mb_info_t *ps_cur_mb_info;
1182
40.2k
    dec_svc_mb_info_t *ps_svc_cur_mb_info;
1183
40.2k
    UWORD16 *pu2_res_luma_csbp;
1184
40.2k
    const UWORD32 u1_mbaff = ps_dec->ps_cur_slice->u1_mbaff_frame_flag;
1185
40.2k
    const UWORD32 u1_slice_type = ps_dec->ps_cur_slice->u1_slice_type;
1186
40.2k
    const WORD32 u1_skip_th =
1187
40.2k
        ((u1_slice_type != I_SLICE) ? (ps_dec->u1_B ? B_8x8 : PRED_8x8R0) : -1);
1188
40.2k
    const UWORD32 u1_ipcm_th = ((u1_slice_type != I_SLICE) ? (ps_dec->u1_B ? 23 : 5) : 0);
1189
40.2k
    WORD32 ret = OK;
1190
1191
40.2k
    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
180k
    for(i = u4_mb_idx; i < u4_num_mbs; i++)
1199
139k
    {
1200
139k
        ps_cur_mb_info = ps_dec->ps_nmb_info + i;
1201
139k
        ps_dec->u4_dma_buf_idx = 0;
1202
139k
        ps_dec->u4_pred_info_idx = 0;
1203
1204
        /*Pointer assignment for Residual NNZ */
1205
139k
        pu2_res_luma_csbp = ps_svc_lyr_dec->pu2_frm_res_luma_csbp + ps_cur_mb_info->u2_mbx;
1206
139k
        pu2_res_luma_csbp += ps_cur_mb_info->u2_mby * ps_svc_lyr_dec->i4_frm_res_luma_csbp_stride;
1207
1208
139k
        if(ps_cur_mb_info->u1_mb_type <= u1_skip_th)
1209
64.0k
        {
1210
64.0k
            {
1211
64.0k
                WORD32 pred_cnt = 0;
1212
64.0k
                pred_info_pkd_t *ps_pred_pkd;
1213
64.0k
                UWORD32 u4_pred_info_pkd_idx;
1214
1215
64.0k
                u4_pred_info_pkd_idx = ps_cur_mb_info->u4_pred_info_pkd_idx;
1216
1217
178k
                while(pred_cnt < ps_cur_mb_info->u1_num_pred_parts)
1218
114k
                {
1219
114k
                    ps_pred_pkd = ps_dec->ps_pred_pkd + u4_pred_info_pkd_idx;
1220
1221
114k
                    ps_dec->p_form_mb_part_info(ps_pred_pkd, ps_dec, ps_cur_mb_info->u2_mbx,
1222
114k
                                                ps_cur_mb_info->u2_mby, (i >> u1_mbaff),
1223
114k
                                                ps_cur_mb_info);
1224
114k
                    u4_pred_info_pkd_idx++;
1225
114k
                    pred_cnt++;
1226
114k
                }
1227
64.0k
            }
1228
64.0k
            if(ps_svc_lyr_dec->u1_layer_identifier == TARGET_LAYER)
1229
64.0k
            {
1230
64.0k
                ps_dec->p_motion_compensate(ps_dec, ps_cur_mb_info);
1231
64.0k
            }
1232
64.0k
        }
1233
75.7k
        else if(ps_cur_mb_info->u1_mb_type == MB_SKIP)
1234
39.3k
        {
1235
39.3k
            {
1236
39.3k
                WORD32 pred_cnt = 0;
1237
39.3k
                pred_info_pkd_t *ps_pred_pkd;
1238
39.3k
                UWORD32 u4_pred_info_pkd_idx;
1239
1240
39.3k
                u4_pred_info_pkd_idx = ps_cur_mb_info->u4_pred_info_pkd_idx;
1241
1242
98.5k
                while(pred_cnt < ps_cur_mb_info->u1_num_pred_parts)
1243
59.1k
                {
1244
59.1k
                    ps_pred_pkd = ps_dec->ps_pred_pkd + u4_pred_info_pkd_idx;
1245
1246
59.1k
                    ps_dec->p_form_mb_part_info(ps_pred_pkd, ps_dec, ps_cur_mb_info->u2_mbx,
1247
59.1k
                                                ps_cur_mb_info->u2_mby, (i >> u1_mbaff),
1248
59.1k
                                                ps_cur_mb_info);
1249
1250
59.1k
                    u4_pred_info_pkd_idx++;
1251
59.1k
                    pred_cnt++;
1252
59.1k
                }
1253
39.3k
            }
1254
39.3k
            if(ps_svc_lyr_dec->u1_layer_identifier == TARGET_LAYER)
1255
39.3k
            {
1256
                /* Decode MB skip */
1257
39.3k
                ps_dec->p_motion_compensate(ps_dec, ps_cur_mb_info);
1258
39.3k
            }
1259
1260
39.3k
            *pu2_res_luma_csbp = 0;
1261
39.3k
            ps_svc_lyr_dec->ps_inter_lyr_mb_prms_cur_mb =
1262
39.3k
                ps_svc_lyr_dec->ps_inter_lyr_mb_prms_frm_start + ps_cur_mb_info->u2_mbx +
1263
39.3k
                (ps_svc_lyr_dec->u2_inter_lyr_mb_prms_stride * (ps_cur_mb_info->u2_mby));
1264
39.3k
            ps_svc_lyr_dec->ps_inter_lyr_mb_prms_cur_mb->i1_mb_mode = SVC_INTER_MB;
1265
39.3k
            ps_svc_lyr_dec->ps_inter_lyr_mb_prms_cur_mb->i1_tx_size =
1266
39.3k
                ps_cur_mb_info->u1_tran_form8x8;
1267
39.3k
            ps_svc_lyr_dec->ps_inter_lyr_mb_prms_cur_mb->u2_luma_nnz = 0;
1268
39.3k
            ps_svc_lyr_dec->ps_inter_lyr_mb_prms_cur_mb->u1_chroma_nnz = 0;
1269
39.3k
        }
1270
139k
    }
1271
1272
    /* N Mb IQ IT RECON  Loop */
1273
180k
    for(j = u4_mb_idx; j < i; j++)
1274
139k
    {
1275
139k
        ps_cur_mb_info = ps_dec->ps_nmb_info + j;
1276
139k
        ps_svc_cur_mb_info = ps_svc_lyr_dec->ps_svc_nmb_info + j;
1277
1278
139k
        ps_svc_lyr_dec->ps_inter_lyr_mb_prms_cur_mb =
1279
139k
            ps_svc_lyr_dec->ps_inter_lyr_mb_prms_frm_start + ps_cur_mb_info->u2_mbx +
1280
139k
            (ps_svc_lyr_dec->u2_inter_lyr_mb_prms_stride * (ps_cur_mb_info->u2_mby));
1281
1282
139k
        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
139k
        pu2_res_luma_csbp = ps_svc_lyr_dec->pu2_frm_res_luma_csbp + ps_cur_mb_info->u2_mbx;
1286
139k
        pu2_res_luma_csbp += ps_cur_mb_info->u2_mby * ps_svc_lyr_dec->i4_frm_res_luma_csbp_stride;
1287
1288
139k
        if(ps_cur_mb_info->u1_mb_type <= u1_skip_th)
1289
64.0k
        {
1290
64.0k
            if(ps_svc_lyr_dec->u1_layer_identifier == TARGET_LAYER)
1291
64.0k
            {
1292
                /* inter intra pred generation */
1293
64.0k
                if(SVCD_FALSE == ps_svc_lyr_dec->u1_dyadic_flag)
1294
28.7k
                {
1295
28.7k
                    ret =
1296
28.7k
                        isvcd_process_ii_mb(ps_svc_lyr_dec, ps_cur_mb_info, ps_svc_cur_mb_info, j);
1297
28.7k
                    if(ret != OK) return ret;
1298
28.7k
                }
1299
64.0k
                if(0 == ps_svc_cur_mb_info->u1_residual_prediction_flag)
1300
21.6k
                {
1301
                    // IT + Recon
1302
21.6k
                    ih264d_process_inter_mb(ps_dec, ps_cur_mb_info, j);
1303
21.6k
                    isvcd_update_inter_mb_inter_layer_info(ps_svc_lyr_dec, ps_cur_mb_info, 0);
1304
21.6k
                    *pu2_res_luma_csbp = ps_cur_mb_info->u2_luma_csbp;
1305
21.6k
                }
1306
42.3k
                else
1307
42.3k
                {
1308
                    // IT + Residual + Recon
1309
42.3k
                    ret = isvcd_process_inter_mb_rsd_pred_target_lyr(ps_svc_lyr_dec, ps_cur_mb_info,
1310
42.3k
                                                                     j, 0, pu2_res_luma_csbp);
1311
42.3k
                    if(ret != OK) return ret;
1312
42.3k
                }
1313
64.0k
            }
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
64.0k
        }
1337
75.7k
        else if((ps_cur_mb_info->u1_mb_type != MB_SKIP) && (ps_cur_mb_info->u1_mb_type != MB_INFER))
1338
7.80k
        {
1339
7.80k
            if((u1_ipcm_th + 25) != ps_cur_mb_info->u1_mb_type)
1340
7.65k
            {
1341
7.65k
                ps_cur_mb_info->u1_mb_type -= (u1_skip_th + 1);
1342
7.65k
                ih264d_process_intra_mb(ps_dec, ps_cur_mb_info, j);
1343
7.65k
                isvcd_update_intra_mb_inter_layer_info(ps_svc_lyr_dec, ps_cur_mb_info);
1344
7.65k
            }
1345
145
            else
1346
145
            {
1347
145
                isvcd_update_ipcm_mb_inter_layer_info(ps_svc_lyr_dec, ps_cur_mb_info);
1348
145
            }
1349
7.80k
            *pu2_res_luma_csbp = 0;
1350
7.80k
        }
1351
67.9k
        else if(ps_cur_mb_info->u1_mb_type == MB_INFER)
1352
28.6k
        {
1353
            /* inter layer intra prediction : intra upsample, IQ, IT ,deblock */
1354
            /* Intra resample for IBL mode */
1355
28.6k
            ret = isvcd_process_ibl_mb(ps_svc_lyr_dec, ps_cur_mb_info, j, 0);
1356
28.6k
            if(ret != OK) return ret;
1357
28.6k
            ih264d_process_inter_mb(ps_dec, ps_cur_mb_info, j);
1358
28.6k
            isvcd_update_inter_mb_inter_layer_info(ps_svc_lyr_dec, ps_cur_mb_info, 1);
1359
28.6k
            *pu2_res_luma_csbp = ps_cur_mb_info->u2_luma_csbp;
1360
1361
28.6k
            ps_dec->pi1_left_pred_mode[0] = DC;
1362
28.6k
            ps_dec->pi1_left_pred_mode[1] = DC;
1363
28.6k
            ps_dec->pi1_left_pred_mode[2] = DC;
1364
28.6k
            ps_dec->pi1_left_pred_mode[3] = DC;
1365
1366
28.6k
            ps_cur_mb_info->ps_curmb->pi1_intrapredmodes[0] = DC;
1367
28.6k
            ps_cur_mb_info->ps_curmb->pi1_intrapredmodes[1] = DC;
1368
28.6k
            ps_cur_mb_info->ps_curmb->pi1_intrapredmodes[2] = DC;
1369
28.6k
            ps_cur_mb_info->ps_curmb->pi1_intrapredmodes[3] = DC;
1370
1371
28.6k
            isvcd_update_ibl_mb_inter_layer_info(ps_svc_lyr_dec, ps_cur_mb_info);
1372
28.6k
        }
1373
1374
139k
        if(ps_svc_lyr_dec->u1_layer_identifier == TARGET_LAYER)
1375
139k
        {
1376
139k
            if(ps_dec->u4_num_cores < 3)
1377
139k
            {
1378
139k
                if(ps_dec->u4_app_disable_deblk_frm == 0)
1379
139k
                    ps_svc_lyr_dec->pf_svc_compute_bs(ps_svc_lyr_dec, ps_cur_mb_info,
1380
139k
                                                      (UWORD16) (j >> u1_mbaff));
1381
139k
            }
1382
139k
        }
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
139k
        if(ps_dec->u4_use_intrapred_line_copy)
1394
139k
        {
1395
139k
            ih264d_copy_intra_pred_line(ps_dec, ps_cur_mb_info, j);
1396
139k
        }
1397
139k
    }
1398
1399
    /*MB deblocking*/
1400
40.2k
    if(ps_dec->u4_nmb_deblk == 1)
1401
40.2k
    {
1402
40.2k
        UWORD32 u4_wd_y, u4_wd_uv;
1403
40.2k
        tfr_ctxt_t *ps_tfr_cxt = &(ps_dec->s_tran_addrecon);
1404
40.2k
        UWORD8 u1_field_pic_flag = ps_dec->ps_cur_slice->u1_field_pic_flag;
1405
40.2k
        const WORD32 i4_cb_qp_idx_ofst = ps_dec->ps_cur_pps->i1_chroma_qp_index_offset;
1406
40.2k
        const WORD32 i4_cr_qp_idx_ofst = ps_dec->ps_cur_pps->i1_second_chroma_qp_index_offset;
1407
1408
40.2k
        u4_wd_y = ps_dec->u2_frm_wd_y << u1_field_pic_flag;
1409
40.2k
        u4_wd_uv = ps_dec->u2_frm_wd_uv << u1_field_pic_flag;
1410
1411
40.2k
        ps_cur_mb_info = ps_dec->ps_nmb_info + u4_mb_idx;
1412
1413
40.2k
        ps_dec->u4_deblk_mb_x = ps_cur_mb_info->u2_mbx;
1414
40.2k
        ps_dec->u4_deblk_mb_y = ps_cur_mb_info->u2_mby;
1415
1416
180k
        for(j = u4_mb_idx; j < i; j++)
1417
139k
        {
1418
139k
            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
139k
            ih264d_deblock_mb_nonmbaff(ps_dec, ps_tfr_cxt, i4_cb_qp_idx_ofst, i4_cr_qp_idx_ofst,
1423
139k
                                       u4_wd_y, u4_wd_uv);
1424
139k
        }
1425
40.2k
    }
1426
1427
40.2k
    if(u4_tfr_n_mb)
1428
40.2k
    {
1429
        /****************************************************************/
1430
        /* Check for End Of Row in Next iteration                       */
1431
        /****************************************************************/
1432
40.2k
        u1_end_of_row_next =
1433
40.2k
            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
40.2k
        ih264d_transfer_mb_group_data(ps_dec, u4_num_mbs, u4_end_of_row, u1_end_of_row_next);
1444
40.2k
        ps_dec->u4_num_mbs_prev_nmb = u4_num_mbs;
1445
40.2k
        ps_dec->u4_pred_info_idx = 0;
1446
40.2k
        ps_dec->u4_dma_buf_idx = 0;
1447
40.2k
    }
1448
40.2k
    return OK;
1449
40.2k
}
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
261k
{
1465
261k
    WORD32 j;
1466
261k
    dec_struct_t *ps_dec = &ps_svc_lyr_dec->s_dec;
1467
261k
    UWORD32 u1_end_of_row_next;
1468
261k
    dec_mb_info_t *ps_cur_mb_info;
1469
261k
    const UWORD32 u1_mbaff = ps_dec->ps_cur_slice->u1_mbaff_frame_flag;
1470
261k
    const UWORD32 u1_slice_type = ps_dec->ps_cur_slice->u1_slice_type;
1471
261k
    const WORD32 u1_skip_th =
1472
261k
        ((u1_slice_type != I_SLICE) ? (ps_dec->u1_B ? B_8x8 : PRED_8x8R0) : -1);
1473
261k
    const UWORD32 u1_ipcm_th = ((u1_slice_type != I_SLICE) ? (ps_dec->u1_B ? 23 : 5) : 0);
1474
261k
    WORD32 ret = OK;
1475
1476
261k
    if(1 != ps_svc_lyr_dec->u1_base_res_flag)
1477
0
    {
1478
0
        return NOT_OK;
1479
0
    }
1480
261k
    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
1.06M
    for(j = u1_mb_idx; j < u4_num_mbs; j++)
1487
802k
    {
1488
802k
        ps_dec->u4_dma_buf_idx = 0;
1489
802k
        ps_dec->u4_pred_info_idx = 0;
1490
802k
        ps_cur_mb_info = ps_dec->ps_nmb_info + j;
1491
1492
802k
        ps_svc_lyr_dec->ps_inter_lyr_mb_prms_cur_mb =
1493
802k
            ps_svc_lyr_dec->ps_inter_lyr_mb_prms_frm_start + ps_cur_mb_info->u2_mbx +
1494
802k
            (ps_svc_lyr_dec->u2_inter_lyr_mb_prms_stride * (ps_cur_mb_info->u2_mby));
1495
1496
802k
        ps_svc_lyr_dec->ps_inter_lyr_mb_prms_cur_mb->i1_slice_id = (WORD8) ps_dec->u2_cur_slice_num;
1497
1498
802k
        if(ps_cur_mb_info->u1_mb_type == MB_SKIP)
1499
699k
        {
1500
699k
            ps_svc_lyr_dec->ps_inter_lyr_mb_prms_cur_mb->i1_mb_mode = SVC_INTER_MB;
1501
699k
            ps_svc_lyr_dec->ps_inter_lyr_mb_prms_cur_mb->i1_tx_size =
1502
699k
                ps_cur_mb_info->u1_tran_form8x8;
1503
699k
            ps_svc_lyr_dec->ps_inter_lyr_mb_prms_cur_mb->u2_luma_nnz = 0;
1504
699k
            ps_svc_lyr_dec->ps_inter_lyr_mb_prms_cur_mb->u1_chroma_nnz = 0;
1505
699k
        }
1506
102k
        else if(ps_cur_mb_info->u1_mb_type <= u1_skip_th)
1507
76.9k
        {
1508
            /* Only IT : Store Residual (WORD16) for Higher Layers : Base layer*/
1509
76.9k
            ret = isvcd_process_inter_mb_no_rsd_pred_non_target(ps_svc_lyr_dec, ps_cur_mb_info, 0);
1510
76.9k
            if(ret != OK) return ret;
1511
76.9k
        }
1512
25.4k
        else if(ps_cur_mb_info->u1_mb_type != MB_SKIP)
1513
25.4k
        {
1514
25.4k
            if((u1_ipcm_th + 25) != ps_cur_mb_info->u1_mb_type)
1515
24.8k
            {
1516
24.8k
                ps_cur_mb_info->u1_mb_type -= (u1_skip_th + 1);
1517
24.8k
                ih264d_process_intra_mb(ps_dec, ps_cur_mb_info, j);
1518
24.8k
                isvcd_update_intra_mb_inter_layer_info(ps_svc_lyr_dec, ps_cur_mb_info);
1519
24.8k
            }
1520
635
            else
1521
635
            {
1522
635
                isvcd_update_ipcm_mb_inter_layer_info(ps_svc_lyr_dec, ps_cur_mb_info);
1523
635
            }
1524
25.4k
        }
1525
1526
802k
        if(ps_dec->u4_use_intrapred_line_copy)
1527
802k
        {
1528
802k
            ih264d_copy_intra_pred_line(ps_dec, ps_cur_mb_info, j);
1529
802k
        }
1530
802k
    }
1531
1532
    /*MB deblocking*/
1533
261k
    if(ps_dec->u4_nmb_deblk == 1)
1534
261k
    {
1535
261k
        UWORD32 u4_wd_y, u4_wd_uv;
1536
261k
        tfr_ctxt_t *ps_tfr_cxt = &(ps_dec->s_tran_addrecon);
1537
261k
        UWORD8 u1_field_pic_flag = ps_dec->ps_cur_slice->u1_field_pic_flag;
1538
261k
        const WORD32 i4_cb_qp_idx_ofst = ps_dec->ps_cur_pps->i1_chroma_qp_index_offset;
1539
261k
        const WORD32 i4_cr_qp_idx_ofst = ps_dec->ps_cur_pps->i1_second_chroma_qp_index_offset;
1540
1541
261k
        u4_wd_y = ps_dec->u2_frm_wd_y << u1_field_pic_flag;
1542
261k
        u4_wd_uv = ps_dec->u2_frm_wd_uv << u1_field_pic_flag;
1543
1544
261k
        ps_cur_mb_info = ps_dec->ps_nmb_info + u1_mb_idx;
1545
1546
261k
        ps_dec->u4_deblk_mb_x = ps_cur_mb_info->u2_mbx;
1547
261k
        ps_dec->u4_deblk_mb_y = ps_cur_mb_info->u2_mby;
1548
1549
1.06M
        for(j = u1_mb_idx; j < u4_num_mbs; j++)
1550
802k
        {
1551
            /* IN SVC base layers only intra MB's Need to be deblocked*/
1552
802k
            deblk_mb_t *ps_top_mb, *ps_left_mb, *ps_cur_mb;
1553
802k
            ps_cur_mb = ps_dec->ps_cur_deblk_mb;
1554
802k
            if(!(ps_cur_mb->u1_deblocking_mode & MB_DISABLE_FILTERING))
1555
25.4k
            {
1556
25.4k
                if(ps_dec->u4_deblk_mb_x)
1557
13.6k
                {
1558
13.6k
                    ps_left_mb = ps_cur_mb - 1;
1559
13.6k
                }
1560
11.7k
                else
1561
11.7k
                {
1562
11.7k
                    ps_left_mb = NULL;
1563
11.7k
                }
1564
25.4k
                if(ps_dec->u4_deblk_mb_y != 0)
1565
19.0k
                {
1566
19.0k
                    ps_top_mb = ps_cur_mb - (ps_dec->u2_frm_wd_in_mbs);
1567
19.0k
                }
1568
6.37k
                else
1569
6.37k
                {
1570
6.37k
                    ps_top_mb = NULL;
1571
6.37k
                }
1572
1573
25.4k
                if(ps_cur_mb->u1_deblocking_mode & MB_DISABLE_LEFT_EDGE) ps_left_mb = NULL;
1574
25.4k
                if(ps_cur_mb->u1_deblocking_mode & MB_DISABLE_TOP_EDGE) ps_top_mb = NULL;
1575
1576
                /* Top Horizontal Edge*/
1577
25.4k
                if(NULL != ps_top_mb)
1578
19.0k
                {
1579
19.0k
                    if(!(ps_top_mb->u1_mb_type & D_INTRA_MB))
1580
13.0k
                    {
1581
13.0k
                        ps_cur_mb->u4_bs_table[0] = 0;
1582
13.0k
                    }
1583
19.0k
                }
1584
6.37k
                else
1585
6.37k
                {
1586
6.37k
                    ps_cur_mb->u4_bs_table[0] = 0;
1587
6.37k
                }
1588
1589
                /* Left Vertical Edge*/
1590
25.4k
                if(NULL != ps_left_mb)
1591
13.6k
                {
1592
13.6k
                    if(!(ps_left_mb->u1_mb_type & D_INTRA_MB))
1593
8.49k
                    {
1594
8.49k
                        ps_cur_mb->u4_bs_table[4] = 0;
1595
8.49k
                    }
1596
13.6k
                }
1597
11.7k
                else
1598
11.7k
                {
1599
11.7k
                    ps_cur_mb->u4_bs_table[4] = 0;
1600
11.7k
                }
1601
25.4k
            }
1602
1603
802k
            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
802k
            ih264d_deblock_mb_nonmbaff(ps_dec, ps_tfr_cxt, i4_cb_qp_idx_ofst, i4_cr_qp_idx_ofst,
1609
802k
                                       u4_wd_y, u4_wd_uv);
1610
802k
        }
1611
261k
    }
1612
1613
261k
    if(u4_tfr_n_mb)
1614
261k
    {
1615
        /****************************************************************/
1616
        /* Check for End Of Row in Next iteration                       */
1617
        /****************************************************************/
1618
261k
        u1_end_of_row_next =
1619
261k
            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
261k
        ih264d_transfer_mb_group_data(ps_dec, u4_num_mbs, u4_end_of_row, u1_end_of_row_next);
1630
261k
        ps_dec->u4_num_mbs_prev_nmb = u4_num_mbs;
1631
261k
        ps_dec->u4_pred_info_idx = 0;
1632
261k
        ps_dec->u4_dma_buf_idx = 0;
1633
261k
    }
1634
261k
    return OK;
1635
261k
}
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
96.2k
{
1651
96.2k
    dec_struct_t *ps_dec = &ps_svc_lyr_dec->s_dec;
1652
96.2k
    intra_sampling_ctxt_t *ps_ctxt;
1653
96.2k
    svc_dec_lyr_struct_t *ps_svc_dec_ref_layer;
1654
96.2k
    pic_buffer_t *ps_frame_buf = ps_dec->ps_cur_pic;
1655
96.2k
    pic_buffer_t *ps_frame_buf_ref_layer;
1656
96.2k
    intra_samp_lyr_ctxt *ps_lyr_ctxt;
1657
96.2k
    mem_element_t s_ref_mb_mode = {0};
1658
96.2k
    mem_element_t s_inp_luma = {0};
1659
96.2k
    mem_element_t s_inp_chroma = {0};
1660
96.2k
    mem_element_t s_out_luma = {0};
1661
96.2k
    mem_element_t s_out_chroma = {0};
1662
96.2k
    WORD32 i4_ref_x_luma, i4_ref_y_luma, i4_luma_incr = 0;
1663
96.2k
    WORD32 i4_ref_x_chroma, i4_ref_y_chroma, i4_chroma_incr = 0;
1664
96.2k
    UWORD32 u4_cur_y_stride, u4_cur_uv_stride;
1665
96.2k
    UWORD32 u4_ref_y_stride, u4_ref_uv_stride;
1666
96.2k
    WORD32 i4_ref_luma_instra_sample_correction_offset = 0;
1667
96.2k
    WORD32 i4_ref_chroma_instra_sample_correction_offset = 0;
1668
96.2k
    ref_mb_map_t *ps_x_off_len_luma;
1669
96.2k
    ref_mb_map_t *ps_y_off_len_luma;
1670
96.2k
    ref_mb_map_t *ps_x_off_len_chroma;
1671
96.2k
    ref_mb_map_t *ps_y_off_len_chroma;
1672
96.2k
    mb_coord_t s_mb_coord = {0};
1673
96.2k
    WORD32 ret = OK;
1674
96.2k
    UNUSED(u4_mb_num);
1675
1676
96.2k
    ps_ctxt = (intra_sampling_ctxt_t *) ps_svc_lyr_dec->pv_intra_sample_ctxt;
1677
96.2k
    ps_svc_dec_ref_layer = ps_svc_lyr_dec->ps_dec_svc_ref_layer;
1678
1679
96.2k
    ps_lyr_ctxt = &ps_ctxt->as_res_lyrs[ps_ctxt->i4_res_lyr_id];
1680
96.2k
    u4_cur_y_stride = ps_dec->u2_frm_wd_y;
1681
96.2k
    u4_cur_uv_stride = ps_dec->u2_frm_wd_uv;
1682
96.2k
    u4_ref_y_stride = ps_svc_dec_ref_layer->s_dec.u2_frm_wd_y;
1683
96.2k
    u4_ref_uv_stride = ps_svc_dec_ref_layer->s_dec.u2_frm_wd_uv;
1684
1685
96.2k
    ps_frame_buf_ref_layer = ps_svc_dec_ref_layer->s_dec.ps_cur_pic;
1686
96.2k
    if(0 == u1_inter_intra_mode)
1687
81.2k
    {
1688
81.2k
        s_out_luma.pv_buffer = ps_frame_buf->pu1_buf1 + (ps_cur_mb_info->u2_mbx << 4) +
1689
81.2k
                               (u4_cur_y_stride * (ps_cur_mb_info->u2_mby << 4));
1690
81.2k
        s_out_luma.i4_element_size = 1;
1691
81.2k
        s_out_luma.i4_num_element_stride = u4_cur_y_stride;
1692
1693
81.2k
        s_out_chroma.pv_buffer = ps_frame_buf->pu1_buf2 +
1694
81.2k
                                 (ps_cur_mb_info->u2_mbx << 3) * YUV420SP_FACTOR +
1695
81.2k
                                 (u4_cur_uv_stride * (ps_cur_mb_info->u2_mby << 3));
1696
81.2k
        s_out_chroma.i4_element_size = 1;
1697
81.2k
        s_out_chroma.i4_num_element_stride = u4_cur_uv_stride;
1698
81.2k
    }
1699
14.9k
    else
1700
14.9k
    {
1701
14.9k
        if(SVCD_TRUE == ps_svc_lyr_dec->s_res_prms.u1_dyadic_flag)
1702
0
        {
1703
0
            return NOT_OK;
1704
0
        }
1705
1706
14.9k
        s_out_luma.pv_buffer = ps_svc_lyr_dec->pu1_ii_resamp_buffer_luma;
1707
14.9k
        s_out_luma.i4_element_size = 1;
1708
14.9k
        s_out_luma.i4_num_element_stride = MB_SIZE;
1709
1710
14.9k
        s_out_chroma.pv_buffer = ps_svc_lyr_dec->pu1_ii_resamp_buffer_chroma;
1711
14.9k
        s_out_chroma.i4_element_size = 1;
1712
14.9k
        s_out_chroma.i4_num_element_stride = MB_SIZE;
1713
14.9k
    }
1714
1715
    /* get the projected locations buffer pointers */
1716
96.2k
    {
1717
96.2k
        intra_samp_map_ctxt_t *ps_luma_map, *ps_chroma_map;
1718
1719
96.2k
        ps_luma_map = &ps_lyr_ctxt->s_luma_map_ctxt;
1720
96.2k
        ps_chroma_map = &ps_lyr_ctxt->s_chroma_map_ctxt;
1721
1722
96.2k
        ps_x_off_len_luma = ps_luma_map->ps_x_offset_length;
1723
96.2k
        ps_y_off_len_luma = ps_luma_map->ps_y_offset_length;
1724
96.2k
        ps_x_off_len_chroma = ps_chroma_map->ps_x_offset_length;
1725
96.2k
        ps_y_off_len_chroma = ps_chroma_map->ps_y_offset_length;
1726
96.2k
    }
1727
96.2k
    i4_ref_x_luma = ps_svc_lyr_dec->ps_intsam_luma_map_horz[ps_cur_mb_info->u2_mbx].i2_offset;
1728
96.2k
    i4_ref_y_luma = ps_svc_lyr_dec->ps_intsam_luma_map_vert[ps_cur_mb_info->u2_mby].i2_offset;
1729
1730
96.2k
    i4_luma_incr = ps_x_off_len_luma[ps_cur_mb_info->u2_mbx].i2_offset - i4_ref_x_luma;
1731
96.2k
    i4_luma_incr +=
1732
96.2k
        (ps_y_off_len_luma[ps_cur_mb_info->u2_mby].i2_offset - i4_ref_y_luma) * u4_ref_y_stride;
1733
1734
96.2k
    i4_ref_x_chroma = ps_svc_lyr_dec->ps_intsam_chroma_map_horz[ps_cur_mb_info->u2_mbx].i2_offset;
1735
96.2k
    i4_ref_y_chroma = ps_svc_lyr_dec->ps_intsam_chroma_map_vert[ps_cur_mb_info->u2_mby].i2_offset;
1736
1737
96.2k
    i4_chroma_incr = ps_x_off_len_chroma[ps_cur_mb_info->u2_mbx].i2_offset - i4_ref_x_chroma;
1738
96.2k
    i4_chroma_incr <<= 1;
1739
96.2k
    i4_chroma_incr += (ps_y_off_len_chroma[ps_cur_mb_info->u2_mby].i2_offset - i4_ref_y_chroma) *
1740
96.2k
                      u4_ref_uv_stride;
1741
96.2k
    if(SVCD_FALSE == ps_svc_lyr_dec->s_res_prms.u1_dyadic_flag)
1742
41.9k
    {
1743
41.9k
        i4_ref_x_luma = CLIP3(0, (ps_svc_dec_ref_layer->s_dec.u2_frm_wd_y - 1), i4_ref_x_luma);
1744
41.9k
        i4_ref_y_luma = CLIP3(0, (ps_svc_dec_ref_layer->s_dec.u2_frm_ht_y - 1), i4_ref_y_luma);
1745
41.9k
    }
1746
1747
96.2k
    i4_ref_luma_instra_sample_correction_offset =
1748
96.2k
        i4_ref_x_luma + (i4_ref_y_luma) * (WORD32) u4_ref_y_stride;
1749
1750
96.2k
    s_inp_luma.pv_buffer = ps_frame_buf_ref_layer->pu1_buf1 + i4_luma_incr +
1751
96.2k
                           i4_ref_luma_instra_sample_correction_offset;
1752
96.2k
    s_inp_luma.i4_element_size = 1;
1753
96.2k
    s_inp_luma.i4_num_element_stride = u4_ref_y_stride;
1754
1755
96.2k
    if(SVCD_FALSE == ps_svc_lyr_dec->s_res_prms.u1_dyadic_flag)
1756
41.9k
    {
1757
41.9k
        i4_ref_x_chroma = CLIP3(0, (ps_svc_dec_ref_layer->s_dec.u2_frm_wd_uv - 1), i4_ref_x_chroma);
1758
41.9k
        i4_ref_y_chroma = CLIP3(0, (ps_svc_dec_ref_layer->s_dec.u2_frm_ht_uv - 1), i4_ref_y_chroma);
1759
41.9k
    }
1760
96.2k
    i4_ref_chroma_instra_sample_correction_offset =
1761
96.2k
        (i4_ref_x_chroma << 1) + (i4_ref_y_chroma) * (WORD32) u4_ref_uv_stride;
1762
1763
96.2k
    s_inp_chroma.pv_buffer = ps_frame_buf_ref_layer->pu1_buf2 + i4_chroma_incr +
1764
96.2k
                             i4_ref_chroma_instra_sample_correction_offset;
1765
96.2k
    s_inp_chroma.i4_element_size = 1;
1766
96.2k
    s_inp_chroma.i4_num_element_stride = u4_ref_uv_stride;
1767
1768
96.2k
    s_ref_mb_mode.pv_buffer = ps_svc_dec_ref_layer->ps_inter_lyr_mb_prms_frm_start;
1769
96.2k
    s_ref_mb_mode.i4_element_size = sizeof(inter_lyr_mb_prms_t);
1770
96.2k
    s_ref_mb_mode.i4_num_element_stride = ps_svc_dec_ref_layer->u2_inter_lyr_mb_prms_stride;
1771
1772
96.2k
    s_mb_coord.u2_mb_x = ps_cur_mb_info->u2_mbx;
1773
96.2k
    s_mb_coord.u2_mb_y = ps_cur_mb_info->u2_mby;
1774
1775
96.2k
    if(SVCD_TRUE == ps_svc_lyr_dec->s_res_prms.u1_dyadic_flag)
1776
54.2k
    {
1777
54.2k
        ret = isvcd_intra_resamp_mb_dyadic(ps_ctxt, &s_inp_luma, &s_inp_chroma, &s_ref_mb_mode,
1778
54.2k
                                           &s_out_luma, &s_out_chroma, &s_mb_coord, ps_svc_lyr_dec);
1779
54.2k
    }
1780
41.9k
    else
1781
41.9k
    {
1782
41.9k
        ret = isvcd_intra_resamp_mb(ps_ctxt, &s_inp_luma, &s_inp_chroma, &s_ref_mb_mode,
1783
41.9k
                                    &s_out_luma, &s_out_chroma, &s_mb_coord);
1784
41.9k
    }
1785
96.2k
    if(OK != ret) return ret;
1786
96.2k
    return OK;
1787
96.2k
}
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
154k
{
1803
154k
    residual_sampling_ctxt_t *ps_ctxt;
1804
154k
    svc_dec_lyr_struct_t *ps_svc_dec_ref_layer;
1805
154k
    res_lyr_ctxt *ps_lyr_ctxt;
1806
154k
    mem_element_t s_ref_mb_mode = {0};
1807
154k
    mem_element_t s_inp_luma = {0};
1808
154k
    mem_element_t s_inp_chroma = {0};
1809
154k
    mem_element_t s_out_luma = {0};
1810
154k
    mem_element_t s_out_chroma = {0};
1811
1812
    /* projected locations pointer */
1813
154k
    ref_mb_map_t *ps_x_off_len_luma;
1814
154k
    ref_mb_map_t *ps_y_off_len_luma;
1815
154k
    ref_mb_map_t *ps_x_off_len_chroma;
1816
154k
    ref_mb_map_t *ps_y_off_len_chroma;
1817
154k
    WORD32 i4_ref_x_luma, i4_ref_y_luma;
1818
154k
    WORD32 i4_ref_x_chroma, i4_ref_y_chroma;
1819
154k
    WORD32 i4_ref_luma_ressam_correction_offset = 0;
1820
154k
    WORD32 i4_ref_chroma_ressam_correction_offset = 0;
1821
154k
    WORD32 i4_inp_luma_stride, i4_inp_chroma_stride;
1822
154k
    WORD32 i4_out_luma_stride, i4_out_chroma_stride;
1823
154k
    WORD32 i4_inp_luma_offset = 0, i4_inp_chroma_offset = 0;
1824
154k
    WORD32 ret;
1825
1826
154k
    ps_svc_dec_ref_layer = ps_svc_lyr_dec->ps_dec_svc_ref_layer;
1827
154k
    ps_ctxt = (residual_sampling_ctxt_t *) ps_svc_lyr_dec->pv_residual_sample_ctxt;
1828
154k
    ps_lyr_ctxt = &ps_ctxt->as_res_lyrs[ps_ctxt->i4_res_lyr_id];
1829
1830
154k
    i4_inp_luma_stride = ps_svc_dec_ref_layer->u2_residual_resample_luma_stride;
1831
154k
    i4_inp_chroma_stride = ps_svc_dec_ref_layer->u2_residual_resample_chroma_stride;
1832
154k
    i4_out_luma_stride = ps_svc_lyr_dec->u2_residual_resample_luma_stride;
1833
154k
    i4_out_chroma_stride = ps_svc_lyr_dec->u2_residual_resample_chroma_stride;
1834
1835
154k
    {
1836
154k
        residual_samp_map_ctxt_t *ps_luma_map, *ps_chroma_map;
1837
1838
154k
        ps_luma_map = &ps_lyr_ctxt->s_luma_map_ctxt;
1839
154k
        ps_chroma_map = &ps_lyr_ctxt->s_chroma_map_ctxt;
1840
154k
        ps_x_off_len_luma = ps_luma_map->ps_x_offset_length;
1841
154k
        ps_y_off_len_luma = ps_luma_map->ps_y_offset_length;
1842
154k
        ps_x_off_len_chroma = ps_chroma_map->ps_x_offset_length;
1843
154k
        ps_y_off_len_chroma = ps_chroma_map->ps_y_offset_length;
1844
154k
    }
1845
154k
    i4_ref_x_luma = ps_svc_lyr_dec->ps_ressam_luma_map_horz[ps_cur_mb_info->u2_mbx].i2_offset;
1846
154k
    i4_ref_y_luma = ps_svc_lyr_dec->ps_ressam_luma_map_vert[ps_cur_mb_info->u2_mby].i2_offset;
1847
1848
154k
    i4_ref_x_chroma = ps_svc_lyr_dec->ps_ressam_chroma_map_horz[ps_cur_mb_info->u2_mbx].i2_offset;
1849
154k
    i4_ref_y_chroma = ps_svc_lyr_dec->ps_ressam_chroma_map_vert[ps_cur_mb_info->u2_mby].i2_offset;
1850
1851
154k
    i4_ref_x_luma = CLIP3(0, (ps_lyr_ctxt->i4_ref_width - 1), i4_ref_x_luma);
1852
154k
    i4_ref_y_luma = CLIP3(0, (ps_lyr_ctxt->i4_ref_height - 1), i4_ref_y_luma);
1853
154k
    i4_ref_x_chroma = CLIP3(0, ((ps_lyr_ctxt->i4_ref_width >> 1) - 1), i4_ref_x_chroma);
1854
154k
    i4_ref_y_chroma = CLIP3(0, ((ps_lyr_ctxt->i4_ref_height >> 1) - 1), i4_ref_y_chroma);
1855
1856
154k
    {
1857
154k
        WORD32 i4_offset_x, i4_offset_y;
1858
1859
154k
        i4_offset_x = ps_x_off_len_luma[ps_cur_mb_info->u2_mbx].i2_offset;
1860
154k
        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
154k
        if(0 <= i4_offset_x)
1864
106k
        {
1865
            /* validity of pointer passed */
1866
106k
            if(!(i4_offset_x >= i4_ref_x_luma))
1867
0
            {
1868
0
                return NOT_OK;
1869
0
            }
1870
106k
            i4_inp_luma_offset += (i4_offset_x - i4_ref_x_luma);
1871
106k
        }
1872
1873
154k
        if(0 <= i4_offset_y)
1874
132k
        {
1875
            /* validity of pointer passed */
1876
132k
            if(!(i4_offset_y >= i4_ref_y_luma))
1877
0
            {
1878
0
                return NOT_OK;
1879
0
            }
1880
132k
            i4_inp_luma_offset += (i4_offset_y - i4_ref_y_luma) * i4_inp_luma_stride;
1881
132k
        }
1882
1883
154k
        i4_offset_x = ps_x_off_len_chroma[ps_cur_mb_info->u2_mbx].i2_offset;
1884
154k
        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
154k
        if(0 <= i4_offset_x)
1888
106k
        {
1889
            /* validity of pointer passed */
1890
106k
            if(!(i4_offset_x >= i4_ref_x_chroma))
1891
0
            {
1892
0
                return NOT_OK;
1893
0
            }
1894
106k
            i4_inp_chroma_offset += (i4_offset_x - i4_ref_x_chroma) << 1;
1895
106k
        }
1896
1897
154k
        if(0 <= i4_offset_y)
1898
132k
        {
1899
            /* validity of pointer passed */
1900
132k
            if(!(i4_offset_y >= i4_ref_y_chroma))
1901
0
            {
1902
0
                return NOT_OK;
1903
0
            }
1904
132k
            i4_inp_chroma_offset += (i4_offset_y - i4_ref_y_chroma) * (i4_inp_chroma_stride << 1);
1905
132k
        }
1906
154k
    }
1907
1908
154k
    i4_ref_luma_ressam_correction_offset = i4_ref_x_luma + (i4_ref_y_luma) *i4_inp_luma_stride;
1909
1910
154k
    s_inp_luma.pv_buffer = ps_svc_dec_ref_layer->pi2_il_residual_resample_mb_luma_frm_start +
1911
154k
                           i4_inp_luma_offset + i4_ref_luma_ressam_correction_offset;
1912
154k
    s_inp_luma.i4_element_size = 1;
1913
154k
    s_inp_luma.i4_num_element_stride = i4_inp_luma_stride;
1914
1915
154k
    i4_ref_chroma_ressam_correction_offset =
1916
154k
        (i4_ref_x_chroma << 1) + (i4_ref_y_chroma) *i4_inp_chroma_stride;
1917
1918
154k
    s_inp_chroma.pv_buffer = ps_svc_dec_ref_layer->pi2_il_residual_resample_mb_chroma_frm_start +
1919
154k
                             i4_inp_chroma_offset + i4_ref_chroma_ressam_correction_offset;
1920
154k
    s_inp_chroma.i4_element_size = 1;
1921
154k
    s_inp_chroma.i4_num_element_stride = i4_inp_luma_stride;
1922
1923
154k
    s_ref_mb_mode.pv_buffer = ps_svc_dec_ref_layer->ps_inter_lyr_mb_prms_frm_start;
1924
154k
    s_ref_mb_mode.i4_element_size = sizeof(inter_lyr_mb_prms_t);
1925
154k
    s_ref_mb_mode.i4_num_element_stride = ps_svc_dec_ref_layer->u2_inter_lyr_mb_prms_stride;
1926
1927
154k
    s_out_luma.i4_element_size = 1;
1928
154k
    s_out_luma.pv_buffer =
1929
154k
        ps_svc_lyr_dec->pi2_il_residual_resample_mb_luma_frm_start +
1930
154k
        ((ps_cur_mb_info->u2_mbx << 4) +
1931
154k
         (i4_out_luma_stride * (ps_cur_mb_info->u2_mby << 4)) * s_out_luma.i4_element_size);
1932
1933
154k
    s_out_luma.i4_num_element_stride = i4_out_luma_stride;
1934
1935
154k
    s_out_chroma.i4_element_size = 1;
1936
154k
    s_out_chroma.pv_buffer =
1937
154k
        ps_svc_lyr_dec->pi2_il_residual_resample_mb_chroma_frm_start +
1938
154k
        ((ps_cur_mb_info->u2_mbx << 4) +
1939
154k
         (i4_out_chroma_stride * (ps_cur_mb_info->u2_mby << 3)) * s_out_chroma.i4_element_size);
1940
154k
    s_out_chroma.i4_num_element_stride = i4_out_chroma_stride;
1941
1942
154k
    ret = ps_lyr_ctxt->pf_residual_samp_mb(ps_ctxt, &s_inp_luma, &s_inp_chroma, &s_ref_mb_mode,
1943
154k
                                           &s_out_luma, &s_out_chroma, ps_cur_mb_info->u2_mbx,
1944
154k
                                           ps_cur_mb_info->u2_mby);
1945
154k
    if(ret != OK)
1946
0
    {
1947
0
        return ret;
1948
0
    }
1949
154k
    return OK;
1950
154k
}
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
154k
{
1969
154k
    UWORD8 *pu1_rec_y, *pu1_rec_u;
1970
154k
    dec_struct_t *ps_dec = &ps_svc_lyr_dec->s_dec;
1971
154k
    UWORD32 ui_rec_width, u4_recwidth_cr;
1972
154k
    UWORD16 u2_luma_stride, u2_chroma_stride;
1973
154k
    WORD16 *pi2_y_coeff, *pi2_luma_res_ptr, *pi2_chroma_res_ptr;
1974
154k
    UWORD32 u1_mb_field_decoding_flag;
1975
154k
    const UWORD8 u1_mbaff = ps_dec->ps_cur_slice->u1_mbaff_frame_flag;
1976
154k
    UWORD32 uc_botMb;
1977
154k
    UWORD32 u4_num_pmbair;
1978
154k
    tfr_ctxt_t *ps_frame_buf = ps_dec->ps_frame_buf_ip_recon;
1979
154k
    UWORD32 u4_luma_dc_only_csbp = 0;
1980
154k
    UWORD32 u4_luma_dc_only_cbp = 0;
1981
154k
    UWORD16 u2_res_luma_csbp = 0;
1982
154k
    WORD32 ret;
1983
1984
154k
    if(0 != ps_dec->ps_cur_slice->u1_mbaff_frame_flag)
1985
0
    {
1986
0
        return NOT_OK;
1987
0
    }
1988
154k
    uc_botMb = 1 - ps_cur_mb_info->u1_topmb;
1989
154k
    u4_num_pmbair = (u4_mb_num >> u1_mbaff);
1990
154k
    u1_mb_field_decoding_flag = ps_cur_mb_info->u1_mb_field_decodingflag;
1991
1992
154k
    pu1_rec_y = ps_frame_buf->pu1_dest_y + (u4_num_pmbair << 4);
1993
154k
    pu1_rec_u = ps_frame_buf->pu1_dest_u + (u4_num_pmbair << 3) * YUV420SP_FACTOR;
1994
154k
    ui_rec_width = ps_dec->u2_frm_wd_y << u1_mb_field_decoding_flag;
1995
154k
    u4_recwidth_cr = ps_dec->u2_frm_wd_uv << u1_mb_field_decoding_flag;
1996
1997
154k
    u2_luma_stride = ps_svc_lyr_dec->u2_residual_resample_luma_stride;
1998
154k
    pi2_luma_res_ptr = ps_svc_lyr_dec->pi2_il_residual_resample_mb_luma_frm_start +
1999
154k
                       (ps_cur_mb_info->u2_mbx << 4) +
2000
154k
                       ((ps_cur_mb_info->u2_mby << 4) * u2_luma_stride);
2001
2002
154k
    u2_chroma_stride = ps_svc_lyr_dec->u2_residual_resample_chroma_stride;
2003
154k
    pi2_chroma_res_ptr = ps_svc_lyr_dec->pi2_il_residual_resample_mb_chroma_frm_start +
2004
154k
                         (ps_cur_mb_info->u2_mbx << 4) +
2005
154k
                         ((ps_cur_mb_info->u2_mby << 3) * u2_chroma_stride);
2006
2007
154k
    ret = isvcd_process_residual_resample_mb(ps_svc_lyr_dec, ps_cur_mb_info);
2008
154k
    if(ret != OK)
2009
0
    {
2010
0
        return ret;
2011
0
    }
2012
154k
    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
154k
    if(!ps_cur_mb_info->u1_tran_form8x8)
2023
142k
    {
2024
142k
        u4_luma_dc_only_csbp = ih264d_unpack_luma_coeff4x4_mb(ps_dec, ps_cur_mb_info, 0);
2025
142k
    }
2026
11.9k
    else
2027
11.9k
    {
2028
11.9k
        if(!ps_dec->ps_cur_pps->u1_entropy_coding_mode)
2029
3.01k
        {
2030
3.01k
            u4_luma_dc_only_cbp = ih264d_unpack_luma_coeff4x4_mb(ps_dec, ps_cur_mb_info, 0);
2031
3.01k
        }
2032
8.89k
        else
2033
8.89k
        {
2034
8.89k
            u4_luma_dc_only_cbp = ih264d_unpack_luma_coeff8x8_mb(ps_dec, ps_cur_mb_info);
2035
8.89k
        }
2036
11.9k
    }
2037
2038
154k
    *pu2_res_luma_csbp = 0;
2039
154k
    pi2_y_coeff = ps_dec->pi2_coeff_data;
2040
2041
    /* Inverse Transform and Reconstruction */
2042
154k
    if(ps_cur_mb_info->u1_cbp & 0x0f)
2043
27.0k
    {
2044
27.0k
        if(!ps_cur_mb_info->u1_tran_form8x8)
2045
15.1k
        {
2046
15.1k
            UWORD32 i;
2047
15.1k
            WORD16 ai2_tmp[16] = {0};
2048
257k
            for(i = 0; i < 16; i++)
2049
242k
            {
2050
242k
                if(CHECKBIT(ps_cur_mb_info->u2_luma_csbp, i))
2051
59.8k
                {
2052
59.8k
                    WORD16 *pi2_level = pi2_y_coeff + (i << 4);
2053
59.8k
                    UWORD8 *pu1_pred_sblk =
2054
59.8k
                        pu1_rec_y + ((i & 0x3) * BLK_SIZE) + (i >> 2) * (ui_rec_width << 2);
2055
59.8k
                    WORD16 *pi2_out = pi2_luma_res_ptr + ((i & 0x3) * BLK_SIZE) +
2056
59.8k
                                      (i >> 2) * (u2_luma_stride << 2);
2057
59.8k
                    PROFILE_DISABLE_IQ_IT_RECON()
2058
59.8k
                    {
2059
59.8k
                        if(CHECKBIT(u4_luma_dc_only_csbp, i))
2060
5.18k
                        {
2061
5.18k
                            u2_res_luma_csbp =
2062
5.18k
                                ps_svc_lyr_dec->pf_iquant_itrans_residual_recon_luma_4x4_dc(
2063
5.18k
                                    pi2_level, pu1_pred_sblk, pi2_out, pu1_pred_sblk, ui_rec_width,
2064
5.18k
                                    u2_luma_stride, ui_rec_width,
2065
5.18k
                                    gau2_ih264_iquant_scale_4x4[ps_cur_mb_info->u1_qp_rem6],
2066
5.18k
                                    (UWORD16 *) ps_dec->s_high_profile.i2_scalinglist4x4[3],
2067
5.18k
                                    ps_cur_mb_info->u1_qp_div6, ai2_tmp, 0, NULL);
2068
5.18k
                        }
2069
54.6k
                        else
2070
54.6k
                        {
2071
54.6k
                            u2_res_luma_csbp =
2072
54.6k
                                ps_svc_lyr_dec->pf_iquant_itrans_residual_recon_luma_4x4(
2073
54.6k
                                    pi2_level, pu1_pred_sblk, pi2_out, pu1_pred_sblk, ui_rec_width,
2074
54.6k
                                    u2_luma_stride, ui_rec_width,
2075
54.6k
                                    gau2_ih264_iquant_scale_4x4[ps_cur_mb_info->u1_qp_rem6],
2076
54.6k
                                    (UWORD16 *) ps_dec->s_high_profile.i2_scalinglist4x4[3],
2077
54.6k
                                    ps_cur_mb_info->u1_qp_div6, ai2_tmp, 0, NULL);
2078
54.6k
                        }
2079
59.8k
                    }
2080
59.8k
                }
2081
182k
                else
2082
182k
                {
2083
182k
                    UWORD8 *pu1_pred_sblk =
2084
182k
                        pu1_rec_y + ((i & 0x3) * BLK_SIZE) + (i >> 2) * (ui_rec_width << 2);
2085
182k
                    WORD16 *pi2_out = pi2_luma_res_ptr + ((i & 0x3) * BLK_SIZE) +
2086
182k
                                      (i >> 2) * (u2_luma_stride << 2);
2087
2088
182k
                    u2_res_luma_csbp = ps_svc_lyr_dec->pf_pred_residual_recon_luma_4x4(
2089
182k
                        pu1_pred_sblk, pi2_out, pu1_pred_sblk, ui_rec_width, u2_luma_stride,
2090
182k
                        ui_rec_width);
2091
182k
                }
2092
242k
                *pu2_res_luma_csbp |= (u2_res_luma_csbp << i);
2093
242k
            }
2094
15.1k
        }
2095
11.9k
        else
2096
11.9k
        {
2097
11.9k
            WORD16 *pi2_scale_matrix_ptr;
2098
11.9k
            WORD32 i;
2099
2100
11.9k
            pi2_scale_matrix_ptr = ps_dec->s_high_profile.i2_scalinglist8x8[1];
2101
2102
59.5k
            for(i = 0; i < 4; i++)
2103
47.6k
            {
2104
47.6k
                WORD16 ai2_tmp[64] = {0};
2105
47.6k
                WORD16 *pi16_levelBlock =
2106
47.6k
                    pi2_y_coeff + (i << 6); /* move to the next 8x8 adding 64 */
2107
2108
47.6k
                UWORD8 *pu1_pred_sblk =
2109
47.6k
                    pu1_rec_y + ((i & 0x1) * BLK8x8SIZE) + (i >> 1) * (ui_rec_width << 3);
2110
47.6k
                WORD16 *pi2_out =
2111
47.6k
                    pi2_luma_res_ptr + ((i & 0x1) * BLK8x8SIZE) + (i >> 1) * (u2_luma_stride << 3);
2112
47.6k
                if(CHECKBIT(ps_cur_mb_info->u1_cbp, i))
2113
31.2k
                {
2114
31.2k
                    PROFILE_DISABLE_IQ_IT_RECON()
2115
31.2k
                    {
2116
31.2k
                        if(CHECKBIT(u4_luma_dc_only_cbp, i))
2117
3.12k
                        {
2118
3.12k
                            u2_res_luma_csbp =
2119
3.12k
                                ps_svc_lyr_dec->pf_iquant_itrans_residual_recon_luma_8x8_dc(
2120
3.12k
                                    pi16_levelBlock, pu1_pred_sblk, pi2_out, pu1_pred_sblk,
2121
3.12k
                                    ui_rec_width, u2_luma_stride, ui_rec_width,
2122
3.12k
                                    gau1_ih264d_dequant8x8_cavlc[ps_cur_mb_info->u1_qp_rem6],
2123
3.12k
                                    (UWORD16 *) pi2_scale_matrix_ptr, ps_cur_mb_info->u1_qp_div6,
2124
3.12k
                                    ai2_tmp, 0, NULL);
2125
3.12k
                        }
2126
28.1k
                        else
2127
28.1k
                        {
2128
28.1k
                            u2_res_luma_csbp =
2129
28.1k
                                ps_svc_lyr_dec->pf_iquant_itrans_residual_recon_luma_8x8(
2130
28.1k
                                    pi16_levelBlock, pu1_pred_sblk, pi2_out, pu1_pred_sblk,
2131
28.1k
                                    ui_rec_width, u2_luma_stride, ui_rec_width,
2132
28.1k
                                    gau1_ih264d_dequant8x8_cavlc[ps_cur_mb_info->u1_qp_rem6],
2133
28.1k
                                    (UWORD16 *) pi2_scale_matrix_ptr, ps_cur_mb_info->u1_qp_div6,
2134
28.1k
                                    ai2_tmp, 0, NULL);
2135
28.1k
                        }
2136
31.2k
                    }
2137
31.2k
                }
2138
16.3k
                else
2139
16.3k
                {
2140
16.3k
                    UWORD8 *pu1_pred_sblk =
2141
16.3k
                        pu1_rec_y + ((i & 0x1) * BLK8x8SIZE) + (i >> 1) * (ui_rec_width << 3);
2142
16.3k
                    WORD16 *pi2_out = pi2_luma_res_ptr + ((i & 0x1) * BLK8x8SIZE) +
2143
16.3k
                                      (i >> 1) * (u2_luma_stride << 3);
2144
2145
16.3k
                    u2_res_luma_csbp = ps_svc_lyr_dec->pf_pred_residual_recon_luma_8x8(
2146
16.3k
                        pu1_pred_sblk, pi2_out, pu1_pred_sblk, ui_rec_width, u2_luma_stride,
2147
16.3k
                        ui_rec_width);
2148
16.3k
                }
2149
47.6k
                *pu2_res_luma_csbp |= (u2_res_luma_csbp << (((i >> 1) << 3) + ((i & 0x01) << 1)));
2150
47.6k
            }
2151
11.9k
        }
2152
27.0k
    }
2153
127k
    else
2154
127k
    {
2155
127k
        UWORD8 *pu1_pred_sblk = pu1_rec_y;
2156
127k
        WORD16 *pi2_out = pi2_luma_res_ptr;
2157
2158
127k
        *pu2_res_luma_csbp = ps_svc_lyr_dec->pf_pred_residual_recon_luma_16x16(
2159
127k
            pu1_pred_sblk, pi2_out, pu1_pred_sblk, ui_rec_width, u2_luma_stride, ui_rec_width);
2160
127k
    }
2161
2162
    /* Decode Chroma Block */
2163
154k
    ih264d_unpack_chroma_coeff4x4_mb(ps_dec, ps_cur_mb_info);
2164
    /*--------------------------------------------------------------------*/
2165
    /* Chroma Blocks decoding                                             */
2166
    /*--------------------------------------------------------------------*/
2167
154k
    {
2168
154k
        UWORD8 u1_chroma_cbp = (UWORD8) (ps_cur_mb_info->u1_cbp >> 4);
2169
2170
154k
        if(u1_chroma_cbp != CBPC_ALLZERO)
2171
13.3k
        {
2172
13.3k
            UWORD32 u4_scale_u = ps_cur_mb_info->u1_qpc_div6;
2173
13.3k
            UWORD32 u4_scale_v = ps_cur_mb_info->u1_qpcr_div6;
2174
13.3k
            UWORD16 u2_chroma_csbp = ps_cur_mb_info->u2_chroma_csbp;
2175
2176
13.3k
            pi2_y_coeff = ps_dec->pi2_coeff_data;
2177
2178
13.3k
            {
2179
13.3k
                UWORD32 i;
2180
13.3k
                WORD16 ai2_tmp[16] = {0};
2181
66.8k
                for(i = 0; i < 4; i++)
2182
53.4k
                {
2183
53.4k
                    WORD16 *pi2_level = pi2_y_coeff + (i << 4);
2184
53.4k
                    UWORD8 *pu1_pred_sblk = pu1_rec_u + ((i & 0x1) * BLK_SIZE * YUV420SP_FACTOR) +
2185
53.4k
                                            (i >> 1) * (u4_recwidth_cr << 2);
2186
53.4k
                    WORD16 *pi2_out = pi2_chroma_res_ptr +
2187
53.4k
                                      ((i & 0x1) * BLK_SIZE * YUV420SP_FACTOR) +
2188
53.4k
                                      (i >> 1) * (u2_chroma_stride << 2);
2189
53.4k
                    PROFILE_DISABLE_IQ_IT_RECON()
2190
53.4k
                    {
2191
53.4k
                        if(CHECKBIT(u2_chroma_csbp, i))
2192
5.82k
                        {
2193
5.82k
                            ps_svc_lyr_dec->pf_iquant_itrans_residual_recon_chroma_4x4(
2194
5.82k
                                pi2_level, pu1_pred_sblk, pi2_out, pu1_pred_sblk, u4_recwidth_cr,
2195
5.82k
                                u2_chroma_stride, u4_recwidth_cr,
2196
5.82k
                                gau2_ih264_iquant_scale_4x4[ps_cur_mb_info->u1_qpc_rem6],
2197
5.82k
                                (UWORD16 *) ps_dec->s_high_profile.i2_scalinglist4x4[4], u4_scale_u,
2198
5.82k
                                ai2_tmp, pi2_level);
2199
5.82k
                        }
2200
47.6k
                        else if(pi2_level[0] != 0)
2201
31.8k
                        {
2202
31.8k
                            ps_svc_lyr_dec->pf_iquant_itrans_residual_recon_chroma_4x4_dc(
2203
31.8k
                                pi2_level, pu1_pred_sblk, pi2_out, pu1_pred_sblk, u4_recwidth_cr,
2204
31.8k
                                u2_chroma_stride, u4_recwidth_cr,
2205
31.8k
                                gau2_ih264_iquant_scale_4x4[ps_cur_mb_info->u1_qpc_rem6],
2206
31.8k
                                (UWORD16 *) ps_dec->s_high_profile.i2_scalinglist4x4[4], u4_scale_u,
2207
31.8k
                                ai2_tmp, pi2_level);
2208
31.8k
                        }
2209
15.8k
                        else
2210
15.8k
                        {
2211
15.8k
                            ps_svc_lyr_dec->pf_pred_residual_recon_chroma_4x4(
2212
15.8k
                                pu1_pred_sblk, pi2_out, pu1_pred_sblk, u4_recwidth_cr,
2213
15.8k
                                u2_chroma_stride, u4_recwidth_cr);
2214
15.8k
                        }
2215
53.4k
                    }
2216
53.4k
                }
2217
13.3k
            }
2218
2219
13.3k
            pi2_y_coeff += MB_CHROM_SIZE;
2220
13.3k
            u2_chroma_csbp >>= 4;
2221
2222
13.3k
            {
2223
13.3k
                UWORD32 i;
2224
13.3k
                WORD16 ai2_tmp[16] = {0};
2225
66.8k
                for(i = 0; i < 4; i++)
2226
53.4k
                {
2227
53.4k
                    WORD16 *pi2_level = pi2_y_coeff + (i << 4);
2228
53.4k
                    UWORD8 *pu1_pred_sblk = pu1_rec_u + 1 +
2229
53.4k
                                            ((i & 0x1) * BLK_SIZE * YUV420SP_FACTOR) +
2230
53.4k
                                            (i >> 1) * (u4_recwidth_cr << 2);
2231
53.4k
                    WORD16 *pi2_out = pi2_chroma_res_ptr + 1 +
2232
53.4k
                                      ((i & 0x1) * BLK_SIZE * YUV420SP_FACTOR) +
2233
53.4k
                                      (i >> 1) * (u2_chroma_stride << 2);
2234
53.4k
                    PROFILE_DISABLE_IQ_IT_RECON()
2235
53.4k
                    {
2236
53.4k
                        if(CHECKBIT(u2_chroma_csbp, i))
2237
5.77k
                        {
2238
5.77k
                            ps_svc_lyr_dec->pf_iquant_itrans_residual_recon_chroma_4x4(
2239
5.77k
                                pi2_level, pu1_pred_sblk, pi2_out, pu1_pred_sblk, u4_recwidth_cr,
2240
5.77k
                                u2_chroma_stride, u4_recwidth_cr,
2241
5.77k
                                gau2_ih264_iquant_scale_4x4[ps_cur_mb_info->u1_qpcr_rem6],
2242
5.77k
                                (UWORD16 *) ps_dec->s_high_profile.i2_scalinglist4x4[5], u4_scale_v,
2243
5.77k
                                ai2_tmp, pi2_level);
2244
5.77k
                        }
2245
47.6k
                        else if(pi2_level[0] != 0)
2246
28.8k
                        {
2247
28.8k
                            ps_svc_lyr_dec->pf_iquant_itrans_residual_recon_chroma_4x4_dc(
2248
28.8k
                                pi2_level, pu1_pred_sblk, pi2_out, pu1_pred_sblk, u4_recwidth_cr,
2249
28.8k
                                u2_chroma_stride, u4_recwidth_cr,
2250
28.8k
                                gau2_ih264_iquant_scale_4x4[ps_cur_mb_info->u1_qpcr_rem6],
2251
28.8k
                                (UWORD16 *) ps_dec->s_high_profile.i2_scalinglist4x4[5], u4_scale_v,
2252
28.8k
                                ai2_tmp, pi2_level);
2253
28.8k
                        }
2254
18.8k
                        else
2255
18.8k
                        {
2256
18.8k
                            ps_svc_lyr_dec->pf_pred_residual_recon_chroma_4x4(
2257
18.8k
                                pu1_pred_sblk, pi2_out, pu1_pred_sblk, u4_recwidth_cr,
2258
18.8k
                                u2_chroma_stride, u4_recwidth_cr);
2259
18.8k
                        }
2260
53.4k
                    }
2261
53.4k
                }
2262
13.3k
            }
2263
13.3k
        }
2264
140k
        else
2265
140k
        {
2266
            /* Cr*/
2267
140k
            {
2268
140k
                UWORD8 *pu1_pred_sblk = pu1_rec_u;
2269
140k
                WORD16 *pi2_out = pi2_chroma_res_ptr;
2270
2271
140k
                ps_svc_lyr_dec->pf_pred_residual_recon_chroma_8x8(pu1_pred_sblk, pi2_out,
2272
140k
                                                                  pu1_pred_sblk, u4_recwidth_cr,
2273
140k
                                                                  u2_chroma_stride, u4_recwidth_cr);
2274
140k
            }
2275
2276
            /* Cb*/
2277
140k
            {
2278
140k
                UWORD8 *pu1_pred_sblk = pu1_rec_u + 1;
2279
140k
                WORD16 *pi2_out = pi2_chroma_res_ptr + 1;
2280
140k
                ps_svc_lyr_dec->pf_pred_residual_recon_chroma_8x8(pu1_pred_sblk, pi2_out,
2281
140k
                                                                  pu1_pred_sblk, u4_recwidth_cr,
2282
140k
                                                                  u2_chroma_stride, u4_recwidth_cr);
2283
140k
            }
2284
140k
        }
2285
154k
    }
2286
154k
    ps_svc_lyr_dec->ps_inter_lyr_mb_prms_cur_mb =
2287
154k
        ps_svc_lyr_dec->ps_inter_lyr_mb_prms_frm_start + ps_cur_mb_info->u2_mbx +
2288
154k
        (ps_svc_lyr_dec->u2_inter_lyr_mb_prms_stride * (ps_cur_mb_info->u2_mby));
2289
154k
    ps_svc_lyr_dec->ps_inter_lyr_mb_prms_cur_mb->i1_mb_mode =
2290
154k
        u1_inference_mode ? SVC_IBL_MB : SVC_INTER_MB;
2291
154k
    ps_svc_lyr_dec->ps_inter_lyr_mb_prms_cur_mb->i1_tx_size = ps_cur_mb_info->u1_tran_form8x8;
2292
154k
    ps_svc_lyr_dec->ps_inter_lyr_mb_prms_cur_mb->u2_luma_nnz = ps_cur_mb_info->u2_luma_csbp;
2293
154k
    ps_svc_lyr_dec->ps_inter_lyr_mb_prms_cur_mb->u1_chroma_nnz =
2294
154k
        (UWORD8) ps_cur_mb_info->u2_chroma_csbp;
2295
154k
    if(CHECKBIT(ps_cur_mb_info->u1_yuv_dc_block_flag, 1))
2296
9.37k
    {
2297
        /* Four bits for Cb in DC only cbp */
2298
9.37k
        ps_svc_lyr_dec->ps_inter_lyr_mb_prms_cur_mb->u1_chroma_nnz |= 0x0F;
2299
9.37k
    }
2300
154k
    if(CHECKBIT(ps_cur_mb_info->u1_yuv_dc_block_flag, 2))
2301
8.85k
    {
2302
        /* Four bits for Cr in DC only cbp */
2303
8.85k
        ps_svc_lyr_dec->ps_inter_lyr_mb_prms_cur_mb->u1_chroma_nnz |= 0xF0;
2304
8.85k
    }
2305
154k
    return (0);
2306
154k
}