Require webrtc::Environment to create VP9 encoder
Bug: webrtc:15860 Change-Id: I0a3f1381f82d0172805e6ed6c44616e5c83b7a1b Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/345743 Reviewed-by: Philip Eliasson <philipel@webrtc.org> Commit-Queue: Danil Chapovalov <danilchap@webrtc.org> Cr-Commit-Position: refs/heads/main@{#42005}
This commit is contained in:
parent
73588223c1
commit
9630287841
@ -691,15 +691,12 @@ rtc_library("webrtc_vp9") {
|
||||
"../../api:refcountedbase",
|
||||
"../../api:scoped_refptr",
|
||||
"../../api/environment",
|
||||
"../../api/transport:field_trial_based_config",
|
||||
"../../api/video:video_frame",
|
||||
"../../api/video:video_frame_i010",
|
||||
"../../api/video:video_rtp_headers",
|
||||
"../../api/video_codecs:scalability_mode",
|
||||
"../../api/video_codecs:video_codecs_api",
|
||||
"../../common_video",
|
||||
"../../media:codec",
|
||||
"../../media:media_constants",
|
||||
"../../rtc_base:buffer",
|
||||
"../../rtc_base:checks",
|
||||
"../../rtc_base:event_tracer",
|
||||
|
||||
@ -21,7 +21,6 @@
|
||||
#include "api/video_codecs/sdp_video_format.h"
|
||||
#include "api/video_codecs/video_encoder.h"
|
||||
#include "api/video_codecs/vp9_profile.h"
|
||||
#include "media/base/codec.h"
|
||||
#include "modules/video_coding/include/video_codec_interface.h"
|
||||
|
||||
namespace webrtc {
|
||||
@ -42,15 +41,9 @@ absl::Nonnull<std::unique_ptr<VideoEncoder>> CreateVp9Encoder(
|
||||
const Environment& env,
|
||||
Vp9EncoderSettings settings = {});
|
||||
|
||||
class VP9Encoder : public VideoEncoder {
|
||||
class VP9Encoder {
|
||||
public:
|
||||
// Deprecated. Use CreateVp9Encoder above, bugs.webrtc.org/15860
|
||||
static std::unique_ptr<VP9Encoder> Create();
|
||||
static std::unique_ptr<VP9Encoder> Create(const cricket::VideoCodec& codec);
|
||||
|
||||
static bool SupportsScalabilityMode(ScalabilityMode scalability_mode);
|
||||
|
||||
~VP9Encoder() override {}
|
||||
};
|
||||
|
||||
class VP9Decoder : public VideoDecoder {
|
||||
|
||||
@ -16,7 +16,6 @@
|
||||
#include <algorithm>
|
||||
|
||||
#include "absl/strings/match.h"
|
||||
#include "api/transport/field_trial_based_config.h"
|
||||
#include "api/video/color_space.h"
|
||||
#include "api/video/i010_buffer.h"
|
||||
#include "common_video/include/video_frame_buffer.h"
|
||||
|
||||
@ -226,25 +226,10 @@ void LibvpxVp9Encoder::EncoderOutputCodedPacketCallback(vpx_codec_cx_pkt* pkt,
|
||||
LibvpxVp9Encoder::LibvpxVp9Encoder(const Environment& env,
|
||||
Vp9EncoderSettings settings,
|
||||
std::unique_ptr<LibvpxInterface> interface)
|
||||
: LibvpxVp9Encoder(std::move(interface),
|
||||
settings.profile,
|
||||
env.field_trials()) {}
|
||||
|
||||
LibvpxVp9Encoder::LibvpxVp9Encoder(const cricket::VideoCodec& codec,
|
||||
std::unique_ptr<LibvpxInterface> interface,
|
||||
const FieldTrialsView& trials)
|
||||
: LibvpxVp9Encoder(
|
||||
std::move(interface),
|
||||
ParseSdpForVP9Profile(codec.params).value_or(VP9Profile::kProfile0),
|
||||
trials) {}
|
||||
|
||||
LibvpxVp9Encoder::LibvpxVp9Encoder(std::unique_ptr<LibvpxInterface> interface,
|
||||
VP9Profile profile,
|
||||
const FieldTrialsView& trials)
|
||||
: libvpx_(std::move(interface)),
|
||||
encoded_image_(),
|
||||
encoded_complete_callback_(nullptr),
|
||||
profile_(profile),
|
||||
profile_(settings.profile),
|
||||
inited_(false),
|
||||
timestamp_(0),
|
||||
rc_max_intra_target_(0),
|
||||
@ -258,30 +243,29 @@ LibvpxVp9Encoder::LibvpxVp9Encoder(std::unique_ptr<LibvpxInterface> interface,
|
||||
num_spatial_layers_(0),
|
||||
num_active_spatial_layers_(0),
|
||||
first_active_layer_(0),
|
||||
layer_deactivation_requires_key_frame_(absl::StartsWith(
|
||||
trials.Lookup("WebRTC-Vp9IssueKeyFrameOnLayerDeactivation"),
|
||||
"Enabled")),
|
||||
layer_deactivation_requires_key_frame_(env.field_trials().IsEnabled(
|
||||
"WebRTC-Vp9IssueKeyFrameOnLayerDeactivation")),
|
||||
is_svc_(false),
|
||||
inter_layer_pred_(InterLayerPredMode::kOn),
|
||||
external_ref_control_(false), // Set in InitEncode because of tests.
|
||||
trusted_rate_controller_(
|
||||
RateControlSettings::ParseFromKeyValueConfig(&trials)
|
||||
RateControlSettings::ParseFromKeyValueConfig(&env.field_trials())
|
||||
.LibvpxVp9TrustedRateController()),
|
||||
first_frame_in_picture_(true),
|
||||
ss_info_needed_(false),
|
||||
force_all_active_layers_(false),
|
||||
is_flexible_mode_(false),
|
||||
variable_framerate_experiment_(ParseVariableFramerateConfig(trials)),
|
||||
variable_framerate_experiment_(
|
||||
ParseVariableFramerateConfig(env.field_trials())),
|
||||
variable_framerate_controller_(
|
||||
variable_framerate_experiment_.framerate_limit),
|
||||
quality_scaler_experiment_(ParseQualityScalerConfig(trials)),
|
||||
quality_scaler_experiment_(ParseQualityScalerConfig(env.field_trials())),
|
||||
external_ref_ctrl_(
|
||||
!absl::StartsWith(trials.Lookup("WebRTC-Vp9ExternalRefCtrl"),
|
||||
"Disabled")),
|
||||
performance_flags_(ParsePerformanceFlagsFromTrials(trials)),
|
||||
!env.field_trials().IsDisabled("WebRTC-Vp9ExternalRefCtrl")),
|
||||
performance_flags_(ParsePerformanceFlagsFromTrials(env.field_trials())),
|
||||
num_steady_state_frames_(0),
|
||||
config_changed_(true),
|
||||
svc_frame_drop_config_(ParseSvcFrameDropConfig(trials)) {
|
||||
svc_frame_drop_config_(ParseSvcFrameDropConfig(env.field_trials())) {
|
||||
codec_ = {};
|
||||
memset(&svc_params_, 0, sizeof(vpx_svc_extra_cfg_t));
|
||||
}
|
||||
|
||||
@ -18,6 +18,7 @@
|
||||
#include <memory>
|
||||
#include <vector>
|
||||
|
||||
#include "api/environment/environment.h"
|
||||
#include "api/fec_controller_override.h"
|
||||
#include "api/field_trials_view.h"
|
||||
#include "api/video_codecs/scalability_mode.h"
|
||||
@ -35,17 +36,12 @@
|
||||
|
||||
namespace webrtc {
|
||||
|
||||
class LibvpxVp9Encoder : public VP9Encoder {
|
||||
class LibvpxVp9Encoder : public VideoEncoder {
|
||||
public:
|
||||
LibvpxVp9Encoder(const Environment& env,
|
||||
Vp9EncoderSettings settings,
|
||||
std::unique_ptr<LibvpxInterface> interface);
|
||||
|
||||
// Deprecated, bugs.webrtc.org/15860
|
||||
LibvpxVp9Encoder(const cricket::VideoCodec& codec,
|
||||
std::unique_ptr<LibvpxInterface> interface,
|
||||
const FieldTrialsView& trials);
|
||||
|
||||
~LibvpxVp9Encoder() override;
|
||||
|
||||
void SetFecControllerOverride(
|
||||
@ -66,10 +62,6 @@ class LibvpxVp9Encoder : public VP9Encoder {
|
||||
EncoderInfo GetEncoderInfo() const override;
|
||||
|
||||
private:
|
||||
LibvpxVp9Encoder(std::unique_ptr<LibvpxInterface> interface,
|
||||
VP9Profile profile,
|
||||
const FieldTrialsView& trials);
|
||||
|
||||
// Determine number of encoder threads to use.
|
||||
int NumberOfThreads(int width, int height, int number_of_cores);
|
||||
|
||||
|
||||
@ -17,8 +17,6 @@
|
||||
#include "api/video_codecs/video_encoder.h"
|
||||
#include "api/video_codecs/vp9_profile.h"
|
||||
#include "common_video/libyuv/include/webrtc_libyuv.h"
|
||||
#include "media/base/codec.h"
|
||||
#include "media/base/media_constants.h"
|
||||
#include "modules/rtp_rtcp/include/rtp_rtcp_defines.h"
|
||||
#include "modules/video_coding/codecs/interface/libvpx_interface.h"
|
||||
#include "modules/video_coding/codecs/interface/mock_libvpx_interface.h"
|
||||
@ -2218,8 +2216,8 @@ TEST(Vp9SpeedSettingsTrialsTest, NoSvcUsesGlobalSpeedFromTl0InLayerConfig) {
|
||||
// Keep a raw pointer for EXPECT calls and the like. Ownership is otherwise
|
||||
// passed on to LibvpxVp9Encoder.
|
||||
auto* const vpx = new NiceMock<MockLibvpxInterface>();
|
||||
LibvpxVp9Encoder encoder(cricket::CreateVideoCodec(cricket::kVp9CodecName),
|
||||
absl::WrapUnique<LibvpxInterface>(vpx), trials);
|
||||
LibvpxVp9Encoder encoder(CreateEnvironment(&trials), {},
|
||||
absl::WrapUnique<LibvpxInterface>(vpx));
|
||||
|
||||
VideoCodec settings = DefaultCodecSettings();
|
||||
settings.width = 480;
|
||||
@ -2262,8 +2260,8 @@ TEST(Vp9SpeedSettingsTrialsTest,
|
||||
// Keep a raw pointer for EXPECT calls and the like. Ownership is otherwise
|
||||
// passed on to LibvpxVp9Encoder.
|
||||
auto* const vpx = new NiceMock<MockLibvpxInterface>();
|
||||
LibvpxVp9Encoder encoder(cricket::CreateVideoCodec(cricket::kVp9CodecName),
|
||||
absl::WrapUnique<LibvpxInterface>(vpx), trials);
|
||||
LibvpxVp9Encoder encoder(CreateEnvironment(&trials), {},
|
||||
absl::WrapUnique<LibvpxInterface>(vpx));
|
||||
|
||||
VideoCodec settings = DefaultCodecSettings();
|
||||
settings.width = 480;
|
||||
@ -2320,8 +2318,8 @@ TEST(Vp9SpeedSettingsTrialsTest, DefaultPerLayerFlagsWithSvc) {
|
||||
// Keep a raw pointer for EXPECT calls and the like. Ownership is otherwise
|
||||
// passed on to LibvpxVp9Encoder.
|
||||
auto* const vpx = new NiceMock<MockLibvpxInterface>();
|
||||
LibvpxVp9Encoder encoder(cricket::CreateVideoCodec(cricket::kVp9CodecName),
|
||||
absl::WrapUnique<LibvpxInterface>(vpx), trials);
|
||||
LibvpxVp9Encoder encoder(CreateEnvironment(&trials), {},
|
||||
absl::WrapUnique<LibvpxInterface>(vpx));
|
||||
|
||||
VideoCodec settings = DefaultCodecSettings();
|
||||
constexpr int kNumSpatialLayers = 3;
|
||||
@ -2470,9 +2468,9 @@ TEST_P(TestVp9ImplSvcFrameDropConfig, SvcFrameDropConfig) {
|
||||
SvcFrameDropConfigTestParameters test_params = GetParam();
|
||||
auto* const vpx = new NiceMock<MockLibvpxInterface>();
|
||||
LibvpxVp9Encoder encoder(
|
||||
cricket::CreateVideoCodec(cricket::kVp9CodecName),
|
||||
absl::WrapUnique<LibvpxInterface>(vpx),
|
||||
test::ExplicitKeyValueConfig(test_params.field_trial));
|
||||
CreateEnvironment(std::make_unique<test::ExplicitKeyValueConfig>(
|
||||
test_params.field_trial)),
|
||||
{}, absl::WrapUnique<LibvpxInterface>(vpx));
|
||||
|
||||
vpx_image_t img;
|
||||
ON_CALL(*vpx, img_wrap).WillByDefault(GetWrapImageFunction(&img));
|
||||
|
||||
@ -13,11 +13,9 @@
|
||||
#include <memory>
|
||||
|
||||
#include "absl/container/inlined_vector.h"
|
||||
#include "api/transport/field_trial_based_config.h"
|
||||
#include "api/video_codecs/scalability_mode.h"
|
||||
#include "api/video_codecs/sdp_video_format.h"
|
||||
#include "api/video_codecs/vp9_profile.h"
|
||||
#include "media/base/media_constants.h"
|
||||
#include "modules/video_coding/codecs/vp9/libvpx_vp9_decoder.h"
|
||||
#include "modules/video_coding/codecs/vp9/libvpx_vp9_encoder.h"
|
||||
#include "modules/video_coding/svc/create_scalability_structure.h"
|
||||
@ -84,28 +82,6 @@ absl::Nonnull<std::unique_ptr<VideoEncoder>> CreateVp9Encoder(
|
||||
#endif
|
||||
}
|
||||
|
||||
std::unique_ptr<VP9Encoder> VP9Encoder::Create() {
|
||||
#ifdef RTC_ENABLE_VP9
|
||||
return std::make_unique<LibvpxVp9Encoder>(
|
||||
cricket::CreateVideoCodec(cricket::kVp9CodecName),
|
||||
LibvpxInterface::Create(), FieldTrialBasedConfig());
|
||||
#else
|
||||
RTC_DCHECK_NOTREACHED();
|
||||
return nullptr;
|
||||
#endif
|
||||
}
|
||||
|
||||
std::unique_ptr<VP9Encoder> VP9Encoder::Create(
|
||||
const cricket::VideoCodec& codec) {
|
||||
#ifdef RTC_ENABLE_VP9
|
||||
return std::make_unique<LibvpxVp9Encoder>(codec, LibvpxInterface::Create(),
|
||||
FieldTrialBasedConfig());
|
||||
#else
|
||||
RTC_DCHECK_NOTREACHED();
|
||||
return nullptr;
|
||||
#endif
|
||||
}
|
||||
|
||||
bool VP9Encoder::SupportsScalabilityMode(ScalabilityMode scalability_mode) {
|
||||
return ScalabilityStructureConfig(scalability_mode).has_value();
|
||||
}
|
||||
|
||||
@ -705,6 +705,7 @@ if (rtc_build_libvpx) {
|
||||
"..:test_support",
|
||||
"../../api:array_view",
|
||||
"../../api:field_trials_view",
|
||||
"../../api/environment:environment_factory",
|
||||
"../../api/video:video_frame",
|
||||
"../../api/video_codecs:video_codecs_api",
|
||||
"../../media:media_constants",
|
||||
|
||||
@ -14,6 +14,7 @@
|
||||
#include "absl/base/macros.h"
|
||||
#include "absl/container/inlined_vector.h"
|
||||
#include "api/array_view.h"
|
||||
#include "api/environment/environment_factory.h"
|
||||
#include "api/field_trials_view.h"
|
||||
#include "api/video/video_frame.h"
|
||||
#include "api/video_codecs/video_codec.h"
|
||||
@ -536,8 +537,8 @@ void FuzzOneInput(const uint8_t* data, size_t size) {
|
||||
LibvpxState state;
|
||||
|
||||
// Initialize encoder
|
||||
LibvpxVp9Encoder encoder(cricket::CreateVideoCodec(cricket::kVp9CodecName),
|
||||
std::make_unique<StubLibvpx>(&state), field_trials);
|
||||
LibvpxVp9Encoder encoder(CreateEnvironment(&field_trials), {},
|
||||
std::make_unique<StubLibvpx>(&state));
|
||||
VideoCodec codec = CodecSettings(helper);
|
||||
if (encoder.InitEncode(&codec, EncoderSettings()) != WEBRTC_VIDEO_CODEC_OK) {
|
||||
return;
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user