Coverage Report

Created: 2025-07-18 07:04

/src/libavc/decoder/svc/isvcd_compute_bs.c
Line
Count
Source (jump to first uncovered line)
1
/******************************************************************************
2
 *
3
 * Copyright (C) 2022 The Android Open Source Project
4
 *
5
 * Licensed under the Apache License, Version 2.0 (the "License");
6
 * you may not use this file except in compliance with the License.
7
 * You may obtain a copy of the License at:
8
 *
9
 * http://www.apache.org/licenses/LICENSE-2.0
10
 *
11
 * Unless required by applicable law or agreed to in writing, software
12
 * distributed under the License is distributed on an "AS IS" BASIS,
13
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
 * See the License for the specific language governing permissions and
15
 * limitations under the License.
16
 *
17
 *****************************************************************************
18
 * Originally developed and contributed by Ittiam Systems Pvt. Ltd, Bangalore
19
 */
20
/**
21
 *******************************************************************************
22
 * @file
23
 *  isvcd_compute_bs.c
24
 *
25
 * @brief
26
 *  This file contains bit flags and info on target layer.
27
 *
28
 * @author
29
 *  Kishore
30
 *
31
 * @par List of Functions:
32
 *  - isvcd_deblk_extract_bit_flags()
33
 *  - isvcd_fill_bs_ibl()
34
 *  - isvcd_compute_bs_non_mbaff_target_lyr_no_inter_layer()
35
 *  - isvcd_compute_bs_non_mbaff()
36
 *  - isvcd_compute_bs_non_mbaff_target_lyr()
37
 *  - isvcd_compute_bs_non_mbaff_medial_lyr()
38
 *
39
 * @remarks
40
 *  None
41
 *
42
 *******************************************************************************
43
 */
44
45
#include "ih264_typedefs.h"
46
#include "ih264_macros.h"
47
#include "ih264_platform_macros.h"
48
#include "isvcd_structs.h"
49
#include "ih264d_defs.h"
50
#include "ih264d_deblocking.h"
51
#include "string.h"
52
#include "ih264d_debug.h"
53
#include "ih264d_tables.h"
54
UWORD16 ih264d_update_csbp_8x8(UWORD16 u2_luma_csbp);
55
void ih264d_fill_bs2_horz_vert(UWORD32 *pu4_bs,        /* Base pointer of BS table */
56
                               WORD32 u4_left_mb_csbp, /* csbp of left mb */
57
                               WORD32 u4_top_mb_csbp,  /* csbp of top mb */
58
                               WORD32 u4_cur_mb_csbp,  /* csbp of current mb */
59
                               const UWORD32 *pu4_packed_bs2, const UWORD16 *pu2_4x4_v2h_reorder);
60
const UWORD32 g_au4_extract_set[NUM_SUB_MB_PARTS] = {0x00000000F, 0x0000000F0, 0x000000F00,
61
                                                     0x00000F000};
62
63
/** \brief extracts the bits from given offset and packs it to last 4 bits  */
64
UWORD16 isvcd_deblk_extract_bit_flags(UWORD16 u2_bit_field, WORD32 i4_initial_bit_mask)
65
80.2k
{
66
80.2k
    WORD32 i4_i;
67
80.2k
    WORD32 i4_bit_mask;
68
80.2k
    UWORD16 u2_result = 0;
69
70
80.2k
    i4_bit_mask = i4_initial_bit_mask;
71
72
401k
    for(i4_i = 0; i4_i < NUM_SUB_MB_PARTS; i4_i++)
73
320k
    {
74
320k
        WORD32 i4_bit;
75
        /* extract the bits of the last column 4x4 blocks */
76
320k
        if(0 == (i4_bit_mask & u2_bit_field))
77
311k
        {
78
311k
            i4_bit = 0;
79
311k
        }
80
9.78k
        else
81
9.78k
        {
82
9.78k
            i4_bit = 1;
83
9.78k
        }
84
        /* store the result */
85
320k
        u2_result |= i4_bit << i4_i;
86
320k
        i4_bit_mask <<= 4;
87
88
320k
    } /* end of loop over num sub Mb parts */
89
80.2k
    return (u2_result);
90
80.2k
}
91
92
/** \brief Fills the BS for edges falling on a IBL boundary  */
93
void isvcd_fill_bs_ibl(deblk_mb_t *ps_deblk_mb, UWORD8 u1_top_mb_type, UWORD8 u1_left_mb_type,
94
                       dec_mb_info_t *ps_cur_mb_info, UWORD16 *pu2_curr_res_luma_csbp,
95
                       UWORD16 *pu2_left_res_luma_csbp, UWORD16 *pu2_top_res_luma_csbp)
96
786k
{
97
    /*! Flow of the module is as follows                                  */
98
    /*! 1. checks if MB edge is falling on IBL boundary                   */
99
    /*! 2. if only Mb edge then it fills the BS based on INTRA or INTER
100
           stauts                                                         */
101
    /*! 3. if the current MB is IBL and neighbours are also neighbours
102
           then it uses the current layer t_coeff flag to decide the
103
           BS of a particular edge                                        */
104
    /*!4. fills the BS for all the edges in curretn MB if IBL             */
105
106
786k
    UWORD16 u2_top_horz_nnz;
107
786k
    UWORD8 u1_top_mb_ibl, u1_left_mb_ibl;
108
786k
    UWORD32 i4_i, i4_edge;
109
786k
    UWORD8 u1_bs;
110
786k
    UWORD8 u1_cnd;
111
786k
    UWORD8 u1_top_intra;
112
786k
    UWORD8 u1_left_intra;
113
786k
    UWORD8 u1_p_nnz, u1_q_nnz;
114
786k
    UWORD8 u1_curr_mb_ibl;
115
786k
    UWORD32 *pu4_bs_table;
116
786k
    UWORD16 u2_curr_nnz;
117
786k
    UWORD8 u1_left_mb_nnz = 0, u1_left_nnz;
118
786k
    WORD32 i4_horz_start = 0;
119
786k
    WORD32 i4_vertical_start = 0;
120
121
786k
    pu4_bs_table = &(ps_deblk_mb->u4_bs_table[0]);
122
123
786k
    u1_top_mb_ibl = u1_top_mb_type & D_INTRA_IBL;
124
786k
    u1_left_mb_ibl = u1_left_mb_type & D_INTRA_IBL;
125
126
786k
    u1_curr_mb_ibl = ps_deblk_mb->u1_mb_type & D_INTRA_IBL;
127
128
786k
    u1_top_intra = u1_top_mb_type & D_INTRA_MB;
129
786k
    u1_left_intra = u1_left_mb_type & D_INTRA_MB;
130
131
    /* return if none of the current top and left is IBL */
132
786k
    if((0 == u1_curr_mb_ibl) && (0 == u1_top_mb_ibl) && (0 == u1_left_mb_ibl))
133
706k
    {
134
706k
        return;
135
706k
    }
136
137
    /* set up the vertical and horz MB edge skip flags */
138
80.2k
    if(0 != u1_curr_mb_ibl)
139
66.6k
    {
140
        /* if top is not IBL */
141
66.6k
        if(0 == u1_top_mb_ibl)
142
21.1k
        {
143
21.1k
            i4_horz_start = 1;
144
21.1k
        }
145
146
        /* if left in not IBL */
147
66.6k
        if(0 == u1_left_mb_ibl)
148
28.7k
        {
149
28.7k
            i4_vertical_start = 1;
150
28.7k
        }
151
66.6k
    }
152
153
    /*******************************************************/
154
    /* Fill BS for mb egdex assuming non IBL case          */
155
    /*******************************************************/
156
157
    /* only the  MB edges fall across IBL boundary */
158
80.2k
    if((0 != u1_curr_mb_ibl) || (0 != u1_top_mb_ibl) || (0 != u1_left_mb_ibl))
159
80.2k
    {
160
80.2k
        UWORD16 u2_temp, u2_i;
161
80.2k
        u2_temp = *pu2_left_res_luma_csbp;
162
401k
        for(u2_i = 0; u2_i < 4; u2_i++)
163
320k
        {
164
320k
            u1_left_mb_nnz |= ((u2_temp & 0x08) >> (3 - u2_i));
165
320k
            u2_temp >>= 4;
166
320k
        }
167
80.2k
        u2_curr_nnz = *pu2_curr_res_luma_csbp;
168
80.2k
        u2_top_horz_nnz = *pu2_top_res_luma_csbp >> 12;
169
170
        /* top is intra and not ibl */
171
80.2k
        if(0 != u1_top_intra)
172
3.68k
        {
173
3.68k
            pu4_bs_table[0] = 0x04040404;
174
3.68k
        }
175
        /* left is intra and not ibl */
176
80.2k
        if(0 != u1_left_intra)
177
2.90k
        {
178
2.90k
            pu4_bs_table[4] = 0x04040404;
179
2.90k
        }
180
181
        /* assume neighbours are inter and update bs */
182
183
        /* Edge = 0 means Vert Edges and Edge = 1 means Horz edges */
184
240k
        for(i4_edge = 0; i4_edge < 2; i4_edge++)
185
160k
        {
186
160k
            UWORD8 u1_p_nnz, u1_q_nnz;
187
160k
            UWORD32 u4_bs_edge = 0;
188
160k
            WORD32 i4_bit_mask;
189
160k
            WORD32 i4_curr_intra_flag;
190
160k
            WORD32 i4_neibor_intra_flag;
191
192
160k
            i4_curr_intra_flag = (0 != u1_curr_mb_ibl);
193
194
160k
            if(0 != i4_edge)
195
80.2k
            {
196
                /* Initialize for the TOP edge */
197
80.2k
                u1_p_nnz = (UWORD8) u2_top_horz_nnz;
198
80.2k
                u1_q_nnz = (UWORD8) (u2_curr_nnz & g_au4_extract_set[0]);
199
80.2k
                i4_neibor_intra_flag = (u1_top_mb_ibl || u1_top_intra);
200
80.2k
            }
201
80.2k
            else
202
80.2k
            {
203
80.2k
                u1_p_nnz = u1_left_mb_nnz;
204
80.2k
                u1_q_nnz = (UWORD8) isvcd_deblk_extract_bit_flags(u2_curr_nnz, 0x01);
205
80.2k
                i4_neibor_intra_flag = (u1_left_mb_ibl || u1_left_intra);
206
80.2k
            }
207
208
160k
            i4_bit_mask = 1;
209
            /* find bs of 4 edges */
210
802k
            for(i4_i = 0; i4_i < 4; i4_i++)
211
641k
            {
212
641k
                UWORD8 u1_p_nnz_temp, u1_q_nnz_temp;
213
214
641k
                u1_p_nnz_temp = (u1_p_nnz & i4_bit_mask);
215
641k
                u1_q_nnz_temp = (u1_q_nnz & i4_bit_mask);
216
217
641k
                u1_cnd = ((u1_p_nnz_temp && (!i4_neibor_intra_flag)) ||
218
641k
                          (u1_q_nnz_temp && (!i4_curr_intra_flag)));
219
220
641k
                u1_bs = u1_cnd ? 2 : 1;
221
222
                /* update the bs of the edge */
223
641k
                u4_bs_edge = (u4_bs_edge << 8) + u1_bs;
224
641k
                i4_bit_mask <<= 1;
225
226
641k
            } /* end of loop over blk edges */
227
228
            /* update the bs of edges */
229
160k
            if(i4_edge && !u1_top_intra)
230
76.5k
            {
231
76.5k
                pu4_bs_table[0] = u4_bs_edge;
232
76.5k
            }
233
83.9k
            else if(!i4_edge && !u1_left_intra)
234
77.3k
            {
235
77.3k
                pu4_bs_table[4] = u4_bs_edge;
236
77.3k
            }
237
160k
        } /* end of loop over v1 vetical and horizontal edge */
238
80.2k
    }
239
    /* current MB is IBL */
240
80.2k
    if(0 != u1_curr_mb_ibl)
241
66.6k
    {
242
66.6k
        UWORD16 u2_temp, u2_i;
243
66.6k
        WORD32 i4_bit_mask_edge = 1;
244
245
66.6k
        u1_left_mb_nnz = 0;
246
66.6k
        u2_temp = ps_cur_mb_info->ps_left_mb->u2_luma_csbp;
247
333k
        for(u2_i = 0; u2_i < 4; u2_i++)
248
266k
        {
249
266k
            u1_left_mb_nnz |= ((u2_temp & 0x08) >> (3 - u2_i));
250
266k
            u2_temp >>= 4;
251
266k
        }
252
66.6k
        u2_curr_nnz = ps_cur_mb_info->ps_curmb->u2_luma_csbp;
253
66.6k
        u2_top_horz_nnz = ps_cur_mb_info->ps_top_mb->u2_luma_csbp >> 12;
254
        /* all are IBL edges then use only t_coeff of current layer*/
255
        /* loop over all edges */
256
333k
        for(i4_edge = 0; i4_edge < 4; i4_edge++)
257
266k
        {
258
266k
            UWORD16 u2_curr_horz_nnz = 0;
259
266k
            WORD32 i4_bit_mask = 1;
260
261
266k
            u2_curr_horz_nnz = u2_curr_nnz & g_au4_extract_set[i4_edge];
262
263
266k
            u2_curr_horz_nnz = (u2_curr_horz_nnz >> (i4_edge * 4));
264
265
266k
            u1_left_nnz = (u1_left_mb_nnz & i4_bit_mask_edge);
266
267
1.33M
            for(i4_i = 0; i4_i < 4; i4_i++)
268
1.06M
            {
269
1.06M
                UWORD8 u1_curr_nnz, u1_top_nnz;
270
271
1.06M
                u1_curr_nnz = (u2_curr_horz_nnz & i4_bit_mask);
272
1.06M
                u1_top_nnz = (u2_top_horz_nnz & i4_bit_mask);
273
                /* update bs horizontal */
274
275
1.06M
                if(!((1 == i4_horz_start) && (0 == i4_edge)))
276
981k
                {
277
981k
                    u1_p_nnz = u1_top_nnz;
278
981k
                    u1_q_nnz = u1_curr_nnz;
279
981k
                    u1_cnd = !(u1_p_nnz || u1_q_nnz);
280
981k
                    u1_bs = u1_cnd ? 0 : 1;
281
981k
                    pu4_bs_table[i4_edge] = (pu4_bs_table[i4_edge] << 8) + u1_bs;
282
981k
                }
283
284
                /* update bs vertical */
285
1.06M
                if(!((1 == i4_vertical_start) && (0 == i4_i)))
286
951k
                {
287
951k
                    u1_p_nnz = u1_left_nnz;
288
951k
                    u1_q_nnz = u1_curr_nnz;
289
951k
                    u1_cnd = !(u1_p_nnz || u1_q_nnz);
290
951k
                    u1_bs = u1_cnd ? 0 : 1;
291
951k
                    pu4_bs_table[i4_i + 4] = (pu4_bs_table[i4_i + 4] << 8) + u1_bs;
292
951k
                }
293
                /* store the current nnz to left nnz */
294
1.06M
                u1_left_nnz = u1_curr_nnz;
295
1.06M
                i4_bit_mask <<= 1;
296
1.06M
            }
297
            /* store the current row nnz to top row nnz */
298
266k
            u2_top_horz_nnz = u2_curr_horz_nnz;
299
266k
            i4_bit_mask_edge <<= 1;
300
266k
        }
301
66.6k
    }
302
80.2k
    return;
303
786k
}
304
305
/*****************************************************************************/
306
/*                                                                           */
307
/*  Function Name : isvcd_compute_bs_non_mbaff_target_lyr_no_inter_layer     */
308
/*                                                                           */
309
/*  Description   : This function computes the pointers of left,top & current*/
310
/*                : Nnz, MvPred & deblk_mb_t and supplies to FillBs function */
311
/*                : for Boundary Strength Calculation                        */
312
/*  Inputs        : <What inputs does the function take?>                    */
313
/*  Processing    : This functions calls deblock MB in the MB increment order*/
314
/*                                                                           */
315
/*  Outputs       : Produces the Boundary Strength for Current Mb            */
316
/*  Returns       : None                                                     */
317
/*                                                                           */
318
/*  Revision History:                                                        */
319
/*                                                                           */
320
/*         DD MM YYYY   Author(s)       Changes (Describe the changes made)  */
321
/*         06 09 2021   Kishore                                              */
322
/*****************************************************************************/
323
324
void isvcd_compute_bs_non_mbaff_target_lyr_no_inter_layer(svc_dec_lyr_struct_t *ps_svc_lyr_dec,
325
                                                          dec_mb_info_t *ps_cur_mb_info,
326
                                                          const UWORD16 u2_mbxn_mb)
327
146k
{
328
146k
    dec_struct_t *ps_dec = &ps_svc_lyr_dec->s_dec;
329
    /* Mvpred and Nnz for top and Courrent */
330
146k
    mv_pred_t *ps_cur_mv_pred, *ps_top_mv_pred = NULL, *ps_left_mv_pred;
331
    /* deblk_mb_t Params */
332
146k
    deblk_mb_t *ps_cur_mb_params; /*< Parameters of current MacroBlock */
333
146k
    deblkmb_neighbour_t *ps_deblk_top_mb;
334
335
    /* Reference Index to POC mapping*/
336
146k
    void **apv_map_ref_idx_to_poc;
337
146k
    UWORD32 u4_leftmbtype;
338
339
146k
    UWORD16 u2_left_csbp, u2_top_csbp, u2_cur_csbp;
340
341
    /* Set of flags */
342
146k
    UWORD32 u4_cur_mb_intra, u1_top_mb_typ, u4_cur_mb_fld;
343
146k
    UWORD32 u1_cur_mb_type;
344
146k
    UWORD32 *pu4_bs_table;
345
346
    /* Neighbour availability */
347
    /* Initialization */
348
146k
    const UWORD32 u2_mbx = ps_cur_mb_info->u2_mbx;
349
146k
    const UWORD32 u2_mby = ps_cur_mb_info->u2_mby;
350
146k
    const UWORD32 u1_pingpong = u2_mbx & 0x01;
351
352
146k
    PROFILE_DISABLE_BOUNDARY_STRENGTH()
353
354
146k
    ps_deblk_top_mb = ps_dec->ps_deblk_top_mb + u2_mbx;
355
356
    /* Pointer assignment for Current DeblkMB, Current Mv Pred  */
357
146k
    ps_cur_mb_params = ps_dec->ps_deblk_mbn + u2_mbxn_mb;
358
146k
    ps_cur_mv_pred = ps_dec->ps_mv_cur + (u2_mbxn_mb << 4);
359
360
146k
    apv_map_ref_idx_to_poc = ps_dec->ppv_map_ref_idx_to_poc + 1;
361
146k
    u1_cur_mb_type = ps_cur_mb_params->u1_mb_type;
362
146k
    u1_top_mb_typ = ps_deblk_top_mb->u1_mb_type;
363
146k
    ps_deblk_top_mb->u1_mb_type = u1_cur_mb_type;
364
365
146k
    ps_cur_mb_params->u1_topmb_qp = ps_deblk_top_mb->u1_mb_qp;
366
146k
    ps_deblk_top_mb->u1_mb_qp = ps_cur_mb_params->u1_mb_qp;
367
146k
    ps_cur_mb_params->u1_left_mb_qp = ps_dec->deblk_left_mb[1].u1_mb_qp;
368
146k
    ps_dec->deblk_left_mb[1].u1_mb_qp = ps_cur_mb_params->u1_mb_qp;
369
370
    /* if no deblocking required for current Mb then continue */
371
    /* Check next Mbs   in Mb group                           */
372
146k
    if(ps_cur_mb_params->u1_deblocking_mode & MB_DISABLE_FILTERING)
373
1.26k
    {
374
1.26k
        void **pu4_map_ref_idx_to_poc_l1 = apv_map_ref_idx_to_poc + POC_LIST_L0_TO_L1_DIFF;
375
1.26k
        {
376
            /* Store Parameter for Top MvPred refernce frame Address */
377
378
1.26k
            void **ppv_top_mv_pred_addr = ps_cur_mb_info->ps_curmb->u4_pic_addrress;
379
1.26k
            WORD8 *p1_refTop0 = (ps_cur_mv_pred + 12)->i1_ref_frame;
380
1.26k
            WORD8 *p1_refTop1 = (ps_cur_mv_pred + 14)->i1_ref_frame;
381
382
            /* Store Left addresses for Next Mb   */
383
1.26k
            void **ppv_left_mv_pred_addr = ps_dec->ps_left_mvpred_addr[!u1_pingpong][1].u4_add;
384
1.26k
            WORD8 *p1_refleft0 = (ps_cur_mv_pred + 3)->i1_ref_frame;
385
386
1.26k
            ppv_top_mv_pred_addr[0] = apv_map_ref_idx_to_poc[p1_refTop0[0]];
387
1.26k
            ppv_top_mv_pred_addr[1] = pu4_map_ref_idx_to_poc_l1[p1_refTop0[1]];
388
389
1.26k
            ppv_left_mv_pred_addr[2] = apv_map_ref_idx_to_poc[p1_refTop1[0]];
390
1.26k
            ppv_top_mv_pred_addr[2] = apv_map_ref_idx_to_poc[p1_refTop1[0]];
391
1.26k
            ppv_left_mv_pred_addr[3] = pu4_map_ref_idx_to_poc_l1[p1_refTop1[1]];
392
1.26k
            ppv_top_mv_pred_addr[3] = pu4_map_ref_idx_to_poc_l1[p1_refTop1[1]];
393
394
1.26k
            ppv_left_mv_pred_addr[0] = apv_map_ref_idx_to_poc[p1_refleft0[0]];
395
1.26k
            ppv_left_mv_pred_addr[1] = pu4_map_ref_idx_to_poc_l1[p1_refleft0[1]];
396
            /* Storing the leftMbtype for next Mb */
397
1.26k
            ps_dec->deblk_left_mb[1].u1_mb_type = ps_cur_mb_params->u1_mb_type;
398
1.26k
        }
399
400
1.26k
        return;
401
1.26k
    }
402
403
    /* Flag for extra left Edge */
404
144k
    ps_cur_mb_params->u1_single_call = 1;
405
406
    /* Update the Left deblk_mb_t and Left MvPred Parameters           */
407
144k
    if(!u2_mbx)
408
18.0k
    {
409
18.0k
        u4_leftmbtype = 0;
410
411
        /* Initialize the ps_left_mv_pred with Junk but Valid Location */
412
        /* to avoid invalid memory access                           */
413
        /* this is read only pointer                                */
414
18.0k
        ps_left_mv_pred = ps_dec->ps_mv_cur + 3;
415
18.0k
    }
416
126k
    else
417
126k
    {
418
126k
        u4_leftmbtype = ps_dec->deblk_left_mb[1].u1_mb_type;
419
420
        /* Come to Left Most Edge of the MB */
421
126k
        ps_left_mv_pred =
422
126k
            (u2_mbxn_mb) ? ps_dec->ps_mv_cur + ((u2_mbxn_mb - 1) << 4) + 3 : ps_dec->ps_mv_left + 3;
423
126k
    }
424
425
144k
    if(!u2_mby) u1_top_mb_typ = 0;
426
427
    /* MvPred Pointer Calculation */
428
144k
    ps_top_mv_pred = ps_cur_mv_pred - (ps_dec->u2_frm_wd_in_mbs << 4) + 12;
429
430
144k
    u4_cur_mb_intra = u1_cur_mb_type & D_INTRA_MB;
431
144k
    u4_cur_mb_fld = !!(u1_cur_mb_type & D_FLD_MB);
432
    /* Compute BS function */
433
144k
    pu4_bs_table = ps_cur_mb_params->u4_bs_table;
434
435
144k
    u2_cur_csbp = ps_cur_mb_info->ps_curmb->u2_luma_csbp;
436
144k
    u2_left_csbp = ps_cur_mb_info->ps_left_mb->u2_luma_csbp;
437
144k
    u2_top_csbp = ps_cur_mb_info->ps_top_mb->u2_luma_csbp;
438
    /* Compute BS function */
439
144k
    if((ps_dec->ps_cur_sps->u1_profile_idc == HIGH_PROFILE_IDC) ||
440
144k
       (ps_dec->ps_cur_sps->u1_profile_idc == SCALABLE_HIGH_PROFILE_IDC) ||
441
144k
       (ps_dec->ps_cur_sps->u1_profile_idc == SCALABLE_BASELINE_PROFILE_IDC))
442
70.8k
    {
443
70.8k
        if(ps_cur_mb_info->u1_tran_form8x8 == 1)
444
47.7k
        {
445
47.7k
            u2_cur_csbp = ih264d_update_csbp_8x8(ps_cur_mb_info->ps_curmb->u2_luma_csbp);
446
47.7k
        }
447
448
70.8k
        if(ps_cur_mb_info->ps_left_mb->u1_tran_form8x8 == 1)
449
44.3k
        {
450
44.3k
            u2_left_csbp = ih264d_update_csbp_8x8(ps_cur_mb_info->ps_left_mb->u2_luma_csbp);
451
44.3k
        }
452
453
70.8k
        if(ps_cur_mb_info->ps_top_mb->u1_tran_form8x8 == 1)
454
38.7k
        {
455
38.7k
            u2_top_csbp = ih264d_update_csbp_8x8(ps_cur_mb_info->ps_top_mb->u2_luma_csbp);
456
38.7k
        }
457
70.8k
    }
458
144k
    if(u4_cur_mb_intra)
459
144k
    {
460
144k
        pu4_bs_table[4] = 0x04040404;
461
144k
        pu4_bs_table[0] = u4_cur_mb_fld ? 0x03030303 : 0x04040404;
462
144k
        pu4_bs_table[1] = 0x03030303;
463
144k
        pu4_bs_table[2] = 0x03030303;
464
144k
        pu4_bs_table[3] = 0x03030303;
465
144k
        pu4_bs_table[5] = 0x03030303;
466
144k
        pu4_bs_table[6] = 0x03030303;
467
144k
        pu4_bs_table[7] = 0x03030303;
468
144k
    }
469
0
    else
470
0
    {
471
0
        UWORD32 u4_is_non16x16 = !!(u1_cur_mb_type & D_PRED_NON_16x16);
472
0
        UWORD32 u4_is_b = ps_dec->u1_B;
473
474
0
        ih264d_fill_bs2_horz_vert(pu4_bs_table, u2_left_csbp, u2_top_csbp, u2_cur_csbp,
475
0
                                  (const UWORD32 *) (gau4_ih264d_packed_bs2),
476
0
                                  (const UWORD16 *) (gau2_ih264d_4x4_v2h_reorder));
477
478
0
        if(u4_leftmbtype & D_INTRA_MB) pu4_bs_table[4] = 0x04040404;
479
480
0
        if(u1_top_mb_typ & D_INTRA_MB) pu4_bs_table[0] = u4_cur_mb_fld ? 0x03030303 : 0x04040404;
481
482
0
        ps_dec->pf_fill_bs1[u4_is_b][u4_is_non16x16](
483
0
            ps_cur_mv_pred, ps_top_mv_pred, apv_map_ref_idx_to_poc, pu4_bs_table, ps_left_mv_pred,
484
0
            &(ps_dec->ps_left_mvpred_addr[u1_pingpong][1]),
485
0
            ps_cur_mb_info->ps_top_mb->u4_pic_addrress, (4 >> u4_cur_mb_fld));
486
0
    }
487
488
144k
    {
489
144k
        void **pu4_map_ref_idx_to_poc_l1 = apv_map_ref_idx_to_poc + POC_LIST_L0_TO_L1_DIFF;
490
144k
        {
491
            /* Store Parameter for Top MvPred refernce frame Address */
492
493
144k
            void **ppv_top_mv_pred_addr = ps_cur_mb_info->ps_curmb->u4_pic_addrress;
494
144k
            WORD8 *p1_refTop0 = (ps_cur_mv_pred + 12)->i1_ref_frame;
495
144k
            WORD8 *p1_refTop1 = (ps_cur_mv_pred + 14)->i1_ref_frame;
496
497
            /* Store Left addresses for Next Mb   */
498
144k
            void **ppv_left_mv_pred_addr = ps_dec->ps_left_mvpred_addr[!u1_pingpong][1].u4_add;
499
144k
            WORD8 *p1_refleft0 = (ps_cur_mv_pred + 3)->i1_ref_frame;
500
501
144k
            ppv_top_mv_pred_addr[0] = apv_map_ref_idx_to_poc[p1_refTop0[0]];
502
144k
            ppv_top_mv_pred_addr[1] = pu4_map_ref_idx_to_poc_l1[p1_refTop0[1]];
503
504
144k
            ppv_left_mv_pred_addr[2] = apv_map_ref_idx_to_poc[p1_refTop1[0]];
505
144k
            ppv_top_mv_pred_addr[2] = apv_map_ref_idx_to_poc[p1_refTop1[0]];
506
144k
            ppv_left_mv_pred_addr[3] = pu4_map_ref_idx_to_poc_l1[p1_refTop1[1]];
507
144k
            ppv_top_mv_pred_addr[3] = pu4_map_ref_idx_to_poc_l1[p1_refTop1[1]];
508
509
144k
            ppv_left_mv_pred_addr[0] = apv_map_ref_idx_to_poc[p1_refleft0[0]];
510
144k
            ppv_left_mv_pred_addr[1] = pu4_map_ref_idx_to_poc_l1[p1_refleft0[1]];
511
512
            /* Storing the leftMbtype for next Mb */
513
144k
            ps_dec->deblk_left_mb[1].u1_mb_type = ps_cur_mb_params->u1_mb_type;
514
144k
        }
515
144k
    }
516
517
    /* For transform 8x8 disable deblocking of the intrernal edges of a 8x8 block */
518
144k
    if(ps_cur_mb_info->u1_tran_form8x8)
519
47.7k
    {
520
47.7k
        pu4_bs_table[1] = 0;
521
47.7k
        pu4_bs_table[3] = 0;
522
47.7k
        pu4_bs_table[5] = 0;
523
47.7k
        pu4_bs_table[7] = 0;
524
47.7k
    }
525
144k
}
526
/*****************************************************************************/
527
/*                                                                           */
528
/*  Function Name : isvcd_compute_bs_non_mbaff                               */
529
/*                                                                           */
530
/*  Description   : This function computes the pointers of left,top & current*/
531
/*                : Nnz, MvPred & deblk_mb_t and supplies to FillBs function */
532
/*                : for Boundary Strength Calculation                        */
533
/*  Inputs        : <What inputs does the function take?>                    */
534
/*  Processing    : This functions calls deblock MB in the MB increment order*/
535
/*                                                                           */
536
/*  Outputs       : Produces the Boundary Strength for Current Mb            */
537
/*  Returns       : None                                                     */
538
/*                                                                           */
539
/*  Revision History:                                                        */
540
/*                                                                           */
541
/*         DD MM YYYY   Author(s)       Changes (Describe the changes made)  */
542
/*         06 09 2021   Kishore                                              */
543
/*****************************************************************************/
544
545
void isvcd_compute_bs_non_mbaff(svc_dec_lyr_struct_t *ps_svc_lyr_dec, dec_mb_info_t *ps_cur_mb_info,
546
                                const UWORD16 u2_mbxn_mb)
547
4.44k
{
548
4.44k
    dec_struct_t *ps_dec = &ps_svc_lyr_dec->s_dec;
549
4.44k
    ps_dec->pf_compute_bs(ps_dec, ps_cur_mb_info, u2_mbxn_mb);
550
4.44k
}
551
/*****************************************************************************/
552
/*                                                                           */
553
/*  Function Name : isvcd_compute_bs_non_mbaff_target_lyr                    */
554
/*                                                                           */
555
/*  Description   : This function computes the pointers of left,top & current*/
556
/*                : Nnz, MvPred & deblk_mb_t and supplies to FillBs function */
557
/*                : for Boundary Strength Calculation                        */
558
/*  Inputs        : <What inputs does the function take?>                    */
559
/*  Processing    : This functions calls deblock MB in the MB increment order*/
560
/*                                                                           */
561
/*  Outputs       : Produces the Boundary Strength for Current Mb            */
562
/*  Returns       : None                                                     */
563
/*                                                                           */
564
/*  Revision History:                                                        */
565
/*                                                                           */
566
/*         DD MM YYYY   Author(s)       Changes (Describe the changes made)  */
567
/*         06 09 2021   Kishore                                              */
568
/*****************************************************************************/
569
570
void isvcd_compute_bs_non_mbaff_target_lyr(svc_dec_lyr_struct_t *ps_svc_lyr_dec,
571
                                           dec_mb_info_t *ps_cur_mb_info, const UWORD16 u2_mbxn_mb)
572
190k
{
573
190k
    dec_struct_t *ps_dec = &ps_svc_lyr_dec->s_dec;
574
    /* Mvpred and Nnz for top and Courrent */
575
190k
    mv_pred_t *ps_cur_mv_pred, *ps_top_mv_pred = NULL, *ps_left_mv_pred;
576
    /* deblk_mb_t Params */
577
190k
    deblk_mb_t *ps_cur_mb_params; /*< Parameters of current MacroBlock */
578
190k
    deblkmb_neighbour_t *ps_deblk_top_mb;
579
580
    /* Reference Index to POC mapping*/
581
190k
    void **apv_map_ref_idx_to_poc;
582
190k
    UWORD32 u4_leftmbtype;
583
190k
    UWORD16 u2_left_csbp, u2_top_csbp, u2_cur_csbp;
584
585
    /* Set of flags */
586
190k
    UWORD32 u4_cur_mb_intra, u1_top_mb_typ, u4_cur_mb_fld;
587
190k
    UWORD32 u4_cur_mb_ibl;
588
190k
    UWORD32 u1_cur_mb_type;
589
190k
    UWORD32 *pu4_bs_table;
590
591
190k
    UWORD16 *pu2_curr_res_luma_csbp;
592
190k
    UWORD16 *pu2_left_res_luma_csbp;
593
190k
    UWORD16 *pu2_top_res_luma_csbp;
594
595
    /* Neighbour availability */
596
    /* Initialization */
597
190k
    const UWORD32 u2_mbx = ps_cur_mb_info->u2_mbx;
598
190k
    const UWORD32 u2_mby = ps_cur_mb_info->u2_mby;
599
190k
    const UWORD32 u1_pingpong = u2_mbx & 0x01;
600
601
190k
    PROFILE_DISABLE_BOUNDARY_STRENGTH()
602
603
190k
    ps_deblk_top_mb = ps_dec->ps_deblk_top_mb + u2_mbx;
604
605
    /* Pointer assignment for Current DeblkMB, Current Mv Pred  */
606
190k
    ps_cur_mb_params = ps_dec->ps_deblk_mbn + u2_mbxn_mb;
607
190k
    ps_cur_mv_pred = ps_dec->ps_mv_cur + (u2_mbxn_mb << 4);
608
609
    /*Pointer assignment for Residual NNZ */
610
190k
    pu2_curr_res_luma_csbp = ps_svc_lyr_dec->pu2_frm_res_luma_csbp + ps_cur_mb_info->u2_mbx;
611
190k
    pu2_curr_res_luma_csbp += ps_cur_mb_info->u2_mby * ps_svc_lyr_dec->i4_frm_res_luma_csbp_stride;
612
613
190k
    pu2_left_res_luma_csbp = pu2_curr_res_luma_csbp - (ps_cur_mb_info->u2_mbx != 0);
614
190k
    pu2_top_res_luma_csbp = pu2_curr_res_luma_csbp - ((ps_cur_mb_info->u2_mby != 0) *
615
190k
                                                      ps_svc_lyr_dec->i4_frm_res_luma_csbp_stride);
616
617
190k
    apv_map_ref_idx_to_poc = ps_dec->ppv_map_ref_idx_to_poc + 1;
618
190k
    u1_cur_mb_type = ps_cur_mb_params->u1_mb_type;
619
190k
    u1_top_mb_typ = ps_deblk_top_mb->u1_mb_type;
620
190k
    ps_deblk_top_mb->u1_mb_type = u1_cur_mb_type;
621
622
190k
    ps_cur_mb_params->u1_topmb_qp = ps_deblk_top_mb->u1_mb_qp;
623
190k
    ps_deblk_top_mb->u1_mb_qp = ps_cur_mb_params->u1_mb_qp;
624
190k
    ps_cur_mb_params->u1_left_mb_qp = ps_dec->deblk_left_mb[1].u1_mb_qp;
625
190k
    ps_dec->deblk_left_mb[1].u1_mb_qp = ps_cur_mb_params->u1_mb_qp;
626
627
    /* if no deblocking required for current Mb then continue */
628
    /* Check next Mbs   in Mb group                           */
629
190k
    if(ps_cur_mb_params->u1_deblocking_mode & MB_DISABLE_FILTERING)
630
9.67k
    {
631
9.67k
        void **pu4_map_ref_idx_to_poc_l1 = apv_map_ref_idx_to_poc + POC_LIST_L0_TO_L1_DIFF;
632
633
        /* Store Parameter for Top MvPred refernce frame Address */
634
9.67k
        void **ppv_top_mv_pred_addr = ps_cur_mb_info->ps_curmb->u4_pic_addrress;
635
9.67k
        WORD8 *p1_refTop0 = (ps_cur_mv_pred + 12)->i1_ref_frame;
636
9.67k
        WORD8 *p1_refTop1 = (ps_cur_mv_pred + 14)->i1_ref_frame;
637
638
        /* Store Left addresses for Next Mb   */
639
9.67k
        void **ppv_left_mv_pred_addr = ps_dec->ps_left_mvpred_addr[!u1_pingpong][1].u4_add;
640
9.67k
        WORD8 *p1_refleft0 = (ps_cur_mv_pred + 3)->i1_ref_frame;
641
642
9.67k
        ppv_top_mv_pred_addr[0] = apv_map_ref_idx_to_poc[p1_refTop0[0]];
643
9.67k
        ppv_top_mv_pred_addr[1] = pu4_map_ref_idx_to_poc_l1[p1_refTop0[1]];
644
645
9.67k
        ppv_left_mv_pred_addr[2] = apv_map_ref_idx_to_poc[p1_refTop1[0]];
646
9.67k
        ppv_top_mv_pred_addr[2] = apv_map_ref_idx_to_poc[p1_refTop1[0]];
647
9.67k
        ppv_left_mv_pred_addr[3] = pu4_map_ref_idx_to_poc_l1[p1_refTop1[1]];
648
9.67k
        ppv_top_mv_pred_addr[3] = pu4_map_ref_idx_to_poc_l1[p1_refTop1[1]];
649
650
9.67k
        ppv_left_mv_pred_addr[0] = apv_map_ref_idx_to_poc[p1_refleft0[0]];
651
9.67k
        ppv_left_mv_pred_addr[1] = pu4_map_ref_idx_to_poc_l1[p1_refleft0[1]];
652
        /* Storing the leftMbtype for next Mb */
653
9.67k
        ps_dec->deblk_left_mb[1].u1_mb_type = ps_cur_mb_params->u1_mb_type;
654
655
9.67k
        return;
656
9.67k
    }
657
658
    /* Flag for extra left Edge */
659
181k
    ps_cur_mb_params->u1_single_call = 1;
660
661
    /* Update the Left deblk_mb_t and Left MvPred Parameters           */
662
181k
    if(!u2_mbx)
663
51.6k
    {
664
51.6k
        u4_leftmbtype = 0;
665
666
        /* Initialize the ps_left_mv_pred with Junk but Valid Location */
667
        /* to avoid invalid memory access                           */
668
        /* this is read only pointer                                */
669
51.6k
        ps_left_mv_pred = ps_dec->ps_mv_cur + 3;
670
51.6k
    }
671
129k
    else
672
129k
    {
673
129k
        u4_leftmbtype = ps_dec->deblk_left_mb[1].u1_mb_type;
674
675
        /* Come to Left Most Edge of the MB */
676
129k
        ps_left_mv_pred =
677
129k
            (u2_mbxn_mb) ? ps_dec->ps_mv_cur + ((u2_mbxn_mb - 1) << 4) + 3 : ps_dec->ps_mv_left + 3;
678
129k
    }
679
680
181k
    if(!u2_mby) u1_top_mb_typ = 0;
681
682
    /* MvPred Pointer Calculation */
683
181k
    ps_top_mv_pred = ps_cur_mv_pred - (ps_dec->u2_frm_wd_in_mbs << 4) + 12;
684
181k
    u4_cur_mb_intra = u1_cur_mb_type & D_INTRA_MB;
685
181k
    u4_cur_mb_ibl = u1_cur_mb_type & D_INTRA_IBL;
686
181k
    u4_cur_mb_fld = !!(u1_cur_mb_type & D_FLD_MB);
687
    /* Compute BS function */
688
181k
    pu4_bs_table = ps_cur_mb_params->u4_bs_table;
689
690
181k
    u2_cur_csbp = ps_cur_mb_info->ps_curmb->u2_luma_csbp;
691
181k
    u2_left_csbp = ps_cur_mb_info->ps_left_mb->u2_luma_csbp;
692
181k
    u2_top_csbp = ps_cur_mb_info->ps_top_mb->u2_luma_csbp;
693
    /* Compute BS function */
694
181k
    if((ps_dec->ps_cur_sps->u1_profile_idc == HIGH_PROFILE_IDC) ||
695
181k
       (ps_dec->ps_cur_sps->u1_profile_idc == SCALABLE_HIGH_PROFILE_IDC) ||
696
181k
       (ps_dec->ps_cur_sps->u1_profile_idc == SCALABLE_BASELINE_PROFILE_IDC))
697
75.8k
    {
698
75.8k
        if(ps_cur_mb_info->u1_tran_form8x8 == 1)
699
8.53k
        {
700
8.53k
            u2_cur_csbp = ih264d_update_csbp_8x8(ps_cur_mb_info->ps_curmb->u2_luma_csbp);
701
8.53k
            ps_cur_mb_info->ps_curmb->u2_luma_csbp = u2_cur_csbp;
702
8.53k
        }
703
75.8k
    }
704
181k
    u2_cur_csbp |= *pu2_curr_res_luma_csbp;
705
181k
    u2_left_csbp |= *pu2_left_res_luma_csbp;
706
181k
    u2_top_csbp |= *pu2_top_res_luma_csbp;
707
708
181k
    if(u4_cur_mb_intra)
709
9.72k
    {
710
9.72k
        pu4_bs_table[4] = 0x04040404;
711
9.72k
        pu4_bs_table[0] = u4_cur_mb_fld ? 0x03030303 : 0x04040404;
712
9.72k
        pu4_bs_table[1] = 0x03030303;
713
9.72k
        pu4_bs_table[2] = 0x03030303;
714
9.72k
        pu4_bs_table[3] = 0x03030303;
715
9.72k
        pu4_bs_table[5] = 0x03030303;
716
9.72k
        pu4_bs_table[6] = 0x03030303;
717
9.72k
        pu4_bs_table[7] = 0x03030303;
718
9.72k
    }
719
171k
    else
720
171k
    {
721
171k
        isvcd_fill_bs_ibl(ps_cur_mb_params, u1_top_mb_typ, u4_leftmbtype, ps_cur_mb_info,
722
171k
                          pu2_curr_res_luma_csbp, pu2_left_res_luma_csbp, pu2_top_res_luma_csbp);
723
724
171k
        if(!u4_cur_mb_ibl)
725
132k
        {
726
132k
            UWORD32 u4_is_non16x16 = !!(u1_cur_mb_type & D_PRED_NON_16x16);
727
132k
            UWORD32 u4_is_b = ps_dec->u1_B;
728
132k
            UWORD32 u4_bs_0, u4_bs_4;
729
730
132k
            u4_bs_0 = pu4_bs_table[0];
731
132k
            u4_bs_4 = pu4_bs_table[4];
732
733
132k
            ih264d_fill_bs2_horz_vert(pu4_bs_table, u2_left_csbp, u2_top_csbp, u2_cur_csbp,
734
132k
                                      (const UWORD32 *) (gau4_ih264d_packed_bs2),
735
132k
                                      (const UWORD16 *) (gau2_ih264d_4x4_v2h_reorder));
736
737
132k
            if(u4_leftmbtype & D_INTRA_MB)
738
527
            {
739
527
                pu4_bs_table[4] = 0x04040404;
740
527
            }
741
132k
            else if(u4_leftmbtype & D_INTRA_IBL)
742
2.77k
            {
743
2.77k
                pu4_bs_table[4] = u4_bs_4;
744
2.77k
            }
745
746
132k
            if(u1_top_mb_typ & D_INTRA_MB)
747
686
            {
748
686
                pu4_bs_table[0] = u4_cur_mb_fld ? 0x03030303 : 0x04040404;
749
686
            }
750
132k
            else if(u1_top_mb_typ & D_INTRA_IBL)
751
3.94k
            {
752
3.94k
                pu4_bs_table[0] = u4_bs_0;
753
3.94k
            }
754
755
132k
            ps_dec->pf_fill_bs1[u4_is_b][u4_is_non16x16](
756
132k
                ps_cur_mv_pred, ps_top_mv_pred, apv_map_ref_idx_to_poc, pu4_bs_table,
757
132k
                ps_left_mv_pred, &(ps_dec->ps_left_mvpred_addr[u1_pingpong][1]),
758
132k
                ps_cur_mb_info->ps_top_mb->u4_pic_addrress, (4 >> u4_cur_mb_fld));
759
132k
        }
760
171k
    }
761
762
181k
    {
763
181k
        void **pu4_map_ref_idx_to_poc_l1 = apv_map_ref_idx_to_poc + POC_LIST_L0_TO_L1_DIFF;
764
        /* Store Parameter for Top MvPred refernce frame Address */
765
181k
        void **ppv_top_mv_pred_addr = ps_cur_mb_info->ps_curmb->u4_pic_addrress;
766
181k
        WORD8 *p1_refTop0 = (ps_cur_mv_pred + 12)->i1_ref_frame;
767
181k
        WORD8 *p1_refTop1 = (ps_cur_mv_pred + 14)->i1_ref_frame;
768
769
        /* Store Left addresses for Next Mb   */
770
181k
        void **ppv_left_mv_pred_addr = ps_dec->ps_left_mvpred_addr[!u1_pingpong][1].u4_add;
771
181k
        WORD8 *p1_refleft0 = (ps_cur_mv_pred + 3)->i1_ref_frame;
772
773
181k
        ppv_top_mv_pred_addr[0] = apv_map_ref_idx_to_poc[p1_refTop0[0]];
774
181k
        ppv_top_mv_pred_addr[1] = pu4_map_ref_idx_to_poc_l1[p1_refTop0[1]];
775
776
181k
        ppv_left_mv_pred_addr[2] = apv_map_ref_idx_to_poc[p1_refTop1[0]];
777
181k
        ppv_top_mv_pred_addr[2] = apv_map_ref_idx_to_poc[p1_refTop1[0]];
778
181k
        ppv_left_mv_pred_addr[3] = pu4_map_ref_idx_to_poc_l1[p1_refTop1[1]];
779
181k
        ppv_top_mv_pred_addr[3] = pu4_map_ref_idx_to_poc_l1[p1_refTop1[1]];
780
781
181k
        ppv_left_mv_pred_addr[0] = apv_map_ref_idx_to_poc[p1_refleft0[0]];
782
181k
        ppv_left_mv_pred_addr[1] = pu4_map_ref_idx_to_poc_l1[p1_refleft0[1]];
783
784
        /* Storing the leftMbtype for next Mb */
785
181k
        ps_dec->deblk_left_mb[1].u1_mb_type = ps_cur_mb_params->u1_mb_type;
786
181k
    }
787
788
    /* For transform 8x8 disable deblocking of the intrernal edges of a 8x8 block */
789
181k
    if(ps_cur_mb_info->u1_tran_form8x8)
790
17.6k
    {
791
17.6k
        pu4_bs_table[1] = 0;
792
17.6k
        pu4_bs_table[3] = 0;
793
17.6k
        pu4_bs_table[5] = 0;
794
17.6k
        pu4_bs_table[7] = 0;
795
17.6k
    }
796
181k
}
797
798
/*****************************************************************************/
799
/*                                                                           */
800
/*  Function Name : isvcd_compute_bs_non_mbaff_medial_lyr                    */
801
/*                                                                           */
802
/*  Description   : This function computes the pointers of left,top & current*/
803
/*                : Nnz, MvPred & deblk_mb_t and supplies to FillBs function */
804
/*                : for Boundary Strength Calculation                        */
805
/*  Inputs        : <What inputs does the function take?>                    */
806
/*  Processing    : This functions calls deblock MB in the MB increment order*/
807
/*                                                                           */
808
/*  Outputs       : Produces the Boundary Strength for Current Mb            */
809
/*  Returns       : None                                                     */
810
/*                                                                           */
811
/*  Revision History:                                                        */
812
/*                                                                           */
813
/*         DD MM YYYY   Author(s)       Changes (Describe the changes made)  */
814
/*         06 09 2021   Kishore                                              */
815
/*****************************************************************************/
816
817
void isvcd_compute_bs_non_mbaff_medial_lyr(svc_dec_lyr_struct_t *ps_svc_lyr_dec,
818
                                           dec_mb_info_t *ps_cur_mb_info, const UWORD16 u2_mbxn_mb)
819
0
{
820
0
    dec_struct_t *ps_dec = &ps_svc_lyr_dec->s_dec;
821
    /* deblk_mb_t Params */
822
0
    deblk_mb_t *ps_cur_mb_params; /*< Parameters of current MacroBlock */
823
0
    deblkmb_neighbour_t *ps_deblk_top_mb;
824
0
    UWORD32 u4_leftmbtype;
825
0
    UWORD16 u2_cur_csbp;
826
827
    /* Set of flags */
828
0
    UWORD32 u4_cur_mb_intra, u1_top_mb_typ, u4_cur_mb_fld;
829
0
    UWORD32 u1_cur_mb_type;
830
0
    UWORD32 *pu4_bs_table;
831
0
    UWORD32 mb_type_intra = 0;
832
833
0
    UWORD16 *pu2_curr_res_luma_csbp;
834
0
    UWORD16 *pu2_left_res_luma_csbp;
835
0
    UWORD16 *pu2_top_res_luma_csbp;
836
837
    /* Neighbour availability */
838
0
    const UWORD32 u2_mbx = ps_cur_mb_info->u2_mbx;
839
0
    const UWORD32 u2_mby = ps_cur_mb_info->u2_mby;
840
841
0
    PROFILE_DISABLE_BOUNDARY_STRENGTH()
842
843
0
    ps_deblk_top_mb = ps_dec->ps_deblk_top_mb + u2_mbx;
844
845
    /* Pointer assignment for Current DeblkMB, Current Mv Pred  */
846
0
    ps_cur_mb_params = ps_dec->ps_deblk_mbn + u2_mbxn_mb;
847
848
    /*Pointer assignment for Residual NNZ */
849
0
    pu2_curr_res_luma_csbp = ps_svc_lyr_dec->pu2_frm_res_luma_csbp + ps_cur_mb_info->u2_mbx;
850
0
    pu2_curr_res_luma_csbp += ps_cur_mb_info->u2_mby * ps_svc_lyr_dec->i4_frm_res_luma_csbp_stride;
851
852
0
    pu2_left_res_luma_csbp = pu2_curr_res_luma_csbp - (ps_cur_mb_info->u2_mbx != 0);
853
0
    pu2_top_res_luma_csbp = pu2_curr_res_luma_csbp - ((ps_cur_mb_info->u2_mby != 0) *
854
0
                                                      ps_svc_lyr_dec->i4_frm_res_luma_csbp_stride);
855
856
0
    u1_cur_mb_type = ps_cur_mb_params->u1_mb_type;
857
0
    u1_top_mb_typ = ps_deblk_top_mb->u1_mb_type;
858
0
    ps_deblk_top_mb->u1_mb_type = u1_cur_mb_type;
859
860
0
    ps_cur_mb_params->u1_topmb_qp = ps_deblk_top_mb->u1_mb_qp;
861
0
    ps_deblk_top_mb->u1_mb_qp = ps_cur_mb_params->u1_mb_qp;
862
0
    ps_cur_mb_params->u1_left_mb_qp = ps_dec->deblk_left_mb[1].u1_mb_qp;
863
0
    ps_dec->deblk_left_mb[1].u1_mb_qp = ps_cur_mb_params->u1_mb_qp;
864
865
    /* if no deblocking required for current Mb then continue */
866
    /* Check next Mbs   in Mb group                           */
867
0
    if(ps_cur_mb_params->u1_deblocking_mode & MB_DISABLE_FILTERING)
868
0
    {
869
        /* Storing the leftMbtype for next Mb */
870
0
        ps_dec->deblk_left_mb[1].u1_mb_type = ps_cur_mb_params->u1_mb_type;
871
0
        return;
872
0
    }
873
874
    /* Flag for extra left Edge */
875
0
    ps_cur_mb_params->u1_single_call = 1;
876
877
    /* Update the Left deblk_mb_t */
878
0
    if(!u2_mbx)
879
0
    {
880
0
        u4_leftmbtype = 0;
881
0
    }
882
0
    else
883
0
    {
884
0
        u4_leftmbtype = ps_dec->deblk_left_mb[1].u1_mb_type;
885
0
    }
886
887
0
    if(!u2_mby) u1_top_mb_typ = 0;
888
889
0
    u4_cur_mb_intra = u1_cur_mb_type & D_INTRA_MB;
890
0
    u4_cur_mb_fld = !!(u1_cur_mb_type & D_FLD_MB);
891
    /* Compute BS function */
892
0
    pu4_bs_table = ps_cur_mb_params->u4_bs_table;
893
894
0
    u2_cur_csbp = ps_cur_mb_info->ps_curmb->u2_luma_csbp;
895
    /* Compute BS function */
896
0
    if((ps_dec->ps_cur_sps->u1_profile_idc == HIGH_PROFILE_IDC) ||
897
0
       (ps_dec->ps_cur_sps->u1_profile_idc == SCALABLE_HIGH_PROFILE_IDC) ||
898
0
       (ps_dec->ps_cur_sps->u1_profile_idc == SCALABLE_BASELINE_PROFILE_IDC))
899
0
    {
900
0
        if(ps_cur_mb_info->u1_tran_form8x8 == 1)
901
0
        {
902
0
            u2_cur_csbp = ih264d_update_csbp_8x8(ps_cur_mb_info->ps_curmb->u2_luma_csbp);
903
0
            ps_cur_mb_info->ps_curmb->u2_luma_csbp = u2_cur_csbp;
904
0
        }
905
0
    }
906
0
    u2_cur_csbp |= *pu2_curr_res_luma_csbp;
907
908
0
    if(u4_cur_mb_intra)
909
0
    {
910
0
        pu4_bs_table[4] = 0x04040404;
911
0
        pu4_bs_table[0] = u4_cur_mb_fld ? 0x03030303 : 0x04040404;
912
0
        pu4_bs_table[1] = 0x03030303;
913
0
        pu4_bs_table[2] = 0x03030303;
914
0
        pu4_bs_table[3] = 0x03030303;
915
0
        pu4_bs_table[5] = 0x03030303;
916
0
        pu4_bs_table[6] = 0x03030303;
917
0
        pu4_bs_table[7] = 0x03030303;
918
0
    }
919
0
    else
920
0
    {
921
0
        isvcd_fill_bs_ibl(ps_cur_mb_params, u1_top_mb_typ, u4_leftmbtype, ps_cur_mb_info,
922
0
                          pu2_curr_res_luma_csbp, pu2_left_res_luma_csbp, pu2_top_res_luma_csbp);
923
0
    }
924
925
0
    mb_type_intra = (u1_top_mb_typ & D_INTRA_MB) || (u1_top_mb_typ & D_INTRA_IBL);
926
927
    /* if Top MB or current MB is INTER */
928
0
    if(!mb_type_intra)
929
0
    {
930
0
        pu4_bs_table[0] = 0;
931
        /* disable the processing of top edge  */
932
0
        ps_cur_mb_params->u1_deblocking_mode |= MB_DISABLE_TOP_EDGE;
933
0
    }
934
935
0
    mb_type_intra = (u4_leftmbtype & D_INTRA_MB) || (u4_leftmbtype & D_INTRA_IBL);
936
    /* if Left MB current MB is INTER */
937
0
    if(!mb_type_intra)
938
0
    {
939
0
        pu4_bs_table[4] = 0;
940
        /* disable the processing of left edge  */
941
0
        ps_cur_mb_params->u1_deblocking_mode |= MB_DISABLE_LEFT_EDGE;
942
0
    }
943
944
    /* overwrite the BS 0 values for corner cases */
945
0
    if(0 == u2_mbx)
946
0
    {
947
0
        pu4_bs_table[4] = 0;
948
0
    }
949
0
    if(0 == u2_mby)
950
0
    {
951
0
        pu4_bs_table[0] = 0;
952
0
    }
953
954
    /* Storing the leftMbtype for next Mb */
955
0
    ps_dec->deblk_left_mb[1].u1_mb_type = ps_cur_mb_params->u1_mb_type;
956
957
    /* For transform 8x8 disable deblocking of the intrernal edges of a 8x8 block */
958
0
    if(ps_cur_mb_info->u1_tran_form8x8)
959
0
    {
960
0
        pu4_bs_table[1] = 0;
961
0
        pu4_bs_table[3] = 0;
962
0
        pu4_bs_table[5] = 0;
963
0
        pu4_bs_table[7] = 0;
964
0
    }
965
0
}