#ifdef UNSAFE_BUFFERS_BUILD
#pragma allow_unsafe_buffers
#endif
#include "media/video/av1_video_encoder.h"
#include <algorithm>
#include <cmath>
#include "base/containers/heap_array.h"
#include "base/logging.h"
#include "base/numerics/checked_math.h"
#include "base/strings/stringprintf.h"
#include "base/time/time.h"
#include "base/trace_event/trace_event.h"
#include "media/base/svc_scalability_mode.h"
#include "media/base/timestamp_constants.h"
#include "media/base/video_color_space.h"
#include "media/base/video_frame.h"
#include "media/base/video_util.h"
#include "media/video/video_encoder_info.h"
#include "third_party/libaom/source/libaom/aom/aomcx.h"
#include "third_party/libyuv/include/libyuv/convert.h"
namespace media {
namespace {
void FreeCodecCtx(aom_codec_ctx_t* codec_ctx) { … }
std::optional<VideoPixelFormat> GetConversionFormat(VideoCodecProfile profile,
VideoPixelFormat format,
bool needs_resize) { … }
aom_img_fmt GetAomImgFormat(VideoPixelFormat format) { … }
void SetupStandardYuvPlanes(const VideoFrame& frame, aom_image_t* aom_image) { … }
EncoderStatus SetUpAomConfig(VideoCodecProfile profile,
const VideoEncoder::Options& opts,
aom_codec_enc_cfg_t& config,
aom_svc_params_t& svc_params) { … }
std::string LogAomErrorMessage(aom_codec_ctx_t* context,
const char* message,
aom_codec_err_t status) { … }
}
Av1VideoEncoder::Av1VideoEncoder() : … { … }
void Av1VideoEncoder::Initialize(VideoCodecProfile profile,
const Options& options,
EncoderInfoCB info_cb,
OutputCB output_cb,
EncoderStatusCB done_cb) { … }
void Av1VideoEncoder::Encode(scoped_refptr<VideoFrame> frame,
const EncodeOptions& encode_options,
EncoderStatusCB done_cb) { … }
void Av1VideoEncoder::ChangeOptions(const Options& options,
OutputCB output_cb,
EncoderStatusCB done_cb) { … }
base::TimeDelta Av1VideoEncoder::GetFrameDuration(const VideoFrame& frame) { … }
VideoEncoderOutput Av1VideoEncoder::GetEncoderOutput(
int temporal_id,
base::TimeDelta timestamp,
gfx::ColorSpace color_space) const { … }
EncoderStatus::Or<int> Av1VideoEncoder::AssignNextTemporalId(bool key_frame) { … }
Av1VideoEncoder::~Av1VideoEncoder() = default;
void Av1VideoEncoder::Flush(EncoderStatusCB done_cb) { … }
void Av1VideoEncoder::UpdateEncoderColorSpace() { … }
}