Skip to content
Snippets Groups Projects
Commit 0e53344b authored by Pierre Lespagnol's avatar Pierre Lespagnol
Browse files

autoadapt: tune parameters for autoadapt algorithm

- Decrease drops threshold for bitrate diminution (10% to 5%)
- Space number of decrease from 2 to 1 every 500ms for delays detection
- Always use bitrate from MediaStream during encoder init

Change-Id: If3d696b8fc1bc7f6fabe98f70652921d4113b7b7
parent 588a23f7
No related branches found
No related tags found
No related merge requests found
...@@ -213,7 +213,7 @@ MediaEncoder::initStream(const SystemCodecInfo& systemCodecInfo, AVBufferRef* fr ...@@ -213,7 +213,7 @@ MediaEncoder::initStream(const SystemCodecInfo& systemCodecInfo, AVBufferRef* fr
for (const auto& it : APIs) { for (const auto& it : APIs) {
accel_ = std::make_unique<video::HardwareAccel>(it); // save accel accel_ = std::make_unique<video::HardwareAccel>(it); // save accel
// Init codec need accel_ to init encoderCtx accelerated // Init codec need accel_ to init encoderCtx accelerated
encoderCtx = initCodec(mediaType, static_cast<AVCodecID>(systemCodecInfo.avcodecId), SystemCodecInfo::DEFAULT_VIDEO_BITRATE); encoderCtx = initCodec(mediaType, static_cast<AVCodecID>(systemCodecInfo.avcodecId), videoOpts_.bitrate);
encoderCtx->opaque = accel_.get(); encoderCtx->opaque = accel_.get();
// Check if pixel format from encoder match pixel format from decoder frame context // Check if pixel format from encoder match pixel format from decoder frame context
// if it mismatch, it means that we are using two different hardware API (nvenc and vaapi for example) // if it mismatch, it means that we are using two different hardware API (nvenc and vaapi for example)
...@@ -249,7 +249,7 @@ MediaEncoder::initStream(const SystemCodecInfo& systemCodecInfo, AVBufferRef* fr ...@@ -249,7 +249,7 @@ MediaEncoder::initStream(const SystemCodecInfo& systemCodecInfo, AVBufferRef* fr
if (!encoderCtx) { if (!encoderCtx) {
JAMI_WARN("Not using hardware encoding for %s", avcodec_get_name(static_cast<AVCodecID>(systemCodecInfo.avcodecId))); JAMI_WARN("Not using hardware encoding for %s", avcodec_get_name(static_cast<AVCodecID>(systemCodecInfo.avcodecId)));
encoderCtx = initCodec(mediaType, static_cast<AVCodecID>(systemCodecInfo.avcodecId), SystemCodecInfo::DEFAULT_VIDEO_BITRATE); encoderCtx = initCodec(mediaType, static_cast<AVCodecID>(systemCodecInfo.avcodecId), videoOpts_.bitrate);
readConfig(encoderCtx); readConfig(encoderCtx);
encoders_.push_back(encoderCtx); encoders_.push_back(encoderCtx);
if (avcodec_open2(encoderCtx, outputCodec_, &options_) < 0) if (avcodec_open2(encoderCtx, outputCodec_, &options_) < 0)
......
...@@ -51,7 +51,7 @@ static constexpr unsigned MAX_SIZE_HISTO_QUALITY {30}; ...@@ -51,7 +51,7 @@ static constexpr unsigned MAX_SIZE_HISTO_QUALITY {30};
static constexpr unsigned MAX_SIZE_HISTO_BITRATE {100}; static constexpr unsigned MAX_SIZE_HISTO_BITRATE {100};
static constexpr unsigned MAX_SIZE_HISTO_JITTER {50}; static constexpr unsigned MAX_SIZE_HISTO_JITTER {50};
static constexpr unsigned MAX_SIZE_HISTO_DELAY {25}; static constexpr unsigned MAX_SIZE_HISTO_DELAY {25};
static constexpr unsigned MAX_REMB_DEC {2}; static constexpr unsigned MAX_REMB_DEC {1};
constexpr auto DELAY_AFTER_RESTART = std::chrono::milliseconds(1000); constexpr auto DELAY_AFTER_RESTART = std::chrono::milliseconds(1000);
constexpr auto EXPIRY_TIME_RTCP = std::chrono::seconds(2); constexpr auto EXPIRY_TIME_RTCP = std::chrono::seconds(2);
...@@ -131,6 +131,7 @@ void VideoRtpSession::startSender() ...@@ -131,6 +131,7 @@ void VideoRtpSession::startSender()
send_.mode = autoQuality ? RateMode::CBR : RateMode::CRF_CONSTRAINED; send_.mode = autoQuality ? RateMode::CBR : RateMode::CRF_CONSTRAINED;
send_.linkableHW = conference_ == nullptr; send_.linkableHW = conference_ == nullptr;
send_.bitrate = videoBitrateInfo_.videoBitrateCurrent;
if (sender_) if (sender_)
initSeqVal_ = sender_->getLastSeqValue() + 10; // Skip a few sequences to make nvenc happy on a sender restart initSeqVal_ = sender_->getLastSeqValue() + 10; // Skip a few sequences to make nvenc happy on a sender restart
...@@ -489,7 +490,7 @@ VideoRtpSession::dropProcessing(RTCPInfo* rtcpi) ...@@ -489,7 +490,7 @@ VideoRtpSession::dropProcessing(RTCPInfo* rtcpi)
else { else {
// If ponderate drops are inferior to 10% that mean drop are not from congestion but from network... // If ponderate drops are inferior to 10% that mean drop are not from congestion but from network...
// ... we can increase // ... we can increase
if (pondLoss >= 10.0f && rtcpi->packetLoss > 0.0f) { if (pondLoss >= 5.0f && rtcpi->packetLoss > 0.0f) {
newBitrate *= 1.0f - rtcpi->packetLoss/150.0f; newBitrate *= 1.0f - rtcpi->packetLoss/150.0f;
histoLoss_.clear(); histoLoss_.clear();
lastMediaRestart_ = now; lastMediaRestart_ = now;
...@@ -515,7 +516,6 @@ VideoRtpSession::delayProcessing(int br) ...@@ -515,7 +516,6 @@ VideoRtpSession::delayProcessing(int br)
setNewBitrate(newBitrate); setNewBitrate(newBitrate);
} }
void void
VideoRtpSession::setNewBitrate(unsigned int newBR) VideoRtpSession::setNewBitrate(unsigned int newBR)
{ {
......
...@@ -53,7 +53,7 @@ VideoSender::VideoSender(const std::string& dest, const DeviceParams& dev, ...@@ -53,7 +53,7 @@ VideoSender::VideoSender(const std::string& dest, const DeviceParams& dev,
{ {
keyFrameFreq_ = dev.framerate.numerator() * KEY_FRAME_PERIOD; keyFrameFreq_ = dev.framerate.numerator() * KEY_FRAME_PERIOD;
videoEncoder_->openOutput(dest, "rtp"); videoEncoder_->openOutput(dest, "rtp");
auto opts = MediaStream("video sender", AV_PIX_FMT_YUV420P, 1 / (rational<int>)dev.framerate, dev.width, dev.height, 1, (rational<int>)dev.framerate); auto opts = MediaStream("video sender", AV_PIX_FMT_YUV420P, 1 / (rational<int>)dev.framerate, dev.width, dev.height, args.bitrate, (rational<int>)dev.framerate);
videoEncoder_->setOptions(opts); videoEncoder_->setOptions(opts);
videoEncoder_->setOptions(args); videoEncoder_->setOptions(args);
videoEncoder_->addStream(args.codec->systemCodecInfo); videoEncoder_->addStream(args.codec->systemCodecInfo);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment