rtc-svc: Fix to key frame counters for spatial layers
Fix so frames_since_key and frames_to_key are
incremented per superframe.
Change-Id: I54e6ca97051b8bf9064861084c1256cfa14b94d9
diff --git a/av1/encoder/encoder.c b/av1/encoder/encoder.c
index 6c390d6..20df292 100644
--- a/av1/encoder/encoder.c
+++ b/av1/encoder/encoder.c
@@ -4345,9 +4345,11 @@
av1_firstpass_info_move_cur_index(firstpass_info);
}
#endif
- cpi->rc.frames_since_key++;
- cpi->rc.frames_to_key--;
- cpi->rc.frames_to_fwd_kf--;
+ if (cpi->svc.spatial_layer_id == cpi->svc.number_spatial_layers - 1) {
+ cpi->rc.frames_since_key++;
+ cpi->rc.frames_to_key--;
+ cpi->rc.frames_to_fwd_kf--;
+ }
}
}
diff --git a/av1/encoder/ratectrl.c b/av1/encoder/ratectrl.c
index 7d2f5f0..9518480 100644
--- a/av1/encoder/ratectrl.c
+++ b/av1/encoder/ratectrl.c
@@ -2277,8 +2277,10 @@
void av1_rc_postencode_update_drop_frame(AV1_COMP *cpi) {
// Update buffer level with zero size, update frame counters, and return.
update_buffer_level(cpi, 0);
- cpi->rc.frames_since_key++;
- cpi->rc.frames_to_key--;
+ if (cpi->svc.spatial_layer_id == cpi->svc.number_spatial_layers - 1) {
+ cpi->rc.frames_since_key++;
+ cpi->rc.frames_to_key--;
+ }
cpi->rc.rc_2_frame = 0;
cpi->rc.rc_1_frame = 0;
cpi->rc.prev_avg_frame_bandwidth = cpi->rc.avg_frame_bandwidth;
diff --git a/av1/ratectrl_rtc.cc b/av1/ratectrl_rtc.cc
index ce2fb2b..6cf53f0 100644
--- a/av1/ratectrl_rtc.cc
+++ b/av1/ratectrl_rtc.cc
@@ -257,7 +257,8 @@
cpi_->svc.layer_context[layer].is_key_frame = 0;
}
}
- cpi_->rc.frames_since_key++;
+ if (cpi_->svc.spatial_layer_id == cpi_->svc.number_spatial_layers - 1)
+ cpi_->rc.frames_since_key++;
if (cpi_->svc.number_spatial_layers > 1 ||
cpi_->svc.number_temporal_layers > 1) {
av1_update_temporal_layer_framerate(cpi_);