Revert "Refactor handling of configuration overrides from Vp8FrameBufferController"
This reverts commit 4d6795f828bc4f2b050405b0ff73d4020b2a2963.
Reason for revert: chromium:961253
Original change's description:
> Refactor handling of configuration overrides from Vp8FrameBufferController
>
> Make Vp8FrameBufferController::UpdateConfiguration return a set
> of desired overrides. These overrides are cumulative with
> previously returned override sets.
>
> Bug: webrtc:10382
> Change-Id: I1aa9544ae0cf6c57115e80963b3bbcdc3101db5e
> Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/134649
> Reviewed-by: Rasmus Brandt <brandtr@webrtc.org>
> Reviewed-by: Erik Språng <sprang@webrtc.org>
> Commit-Queue: Elad Alon <eladalon@webrtc.org>
> Cr-Commit-Position: refs/heads/master@{#27835}
TBR=brandtr@webrtc.org,eladalon@webrtc.org,sprang@webrtc.org
Bug: chromium:961253
Change-Id: I06f0eafd4f38c441ddbdfeebae8055b02465eb9b
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/135940
Commit-Queue: Elad Alon <eladalon@webrtc.org>
Reviewed-by: Elad Alon <eladalon@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#27900}
diff --git a/api/video_codecs/vp8_frame_buffer_controller.h b/api/video_codecs/vp8_frame_buffer_controller.h
index bcfbd97..f71740e 100644
--- a/api/video_codecs/vp8_frame_buffer_controller.h
+++ b/api/video_codecs/vp8_frame_buffer_controller.h
@@ -11,7 +11,6 @@
#ifndef API_VIDEO_CODECS_VP8_FRAME_BUFFER_CONTROLLER_H_
#define API_VIDEO_CODECS_VP8_FRAME_BUFFER_CONTROLLER_H_
-#include <array>
#include <memory>
#include <vector>
@@ -47,48 +46,34 @@
struct CodecSpecificInfo;
-// Each member represents an override of the VPX configuration if the optional
-// value is set.
+// TODO(eladalon): This configuration is temporal-layers specific; refactor.
struct Vp8EncoderConfig {
- struct TemporalLayerConfig {
- bool operator!=(const TemporalLayerConfig& other) const {
- return ts_number_layers != other.ts_number_layers ||
- ts_target_bitrate != other.ts_target_bitrate ||
- ts_rate_decimator != other.ts_rate_decimator ||
- ts_periodicity != other.ts_periodicity ||
- ts_layer_id != other.ts_layer_id;
- }
+ static constexpr size_t kMaxPeriodicity = 16;
+ static constexpr size_t kMaxLayers = 5;
- static constexpr size_t kMaxPeriodicity = 16;
- static constexpr size_t kMaxLayers = 5;
+ // Number of active temporal layers. Set to 0 if not used.
+ uint32_t ts_number_layers;
+ // Arrays of length |ts_number_layers|, indicating (cumulative) target bitrate
+ // and rate decimator (e.g. 4 if every 4th frame is in the given layer) for
+ // each active temporal layer, starting with temporal id 0.
+ uint32_t ts_target_bitrate[kMaxLayers];
+ uint32_t ts_rate_decimator[kMaxLayers];
- // Number of active temporal layers. Set to 0 if not used.
- uint32_t ts_number_layers;
-
- // Arrays of length |ts_number_layers|, indicating (cumulative) target
- // bitrate and rate decimator (e.g. 4 if every 4th frame is in the given
- // layer) for each active temporal layer, starting with temporal id 0.
- std::array<uint32_t, kMaxLayers> ts_target_bitrate;
- std::array<uint32_t, kMaxLayers> ts_rate_decimator;
-
- // The periodicity of the temporal pattern. Set to 0 if not used.
- uint32_t ts_periodicity;
-
- // Array of length |ts_periodicity| indicating the sequence of temporal id's
- // to assign to incoming frames.
- std::array<uint32_t, kMaxPeriodicity> ts_layer_id;
- };
-
- absl::optional<TemporalLayerConfig> temporal_layer_config;
+ // The periodicity of the temporal pattern. Set to 0 if not used.
+ uint32_t ts_periodicity;
+ // Array of length |ts_periodicity| indicating the sequence of temporal id's
+ // to assign to incoming frames.
+ uint32_t ts_layer_id[kMaxPeriodicity];
// Target bitrate, in bps.
- absl::optional<uint32_t> rc_target_bitrate;
+ uint32_t rc_target_bitrate;
- // Clamp QP to max. Use 0 to disable clamping.
- absl::optional<uint32_t> rc_max_quantizer;
+ // Clamp QP to min/max. Use 0 to disable clamping.
+ uint32_t rc_min_quantizer;
+ uint32_t rc_max_quantizer;
- // Error resilience mode.
- absl::optional<uint32_t> g_error_resilient;
+ // If has_value(), override error resilience to value().
+ absl::optional<uint32_t> error_resilient;
};
// This interface defines a way of delegating the logic of buffer management.
@@ -98,10 +83,6 @@
public:
virtual ~Vp8FrameBufferController() = default;
- // Set limits on QP.
- // The limits are suggestion-only; the controller is allowed to exceed them.
- virtual void SetQpLimits(size_t stream_index, int min_qp, int max_qp) = 0;
-
// Number of streamed controlled by |this|.
virtual size_t StreamCount() const = 0;
@@ -122,13 +103,12 @@
const std::vector<uint32_t>& bitrates_bps,
int framerate_fps) = 0;
- // 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.)
- virtual Vp8EncoderConfig UpdateConfiguration(size_t stream_index) = 0;
+ // Called by the encoder before encoding a frame. |cfg| contains the current
+ // configuration. If the encoder wishes any part of that to be changed before
+ // the encode step, |cfg| should be changed and then return true. If false is
+ // returned, the encoder will proceed without updating the configuration.
+ virtual bool UpdateConfiguration(size_t stream_index,
+ Vp8EncoderConfig* cfg) = 0;
// Returns the recommended VP8 encode flags needed.
// The timestamp may be used as both a time and a unique identifier, and so
diff --git a/api/video_codecs/vp8_temporal_layers.cc b/api/video_codecs/vp8_temporal_layers.cc
index 22916a7..7f7d8ad 100644
--- a/api/video_codecs/vp8_temporal_layers.cc
+++ b/api/video_codecs/vp8_temporal_layers.cc
@@ -28,13 +28,6 @@
}));
}
-void Vp8TemporalLayers::SetQpLimits(size_t stream_index,
- int min_qp,
- int max_qp) {
- RTC_DCHECK_LT(stream_index, controllers_.size());
- return controllers_[stream_index]->SetQpLimits(0, min_qp, max_qp);
-}
-
size_t Vp8TemporalLayers::StreamCount() const {
return controllers_.size();
}
@@ -54,9 +47,10 @@
framerate_fps);
}
-Vp8EncoderConfig Vp8TemporalLayers::UpdateConfiguration(size_t stream_index) {
+bool Vp8TemporalLayers::UpdateConfiguration(size_t stream_index,
+ Vp8EncoderConfig* cfg) {
RTC_DCHECK_LT(stream_index, controllers_.size());
- return controllers_[stream_index]->UpdateConfiguration(0);
+ return controllers_[stream_index]->UpdateConfiguration(0, cfg);
}
Vp8FrameConfig Vp8TemporalLayers::NextFrameConfig(size_t stream_index,
diff --git a/api/video_codecs/vp8_temporal_layers.h b/api/video_codecs/vp8_temporal_layers.h
index 4194352..3864705 100644
--- a/api/video_codecs/vp8_temporal_layers.h
+++ b/api/video_codecs/vp8_temporal_layers.h
@@ -35,8 +35,6 @@
std::vector<std::unique_ptr<Vp8FrameBufferController>>&& controllers);
~Vp8TemporalLayers() override = default;
- void SetQpLimits(size_t stream_index, int min_qp, int max_qp) override;
-
size_t StreamCount() const override;
bool SupportsEncoderFrameDropping(size_t stream_index) const override;
@@ -45,7 +43,7 @@
const std::vector<uint32_t>& bitrates_bps,
int framerate_fps) override;
- Vp8EncoderConfig UpdateConfiguration(size_t stream_index) override;
+ bool UpdateConfiguration(size_t stream_index, Vp8EncoderConfig* cfg) override;
Vp8FrameConfig NextFrameConfig(size_t stream_index,
uint32_t rtp_timestamp) override;