/* Estimate the total amount of influence on future quality that could be had if we
* were to improve the reference samples used to inter predict any given macroblock.
*
* 若我们提升宏块的质量,则会对未来的质量照成多大的提升。
* 该函数以行为单位来调用,以宏块为单位进行计算,所以参数以向量的形式输入:
* propagate_in[i]表示宏块有多少信息是参考别人的
* intra_costs[i]表示宏块的帧内预测satd
* inter_costs[i]表示宏块的帧间预测satd
* inv_qscales[i]表示用于将satd转化为bits的参数
* fps_factor[i] 表示当前计算的一行宏块(所在帧的duration)与(所在mb_tree帧组的平均duration)的比值
* len表示一行宏块的个数
*
* dst[i] 存放计算后的propagate_amount
*
*/
static void mbtree_propagate_cost( int16_t *dst, uint16_t *propagate_in, uint16_t *intra_costs,
uint16_t *inter_costs, uint16_t *inv_qscales, float *fps_factor, int len )
{
float fps = *fps_factor;
for( int i = 0; i < len; i++ ) //遍历每个宏块
{
//得到宏块i的intra cost
int intra_cost = intra_costs[i];
//得到宏块i的inter cost,若intra_cost<=inter_cost,则inter_cost=intra_cost
int inter_cost = X264_MIN(intra_costs[i], inter_costs[i] & LOWRES_COST_MASK);
//得到intra的bits信息量
float propagate_intra = intra_cost * inv_qscales[i];
//得到当前总bits信息量,即propagate_in + propagate_intra
float propagate_amount = propagate_in[i] + propagate_intra*fps;
//propagate_num表示宏块有多少信息是通过帧间预测来的
float propagate_num = intra_cost - inter_cost;
//propagate_denom作为分母
float propagate_denom = intra_cost;
/*
propagate_num intra_cost - inter_cost
------------------ = ------------------------- * 100% 表示
propagate_denom intra_cost
帧间参考给当前宏块带来了这么多百分比的增益
*/
dst[i] = X264_MIN((int)(propagate_amount * propagate_num / propagate_denom + 0.5f), 32767);
}
}
码控-mbtree_propagate_cost()
最新推荐文章于 2024-08-28 21:01:03 发布