webrtc_video_encoder.cc 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. // Copyright 2021 The Chromium Authors. All rights reserved.
  2. // Use of this source code is governed by a BSD-style license that can be
  3. // found in the LICENSE file.
  4. #include "remoting/codec/webrtc_video_encoder.h"
  5. #include "base/system/sys_info.h"
  6. namespace remoting {
  7. WebrtcVideoEncoder::EncodedFrame::EncodedFrame() = default;
  8. WebrtcVideoEncoder::EncodedFrame::~EncodedFrame() = default;
  9. WebrtcVideoEncoder::EncodedFrame::EncodedFrame(
  10. WebrtcVideoEncoder::EncodedFrame&&) = default;
  11. WebrtcVideoEncoder::EncodedFrame& WebrtcVideoEncoder::EncodedFrame::operator=(
  12. WebrtcVideoEncoder::EncodedFrame&&) = default;
  13. // static
  14. int WebrtcVideoEncoder::GetEncoderThreadCount(int frame_width) {
  15. int thread_num;
  16. if (frame_width >= 3840) {
  17. thread_num = 16;
  18. } else if (frame_width >= 2560) {
  19. thread_num = 8;
  20. } else if (frame_width >= 1280) {
  21. thread_num = 4;
  22. } else if (frame_width >= 720) {
  23. thread_num = 2;
  24. } else {
  25. thread_num = 1;
  26. }
  27. // Allow multiple cores on a system to be used for encoding to increase
  28. // performance while at the same time ensuring we don't bog down the system by
  29. // taking all of the available cores.
  30. return std::min(thread_num, ((base::SysInfo::NumberOfProcessors() + 1) / 2));
  31. }
  32. } // namespace remoting