chromium/media/gpu/vaapi/test/fake_libva_driver/fake_drv_video.cc

// Copyright 2020 The Chromium OS Authors.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#ifdef UNSAFE_BUFFERS_BUILD
// TODO(crbug.com/40285824): Remove this and convert code to safer constructs.
#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) {}

// Needed to be able to instantiate kCapabilities statically.
#define MAX_CAPABILITY_ATTRIBUTES

const VAImageFormat kSupportedImageFormats[] =;

struct Capability {};
const struct Capability kCapabilities[] =;

const size_t kCapabilitiesSize =;

/**
 * Original comment:
 * Query supported profiles
 * The caller must provide a "profile_list" array that can hold at
 * least vaMaxNumProfiles() entries. The actual number of profiles
 * returned in "profile_list" is returned in "num_profile".
 */
VAStatus FakeQueryConfigProfiles(VADriverContextP ctx,
                                 VAProfile* profile_list,
                                 int* num_profiles) {}

/**
 * Original comment:
 * Query supported entrypoints for a given profile
 * The caller must provide an "entrypoint_list" array that can hold at
 * least vaMaxNumEntrypoints() entries. The actual number of entrypoints
 * returned in "entrypoint_list" is returned in "num_entrypoints".
 */
VAStatus FakeQueryConfigEntrypoints(VADriverContextP ctx,
                                    VAProfile profile,
                                    VAEntrypoint* entrypoint_list,
                                    int* num_entrypoints) {}

/**
 * Original comment:
 * Get attributes for a given profile/entrypoint pair
 * The caller must provide an "attrib_list" with all attributes to be
 * retrieved.  Upon return, the attributes in "attrib_list" have been
 * updated with their value.  Unknown attributes or attributes that are
 * not supported for the given profile/entrypoint pair will have their
 * value set to VA_ATTRIB_NOT_SUPPORTED
 */
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) {}

/**
 * Original comment:
 * Query all attributes for a given configuration
 * The profile of the configuration is returned in "profile"
 * The entrypoint of the configuration is returned in "entrypoint"
 * The caller must provide an "attrib_list" array that can hold at least
 * vaMaxNumConfigAttributes() entries. The actual number of attributes
 * returned in "attrib_list" is returned in "num_attribs"
 */
// Misleading function name: it queries |profile|, |entrypoint| and  attributes
// (|attrib_list|) for the given |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) {}