#ifdef UNSAFE_BUFFERS_BUILD
#pragma allow_unsafe_buffers
#endif
#include "remoting/codec/webrtc_video_encoder_vpx.h"
#include <algorithm>
#include <utility>
#include "base/functional/bind.h"
#include "base/functional/callback.h"
#include "base/logging.h"
#include "base/memory/ptr_util.h"
#include "base/system/sys_info.h"
#include "build/build_config.h"
#include "build/chromeos_buildflags.h"
#include "remoting/base/cpu_utils.h"
#include "remoting/base/util.h"
#include "remoting/codec/utils.h"
#include "remoting/proto/video.pb.h"
#include "third_party/libvpx/source/libvpx/vpx/vp8cx.h"
#include "third_party/libvpx/source/libvpx/vpx/vpx_encoder.h"
#include "third_party/libyuv/include/libyuv/convert_from_argb.h"
#include "third_party/webrtc/modules/desktop_capture/desktop_frame.h"
#include "third_party/webrtc/modules/desktop_capture/desktop_geometry.h"
#include "third_party/webrtc/modules/desktop_capture/desktop_region.h"
namespace remoting {
namespace {
constexpr int kBytesPerRgbPixel = …;
constexpr int kVp9I420ProfileNumber = …;
constexpr int kVp9I444ProfileNumber = …;
constexpr int kVp9AqModeCyclicRefresh = …;
constexpr int kDefaultTargetBitrateKbps = …;
constexpr int kVp8MinimumTargetBitrateKbpsPerMegapixel = …;
constexpr int kVp9LosslessEncodeSpeed = …;
constexpr int kVp9DefaultEncoderSpeed = …;
constexpr int kVp9MaxEncoderSpeed = …;
void SetCommonCodecParameters(vpx_codec_enc_cfg_t* config,
const webrtc::DesktopSize& size) { … }
void SetVp8CodecParameters(vpx_codec_enc_cfg_t* config,
const webrtc::DesktopSize& size) { … }
void SetVp9CodecParameters(vpx_codec_enc_cfg_t* config,
const webrtc::DesktopSize& size,
bool lossless_color) { … }
void SetVp8CodecOptions(vpx_codec_ctx_t* codec) { … }
void SetVp9CodecOptions(vpx_codec_ctx_t* codec, int encoder_speed) { … }
}
std::unique_ptr<WebrtcVideoEncoder> WebrtcVideoEncoderVpx::CreateForVP8() { … }
std::unique_ptr<WebrtcVideoEncoder> WebrtcVideoEncoderVpx::CreateForVP9() { … }
WebrtcVideoEncoderVpx::~WebrtcVideoEncoderVpx() = default;
void WebrtcVideoEncoderVpx::SetTickClockForTests(
const base::TickClock* tick_clock) { … }
void WebrtcVideoEncoderVpx::SetLosslessColor(bool want_lossless) { … }
void WebrtcVideoEncoderVpx::SetEncoderSpeed(int encoder_speed) { … }
void WebrtcVideoEncoderVpx::Encode(std::unique_ptr<webrtc::DesktopFrame> frame,
const FrameParams& params,
EncodeCallback done) { … }
WebrtcVideoEncoderVpx::WebrtcVideoEncoderVpx(bool use_vp9)
: … { … }
void WebrtcVideoEncoderVpx::Configure(const webrtc::DesktopSize& size) { … }
void WebrtcVideoEncoderVpx::UpdateConfig(const FrameParams& params) { … }
void WebrtcVideoEncoderVpx::PrepareImage(
const webrtc::DesktopFrame* frame,
webrtc::DesktopRegion* updated_region) { … }
}