Stop using VideoCodec.targetBitrate for vp8 screenshare config
This is a step toward simplifying the VideoCodec struct and removing the targetBitrate. The hard-coded values now reside in SimulcastRateAllocator. A follow-up will do away with the field altogether. Bug: webrtc:9504 Change-Id: I74d483682309d363048fbbbd31e0607d7242f504 Reviewed-on: https://webrtc-review.googlesource.com/87424 Reviewed-by: Rasmus Brandt <brandtr@webrtc.org> Commit-Queue: Erik Språng <sprang@webrtc.org> Cr-Commit-Position: refs/heads/master@{#23876}
This commit is contained in:
@ -281,11 +281,7 @@ int32_t H264EncoderImpl::InitEncode(const VideoCodec* inst,
|
||||
|
||||
// Codec_settings uses kbits/second; encoder uses bits/second.
|
||||
configurations_[i].max_bps = codec_.maxBitrate * 1000;
|
||||
if (codec_.targetBitrate == 0) {
|
||||
configurations_[i].target_bps = codec_.startBitrate * 1000;
|
||||
} else {
|
||||
configurations_[i].target_bps = codec_.targetBitrate * 1000;
|
||||
}
|
||||
|
||||
// Create encoder parameters based on the layer configuration.
|
||||
SEncParamExt encoder_params = CreateEncoderParams(i);
|
||||
@ -315,9 +311,7 @@ int32_t H264EncoderImpl::InitEncode(const VideoCodec* inst,
|
||||
|
||||
SimulcastRateAllocator init_allocator(codec_);
|
||||
BitrateAllocation allocation = init_allocator.GetAllocation(
|
||||
codec_.targetBitrate ? codec_.targetBitrate * 1000
|
||||
: codec_.startBitrate * 1000,
|
||||
codec_.maxFramerate);
|
||||
codec_.startBitrate * 1000, codec_.maxFramerate);
|
||||
return SetRateAllocation(allocation, codec_.maxFramerate);
|
||||
}
|
||||
|
||||
|
@ -28,7 +28,7 @@ void SetDefaultSettings(VideoCodec* codec_settings) {
|
||||
// If frame dropping is false, we get a warning that bitrate can't
|
||||
// be controlled for RC_QUALITY_MODE; RC_BITRATE_MODE and RC_TIMESTAMP_MODE
|
||||
codec_settings->H264()->frameDroppingOn = true;
|
||||
codec_settings->targetBitrate = 2000;
|
||||
codec_settings->startBitrate = 2000;
|
||||
codec_settings->maxBitrate = 4000;
|
||||
}
|
||||
|
||||
|
@ -18,7 +18,6 @@ static const int kEncodeTimeoutMs = 100;
|
||||
static const int kDecodeTimeoutMs = 25;
|
||||
// Set bitrate to get higher quality.
|
||||
static const int kStartBitrate = 300;
|
||||
static const int kTargetBitrate = 2000;
|
||||
static const int kMaxBitrate = 4000;
|
||||
static const int kWidth = 176; // Width of the input image.
|
||||
static const int kHeight = 144; // Height of the input image.
|
||||
@ -61,7 +60,6 @@ void VideoCodecUnitTest::FakeDecodeCompleteCallback::Decoded(
|
||||
void VideoCodecUnitTest::SetUp() {
|
||||
webrtc::test::CodecSettings(kVideoCodecVP8, &codec_settings_);
|
||||
codec_settings_.startBitrate = kStartBitrate;
|
||||
codec_settings_.targetBitrate = kTargetBitrate;
|
||||
codec_settings_.maxBitrate = kMaxBitrate;
|
||||
codec_settings_.maxFramerate = kMaxFramerate;
|
||||
codec_settings_.width = kWidth;
|
||||
|
@ -56,7 +56,6 @@ std::vector<uint32_t> GetTemporalLayerRates(int target_bitrate_kbps,
|
||||
VideoCodec codec;
|
||||
codec.codecType = VideoCodecType::kVideoCodecVP8;
|
||||
codec.numberOfSimulcastStreams = 1;
|
||||
codec.targetBitrate = target_bitrate_kbps;
|
||||
codec.maxBitrate = target_bitrate_kbps;
|
||||
codec.maxFramerate = framerate_fps;
|
||||
codec.simulcastStream[0].targetBitrate = target_bitrate_kbps;
|
||||
|
@ -30,7 +30,6 @@ class DefaultVideoBitrateAllocatorTest : public ::testing::Test {
|
||||
codec_.codecType = kVideoCodecVP8;
|
||||
codec_.minBitrate = kMinBitrateBps / 1000;
|
||||
codec_.maxBitrate = kMaxBitrateBps / 1000;
|
||||
codec_.targetBitrate = (kMinBitrateBps + kMaxBitrateBps) / 2000;
|
||||
codec_.maxFramerate = kMaxFramerate;
|
||||
allocator_.reset(new DefaultVideoBitrateAllocator(codec_));
|
||||
}
|
||||
|
@ -34,6 +34,9 @@ static const float
|
||||
static const float kShort3TlRateAllocation[kMaxTemporalStreams] = {
|
||||
0.6f, 0.8f, 1.0f, 1.0f // 3 layers {60%, 20%, 20%}
|
||||
};
|
||||
|
||||
const uint32_t kLegacyScreenshareTl0BitrateKbps = 200;
|
||||
const uint32_t kLegacyScreenshareTl1BitrateKbps = 1000;
|
||||
} // namespace
|
||||
|
||||
float SimulcastRateAllocator::GetTemporalRateAllocation(int num_layers,
|
||||
@ -164,7 +167,6 @@ void SimulcastRateAllocator::DistributeAllocationToTemporalLayers(
|
||||
// with legacy mode for simulcast stream 0.
|
||||
const bool conference_screenshare_mode =
|
||||
codec_.mode == VideoCodecMode::kScreensharing &&
|
||||
codec_.targetBitrate > 0 &&
|
||||
((num_spatial_streams == 1 && num_temporal_streams == 2) || // Legacy.
|
||||
(num_spatial_streams > 1 && simulcast_id == 0)); // Simulcast.
|
||||
if (conference_screenshare_mode) {
|
||||
@ -173,9 +175,10 @@ void SimulcastRateAllocator::DistributeAllocationToTemporalLayers(
|
||||
// to allow for a different max bitrate, so if the codec can't meet
|
||||
// the target we still allow it to overshoot up to the max before dropping
|
||||
// frames. This hack should be improved.
|
||||
int tl0_bitrate = std::min(codec_.targetBitrate, target_bitrate_kbps);
|
||||
max_bitrate_kbps = std::min(codec_.maxBitrate, target_bitrate_kbps);
|
||||
target_bitrate_kbps = tl0_bitrate;
|
||||
max_bitrate_kbps =
|
||||
std::min(kLegacyScreenshareTl1BitrateKbps, target_bitrate_kbps);
|
||||
target_bitrate_kbps =
|
||||
std::min(kLegacyScreenshareTl0BitrateKbps, target_bitrate_kbps);
|
||||
} else if (num_spatial_streams == 1) {
|
||||
max_bitrate_kbps = codec_.maxBitrate;
|
||||
} else {
|
||||
|
@ -24,10 +24,11 @@ namespace webrtc {
|
||||
namespace {
|
||||
using ::testing::_;
|
||||
|
||||
constexpr uint32_t kMinBitrateKbps = 50;
|
||||
constexpr uint32_t kTargetBitrateKbps = 100;
|
||||
constexpr uint32_t kMaxBitrateKbps = 1000;
|
||||
constexpr uint32_t kFramerateFps = 5;
|
||||
constexpr uint32_t kMinBitrateKbps = 50;
|
||||
// These correspond to kLegacyScreenshareTl(0|1)BitrateKbps in cc.
|
||||
constexpr uint32_t kTargetBitrateKbps = 200;
|
||||
constexpr uint32_t kMaxBitrateKbps = 1000;
|
||||
|
||||
class MockTemporalLayers : public TemporalLayers {
|
||||
public:
|
||||
@ -52,7 +53,6 @@ class SimulcastRateAllocatorTest : public ::testing::TestWithParam<bool> {
|
||||
memset(&codec_, 0, sizeof(VideoCodec));
|
||||
codec_.codecType = kVideoCodecVP8;
|
||||
codec_.minBitrate = kMinBitrateKbps;
|
||||
codec_.targetBitrate = kTargetBitrateKbps;
|
||||
codec_.maxBitrate = kMaxBitrateKbps;
|
||||
codec_.active = true;
|
||||
CreateAllocator();
|
||||
@ -481,7 +481,6 @@ class ScreenshareRateAllocationTest : public SimulcastRateAllocatorTest {
|
||||
codec_.simulcastStream[0].active = active;
|
||||
} else {
|
||||
codec_.numberOfSimulcastStreams = 0;
|
||||
codec_.targetBitrate = kTargetBitrateKbps;
|
||||
codec_.VP8()->numberOfTemporalLayers = 2;
|
||||
codec_.active = active;
|
||||
}
|
||||
|
@ -84,9 +84,6 @@ VideoCodec VideoCodecInitializer::VideoEncoderConfigToVideoCodec(
|
||||
break;
|
||||
case VideoEncoderConfig::ContentType::kScreen:
|
||||
video_codec.mode = VideoCodecMode::kScreensharing;
|
||||
if (!streams.empty() && streams[0].num_temporal_layers == 2u) {
|
||||
video_codec.targetBitrate = streams[0].target_bitrate_bps / 1000;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
|
@ -28,7 +28,7 @@ static const uint32_t kDefaultTargetBitrateBps = 2000000;
|
||||
static const uint32_t kDefaultMaxBitrateBps = 2000000;
|
||||
static const uint32_t kDefaultMinTransmitBitrateBps = 400000;
|
||||
static const int kDefaultMaxQp = 48;
|
||||
static const uint32_t kScreenshareTl0BitrateBps = 100000;
|
||||
static const uint32_t kScreenshareTl0BitrateBps = 200000;
|
||||
static const uint32_t kScreenshareCodecTargetBitrateBps = 200000;
|
||||
static const uint32_t kScreenshareDefaultFramerate = 5;
|
||||
// Bitrates for the temporal layers of the higher screenshare simulcast stream.
|
||||
|
@ -2786,8 +2786,10 @@ TEST_F(VideoSendStreamTest, TranslatesTwoLayerScreencastToTargetBitrate) {
|
||||
int32_t InitEncode(const VideoCodec* config,
|
||||
int32_t number_of_cores,
|
||||
size_t max_payload_size) override {
|
||||
EXPECT_EQ(config->numberOfSimulcastStreams, 1);
|
||||
EXPECT_EQ(static_cast<unsigned int>(kScreencastMaxTargetBitrateDeltaKbps),
|
||||
config->maxBitrate - config->targetBitrate);
|
||||
config->simulcastStream[0].maxBitrate -
|
||||
config->simulcastStream[0].targetBitrate);
|
||||
observation_complete_.Set();
|
||||
return test::FakeEncoder::InitEncode(config, number_of_cores,
|
||||
max_payload_size);
|
||||
|
Reference in New Issue
Block a user