Merge "libhevcenc: pre enc intra cleanup"

This commit is contained in:
Ray Essick 2019-12-05 21:54:12 +00:00 committed by Gerrit Code Review
commit 3fac63c9b7
15 changed files with 1023 additions and 2886 deletions

View file

@ -122,51 +122,33 @@ static void copy_2d_neon(
if(blk_wd == 4)
{
assert((blk_ht & 1) == 0);
for(; blk_ht > 0; blk_ht -= 2)
for(; blk_ht > 0; blk_ht--)
{
// row 0
*(uint32_t *)pu1_dst = *(const uint32_t *)pu1_src;
pu1_src += src_strd;
pu1_dst += dst_strd;
// row 1
*(uint32_t *)pu1_dst = *(const uint32_t *)pu1_src;
memcpy(pu1_dst, pu1_src, 4);
pu1_src += src_strd;
pu1_dst += dst_strd;
}
}
else if(blk_wd == 8)
{
assert((blk_ht & 1) == 0);
for(; blk_ht > 0; blk_ht -= 2)
for(; blk_ht > 0; blk_ht--)
{
uint8x8_t src_0, src_1;
uint8x8_t src = vld1_u8(pu1_src);
// row 0
src_0 = vld1_u8(pu1_src);
vst1_u8(pu1_dst, src_0);
// row 1
src_1 = vld1_u8(pu1_src + src_strd);
vst1_u8(pu1_dst + dst_strd, src_1);
pu1_src += 2 * src_strd;
pu1_dst += 2 * dst_strd;
vst1_u8(pu1_dst, src);
pu1_src += src_strd;
pu1_dst += dst_strd;
}
}
else if(blk_wd == 16)
{
assert((blk_ht & 1) == 0);
for(; blk_ht > 0; blk_ht -= 2)
for(; blk_ht > 0; blk_ht--)
{
uint8x16_t src_0, src_1;
uint8x16_t src = vld1q_u8(pu1_src);
// row 0
src_0 = vld1q_u8(pu1_src);
vst1q_u8(pu1_dst, src_0);
// row 1
src_1 = vld1q_u8(pu1_src + src_strd);
vst1q_u8(pu1_dst + dst_strd, src_1);
pu1_src += 2 * src_strd;
pu1_dst += 2 * dst_strd;
vst1q_u8(pu1_dst, src);
pu1_src += src_strd;
pu1_dst += dst_strd;
}
}
else if(blk_wd == 32)

File diff suppressed because it is too large Load diff

View file

@ -46,12 +46,6 @@
/*****************************************************************************/
extern WORD32 g_i4_ip_funcs[MAX_NUM_IP_MODES];
/*****************************************************************************/
/* Constant Macros */
/*****************************************************************************/
#define POW_2_TO_1_BY_4 (1.1892)
#define POW_2_TO_3_BY_4 (1.6818)
/*****************************************************************************/
/* Extern Function Declarations */
/*****************************************************************************/
@ -84,9 +78,7 @@ void ihevce_decomp_pre_intra_process(
frm_ctb_ctxt_t *ps_frm_ctb_prms,
void *pv_multi_thrd_ctxt,
WORD32 thrd_id,
WORD32 i4_ping_pong,
ihevce_8x8_L0_satd_t *ps_layer0_cur_satd,
ihevce_8x8_L0_mean_t *ps_layer0_cur_mean);
WORD32 i4_ping_pong);
void ihevce_decomp_pre_intra_frame_init(
void *pv_ctxt,
@ -96,18 +88,12 @@ void ihevce_decomp_pre_intra_frame_init(
ihevce_ed_blk_t *ps_layer2_buf,
ihevce_ed_ctb_l1_t *ps_ed_ctb_l1,
WORD32 i4_ol_sad_lambda_qf,
WORD32 i4_slice_type,
ctb_analyse_t *ps_ctb_analyse);
/* Calculate the average activitiies at 16*16 (8*8 in L1)
and 32*32 (8*8 in L2) block sizes */
void ihevce_decomp_pre_intra_curr_frame_pre_intra_deinit(
void *pv_pre_intra_ctxt,
pre_enc_me_ctxt_t *ps_curr_out,
WORD32 i4_is_last_thread,
frm_ctb_ctxt_t *ps_frm_ctb_prms,
WORD32 i4_temporal_lyr_id,
WORD32 i4_enable_noise_detection);
frm_ctb_ctxt_t *ps_frm_ctb_prms);
void ihevce_scale_by_2(
UWORD8 *pu1_src,
@ -126,28 +112,19 @@ void ihevce_scale_by_2(
void ihevce_ed_frame_init(void *pv_ed_ctxt, WORD32 i4_layer_no);
void ihevce_intra_populate_mode_bits_cost(
WORD32 top_intra_mode,
WORD32 left_intra_mode,
WORD32 available_top,
WORD32 available_left,
WORD32 cu_pos_y,
UWORD16 *mode_bits_cost,
WORD32 lambda);
float fast_log2(float val);
WORD32 ihevce_cu_level_qp_mod(
WORD32 i4_qscale,
WORD32 i4_satd,
long double ld_curr_frame_log_avg,
WORD32 frm_qscale,
WORD32 cu_satd,
long double frm_avg_activity,
float f_mod_strength,
WORD32 *pi4_8x8_act_factor,
WORD32 *pi4_qscale_mod,
rc_quant_t *ps_rc_quant_ctxt);
WORD32 *pi4_act_factor,
WORD32 *pi4_q_scale_mod,
rc_quant_t *rc_quant_ctxt);
/*return intra SATD of entire frame*/
LWORD64 ihevce_decomp_pre_intra_get_frame_satd(void *pv_ctxt, WORD32 *i4_width, WORD32 *i4_hieght);
LWORD64 ihevce_decomp_pre_intra_get_frame_satd(void *pv_ctxt, WORD32 *wd, WORD32 *ht);
LWORD64 ihevce_decomp_pre_intra_get_frame_satd_squared(
void *pv_ctxt, WORD32 *i4_width, WORD32 *i4_hieght);
LWORD64 ihevce_decomp_pre_intra_get_frame_satd_squared(void *pv_ctxt, WORD32 *wd, WORD32 *ht);
#endif

View file

@ -97,18 +97,6 @@ typedef struct
/** lambda for cost calculation */
WORD32 lambda;
/*pic type*/
WORD32 i4_slice_type;
/**
* Until what level, intra is evaluated.
* 0 - 8
* 1 - 4
* 2 - 2
* 3 - 4
*/
WORD32 level;
/*Pointer to 4x4 blocks of entire frame */
ihevce_ed_blk_t *ps_ed_pic;
@ -121,10 +109,6 @@ typedef struct
/*Pointer to ctb level data of current ctb */
ihevce_ed_ctb_l1_t *ps_ed_ctb_l1;
WORD32 left_ctb_intra_modes[20];
WORD32 sad[64 * NUM_MODES];
/*Sum of best SATDs at L1*/
LWORD64 i8_sum_best_satd;
@ -148,15 +132,6 @@ typedef struct
/** mode bits costs array. This is used as local variable in ed_calc_8x8_blk */
UWORD16 au2_mode_bits_cost_full_ctb[4][NUM_MODES];
/** reference data for 4x4 block for incomplete ctb proc. Variable local to ed_calc_incomplete_ctb*/
UWORD8 au1_ref_ic_ctb[18];
/** top intra modes for incomplete ctb proc. Variable local to ed_calc_incomplete_ctb*/
WORD32 ai4_top_intra_modes_ic_ctb[20];
/** mode bits cost for incomplete ctb proc. Variable local to ed_calc_incomplete_ctb*/
UWORD16 au2_mode_bits_cost_ic_ctb[NUM_MODES];
/** Pointer to structure containing function pointers of common*/
func_selector_t *ps_func_selector;
@ -209,9 +184,6 @@ typedef struct
/** Array for working memory of the thread */
UWORD8 au1_wkg_mem[((MAX_CTB_SIZE >> 1) * (MAX_CTB_SIZE + 2 * NUM_EXTRA_ROWS_REQ))];
/** Pointer for working memory of the thread */
UWORD8 *pu1_wkg_mem;
/** Encoder quality preset : See IHEVCE_QUALITY_CONFIG_T for presets */
WORD32 i4_quality_preset;
@ -222,14 +194,6 @@ typedef struct
ihevce_ed_blk_t *ps_layer2_buf;
ihevce_ed_ctb_l1_t *ps_ed_ctb_l1;
/** to store the L0 8x8 cur SATD */
ihevce_8x8_L0_satd_t *ps_layer0_cur_satd;
/** to store the L0 8x8 cur mean*/
ihevce_8x8_L0_mean_t *ps_layer0_cur_mean;
WORD32 i4_slice_type;
WORD32 i4_codec_level;
WORD32 ai4_lambda[MAX_NUM_HME_LAYERS];
/* pointer to the structure ps_ctb_analyse in pre_enc_me_ctxt_t */
@ -266,4 +230,4 @@ typedef struct
/* Extern Function Declarations */
/*****************************************************************************/
#endif /* _IHEVCE_ENC_LOOP_STRUCTS_H_ */
#endif /* _IHEVCE_DECOMP_PRE_INTRA_STRUCTS_H_ */

View file

@ -1211,29 +1211,7 @@ typedef struct
UWORD16 sad_cost;
} ihevce_ed_mode_attr_t; //early decision
/**
******************************************************************************
* @brief Structure at 8x8 block level which has parameters such as cur satd
* for QP mod @ L0 level
******************************************************************************
*/
typedef struct
{
/*Store SATD of current data at 8*8 level for current layer (L0)*/
WORD32 i4_8x8_cur_satd;
} ihevce_8x8_L0_satd_t;
/**
******************************************************************************
* @brief Structure at 8x8 block level mean for MEAN based QP mod
******************************************************************************
*/
typedef struct
{
/*Store SATD of current data at 8*8 level for current layer (L0)*/
WORD16 i2_8x8_cur_mean;
} ihevce_8x8_L0_mean_t;
//#define DEBUG_ED_CTB_POS
/**
******************************************************************************
* @brief Structure at 4x4 block level which has parameters about early
@ -1249,25 +1227,19 @@ typedef struct
* 2 - eval inter only
* 3 - eval both intra and inter
*/
UWORD8 intra_or_inter : 2;
UWORD8 intra_or_inter;
UWORD8 merge_success : 1;
UWORD8 merge_success;
/** Best mode for the current 4x4 prediction block */
UWORD8 best_mode;
/* sad cost for the best prediction mode */
//UWORD16 best_sad_cost;
/** Best mode for the current 4x4 prediction block */
UWORD8 best_merge_mode;
/*Store SATD at 4*4 level for current layer (L1)*/
/** Store SATD at 4*4 level for current layer (L1) */
WORD32 i4_4x4_satd;
/*Store SATD of current data at 4*4 level for current layer (L1)*/
WORD32 i4_4x4_cur_satd;
} ihevce_ed_blk_t; //early decision
/* l1 ipe ctb analyze structure */
@ -1278,41 +1250,37 @@ typedef struct
WORD32 i4_sum_4x4_satd[16];
WORD32 i4_min_4x4_satd[16];
/*satd for L1_8x8 blocks in L1_32x32
16 - num L1_8x8 in L1_32x32
2 =>
0 - sum of L1_4x4 @ L1_8x8
- equivalent to transform size of 16x16 @ L0
1 - min/median of L1_4x4 @ L1_8x8
- equivalent to transform size of 8x8 @ L0
*/
/* satd for L1_8x8 blocks in L1_32x32
* [16] : num L1_8x8 in L1_32x32
* [2] : 0 - sum of L1_4x4 @ L1_8x8
* - equivalent to transform size of 16x16 @ L0
* 1 - min/median of L1_4x4 @ L1_8x8
* - equivalent to transform size of 8x8 @ L0
*/
WORD32 i4_8x8_satd[16][2];
/*satd for L1_16x16 blocks in L1_32x32
4 - num L1_16x16 in L1_32x32
3 =>
0 - sum of (sum of L1_4x4 @ L1_8x8) @ L1_16x16
- equivalent to transform size of 32x32 @ L0
1 - min/median of (sum of L1_4x4 @ L1_8x8) @ L1_16x16
- equivalent to transform size of 16x16 @ L0
2 - min/median of (min/median of L1_4x4 @ L1_8x8) @ L1_16x16
- equivalent to transform size of 8x8 @ L0
*/
/* satd for L1_16x16 blocks in L1_32x32
* [4] : num L1_16x16 in L1_32x32
* [3] : 0 - sum of (sum of L1_4x4 @ L1_8x8) @ L1_16x16
* - equivalent to transform size of 32x32 @ L0
* 1 - min/median of (sum of L1_4x4 @ L1_8x8) @ L1_16x16
* - equivalent to transform size of 16x16 @ L0
* 2 - min/median of (min/median of L1_4x4 @ L1_8x8) @ L1_16x16
* - equivalent to transform size of 8x8 @ L0
*/
WORD32 i4_16x16_satd[4][3];
/*satd for 32x32 block in L1*/
/*Please note that i4_32x32_satd[0][3] contains sum of all 32x32 */
/*satd for L1_32x32 blocks in L1_32x32
1 - num L1_32x32 in L1_32x32
4 =>
0 - min/median of (sum of (sum of L1_4x4 @ L1_8x8) @ L1_16x16) @ L1_32x32
- equivalent to transform size of 32x32 @ L0
1 - min/median of (sum of L1_4x4 @ L1_8x8) @ L1_32x32
- equivalent to transform size of 16x16 @ L0
2 - min/median of (min/median of L1_4x4 @ L1_8x8) @ L1_32x32
- equivalent to transform size of 8x8 @ L0
3 - sum of (sum of (sum of L1_4x4 @ L1_8x8) @ L1_16x16) @ L1_32x32
*/
/* Please note that i4_32x32_satd[0][3] contains sum of all 32x32 */
/* satd for L1_32x32 blocks in L1_32x32
* [1] : num L1_32x32 in L1_32x32
* [4] : 0 - min/median of (sum of (sum of L1_4x4 @ L1_8x8) @ L1_16x16) @ L1_32x32
* - equivalent to transform size of 32x32 @ L0
* 1 - min/median of (sum of L1_4x4 @ L1_8x8) @ L1_32x32
* - equivalent to transform size of 16x16 @ L0
* 2 - min/median of (min/median of L1_4x4 @ L1_8x8) @ L1_32x32
* - equivalent to transform size of 8x8 @ L0
* 3 - sum of (sum of (sum of L1_4x4 @ L1_8x8) @ L1_16x16) @ L1_32x32
*/
WORD32 i4_32x32_satd[1][4];
/*Store SATD at 8x8 level for current layer (L1)*/
@ -1371,9 +1339,6 @@ typedef struct
*/
UWORD8 au1_4x4_best_modes[4][MAX_INTRA_CU_CANDIDATES + 1];
/** best 8x8 intra sad/SATD cost */
WORD32 i4_best_intra_cost;
/** flag to indicate if nxn pu mode (different pu at 4x4 level) is enabled */
UWORD8 b1_enable_nxn : 1;
@ -1405,9 +1370,6 @@ typedef struct
/** 8x8 children intra analyze for this 16x16 */
intra8_analyse_t as_intra8_analyse[4];
/* best 16x16 intra sad/SATD cost */
WORD32 i4_best_intra_cost;
/* indicates if 16x16 is best cu or 8x8 cu */
UWORD8 b1_split_flag : 1;
@ -1446,9 +1408,6 @@ typedef struct
/** 16x16 children intra analyze for this 32x32 */
intra16_analyse_t as_intra16_analyse[4];
/* best 32x32 intra sad/SATD cost */
WORD32 i4_best_intra_cost;
/* indicates if 32x32 is best cu or 16x16 cu */
UWORD8 b1_split_flag : 1;
@ -1500,16 +1459,6 @@ typedef struct
/* best 64x64 intra cost */
WORD32 i4_best64x64_intra_cost;
/**
* CTB level early intra / inter decision at 8x8 block level
* 0 - invalid decision
* 1 - eval intra only
* 2 - eval inter only
* 3 - eval both intra and inter
*/
/* Z scan format */
WORD8 ai1_early_intra_inter_decision[MAX_CU_IN_CTB];
/*
@L0 level
4 => 0 - 32x32 TU in 64x64 CU
@ -1639,12 +1588,6 @@ typedef struct
/** Buffer pointer for CTB level information in pre intra pass*/
ihevce_ed_ctb_l1_t *ps_ed_ctb_l1;
/* L0 cur 8x8 satd for QP mod*/
ihevce_8x8_L0_satd_t *ps_layer0_cur_satd;
/* L0 cur 8x8 mean for QP mod*/
ihevce_8x8_L0_mean_t *ps_layer0_cur_mean;
/** vps parameters activated by current slice */
sei_params_t s_sei;

View file

@ -3214,6 +3214,10 @@ WORD32 ihevce_enc_frm_proc_slave_thrd(void *pv_frm_proc_thrd_ctxt)
ps_curr_L0_IPE_inp_prms =
ps_enc_ctxt->s_multi_thrd.aps_cur_L0_ipe_inp_prms[i4_me_frm_id];
ps_curr_inp = ps_enc_ctxt->s_multi_thrd.aps_cur_inp_me_prms[i4_me_frm_id]->ps_curr_inp;
if(i4_thrd_id == 0)
{
PROFILE_START(&ps_hle_ctxt->profile_enc_me[ps_enc_ctxt->i4_resolution_id]);
}
/* -------------------------------------------------- */
/* Motion estimation (enc layer) of entire frame */
@ -3249,7 +3253,6 @@ WORD32 ihevce_enc_frm_proc_slave_thrd(void *pv_frm_proc_thrd_ctxt)
i4_me_frm_id);
}
else
{
/* Init i4_is_prev_frame_reference for the next P-frame */
me_master_ctxt_t *ps_master_ctxt =
@ -3274,6 +3277,10 @@ WORD32 ihevce_enc_frm_proc_slave_thrd(void *pv_frm_proc_thrd_ctxt)
}
}
}
if(i4_thrd_id == 0)
{
PROFILE_STOP(&ps_hle_ctxt->profile_enc_me[ps_enc_ctxt->i4_resolution_id], NULL);
}
}
/************************************/
/****** ENTER CRITICAL SECTION *****/
@ -5363,7 +5370,6 @@ void ihevce_pre_enc_init(
ps_curr_out->ps_layer2_buf,
ps_curr_out->ps_ed_ctb_l1,
ps_curr_out->as_lambda_prms[0].i4_ol_sad_lambda_qf,
ps_curr_out->s_slice_hdr.i1_slice_type,
ps_curr_out->ps_ctb_analyse);
}
@ -5379,73 +5385,6 @@ void ihevce_pre_enc_init(
//*pps_frm_recon_ret = ps_frm_recon;
}
/*!
******************************************************************************
* \if Function name : ihevce_pre_enc_process_frame \endif
*
* \brief
* Frame processing main function
*
* \param[in] Encoder context pointer
* \param[in] Current input buffer params pointer
* \param[out] Current output buffer params pointer
* \param[in] Current frame QP
*
* \return
* None
*
* \author
* Ittiam
*
*****************************************************************************
*/
void ihevce_pre_enc_process_frame(
enc_ctxt_t *ps_enc_ctxt,
ihevce_lap_enc_buf_t *ps_curr_inp,
pre_enc_me_ctxt_t *ps_curr_out,
WORD32 i4_cur_frame_qp,
WORD32 i4_thrd_id,
WORD32 i4_ping_pong)
{
if(1 == ps_curr_out->i4_frm_proc_valid_flag)
{
/* ------------------------------------------------------------ */
/* Layer Decomp and Intra 4x4 Analysis */
/* ------------------------------------------------------------ */
ihevce_decomp_pre_intra_process(
ps_enc_ctxt->s_module_ctxt.pv_decomp_pre_intra_ctxt,
&ps_curr_inp->s_lap_out,
&ps_enc_ctxt->s_frm_ctb_prms,
&ps_enc_ctxt->s_multi_thrd,
i4_thrd_id,
i4_ping_pong,
ps_curr_out->ps_layer0_cur_satd,
ps_curr_out->ps_layer0_cur_mean);
/* ------------------------------------------------------------ */
/* Coarse Motion estimation and early intra-inter decision */
/* ------------------------------------------------------------ */
ihevce_coarse_me_process(
ps_enc_ctxt->s_module_ctxt.pv_coarse_me_ctxt,
ps_curr_inp,
&ps_enc_ctxt->s_multi_thrd,
i4_thrd_id,
i4_ping_pong);
/* ------------------------------------------------------------ */
/* Update qp used in based in L1 satd/act in case of scene cut */
/* ------------------------------------------------------------ */
//ihevce_update_qp_L1_sad_based(ps_enc_ctxt,ps_curr_inp,ps_curr_out);
/* Calculate the average activity values from the previous frame and
these would be used by the current frame*/
/*ihevce_decomp_pre_intra_curr_frame_pre_intra_deinit(
ps_enc_ctxt->s_module_ctxt.pv_decomp_pre_intra_ctxt,
ps_enc_ctxt->s_module_ctxt.pv_ipe_ctxt,
i4_thrd_id);*/
}
}
/*!
******************************************************************************
* \if Function name : ihevce_pre_enc_coarse_me_init \endif
@ -5558,318 +5497,149 @@ void ihevce_pre_enc_coarse_me_init(
*pps_frm_recon_ret = ps_frm_recon;
}
#define MAX_64BIT_VAL 0x7fffffffffffffff
/*!
******************************************************************************
* \if Function name : ihevce_variance_calc_acc_activity \endif
*
* \brief
* Function to calculate modulation based on spatial variance across lap period
*
* \param[in] pv_ctxt : pointer to IPE module
*
* \return
* None
*
* \author
* Ittiam
* Function to calculate modulation based on spatial variance across lap period
*
*****************************************************************************
*/
void ihevce_variance_calc_acc_activity(enc_ctxt_t *ps_enc_ctxt, WORD32 i4_cur_ipe_idx)
{
WORD32 j, i4_k;
WORD32 i = 0;
WORD32 is_i_frame =
((ps_enc_ctxt->s_multi_thrd.aps_curr_inp_pre_enc[i4_cur_ipe_idx]->s_lap_out.i4_pic_type ==
IV_I_FRAME) ||
(ps_enc_ctxt->s_multi_thrd.aps_curr_inp_pre_enc[i4_cur_ipe_idx]->s_lap_out.i4_pic_type ==
IV_IDR_FRAME));
WORD32 is_p_frame =
(ps_enc_ctxt->s_multi_thrd.aps_curr_inp_pre_enc[i4_cur_ipe_idx]->s_lap_out.i4_pic_type ==
IV_P_FRAME);
WORD32 i4_delay_loop = ps_enc_ctxt->s_multi_thrd.i4_max_delay_pre_me_btw_l0_ipe;
pre_enc_me_ctxt_t *ps_pre_enc_me_ctxt_t;
pre_enc_me_ctxt_t *ps_curr_out = ps_enc_ctxt->s_multi_thrd.aps_curr_out_pre_enc[i4_cur_ipe_idx];
rc_lap_out_params_t *ps_temp_ipe_rc_lap_out;
UWORD8 is_no_scene_change = 1;
WORD32 loop_lap2, i4_pass_num;
UWORD32 u4_scene_num;
i4_pass_num = ps_enc_ctxt->ps_stat_prms->s_pass_prms.i4_pass;
ps_temp_ipe_rc_lap_out =
&ps_enc_ctxt->s_multi_thrd.aps_curr_inp_pre_enc[i4_cur_ipe_idx]->s_rc_lap_out;
WORD32 is_curr_bslice = (ps_curr_out->s_slice_hdr.i1_slice_type == BSLICE);
#if MODULATION_OVER_LAP
WORD32 loop_lap2 = MAX(1, ps_enc_ctxt->s_multi_thrd.i4_delay_pre_me_btw_l0_ipe - 1);
#else
WORD32 loop_lap2 = 1;
#endif
WORD32 i4_delay_loop = ps_enc_ctxt->s_multi_thrd.i4_max_delay_pre_me_btw_l0_ipe;
WORD32 i, j;
ps_curr_out->i8_acc_frame_8x8_sum_act_sqr = 0;
ps_curr_out->i8_acc_frame_8x8_sum_act_for_strength = 0;
for(i4_k = 0; i4_k < 2; i4_k++)
for(i = 0; i < 2; i++)
{
ps_curr_out->i8_acc_frame_8x8_sum_act[i4_k] = 0;
ps_curr_out->i4_acc_frame_8x8_num_blks[i4_k] = 0;
ps_curr_out->i8_acc_frame_16x16_sum_act[i4_k] = 0;
ps_curr_out->i4_acc_frame_16x16_num_blks[i4_k] = 0;
ps_curr_out->i8_acc_frame_32x32_sum_act[i4_k] = 0;
ps_curr_out->i4_acc_frame_32x32_num_blks[i4_k] = 0;
ps_curr_out->i8_acc_frame_8x8_sum_act[i] = 0;
ps_curr_out->i4_acc_frame_8x8_num_blks[i] = 0;
ps_curr_out->i8_acc_frame_16x16_sum_act[i] = 0;
ps_curr_out->i4_acc_frame_16x16_num_blks[i] = 0;
ps_curr_out->i8_acc_frame_32x32_sum_act[i] = 0;
ps_curr_out->i4_acc_frame_32x32_num_blks[i] = 0;
}
ps_curr_out->i8_acc_frame_16x16_sum_act[i4_k] = 0;
ps_curr_out->i4_acc_frame_16x16_num_blks[i4_k] = 0;
ps_curr_out->i8_acc_frame_16x16_sum_act[i] = 0;
ps_curr_out->i4_acc_frame_16x16_num_blks[i] = 0;
ps_curr_out->i8_acc_frame_32x32_sum_act[i] = 0;
ps_curr_out->i4_acc_frame_32x32_num_blks[i] = 0;
ps_curr_out->i8_acc_frame_32x32_sum_act[i4_k] = 0;
ps_curr_out->i4_acc_frame_32x32_num_blks[i4_k] = 0;
u4_scene_num =
ps_enc_ctxt->s_multi_thrd.aps_curr_inp_pre_enc[i4_cur_ipe_idx]->s_lap_out.u4_scene_num;
//ps_curr_out->i4_acc_frame_median_sum_act = 0;
#if MODULATION_OVER_LAP
if(ps_enc_ctxt->s_multi_thrd.i4_delay_pre_me_btw_l0_ipe - 1 <= 0)
loop_lap2 = 1;
else
loop_lap2 = ps_enc_ctxt->s_multi_thrd.i4_delay_pre_me_btw_l0_ipe - 1;
#else
loop_lap2 = 1;
#endif
if(ps_temp_ipe_rc_lap_out->ps_rc_lap_out_next_encode == NULL ||
ps_temp_ipe_rc_lap_out->i4_is_non_I_scd)
if(!is_curr_bslice)
{
is_no_scene_change = 0;
}
/*Loop over complete lap2 struct ad make sure no scene change occurs in the lap2 frmaes */
for(i = 1; i < loop_lap2; i++)
{
WORD32 i4_temp_ipe_idx = (i4_cur_ipe_idx + i) % i4_delay_loop;
if(0 == is_no_scene_change)
{
loop_lap2 = i;
break;
}
ps_temp_ipe_rc_lap_out =
&ps_enc_ctxt->s_multi_thrd.aps_curr_inp_pre_enc[i4_temp_ipe_idx]->s_rc_lap_out;
/*check if the current frame scene num is same as previous frame scene num */
is_no_scene_change = (u4_scene_num == ps_temp_ipe_rc_lap_out->u4_rc_scene_num);
if(ps_temp_ipe_rc_lap_out->ps_rc_lap_out_next_encode == NULL ||
ps_temp_ipe_rc_lap_out->i4_is_non_I_scd)
{
is_no_scene_change = 0;
loop_lap2 = i;
break;
}
}
/*Only if there is no scene change then process the lap2 for modulation index calcuation */
if(((1 == is_i_frame) || (1 == is_p_frame)) &&
(1 == is_no_scene_change || (ps_enc_ctxt->i4_active_scene_num != (WORD32)u4_scene_num)))
{
//do
ps_enc_ctxt->i4_active_scene_num = u4_scene_num;
for(i = 0; i < loop_lap2; i++)
{
WORD32 i4_temp_ipe_idx = (i4_cur_ipe_idx + i) % i4_delay_loop;
UWORD8 i_frame =
((ps_enc_ctxt->s_multi_thrd.aps_curr_inp_pre_enc[i4_temp_ipe_idx]
->s_lap_out.i4_pic_type == IV_I_FRAME) ||
(ps_enc_ctxt->s_multi_thrd.aps_curr_inp_pre_enc[i4_temp_ipe_idx]
->s_lap_out.i4_pic_type == IV_IDR_FRAME));
UWORD8 p_frame =
(ps_enc_ctxt->s_multi_thrd.aps_curr_inp_pre_enc[i4_temp_ipe_idx]
->s_lap_out.i4_pic_type == IV_P_FRAME);
WORD32 ipe_idx_tmp = (i4_cur_ipe_idx + i) % i4_delay_loop;
ihevce_lap_enc_buf_t *ps_in = ps_enc_ctxt->s_multi_thrd.aps_curr_inp_pre_enc[ipe_idx_tmp];
pre_enc_me_ctxt_t *ps_out = ps_enc_ctxt->s_multi_thrd.aps_curr_out_pre_enc[ipe_idx_tmp];
UWORD8 is_bslice = (ps_out->s_slice_hdr.i1_slice_type == BSLICE);
ps_pre_enc_me_ctxt_t = ps_enc_ctxt->s_multi_thrd.aps_curr_out_pre_enc[i4_temp_ipe_idx];
if(1 == (p_frame || i_frame))
if(!is_bslice)
{
ps_curr_out->i8_acc_frame_8x8_sum_act_sqr +=
ps_pre_enc_me_ctxt_t->u8_curr_frame_8x8_sum_act_sqr;
ps_curr_out->i8_acc_frame_8x8_sum_act_for_strength +=
ps_pre_enc_me_ctxt_t->i4_curr_frame_8x8_sum_act_for_strength[0];
for(i4_k = 0; i4_k < 2; i4_k++)
ps_curr_out->i8_acc_frame_8x8_sum_act_sqr += ps_out->u8_curr_frame_8x8_sum_act_sqr;
ps_curr_out->i8_acc_frame_8x8_sum_act_for_strength += ps_out->i4_curr_frame_8x8_sum_act_for_strength[0];
for(j = 0; j < 2; j++)
{
ps_curr_out->i8_acc_frame_8x8_sum_act[i4_k] +=
ps_pre_enc_me_ctxt_t->i8_curr_frame_8x8_sum_act[i4_k];
ps_curr_out->i4_acc_frame_8x8_num_blks[i4_k] +=
ps_pre_enc_me_ctxt_t->i4_curr_frame_8x8_num_blks[i4_k];
ps_curr_out->i8_acc_frame_16x16_sum_act[i4_k] +=
ps_pre_enc_me_ctxt_t->i8_curr_frame_16x16_sum_act[i4_k];
ps_curr_out->i4_acc_frame_16x16_num_blks[i4_k] +=
ps_pre_enc_me_ctxt_t->i4_curr_frame_16x16_num_blks[i4_k];
ps_curr_out->i8_acc_frame_32x32_sum_act[i4_k] +=
ps_pre_enc_me_ctxt_t->i8_curr_frame_32x32_sum_act[i4_k];
ps_curr_out->i4_acc_frame_32x32_num_blks[i4_k] +=
ps_pre_enc_me_ctxt_t->i4_curr_frame_32x32_num_blks[i4_k];
ps_curr_out->i8_acc_frame_8x8_sum_act[j] += ps_out->i8_curr_frame_8x8_sum_act[j];
ps_curr_out->i4_acc_frame_8x8_num_blks[j] += ps_out->i4_curr_frame_8x8_num_blks[j];
ps_curr_out->i8_acc_frame_16x16_sum_act[j] += ps_out->i8_curr_frame_16x16_sum_act[j];
ps_curr_out->i4_acc_frame_16x16_num_blks[j] += ps_out->i4_curr_frame_16x16_num_blks[j];
ps_curr_out->i8_acc_frame_32x32_sum_act[j] += ps_out->i8_curr_frame_32x32_sum_act[j];
ps_curr_out->i4_acc_frame_32x32_num_blks[j] += ps_out->i4_curr_frame_32x32_num_blks[j];
}
ps_curr_out->i8_acc_frame_16x16_sum_act[i4_k] +=
ps_pre_enc_me_ctxt_t->i8_curr_frame_16x16_sum_act[i4_k];
ps_curr_out->i4_acc_frame_16x16_num_blks[i4_k] +=
ps_pre_enc_me_ctxt_t->i4_curr_frame_16x16_num_blks[i4_k];
ps_curr_out->i8_acc_frame_32x32_sum_act[i4_k] +=
ps_pre_enc_me_ctxt_t->i8_curr_frame_32x32_sum_act[i4_k];
ps_curr_out->i4_acc_frame_32x32_num_blks[i4_k] +=
ps_pre_enc_me_ctxt_t->i4_curr_frame_32x32_num_blks[i4_k];
//ps_curr_out->i4_acc_frame_median_sum_act += ps_lap_out->i4_curr_frame_median_sum_act;
//ps_curr_out->i4_acc_frame_median_num_blks += ps_lap_out->i4_curr_frame_median_num_blks;
ps_curr_out->i8_acc_frame_16x16_sum_act[j] += ps_out->i8_curr_frame_16x16_sum_act[j];
ps_curr_out->i4_acc_frame_16x16_num_blks[j] += ps_out->i4_curr_frame_16x16_num_blks[j];
ps_curr_out->i8_acc_frame_32x32_sum_act[j] += ps_out->i8_curr_frame_32x32_sum_act[j];
ps_curr_out->i4_acc_frame_32x32_num_blks[j] += ps_out->i4_curr_frame_32x32_num_blks[j];
}
//ps_is_next_frame_available = (ihevce_lap_output_params_t *)ps_is_next_frame_available->ps_lap_out_next_encode;
if(NULL == ps_enc_ctxt->s_multi_thrd.aps_curr_inp_pre_enc[i4_temp_ipe_idx]
->s_rc_lap_out.ps_rc_lap_out_next_encode)
if(NULL == ps_in->s_rc_lap_out.ps_rc_lap_out_next_encode)
break;
} //while(NULL != ps_is_next_frame_available);
}
/*calculate corr. average, overwrite frame avg by acc. avergae*/
for(j = 0; j < 3; j++)
{
for(i4_k = 0; i4_k < 2; i4_k++)
if(j < 2)
ASSERT(0 != ps_curr_out->i4_acc_frame_8x8_num_blks[j]);
ASSERT(0 != ps_curr_out->i4_acc_frame_16x16_num_blks[j]);
ASSERT(0 != ps_curr_out->i4_acc_frame_32x32_num_blks[j]);
#define AVG_ACTIVITY(a, b, c) a = ((b + (c >> 1)) / c)
if(j < 2)
{
if(1 == is_i_frame)
if(0 == ps_curr_out->i4_acc_frame_8x8_num_blks[j])
{
ASSERT(0 != ps_curr_out->i4_acc_frame_8x8_num_blks[i4_k]);
ASSERT(0 != ps_curr_out->i4_acc_frame_16x16_num_blks[i4_k]);
ASSERT(0 != ps_curr_out->i4_acc_frame_32x32_num_blks[i4_k]);
}
/*In P frame, if no occlusion is present, tehn accumalted avg can be 0*/
/*In that case, modulation index is made 1*/
if(0 == ps_curr_out->i4_acc_frame_8x8_num_blks[i4_k])
{
ps_curr_out->i8_curr_frame_8x8_avg_act[i4_k] = 0;
ps_curr_out->i8_curr_frame_8x8_avg_act[j] = 0;
}
else
{
ps_curr_out->i8_curr_frame_8x8_sum_act_for_strength =
(ps_curr_out->i8_acc_frame_8x8_sum_act_for_strength +
(ps_curr_out->i4_acc_frame_8x8_num_blks[i4_k] >> 1)) /
ps_curr_out->i4_acc_frame_8x8_num_blks[i4_k];
ps_curr_out->i8_curr_frame_8x8_avg_act[i4_k] =
(ps_curr_out->i8_acc_frame_8x8_sum_act[i4_k] +
(ps_curr_out->i4_acc_frame_8x8_num_blks[i4_k] >> 1)) /
ps_curr_out->i4_acc_frame_8x8_num_blks[i4_k];
ps_curr_out->ld_curr_frame_8x8_log_avg[i4_k] =
(log(1 + (long double)ps_curr_out->i8_curr_frame_8x8_avg_act[i4_k]) /
log(2.0));
}
if(0 == ps_curr_out->i4_acc_frame_16x16_num_blks[i4_k])
{
ps_curr_out->i8_curr_frame_16x16_avg_act[i4_k] = 0;
}
else
{
ps_curr_out->i8_curr_frame_16x16_avg_act[i4_k] =
(ps_curr_out->i8_acc_frame_16x16_sum_act[i4_k] +
(ps_curr_out->i4_acc_frame_16x16_num_blks[i4_k] >> 1)) /
ps_curr_out->i4_acc_frame_16x16_num_blks[i4_k];
ps_curr_out->ld_curr_frame_16x16_log_avg[i4_k] =
(log(1 + (long double)ps_curr_out->i8_curr_frame_16x16_avg_act[i4_k]) /
log(2.0));
}
if(0 == ps_curr_out->i4_acc_frame_32x32_num_blks[i4_k])
{
ps_curr_out->i8_curr_frame_32x32_avg_act[i4_k] = 0;
}
else
{
ps_curr_out->i8_curr_frame_32x32_avg_act[i4_k] =
(ps_curr_out->i8_acc_frame_32x32_sum_act[i4_k] +
(ps_curr_out->i4_acc_frame_32x32_num_blks[i4_k] >> 1)) /
ps_curr_out->i4_acc_frame_32x32_num_blks[i4_k];
ps_curr_out->ld_curr_frame_32x32_log_avg[i4_k] =
(log(1 + (long double)ps_curr_out->i8_curr_frame_32x32_avg_act[i4_k]) /
log(2.0));
AVG_ACTIVITY(ps_curr_out->i8_curr_frame_8x8_sum_act_for_strength,
ps_curr_out->i8_acc_frame_8x8_sum_act_for_strength,
ps_curr_out->i4_acc_frame_8x8_num_blks[j]);
AVG_ACTIVITY(ps_curr_out->i8_curr_frame_8x8_avg_act[j],
ps_curr_out->i8_acc_frame_8x8_sum_act[j],
ps_curr_out->i4_acc_frame_8x8_num_blks[j]);
ps_curr_out->ld_curr_frame_8x8_log_avg[j] =
fast_log2(1 + ps_curr_out->i8_curr_frame_8x8_avg_act[j]);
}
}
if(1 == is_i_frame)
if(0 == ps_curr_out->i4_acc_frame_16x16_num_blks[j])
{
ASSERT(0 != ps_curr_out->i4_acc_frame_16x16_num_blks[i4_k]);
ASSERT(0 != ps_curr_out->i4_acc_frame_32x32_num_blks[i4_k]);
//ASSERT(0 != ps_curr_out->i4_acc_frame_median_num_blks);
}
if(0 == ps_curr_out->i4_acc_frame_16x16_num_blks[i4_k])
{
ps_curr_out->i8_curr_frame_16x16_avg_act[i4_k] = 0;
ps_curr_out->i8_curr_frame_16x16_avg_act[j] = 0;
}
else
{
ps_curr_out->i8_curr_frame_16x16_avg_act[i4_k] =
(ps_curr_out->i8_acc_frame_16x16_sum_act[i4_k] +
(ps_curr_out->i4_acc_frame_16x16_num_blks[i4_k] >> 1)) /
ps_curr_out->i4_acc_frame_16x16_num_blks[i4_k];
ps_curr_out->ld_curr_frame_16x16_log_avg[i4_k] =
(log(1 + (long double)ps_curr_out->i8_curr_frame_16x16_avg_act[i4_k]) /
log(2.0));
AVG_ACTIVITY(ps_curr_out->i8_curr_frame_16x16_avg_act[j],
ps_curr_out->i8_acc_frame_16x16_sum_act[j],
ps_curr_out->i4_acc_frame_16x16_num_blks[j]);
ps_curr_out->ld_curr_frame_16x16_log_avg[j] =
fast_log2(1 + ps_curr_out->i8_curr_frame_16x16_avg_act[j]);
}
if(0 == ps_curr_out->i4_acc_frame_32x32_num_blks[i4_k])
if(0 == ps_curr_out->i4_acc_frame_32x32_num_blks[j])
{
ps_curr_out->i8_curr_frame_32x32_avg_act[i4_k] = 0;
ps_curr_out->i8_curr_frame_32x32_avg_act[j] = 0;
}
else
{
ps_curr_out->i8_curr_frame_32x32_avg_act[i4_k] =
(ps_curr_out->i8_acc_frame_32x32_sum_act[i4_k] +
(ps_curr_out->i4_acc_frame_32x32_num_blks[i4_k] >> 1)) /
ps_curr_out->i4_acc_frame_32x32_num_blks[i4_k];
ps_curr_out->ld_curr_frame_32x32_log_avg[i4_k] =
(log(1 + (long double)ps_curr_out->i8_curr_frame_32x32_avg_act[i4_k]) /
log(2.0));
AVG_ACTIVITY(ps_curr_out->i8_curr_frame_32x32_avg_act[j],
ps_curr_out->i8_acc_frame_32x32_sum_act[j],
ps_curr_out->i4_acc_frame_32x32_num_blks[j]);
ps_curr_out->ld_curr_frame_32x32_log_avg[j] =
fast_log2(1 + ps_curr_out->i8_curr_frame_32x32_avg_act[j]);
}
}
/*store the avg activity for B pictures*/
{
/* store the avg activity for B pictures */
#if POW_OPT
ps_enc_ctxt->ald_lap2_8x8_log_avg_act_from_T0[0] =
ps_curr_out->ld_curr_frame_8x8_log_avg[0];
ps_enc_ctxt->ald_lap2_8x8_log_avg_act_from_T0[1] =
ps_curr_out->ld_curr_frame_8x8_log_avg[1];
ps_enc_ctxt->ald_lap2_16x16_log_avg_act_from_T0[0] =
ps_curr_out->ld_curr_frame_16x16_log_avg[0];
ps_enc_ctxt->ald_lap2_16x16_log_avg_act_from_T0[1] =
ps_curr_out->ld_curr_frame_16x16_log_avg[1];
ps_enc_ctxt->ald_lap2_16x16_log_avg_act_from_T0[2] =
ps_curr_out->ld_curr_frame_16x16_log_avg[2];
ps_enc_ctxt->ald_lap2_32x32_log_avg_act_from_T0[0] =
ps_curr_out->ld_curr_frame_32x32_log_avg[0];
ps_enc_ctxt->ald_lap2_32x32_log_avg_act_from_T0[1] =
ps_curr_out->ld_curr_frame_32x32_log_avg[1];
ps_enc_ctxt->ald_lap2_32x32_log_avg_act_from_T0[2] =
ps_curr_out->ld_curr_frame_32x32_log_avg[2];
ps_enc_ctxt->ald_lap2_8x8_log_avg_act_from_T0[0] = ps_curr_out->ld_curr_frame_8x8_log_avg[0];
ps_enc_ctxt->ald_lap2_8x8_log_avg_act_from_T0[1] = ps_curr_out->ld_curr_frame_8x8_log_avg[1];
ps_enc_ctxt->ald_lap2_16x16_log_avg_act_from_T0[0] = ps_curr_out->ld_curr_frame_16x16_log_avg[0];
ps_enc_ctxt->ald_lap2_16x16_log_avg_act_from_T0[1] = ps_curr_out->ld_curr_frame_16x16_log_avg[1];
ps_enc_ctxt->ald_lap2_16x16_log_avg_act_from_T0[2] = ps_curr_out->ld_curr_frame_16x16_log_avg[2];
ps_enc_ctxt->ald_lap2_32x32_log_avg_act_from_T0[0] = ps_curr_out->ld_curr_frame_32x32_log_avg[0];
ps_enc_ctxt->ald_lap2_32x32_log_avg_act_from_T0[1] = ps_curr_out->ld_curr_frame_32x32_log_avg[1];
ps_enc_ctxt->ald_lap2_32x32_log_avg_act_from_T0[2] = ps_curr_out->ld_curr_frame_32x32_log_avg[2];
#else
ps_enc_ctxt->ai8_lap2_8x8_avg_act_from_T0[0] =
ps_curr_out->i8_curr_frame_8x8_avg_act[0];
ps_enc_ctxt->ai8_lap2_8x8_avg_act_from_T0[1] =
ps_curr_out->i8_curr_frame_8x8_avg_act[1];
ps_enc_ctxt->ai8_lap2_16x16_avg_act_from_T0[0] =
ps_curr_out->i8_curr_frame_16x16_avg_act[0];
ps_enc_ctxt->ai8_lap2_16x16_avg_act_from_T0[1] =
ps_curr_out->i8_curr_frame_16x16_avg_act[1];
ps_enc_ctxt->ai8_lap2_16x16_avg_act_from_T0[2] =
ps_curr_out->i8_curr_frame_16x16_avg_act[2];
ps_enc_ctxt->ai8_lap2_32x32_avg_act_from_T0[0] =
ps_curr_out->i8_curr_frame_32x32_avg_act[0];
ps_enc_ctxt->ai8_lap2_32x32_avg_act_from_T0[1] =
ps_curr_out->i8_curr_frame_32x32_avg_act[1];
ps_enc_ctxt->ai8_lap2_32x32_avg_act_from_T0[2] =
ps_curr_out->i8_curr_frame_32x32_avg_act[2];
ps_enc_ctxt->ai8_lap2_8x8_avg_act_from_T0[0] = ps_curr_out->i8_curr_frame_8x8_avg_act[0];
ps_enc_ctxt->ai8_lap2_8x8_avg_act_from_T0[1] = ps_curr_out->i8_curr_frame_8x8_avg_act[1];
ps_enc_ctxt->ai8_lap2_16x16_avg_act_from_T0[0] = ps_curr_out->i8_curr_frame_16x16_avg_act[0];
ps_enc_ctxt->ai8_lap2_16x16_avg_act_from_T0[1] = ps_curr_out->i8_curr_frame_16x16_avg_act[1];
ps_enc_ctxt->ai8_lap2_16x16_avg_act_from_T0[2] = ps_curr_out->i8_curr_frame_16x16_avg_act[2];
ps_enc_ctxt->ai8_lap2_32x32_avg_act_from_T0[0] = ps_curr_out->i8_curr_frame_32x32_avg_act[0];
ps_enc_ctxt->ai8_lap2_32x32_avg_act_from_T0[1] = ps_curr_out->i8_curr_frame_32x32_avg_act[1];
ps_enc_ctxt->ai8_lap2_32x32_avg_act_from_T0[2] = ps_curr_out->i8_curr_frame_32x32_avg_act[2];
#endif
}
/*Calculte modulation index */
/* calculate modulation index */
{
LWORD64 i8_mean, i8_mean_sqr, i8_variance;
LWORD64 i8_deviation;
@ -5879,44 +5649,34 @@ void ihevce_variance_calc_acc_activity(enc_ctxt_t *ps_enc_ctxt, WORD32 i4_cur_ip
if(ps_curr_out->i4_acc_frame_8x8_num_blks[0] > 0)
{
#if STRENGTH_BASED_ON_CURR_FRM
i8_mean_sqr =
((ps_curr_out->i8_curr_frame_8x8_sum_act_sqr +
(ps_curr_out->i4_curr_frame_8x8_num_blks[0] >> 1)) /
ps_curr_out->i4_curr_frame_8x8_num_blks[0]);
AVG_ACTIVITY(i8_mean_sqr, ps_curr_out->i8_curr_frame_8x8_sum_act_sqr,
ps_curr_out->i4_curr_frame_8x8_num_blks[0]);
#else
i8_mean_sqr =
((ps_curr_out->i8_acc_frame_8x8_sum_act_sqr +
(ps_curr_out->i4_acc_frame_8x8_num_blks[0] >> 1)) /
ps_curr_out->i4_acc_frame_8x8_num_blks[0]);
AVG_ACTIVITY(i8_mean_sqr, ps_curr_out->i8_acc_frame_8x8_sum_act_sqr,
ps_curr_out->i4_acc_frame_8x8_num_blks[0]);
#endif
i8_mean = (ps_curr_out->i8_curr_frame_8x8_sum_act_for_strength);
i8_mean = ps_curr_out->i8_curr_frame_8x8_sum_act_for_strength;
i8_variance = i8_mean_sqr - (i8_mean * i8_mean);
i8_deviation = (LWORD64)sqrt((long double)i8_variance);
#if STRENGTH_BASED_ON_DEVIATION
i8_deviation = sqrt(i8_variance);
if(((float)i8_deviation) <= (REF_MOD_DEVIATION))
#if STRENGTH_BASED_ON_DEVIATION
if(i8_deviation <= REF_MOD_DEVIATION)
{
f_strength =
(float)((((float)i8_deviation - (BELOW_REF_DEVIATION)) * REF_MOD_STRENGTH) / ((REF_MOD_DEVIATION) - (BELOW_REF_DEVIATION)));
f_strength = ((i8_deviation - BELOW_REF_DEVIATION) * REF_MOD_STRENGTH) / (REF_MOD_DEVIATION - BELOW_REF_DEVIATION);
}
else
{
f_strength =
(float)((((float)i8_deviation - (ABOVE_REF_DEVIATION)) * REF_MOD_STRENGTH) / ((REF_MOD_DEVIATION) - (ABOVE_REF_DEVIATION)));
f_strength = ((i8_deviation - ABOVE_REF_DEVIATION) * REF_MOD_STRENGTH) / (REF_MOD_DEVIATION - ABOVE_REF_DEVIATION);
}
#else
f_strength = (((float)((float)i8_mean_sqr / (float)(i8_mean * i8_mean)) - 1.0)) *
REF_MOD_STRENGTH / REF_MOD_VARIANCE;
f_strength = ((i8_mean_sqr / (float)(i8_mean * i8_mean)) - 1.0) * REF_MOD_STRENGTH / REF_MOD_VARIANCE;
#endif
i4_mod_factor = (WORD32)(i8_deviation / 60);
f_strength = (float)CLIP3(f_strength, 0.0, REF_MAX_STRENGTH);
f_strength = CLIP3(f_strength, 0.0, REF_MAX_STRENGTH);
}
else
{
/*If not sufficient blocks are present, turn modulation index to 1 */
/* If not sufficient blocks are present, turn modulation index to 1 */
i4_mod_factor = 1;
f_strength = 0;
}
@ -5924,159 +5684,39 @@ void ihevce_variance_calc_acc_activity(enc_ctxt_t *ps_enc_ctxt, WORD32 i4_cur_ip
ps_curr_out->ai4_mod_factor_derived_by_variance[1] = i4_mod_factor;
ps_curr_out->f_strength = f_strength;
if(1 == ps_enc_ctxt->s_runtime_src_prms.i4_field_pic)
{
/*For Interlace period, store mod factor and strenght if only first field*/
if(1 == ps_enc_ctxt->s_multi_thrd.aps_curr_inp_pre_enc[i4_cur_ipe_idx]
->s_lap_out.i4_first_field)
{
ps_enc_ctxt->ai4_mod_factor_derived_by_variance[0] = i4_mod_factor;
ps_enc_ctxt->ai4_mod_factor_derived_by_variance[1] = i4_mod_factor;
ps_enc_ctxt->f_strength = f_strength;
}
}
else
{
ps_enc_ctxt->ai4_mod_factor_derived_by_variance[0] = i4_mod_factor;
ps_enc_ctxt->ai4_mod_factor_derived_by_variance[1] = i4_mod_factor;
ps_enc_ctxt->f_strength = f_strength;
}
ps_enc_ctxt->ai4_mod_factor_derived_by_variance[0] = i4_mod_factor;
ps_enc_ctxt->ai4_mod_factor_derived_by_variance[1] = i4_mod_factor;
ps_enc_ctxt->f_strength = f_strength;
}
}
else
{
ps_curr_out->ai4_mod_factor_derived_by_variance[0] =
ps_enc_ctxt->ai4_mod_factor_derived_by_variance[0];
ps_curr_out->ai4_mod_factor_derived_by_variance[1] =
ps_enc_ctxt->ai4_mod_factor_derived_by_variance[1];
ps_curr_out->ai4_mod_factor_derived_by_variance[0] = ps_enc_ctxt->ai4_mod_factor_derived_by_variance[0];
ps_curr_out->ai4_mod_factor_derived_by_variance[1] = ps_enc_ctxt->ai4_mod_factor_derived_by_variance[1];
ps_curr_out->f_strength = ps_enc_ctxt->f_strength;
/*copy the prev avg activity from Tid 0 for B pictures*/
{
/* copy the prev avg activity from Tid 0 for B pictures*/
#if POW_OPT
ps_curr_out->ld_curr_frame_8x8_log_avg[0] =
ps_enc_ctxt->ald_lap2_8x8_log_avg_act_from_T0[0];
ps_curr_out->ld_curr_frame_8x8_log_avg[1] =
ps_enc_ctxt->ald_lap2_8x8_log_avg_act_from_T0[1];
ps_curr_out->ld_curr_frame_16x16_log_avg[0] =
ps_enc_ctxt->ald_lap2_16x16_log_avg_act_from_T0[0];
ps_curr_out->ld_curr_frame_16x16_log_avg[1] =
ps_enc_ctxt->ald_lap2_16x16_log_avg_act_from_T0[1];
ps_curr_out->ld_curr_frame_16x16_log_avg[2] =
ps_enc_ctxt->ald_lap2_16x16_log_avg_act_from_T0[2];
ps_curr_out->ld_curr_frame_32x32_log_avg[0] =
ps_enc_ctxt->ald_lap2_32x32_log_avg_act_from_T0[0];
ps_curr_out->ld_curr_frame_32x32_log_avg[1] =
ps_enc_ctxt->ald_lap2_32x32_log_avg_act_from_T0[1];
ps_curr_out->ld_curr_frame_32x32_log_avg[2] =
ps_enc_ctxt->ald_lap2_32x32_log_avg_act_from_T0[2];
ps_curr_out->ld_curr_frame_8x8_log_avg[0] = ps_enc_ctxt->ald_lap2_8x8_log_avg_act_from_T0[0];
ps_curr_out->ld_curr_frame_8x8_log_avg[1] = ps_enc_ctxt->ald_lap2_8x8_log_avg_act_from_T0[1];
ps_curr_out->ld_curr_frame_16x16_log_avg[0] = ps_enc_ctxt->ald_lap2_16x16_log_avg_act_from_T0[0];
ps_curr_out->ld_curr_frame_16x16_log_avg[1] = ps_enc_ctxt->ald_lap2_16x16_log_avg_act_from_T0[1];
ps_curr_out->ld_curr_frame_16x16_log_avg[2] = ps_enc_ctxt->ald_lap2_16x16_log_avg_act_from_T0[2];
ps_curr_out->ld_curr_frame_32x32_log_avg[0] = ps_enc_ctxt->ald_lap2_32x32_log_avg_act_from_T0[0];
ps_curr_out->ld_curr_frame_32x32_log_avg[1] = ps_enc_ctxt->ald_lap2_32x32_log_avg_act_from_T0[1];
ps_curr_out->ld_curr_frame_32x32_log_avg[2] = ps_enc_ctxt->ald_lap2_32x32_log_avg_act_from_T0[2];
#else
ps_curr_out->i8_curr_frame_8x8_avg_act[0] =
ps_enc_ctxt->ai8_lap2_8x8_avg_act_from_T0[0];
ps_curr_out->i8_curr_frame_8x8_avg_act[1] =
ps_enc_ctxt->ai8_lap2_8x8_avg_act_from_T0[1];
ps_curr_out->i8_curr_frame_16x16_avg_act[0] =
ps_enc_ctxt->ai8_lap2_16x16_avg_act_from_T0[0];
ps_curr_out->i8_curr_frame_16x16_avg_act[1] =
ps_enc_ctxt->ai8_lap2_16x16_avg_act_from_T0[1];
ps_curr_out->i8_curr_frame_16x16_avg_act[2] =
ps_enc_ctxt->ai8_lap2_16x16_avg_act_from_T0[2];
ps_curr_out->i8_curr_frame_32x32_avg_act[0] =
ps_enc_ctxt->ai8_lap2_32x32_avg_act_from_T0[0];
ps_curr_out->i8_curr_frame_32x32_avg_act[1] =
ps_enc_ctxt->ai8_lap2_32x32_avg_act_from_T0[1];
ps_curr_out->i8_curr_frame_32x32_avg_act[2] =
ps_enc_ctxt->ai8_lap2_32x32_avg_act_from_T0[2];
ps_curr_out->i8_curr_frame_8x8_avg_act[0] = ps_enc_ctxt->ai8_lap2_8x8_avg_act_from_T0[0];
ps_curr_out->i8_curr_frame_8x8_avg_act[1] = ps_enc_ctxt->ai8_lap2_8x8_avg_act_from_T0[1];
ps_curr_out->i8_curr_frame_16x16_avg_act[0] = ps_enc_ctxt->ai8_lap2_16x16_avg_act_from_T0[0];
ps_curr_out->i8_curr_frame_16x16_avg_act[1] = ps_enc_ctxt->ai8_lap2_16x16_avg_act_from_T0[1];
ps_curr_out->i8_curr_frame_16x16_avg_act[2] = ps_enc_ctxt->ai8_lap2_16x16_avg_act_from_T0[2];
ps_curr_out->i8_curr_frame_32x32_avg_act[0] = ps_enc_ctxt->ai8_lap2_32x32_avg_act_from_T0[0];
ps_curr_out->i8_curr_frame_32x32_avg_act[1] = ps_enc_ctxt->ai8_lap2_32x32_avg_act_from_T0[1];
ps_curr_out->i8_curr_frame_32x32_avg_act[2] = ps_enc_ctxt->ai8_lap2_32x32_avg_act_from_T0[2];
#endif
}
}
/*If Compenated block, then CLIP qp to max of frame qp and modulated qp*/
{
WORD32 ctb_ctr, vert_ctr;
WORD32 ctb_ctr_blks = ps_enc_ctxt->s_frm_ctb_prms.i4_num_ctbs_horz;
WORD32 vert_ctr_blks = ps_enc_ctxt->s_frm_ctb_prms.i4_num_ctbs_vert;
ihevce_ed_ctb_l1_t *ps_ed_ctb_pic_l1 =
ps_enc_ctxt->s_multi_thrd.aps_curr_out_pre_enc[i4_cur_ipe_idx]->ps_ed_ctb_l1;
WORD32 i4_pic_type =
ps_enc_ctxt->s_multi_thrd.aps_curr_inp_pre_enc[i4_cur_ipe_idx]->s_lap_out.i4_pic_type;
for(vert_ctr = 0; vert_ctr < vert_ctr_blks; vert_ctr++)
{
ihevce_ed_ctb_l1_t *ps_ed_ctb_row_l1 = ps_ed_ctb_pic_l1 + vert_ctr * ctb_ctr_blks;
for(ctb_ctr = 0; ctb_ctr < ctb_ctr_blks; ctb_ctr++)
{
ihevce_ed_ctb_l1_t *ps_ed_ctb_curr_l1 = ps_ed_ctb_row_l1 + ctb_ctr;
WORD32 is_min_block_comensated_in_l32x32 = 0;
/*Populate avg satd to calculate MI and activity factors*/
for(i = 0; i < 4; i++)
{
WORD32 is_min_block_comensated_in_l116x16 = 0;
for(j = 0; j < 4; j++)
{
/*Accumulate the sum of 8*8 activities in the current layer (16*16 CU in L0)*/
if(ps_ed_ctb_curr_l1->i4_sum_4x4_satd[i * 4 + j] != -1)
{
WORD32 is_skipped = 0;
if((i4_pic_type != IV_I_FRAME) && (i4_pic_type != IV_IDR_FRAME) &&
(1 == is_skipped))
{
is_min_block_comensated_in_l116x16 += 1;
is_min_block_comensated_in_l32x32 += 1;
if(ps_ed_ctb_curr_l1->i4_8x8_satd[i * 4 + j][0] <
ps_curr_out->i8_curr_frame_8x8_avg_act[0])
ps_ed_ctb_curr_l1->i4_8x8_satd[i * 4 + j][0] = -1;
if(ps_ed_ctb_curr_l1->i4_8x8_satd[i * 4 + j][1] <
ps_curr_out->i8_curr_frame_8x8_avg_act[1])
ps_ed_ctb_curr_l1->i4_8x8_satd[i * 4 + j][1] = -1;
}
}
}
if(4 == is_min_block_comensated_in_l116x16)
{
if(ps_ed_ctb_curr_l1->i4_16x16_satd[i][0] <
ps_curr_out->i8_curr_frame_16x16_avg_act[0])
ps_ed_ctb_curr_l1->i4_16x16_satd[i][0] = -1;
if(ps_ed_ctb_curr_l1->i4_16x16_satd[i][1] <
ps_curr_out->i8_curr_frame_16x16_avg_act[1])
ps_ed_ctb_curr_l1->i4_16x16_satd[i][1] = -1;
if(ps_ed_ctb_curr_l1->i4_16x16_satd[i][2] <
ps_curr_out->i8_curr_frame_16x16_avg_act[2])
ps_ed_ctb_curr_l1->i4_16x16_satd[i][2] = -1;
}
}
if((16 == is_min_block_comensated_in_l32x32))
{
if(ps_ed_ctb_curr_l1->i4_32x32_satd[0][0] <
ps_curr_out->i8_curr_frame_32x32_avg_act[0])
ps_ed_ctb_curr_l1->i4_32x32_satd[0][0] = -1;
if(ps_ed_ctb_curr_l1->i4_32x32_satd[0][1] <
ps_curr_out->i8_curr_frame_32x32_avg_act[1])
ps_ed_ctb_curr_l1->i4_32x32_satd[0][1] = -1;
if(ps_ed_ctb_curr_l1->i4_32x32_satd[0][2] <
ps_curr_out->i8_curr_frame_32x32_avg_act[2])
ps_ed_ctb_curr_l1->i4_32x32_satd[0][2] = -1;
}
}
}
}
/**/
return;
#undef AVG_ACTIVITY
}
/*!
@ -6119,10 +5759,6 @@ WORD32 ihevce_pre_enc_process_frame_thrd(void *pv_frm_proc_thrd_ctxt)
(void)ps_hle_ctxt;
(void)i4_resolution_id;
if(i4_thrd_id == 0)
{
PROFILE_START(&ps_hle_ctxt->profile_pre_enc[i4_resolution_id]);
}
/* ---------- Processing Loop until Flush command is received --------- */
while(0 == i4_end_flag)
@ -6257,7 +5893,10 @@ WORD32 ihevce_pre_enc_process_frame_thrd(void *pv_frm_proc_thrd_ctxt)
if(OSAL_SUCCESS != i4_status)
return 0;
}
if(i4_thrd_id == 0)
{
PROFILE_START(&ps_hle_ctxt->profile_pre_enc_l1l2[i4_resolution_id]);
}
/* ------------------------------------------------------------ */
/* Layer Decomp and Pre Intra Analysis */
/* ------------------------------------------------------------ */
@ -6273,9 +5912,7 @@ WORD32 ihevce_pre_enc_process_frame_thrd(void *pv_frm_proc_thrd_ctxt)
&ps_enc_ctxt->s_frm_ctb_prms,
ps_multi_thrd,
i4_thrd_id,
i4_cur_decomp_idx,
ps_curr_out->ps_layer0_cur_satd,
ps_curr_out->ps_layer0_cur_mean);
i4_cur_decomp_idx);
}
}
@ -6470,10 +6107,7 @@ WORD32 ihevce_pre_enc_process_frame_thrd(void *pv_frm_proc_thrd_ctxt)
ihevce_decomp_pre_intra_curr_frame_pre_intra_deinit(
ps_enc_ctxt->s_module_ctxt.pv_decomp_pre_intra_ctxt,
ps_multi_thrd->aps_curr_out_pre_enc[i4_cur_coarse_me_idx],
1,
&ps_enc_ctxt->s_frm_ctb_prms,
ps_curr_inp->s_lap_out.i4_temporal_lyr_id,
i4_enable_noise_detection);
&ps_enc_ctxt->s_frm_ctb_prms);
}
}
@ -6553,10 +6187,18 @@ WORD32 ihevce_pre_enc_process_frame_thrd(void *pv_frm_proc_thrd_ctxt)
return 0;
}
if(i4_thrd_id == 0)
{
PROFILE_STOP(&ps_hle_ctxt->profile_pre_enc_l1l2[i4_resolution_id], NULL);
}
/* ----------------------------------------------------------- */
/* IPE init and process */
/* ----------------------------------------------------------- */
if(i4_thrd_id == 0)
{
PROFILE_START(&ps_hle_ctxt->profile_pre_enc_l0ipe[i4_resolution_id]);
}
if(i4_num_buf_prod_for_l0_ipe >= ps_multi_thrd->i4_delay_pre_me_btw_l0_ipe || i4_end_flag ||
i4_out_flush_flag)
{
@ -7001,10 +6643,10 @@ WORD32 ihevce_pre_enc_process_frame_thrd(void *pv_frm_proc_thrd_ctxt)
}
} while((i4_end_flag || i4_out_flush_flag) && i4_num_buf_prod_for_l0_ipe);
}
}
if(i4_thrd_id == 0)
{
PROFILE_STOP(&ps_hle_ctxt->profile_pre_enc[i4_resolution_id], NULL);
if(i4_thrd_id == 0)
{
PROFILE_STOP(&ps_hle_ctxt->profile_pre_enc_l0ipe[i4_resolution_id], NULL);
}
}
return 0;

View file

@ -109,12 +109,8 @@ void calc_l1_level_hme_intra_sad_different_qp(
WORD32 ihevce_pre_enc_process_frame_thrd(void *pv_hle_ctxt);
WORD32 ihevce_enc_process_frame_thrd(void *pv_hle_ctxt);
WORD32 ihevce_enc_frm_proc_slave_thrd(void *pv_frm_proc_thrd_ctxt);
WORD32 ihevce_pre_enc_frm_proc_slave_thrd(void *pv_frm_proc_thrd_ctxt);
void ihevce_set_pre_enc_prms(enc_ctxt_t *ps_enc_ctxt);
#endif /* _IHEVCE_FRAME_PROCESS_H_ */

View file

@ -677,11 +677,6 @@ const UWORD32 gau4_nbr_flags_8x8_4x4blks[64] = {
0x11180, 0x10180, 0x11180, 0x10180
};
/**
* @brief subset of intra modes to be evaluated during pre enc intra process
*/
const UWORD8 gau1_modes_to_eval[11] = { 0, 1, 26, 2, 6, 10, 14, 18, 22, 30, 34 };
const float gad_look_up_activity[TOT_QP_MOD_OFFSET] = { 0.314980262f, 0.353553391f, 0.396850263f,
0.445449359f, 0.5f, 0.561231024f,
0.629960525f, 0.707106781f, 0.793700526f,

View file

@ -121,7 +121,6 @@ extern UWORD8 gau1_inter_tu_shft_amt[4];
extern WORD32 g_i4_ip_funcs[MAX_NUM_IP_MODES];
extern const UWORD8 gau1_chroma422_intra_angle_mapping[36];
extern const UWORD32 gau4_nbr_flags_8x8_4x4blks[64];
extern const UWORD8 gau1_modes_to_eval[11];
extern WORD32 gai4_subBlock2csbfId_map4x4TU[1];
extern WORD32 gai4_subBlock2csbfId_map8x8TU[4];

View file

@ -443,7 +443,9 @@ IV_API_CALL_STATUS_T ihevce_hle_interface_create(ihevce_hle_ctxt_t *ps_hle_ctxt)
{
WORD32 i4_br_id;
PROFILE_INIT(&ps_hle_ctxt->profile_pre_enc[ctr]);
PROFILE_INIT(&ps_hle_ctxt->profile_enc_me[ctr]);
PROFILE_INIT(&ps_hle_ctxt->profile_pre_enc_l1l2[ctr]);
PROFILE_INIT(&ps_hle_ctxt->profile_pre_enc_l0ipe[ctr]);
for(i4_br_id = 0; i4_br_id < ps_enc_ctxt->i4_num_bitrates; i4_br_id++)
{
PROFILE_INIT(&ps_hle_ctxt->profile_enc[ctr][i4_br_id]);
@ -2243,10 +2245,12 @@ IV_API_CALL_STATUS_T ihevce_hle_interface_delete(ihevce_hle_ctxt_t *ps_hle_ctxt)
{
WORD32 i4_br_id;
PROFILE_END(&ps_hle_ctxt->profile_pre_enc[res_ctr], "pre enc process");
PROFILE_END(&ps_hle_ctxt->profile_pre_enc_l1l2[res_ctr], "pre enc l1l2 process");
PROFILE_END(&ps_hle_ctxt->profile_pre_enc_l0ipe[res_ctr], "pre enc l0 ipe process");
PROFILE_END(&ps_hle_ctxt->profile_enc_me[res_ctr], "enc me process");
for(i4_br_id = 0; i4_br_id < ai4_num_bitrate_instances[res_ctr]; i4_br_id++)
{
PROFILE_END(&ps_hle_ctxt->profile_enc[res_ctr][i4_br_id], "enc process");
PROFILE_END(&ps_hle_ctxt->profile_enc[res_ctr][i4_br_id], "enc loop process");
PROFILE_END(&ps_hle_ctxt->profile_entropy[res_ctr][i4_br_id], "entropy process");
}
}

View file

@ -205,7 +205,9 @@ typedef struct
* profile stats
*/
profile_database_t profile_hle;
profile_database_t profile_pre_enc[IHEVCE_MAX_NUM_RESOLUTIONS];
profile_database_t profile_pre_enc_l1l2[IHEVCE_MAX_NUM_RESOLUTIONS];
profile_database_t profile_pre_enc_l0ipe[IHEVCE_MAX_NUM_RESOLUTIONS];
profile_database_t profile_enc_me[IHEVCE_MAX_NUM_RESOLUTIONS];
profile_database_t profile_enc[IHEVCE_MAX_NUM_RESOLUTIONS][IHEVCE_MAX_NUM_BITRATES];
profile_database_t profile_entropy[IHEVCE_MAX_NUM_RESOLUTIONS][IHEVCE_MAX_NUM_BITRATES];

View file

@ -213,10 +213,9 @@ void ihevce_ipe_recompute_lambda_from_min_8x8_act_in_ctb(
i8_avg_satd = ps_ctxt->i8_curr_frame_32x32_avg_act[2];
#else
i4_curr_satd = ps_ed_ctb_l1->i4_32x32_satd[0][3];
ld_avg_satd = 2.0 + ps_ctxt->ld_curr_frame_16x16_log_avg[0];
#endif
if(ps_ctxt->i4_l0ipe_qp_mod)
{
#if MODULATE_LAMDA_WHEN_SPATIAL_MOD_ON
@ -1429,7 +1428,6 @@ void ihevce_populate_ipe_ol_cu_lambda_prms(
*
*****************************************************************************
*/
#define MAX_64BIT_VAL 0x7fffffffffffffff
void ihevce_populate_ipe_frame_init(
void *pv_ctxt,
ihevce_static_cfg_params_t *ps_stat_prms,

View file

@ -54,8 +54,6 @@
#define FRAME_PARALLEL_LVL 0
#define NUM_SG_INTERLEAVED (1 + FRAME_PARALLEL_LVL)
//#define MAX_NUM_ENC_LOOP_PARALLEL ((1 << FRAME_PARALLEL_LVL) + 2)
//#define MAX_NUM_ME_PARALLEL ((1 << FRAME_PARALLEL_LVL) + 2)
#define MAX_NUM_ENC_LOOP_PARALLEL 1
#define MAX_NUM_ME_PARALLEL 1
#define DIST_MODE_3_NON_REF_B 0 // disabled for normal cases

View file

@ -1098,37 +1098,6 @@ void ihevce_mem_manager_init(enc_ctxt_t *ps_enc_ctxt, ihevce_hle_ctxt_t *ps_intr
ps_memtab[total_memtabs_used].i4_mem_size = buf_size;
/* increment the memtab counter */
total_memtabs_used++;
total_system_memtabs++;
/*
* L0 8x8 cur satd for qp mod
*/
buf_size = (a_ctb_align_wd[0] >> 3) * (a_ctb_align_ht[0] >> 3) * sizeof(ihevce_8x8_L0_satd_t) *
num_bufs_preenc_me_que;
ps_memtab[total_memtabs_used].i4_mem_alignment = 8;
ps_memtab[total_memtabs_used].e_mem_type = (IV_MEM_TYPE_T)space_for_mem_in_pre_enc_grp;
ps_memtab[total_memtabs_used].i4_mem_size = buf_size;
/* increment the memtab counter */
total_memtabs_used++;
total_system_memtabs++;
/*
* L0 8x8 cur mean for qp mod
*/
buf_size = (a_ctb_align_wd[0] >> 3) * (a_ctb_align_ht[0] >> 3) * sizeof(ihevce_8x8_L0_mean_t) *
num_bufs_preenc_me_que;
ps_memtab[total_memtabs_used].i4_mem_alignment = 8;
ps_memtab[total_memtabs_used].e_mem_type = (IV_MEM_TYPE_T)space_for_mem_in_pre_enc_grp;
ps_memtab[total_memtabs_used].i4_mem_size = buf_size;
/* increment the memtab counter */
total_memtabs_used++;
total_system_memtabs++;
@ -1913,8 +1882,6 @@ void ihevce_mem_manager_init(enc_ctxt_t *ps_enc_ctxt, ihevce_hle_ctxt_t *ps_intr
ihevce_ed_ctb_l1_t *ps_ed_ctb_l1;
ihevce_ed_blk_t *ps_layer1_buf;
ihevce_ed_blk_t *ps_layer2_buf;
ihevce_8x8_L0_satd_t *ps_layer0_cur_satd;
ihevce_8x8_L0_mean_t *ps_layer0_cur_mean;
UWORD8 *pu1_lap_input_yuv_buf[4];
UWORD8 *pu1_input_synch_ctrl_cmd;
WORD32 i4_count = 0;
@ -1989,14 +1956,6 @@ void ihevce_mem_manager_init(enc_ctxt_t *ps_enc_ctxt, ihevce_hle_ctxt_t *ps_intr
ps_ipe_analyse_ctb = (ipe_l0_ctb_analyse_for_me_t *)ps_memtab->pv_base;
ps_memtab++;
/*L0 8x8 cur satd for qp mod*/
ps_layer0_cur_satd = (ihevce_8x8_L0_satd_t *)ps_memtab->pv_base;
ps_memtab++;
/*L0 8x8 cur mean for qp mod*/
ps_layer0_cur_mean = (ihevce_8x8_L0_mean_t *)ps_memtab->pv_base;
ps_memtab++;
/*Contains ctb level information at pre-intra stage */
ps_ed_ctb_l1 = (ihevce_ed_ctb_l1_t *)ps_memtab->pv_base;
ps_memtab++;
@ -2056,8 +2015,6 @@ void ihevce_mem_manager_init(enc_ctxt_t *ps_enc_ctxt, ihevce_hle_ctxt_t *ps_intr
ps_pre_enc_bufs->pv_me_ref_idx = (void *)pu1_ref_idx_bank;
ps_pre_enc_bufs->ps_layer1_buf = ps_layer1_buf;
ps_pre_enc_bufs->ps_layer2_buf = ps_layer2_buf;
ps_pre_enc_bufs->ps_layer0_cur_satd = ps_layer0_cur_satd;
ps_pre_enc_bufs->ps_layer0_cur_mean = ps_layer0_cur_mean;
ps_pre_enc_bufs->ps_ed_ctb_l1 = ps_ed_ctb_l1;
ps_pre_enc_bufs->plf_intra_8x8_cost = plf_intra_8x8_cost;
@ -2071,7 +2028,6 @@ void ihevce_mem_manager_init(enc_ctxt_t *ps_enc_ctxt, ihevce_hle_ctxt_t *ps_intr
ps_ed_ctb_l1 += (a_ctb_align_wd[1] >> 5) * (a_ctb_align_ht[1] >> 5);
ps_layer1_buf += (a_ctb_align_wd[1] >> 2) * (a_ctb_align_ht[1] >> 2);
ps_layer2_buf += (a_ctb_align_wd[2] >> 2) * (a_ctb_align_ht[2] >> 2);
ps_layer0_cur_satd += (a_ctb_align_wd[0] >> 3) * (a_ctb_align_ht[0] >> 3);
ps_pre_enc_bufs++;
}

View file

@ -760,58 +760,21 @@ void ihevce_bracketing_analysis(
/* ------------------------------------------------ */
/* populate the early decisions done by L1 analysis */
/* ------------------------------------------------ */
for(i = 0; i < (MAX_CU_IN_CTB >> 2); i++)
{
ihevce_ed_blk_t *ps_ed_blk_l1_curr = ps_ed_l1_ctb;
WORD32 ctr_8x8;
WORD8 *pi1_ed_buf;
/* set all the decisions to invalid */
memset(
&ps_l0_ipe_out_ctb->ai1_early_intra_inter_decision[0],
0,
sizeof(UWORD8) * MAX_CU_IN_CTB);
pi1_ed_buf = &ps_l0_ipe_out_ctb->ai1_early_intra_inter_decision[0];
for(ctr_8x8 = 0; ctr_8x8 < MAX_CTB_SIZE; ctr_8x8++)
{
WORD32 pos_x_8x8, pos_y_8x8;
pos_x_8x8 = gau1_cu_pos_x[ctr_8x8];
pos_y_8x8 = gau1_cu_pos_y[ctr_8x8];
pi1_ed_buf[pos_x_8x8 + (pos_y_8x8 * MAX_CU_IN_CTB_ROW)] =
ps_ed_blk_l1_curr->intra_or_inter;
ps_ed_blk_l1_curr++;
}
for(ctr_8x8 = 0; ctr_8x8 < (MAX_CU_IN_CTB >> 2); ctr_8x8++)
{
ps_l0_ipe_out_ctb->ai4_best_sad_8x8_l1_ipe[ctr_8x8] =
ps_ed_ctb_l1->i4_best_sad_8x8_l1_ipe[ctr_8x8];
ps_l0_ipe_out_ctb->ai4_best_sad_cost_8x8_l1_ipe[ctr_8x8] =
ps_ed_ctb_l1->i4_best_sad_cost_8x8_l1_ipe[ctr_8x8];
/*Earlier only me sad was getting populated, now best of ipe and me is populated*/
ps_l0_ipe_out_ctb->ai4_best_sad_8x8_l1_me[ctr_8x8] =
ps_ed_ctb_l1->i4_best_sad_8x8_l1_me[ctr_8x8];
//ps_ed_ctb_l1->i4_sad_me_for_ref[ctr_8x8];
ps_l0_ipe_out_ctb->ai4_best_sad_cost_8x8_l1_me[ctr_8x8] =
ps_ed_ctb_l1->i4_best_sad_cost_8x8_l1_me[ctr_8x8];
//ps_ed_ctb_l1->i4_sad_cost_me_for_ref[ctr_8x8];
}
/*Init CTB level accumalated SATD and MPM bits */
ps_l0_ipe_out_ctb->i4_ctb_acc_satd = 0;
ps_l0_ipe_out_ctb->i4_ctb_acc_mpm_bits = 0;
ps_l0_ipe_out_ctb->ai4_best_sad_8x8_l1_ipe[i] = ps_ed_ctb_l1->i4_best_sad_8x8_l1_ipe[i];
ps_l0_ipe_out_ctb->ai4_best_sad_cost_8x8_l1_ipe[i] = ps_ed_ctb_l1->i4_best_sad_cost_8x8_l1_ipe[i];
ps_l0_ipe_out_ctb->ai4_best_sad_8x8_l1_me[i] = ps_ed_ctb_l1->i4_best_sad_8x8_l1_me[i];
ps_l0_ipe_out_ctb->ai4_best_sad_cost_8x8_l1_me[i] = ps_ed_ctb_l1->i4_best_sad_cost_8x8_l1_me[i];
}
/* Init CTB level accumalated SATD and MPM bits */
ps_l0_ipe_out_ctb->i4_ctb_acc_satd = 0;
ps_l0_ipe_out_ctb->i4_ctb_acc_mpm_bits = 0;
/* ------------------------------------------------ */
/* Loop over all the blocks in current CTB */
/* ------------------------------------------------ */
{
/* 64 8x8 blocks should be encountered for the do,while loop to exit */
do
@ -1000,7 +963,6 @@ void ihevce_bracketing_analysis(
//set only first mode since if it's 255. it wont go ahead
ps_intra32_analyse->au1_best_modes_32x32_tu[0] = 255;
ps_intra32_analyse->au1_best_modes_16x16_tu[0] = 255;
ps_intra32_analyse->i4_best_intra_cost = MAX_INTRA_COST_IPE;
*pi4_intra_32_cost = MAX_INTRA_COST_IPE;
@ -1014,8 +976,6 @@ void ihevce_bracketing_analysis(
.au1_best_modes_16x16_tu[0] = 255;
ps_intra32_analyse->as_intra16_analyse[i4_local_ctr1]
.au1_best_modes_8x8_tu[0] = 255;
ps_intra32_analyse->as_intra16_analyse[i4_local_ctr1]
.i4_best_intra_cost = MAX_INTRA_COST_IPE;
ps_intra32_analyse->as_intra16_analyse[i4_local_ctr1].b1_merge_flag = 0;
ps_intra32_analyse->as_intra16_analyse[i4_local_ctr1].b1_valid_cu = 0;
ps_intra32_analyse->as_intra16_analyse[i4_local_ctr1].b1_split_flag = 0;
@ -1048,9 +1008,6 @@ void ihevce_bracketing_analysis(
ps_intra32_analyse->as_intra16_analyse[i4_local_ctr1]
.as_intra8_analyse[i4_local_ctr2]
.au1_best_modes_4x4_tu[0] = 255;
ps_intra32_analyse->as_intra16_analyse[i4_local_ctr1]
.as_intra8_analyse[i4_local_ctr2]
.i4_best_intra_cost = MAX_INTRA_COST_IPE;
ps_intra32_analyse->as_intra16_analyse[i4_local_ctr1]
.as_intra8_analyse[i4_local_ctr2]
.b1_valid_cu = 0;
@ -1623,7 +1580,6 @@ void ihevce_bracketing_analysis(
//set only first mode since if it's 255. it wont go ahead
ps_intra16_analyse->au1_best_modes_16x16_tu[0] = 255;
ps_intra16_analyse->au1_best_modes_8x8_tu[0] = 255;
ps_intra16_analyse->i4_best_intra_cost = MAX_INTRA_COST_IPE;
*pi4_intra_16_cost = MAX_INTRA_COST_IPE;
/*since ME will start evaluating from bottom up, set the lower
@ -1642,8 +1598,6 @@ void ihevce_bracketing_analysis(
.au1_best_modes_8x8_tu[0] = 255;
ps_intra16_analyse->as_intra8_analyse[i4_local_ctr]
.au1_best_modes_4x4_tu[0] = 255;
ps_intra16_analyse->as_intra8_analyse[i4_local_ctr].i4_best_intra_cost =
MAX_INTRA_COST_IPE;
pi4_intra_8_cost
[(i4_local_ctr & 1) + (MAX_CU_IN_CTB_ROW * (i4_local_ctr >> 1))] =
@ -2137,8 +2091,6 @@ void ihevce_bracketing_analysis(
ps_intra16_analyse->b1_valid_cu = 0;
ps_intra16_analyse->b1_merge_flag = 0;
ps_intra16_analyse->i4_best_intra_cost = MAX_INTRA_COST_IPE;
for(i = 0; i < 4; i++)
{
intra8_analyse_t *ps_intra8_analyse;
@ -2159,7 +2111,6 @@ void ihevce_bracketing_analysis(
ps_intra8_analyse->au1_4x4_best_modes[3][0] = 255;
ps_intra8_analyse->au1_best_modes_4x4_tu[0] = 255;
ps_intra8_analyse->au1_best_modes_8x8_tu[0] = 255;
ps_intra8_analyse->i4_best_intra_cost = MAX_INTRA_COST_IPE;
ps_cu_node->ps_parent->u1_cu_size = 8;
ps_cu_node->ps_parent->u2_x0 =