Refactoring: Hide VideoCodec.codecSpecific as "private"

This refactoring allows runtime checks that functions that access
codec specific information are using the correct union member.
The API also allows replacing the union with another implementation
without changes at calling sites.

BUG=webrtc:6603

Review-Url: https://codereview.webrtc.org/2001533003
Cr-Commit-Position: refs/heads/master@{#14775}
This commit is contained in:
hta
2016-10-25 09:05:06 -07:00
committed by Commit bot
parent 189f9b1b65
commit 257dc39841
18 changed files with 185 additions and 145 deletions

View File

@ -191,34 +191,27 @@ class VideoProcessorIntegrationTest : public testing::Test {
// These features may be set depending on the test.
switch (config_.codec_settings->codecType) {
case kVideoCodecH264:
config_.codec_settings->codecSpecific.H264.frameDroppingOn =
frame_dropper_on_;
config_.codec_settings->codecSpecific.H264.keyFrameInterval =
config_.codec_settings->H264()->frameDroppingOn = frame_dropper_on_;
config_.codec_settings->H264()->keyFrameInterval =
kBaseKeyFrameInterval;
break;
case kVideoCodecVP8:
config_.codec_settings->codecSpecific.VP8.errorConcealmentOn =
config_.codec_settings->VP8()->errorConcealmentOn =
error_concealment_on_;
config_.codec_settings->codecSpecific.VP8.denoisingOn = denoising_on_;
config_.codec_settings->codecSpecific.VP8.numberOfTemporalLayers =
config_.codec_settings->VP8()->denoisingOn = denoising_on_;
config_.codec_settings->VP8()->numberOfTemporalLayers =
num_temporal_layers_;
config_.codec_settings->codecSpecific.VP8.frameDroppingOn =
frame_dropper_on_;
config_.codec_settings->codecSpecific.VP8.automaticResizeOn =
spatial_resize_on_;
config_.codec_settings->codecSpecific.VP8.keyFrameInterval =
kBaseKeyFrameInterval;
config_.codec_settings->VP8()->frameDroppingOn = frame_dropper_on_;
config_.codec_settings->VP8()->automaticResizeOn = spatial_resize_on_;
config_.codec_settings->VP8()->keyFrameInterval = kBaseKeyFrameInterval;
break;
case kVideoCodecVP9:
config_.codec_settings->codecSpecific.VP9.denoisingOn = denoising_on_;
config_.codec_settings->codecSpecific.VP9.numberOfTemporalLayers =
config_.codec_settings->VP9()->denoisingOn = denoising_on_;
config_.codec_settings->VP9()->numberOfTemporalLayers =
num_temporal_layers_;
config_.codec_settings->codecSpecific.VP9.frameDroppingOn =
frame_dropper_on_;
config_.codec_settings->codecSpecific.VP9.automaticResizeOn =
spatial_resize_on_;
config_.codec_settings->codecSpecific.VP9.keyFrameInterval =
kBaseKeyFrameInterval;
config_.codec_settings->VP9()->frameDroppingOn = frame_dropper_on_;
config_.codec_settings->VP9()->automaticResizeOn = spatial_resize_on_;
config_.codec_settings->VP9()->keyFrameInterval = kBaseKeyFrameInterval;
break;
default:
assert(false);

View File

@ -215,8 +215,7 @@ int HandleCommandLineFlags(webrtc::test::TestConfig* config) {
FLAGS_temporal_layers);
return 13;
}
config->codec_settings->codecSpecific.VP8.numberOfTemporalLayers =
FLAGS_temporal_layers;
config->codec_settings->VP8()->numberOfTemporalLayers = FLAGS_temporal_layers;
// Check the bit rate.
if (FLAGS_bitrate <= 0) {

View File

@ -74,12 +74,10 @@ int VerifyCodec(const webrtc::VideoCodec* inst) {
if (inst->width <= 1 || inst->height <= 1) {
return WEBRTC_VIDEO_CODEC_ERR_PARAMETER;
}
if (inst->codecSpecific.VP8.feedbackModeOn &&
inst->numberOfSimulcastStreams > 1) {
if (inst->VP8().feedbackModeOn && inst->numberOfSimulcastStreams > 1) {
return WEBRTC_VIDEO_CODEC_ERR_PARAMETER;
}
if (inst->codecSpecific.VP8.automaticResizeOn &&
inst->numberOfSimulcastStreams > 1) {
if (inst->VP8().automaticResizeOn && inst->numberOfSimulcastStreams > 1) {
return WEBRTC_VIDEO_CODEC_ERR_PARAMETER;
}
return WEBRTC_VIDEO_CODEC_OK;
@ -182,7 +180,7 @@ int SimulcastEncoderAdapter::InitEncode(const VideoCodec* inst,
// Special mode when screensharing on a single stream.
if (number_of_streams == 1 && inst->mode == kScreensharing) {
screensharing_tl_factory_.reset(new ScreenshareTemporalLayersFactory());
codec_.codecSpecific.VP8.tl_factory = screensharing_tl_factory_.get();
codec_.VP8()->tl_factory = screensharing_tl_factory_.get();
}
std::string implementation_name;
@ -386,7 +384,7 @@ int SimulcastEncoderAdapter::SetRates(uint32_t new_bitrate_kbit,
// the target we still allow it to overshoot up to the max before dropping
// frames. This hack should be improved.
if (codec_.targetBitrate > 0 &&
(codec_.codecSpecific.VP8.numberOfTemporalLayers == 2 ||
(codec_.VP8()->numberOfTemporalLayers == 2 ||
codec_.simulcastStream[0].numberOfTemporalLayers == 2)) {
stream_bitrate_kbps = std::min(codec_.maxBitrate, stream_bitrate_kbps);
// TODO(ronghuawu): Can't change max bitrate via the VideoEncoder
@ -425,7 +423,7 @@ void SimulcastEncoderAdapter::PopulateStreamCodec(
*stream_codec = *inst;
// Stream specific settings.
stream_codec->codecSpecific.VP8.numberOfTemporalLayers =
stream_codec->VP8()->numberOfTemporalLayers =
inst->simulcastStream[stream_index].numberOfTemporalLayers;
stream_codec->numberOfSimulcastStreams = 0;
stream_codec->width = inst->simulcastStream[stream_index].width;
@ -443,10 +441,10 @@ void SimulcastEncoderAdapter::PopulateStreamCodec(
// kComplexityHigher, which maps to cpu_used = -4.
int pixels_per_frame = stream_codec->width * stream_codec->height;
if (pixels_per_frame < 352 * 288) {
stream_codec->codecSpecific.VP8.complexity = webrtc::kComplexityHigher;
stream_codec->VP8()->complexity = webrtc::kComplexityHigher;
}
// Turn off denoising for all streams but the highest resolution.
stream_codec->codecSpecific.VP8.denoisingOn = false;
stream_codec->VP8()->denoisingOn = false;
}
// TODO(ronghuawu): what to do with targetBitrate.

View File

@ -289,28 +289,19 @@ class TestSimulcastEncoderAdapterFake : public ::testing::Test,
EXPECT_EQ(ref.maxBitrate, target.maxBitrate);
EXPECT_EQ(ref.minBitrate, target.minBitrate);
EXPECT_EQ(ref.maxFramerate, target.maxFramerate);
EXPECT_EQ(ref.codecSpecific.VP8.pictureLossIndicationOn,
target.codecSpecific.VP8.pictureLossIndicationOn);
EXPECT_EQ(ref.codecSpecific.VP8.feedbackModeOn,
target.codecSpecific.VP8.feedbackModeOn);
EXPECT_EQ(ref.codecSpecific.VP8.complexity,
target.codecSpecific.VP8.complexity);
EXPECT_EQ(ref.codecSpecific.VP8.resilience,
target.codecSpecific.VP8.resilience);
EXPECT_EQ(ref.codecSpecific.VP8.numberOfTemporalLayers,
target.codecSpecific.VP8.numberOfTemporalLayers);
EXPECT_EQ(ref.codecSpecific.VP8.denoisingOn,
target.codecSpecific.VP8.denoisingOn);
EXPECT_EQ(ref.codecSpecific.VP8.errorConcealmentOn,
target.codecSpecific.VP8.errorConcealmentOn);
EXPECT_EQ(ref.codecSpecific.VP8.automaticResizeOn,
target.codecSpecific.VP8.automaticResizeOn);
EXPECT_EQ(ref.codecSpecific.VP8.frameDroppingOn,
target.codecSpecific.VP8.frameDroppingOn);
EXPECT_EQ(ref.codecSpecific.VP8.keyFrameInterval,
target.codecSpecific.VP8.keyFrameInterval);
EXPECT_EQ(ref.codecSpecific.VP8.tl_factory,
target.codecSpecific.VP8.tl_factory);
EXPECT_EQ(ref.VP8().pictureLossIndicationOn,
target.VP8().pictureLossIndicationOn);
EXPECT_EQ(ref.VP8().feedbackModeOn, target.VP8().feedbackModeOn);
EXPECT_EQ(ref.VP8().complexity, target.VP8().complexity);
EXPECT_EQ(ref.VP8().resilience, target.VP8().resilience);
EXPECT_EQ(ref.VP8().numberOfTemporalLayers,
target.VP8().numberOfTemporalLayers);
EXPECT_EQ(ref.VP8().denoisingOn, target.VP8().denoisingOn);
EXPECT_EQ(ref.VP8().errorConcealmentOn, target.VP8().errorConcealmentOn);
EXPECT_EQ(ref.VP8().automaticResizeOn, target.VP8().automaticResizeOn);
EXPECT_EQ(ref.VP8().frameDroppingOn, target.VP8().frameDroppingOn);
EXPECT_EQ(ref.VP8().keyFrameInterval, target.VP8().keyFrameInterval);
EXPECT_EQ(ref.VP8().tl_factory, target.VP8().tl_factory);
EXPECT_EQ(ref.qpMax, target.qpMax);
EXPECT_EQ(0, target.numberOfSimulcastStreams);
EXPECT_EQ(ref.mode, target.mode);
@ -321,7 +312,7 @@ class TestSimulcastEncoderAdapterFake : public ::testing::Test,
void InitRefCodec(int stream_index, VideoCodec* ref_codec) {
*ref_codec = codec_;
ref_codec->codecSpecific.VP8.numberOfTemporalLayers =
ref_codec->VP8()->numberOfTemporalLayers =
kTestTemporalLayerProfile[stream_index];
ref_codec->width = codec_.simulcastStream[stream_index].width;
ref_codec->height = codec_.simulcastStream[stream_index].height;
@ -337,14 +328,14 @@ class TestSimulcastEncoderAdapterFake : public ::testing::Test,
// stream 0, the lowest resolution stream.
InitRefCodec(0, &ref_codec);
ref_codec.qpMax = 45;
ref_codec.codecSpecific.VP8.complexity = webrtc::kComplexityHigher;
ref_codec.codecSpecific.VP8.denoisingOn = false;
ref_codec.VP8()->complexity = webrtc::kComplexityHigher;
ref_codec.VP8()->denoisingOn = false;
ref_codec.startBitrate = 100; // Should equal to the target bitrate.
VerifyCodec(ref_codec, 0);
// stream 1
InitRefCodec(1, &ref_codec);
ref_codec.codecSpecific.VP8.denoisingOn = false;
ref_codec.VP8()->denoisingOn = false;
// The start bitrate (300kbit) minus what we have for the lower layers
// (100kbit).
ref_codec.startBitrate = 200;

View File

@ -153,7 +153,7 @@ class SkipEncodingUnusedStreamsTest {
VideoCodec* settings,
uint32_t target_bitrate) {
SpyingTemporalLayersFactory spy_factory;
settings->codecSpecific.VP8.tl_factory = &spy_factory;
settings->VP8()->tl_factory = &spy_factory;
EXPECT_EQ(0, encoder->InitEncode(settings, 1, 1200));
encoder->SetRates(target_bitrate, 30);
@ -288,13 +288,13 @@ class TestVp8Simulcast : public ::testing::Test {
ConfigureStream(kDefaultWidth, kDefaultHeight, kMaxBitrates[2],
kMinBitrates[2], kTargetBitrates[2],
&settings->simulcastStream[2], temporal_layer_profile[2]);
settings->codecSpecific.VP8.resilience = kResilientStream;
settings->codecSpecific.VP8.denoisingOn = true;
settings->codecSpecific.VP8.errorConcealmentOn = false;
settings->codecSpecific.VP8.automaticResizeOn = false;
settings->codecSpecific.VP8.feedbackModeOn = false;
settings->codecSpecific.VP8.frameDroppingOn = true;
settings->codecSpecific.VP8.keyFrameInterval = 3000;
settings->VP8()->resilience = kResilientStream;
settings->VP8()->denoisingOn = true;
settings->VP8()->errorConcealmentOn = false;
settings->VP8()->automaticResizeOn = false;
settings->VP8()->feedbackModeOn = false;
settings->VP8()->frameDroppingOn = true;
settings->VP8()->keyFrameInterval = 3000;
}
static void ConfigureStream(int width,
@ -563,7 +563,7 @@ class TestVp8Simulcast : public ::testing::Test {
void SwitchingToOneStream(int width, int height) {
// Disable all streams except the last and set the bitrate of the last to
// 100 kbps. This verifies the way GTP switches to screenshare mode.
settings_.codecSpecific.VP8.numberOfTemporalLayers = 1;
settings_.VP8()->numberOfTemporalLayers = 1;
settings_.maxBitrate = 100;
settings_.startBitrate = 100;
settings_.width = width;

View File

@ -160,7 +160,7 @@ class TestVp8Impl : public ::testing::Test {
codec_inst_.startBitrate = 300;
codec_inst_.maxBitrate = 4000;
codec_inst_.qpMax = 56;
codec_inst_.codecSpecific.VP8.denoisingOn = true;
codec_inst_.VP8()->denoisingOn = true;
EXPECT_EQ(WEBRTC_VIDEO_CODEC_OK,
encoder_->InitEncode(&codec_inst_, 1, 1440));
@ -213,8 +213,8 @@ TEST_F(TestVp8Impl, EncoderParameterTest) {
codec_inst_.maxFramerate = 30;
codec_inst_.startBitrate = 300;
codec_inst_.qpMax = 56;
codec_inst_.codecSpecific.VP8.complexity = kComplexityNormal;
codec_inst_.codecSpecific.VP8.numberOfTemporalLayers = 1;
codec_inst_.VP8()->complexity = kComplexityNormal;
codec_inst_.VP8()->numberOfTemporalLayers = 1;
// Calls before InitEncode().
EXPECT_EQ(WEBRTC_VIDEO_CODEC_OK, encoder_->Release());
int bit_rate = 300;

View File

@ -247,7 +247,7 @@ int VP8EncoderImpl::SetRates(uint32_t new_bitrate_kbit,
// the target we still allow it to overshoot up to the max before dropping
// frames. This hack should be improved.
if (codec_.targetBitrate > 0 &&
(codec_.codecSpecific.VP8.numberOfTemporalLayers == 2 ||
(codec_.VP8()->numberOfTemporalLayers == 2 ||
codec_.simulcastStream[0].numberOfTemporalLayers == 2)) {
int tl0_bitrate = std::min(codec_.targetBitrate, target_bitrate);
max_bitrate = std::min(codec_.maxBitrate, target_bitrate);
@ -286,7 +286,7 @@ void VP8EncoderImpl::SetupTemporalLayers(int num_streams,
int num_temporal_layers,
const VideoCodec& codec) {
TemporalLayersFactory default_factory;
const TemporalLayersFactory* tl_factory = codec.codecSpecific.VP8.tl_factory;
const TemporalLayersFactory* tl_factory = codec.VP8().tl_factory;
if (!tl_factory)
tl_factory = &default_factory;
if (num_streams == 1) {
@ -328,12 +328,10 @@ int VP8EncoderImpl::InitEncode(const VideoCodec* inst,
if (number_of_cores < 1) {
return WEBRTC_VIDEO_CODEC_ERR_PARAMETER;
}
if (inst->codecSpecific.VP8.feedbackModeOn &&
inst->numberOfSimulcastStreams > 1) {
if (inst->VP8().feedbackModeOn && inst->numberOfSimulcastStreams > 1) {
return WEBRTC_VIDEO_CODEC_ERR_PARAMETER;
}
if (inst->codecSpecific.VP8.automaticResizeOn &&
inst->numberOfSimulcastStreams > 1) {
if (inst->VP8().automaticResizeOn && inst->numberOfSimulcastStreams > 1) {
return WEBRTC_VIDEO_CODEC_ERR_PARAMETER;
}
int retVal = Release();
@ -350,14 +348,14 @@ int VP8EncoderImpl::InitEncode(const VideoCodec* inst,
int num_temporal_layers =
doing_simulcast ? inst->simulcastStream[0].numberOfTemporalLayers
: inst->codecSpecific.VP8.numberOfTemporalLayers;
: inst->VP8().numberOfTemporalLayers;
// TODO(andresp): crash if num temporal layers is bananas.
if (num_temporal_layers < 1)
num_temporal_layers = 1;
SetupTemporalLayers(number_of_streams, num_temporal_layers, *inst);
feedback_mode_ = inst->codecSpecific.VP8.feedbackModeOn;
feedback_mode_ = inst->VP8().feedbackModeOn;
timestamp_ = 0;
codec_ = *inst;
@ -419,7 +417,7 @@ int VP8EncoderImpl::InitEncode(const VideoCodec* inst,
configurations_[0].g_lag_in_frames = 0; // 0- no frame lagging
// Set the error resilience mode according to user settings.
switch (inst->codecSpecific.VP8.resilience) {
switch (inst->VP8().resilience) {
case kResilienceOff:
// TODO(marpan): We should set keep error resilience off for this mode,
// independent of temporal layer settings, and make sure we set
@ -437,8 +435,7 @@ int VP8EncoderImpl::InitEncode(const VideoCodec* inst,
}
// rate control settings
configurations_[0].rc_dropframe_thresh =
inst->codecSpecific.VP8.frameDroppingOn ? 30 : 0;
configurations_[0].rc_dropframe_thresh = inst->VP8().frameDroppingOn ? 30 : 0;
configurations_[0].rc_end_usage = VPX_CBR;
configurations_[0].g_pass = VPX_RC_ONE_PASS;
// TODO(hellner): investigate why the following two lines produce
@ -449,7 +446,7 @@ int VP8EncoderImpl::InitEncode(const VideoCodec* inst,
// inst->codecSpecific.VP8.automaticResizeOn ? 1 : 0;
configurations_[0].rc_resize_allowed = 0;
// Handle resizing outside of libvpx when doing single-stream.
if (inst->codecSpecific.VP8.automaticResizeOn && number_of_streams > 1) {
if (inst->VP8().automaticResizeOn && number_of_streams > 1) {
configurations_[0].rc_resize_allowed = 1;
}
configurations_[0].rc_min_quantizer = 2;
@ -470,15 +467,15 @@ int VP8EncoderImpl::InitEncode(const VideoCodec* inst,
// Disable periodic key frames if we get feedback from the decoder
// through SLI and RPSI.
configurations_[0].kf_mode = VPX_KF_DISABLED;
} else if (inst->codecSpecific.VP8.keyFrameInterval > 0) {
} else if (inst->VP8().keyFrameInterval > 0) {
configurations_[0].kf_mode = VPX_KF_AUTO;
configurations_[0].kf_max_dist = inst->codecSpecific.VP8.keyFrameInterval;
configurations_[0].kf_max_dist = inst->VP8().keyFrameInterval;
} else {
configurations_[0].kf_mode = VPX_KF_DISABLED;
}
// Allow the user to set the complexity for the base stream.
switch (inst->codecSpecific.VP8.complexity) {
switch (inst->VP8().complexity) {
case kComplexityHigh:
cpu_speed_[0] = -5;
break;
@ -563,7 +560,7 @@ int VP8EncoderImpl::InitEncode(const VideoCodec* inst,
// use frame drops as a signal and is only applicable when we drop frames.
quality_scaler_enabled_ = encoders_.size() == 1 &&
configurations_[0].rc_dropframe_thresh > 0 &&
codec_.codecSpecific.VP8.automaticResizeOn;
codec_.VP8()->automaticResizeOn;
return InitAndSetControlSettings();
}
@ -576,7 +573,7 @@ int VP8EncoderImpl::SetCpuSpeed(int width, int height) {
#else
// For non-ARM, increase encoding complexity (i.e., use lower speed setting)
// if resolution is below CIF. Otherwise, keep the default/user setting
// (|cpu_speed_default_|) set on InitEncode via codecSpecific.VP8.complexity.
// (|cpu_speed_default_|) set on InitEncode via VP8().complexity.
if (width * height < 352 * 288)
return (cpu_speed_default_ < -4) ? -4 : cpu_speed_default_;
else
@ -644,13 +641,12 @@ int VP8EncoderImpl::InitAndSetControlSettings() {
#else
denoiser_state = kDenoiserOnAdaptive;
#endif
vpx_codec_control(
&encoders_[0], VP8E_SET_NOISE_SENSITIVITY,
codec_.codecSpecific.VP8.denoisingOn ? denoiser_state : kDenoiserOff);
vpx_codec_control(&encoders_[0], VP8E_SET_NOISE_SENSITIVITY,
codec_.VP8()->denoisingOn ? denoiser_state : kDenoiserOff);
if (encoders_.size() > 2) {
vpx_codec_control(
&encoders_[1], VP8E_SET_NOISE_SENSITIVITY,
codec_.codecSpecific.VP8.denoisingOn ? denoiser_state : kDenoiserOff);
codec_.VP8()->denoisingOn ? denoiser_state : kDenoiserOff);
}
for (size_t i = 0; i < encoders_.size(); ++i) {
// Allow more screen content to be detected as static.
@ -780,7 +776,7 @@ int VP8EncoderImpl::Encode(const VideoFrame& frame,
// Adapt the size of the key frame when in screenshare with 1 temporal
// layer.
if (encoders_.size() == 1 && codec_.mode == kScreensharing &&
codec_.codecSpecific.VP8.numberOfTemporalLayers <= 1) {
codec_.VP8()->numberOfTemporalLayers <= 1) {
const uint32_t forceKeyFrameIntraTh = 100;
vpx_codec_control(&(encoders_[0]), VP8E_SET_MAX_INTRA_BITRATE_PCT,
forceKeyFrameIntraTh);
@ -1073,7 +1069,7 @@ int VP8DecoderImpl::InitDecode(const VideoCodec* inst, int number_of_cores) {
decoder_ = new vpx_codec_ctx_t;
}
if (inst && inst->codecType == kVideoCodecVP8) {
feedback_mode_ = inst->codecSpecific.VP8.feedbackModeOn;
feedback_mode_ = inst->VP8().feedbackModeOn;
}
vpx_codec_dec_cfg_t cfg;
// Setting number of threads to a constant value (1)

View File

@ -135,8 +135,8 @@ int SequenceCoder(webrtc::test::CommandLineParser* parser) {
webrtc::VP8Encoder* encoder = webrtc::VP8Encoder::Create();
webrtc::VP8Decoder* decoder = webrtc::VP8Decoder::Create();
inst.codecType = webrtc::kVideoCodecVP8;
inst.codecSpecific.VP8.feedbackModeOn = false;
inst.codecSpecific.VP8.denoisingOn = true;
inst.VP8()->feedbackModeOn = false;
inst.VP8()->denoisingOn = true;
inst.maxFramerate = framerate;
inst.startBitrate = target_bitrate;
inst.maxBitrate = 8000;

View File

@ -242,11 +242,11 @@ int VP9EncoderImpl::InitEncode(const VideoCodec* inst,
if (number_of_cores < 1) {
return WEBRTC_VIDEO_CODEC_ERR_PARAMETER;
}
if (inst->codecSpecific.VP9.numberOfTemporalLayers > 3) {
if (inst->VP9().numberOfTemporalLayers > 3) {
return WEBRTC_VIDEO_CODEC_ERR_PARAMETER;
}
// libvpx currently supports only one or two spatial layers.
if (inst->codecSpecific.VP9.numberOfSpatialLayers > 2) {
if (inst->VP9().numberOfSpatialLayers > 2) {
return WEBRTC_VIDEO_CODEC_ERR_PARAMETER;
}
@ -265,8 +265,8 @@ int VP9EncoderImpl::InitEncode(const VideoCodec* inst,
codec_ = *inst;
}
num_spatial_layers_ = inst->codecSpecific.VP9.numberOfSpatialLayers;
num_temporal_layers_ = inst->codecSpecific.VP9.numberOfTemporalLayers;
num_spatial_layers_ = inst->VP9().numberOfSpatialLayers;
num_temporal_layers_ = inst->VP9().numberOfTemporalLayers;
if (num_temporal_layers_ == 0)
num_temporal_layers_ = 1;
@ -298,8 +298,7 @@ int VP9EncoderImpl::InitEncode(const VideoCodec* inst,
config_->g_lag_in_frames = 0; // 0- no frame lagging
config_->g_threads = 1;
// Rate control settings.
config_->rc_dropframe_thresh =
inst->codecSpecific.VP9.frameDroppingOn ? 30 : 0;
config_->rc_dropframe_thresh = inst->VP9().frameDroppingOn ? 30 : 0;
config_->rc_end_usage = VPX_CBR;
config_->g_pass = VPX_RC_ONE_PASS;
config_->rc_min_quantizer = 2;
@ -311,17 +310,16 @@ int VP9EncoderImpl::InitEncode(const VideoCodec* inst,
config_->rc_buf_sz = 1000;
// Set the maximum target size of any key-frame.
rc_max_intra_target_ = MaxIntraTarget(config_->rc_buf_optimal_sz);
if (inst->codecSpecific.VP9.keyFrameInterval > 0) {
if (inst->VP9().keyFrameInterval > 0) {
config_->kf_mode = VPX_KF_AUTO;
config_->kf_max_dist = inst->codecSpecific.VP9.keyFrameInterval;
config_->kf_max_dist = inst->VP9().keyFrameInterval;
// Needs to be set (in svc mode) to get correct periodic key frame interval
// (will have no effect in non-svc).
config_->kf_min_dist = config_->kf_max_dist;
} else {
config_->kf_mode = VPX_KF_DISABLED;
}
config_->rc_resize_allowed =
inst->codecSpecific.VP9.automaticResizeOn ? 1 : 0;
config_->rc_resize_allowed = inst->VP9().automaticResizeOn ? 1 : 0;
// Determine number of threads based on the image size and #cores.
config_->g_threads =
NumberOfThreads(config_->g_w, config_->g_h, number_of_cores);
@ -330,7 +328,7 @@ int VP9EncoderImpl::InitEncode(const VideoCodec* inst,
// TODO(asapersson): Check configuration of temporal switch up and increase
// pattern length.
is_flexible_mode_ = inst->codecSpecific.VP9.flexibleMode;
is_flexible_mode_ = inst->VP9().flexibleMode;
if (is_flexible_mode_) {
config_->temporal_layering_mode = VP9E_TEMPORAL_LAYERING_MODE_BYPASS;
config_->ts_number_layers = num_temporal_layers_;
@ -424,7 +422,7 @@ int VP9EncoderImpl::InitAndSetControlSettings(const VideoCodec* inst) {
vpx_codec_control(encoder_, VP8E_SET_MAX_INTRA_BITRATE_PCT,
rc_max_intra_target_);
vpx_codec_control(encoder_, VP9E_SET_AQ_MODE,
inst->codecSpecific.VP9.adaptiveQpMode ? 3 : 0);
inst->VP9().adaptiveQpMode ? 3 : 0);
vpx_codec_control(
encoder_, VP9E_SET_SVC,
@ -448,9 +446,9 @@ int VP9EncoderImpl::InitAndSetControlSettings(const VideoCodec* inst) {
#if !defined(WEBRTC_ARCH_ARM) && !defined(WEBRTC_ARCH_ARM64) && \
!defined(ANDROID)
// Note denoiser is still off by default until further testing/optimization,
// i.e., codecSpecific.VP9.denoisingOn == 0.
// i.e., VP9().denoisingOn == 0.
vpx_codec_control(encoder_, VP9E_SET_NOISE_SENSITIVITY,
inst->codecSpecific.VP9.denoisingOn ? 1 : 0);
inst->VP9().denoisingOn ? 1 : 0);
#endif
if (codec_.mode == kScreensharing) {
// Adjust internal parameters to screen content.
@ -565,11 +563,11 @@ void VP9EncoderImpl::PopulateCodecSpecific(CodecSpecificInfo* codec_specific,
// TODO(asapersson): Set correct value.
vp9_info->inter_pic_predicted =
(pkt.data.frame.flags & VPX_FRAME_IS_KEY) ? false : true;
vp9_info->flexible_mode = codec_.codecSpecific.VP9.flexibleMode;
vp9_info->ss_data_available = ((pkt.data.frame.flags & VPX_FRAME_IS_KEY) &&
!codec_.codecSpecific.VP9.flexibleMode)
? true
: false;
vp9_info->flexible_mode = codec_.VP9()->flexibleMode;
vp9_info->ss_data_available =
((pkt.data.frame.flags & VPX_FRAME_IS_KEY) && !codec_.VP9()->flexibleMode)
? true
: false;
vpx_svc_layer_id_t layer_id = {0};
vpx_codec_control(encoder_, VP9E_GET_SVC_LAYER_ID, &layer_id);