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