Coverage Report

Created: 2026-09-01 06:44

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/libavc/decoder/svc/isvcd_compute_bs.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_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
60.2k
{
66
60.2k
    WORD32 i4_i;
67
60.2k
    WORD32 i4_bit_mask;
68
60.2k
    UWORD16 u2_result = 0;
69
70
60.2k
    i4_bit_mask = i4_initial_bit_mask;
71
72
301k
    for(i4_i = 0; i4_i < NUM_SUB_MB_PARTS; i4_i++)
73
240k
    {
74
240k
        WORD32 i4_bit;
75
        /* extract the bits of the last column 4x4 blocks */
76
240k
        if(0 == (i4_bit_mask & u2_bit_field))
77
225k
        {
78
225k
            i4_bit = 0;
79
225k
        }
80
15.6k
        else
81
15.6k
        {
82
15.6k
            i4_bit = 1;
83
15.6k
        }
84
        /* store the result */
85
240k
        u2_result |= i4_bit << i4_i;
86
240k
        i4_bit_mask <<= 4;
87
88
240k
    } /* end of loop over num sub Mb parts */
89
60.2k
    return (u2_result);
90
60.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
963k
{
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
963k
    UWORD16 u2_top_horz_nnz;
107
963k
    UWORD8 u1_top_mb_ibl, u1_left_mb_ibl;
108
963k
    UWORD32 i4_i, i4_edge;
109
963k
    UWORD8 u1_bs;
110
963k
    UWORD8 u1_cnd;
111
963k
    UWORD8 u1_top_intra;
112
963k
    UWORD8 u1_left_intra;
113
963k
    UWORD8 u1_p_nnz, u1_q_nnz;
114
963k
    UWORD8 u1_curr_mb_ibl;
115
963k
    UWORD32 *pu4_bs_table;
116
963k
    UWORD16 u2_curr_nnz;
117
963k
    UWORD8 u1_left_mb_nnz = 0, u1_left_nnz;
118
963k
    WORD32 i4_horz_start = 0;
119
963k
    WORD32 i4_vertical_start = 0;
120
121
963k
    pu4_bs_table = &(ps_deblk_mb->u4_bs_table[0]);
122
123
963k
    u1_top_mb_ibl = u1_top_mb_type & D_INTRA_IBL;
124
963k
    u1_left_mb_ibl = u1_left_mb_type & D_INTRA_IBL;
125
126
963k
    u1_curr_mb_ibl = ps_deblk_mb->u1_mb_type & D_INTRA_IBL;
127
128
963k
    u1_top_intra = u1_top_mb_type & D_INTRA_MB;
129
963k
    u1_left_intra = u1_left_mb_type & D_INTRA_MB;
130
131
    /* return if none of the current top and left is IBL */
132
963k
    if((0 == u1_curr_mb_ibl) && (0 == u1_top_mb_ibl) && (0 == u1_left_mb_ibl))
133
903k
    {
134
903k
        return;
135
903k
    }
136
137
    /* set up the vertical and horz MB edge skip flags */
138
60.2k
    if(0 != u1_curr_mb_ibl)
139
47.6k
    {
140
        /* if top is not IBL */
141
47.6k
        if(0 == u1_top_mb_ibl)
142
17.9k
        {
143
17.9k
            i4_horz_start = 1;
144
17.9k
        }
145
146
        /* if left in not IBL */
147
47.6k
        if(0 == u1_left_mb_ibl)
148
22.1k
        {
149
22.1k
            i4_vertical_start = 1;
150
22.1k
        }
151
47.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
60.2k
    if((0 != u1_curr_mb_ibl) || (0 != u1_top_mb_ibl) || (0 != u1_left_mb_ibl))
159
60.2k
    {
160
60.2k
        UWORD16 u2_temp, u2_i;
161
60.2k
        u2_temp = *pu2_left_res_luma_csbp;
162
301k
        for(u2_i = 0; u2_i < 4; u2_i++)
163
240k
        {
164
240k
            u1_left_mb_nnz |= ((u2_temp & 0x08) >> (3 - u2_i));
165
240k
            u2_temp >>= 4;
166
240k
        }
167
60.2k
        u2_curr_nnz = *pu2_curr_res_luma_csbp;
168
60.2k
        u2_top_horz_nnz = *pu2_top_res_luma_csbp >> 12;
169
170
        /* top is intra and not ibl */
171
60.2k
        if(0 != u1_top_intra)
172
3.61k
        {
173
3.61k
            pu4_bs_table[0] = 0x04040404;
174
3.61k
        }
175
        /* left is intra and not ibl */
176
60.2k
        if(0 != u1_left_intra)
177
3.15k
        {
178
3.15k
            pu4_bs_table[4] = 0x04040404;
179
3.15k
        }
180
181
        /* assume neighbours are inter and update bs */
182
183
        /* Edge = 0 means Vert Edges and Edge = 1 means Horz edges */
184
180k
        for(i4_edge = 0; i4_edge < 2; i4_edge++)
185
120k
        {
186
120k
            UWORD8 u1_p_nnz, u1_q_nnz;
187
120k
            UWORD32 u4_bs_edge = 0;
188
120k
            WORD32 i4_bit_mask;
189
120k
            WORD32 i4_curr_intra_flag;
190
120k
            WORD32 i4_neibor_intra_flag;
191
192
120k
            i4_curr_intra_flag = (0 != u1_curr_mb_ibl);
193
194
120k
            if(0 != i4_edge)
195
60.2k
            {
196
                /* Initialize for the TOP edge */
197
60.2k
                u1_p_nnz = (UWORD8) u2_top_horz_nnz;
198
60.2k
                u1_q_nnz = (UWORD8) (u2_curr_nnz & g_au4_extract_set[0]);
199
60.2k
                i4_neibor_intra_flag = (u1_top_mb_ibl || u1_top_intra);
200
60.2k
            }
201
60.2k
            else
202
60.2k
            {
203
60.2k
                u1_p_nnz = u1_left_mb_nnz;
204
60.2k
                u1_q_nnz = (UWORD8) isvcd_deblk_extract_bit_flags(u2_curr_nnz, 0x01);
205
60.2k
                i4_neibor_intra_flag = (u1_left_mb_ibl || u1_left_intra);
206
60.2k
            }
207
208
120k
            i4_bit_mask = 1;
209
            /* find bs of 4 edges */
210
602k
            for(i4_i = 0; i4_i < 4; i4_i++)
211
481k
            {
212
481k
                UWORD8 u1_p_nnz_temp, u1_q_nnz_temp;
213
214
481k
                u1_p_nnz_temp = (u1_p_nnz & i4_bit_mask);
215
481k
                u1_q_nnz_temp = (u1_q_nnz & i4_bit_mask);
216
217
481k
                u1_cnd = ((u1_p_nnz_temp && (!i4_neibor_intra_flag)) ||
218
475k
                          (u1_q_nnz_temp && (!i4_curr_intra_flag)));
219
220
481k
                u1_bs = u1_cnd ? 2 : 1;
221
222
                /* update the bs of the edge */
223
481k
                u4_bs_edge = (u4_bs_edge << 8) + u1_bs;
224
481k
                i4_bit_mask <<= 1;
225
226
481k
            } /* end of loop over blk edges */
227
228
            /* update the bs of edges */
229
120k
            if(i4_edge && !u1_top_intra)
230
56.6k
            {
231
56.6k
                pu4_bs_table[0] = u4_bs_edge;
232
56.6k
            }
233
63.8k
            else if(!i4_edge && !u1_left_intra)
234
57.0k
            {
235
57.0k
                pu4_bs_table[4] = u4_bs_edge;
236
57.0k
            }
237
120k
        } /* end of loop over v1 vetical and horizontal edge */
238
60.2k
    }
239
    /* current MB is IBL */
240
60.2k
    if(0 != u1_curr_mb_ibl)
241
47.6k
    {
242
47.6k
        UWORD16 u2_temp, u2_i;
243
47.6k
        WORD32 i4_bit_mask_edge = 1;
244
245
47.6k
        u1_left_mb_nnz = 0;
246
47.6k
        u2_temp = ps_cur_mb_info->ps_left_mb->u2_luma_csbp;
247
238k
        for(u2_i = 0; u2_i < 4; u2_i++)
248
190k
        {
249
190k
            u1_left_mb_nnz |= ((u2_temp & 0x08) >> (3 - u2_i));
250
190k
            u2_temp >>= 4;
251
190k
        }
252
47.6k
        u2_curr_nnz = ps_cur_mb_info->ps_curmb->u2_luma_csbp;
253
47.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
238k
        for(i4_edge = 0; i4_edge < 4; i4_edge++)
257
190k
        {
258
190k
            UWORD16 u2_curr_horz_nnz = 0;
259
190k
            WORD32 i4_bit_mask = 1;
260
261
190k
            u2_curr_horz_nnz = u2_curr_nnz & g_au4_extract_set[i4_edge];
262
263
190k
            u2_curr_horz_nnz = (u2_curr_horz_nnz >> (i4_edge * 4));
264
265
190k
            u1_left_nnz = (u1_left_mb_nnz & i4_bit_mask_edge);
266
267
952k
            for(i4_i = 0; i4_i < 4; i4_i++)
268
762k
            {
269
762k
                UWORD8 u1_curr_nnz, u1_top_nnz;
270
271
762k
                u1_curr_nnz = (u2_curr_horz_nnz & i4_bit_mask);
272
762k
                u1_top_nnz = (u2_top_horz_nnz & i4_bit_mask);
273
                /* update bs horizontal */
274
275
762k
                if(!((1 == i4_horz_start) && (0 == i4_edge)))
276
690k
                {
277
690k
                    u1_p_nnz = u1_top_nnz;
278
690k
                    u1_q_nnz = u1_curr_nnz;
279
690k
                    u1_cnd = !(u1_p_nnz || u1_q_nnz);
280
690k
                    u1_bs = u1_cnd ? 0 : 1;
281
690k
                    pu4_bs_table[i4_edge] = (pu4_bs_table[i4_edge] << 8) + u1_bs;
282
690k
                }
283
284
                /* update bs vertical */
285
762k
                if(!((1 == i4_vertical_start) && (0 == i4_i)))
286
673k
                {
287
673k
                    u1_p_nnz = u1_left_nnz;
288
673k
                    u1_q_nnz = u1_curr_nnz;
289
673k
                    u1_cnd = !(u1_p_nnz || u1_q_nnz);
290
673k
                    u1_bs = u1_cnd ? 0 : 1;
291
673k
                    pu4_bs_table[i4_i + 4] = (pu4_bs_table[i4_i + 4] << 8) + u1_bs;
292
673k
                }
293
                /* store the current nnz to left nnz */
294
762k
                u1_left_nnz = u1_curr_nnz;
295
762k
                i4_bit_mask <<= 1;
296
762k
            }
297
            /* store the current row nnz to top row nnz */
298
190k
            u2_top_horz_nnz = u2_curr_horz_nnz;
299
190k
            i4_bit_mask_edge <<= 1;
300
190k
        }
301
47.6k
    }
302
60.2k
    return;
303
963k
}
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
107k
{
328
107k
    dec_struct_t *ps_dec = &ps_svc_lyr_dec->s_dec;
329
    /* Mvpred and Nnz for top and Courrent */
330
107k
    mv_pred_t *ps_cur_mv_pred, *ps_top_mv_pred = NULL, *ps_left_mv_pred;
331
    /* deblk_mb_t Params */
332
107k
    deblk_mb_t *ps_cur_mb_params; /*< Parameters of current MacroBlock */
333
107k
    deblkmb_neighbour_t *ps_deblk_top_mb;
334
335
    /* Reference Index to POC mapping*/
336
107k
    void **apv_map_ref_idx_to_poc;
337
107k
    UWORD32 u4_leftmbtype;
338
339
107k
    UWORD16 u2_left_csbp, u2_top_csbp, u2_cur_csbp;
340
341
    /* Set of flags */
342
107k
    UWORD32 u4_cur_mb_intra, u1_top_mb_typ, u4_cur_mb_fld;
343
107k
    UWORD32 u1_cur_mb_type;
344
107k
    UWORD32 *pu4_bs_table;
345
346
    /* Neighbour availability */
347
    /* Initialization */
348
107k
    const UWORD32 u2_mbx = ps_cur_mb_info->u2_mbx;
349
107k
    const UWORD32 u2_mby = ps_cur_mb_info->u2_mby;
350
107k
    const UWORD32 u1_pingpong = u2_mbx & 0x01;
351
352
107k
    PROFILE_DISABLE_BOUNDARY_STRENGTH()
353
354
107k
    ps_deblk_top_mb = ps_dec->ps_deblk_top_mb + u2_mbx;
355
356
    /* Pointer assignment for Current DeblkMB, Current Mv Pred  */
357
107k
    ps_cur_mb_params = ps_dec->ps_deblk_mbn + u2_mbxn_mb;
358
107k
    ps_cur_mv_pred = ps_dec->ps_mv_cur + (u2_mbxn_mb << 4);
359
360
107k
    apv_map_ref_idx_to_poc = ps_dec->ppv_map_ref_idx_to_poc + 1;
361
107k
    u1_cur_mb_type = ps_cur_mb_params->u1_mb_type;
362
107k
    u1_top_mb_typ = ps_deblk_top_mb->u1_mb_type;
363
107k
    ps_deblk_top_mb->u1_mb_type = u1_cur_mb_type;
364
365
107k
    ps_cur_mb_params->u1_topmb_qp = ps_deblk_top_mb->u1_mb_qp;
366
107k
    ps_deblk_top_mb->u1_mb_qp = ps_cur_mb_params->u1_mb_qp;
367
107k
    ps_cur_mb_params->u1_left_mb_qp = ps_dec->deblk_left_mb[1].u1_mb_qp;
368
107k
    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
107k
    if(ps_cur_mb_params->u1_deblocking_mode & MB_DISABLE_FILTERING)
373
1.62k
    {
374
1.62k
        void **pu4_map_ref_idx_to_poc_l1 = apv_map_ref_idx_to_poc + POC_LIST_L0_TO_L1_DIFF;
375
1.62k
        {
376
            /* Store Parameter for Top MvPred refernce frame Address */
377
378
1.62k
            void **ppv_top_mv_pred_addr = ps_cur_mb_info->ps_curmb->u4_pic_addrress;
379
1.62k
            WORD8 *p1_refTop0 = (ps_cur_mv_pred + 12)->i1_ref_frame;
380
1.62k
            WORD8 *p1_refTop1 = (ps_cur_mv_pred + 14)->i1_ref_frame;
381
382
            /* Store Left addresses for Next Mb   */
383
1.62k
            void **ppv_left_mv_pred_addr = ps_dec->ps_left_mvpred_addr[!u1_pingpong][1].u4_add;
384
1.62k
            WORD8 *p1_refleft0 = (ps_cur_mv_pred + 3)->i1_ref_frame;
385
386
1.62k
            ppv_top_mv_pred_addr[0] = apv_map_ref_idx_to_poc[p1_refTop0[0]];
387
1.62k
            ppv_top_mv_pred_addr[1] = pu4_map_ref_idx_to_poc_l1[p1_refTop0[1]];
388
389
1.62k
            ppv_left_mv_pred_addr[2] = apv_map_ref_idx_to_poc[p1_refTop1[0]];
390
1.62k
            ppv_top_mv_pred_addr[2] = apv_map_ref_idx_to_poc[p1_refTop1[0]];
391
1.62k
            ppv_left_mv_pred_addr[3] = pu4_map_ref_idx_to_poc_l1[p1_refTop1[1]];
392
1.62k
            ppv_top_mv_pred_addr[3] = pu4_map_ref_idx_to_poc_l1[p1_refTop1[1]];
393
394
1.62k
            ppv_left_mv_pred_addr[0] = apv_map_ref_idx_to_poc[p1_refleft0[0]];
395
1.62k
            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.62k
            ps_dec->deblk_left_mb[1].u1_mb_type = ps_cur_mb_params->u1_mb_type;
398
1.62k
        }
399
400
1.62k
        return;
401
1.62k
    }
402
403
    /* Flag for extra left Edge */
404
105k
    ps_cur_mb_params->u1_single_call = 1;
405
406
    /* Update the Left deblk_mb_t and Left MvPred Parameters           */
407
105k
    if(!u2_mbx)
408
17.8k
    {
409
17.8k
        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
17.8k
        ps_left_mv_pred = ps_dec->ps_mv_cur + 3;
415
17.8k
    }
416
87.7k
    else
417
87.7k
    {
418
87.7k
        u4_leftmbtype = ps_dec->deblk_left_mb[1].u1_mb_type;
419
420
        /* Come to Left Most Edge of the MB */
421
87.7k
        ps_left_mv_pred =
422
87.7k
            (u2_mbxn_mb) ? ps_dec->ps_mv_cur + ((u2_mbxn_mb - 1) << 4) + 3 : ps_dec->ps_mv_left + 3;
423
87.7k
    }
424
425
105k
    if(!u2_mby) u1_top_mb_typ = 0;
426
427
    /* MvPred Pointer Calculation */
428
105k
    ps_top_mv_pred = ps_cur_mv_pred - (ps_dec->u2_frm_wd_in_mbs << 4) + 12;
429
430
105k
    u4_cur_mb_intra = u1_cur_mb_type & D_INTRA_MB;
431
105k
    u4_cur_mb_fld = !!(u1_cur_mb_type & D_FLD_MB);
432
    /* Compute BS function */
433
105k
    pu4_bs_table = ps_cur_mb_params->u4_bs_table;
434
435
105k
    u2_cur_csbp = ps_cur_mb_info->ps_curmb->u2_luma_csbp;
436
105k
    u2_left_csbp = ps_cur_mb_info->ps_left_mb->u2_luma_csbp;
437
105k
    u2_top_csbp = ps_cur_mb_info->ps_top_mb->u2_luma_csbp;
438
    /* Compute BS function */
439
105k
    if((ps_dec->ps_cur_sps->u1_profile_idc == HIGH_PROFILE_IDC) ||
440
60.3k
       (ps_dec->ps_cur_sps->u1_profile_idc == SCALABLE_HIGH_PROFILE_IDC) ||
441
60.3k
       (ps_dec->ps_cur_sps->u1_profile_idc == SCALABLE_BASELINE_PROFILE_IDC))
442
45.2k
    {
443
45.2k
        if(ps_cur_mb_info->u1_tran_form8x8 == 1)
444
25.3k
        {
445
25.3k
            u2_cur_csbp = ih264d_update_csbp_8x8(ps_cur_mb_info->ps_curmb->u2_luma_csbp);
446
25.3k
        }
447
448
45.2k
        if(ps_cur_mb_info->ps_left_mb->u1_tran_form8x8 == 1)
449
22.3k
        {
450
22.3k
            u2_left_csbp = ih264d_update_csbp_8x8(ps_cur_mb_info->ps_left_mb->u2_luma_csbp);
451
22.3k
        }
452
453
45.2k
        if(ps_cur_mb_info->ps_top_mb->u1_tran_form8x8 == 1)
454
15.6k
        {
455
15.6k
            u2_top_csbp = ih264d_update_csbp_8x8(ps_cur_mb_info->ps_top_mb->u2_luma_csbp);
456
15.6k
        }
457
45.2k
    }
458
105k
    if(u4_cur_mb_intra)
459
105k
    {
460
105k
        pu4_bs_table[4] = 0x04040404;
461
105k
        pu4_bs_table[0] = u4_cur_mb_fld ? 0x03030303 : 0x04040404;
462
105k
        pu4_bs_table[1] = 0x03030303;
463
105k
        pu4_bs_table[2] = 0x03030303;
464
105k
        pu4_bs_table[3] = 0x03030303;
465
105k
        pu4_bs_table[5] = 0x03030303;
466
105k
        pu4_bs_table[6] = 0x03030303;
467
105k
        pu4_bs_table[7] = 0x03030303;
468
105k
    }
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
105k
    {
489
105k
        void **pu4_map_ref_idx_to_poc_l1 = apv_map_ref_idx_to_poc + POC_LIST_L0_TO_L1_DIFF;
490
105k
        {
491
            /* Store Parameter for Top MvPred refernce frame Address */
492
493
105k
            void **ppv_top_mv_pred_addr = ps_cur_mb_info->ps_curmb->u4_pic_addrress;
494
105k
            WORD8 *p1_refTop0 = (ps_cur_mv_pred + 12)->i1_ref_frame;
495
105k
            WORD8 *p1_refTop1 = (ps_cur_mv_pred + 14)->i1_ref_frame;
496
497
            /* Store Left addresses for Next Mb   */
498
105k
            void **ppv_left_mv_pred_addr = ps_dec->ps_left_mvpred_addr[!u1_pingpong][1].u4_add;
499
105k
            WORD8 *p1_refleft0 = (ps_cur_mv_pred + 3)->i1_ref_frame;
500
501
105k
            ppv_top_mv_pred_addr[0] = apv_map_ref_idx_to_poc[p1_refTop0[0]];
502
105k
            ppv_top_mv_pred_addr[1] = pu4_map_ref_idx_to_poc_l1[p1_refTop0[1]];
503
504
105k
            ppv_left_mv_pred_addr[2] = apv_map_ref_idx_to_poc[p1_refTop1[0]];
505
105k
            ppv_top_mv_pred_addr[2] = apv_map_ref_idx_to_poc[p1_refTop1[0]];
506
105k
            ppv_left_mv_pred_addr[3] = pu4_map_ref_idx_to_poc_l1[p1_refTop1[1]];
507
105k
            ppv_top_mv_pred_addr[3] = pu4_map_ref_idx_to_poc_l1[p1_refTop1[1]];
508
509
105k
            ppv_left_mv_pred_addr[0] = apv_map_ref_idx_to_poc[p1_refleft0[0]];
510
105k
            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
105k
            ps_dec->deblk_left_mb[1].u1_mb_type = ps_cur_mb_params->u1_mb_type;
514
105k
        }
515
105k
    }
516
517
    /* For transform 8x8 disable deblocking of the intrernal edges of a 8x8 block */
518
105k
    if(ps_cur_mb_info->u1_tran_form8x8)
519
25.3k
    {
520
25.3k
        pu4_bs_table[1] = 0;
521
25.3k
        pu4_bs_table[3] = 0;
522
25.3k
        pu4_bs_table[5] = 0;
523
25.3k
        pu4_bs_table[7] = 0;
524
25.3k
    }
525
105k
}
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
8.05k
{
548
8.05k
    dec_struct_t *ps_dec = &ps_svc_lyr_dec->s_dec;
549
8.05k
    ps_dec->pf_compute_bs(ps_dec, ps_cur_mb_info, u2_mbxn_mb);
550
8.05k
}
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
163k
{
573
163k
    dec_struct_t *ps_dec = &ps_svc_lyr_dec->s_dec;
574
    /* Mvpred and Nnz for top and Courrent */
575
163k
    mv_pred_t *ps_cur_mv_pred, *ps_top_mv_pred = NULL, *ps_left_mv_pred;
576
    /* deblk_mb_t Params */
577
163k
    deblk_mb_t *ps_cur_mb_params; /*< Parameters of current MacroBlock */
578
163k
    deblkmb_neighbour_t *ps_deblk_top_mb;
579
580
    /* Reference Index to POC mapping*/
581
163k
    void **apv_map_ref_idx_to_poc;
582
163k
    UWORD32 u4_leftmbtype;
583
163k
    UWORD16 u2_left_csbp, u2_top_csbp, u2_cur_csbp;
584
585
    /* Set of flags */
586
163k
    UWORD32 u4_cur_mb_intra, u1_top_mb_typ, u4_cur_mb_fld;
587
163k
    UWORD32 u4_cur_mb_ibl;
588
163k
    UWORD32 u1_cur_mb_type;
589
163k
    UWORD32 *pu4_bs_table;
590
591
163k
    UWORD16 *pu2_curr_res_luma_csbp;
592
163k
    UWORD16 *pu2_left_res_luma_csbp;
593
163k
    UWORD16 *pu2_top_res_luma_csbp;
594
595
    /* Neighbour availability */
596
    /* Initialization */
597
163k
    const UWORD32 u2_mbx = ps_cur_mb_info->u2_mbx;
598
163k
    const UWORD32 u2_mby = ps_cur_mb_info->u2_mby;
599
163k
    const UWORD32 u1_pingpong = u2_mbx & 0x01;
600
601
163k
    PROFILE_DISABLE_BOUNDARY_STRENGTH()
602
603
163k
    ps_deblk_top_mb = ps_dec->ps_deblk_top_mb + u2_mbx;
604
605
    /* Pointer assignment for Current DeblkMB, Current Mv Pred  */
606
163k
    ps_cur_mb_params = ps_dec->ps_deblk_mbn + u2_mbxn_mb;
607
163k
    ps_cur_mv_pred = ps_dec->ps_mv_cur + (u2_mbxn_mb << 4);
608
609
    /*Pointer assignment for Residual NNZ */
610
163k
    pu2_curr_res_luma_csbp = ps_svc_lyr_dec->pu2_frm_res_luma_csbp + ps_cur_mb_info->u2_mbx;
611
163k
    pu2_curr_res_luma_csbp += ps_cur_mb_info->u2_mby * ps_svc_lyr_dec->i4_frm_res_luma_csbp_stride;
612
613
163k
    pu2_left_res_luma_csbp = pu2_curr_res_luma_csbp - (ps_cur_mb_info->u2_mbx != 0);
614
163k
    pu2_top_res_luma_csbp = pu2_curr_res_luma_csbp - ((ps_cur_mb_info->u2_mby != 0) *
615
163k
                                                      ps_svc_lyr_dec->i4_frm_res_luma_csbp_stride);
616
617
163k
    apv_map_ref_idx_to_poc = ps_dec->ppv_map_ref_idx_to_poc + 1;
618
163k
    u1_cur_mb_type = ps_cur_mb_params->u1_mb_type;
619
163k
    u1_top_mb_typ = ps_deblk_top_mb->u1_mb_type;
620
163k
    ps_deblk_top_mb->u1_mb_type = u1_cur_mb_type;
621
622
163k
    ps_cur_mb_params->u1_topmb_qp = ps_deblk_top_mb->u1_mb_qp;
623
163k
    ps_deblk_top_mb->u1_mb_qp = ps_cur_mb_params->u1_mb_qp;
624
163k
    ps_cur_mb_params->u1_left_mb_qp = ps_dec->deblk_left_mb[1].u1_mb_qp;
625
163k
    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
163k
    if(ps_cur_mb_params->u1_deblocking_mode & MB_DISABLE_FILTERING)
630
5.89k
    {
631
5.89k
        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
5.89k
        void **ppv_top_mv_pred_addr = ps_cur_mb_info->ps_curmb->u4_pic_addrress;
635
5.89k
        WORD8 *p1_refTop0 = (ps_cur_mv_pred + 12)->i1_ref_frame;
636
5.89k
        WORD8 *p1_refTop1 = (ps_cur_mv_pred + 14)->i1_ref_frame;
637
638
        /* Store Left addresses for Next Mb   */
639
5.89k
        void **ppv_left_mv_pred_addr = ps_dec->ps_left_mvpred_addr[!u1_pingpong][1].u4_add;
640
5.89k
        WORD8 *p1_refleft0 = (ps_cur_mv_pred + 3)->i1_ref_frame;
641
642
5.89k
        ppv_top_mv_pred_addr[0] = apv_map_ref_idx_to_poc[p1_refTop0[0]];
643
5.89k
        ppv_top_mv_pred_addr[1] = pu4_map_ref_idx_to_poc_l1[p1_refTop0[1]];
644
645
5.89k
        ppv_left_mv_pred_addr[2] = apv_map_ref_idx_to_poc[p1_refTop1[0]];
646
5.89k
        ppv_top_mv_pred_addr[2] = apv_map_ref_idx_to_poc[p1_refTop1[0]];
647
5.89k
        ppv_left_mv_pred_addr[3] = pu4_map_ref_idx_to_poc_l1[p1_refTop1[1]];
648
5.89k
        ppv_top_mv_pred_addr[3] = pu4_map_ref_idx_to_poc_l1[p1_refTop1[1]];
649
650
5.89k
        ppv_left_mv_pred_addr[0] = apv_map_ref_idx_to_poc[p1_refleft0[0]];
651
5.89k
        ppv_left_mv_pred_addr[1] = pu4_map_ref_idx_to_poc_l1[p1_refleft0[1]];
652
        /* Storing the leftMbtype for next Mb */
653
5.89k
        ps_dec->deblk_left_mb[1].u1_mb_type = ps_cur_mb_params->u1_mb_type;
654
655
5.89k
        return;
656
5.89k
    }
657
658
    /* Flag for extra left Edge */
659
158k
    ps_cur_mb_params->u1_single_call = 1;
660
661
    /* Update the Left deblk_mb_t and Left MvPred Parameters           */
662
158k
    if(!u2_mbx)
663
45.2k
    {
664
45.2k
        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
45.2k
        ps_left_mv_pred = ps_dec->ps_mv_cur + 3;
670
45.2k
    }
671
112k
    else
672
112k
    {
673
112k
        u4_leftmbtype = ps_dec->deblk_left_mb[1].u1_mb_type;
674
675
        /* Come to Left Most Edge of the MB */
676
112k
        ps_left_mv_pred =
677
112k
            (u2_mbxn_mb) ? ps_dec->ps_mv_cur + ((u2_mbxn_mb - 1) << 4) + 3 : ps_dec->ps_mv_left + 3;
678
112k
    }
679
680
158k
    if(!u2_mby) u1_top_mb_typ = 0;
681
682
    /* MvPred Pointer Calculation */
683
158k
    ps_top_mv_pred = ps_cur_mv_pred - (ps_dec->u2_frm_wd_in_mbs << 4) + 12;
684
158k
    u4_cur_mb_intra = u1_cur_mb_type & D_INTRA_MB;
685
158k
    u4_cur_mb_ibl = u1_cur_mb_type & D_INTRA_IBL;
686
158k
    u4_cur_mb_fld = !!(u1_cur_mb_type & D_FLD_MB);
687
    /* Compute BS function */
688
158k
    pu4_bs_table = ps_cur_mb_params->u4_bs_table;
689
690
158k
    u2_cur_csbp = ps_cur_mb_info->ps_curmb->u2_luma_csbp;
691
158k
    u2_left_csbp = ps_cur_mb_info->ps_left_mb->u2_luma_csbp;
692
158k
    u2_top_csbp = ps_cur_mb_info->ps_top_mb->u2_luma_csbp;
693
    /* Compute BS function */
694
158k
    if((ps_dec->ps_cur_sps->u1_profile_idc == HIGH_PROFILE_IDC) ||
695
153k
       (ps_dec->ps_cur_sps->u1_profile_idc == SCALABLE_HIGH_PROFILE_IDC) ||
696
120k
       (ps_dec->ps_cur_sps->u1_profile_idc == SCALABLE_BASELINE_PROFILE_IDC))
697
67.2k
    {
698
67.2k
        if(ps_cur_mb_info->u1_tran_form8x8 == 1)
699
9.24k
        {
700
9.24k
            u2_cur_csbp = ih264d_update_csbp_8x8(ps_cur_mb_info->ps_curmb->u2_luma_csbp);
701
9.24k
            ps_cur_mb_info->ps_curmb->u2_luma_csbp = u2_cur_csbp;
702
9.24k
        }
703
67.2k
    }
704
158k
    u2_cur_csbp |= *pu2_curr_res_luma_csbp;
705
158k
    u2_left_csbp |= *pu2_left_res_luma_csbp;
706
158k
    u2_top_csbp |= *pu2_top_res_luma_csbp;
707
708
158k
    if(u4_cur_mb_intra)
709
13.8k
    {
710
13.8k
        pu4_bs_table[4] = 0x04040404;
711
13.8k
        pu4_bs_table[0] = u4_cur_mb_fld ? 0x03030303 : 0x04040404;
712
13.8k
        pu4_bs_table[1] = 0x03030303;
713
13.8k
        pu4_bs_table[2] = 0x03030303;
714
13.8k
        pu4_bs_table[3] = 0x03030303;
715
13.8k
        pu4_bs_table[5] = 0x03030303;
716
13.8k
        pu4_bs_table[6] = 0x03030303;
717
13.8k
        pu4_bs_table[7] = 0x03030303;
718
13.8k
    }
719
144k
    else
720
144k
    {
721
144k
        isvcd_fill_bs_ibl(ps_cur_mb_params, u1_top_mb_typ, u4_leftmbtype, ps_cur_mb_info,
722
144k
                          pu2_curr_res_luma_csbp, pu2_left_res_luma_csbp, pu2_top_res_luma_csbp);
723
724
144k
        if(!u4_cur_mb_ibl)
725
115k
        {
726
115k
            UWORD32 u4_is_non16x16 = !!(u1_cur_mb_type & D_PRED_NON_16x16);
727
115k
            UWORD32 u4_is_b = ps_dec->u1_B;
728
115k
            UWORD32 u4_bs_0, u4_bs_4;
729
730
115k
            u4_bs_0 = pu4_bs_table[0];
731
115k
            u4_bs_4 = pu4_bs_table[4];
732
733
115k
            ih264d_fill_bs2_horz_vert(pu4_bs_table, u2_left_csbp, u2_top_csbp, u2_cur_csbp,
734
115k
                                      (const UWORD32 *) (gau4_ih264d_packed_bs2),
735
115k
                                      (const UWORD16 *) (gau2_ih264d_4x4_v2h_reorder));
736
737
115k
            if(u4_leftmbtype & D_INTRA_MB)
738
1.89k
            {
739
1.89k
                pu4_bs_table[4] = 0x04040404;
740
1.89k
            }
741
113k
            else if(u4_leftmbtype & D_INTRA_IBL)
742
2.21k
            {
743
2.21k
                pu4_bs_table[4] = u4_bs_4;
744
2.21k
            }
745
746
115k
            if(u1_top_mb_typ & D_INTRA_MB)
747
1.50k
            {
748
1.50k
                pu4_bs_table[0] = u4_cur_mb_fld ? 0x03030303 : 0x04040404;
749
1.50k
            }
750
114k
            else if(u1_top_mb_typ & D_INTRA_IBL)
751
3.22k
            {
752
3.22k
                pu4_bs_table[0] = u4_bs_0;
753
3.22k
            }
754
755
115k
            ps_dec->pf_fill_bs1[u4_is_b][u4_is_non16x16](
756
115k
                ps_cur_mv_pred, ps_top_mv_pred, apv_map_ref_idx_to_poc, pu4_bs_table,
757
115k
                ps_left_mv_pred, &(ps_dec->ps_left_mvpred_addr[u1_pingpong][1]),
758
115k
                ps_cur_mb_info->ps_top_mb->u4_pic_addrress, (4 >> u4_cur_mb_fld));
759
115k
        }
760
144k
    }
761
762
158k
    {
763
158k
        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
158k
        void **ppv_top_mv_pred_addr = ps_cur_mb_info->ps_curmb->u4_pic_addrress;
766
158k
        WORD8 *p1_refTop0 = (ps_cur_mv_pred + 12)->i1_ref_frame;
767
158k
        WORD8 *p1_refTop1 = (ps_cur_mv_pred + 14)->i1_ref_frame;
768
769
        /* Store Left addresses for Next Mb   */
770
158k
        void **ppv_left_mv_pred_addr = ps_dec->ps_left_mvpred_addr[!u1_pingpong][1].u4_add;
771
158k
        WORD8 *p1_refleft0 = (ps_cur_mv_pred + 3)->i1_ref_frame;
772
773
158k
        ppv_top_mv_pred_addr[0] = apv_map_ref_idx_to_poc[p1_refTop0[0]];
774
158k
        ppv_top_mv_pred_addr[1] = pu4_map_ref_idx_to_poc_l1[p1_refTop0[1]];
775
776
158k
        ppv_left_mv_pred_addr[2] = apv_map_ref_idx_to_poc[p1_refTop1[0]];
777
158k
        ppv_top_mv_pred_addr[2] = apv_map_ref_idx_to_poc[p1_refTop1[0]];
778
158k
        ppv_left_mv_pred_addr[3] = pu4_map_ref_idx_to_poc_l1[p1_refTop1[1]];
779
158k
        ppv_top_mv_pred_addr[3] = pu4_map_ref_idx_to_poc_l1[p1_refTop1[1]];
780
781
158k
        ppv_left_mv_pred_addr[0] = apv_map_ref_idx_to_poc[p1_refleft0[0]];
782
158k
        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
158k
        ps_dec->deblk_left_mb[1].u1_mb_type = ps_cur_mb_params->u1_mb_type;
786
158k
    }
787
788
    /* For transform 8x8 disable deblocking of the intrernal edges of a 8x8 block */
789
158k
    if(ps_cur_mb_info->u1_tran_form8x8)
790
20.4k
    {
791
20.4k
        pu4_bs_table[1] = 0;
792
20.4k
        pu4_bs_table[3] = 0;
793
20.4k
        pu4_bs_table[5] = 0;
794
20.4k
        pu4_bs_table[7] = 0;
795
20.4k
    }
796
158k
}
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
}