#ifdef UNSAFE_BUFFERS_BUILD
#pragma allow_unsafe_buffers
#endif
#include <stdbool.h>
#include <va/va.h>
#include <va/va_backend.h>
#include <va/va_drmcommon.h>
#include <set>
#include "base/check.h"
#include "base/numerics/checked_math.h"
#include "media/gpu/vaapi/test/fake_libva_driver/fake_driver.h"
#include "third_party/libyuv/include/libyuv.h"
VAStatus FakeTerminate(VADriverContextP ctx) { … }
#define MAX_CAPABILITY_ATTRIBUTES …
const VAImageFormat kSupportedImageFormats[] = …;
struct Capability { … };
const struct Capability kCapabilities[] = …;
const size_t kCapabilitiesSize = …;
VAStatus FakeQueryConfigProfiles(VADriverContextP ctx,
VAProfile* profile_list,
int* num_profiles) { … }
VAStatus FakeQueryConfigEntrypoints(VADriverContextP ctx,
VAProfile profile,
VAEntrypoint* entrypoint_list,
int* num_entrypoints) { … }
VAStatus FakeGetConfigAttributes(VADriverContextP ctx,
VAProfile profile,
VAEntrypoint entrypoint,
VAConfigAttrib* attrib_list,
int num_attribs) { … }
VAStatus FakeCreateConfig(VADriverContextP ctx,
VAProfile profile,
VAEntrypoint entrypoint,
VAConfigAttrib* attrib_list,
int num_attribs,
VAConfigID* config_id) { … }
VAStatus FakeQueryConfigAttributes(VADriverContextP ctx,
VAConfigID config_id,
VAProfile* profile,
VAEntrypoint* entrypoint,
VAConfigAttrib* attrib_list,
int* num_attribs) { … }
VAStatus FakeDestroyConfig(VADriverContextP ctx, VAConfigID config_id) { … }
VAStatus FakeCreateSurfaces(VADriverContextP ctx,
int width,
int height,
int format,
int num_surfaces,
VASurfaceID* surfaces) { … }
VAStatus FakeDestroySurfaces(VADriverContextP ctx,
VASurfaceID* surface_list,
int num_surfaces) { … }
VAStatus FakeCreateContext(VADriverContextP ctx,
VAConfigID config_id,
int picture_width,
int picture_height,
int flag,
VASurfaceID* render_targets,
int num_render_targets,
VAContextID* context) { … }
VAStatus FakeDestroyContext(VADriverContextP ctx, VAContextID context) { … }
VAStatus FakeCreateBuffer(VADriverContextP ctx,
VAContextID context,
VABufferType type,
unsigned int size,
unsigned int num_elements,
void* data,
VABufferID* buf_id) { … }
VAStatus FakeBufferSetNumElements(VADriverContextP ctx,
VABufferID buf_id,
unsigned int num_elements) { … }
VAStatus FakeMapBuffer(VADriverContextP ctx, VABufferID buf_id, void** pbuf) { … }
VAStatus FakeUnmapBuffer(VADriverContextP ctx, VABufferID buf_id) { … }
VAStatus FakeDestroyBuffer(VADriverContextP ctx, VABufferID buffer_id) { … }
VAStatus FakeBeginPicture(VADriverContextP ctx,
VAContextID context,
VASurfaceID render_target) { … }
VAStatus FakeRenderPicture(VADriverContextP ctx,
VAContextID context,
VABufferID* buffers,
int num_buffers) { … }
VAStatus FakeEndPicture(VADriverContextP ctx, VAContextID context) { … }
VAStatus FakeSyncSurface(VADriverContextP ctx, VASurfaceID render_target) { … }
VAStatus FakeQuerySurfaceStatus(VADriverContextP ctx,
VASurfaceID render_target,
VASurfaceStatus* status) { … }
VAStatus FakePutSurface(VADriverContextP ctx,
VASurfaceID surface,
void* draw,
short srcx,
short srcy,
unsigned short srcw,
unsigned short srch,
short destx,
short desty,
unsigned short destw,
unsigned short desth,
VARectangle* cliprects,
unsigned int number_cliprects,
unsigned int flags) { … }
VAStatus FakeQueryImageFormats(VADriverContextP ctx,
VAImageFormat* format_list,
int* num_formats) { … }
VAStatus FakeCreateImage(VADriverContextP ctx,
VAImageFormat* format,
int width,
int height,
VAImage* image) { … }
VAStatus FakeDestroyImage(VADriverContextP ctx, VAImageID image) { … }
VAStatus FakeSetImagePalette(VADriverContextP ctx,
VAImageID image,
unsigned char* palette) { … }
VAStatus FakeGetImage(VADriverContextP ctx,
VASurfaceID surface,
int x,
int y,
unsigned int width,
unsigned int height,
VAImageID image) { … }
VAStatus FakePutImage(VADriverContextP ctx,
VASurfaceID surface,
VAImageID image,
int src_x,
int src_y,
unsigned int src_width,
unsigned int src_height,
int dest_x,
int dest_y,
unsigned int dest_width,
unsigned int dest_height) { … }
VAStatus FakeDeriveImage(VADriverContextP ctx,
VASurfaceID surface,
VAImage* image) { … }
VAStatus FakeQuerySubpictureFormats(VADriverContextP ctx,
VAImageFormat* format_list,
unsigned int* flags,
unsigned int* num_formats) { … }
VAStatus FakeCreateSubpicture(VADriverContextP ctx,
VAImageID image,
VASubpictureID* subpicture) { … }
VAStatus FakeDestroySubpicture(VADriverContextP ctx,
VASubpictureID subpicture) { … }
VAStatus FakeSetSubpictureImage(VADriverContextP ctx,
VASubpictureID subpicture,
VAImageID image) { … }
VAStatus FakeSetSubpictureChromakey(VADriverContextP ctx,
VASubpictureID subpicture,
unsigned int chromakey_min,
unsigned int chromakey_max,
unsigned int chromakey_mask) { … }
VAStatus FakeSetSubpictureGlobalAlpha(VADriverContextP ctx,
VASubpictureID subpicture,
float global_alpha) { … }
VAStatus FakeAssociateSubpicture(VADriverContextP ctx,
VASubpictureID subpicture,
VASurfaceID* target_surfaces,
int num_surfaces,
int16_t src_x,
int16_t src_y,
uint16_t src_width,
uint16_t src_height,
int16_t dest_x,
int16_t dest_y,
uint16_t dest_width,
uint16_t dest_height,
uint32_t flags) { … }
VAStatus FakeDeassociateSubpicture(VADriverContextP ctx,
VASubpictureID subpicture,
VASurfaceID* target_surfaces,
int num_surfaces) { … }
VAStatus FakeQueryDisplayAttributes(VADriverContextP ctx,
VADisplayAttribute* attr_list,
int* num_attributes) { … }
VAStatus FakeGetDisplayAttributes(VADriverContextP ctx,
VADisplayAttribute* attr_list,
int num_attributes) { … }
VAStatus FakeSetDisplayAttributes(VADriverContextP ctx,
VADisplayAttribute* attr_list,
int num_attributes) { … }
VAStatus FakeQuerySurfaceAttributes(VADriverContextP ctx,
VAConfigID config,
VASurfaceAttrib* attribs,
unsigned int* num_attribs) { … }
VAStatus FakeCreateSurfaces2(VADriverContextP ctx,
unsigned int format,
unsigned int width,
unsigned int height,
VASurfaceID* surfaces,
unsigned int num_surfaces,
VASurfaceAttrib* attrib_list,
unsigned int num_attribs) { … }
#define MAX_PROFILES …
#define MAX_ENTRYPOINTS …
#define MAX_CONFIG_ATTRIBUTES …
#if MAX_CAPABILITY_ATTRIBUTES >= MAX_CONFIG_ATTRIBUTES
#error "MAX_CAPABILITY_ATTRIBUTES should be smaller than MAX_CONFIG_ATTRIBUTES"
#endif
#define MAX_IMAGE_FORMATS …
#define MAX_SUBPIC_FORMATS …
#define DLL_EXPORT …
extern "C" VAStatus DLL_EXPORT __vaDriverInit_1_0(VADriverContextP ctx) { … }