xref: /aosp_15_r20/external/libavc/decoder/svc/isvcd_compute_bs.c (revision 495ae853bb871d1e5a258cb02c2cc13cde8ddb9a)
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  */
isvcd_deblk_extract_bit_flags(UWORD16 u2_bit_field,WORD32 i4_initial_bit_mask)64 UWORD16 isvcd_deblk_extract_bit_flags(UWORD16 u2_bit_field, WORD32 i4_initial_bit_mask)
65 {
66     WORD32 i4_i;
67     WORD32 i4_bit_mask;
68     UWORD16 u2_result = 0;
69 
70     i4_bit_mask = i4_initial_bit_mask;
71 
72     for(i4_i = 0; i4_i < NUM_SUB_MB_PARTS; i4_i++)
73     {
74         WORD32 i4_bit;
75         /* extract the bits of the last column 4x4 blocks */
76         if(0 == (i4_bit_mask & u2_bit_field))
77         {
78             i4_bit = 0;
79         }
80         else
81         {
82             i4_bit = 1;
83         }
84         /* store the result */
85         u2_result |= i4_bit << i4_i;
86         i4_bit_mask <<= 4;
87 
88     } /* end of loop over num sub Mb parts */
89     return (u2_result);
90 }
91 
92 /** \brief Fills the BS for edges falling on a IBL boundary  */
isvcd_fill_bs_ibl(deblk_mb_t * ps_deblk_mb,UWORD8 u1_top_mb_type,UWORD8 u1_left_mb_type,dec_mb_info_t * ps_cur_mb_info,UWORD16 * pu2_curr_res_luma_csbp,UWORD16 * pu2_left_res_luma_csbp,UWORD16 * pu2_top_res_luma_csbp)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 {
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     UWORD16 u2_top_horz_nnz;
107     UWORD8 u1_top_mb_ibl, u1_left_mb_ibl;
108     UWORD32 i4_i, i4_edge;
109     UWORD8 u1_bs;
110     UWORD8 u1_cnd;
111     UWORD8 u1_top_intra;
112     UWORD8 u1_left_intra;
113     UWORD8 u1_p_nnz, u1_q_nnz;
114     UWORD8 u1_curr_mb_ibl;
115     UWORD32 *pu4_bs_table;
116     UWORD16 u2_curr_nnz;
117     UWORD8 u1_left_mb_nnz = 0, u1_left_nnz;
118     WORD32 i4_horz_start = 0;
119     WORD32 i4_vertical_start = 0;
120 
121     pu4_bs_table = &(ps_deblk_mb->u4_bs_table[0]);
122 
123     u1_top_mb_ibl = u1_top_mb_type & D_INTRA_IBL;
124     u1_left_mb_ibl = u1_left_mb_type & D_INTRA_IBL;
125 
126     u1_curr_mb_ibl = ps_deblk_mb->u1_mb_type & D_INTRA_IBL;
127 
128     u1_top_intra = u1_top_mb_type & D_INTRA_MB;
129     u1_left_intra = u1_left_mb_type & D_INTRA_MB;
130 
131     /* return if none of the current top and left is IBL */
132     if((0 == u1_curr_mb_ibl) && (0 == u1_top_mb_ibl) && (0 == u1_left_mb_ibl))
133     {
134         return;
135     }
136 
137     /* set up the vertical and horz MB edge skip flags */
138     if(0 != u1_curr_mb_ibl)
139     {
140         /* if top is not IBL */
141         if(0 == u1_top_mb_ibl)
142         {
143             i4_horz_start = 1;
144         }
145 
146         /* if left in not IBL */
147         if(0 == u1_left_mb_ibl)
148         {
149             i4_vertical_start = 1;
150         }
151     }
152 
153     /*******************************************************/
154     /* Fill BS for mb egdex assuming non IBL case          */
155     /*******************************************************/
156 
157     /* only the  MB edges fall across IBL boundary */
158     if((0 != u1_curr_mb_ibl) || (0 != u1_top_mb_ibl) || (0 != u1_left_mb_ibl))
159     {
160         UWORD16 u2_temp, u2_i;
161         u2_temp = *pu2_left_res_luma_csbp;
162         for(u2_i = 0; u2_i < 4; u2_i++)
163         {
164             u1_left_mb_nnz |= ((u2_temp & 0x08) >> (3 - u2_i));
165             u2_temp >>= 4;
166         }
167         u2_curr_nnz = *pu2_curr_res_luma_csbp;
168         u2_top_horz_nnz = *pu2_top_res_luma_csbp >> 12;
169 
170         /* top is intra and not ibl */
171         if(0 != u1_top_intra)
172         {
173             pu4_bs_table[0] = 0x04040404;
174         }
175         /* left is intra and not ibl */
176         if(0 != u1_left_intra)
177         {
178             pu4_bs_table[4] = 0x04040404;
179         }
180 
181         /* assume neighbours are inter and update bs */
182 
183         /* Edge = 0 means Vert Edges and Edge = 1 means Horz edges */
184         for(i4_edge = 0; i4_edge < 2; i4_edge++)
185         {
186             UWORD8 u1_p_nnz, u1_q_nnz;
187             UWORD32 u4_bs_edge = 0;
188             WORD32 i4_bit_mask;
189             WORD32 i4_curr_intra_flag;
190             WORD32 i4_neibor_intra_flag;
191 
192             i4_curr_intra_flag = (0 != u1_curr_mb_ibl);
193 
194             if(0 != i4_edge)
195             {
196                 /* Initialize for the TOP edge */
197                 u1_p_nnz = (UWORD8) u2_top_horz_nnz;
198                 u1_q_nnz = (UWORD8) (u2_curr_nnz & g_au4_extract_set[0]);
199                 i4_neibor_intra_flag = (u1_top_mb_ibl || u1_top_intra);
200             }
201             else
202             {
203                 u1_p_nnz = u1_left_mb_nnz;
204                 u1_q_nnz = (UWORD8) isvcd_deblk_extract_bit_flags(u2_curr_nnz, 0x01);
205                 i4_neibor_intra_flag = (u1_left_mb_ibl || u1_left_intra);
206             }
207 
208             i4_bit_mask = 1;
209             /* find bs of 4 edges */
210             for(i4_i = 0; i4_i < 4; i4_i++)
211             {
212                 UWORD8 u1_p_nnz_temp, u1_q_nnz_temp;
213 
214                 u1_p_nnz_temp = (u1_p_nnz & i4_bit_mask);
215                 u1_q_nnz_temp = (u1_q_nnz & i4_bit_mask);
216 
217                 u1_cnd = ((u1_p_nnz_temp && (!i4_neibor_intra_flag)) ||
218                           (u1_q_nnz_temp && (!i4_curr_intra_flag)));
219 
220                 u1_bs = u1_cnd ? 2 : 1;
221 
222                 /* update the bs of the edge */
223                 u4_bs_edge = (u4_bs_edge << 8) + u1_bs;
224                 i4_bit_mask <<= 1;
225 
226             } /* end of loop over blk edges */
227 
228             /* update the bs of edges */
229             if(i4_edge && !u1_top_intra)
230             {
231                 pu4_bs_table[0] = u4_bs_edge;
232             }
233             else if(!i4_edge && !u1_left_intra)
234             {
235                 pu4_bs_table[4] = u4_bs_edge;
236             }
237         } /* end of loop over v1 vetical and horizontal edge */
238     }
239     /* current MB is IBL */
240     if(0 != u1_curr_mb_ibl)
241     {
242         UWORD16 u2_temp, u2_i;
243         WORD32 i4_bit_mask_edge = 1;
244 
245         u1_left_mb_nnz = 0;
246         u2_temp = ps_cur_mb_info->ps_left_mb->u2_luma_csbp;
247         for(u2_i = 0; u2_i < 4; u2_i++)
248         {
249             u1_left_mb_nnz |= ((u2_temp & 0x08) >> (3 - u2_i));
250             u2_temp >>= 4;
251         }
252         u2_curr_nnz = ps_cur_mb_info->ps_curmb->u2_luma_csbp;
253         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         for(i4_edge = 0; i4_edge < 4; i4_edge++)
257         {
258             UWORD16 u2_curr_horz_nnz = 0;
259             WORD32 i4_bit_mask = 1;
260 
261             u2_curr_horz_nnz = u2_curr_nnz & g_au4_extract_set[i4_edge];
262 
263             u2_curr_horz_nnz = (u2_curr_horz_nnz >> (i4_edge * 4));
264 
265             u1_left_nnz = (u1_left_mb_nnz & i4_bit_mask_edge);
266 
267             for(i4_i = 0; i4_i < 4; i4_i++)
268             {
269                 UWORD8 u1_curr_nnz, u1_top_nnz;
270 
271                 u1_curr_nnz = (u2_curr_horz_nnz & i4_bit_mask);
272                 u1_top_nnz = (u2_top_horz_nnz & i4_bit_mask);
273                 /* update bs horizontal */
274 
275                 if(!((1 == i4_horz_start) && (0 == i4_edge)))
276                 {
277                     u1_p_nnz = u1_top_nnz;
278                     u1_q_nnz = u1_curr_nnz;
279                     u1_cnd = !(u1_p_nnz || u1_q_nnz);
280                     u1_bs = u1_cnd ? 0 : 1;
281                     pu4_bs_table[i4_edge] = (pu4_bs_table[i4_edge] << 8) + u1_bs;
282                 }
283 
284                 /* update bs vertical */
285                 if(!((1 == i4_vertical_start) && (0 == i4_i)))
286                 {
287                     u1_p_nnz = u1_left_nnz;
288                     u1_q_nnz = u1_curr_nnz;
289                     u1_cnd = !(u1_p_nnz || u1_q_nnz);
290                     u1_bs = u1_cnd ? 0 : 1;
291                     pu4_bs_table[i4_i + 4] = (pu4_bs_table[i4_i + 4] << 8) + u1_bs;
292                 }
293                 /* store the current nnz to left nnz */
294                 u1_left_nnz = u1_curr_nnz;
295                 i4_bit_mask <<= 1;
296             }
297             /* store the current row nnz to top row nnz */
298             u2_top_horz_nnz = u2_curr_horz_nnz;
299             i4_bit_mask_edge <<= 1;
300         }
301     }
302     return;
303 }
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 
isvcd_compute_bs_non_mbaff_target_lyr_no_inter_layer(svc_dec_lyr_struct_t * ps_svc_lyr_dec,dec_mb_info_t * ps_cur_mb_info,const UWORD16 u2_mbxn_mb)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 {
328     dec_struct_t *ps_dec = &ps_svc_lyr_dec->s_dec;
329     /* Mvpred and Nnz for top and Courrent */
330     mv_pred_t *ps_cur_mv_pred, *ps_top_mv_pred = NULL, *ps_left_mv_pred;
331     /* deblk_mb_t Params */
332     deblk_mb_t *ps_cur_mb_params; /*< Parameters of current MacroBlock */
333     deblkmb_neighbour_t *ps_deblk_top_mb;
334 
335     /* Reference Index to POC mapping*/
336     void **apv_map_ref_idx_to_poc;
337     UWORD32 u4_leftmbtype;
338 
339     UWORD16 u2_left_csbp, u2_top_csbp, u2_cur_csbp;
340 
341     /* Set of flags */
342     UWORD32 u4_cur_mb_intra, u1_top_mb_typ, u4_cur_mb_fld;
343     UWORD32 u1_cur_mb_type;
344     UWORD32 *pu4_bs_table;
345 
346     /* Neighbour availability */
347     /* Initialization */
348     const UWORD32 u2_mbx = ps_cur_mb_info->u2_mbx;
349     const UWORD32 u2_mby = ps_cur_mb_info->u2_mby;
350     const UWORD32 u1_pingpong = u2_mbx & 0x01;
351 
352     PROFILE_DISABLE_BOUNDARY_STRENGTH()
353 
354     ps_deblk_top_mb = ps_dec->ps_deblk_top_mb + u2_mbx;
355 
356     /* Pointer assignment for Current DeblkMB, Current Mv Pred  */
357     ps_cur_mb_params = ps_dec->ps_deblk_mbn + u2_mbxn_mb;
358     ps_cur_mv_pred = ps_dec->ps_mv_cur + (u2_mbxn_mb << 4);
359 
360     apv_map_ref_idx_to_poc = ps_dec->ppv_map_ref_idx_to_poc + 1;
361     u1_cur_mb_type = ps_cur_mb_params->u1_mb_type;
362     u1_top_mb_typ = ps_deblk_top_mb->u1_mb_type;
363     ps_deblk_top_mb->u1_mb_type = u1_cur_mb_type;
364 
365     ps_cur_mb_params->u1_topmb_qp = ps_deblk_top_mb->u1_mb_qp;
366     ps_deblk_top_mb->u1_mb_qp = ps_cur_mb_params->u1_mb_qp;
367     ps_cur_mb_params->u1_left_mb_qp = ps_dec->deblk_left_mb[1].u1_mb_qp;
368     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     if(ps_cur_mb_params->u1_deblocking_mode & MB_DISABLE_FILTERING)
373     {
374         void **pu4_map_ref_idx_to_poc_l1 = apv_map_ref_idx_to_poc + POC_LIST_L0_TO_L1_DIFF;
375         {
376             /* Store Parameter for Top MvPred refernce frame Address */
377 
378             void **ppv_top_mv_pred_addr = ps_cur_mb_info->ps_curmb->u4_pic_addrress;
379             WORD8 *p1_refTop0 = (ps_cur_mv_pred + 12)->i1_ref_frame;
380             WORD8 *p1_refTop1 = (ps_cur_mv_pred + 14)->i1_ref_frame;
381 
382             /* Store Left addresses for Next Mb   */
383             void **ppv_left_mv_pred_addr = ps_dec->ps_left_mvpred_addr[!u1_pingpong][1].u4_add;
384             WORD8 *p1_refleft0 = (ps_cur_mv_pred + 3)->i1_ref_frame;
385 
386             ppv_top_mv_pred_addr[0] = apv_map_ref_idx_to_poc[p1_refTop0[0]];
387             ppv_top_mv_pred_addr[1] = pu4_map_ref_idx_to_poc_l1[p1_refTop0[1]];
388 
389             ppv_left_mv_pred_addr[2] = apv_map_ref_idx_to_poc[p1_refTop1[0]];
390             ppv_top_mv_pred_addr[2] = apv_map_ref_idx_to_poc[p1_refTop1[0]];
391             ppv_left_mv_pred_addr[3] = pu4_map_ref_idx_to_poc_l1[p1_refTop1[1]];
392             ppv_top_mv_pred_addr[3] = pu4_map_ref_idx_to_poc_l1[p1_refTop1[1]];
393 
394             ppv_left_mv_pred_addr[0] = apv_map_ref_idx_to_poc[p1_refleft0[0]];
395             ppv_left_mv_pred_addr[1] = pu4_map_ref_idx_to_poc_l1[p1_refleft0[1]];
396             /* Storing the leftMbtype for next Mb */
397             ps_dec->deblk_left_mb[1].u1_mb_type = ps_cur_mb_params->u1_mb_type;
398         }
399 
400         return;
401     }
402 
403     /* Flag for extra left Edge */
404     ps_cur_mb_params->u1_single_call = 1;
405 
406     /* Update the Left deblk_mb_t and Left MvPred Parameters           */
407     if(!u2_mbx)
408     {
409         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         ps_left_mv_pred = ps_dec->ps_mv_cur + 3;
415     }
416     else
417     {
418         u4_leftmbtype = ps_dec->deblk_left_mb[1].u1_mb_type;
419 
420         /* Come to Left Most Edge of the MB */
421         ps_left_mv_pred =
422             (u2_mbxn_mb) ? ps_dec->ps_mv_cur + ((u2_mbxn_mb - 1) << 4) + 3 : ps_dec->ps_mv_left + 3;
423     }
424 
425     if(!u2_mby) u1_top_mb_typ = 0;
426 
427     /* MvPred Pointer Calculation */
428     ps_top_mv_pred = ps_cur_mv_pred - (ps_dec->u2_frm_wd_in_mbs << 4) + 12;
429 
430     u4_cur_mb_intra = u1_cur_mb_type & D_INTRA_MB;
431     u4_cur_mb_fld = !!(u1_cur_mb_type & D_FLD_MB);
432     /* Compute BS function */
433     pu4_bs_table = ps_cur_mb_params->u4_bs_table;
434 
435     u2_cur_csbp = ps_cur_mb_info->ps_curmb->u2_luma_csbp;
436     u2_left_csbp = ps_cur_mb_info->ps_left_mb->u2_luma_csbp;
437     u2_top_csbp = ps_cur_mb_info->ps_top_mb->u2_luma_csbp;
438     /* Compute BS function */
439     if((ps_dec->ps_cur_sps->u1_profile_idc == HIGH_PROFILE_IDC) ||
440        (ps_dec->ps_cur_sps->u1_profile_idc == SCALABLE_HIGH_PROFILE_IDC) ||
441        (ps_dec->ps_cur_sps->u1_profile_idc == SCALABLE_BASELINE_PROFILE_IDC))
442     {
443         if(ps_cur_mb_info->u1_tran_form8x8 == 1)
444         {
445             u2_cur_csbp = ih264d_update_csbp_8x8(ps_cur_mb_info->ps_curmb->u2_luma_csbp);
446         }
447 
448         if(ps_cur_mb_info->ps_left_mb->u1_tran_form8x8 == 1)
449         {
450             u2_left_csbp = ih264d_update_csbp_8x8(ps_cur_mb_info->ps_left_mb->u2_luma_csbp);
451         }
452 
453         if(ps_cur_mb_info->ps_top_mb->u1_tran_form8x8 == 1)
454         {
455             u2_top_csbp = ih264d_update_csbp_8x8(ps_cur_mb_info->ps_top_mb->u2_luma_csbp);
456         }
457     }
458     if(u4_cur_mb_intra)
459     {
460         pu4_bs_table[4] = 0x04040404;
461         pu4_bs_table[0] = u4_cur_mb_fld ? 0x03030303 : 0x04040404;
462         pu4_bs_table[1] = 0x03030303;
463         pu4_bs_table[2] = 0x03030303;
464         pu4_bs_table[3] = 0x03030303;
465         pu4_bs_table[5] = 0x03030303;
466         pu4_bs_table[6] = 0x03030303;
467         pu4_bs_table[7] = 0x03030303;
468     }
469     else
470     {
471         UWORD32 u4_is_non16x16 = !!(u1_cur_mb_type & D_PRED_NON_16x16);
472         UWORD32 u4_is_b = ps_dec->u1_B;
473 
474         ih264d_fill_bs2_horz_vert(pu4_bs_table, u2_left_csbp, u2_top_csbp, u2_cur_csbp,
475                                   (const UWORD32 *) (gau4_ih264d_packed_bs2),
476                                   (const UWORD16 *) (gau2_ih264d_4x4_v2h_reorder));
477 
478         if(u4_leftmbtype & D_INTRA_MB) pu4_bs_table[4] = 0x04040404;
479 
480         if(u1_top_mb_typ & D_INTRA_MB) pu4_bs_table[0] = u4_cur_mb_fld ? 0x03030303 : 0x04040404;
481 
482         ps_dec->pf_fill_bs1[u4_is_b][u4_is_non16x16](
483             ps_cur_mv_pred, ps_top_mv_pred, apv_map_ref_idx_to_poc, pu4_bs_table, ps_left_mv_pred,
484             &(ps_dec->ps_left_mvpred_addr[u1_pingpong][1]),
485             ps_cur_mb_info->ps_top_mb->u4_pic_addrress, (4 >> u4_cur_mb_fld));
486     }
487 
488     {
489         void **pu4_map_ref_idx_to_poc_l1 = apv_map_ref_idx_to_poc + POC_LIST_L0_TO_L1_DIFF;
490         {
491             /* Store Parameter for Top MvPred refernce frame Address */
492 
493             void **ppv_top_mv_pred_addr = ps_cur_mb_info->ps_curmb->u4_pic_addrress;
494             WORD8 *p1_refTop0 = (ps_cur_mv_pred + 12)->i1_ref_frame;
495             WORD8 *p1_refTop1 = (ps_cur_mv_pred + 14)->i1_ref_frame;
496 
497             /* Store Left addresses for Next Mb   */
498             void **ppv_left_mv_pred_addr = ps_dec->ps_left_mvpred_addr[!u1_pingpong][1].u4_add;
499             WORD8 *p1_refleft0 = (ps_cur_mv_pred + 3)->i1_ref_frame;
500 
501             ppv_top_mv_pred_addr[0] = apv_map_ref_idx_to_poc[p1_refTop0[0]];
502             ppv_top_mv_pred_addr[1] = pu4_map_ref_idx_to_poc_l1[p1_refTop0[1]];
503 
504             ppv_left_mv_pred_addr[2] = apv_map_ref_idx_to_poc[p1_refTop1[0]];
505             ppv_top_mv_pred_addr[2] = apv_map_ref_idx_to_poc[p1_refTop1[0]];
506             ppv_left_mv_pred_addr[3] = pu4_map_ref_idx_to_poc_l1[p1_refTop1[1]];
507             ppv_top_mv_pred_addr[3] = pu4_map_ref_idx_to_poc_l1[p1_refTop1[1]];
508 
509             ppv_left_mv_pred_addr[0] = apv_map_ref_idx_to_poc[p1_refleft0[0]];
510             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             ps_dec->deblk_left_mb[1].u1_mb_type = ps_cur_mb_params->u1_mb_type;
514         }
515     }
516 
517     /* For transform 8x8 disable deblocking of the intrernal edges of a 8x8 block */
518     if(ps_cur_mb_info->u1_tran_form8x8)
519     {
520         pu4_bs_table[1] = 0;
521         pu4_bs_table[3] = 0;
522         pu4_bs_table[5] = 0;
523         pu4_bs_table[7] = 0;
524     }
525 }
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 
isvcd_compute_bs_non_mbaff(svc_dec_lyr_struct_t * ps_svc_lyr_dec,dec_mb_info_t * ps_cur_mb_info,const UWORD16 u2_mbxn_mb)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 {
548     dec_struct_t *ps_dec = &ps_svc_lyr_dec->s_dec;
549     ps_dec->pf_compute_bs(ps_dec, ps_cur_mb_info, u2_mbxn_mb);
550 }
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 
isvcd_compute_bs_non_mbaff_target_lyr(svc_dec_lyr_struct_t * ps_svc_lyr_dec,dec_mb_info_t * ps_cur_mb_info,const UWORD16 u2_mbxn_mb)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 {
573     dec_struct_t *ps_dec = &ps_svc_lyr_dec->s_dec;
574     /* Mvpred and Nnz for top and Courrent */
575     mv_pred_t *ps_cur_mv_pred, *ps_top_mv_pred = NULL, *ps_left_mv_pred;
576     /* deblk_mb_t Params */
577     deblk_mb_t *ps_cur_mb_params; /*< Parameters of current MacroBlock */
578     deblkmb_neighbour_t *ps_deblk_top_mb;
579 
580     /* Reference Index to POC mapping*/
581     void **apv_map_ref_idx_to_poc;
582     UWORD32 u4_leftmbtype;
583     UWORD16 u2_left_csbp, u2_top_csbp, u2_cur_csbp;
584 
585     /* Set of flags */
586     UWORD32 u4_cur_mb_intra, u1_top_mb_typ, u4_cur_mb_fld;
587     UWORD32 u4_cur_mb_ibl;
588     UWORD32 u1_cur_mb_type;
589     UWORD32 *pu4_bs_table;
590 
591     UWORD16 *pu2_curr_res_luma_csbp;
592     UWORD16 *pu2_left_res_luma_csbp;
593     UWORD16 *pu2_top_res_luma_csbp;
594 
595     /* Neighbour availability */
596     /* Initialization */
597     const UWORD32 u2_mbx = ps_cur_mb_info->u2_mbx;
598     const UWORD32 u2_mby = ps_cur_mb_info->u2_mby;
599     const UWORD32 u1_pingpong = u2_mbx & 0x01;
600 
601     PROFILE_DISABLE_BOUNDARY_STRENGTH()
602 
603     ps_deblk_top_mb = ps_dec->ps_deblk_top_mb + u2_mbx;
604 
605     /* Pointer assignment for Current DeblkMB, Current Mv Pred  */
606     ps_cur_mb_params = ps_dec->ps_deblk_mbn + u2_mbxn_mb;
607     ps_cur_mv_pred = ps_dec->ps_mv_cur + (u2_mbxn_mb << 4);
608 
609     /*Pointer assignment for Residual NNZ */
610     pu2_curr_res_luma_csbp = ps_svc_lyr_dec->pu2_frm_res_luma_csbp + ps_cur_mb_info->u2_mbx;
611     pu2_curr_res_luma_csbp += ps_cur_mb_info->u2_mby * ps_svc_lyr_dec->i4_frm_res_luma_csbp_stride;
612 
613     pu2_left_res_luma_csbp = pu2_curr_res_luma_csbp - (ps_cur_mb_info->u2_mbx != 0);
614     pu2_top_res_luma_csbp = pu2_curr_res_luma_csbp - ((ps_cur_mb_info->u2_mby != 0) *
615                                                       ps_svc_lyr_dec->i4_frm_res_luma_csbp_stride);
616 
617     apv_map_ref_idx_to_poc = ps_dec->ppv_map_ref_idx_to_poc + 1;
618     u1_cur_mb_type = ps_cur_mb_params->u1_mb_type;
619     u1_top_mb_typ = ps_deblk_top_mb->u1_mb_type;
620     ps_deblk_top_mb->u1_mb_type = u1_cur_mb_type;
621 
622     ps_cur_mb_params->u1_topmb_qp = ps_deblk_top_mb->u1_mb_qp;
623     ps_deblk_top_mb->u1_mb_qp = ps_cur_mb_params->u1_mb_qp;
624     ps_cur_mb_params->u1_left_mb_qp = ps_dec->deblk_left_mb[1].u1_mb_qp;
625     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     if(ps_cur_mb_params->u1_deblocking_mode & MB_DISABLE_FILTERING)
630     {
631         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         void **ppv_top_mv_pred_addr = ps_cur_mb_info->ps_curmb->u4_pic_addrress;
635         WORD8 *p1_refTop0 = (ps_cur_mv_pred + 12)->i1_ref_frame;
636         WORD8 *p1_refTop1 = (ps_cur_mv_pred + 14)->i1_ref_frame;
637 
638         /* Store Left addresses for Next Mb   */
639         void **ppv_left_mv_pred_addr = ps_dec->ps_left_mvpred_addr[!u1_pingpong][1].u4_add;
640         WORD8 *p1_refleft0 = (ps_cur_mv_pred + 3)->i1_ref_frame;
641 
642         ppv_top_mv_pred_addr[0] = apv_map_ref_idx_to_poc[p1_refTop0[0]];
643         ppv_top_mv_pred_addr[1] = pu4_map_ref_idx_to_poc_l1[p1_refTop0[1]];
644 
645         ppv_left_mv_pred_addr[2] = apv_map_ref_idx_to_poc[p1_refTop1[0]];
646         ppv_top_mv_pred_addr[2] = apv_map_ref_idx_to_poc[p1_refTop1[0]];
647         ppv_left_mv_pred_addr[3] = pu4_map_ref_idx_to_poc_l1[p1_refTop1[1]];
648         ppv_top_mv_pred_addr[3] = pu4_map_ref_idx_to_poc_l1[p1_refTop1[1]];
649 
650         ppv_left_mv_pred_addr[0] = apv_map_ref_idx_to_poc[p1_refleft0[0]];
651         ppv_left_mv_pred_addr[1] = pu4_map_ref_idx_to_poc_l1[p1_refleft0[1]];
652         /* Storing the leftMbtype for next Mb */
653         ps_dec->deblk_left_mb[1].u1_mb_type = ps_cur_mb_params->u1_mb_type;
654 
655         return;
656     }
657 
658     /* Flag for extra left Edge */
659     ps_cur_mb_params->u1_single_call = 1;
660 
661     /* Update the Left deblk_mb_t and Left MvPred Parameters           */
662     if(!u2_mbx)
663     {
664         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         ps_left_mv_pred = ps_dec->ps_mv_cur + 3;
670     }
671     else
672     {
673         u4_leftmbtype = ps_dec->deblk_left_mb[1].u1_mb_type;
674 
675         /* Come to Left Most Edge of the MB */
676         ps_left_mv_pred =
677             (u2_mbxn_mb) ? ps_dec->ps_mv_cur + ((u2_mbxn_mb - 1) << 4) + 3 : ps_dec->ps_mv_left + 3;
678     }
679 
680     if(!u2_mby) u1_top_mb_typ = 0;
681 
682     /* MvPred Pointer Calculation */
683     ps_top_mv_pred = ps_cur_mv_pred - (ps_dec->u2_frm_wd_in_mbs << 4) + 12;
684     u4_cur_mb_intra = u1_cur_mb_type & D_INTRA_MB;
685     u4_cur_mb_ibl = u1_cur_mb_type & D_INTRA_IBL;
686     u4_cur_mb_fld = !!(u1_cur_mb_type & D_FLD_MB);
687     /* Compute BS function */
688     pu4_bs_table = ps_cur_mb_params->u4_bs_table;
689 
690     u2_cur_csbp = ps_cur_mb_info->ps_curmb->u2_luma_csbp;
691     u2_left_csbp = ps_cur_mb_info->ps_left_mb->u2_luma_csbp;
692     u2_top_csbp = ps_cur_mb_info->ps_top_mb->u2_luma_csbp;
693     /* Compute BS function */
694     if((ps_dec->ps_cur_sps->u1_profile_idc == HIGH_PROFILE_IDC) ||
695        (ps_dec->ps_cur_sps->u1_profile_idc == SCALABLE_HIGH_PROFILE_IDC) ||
696        (ps_dec->ps_cur_sps->u1_profile_idc == SCALABLE_BASELINE_PROFILE_IDC))
697     {
698         if(ps_cur_mb_info->u1_tran_form8x8 == 1)
699         {
700             u2_cur_csbp = ih264d_update_csbp_8x8(ps_cur_mb_info->ps_curmb->u2_luma_csbp);
701             ps_cur_mb_info->ps_curmb->u2_luma_csbp = u2_cur_csbp;
702         }
703     }
704     u2_cur_csbp |= *pu2_curr_res_luma_csbp;
705     u2_left_csbp |= *pu2_left_res_luma_csbp;
706     u2_top_csbp |= *pu2_top_res_luma_csbp;
707 
708     if(u4_cur_mb_intra)
709     {
710         pu4_bs_table[4] = 0x04040404;
711         pu4_bs_table[0] = u4_cur_mb_fld ? 0x03030303 : 0x04040404;
712         pu4_bs_table[1] = 0x03030303;
713         pu4_bs_table[2] = 0x03030303;
714         pu4_bs_table[3] = 0x03030303;
715         pu4_bs_table[5] = 0x03030303;
716         pu4_bs_table[6] = 0x03030303;
717         pu4_bs_table[7] = 0x03030303;
718     }
719     else
720     {
721         isvcd_fill_bs_ibl(ps_cur_mb_params, u1_top_mb_typ, u4_leftmbtype, ps_cur_mb_info,
722                           pu2_curr_res_luma_csbp, pu2_left_res_luma_csbp, pu2_top_res_luma_csbp);
723 
724         if(!u4_cur_mb_ibl)
725         {
726             UWORD32 u4_is_non16x16 = !!(u1_cur_mb_type & D_PRED_NON_16x16);
727             UWORD32 u4_is_b = ps_dec->u1_B;
728             UWORD32 u4_bs_0, u4_bs_4;
729 
730             u4_bs_0 = pu4_bs_table[0];
731             u4_bs_4 = pu4_bs_table[4];
732 
733             ih264d_fill_bs2_horz_vert(pu4_bs_table, u2_left_csbp, u2_top_csbp, u2_cur_csbp,
734                                       (const UWORD32 *) (gau4_ih264d_packed_bs2),
735                                       (const UWORD16 *) (gau2_ih264d_4x4_v2h_reorder));
736 
737             if(u4_leftmbtype & D_INTRA_MB)
738             {
739                 pu4_bs_table[4] = 0x04040404;
740             }
741             else if(u4_leftmbtype & D_INTRA_IBL)
742             {
743                 pu4_bs_table[4] = u4_bs_4;
744             }
745 
746             if(u1_top_mb_typ & D_INTRA_MB)
747             {
748                 pu4_bs_table[0] = u4_cur_mb_fld ? 0x03030303 : 0x04040404;
749             }
750             else if(u1_top_mb_typ & D_INTRA_IBL)
751             {
752                 pu4_bs_table[0] = u4_bs_0;
753             }
754 
755             ps_dec->pf_fill_bs1[u4_is_b][u4_is_non16x16](
756                 ps_cur_mv_pred, ps_top_mv_pred, apv_map_ref_idx_to_poc, pu4_bs_table,
757                 ps_left_mv_pred, &(ps_dec->ps_left_mvpred_addr[u1_pingpong][1]),
758                 ps_cur_mb_info->ps_top_mb->u4_pic_addrress, (4 >> u4_cur_mb_fld));
759         }
760     }
761 
762     {
763         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         void **ppv_top_mv_pred_addr = ps_cur_mb_info->ps_curmb->u4_pic_addrress;
766         WORD8 *p1_refTop0 = (ps_cur_mv_pred + 12)->i1_ref_frame;
767         WORD8 *p1_refTop1 = (ps_cur_mv_pred + 14)->i1_ref_frame;
768 
769         /* Store Left addresses for Next Mb   */
770         void **ppv_left_mv_pred_addr = ps_dec->ps_left_mvpred_addr[!u1_pingpong][1].u4_add;
771         WORD8 *p1_refleft0 = (ps_cur_mv_pred + 3)->i1_ref_frame;
772 
773         ppv_top_mv_pred_addr[0] = apv_map_ref_idx_to_poc[p1_refTop0[0]];
774         ppv_top_mv_pred_addr[1] = pu4_map_ref_idx_to_poc_l1[p1_refTop0[1]];
775 
776         ppv_left_mv_pred_addr[2] = apv_map_ref_idx_to_poc[p1_refTop1[0]];
777         ppv_top_mv_pred_addr[2] = apv_map_ref_idx_to_poc[p1_refTop1[0]];
778         ppv_left_mv_pred_addr[3] = pu4_map_ref_idx_to_poc_l1[p1_refTop1[1]];
779         ppv_top_mv_pred_addr[3] = pu4_map_ref_idx_to_poc_l1[p1_refTop1[1]];
780 
781         ppv_left_mv_pred_addr[0] = apv_map_ref_idx_to_poc[p1_refleft0[0]];
782         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         ps_dec->deblk_left_mb[1].u1_mb_type = ps_cur_mb_params->u1_mb_type;
786     }
787 
788     /* For transform 8x8 disable deblocking of the intrernal edges of a 8x8 block */
789     if(ps_cur_mb_info->u1_tran_form8x8)
790     {
791         pu4_bs_table[1] = 0;
792         pu4_bs_table[3] = 0;
793         pu4_bs_table[5] = 0;
794         pu4_bs_table[7] = 0;
795     }
796 }
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 
isvcd_compute_bs_non_mbaff_medial_lyr(svc_dec_lyr_struct_t * ps_svc_lyr_dec,dec_mb_info_t * ps_cur_mb_info,const UWORD16 u2_mbxn_mb)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 {
820     dec_struct_t *ps_dec = &ps_svc_lyr_dec->s_dec;
821     /* deblk_mb_t Params */
822     deblk_mb_t *ps_cur_mb_params; /*< Parameters of current MacroBlock */
823     deblkmb_neighbour_t *ps_deblk_top_mb;
824     UWORD32 u4_leftmbtype;
825     UWORD16 u2_cur_csbp;
826 
827     /* Set of flags */
828     UWORD32 u4_cur_mb_intra, u1_top_mb_typ, u4_cur_mb_fld;
829     UWORD32 u1_cur_mb_type;
830     UWORD32 *pu4_bs_table;
831     UWORD32 mb_type_intra = 0;
832 
833     UWORD16 *pu2_curr_res_luma_csbp;
834     UWORD16 *pu2_left_res_luma_csbp;
835     UWORD16 *pu2_top_res_luma_csbp;
836 
837     /* Neighbour availability */
838     const UWORD32 u2_mbx = ps_cur_mb_info->u2_mbx;
839     const UWORD32 u2_mby = ps_cur_mb_info->u2_mby;
840 
841     PROFILE_DISABLE_BOUNDARY_STRENGTH()
842 
843     ps_deblk_top_mb = ps_dec->ps_deblk_top_mb + u2_mbx;
844 
845     /* Pointer assignment for Current DeblkMB, Current Mv Pred  */
846     ps_cur_mb_params = ps_dec->ps_deblk_mbn + u2_mbxn_mb;
847 
848     /*Pointer assignment for Residual NNZ */
849     pu2_curr_res_luma_csbp = ps_svc_lyr_dec->pu2_frm_res_luma_csbp + ps_cur_mb_info->u2_mbx;
850     pu2_curr_res_luma_csbp += ps_cur_mb_info->u2_mby * ps_svc_lyr_dec->i4_frm_res_luma_csbp_stride;
851 
852     pu2_left_res_luma_csbp = pu2_curr_res_luma_csbp - (ps_cur_mb_info->u2_mbx != 0);
853     pu2_top_res_luma_csbp = pu2_curr_res_luma_csbp - ((ps_cur_mb_info->u2_mby != 0) *
854                                                       ps_svc_lyr_dec->i4_frm_res_luma_csbp_stride);
855 
856     u1_cur_mb_type = ps_cur_mb_params->u1_mb_type;
857     u1_top_mb_typ = ps_deblk_top_mb->u1_mb_type;
858     ps_deblk_top_mb->u1_mb_type = u1_cur_mb_type;
859 
860     ps_cur_mb_params->u1_topmb_qp = ps_deblk_top_mb->u1_mb_qp;
861     ps_deblk_top_mb->u1_mb_qp = ps_cur_mb_params->u1_mb_qp;
862     ps_cur_mb_params->u1_left_mb_qp = ps_dec->deblk_left_mb[1].u1_mb_qp;
863     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     if(ps_cur_mb_params->u1_deblocking_mode & MB_DISABLE_FILTERING)
868     {
869         /* Storing the leftMbtype for next Mb */
870         ps_dec->deblk_left_mb[1].u1_mb_type = ps_cur_mb_params->u1_mb_type;
871         return;
872     }
873 
874     /* Flag for extra left Edge */
875     ps_cur_mb_params->u1_single_call = 1;
876 
877     /* Update the Left deblk_mb_t */
878     if(!u2_mbx)
879     {
880         u4_leftmbtype = 0;
881     }
882     else
883     {
884         u4_leftmbtype = ps_dec->deblk_left_mb[1].u1_mb_type;
885     }
886 
887     if(!u2_mby) u1_top_mb_typ = 0;
888 
889     u4_cur_mb_intra = u1_cur_mb_type & D_INTRA_MB;
890     u4_cur_mb_fld = !!(u1_cur_mb_type & D_FLD_MB);
891     /* Compute BS function */
892     pu4_bs_table = ps_cur_mb_params->u4_bs_table;
893 
894     u2_cur_csbp = ps_cur_mb_info->ps_curmb->u2_luma_csbp;
895     /* Compute BS function */
896     if((ps_dec->ps_cur_sps->u1_profile_idc == HIGH_PROFILE_IDC) ||
897        (ps_dec->ps_cur_sps->u1_profile_idc == SCALABLE_HIGH_PROFILE_IDC) ||
898        (ps_dec->ps_cur_sps->u1_profile_idc == SCALABLE_BASELINE_PROFILE_IDC))
899     {
900         if(ps_cur_mb_info->u1_tran_form8x8 == 1)
901         {
902             u2_cur_csbp = ih264d_update_csbp_8x8(ps_cur_mb_info->ps_curmb->u2_luma_csbp);
903             ps_cur_mb_info->ps_curmb->u2_luma_csbp = u2_cur_csbp;
904         }
905     }
906     u2_cur_csbp |= *pu2_curr_res_luma_csbp;
907 
908     if(u4_cur_mb_intra)
909     {
910         pu4_bs_table[4] = 0x04040404;
911         pu4_bs_table[0] = u4_cur_mb_fld ? 0x03030303 : 0x04040404;
912         pu4_bs_table[1] = 0x03030303;
913         pu4_bs_table[2] = 0x03030303;
914         pu4_bs_table[3] = 0x03030303;
915         pu4_bs_table[5] = 0x03030303;
916         pu4_bs_table[6] = 0x03030303;
917         pu4_bs_table[7] = 0x03030303;
918     }
919     else
920     {
921         isvcd_fill_bs_ibl(ps_cur_mb_params, u1_top_mb_typ, u4_leftmbtype, ps_cur_mb_info,
922                           pu2_curr_res_luma_csbp, pu2_left_res_luma_csbp, pu2_top_res_luma_csbp);
923     }
924 
925     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     if(!mb_type_intra)
929     {
930         pu4_bs_table[0] = 0;
931         /* disable the processing of top edge  */
932         ps_cur_mb_params->u1_deblocking_mode |= MB_DISABLE_TOP_EDGE;
933     }
934 
935     mb_type_intra = (u4_leftmbtype & D_INTRA_MB) || (u4_leftmbtype & D_INTRA_IBL);
936     /* if Left MB current MB is INTER */
937     if(!mb_type_intra)
938     {
939         pu4_bs_table[4] = 0;
940         /* disable the processing of left edge  */
941         ps_cur_mb_params->u1_deblocking_mode |= MB_DISABLE_LEFT_EDGE;
942     }
943 
944     /* overwrite the BS 0 values for corner cases */
945     if(0 == u2_mbx)
946     {
947         pu4_bs_table[4] = 0;
948     }
949     if(0 == u2_mby)
950     {
951         pu4_bs_table[0] = 0;
952     }
953 
954     /* Storing the leftMbtype for next Mb */
955     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     if(ps_cur_mb_info->u1_tran_form8x8)
959     {
960         pu4_bs_table[1] = 0;
961         pu4_bs_table[3] = 0;
962         pu4_bs_table[5] = 0;
963         pu4_bs_table[7] = 0;
964     }
965 }
966