Accumulate frame tpl stats and pass through rate control api
Tpl stats is computed at the beginning of encoding the altref frame. We aggregate tpl stats of all blocks for every frame of the current group of picture. After the altref frame is encoded, the tpl stats is passed through the encode frame result to external environment. Change-Id: I2284f8cf9c45d35ba02f3ea45f0187edbbf48294
This commit is contained in:
@@ -207,6 +207,24 @@ static void update_motion_vector_info(
|
||||
}
|
||||
}
|
||||
|
||||
static void update_tpl_stats_info(const TplDepStats *input_tpl_stats_info,
|
||||
const int show_frame_count,
|
||||
TplStatsInfo *output_tpl_stats_info) {
|
||||
int frame_idx;
|
||||
for (frame_idx = 0; frame_idx < show_frame_count; ++frame_idx) {
|
||||
output_tpl_stats_info[frame_idx].intra_cost =
|
||||
input_tpl_stats_info[frame_idx].intra_cost;
|
||||
output_tpl_stats_info[frame_idx].inter_cost =
|
||||
input_tpl_stats_info[frame_idx].inter_cost;
|
||||
output_tpl_stats_info[frame_idx].mc_flow =
|
||||
input_tpl_stats_info[frame_idx].mc_flow;
|
||||
output_tpl_stats_info[frame_idx].mc_dep_cost =
|
||||
input_tpl_stats_info[frame_idx].mc_dep_cost;
|
||||
output_tpl_stats_info[frame_idx].mc_ref_cost =
|
||||
input_tpl_stats_info[frame_idx].mc_ref_cost;
|
||||
}
|
||||
}
|
||||
|
||||
static void update_frame_counts(const FRAME_COUNTS *input_counts,
|
||||
FrameCounts *output_counts) {
|
||||
// Init array sizes.
|
||||
@@ -486,6 +504,7 @@ static bool init_encode_frame_result(EncodeFrameResult *encode_frame_result,
|
||||
encode_frame_result->num_cols_4x4);
|
||||
encode_frame_result->motion_vector_info.resize(
|
||||
encode_frame_result->num_rows_4x4 * encode_frame_result->num_cols_4x4);
|
||||
encode_frame_result->tpl_stats_info.resize(MAX_LAG_BUFFERS);
|
||||
|
||||
if (encode_frame_result->coding_data.get() == nullptr) {
|
||||
return false;
|
||||
@@ -507,7 +526,7 @@ static void encode_frame_result_update_rq_history(
|
||||
}
|
||||
|
||||
static void update_encode_frame_result(
|
||||
EncodeFrameResult *encode_frame_result,
|
||||
EncodeFrameResult *encode_frame_result, const int show_frame_count,
|
||||
const ENCODE_FRAME_RESULT *encode_frame_info) {
|
||||
encode_frame_result->coding_data_bit_size =
|
||||
encode_frame_result->coding_data_byte_size * 8;
|
||||
@@ -536,6 +555,10 @@ static void update_encode_frame_result(
|
||||
kMotionVectorSubPixelPrecision);
|
||||
update_frame_counts(&encode_frame_info->frame_counts,
|
||||
&encode_frame_result->frame_counts);
|
||||
if (encode_frame_result->frame_type == kFrameTypeAltRef) {
|
||||
update_tpl_stats_info(encode_frame_info->tpl_stats_info, show_frame_count,
|
||||
&encode_frame_result->tpl_stats_info[0]);
|
||||
}
|
||||
encode_frame_result_update_rq_history(&encode_frame_info->rq_history,
|
||||
encode_frame_result);
|
||||
}
|
||||
@@ -1169,7 +1192,10 @@ void SimpleEncode::EncodeFrame(EncodeFrameResult *encode_frame_result) {
|
||||
abort();
|
||||
}
|
||||
|
||||
update_encode_frame_result(encode_frame_result, &encode_frame_info);
|
||||
const GroupOfPicture group_of_picture = this->ObserveGroupOfPicture();
|
||||
const int show_frame_count = group_of_picture.show_frame_count;
|
||||
update_encode_frame_result(encode_frame_result, show_frame_count,
|
||||
&encode_frame_info);
|
||||
PostUpdateState(*encode_frame_result);
|
||||
} else {
|
||||
// TODO(angiebird): Clean up encode_frame_result.
|
||||
|
||||
Reference in New Issue
Block a user