该部分主要包含以下几个函数:
<lookahead.h>头文件中包含2、4、5
1.static void get_ipred_neighbor(pel *dst, int x, int y, int w, int h, int pic_width, int pic_height, pel *src, int s_src, int bit_depth)
//对预测帧做像素值填充。填充最左列和最上方时,往左往右多填充一行,填充值与紧挨着的数值一样。
2.double loka_estimate_coding_cost(inter_search_t *pi, com_img_t *img_org, com_img_t **ref_l0, com_img_t **ref_l1, int num_ref[2], int bit_depth, double *icost, double icost_uv[2], float* map_dqp)
//编码代价的计算。
①开始设置base_qp=32,base_lambda = 1.43631 * pow(2.0, (base_qp - 16.0) / 4.0);
②有以下cost需要计算:
1>double total_cost = 0;
total_cost += min_cost;
2>double total_icost = 0;
total_icost += min_icost;
3>double total_icost_u = 0;
get_ipred_neighbor(nb_buf + INTRA_NEIB_MID, xc, yc, UNITC_SIZE, UNITC_SIZE, pic_width / 2, pic_height / 2, orgu, i_org_c, bit_depth);
com_intra_pred(nb_buf + INTRA_NEIB_MID, pred_buf, best_mode, UNITC_SIZE, UNITC_SIZE, bit_depth, avaliable_nb, 0);
total_icost_u += com_had(UNITC_SIZE, UNITC_SIZE, orgu, i_org_c, pred_buf, UNITC_SIZE, bit_depth);
4>double total_icost_v = 0;
get_ipred_neighbor(nb_buf + INTRA_NEIB_MID, xc, yc, UNITC_SIZE, UNITC_SIZE, pic_width / 2, pic_height / 2, orgv, i_org_c, bit_depth);
com_intra_pred(nb_buf + INTRA_NEIB_MID, pred_buf, best_mode, UNITC_SIZE, UNITC_SIZE, bit_depth, avaliable_nb, 0);
total_icost_v += com_had(UNITC_SIZE, UNITC_SIZE, orgv, i_org_c, pred_buf, UNITC_SIZE, bit_depth);
5>double total_var = 0;
var[x / UNIT_SIZE] = (float)(0.8 * log2((double)COM_MAX(energy, 1)));
total_var += var[x / UNIT_SIZE];
③运动估计的整像素搜索。me_search_tz
④com_mc_blk_luma
⑤com_had 返回SATD
3.static double loka_get_ref_cost(inter_search_t *pi, com_img_t *img_org, com_img_t *ref0, com_img_t *ref1, int bit_depth)
//顾名思义,计算参考帧的cost(pcost)。利用 loka_estimate_coding_cost
4.double loka_get_sc_ratio(inter_search_t *pi, com_img_t *img_org, com_img_t *img_last, int bit_depth)
{
函数内只有三句。
double icost;
double pcost = loka_estimate_coding_cost(pi, img_org, ref_l0, NULL, num_refp, bit_depth, &icost, NULL, NULL);
return pcost / icost;
}
5.void loka_slicetype_decision(enc_ctrl_t *h)
//分析帧的类别:I\B\P,播放序列和编码序列的转换。
IDR首个I帧。
//以场景切换(scenecut)确定GOP分组。
6.static void push_sub_gop(enc_ctrl_t *h, int start, int num, int level)
7.static void update_last_ip(enc_ctrl_t *h, com_img_t *img, int type)