#ifdef UNSAFE_BUFFERS_BUILD
#pragma allow_unsafe_buffers
#endif
#include "remoting/codec/video_encoder_vpx.h"
#include <utility>
#include "base/functional/bind.h"
#include "base/logging.h"
#include "base/memory/ptr_util.h"
#include "base/system/sys_info.h"
#include "remoting/base/util.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 {
const int kBytesPerRgbPixel = …;
const int kMacroBlockSize = …;
const int kVp9I420ProfileNumber = …;
const int kVp9I444ProfileNumber = …;
const int kVp9AqModeCyclicRefresh = …;
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) { … }
void FreeImageIfMismatched(bool use_i444,
const webrtc::DesktopSize& size,
std::unique_ptr<vpx_image_t>* out_image,
base::HeapArray<uint8_t>* out_image_buffer) { … }
void CreateImage(bool use_i444,
const webrtc::DesktopSize& size,
std::unique_ptr<vpx_image_t>* out_image,
base::HeapArray<uint8_t>* out_image_buffer) { … }
}
std::unique_ptr<VideoEncoderVpx> VideoEncoderVpx::CreateForVP8() { … }
std::unique_ptr<VideoEncoderVpx> VideoEncoderVpx::CreateForVP9() { … }
VideoEncoderVpx::~VideoEncoderVpx() = default;
void VideoEncoderVpx::SetTickClockForTests(const base::TickClock* tick_clock) { … }
void VideoEncoderVpx::SetLosslessColor(bool want_lossless) { … }
std::unique_ptr<VideoPacket> VideoEncoderVpx::Encode(
const webrtc::DesktopFrame& frame) { … }
VideoEncoderVpx::VideoEncoderVpx(bool use_vp9)
: … { … }
void VideoEncoderVpx::Configure(const webrtc::DesktopSize& size) { … }
void VideoEncoderVpx::PrepareImage(const webrtc::DesktopFrame& frame,
webrtc::DesktopRegion* updated_region) { … }
void VideoEncoderVpx::SetActiveMapFromRegion(
const webrtc::DesktopRegion& updated_region) { … }
void VideoEncoderVpx::UpdateRegionFromActiveMap(
webrtc::DesktopRegion* updated_region) { … }
}