Allow Vp8FrameBufferController::UpdateConfiguration to reset set of overrides

Bug: webrtc:10737
Change-Id: Ifdf82f140465d114300eda1e3ba1a26c70aaef76
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/141663
Reviewed-by: Rasmus Brandt <brandtr@webrtc.org>
Commit-Queue: Elad Alon <eladalon@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#28247}
diff --git a/api/video_codecs/vp8_frame_buffer_controller.h b/api/video_codecs/vp8_frame_buffer_controller.h
index a0e1c78..0d38455 100644
--- a/api/video_codecs/vp8_frame_buffer_controller.h
+++ b/api/video_codecs/vp8_frame_buffer_controller.h
@@ -89,6 +89,9 @@
 
   // Error resilience mode.
   absl::optional<uint32_t> g_error_resilient;
+
+  // If set to true, all previous configuration overrides should be reset.
+  bool reset_previous_configuration_overrides = false;
 };
 
 // This interface defines a way of delegating the logic of buffer management.
@@ -125,9 +128,8 @@
   // Called by the encoder before encoding a frame. Returns a set of overrides
   // the controller wishes to enact in the encoder's configuration.
   // If a value is not overridden, previous overrides are still in effect.
-  // (It is therefore not possible to go from a specific override to
-  // no-override. Once the controller takes responsibility over a value, it
-  // must maintain responsibility for it.)
+  // However, if |Vp8EncoderConfig::reset_previous_configuration_overrides|
+  // is set to |true|, all previous overrides are reset.
   virtual Vp8EncoderConfig UpdateConfiguration(size_t stream_index) = 0;
 
   // Returns the recommended VP8 encode flags needed.
diff --git a/modules/video_coding/codecs/vp8/libvpx_vp8_encoder.cc b/modules/video_coding/codecs/vp8/libvpx_vp8_encoder.cc
index 70a00d2..c3257e4 100644
--- a/modules/video_coding/codecs/vp8/libvpx_vp8_encoder.cc
+++ b/modules/video_coding/codecs/vp8/libvpx_vp8_encoder.cc
@@ -893,6 +893,11 @@
   const Vp8EncoderConfig new_config =
       frame_buffer_controller_->UpdateConfiguration(stream_index);
 
+  if (new_config.reset_previous_configuration_overrides) {
+    *config = new_config;
+    return true;
+  }
+
   const bool changes_made = MaybeExtendVp8EncoderConfig(new_config, config);
 
   // Note that overrides must be applied even if they haven't changed.