#ifdef UNSAFE_BUFFERS_BUILD
#pragma allow_unsafe_buffers
#endif
#include "media/gpu/vaapi/av1_vaapi_video_encoder_delegate.h"
#include <bit>
#include <utility>
#include "base/bits.h"
#include "base/logging.h"
#include "media/gpu/macros.h"
#include "media/gpu/vaapi/vaapi_common.h"
#include "media/gpu/vaapi/vaapi_wrapper.h"
#include "third_party/libaom/source/libaom/av1/ratectrl_rtc.h"
#include "third_party/libgav1/src/src/utils/constants.h"
namespace media {
namespace {
constexpr int kKFPeriod = …;
constexpr uint8_t kMinQP = …;
constexpr uint8_t kMaxQP = …;
constexpr gfx::Size kAV1AlignmentSize(64, 64);
constexpr int kCDEFStrengthDivisor = …;
constexpr int kPrimaryReferenceNone = …;
#define ARRAY_SIZE(x) …
uint8_t QindexToQuantizer(uint8_t q_index) { … }
enum AV1ReferenceMode { … };
struct { … } kAV1LevelSpecs[] = …;
int ComputeLevel(const gfx::Size& coded_size, uint32_t framerate) { … }
scoped_refptr<AV1Picture> GetAV1Picture(
const VaapiVideoEncoderDelegate::EncodeJob& job) { … }
void DownscaleSegmentMap(const uint8_t* src_seg_map,
uint32_t src_seg_size,
size_t num_segments,
uint8_t* dst_seg_map,
uint32_t dst_seg_size,
const gfx::Size& coded_size) { … }
AV1BitstreamBuilder::SequenceHeader FillAV1BuilderSequenceHeader(
const gfx::Size& visible_size,
int level_idx) { … }
AV1BitstreamBuilder::FrameHeader FillAV1BuilderFrameHeader(
const VAEncPictureParameterBufferAV1& pic_param,
const AV1VaapiVideoEncoderDelegate::EncodeParams& current_params) { … }
}
AV1VaapiVideoEncoderDelegate::EncodeParams::EncodeParams()
: … { … }
AV1VaapiVideoEncoderDelegate::AV1VaapiVideoEncoderDelegate(
scoped_refptr<VaapiWrapper> vaapi_wrapper,
base::RepeatingClosure error_cb)
: … { … }
bool AV1VaapiVideoEncoderDelegate::Initialize(
const VideoEncodeAccelerator::Config& config,
const VaapiVideoEncoderDelegate::Config& ave_config) { … }
AV1VaapiVideoEncoderDelegate::~AV1VaapiVideoEncoderDelegate() = default;
bool AV1VaapiVideoEncoderDelegate::UpdateRates(
const VideoBitrateAllocation& bitrate_allocation,
uint32_t framerate) { … }
gfx::Size AV1VaapiVideoEncoderDelegate::GetCodedSize() const { … }
size_t AV1VaapiVideoEncoderDelegate::GetMaxNumOfRefFrames() const { … }
std::vector<gfx::Size> AV1VaapiVideoEncoderDelegate::GetSVCLayerResolutions() { … }
BitstreamBufferMetadata AV1VaapiVideoEncoderDelegate::GetMetadata(
const EncodeJob& encode_job,
size_t payload_size) { … }
VaapiVideoEncoderDelegate::PrepareEncodeJobResult
AV1VaapiVideoEncoderDelegate::PrepareEncodeJob(EncodeJob& encode_job) { … }
void AV1VaapiVideoEncoderDelegate::BitrateControlUpdate(
const BitstreamBufferMetadata& metadata) { … }
bool AV1VaapiVideoEncoderDelegate::SubmitTemporalDelimiter(
size_t& temporal_delimiter_obu_size) { … }
bool AV1VaapiVideoEncoderDelegate::SubmitSequenceHeader(
size_t& sequence_header_obu_size) { … }
bool AV1VaapiVideoEncoderDelegate::SubmitSequenceParam() { … }
bool AV1VaapiVideoEncoderDelegate::SubmitSequenceHeaderOBU(
size_t& sequence_header_obu_size) { … }
bool AV1VaapiVideoEncoderDelegate::SubmitFrame(const EncodeJob& job,
size_t frame_header_obu_offset) { … }
bool AV1VaapiVideoEncoderDelegate::FillPictureParam(
VAEncPictureParameterBufferAV1& pic_param,
VAEncSegMapBufferAV1& segment_map_param,
const EncodeJob& job,
const AV1Picture& pic) { … }
bool AV1VaapiVideoEncoderDelegate::SubmitFrameOBU(
const VAEncPictureParameterBufferAV1& pic_param,
size_t& frame_header_obu_size_offset) { … }
bool AV1VaapiVideoEncoderDelegate::SubmitPictureParam(
const VAEncPictureParameterBufferAV1& pic_param) { … }
bool AV1VaapiVideoEncoderDelegate::SubmitSegmentMap(
const VAEncSegMapBufferAV1& segment_map_param) { … }
bool AV1VaapiVideoEncoderDelegate::SubmitTileGroup() { … }
bool AV1VaapiVideoEncoderDelegate::SubmitPackedData(
const std::vector<uint8_t>& data) { … }
}