Disable frame dropper for screenshare mode.

BUG=1466

Review URL: https://webrtc-codereview.appspot.com/1170004

git-svn-id: http://webrtc.googlecode.com/svn/trunk@3629 4adac7df-926f-26a2-2b94-8c16560cd09d
This commit is contained in:
stefan@webrtc.org 2013-03-07 13:12:32 +00:00
parent 7c16c3c4a1
commit 84cd8e39cf
8 changed files with 42 additions and 16 deletions

View File

@ -37,6 +37,7 @@ DefaultTemporalLayers::DefaultTemporalLayers(int numberOfTemporalLayers,
}
bool DefaultTemporalLayers::ConfigureBitrates(int bitrateKbit,
int max_bitrate_kbit,
int framerate,
vpx_codec_enc_cfg_t* cfg) {
switch (number_of_temporal_layers_) {

View File

@ -27,6 +27,7 @@ class DefaultTemporalLayers : public TemporalLayers {
virtual int EncodeFlags(uint32_t timestamp);
virtual bool ConfigureBitrates(int bitrate_kbit,
int max_bitrate_kbit,
int framerate,
vpx_codec_enc_cfg_t* cfg);

View File

@ -66,7 +66,7 @@ TEST(TemporalLayersTest, 2Layers) {
DefaultTemporalLayers tl(2, 0);
vpx_codec_enc_cfg_t cfg;
CodecSpecificInfoVP8 vp8_info;
tl.ConfigureBitrates(500, 30, &cfg);
tl.ConfigureBitrates(500, 500, 30, &cfg);
int expected_flags[16] = { kTemporalUpdateLastAndGoldenRefAltRef,
kTemporalUpdateGoldenWithoutDependencyRefAltRef,
@ -106,7 +106,7 @@ TEST(TemporalLayersTest, 3Layers) {
DefaultTemporalLayers tl(3, 0);
vpx_codec_enc_cfg_t cfg;
CodecSpecificInfoVP8 vp8_info;
tl.ConfigureBitrates(500, 30, &cfg);
tl.ConfigureBitrates(500, 500, 30, &cfg);
int expected_flags[16] = { kTemporalUpdateLastAndGoldenRefAltRef,
kTemporalUpdateNoneNoRefGolden,
@ -146,7 +146,7 @@ TEST(TemporalLayersTest, 4Layers) {
DefaultTemporalLayers tl(4, 0);
vpx_codec_enc_cfg_t cfg;
CodecSpecificInfoVP8 vp8_info;
tl.ConfigureBitrates(500, 30, &cfg);
tl.ConfigureBitrates(500, 500, 30, &cfg);
int expected_flags[16] = {
kTemporalUpdateLast,
kTemporalUpdateNone,
@ -186,7 +186,7 @@ TEST(TemporalLayersTest, KeyFrame) {
DefaultTemporalLayers tl(3, 0);
vpx_codec_enc_cfg_t cfg;
CodecSpecificInfoVP8 vp8_info;
tl.ConfigureBitrates(500, 30, &cfg);
tl.ConfigureBitrates(500, 500, 30, &cfg);
int expected_flags[8] = {
kTemporalUpdateLastAndGoldenRefAltRef,

View File

@ -31,6 +31,7 @@ class TemporalLayers {
virtual int EncodeFlags(uint32_t timestamp) = 0;
virtual bool ConfigureBitrates(int bitrate_kbit,
int max_bitrate_kbit,
int framerate,
vpx_codec_enc_cfg_t* cfg) = 0;

View File

@ -113,7 +113,8 @@ int VP8EncoderImpl::SetRates(uint32_t new_bitrate_kbit,
config_->rc_target_bitrate = new_bitrate_kbit; // in kbit/s
#if WEBRTC_LIBVPX_VERSION >= 971
temporal_layers_->ConfigureBitrates(new_bitrate_kbit, new_framerate, config_);
temporal_layers_->ConfigureBitrates(new_bitrate_kbit, codec_.maxBitrate,
new_framerate, config_);
#endif
codec_.maxFramerate = new_framerate;
@ -190,8 +191,8 @@ int VP8EncoderImpl::InitEncode(const VideoCodec* inst,
config_->rc_target_bitrate = inst->startBitrate; // in kbit/s
#if WEBRTC_LIBVPX_VERSION >= 971
temporal_layers_->ConfigureBitrates(inst->startBitrate, inst->maxFramerate,
config_);
temporal_layers_->ConfigureBitrates(inst->startBitrate, inst->maxBitrate,
inst->maxFramerate, config_);
#endif
// setting the time base of the codec
config_->g_timebase.num = 1;

View File

@ -330,6 +330,10 @@ VideoCodingModuleImpl::RegisterSendCodec(const VideoCodec* sendCodec,
_sendCodecType = sendCodec->codecType;
int numLayers = (_sendCodecType != kVideoCodecVP8) ? 1 :
sendCodec->codecSpecific.VP8.numberOfTemporalLayers;
// Disable frame dropper if screensharing if we have layers.
bool disable_frame_dropper =
numLayers > 1 && sendCodec->mode == kScreensharing;
_mediaOpt.EnableFrameDropper(!disable_frame_dropper);
_nextFrameTypes.clear();
_nextFrameTypes.resize(VCM_MAX(sendCodec->numberOfSimulcastStreams, 1),
kVideoFrameDelta);

View File

@ -15,12 +15,30 @@
namespace webrtc
{
const float kDefaultKeyFrameSizeAvgKBits = 0.9f;
const float kDefaultKeyFrameRatio = 0.99f;
const float kDefaultDropRatioAlpha = 0.9f;
const float kDefaultDropRatioMax = 0.96f;
const float kDefaultMaxTimeToDropFrames = 4.0f; // In seconds.
FrameDropper::FrameDropper()
:
_keyFrameSizeAvgKbits(0.9f),
_keyFrameRatio(0.99f),
_dropRatio(0.9f, 0.96f),
_enabled(true)
_keyFrameSizeAvgKbits(kDefaultKeyFrameSizeAvgKBits),
_keyFrameRatio(kDefaultKeyFrameRatio),
_dropRatio(kDefaultDropRatioAlpha, kDefaultDropRatioMax),
_enabled(true),
_max_time_drops(kDefaultMaxTimeToDropFrames)
{
Reset();
}
FrameDropper::FrameDropper(float max_time_drops)
:
_keyFrameSizeAvgKbits(kDefaultKeyFrameSizeAvgKBits),
_keyFrameRatio(kDefaultKeyFrameRatio),
_dropRatio(kDefaultDropRatioAlpha, kDefaultDropRatioMax),
_enabled(true),
_max_time_drops(max_time_drops)
{
Reset();
}
@ -138,6 +156,10 @@ FrameDropper::Leak(WebRtc_UWord32 inputFrameRate)
_keyFrameCount--;
}
_accumulator -= T;
if (_accumulator < 0.0f)
{
_accumulator = 0.0f;
}
UpdateRatio();
}
@ -192,10 +214,6 @@ FrameDropper::UpdateRatio()
{
_dropRatio.Apply(1.0f, 0.0f);
}
if (_accumulator < 0.0f)
{
_accumulator = 0.0f;
}
_wasBelowMax = _accumulator < _accumulatorMax;
}

View File

@ -24,6 +24,7 @@ class FrameDropper
{
public:
FrameDropper();
explicit FrameDropper(float max_time_drops);
virtual ~FrameDropper() {}
// Resets the FrameDropper to its initial state.
@ -66,7 +67,6 @@ public:
// instruction of when to drop frames.
virtual float ActualFrameRate(WebRtc_UWord32 inputFrameRate) const;
private:
void FillBucket(float inKbits, float outKbits);
void UpdateRatio();