Allow to propagate field trials into Vp8 Decoder
Bug: webrtc:15791 Change-Id: I0cd279006924c7a4859697b26a2271c3dc63ea6d Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/337400 Reviewed-by: Philip Eliasson <philipel@webrtc.org> Commit-Queue: Danil Chapovalov <danilchap@webrtc.org> Cr-Commit-Position: refs/heads/main@{#41741}
This commit is contained in:
parent
f7b22c66ff
commit
b158537a4f
@ -41,8 +41,11 @@ if (rtc_include_tests) {
|
||||
"../../../rtc_base:rtc_base_tests_utils",
|
||||
"../../../test:fake_video_codecs",
|
||||
"../../../test:field_trial",
|
||||
"../../../test:scoped_key_value_config",
|
||||
"../../../test:test_support",
|
||||
"../../../test:video_test_common",
|
||||
"../../environment",
|
||||
"../../environment:environment_factory",
|
||||
"../../video:encoded_image",
|
||||
"../../video:video_bitrate_allocation",
|
||||
"../../video:video_frame",
|
||||
|
||||
@ -13,6 +13,8 @@
|
||||
#include <stdint.h>
|
||||
|
||||
#include "absl/types/optional.h"
|
||||
#include "api/environment/environment.h"
|
||||
#include "api/environment/environment_factory.h"
|
||||
#include "api/video/encoded_image.h"
|
||||
#include "api/video/video_frame.h"
|
||||
#include "api/video_codecs/video_decoder.h"
|
||||
@ -20,8 +22,8 @@
|
||||
#include "modules/video_coding/include/video_codec_interface.h"
|
||||
#include "modules/video_coding/include/video_error_codes.h"
|
||||
#include "rtc_base/checks.h"
|
||||
#include "test/field_trial.h"
|
||||
#include "test/gtest.h"
|
||||
#include "test/scoped_key_value_config.h"
|
||||
|
||||
namespace webrtc {
|
||||
|
||||
@ -32,9 +34,10 @@ class VideoDecoderSoftwareFallbackWrapperTest : public ::testing::Test {
|
||||
explicit VideoDecoderSoftwareFallbackWrapperTest(
|
||||
const std::string& field_trials)
|
||||
: override_field_trials_(field_trials),
|
||||
env_(CreateEnvironment(&override_field_trials_)),
|
||||
fake_decoder_(new CountingFakeDecoder()),
|
||||
fallback_wrapper_(CreateVideoDecoderSoftwareFallbackWrapper(
|
||||
std::unique_ptr<VideoDecoder>(VP8Decoder::Create()),
|
||||
CreateVp8Decoder(env_),
|
||||
std::unique_ptr<VideoDecoder>(fake_decoder_))) {}
|
||||
|
||||
class CountingFakeDecoder : public VideoDecoder {
|
||||
@ -71,7 +74,8 @@ class VideoDecoderSoftwareFallbackWrapperTest : public ::testing::Test {
|
||||
int release_count_ = 0;
|
||||
int reset_count_ = 0;
|
||||
};
|
||||
test::ScopedFieldTrials override_field_trials_;
|
||||
test::ScopedKeyValueConfig override_field_trials_;
|
||||
const Environment env_;
|
||||
// `fake_decoder_` is owned and released by `fallback_wrapper_`.
|
||||
CountingFakeDecoder* fake_decoder_;
|
||||
std::unique_ptr<VideoDecoder> fallback_wrapper_;
|
||||
|
||||
@ -585,7 +585,10 @@ rtc_library("webrtc_vp8") {
|
||||
":webrtc_vp8_scalability",
|
||||
":webrtc_vp8_temporal_layers",
|
||||
"../../api:fec_controller_api",
|
||||
"../../api:field_trials_view",
|
||||
"../../api:scoped_refptr",
|
||||
"../../api/environment",
|
||||
"../../api/transport:field_trial_based_config",
|
||||
"../../api/units:time_delta",
|
||||
"../../api/units:timestamp",
|
||||
"../../api/video:encoded_image",
|
||||
|
||||
@ -14,6 +14,7 @@
|
||||
#include <memory>
|
||||
#include <vector>
|
||||
|
||||
#include "api/environment/environment.h"
|
||||
#include "api/video_codecs/video_encoder.h"
|
||||
#include "api/video_codecs/vp8_frame_buffer_controller.h"
|
||||
#include "modules/video_coding/include/video_codec_interface.h"
|
||||
@ -40,11 +41,15 @@ class VP8Encoder {
|
||||
static std::unique_ptr<VideoEncoder> Create(Settings settings);
|
||||
};
|
||||
|
||||
// TODO: bugs.webrtc.org/15791 - Deprecate and delete in favor of the
|
||||
// CreateVp8Decoder function.
|
||||
class VP8Decoder {
|
||||
public:
|
||||
static std::unique_ptr<VideoDecoder> Create();
|
||||
};
|
||||
|
||||
std::unique_ptr<VideoDecoder> CreateVp8Decoder(const Environment& env);
|
||||
|
||||
} // namespace webrtc
|
||||
|
||||
#endif // MODULES_VIDEO_CODING_CODECS_VP8_INCLUDE_VP8_H_
|
||||
|
||||
@ -18,7 +18,10 @@
|
||||
#include <string>
|
||||
|
||||
#include "absl/types/optional.h"
|
||||
#include "api/environment/environment.h"
|
||||
#include "api/field_trials_view.h"
|
||||
#include "api/scoped_refptr.h"
|
||||
#include "api/transport/field_trial_based_config.h"
|
||||
#include "api/video/i420_buffer.h"
|
||||
#include "api/video/video_frame.h"
|
||||
#include "api/video/video_frame_buffer.h"
|
||||
@ -28,7 +31,6 @@
|
||||
#include "rtc_base/checks.h"
|
||||
#include "rtc_base/numerics/exp_filter.h"
|
||||
#include "rtc_base/time_utils.h"
|
||||
#include "system_wrappers/include/field_trial.h"
|
||||
#include "system_wrappers/include/metrics.h"
|
||||
#include "third_party/libyuv/include/libyuv/convert.h"
|
||||
#include "vpx/vp8.h"
|
||||
@ -59,9 +61,9 @@ absl::optional<LibvpxVp8Decoder::DeblockParams> DefaultDeblockParams() {
|
||||
}
|
||||
|
||||
absl::optional<LibvpxVp8Decoder::DeblockParams>
|
||||
GetPostProcParamsFromFieldTrialGroup() {
|
||||
std::string group = webrtc::field_trial::FindFullName(
|
||||
kIsArm ? kVp8PostProcArmFieldTrial : kVp8PostProcFieldTrial);
|
||||
GetPostProcParamsFromFieldTrialGroup(const FieldTrialsView& field_trials) {
|
||||
std::string group = field_trials.Lookup(kIsArm ? kVp8PostProcArmFieldTrial
|
||||
: kVp8PostProcFieldTrial);
|
||||
if (group.empty()) {
|
||||
return DefaultDeblockParams();
|
||||
}
|
||||
@ -89,6 +91,10 @@ std::unique_ptr<VideoDecoder> VP8Decoder::Create() {
|
||||
return std::make_unique<LibvpxVp8Decoder>();
|
||||
}
|
||||
|
||||
std::unique_ptr<VideoDecoder> CreateVp8Decoder(const Environment& env) {
|
||||
return std::make_unique<LibvpxVp8Decoder>(env);
|
||||
}
|
||||
|
||||
class LibvpxVp8Decoder::QpSmoother {
|
||||
public:
|
||||
QpSmoother() : last_sample_ms_(rtc::TimeMillis()), smoother_(kAlpha) {}
|
||||
@ -114,9 +120,14 @@ class LibvpxVp8Decoder::QpSmoother {
|
||||
};
|
||||
|
||||
LibvpxVp8Decoder::LibvpxVp8Decoder()
|
||||
: use_postproc_(
|
||||
kIsArm ? webrtc::field_trial::IsEnabled(kVp8PostProcArmFieldTrial)
|
||||
: true),
|
||||
: LibvpxVp8Decoder(FieldTrialBasedConfig()) {}
|
||||
|
||||
LibvpxVp8Decoder::LibvpxVp8Decoder(const Environment& env)
|
||||
: LibvpxVp8Decoder(env.field_trials()) {}
|
||||
|
||||
LibvpxVp8Decoder::LibvpxVp8Decoder(const FieldTrialsView& field_trials)
|
||||
: use_postproc_(kIsArm ? field_trials.IsEnabled(kVp8PostProcArmFieldTrial)
|
||||
: true),
|
||||
buffer_pool_(false, 300 /* max_number_of_buffers*/),
|
||||
decode_complete_callback_(NULL),
|
||||
inited_(false),
|
||||
@ -124,8 +135,9 @@ LibvpxVp8Decoder::LibvpxVp8Decoder()
|
||||
last_frame_width_(0),
|
||||
last_frame_height_(0),
|
||||
key_frame_required_(true),
|
||||
deblock_params_(use_postproc_ ? GetPostProcParamsFromFieldTrialGroup()
|
||||
: absl::nullopt),
|
||||
deblock_params_(use_postproc_
|
||||
? GetPostProcParamsFromFieldTrialGroup(field_trials)
|
||||
: absl::nullopt),
|
||||
qp_smoother_(use_postproc_ ? new QpSmoother() : nullptr) {}
|
||||
|
||||
LibvpxVp8Decoder::~LibvpxVp8Decoder() {
|
||||
|
||||
@ -14,6 +14,8 @@
|
||||
#include <memory>
|
||||
|
||||
#include "absl/types/optional.h"
|
||||
#include "api/environment/environment.h"
|
||||
#include "api/field_trials_view.h"
|
||||
#include "api/video/encoded_image.h"
|
||||
#include "api/video_codecs/video_decoder.h"
|
||||
#include "common_video/include/video_frame_buffer_pool.h"
|
||||
@ -26,7 +28,10 @@ namespace webrtc {
|
||||
|
||||
class LibvpxVp8Decoder : public VideoDecoder {
|
||||
public:
|
||||
// TODO: bugs.webrtc.org/15791 - Delete default constructor when
|
||||
// Environment is always propagated.
|
||||
LibvpxVp8Decoder();
|
||||
explicit LibvpxVp8Decoder(const Environment& env);
|
||||
~LibvpxVp8Decoder() override;
|
||||
|
||||
bool Configure(const Settings& settings) override;
|
||||
@ -56,6 +61,7 @@ class LibvpxVp8Decoder : public VideoDecoder {
|
||||
|
||||
private:
|
||||
class QpSmoother;
|
||||
explicit LibvpxVp8Decoder(const FieldTrialsView& field_trials);
|
||||
int ReturnFrame(const vpx_image_t* img,
|
||||
uint32_t timeStamp,
|
||||
int qp,
|
||||
|
||||
@ -27,7 +27,9 @@ std::unique_ptr<SimulcastTestFixture> CreateSpecificSimulcastTestFixture() {
|
||||
[]() { return VP8Encoder::Create(); });
|
||||
std::unique_ptr<VideoDecoderFactory> decoder_factory =
|
||||
std::make_unique<FunctionVideoDecoderFactory>(
|
||||
[]() { return VP8Decoder::Create(); });
|
||||
[](const Environment& env, const SdpVideoFormat& format) {
|
||||
return CreateVp8Decoder(env);
|
||||
});
|
||||
return CreateSimulcastTestFixture(std::move(encoder_factory),
|
||||
std::move(decoder_factory),
|
||||
SdpVideoFormat("VP8"));
|
||||
|
||||
@ -13,6 +13,7 @@
|
||||
#include <algorithm>
|
||||
#include <memory>
|
||||
|
||||
#include "api/environment/environment_factory.h"
|
||||
#include "api/test/create_frame_generator.h"
|
||||
#include "api/test/frame_generator_interface.h"
|
||||
#include "api/test/mock_video_decoder.h"
|
||||
@ -70,7 +71,7 @@ class TestVp8Impl : public VideoCodecUnitTest {
|
||||
}
|
||||
|
||||
std::unique_ptr<VideoDecoder> CreateDecoder() override {
|
||||
return VP8Decoder::Create();
|
||||
return CreateVp8Decoder(CreateEnvironment());
|
||||
}
|
||||
|
||||
void ModifyCodecSettings(VideoCodec* codec_settings) override {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user