#ifdef UNSAFE_BUFFERS_BUILD
#pragma allow_unsafe_buffers
#endif
#include "media/gpu/vaapi/av1_vaapi_video_decoder_delegate.h"
#include <string.h>
#include <va/va.h>
#include <algorithm>
#include <vector>
#include "base/functional/callback_helpers.h"
#include "base/logging.h"
#include "base/memory/scoped_refptr.h"
#include "build/chromeos_buildflags.h"
#include "media/gpu/av1_picture.h"
#include "media/gpu/vaapi/vaapi_common.h"
#include "media/gpu/vaapi/vaapi_decode_surface_handler.h"
#include "media/gpu/vaapi/vaapi_wrapper.h"
#include "third_party/libgav1/src/src/obu_parser.h"
#include "third_party/libgav1/src/src/utils/types.h"
#include "third_party/libgav1/src/src/warp_prediction.h"
namespace media {
DecodeStatus;
namespace {
#define ARRAY_SIZE(ar) …
#define STD_ARRAY_SIZE(ar) …
void FillSegmentInfo(VASegmentationStructAV1& va_seg_info,
const libgav1::Segmentation& segmentation) { … }
void FillFilmGrainInfo(VAFilmGrainStructAV1& va_film_grain_info,
const libgav1::FilmGrainParams& film_grain_params) { … }
void FillGlobalMotionInfo(
VAWarpedMotionParamsAV1 va_warped_motion[7],
const std::array<libgav1::GlobalMotion, libgav1::kNumReferenceFrameTypes>&
global_motion) { … }
bool FillTileInfo(VADecPictureParameterBufferAV1& va_pic_param,
const libgav1::TileInfo& tile_info) { … }
void FillLoopFilterInfo(VADecPictureParameterBufferAV1& va_pic_param,
const libgav1::LoopFilter& loop_filter) { … }
void FillQuantizationInfo(VADecPictureParameterBufferAV1& va_pic_param,
const libgav1::QuantizerParameters& quant_param) { … }
void FillCdefInfo(VADecPictureParameterBufferAV1& va_pic_param,
const libgav1::Cdef& cdef,
uint8_t color_bitdepth) { … }
void FillModeControlInfo(VADecPictureParameterBufferAV1& va_pic_param,
const libgav1::ObuFrameHeader& frame_header) { … }
void FillLoopRestorationInfo(VADecPictureParameterBufferAV1& va_pic_param,
const libgav1::LoopRestoration& loop_restoration) { … }
bool FillAV1PictureParameter(const AV1Picture& pic,
const libgav1::ObuSequenceHeader& sequence_header,
const AV1ReferenceFrameVector& ref_frames,
VADecPictureParameterBufferAV1& va_pic_param) { … }
bool FillAV1SliceParameters(
const libgav1::Vector<libgav1::TileBuffer>& tile_buffers,
const size_t tile_columns,
base::span<const uint8_t> data,
std::vector<VASliceParameterBufferAV1>& va_slice_params) { … }
}
AV1VaapiVideoDecoderDelegate::AV1VaapiVideoDecoderDelegate(
VaapiDecodeSurfaceHandler* const vaapi_dec,
scoped_refptr<VaapiWrapper> vaapi_wrapper,
ProtectedSessionUpdateCB on_protected_session_update_cb,
CdmContext* cdm_context,
EncryptionScheme encryption_scheme)
: … { … }
AV1VaapiVideoDecoderDelegate::~AV1VaapiVideoDecoderDelegate() { … }
scoped_refptr<AV1Picture> AV1VaapiVideoDecoderDelegate::CreateAV1Picture(
bool apply_grain) { … }
bool AV1VaapiVideoDecoderDelegate::OutputPicture(const AV1Picture& pic) { … }
DecodeStatus AV1VaapiVideoDecoderDelegate::SubmitDecode(
const AV1Picture& pic,
const libgav1::ObuSequenceHeader& seq_header,
const AV1ReferenceFrameVector& ref_frames,
const libgav1::Vector<libgav1::TileBuffer>& tile_buffers,
base::span<const uint8_t> data) { … }
void AV1VaapiVideoDecoderDelegate::OnVAContextDestructionSoon() { … }
}