17ec681f3Smrg/**************************************************************************
27ec681f3Smrg *
37ec681f3Smrg * Copyright 2010 Thomas Balling Sørensen & Orasanu Lucian.
47ec681f3Smrg * Copyright 2014 Advanced Micro Devices, Inc.
57ec681f3Smrg * All Rights Reserved.
67ec681f3Smrg *
77ec681f3Smrg * Permission is hereby granted, free of charge, to any person obtaining a
87ec681f3Smrg * copy of this software and associated documentation files (the
97ec681f3Smrg * "Software"), to deal in the Software without restriction, including
107ec681f3Smrg * without limitation the rights to use, copy, modify, merge, publish,
117ec681f3Smrg * distribute, sub license, and/or sell copies of the Software, and to
127ec681f3Smrg * permit persons to whom the Software is furnished to do so, subject to
137ec681f3Smrg * the following conditions:
147ec681f3Smrg *
157ec681f3Smrg * The above copyright notice and this permission notice (including the
167ec681f3Smrg * next paragraph) shall be included in all copies or substantial portions
177ec681f3Smrg * of the Software.
187ec681f3Smrg *
197ec681f3Smrg * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
207ec681f3Smrg * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
217ec681f3Smrg * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
227ec681f3Smrg * IN NO EVENT SHALL THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR
237ec681f3Smrg * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
247ec681f3Smrg * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
257ec681f3Smrg * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
267ec681f3Smrg *
277ec681f3Smrg **************************************************************************/
287ec681f3Smrg
297ec681f3Smrg#ifndef VA_PRIVATE_H
307ec681f3Smrg#define VA_PRIVATE_H
317ec681f3Smrg
327ec681f3Smrg#include <assert.h>
337ec681f3Smrg
347ec681f3Smrg#include <va/va.h>
357ec681f3Smrg#include <va/va_backend.h>
367ec681f3Smrg#include <va/va_backend_vpp.h>
377ec681f3Smrg#include <va/va_drmcommon.h>
387ec681f3Smrg
397ec681f3Smrg#include "pipe/p_video_enums.h"
407ec681f3Smrg#include "pipe/p_video_codec.h"
417ec681f3Smrg#include "pipe/p_video_state.h"
427ec681f3Smrg
437ec681f3Smrg#include "vl/vl_compositor.h"
447ec681f3Smrg#include "vl/vl_csc.h"
457ec681f3Smrg
467ec681f3Smrg#include "util/u_dynarray.h"
477ec681f3Smrg#include "os/os_thread.h"
487ec681f3Smrg
497ec681f3Smrg#ifndef VA_RT_FORMAT_YUV420_10
507ec681f3Smrg#define VA_RT_FORMAT_YUV420_10  VA_RT_FORMAT_YUV420_10BPP
517ec681f3Smrg#endif
527ec681f3Smrg
537ec681f3Smrg#define VL_VA_DRIVER(ctx) ((vlVaDriver *)ctx->pDriverData)
547ec681f3Smrg#define VL_VA_PSCREEN(ctx) (VL_VA_DRIVER(ctx)->vscreen->pscreen)
557ec681f3Smrg
567ec681f3Smrg#define VL_VA_MAX_IMAGE_FORMATS 12
577ec681f3Smrg#define VL_VA_ENC_GOP_COEFF 16
587ec681f3Smrg
597ec681f3Smrg#define UINT_TO_PTR(x) ((void*)(uintptr_t)(x))
607ec681f3Smrg#define PTR_TO_UINT(x) ((unsigned)((intptr_t)(x)))
617ec681f3Smrg
627ec681f3Smrg#define SOI 2
637ec681f3Smrg#define DQT (4 + 4 * 65)
647ec681f3Smrg#define DHT (4 + 2 * 29 + 2 * 179)
657ec681f3Smrg#define DRI 6
667ec681f3Smrg#define SOF (10 + 255 * 3)
677ec681f3Smrg#define SOS (8 + 4 * 2)
687ec681f3Smrg#define MAX_MJPEG_SLICE_HEADER_SIZE (SOI + DQT + DHT + DRI + SOF + SOS)
697ec681f3Smrg
707ec681f3Smrgstatic inline enum pipe_video_chroma_format
717ec681f3SmrgChromaToPipe(int format)
727ec681f3Smrg{
737ec681f3Smrg   switch (format) {
747ec681f3Smrg   case VA_RT_FORMAT_YUV420:
757ec681f3Smrg   case VA_RT_FORMAT_YUV420_10BPP:
767ec681f3Smrg      return PIPE_VIDEO_CHROMA_FORMAT_420;
777ec681f3Smrg   case VA_RT_FORMAT_YUV422:
787ec681f3Smrg      return PIPE_VIDEO_CHROMA_FORMAT_422;
797ec681f3Smrg   case VA_RT_FORMAT_YUV444:
807ec681f3Smrg      return PIPE_VIDEO_CHROMA_FORMAT_444;
817ec681f3Smrg   default:
827ec681f3Smrg      return PIPE_VIDEO_CHROMA_FORMAT_NONE;
837ec681f3Smrg   }
847ec681f3Smrg}
857ec681f3Smrg
867ec681f3Smrgstatic inline enum pipe_format
877ec681f3SmrgVaFourccToPipeFormat(unsigned format)
887ec681f3Smrg{
897ec681f3Smrg   switch(format) {
907ec681f3Smrg   case VA_FOURCC('N','V','1','2'):
917ec681f3Smrg      return PIPE_FORMAT_NV12;
927ec681f3Smrg   case VA_FOURCC('P','0','1','0'):
937ec681f3Smrg      return PIPE_FORMAT_P010;
947ec681f3Smrg   case VA_FOURCC('P','0','1','6'):
957ec681f3Smrg      return PIPE_FORMAT_P016;
967ec681f3Smrg   case VA_FOURCC('I','4','2','0'):
977ec681f3Smrg      return PIPE_FORMAT_IYUV;
987ec681f3Smrg   case VA_FOURCC('Y','V','1','2'):
997ec681f3Smrg      return PIPE_FORMAT_YV12;
1007ec681f3Smrg   case VA_FOURCC('Y','U','Y','V'):
1017ec681f3Smrg   case VA_FOURCC('Y','U','Y','2'):
1027ec681f3Smrg      return PIPE_FORMAT_YUYV;
1037ec681f3Smrg   case VA_FOURCC('U','Y','V','Y'):
1047ec681f3Smrg      return PIPE_FORMAT_UYVY;
1057ec681f3Smrg   case VA_FOURCC('B','G','R','A'):
1067ec681f3Smrg      return PIPE_FORMAT_B8G8R8A8_UNORM;
1077ec681f3Smrg   case VA_FOURCC('R','G','B','A'):
1087ec681f3Smrg      return PIPE_FORMAT_R8G8B8A8_UNORM;
1097ec681f3Smrg   case VA_FOURCC('B','G','R','X'):
1107ec681f3Smrg      return PIPE_FORMAT_B8G8R8X8_UNORM;
1117ec681f3Smrg   case VA_FOURCC('R','G','B','X'):
1127ec681f3Smrg      return PIPE_FORMAT_R8G8B8X8_UNORM;
1137ec681f3Smrg   default:
1147ec681f3Smrg      assert(0);
1157ec681f3Smrg      return PIPE_FORMAT_NONE;
1167ec681f3Smrg   }
1177ec681f3Smrg}
1187ec681f3Smrg
1197ec681f3Smrgstatic inline unsigned
1207ec681f3SmrgPipeFormatToVaFourcc(enum pipe_format p_format)
1217ec681f3Smrg{
1227ec681f3Smrg   switch (p_format) {
1237ec681f3Smrg   case PIPE_FORMAT_NV12:
1247ec681f3Smrg      return VA_FOURCC('N','V','1','2');
1257ec681f3Smrg   case PIPE_FORMAT_P010:
1267ec681f3Smrg      return VA_FOURCC('P','0','1','0');
1277ec681f3Smrg   case PIPE_FORMAT_P016:
1287ec681f3Smrg      return VA_FOURCC('P','0','1','6');
1297ec681f3Smrg   case PIPE_FORMAT_IYUV:
1307ec681f3Smrg      return VA_FOURCC('I','4','2','0');
1317ec681f3Smrg   case PIPE_FORMAT_YV12:
1327ec681f3Smrg      return VA_FOURCC('Y','V','1','2');
1337ec681f3Smrg   case PIPE_FORMAT_UYVY:
1347ec681f3Smrg      return VA_FOURCC('U','Y','V','Y');
1357ec681f3Smrg   case PIPE_FORMAT_YUYV:
1367ec681f3Smrg      return VA_FOURCC('Y','U','Y','V');
1377ec681f3Smrg   case PIPE_FORMAT_B8G8R8A8_UNORM:
1387ec681f3Smrg      return VA_FOURCC('B','G','R','A');
1397ec681f3Smrg   case PIPE_FORMAT_R8G8B8A8_UNORM:
1407ec681f3Smrg      return VA_FOURCC('R','G','B','A');
1417ec681f3Smrg   case PIPE_FORMAT_B8G8R8X8_UNORM:
1427ec681f3Smrg      return VA_FOURCC('B','G','R','X');
1437ec681f3Smrg   case PIPE_FORMAT_R8G8B8X8_UNORM:
1447ec681f3Smrg      return VA_FOURCC('R','G','B','X');
1457ec681f3Smrg   default:
1467ec681f3Smrg      assert(0);
1477ec681f3Smrg      return -1;
1487ec681f3Smrg   }
1497ec681f3Smrg}
1507ec681f3Smrg
1517ec681f3Smrgstatic inline VAProfile
1527ec681f3SmrgPipeToProfile(enum pipe_video_profile profile)
1537ec681f3Smrg{
1547ec681f3Smrg   switch (profile) {
1557ec681f3Smrg   case PIPE_VIDEO_PROFILE_MPEG2_SIMPLE:
1567ec681f3Smrg      return VAProfileMPEG2Simple;
1577ec681f3Smrg   case PIPE_VIDEO_PROFILE_MPEG2_MAIN:
1587ec681f3Smrg      return VAProfileMPEG2Main;
1597ec681f3Smrg   case PIPE_VIDEO_PROFILE_MPEG4_SIMPLE:
1607ec681f3Smrg      return VAProfileMPEG4Simple;
1617ec681f3Smrg   case PIPE_VIDEO_PROFILE_MPEG4_ADVANCED_SIMPLE:
1627ec681f3Smrg      return VAProfileMPEG4AdvancedSimple;
1637ec681f3Smrg   case PIPE_VIDEO_PROFILE_VC1_SIMPLE:
1647ec681f3Smrg      return VAProfileVC1Simple;
1657ec681f3Smrg   case PIPE_VIDEO_PROFILE_VC1_MAIN:
1667ec681f3Smrg      return VAProfileVC1Main;
1677ec681f3Smrg   case PIPE_VIDEO_PROFILE_VC1_ADVANCED:
1687ec681f3Smrg      return VAProfileVC1Advanced;
1697ec681f3Smrg   case PIPE_VIDEO_PROFILE_MPEG4_AVC_BASELINE:
1707ec681f3Smrg      return VAProfileH264ConstrainedBaseline;
1717ec681f3Smrg   case PIPE_VIDEO_PROFILE_MPEG4_AVC_MAIN:
1727ec681f3Smrg      return VAProfileH264Main;
1737ec681f3Smrg   case PIPE_VIDEO_PROFILE_MPEG4_AVC_HIGH:
1747ec681f3Smrg      return VAProfileH264High;
1757ec681f3Smrg   case PIPE_VIDEO_PROFILE_HEVC_MAIN:
1767ec681f3Smrg      return VAProfileHEVCMain;
1777ec681f3Smrg   case PIPE_VIDEO_PROFILE_HEVC_MAIN_10:
1787ec681f3Smrg      return VAProfileHEVCMain10;
1797ec681f3Smrg   case PIPE_VIDEO_PROFILE_JPEG_BASELINE:
1807ec681f3Smrg      return VAProfileJPEGBaseline;
1817ec681f3Smrg   case PIPE_VIDEO_PROFILE_VP9_PROFILE0:
1827ec681f3Smrg      return VAProfileVP9Profile0;
1837ec681f3Smrg   case PIPE_VIDEO_PROFILE_VP9_PROFILE2:
1847ec681f3Smrg      return VAProfileVP9Profile2;
1857ec681f3Smrg   case PIPE_VIDEO_PROFILE_AV1_MAIN:
1867ec681f3Smrg      return VAProfileAV1Profile0;
1877ec681f3Smrg   case PIPE_VIDEO_PROFILE_MPEG4_AVC_EXTENDED:
1887ec681f3Smrg   case PIPE_VIDEO_PROFILE_MPEG4_AVC_HIGH10:
1897ec681f3Smrg   case PIPE_VIDEO_PROFILE_MPEG4_AVC_HIGH422:
1907ec681f3Smrg   case PIPE_VIDEO_PROFILE_MPEG4_AVC_HIGH444:
1917ec681f3Smrg   case PIPE_VIDEO_PROFILE_MPEG4_AVC_CONSTRAINED_BASELINE:
1927ec681f3Smrg   case PIPE_VIDEO_PROFILE_HEVC_MAIN_12:
1937ec681f3Smrg   case PIPE_VIDEO_PROFILE_HEVC_MAIN_STILL:
1947ec681f3Smrg   case PIPE_VIDEO_PROFILE_HEVC_MAIN_444:
1957ec681f3Smrg   case PIPE_VIDEO_PROFILE_UNKNOWN:
1967ec681f3Smrg      return VAProfileNone;
1977ec681f3Smrg   default:
1987ec681f3Smrg      assert(0);
1997ec681f3Smrg      return -1;
2007ec681f3Smrg   }
2017ec681f3Smrg}
2027ec681f3Smrg
2037ec681f3Smrgstatic inline enum pipe_video_profile
2047ec681f3SmrgProfileToPipe(VAProfile profile)
2057ec681f3Smrg{
2067ec681f3Smrg   switch (profile) {
2077ec681f3Smrg   case VAProfileMPEG2Simple:
2087ec681f3Smrg      return PIPE_VIDEO_PROFILE_MPEG2_SIMPLE;
2097ec681f3Smrg   case VAProfileMPEG2Main:
2107ec681f3Smrg      return PIPE_VIDEO_PROFILE_MPEG2_MAIN;
2117ec681f3Smrg   case VAProfileMPEG4Simple:
2127ec681f3Smrg      return PIPE_VIDEO_PROFILE_MPEG4_SIMPLE;
2137ec681f3Smrg   case VAProfileMPEG4AdvancedSimple:
2147ec681f3Smrg      return PIPE_VIDEO_PROFILE_MPEG4_ADVANCED_SIMPLE;
2157ec681f3Smrg   case VAProfileVC1Simple:
2167ec681f3Smrg      return PIPE_VIDEO_PROFILE_VC1_SIMPLE;
2177ec681f3Smrg   case VAProfileVC1Main:
2187ec681f3Smrg      return PIPE_VIDEO_PROFILE_VC1_MAIN;
2197ec681f3Smrg   case VAProfileVC1Advanced:
2207ec681f3Smrg      return PIPE_VIDEO_PROFILE_VC1_ADVANCED;
2217ec681f3Smrg   case VAProfileH264ConstrainedBaseline:
2227ec681f3Smrg      return PIPE_VIDEO_PROFILE_MPEG4_AVC_BASELINE;
2237ec681f3Smrg   case VAProfileH264Main:
2247ec681f3Smrg      return PIPE_VIDEO_PROFILE_MPEG4_AVC_MAIN;
2257ec681f3Smrg   case VAProfileH264High:
2267ec681f3Smrg      return PIPE_VIDEO_PROFILE_MPEG4_AVC_HIGH;
2277ec681f3Smrg   case VAProfileHEVCMain:
2287ec681f3Smrg      return PIPE_VIDEO_PROFILE_HEVC_MAIN;
2297ec681f3Smrg   case VAProfileHEVCMain10:
2307ec681f3Smrg      return PIPE_VIDEO_PROFILE_HEVC_MAIN_10;
2317ec681f3Smrg   case VAProfileJPEGBaseline:
2327ec681f3Smrg      return PIPE_VIDEO_PROFILE_JPEG_BASELINE;
2337ec681f3Smrg   case VAProfileVP9Profile0:
2347ec681f3Smrg      return PIPE_VIDEO_PROFILE_VP9_PROFILE0;
2357ec681f3Smrg   case VAProfileVP9Profile2:
2367ec681f3Smrg      return PIPE_VIDEO_PROFILE_VP9_PROFILE2;
2377ec681f3Smrg   case VAProfileAV1Profile0:
2387ec681f3Smrg      return PIPE_VIDEO_PROFILE_AV1_MAIN;
2397ec681f3Smrg   case VAProfileNone:
2407ec681f3Smrg       return PIPE_VIDEO_PROFILE_UNKNOWN;
2417ec681f3Smrg   default:
2427ec681f3Smrg      return PIPE_VIDEO_PROFILE_UNKNOWN;
2437ec681f3Smrg   }
2447ec681f3Smrg}
2457ec681f3Smrg
2467ec681f3Smrgtypedef struct {
2477ec681f3Smrg   struct vl_screen *vscreen;
2487ec681f3Smrg   struct pipe_context *pipe;
2497ec681f3Smrg   struct handle_table *htab;
2507ec681f3Smrg   struct vl_compositor compositor;
2517ec681f3Smrg   struct vl_compositor_state cstate;
2527ec681f3Smrg   vl_csc_matrix csc;
2537ec681f3Smrg   mtx_t mutex;
2547ec681f3Smrg   char vendor_string[256];
2557ec681f3Smrg} vlVaDriver;
2567ec681f3Smrg
2577ec681f3Smrgtypedef struct {
2587ec681f3Smrg   VAImage *image;
2597ec681f3Smrg
2607ec681f3Smrg   struct u_rect src_rect;
2617ec681f3Smrg   struct u_rect dst_rect;
2627ec681f3Smrg
2637ec681f3Smrg   struct pipe_sampler_view *sampler;
2647ec681f3Smrg} vlVaSubpicture;
2657ec681f3Smrg
2667ec681f3Smrgtypedef struct {
2677ec681f3Smrg   VABufferType type;
2687ec681f3Smrg   unsigned int size;
2697ec681f3Smrg   unsigned int num_elements;
2707ec681f3Smrg   void *data;
2717ec681f3Smrg   struct {
2727ec681f3Smrg      struct pipe_resource *resource;
2737ec681f3Smrg      struct pipe_transfer *transfer;
2747ec681f3Smrg   } derived_surface;
2757ec681f3Smrg   unsigned int export_refcount;
2767ec681f3Smrg   VABufferInfo export_state;
2777ec681f3Smrg   unsigned int coded_size;
2787ec681f3Smrg   struct pipe_video_buffer *derived_image_buffer;
2797ec681f3Smrg} vlVaBuffer;
2807ec681f3Smrg
2817ec681f3Smrgtypedef struct {
2827ec681f3Smrg   struct pipe_video_codec templat, *decoder;
2837ec681f3Smrg   struct pipe_video_buffer *target;
2847ec681f3Smrg   union {
2857ec681f3Smrg      struct pipe_picture_desc base;
2867ec681f3Smrg      struct pipe_mpeg12_picture_desc mpeg12;
2877ec681f3Smrg      struct pipe_mpeg4_picture_desc mpeg4;
2887ec681f3Smrg      struct pipe_vc1_picture_desc vc1;
2897ec681f3Smrg      struct pipe_h264_picture_desc h264;
2907ec681f3Smrg      struct pipe_h265_picture_desc h265;
2917ec681f3Smrg      struct pipe_mjpeg_picture_desc mjpeg;
2927ec681f3Smrg      struct pipe_vp9_picture_desc vp9;
2937ec681f3Smrg      struct pipe_av1_picture_desc av1;
2947ec681f3Smrg      struct pipe_h264_enc_picture_desc h264enc;
2957ec681f3Smrg      struct pipe_h265_enc_picture_desc h265enc;
2967ec681f3Smrg   } desc;
2977ec681f3Smrg
2987ec681f3Smrg   struct {
2997ec681f3Smrg      unsigned long long int frame_num;
3007ec681f3Smrg      unsigned int start_code_size;
3017ec681f3Smrg      unsigned int vti_bits;
3027ec681f3Smrg      unsigned int quant_scale;
3037ec681f3Smrg      VAPictureParameterBufferMPEG4 pps;
3047ec681f3Smrg      uint8_t start_code[32];
3057ec681f3Smrg   } mpeg4;
3067ec681f3Smrg
3077ec681f3Smrg   struct {
3087ec681f3Smrg      unsigned sampling_factor;
3097ec681f3Smrg      uint8_t slice_header[MAX_MJPEG_SLICE_HEADER_SIZE];
3107ec681f3Smrg      unsigned int slice_header_size;
3117ec681f3Smrg   } mjpeg;
3127ec681f3Smrg
3137ec681f3Smrg   struct vl_deint_filter *deint;
3147ec681f3Smrg   vlVaBuffer *coded_buf;
3157ec681f3Smrg   int target_id;
3167ec681f3Smrg   bool first_single_submitted;
3177ec681f3Smrg   int gop_coeff;
3187ec681f3Smrg   bool needs_begin_frame;
3197ec681f3Smrg   void *blit_cs;
3207ec681f3Smrg   int packed_header_type;
3217ec681f3Smrg} vlVaContext;
3227ec681f3Smrg
3237ec681f3Smrgtypedef struct {
3247ec681f3Smrg   enum pipe_video_profile profile;
3257ec681f3Smrg   enum pipe_video_entrypoint entrypoint;
3267ec681f3Smrg   enum pipe_h2645_enc_rate_control_method rc;
3277ec681f3Smrg   unsigned int rt_format;
3287ec681f3Smrg} vlVaConfig;
3297ec681f3Smrg
3307ec681f3Smrgtypedef struct {
3317ec681f3Smrg   struct pipe_video_buffer templat, *buffer;
3327ec681f3Smrg   struct util_dynarray subpics; /* vlVaSubpicture */
3337ec681f3Smrg   VAContextID ctx;
3347ec681f3Smrg   vlVaBuffer *coded_buf;
3357ec681f3Smrg   void *feedback;
3367ec681f3Smrg   unsigned int frame_num_cnt;
3377ec681f3Smrg   bool force_flushed;
3387ec681f3Smrg} vlVaSurface;
3397ec681f3Smrg
3407ec681f3Smrg// Public functions:
3417ec681f3SmrgVAStatus VA_DRIVER_INIT_FUNC(VADriverContextP ctx);
3427ec681f3Smrg
3437ec681f3Smrg// vtable functions:
3447ec681f3SmrgVAStatus vlVaTerminate(VADriverContextP ctx);
3457ec681f3SmrgVAStatus vlVaQueryConfigProfiles(VADriverContextP ctx, VAProfile *profile_list,int *num_profiles);
3467ec681f3SmrgVAStatus vlVaQueryConfigEntrypoints(VADriverContextP ctx, VAProfile profile,
3477ec681f3Smrg                                    VAEntrypoint  *entrypoint_list, int *num_entrypoints);
3487ec681f3SmrgVAStatus vlVaGetConfigAttributes(VADriverContextP ctx, VAProfile profile, VAEntrypoint entrypoint,
3497ec681f3Smrg                                 VAConfigAttrib *attrib_list, int num_attribs);
3507ec681f3SmrgVAStatus vlVaCreateConfig(VADriverContextP ctx, VAProfile profile, VAEntrypoint entrypoint,
3517ec681f3Smrg                          VAConfigAttrib *attrib_list, int num_attribs, VAConfigID *config_id);
3527ec681f3SmrgVAStatus vlVaDestroyConfig(VADriverContextP ctx, VAConfigID config_id);
3537ec681f3SmrgVAStatus vlVaQueryConfigAttributes(VADriverContextP ctx, VAConfigID config_id, VAProfile *profile,
3547ec681f3Smrg                                   VAEntrypoint *entrypoint, VAConfigAttrib *attrib_list, int *num_attribs);
3557ec681f3SmrgVAStatus vlVaCreateSurfaces(VADriverContextP ctx, int width, int height, int format,
3567ec681f3Smrg                            int num_surfaces, VASurfaceID *surfaces);
3577ec681f3SmrgVAStatus vlVaDestroySurfaces(VADriverContextP ctx, VASurfaceID *surface_list, int num_surfaces);
3587ec681f3SmrgVAStatus vlVaCreateContext(VADriverContextP ctx, VAConfigID config_id, int picture_width, int picture_height,
3597ec681f3Smrg                           int flag, VASurfaceID *render_targets, int num_render_targets, VAContextID *context);
3607ec681f3SmrgVAStatus vlVaDestroyContext(VADriverContextP ctx, VAContextID context);
3617ec681f3SmrgVAStatus vlVaCreateBuffer(VADriverContextP ctx, VAContextID context, VABufferType type, unsigned int size,
3627ec681f3Smrg                          unsigned int num_elements, void *data, VABufferID *buf_id);
3637ec681f3SmrgVAStatus vlVaBufferSetNumElements(VADriverContextP ctx, VABufferID buf_id, unsigned int num_elements);
3647ec681f3SmrgVAStatus vlVaMapBuffer(VADriverContextP ctx, VABufferID buf_id, void **pbuf);
3657ec681f3SmrgVAStatus vlVaUnmapBuffer(VADriverContextP ctx, VABufferID buf_id);
3667ec681f3SmrgVAStatus vlVaDestroyBuffer(VADriverContextP ctx, VABufferID buffer_id);
3677ec681f3SmrgVAStatus vlVaBeginPicture(VADriverContextP ctx, VAContextID context, VASurfaceID render_target);
3687ec681f3SmrgVAStatus vlVaRenderPicture(VADriverContextP ctx, VAContextID context, VABufferID *buffers, int num_buffers);
3697ec681f3SmrgVAStatus vlVaEndPicture(VADriverContextP ctx, VAContextID context);
3707ec681f3SmrgVAStatus vlVaSyncSurface(VADriverContextP ctx, VASurfaceID render_target);
3717ec681f3SmrgVAStatus vlVaQuerySurfaceStatus(VADriverContextP ctx, VASurfaceID render_target, VASurfaceStatus *status);
3727ec681f3SmrgVAStatus vlVaQuerySurfaceError(VADriverContextP ctx, VASurfaceID render_target,
3737ec681f3Smrg                               VAStatus error_status, void **error_info);
3747ec681f3SmrgVAStatus vlVaPutSurface(VADriverContextP ctx, VASurfaceID surface, void* draw, short srcx, short srcy,
3757ec681f3Smrg                        unsigned short srcw, unsigned short srch, short destx, short desty, unsigned short destw,
3767ec681f3Smrg                        unsigned short desth, VARectangle *cliprects, unsigned int number_cliprects,
3777ec681f3Smrg                        unsigned int flags);
3787ec681f3SmrgVAStatus vlVaQueryImageFormats(VADriverContextP ctx, VAImageFormat *format_list, int *num_formats);
3797ec681f3SmrgVAStatus vlVaQuerySubpictureFormats(VADriverContextP ctx, VAImageFormat *format_list,
3807ec681f3Smrg                                    unsigned int *flags, unsigned int *num_formats);
3817ec681f3SmrgVAStatus vlVaCreateImage(VADriverContextP ctx, VAImageFormat *format, int width, int height, VAImage *image);
3827ec681f3SmrgVAStatus vlVaDeriveImage(VADriverContextP ctx, VASurfaceID surface, VAImage *image);
3837ec681f3SmrgVAStatus vlVaDestroyImage(VADriverContextP ctx, VAImageID image);
3847ec681f3SmrgVAStatus vlVaSetImagePalette(VADriverContextP ctx, VAImageID image, unsigned char *palette);
3857ec681f3SmrgVAStatus vlVaGetImage(VADriverContextP ctx, VASurfaceID surface, int x, int y,
3867ec681f3Smrg                      unsigned int width, unsigned int height, VAImageID image);
3877ec681f3SmrgVAStatus vlVaPutImage(VADriverContextP ctx, VASurfaceID surface, VAImageID image, int src_x, int src_y,
3887ec681f3Smrg                      unsigned int src_width, unsigned int src_height, int dest_x, int dest_y,
3897ec681f3Smrg                      unsigned int dest_width, unsigned int dest_height);
3907ec681f3SmrgVAStatus vlVaQuerySubpictureFormats(VADriverContextP ctx, VAImageFormat *format_list,
3917ec681f3Smrg                                    unsigned int *flags, unsigned int *num_formats);
3927ec681f3SmrgVAStatus vlVaCreateSubpicture(VADriverContextP ctx, VAImageID image, VASubpictureID *subpicture);
3937ec681f3SmrgVAStatus vlVaDestroySubpicture(VADriverContextP ctx, VASubpictureID subpicture);
3947ec681f3SmrgVAStatus vlVaSubpictureImage(VADriverContextP ctx, VASubpictureID subpicture, VAImageID image);
3957ec681f3SmrgVAStatus vlVaSetSubpictureChromakey(VADriverContextP ctx, VASubpictureID subpicture,
3967ec681f3Smrg                                    unsigned int chromakey_min, unsigned int chromakey_max,
3977ec681f3Smrg                                    unsigned int chromakey_mask);
3987ec681f3SmrgVAStatus vlVaSetSubpictureGlobalAlpha(VADriverContextP ctx, VASubpictureID subpicture, float global_alpha);
3997ec681f3SmrgVAStatus vlVaAssociateSubpicture(VADriverContextP ctx, VASubpictureID subpicture, VASurfaceID *target_surfaces,
4007ec681f3Smrg                                 int num_surfaces, short src_x, short src_y,
4017ec681f3Smrg                                 unsigned short src_width, unsigned short src_height,
4027ec681f3Smrg                                 short dest_x, short dest_y, unsigned short dest_width, unsigned short dest_height,
4037ec681f3Smrg                                 unsigned int flags);
4047ec681f3SmrgVAStatus vlVaDeassociateSubpicture(VADriverContextP ctx, VASubpictureID subpicture,
4057ec681f3Smrg                                   VASurfaceID *target_surfaces, int num_surfaces);
4067ec681f3SmrgVAStatus vlVaQueryDisplayAttributes(VADriverContextP ctx, VADisplayAttribute *attr_list, int *num_attributes);
4077ec681f3SmrgVAStatus vlVaGetDisplayAttributes(VADriverContextP ctx, VADisplayAttribute *attr_list, int num_attributes);
4087ec681f3SmrgVAStatus vlVaSetDisplayAttributes(VADriverContextP ctx, VADisplayAttribute *attr_list, int num_attributes);
4097ec681f3SmrgVAStatus vlVaBufferInfo(VADriverContextP ctx, VABufferID buf_id, VABufferType *type,
4107ec681f3Smrg                        unsigned int *size, unsigned int *num_elements);
4117ec681f3SmrgVAStatus vlVaLockSurface(VADriverContextP ctx, VASurfaceID surface, unsigned int *fourcc,
4127ec681f3Smrg                         unsigned int *luma_stride, unsigned int *chroma_u_stride, unsigned int *chroma_v_stride,
4137ec681f3Smrg                         unsigned int *luma_offset, unsigned int *chroma_u_offset, unsigned int *chroma_v_offset,
4147ec681f3Smrg                         unsigned int *buffer_name, void **buffer);
4157ec681f3SmrgVAStatus vlVaUnlockSurface(VADriverContextP ctx, VASurfaceID surface);
4167ec681f3SmrgVAStatus vlVaCreateSurfaces2(VADriverContextP ctx, unsigned int format, unsigned int width, unsigned int height,
4177ec681f3Smrg                             VASurfaceID *surfaces, unsigned int num_surfaces, VASurfaceAttrib *attrib_list,
4187ec681f3Smrg                             unsigned int num_attribs);
4197ec681f3SmrgVAStatus vlVaQuerySurfaceAttributes(VADriverContextP ctx, VAConfigID config, VASurfaceAttrib *attrib_list,
4207ec681f3Smrg                                    unsigned int *num_attribs);
4217ec681f3Smrg
4227ec681f3SmrgVAStatus vlVaAcquireBufferHandle(VADriverContextP ctx, VABufferID buf_id, VABufferInfo *out_buf_info);
4237ec681f3SmrgVAStatus vlVaReleaseBufferHandle(VADriverContextP ctx, VABufferID buf_id);
4247ec681f3SmrgVAStatus vlVaExportSurfaceHandle(VADriverContextP ctx, VASurfaceID surface_id, uint32_t mem_type, uint32_t flags, void *descriptor);
4257ec681f3Smrg
4267ec681f3SmrgVAStatus vlVaQueryVideoProcFilters(VADriverContextP ctx, VAContextID context, VAProcFilterType *filters,
4277ec681f3Smrg                                   unsigned int *num_filters);
4287ec681f3SmrgVAStatus vlVaQueryVideoProcFilterCaps(VADriverContextP ctx, VAContextID context, VAProcFilterType type,
4297ec681f3Smrg                                      void *filter_caps, unsigned int *num_filter_caps);
4307ec681f3SmrgVAStatus vlVaQueryVideoProcPipelineCaps(VADriverContextP ctx, VAContextID context, VABufferID *filters,
4317ec681f3Smrg                                        unsigned int num_filters, VAProcPipelineCaps *pipeline_cap);
4327ec681f3Smrg
4337ec681f3Smrg// internal functions
4347ec681f3SmrgVAStatus vlVaHandleVAProcPipelineParameterBufferType(vlVaDriver *drv, vlVaContext *context, vlVaBuffer *buf);
4357ec681f3SmrgVAStatus vlVaHandleSurfaceAllocate(vlVaDriver *drv, vlVaSurface *surface, struct pipe_video_buffer *templat,
4367ec681f3Smrg                                   const uint64_t *modifiers, unsigned int modifiers_count);
4377ec681f3Smrgvoid vlVaGetReferenceFrame(vlVaDriver *drv, VASurfaceID surface_id, struct pipe_video_buffer **ref_frame);
4387ec681f3Smrgvoid vlVaHandlePictureParameterBufferMPEG12(vlVaDriver *drv, vlVaContext *context, vlVaBuffer *buf);
4397ec681f3Smrgvoid vlVaHandleIQMatrixBufferMPEG12(vlVaContext *context, vlVaBuffer *buf);
4407ec681f3Smrgvoid vlVaHandleSliceParameterBufferMPEG12(vlVaContext *context, vlVaBuffer *buf);
4417ec681f3Smrgvoid vlVaHandlePictureParameterBufferH264(vlVaDriver *drv, vlVaContext *context, vlVaBuffer *buf);
4427ec681f3Smrgvoid vlVaHandleIQMatrixBufferH264(vlVaContext *context, vlVaBuffer *buf);
4437ec681f3Smrgvoid vlVaHandleSliceParameterBufferH264(vlVaContext *context, vlVaBuffer *buf);
4447ec681f3Smrgvoid vlVaHandlePictureParameterBufferVC1(vlVaDriver *drv, vlVaContext *context, vlVaBuffer *buf);
4457ec681f3Smrgvoid vlVaHandleSliceParameterBufferVC1(vlVaContext *context, vlVaBuffer *buf);
4467ec681f3Smrgvoid vlVaHandlePictureParameterBufferMPEG4(vlVaDriver *drv, vlVaContext *context, vlVaBuffer *buf);
4477ec681f3Smrgvoid vlVaHandleIQMatrixBufferMPEG4(vlVaContext *context, vlVaBuffer *buf);
4487ec681f3Smrgvoid vlVaHandleSliceParameterBufferMPEG4(vlVaContext *context, vlVaBuffer *buf);
4497ec681f3Smrgvoid vlVaDecoderFixMPEG4Startcode(vlVaContext *context);
4507ec681f3Smrgvoid vlVaGetJpegSliceHeader(vlVaContext *context);
4517ec681f3Smrgvoid vlVaHandlePictureParameterBufferHEVC(vlVaDriver *drv, vlVaContext *context, vlVaBuffer *buf);
4527ec681f3Smrgvoid vlVaHandleIQMatrixBufferHEVC(vlVaContext *context, vlVaBuffer *buf);
4537ec681f3Smrgvoid vlVaHandleSliceParameterBufferHEVC(vlVaContext *context, vlVaBuffer *buf);
4547ec681f3Smrgvoid vlVaHandlePictureParameterBufferMJPEG(vlVaDriver *drv, vlVaContext *context, vlVaBuffer *buf);
4557ec681f3Smrgvoid vlVaHandleIQMatrixBufferMJPEG(vlVaContext *context, vlVaBuffer *buf);
4567ec681f3Smrgvoid vlVaHandleHuffmanTableBufferType(vlVaContext *context, vlVaBuffer *buf);
4577ec681f3Smrgvoid vlVaHandleSliceParameterBufferMJPEG(vlVaContext *context, vlVaBuffer *buf);
4587ec681f3Smrgvoid vlVaHandlePictureParameterBufferVP9(vlVaDriver *drv, vlVaContext *context, vlVaBuffer *buf);
4597ec681f3Smrgvoid vlVaHandleSliceParameterBufferVP9(vlVaContext *context, vlVaBuffer *buf);
4607ec681f3Smrgvoid vlVaDecoderVP9BitstreamHeader(vlVaContext *context, vlVaBuffer *buf);
4617ec681f3Smrgvoid vlVaHandlePictureParameterBufferAV1(vlVaDriver *drv, vlVaContext *context, vlVaBuffer *buf);
4627ec681f3Smrgvoid vlVaHandleSliceParameterBufferAV1(vlVaContext *context, vlVaBuffer *buf, unsigned int num);
4637ec681f3Smrgvoid getEncParamPresetH264(vlVaContext *context);
4647ec681f3Smrgvoid getEncParamPresetH265(vlVaContext *context);
4657ec681f3SmrgVAStatus vlVaHandleVAEncPictureParameterBufferTypeH264(vlVaDriver *drv, vlVaContext *context, vlVaBuffer *buf);
4667ec681f3SmrgVAStatus vlVaHandleVAEncSliceParameterBufferTypeH264(vlVaDriver *drv, vlVaContext *context, vlVaBuffer *buf);
4677ec681f3SmrgVAStatus vlVaHandleVAEncSequenceParameterBufferTypeH264(vlVaDriver *drv, vlVaContext *context, vlVaBuffer *buf);
4687ec681f3SmrgVAStatus vlVaHandleVAEncMiscParameterTypeRateControlH264(vlVaContext *context, VAEncMiscParameterBuffer *buf);
4697ec681f3SmrgVAStatus vlVaHandleVAEncMiscParameterTypeFrameRateH264(vlVaContext *context, VAEncMiscParameterBuffer *buf);
4707ec681f3SmrgVAStatus vlVaHandleVAEncMiscParameterTypeTemporalLayerH264(vlVaContext *context, VAEncMiscParameterBuffer *buf);
4717ec681f3SmrgVAStatus vlVaHandleVAEncPictureParameterBufferTypeHEVC(vlVaDriver *drv, vlVaContext *context, vlVaBuffer *buf);
4727ec681f3SmrgVAStatus vlVaHandleVAEncSliceParameterBufferTypeHEVC(vlVaDriver *drv, vlVaContext *context, vlVaBuffer *buf);
4737ec681f3SmrgVAStatus vlVaHandleVAEncSequenceParameterBufferTypeHEVC(vlVaDriver *drv, vlVaContext *context, vlVaBuffer *buf);
4747ec681f3SmrgVAStatus vlVaHandleVAEncMiscParameterTypeRateControlHEVC(vlVaContext *context, VAEncMiscParameterBuffer *buf);
4757ec681f3SmrgVAStatus vlVaHandleVAEncMiscParameterTypeFrameRateHEVC(vlVaContext *context, VAEncMiscParameterBuffer *buf);
4767ec681f3SmrgVAStatus vlVaHandleVAEncPackedHeaderDataBufferTypeHEVC(vlVaContext *context, vlVaBuffer *buf);
4777ec681f3Smrg#endif //VA_PRIVATE_H
478