Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
jami-daemon
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Requirements
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Locked files
Deploy
Releases
Model registry
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
savoirfairelinux
jami-daemon
Commits
cbbf2f71
Commit
cbbf2f71
authored
4 years ago
by
Pierre Lespagnol
Committed by
Adrien Béraud
4 years ago
Browse files
Options
Downloads
Patches
Plain Diff
autoadapt: use crf mode for the congestion control algo
Change-Id: I1c30102c406277c38605b73fec43debd153df1fc
parent
365a1169
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/media/media_encoder.cpp
+9
-12
9 additions, 12 deletions
src/media/media_encoder.cpp
src/media/video/video_rtp_session.cpp
+0
-1
0 additions, 1 deletion
src/media/video/video_rtp_session.cpp
with
9 additions
and
13 deletions
src/media/media_encoder.cpp
+
9
−
12
View file @
cbbf2f71
...
...
@@ -819,16 +819,15 @@ MediaEncoder::initH264(AVCodecContext* encoderCtx, uint64_t br)
if
(
mode_
==
RateMode
::
CRF_CONSTRAINED
)
{
uint64_t
maxBitrate
=
1000
*
br
;
uint8_t
crf
=
(
uint8_t
)
std
::
round
(
LOGREG_PARAM_A
+
log
(
pow
(
maxBitrate
,
LOGREG_PARAM_B
)));
// CRF = A + B*ln(maxBitrate)
uint64_t
bufSize
=
maxBitrate
*
2
;
// bufsize parameter impact the variation of the bitrate, reduce to half the maxrate to limit peak and congestion
//https://trac.ffmpeg.org/wiki/Limiting%20the%20output%20bitrate
uint64_t
bufSize
=
maxBitrate
/
2
;
av_opt_set_int
(
encoderCtx
,
"crf"
,
crf
,
AV_OPT_SEARCH_CHILDREN
);
av_opt_set_int
(
encoderCtx
,
"b"
,
maxBitrate
,
AV_OPT_SEARCH_CHILDREN
);
av_opt_set_int
(
encoderCtx
,
"maxrate"
,
maxBitrate
,
AV_OPT_SEARCH_CHILDREN
);
av_opt_set_int
(
encoderCtx
,
"minrate"
,
-
1
,
AV_OPT_SEARCH_CHILDREN
);
av_opt_set_int
(
encoderCtx
,
"bufsize"
,
bufSize
,
AV_OPT_SEARCH_CHILDREN
);
JAMI_DBG
(
"H264 encoder setup: crf=%u, maxrate=%lu, bufsize=%lu"
,
crf
,
maxBitrate
,
bufSize
);
JAMI_DBG
(
"H264 encoder setup: crf=%u, maxrate=%lu
kbit/s
, bufsize=%lu
kbit
"
,
crf
,
maxBitrate
/
1000
,
bufSize
/
1000
);
}
// If auto quality enabled use CRB mode
else
if
(
mode_
==
RateMode
::
CBR
)
{
av_opt_set_int
(
encoderCtx
,
"b"
,
br
*
1000
,
AV_OPT_SEARCH_CHILDREN
);
av_opt_set_int
(
encoderCtx
,
"maxrate"
,
br
*
1000
,
AV_OPT_SEARCH_CHILDREN
);
...
...
@@ -849,13 +848,11 @@ MediaEncoder::initH265(AVCodecContext* encoderCtx, uint64_t br)
// H265 use 50% less bitrate compared to H264 (half bitrate is equivalent to a change 6 for CRF)
// https://slhck.info/video/2017/02/24/crf-guide.html
uint8_t
crf
=
(
uint8_t
)
std
::
round
(
LOGREG_PARAM_A
+
log
(
pow
(
maxBitrate
,
LOGREG_PARAM_B
))
-
6
);
// CRF = A + B*ln(maxBitrate)
uint64_t
bufSize
=
maxBitrate
*
2
;
uint64_t
bufSize
=
maxBitrate
/
2
;
av_opt_set_int
(
encoderCtx
,
"crf"
,
crf
,
AV_OPT_SEARCH_CHILDREN
);
av_opt_set_int
(
encoderCtx
,
"b"
,
maxBitrate
,
AV_OPT_SEARCH_CHILDREN
);
av_opt_set_int
(
encoderCtx
,
"maxrate"
,
maxBitrate
,
AV_OPT_SEARCH_CHILDREN
);
av_opt_set_int
(
encoderCtx
,
"minrate"
,
-
1
,
AV_OPT_SEARCH_CHILDREN
);
av_opt_set_int
(
encoderCtx
,
"bufsize"
,
bufSize
,
AV_OPT_SEARCH_CHILDREN
);
JAMI_DBG
(
"H265 encoder setup: crf=%u, maxrate=%lu, bufsize=%lu"
,
crf
,
maxBitrate
,
bufSize
);
JAMI_DBG
(
"H265 encoder setup: crf=%u, maxrate=%lu
kbit/s
, bufsize=%lu
kbit
"
,
crf
,
maxBitrate
/
1000
,
bufSize
/
1000
);
}
else
if
(
mode_
==
RateMode
::
CBR
)
{
av_opt_set_int
(
encoderCtx
,
"b"
,
br
*
1000
,
AV_OPT_SEARCH_CHILDREN
);
...
...
@@ -891,7 +888,7 @@ MediaEncoder::initVP8(AVCodecContext* encoderCtx, uint64_t br)
// http://www.webmproject.org/docs/encoder-parameters/
uint64_t
maxBitrate
=
1000
*
br
;
uint8_t
crf
=
(
uint8_t
)
std
::
round
(
LOGREG_PARAM_A
+
log
(
pow
(
maxBitrate
,
LOGREG_PARAM_B
)));
// CRF = A + B*ln(maxBitrate)
uint64_t
bufSize
=
2
*
maxBitrate
;
uint64_t
bufSize
=
maxBitrate
/
2
;
av_opt_set
(
encoderCtx
,
"quality"
,
"realtime"
,
AV_OPT_SEARCH_CHILDREN
);
av_opt_set_int
(
encoderCtx
,
"error-resilient"
,
1
,
AV_OPT_SEARCH_CHILDREN
);
...
...
@@ -917,7 +914,7 @@ void
MediaEncoder
::
initMPEG4
(
AVCodecContext
*
encoderCtx
,
uint64_t
br
)
{
uint64_t
maxBitrate
=
1000
*
br
;
uint64_t
bufSize
=
2
*
maxBitrate
;
uint64_t
bufSize
=
maxBitrate
/
2
;
// Use CBR (set bitrate)
encoderCtx
->
rc_buffer_size
=
bufSize
;
...
...
@@ -929,7 +926,7 @@ void
MediaEncoder
::
initH263
(
AVCodecContext
*
encoderCtx
,
uint64_t
br
)
{
uint64_t
maxBitrate
=
1000
*
br
;
uint64_t
bufSize
=
2
*
maxBitrate
;
uint64_t
bufSize
=
maxBitrate
/
2
;
// Use CBR (set bitrate)
encoderCtx
->
rc_buffer_size
=
bufSize
;
...
...
This diff is collapsed.
Click to expand it.
src/media/video/video_rtp_session.cpp
+
0
−
1
View file @
cbbf2f71
...
...
@@ -136,7 +136,6 @@ void VideoRtpSession::startSender()
auto
codecVideo
=
std
::
static_pointer_cast
<
jami
::
AccountVideoCodecInfo
>
(
send_
.
codec
);
auto
autoQuality
=
codecVideo
->
isAutoQualityEnabled
;
send_
.
mode
=
autoQuality
?
RateMode
::
CBR
:
RateMode
::
CRF_CONSTRAINED
;
send_
.
linkableHW
=
conference_
==
nullptr
;
send_
.
bitrate
=
videoBitrateInfo_
.
videoBitrateCurrent
;
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment