Merge pull request #3370 from metalefty/x264-threads
make x264 threads configurable
This commit is contained in:
+10
-2
@@ -68,7 +68,7 @@ for use with xrdp. Here are available options:
|
|||||||
|
|
||||||
.TP
|
.TP
|
||||||
\fBprofile\fR = \fI<string>\fR
|
\fBprofile\fR = \fI<string>\fR
|
||||||
Select a profile. Here are available options:
|
Select a profile. Here are available options:
|
||||||
|
|
||||||
.B main, baseline, high, high10, high422, high444
|
.B main, baseline, high, high10, high422, high444
|
||||||
|
|
||||||
@@ -83,12 +83,20 @@ Set the size of the VBV buffer size in kilobits.
|
|||||||
|
|
||||||
.TP
|
.TP
|
||||||
\fBfps_num\fR = \fI<integer>\fR
|
\fBfps_num\fR = \fI<integer>\fR
|
||||||
Set the fps numerator.
|
Set the fps numerator.
|
||||||
|
|
||||||
.TP
|
.TP
|
||||||
\fBfps_den\fR = \fI<integer>\fR
|
\fBfps_den\fR = \fI<integer>\fR
|
||||||
Set the fps denominator.
|
Set the fps denominator.
|
||||||
|
|
||||||
|
.TP
|
||||||
|
\fBthreads = \fI<integer>\fR
|
||||||
|
Specify how many CPU threads to use for H.264 encoding per screen (0 for
|
||||||
|
auto). Carefully evaluate this value when configuring it to avoid exhausting
|
||||||
|
the available threads. For example, if 3 users are connected simultaneously
|
||||||
|
with dual screens, xrdp may use up to <threads> * 3 * 2 threads for H.264
|
||||||
|
encoding. Please also note that too many threads can hurt quality.
|
||||||
|
|
||||||
.SH "OPENH264"
|
.SH "OPENH264"
|
||||||
|
|
||||||
\fB[OpenH264]\fR section defines encoding parameters that will be passed to
|
\fB[OpenH264]\fR section defines encoding parameters that will be passed to
|
||||||
|
|||||||
@@ -9,6 +9,7 @@ vbv_max_bitrate = 0
|
|||||||
vbv_buffer_size = 0
|
vbv_buffer_size = 0
|
||||||
fps_num = 24
|
fps_num = 24
|
||||||
fps_den = 1
|
fps_den = 1
|
||||||
|
threads = 1
|
||||||
|
|
||||||
[x264.lan]
|
[x264.lan]
|
||||||
[x264.wan]
|
[x264.wan]
|
||||||
|
|||||||
@@ -9,6 +9,7 @@ vbv_max_bitrate = 0
|
|||||||
vbv_buffer_size = 0
|
vbv_buffer_size = 0
|
||||||
fps_num = 24
|
fps_num = 24
|
||||||
fps_den = 1
|
fps_den = 1
|
||||||
|
threads = 1
|
||||||
|
|
||||||
[x264.lan]
|
[x264.lan]
|
||||||
[x264.wan]
|
[x264.wan]
|
||||||
|
|||||||
@@ -9,6 +9,7 @@ vbv_max_bitrate = 0
|
|||||||
vbv_buffer_size = 0
|
vbv_buffer_size = 0
|
||||||
fps_num = 24
|
fps_num = 24
|
||||||
fps_den = 1
|
fps_den = 1
|
||||||
|
threads = 1
|
||||||
|
|
||||||
[x264.lan]
|
[x264.lan]
|
||||||
[x264.wan]
|
[x264.wan]
|
||||||
|
|||||||
@@ -9,6 +9,7 @@ vbv_max_bitrate = 0
|
|||||||
vbv_buffer_size = 0
|
vbv_buffer_size = 0
|
||||||
fps_num = 24
|
fps_num = 24
|
||||||
fps_den = 1
|
fps_den = 1
|
||||||
|
threads = 1
|
||||||
|
|
||||||
[x264.lan]
|
[x264.lan]
|
||||||
[x264.wan]
|
[x264.wan]
|
||||||
|
|||||||
@@ -9,6 +9,7 @@ vbv_max_bitrate = 0
|
|||||||
vbv_buffer_size = 0
|
vbv_buffer_size = 0
|
||||||
fps_num = 24
|
fps_num = 24
|
||||||
fps_den = 1
|
fps_den = 1
|
||||||
|
threads = 1
|
||||||
|
|
||||||
[x264.lan]
|
[x264.lan]
|
||||||
[x264.wan]
|
[x264.wan]
|
||||||
|
|||||||
@@ -9,6 +9,7 @@ vbv_max_bitrate = 0
|
|||||||
vbv_buffer_size = 0
|
vbv_buffer_size = 0
|
||||||
fps_num = 24
|
fps_num = 24
|
||||||
fps_den = 1
|
fps_den = 1
|
||||||
|
threads = 1
|
||||||
|
|
||||||
[x264.lan]
|
[x264.lan]
|
||||||
[x264.wan]
|
[x264.wan]
|
||||||
|
|||||||
@@ -19,6 +19,7 @@ vbv_max_bitrate = 0
|
|||||||
vbv_buffer_size = 0
|
vbv_buffer_size = 0
|
||||||
fps_num = 60
|
fps_num = 60
|
||||||
fps_den = 1
|
fps_den = 1
|
||||||
|
threads = 1
|
||||||
|
|
||||||
[x264.lan]
|
[x264.lan]
|
||||||
# inherits default
|
# inherits default
|
||||||
|
|||||||
@@ -19,6 +19,7 @@ vbv_max_bitrate = 0
|
|||||||
vbv_buffer_size = 0
|
vbv_buffer_size = 0
|
||||||
fps_num = 60
|
fps_num = 60
|
||||||
fps_den = 1
|
fps_den = 1
|
||||||
|
threads = 1
|
||||||
|
|
||||||
[x264.lan]
|
[x264.lan]
|
||||||
# inherits default
|
# inherits default
|
||||||
|
|||||||
@@ -19,6 +19,7 @@ vbv_max_bitrate = 0
|
|||||||
vbv_buffer_size = 0
|
vbv_buffer_size = 0
|
||||||
fps_num = 60
|
fps_num = 60
|
||||||
fps_den = 1
|
fps_den = 1
|
||||||
|
threads = 1
|
||||||
|
|
||||||
[x264.lan]
|
[x264.lan]
|
||||||
# inherits default
|
# inherits default
|
||||||
|
|||||||
@@ -19,6 +19,7 @@ vbv_max_bitrate = 0
|
|||||||
vbv_buffer_size = 0
|
vbv_buffer_size = 0
|
||||||
fps_num = 60
|
fps_num = 60
|
||||||
fps_den = 1
|
fps_den = 1
|
||||||
|
threads = 1
|
||||||
|
|
||||||
[x264.lan]
|
[x264.lan]
|
||||||
# inherits default
|
# inherits default
|
||||||
|
|||||||
@@ -19,6 +19,7 @@ vbv_max_bitrate = 0
|
|||||||
vbv_buffer_size = 0
|
vbv_buffer_size = 0
|
||||||
fps_num = 60
|
fps_num = 60
|
||||||
fps_den = 1
|
fps_den = 1
|
||||||
|
threads = 1 # recommended: 1 or 2, see `man gfx.toml` for details
|
||||||
|
|
||||||
[x264.lan]
|
[x264.lan]
|
||||||
# inherits default
|
# inherits default
|
||||||
|
|||||||
@@ -153,7 +153,7 @@ xrdp_encoder_x264_encode(void *handle, int session, int left, int top,
|
|||||||
x264_param_default_preset(&(xe->x264_params),
|
x264_param_default_preset(&(xe->x264_params),
|
||||||
xg->x264_param[ct].preset,
|
xg->x264_param[ct].preset,
|
||||||
xg->x264_param[ct].tune);
|
xg->x264_param[ct].tune);
|
||||||
xe->x264_params.i_threads = 1;
|
xe->x264_params.i_threads = xg->x264_param[ct].threads;
|
||||||
xe->x264_params.i_width = (width + 15) & ~15;
|
xe->x264_params.i_width = (width + 15) & ~15;
|
||||||
xe->x264_params.i_height = (height + 15) & ~15;
|
xe->x264_params.i_height = (height + 15) & ~15;
|
||||||
xe->x264_params.i_fps_num = xg->x264_param[ct].fps_num;
|
xe->x264_params.i_fps_num = xg->x264_param[ct].fps_num;
|
||||||
|
|||||||
@@ -47,6 +47,7 @@
|
|||||||
#define X264_DEFAULT_PROFILE "main"
|
#define X264_DEFAULT_PROFILE "main"
|
||||||
#define X264_DEFAULT_FPS_NUM 24
|
#define X264_DEFAULT_FPS_NUM 24
|
||||||
#define X264_DEFAULT_FPS_DEN 1
|
#define X264_DEFAULT_FPS_DEN 1
|
||||||
|
#define X264_DEFAULT_THREADS 1 /* not to exhaust CPU threads for 1 user */
|
||||||
|
|
||||||
const char *
|
const char *
|
||||||
tconfig_codec_order_to_str(
|
tconfig_codec_order_to_str(
|
||||||
@@ -334,6 +335,33 @@ tconfig_load_gfx_x264_ct(toml_table_t *tfile, const int connection_type,
|
|||||||
param[connection_type].fps_den = X264_DEFAULT_FPS_DEN;
|
param[connection_type].fps_den = X264_DEFAULT_FPS_DEN;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* threads */
|
||||||
|
datum = toml_int_in(x264_ct, "threads");
|
||||||
|
if (datum.ok)
|
||||||
|
{
|
||||||
|
if (datum.u.i >= 0)
|
||||||
|
{
|
||||||
|
param[connection_type].threads = datum.u.i;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
TCLOG(LOG_LEVEL_WARNING,
|
||||||
|
"[x264.%s] an invalid value (< 0) is specified for threads, "
|
||||||
|
"adopting the default value [%d]",
|
||||||
|
rdpbcgr_connection_type_names[connection_type],
|
||||||
|
X264_DEFAULT_THREADS);
|
||||||
|
param[connection_type].threads = X264_DEFAULT_THREADS;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (connection_type == 0)
|
||||||
|
{
|
||||||
|
TCLOG(LOG_LEVEL_WARNING,
|
||||||
|
"[x264.%s] threads is not set, adopting the default value [%d]",
|
||||||
|
rdpbcgr_connection_type_names[connection_type],
|
||||||
|
X264_DEFAULT_THREADS);
|
||||||
|
param[connection_type].threads = X264_DEFAULT_THREADS;
|
||||||
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -42,6 +42,7 @@ struct xrdp_tconfig_gfx_x264_param
|
|||||||
int vbv_buffer_size;
|
int vbv_buffer_size;
|
||||||
int fps_num;
|
int fps_num;
|
||||||
int fps_den;
|
int fps_den;
|
||||||
|
int threads;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct xrdp_tconfig_gfx_openh264_param
|
struct xrdp_tconfig_gfx_openh264_param
|
||||||
|
|||||||
Reference in New Issue
Block a user