FPMT: Abstract call to av1_rc_postencode_update
Extracted the call to av1_rc_postencode_update() from
encode_frame_to_data_rate() to av1_post_encode_updates().
Added a flag is_dropped_frame to handle rc update for dropped frames.
Change-Id: Iefcf55345b11c50cc73cf02320a5bfc864d970c2
diff --git a/av1/encoder/encoder.c b/av1/encoder/encoder.c
index de237b3..fe73546 100644
--- a/av1/encoder/encoder.c
+++ b/av1/encoder/encoder.c
@@ -559,6 +559,7 @@
cm->width = oxcf->frm_dim_cfg.width;
cm->height = oxcf->frm_dim_cfg.height;
+ cpi->is_dropped_frame = false;
alloc_compressor_data(cpi);
@@ -3445,7 +3446,6 @@
// Since we allocate a spot for the OVERLAY frame in the gf group, we need
// to do post-encoding update accordingly.
av1_set_target_rate(cpi, cm->width, cm->height);
- av1_rc_postencode_update(cpi, *size);
if (is_psnr_calc_enabled(cpi)) {
cpi->source =
@@ -3508,6 +3508,7 @@
av1_setup_frame_size(cpi);
av1_rc_postencode_update_drop_frame(cpi);
release_scaled_references(cpi);
+ cpi->is_dropped_frame = true;
return AOM_CODEC_OK;
}
}
@@ -3687,8 +3688,6 @@
cpi->last_frame_type = current_frame->frame_type;
- av1_rc_postencode_update(cpi, *size);
-
// Clear the one shot update flags for segmentation map and mode/ref loop
// filter deltas.
cm->seg.update_map = 0;
@@ -4214,6 +4213,10 @@
AV1_PRIMARY *const ppi = cpi->ppi;
AV1_COMMON *const cm = &cpi->common;
+ if (!is_stat_generation_stage(cpi) && !cpi->is_dropped_frame) {
+ av1_rc_postencode_update(cpi, size);
+ }
+
if (pop_lookahead == 1) {
av1_lookahead_pop(cpi->ppi->lookahead, flush, cpi->compressor_stage);
}
@@ -4281,6 +4284,7 @@
av1_one_pass_cbr_svc_start_layer(cpi);
}
+ cpi->is_dropped_frame = false;
cm->showable_frame = 0;
*size = 0;
cpi->available_bs_size = avail_size;
diff --git a/av1/encoder/encoder.h b/av1/encoder/encoder.h
index 583f412..dc9500a 100644
--- a/av1/encoder/encoder.h
+++ b/av1/encoder/encoder.h
@@ -2959,6 +2959,11 @@
* Frame level Wiener filter normalization.
*/
int64_t norm_wiener_variance;
+
+ /*!
+ * Flag to indicate that current frame is dropped.
+ */
+ bool is_dropped_frame;
} AV1_COMP;
/*!
diff --git a/av1/encoder/ratectrl.h b/av1/encoder/ratectrl.h
index 0f59d94..afba7c5 100644
--- a/av1/encoder/ratectrl.h
+++ b/av1/encoder/ratectrl.h
@@ -391,8 +391,7 @@
//
// Then, call encode_frame_to_data_rate() to perform the
// actual encode. This function will in turn call encode_frame()
-// one or more times, followed by one of:
-// av1_rc_postencode_update()
+// one or more times, followed by:
// av1_rc_postencode_update_drop_frame()
//
// The majority of rate control parameters are only expected