#ifdef UNSAFE_BUFFERS_BUILD
#pragma allow_unsafe_buffers
#endif
#include "media/gpu/vaapi/vaapi_jpeg_decoder.h"
#include <string.h>
#include <va/va.h>
#include <iostream>
#include <type_traits>
#include "base/logging.h"
#include "base/numerics/safe_conversions.h"
#include "gpu/config/gpu_finch_features.h"
#include "media/base/video_types.h"
#include "media/gpu/macros.h"
#include "media/gpu/vaapi/vaapi_utils.h"
#include "media/gpu/vaapi/vaapi_wrapper.h"
#include "media/parsers/jpeg_parser.h"
#include "ui/gfx/geometry/size.h"
namespace media {
namespace {
static void FillPictureParameters(
const JpegFrameHeader& frame_header,
VAPictureParameterBufferJPEGBaseline* pic_param) { … }
static void FillIQMatrix(const JpegQuantizationTable* q_table,
VAIQMatrixBufferJPEGBaseline* iq_matrix) { … }
static void FillHuffmanTable(const JpegHuffmanTable* dc_table,
const JpegHuffmanTable* ac_table,
VAHuffmanTableBufferJPEGBaseline* huffman_table) { … }
static void FillSliceParameters(
const JpegParseResult& parse_result,
VASliceParameterBufferJPEGBaseline* slice_param) { … }
static bool IsVaapiSupportedJpeg(const JpegParseResult& jpeg) { … }
}
unsigned int VaSurfaceFormatForJpeg(const JpegFrameHeader& frame_header) { … }
VaapiJpegDecoder::VaapiJpegDecoder()
: … { … }
VaapiJpegDecoder::~VaapiJpegDecoder() = default;
VaapiImageDecodeStatus VaapiJpegDecoder::AllocateVASurfaceAndSubmitVABuffers(
base::span<const uint8_t> encoded_image) { … }
gpu::ImageDecodeAcceleratorType VaapiJpegDecoder::GetType() const { … }
SkYUVColorSpace VaapiJpegDecoder::GetYUVColorSpace() const { … }
std::optional<gpu::ImageDecodeAcceleratorSupportedProfile>
VaapiJpegDecoder::GetSupportedProfile() { … }
std::unique_ptr<ScopedVAImage> VaapiJpegDecoder::GetImage(
uint32_t preferred_image_fourcc,
VaapiImageDecodeStatus* status) { … }
bool VaapiJpegDecoder::MaybeCreateSurface(unsigned int picture_va_rt_format,
const gfx::Size& new_coded_size,
const gfx::Size& new_visible_size) { … }
bool VaapiJpegDecoder::SubmitBuffers(const JpegParseResult& parse_result) { … }
}