Lines Matching defs:ps_ctxt
169 void ihevce_enc_loop_ctb_left_copy(ihevce_enc_loop_ctxt_t *ps_ctxt, enc_loop_cu_prms_t *ps_cu_prms)
181 UWORD8 u1_is_422 = (ps_ctxt->u1_chroma_array_type == 2);
183 pu1_luma_left = (UWORD8 *)ps_ctxt->pv_left_luma_data;
184 pu1_chrm_left = (UWORD8 *)ps_ctxt->pv_left_chrm_data;
185 ps_left_nbr = &ps_ctxt->as_left_col_nbr[0];
216 ps_nbr = &ps_ctxt->as_ctb_nbr_arr[0];
283 * \param[in] ps_ctxt : pointer to enc_loop module
302 ihevce_enc_loop_ctxt_t *ps_ctxt,
338 WORD32 i4_best_cu_qp = ps_ctxt->ps_rc_quant_ctxt->i2_min_qp - 1;
344 UWORD8 u1_is_422 = (ps_ctxt->u1_chroma_array_type == 2);
348 ps_ctxt->as_cu_prms[0].i8_best_rdopt_cost = MAX_COST_64;
349 ps_ctxt->as_cu_prms[1].i8_best_rdopt_cost = MAX_COST_64;
352 ps_ctxt->i4_zcbf_rdo_level = ZCBF_ENABLE;
359 ps_ctxt->ps_enc_out_ctxt->b3_cu_pos_x = ps_cu_analyse->b3_cu_pos_x;
360 ps_ctxt->ps_enc_out_ctxt->b3_cu_pos_y = ps_cu_analyse->b3_cu_pos_y;
361 ps_ctxt->ps_enc_out_ctxt->u1_cu_size = ps_cu_analyse->u1_cu_size;
364 ps_curr_nbr_4x4 = &ps_ctxt->as_ctb_nbr_arr[0];
373 if(!ps_ctxt->u1_is_input_data_hbd)
394 pu1_cu_left = (UWORD8 *)ps_ctxt->pv_left_luma_data;
398 ps_left_nbr_4x4 = &ps_ctxt->as_left_col_nbr[0];
418 pu1_cu_top = (UWORD8 *)ps_ctxt->pv_top_row_luma;
422 ps_top_nbr_4x4 = ps_ctxt->ps_top_row_nbr;
472 ps_ctxt->pu1_ctb_nbr_map,
473 ps_ctxt->i4_nbr_map_strd,
486 ps_ctxt->s_rdopt_entropy_ctxt.as_cu_entropy_ctxt[0].i4_num_nbr_skip_cus =
488 ps_ctxt->s_rdopt_entropy_ctxt.as_cu_entropy_ctxt[1].i4_num_nbr_skip_cus =
513 s_chrm_cu_buf_prms.pu1_cu_left = (UWORD8 *)ps_ctxt->pv_left_chrm_data;
528 s_chrm_cu_buf_prms.pu1_cu_top = (UWORD8 *)ps_ctxt->pv_top_row_chroma;
556 i4_ctb_y_off = ps_ctxt->s_mc_ctxt.i4_ctb_frm_pos_y;
557 ps_ctxt->i4_satd_buf_idx = rd_opt_curr_idx;
560 ps_ctxt->s_cu_me_intra_pred_prms.i4_pointer_count = 0;
570 ps_ctxt->s_cu_inter_merge_skip.u1_num_merge_cands = 0;
571 ps_ctxt->s_cu_inter_merge_skip.u1_num_skip_cands = 0;
572 ps_ctxt->s_mixed_mode_inter_cu.u1_num_mixed_mode_type0_cands = 0;
573 ps_ctxt->s_mixed_mode_inter_cu.u1_num_mixed_mode_type1_cands = 0;
574 ps_ctxt->s_pred_buf_data.i4_pred_stride = ps_cu_analyse->u1_cu_size;
581 if(ps_ctxt->u1_disable_intra_eval)
590 if((!ps_ctxt->u1_use_top_at_ctb_boundary) && u1_enable_top_row_sync)
602 ((ihevce_tile_params_t *)ps_ctxt->pv_tile_params_base +
603 ps_ctxt->i4_tile_col_idx);
618 ps_ctxt->pv_dep_mngr_enc_loop_cu_top_right,
622 ps_ctxt->i4_tile_col_idx, /* Col Tile No. */
623 ps_ctxt->thrd_id);
627 s_prms.i4_ctb_nbr_map_stride = ps_ctxt->i4_nbr_map_strd;
628 s_prms.i4_max_num_inter_rdopt_cands = ps_ctxt->i4_max_num_inter_rdopt_cands;
631 s_prms.ps_cu_inter_merge_skip = &ps_ctxt->s_cu_inter_merge_skip;
632 s_prms.aps_cu_nbr_buf[0] = &ps_ctxt->as_cu_nbr[ps_ctxt->i4_satd_buf_idx][0];
633 s_prms.aps_cu_nbr_buf[1] = &ps_ctxt->as_cu_nbr[!ps_ctxt->i4_satd_buf_idx][0];
635 s_prms.ps_mc_ctxt = &ps_ctxt->s_mc_ctxt;
637 s_prms.ps_mixed_modes_datastore = &ps_ctxt->s_mixed_mode_inter_cu;
638 s_prms.ps_mv_pred_ctxt = &ps_ctxt->s_mv_pred_ctxt;
639 s_prms.ps_pred_buf_data = &ps_ctxt->s_pred_buf_data;
642 s_prms.pu1_ctb_nbr_map = ps_ctxt->pu1_ctb_nbr_map;
647 s_prms.u1_max_merge_candidates = ps_ctxt->i4_max_merge_candidates;
649 s_prms.u1_use_satd_for_merge_eval = ps_ctxt->i4_use_satd_for_merge_eval;
650 s_prms.u1_quality_preset = ps_ctxt->i4_quality_preset;
651 s_prms.i1_slice_type = ps_ctxt->i1_slice_type;
652 s_prms.ps_cu_me_intra_pred_prms = &ps_ctxt->s_cu_me_intra_pred_prms;
653 s_prms.u1_is_hbd = (ps_ctxt->u1_bit_depth > 8);
656 s_prms.i4_lambda_qf = ps_ctxt->i4_sad_lamda;
660 ps_ctxt->s_rdopt_entropy_ctxt.au1_init_cabac_ctxt_states[IHEVC_CAB_MERGE_IDX_EXT];
668 if(ps_ctxt->s_mv_pred_ctxt.ps_slice_hdr->i1_slice_type != PSLICE)
670 if(ps_ctxt->i4_temporal_layer == 1)
692 s_prms.ps_cmn_utils_optimised_function_list = &ps_ctxt->s_cmn_opt_func;
694 s_prms.pf_evalsad_pt_npu_mxn_8bit = (FT_SAD_EVALUATOR *)ps_ctxt->pv_evalsad_pt_npu_mxn_8bit;
703 au1_buf_ids, &ps_ctxt->s_pred_buf_data.u4_is_buf_in_use, NUM_CU_ME_INTRA_PRED_IDX - 1);
707 for(ctr = ps_ctxt->s_cu_me_intra_pred_prms.i4_pointer_count; ctr < u1_num_bufs_allocated;
711 ps_ctxt->s_cu_me_intra_pred_prms.pu1_pred_data[ctr] =
712 (UWORD8 *)ps_ctxt->s_pred_buf_data.apv_inter_pred_data[au1_buf_ids[ctr]];
715 ps_ctxt->s_cu_me_intra_pred_prms.ai4_pred_data_stride[ctr] = ps_cu_analyse->u1_cu_size;
717 ps_ctxt->s_cu_me_intra_pred_prms.i4_pointer_count++;
721 ps_ctxt->s_cu_me_intra_pred_prms.pu1_pred_data[ctr] =
722 (UWORD8 *)ps_ctxt->pv_422_chroma_intra_pred_buf;
725 ps_ctxt->s_cu_me_intra_pred_prms.ai4_pred_data_stride[ctr] = ps_cu_analyse->u1_cu_size;
727 ps_ctxt->s_cu_me_intra_pred_prms.i4_pointer_count++;
735 au1_buf_ids, &ps_ctxt->s_pred_buf_data.u4_is_buf_in_use, NUM_CU_ME_INTRA_PRED_IDX);
739 for(ctr = ps_ctxt->s_cu_me_intra_pred_prms.i4_pointer_count; ctr < u1_num_bufs_allocated;
743 ps_ctxt->s_cu_me_intra_pred_prms.pu1_pred_data[ctr] =
744 (UWORD8 *)ps_ctxt->s_pred_buf_data.apv_inter_pred_data[au1_buf_ids[ctr]];
747 ps_ctxt->s_cu_me_intra_pred_prms.ai4_pred_data_stride[ctr] = ps_cu_analyse->u1_cu_size;
749 ps_ctxt->s_cu_me_intra_pred_prms.i4_pointer_count++;
753 ihevce_mark_all_modes_to_evaluate(ps_ctxt, ps_cu_analyse);
755 ps_ctxt->as_cu_prms[0].s_recon_datastore.u1_is_lumaRecon_available = 0;
756 ps_ctxt->as_cu_prms[1].s_recon_datastore.u1_is_lumaRecon_available = 0;
757 ps_ctxt->as_cu_prms[0].s_recon_datastore.au1_is_chromaRecon_available[0] = 0;
758 ps_ctxt->as_cu_prms[1].s_recon_datastore.au1_is_chromaRecon_available[0] = 0;
759 ps_ctxt->as_cu_prms[0].s_recon_datastore.au1_is_chromaRecon_available[1] = 0;
760 ps_ctxt->as_cu_prms[1].s_recon_datastore.au1_is_chromaRecon_available[1] = 0;
761 ps_ctxt->as_cu_prms[0].s_recon_datastore.au1_is_chromaRecon_available[2] = 0;
762 ps_ctxt->as_cu_prms[1].s_recon_datastore.au1_is_chromaRecon_available[2] = 0;
797 ps_ctxt->s_rdopt_entropy_ctxt.i4_curr_buf_idx = rd_opt_curr_idx;
801 &ps_ctxt->au1_rdopt_init_ctxt_models[0],
802 &ps_ctxt->s_rdopt_entropy_ctxt.au1_init_cabac_ctxt_states[0],
805 rd_opt_cost = ((pf_inter_rdopt_cu_mc_mvp)ps_ctxt->pv_inter_rdopt_cu_mc_mvp)(
806 ps_ctxt,
818 if((ps_ctxt->u1_bit_depth == 8) && (!ps_inter_cand->b1_skip_flag))
822 (me_func_selector_t *)ps_ctxt->pv_err_func_selector,
823 ps_ctxt->ai2_scratch,
826 ps_ctxt->i4_satd_lamda,
829 ps_ctxt->u1_max_tr_depth);
833 ps_ctxt->i4_zcbf_rdo_level = NO_ZCBF;
835 ps_ctxt->i4_zcbf_rdo_level = ZCBF_ENABLE;
838 rd_opt_cost += ((pf_inter_rdopt_cu_ntu)ps_ctxt->pv_inter_rdopt_cu_ntu)(
839 ps_ctxt,
849 !ps_ctxt->u1_is_refPic ? ALPHA_FOR_NOISE_TERM_IN_RDOPT
855 if(!ps_ctxt->u1_enable_psyRDOPT && ps_cu_prms->u1_is_cu_noisy)
857 ps_ctxt->i8_cl_ssd_lambda_qf = ps_ctxt->s_sao_ctxt_t.i8_cl_ssd_lambda_qf;
858 ps_ctxt->i8_cl_ssd_lambda_chroma_qf =
859 ps_ctxt->s_sao_ctxt_t.i8_cl_ssd_lambda_chroma_qf;
870 ps_ctxt->as_cu_prms[rd_opt_best_idx].i8_best_rdopt_cost = rd_opt_cost;
872 i4_best_cu_qp = ps_ctxt->i4_cu_qp;
880 ps_ctxt->pu1_ctb_nbr_map,
881 ps_ctxt->i4_nbr_map_strd,
894 ps_enc_loop_bestprms = &ps_ctxt->as_cu_prms[rd_opt_best_idx];
909 if(IHEVCE_QUALITY_P3 > ps_ctxt->i4_quality_preset)
914 if((IHEVCE_QUALITY_P0 == ps_ctxt->i4_quality_preset) && (ps_cu_prms->u1_is_cu_noisy) &&
915 (ps_ctxt->i1_slice_type != ISLICE) && (0 != s_inter_cu_mode_info.u1_num_inter_cands))
950 if(!ps_ctxt->u1_use_top_at_ctb_boundary)
962 ((ihevce_tile_params_t *)ps_ctxt->pv_tile_params_base +
963 ps_ctxt->i4_tile_col_idx);
978 ps_ctxt->pv_dep_mngr_enc_loop_cu_top_right,
982 ps_ctxt->i4_tile_col_idx, /* Col Tile No. */
983 ps_ctxt->thrd_id);
990 ps_ctxt->i4_zcbf_rdo_level = ZCBF_ENABLE;
992 ps_ctxt->i4_zcbf_rdo_level = NO_ZCBF;
996 if((ps_ctxt->i1_slice_type != ISLICE) && (ps_ctxt->i4_quality_preset >= IHEVCE_QUALITY_P3))
999 ps_ctxt,
1007 ps_ctxt,
1016 if(1 == ps_ctxt->s_chroma_rdopt_ctxt.u1_eval_chrm_satd)
1023 &ps_ctxt->au1_rdopt_init_ctxt_models[0],
1024 &ps_ctxt->s_rdopt_entropy_ctxt.au1_init_cabac_ctxt_states[0],
1028 ps_ctxt->s_rdopt_entropy_ctxt.i4_curr_buf_idx = rd_opt_curr_idx;
1031 ((pf_intra_chroma_pred_mode_selector)ps_ctxt->pv_intra_chroma_pred_mode_selector)(
1032 ps_ctxt,
1037 !ps_ctxt->u1_is_refPic ? ALPHA_FOR_NOISE_TERM_IN_RDOPT
1044 if(!ps_ctxt->u1_enable_psyRDOPT && ps_cu_prms->u1_is_cu_noisy)
1046 ps_ctxt->i8_cl_ssd_lambda_qf = ps_ctxt->s_sao_ctxt_t.i8_cl_ssd_lambda_qf;
1047 ps_ctxt->i8_cl_ssd_lambda_chroma_qf =
1048 ps_ctxt->s_sao_ctxt_t.i8_cl_ssd_lambda_chroma_qf;
1062 &ps_ctxt->au1_rdopt_init_ctxt_models[0],
1063 &ps_ctxt->s_rdopt_entropy_ctxt.au1_init_cabac_ctxt_states[0],
1067 ps_ctxt->s_rdopt_entropy_ctxt.i4_curr_buf_idx = rd_opt_curr_idx;
1070 ((pf_intra_chroma_pred_mode_selector)ps_ctxt->pv_intra_chroma_pred_mode_selector)(
1071 ps_ctxt,
1076 !ps_ctxt->u1_is_refPic ? ALPHA_FOR_NOISE_TERM_IN_RDOPT
1083 if(!ps_ctxt->u1_enable_psyRDOPT && ps_cu_prms->u1_is_cu_noisy)
1085 ps_ctxt->i8_cl_ssd_lambda_qf = ps_ctxt->s_sao_ctxt_t.i8_cl_ssd_lambda_qf;
1086 ps_ctxt->i8_cl_ssd_lambda_chroma_qf =
1087 ps_ctxt->s_sao_ctxt_t.i8_cl_ssd_lambda_chroma_qf;
1112 ((ps_ctxt->i4_quality_preset == IHEVCE_QUALITY_P5) ||
1113 (ps_ctxt->i4_quality_preset == IHEVCE_QUALITY_P6)) &&
1114 (ps_ctxt->i1_slice_type != ISLICE))
1173 ((ps_ctxt->i4_quality_preset == IHEVCE_QUALITY_P5) ||
1174 (ps_ctxt->i4_quality_preset == IHEVCE_QUALITY_P6)) &&
1175 (ps_ctxt->i1_slice_type != ISLICE) && (ps_cu_analyse->u1_cu_size == 64))
1202 ps_ctxt->s_rdopt_entropy_ctxt.i4_curr_buf_idx = rd_opt_curr_idx;
1207 pv_pred = ps_ctxt->s_cu_me_intra_pred_prms.pu1_pred_data[rd_opt_curr_idx];
1212 &ps_ctxt->au1_rdopt_init_ctxt_models[0],
1213 &ps_ctxt->s_rdopt_entropy_ctxt.au1_init_cabac_ctxt_states[0],
1217 rd_opt_cost = ((pf_intra_rdopt_cu_ntu)ps_ctxt->pv_intra_rdopt_cu_ntu)(
1218 ps_ctxt,
1221 ps_ctxt->s_cu_me_intra_pred_prms.ai4_pred_data_stride[rd_opt_curr_idx],
1235 !ps_ctxt->u1_is_refPic ? ALPHA_FOR_NOISE_TERM_IN_RDOPT
1241 if(!ps_ctxt->u1_enable_psyRDOPT && ps_cu_prms->u1_is_cu_noisy)
1243 ps_ctxt->i8_cl_ssd_lambda_qf = ps_ctxt->s_sao_ctxt_t.i8_cl_ssd_lambda_qf;
1244 ps_ctxt->i8_cl_ssd_lambda_chroma_qf =
1245 ps_ctxt->s_sao_ctxt_t.i8_cl_ssd_lambda_chroma_qf;
1255 i4_best_cu_qp = ps_ctxt->i4_cu_qp;
1258 ps_ctxt->as_cu_prms[rd_opt_best_idx].i8_best_rdopt_cost = rd_opt_cost;
1262 (ps_ctxt->as_cu_prms[rd_opt_best_idx].u1_intra_flag) &&
1263 (ps_ctxt->i4_quality_preset <= IHEVCE_QUALITY_P2) && !FORCE_INTRA_TU_DEPTH_TO_0)
1268 if(ps_ctxt->as_cu_prms[rd_opt_best_idx].u1_part_mode == SIZE_2Nx2N)
1271 255; //ps_ctxt->as_cu_prms[rd_opt_best_idx].au1_intra_pred_mode[0];
1278 ps_ctxt->as_cu_prms[rd_opt_best_idx].au1_intra_pred_mode,
1318 ps_ctxt->pu1_ctb_nbr_map,
1319 ps_ctxt->i4_nbr_map_strd,
1328 ASSERT(i4_best_cu_qp > (ps_ctxt->ps_rc_quant_ctxt->i2_min_qp - 1));
1329 ps_ctxt->i4_cu_qp = i4_best_cu_qp;
1344 if(ps_ctxt->i4_quality_preset < IHEVCE_QUALITY_P2)
1346 pu1_ecd_data = &ps_ctxt->pu1_cu_recur_coeffs[0];
1349 pu1_ecd_data = &ps_ctxt->pu1_cu_recur_coeffs[0];
1352 ps_enc_loop_bestprms = &ps_ctxt->as_cu_prms[rd_opt_best_idx];
1356 if(!ps_ctxt->u1_is_input_data_hbd)
1360 pv_final_pred = ps_ctxt->s_cu_me_intra_pred_prms.pu1_pred_data[rd_opt_best_idx];
1362 ps_ctxt->s_cu_me_intra_pred_prms.ai4_pred_data_stride[rd_opt_best_idx];
1371 ps_ctxt->s_cu_me_intra_pred_prms.pu1_pred_data[CU_ME_INTRA_PRED_CHROMA_IDX] +
1375 ps_ctxt->s_cu_me_intra_pred_prms.ai4_pred_data_stride[CU_ME_INTRA_PRED_CHROMA_IDX];
1378 ihevce_set_eval_flags(ps_ctxt, ps_enc_loop_bestprms);
1387 if(!ps_ctxt->u1_is_input_data_hbd)
1390 if(ps_ctxt->i4_quality_preset < IHEVCE_QUALITY_P2)
1392 pv_cu_luma_recon = ps_ctxt->pv_cu_luma_recon;
1393 pv_cu_chroma_recon = ps_ctxt->pv_cu_chrma_recon;
1410 pv_cu_luma_recon = ps_ctxt->pv_cu_luma_recon;
1411 pv_cu_chroma_recon = ps_ctxt->pv_cu_chrma_recon;
1428 s_prms.pu1_csbf_buf = &ps_ctxt->au1_cu_csbf[0];
1429 s_prms.csbf_strd = ps_ctxt->i4_cu_csbf_strd;
1449 ((pf_final_rdopt_mode_prcs)ps_ctxt->pv_final_rdopt_mode_prcs)(ps_ctxt, &s_prms);
1452 if(!ps_ctxt->u1_enable_psyRDOPT && ps_cu_prms->u1_is_cu_noisy)
1454 ps_ctxt->i8_cl_ssd_lambda_qf = ps_ctxt->s_sao_ctxt_t.i8_cl_ssd_lambda_qf;
1455 ps_ctxt->i8_cl_ssd_lambda_chroma_qf =
1456 ps_ctxt->s_sao_ctxt_t.i8_cl_ssd_lambda_chroma_qf;
1468 ps_enc_loop_bestprms = &ps_ctxt->as_cu_prms[rd_opt_best_idx];
1526 ps_entropy_ctxt = ps_ctxt->s_rdopt_entropy_ctxt.as_cu_entropy_ctxt;
1540 ps_ctxt->ps_enc_out_ctxt->i1_cu_qp = ps_cu_analyse->i1_cu_qp;
1545 ps_ctxt->ps_enc_out_ctxt->b1_first_cu_in_qg = 1;
1549 ps_ctxt->ps_enc_out_ctxt->b1_first_cu_in_qg = 0;
1555 ps_ctxt->pu1_ctb_nbr_map,
1556 ps_ctxt->i4_nbr_map_strd,
1565 &ps_ctxt->s_rdopt_entropy_ctxt,
1578 &ps_ctxt->ps_enc_out_ctxt->s_cu_prms,
1579 &ps_ctxt->as_cu_prms[rd_opt_best_idx],
1584 &ps_ctxt->as_cu_recur_nbr[0],
1585 &ps_ctxt->as_cu_nbr[rd_opt_best_idx][0],
1589 ps_ctxt->ps_enc_out_ctxt->ps_cu_prms = &ps_ctxt->ps_enc_out_ctxt->s_cu_prms;
1591 ps_ctxt->ps_cu_recur_nbr = &ps_ctxt->as_cu_recur_nbr[0];
1594 if(ps_ctxt->i4_quality_preset >= IHEVCE_QUALITY_P2)
1596 ps_ctxt->ps_enc_out_ctxt->ps_cu_prms = &ps_ctxt->as_cu_prms[rd_opt_best_idx];
1598 ps_ctxt->ps_cu_recur_nbr = &ps_ctxt->as_cu_nbr[rd_opt_best_idx][0];
1600 if(ps_ctxt->u1_disable_intra_eval && ps_ctxt->i4_deblk_pad_hpel_cur_pic)
1612 ((ihevce_tile_params_t *)ps_ctxt->pv_tile_params_base +
1613 ps_ctxt->i4_tile_col_idx);
1629 ps_ctxt->pv_dep_mngr_enc_loop_cu_top_right,
1633 ps_ctxt->i4_tile_col_idx, /* Col Tile No. */
1634 ps_ctxt->thrd_id);
1642 &ps_ctxt->ps_enc_out_ctxt->s_cu_prms,
1643 &ps_ctxt->as_cu_prms[rd_opt_best_idx],
1648 &ps_ctxt->as_cu_recur_nbr[0],
1649 &ps_ctxt->as_cu_nbr[rd_opt_best_idx][0],
1653 ps_ctxt->ps_enc_out_ctxt->ps_cu_prms = &ps_ctxt->ps_enc_out_ctxt->s_cu_prms;
1655 ps_ctxt->ps_cu_recur_nbr = &ps_ctxt->as_cu_recur_nbr[0];
1659 ps_ctxt->s_pred_buf_data.u4_is_buf_in_use &=
1660 ~((1 << (ps_ctxt->i4_max_num_inter_rdopt_cands + 4)) - 1);
1694 ihevce_enc_loop_ctxt_t *ps_ctxt,
1739 UWORD8 is_inp_422 = (ps_ctxt->u1_chroma_array_type == 2);
1746 ps_ctxt->s_sao_ctxt_t.u4_num_ctbs_horz = ps_frm_ctb_prms->i4_num_ctbs_horz;
1747 ps_ctxt->s_sao_ctxt_t.u4_num_ctbs_vert = ps_frm_ctb_prms->i4_num_ctbs_vert;
1750 pv_dep_mngr_enc_loop_dblk = ps_ctxt->pv_dep_mngr_enc_loop_dblk;
1752 pv_dep_mngr_enc_loop_cu_top_right = ps_ctxt->pv_dep_mngr_enc_loop_cu_top_right;
1778 ps_ctxt->u1_cabac_states_next_row_copied_flag = 0;
1779 ps_ctxt->u1_cabac_states_first_cu_copied_flag = 0;
1788 ps_ctxt->i4_is_first_cu_qg_coded = 0;
1794 memcpy(&s_deblk_ctb_row_params, &ps_ctxt->s_deblk_ctbrow_prms, sizeof(deblk_ctbrow_prms_t));
1826 ps_ctxt->i4_last_cu_qp_from_prev_ctb = ps_ctxt->i4_frame_qp;
1848 ps_ctxt->i4_prev_QP = ps_ctxt->i4_last_cu_qp_from_prev_ctb;
1851 if(ps_ctxt->i4_sub_pic_level_rc)
1853 ihevce_sub_pic_rc_scale_query((void *)ps_multi_thrd_ctxt, (void *)ps_ctxt);
1876 ps_ctxt->u4_cur_ctb_ht = cur_ctb_ht;
1877 ps_ctxt->u4_cur_ctb_wd = cur_ctb_wd;
1884 if((ps_ctxt->i4_bitrate_instance_num == 0) &&
1885 ((ISLICE != ps_ctxt->i1_slice_type) || L0ME_IN_OPENLOOP_MODE))
1894 ps_ctxt->i4_tile_col_idx, /* Col Tile No. */
1895 ps_ctxt->thrd_id);
1904 if(ISLICE != ps_ctxt->i1_slice_type)
1948 &ps_ctxt->au1_nbr_ctb_map[0][0],
1955 ps_ctxt->pu1_ctb_nbr_map,
1956 ps_ctxt->i4_nbr_map_strd,
1962 ps_ctxt->s_mc_ctxt.i4_ctb_frm_pos_x = ctb_ctr * ctb_size;
1963 ps_ctxt->s_mc_ctxt.i4_ctb_frm_pos_y = vert_ctr * ctb_size;
1966 ps_ctxt->s_mv_pred_ctxt.i4_ctb_x = ctb_ctr;
1967 ps_ctxt->s_mv_pred_ctxt.i4_ctb_y = vert_ctr;
1970 if(ps_ctxt->i4_deblk_pad_hpel_cur_pic)
1972 ihevce_bs_init_ctb(&ps_ctxt->s_deblk_bs_prms, ps_frm_ctb_prms, ctb_ctr, vert_ctr);
1976 ihevce_entropy_rdo_ctb_init(&ps_ctxt->s_rdopt_entropy_ctxt, ctb_ctr, vert_ctr);
1989 if(ps_ctxt->i4_bitrate_instance_num == 0)
1996 &ps_ctxt->au1_rdopt_recur_ctxt_models[i][0],
1997 &ps_ctxt->s_rdopt_entropy_ctxt.au1_init_cabac_ctxt_states[0],
2002 if(ps_ctxt->i4_bitrate_instance_num == 0)
2004 if(ps_ctxt->i4_quality_preset < IHEVCE_QUALITY_P2)
2011 &ps_ctxt->au1_rdopt_recur_ctxt_models[i][0],
2012 &ps_ctxt->s_rdopt_entropy_ctxt.au1_init_cabac_ctxt_states[0],
2019 if(ps_ctxt->i4_bitrate_instance_num == 0)
2022 if(ISLICE == ps_ctxt->i1_slice_type)
2031 (IHEVCE_QUALITY_CONFIG_T)ps_ctxt->i4_quality_preset,
2038 ps_ctxt->ps_enc_out_ctxt = &ps_ctxt->as_enc_cu_ctxt[0];
2039 ps_ctxt->pu1_ecd_data = pu1_row_ecd_data;
2040 if(ps_ctxt->i4_use_ctb_level_lamda)
2043 ps_ctxt, -1, ps_ctb_ipe_analyse->i4_64x64_act_factor[3][1], 0);
2058 if(ps_ctxt->u1_enable_psyRDOPT)
2082 is_hbd = ps_ctxt->u1_is_input_data_hbd;
2116 ps_ctxt->ai4_source_satd_8x8[index_satd] =
2118 ps_ctxt->s_cmn_opt_func.pf_AC_HAD_8x8_8bit(
2130 if(ps_ctxt->u1_enable_psyRDOPT)
2150 is_hbd = ps_ctxt->u1_is_input_data_hbd; // 8 bit
2154 // ps_ctxt->u1_chroma_array_type
2155 if(ps_ctxt->u1_chroma_array_type == 1)
2210 ps_ctxt->ai4_source_chroma_satd[index_satd] =
2211 ps_ctxt->s_cmn_opt_func.pf_chroma_AC_HAD_4x4_8bit(
2230 ps_ctxt,
2245 if(ps_ctxt->i1_slice_type != ISLICE)
2252 if(1 == ps_ctxt->i4_sub_pic_level_rc)
2257 (void *)ps_ctxt,
2262 ps_ctxt->ps_enc_out_ctxt->u1_cu_size = 128;
2268 ihevce_enc_cu_node_ctxt_t *ps_enc_out_ctxt = &ps_ctxt->as_enc_cu_ctxt[0];
2270 ps_ctxt->pu1_ecd_data = pu1_row_ecd_data;
2275 ps_ctxt,
2291 if(ps_ctxt->i4_quality_preset < IHEVCE_QUALITY_P2)
2293 ihevce_enc_cu_node_ctxt_t *ps_enc_out_ctxt = &ps_ctxt->as_enc_cu_ctxt[0];
2295 ps_ctxt->pu1_ecd_data = pu1_row_ecd_data;
2300 ps_ctxt,
2318 ((pf_enc_loop_ctb_left_copy)ps_ctxt->pv_enc_loop_ctb_left_copy)(ps_ctxt, &s_cu_prms);
2320 if(ps_ctxt->i4_deblk_pad_hpel_cur_pic)
2324 &ps_ctxt->s_deblk_bs_prms,
2332 if((0 == ps_ctxt->i4_deblock_type) && (ps_ctxt->i4_deblk_pad_hpel_cur_pic))
2335 UWORD32 *pu4_bs_horz = &ps_ctxt->s_deblk_bs_prms.au4_horz_bs[0];
2336 UWORD32 *pu4_bs_vert = &ps_ctxt->s_deblk_bs_prms.au4_vert_bs[0];
2377 ps_ctxt->i4_tile_col_idx /* Col Tile No. */);
2379 ps_ctxt->s_sao_ctxt_t.ps_cmn_utils_optimised_function_list = &ps_ctxt->s_cmn_opt_func;
2383 memcpy(&s_deblk_ctb_row_params, &ps_ctxt->s_deblk_ctbrow_prms, sizeof(deblk_ctbrow_prms_t));
2398 if(!ps_ctxt->u1_is_input_data_hbd)
2437 if(ps_ctxt->i4_deblk_pad_hpel_cur_pic)
2447 ps_ctxt->i4_tile_col_idx, /* Col Tile No. */
2448 ps_ctxt->thrd_id);
2451 if((0 == ps_ctxt->i4_deblock_type))
2457 ps_ctxt,
2464 ps_ctxt->s_deblk_prms.i4_ctb_size = ctb_size;
2467 ps_ctxt->s_deblk_prms.pu1_ctb_y = s_cu_prms.pu1_luma_recon;
2468 ps_ctxt->s_deblk_prms.pu1_ctb_uv = s_cu_prms.pu1_chrm_recon;
2469 ps_ctxt->s_deblk_prms.i4_luma_pic_stride = s_cu_prms.i4_luma_recon_stride;
2470 ps_ctxt->s_deblk_prms.i4_chroma_pic_stride = s_cu_prms.i4_chrm_recon_stride;
2472 ps_ctxt->s_deblk_prms.i4_deblock_top_ctb_edge = (0 == vert_ctr) ? 0 : 1;
2474 ps_ctxt->s_deblk_prms.i4_deblock_top_ctb_edge =
2477 ps_ctxt->s_deblk_prms.i4_deblock_left_ctb_edge = (ctb_start == ctb_ctr) ? 0 : 1;
2481 &ps_ctxt->s_deblk_prms, last_col_tile, &s_deblk_ctb_row_params);
2491 } //end of if((0 == ps_ctxt->i4_deblock_type)
2492 } // end of if(ps_ctxt->i4_deblk_pad_hpel_cur_pic)
2495 if(ps_ctxt->s_sao_ctxt_t.ps_slice_hdr->i1_slice_sao_luma_flag ||
2496 ps_ctxt->s_sao_ctxt_t.ps_slice_hdr->i1_slice_sao_chroma_flag)
2498 sao_ctxt_t *ps_sao_ctxt = &ps_ctxt->s_sao_ctxt_t;
2532 (ctb_size >> (ps_ctxt->u1_chroma_array_type == 1))) +
2548 (ctb_size >> (ps_ctxt->u1_chroma_array_type == 1))) +
2557 &ps_sao_ctxt->aps_frm_top_ctb_sao[ps_ctxt->i4_enc_frm_id]
2561 (ps_ctxt->i4_bitrate_instance_num *
2566 ps_sao_ctxt->apu1_sao_src_frm_top_luma[ps_ctxt->i4_enc_frm_id] +
2569 ps_ctxt->i4_bitrate_instance_num * (ps_sao_ctxt->i4_top_luma_buf_size +
2574 ps_sao_ctxt->apu1_sao_src_frm_top_chroma[ps_ctxt->i4_enc_frm_id] +
2577 ps_ctxt->i4_bitrate_instance_num * (ps_sao_ctxt->i4_top_luma_buf_size +
2584 &ps_ctxt->s_sao_ctxt_t,
2588 ps_ctxt
2589 ->aaps_enc_loop_rc_params[ps_ctxt->i4_enc_frm_id]
2590 [ps_ctxt->i4_bitrate_instance_num]
2592 ps_ctxt
2593 ->aaps_enc_loop_rc_params[ps_ctxt->i4_enc_frm_id]
2594 [ps_ctxt->i4_bitrate_instance_num]
2597 if(ps_ctxt->i4_deblk_pad_hpel_cur_pic &
2605 ps_ctxt->i4_quality_preset,
2607 ps_ctxt->ai2_scratch,
2608 ps_ctxt->i4_bitrate_instance_num,
2609 ps_ctxt->ps_func_selector);
2620 ps_ctxt->s_sao_ctxt_t.i4_ctb_x = ctb_ctr;
2623 ps_ctxt->s_sao_ctxt_t.i4_ctb_y = vert_ctr - 1;
2625 ps_ctb_out_sao = ps_ctxt->s_sao_ctxt_t.ps_ctb_out +
2628 ps_ctxt->s_sao_ctxt_t.ps_sao = &ps_ctb_out_sao->s_sao;
2630 ps_ctxt->s_sao_ctxt_t.i4_sao_blk_wd =
2634 ps_ctxt->s_sao_ctxt_t.i4_sao_blk_ht = ps_ctxt->s_sao_ctxt_t.i4_ctb_size;
2636 ps_ctxt->s_sao_ctxt_t.i4_is_last_ctb_row = 0;
2637 ps_ctxt->s_sao_ctxt_t.i4_is_last_ctb_col = 1;
2650 (ctb_size >> (ps_ctxt->u1_chroma_array_type == 1))) +
2666 (ctb_size >> (ps_ctxt->u1_chroma_array_type == 1))) +
2675 &ps_sao_ctxt->aps_frm_top_ctb_sao[ps_ctxt->i4_enc_frm_id]
2679 (ps_ctxt->i4_bitrate_instance_num *
2684 ps_sao_ctxt->apu1_sao_src_frm_top_luma[ps_ctxt->i4_enc_frm_id] +
2687 ps_ctxt->i4_bitrate_instance_num * (ps_sao_ctxt->i4_top_luma_buf_size +
2692 ps_sao_ctxt->apu1_sao_src_frm_top_chroma[ps_ctxt->i4_enc_frm_id] +
2695 ps_ctxt->i4_bitrate_instance_num * (ps_sao_ctxt->i4_top_luma_buf_size +
2702 &ps_ctxt->s_sao_ctxt_t,
2706 ps_ctxt
2707 ->aaps_enc_loop_rc_params[ps_ctxt->i4_enc_frm_id]
2708 [ps_ctxt->i4_bitrate_instance_num]
2710 ps_ctxt
2711 ->aaps_enc_loop_rc_params[ps_ctxt->i4_enc_frm_id]
2712 [ps_ctxt->i4_bitrate_instance_num]
2715 if(ps_ctxt->i4_deblk_pad_hpel_cur_pic &
2723 ps_ctxt->i4_quality_preset,
2725 ps_ctxt->ai2_scratch,
2726 ps_ctxt->i4_bitrate_instance_num,
2727 ps_ctxt->ps_func_selector);
2733 if(1 == ps_ctxt->i4_deblk_pad_hpel_cur_pic)
2740 ps_ctxt->i4_quality_preset,
2742 ps_ctxt->ai2_scratch,
2743 ps_ctxt->i4_bitrate_instance_num,
2744 ps_ctxt->ps_func_selector);
2753 ps_ctxt->i4_tile_col_idx /* Col Tile No. */);
2756 if(!ps_ctxt->i4_bitrate_instance_num)
2758 if(ps_ctxt->s_sao_ctxt_t.ps_slice_hdr->i1_slice_sao_luma_flag ||
2759 ps_ctxt->s_sao_ctxt_t.ps_slice_hdr->i1_slice_sao_chroma_flag)
2797 if(ps_ctxt->s_sao_ctxt_t.ps_slice_hdr->i1_slice_sao_luma_flag ||
2798 ps_ctxt->s_sao_ctxt_t.ps_slice_hdr->i1_slice_sao_chroma_flag)
2800 sao_ctxt_t *ps_sao_ctxt = &ps_ctxt->s_sao_ctxt_t;
2810 ps_ctxt->s_sao_ctxt_t.i4_ctb_x = ctb_ctr - 1;
2813 ps_ctxt->s_sao_ctxt_t.i4_ctb_y = vert_ctr;
2815 ps_ctb_out_sao = ps_ctxt->s_sao_ctxt_t.ps_ctb_out +
2818 ps_ctxt->s_sao_ctxt_t.ps_sao = &ps_ctb_out_sao->s_sao;
2820 ps_ctxt->s_sao_ctxt_t.i4_sao_blk_wd = ps_ctxt->s_sao_ctxt_t.i4_ctb_size;
2821 ps_ctxt->s_sao_ctxt_t.i4_is_last_ctb_col = 0;
2823 ps_ctxt->s_sao_ctxt_t.i4_sao_blk_ht =
2827 ps_ctxt->s_sao_ctxt_t.i4_is_last_ctb_row = 1;
2840 (ctb_size >> (ps_ctxt->u1_chroma_array_type == 1))) +
2856 (ctb_size >> (ps_ctxt->u1_chroma_array_type == 1))) +
2865 &ps_sao_ctxt->aps_frm_top_ctb_sao[ps_ctxt->i4_enc_frm_id]
2869 (ps_ctxt->i4_bitrate_instance_num *
2874 ps_sao_ctxt->apu1_sao_src_frm_top_luma[ps_ctxt->i4_enc_frm_id] +
2877 ps_ctxt->i4_bitrate_instance_num * (ps_sao_ctxt->i4_top_luma_buf_size +
2882 ps_sao_ctxt->apu1_sao_src_frm_top_chroma[ps_ctxt->i4_enc_frm_id] +
2885 ps_ctxt->i4_bitrate_instance_num * (ps_sao_ctxt->i4_top_luma_buf_size +
2891 &ps_ctxt->s_sao_ctxt_t,
2895 ps_ctxt
2896 ->aaps_enc_loop_rc_params[ps_ctxt->i4_enc_frm_id]
2897 [ps_ctxt->i4_bitrate_instance_num]
2899 ps_ctxt
2900 ->aaps_enc_loop_rc_params[ps_ctxt->i4_enc_frm_id]
2901 [ps_ctxt->i4_bitrate_instance_num]
2904 if(ps_ctxt->i4_deblk_pad_hpel_cur_pic &
2912 ps_ctxt->i4_quality_preset,
2914 ps_ctxt->ai2_scratch,
2915 ps_ctxt->i4_bitrate_instance_num,
2916 ps_ctxt->ps_func_selector);
2926 ps_ctxt->s_sao_ctxt_t.i4_ctb_x = ctb_ctr;
2929 ps_ctxt->s_sao_ctxt_t.i4_ctb_y = vert_ctr;
2931 ps_ctb_out_sao = ps_ctxt->s_sao_ctxt_t.ps_ctb_out +
2934 ps_ctxt->s_sao_ctxt_t.ps_sao = &ps_ctb_out_sao->s_sao;
2936 ps_ctxt->s_sao_ctxt_t.i4_sao_blk_wd =
2940 ps_ctxt->s_sao_ctxt_t.i4_sao_blk_ht =
2944 ps_ctxt->s_sao_ctxt_t.i4_is_last_ctb_row = 1;
2945 ps_ctxt->s_sao_ctxt_t.i4_is_last_ctb_col = 1;
2958 (ctb_size >> (ps_ctxt->u1_chroma_array_type == 1))) +
2974 (ctb_size >> (ps_ctxt->u1_chroma_array_type == 1))) +
2983 &ps_sao_ctxt->aps_frm_top_ctb_sao[ps_ctxt->i4_enc_frm_id]
2987 (ps_ctxt->i4_bitrate_instance_num *
2992 ps_sao_ctxt->apu1_sao_src_frm_top_luma[ps_ctxt->i4_enc_frm_id] +
2995 ps_ctxt->i4_bitrate_instance_num * (ps_sao_ctxt->i4_top_luma_buf_size +
3000 ps_sao_ctxt->apu1_sao_src_frm_top_chroma[ps_ctxt->i4_enc_frm_id] +
3003 ps_ctxt->i4_bitrate_instance_num * (ps_sao_ctxt->i4_top_luma_buf_size +
3010 &ps_ctxt->s_sao_ctxt_t,
3014 ps_ctxt
3015 ->aaps_enc_loop_rc_params[ps_ctxt->i4_enc_frm_id]
3016 [ps_ctxt->i4_bitrate_instance_num]
3018 ps_ctxt
3019 ->aaps_enc_loop_rc_params[ps_ctxt->i4_enc_frm_id]
3020 [ps_ctxt->i4_bitrate_instance_num]
3023 if(ps_ctxt->i4_deblk_pad_hpel_cur_pic &
3031 ps_ctxt->i4_quality_preset,
3033 ps_ctxt->ai2_scratch,
3034 ps_ctxt->i4_bitrate_instance_num,
3035 ps_ctxt->ps_func_selector);
3044 if(!ps_ctxt->i4_bitrate_instance_num)
3125 ihevce_enc_loop_ctxt_t *ps_ctxt = ps_master_ctxt->aps_enc_loop_thrd_ctxt[thrd_id];
3127 WORD32 i4_bitrate_instance_num = ps_ctxt->i4_bitrate_instance_num;
3130 ps_ctxt->i8_cl_ssd_lambda_qf = ps_frm_lamda->i8_cl_ssd_lambda_qf;
3131 ps_ctxt->i8_cl_ssd_lambda_chroma_qf = ps_frm_lamda->i8_cl_ssd_lambda_chroma_qf;
3132 ps_ctxt->u4_chroma_cost_weighing_factor = ps_frm_lamda->u4_chroma_cost_weighing_factor;
3133 ps_ctxt->i4_satd_lamda = ps_frm_lamda->i4_cl_satd_lambda_qf;
3134 ps_ctxt->i4_sad_lamda = ps_frm_lamda->i4_cl_sad_type2_lambda_qf;
3135 ps_ctxt->thrd_id = thrd_id;
3136 ps_ctxt->u1_is_refPic = ps_curr_inp->s_lap_out.i4_is_ref_pic;
3139 ps_ctxt->s_sao_ctxt_t.ps_ctb_data = ps_ctb_in;
3140 ps_ctxt->s_sao_ctxt_t.i4_ctb_data_stride = ps_frm_ctb_prms->i4_num_ctbs_horz;
3144 ps_ctxt->pv_err_func_selector = ps_func_selector;
3150 ps_ctxt->i4_deblk_pad_hpel_cur_pic =
3152 ((ps_ctxt->s_sao_ctxt_t.ps_slice_hdr->i1_slice_sao_luma_flag ||
3153 ps_ctxt->s_sao_ctxt_t.ps_slice_hdr->i1_slice_sao_chroma_flag)
3158 ps_ctxt->i4_share_flag = (ps_frm_recon->i4_is_reference != 0);
3159 ps_ctxt->pv_frm_recon = (void *)ps_frm_recon;
3162 ps_ctxt->s_sao_ctxt_t.i8_cl_ssd_lambda_qf = ps_frm_lamda->i8_cl_ssd_lambda_qf;
3163 ps_ctxt->s_sao_ctxt_t.i8_cl_ssd_lambda_chroma_qf = ps_frm_lamda->i8_cl_ssd_lambda_chroma_qf;
3166 ps_ctxt,
3168 (WORD32)ps_ctxt->i1_slice_type,
3172 ps_ctxt->u1_disable_intra_eval = DISABLE_INTRA_IN_BPICS &&
3173 (IHEVCE_QUALITY_P6 == ps_ctxt->i4_quality_preset) &&
3174 (ps_ctxt->i4_temporal_layer_id > TEMPORAL_LAYER_DISABLE);
3191 s_pad_interp_recon.u1_chroma_array_type = ps_ctxt->u1_chroma_array_type;
3211 UWORD8 is_inp_422 = (ps_ctxt->u1_chroma_array_type == 2);
3218 ps_ctxt->s_sao_ctxt_t.ps_ctb_out = ps_ctb_out;
3260 ps_ctxt->i4_tile_col_idx = tile_col_idx;
3275 if(!ps_ctxt->u1_is_input_data_hbd)
3294 if(!ps_ctxt->u1_is_input_data_hbd)
3309 ps_ctxt->s_sao_ctxt_t.pu1_frm_luma_src_buf =
3315 ps_ctxt->s_sao_ctxt_t.i4_frm_luma_src_stride =
3318 ps_ctxt->s_sao_ctxt_t.pu1_frm_chroma_src_buf =
3321 ps_ctxt->s_sao_ctxt_t.i4_frm_chroma_src_stride =
3393 ps_ctxt->pv_dep_mngr_enc_loop_cu_top_right =
3394 ps_master_ctxt->aapv_dep_mngr_enc_loop_cu_top_right[ps_ctxt->i4_enc_frm_id]
3397 ps_ctxt->pv_dep_mngr_enc_loop_dblk =
3399 ->aapv_dep_mngr_enc_loop_dblk[ps_ctxt->i4_enc_frm_id][i4_bitrate_instance_num];
3401 ps_ctxt->pu1_curr_row_cabac_state = &ps_master_ctxt->au1_ctxt_models[vert_ctr][0];
3405 ps_ctxt->pv_top_row_luma =
3406 (UWORD8 *)ps_ctxt->apv_frm_top_row_luma[ps_ctxt->i4_enc_frm_id] +
3407 (ps_ctxt->i4_frm_top_row_luma_size * ps_ctxt->i4_bitrate_instance_num) +
3408 (vert_ctr - 1) * ps_ctxt->i4_top_row_luma_stride;
3410 ps_ctxt->pv_top_row_chroma =
3411 (UWORD8 *)ps_ctxt->apv_frm_top_row_chroma[ps_ctxt->i4_enc_frm_id] +
3412 (ps_ctxt->i4_frm_top_row_chroma_size * ps_ctxt->i4_bitrate_instance_num) +
3413 (vert_ctr - 1) * ps_ctxt->i4_top_row_chroma_stride;
3416 ps_ctxt->pv_bot_row_luma =
3417 (UWORD8 *)ps_ctxt->apv_frm_top_row_luma[ps_ctxt->i4_enc_frm_id] +
3418 (ps_ctxt->i4_frm_top_row_luma_size * ps_ctxt->i4_bitrate_instance_num) +
3419 (vert_ctr)*ps_ctxt->i4_top_row_luma_stride;
3421 ps_ctxt->pv_bot_row_chroma =
3422 (UWORD8 *)ps_ctxt->apv_frm_top_row_chroma[ps_ctxt->i4_enc_frm_id] +
3423 (ps_ctxt->i4_frm_top_row_chroma_size * ps_ctxt->i4_bitrate_instance_num) +
3424 (vert_ctr)*ps_ctxt->i4_top_row_chroma_stride;
3427 ps_ctxt->s_sao_ctxt_t.pu1_frm_luma_recon_buf =
3429 ps_ctxt->s_sao_ctxt_t.i4_frm_luma_recon_stride =
3432 ps_ctxt->s_sao_ctxt_t.pu1_frm_chroma_recon_buf =
3434 ps_ctxt->s_sao_ctxt_t.i4_frm_chroma_recon_stride =
3437 ps_ctxt->s_sao_ctxt_t.ps_rdopt_entropy_ctxt = &ps_ctxt->s_rdopt_entropy_ctxt;
3439 ps_ctxt->s_sao_ctxt_t.i4_frm_top_luma_buf_stride =
3440 ps_ctxt->s_sao_ctxt_t.u4_ctb_aligned_wd + 1;
3442 ps_ctxt->s_sao_ctxt_t.i4_frm_top_chroma_buf_stride =
3443 ps_ctxt->s_sao_ctxt_t.u4_ctb_aligned_wd + 2;
3446 ps_ctxt->ps_top_row_nbr =
3447 ps_ctxt->aps_frm_top_row_nbr[ps_ctxt->i4_enc_frm_id] +
3448 (ps_ctxt->i4_frm_top_row_nbr_size * ps_ctxt->i4_bitrate_instance_num) +
3449 (vert_ctr - 1) * ps_ctxt->i4_top_row_nbr_stride;
3451 ps_ctxt->ps_bot_row_nbr =
3452 ps_ctxt->aps_frm_top_row_nbr[ps_ctxt->i4_enc_frm_id] +
3453 (ps_ctxt->i4_frm_top_row_nbr_size * ps_ctxt->i4_bitrate_instance_num) +
3454 (vert_ctr)*ps_ctxt->i4_top_row_nbr_stride;
3458 ps_ctxt->pu1_top_rt_cabac_state = &ps_master_ctxt->au1_ctxt_models[vert_ctr - 1][0];
3462 ps_ctxt->pu1_top_rt_cabac_state = NULL;
3466 ps_ctxt->s_rdopt_entropy_ctxt.as_cu_entropy_ctxt[0]
3468 ps_ctxt->s_rdopt_entropy_ctxt.as_cu_entropy_ctxt[1]
3473 ps_ctxt,
3493 ps_ctxt->pv_dep_mngr_encloop_dep_me,
4393 ihevce_enc_loop_ctxt_t *ps_ctxt;
4416 ps_ctxt = (ihevce_enc_loop_ctxt_t *)ps_mem_tab[ENC_LOOP_THRDS_CTXT].pv_base;
4418 ps_ctxt->ps_rc_quant_ctxt = ps_rc_quant_ctxt;
4468 ps_master_ctxt->aps_enc_loop_thrd_ctxt[ctr] = ps_ctxt;
4470 ps_ctxt->pv_tile_params_base = (void *)ps_tile_params_base;
4472 &ps_ctxt->s_cmn_opt_func, u1_is_popcnt_available, ps_init_prms->e_arch_type);
4474 (FT_SAD_EVALUATOR **)(&ps_ctxt->pv_evalsad_pt_npu_mxn_8bit), ps_init_prms->e_arch_type);
4475 ps_ctxt->i4_max_search_range_horizontal =
4477 ps_ctxt->i4_max_search_range_vertical =
4480 ps_ctxt->i4_quality_preset =
4483 if(ps_ctxt->i4_quality_preset == IHEVCE_QUALITY_P7)
4485 ps_ctxt->i4_quality_preset = IHEVCE_QUALITY_P6;
4488 ps_ctxt->i4_num_proc_thrds = ps_master_ctxt->i4_num_proc_thrds;
4490 ps_ctxt->i4_rc_pass = ps_init_prms->s_pass_prms.i4_pass;
4492 ps_ctxt->u1_chroma_array_type = (i4_chroma_format == IV_YUV_422SP_UV) ? 2 : 1;
4494 ps_ctxt->s_deblk_prms.u1_chroma_array_type = ps_ctxt->u1_chroma_array_type;
4496 ps_ctxt->pi2_scal_mat = (WORD16 *)ps_mem_tab[ENC_LOOP_SCALE_MAT].pv_base;
4498 ps_ctxt->pi2_rescal_mat = (WORD16 *)ps_mem_tab[ENC_LOOP_RESCALE_MAT].pv_base;
4500 if(ps_ctxt->i4_quality_preset < IHEVCE_QUALITY_P2)
4502 ps_ctxt->i4_use_ctb_level_lamda = 0;
4506 ps_ctxt->i4_use_ctb_level_lamda = 0;
4510 ps_ctxt->ps_func_selector = ps_func_selector;
4512 ps_ctxt->s_mc_ctxt.ps_func_selector = ps_func_selector;
4515 ps_ctxt->s_mc_ctxt.ai4_tile_xtra_pel[0] = 0;
4516 ps_ctxt->s_mc_ctxt.ai4_tile_xtra_pel[1] = 0;
4517 ps_ctxt->s_mc_ctxt.ai4_tile_xtra_pel[2] = 0;
4518 ps_ctxt->s_mc_ctxt.ai4_tile_xtra_pel[3] = 0;
4520 ps_ctxt->s_deblk_prms.ps_func_selector = ps_func_selector;
4521 ps_ctxt->i4_top_row_luma_stride = (u4_width + MAX_CU_SIZE + 1);
4523 ps_ctxt->i4_frm_top_row_luma_size =
4524 ps_ctxt->i4_top_row_luma_stride * (u4_ctb_rows_in_a_frame + 1);
4526 ps_ctxt->i4_top_row_chroma_stride = (u4_width + MAX_CU_SIZE + 2);
4528 ps_ctxt->i4_frm_top_row_chroma_size =
4529 ps_ctxt->i4_top_row_chroma_stride * (u4_ctb_rows_in_a_frame + 1);
4535 ps_ctxt->apv_frm_top_row_luma[i4_enc_frm_id] =
4537 (ps_ctxt->i4_frm_top_row_luma_size * i4_enc_frm_id * i4_num_bitrate_inst);
4540 ps_ctxt->apv_frm_top_row_luma[i4_enc_frm_id] =
4541 (UWORD8 *)ps_ctxt->apv_frm_top_row_luma[i4_enc_frm_id] +
4542 ps_ctxt->i4_top_row_luma_stride;
4545 ps_ctxt->apv_frm_top_row_chroma[i4_enc_frm_id] =
4547 (ps_ctxt->i4_frm_top_row_chroma_size * i4_enc_frm_id * i4_num_bitrate_inst);
4550 ps_ctxt->apv_frm_top_row_chroma[i4_enc_frm_id] =
4551 (UWORD8 *)ps_ctxt->apv_frm_top_row_chroma[i4_enc_frm_id] +
4552 ps_ctxt->i4_top_row_chroma_stride;
4557 ps_ctxt->i4_top_row_nbr_stride = (((u4_width + MAX_CU_SIZE) >> 2) + 1);
4558 ps_ctxt->i4_frm_top_row_nbr_size =
4559 ps_ctxt->i4_top_row_nbr_stride * (u4_ctb_rows_in_a_frame + 1);
4562 ps_ctxt->aps_frm_top_row_nbr[i4_enc_frm_id] =
4564 (ps_ctxt->i4_frm_top_row_nbr_size * i4_enc_frm_id * i4_num_bitrate_inst);
4565 ps_ctxt->aps_frm_top_row_nbr[i4_enc_frm_id] += ps_ctxt->i4_top_row_nbr_stride;
4592 ps_ctxt->as_cu_prms[i].pu1_cu_coeffs =
4597 ((LWORD64)ps_ctxt->as_cu_prms[i].pu1_cu_coeffs & 0xf);
4599 ps_ctxt->as_cu_prms[i].pu1_cu_coeffs += (16 - i4_16byte_boundary_overshoot);
4603 ps_ctxt->pu1_cu_recur_coeffs =
4624 ps_ctxt->as_cu_prms[i].pi2_cu_deq_coeffs =
4629 ((LWORD64)ps_ctxt->as_cu_prms[i].pi2_cu_deq_coeffs & 0xf);
4631 ps_ctxt->as_cu_prms[i].pi2_cu_deq_coeffs =
4633 *)((UWORD8 *)ps_ctxt->as_cu_prms[i].pi2_cu_deq_coeffs + (16 - i4_16byte_boundary_overshoot));
4641 ps_ctxt->s_deblk_ctbrow_prms.u4_qp_top_4x4_buf_strd = (MAX_CTB_SIZE / 4) * u4_ctb_in_a_row;
4643 ps_ctxt->s_deblk_ctbrow_prms.u4_qp_top_4x4_buf_size =
4644 ps_ctxt->s_deblk_ctbrow_prms.u4_qp_top_4x4_buf_strd * u4_ctb_rows_in_a_frame;
4650 ps_ctxt->s_deblk_ctbrow_prms.api1_qp_top_4x4_ctb_row[i4_enc_frm_id] =
4652 (ps_ctxt->s_deblk_ctbrow_prms.u4_qp_top_4x4_buf_size * i4_num_bitrate_inst *
4656 ps_ctxt->s_deblk_ctbrow_prms.pu4_ctb_row_bs_vert = (UWORD32 *)pu1_deblk_base;
4658 ps_ctxt->s_deblk_ctbrow_prms.pu4_ctb_row_bs_horz =
4661 ps_ctxt->s_deblk_ctbrow_prms.pi1_ctb_row_qp = (WORD8 *)pu1_deblk_base + u4_size_bs_memory;
4664 ps_ctxt->s_deblk_ctbrow_prms.u4_qp_buffer_stride = (MAX_CTB_SIZE / 4) * u4_ctb_in_a_row;
4674 ps_ctxt->s_sao_ctxt_t.i4_top_luma_buf_size =
4676 ps_ctxt->s_sao_ctxt_t.i4_top_chroma_buf_size =
4678 ps_ctxt->s_sao_ctxt_t.i4_num_ctb_units =
4683 ps_ctxt->s_sao_ctxt_t.apu1_sao_src_frm_top_luma[i4_enc_frm_id] =
4685 ((ps_ctxt->s_sao_ctxt_t.i4_top_luma_buf_size +
4686 ps_ctxt->s_sao_ctxt_t.i4_top_chroma_buf_size) *
4691 ps_ctxt
4693 ((ps_ctxt->s_sao_ctxt_t.i4_top_luma_buf_size +
4694 ps_ctxt->s_sao_ctxt_t.i4_top_chroma_buf_size) *
4699 ps_ctxt->s_sao_ctxt_t.aps_frm_top_ctb_sao[i4_enc_frm_id] = (sao_enc_t *) (pu1_sao_base +
4700 ((ps_ctxt->s_sao_ctxt_t.i4_top_luma_buf_size + ps_ctxt->s_sao_ctxt_t.i4_top_chroma_buf_size)
4702 (ps_ctxt->s_sao_ctxt_t.i4_num_ctb_units * sizeof(sao_enc_t) *i4_num_bitrate_inst * i4_enc_frm_id));
4704 ps_ctxt->s_sao_ctxt_t.i4_ctb_size =
4706 ps_ctxt->s_sao_ctxt_t.u4_ctb_aligned_wd = u4_ctb_aligned_wd;
4712 ps_ctxt->i4_nbr_map_strd = MAX_PU_IN_CTB_ROW + 1 + 8;
4714 ps_ctxt->pu1_ctb_nbr_map = ps_ctxt->au1_nbr_ctb_map[0];
4716 ps_ctxt->i4_deblock_type = ps_init_prms->s_coding_tools_prms.i4_deblocking_type;
4719 ps_ctxt->pu1_ctb_nbr_map += ps_ctxt->i4_nbr_map_strd;
4720 ps_ctxt->pu1_ctb_nbr_map++;
4722 ps_ctxt->i4_cu_csbf_strd = MAX_TU_IN_CTB_ROW;
4724 CREATE_SUBBLOCK2CSBFID_MAP(gai4_subBlock2csbfId_map4x4TU, 1, 4, ps_ctxt->i4_cu_csbf_strd);
4726 CREATE_SUBBLOCK2CSBFID_MAP(gai4_subBlock2csbfId_map8x8TU, 4, 8, ps_ctxt->i4_cu_csbf_strd);
4729 gai4_subBlock2csbfId_map16x16TU, 16, 16, ps_ctxt->i4_cu_csbf_strd);
4732 gai4_subBlock2csbfId_map32x32TU, 64, 32, ps_ctxt->i4_cu_csbf_strd);
4735 ps_ctxt->as_cu_prms[0].i4_chrm_deq_coeff_strt_idx = (MAX_CU_SIZE * MAX_CU_SIZE);
4736 ps_ctxt->as_cu_prms[1].i4_chrm_deq_coeff_strt_idx = (MAX_CU_SIZE * MAX_CU_SIZE);
4740 ps_ctxt->pv_inter_rdopt_cu_mc_mvp =
4743 ps_ctxt->pv_inter_rdopt_cu_ntu = (pf_inter_rdopt_cu_ntu)ihevce_inter_rdopt_cu_ntu;
4746 if(ps_ctxt->i4_quality_preset == IHEVCE_QUALITY_P0)
4748 ps_ctxt->pv_inter_rdopt_cu_ntu =
4752 ps_ctxt->pv_intra_chroma_pred_mode_selector =
4754 ps_ctxt->pv_intra_rdopt_cu_ntu = (pf_intra_rdopt_cu_ntu)ihevce_intra_rdopt_cu_ntu;
4755 ps_ctxt->pv_final_rdopt_mode_prcs =
4757 ps_ctxt->pv_store_cu_results = (pf_store_cu_results)ihevce_store_cu_results;
4758 ps_ctxt->pv_enc_loop_cu_bot_copy = (pf_enc_loop_cu_bot_copy)ihevce_enc_loop_cu_bot_copy;
4759 ps_ctxt->pv_enc_loop_ctb_left_copy =
4773 ps_ctxt->s_chroma_rdopt_ctxt.as_chr_intra_satd_ctxt[i].pv_pred_data = pu1_base;
4785 ps_ctxt->pv_ref_sub_out = pu1_base;
4795 ps_ctxt->pv_ref_filt_out = pu1_base;
4800 if(ps_ctxt->i4_quality_preset == IHEVCE_QUALITY_P0)
4809 ps_ctxt->pv_cu_luma_recon = pu1_base;
4820 ps_ctxt->pv_cu_chrma_recon = pu1_base;
4826 if(ps_ctxt->i4_quality_preset == IHEVCE_QUALITY_P0)
4835 ps_ctxt->pv_CTB_pred_luma = pu1_base;
4845 ps_ctxt->pv_CTB_pred_chroma = pu1_base;
4856 ps_ctxt->pv_left_luma_data = pu1_base;
4867 ps_ctxt->pv_left_chrm_data = pu1_base;
4883 ps_ctxt->i4_max_num_inter_rdopt_cands = i4_num_bufs_per_thread - 4;
4885 ps_ctxt->s_pred_buf_data.u4_is_buf_in_use = UINT_MAX;
4893 ps_ctxt->s_pred_buf_data.apv_inter_pred_data[i] =
4895 ps_ctxt->s_pred_buf_data.u4_is_buf_in_use ^= (1 << i);
4910 ps_ctxt->pv_422_chroma_intra_pred_buf = pv_base;
4914 ps_ctxt->pv_422_chroma_intra_pred_buf = NULL;
4924 WORD32 i4_quality_preset = ps_ctxt->i4_quality_preset;
4930 ps_ctxt->as_cu_prms[0].s_recon_datastore.apv_luma_recon_bufs[0] =
4932 ps_ctxt->as_cu_prms[0].s_recon_datastore.apv_luma_recon_bufs[1] =
4934 ps_ctxt->as_cu_prms[1].s_recon_datastore.apv_luma_recon_bufs[0] =
4936 ps_ctxt->as_cu_prms[1].s_recon_datastore.apv_luma_recon_bufs[1] =
4946 ps_ctxt->as_cu_prms[0].s_recon_datastore.apv_chroma_recon_bufs[0] =
4948 ps_ctxt->as_cu_prms[1].s_recon_datastore.apv_chroma_recon_bufs[0] =
4951 ps_ctxt->as_cu_prms[0].s_recon_datastore.apv_chroma_recon_bufs[0] = NULL;
4952 ps_ctxt->as_cu_prms[1].s_recon_datastore.apv_chroma_recon_bufs[0] = NULL;
4956 ps_ctxt->as_cu_prms[0].s_recon_datastore.apv_chroma_recon_bufs[1] =
4958 ps_ctxt->as_cu_prms[0].s_recon_datastore.apv_chroma_recon_bufs[2] =
4960 ps_ctxt->as_cu_prms[1].s_recon_datastore.apv_chroma_recon_bufs[1] =
4962 ps_ctxt->as_cu_prms[1].s_recon_datastore.apv_chroma_recon_bufs[2] =
4965 ps_ctxt->as_cu_prms[0].s_recon_datastore.apv_chroma_recon_bufs[1] = NULL;
4966 ps_ctxt->as_cu_prms[0].s_recon_datastore.apv_chroma_recon_bufs[2] = NULL;
4967 ps_ctxt->as_cu_prms[1].s_recon_datastore.apv_chroma_recon_bufs[1] = NULL;
4968 ps_ctxt->as_cu_prms[1].s_recon_datastore.apv_chroma_recon_bufs[2] = NULL;
4976 ps_ctxt->as_cu_prms[0].s_recon_datastore.apv_chroma_recon_bufs[0] =
4978 ps_ctxt->as_cu_prms[1].s_recon_datastore.apv_chroma_recon_bufs[0] =
4981 ps_ctxt->as_cu_prms[0].s_recon_datastore.apv_chroma_recon_bufs[0] = NULL;
4982 ps_ctxt->as_cu_prms[1].s_recon_datastore.apv_chroma_recon_bufs[0] = NULL;
4986 ps_ctxt->as_cu_prms[0].s_recon_datastore.apv_chroma_recon_bufs[1] =
4988 ps_ctxt->as_cu_prms[0].s_recon_datastore.apv_chroma_recon_bufs[2] =
4990 ps_ctxt->as_cu_prms[1].s_recon_datastore.apv_chroma_recon_bufs[1] =
4992 ps_ctxt->as_cu_prms[1].s_recon_datastore.apv_chroma_recon_bufs[2] =
4995 ps_ctxt->as_cu_prms[0].s_recon_datastore.apv_chroma_recon_bufs[1] = NULL;
4996 ps_ctxt->as_cu_prms[0].s_recon_datastore.apv_chroma_recon_bufs[2] = NULL;
4997 ps_ctxt->as_cu_prms[1].s_recon_datastore.apv_chroma_recon_bufs[1] = NULL;
4998 ps_ctxt->as_cu_prms[1].s_recon_datastore.apv_chroma_recon_bufs[2] = NULL;
5006 ps_ctxt->as_cu_prms[0].s_recon_datastore.apv_chroma_recon_bufs[0] =
5008 ps_ctxt->as_cu_prms[1].s_recon_datastore.apv_chroma_recon_bufs[0] =
5011 ps_ctxt->as_cu_prms[0].s_recon_datastore.apv_chroma_recon_bufs[0] = NULL;
5012 ps_ctxt->as_cu_prms[1].s_recon_datastore.apv_chroma_recon_bufs[0] = NULL;
5016 ps_ctxt->as_cu_prms[0].s_recon_datastore.apv_chroma_recon_bufs[1] =
5018 ps_ctxt->as_cu_prms[0].s_recon_datastore.apv_chroma_recon_bufs[2] =
5020 ps_ctxt->as_cu_prms[1].s_recon_datastore.apv_chroma_recon_bufs[1] =
5022 ps_ctxt->as_cu_prms[1].s_recon_datastore.apv_chroma_recon_bufs[2] =
5025 ps_ctxt->as_cu_prms[0].s_recon_datastore.apv_chroma_recon_bufs[1] = NULL;
5026 ps_ctxt
5027 ps_ctxt->as_cu_prms[1].s_recon_datastore.apv_chroma_recon_bufs[1] = NULL;
5028 ps_ctxt->as_cu_prms[1].s_recon_datastore.apv_chroma_recon_bufs[2] = NULL;
5036 ps_ctxt->as_cu_prms[0].s_recon_datastore.apv_chroma_recon_bufs[0] =
5038 ps_ctxt->as_cu_prms[1].s_recon_datastore.apv_chroma_recon_bufs[0] =
5041 ps_ctxt->as_cu_prms[0].s_recon_datastore.apv_chroma_recon_bufs[0] = NULL;
5042 ps_ctxt->as_cu_prms[1].s_recon_datastore.apv_chroma_recon_bufs[0] = NULL;
5046 ps_ctxt->as_cu_prms[0].s_recon_datastore.apv_chroma_recon_bufs[1] =
5048 ps_ctxt->as_cu_prms[0].s_recon_datastore.apv_chroma_recon_bufs[2] =
5050 ps_ctxt->as_cu_prms[1].s_recon_datastore.apv_chroma_recon_bufs[1] =
5052 ps_ctxt->as_cu_prms[1].s_recon_datastore.apv_chroma_recon_bufs[2] =
5055 ps_ctxt->as_cu_prms[0].s_recon_datastore.apv_chroma_recon_bufs[1] = NULL;
5056 ps_ctxt->as_cu_prms[0].s_recon_datastore.apv_chroma_recon_bufs[2] = NULL;
5057 ps_ctxt->as_cu_prms[1].s_recon_datastore.apv_chroma_recon_bufs[1] = NULL;
5058 ps_ctxt->as_cu_prms[1].s_recon_datastore.apv_chroma_recon_bufs[2] = NULL;
5066 ps_ctxt->as_cu_prms[0].s_recon_datastore.apv_chroma_recon_bufs[0] =
5068 ps_ctxt->as_cu_prms[1].s_recon_datastore.apv_chroma_recon_bufs[0] =
5071 ps_ctxt->as_cu_prms[0].s_recon_datastore.apv_chroma_recon_bufs[0] = NULL;
5072 ps_ctxt->as_cu_prms[1].s_recon_datastore.apv_chroma_recon_bufs[0] = NULL;
5076 ps_ctxt->as_cu_prms[0].s_recon_datastore.apv_chroma_recon_bufs[1] =
5078 ps_ctxt->as_cu_prms[0].s_recon_datastore.apv_chroma_recon_bufs[2] =
5080 ps_ctxt->as_cu_prms[1].s_recon_datastore.apv_chroma_recon_bufs[1] =
5082 ps_ctxt->as_cu_prms[1].s_recon_datastore.apv_chroma_recon_bufs[2] =
5085 ps_ctxt->as_cu_prms[0].s_recon_datastore.apv_chroma_recon_bufs[1] = NULL;
5086 ps_ctxt->as_cu_prms[0].s_recon_datastore.apv_chroma_recon_bufs[2] = NULL;
5087 ps_ctxt->as_cu_prms[1].s_recon_datastore.apv_chroma_recon_bufs[1] = NULL;
5088 ps_ctxt->as_cu_prms[1].s_recon_datastore.apv_chroma_recon_bufs[2] = NULL;
5096 ps_ctxt->as_cu_prms[0].s_recon_datastore.i4_lumaRecon_stride = MAX_CU_SIZE;
5097 ps_ctxt->as_cu_prms[1].s_recon_datastore.i4_lumaRecon_stride = MAX_CU_SIZE;
5098 ps_ctxt->as_cu_prms[0].s_recon_datastore.i4_chromaRecon_stride = MAX_CU_SIZE;
5099 ps_ctxt->as_cu_prms[1].s_recon_datastore.i4_chromaRecon_stride = MAX_CU_SIZE;
5110 ps_ctxt->i4_zcbf_rdo_level = ZCBF_ENABLE;
5112 if(ps_ctxt->i4_quality_preset < IHEVCE_QUALITY_P3)
5114 ps_ctxt->i4_quant_rounding_level = CU_LEVEL_QUANT_ROUNDING;
5115 ps_ctxt->i4_chroma_quant_rounding_level = CHROMA_QUANT_ROUNDING;
5116 ps_ctxt->i4_rdoq_level = ALL_CAND_RDOQ;
5117 ps_ctxt->i4_sbh_level = ALL_CAND_SBH;
5119 else if(ps_ctxt->i4_quality_preset == IHEVCE_QUALITY_P3)
5121 ps_ctxt->i4_quant_rounding_level = FIXED_QUANT_ROUNDING;
5122 ps_ctxt->i4_chroma_quant_rounding_level = FIXED_QUANT_ROUNDING;
5123 ps_ctxt->i4_rdoq_level = NO_RDOQ;
5124 ps_ctxt->i4_sbh_level = NO_SBH;
5128 ps_ctxt->i4_quant_rounding_level = FIXED_QUANT_ROUNDING;
5129 ps_ctxt->i4_chroma_quant_rounding_level = FIXED_QUANT_ROUNDING;
5130 ps_ctxt->i4_rdoq_level = NO_RDOQ;
5131 ps_ctxt->i4_sbh_level = NO_SBH;
5135 ps_ctxt->i4_quant_rounding_level = FIXED_QUANT_ROUNDING;
5136 ps_ctxt->i4_chroma_quant_rounding_level = FIXED_QUANT_ROUNDING;
5142 ps_ctxt->i4_rdoq_level = NO_RDOQ;
5146 ps_ctxt->i4_rdoq_level = NO_RDOQ;
5150 ps_ctxt->i4_sbh_level = NO_SBH;
5155 ps_ctxt->pi4_quant_round_factor_cu_ctb_0_1[0] = &ps_ctxt->i4_quant_round_4x4[0][0];
5156 ps_ctxt->pi4_quant_round_factor_cu_ctb_0_1[1] = &ps_ctxt->i4_quant_round_8x8[0][0];
5157 ps_ctxt->pi4_quant_round_factor_cu_ctb_0_1[2] = &ps_ctxt->i4_quant_round_16x16[0][0];
5158 ps_ctxt->pi4_quant_round_factor_cu_ctb_0_1[4] = &ps_ctxt->i4_quant_round_32x32[0][0];
5160 ps_ctxt->pi4_quant_round_factor_cu_ctb_1_2[0] = &ps_ctxt->i4_quant_round_4x4[1][0];
5161 ps_ctxt->pi4_quant_round_factor_cu_ctb_1_2[1] = &ps_ctxt->i4_quant_round_8x8[1][0];
5162 ps_ctxt->pi4_quant_round_factor_cu_ctb_1_2[2] = &ps_ctxt->i4_quant_round_16x16[1][0];
5163 ps_ctxt->pi4_quant_round_factor_cu_ctb_1_2[4] = &ps_ctxt->i4_quant_round_32x32[1][0];
5165 ps_ctxt->pi4_quant_round_factor_cr_cu_ctb_0_1[0] = &ps_ctxt->i4_quant_round_cr_4x4[0][0];
5166 ps_ctxt->pi4_quant_round_factor_cr_cu_ctb_0_1[1] = &ps_ctxt->i4_quant_round_cr_8x8[0][0];
5167 ps_ctxt->pi4_quant_round_factor_cr_cu_ctb_0_1[2] = &ps_ctxt->i4_quant_round_cr_16x16[0][0];
5169 ps_ctxt->pi4_quant_round_factor_cr_cu_ctb_1_2[0] = &ps_ctxt->i4_quant_round_cr_4x4[1][0];
5170 ps_ctxt->pi4_quant_round_factor_cr_cu_ctb_1_2[1] = &ps_ctxt->i4_quant_round_cr_8x8[1][0];
5171 ps_ctxt->pi4_quant_round_factor_cr_cu_ctb_1_2[2] = &ps_ctxt->i4_quant_round_cr_16x16[1][0];
5180 ps_ctxt->s_rdoq_sbh_ctxt.i4_perform_best_cand_rdoq =
5181 (ps_ctxt->i4_rdoq_level == BEST_CAND_RDOQ);
5184 ps_ctxt->s_rdoq_sbh_ctxt.i4_perform_best_cand_rdoq =
5185 ps_ctxt->s_rdoq_sbh_ctxt.i4_perform_best_cand_rdoq ||
5186 ((BEST_CAND_SBH == ps_ctxt->i4_sbh_level) &&
5187 (ALL_CAND_RDOQ == ps_ctxt->i4_rdoq_level));
5189 ps_ctxt->s_rdoq_sbh_ctxt.i4_perform_best_cand_sbh =
5190 (ps_ctxt->i4_sbh_level == BEST_CAND_SBH);
5199 ps_ctxt->s_rdoq_sbh_ctxt.i4_perform_best_cand_sbh =
5200 ps_ctxt->s_rdoq_sbh_ctxt.i4_perform_best_cand_sbh ||
5201 ((BEST_CAND_RDOQ == ps_ctxt->i4_rdoq_level) &&
5202 (ALL_CAND_SBH == ps_ctxt->i4_sbh_level));
5207 ps_ctxt->s_rdoq_sbh_ctxt.i4_perform_all_cand_rdoq =
5208 (ps_ctxt->i4_rdoq_level == ALL_CAND_RDOQ);
5209 ps_ctxt->s_rdoq_sbh_ctxt.i4_perform_all_cand_sbh =
5210 (ps_ctxt->i4_sbh_level == ALL_CAND_SBH);
5211 ps_ctxt->s_rdoq_sbh_ctxt.i4_bit_depth =
5219 if(ps_ctxt->i4_rdoq_level == NO_RDOQ)
5221 ps_ctxt->apf_quant_iquant_ssd[0] =
5223 ps_ctxt->apf_quant_iquant_ssd[2] = ps_func_selector->ihevc_quant_iquant_fptr;
5227 ps_ctxt->apf_quant_iquant_ssd[0] =
5229 ps_ctxt->apf_quant_iquant_ssd[2] =
5234 if(ps_ctxt->i4_quant_rounding_level != FIXED_QUANT_ROUNDING)
5236 ps_ctxt->apf_quant_iquant_ssd[1] =
5238 ps_ctxt->apf_quant_iquant_ssd[3] =
5243 ps_ctxt->apf_quant_iquant_ssd[1] =
5245 ps_ctxt->apf_quant_iquant_ssd[3] = ps_func_selector->ihevc_quant_iquant_fptr;
5250 if(ps_ctxt->i4_rdoq_level == NO_RDOQ)
5252 ps_ctxt->apf_quant_iquant_ssd[0] =
5254 ps_ctxt->apf_quant_iquant_ssd[2] =
5259 ps_ctxt->apf_quant_iquant_ssd[0] =
5261 ps_ctxt->apf_quant_iquant_ssd[2] =
5266 if(ps_ctxt->i4_quant_rounding_level != FIXED_QUANT_ROUNDING)
5268 ps_ctxt->apf_quant_iquant_ssd[1] =
5270 ps_ctxt->apf_quant_iquant_ssd[3] =
5275 ps_ctxt->apf_quant_iquant_ssd[1] =
5277 ps_ctxt->apf_quant_iquant_ssd[3] =
5282 ps_ctxt->s_sao_ctxt_t.apf_sao_luma[0] =
5284 ps_ctxt->s_sao_ctxt_t.apf_sao_luma[1] =
5286 ps_ctxt->s_sao_ctxt_t.apf_sao_luma[2] =
5288 ps_ctxt->s_sao_ctxt_t.apf_sao_luma[3] =
5291 ps_ctxt->s_sao_ctxt_t.apf_sao_chroma[0] =
5293 ps_ctxt->s_sao_ctxt_t.apf_sao_chroma[1] =
5295 ps_ctxt->s_sao_ctxt_t.apf_sao_chroma[2] =
5297 ps_ctxt->s_sao_ctxt_t.apf_sao_chroma[3] =
5300 ps_ctxt->apf_it_recon[0] = ps_func_selector->ihevc_itrans_recon_4x4_ttype1_fptr;
5301 ps_ctxt->apf_it_recon[1] = ps_func_selector->ihevc_itrans_recon_4x4_fptr;
5302 ps_ctxt->apf_it_recon[2] = ps_func_selector->ihevc_itrans_recon_8x8_fptr;
5303 ps_ctxt->apf_it_recon[3] = ps_func_selector->ihevc_itrans_recon_16x16_fptr;
5304 ps_ctxt->apf_it_recon[4] = ps_func_selector->ihevc_itrans_recon_32x32_fptr;
5306 ps_ctxt->apf_chrm_it_recon[0] = ps_func_selector->ihevc_chroma_itrans_recon_4x4_fptr;
5307 ps_ctxt->apf_chrm_it_recon[1] = ps_func_selector->ihevc_chroma_itrans_recon_8x8_fptr;
5308 ps_ctxt->apf_chrm_it_recon[2] = ps_func_selector->ihevc_chroma_itrans_recon_16x16_fptr;
5310 ps_ctxt->apf_resd_trns[0] = ps_func_selector->ihevc_resi_trans_4x4_ttype1_fptr;
5311 ps_ctxt->apf_resd_trns[1] = ps_func_selector->ihevc_resi_trans_4x4_fptr;
5312 ps_ctxt->apf_resd_trns[2] = ps_func_selector->ihevc_resi_trans_8x8_fptr;
5313 ps_ctxt->apf_resd_trns[3] = ps_func_selector->ihevc_resi_trans_16x16_fptr;
5314 ps_ctxt->apf_resd_trns[4] = ps_func_selector->ihevc_resi_trans_32x32_fptr;
5316 ps_ctxt->apf_chrm_resd_trns[0] = ps_func_selector->ihevc_resi_trans_4x4_fptr;
5317 ps_ctxt->apf_chrm_resd_trns[1] = ps_func_selector->ihevc_resi_trans_8x8_fptr;
5318 ps_ctxt->apf_chrm_resd_trns[2] = ps_func_selector->ihevc_resi_trans_16x16_fptr;
5320 ps_ctxt->apf_lum_ip[IP_FUNC_MODE_0] =
5322 ps_ctxt->apf_lum_ip[IP_FUNC_MODE_1] = ps_func_selector->ihevc_intra_pred_luma_dc_fptr;
5323 ps_ctxt->apf_lum_ip[IP_FUNC_MODE_2] =
5325 ps_ctxt->apf_lum_ip[IP_FUNC_MODE_3TO9] =
5327 ps_ctxt->apf_lum_ip[IP_FUNC_MODE_10] =
5329 ps_ctxt->apf_lum_ip[IP_FUNC_MODE_11TO17] =
5331 ps_ctxt->apf_lum_ip[IP_FUNC_MODE_18_34] =
5333 ps_ctxt->apf_lum_ip[IP_FUNC_MODE_19TO25] =
5335 ps_ctxt->apf_lum_ip[IP_FUNC_MODE_26] = ps_func_selector->ihevc_intra_pred_luma_ver_fptr;
5336 ps_ctxt->apf_lum_ip[IP_FUNC_MODE_27TO33] =
5339 ps_ctxt->apf_chrm_ip[IP_FUNC_MODE_0] =
5341 ps_ctxt->apf_chrm_ip[IP_FUNC_MODE_1] =
5343 ps_ctxt->apf_chrm_ip[IP_FUNC_MODE_2] =
5345 ps_ctxt->apf_chrm_ip[IP_FUNC_MODE_3TO9] =
5347 ps_ctxt->apf_chrm_ip[IP_FUNC_MODE_10] =
5349 ps_ctxt->apf_chrm_ip[IP_FUNC_MODE_11TO17] =
5351 ps_ctxt->apf_chrm_ip[IP_FUNC_MODE_18_34] =
5353 ps_ctxt->apf_chrm_ip[IP_FUNC_MODE_19TO25] =
5355 ps_ctxt->apf_chrm_ip[IP_FUNC_MODE_26] =
5357 ps_ctxt->apf_chrm_ip[IP_FUNC_MODE_27TO33] =
5360 ps_ctxt->apf_chrm_resd_trns_had[0] =
5361 (pf_res_trans_luma_had_chroma)ps_ctxt->s_cmn_opt_func.pf_chroma_HAD_4x4_8bit;
5362 ps_ctxt->apf_chrm_resd_trns_had[1] =
5363 (pf_res_trans_luma_had_chroma)ps_ctxt->s_cmn_opt_func.pf_chroma_HAD_8x8_8bit;
5364 ps_ctxt->apf_chrm_resd_trns_had[2] =
5365 (pf_res_trans_luma_had_chroma)ps_ctxt->s_cmn_opt_func.pf_chroma_HAD_16x16_8bit;
5371 ps_ctxt->api2_scal_mat[0] = (WORD16 *)&gi2_flat_scale_mat_4x4[0];
5372 ps_ctxt->api2_scal_mat[1] = (WORD16 *)&gi2_flat_scale_mat_4x4[0];
5373 ps_ctxt->api2_scal_mat[2] = (WORD16 *)&gi2_flat_scale_mat_8x8[0];
5374 ps_ctxt->api2_scal_mat[3] = (WORD16 *)&gi2_flat_scale_mat_16x16[0];
5375 ps_ctxt->api2_scal_mat[4] = (WORD16 *)&gi2_flat_scale_mat_32x32[0];
5377 ps_ctxt->api2_scal_mat[5] = (WORD16 *)&gi2_flat_scale_mat_4x4[0];
5378 ps_ctxt->api2_scal_mat[6] = (WORD16 *)&gi2_flat_scale_mat_4x4[0];
5379 ps_ctxt->api2_scal_mat[7] = (WORD16 *)&gi2_flat_scale_mat_8x8[0];
5380 ps_ctxt->api2_scal_mat[8] = (WORD16 *)&gi2_flat_scale_mat_16x16[0];
5381 ps_ctxt->api2_scal_mat[9] = (WORD16 *)&gi2_flat_scale_mat_32x32[0];
5384 ps_ctxt->api2_rescal_mat[0] = (WORD16 *)&gi2_flat_rescale_mat_4x4[0];
5385 ps_ctxt->api2_rescal_mat[1] = (WORD16 *)&gi2_flat_rescale_mat_4x4[0];
5386 ps_ctxt->api2_rescal_mat[2] = (WORD16 *)&gi2_flat_rescale_mat_8x8[0];
5387 ps_ctxt->api2_rescal_mat[3] = (WORD16 *)&gi2_flat_rescale_mat_16x16[0];
5388 ps_ctxt->api2_rescal_mat[4] = (WORD16 *)&gi2_flat_rescale_mat_32x32[0];
5390 ps_ctxt->api2_rescal_mat[5] = (WORD16 *)&gi2_flat_rescale_mat_4x4[0];
5391 ps_ctxt->api2_rescal_mat[6] = (WORD16 *)&gi2_flat_rescale_mat_4x4[0];
5392 ps_ctxt->api2_rescal_mat[7] = (WORD16 *)&gi2_flat_rescale_mat_8x8[0];
5393 ps_ctxt->api2_rescal_mat[8] = (WORD16 *)&gi2_flat_rescale_mat_16x16[0];
5394 ps_ctxt->api2_rescal_mat[9] = (WORD16 *)&gi2_flat_rescale_mat_32x32[0];
5399 ps_ctxt->api2_scal_mat[0] = (WORD16 *)&gi2_flat_scale_mat_4x4[0];
5400 ps_ctxt->api2_scal_mat[1] = (WORD16 *)&gi2_flat_scale_mat_4x4[0];
5401 ps_ctxt->api2_scal_mat[2] = (WORD16 *)&gi2_intra_default_scale_mat_8x8[0];
5402 ps_ctxt->api2_scal_mat[3] = (WORD16 *)&gi2_intra_default_scale_mat_16x16[0];
5403 ps_ctxt->api2_scal_mat[4] = (WORD16 *)&gi2_intra_default_scale_mat_32x32[0];
5405 ps_ctxt->api2_scal_mat[5] = (WORD16 *)&gi2_flat_scale_mat_4x4[0];
5406 ps_ctxt->api2_scal_mat[6] = (WORD16 *)&gi2_flat_scale_mat_4x4[0];
5407 ps_ctxt->api2_scal_mat[7] = (WORD16 *)&gi2_inter_default_scale_mat_8x8[0];
5408 ps_ctxt->api2_scal_mat[8] = (WORD16 *)&gi2_inter_default_scale_mat_16x16[0];
5409 ps_ctxt->api2_scal_mat[9] = (WORD16 *)&gi2_inter_default_scale_mat_32x32[0];
5412 ps_ctxt->api2_rescal_mat[0] = (WORD16 *)&gi2_flat_rescale_mat_4x4[0];
5413 ps_ctxt->api2_rescal_mat[1] = (WORD16 *)&gi2_flat_rescale_mat_4x4[0];
5414 ps_ctxt->api2_rescal_mat[2] = (WORD16 *)&gi2_intra_default_rescale_mat_8x8[0];
5415 ps_ctxt->api2_rescal_mat[3] = (WORD16 *)&gi2_intra_default_rescale_mat_16x16[0];
5416 ps_ctxt->api2_rescal_mat[4] = (WORD16 *)&gi2_intra_default_rescale_mat_32x32[0];
5418 ps_ctxt->api2_rescal_mat[5] = (WORD16 *)&gi2_flat_rescale_mat_4x4[0];
5419 ps_ctxt->api2_rescal_mat[6] = (WORD16 *)&gi2_flat_rescale_mat_4x4[0];
5420 ps_ctxt->api2_rescal_mat[7] = (WORD16 *)&gi2_inter_default_rescale_mat_8x8[0];
5421 ps_ctxt->api2_rescal_mat[8] = (WORD16 *)&gi2_inter_default_rescale_mat_16x16[0];
5422 ps_ctxt->api2_rescal_mat[9] = (WORD16 *)&gi2_inter_default_rescale_mat_32x32[0];
5430 ps_ctxt->s_cu_final_recon_flags.u1_eval_header_data = 0;
5431 ps_ctxt->s_cu_final_recon_flags.u1_eval_luma_pred_data = 0;
5432 ps_ctxt->s_cu_final_recon_flags.u1_eval_recon_data = 1;
5434 switch(ps_ctxt->i4_quality_preset)
5438 ps_ctxt->i4_max_merge_candidates = 5;
5439 ps_ctxt->i4_use_satd_for_merge_eval = 1;
5440 ps_ctxt->u1_use_top_at_ctb_boundary = 1;
5441 ps_ctxt->u1_use_early_cbf_data = 0;
5442 ps_ctxt->s_chroma_rdopt_ctxt.u1_eval_chrm_rdopt = ENABLE_CHROMA_RDOPT_EVAL_IN_PQ;
5443 ps_ctxt->s_chroma_rdopt_ctxt.u1_eval_chrm_satd =
5450 ps_ctxt->i4_max_merge_candidates = 5;
5451 ps_ctxt->i4_use_satd_for_merge_eval = 1;
5452 ps_ctxt->u1_use_top_at_ctb_boundary = 1;
5453 ps_ctxt->u1_use_early_cbf_data = 0;
5455 ps_ctxt->s_chroma_rdopt_ctxt.u1_eval_chrm_rdopt = ENABLE_CHROMA_RDOPT_EVAL_IN_HQ;
5456 ps_ctxt->s_chroma_rdopt_ctxt.u1_eval_chrm_satd =
5463 ps_ctxt->i4_max_merge_candidates = 3;
5464 ps_ctxt->i4_use_satd_for_merge_eval = 1;
5465 ps_ctxt->u1_use_top_at_ctb_boundary = 0;
5467 ps_ctxt->u1_use_early_cbf_data = 0;
5468 ps_ctxt->s_chroma_rdopt_ctxt.u1_eval_chrm_rdopt = ENABLE_CHROMA_RDOPT_EVAL_IN_MS;
5469 ps_ctxt->s_chroma_rdopt_ctxt.u1_eval_chrm_satd =
5476 ps_ctxt->i4_max_merge_candidates = 2;
5477 ps_ctxt->i4_use_satd_for_merge_eval = 1;
5478 ps_ctxt->u1_use_top_at_ctb_boundary = 0;
5479 ps_ctxt->u1_use_early_cbf_data = 0;
5480 ps_ctxt->s_chroma_rdopt_ctxt.u1_eval_chrm_rdopt = ENABLE_CHROMA_RDOPT_EVAL_IN_HS;
5481 ps_ctxt->s_chroma_rdopt_ctxt.u1_eval_chrm_satd =
5488 ps_ctxt->i4_max_merge_candidates = 2;
5489 ps_ctxt->i4_use_satd_for_merge_eval = 0;
5490 ps_ctxt->u1_use_top_at_ctb_boundary = 0;
5491 ps_ctxt->u1_use_early_cbf_data = 0;
5492 ps_ctxt->s_chroma_rdopt_ctxt.u1_eval_chrm_rdopt = ENABLE_CHROMA_RDOPT_EVAL_IN_XS;
5493 ps_ctxt->s_chroma_rdopt_ctxt.u1_eval_chrm_satd =
5500 ps_ctxt->i4_max_merge_candidates = 2;
5501 ps_ctxt->i4_use_satd_for_merge_eval = 0;
5502 ps_ctxt->u1_use_top_at_ctb_boundary = 0;
5503 ps_ctxt->u1_use_early_cbf_data = EARLY_CBF_ON;
5513 ps_ctxt->i4_max_merge_candidates = 0;
5516 ps_ctxt->s_cu_final_recon_flags.u1_eval_chroma_pred_data =
5517 !ps_ctxt->s_chroma_rdopt_ctxt.u1_eval_chrm_rdopt;
5550 ps_ctxt->aaps_enc_loop_rc_params[i4_enc_frm_id][i] = ps_enc_loop_rc_params;
5557 ps_ctxt->s_chroma_rdopt_ctxt.u1_eval_chrm_satd = 0;
5560 ps_ctxt->s_chroma_rdopt_ctxt.as_chr_intra_satd_ctxt[TU_EQ_CU].i4_iq_buff_stride =
5562 ps_ctxt->s_chroma_rdopt_ctxt.as_chr_intra_satd_ctxt[TU_EQ_CU_DIV2].i4_iq_buff_stride =
5565 ps_ctxt->s_chroma_rdopt_ctxt.as_chr_intra_satd_ctxt[TU_EQ_CU].i4_pred_stride = MAX_TU_SIZE
5567 ps_ctxt->s_chroma_rdopt_ctxt.as_chr_intra_satd_ctxt[TU_EQ_CU_DIV2].i4_pred_stride =
5572 ps_ctxt->pi4_offset_for_last_cu_qp = &ps_master_ctxt->ai4_offset_for_last_cu_qp[0];
5574 ps_ctxt->i4_qp_mod = ps_init_prms->s_config_prms.i4_cu_level_rc & 1;
5584 ps_ctxt->u1_enable_psyRDOPT = 1;
5585 ps_ctxt->u4_psy_strength = psy_strength >> BITPOS_IN_VQ_TOGGLE_FOR_ENABLING_PSYRDOPT_1;
5588 ps_ctxt->u1_enable_psyRDOPT = 0;
5589 ps_ctxt->u4_psy_strength = 0;
5593 ps_ctxt->u1_is_stasino_enabled =
5599 ps_ctxt->u1_max_inter_tr_depth = ps_init_prms->s_config_prms.i4_max_tr_tree_depth_nI;
5600 ps_ctxt->u1_max_intra_tr_depth = ps_init_prms->s_config_prms.i4_max_tr_tree_depth_I;
5601 ps_ctxt++;
5943 ihevce_enc_loop_ctxt_t *ps_ctxt;
5976 ps_ctxt = ps_master_ctxt->aps_enc_loop_thrd_ctxt[i4_thrd_id];
5979 ps_ctxt->s_sao_ctxt_t.ps_pps = ps_pps;
5980 ps_ctxt->s_sao_ctxt_t.ps_sps = ps_sps;
5981 ps_ctxt->s_sao_ctxt_t.ps_slice_hdr = ps_slice_hdr;
5984 ps_ctxt->i4_bitrate_instance_num = i4_bitrate_instance_num;
5985 ps_ctxt->i4_num_bitrates = i4_num_bitrates;
5986 ps_ctxt->i4_chroma_format = ps_enc_ctxt->ps_stat_prms->s_src_prms.i4_chr_format;
5987 ps_ctxt->i4_is_first_query = 1;
5988 ps_ctxt->i4_is_ctb_qp_modified = 0;
5994 ps_ctxt->i4_enc_frm_id = 0;
5999 ps_ctxt->i4_enc_frm_id = i4_enc_frm_id;
6038 ps_ctxt->u4_total_cu_bits = 0;
6039 ps_ctxt->u4_total_cu_hdr_bits = 0;
6041 ps_ctxt->u4_cu_tot_bits_into_qscale = 0;
6042 ps_ctxt->u4_cu_tot_bits = 0;
6043 ps_ctxt->u4_total_cu_bits_mul_qs = 0;
6044 ps_ctxt->i4_display_num = i4_display_num;
6045 ps_ctxt->i4_sub_pic_level_rc = ps_enc_ctxt->s_multi_thrd.i4_in_frame_rc_enabled;
6047 //ps_ctxt->i4_num_ctb_for_out_scale = (10 * i4_tot_frame_ctb)/100 ;
6048 ps_ctxt->i4_num_ctb_for_out_scale = (UPDATE_QP_AT_CTB * i4_tot_frame_ctb) / 100;
6050 ps_ctxt->i4_cu_qp_sub_pic_rc = (1 << QP_LEVEL_MOD_ACT_FACTOR);
6052 ps_ctxt->i8_frame_l1_ipe_sad =
6054 ps_ctxt->i8_frame_l0_ipe_satd =
6056 ps_ctxt->i8_frame_l1_me_sad =
6058 ps_ctxt->i8_frame_l1_activity_fact =
6060 if(ps_ctxt->i4_sub_pic_level_rc)
6064 .ai4_frame_bits_estimated[ps_ctxt->i4_bitrate_instance_num] != 0);
6066 ps_ctxt->ai4_frame_bits_estimated[ps_ctxt->i4_enc_frm_id]
6067 [ps_ctxt->i4_bitrate_instance_num] =
6069 .ai4_frame_bits_estimated[ps_ctxt->i4_bitrate_instance_num];
6073 ps_ctxt->i4_is_I_scenecut =
6078 ps_ctxt->i4_is_non_I_scenecut =
6080 (ps_ctxt->i4_is_I_scenecut == 0));
6082 /*ps_ctxt->i4_is_I_only_scd = ps_curr_inp_prms->ps_curr_inp->s_lap_out.i4_is_I_only_scd;
6083 ps_ctxt->i4_is_non_I_scd = ps_curr_inp_prms->ps_curr_inp->s_lap_out.i4_is_non_I_scd;*/
6084 ps_ctxt->i4_is_model_valid =
6094 ps_ctxt->u1_is_input_data_hbd = (ps_sps->i1_bit_depth_luma_minus8 > 0);
6096 ps_ctxt->u1_bit_depth = ps_sps->i1_bit_depth_luma_minus8 + 8;
6098 ps_ctxt->s_mc_ctxt.i4_bit_depth = ps_ctxt->u1_bit_depth;
6099 ps_ctxt->s_mc_ctxt.u1_chroma_array_type = ps_ctxt->u1_chroma_array_type;
6102 ps_ctxt->i4_chroma_qp_offset = chroma_qp_offset;
6103 ps_ctxt->i1_cu_qp_delta_enable = ps_pps->i1_cu_qp_delta_enabled_flag;
6104 ps_ctxt->i1_entropy_coding_sync_enabled_flag = ps_pps->i1_entropy_coding_sync_enabled_flag;
6106 ps_ctxt->i4_is_ref_pic = ps_curr_inp_prms->ps_curr_inp->s_lap_out.i4_is_ref_pic;
6107 ps_ctxt->i4_temporal_layer = ps_curr_inp_prms->ps_curr_inp->s_lap_out.i4_temporal_lyr_id;
6108 ps_ctxt->i4_use_const_lamda_modifier = USE_CONSTANT_LAMBDA_MODIFIER;
6109 ps_ctxt->i4_use_const_lamda_modifier =
6110 ps_ctxt->i4_use_const_lamda_modifier ||
6123 ps_ctxt->f_i_pic_lamda_modifier =
6127 ps_ctxt->i4_frame_qp = i4_frm_qp;
6128 ps_ctxt->i4_frame_mod_qp = i4_frm_qp;
6129 ps_ctxt->i4_cu_qp = i4_frm_qp;
6130 ps_ctxt->i4_prev_cu_qp = i4_frm_qp;
6131 ps_ctxt->i4_chrm_cu_qp =
6132 (ps_ctxt->u1_chroma_array_type == 2)
6136 ps_ctxt->i4_cu_qp_div6 = (i4_frm_qp + (6 * (ps_ctxt->u1_bit_depth - 8))) / 6;
6139 ps_ctxt->i4_cu_qp_mod6 = (i4_frm_qp + (6 * (ps_ctxt->u1_bit_depth - 8))) % 6;
6141 ps_ctxt->i4_chrm_cu_qp_div6 =
6142 (ps_ctxt->i4_chrm_cu_qp + (6 * (ps_ctxt->u1_bit_depth - 8))) / 6;
6143 ps_ctxt->i4_chrm_cu_qp_mod6 =
6144 (ps_ctxt->i4_chrm_cu_qp + (6 * (ps_ctxt->u1_bit_depth - 8))) % 6;
6150 ps_ctxt->i4_quant_rnd_factor[PRED_MODE_INTER] = 85
6155 ps_ctxt->i4_quant_rnd_factor[PRED_MODE_INTER] = (1 << QUANT_ROUND_FACTOR_Q) / 3;
6161 ps_ctxt->i4_quant_rnd_factor[PRED_MODE_INTRA] = 171
6167 ps_ctxt->i4_quant_rnd_factor[PRED_MODE_INTRA] =
6168 ps_ctxt->i4_quant_rnd_factor[PRED_MODE_INTER];
6172 ps_ctxt->i1_strong_intra_smoothing_enable_flag = i1_strong_intra_smoothing_enable_flag;
6174 ps_ctxt->i1_slice_type = i1_slice_type;
6177 ps_ctxt->s_mc_ctxt.ps_ref_list = aps_ref_list;
6178 ps_ctxt->s_mc_ctxt.i1_weighted_pred_flag = i1_weighted_pred_flag;
6179 ps_ctxt->s_mc_ctxt.i1_weighted_bipred_flag = i1_weighted_bipred_flag;
6180 ps_ctxt->s_mc_ctxt.i4_log2_luma_wght_denom = log2_luma_wght_denom;
6181 ps_ctxt->s_mc_ctxt.i4_log2_chroma_wght_denom = log2_chroma_wght_denom;
6184 ps_ctxt->s_mv_pred_ctxt.ps_ref_list = aps_ref_list;
6185 ps_ctxt->s_mv_pred_ctxt.ps_slice_hdr = ps_slice_hdr;
6186 ps_ctxt->s_mv_pred_ctxt.ps_sps = ps_sps;
6187 ps_ctxt->s_mv_pred_ctxt.i4_log2_parallel_merge_level_minus2 =
6191 if(ps_ctxt->s_mv_pred_ctxt.ps_slice_hdr->i1_slice_temporal_mvp_enable_flag)
6193 if((ps_ctxt->s_mv_pred_ctxt.ps_slice_hdr->i1_num_ref_idx_l1_active > 0) &&
6194 (ps_ctxt->s_mv_pred_ctxt.ps_ref_list[1][0]->i4_frame_qp <
6195 ps_ctxt->s_mv_pred_ctxt.ps_ref_list[0][0]->i4_frame_qp))
6197 ps_ctxt->s_mv_pred_ctxt.ps_slice_hdr->i1_collocated_from_l0_flag = 1;
6202 ps_ctxt->s_deblk_prms.i4_beta_offset_div2 = ps_slice_hdr->i1_beta_offset_div2;
6203 ps_ctxt->s_deblk_prms.i4_tc_offset_div2 = ps_slice_hdr->i1_tc_offset_div2;
6205 ps_ctxt->s_deblk_prms.i4_cb_qp_indx_offset = ps_pps->i1_pic_cb_qp_offset;
6207 ps_ctxt->s_deblk_prms.i4_cr_qp_indx_offset = ps_pps->i1_pic_cr_qp_offset;
6209 ps_ctxt->aaps_enc_loop_rc_params[ps_ctxt->i4_enc_frm_id][i4_bitrate_instance_num]
6211 ps_ctxt->aaps_enc_loop_rc_params[ps_ctxt->i4_enc_frm_id][i4_bitrate_instance_num]
6213 ps_ctxt->aaps_enc_loop_rc_params[ps_ctxt->i4_enc_frm_id][i4_bitrate_instance_num]
6215 ps_ctxt->aaps_enc_loop_rc_params[ps_ctxt->i4_enc_frm_id][i4_bitrate_instance_num]
6217 ps_ctxt->aaps_enc_loop_rc_params[ps_ctxt->i4_enc_frm_id][i4_bitrate_instance_num]
6220 ps_ctxt->aaps_enc_loop_rc_params[ps_ctxt->i4_enc_frm_id][i4_bitrate_instance_num]
6222 ps_ctxt->aaps_enc_loop_rc_params[ps_ctxt->i4_enc_frm_id][i4_bitrate_instance_num]
6224 ps_ctxt->aaps_enc_loop_rc_params[ps_ctxt->i4_enc_frm_id][i4_bitrate_instance_num]
6227 ps_ctxt->aaps_enc_loop_rc_params[ps_ctxt->i4_enc_frm_id][i4_bitrate_instance_num]
6229 ps_ctxt->aaps_enc_loop_rc_params[ps_ctxt->i4_enc_frm_id][i4_bitrate_instance_num]
6231 ps_ctxt->aaps_enc_loop_rc_params[ps_ctxt->i4_enc_frm_id][i4_bitrate_instance_num]
6233 ps_ctxt->aaps_enc_loop_rc_params[ps_ctxt->i4_enc_frm_id][i4_bitrate_instance_num]
6235 ps_ctxt->aaps_enc_loop_rc_params[ps_ctxt->i4_enc_frm_id][i4_bitrate_instance_num]
6237 ps_ctxt->aaps_enc_loop_rc_params[ps_ctxt->i4_enc_frm_id][i4_bitrate_instance_num]
6239 ps_ctxt->aaps_enc_loop_rc_params[ps_ctxt->i4_enc_frm_id][i4_bitrate_instance_num]
6241 ps_ctxt->aaps_enc_loop_rc_params[ps_ctxt->i4_enc_frm_id][i4_bitrate_instance_num]
6243 ps_ctxt->aaps_enc_loop_rc_params[ps_ctxt->i4_enc_frm_id][i4_bitrate_instance_num]
6246 GET_FRAME_QSTEP_FROM_QP(ps_ctxt->i4_frame_qp, ps_ctxt->i4_frame_qstep);
6248 ps_ctxt->u1_max_tr_depth = ps_sps->i1_max_transform_hierarchy_depth_inter;
6250 ps_ctxt->ps_rc_quant_ctxt = &ps_enc_ctxt->s_rc_quant;
6253 &ps_ctxt->s_rdopt_entropy_ctxt,
6262 ps_ctxt->pv_dep_mngr_encloop_dep_me = pv_dep_mngr_encloop_dep_me;
6291 ihevce_enc_loop_ctxt_t *ps_ctxt;
6314 ps_ctxt = ps_master_ctxt->aps_enc_loop_thrd_ctxt[i];
6316 ps_ctxt->aaps_enc_loop_rc_params[i4_enc_frm_id][i4_br_id]->u4_frame_open_loop_intra_sad;
6318 ps_ctxt->aaps_enc_loop_rc_params[i4_enc_frm_id][i4_br_id]->i8_frame_open_loop_ssd;
6320 ps_ctxt->aaps_enc_loop_rc_params[i4_enc_frm_id][i4_br_id]->u4_frame_intra_sad;
6322 ps_ctxt->aaps_enc_loop_rc_params[i4_enc_frm_id][i4_br_id]->u4_frame_sad_acc;
6324 ps_ctxt->aaps_enc_loop_rc_params[i4_enc_frm_id][i4_br_id]->u4_frame_rdopt_bits;
6326 ps_ctxt->aaps_enc_loop_rc_params[i4_enc_frm_id][i4_br_id]->u4_frame_rdopt_header_bits;
6327 i4_qp_normalized_8x8_cu_sum[0] += ps_ctxt->aaps_enc_loop_rc_params[i4_enc_frm_id][i4_br_id]
6329 i4_qp_normalized_8x8_cu_sum[1] += ps_ctxt->aaps_enc_loop_rc_params[i4_enc_frm_id][i4_br_id]
6332 ps_ctxt->aaps_enc_loop_rc_params[i4_enc_frm_id][i4_br_id]->i4_8x8_cu_sum[0];
6334 ps_ctxt->aaps_enc_loop_rc_params[i4_enc_frm_id][i4_br_id]->i4_8x8_cu_sum[1];
6336 ps_ctxt->aaps_enc_loop_rc_params[i4_enc_frm_id][i4_br_id]->i8_sad_by_qscale[0];
6338 ps_ctxt->aaps_enc_loop_rc_params[i4_enc_frm_id][i4_br_id]->i8_sad_by_qscale[1];