Enable frame dropping in libaom AV1 encoder
Bug: webrtc:15225 Change-Id: Ife16a61d47d7aa2f20548d30c56bf59844de1b26 Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/307500 Commit-Queue: Sergey Silkin <ssilkin@webrtc.org> Reviewed-by: Erik Språng <sprang@webrtc.org> Cr-Commit-Position: refs/heads/main@{#40236}
This commit is contained in:
parent
a458fe5497
commit
d615704551
@ -54,7 +54,9 @@ rtc_library("libaom_av1_encoder") {
|
||||
sources = [ "libaom_av1_encoder.cc" ]
|
||||
deps = [
|
||||
"../..:video_codec_interface",
|
||||
"../../../../api:field_trials_view",
|
||||
"../../../../api:scoped_refptr",
|
||||
"../../../../api/transport:field_trial_based_config",
|
||||
"../../../../api/video:encoded_image",
|
||||
"../../../../api/video:video_frame",
|
||||
"../../../../api/video_codecs:scalability_mode",
|
||||
|
||||
@ -18,8 +18,11 @@
|
||||
|
||||
#include "absl/algorithm/container.h"
|
||||
#include "absl/base/macros.h"
|
||||
#include "absl/strings/match.h"
|
||||
#include "absl/types/optional.h"
|
||||
#include "api/field_trials_view.h"
|
||||
#include "api/scoped_refptr.h"
|
||||
#include "api/transport/field_trial_based_config.h"
|
||||
#include "api/video/encoded_image.h"
|
||||
#include "api/video/i420_buffer.h"
|
||||
#include "api/video/video_frame.h"
|
||||
@ -68,8 +71,8 @@ aom_superblock_size_t GetSuperblockSize(int width, int height, int threads) {
|
||||
|
||||
class LibaomAv1Encoder final : public VideoEncoder {
|
||||
public:
|
||||
explicit LibaomAv1Encoder(
|
||||
const absl::optional<LibaomAv1EncoderAuxConfig>& aux_config);
|
||||
LibaomAv1Encoder(const absl::optional<LibaomAv1EncoderAuxConfig>& aux_config,
|
||||
const FieldTrialsView& trials);
|
||||
~LibaomAv1Encoder();
|
||||
|
||||
int InitEncode(const VideoCodec* codec_settings,
|
||||
@ -122,6 +125,9 @@ class LibaomAv1Encoder final : public VideoEncoder {
|
||||
EncodedImageCallback* encoded_image_callback_;
|
||||
int64_t timestamp_;
|
||||
const LibaomAv1EncoderInfoSettings encoder_info_override_;
|
||||
// TODO(webrtc:15225): Kill switch for disabling frame dropping. Remove it
|
||||
// after frame dropping is fully rolled out.
|
||||
bool disable_frame_dropping_;
|
||||
};
|
||||
|
||||
int32_t VerifyCodecSettings(const VideoCodec& codec_settings) {
|
||||
@ -153,13 +159,17 @@ int32_t VerifyCodecSettings(const VideoCodec& codec_settings) {
|
||||
}
|
||||
|
||||
LibaomAv1Encoder::LibaomAv1Encoder(
|
||||
const absl::optional<LibaomAv1EncoderAuxConfig>& aux_config)
|
||||
const absl::optional<LibaomAv1EncoderAuxConfig>& aux_config,
|
||||
const FieldTrialsView& trials)
|
||||
: inited_(false),
|
||||
rates_configured_(false),
|
||||
aux_config_(aux_config),
|
||||
frame_for_encode_(nullptr),
|
||||
encoded_image_callback_(nullptr),
|
||||
timestamp_(0) {}
|
||||
timestamp_(0),
|
||||
disable_frame_dropping_(absl::StartsWith(
|
||||
trials.Lookup("WebRTC-LibaomAv1Encoder-DisableFrameDropping"),
|
||||
"Enabled")) {}
|
||||
|
||||
LibaomAv1Encoder::~LibaomAv1Encoder() {
|
||||
Release();
|
||||
@ -225,6 +235,9 @@ int LibaomAv1Encoder::InitEncode(const VideoCodec* codec_settings,
|
||||
cfg_.g_timebase.num = 1;
|
||||
cfg_.g_timebase.den = kRtpTicksPerSecond;
|
||||
cfg_.rc_target_bitrate = encoder_settings_.startBitrate; // kilobits/sec.
|
||||
cfg_.rc_dropframe_thresh =
|
||||
(!disable_frame_dropping_ && encoder_settings_.GetFrameDropEnabled()) ? 30
|
||||
: 0;
|
||||
cfg_.g_input_bit_depth = kBitDepth;
|
||||
cfg_.kf_mode = AOM_KF_DISABLED;
|
||||
cfg_.rc_min_quantizer = kQpMin;
|
||||
@ -825,12 +838,14 @@ VideoEncoder::EncoderInfo LibaomAv1Encoder::GetEncoderInfo() const {
|
||||
} // namespace
|
||||
|
||||
std::unique_ptr<VideoEncoder> CreateLibaomAv1Encoder() {
|
||||
return std::make_unique<LibaomAv1Encoder>(absl::nullopt);
|
||||
return std::make_unique<LibaomAv1Encoder>(absl::nullopt,
|
||||
FieldTrialBasedConfig());
|
||||
}
|
||||
|
||||
std::unique_ptr<VideoEncoder> CreateLibaomAv1Encoder(
|
||||
const LibaomAv1EncoderAuxConfig& aux_config) {
|
||||
return std::make_unique<LibaomAv1Encoder>(aux_config);
|
||||
return std::make_unique<LibaomAv1Encoder>(aux_config,
|
||||
FieldTrialBasedConfig());
|
||||
}
|
||||
|
||||
} // namespace webrtc
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user