aom: Fix keyframe counter update for dropped frames.

From 8bc0414a1c6eb52ae274e61f95ee92b0f358c1a0 Mon Sep 17 00:00:00 2001
From: Marco Paniconi <[EMAIL REDACTED]>
Date: Mon, 15 Jul 2024 15:52:24 -0700
Subject: [PATCH] Fix keyframe counter update for dropped frames.

The counters are always updated in update_rc_counters(),
for encoded or dropped frames. So the additional update
in postencode_update_drop_frame() is not needed.

Remove the update in postencode_update_drop_frame(). And
this then requires an update in RateControlRTC::ComputeQP(),
to keep external and internal RC the same.

Change-Id: I2f1f67f8aa6586603801d5d65889445e2000d720
---
 av1/encoder/ratectrl.c | 4 ----
 av1/ratectrl_rtc.cc    | 2 ++
 2 files changed, 2 insertions(+), 4 deletions(-)

diff --git a/av1/encoder/ratectrl.c b/av1/encoder/ratectrl.c
index c4048b6ce..9750ce911 100644
--- a/av1/encoder/ratectrl.c
+++ b/av1/encoder/ratectrl.c
@@ -2431,10 +2431,6 @@ void av1_rc_postencode_update(AV1_COMP *cpi, uint64_t bytes_used) {
 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);
-  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 eab3d1de3..7f1640a77 100644
--- a/av1/ratectrl_rtc.cc
+++ b/av1/ratectrl_rtc.cc
@@ -309,6 +309,8 @@ FrameDropDecision AV1RateControlRTC::ComputeQP(
       av1_rc_drop_frame(cpi_)) {
     cpi_->is_dropped_frame = true;
     av1_rc_postencode_update_drop_frame(cpi_);
+    if (cpi_->svc.spatial_layer_id == cpi_->svc.number_spatial_layers - 1)
+      cpi_->rc.frames_since_key++;
     cpi_->frame_index_set.show_frame_count++;
     cpi_->common.current_frame.frame_number++;
     return FrameDropDecision::kDrop;