Skip to content
Snippets Groups Projects
Commit d08826f0 authored by Adrien Béraud's avatar Adrien Béraud
Browse files

encoder: use max 16 threads for video, 4 for audio

Audio encoding is usually mono-threaded and doesn't require
as much CPU as video encoding. Limit to 4 threads since more
would not be useful and might introduce latency and decrease performance.

Video encoding takes significantly more resources, however for live encoding,
using more than 16 threads might introduce unreasonable latency.
Since new customer CPUs (AMD Ryzen and Intel Core i7/i9) now have
more than 16 logical cores, setting a higher bound of 16 threads.

Change-Id: I5dc2d3f51019c563b8cec3fbddffa13cbafdb9a5
parent 15f8fb84
Branches
No related tags found
No related merge requests found
...@@ -521,7 +521,7 @@ void MediaEncoder::prepareEncoderContext(bool is_video) ...@@ -521,7 +521,7 @@ void MediaEncoder::prepareEncoderContext(bool is_video)
encoderName = "encoder?"; encoderName = "encoder?";
encoderCtx_->thread_count = std::thread::hardware_concurrency(); encoderCtx_->thread_count = std::min(std::thread::hardware_concurrency(), is_video ? 16u : 4u);
RING_DBG("[%s] Using %d threads", encoderName, encoderCtx_->thread_count); RING_DBG("[%s] Using %d threads", encoderName, encoderCtx_->thread_count);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment