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:
@@ -37,6 +37,7 @@ DefaultTemporalLayers::DefaultTemporalLayers(int numberOfTemporalLayers,
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool DefaultTemporalLayers::ConfigureBitrates(int bitrateKbit,
|
bool DefaultTemporalLayers::ConfigureBitrates(int bitrateKbit,
|
||||||
|
int max_bitrate_kbit,
|
||||||
int framerate,
|
int framerate,
|
||||||
vpx_codec_enc_cfg_t* cfg) {
|
vpx_codec_enc_cfg_t* cfg) {
|
||||||
switch (number_of_temporal_layers_) {
|
switch (number_of_temporal_layers_) {
|
||||||
|
|||||||
@@ -27,6 +27,7 @@ class DefaultTemporalLayers : public TemporalLayers {
|
|||||||
virtual int EncodeFlags(uint32_t timestamp);
|
virtual int EncodeFlags(uint32_t timestamp);
|
||||||
|
|
||||||
virtual bool ConfigureBitrates(int bitrate_kbit,
|
virtual bool ConfigureBitrates(int bitrate_kbit,
|
||||||
|
int max_bitrate_kbit,
|
||||||
int framerate,
|
int framerate,
|
||||||
vpx_codec_enc_cfg_t* cfg);
|
vpx_codec_enc_cfg_t* cfg);
|
||||||
|
|
||||||
|
|||||||
@@ -66,7 +66,7 @@ TEST(TemporalLayersTest, 2Layers) {
|
|||||||
DefaultTemporalLayers tl(2, 0);
|
DefaultTemporalLayers tl(2, 0);
|
||||||
vpx_codec_enc_cfg_t cfg;
|
vpx_codec_enc_cfg_t cfg;
|
||||||
CodecSpecificInfoVP8 vp8_info;
|
CodecSpecificInfoVP8 vp8_info;
|
||||||
tl.ConfigureBitrates(500, 30, &cfg);
|
tl.ConfigureBitrates(500, 500, 30, &cfg);
|
||||||
|
|
||||||
int expected_flags[16] = { kTemporalUpdateLastAndGoldenRefAltRef,
|
int expected_flags[16] = { kTemporalUpdateLastAndGoldenRefAltRef,
|
||||||
kTemporalUpdateGoldenWithoutDependencyRefAltRef,
|
kTemporalUpdateGoldenWithoutDependencyRefAltRef,
|
||||||
@@ -106,7 +106,7 @@ TEST(TemporalLayersTest, 3Layers) {
|
|||||||
DefaultTemporalLayers tl(3, 0);
|
DefaultTemporalLayers tl(3, 0);
|
||||||
vpx_codec_enc_cfg_t cfg;
|
vpx_codec_enc_cfg_t cfg;
|
||||||
CodecSpecificInfoVP8 vp8_info;
|
CodecSpecificInfoVP8 vp8_info;
|
||||||
tl.ConfigureBitrates(500, 30, &cfg);
|
tl.ConfigureBitrates(500, 500, 30, &cfg);
|
||||||
|
|
||||||
int expected_flags[16] = { kTemporalUpdateLastAndGoldenRefAltRef,
|
int expected_flags[16] = { kTemporalUpdateLastAndGoldenRefAltRef,
|
||||||
kTemporalUpdateNoneNoRefGolden,
|
kTemporalUpdateNoneNoRefGolden,
|
||||||
@@ -146,7 +146,7 @@ TEST(TemporalLayersTest, 4Layers) {
|
|||||||
DefaultTemporalLayers tl(4, 0);
|
DefaultTemporalLayers tl(4, 0);
|
||||||
vpx_codec_enc_cfg_t cfg;
|
vpx_codec_enc_cfg_t cfg;
|
||||||
CodecSpecificInfoVP8 vp8_info;
|
CodecSpecificInfoVP8 vp8_info;
|
||||||
tl.ConfigureBitrates(500, 30, &cfg);
|
tl.ConfigureBitrates(500, 500, 30, &cfg);
|
||||||
int expected_flags[16] = {
|
int expected_flags[16] = {
|
||||||
kTemporalUpdateLast,
|
kTemporalUpdateLast,
|
||||||
kTemporalUpdateNone,
|
kTemporalUpdateNone,
|
||||||
@@ -186,7 +186,7 @@ TEST(TemporalLayersTest, KeyFrame) {
|
|||||||
DefaultTemporalLayers tl(3, 0);
|
DefaultTemporalLayers tl(3, 0);
|
||||||
vpx_codec_enc_cfg_t cfg;
|
vpx_codec_enc_cfg_t cfg;
|
||||||
CodecSpecificInfoVP8 vp8_info;
|
CodecSpecificInfoVP8 vp8_info;
|
||||||
tl.ConfigureBitrates(500, 30, &cfg);
|
tl.ConfigureBitrates(500, 500, 30, &cfg);
|
||||||
|
|
||||||
int expected_flags[8] = {
|
int expected_flags[8] = {
|
||||||
kTemporalUpdateLastAndGoldenRefAltRef,
|
kTemporalUpdateLastAndGoldenRefAltRef,
|
||||||
|
|||||||
@@ -31,6 +31,7 @@ class TemporalLayers {
|
|||||||
virtual int EncodeFlags(uint32_t timestamp) = 0;
|
virtual int EncodeFlags(uint32_t timestamp) = 0;
|
||||||
|
|
||||||
virtual bool ConfigureBitrates(int bitrate_kbit,
|
virtual bool ConfigureBitrates(int bitrate_kbit,
|
||||||
|
int max_bitrate_kbit,
|
||||||
int framerate,
|
int framerate,
|
||||||
vpx_codec_enc_cfg_t* cfg) = 0;
|
vpx_codec_enc_cfg_t* cfg) = 0;
|
||||||
|
|
||||||
|
|||||||
@@ -113,7 +113,8 @@ int VP8EncoderImpl::SetRates(uint32_t new_bitrate_kbit,
|
|||||||
config_->rc_target_bitrate = new_bitrate_kbit; // in kbit/s
|
config_->rc_target_bitrate = new_bitrate_kbit; // in kbit/s
|
||||||
|
|
||||||
#if WEBRTC_LIBVPX_VERSION >= 971
|
#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
|
#endif
|
||||||
codec_.maxFramerate = new_framerate;
|
codec_.maxFramerate = new_framerate;
|
||||||
|
|
||||||
@@ -190,8 +191,8 @@ int VP8EncoderImpl::InitEncode(const VideoCodec* inst,
|
|||||||
config_->rc_target_bitrate = inst->startBitrate; // in kbit/s
|
config_->rc_target_bitrate = inst->startBitrate; // in kbit/s
|
||||||
|
|
||||||
#if WEBRTC_LIBVPX_VERSION >= 971
|
#if WEBRTC_LIBVPX_VERSION >= 971
|
||||||
temporal_layers_->ConfigureBitrates(inst->startBitrate, inst->maxFramerate,
|
temporal_layers_->ConfigureBitrates(inst->startBitrate, inst->maxBitrate,
|
||||||
config_);
|
inst->maxFramerate, config_);
|
||||||
#endif
|
#endif
|
||||||
// setting the time base of the codec
|
// setting the time base of the codec
|
||||||
config_->g_timebase.num = 1;
|
config_->g_timebase.num = 1;
|
||||||
|
|||||||
@@ -330,6 +330,10 @@ VideoCodingModuleImpl::RegisterSendCodec(const VideoCodec* sendCodec,
|
|||||||
_sendCodecType = sendCodec->codecType;
|
_sendCodecType = sendCodec->codecType;
|
||||||
int numLayers = (_sendCodecType != kVideoCodecVP8) ? 1 :
|
int numLayers = (_sendCodecType != kVideoCodecVP8) ? 1 :
|
||||||
sendCodec->codecSpecific.VP8.numberOfTemporalLayers;
|
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.clear();
|
||||||
_nextFrameTypes.resize(VCM_MAX(sendCodec->numberOfSimulcastStreams, 1),
|
_nextFrameTypes.resize(VCM_MAX(sendCodec->numberOfSimulcastStreams, 1),
|
||||||
kVideoFrameDelta);
|
kVideoFrameDelta);
|
||||||
|
|||||||
@@ -15,12 +15,30 @@
|
|||||||
namespace webrtc
|
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()
|
FrameDropper::FrameDropper()
|
||||||
:
|
:
|
||||||
_keyFrameSizeAvgKbits(0.9f),
|
_keyFrameSizeAvgKbits(kDefaultKeyFrameSizeAvgKBits),
|
||||||
_keyFrameRatio(0.99f),
|
_keyFrameRatio(kDefaultKeyFrameRatio),
|
||||||
_dropRatio(0.9f, 0.96f),
|
_dropRatio(kDefaultDropRatioAlpha, kDefaultDropRatioMax),
|
||||||
_enabled(true)
|
_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();
|
Reset();
|
||||||
}
|
}
|
||||||
@@ -138,6 +156,10 @@ FrameDropper::Leak(WebRtc_UWord32 inputFrameRate)
|
|||||||
_keyFrameCount--;
|
_keyFrameCount--;
|
||||||
}
|
}
|
||||||
_accumulator -= T;
|
_accumulator -= T;
|
||||||
|
if (_accumulator < 0.0f)
|
||||||
|
{
|
||||||
|
_accumulator = 0.0f;
|
||||||
|
}
|
||||||
UpdateRatio();
|
UpdateRatio();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -192,10 +214,6 @@ FrameDropper::UpdateRatio()
|
|||||||
{
|
{
|
||||||
_dropRatio.Apply(1.0f, 0.0f);
|
_dropRatio.Apply(1.0f, 0.0f);
|
||||||
}
|
}
|
||||||
if (_accumulator < 0.0f)
|
|
||||||
{
|
|
||||||
_accumulator = 0.0f;
|
|
||||||
}
|
|
||||||
_wasBelowMax = _accumulator < _accumulatorMax;
|
_wasBelowMax = _accumulator < _accumulatorMax;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -24,6 +24,7 @@ class FrameDropper
|
|||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
FrameDropper();
|
FrameDropper();
|
||||||
|
explicit FrameDropper(float max_time_drops);
|
||||||
virtual ~FrameDropper() {}
|
virtual ~FrameDropper() {}
|
||||||
|
|
||||||
// Resets the FrameDropper to its initial state.
|
// Resets the FrameDropper to its initial state.
|
||||||
@@ -66,7 +67,6 @@ public:
|
|||||||
// instruction of when to drop frames.
|
// instruction of when to drop frames.
|
||||||
virtual float ActualFrameRate(WebRtc_UWord32 inputFrameRate) const;
|
virtual float ActualFrameRate(WebRtc_UWord32 inputFrameRate) const;
|
||||||
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void FillBucket(float inKbits, float outKbits);
|
void FillBucket(float inKbits, float outKbits);
|
||||||
void UpdateRatio();
|
void UpdateRatio();
|
||||||
|
|||||||
Reference in New Issue
Block a user