Don't expose resilience mode in VP8 and VP9 configuration.

This deletes the resilienceOn flag in VideoCodecVP8 and VideoCodecVP9.
Instead, the implementations of VP8 and VP9 set resilience mode
internally, based on the configuration of temporal and spatial layers.

The nack_enabled argument to VideoCodecInitializer::SetupCodec becomes
unused with this cl. In a followup, it will be deleted, together with
the corresponding argument to VideoStreamEncoder methods.

An applications which really wants to configure resilience differently
can do that by injecting an EncoderFactory with encoders behaving
as desired.

Bug: webrtc:8830
Change-Id: I9990faf07d3e95c0fb4a56fcc9a56c2005b4a6fa
Reviewed-on: https://webrtc-review.googlesource.com/71380
Reviewed-by: Karl Wiberg <kwiberg@webrtc.org>
Reviewed-by: Sergey Silkin <ssilkin@webrtc.org>
Reviewed-by: Rasmus Brandt <brandtr@webrtc.org>
Commit-Queue: Niels Moller <nisse@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#23025}
This commit is contained in:
Niels Möller
2018-04-25 14:46:06 +02:00
committed by Commit Bot
parent d5cb477576
commit 65fb4049c1
17 changed files with 34 additions and 232 deletions

View File

@ -68,7 +68,6 @@ std::string CodecSpecificToString(const VideoCodec& codec) {
switch (codec.codecType) {
case kVideoCodecVP8:
ss << "complexity: " << codec.VP8().complexity;
ss << "\nresilience: " << codec.VP8().resilienceOn;
ss << "\nnum_temporal_layers: "
<< static_cast<int>(codec.VP8().numberOfTemporalLayers);
ss << "\ndenoising: " << codec.VP8().denoisingOn;
@ -78,7 +77,6 @@ std::string CodecSpecificToString(const VideoCodec& codec) {
break;
case kVideoCodecVP9:
ss << "complexity: " << codec.VP9().complexity;
ss << "\nresilience: " << codec.VP9().resilienceOn;
ss << "\nnum_temporal_layers: "
<< static_cast<int>(codec.VP9().numberOfTemporalLayers);
ss << "\nnum_spatial_layers: "
@ -111,7 +109,6 @@ void TestConfig::SetCodecSettings(std::string codec_name,
bool denoising_on,
bool frame_dropper_on,
bool spatial_resize_on,
bool resilience_on,
size_t width,
size_t height) {
this->codec_name = codec_name;
@ -143,7 +140,6 @@ void TestConfig::SetCodecSettings(std::string codec_name,
switch (codec_settings.codecType) {
case kVideoCodecVP8:
codec_settings.VP8()->resilienceOn = resilience_on;
codec_settings.VP8()->numberOfTemporalLayers =
static_cast<uint8_t>(num_temporal_layers);
codec_settings.VP8()->denoisingOn = denoising_on;
@ -152,7 +148,6 @@ void TestConfig::SetCodecSettings(std::string codec_name,
codec_settings.VP8()->keyFrameInterval = kBaseKeyFrameInterval;
break;
case kVideoCodecVP9:
codec_settings.VP9()->resilienceOn = resilience_on;
codec_settings.VP9()->numberOfTemporalLayers =
static_cast<uint8_t>(num_temporal_layers);
codec_settings.VP9()->denoisingOn = denoising_on;

View File

@ -38,7 +38,6 @@ struct TestConfig {
bool denoising_on,
bool frame_dropper_on,
bool spatial_resize_on,
bool resilience_on,
size_t width,
size_t height);

View File

@ -24,7 +24,6 @@ namespace test {
namespace {
// Codec settings.
const bool kResilienceOn = true;
const int kCifWidth = 352;
const int kCifHeight = 288;
#if !defined(WEBRTC_IOS)
@ -101,13 +100,13 @@ class VideoProcessorIntegrationTestLibvpx
#if !defined(RTC_DISABLE_VP9)
TEST_F(VideoProcessorIntegrationTestLibvpx, HighBitrateVP9) {
config_.SetCodecSettings(cricket::kVp9CodecName, 1, 1, 1, false, true, false,
kResilienceOn, kCifWidth, kCifHeight);
kCifWidth, kCifHeight);
config_.num_frames = kNumFramesShort;
std::vector<RateProfile> rate_profiles = {{500, 30, kNumFramesShort}};
std::vector<RateControlThresholds> rc_thresholds = {
{5, 1, 0, 0.1, 0.3, 0.1, 0, 1}};
{5, 1, 0, 0.11, 0.3, 0.1, 0, 1}};
std::vector<QualityThresholds> quality_thresholds = {{37, 36, 0.94, 0.92}};
@ -117,7 +116,7 @@ TEST_F(VideoProcessorIntegrationTestLibvpx, HighBitrateVP9) {
TEST_F(VideoProcessorIntegrationTestLibvpx, ChangeBitrateVP9) {
config_.SetCodecSettings(cricket::kVp9CodecName, 1, 1, 1, false, true, false,
kResilienceOn, kCifWidth, kCifHeight);
kCifWidth, kCifHeight);
std::vector<RateProfile> rate_profiles = {
{200, 30, 100}, // target_kbps, input_fps, frame_index_rate_update
@ -138,7 +137,7 @@ TEST_F(VideoProcessorIntegrationTestLibvpx, ChangeBitrateVP9) {
TEST_F(VideoProcessorIntegrationTestLibvpx, ChangeFramerateVP9) {
config_.SetCodecSettings(cricket::kVp9CodecName, 1, 1, 1, false, true, false,
kResilienceOn, kCifWidth, kCifHeight);
kCifWidth, kCifHeight);
std::vector<RateProfile> rate_profiles = {
{100, 24, 100}, // target_kbps, input_fps, frame_index_rate_update
@ -149,7 +148,7 @@ TEST_F(VideoProcessorIntegrationTestLibvpx, ChangeFramerateVP9) {
std::vector<RateControlThresholds> rc_thresholds = {
{10, 2, 40, 0.4, 0.5, 0.2, 0, 1},
{8, 2, 5, 0.2, 0.5, 0.2, 0, 0},
{5, 2, 0, 0.2, 0.5, 0.3, 0, 0}};
{5, 2, 0, 0.21, 0.5, 0.3, 0, 0}};
// Quality should be higher for lower framerates for the same content.
std::vector<QualityThresholds> quality_thresholds = {
@ -161,13 +160,13 @@ TEST_F(VideoProcessorIntegrationTestLibvpx, ChangeFramerateVP9) {
TEST_F(VideoProcessorIntegrationTestLibvpx, DenoiserOnVP9) {
config_.SetCodecSettings(cricket::kVp9CodecName, 1, 1, 1, true, true, false,
kResilienceOn, kCifWidth, kCifHeight);
kCifWidth, kCifHeight);
config_.num_frames = kNumFramesShort;
std::vector<RateProfile> rate_profiles = {{500, 30, kNumFramesShort}};
std::vector<RateControlThresholds> rc_thresholds = {
{5, 1, 0, 0.1, 0.3, 0.1, 0, 1}};
{5, 1, 0, 0.11, 0.3, 0.1, 0, 1}};
std::vector<QualityThresholds> quality_thresholds = {{37.5, 36, 0.94, 0.93}};
@ -177,7 +176,7 @@ TEST_F(VideoProcessorIntegrationTestLibvpx, DenoiserOnVP9) {
TEST_F(VideoProcessorIntegrationTestLibvpx, VeryLowBitrateVP9) {
config_.SetCodecSettings(cricket::kVp9CodecName, 1, 1, 1, false, true, true,
kResilienceOn, kCifWidth, kCifHeight);
kCifWidth, kCifHeight);
std::vector<RateProfile> rate_profiles = {{50, 30, kNumFramesLong}};
@ -197,7 +196,7 @@ TEST_F(VideoProcessorIntegrationTestLibvpx, VeryLowBitrateVP9) {
TEST_F(VideoProcessorIntegrationTestLibvpx, HighBitrateVP8) {
config_.SetCodecSettings(cricket::kVp8CodecName, 1, 1, 1, true, true, false,
kResilienceOn, kCifWidth, kCifHeight);
kCifWidth, kCifHeight);
config_.num_frames = kNumFramesShort;
std::vector<RateProfile> rate_profiles = {{500, 30, kNumFramesShort}};
@ -233,7 +232,7 @@ TEST_F(VideoProcessorIntegrationTestLibvpx, HighBitrateVP8) {
#endif
TEST_F(VideoProcessorIntegrationTestLibvpx, MAYBE_ChangeBitrateVP8) {
config_.SetCodecSettings(cricket::kVp8CodecName, 1, 1, 1, true, true, false,
kResilienceOn, kCifWidth, kCifHeight);
kCifWidth, kCifHeight);
std::vector<RateProfile> rate_profiles = {
{200, 30, 100}, // target_kbps, input_fps, frame_index_rate_update
@ -242,7 +241,7 @@ TEST_F(VideoProcessorIntegrationTestLibvpx, MAYBE_ChangeBitrateVP8) {
std::vector<RateControlThresholds> rc_thresholds = {
{5, 1, 0, 0.1, 0.2, 0.1, 0, 1},
{15, 1, 0, 0.1, 0.2, 0.1, 0, 0},
{15.5, 1, 0, 0.1, 0.2, 0.1, 0, 0},
{15, 1, 0, 0.3, 0.2, 0.1, 0, 0}};
// std::vector<QualityThresholds> quality_thresholds = {
@ -264,7 +263,7 @@ TEST_F(VideoProcessorIntegrationTestLibvpx, MAYBE_ChangeBitrateVP8) {
#endif
TEST_F(VideoProcessorIntegrationTestLibvpx, MAYBE_ChangeFramerateVP8) {
config_.SetCodecSettings(cricket::kVp8CodecName, 1, 1, 1, true, true, false,
kResilienceOn, kCifWidth, kCifHeight);
kCifWidth, kCifHeight);
std::vector<RateProfile> rate_profiles = {
{80, 24, 100}, // target_kbps, input_fps, frame_index_rate_update
@ -301,7 +300,7 @@ TEST_F(VideoProcessorIntegrationTestLibvpx, MAYBE_ChangeFramerateVP8) {
#endif
TEST_F(VideoProcessorIntegrationTestLibvpx, MAYBE_TemporalLayersVP8) {
config_.SetCodecSettings(cricket::kVp8CodecName, 1, 1, 3, true, true, false,
kResilienceOn, kCifWidth, kCifHeight);
kCifWidth, kCifHeight);
std::vector<RateProfile> rate_profiles = {{200, 30, 150},
{400, 30, kNumFramesLong}};
@ -336,7 +335,7 @@ TEST_F(VideoProcessorIntegrationTestLibvpx, MAYBE_MultiresVP8) {
config_.filepath = ResourcePath(config_.filename, "yuv");
config_.num_frames = 100;
config_.SetCodecSettings(cricket::kVp8CodecName, 3, 1, 3, true, true, false,
kResilienceOn, 1280, 720);
1280, 720);
std::vector<RateProfile> rate_profiles = {{1500, 30, config_.num_frames}};
@ -360,7 +359,7 @@ TEST_F(VideoProcessorIntegrationTestLibvpx, MAYBE_SimulcastVP8) {
config_.num_frames = 100;
config_.simulcast_adapted_encoder = true;
config_.SetCodecSettings(cricket::kVp8CodecName, 3, 1, 3, true, true, false,
kResilienceOn, 1280, 720);
1280, 720);
std::vector<RateProfile> rate_profiles = {{1500, 30, config_.num_frames}};
@ -383,7 +382,7 @@ TEST_F(VideoProcessorIntegrationTestLibvpx, MAYBE_SvcVP9) {
config_.filepath = ResourcePath(config_.filename, "yuv");
config_.num_frames = 100;
config_.SetCodecSettings(cricket::kVp9CodecName, 1, 3, 3, true, true, false,
kResilienceOn, 1280, 720);
1280, 720);
std::vector<RateProfile> rate_profiles = {{1500, 30, config_.num_frames}};
@ -401,7 +400,7 @@ TEST_F(VideoProcessorIntegrationTestLibvpx, DISABLED_MultiresVP8RdPerf) {
config_.num_frames = 300;
config_.print_frame_level_stats = true;
config_.SetCodecSettings(cricket::kVp8CodecName, 3, 1, 3, true, true, false,
kResilienceOn, 1280, 720);
1280, 720);
std::map<size_t, std::vector<VideoStatistics>> rd_stats;
for (size_t bitrate_kbps : kBitrateRdPerfKbps) {
@ -424,7 +423,7 @@ TEST_F(VideoProcessorIntegrationTestLibvpx, DISABLED_SvcVP9RdPerf) {
config_.num_frames = 300;
config_.print_frame_level_stats = true;
config_.SetCodecSettings(cricket::kVp9CodecName, 1, 3, 3, true, true, false,
kResilienceOn, 1280, 720);
1280, 720);
std::map<size_t, std::vector<VideoStatistics>> rd_stats;
for (size_t bitrate_kbps : kBitrateRdPerfKbps) {

View File

@ -41,7 +41,7 @@ class VideoProcessorIntegrationTestMediaCodec
TEST_F(VideoProcessorIntegrationTestMediaCodec, ForemanCif500kbpsVp8) {
config_.SetCodecSettings(cricket::kVp8CodecName, 1, 1, 1, false, false, false,
false, 352, 288);
352, 288);
std::vector<RateProfile> rate_profiles = {
{500, kForemanFramerateFps, kForemanNumFrames}};
@ -61,7 +61,7 @@ TEST_F(VideoProcessorIntegrationTestMediaCodec, ForemanCif500kbpsVp8) {
TEST_F(VideoProcessorIntegrationTestMediaCodec, ForemanCif500kbpsH264CBP) {
config_.encoded_frame_checker = &h264_keyframe_checker_;
config_.SetCodecSettings(cricket::kH264CodecName, 1, 1, 1, false, false,
false, false, 352, 288);
false, 352, 288);
std::vector<RateProfile> rate_profiles = {
{500, kForemanFramerateFps, kForemanNumFrames}};
@ -87,7 +87,7 @@ TEST_F(VideoProcessorIntegrationTestMediaCodec,
config_.h264_codec_settings.profile = H264::kProfileConstrainedHigh;
config_.encoded_frame_checker = &h264_keyframe_checker_;
config_.SetCodecSettings(cricket::kH264CodecName, 1, 1, 1, false, false,
false, false, 352, 288);
false, 352, 288);
std::vector<RateProfile> rate_profiles = {
{500, kForemanFramerateFps, kForemanNumFrames}};
@ -123,7 +123,7 @@ TEST_F(VideoProcessorIntegrationTestMediaCodec, ForemanMixedRes100kbpsVp8H264) {
std::to_string(height);
config_.filepath = ResourcePath(config_.filename, "yuv");
config_.num_frames = kNumFrames;
config_.SetCodecSettings(codec, 1, 1, 1, false, false, false, false,
config_.SetCodecSettings(codec, 1, 1, 1, false, false, false,
width, height);
ProcessFramesAndMaybeVerify(

View File

@ -22,7 +22,6 @@ namespace test {
namespace {
// Codec settings.
const bool kResilienceOn = true;
const int kCifWidth = 352;
const int kCifHeight = 288;
const int kNumFrames = 100;
@ -45,7 +44,7 @@ class VideoProcessorIntegrationTestOpenH264
TEST_F(VideoProcessorIntegrationTestOpenH264, ConstantHighBitrate) {
config_.SetCodecSettings(cricket::kH264CodecName, 1, 1, 1, false, true, false,
kResilienceOn, kCifWidth, kCifHeight);
kCifWidth, kCifHeight);
std::vector<RateProfile> rate_profiles = {{500, 30, kNumFrames}};
@ -65,7 +64,7 @@ TEST_F(VideoProcessorIntegrationTestOpenH264, SingleNalUnit) {
H264PacketizationMode::SingleNalUnit;
config_.max_payload_size_bytes = 500;
config_.SetCodecSettings(cricket::kH264CodecName, 1, 1, 1, false, true, false,
kResilienceOn, kCifWidth, kCifHeight);
kCifWidth, kCifHeight);
std::vector<RateProfile> rate_profiles = {{500, 30, kNumFrames}};

View File

@ -25,7 +25,6 @@ const bool kHwCodec[] = {false};
// Codec settings.
const int kNumSpatialLayers = 1;
const int kNumTemporalLayers = 1;
const bool kResilienceOn = kNumSpatialLayers > 1 || kNumTemporalLayers > 1;
const bool kDenoisingOn = false;
const bool kSpatialResizeOn = false;
const bool kFrameDropperOn = false;
@ -75,7 +74,7 @@ class VideoProcessorIntegrationTestParameterized
config_.SetCodecSettings(codec_name, num_simulcast_streams,
num_spatial_layers, kNumTemporalLayers,
kDenoisingOn, kFrameDropperOn, kSpatialResizeOn,
kResilienceOn, width, height);
width, height);
std::vector<RateProfile> rate_profiles = {
{bitrate_, framerate, kNumFrames}};

View File

@ -70,7 +70,7 @@ class VideoProcessorIntegrationTestVideoToolbox
MAYBE_TEST_F(VideoProcessorIntegrationTestVideoToolbox,
ForemanCif500kbpsH264CBP) {
config_.SetCodecSettings(cricket::kH264CodecName, 1, 1, 1, false, false,
false, false, 352, 288);
false, 352, 288);
std::vector<RateProfile> rate_profiles = {{500, 30, kForemanNumFrames}};
@ -86,7 +86,7 @@ MAYBE_TEST_F(VideoProcessorIntegrationTestVideoToolbox,
config_.h264_codec_settings.profile = H264::kProfileConstrainedHigh;
config_.SetCodecSettings(cricket::kH264CodecName, 1, 1, 1, false, false,
false, false, 352, 288);
false, 352, 288);
std::vector<RateProfile> rate_profiles = {{500, 30, kForemanNumFrames}};

View File

@ -53,7 +53,7 @@ class VideoProcessorTest : public testing::Test {
protected:
VideoProcessorTest() : q_("VP queue") {
config_.SetCodecSettings(cricket::kVp8CodecName, 1, 1, 1, false, false,
false, false, kWidth, kHeight);
false, kWidth, kHeight);
decoder_mock_ = new MockVideoDecoder();
decoders_.push_back(std::unique_ptr<VideoDecoder>(decoder_mock_));

View File

@ -440,9 +440,9 @@ int LibvpxVp8Encoder::InitEncode(const VideoCodec* inst,
configurations_[0].g_timebase.den = 90000;
configurations_[0].g_lag_in_frames = 0; // 0- no frame lagging
// Set the error resilience mode according to user settings.
// Set the error resilience mode for temporal layers (but not simulcast).
configurations_[0].g_error_resilient =
inst->VP8().resilienceOn ? VPX_ERROR_RESILIENT_DEFAULT : 0;
(num_temporal_layers > 1) ? VPX_ERROR_RESILIENT_DEFAULT : 0;
// rate control settings
configurations_[0].rc_dropframe_thresh = inst->VP8().frameDroppingOn ? 30 : 0;
@ -667,7 +667,7 @@ int LibvpxVp8Encoder::InitAndSetControlSettings() {
vpx_codec_control(&(encoders_[i]), VP8E_SET_SCREEN_CONTENT_MODE,
codec_.mode == kScreensharing ? 2 : 0);
// Apply boost on golden frames (has only effect when resilience is off).
if (use_gf_boost_ && !codec_.VP8()->resilienceOn) {
if (use_gf_boost_ && configurations_[0].g_error_resilient == 0) {
int gf_boost_percent;
if (GetGfBoostPercentageFromFieldTrialGroup(&gf_boost_percent)) {
vpx_codec_control(&(encoders_[i]), VP8E_SET_GF_CBR_BOOST_PCT,

View File

@ -214,7 +214,6 @@ class TestVp8Simulcast : public ::testing::Test {
ConfigureStream(kDefaultWidth, kDefaultHeight, kMaxBitrates[2],
kMinBitrates[2], kTargetBitrates[2],
&settings->simulcastStream[2], temporal_layer_profile[2]);
settings->VP8()->resilienceOn = true;
settings->VP8()->denoisingOn = true;
settings->VP8()->automaticResizeOn = false;
settings->VP8()->frameDroppingOn = true;

View File

@ -266,6 +266,7 @@ int VP9EncoderImpl::InitEncode(const VideoCodec* inst,
}
num_spatial_layers_ = inst->VP9().numberOfSpatialLayers;
RTC_DCHECK_GT(num_spatial_layers_, 0);
num_temporal_layers_ = inst->VP9().numberOfTemporalLayers;
if (num_temporal_layers_ == 0)
num_temporal_layers_ = 1;
@ -290,7 +291,8 @@ int VP9EncoderImpl::InitEncode(const VideoCodec* inst,
config_->g_w = codec_.width;
config_->g_h = codec_.height;
config_->rc_target_bitrate = inst->startBitrate; // in kbit/s
config_->g_error_resilient = inst->VP9().resilienceOn ? 1 : 0;
config_->g_error_resilient =
(num_spatial_layers_ > 1 || num_temporal_layers_ > 1) ? 1 : 0;
// Setting the time base of the codec.
config_->g_timebase.num = 1;
config_->g_timebase.den = 90000;