Remove ResourceAdaptationModule::OnMaybeEncodeFrame

We can react just as well at OnEncodeVideoFrame, which is the same
behaviour except after checking if the Encoder is paused and the frame
dropper.

For the initial frame drop, the frame dropper is irrelevant as the frame
can not be dropped until we are accepting frames. If we didn't drop the
frame, the encoder can't be paused as the data rate
is over 0.

For the quality rampup experiment, similar for encoder paused - we can't
rampup if we are paused anyways since the data rate needs to be non-zero.
If we are dropping frames we likely don't want to do quality rampup
anyways.

Bug: webrtc:11222
Change-Id: Ie3e09d9d8d509dc17ba7a1443cf4747f61c04f6a
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/168601
Reviewed-by: Henrik Boström <hbos@webrtc.org>
Reviewed-by: Ilya Nikolaevskiy <ilnik@webrtc.org>
Commit-Queue: Evan Shrubsole <eshr@google.com>
Cr-Commit-Position: refs/heads/master@{#30539}
This commit is contained in:
Evan Shrubsole
2020-02-14 14:12:48 +01:00
committed by Commit Bot
parent 06901cfb04
commit 93d9ae8a17
4 changed files with 4 additions and 17 deletions

View File

@ -119,15 +119,7 @@ class ResourceAdaptationModuleInterface {
// TODO(hbos): If we take frame rate into account perhaps it would be valid to
// adapt down in frame rate as well.
virtual void OnFrameDroppedDueToSize() = 0;
// 2.ii) If the frame will not be dropped due to size then signal that it may
// get encoded. However the frame is not guaranteed to be encoded right away
// or ever (for example if encoding is paused).
// TODO(eshr): Try replace OnMaybeEncodeFrame and merge behaviour into
// EncodeStarted.
// TODO(eshr): Try to merge OnFrame, OnFrameDroppedDueToSize, and
// OnMaybeEncode frame into one method.
virtual void OnMaybeEncodeFrame() = 0;
// 2.iii) An input frame is about to be encoded. It may have been cropped and
// 2.ii) An input frame is about to be encoded. It may have been cropped and
// have different dimensions than what was observed at OnFrame(). Next
// up: encoding completes or fails, see OnEncodeCompleted(). There is
// currently no signal for encode failure.

View File

@ -367,7 +367,7 @@ class OveruseFrameDetectorResourceAdaptationModule::InitialFrameDropper {
void OnFrameDroppedDueToSize() { ++initial_framedrop_; }
void OnMaybeEncodeFrame() { initial_framedrop_ = kMaxInitialFramedrop; }
void OnEncodeStarted() { initial_framedrop_ = kMaxInitialFramedrop; }
void OnQualityScalerSettingsUpdated() {
if (quality_scaler_resource_->is_started()) {
@ -536,6 +536,8 @@ void OveruseFrameDetectorResourceAdaptationModule::OnFrameDroppedDueToSize() {
void OveruseFrameDetectorResourceAdaptationModule::OnEncodeStarted(
const VideoFrame& cropped_frame,
int64_t time_when_first_seen_us) {
initial_frame_dropper_->OnEncodeStarted();
MaybePerformQualityRampupExperiment();
encode_usage_resource_->OnEncodeStarted(cropped_frame,
time_when_first_seen_us);
}
@ -563,11 +565,6 @@ bool OveruseFrameDetectorResourceAdaptationModule::DropInitialFrames() const {
return initial_frame_dropper_->DropInitialFrames();
}
void OveruseFrameDetectorResourceAdaptationModule::OnMaybeEncodeFrame() {
initial_frame_dropper_->OnMaybeEncodeFrame();
MaybePerformQualityRampupExperiment();
}
void OveruseFrameDetectorResourceAdaptationModule::UpdateQualityScalerSettings(
absl::optional<VideoEncoder::QpThresholds> qp_thresholds) {
if (qp_thresholds.has_value()) {

View File

@ -86,7 +86,6 @@ class OveruseFrameDetectorResourceAdaptationModule
void OnFrame(const VideoFrame& frame) override;
void OnFrameDroppedDueToSize() override;
void OnMaybeEncodeFrame() override;
void OnEncodeStarted(const VideoFrame& cropped_frame,
int64_t time_when_first_seen_us) override;
void OnEncodeCompleted(const EncodedImage& encoded_image,

View File

@ -1079,7 +1079,6 @@ void VideoStreamEncoder::MaybeEncodeVideoFrame(const VideoFrame& video_frame,
}
return;
}
resource_adaptation_module_->OnMaybeEncodeFrame();
if (EncoderPaused()) {
// Storing references to a native buffer risks blocking frame capture.