Moved effort_level to FrameEncodeSettings.
Bug: b/336978562 Change-Id: Ie902b3ecc45939ae6bc5b61f8ff8a26b68c5d440 Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/350604 Reviewed-by: Erik Språng <sprang@webrtc.org> Commit-Queue: Philip Eliasson <philipel@webrtc.org> Cr-Commit-Position: refs/heads/main@{#42337}
This commit is contained in:
parent
5ef183eee8
commit
7518ae9ac9
@ -97,7 +97,7 @@ class LibaomAv1Encoder : public VideoEncoderInterface {
|
||||
aom_codec_enc_cfg_t cfg_;
|
||||
|
||||
absl::optional<VideoCodecMode> current_content_type_;
|
||||
absl::optional<int> current_effort_level_;
|
||||
std::array<absl::optional<int>, kMaxSpatialLayersWtf> current_effort_level_;
|
||||
int max_number_of_threads_;
|
||||
std::array<absl::optional<Resolution>, 8> last_resolution_in_buffer_;
|
||||
};
|
||||
@ -266,13 +266,6 @@ bool ValidateEncodeParams(
|
||||
return low <= val && val < high;
|
||||
};
|
||||
|
||||
if (!in_range(kMinEffortLevel, kMaxEffortLevel + 1,
|
||||
tu_settings.effort_level)) {
|
||||
RTC_LOG(LS_ERROR) << "Unsupported effort level "
|
||||
<< tu_settings.effort_level;
|
||||
return false;
|
||||
}
|
||||
|
||||
for (size_t i = 0; i < frame_settings.size(); ++i) {
|
||||
const VideoEncoderInterface::FrameEncodeSettings& settings =
|
||||
frame_settings[i];
|
||||
@ -282,6 +275,12 @@ bool ValidateEncodeParams(
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!in_range(kMinEffortLevel, kMaxEffortLevel + 1,
|
||||
settings.effort_level)) {
|
||||
RTC_LOG(LS_ERROR) << "Unsupported effort level " << settings.effort_level;
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!in_range(0, kMaxSpatialLayersWtf, settings.spatial_id)) {
|
||||
RTC_LOG(LS_ERROR) << "invalid spatial id " << settings.spatial_id;
|
||||
return false;
|
||||
@ -637,14 +636,6 @@ void LibaomAv1Encoder::Encode(
|
||||
return;
|
||||
}
|
||||
|
||||
if (tu_settings.effort_level != current_effort_level_) {
|
||||
// For RTC we use speed level 6 to 10, with 8 being the default. Note that
|
||||
// low effort means higher speed.
|
||||
SET_OR_DO_ERROR_CALLBACK_AND_RETURN(AOME_SET_CPUUSED,
|
||||
8 - tu_settings.effort_level);
|
||||
current_effort_level_ = tu_settings.effort_level;
|
||||
}
|
||||
|
||||
if (current_content_type_ != tu_settings.content_hint) {
|
||||
if (tu_settings.content_hint == VideoCodecMode::kScreensharing) {
|
||||
// TD: Set speed 11?
|
||||
@ -738,6 +729,14 @@ void LibaomAv1Encoder::Encode(
|
||||
// TD: What should duration be when Cqp is used?
|
||||
duration = TimeDelta::Millis(1);
|
||||
}
|
||||
|
||||
if (settings.effort_level != current_effort_level_[settings.spatial_id]) {
|
||||
// For RTC we use speed level 6 to 10, with 8 being the default. Note
|
||||
// that low effort means higher speed.
|
||||
SET_OR_DO_ERROR_CALLBACK_AND_RETURN(AOME_SET_CPUUSED,
|
||||
8 - settings.effort_level);
|
||||
current_effort_level_[settings.spatial_id] = settings.effort_level;
|
||||
}
|
||||
}
|
||||
|
||||
RTC_LOG(LS_WARNING)
|
||||
|
||||
@ -178,6 +178,11 @@ class FrameEncoderSettingsBuilder {
|
||||
return *this;
|
||||
}
|
||||
|
||||
FrameEncoderSettingsBuilder& Effort(int effort_level) {
|
||||
frame_encode_settings_.effort_level = effort_level;
|
||||
return *this;
|
||||
}
|
||||
|
||||
operator VideoEncoderInterface::FrameEncodeSettings&&() {
|
||||
return std::move(frame_encode_settings_);
|
||||
}
|
||||
@ -661,10 +666,9 @@ TEST(LibaomAv1Encoder, HigherEffortLevelYieldsHigherQualityFrames) {
|
||||
for (int i = effort_range.first; i <= effort_range.second; ++i) {
|
||||
auto enc = LibaomAv1EncoderFactory().CreateEncoder(kCbrEncoderSettings, {});
|
||||
EncodeResults res;
|
||||
enc->Encode(
|
||||
frame_in,
|
||||
{.presentation_timestamp = Timestamp::Millis(0), .effort_level = i},
|
||||
ToVec({Fb().Rate(kCbr).Res(640, 360).Upd(0).Key().Cb(res.Cb())}));
|
||||
enc->Encode(frame_in, {.presentation_timestamp = Timestamp::Millis(0)},
|
||||
ToVec({Fb().Rate(kCbr).Res(640, 360).Upd(0).Key().Effort(i).Cb(
|
||||
res.Cb())}));
|
||||
double psnr = Psnr(frame_in, dec.Decode(*res.FrameAt(0)));
|
||||
EXPECT_THAT(psnr, Gt(psnr_last));
|
||||
psnr_last = psnr;
|
||||
|
||||
@ -40,7 +40,6 @@ class VideoEncoderInterface {
|
||||
struct TemporalUnitSettings {
|
||||
VideoCodecMode content_hint = VideoCodecMode::kRealtimeVideo;
|
||||
Timestamp presentation_timestamp;
|
||||
int effort_level = 0;
|
||||
};
|
||||
|
||||
// Results from calling Encode. Called once for each configured frame.
|
||||
@ -72,6 +71,7 @@ class VideoEncoderInterface {
|
||||
Resolution resolution;
|
||||
std::vector<int> reference_buffers;
|
||||
absl::optional<int> update_buffer;
|
||||
int effort_level = 0;
|
||||
|
||||
EncodeResultCallback result_callback;
|
||||
};
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user